From: Duje Mihanović Date: Mon, 27 Jun 2022 19:29:50 +0000 (+0200) Subject: Merge branch 'elf' into mm X-Git-Url: http://git.dujemihanovic.xyz/%7B%7B%20%24.Site.BaseURL%20%7D%7Dposts/index.xml?a=commitdiff_plain;h=5eb69417259dd239d1d7b69724b7e2bccb7d146e;hp=-c;p=nameless-os.git Merge branch 'elf' into mm --- 5eb69417259dd239d1d7b69724b7e2bccb7d146e diff --combined boot/x86/stage3/loader.s index 747905d,87598f4..bd2fb9b --- a/boot/x86/stage3/loader.s +++ b/boot/x86/stage3/loader.s @@@ -1,7 -1,9 +1,9 @@@ bits 16 cpu 686 - org 0x1800 + extern run_kernel + + section .text %include "../fat32/fat32-structs.s" %macro print 1 @@@ -11,7 -13,11 +13,11 @@@ pop si %endmacro + extern __STACK_BOTTOM__ + + global _start _start: + mov sp, __STACK_BOTTOM__ mov [BOOT_DRIVE], dl call enable_unreal print begin @@@ -55,9 -61,11 +61,11 @@@ 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 @@@ -65,6 -73,11 +73,11 @@@ print kernel_loaded call get_e820_map + mov ebx, ecx + mov eax, 24 + mul ecx + add eax, 20 + sub sp, ax cli lgdt [gdt] @@@ -147,7 -160,6 +160,6 @@@ memcpy pop esi ret - %include "unreal.s" %include "a20.s" %include "../fat32/fat32.s" @@@ -155,8 -167,9 +167,9 @@@ %include "print.s" %include "e820.s" - in_protected: bits 32 + section .text + in_protected: mov ax, 0x10 mov ds, ax mov es, ax @@@ -164,13 -177,18 +177,18 @@@ mov fs, ax mov gs, ax - call load_paging_structs - call enable_paging + push dword [KERNEL_SIZE] + push 0x100000 + push ebx + push edi + call run_kernel + + section .bss + KERNEL_SIZE: resd 1 - jmp 0x8:0xc0000000 - nop + 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 @@@ -178,7 -196,7 +196,7 @@@ crit_err: db "A critical error occurred 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 @@@ -192,5 -210,3 +210,5 @@@ ss_s: db "SS: ", space: db " ", 0 hex_delm: db "0x", 0 newline: db 0xd, 0xa, 0 + +%include "paging.s"