X-Git-Url: http://git.dujemihanovic.xyz/%7B%7B%20%24image.RelPermalink%20%7D%7D?a=blobdiff_plain;f=boot%2Fx86%2Fstage3%2Floader.s;h=87598f4b0c93a6d95cbb1aa21dcf6a87723ff1da;hb=da4e7bf5dd2b9448b638255a20ee503b0641e495;hp=cdecbaac1b45f56740737cb355b28fefb6151863;hpb=320a0c820a129a39cc6a8a383ea4e2770f3ee50b;p=nameless-os.git diff --git a/boot/x86/stage3/loader.s b/boot/x86/stage3/loader.s index cdecbaa..87598f4 100644 --- a/boot/x86/stage3/loader.s +++ b/boot/x86/stage3/loader.s @@ -1,6 +1,8 @@ bits 16 cpu 686 +extern run_kernel + section .text %include "../fat32/fat32-structs.s" @@ -59,9 +61,11 @@ _start: pop si pop cx print kernel_found + mov eax, [es:di+dir_entry.filesize] + mov [KERNEL_SIZE], eax mov ax, [es:di+dir_entry.firstclushi] shl eax, 16 - mov ax, [es:di+(dir_entry.firstcluslo)] + mov ax, [es:di+dir_entry.firstcluslo] call print_dword mov edi, 0x100000 print kernel_loading @@ -69,6 +73,11 @@ _start: print kernel_loaded call get_e820_map + mov ebx, ecx + mov eax, 24 + mul ecx + add eax, 20 + sub sp, ax cli lgdt [gdt] @@ -168,17 +177,18 @@ in_protected: mov fs, ax mov gs, ax - call load_paging_structs - call enable_paging - - jmp 0x8:0xc0000000 - nop + push dword [KERNEL_SIZE] + push 0x100000 + push ebx + push edi + call run_kernel -%include "paging.s" +section .bss +KERNEL_SIZE: resd 1 section .rodata -kernel_name: db "KERNEL BIN" +kernel_name: db "KERNEL ELF" 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 @@ -186,7 +196,7 @@ 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 +missing_kernel: db "Could not find KERNEL.ELF", 0xd, 0xa, 0 eax_s: db "EAX: ", 0 ebx_s: db "EBX: ", 0 ecx_s: db "ECX: ", 0