aboutsummaryrefslogtreecommitdiff
path: root/mubios
diff options
context:
space:
mode:
authorRichard Qin <richard.qin.x@gmail.com>2026-11-08 06:48:12 +0800
committerRichard Qin <richard.qin.x@gmail.com>2026-11-08 06:48:12 +0800
commit58e9f8a9c7f63e500a20c7ee15ee7c67a3f90abc (patch)
tree9a10e8e2a5a32d9ae7ca5e87dcec6c45572bd464 /mubios
parente3598eddc3ec9a3deb321a2c04803246db4abb84 (diff)
downloadrcc-project-58e9f8a9c7f63e500a20c7ee15ee7c67a3f90abc.tar.gz
rcc-project-58e9f8a9c7f63e500a20c7ee15ee7c67a3f90abc.tar.xz
[mubios] Transfer control from the BIOS to the MBR, which has been loaded at 0x7C00.
Signed-off-by: Richard Qin <richard.qin.x@gmail.com>
Diffstat (limited to 'mubios')
-rw-r--r--mubios/arch/reset.S18
1 files changed, 18 insertions, 0 deletions
diff --git a/mubios/arch/reset.S b/mubios/arch/reset.S
index 0be8a05..9654a0f 100644
--- a/mubios/arch/reset.S
+++ b/mubios/arch/reset.S
@@ -20,6 +20,10 @@
.intel_syntax noprefix
.code16
+ .equ MBR_LOAD_SEGMENT, 0x0000
+ .equ MBR_LOAD_OFFSET, 0x7C00
+ .equ BOOT_DRIVE_SLOT, 0x7FFC
+
.extern enter_protected_mode
.section .text16.entry, "ax"
@@ -36,9 +40,23 @@ reset_entry:
mov es, ax
mov ss, ax
mov sp, 0x8000
+ mov byte ptr [BOOT_DRIVE_SLOT], dl
call enter_protected_mode
+ cli
+ mov dl, byte ptr [BOOT_DRIVE_SLOT]
+ xor ax, ax
+ mov ds, ax
+ mov es, ax
+ mov ss, ax
+ mov sp, MBR_LOAD_OFFSET
+ cld
+
+ .byte 0xEA
+ .word MBR_LOAD_OFFSET
+ .word MBR_LOAD_SEGMENT
+
reset_halt:
sti