From 46cd7e026b04d477261b7e06de1005ae16465585 Mon Sep 17 00:00:00 2001 From: "Chloe M." Date: Thu, 20 Aug 2026 11:08:38 +0000 Subject: boot/amd64: mbr: Jump to stage 2 Signed-off-by: Chloe M. --- boot/arch/amd64/mbr/mbr.S | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'boot/arch/amd64/mbr') diff --git a/boot/arch/amd64/mbr/mbr.S b/boot/arch/amd64/mbr/mbr.S index 1ce1da1..5d876c2 100644 --- a/boot/arch/amd64/mbr/mbr.S +++ b/boot/arch/amd64/mbr/mbr.S @@ -56,12 +56,22 @@ reloc: /* Get stage2 */ call find_stage2 -1: cli - hlt - jmp 1b + + /* Obtain the data offset */ + mov $BOOT_SEG, %ax + mov %ax, %ds + add $40, %si + movw (%si), %ax + + /* Jump to stage 2 */ + pushw $BOOT_SEG + pushw %ax + lret /* * Locate stage2 on the disk + * + * Stage 2 data descriptor is returned in %SI */ find_stage2: push %ds @@ -98,12 +108,11 @@ find_stage2: rep cmpsb jne 1b + mov %dx, %si stc pop %es pop %ds jnc .not_found - - /* TODO: On found, return the offset to the data in %CX */ ret .not_found: pop %ds @@ -124,7 +133,6 @@ find_stage2: hlt jmp 1b - /* * Read sectors from the disk */ -- cgit v1.2.3