File tree 2 files changed +34
-0
lines changed
2 files changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -41,5 +41,39 @@ loader_start:
41
41
mov dx , 0x1800
42
42
int 0x10
43
43
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 $
44
78
45
79
You can’t perform that action at this time.
0 commit comments