Skip to content

Commit be5d6c0

Browse files
committed
feat: Flush pipeline & enter protect mode
1 parent e5442e8 commit be5d6c0

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

Diff for: boot/loader.S

+34
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,39 @@ loader_start:
4141
mov dx, 0x1800
4242
int 0x10
4343

44+
; ============= READY TO PROTECT MODE ===============
45+
; 1. Enable A20
46+
; 2. Load GDT
47+
; 3. Set PE of CR0 to 1
48+
49+
50+
; ------------- Enable A20 ---------------
51+
in al, 0x92
52+
or al, 0000_0010B
53+
out 0x92, al
54+
55+
; ------------- Load GDT ---------------
56+
lgdt [gdt_ptr]
57+
58+
; ------------- PE on, protect mode on ---------------
59+
mov eax, cr0
60+
or eax, 0x00000001
61+
mov cr0, eax
62+
63+
jmp dword SELECTOR_CODE:p_mode_start ; flush the pipline
64+
65+
[bits 32]
66+
p_mode_start:
67+
mov ax, SELECTOR_DATA
68+
mov ds, ax
69+
mov es, ax
70+
mov ss, ax
71+
mov esp, LOADER_STACK_TOP
72+
mov ax, SELECTOR_VIDEO
73+
mov gs, ax
74+
75+
mov byte [gs:160], 'p'
76+
77+
jmp $
4478

4579

Diff for: img/cocotiOS.img

442 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)