Skip to content

Commit 7f7fec7

Browse files
committed
Set up VESA mode properly instead of hardcoding it
Use the vesa init code from Redox. Comment out prompting the user for resolution for now (we can make it configurable later).
1 parent 15fda23 commit 7f7fec7

File tree

10 files changed

+442
-211
lines changed

10 files changed

+442
-211
lines changed

Cargo.toml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,9 @@ serde = { version = "1.0", features = ["derive"], optional = true}
6565
default = []
6666
builder = ["argh", "thiserror", "displaydoc", "anyhow", "llvm-tools", "json", "fatfs", "gpt"]
6767
runner = ["anyhow"]
68-
bios_bin = ["binary", "vga_320x200", "rsdp"]
69-
uefi_bin = ["binary", "uefi", "font8x8"]
70-
binary = ["llvm-tools-build", "x86_64", "toml", "xmas-elf", "usize_conversions", "log", "conquer-once", "spinning_top", "serde"]
71-
vga_320x200 = ["font8x8"]
68+
bios_bin = ["binary", "rsdp"]
69+
uefi_bin = ["binary", "uefi"]
70+
binary = ["llvm-tools-build", "x86_64", "toml", "xmas-elf", "usize_conversions", "log", "conquer-once", "spinning_top", "serde", "font8x8"]
7271
recursive_page_table = []
7372
map_physical_memory = []
7473

src/asm/stage_2.s

Lines changed: 68 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ create_memory_map:
8787
call do_e820
8888

8989
video_mode_config:
90-
call config_video_mode
90+
call vesa
9191

9292
enter_protected_mode_again:
9393
cli
@@ -103,3 +103,70 @@ enter_protected_mode_again:
103103

104104
spin32:
105105
jmp spin32
106+
107+
108+
109+
# print a string and a newline
110+
# IN
111+
# esi: points at zero-terminated String
112+
vga_println:
113+
push eax
114+
push ebx
115+
push ecx
116+
push edx
117+
118+
call vga_print
119+
120+
# newline
121+
mov edx, 0
122+
mov eax, vga_position
123+
mov ecx, 80 * 2
124+
div ecx
125+
add eax, 1
126+
mul ecx
127+
mov vga_position, eax
128+
129+
pop edx
130+
pop ecx
131+
pop ebx
132+
pop eax
133+
134+
ret
135+
136+
# print a string
137+
# IN
138+
# esi: points at zero-terminated String
139+
# CLOBBER
140+
# ah, ebx
141+
vga_print:
142+
cld
143+
vga_print_loop:
144+
# note: if direction flag is set (via std)
145+
# this will DECREMENT the ptr, effectively
146+
# reading/printing in reverse.
147+
lodsb al, BYTE PTR [esi]
148+
test al, al
149+
jz vga_print_done
150+
call vga_print_char
151+
jmp vga_print_loop
152+
vga_print_done:
153+
ret
154+
155+
156+
# print a character
157+
# IN
158+
# al: character to print
159+
# CLOBBER
160+
# ah, ebx
161+
vga_print_char:
162+
mov ebx, vga_position
163+
mov ah, 0x0f
164+
mov [ebx + 0xa0000], ax
165+
166+
add ebx, 2
167+
mov [vga_position], ebx
168+
169+
ret
170+
171+
vga_position:
172+
.double 0

src/asm/stage_3.s

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@ stage_3:
1313
mov es, bx # set extra segment
1414
mov ss, bx # set stack segment
1515

16-
mov si, offset boot_third_stage_str
17-
call vga_println
18-
1916
check_cpu:
2017
call check_cpuid
2118
call check_long_mode
@@ -168,6 +165,5 @@ gdt_64_pointer:
168165
.word gdt_64_pointer - gdt_64 - 1 # 16-bit Size (Limit) of GDT.
169166
.long gdt_64 # 32-bit Base Address of GDT. (CPU will zero extend to 64-bit)
170167

171-
boot_third_stage_str: .asciz "Booting (third stage)..."
172168
no_cpuid_str: .asciz "Error: CPU does not support CPUID"
173169
no_long_mode_str: .asciz "Error: CPU does not support long mode"

0 commit comments

Comments
 (0)