]> git.dujemihanovic.xyz Git - nameless-os.git/blobdiff - boot/x86/stage3/loader.s
Compile stage3 in ELF format
[nameless-os.git] / boot / x86 / stage3 / loader.s
index ec08c61bd0f5d00644cf471ebe26274f93153c9e..cdecbaac1b45f56740737cb355b28fefb6151863 100644 (file)
@@ -1,7 +1,7 @@
 bits 16
 cpu 686
-org 0x1800
 
+section .text
 %include "../fat32/fat32-structs.s"
 
 %macro print 1
@@ -11,7 +11,11 @@ org 0x1800
        pop si
 %endmacro
 
+extern __STACK_BOTTOM__
+
+global _start
 _start:
+       mov sp, __STACK_BOTTOM__
        mov [BOOT_DRIVE], dl
        call enable_unreal
        print begin
@@ -64,6 +68,8 @@ _start:
        call read_clus_chain_unreal ; load kernel
        print kernel_loaded
        
+       call get_e820_map
+
        cli
        lgdt [gdt]
        mov eax, cr0
@@ -145,24 +151,32 @@ memcpy:
        pop esi
        ret
 
-
 %include "unreal.s"
 %include "a20.s"
 %include "../fat32/fat32.s"
 %include "gdt.s"
 %include "print.s"
+%include "e820.s"
 
-in_protected:
 bits 32
+section .text
+in_protected:
        mov ax, 0x10
        mov ds, ax
        mov es, ax
        mov ss, ax
        mov fs, ax
        mov gs, ax
-       call 0x100000
-       hlt
-       jmp $-1
+
+       call load_paging_structs
+       call enable_paging
+
+       jmp 0x8:0xc0000000
+       nop
+
+%include "paging.s"
+
+section .rodata
 
 kernel_name: db "KERNEL  BIN"
 begin: db "Nameless Bootloader revision ", GIT_REVISION, 0xd, 0xa, 0