Skip to content

Commit 48e880d

Browse files
committed
Also set stack segment to 32 bit in unreal mode
1 parent 0f6453c commit 48e880d

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

Diff for: bios/stage-2/src/protected_mode.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,10 @@ unsafe impl Sync for GdtPointer {}
5959

6060
pub fn enter_unreal_mode() {
6161
let ds: u16;
62+
let ss: u16;
6263
unsafe {
6364
asm!("mov {0:x}, ds", out(reg) ds, options(nomem, nostack, preserves_flags));
65+
asm!("mov {0:x}, ss", out(reg) ss, options(nomem, nostack, preserves_flags));
6466
}
6567

6668
GDT.clear_interrupts_and_load();
@@ -70,14 +72,15 @@ pub fn enter_unreal_mode() {
7072

7173
// load GDT
7274
unsafe {
73-
asm!("mov {0}, 0x10", "mov ds, {0}", out(reg) _);
75+
asm!("mov {0}, 0x10", "mov ds, {0}", "mov ss, {0}", out(reg) _);
7476
}
7577

7678
// unset protected mode bit again
7779
write_cr0(cr0);
7880

7981
unsafe {
8082
asm!("mov ds, {0:x}", in(reg) ds, options(nostack, preserves_flags));
83+
asm!("mov ss, {0:x}", in(reg) ss, options(nostack, preserves_flags));
8184
asm!("sti");
8285
}
8386
}

0 commit comments

Comments
 (0)