VirtualBox

source: vbox/trunk/src/VBox/Devices/Graphics/BIOS-new/vberom.asm@ 43152

Last change on this file since 43152 was 43152, checked in by vboxsync, 12 years ago

VGABIOS: Allow building with DEBUG_VGA again.

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