Skip to content

Commit 261660b

Browse files
IsaacWoodsphil-opp
authored andcommitted
Set Target Operating Mode (#18)
1 parent 298ba88 commit 261660b

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/second_stage.s

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,18 @@ second_stage:
1010
lea si, second_stage_start_str
1111
call println
1212

13+
set_target_operating_mode:
14+
# Some BIOSs assume the processor will only operate in Legacy Mode. We change the Target
15+
# Operating Mode to "Long Mode Target Only", so the firmware expects each CPU to enter Long Mode
16+
# once and then stay in it. This allows the firmware to enable mode-specifc optimizations.
17+
# We save the flags, because CF is set if the callback is not supported (in which case, this is
18+
# a NOP)
19+
pushf
20+
mov ax, 0xec00
21+
mov bl, 0x2
22+
int 0x15
23+
popf
24+
1325
load_kernel_from_disk:
1426
# start of memory buffer
1527
lea eax, _kernel_buffer

0 commit comments

Comments
 (0)