diff --git a/bootloader/main.asm b/bootloader/main.asm index 06a0fac..9931204 100644 --- a/bootloader/main.asm +++ b/bootloader/main.asm @@ -3,6 +3,10 @@ DISK_ID EQU 0x81 org 0x7C00 bits 16 +; memory layout: +; 0x8000 -> ... = ELF file, unparsed +; 0x100000 -> ... = actual kernel + jmp .start [bits 16] @@ -219,17 +223,10 @@ mov ss, ax ; set up stack mov esp, 0x090000 -; load offset from ELF file -; mind the differing endian -mov edx, 0x8018 -mov ah, [ds:edx+2] -mov al, [ds:edx+3] -shl eax, 16 -mov ah, [ds:edx] -mov al, [ds:edx+1] +; parse ELF file to 0x10000 -; add the beginning 0x8000 -add eax, 0x8000 +; load memory position from ELF file +mov eax, [ds:0x8018] jmp eax diff --git a/kernel/kernel.c b/kernel/kernel.c index 8a7e29e..86f55e7 100644 --- a/kernel/kernel.c +++ b/kernel/kernel.c @@ -110,9 +110,9 @@ void kernel_main(void) terminal_initialize(); /* Newline support is left as an exercise. */ - // terminal_writestring("Hello, "); - // terminal_setcolor(vga_entry_color(VGA_COLOR_GREEN, VGA_COLOR_BLACK)); - // terminal_writestring("kernel"); - // terminal_setcolor(vga_entry_color(VGA_COLOR_LIGHT_GREY, VGA_COLOR_BLACK)); - // terminal_writestring(" World!\n"); + terminal_writestring("Hello, "); + terminal_setcolor(vga_entry_color(VGA_COLOR_GREEN, VGA_COLOR_BLACK)); + terminal_writestring("kernel"); + terminal_setcolor(vga_entry_color(VGA_COLOR_LIGHT_GREY, VGA_COLOR_BLACK)); + terminal_writestring(" World!\n"); } \ No newline at end of file diff --git a/kernel/linker.ld b/kernel/linker.ld index 846b2ec..b46b0ab 100644 --- a/kernel/linker.ld +++ b/kernel/linker.ld @@ -6,8 +6,8 @@ ENTRY(_start) kernel image. */ SECTIONS { - /* Set this to 0, so the program entry is the relative position to the start of the kernel */ - . = 0; + /* Bootloader will put the kernel at 1M */ + . = 1M; /* First put the multiboot header, as it is required to be put very early early in the image or the bootloader won't recognize the file format.