X-Git-Url: http://git.dujemihanovic.xyz/%7B%7B%20%24image.RelPermalink%20%7D%7D?a=blobdiff_plain;f=kernel%2Fentry.s;h=d6490a1159587a81cda63257b3ee3e9028fdaf68;hb=da4e7bf5dd2b9448b638255a20ee503b0641e495;hp=c38ac764d8eb68e74f8f97413881d3b69ec0273a;hpb=d895d72c4e8625b435add9067fe8f7298de2d301;p=nameless-os.git diff --git a/kernel/entry.s b/kernel/entry.s index c38ac76..d6490a1 100644 --- a/kernel/entry.s +++ b/kernel/entry.s @@ -2,12 +2,31 @@ bits 32 extern kmain extern __STACK_BOTTOM__ +section .text global _start _start: + ; Here, the stack will look like: + ; return address, map pointer, map size. + + ; Skip the return address. + add esp, 4 + ; Save the kernel arguments. + ; Can this be done without the global variables? + pop dword [e820_map] + pop dword [e820_map_size] + sub esp, 12 + ; Do the stack switch. mov ebp, __STACK_BOTTOM__ mov esp, ebp - push ebx - push edi + ; Restore the kernel arguments. + push dword [e820_map_size] + push dword [e820_map] + ; Call the actual kernel. call kmain hlt jmp $-1 + +; Temporarily save arguments here to survive the upcoming stack switch. +section .bss +e820_map: resd 1 +e820_map_size: resd 1