From caed66a2439aa3690dc612d74fb3073bb5f0bc5f Mon Sep 17 00:00:00 2001 From: Elaina Claus Date: Wed, 10 Sep 2025 11:36:10 -0400 Subject: [PATCH] don't relocate the MBR to the stage2 heap space this will save us disk reads for patition table info --- include/entry.inc | 2 +- src/mbr/mbr.nasm | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/include/entry.inc b/include/entry.inc index 5fb6a99..478fda5 100755 --- a/include/entry.inc +++ b/include/entry.inc @@ -15,7 +15,7 @@ %ifndef __INC_ENTRY -%define MBR_ENTRY 0x8C00 +%define MBR_ENTRY 0x6C00 %define VBR_ENTRY 0x7C00 %define STAGE2_ENTRY 0x0500 diff --git a/src/mbr/mbr.nasm b/src/mbr/mbr.nasm index 378d4ff..b8f7f2f 100755 --- a/src/mbr/mbr.nasm +++ b/src/mbr/mbr.nasm @@ -14,7 +14,7 @@ ; along with this program. If not, see . [BITS 16] -[ORG 0x8C00] +[ORG 0x6C00] [CPU KATMAI] [WARNING -reloc-abs-byte] [WARNING -reloc-abs-word] ; Yes, we use absolute addresses. surpress these warnings. @@ -36,6 +36,7 @@ nop %undef __STEVIA_DEV_DEBUG +; BIOS will load 1st sector of boot drive to 0x7c00, init and relocate ALIGN 4 init: cli ; We do not want to be interrupted @@ -64,7 +65,7 @@ init: mov ch, 0x02 ; 0x0200 in cx mov si, 0x7C00 ; Current MBR Address (loaded here by BIOS) mov di, MBR_ENTRY ; New MBR Address (our new relocation address) - rep movsb ; copy 512 bytes from 0x0000:7c00 to 0x0000:MBR_ENTRY (7A00 as of writing) + rep movsb ; copy 512 bytes from 0x0000:7c00 to 0x0000:MBR_ENTRY (6C00 as of writing) sti @@ -126,7 +127,7 @@ main: mov dword eax, dword [bx + PartEntry_t.lba_start] push dword eax ; lba (4) - push word VBR_ENTRY ; offset = 0x7c00 (2) + push word 0x7C00 ; offset = 0x7c00 (2) push 0x00 ; segment = 0 (2) ; uint8_t read_stage2_raw(uint16_t buf_segment, uint16_t buf_offset, @@ -176,7 +177,7 @@ PartEntry4: times 16 db 0x00 BootSig: dw 0xAA55 ; Add boot signature at the end of bootloader - +; !!! end of MBR !!! section .bss follows=.text begin_bss: