Fri, 08 Dec 2023 20:31:49 +0100
4 files changed,
21 insertions(+),
13 deletions(-)
M
boot/drives.s
→
boot/drives.s
@@ -201,7 +201,7 @@ load_end:
movw $0x0000, %si # buffer address movw $0x1000, %ax movw %ax, %es - call print + ;call print movw $done_msg, %si call print
M
boot/entry.s
→
boot/entry.s
@@ -16,7 +16,7 @@ movw %ax, %es
movw %ax, %fs # setup stack - movw $0x9000, %sp + movw $0x7c00, %sp movw %sp, %bp # save boot drive index@@ -33,7 +33,7 @@ call print
# load rest of bootloader movw $0x0000, %bx # buffer address - movw $0x07e0, %ax + movw $0x0100, %ax movw %ax, %es # buffer address (segment) movb $0x02, %ah # function 0x02: read a sector movb $0x07, %al # sectors to read count@@ -44,7 +44,9 @@ lea bootdriv_id, %si
movb (%si), %dl int $0x13 - jnc bl_loaded + jc error + + ljmp $0, $bl_loaded # auxiliary functions .global error@@ -128,6 +130,7 @@ .ascii "Loading bootloader..."
.byte 0 .section .text +.code16 bl_loaded: mov $done_msg, %si call print
M
boot/link.txt
→
boot/link.txt
@@ -7,27 +7,32 @@ PART_TABLE_START = 0x00007DBE;
MEMORY { - BOOT_VMA : ORIGIN = 0x00007C00, LENGTH = 0x00001000 + STAGE1_VMA : ORIGIN = 0x00007C00, LENGTH = 0x00001000 + STAGE2_VMA : ORIGIN = 0x00001000, LENGTH = 0x00001000 BOOT_DATA : ORIGIN = 0x00009000, LENGTH = 0x00001000 KERNEL_VMA : ORIGIN = 0xC0000000, LENGTH = 0x30000000 } SECTIONS { - BOOT : AT(0x0000) + STAGE1 : AT(0x0000) { */*.o(.mbr) . = 510; BYTE(0x55) BYTE(0xAA) - */*.o(.text) - } >BOOT_VMA + } >STAGE1_VMA - .data : + STAGE2 : AT(LOADADDR(STAGE1) + SIZEOF(STAGE1)) { + */*.o(.text) */*.o(.rodata*) */*.o(.data) - } >BOOT_VMA + } >STAGE2_VMA + + .data : AT(LOADADDR(STAGE2) + SIZEOF(STAGE2)) + { + } >STAGE2_VMA .bss : {
M
boot/paging.c
→
boot/paging.c
@@ -4,9 +4,9 @@ #include "string.h"
void *create_kernel_environment() { - PAGE_DIR_ENTRY (*pdir)[PAGE_ENTRY_COUNT] = (void*)(1 * PAGE_SIZE); - PAGE_TABLE_ENTRY (*kernel)[PAGE_ENTRY_COUNT] = (void*)(2 * PAGE_SIZE); - PAGE_TABLE_ENTRY (*lowmem)[PAGE_ENTRY_COUNT] = (void*)(3 * PAGE_SIZE); + PAGE_DIR_ENTRY (*pdir)[PAGE_ENTRY_COUNT] = (void*)(2 * PAGE_SIZE); + PAGE_TABLE_ENTRY (*kernel)[PAGE_ENTRY_COUNT] = (void*)(3 * PAGE_SIZE); + PAGE_TABLE_ENTRY (*lowmem)[PAGE_ENTRY_COUNT] = (void*)(4 * PAGE_SIZE); // set everything to zero memset(pdir, 0, 3 * PAGE_SIZE);