Skip to content

Commit 0c9252d

Browse files
committed
Add VESA initiation code to Stage 1 bootloader (Issue #37)
1 parent 2512b1b commit 0c9252d

File tree

1 file changed

+29
-1
lines changed

1 file changed

+29
-1
lines changed

src/stage_1.s

+29-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,32 @@
77
# the bootloader from disk, and jumps to stage_2.
88

99
_start:
10+
# Try VESA
11+
mov ax, 0x9000
12+
mov es, ax
13+
mov di, 0
14+
mov ax, 0x4f00
15+
int 0x10
16+
cmp ax, 0x004f
17+
jne zero
18+
# Check VESA version 2 or 3
19+
mov ax, es:[di+4]
20+
cmp ax, 0x0300
21+
je init_vesa
22+
cmp ax, 0x0200
23+
jne zero
24+
# Hard coded 800x600x16bit mode; this gets us the PHY-addr of the FB
25+
init_vesa:
26+
mov ax, 0x4f01
27+
mov cx, 0x114
28+
mov di, VESAInfo
29+
int 0x10
30+
31+
mov ax, 0x4f02
32+
mov bx, 0x4114
33+
int 0x10
34+
35+
zero:
1036
# zero segment registers
1137
xor ax, ax
1238
mov ds, ax
@@ -35,7 +61,6 @@ enable_a20:
3561
out 0x92, al
3662
enable_a20_after:
3763

38-
3964
enter_protected_mode:
4065
# clear interrupts
4166
cli
@@ -231,3 +256,6 @@ dap_start_lba:
231256

232257
.org 510
233258
.word 0xaa55 # magic number for bootable disk
259+
260+
VESAInfo:
261+
.space 256, 0

0 commit comments

Comments
 (0)