VirtualBox

source: vbox/trunk/src/VBox/Devices/Graphics/BIOS/vberom.asm@ 65919

Last change on this file since 65919 was 63617, checked in by vboxsync, 8 years ago

VGA BIOS: Fixed 4bpp scanline calculation, see bugref:8558.

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

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette