5
#define VESA_INFO_SIZE 1024
7
#define VESA_MODE_ATTRIBUTES_OFFSET 0
8
#define VESA_MODE_LIST_PTR_OFFSET 14
9
#define VESA_MODE_SCANLINE_OFFSET 16
10
#define VESA_MODE_WIDTH_OFFSET 18
11
#define VESA_MODE_HEIGHT_OFFSET 20
12
#define VESA_MODE_BPP_OFFSET 25
13
#define VESA_MODE_RED_MASK_OFFSET 31
14
#define VESA_MODE_RED_POS_OFFSET 32
15
#define VESA_MODE_GREEN_MASK_OFFSET 33
16
#define VESA_MODE_GREEN_POS_OFFSET 34
17
#define VESA_MODE_BLUE_MASK_OFFSET 35
18
#define VESA_MODE_BLUE_POS_OFFSET 36
19
#define VESA_MODE_PHADDR_OFFSET 40
21
#define VESA_END_OF_MODES 0xffff
25
#define VESA_GET_INFO 0x4f00
26
#define VESA_GET_MODE_INFO 0x4f01
27
#define VESA_SET_MODE 0x4f02
28
#define VESA_SET_PALETTE 0x4f09
32
jmp $gdtselector(VESA_INIT_DES), $vesa_init_real - vesa_init
41
jmp $VESA_INIT_SEGMENT, $vesa_init_real2 - vesa_init
44
mov $VESA_INIT_SEGMENT, %bx
53
movl $0x0000fffc, %esp
54
movl $0x0000fffc, %ebp
57
# parse default mode string
59
mov $default_mode - vesa_init, %di
77
# multiply default_width by 10 and add digit
79
mov default_width - vesa_init, %bx
80
lea (%ebx, %ebx, 4), %ebx
83
mov %bx, default_width - vesa_init
108
# multiply default_height by 10 and add digit
110
mov default_height - vesa_init, %bx
111
lea (%ebx, %ebx, 4), %ebx
114
mov %bx, default_height - vesa_init
139
# multiply default_bpp by 10 and add digit
141
mov default_bpp - vesa_init, %bx
142
lea (%ebx, %ebx, 4), %ebx
145
mov %bx, default_bpp - vesa_init
153
mov $VESA_GET_INFO, %ax
154
mov $e_vesa_init - vesa_init, %di
162
mov 2 + VESA_MODE_LIST_PTR_OFFSET(%di), %si
164
mov VESA_MODE_LIST_PTR_OFFSET(%di), %si
166
add $VESA_INFO_SIZE, %di
171
cmp $VESA_END_OF_MODES, %cx
179
mov $VESA_GET_MODE_INFO, %ax
188
# check for proper attributes (supported, color, graphics, linear framebuffer)
190
mov VESA_MODE_ATTRIBUTES_OFFSET(%di), %ax
195
# check for proper resolution
197
mov default_width - vesa_init, %ax
198
cmp VESA_MODE_WIDTH_OFFSET(%di), %ax
201
mov default_height - vesa_init, %ax
202
cmp VESA_MODE_HEIGHT_OFFSET(%di), %ax
205
# check for proper bpp
207
mov default_bpp - vesa_init, %al
208
cmp VESA_MODE_BPP_OFFSET(%di), %al
212
cmp default_bpp - vesa_init, %al
215
# for 24 bpp modes accept also 32 bit bpp
218
cmp VESA_MODE_BPP_OFFSET(%di), %al
225
mov $VESA_SET_MODE, %ax
232
# set 3:2:3 VGA palette
234
mov VESA_MODE_BPP_OFFSET(%di), %al
238
mov VESA_MODE_ATTRIBUTES_OFFSET(%di), %ax
240
mov $vga323 - vesa_init, %di
243
bt $5, %ax # test if VGA compatible registers are present
246
# try VESA routine to set palette
247
mov $VESA_SET_PALETTE, %ax
256
# try VGA registers to set palette
257
movw $0x3c6, %dx # set palette mask
261
movw $0x3c8, %dx # first index to set
265
movw $0x3c9, %dx # data port
286
# store mode parameters
287
# eax = bpp[8] scanline[16]
288
# ebx = width[16] height[16]
289
# edx = red_mask[8] red_pos[8] green_mask[8] green_pos[8]
290
# esi = blue_mask[8] blue_pos[8]
291
# edi = linear frame buffer
293
mov VESA_MODE_BPP_OFFSET(%di), %al
296
mov VESA_MODE_SCANLINE_OFFSET(%di), %ax
298
mov VESA_MODE_WIDTH_OFFSET(%di), %bx
300
mov VESA_MODE_HEIGHT_OFFSET(%di), %bx
302
mov VESA_MODE_BLUE_MASK_OFFSET(%di), %dl
304
mov VESA_MODE_BLUE_POS_OFFSET(%di), %dl
307
mov VESA_MODE_RED_MASK_OFFSET(%di), %dl
309
mov VESA_MODE_RED_POS_OFFSET(%di), %dl
311
mov VESA_MODE_GREEN_MASK_OFFSET(%di), %dl
313
mov VESA_MODE_GREEN_POS_OFFSET(%di), %dl
315
mov VESA_MODE_PHADDR_OFFSET(%di), %edi
327
ljmpl $gdtselector(KTEXT32_DES), $(vesa_init_protected - vesa_init + VESA_INIT_SEGMENT << 4)
330
# no prefered mode found
334
mov $VESA_GET_MODE_INFO, %ax
341
jz set_mode # force relative jump
344
# reset to EGA text mode (because of problems with VESA)
347
mov $0xffffffff, %edi
349
jz vesa_leave_real # force relative jump
352
#include "vga323.pal"
364
.ascii STRING(CONFIG_VESA_MODE)
366
.asciz STRING(CONFIG_VESA_BPP)
369
#include "vesa_ret.inc"