summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChloe M. <chloe@aptel.org>2026-08-20 11:08:38 +0000
committerChloe M. <chloe@aptel.org>2026-08-20 11:15:29 +0000
commit46cd7e026b04d477261b7e06de1005ae16465585 (patch)
tree3f92e5b7e225991fff519c9c025053e5b2100d07
parentd76ad3e636bdcfab548e7cc7cb73ca809db6cb94 (diff)
boot/amd64: mbr: Jump to stage 2
Signed-off-by: Chloe M. <chloe@aptel.org>
-rw-r--r--boot/arch/amd64/mbr/mbr.S20
1 files changed, 14 insertions, 6 deletions
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
*/