Skip to content

Commit d433419

Browse files
committed
Add VESA initiation code feature (Issue #37)
1 parent 2512b1b commit d433419

File tree

4 files changed

+47
-2
lines changed

4 files changed

+47
-2
lines changed

Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ llvm-tools = "0.1"
2828
[features]
2929
default = []
3030
vga_320x200 = []
31+
vesa_800x600 = []
3132
recursive_page_table = []
3233
map_physical_memory = []
3334

src/main.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,11 @@ global_asm!(include_str!("stage_2.s"));
3131
global_asm!(include_str!("e820.s"));
3232
global_asm!(include_str!("stage_3.s"));
3333

34+
#[cfg(feature = "vesa_800x600")]
35+
global_asm!(include_str!("video_mode/vesa_800x600.s"));
3436
#[cfg(feature = "vga_320x200")]
3537
global_asm!(include_str!("video_mode/vga_320x200.s"));
36-
#[cfg(not(feature = "vga_320x200"))]
38+
#[cfg(not(any(feature = "vesa_800x600", feature = "vga_320x200")))]
3739
global_asm!(include_str!("video_mode/vga_text_80x25.s"));
3840

3941
unsafe fn context_switch(boot_info: VirtAddr, entry_point: VirtAddr, stack_pointer: VirtAddr) -> ! {

src/stage_1.s

-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ enable_a20:
3535
out 0x92, al
3636
enable_a20_after:
3737

38-
3938
enter_protected_mode:
4039
# clear interrupts
4140
cli

src/video_mode/vesa_800x600.s

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
.section .boot, "awx"
2+
.intel_syntax noprefix
3+
.code16
4+
5+
# This code is responsible for enabling VESA graphics while in
6+
# real mode.
7+
config_video_mode:
8+
# Try VESA
9+
mov ax, 0x9000
10+
mov es, ax
11+
mov di, 0
12+
mov ax, 0x4f00
13+
int 0x10
14+
cmp ax, 0x004f
15+
jne vesa_out
16+
# Check VESA version 2 or 3
17+
mov ax, es:[di+4]
18+
cmp ax, 0x0300
19+
je init_vesa
20+
cmp ax, 0x0200
21+
jne vesa_out
22+
# Hard coded 800x600x16bit mode; this gets us the PHY-addr of the FB
23+
init_vesa:
24+
mov ax, 0x4f01
25+
mov cx, 0x114
26+
mov di, VESAInfo
27+
int 0x10
28+
29+
mov ax, 0x4f02
30+
mov bx, 0x4114
31+
int 0x10
32+
33+
vesa_out:
34+
ret
35+
36+
vga_println:
37+
ret
38+
39+
vga_map_frame_buffer:
40+
ret
41+
42+
VESAInfo:
43+
.space 256, 0

0 commit comments

Comments
 (0)