; Here is our entry point to the kernel ; A very simple assembly file ; We set up some parameters and then pass the execution to our kmain global loader ; entry symbol for ELF extern kmain extern gdt_init MAGIC_NUMBER equ 0x1BADB002 ; magic number constant FLAGS equ 0x3 CHECKSUM equ -(MAGIC_NUMBER + FLAGS) ; calculate the checksum KERNEL_STACK_SIZE equ 4096 ; The multiboot section is a semi requirement for grub ; All this is doing is placing the required magic number, flags, and the checksum into the file first ; This lets grub know if this is a valid multiboot kernel or not section .multiboot align 4 ; code must be 4 byte aligned dd MAGIC_NUMBER dd FLAGS dd CHECKSUM ; Here we're setting up the stack ; Giving us 4096 bytes (resb) section .bss align 4 kernel_stack: resb KERNEL_STACK_SIZE section .text loader: mov esp, kernel_stack + KERNEL_STACK_SIZE ; move the top of the stack into esp call kmain ; pass execution over to our kmain function, where all of the real stuff is done ; Should the system exit, we clear the interrupt flag ; and do an infinite loop of nothing cli loop: hlt jmp loop