global start bits 32 ; create the multiboot header section .bootstrap.data align 8 mb_start: dd 0xe85250d6 dd 0 dd mb_end - mb_start dd -(0xe85250d6 + (mb_end - mb_start)) dw 0 dw 0 dd 8 mb_end: ; create the stack for bootstrapping section .bootstrap.bss align 16 bootstrap_stack_start: resb 1024 ; 1 KiB bootstrap_stack_end: ; create the stack for the kernel section .bss align 16 stack_start: resb 16384 ; 16 KiB stack_end: ; load the kernel into the higher half section .bootstrap.text align 8 start: ; init bootstrap stack mov esp, bootstrap_stack_end mov ebp, bootstrap_stack_end ; load kernel into higher half and init paging extern paging_init call paging_init jmp near load_kernel ; initalize kernel after it has been loaded in higher half section .text align 8 load_kernel: ; init stack mov esp, stack_end mov ebp, stack_end ; load global descripter table extern load_gdt call load_gdt ; unmap kernel at page 0 extern paging_finish call paging_finish ; initalize the FPU finit ; start kernel sti extern KERNEL_MAPPING add ebx, KERNEL_MAPPING push ebx call kernel_main extern kernel_main ; hlt forever if kernel quits (it should never) cli halt: hlt jmp halt