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
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

View File

@ -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");
}

View File

@ -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.