@@ -13,17 +13,8 @@ stage_3:
13
13
mov es , bx # set extra segment
14
14
mov ss , bx # set stack segment
15
15
16
- # print "3rd stage" to the top right
17
- mov eax , 0x0f720f33 # "3r"
18
- mov [ 0xb808c ], eax
19
- mov eax , 0x0f200f64 # "d "
20
- mov [ 0xb808c + 4 ], eax
21
- mov eax , 0x0f740f73 # "st"
22
- mov [ 0xb808c + 8 ], eax
23
- mov eax , 0x0f670f61 # "ag"
24
- mov [ 0xb808c + 12 ], eax
25
- mov eax , 0x0f200f65 # "e "
26
- mov [ 0xb808c + 16 ], eax
16
+ lea si , boot_third_stage_str
17
+ call vga_println
27
18
28
19
check_ cpu :
29
20
call check_cpuid
@@ -86,13 +77,8 @@ set_up_page_tables:
86
77
add ecx , 1
87
78
cmp ecx , edx
88
79
jb map_p1_table
89
- #
90
- map_vga_buffer:
91
- mov eax , 0xb8000
92
- or eax , ( 1 | 2 )
93
- mov ecx , 0xb8000
94
- shr ecx , 12
95
- mov [ _p1 + ecx * 8 ], eax
80
+ map_framebuffer:
81
+ call vga_map_frame_buffer
96
82
97
83
enable_paging:
98
84
# Write back cache and add a memory fence. I'm not sure if this is
@@ -165,15 +151,8 @@ check_cpuid:
165
151
je no_cpuid
166
152
ret
167
153
no_cpuid:
168
- # print "no cpuid" to the top right
169
- mov eax , 0x4f6f4f6e # "no"
170
- mov [ 0xb8130 ], eax
171
- mov eax , 0x4f634f20 # " c"
172
- mov [ 0xb8130 + 4 ], eax
173
- mov eax , 0x4f754f70 # "pu"
174
- mov [ 0xb8130 + 8 ], eax
175
- mov eax , 0x4f644f69 # "id"
176
- mov [ 0xb8130 + 12 ], eax
154
+ lea esi , no_cpuid_str
155
+ call vga_println
177
156
no_cpuid_spin:
178
157
hlt
179
158
jmp no_cpuid_spin
@@ -192,19 +171,8 @@ check_long_mode:
192
171
jz no_long_mode # If it's not set , there is no long mode
193
172
ret
194
173
no_long_mode:
195
- # print "no long mode" to the top right
196
- mov eax , 0x4f6f4f6e # "no"
197
- mov [ 0xb8128 ], eax
198
- mov eax , 0x4f6c4f20 # " l"
199
- mov [ 0xb8128 + 4 ], eax
200
- mov eax , 0x4f6e4f6f # "on"
201
- mov [ 0xb8128 + 8 ], eax
202
- mov eax , 0x4f204f67 # "g "
203
- mov [ 0xb8128 + 12 ], eax
204
- mov eax , 0x4f6f4f6d # "mo"
205
- mov [ 0xb8128 + 16 ], eax
206
- mov eax , 0x4f654f64 # "de"
207
- mov [ 0xb8128 + 20 ], eax
174
+ lea esi , no_long_mode_str
175
+ call vga_println
208
176
no_long_mode_spin:
209
177
hlt
210
178
jmp no_long_mode_spin
@@ -226,3 +194,7 @@ gdt_64:
226
194
gdt_64_pointer:
227
195
. word gdt_64_pointer - gdt_64 - 1 # 16 - bit Size (Limit) of GDT.
228
196
.long gdt_64 # 32 - bit Base Address of GDT. ( CPU will zero extend to 64 - bit)
197
+
198
+ boot_third_stage_str: .asciz "Booting (third stage)..."
199
+ no_cpuid_str: .asciz "Error: CPU does not support CPUID"
200
+ no_long_mode_str: .asciz "Error: CPU does not support long mode"
0 commit comments