Restructure bootloader

This commit is contained in:
Robbe Van Herck 2019-12-28 21:05:22 +01:00
parent 984ef385f1
commit a9985ea925
No known key found for this signature in database
GPG Key ID: A66F76F7B81BD784
3 changed files with 14 additions and 17 deletions

View File

@ -3,6 +3,10 @@ DISK_ID EQU 0x81
org 0x7C00 org 0x7C00
bits 16 bits 16
; memory layout:
; 0x8000 -> ... = ELF file, unparsed
; 0x100000 -> ... = actual kernel
jmp .start jmp .start
[bits 16] [bits 16]
@ -219,17 +223,10 @@ mov ss, ax
; set up stack ; set up stack
mov esp, 0x090000 mov esp, 0x090000
; load offset from ELF file ; parse ELF file to 0x10000
; 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]
; add the beginning 0x8000 ; load memory position from ELF file
add eax, 0x8000 mov eax, [ds:0x8018]
jmp eax jmp eax

View File

@ -110,9 +110,9 @@ void kernel_main(void)
terminal_initialize(); terminal_initialize();
/* Newline support is left as an exercise. */ /* Newline support is left as an exercise. */
// terminal_writestring("Hello, "); terminal_writestring("Hello, ");
// terminal_setcolor(vga_entry_color(VGA_COLOR_GREEN, VGA_COLOR_BLACK)); terminal_setcolor(vga_entry_color(VGA_COLOR_GREEN, VGA_COLOR_BLACK));
// terminal_writestring("kernel"); terminal_writestring("kernel");
// terminal_setcolor(vga_entry_color(VGA_COLOR_LIGHT_GREY, VGA_COLOR_BLACK)); terminal_setcolor(vga_entry_color(VGA_COLOR_LIGHT_GREY, VGA_COLOR_BLACK));
// terminal_writestring(" World!\n"); terminal_writestring(" World!\n");
} }

View File

@ -6,8 +6,8 @@ ENTRY(_start)
kernel image. */ kernel image. */
SECTIONS SECTIONS
{ {
/* Set this to 0, so the program entry is the relative position to the start of the kernel */ /* Bootloader will put the kernel at 1M */
. = 0; . = 1M;
/* First put the multiboot header, as it is required to be put very early /* 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. early in the image or the bootloader won't recognize the file format.