]> git.dujemihanovic.xyz Git - nameless-os.git/blobdiff - boot/x86/stage3/loader.s
Fix various warnings
[nameless-os.git] / boot / x86 / stage3 / loader.s
index bd703bacde4700755c287e4bed7663ec0432a391..747905d704ef8bc0ae3c50921d996c3bc5ac000e 100644 (file)
@@ -1,6 +1,6 @@
 bits 16
 cpu 686
-org 0x8000
+org 0x1800
 
 %include "../fat32/fat32-structs.s"
 
@@ -14,7 +14,7 @@ org 0x8000
 _start:
        mov [BOOT_DRIVE], dl
        call enable_unreal
-       print string
+       print begin
        call check_a20
        jc .a20_enabled
        call enable_a20
@@ -22,7 +22,7 @@ _start:
 .a20_enabled:
        print a20_enabled
        call get_1st_data_sec
-       mov ax, 0x2000
+       mov ax, 0x1000
        mov es, ax
        mov eax, BPB_RootClus
        xor di, di
@@ -60,8 +60,12 @@ _start:
        mov ax, [es:di+(dir_entry.firstcluslo)]
        call print_dword
        mov edi, 0x100000
+       print kernel_loading
        call read_clus_chain_unreal ; load kernel
+       print kernel_loaded
        
+       call get_e820_map
+
        cli
        lgdt [gdt]
        mov eax, cr0
@@ -88,7 +92,7 @@ read_clus_chain_unreal:
        push es
        push ax
        xor di, di
-       mov ax, 0x100
+       mov ax, 0x1000
        mov es, ax
        pop ax
        call read_cluster
@@ -99,7 +103,7 @@ read_clus_chain_unreal:
        push eax
        push ebx
        push ecx
-       mov esi, 0x1000
+       mov esi, 0x10000
        xor ebx, ebx
        movzx eax, word BPB_BytsPerSec
        movzx bx, byte BPB_SecPerClus
@@ -149,6 +153,7 @@ memcpy:
 %include "../fat32/fat32.s"
 %include "gdt.s"
 %include "print.s"
+%include "e820.s"
 
 in_protected:
 bits 32
@@ -158,16 +163,21 @@ bits 32
        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
 
 kernel_name: db "KERNEL  BIN"
-string: db "Hello from LOADER.BIN!", 0xd, 0xa, 0
-a20_enabled: db "A20 is enabled", 0xd, 0xa, 0
+begin: db "Nameless Bootloader revision ", GIT_REVISION, 0xd, 0xa, 0
+a20_enabled: db "A20 has been enabled", 0xd, 0xa, "Searching for kernel...", 0xd, 0xa, 0
 a20_fail: db "Failed to enable A20, giving up!", 0xd, 0xa, 0
 crit_err: db "A critical error occurred, dumping registers now: ", 0xd, 0xa, 0
 kernel_found: db "Found kernel at cluster ", 0
+kernel_loading: db 0xd, 0xa, "Loading kernel...", 0xd, 0xa, 0
+kernel_loaded: db "Kernel successfully loaded.", 0xd, 0xa, "Setting up kernel environment and running kernel...", 0xd, 0xa, 0
 missing_kernel: db "Could not find KERNEL.BIN", 0xd, 0xa, 0
 eax_s: db "EAX: ", 0
 ebx_s: db "EBX: ", 0
@@ -182,3 +192,5 @@ ss_s: db "SS: ", 0
 space: db " ", 0
 hex_delm: db "0x", 0
 newline: db 0xd, 0xa, 0
+
+%include "paging.s"