]> git.dujemihanovic.xyz Git - nameless-os.git/blob - boot/x86/stage3/unreal.s
Merge branch 'elf' into mm
[nameless-os.git] / boot / x86 / stage3 / unreal.s
1 ; Routine for enabling unreal mode, which allows using 32-bit offsets in real mode
2
3 bits 16
4 section .text
5
6 enable_unreal:
7 cli
8 push eax
9 push bx
10 push ds
11
12 lgdt [gdt_info]
13 mov eax, cr0
14 or al, 1
15 mov cr0, eax
16
17 jmp $+2
18
19 mov bx, 0x8
20 mov ds, bx
21
22 and al, 0xfe
23 mov cr0, eax
24
25 pop ds
26 pop bx
27 pop eax
28 sti
29 ret
30
31 section .rodata
32
33 ; GDT with 1 flat data segment descriptor
34 gdt_info:
35 dw gdt_end-gdt_start-1
36 dd gdt_start
37 gdt_start: dq 0 ; null entry
38 gdt_flat:
39 dw 0xffff
40 dw 0
41 db 0
42 db 10010010b
43 db 11001111b
44 db 0
45 gdt_end: