1 | ;; ============================================================================================
|
---|
2 | ;;
|
---|
3 | ;; Copyright (C) 2002 Jeroen Janssen
|
---|
4 | ;;
|
---|
5 | ;; This library is free software; you can redistribute it and/or
|
---|
6 | ;; modify it under the terms of the GNU Lesser General Public
|
---|
7 | ;; License as published by the Free Software Foundation; either
|
---|
8 | ;; version 2 of the License, or (at your option) any later version.
|
---|
9 | ;;
|
---|
10 | ;; This library is distributed in the hope that it will be useful,
|
---|
11 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
12 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
13 | ;; Lesser General Public License for more details.
|
---|
14 | ;;
|
---|
15 | ;; You should have received a copy of the GNU Lesser General Public
|
---|
16 | ;; License along with this library; if not, write to the Free Software
|
---|
17 | ;; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
---|
18 | ;;
|
---|
19 | ;; ============================================================================================
|
---|
20 | ;;
|
---|
21 | ;; This VBE is part of the VGA Bios specific to the plex86/bochs Emulated VGA card.
|
---|
22 | ;; You can NOT drive any physical vga card with it.
|
---|
23 | ;;
|
---|
24 | ;; ============================================================================================
|
---|
25 | ;;
|
---|
26 | ;; This VBE Bios is based on information taken from :
|
---|
27 | ;; - VESA BIOS EXTENSION (VBE) Core Functions Standard Version 3.0 located at www.vesa.org
|
---|
28 | ;;
|
---|
29 | ;; ============================================================================================
|
---|
30 |
|
---|
31 |
|
---|
32 | ; Oracle LGPL Disclaimer: For the avoidance of doubt, except that if any license choice
|
---|
33 | ; other than GPL or LGPL is available it will apply instead, Oracle elects to use only
|
---|
34 | ; the Lesser General Public License version 2.1 (LGPLv2) at this time for any software where
|
---|
35 | ; a choice of LGPL license versions is made available with the language indicating
|
---|
36 | ; that LGPLv2 or any later version may be used, or where a choice of which version
|
---|
37 | ; of the LGPL is applied is otherwise unspecified.
|
---|
38 |
|
---|
39 | include vgadefs.inc
|
---|
40 | include commondefs.inc
|
---|
41 |
|
---|
42 | public _vga_compat_setup
|
---|
43 | public dispi_set_enable_
|
---|
44 | public dispi_set_bank_
|
---|
45 | public _dispi_set_bank_farcall
|
---|
46 | public _dispi_get_max_bpp
|
---|
47 | public _vbe_has_vbe_display
|
---|
48 |
|
---|
49 | public vbe_biosfn_return_current_mode
|
---|
50 | public vbe_biosfn_display_window_control
|
---|
51 | public vbe_biosfn_set_get_display_start
|
---|
52 | public vbe_biosfn_set_get_dac_palette_format
|
---|
53 | public vbe_biosfn_set_get_palette_data
|
---|
54 | public vbe_biosfn_return_protected_mode_interface
|
---|
55 |
|
---|
56 | VGAROM segment public 'CODE'
|
---|
57 |
|
---|
58 | SET_DEFAULT_CPU
|
---|
59 |
|
---|
60 | VBE_BYTEWISE_IO EQU 1
|
---|
61 |
|
---|
62 | ;; Bytewise in/out
|
---|
63 | ifdef VBE_BYTEWISE_IO
|
---|
64 |
|
---|
65 | public do_out_dx_ax
|
---|
66 | public do_in_ax_dx
|
---|
67 |
|
---|
68 | do_out_dx_ax:
|
---|
69 | xchg ah, al
|
---|
70 | out dx, al
|
---|
71 | xchg ah, al
|
---|
72 | out dx, al
|
---|
73 | ret
|
---|
74 |
|
---|
75 | do_in_ax_dx:
|
---|
76 | in al, dx
|
---|
77 | xchg ah, al
|
---|
78 | in al, dx
|
---|
79 | ret
|
---|
80 |
|
---|
81 | out_dx_ax EQU call do_out_dx_ax
|
---|
82 | in_ax_dx EQU call do_in_ax_dx
|
---|
83 | else
|
---|
84 | out_dx_ax EQU out dx, ax
|
---|
85 | in_ax_dx EQU in ax, dx
|
---|
86 | endif
|
---|
87 |
|
---|
88 | ;; Vertical retrace waiting
|
---|
89 | wait_vsync:
|
---|
90 | push ax
|
---|
91 | push dx
|
---|
92 | mov dx, 03DAh ; @todo use a symbolic constant!
|
---|
93 | wv_loop:
|
---|
94 | in al, dx
|
---|
95 | test al, 8
|
---|
96 | jz wv_loop
|
---|
97 | pop dx
|
---|
98 | pop ax
|
---|
99 | ret
|
---|
100 |
|
---|
101 | wait_not_vsync:
|
---|
102 | push ax
|
---|
103 | push dx
|
---|
104 | mov dx, 03DAh ; @todo use a symbolic constant!
|
---|
105 | wnv_loop:
|
---|
106 | in al, dx
|
---|
107 | test al, 8
|
---|
108 | jnz wnv_loop
|
---|
109 | pop dx
|
---|
110 | pop ax
|
---|
111 | ret
|
---|
112 |
|
---|
113 |
|
---|
114 | ; AL = bits per pixel / AH = bytes per pixel
|
---|
115 | dispi_get_bpp:
|
---|
116 | push dx
|
---|
117 | mov dx, VBE_DISPI_IOPORT_INDEX
|
---|
118 | mov ax, VBE_DISPI_INDEX_BPP
|
---|
119 | out_dx_ax
|
---|
120 | mov dx, VBE_DISPI_IOPORT_DATA
|
---|
121 | in_ax_dx
|
---|
122 | cmp al, 4
|
---|
123 | jbe get_bpp_noinc
|
---|
124 | mov ah, al
|
---|
125 | if VBOX_BIOS_CPU gt 8086
|
---|
126 | shr ah, 3
|
---|
127 | else
|
---|
128 | shr ah, 1
|
---|
129 | shr ah, 1
|
---|
130 | shr ah, 1
|
---|
131 | endif
|
---|
132 | test al, 07
|
---|
133 | jz get_bpp_noinc
|
---|
134 | inc ah
|
---|
135 | get_bpp_noinc:
|
---|
136 | pop dx
|
---|
137 | ret
|
---|
138 |
|
---|
139 | ; get display capabilities
|
---|
140 |
|
---|
141 | _dispi_get_max_bpp:
|
---|
142 | push dx
|
---|
143 | push bx
|
---|
144 | call dispi_get_enable
|
---|
145 | mov bx, ax
|
---|
146 | or ax, VBE_DISPI_GETCAPS
|
---|
147 | call dispi_set_enable_
|
---|
148 | mov dx, VBE_DISPI_IOPORT_INDEX
|
---|
149 | mov ax, VBE_DISPI_INDEX_BPP
|
---|
150 | out_dx_ax
|
---|
151 | mov dx, VBE_DISPI_IOPORT_DATA
|
---|
152 | in_ax_dx
|
---|
153 | push ax
|
---|
154 | mov ax, bx
|
---|
155 | call dispi_set_enable_
|
---|
156 | pop ax
|
---|
157 | pop bx
|
---|
158 | pop dx
|
---|
159 | ret
|
---|
160 |
|
---|
161 | dispi_set_enable_:
|
---|
162 | push dx
|
---|
163 | push ax
|
---|
164 | mov dx, VBE_DISPI_IOPORT_INDEX
|
---|
165 | mov ax, VBE_DISPI_INDEX_ENABLE
|
---|
166 | out_dx_ax
|
---|
167 | pop ax
|
---|
168 | mov dx, VBE_DISPI_IOPORT_DATA
|
---|
169 | out_dx_ax
|
---|
170 | pop dx
|
---|
171 | ret
|
---|
172 |
|
---|
173 | dispi_get_enable:
|
---|
174 | push dx
|
---|
175 | mov dx, VBE_DISPI_IOPORT_INDEX
|
---|
176 | mov ax, VBE_DISPI_INDEX_ENABLE
|
---|
177 | out_dx_ax
|
---|
178 | mov dx, VBE_DISPI_IOPORT_DATA
|
---|
179 | in_ax_dx
|
---|
180 | pop dx
|
---|
181 | ret
|
---|
182 |
|
---|
183 | dispi_set_bank_:
|
---|
184 | push dx
|
---|
185 | push ax
|
---|
186 | mov dx, VBE_DISPI_IOPORT_INDEX
|
---|
187 | mov ax, VBE_DISPI_INDEX_BANK
|
---|
188 | out_dx_ax
|
---|
189 | pop ax
|
---|
190 | mov dx, VBE_DISPI_IOPORT_DATA
|
---|
191 | out_dx_ax
|
---|
192 | pop dx
|
---|
193 | ret
|
---|
194 |
|
---|
195 | dispi_get_bank:
|
---|
196 | push dx
|
---|
197 | mov dx, VBE_DISPI_IOPORT_INDEX
|
---|
198 | mov ax, VBE_DISPI_INDEX_BANK
|
---|
199 | out_dx_ax
|
---|
200 | mov dx, VBE_DISPI_IOPORT_DATA
|
---|
201 | in_ax_dx
|
---|
202 | pop dx
|
---|
203 | ret
|
---|
204 |
|
---|
205 | _dispi_set_bank_farcall:
|
---|
206 | cmp bx, 0100h
|
---|
207 | je dispi_set_bank_farcall_get
|
---|
208 | or bx,bx
|
---|
209 | jnz dispi_set_bank_farcall_error
|
---|
210 | mov ax, dx
|
---|
211 | push dx
|
---|
212 | push ax
|
---|
213 | mov ax, VBE_DISPI_INDEX_BANK
|
---|
214 | mov dx, VBE_DISPI_IOPORT_INDEX
|
---|
215 | out_dx_ax
|
---|
216 | pop ax
|
---|
217 | mov dx, VBE_DISPI_IOPORT_DATA
|
---|
218 | out_dx_ax
|
---|
219 | in_ax_dx
|
---|
220 | pop dx
|
---|
221 | cmp dx,ax
|
---|
222 | jne dispi_set_bank_farcall_error
|
---|
223 | mov ax, 004Fh
|
---|
224 | retf
|
---|
225 | dispi_set_bank_farcall_get:
|
---|
226 | mov ax, VBE_DISPI_INDEX_BANK
|
---|
227 | mov dx, VBE_DISPI_IOPORT_INDEX
|
---|
228 | out_dx_ax
|
---|
229 | mov dx, VBE_DISPI_IOPORT_DATA
|
---|
230 | in_ax_dx
|
---|
231 | mov dx,ax
|
---|
232 | retf
|
---|
233 | dispi_set_bank_farcall_error:
|
---|
234 | mov ax, 014Fh
|
---|
235 | retf
|
---|
236 |
|
---|
237 | dispi_set_x_offset:
|
---|
238 | push dx
|
---|
239 | push ax
|
---|
240 | mov dx, VBE_DISPI_IOPORT_INDEX
|
---|
241 | mov ax, VBE_DISPI_INDEX_X_OFFSET
|
---|
242 | out_dx_ax
|
---|
243 | pop ax
|
---|
244 | mov dx, VBE_DISPI_IOPORT_DATA
|
---|
245 | out_dx_ax
|
---|
246 | pop dx
|
---|
247 | ret
|
---|
248 |
|
---|
249 | dispi_get_x_offset:
|
---|
250 | push dx
|
---|
251 | mov dx, VBE_DISPI_IOPORT_INDEX
|
---|
252 | mov ax, VBE_DISPI_INDEX_X_OFFSET
|
---|
253 | out_dx_ax
|
---|
254 | mov dx, VBE_DISPI_IOPORT_DATA
|
---|
255 | in_ax_dx
|
---|
256 | pop dx
|
---|
257 | ret
|
---|
258 |
|
---|
259 | dispi_set_y_offset:
|
---|
260 | push dx
|
---|
261 | push ax
|
---|
262 | mov dx, VBE_DISPI_IOPORT_INDEX
|
---|
263 | mov ax, VBE_DISPI_INDEX_Y_OFFSET
|
---|
264 | out_dx_ax
|
---|
265 | pop ax
|
---|
266 | mov dx, VBE_DISPI_IOPORT_DATA
|
---|
267 | out_dx_ax
|
---|
268 | pop dx
|
---|
269 | ret
|
---|
270 |
|
---|
271 | dispi_get_y_offset:
|
---|
272 | push dx
|
---|
273 | mov dx, VBE_DISPI_IOPORT_INDEX
|
---|
274 | mov ax, VBE_DISPI_INDEX_Y_OFFSET
|
---|
275 | out_dx_ax
|
---|
276 | mov dx, VBE_DISPI_IOPORT_DATA
|
---|
277 | in_ax_dx
|
---|
278 | pop dx
|
---|
279 | ret
|
---|
280 |
|
---|
281 | vga_set_virt_width:
|
---|
282 | push ax
|
---|
283 | push bx
|
---|
284 | push dx
|
---|
285 | mov bx, ax
|
---|
286 | call dispi_get_bpp
|
---|
287 | cmp al, 4
|
---|
288 | ja set_width_svga
|
---|
289 | shr bx, 1
|
---|
290 | set_width_svga:
|
---|
291 | if VBOX_BIOS_CPU gt 8086
|
---|
292 | shr bx, 3
|
---|
293 | else
|
---|
294 | shr bx, 1
|
---|
295 | shr bx, 1
|
---|
296 | shr bx, 1
|
---|
297 | endif
|
---|
298 | mov dx, VGAREG_VGA_CRTC_ADDRESS
|
---|
299 | mov ah, bl
|
---|
300 | mov al, 13h
|
---|
301 | out dx, ax
|
---|
302 | pop dx
|
---|
303 | pop bx
|
---|
304 | pop ax
|
---|
305 | ret
|
---|
306 |
|
---|
307 | _vga_compat_setup:
|
---|
308 | push ax
|
---|
309 | push dx
|
---|
310 |
|
---|
311 | ; set CRT X resolution
|
---|
312 | mov dx, VBE_DISPI_IOPORT_INDEX
|
---|
313 | mov ax, VBE_DISPI_INDEX_XRES
|
---|
314 | out_dx_ax
|
---|
315 | mov dx, VBE_DISPI_IOPORT_DATA
|
---|
316 | in_ax_dx
|
---|
317 | push ax
|
---|
318 | mov dx, VGAREG_VGA_CRTC_ADDRESS
|
---|
319 | mov ax, 0011h
|
---|
320 | out dx, ax
|
---|
321 | pop ax
|
---|
322 | push ax
|
---|
323 | if VBOX_BIOS_CPU gt 8086
|
---|
324 | shr ax, 3
|
---|
325 | else
|
---|
326 | shr ax, 1
|
---|
327 | shr ax, 1
|
---|
328 | shr ax, 1
|
---|
329 | endif
|
---|
330 | dec ax
|
---|
331 | mov ah, al
|
---|
332 | mov al, 01
|
---|
333 | out dx, ax
|
---|
334 | pop ax
|
---|
335 | call vga_set_virt_width
|
---|
336 |
|
---|
337 | ; set CRT Y resolution
|
---|
338 | mov dx, VBE_DISPI_IOPORT_INDEX
|
---|
339 | mov ax, VBE_DISPI_INDEX_YRES
|
---|
340 | out_dx_ax
|
---|
341 | mov dx, VBE_DISPI_IOPORT_DATA
|
---|
342 | in_ax_dx
|
---|
343 | dec ax
|
---|
344 | push ax
|
---|
345 | mov dx, VGAREG_VGA_CRTC_ADDRESS
|
---|
346 | mov ah, al
|
---|
347 | mov al, 12h
|
---|
348 | out dx, ax
|
---|
349 | pop ax
|
---|
350 | mov al, 07
|
---|
351 | out dx, al
|
---|
352 | inc dx
|
---|
353 | in al, dx
|
---|
354 | and al, 0BDh
|
---|
355 | test ah, 01
|
---|
356 | jz bit8_clear
|
---|
357 | or al, 02
|
---|
358 | bit8_clear:
|
---|
359 | test ah, 02
|
---|
360 | jz bit9_clear
|
---|
361 | or al, 40h
|
---|
362 | bit9_clear:
|
---|
363 | out dx, al
|
---|
364 |
|
---|
365 | ; other settings
|
---|
366 | mov dx, VGAREG_VGA_CRTC_ADDRESS
|
---|
367 | mov ax, 0009
|
---|
368 | out dx, al
|
---|
369 | mov dx, VGAREG_VGA_CRTC_DATA
|
---|
370 | in al, dx
|
---|
371 | and al, 60h ; clear double scan bit and cell height
|
---|
372 | out dx, al
|
---|
373 | mov dx, VGAREG_VGA_CRTC_ADDRESS
|
---|
374 | mov al, 17h
|
---|
375 | out dx, al
|
---|
376 | mov dx, VGAREG_VGA_CRTC_DATA
|
---|
377 | in al, dx
|
---|
378 | or al, 03
|
---|
379 | out dx, al
|
---|
380 | mov dx, VGAREG_ACTL_RESET
|
---|
381 | in al, dx
|
---|
382 | mov dx, VGAREG_ACTL_ADDRESS
|
---|
383 | mov al, 10h
|
---|
384 | out dx, al
|
---|
385 | mov dx, VGAREG_ACTL_READ_DATA
|
---|
386 | in al, dx
|
---|
387 | or al, 01
|
---|
388 | mov dx, VGAREG_ACTL_ADDRESS
|
---|
389 | out dx, al
|
---|
390 | mov al, 20h
|
---|
391 | out dx, al
|
---|
392 | mov dx, VGAREG_GRDC_ADDRESS
|
---|
393 | mov ax, 0506h
|
---|
394 | out dx, ax
|
---|
395 | mov dx, VGAREG_SEQU_ADDRESS
|
---|
396 | mov ax, 0F02h
|
---|
397 | out dx, ax
|
---|
398 |
|
---|
399 | ; settings for >= 8bpp
|
---|
400 | mov dx, VBE_DISPI_IOPORT_INDEX
|
---|
401 | mov ax, VBE_DISPI_INDEX_BPP
|
---|
402 | out_dx_ax
|
---|
403 | mov dx, VBE_DISPI_IOPORT_DATA
|
---|
404 | in_ax_dx
|
---|
405 | cmp al, 08
|
---|
406 | jb vga_compat_end
|
---|
407 | mov dx, VGAREG_VGA_CRTC_ADDRESS
|
---|
408 | mov al, 14h
|
---|
409 | out dx, al
|
---|
410 | mov dx, VGAREG_VGA_CRTC_DATA
|
---|
411 | in al, dx
|
---|
412 | or al, 40h
|
---|
413 | out dx, al
|
---|
414 | mov dx, VGAREG_ACTL_RESET
|
---|
415 | in al, dx
|
---|
416 | mov dx, VGAREG_ACTL_ADDRESS
|
---|
417 | mov al, 10h
|
---|
418 | out dx, al
|
---|
419 | mov dx, VGAREG_ACTL_READ_DATA
|
---|
420 | in al, dx
|
---|
421 | or al, 40h
|
---|
422 | mov dx, VGAREG_ACTL_ADDRESS
|
---|
423 | out dx, al
|
---|
424 | mov al, 20h
|
---|
425 | out dx, al
|
---|
426 | mov dx, VGAREG_SEQU_ADDRESS
|
---|
427 | mov al, 04
|
---|
428 | out dx, al
|
---|
429 | mov dx, VGAREG_SEQU_DATA
|
---|
430 | in al, dx
|
---|
431 | or al, 08
|
---|
432 | out dx, al
|
---|
433 | mov dx, VGAREG_GRDC_ADDRESS
|
---|
434 | mov al, 05
|
---|
435 | out dx, al
|
---|
436 | mov dx, VGAREG_GRDC_DATA
|
---|
437 | in al, dx
|
---|
438 | and al, 9Fh
|
---|
439 | or al, 40h
|
---|
440 | out dx, al
|
---|
441 |
|
---|
442 | vga_compat_end:
|
---|
443 | pop dx
|
---|
444 | pop ax
|
---|
445 |
|
---|
446 |
|
---|
447 | ; Has VBE display - Returns true if VBE display detected
|
---|
448 |
|
---|
449 | _vbe_has_vbe_display:
|
---|
450 | push ds
|
---|
451 | push bx
|
---|
452 | mov ax, BIOSMEM_SEG
|
---|
453 | mov ds, ax
|
---|
454 | mov bx, BIOSMEM_VBE_FLAG
|
---|
455 | mov al, [bx]
|
---|
456 | and al, 01
|
---|
457 | xor ah, ah
|
---|
458 | pop bx
|
---|
459 | pop ds
|
---|
460 | ret
|
---|
461 |
|
---|
462 |
|
---|
463 | ; Function 03h - Return Current VBE Mode
|
---|
464 | ;
|
---|
465 | ; Input:
|
---|
466 | ; AX = 4F03h
|
---|
467 | ; Output:
|
---|
468 | ; AX = VBE Return Status
|
---|
469 | ; BX = Current VBE Mode
|
---|
470 | ;
|
---|
471 | ;
|
---|
472 | vbe_biosfn_return_current_mode:
|
---|
473 | push ds
|
---|
474 | mov ax, BIOSMEM_SEG
|
---|
475 | mov ds, ax
|
---|
476 | call dispi_get_enable
|
---|
477 | and ax, VBE_DISPI_ENABLED
|
---|
478 | jz no_vbe_mode
|
---|
479 | mov bx, BIOSMEM_VBE_MODE
|
---|
480 | mov ax, [bx]
|
---|
481 | mov bx, ax
|
---|
482 | jnz vbe_03_ok
|
---|
483 | no_vbe_mode:
|
---|
484 | mov bx, BIOSMEM_CURRENT_MODE
|
---|
485 | mov al, [bx]
|
---|
486 | mov bl, al
|
---|
487 | xor bh, bh
|
---|
488 | vbe_03_ok:
|
---|
489 | mov ax, 004Fh
|
---|
490 | pop ds
|
---|
491 | ret
|
---|
492 |
|
---|
493 |
|
---|
494 | ; Function 05h - Display Window Control
|
---|
495 | ;
|
---|
496 | ; Input:
|
---|
497 | ; AX = 4F05h
|
---|
498 | ; (16-bit) BH = 00h Set memory window
|
---|
499 | ; = 01h Get memory window
|
---|
500 | ; BL = Window number
|
---|
501 | ; = 00h Window A
|
---|
502 | ; = 01h Window B
|
---|
503 | ; DX = Window number in video memory in window
|
---|
504 | ; granularity units (Set Memory Window only)
|
---|
505 | ; Note:
|
---|
506 | ; If this function is called while in a linear frame buffer mode,
|
---|
507 | ; this function must fail with completion code AH=03h
|
---|
508 | ;
|
---|
509 | ; Output:
|
---|
510 | ; AX = VBE Return Status
|
---|
511 | ; DX = Window number in window granularity units
|
---|
512 | ; (Get Memory Window only)
|
---|
513 |
|
---|
514 | vbe_biosfn_display_window_control:
|
---|
515 | cmp bl, 0
|
---|
516 | jne vbe_05_failed
|
---|
517 | cmp bh, 1
|
---|
518 | je get_display_window
|
---|
519 | jb set_display_window
|
---|
520 | mov ax, 0100h
|
---|
521 | ret
|
---|
522 | set_display_window:
|
---|
523 | mov ax, dx
|
---|
524 | call dispi_set_bank_
|
---|
525 | call dispi_get_bank
|
---|
526 | cmp ax, dx
|
---|
527 | jne vbe_05_failed
|
---|
528 | mov ax, 004Fh
|
---|
529 | ret
|
---|
530 | get_display_window:
|
---|
531 | call dispi_get_bank
|
---|
532 | mov dx, ax
|
---|
533 | mov ax, 004Fh
|
---|
534 | ret
|
---|
535 | vbe_05_failed:
|
---|
536 | mov ax, 014Fh
|
---|
537 | ret
|
---|
538 |
|
---|
539 |
|
---|
540 | ; Function 07h - Set/Get Display Start
|
---|
541 | ;
|
---|
542 | ; Input(16-bit):
|
---|
543 | ; AX = 4F07h
|
---|
544 | ; BH = 00h Reserved and must be 00h
|
---|
545 | ; BL = 00h Set Display Start
|
---|
546 | ; = 01h Get Display Start
|
---|
547 | ; = 02h Schedule Display Start (Alternate)
|
---|
548 | ; = 03h Schedule Stereoscopic Display Start
|
---|
549 | ; = 04h Get Scheduled Display Start Status
|
---|
550 | ; = 05h Enable Stereoscopic Mode
|
---|
551 | ; = 06h Disable Stereoscopic Mode
|
---|
552 | ; = 80h Set Display Start during Vertical Retrace
|
---|
553 | ; = 82h Set Display Start during Vertical Retrace (Alternate)
|
---|
554 | ; = 83h Set Stereoscopic Display Start during Vertical Retrace
|
---|
555 | ; ECX = If BL=02h/82h Display Start Address in bytes
|
---|
556 | ; If BL=03h/83h Left Image Start Address in bytes
|
---|
557 | ; EDX = If BL=03h/83h Right Image Start Address in bytes
|
---|
558 | ; CX = If BL=00h/80h First Displayed Pixel In Scan Line
|
---|
559 | ; DX = If BL=00h/80h First Displayed Scan Line
|
---|
560 | ;
|
---|
561 | ; Output:
|
---|
562 | ; AX = VBE Return Status
|
---|
563 | ; BH = If BL=01h Reserved and will be 0
|
---|
564 | ; CX = If BL=01h First Displayed Pixel In Scan Line
|
---|
565 | ; If BL=04h 0 if flip has not occurred, not 0 if it has
|
---|
566 | ; DX = If BL=01h First Displayed Scan Line
|
---|
567 | ;
|
---|
568 | ; Input(32-bit):
|
---|
569 | ; BH = 00h Reserved and must be 00h
|
---|
570 | ; BL = 00h Set Display Start
|
---|
571 | ; = 80h Set Display Start during Vertical Retrace
|
---|
572 | ; CX = Bits 0-15 of display start address
|
---|
573 | ; DX = Bits 16-31 of display start address
|
---|
574 | ; ES = Selector for memory mapped registers
|
---|
575 | ;
|
---|
576 | vbe_biosfn_set_get_display_start:
|
---|
577 | cmp bl, 80h
|
---|
578 | je set_display_start_wait
|
---|
579 | cmp bl, 1
|
---|
580 | je get_display_start
|
---|
581 | jb set_display_start
|
---|
582 | mov ax, 0100h
|
---|
583 | ret
|
---|
584 | set_display_start_wait:
|
---|
585 | call wait_not_vsync
|
---|
586 | call wait_vsync
|
---|
587 | set_display_start:
|
---|
588 | mov ax, cx
|
---|
589 | call dispi_set_x_offset
|
---|
590 | mov ax, dx
|
---|
591 | call dispi_set_y_offset
|
---|
592 | mov ax, 004Fh
|
---|
593 | ret
|
---|
594 | get_display_start:
|
---|
595 | call dispi_get_x_offset
|
---|
596 | mov cx, ax
|
---|
597 | call dispi_get_y_offset
|
---|
598 | mov dx, ax
|
---|
599 | xor bh, bh
|
---|
600 | mov ax, 004Fh
|
---|
601 | ret
|
---|
602 |
|
---|
603 |
|
---|
604 | ; Function 08h - Set/Get Dac Palette Format
|
---|
605 | ;
|
---|
606 | ; Input:
|
---|
607 | ; AX = 4F08h
|
---|
608 | ; BL = 00h set DAC palette width
|
---|
609 | ; = 01h get DAC palette width
|
---|
610 | ; BH = If BL=00h: desired number of bits per primary color
|
---|
611 | ; Output:
|
---|
612 | ; AX = VBE Return Status
|
---|
613 | ; BH = current number of bits per primary color (06h = standard VGA)
|
---|
614 | ;
|
---|
615 | vbe_biosfn_set_get_dac_palette_format:
|
---|
616 | cmp bl, 1
|
---|
617 | je get_dac_palette_format
|
---|
618 | jb set_dac_palette_format
|
---|
619 | mov ax, 0100h
|
---|
620 | ret
|
---|
621 | set_dac_palette_format:
|
---|
622 | call dispi_get_enable
|
---|
623 | cmp bh, 6
|
---|
624 | je set_normal_dac
|
---|
625 | cmp bh, 8
|
---|
626 | jne vbe_08_unsupported
|
---|
627 | or ax, VBE_DISPI_8BIT_DAC
|
---|
628 | jnz set_dac_mode
|
---|
629 | set_normal_dac:
|
---|
630 | and ax, NOT VBE_DISPI_8BIT_DAC
|
---|
631 | set_dac_mode:
|
---|
632 | call dispi_set_enable_
|
---|
633 | get_dac_palette_format:
|
---|
634 | mov bh, 6
|
---|
635 | call dispi_get_enable
|
---|
636 | and ax, VBE_DISPI_8BIT_DAC
|
---|
637 | jz vbe_08_ok
|
---|
638 | mov bh, 8
|
---|
639 | vbe_08_ok:
|
---|
640 | mov ax, 004Fh
|
---|
641 | ret
|
---|
642 | vbe_08_unsupported:
|
---|
643 | mov ax, 014Fh
|
---|
644 | ret
|
---|
645 |
|
---|
646 |
|
---|
647 | ; Function 09h - Set/Get Palette Data
|
---|
648 | ;
|
---|
649 | ; Input:
|
---|
650 | ; AX = 4F09h
|
---|
651 | ; (16-bit) BL = 00h Set palette data
|
---|
652 | ; = 01h Get palette data
|
---|
653 | ; = 02h Set secondary palette data
|
---|
654 | ; = 03h Get secondary palette data
|
---|
655 | ; = 80h Set palette data during VRetrace
|
---|
656 | ; CX = Number of entries to update (<= 256)
|
---|
657 | ; DX = First entry to update
|
---|
658 | ; ES:DI = Table of palette values
|
---|
659 | ; Output:
|
---|
660 | ; AX = VBE Return Status
|
---|
661 | ;
|
---|
662 | ; Notes:
|
---|
663 | ; Secondary palette support is a "future extension".
|
---|
664 | ; Attempts to set/get it should return status 02h.
|
---|
665 | ;
|
---|
666 | ; In VBE 3.0, reading palette data is optional and
|
---|
667 | ; subfunctions 01h and 03h may return failure.
|
---|
668 | ;
|
---|
669 | ; The format of palette entries is as follows:
|
---|
670 | ;
|
---|
671 | ; PaletteEntry struc
|
---|
672 | ; Blue db ? ; Blue channel value (6 or 8 bits)
|
---|
673 | ; Green db ? ; Green channel value (6 or 8 bits)
|
---|
674 | ; Red db ? ; Red channel value (6 or 8 bits)
|
---|
675 | ; Padding db ? ; DWORD alignment byte (unused)
|
---|
676 | ; PaletteEntry ends
|
---|
677 | ;
|
---|
678 | ; Most applications use VGA DAC registers directly to
|
---|
679 | ; set/get palette in VBE modes. However, subfn 4F09h is
|
---|
680 | ; required for NonVGA controllers (eg. XGA).
|
---|
681 | ;
|
---|
682 | vbe_biosfn_set_get_palette_data:
|
---|
683 | test bl, bl
|
---|
684 | jz set_palette_data
|
---|
685 | cmp bl, 01
|
---|
686 | je get_palette_data
|
---|
687 | cmp bl, 03
|
---|
688 | jbe vbe_09_nohw
|
---|
689 | cmp bl, 80h
|
---|
690 | jne vbe_09_unsupported
|
---|
691 | if 0
|
---|
692 | ; this is where we could wait for vertical retrace
|
---|
693 | endif
|
---|
694 | set_palette_data:
|
---|
695 | DO_pushad
|
---|
696 | push ds
|
---|
697 | push es
|
---|
698 | pop ds
|
---|
699 | mov al, dl
|
---|
700 | mov dx, VGAREG_DAC_WRITE_ADDRESS
|
---|
701 | out dx, al
|
---|
702 | inc dx
|
---|
703 | mov si, di
|
---|
704 | set_pal_loop:
|
---|
705 | if VBOX_BIOS_CPU ge 80386
|
---|
706 | lodsd
|
---|
707 | ror eax, 16
|
---|
708 | out dx, al
|
---|
709 | rol eax, 8
|
---|
710 | out dx, al
|
---|
711 | rol eax, 8
|
---|
712 | out dx, al
|
---|
713 | else
|
---|
714 | lodsw
|
---|
715 | mov bx, ax
|
---|
716 | lodsw
|
---|
717 | out dx, al
|
---|
718 | mov al, bh
|
---|
719 | out dx, al
|
---|
720 | mov al, bl
|
---|
721 | out dx, al
|
---|
722 | endif
|
---|
723 | loop set_pal_loop
|
---|
724 | pop ds
|
---|
725 | DO_popad
|
---|
726 | vbe_09_ok:
|
---|
727 | mov ax, 004Fh
|
---|
728 | ret
|
---|
729 |
|
---|
730 | get_palette_data:
|
---|
731 | DO_pushad
|
---|
732 | mov al, dl
|
---|
733 | mov dx, VGAREG_DAC_READ_ADDRESS
|
---|
734 | out dx, al
|
---|
735 | add dl, 2
|
---|
736 | if VBOX_BIOS_CPU ge 80386
|
---|
737 | get_pal_loop:
|
---|
738 | xor eax, eax
|
---|
739 | in al, dx
|
---|
740 | shl eax, 8
|
---|
741 | in al, dx
|
---|
742 | shl eax, 8
|
---|
743 | in al, dx
|
---|
744 | stosd
|
---|
745 | else
|
---|
746 | xor bx, bx
|
---|
747 | get_pal_loop:
|
---|
748 | in al, dx
|
---|
749 | mov bl, al
|
---|
750 | in al, dx
|
---|
751 | mov ah, al
|
---|
752 | in al, dx
|
---|
753 | stosw
|
---|
754 | mov ax, bx
|
---|
755 | stosw
|
---|
756 | endif
|
---|
757 | loop get_pal_loop
|
---|
758 | DO_popad
|
---|
759 | jmp vbe_09_ok
|
---|
760 |
|
---|
761 | vbe_09_unsupported:
|
---|
762 | mov ax, 014Fh
|
---|
763 | ret
|
---|
764 | vbe_09_nohw:
|
---|
765 | mov ax, 024Fh
|
---|
766 | ret
|
---|
767 |
|
---|
768 |
|
---|
769 | ; Function 0Ah - Return VBE Protected Mode Interface
|
---|
770 | ;
|
---|
771 | ; Input: AX = 4F0Ah VBE 2.0 Protected Mode Interface
|
---|
772 | ; BL = 00h Return protected mode table
|
---|
773 | ; Output: AX = Status
|
---|
774 | ; ES = Real Mode Segment of Table
|
---|
775 | ; DI = Offset of Table
|
---|
776 | ; CX = Length of Table including protected mode code
|
---|
777 | ; (for copying purposes)
|
---|
778 | ;
|
---|
779 | vbe_biosfn_return_protected_mode_interface:
|
---|
780 | test bl, bl
|
---|
781 | jnz _fail
|
---|
782 | mov di, 0C000h
|
---|
783 | mov es, di
|
---|
784 | mov di, offset vesa_pm_start
|
---|
785 | mov cx, vesa_pm_end - vesa_pm_start
|
---|
786 | mov ax, 004Fh
|
---|
787 | ret
|
---|
788 | _fail:
|
---|
789 | mov ax, 014fh
|
---|
790 | ret
|
---|
791 |
|
---|
792 | VGAROM ends
|
---|
793 |
|
---|
794 | ;;
|
---|
795 | ;; 32-bit VBE interface
|
---|
796 | ;;
|
---|
797 |
|
---|
798 | .386
|
---|
799 |
|
---|
800 | public vesa_pm_start
|
---|
801 | public vesa_pm_end
|
---|
802 |
|
---|
803 | VBE32 segment public use32 'CODE'
|
---|
804 |
|
---|
805 | align 2
|
---|
806 |
|
---|
807 | vesa_pm_start:
|
---|
808 | dw vesa_pm_set_window - vesa_pm_start
|
---|
809 | dw vesa_pm_set_display_start - vesa_pm_start
|
---|
810 | dw vesa_pm_unimplemented - vesa_pm_start
|
---|
811 | dw vesa_pm_io_ports_table - vesa_pm_start
|
---|
812 | vesa_pm_io_ports_table:
|
---|
813 | dw VBE_DISPI_IOPORT_INDEX
|
---|
814 | dw VBE_DISPI_IOPORT_INDEX + 1
|
---|
815 | dw VBE_DISPI_IOPORT_DATA
|
---|
816 | dw VBE_DISPI_IOPORT_DATA + 1
|
---|
817 | dw 3B6h
|
---|
818 | dw 3B7h
|
---|
819 | dw 0FFFFh
|
---|
820 | dw 0FFFFh
|
---|
821 |
|
---|
822 | vesa_pm_set_window:
|
---|
823 | cmp bx, 0
|
---|
824 | je vesa_pm_set_display_window1
|
---|
825 | mov ax, 0100h
|
---|
826 | ret
|
---|
827 | vesa_pm_set_display_window1:
|
---|
828 | mov ax, dx
|
---|
829 | push dx
|
---|
830 | push ax
|
---|
831 | mov dx, VBE_DISPI_IOPORT_INDEX
|
---|
832 | mov ax, VBE_DISPI_INDEX_BANK
|
---|
833 | out dx, ax
|
---|
834 | pop ax
|
---|
835 | mov dx, VBE_DISPI_IOPORT_DATA
|
---|
836 | out dx, ax
|
---|
837 | in ax, dx
|
---|
838 | pop dx
|
---|
839 | cmp dx, ax
|
---|
840 | jne illegal_window
|
---|
841 | mov ax, 004Fh
|
---|
842 | ret
|
---|
843 | illegal_window:
|
---|
844 | mov ax, 014Fh
|
---|
845 | ret
|
---|
846 | vesa_pm_set_display_start:
|
---|
847 | cmp bl, 80h
|
---|
848 | je vesa_pm_set_display_start1_wait
|
---|
849 | cmp bl, 00
|
---|
850 | je vesa_pm_set_display_start1
|
---|
851 | mov ax, 0100h
|
---|
852 | ret
|
---|
853 | vesa_pm_set_display_start1_wait:
|
---|
854 | push edx
|
---|
855 | mov dx, 03DAh ; @todo: use symbolic constant
|
---|
856 | wnv_loop_32:
|
---|
857 | in al, dx
|
---|
858 | test al, 8
|
---|
859 | jnz wnv_loop_32
|
---|
860 | wv_loop_32:
|
---|
861 | in al, dx
|
---|
862 | test al, 8
|
---|
863 | jz wv_loop_32
|
---|
864 | pop edx
|
---|
865 | vesa_pm_set_display_start1:
|
---|
866 | ; convert offset to (X, Y) coordinate
|
---|
867 | ; (would be simpler to change Bochs VBE API...)
|
---|
868 | push eax
|
---|
869 | push ecx
|
---|
870 | push edx
|
---|
871 | push esi
|
---|
872 | push edi
|
---|
873 | shl edx, 16
|
---|
874 | and ecx, 0FFFFh
|
---|
875 | or ecx, edx
|
---|
876 | shl ecx, 2
|
---|
877 | mov eax, ecx
|
---|
878 | push eax
|
---|
879 | mov dx, VBE_DISPI_IOPORT_INDEX
|
---|
880 | mov ax, VBE_DISPI_INDEX_VIRT_WIDTH
|
---|
881 | out dx, ax
|
---|
882 | mov dx, VBE_DISPI_IOPORT_DATA
|
---|
883 | in ax, dx
|
---|
884 | movzx ecx, ax
|
---|
885 | mov dx, VBE_DISPI_IOPORT_INDEX
|
---|
886 | mov ax, VBE_DISPI_INDEX_BPP
|
---|
887 | out dx, ax
|
---|
888 | mov dx, VBE_DISPI_IOPORT_DATA
|
---|
889 | in ax, dx
|
---|
890 | movzx esi, ax
|
---|
891 | pop eax
|
---|
892 |
|
---|
893 | cmp esi, 4
|
---|
894 | jz bpp4_mode
|
---|
895 | add esi, 7
|
---|
896 | shr esi, 3
|
---|
897 | imul ecx, esi
|
---|
898 | xor edx, edx
|
---|
899 | div ecx
|
---|
900 | mov edi, eax
|
---|
901 | mov eax, edx
|
---|
902 | xor edx, edx
|
---|
903 | div esi
|
---|
904 | jmp set_xy_regs
|
---|
905 |
|
---|
906 | bpp4_mode:
|
---|
907 | shr ecx, 1
|
---|
908 | xor edx, edx
|
---|
909 | div ecx
|
---|
910 | mov edi, eax
|
---|
911 | mov eax, edx
|
---|
912 | shl eax, 1
|
---|
913 |
|
---|
914 | set_xy_regs:
|
---|
915 | push dx
|
---|
916 | push ax
|
---|
917 | mov dx, VBE_DISPI_IOPORT_INDEX
|
---|
918 | mov ax, VBE_DISPI_INDEX_X_OFFSET
|
---|
919 | out dx, ax
|
---|
920 | pop ax
|
---|
921 | mov dx, VBE_DISPI_IOPORT_DATA
|
---|
922 | out dx, ax
|
---|
923 | pop dx
|
---|
924 |
|
---|
925 | mov ax, di
|
---|
926 | push dx
|
---|
927 | push ax
|
---|
928 | mov dx, VBE_DISPI_IOPORT_INDEX
|
---|
929 | mov ax, VBE_DISPI_INDEX_Y_OFFSET
|
---|
930 | out dx, ax
|
---|
931 | pop ax
|
---|
932 | mov dx, VBE_DISPI_IOPORT_DATA
|
---|
933 | out dx, ax
|
---|
934 | pop dx
|
---|
935 |
|
---|
936 | pop edi
|
---|
937 | pop esi
|
---|
938 | pop edx
|
---|
939 | pop ecx
|
---|
940 | pop eax
|
---|
941 | mov ax, 004fh
|
---|
942 | ret
|
---|
943 |
|
---|
944 | vesa_pm_unimplemented:
|
---|
945 | mov ax, 014Fh
|
---|
946 | ret
|
---|
947 | vesa_pm_end:
|
---|
948 |
|
---|
949 | VBE32 ends
|
---|
950 |
|
---|
951 | end
|
---|