]> git.dujemihanovic.xyz Git - nameless-os.git/blob - kernel/entry.s
Load ELF kernel instead of flat binary
[nameless-os.git] / kernel / entry.s
1 bits 32
2 extern kmain
3 extern __STACK_BOTTOM__
4
5 section .text
6 global _start
7 _start:
8 ; Here, the stack will look like:
9 ; return address, map pointer, map size.
10
11 ; Skip the return address.
12 add esp, 4
13 ; Save the kernel arguments.
14 ; Can this be done without the global variables?
15 pop dword [e820_map]
16 pop dword [e820_map_size]
17 sub esp, 12
18 ; Do the stack switch.
19 mov ebp, __STACK_BOTTOM__
20 mov esp, ebp
21 ; Restore the kernel arguments.
22 push dword [e820_map_size]
23 push dword [e820_map]
24 ; Call the actual kernel.
25 call kmain
26 hlt
27 jmp $-1
28
29 ; Temporarily save arguments here to survive the upcoming stack switch.
30 section .bss
31 e820_map: resd 1
32 e820_map_size: resd 1