File tree Expand file tree Collapse file tree 3 files changed +31
-10
lines changed Expand file tree Collapse file tree 3 files changed +31
-10
lines changed Original file line number Diff line number Diff line change @@ -34,7 +34,7 @@ enter_protected_mode:
34
34
push ds
35
35
push es
36
36
37
- lgdt [ gdtinfo ]
37
+ lgdt [ gdt32info ]
38
38
39
39
mov eax , cr0
40
40
or al , 1 # set protected mode bit
@@ -43,7 +43,7 @@ enter_protected_mode:
43
43
jmp protected_mode # tell 386 / 486 to not crash
44
44
45
45
protected_mode:
46
- mov bx , 0x8
46
+ mov bx , 0x10
47
47
mov ds , bx # set data segment
48
48
mov es , bx # set extra segment
49
49
@@ -183,14 +183,23 @@ no_cpuid_str: .asciz "No CPUID support"
183
183
no_int13h_extensions_str: .asciz "No support for int13h extensions"
184
184
rest_of_bootloader_load_failed_str: .asciz "Failed to load rest of bootloader"
185
185
186
- gdtinfo :
187
- . word gdt_end - gdt - 1 # last byte in table
188
- . word gdt # start of table
186
+ gdt32info :
187
+ . word gdt32_end - gdt32 - 1 # last byte in table
188
+ . word gdt32 # start of table
189
189
190
- gdt :
190
+ gdt32 :
191
191
# entry 0 is always unused
192
192
.quad 0
193
- flatdesc:
193
+ codedesc:
194
+ . byte 0xff
195
+ . byte 0xff
196
+ . byte 0
197
+ . byte 0
198
+ . byte 0
199
+ . byte 0x9a
200
+ . byte 0xcf
201
+ . byte 0
202
+ datadesc:
194
203
. byte 0xff
195
204
. byte 0xff
196
205
. byte 0
@@ -199,7 +208,7 @@ flatdesc:
199
208
. byte 0x92
200
209
. byte 0xcf
201
210
. byte 0
202
- gdt_end :
211
+ gdt32_end :
203
212
204
213
dap: # disk access packet
205
214
. byte 0x10 # size of dap
Original file line number Diff line number Diff line change @@ -78,9 +78,16 @@ create_memory_map:
78
78
call do_e820
79
79
80
80
enter_protected_mode_again:
81
- jmp enter_protected_mode_again
81
+ cli
82
+ lgdt [ gdt32info ]
83
+ mov eax , cr0
84
+ or al , 1 # set protected mode bit
85
+ mov cr0 , eax
82
86
87
+ push 0x8
83
88
lea eax , [ stage_3 ]
84
- jmp eax
89
+ push eax
90
+ retf
91
+
85
92
spin32:
86
93
jmp spin32
Original file line number Diff line number Diff line change 5
5
no_long_mode_str: .asciz "No long mode support"
6
6
7
7
stage_3:
8
+ mov bx , 0x10
9
+ mov ds , bx # set data segment
10
+ mov es , bx # set extra segment
11
+ mov ss , bx # set stack segment
12
+
8
13
check_ cpu :
9
14
call check_cpuid
10
15
call check_long_mode
You can’t perform that action at this time.
0 commit comments