Skip to content

Commit 5b39d1f

Browse files
Ian SeylerIan Seyler
Ian Seyler
authored and
Ian Seyler
committed
Cleanup
1 parent 959d09a commit 5b39d1f

File tree

1 file changed

+9
-23
lines changed

1 file changed

+9
-23
lines changed

src/boot/uefi.asm

+9-23
Original file line numberDiff line numberDiff line change
@@ -274,30 +274,22 @@ again:
274274
lgdt [gdtr]
275275

276276
; Switch to compatibility mode
277-
push SYS32_DATA_SEL
278-
push 0x8000
279-
pushf
280-
push SYS32_CODE_SEL
281-
push testcode
282-
iretq
283-
284-
; Switch to compatibility mode
285-
; mov rax, SYS32_CODE_SEL ; Compatibility mode
286-
; push rax
287-
; lea rax, [compatmode]
288-
; push rax
289-
; retfq
277+
mov rax, SYS32_CODE_SEL ; Compatibility mode
278+
push rax
279+
lea rax, [compatmode]
280+
push rax
281+
retfq
290282

291283
BITS 32
292284
compatmode:
293-
testcode:
294285

295286
; Switch to 32-bit mode
296287
mov eax, SYS32_DATA_SEL ; Clear the segment registers
297288
mov ds, ax
298289
mov es, ax
299290
mov fs, ax
300291
mov gs, ax
292+
mov ss, ax
301293

302294
; Deactivate IA-32e mode by clearing CR0.PG
303295
mov eax, cr0
@@ -311,20 +303,14 @@ testcode:
311303
; Disable IA-32e mode by setting IA32_EFER.LME = 0
312304
mov ecx, 0xC0000080 ; EFER MSR number
313305
rdmsr ; Read EFER
314-
and eax, 0xFFFFFEFF ; LME (Bit 8)
306+
and eax, 0xFFFFFEFF ; Clear LME (Bit 8)
315307
wrmsr ; Write EFER
316308

317-
xor eax, eax
318-
; mov eax, cr4
319-
; btc eax, 7 ; Clear PGE (Bit 7)
320-
; btc eax, 5 ; Clear PAE (Bit 5)
321-
; bts eax, 4 ; Set PSE (bit 4) - Enable 4MB pages
309+
mov eax, 0x00000010 ; Set PSE (Bit 4)
322310
mov cr4, eax
323311

324312
; Enable legacy paged-protected mode by setting CR0.PG
325-
mov eax, 0x11
326-
; mov eax, cr0
327-
; bts eax, 31 ; Set PG (Bit 31)
313+
mov eax, 0x00000001 ; Set PM (Bit 0)
328314
mov cr0, eax
329315

330316
jmp SYS32_CODE_SEL:0x8000 ; 32-bit jump to set CS

0 commit comments

Comments
 (0)