adds some comments, fixes a few tiny bugs

This commit is contained in:
2025-05-31 20:50:47 -04:00
parent c50d3f14a6
commit 89c02d6a93
3 changed files with 56 additions and 8 deletions

View File

@ -1,3 +1,7 @@
; 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
@ -6,12 +10,17 @@ 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:
@ -19,10 +28,12 @@ kernel_stack:
section .text
loader:
mov esp, kernel_stack + KERNEL_STACK_SIZE
mov esp, kernel_stack + KERNEL_STACK_SIZE ; move the top of the stack into esp
call kmain
call kmain ; pass execution over to our kmain function, where all of the real stuff is done
;cli
; Should the system exit, we clear the interrupt flag
; and do an infinite loop of nothing
cli
loop: hlt
jmp loop