1 // ============================================================================================
3 // Copyright (C) 2002 Jeroen Janssen
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.
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.
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
19 // ============================================================================================
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.
24 // ============================================================================================
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
29 // ============================================================================================
34 // disable VESA/VBE2 check in vbe info
35 //#define VBE2_NO_VESA_CHECK
39 #include "vbetables.h"
41 #define VBE_TOTAL_VIDEO_MEMORY_DIV_64K (VBE_DISPI_TOTAL_VIDEO_MEMORY_MB*1024/64)
43 // The current OEM Software Revision of this VBE Bios
44 #define VBE_OEM_SOFTWARE_REV 0x0002;
46 extern char vbebios_copyright
;
47 extern char vbebios_vendor_name
;
48 extern char vbebios_product_name
;
49 extern char vbebios_product_revision
;
52 // FIXME: 'merge' these (c) etc strings with the vgabios.c strings?
54 .ascii
"Bochs/Plex86 VBE(C) 2003 http://savannah.nongnu.org/projects/vgabios/"
58 .ascii
"Bochs/Plex86 Developers"
61 _vbebios_product_name
:
62 .ascii
"Bochs/Plex86 VBE Adapter"
65 _vbebios_product_revision
:
70 .ascii
"Bochs VBE Display Adapter enabled"
75 _no_vbebios_info_string
:
76 .ascii
"NO Bochs VBE Support available!"
81 #if defined(USE_BX_INFO) || defined(DEBUG)
83 .ascii
"VBE Bios $Id$"
89 dw vesa_pm_set_window
- vesa_pm_start
90 dw vesa_pm_set_display_start
- vesa_pm_start
91 dw vesa_pm_unimplemented
- vesa_pm_start
92 dw vesa_pm_io_ports_table
- vesa_pm_start
93 vesa_pm_io_ports_table
:
94 dw VBE_DISPI_IOPORT_INDEX
95 dw VBE_DISPI_IOPORT_INDEX
+ 1
96 dw VBE_DISPI_IOPORT_DATA
97 dw VBE_DISPI_IOPORT_DATA
+ 1
104 je vesa_pm_set_display_window1
107 vesa_pm_set_display_window1
:
111 mov dx
, # VBE_DISPI_IOPORT_INDEX
112 mov ax
, # VBE_DISPI_INDEX_BANK
115 mov dx
, # VBE_DISPI_IOPORT_DATA
127 vesa_pm_set_display_start
:
129 je vesa_pm_set_display_start1
131 je vesa_pm_set_display_start1
134 vesa_pm_set_display_start1
:
135 ; convert offset
to (X
, Y
) coordinate
136 ; (would be simpler to change Bochs VBE API
...)
149 mov dx
, # VBE_DISPI_IOPORT_INDEX
150 mov ax
, # VBE_DISPI_INDEX_VIRT_WIDTH
152 mov dx
, # VBE_DISPI_IOPORT_DATA
156 mov dx
, # VBE_DISPI_IOPORT_INDEX
157 mov ax
, # VBE_DISPI_INDEX_BPP
159 mov dx
, # VBE_DISPI_IOPORT_DATA
188 mov dx
, # VBE_DISPI_IOPORT_INDEX
189 mov ax
, # VBE_DISPI_INDEX_X_OFFSET
192 mov dx
, # VBE_DISPI_IOPORT_DATA
199 mov dx
, # VBE_DISPI_IOPORT_INDEX
200 mov ax
, # VBE_DISPI_INDEX_Y_OFFSET
203 mov dx
, # VBE_DISPI_IOPORT_DATA
215 vesa_pm_unimplemented
:
221 ; DISPI ioport functions
225 mov dx
, # VBE_DISPI_IOPORT_INDEX
226 mov ax
, # VBE_DISPI_INDEX_ID
228 mov dx
, # VBE_DISPI_IOPORT_DATA
236 mov dx
, # VBE_DISPI_IOPORT_INDEX
237 mov ax
, # VBE_DISPI_INDEX_ID
240 mov dx
, # VBE_DISPI_IOPORT_DATA
246 static void dispi_set_xres(xres
)
255 mov dx
, # VBE_DISPI_IOPORT_INDEX
256 mov ax
, # VBE_DISPI_INDEX_XRES
258 mov dx
, # VBE_DISPI_IOPORT_DATA
268 static void dispi_set_yres(yres
)
271 outw(VBE_DISPI_IOPORT_INDEX
,VBE_DISPI_INDEX_YRES
);
272 outw(VBE_DISPI_IOPORT_DATA
,yres
);
275 static void dispi_set_bpp(bpp
)
278 outw(VBE_DISPI_IOPORT_INDEX
,VBE_DISPI_INDEX_BPP
);
279 outw(VBE_DISPI_IOPORT_DATA
,bpp
);
283 ; AL
= bits per pixel
/ AH
= bytes per pixel
286 mov dx
, # VBE_DISPI_IOPORT_INDEX
287 mov ax
, # VBE_DISPI_INDEX_BPP
289 mov dx
, # VBE_DISPI_IOPORT_DATA
300 ; get display capabilities
305 call dispi_get_enable
307 or ax
, # VBE_DISPI_GETCAPS
308 call _dispi_set_enable
309 mov dx
, # VBE_DISPI_IOPORT_INDEX
310 mov ax
, # VBE_DISPI_INDEX_XRES
312 mov dx
, # VBE_DISPI_IOPORT_DATA
316 call _dispi_set_enable
325 call dispi_get_enable
327 or ax
, # VBE_DISPI_GETCAPS
328 call _dispi_set_enable
329 mov dx
, # VBE_DISPI_IOPORT_INDEX
330 mov ax
, # VBE_DISPI_INDEX_BPP
332 mov dx
, # VBE_DISPI_IOPORT_DATA
336 call _dispi_set_enable
345 mov dx
, # VBE_DISPI_IOPORT_INDEX
346 mov ax
, # VBE_DISPI_INDEX_ENABLE
349 mov dx
, # VBE_DISPI_IOPORT_DATA
356 mov dx
, # VBE_DISPI_IOPORT_INDEX
357 mov ax
, # VBE_DISPI_INDEX_ENABLE
359 mov dx
, # VBE_DISPI_IOPORT_DATA
367 mov dx
, # VBE_DISPI_IOPORT_INDEX
368 mov ax
, # VBE_DISPI_INDEX_BANK
371 mov dx
, # VBE_DISPI_IOPORT_DATA
378 mov dx
, # VBE_DISPI_IOPORT_INDEX
379 mov ax
, # VBE_DISPI_INDEX_BANK
381 mov dx
, # VBE_DISPI_IOPORT_DATA
387 static void dispi_set_bank_farcall()
391 je dispi_set_bank_farcall_get
393 jnz dispi_set_bank_farcall_error
397 mov ax
,# VBE_DISPI_INDEX_BANK
398 mov dx
,# VBE_DISPI_IOPORT_INDEX
401 mov dx
,# VBE_DISPI_IOPORT_DATA
406 jne dispi_set_bank_farcall_error
409 dispi_set_bank_farcall_get
:
410 mov ax
,# VBE_DISPI_INDEX_BANK
411 mov dx
,# VBE_DISPI_IOPORT_INDEX
413 mov dx
,# VBE_DISPI_IOPORT_DATA
417 dispi_set_bank_farcall_error
:
427 mov dx
, # VBE_DISPI_IOPORT_INDEX
428 mov ax
, # VBE_DISPI_INDEX_X_OFFSET
431 mov dx
, # VBE_DISPI_IOPORT_DATA
438 mov dx
, # VBE_DISPI_IOPORT_INDEX
439 mov ax
, # VBE_DISPI_INDEX_X_OFFSET
441 mov dx
, # VBE_DISPI_IOPORT_DATA
449 mov dx
, # VBE_DISPI_IOPORT_INDEX
450 mov ax
, # VBE_DISPI_INDEX_Y_OFFSET
453 mov dx
, # VBE_DISPI_IOPORT_DATA
460 mov dx
, # VBE_DISPI_IOPORT_INDEX
461 mov ax
, # VBE_DISPI_INDEX_Y_OFFSET
463 mov dx
, # VBE_DISPI_IOPORT_DATA
479 mov dx
, # VGAREG_VGA_CRTC_ADDRESS
488 dispi_set_virt_width
:
489 call vga_set_virt_width
492 mov dx
, # VBE_DISPI_IOPORT_INDEX
493 mov ax
, # VBE_DISPI_INDEX_VIRT_WIDTH
496 mov dx
, # VBE_DISPI_IOPORT_DATA
501 dispi_get_virt_width
:
503 mov dx
, # VBE_DISPI_IOPORT_INDEX
504 mov ax
, # VBE_DISPI_INDEX_VIRT_WIDTH
506 mov dx
, # VBE_DISPI_IOPORT_DATA
511 dispi_get_virt_height
:
513 mov dx
, # VBE_DISPI_IOPORT_INDEX
514 mov ax
, # VBE_DISPI_INDEX_VIRT_HEIGHT
516 mov dx
, # VBE_DISPI_IOPORT_DATA
525 ; set CRT X resolution
526 mov dx
, # VBE_DISPI_IOPORT_INDEX
527 mov ax
, # VBE_DISPI_INDEX_XRES
529 mov dx
, # VBE_DISPI_IOPORT_DATA
532 mov dx
, # VGAREG_VGA_CRTC_ADDRESS
543 call vga_set_virt_width
545 ; set CRT Y resolution
546 mov dx
, # VBE_DISPI_IOPORT_INDEX
547 mov ax
, # VBE_DISPI_INDEX_YRES
549 mov dx
, # VBE_DISPI_IOPORT_DATA
553 mov dx
, # VGAREG_VGA_CRTC_ADDRESS
574 mov dx
, # VGAREG_VGA_CRTC_ADDRESS
579 mov dx
, # VGAREG_VGA_CRTC_DATA
583 mov dx
, # VGAREG_ACTL_RESET
585 mov dx
, # VGAREG_ACTL_ADDRESS
588 mov dx
, # VGAREG_ACTL_READ_DATA
591 mov dx
, # VGAREG_ACTL_ADDRESS
595 mov dx
, # VGAREG_GRDC_ADDRESS
598 mov dx
, # VGAREG_SEQU_ADDRESS
602 ; settings
for >= 8bpp
603 mov dx
, # VBE_DISPI_IOPORT_INDEX
604 mov ax
, # VBE_DISPI_INDEX_BPP
606 mov dx
, # VBE_DISPI_IOPORT_DATA
610 mov dx
, # VGAREG_VGA_CRTC_ADDRESS
613 mov dx
, # VGAREG_VGA_CRTC_DATA
617 mov dx
, # VGAREG_ACTL_RESET
619 mov dx
, # VGAREG_ACTL_ADDRESS
622 mov dx
, # VGAREG_ACTL_READ_DATA
625 mov dx
, # VGAREG_ACTL_ADDRESS
629 mov dx
, # VGAREG_SEQU_ADDRESS
632 mov dx
, # VGAREG_SEQU_DATA
636 mov dx
, # VGAREG_GRDC_ADDRESS
639 mov dx
, # VGAREG_GRDC_DATA
651 // ModeInfo helper function
652 static ModeInfoListItem
* mode_info_find_mode(mode
, using_lfb
)
653 Bit16u mode
; Boolean using_lfb
;
655 ModeInfoListItem
*cur_info
=&mode_info_list
;
657 while (cur_info
->mode
!= VBE_VESA_MODE_END_OF_LIST
)
659 if (cur_info
->mode
== mode
)
665 else if (cur_info
->info
.ModeAttributes
& VBE_MODE_ATTRIBUTE_LINEAR_FRAME_BUFFER_MODE
)
685 ; Has VBE display
- Returns
true if VBE display detected
687 _vbe_has_vbe_display
:
690 mov ax
, # BIOSMEM_SEG
692 mov bx
, # BIOSMEM_VBE_FLAG
700 ; VBE Init
- Initialise the Vesa Bios Extension Code
701 ; This function does a sanity check on the host side display code interface
.
704 mov ax
, # VBE_DISPI_ID0
707 cmp ax
, # VBE_DISPI_ID0
711 mov ax
, # BIOSMEM_SEG
713 mov bx
, # BIOSMEM_VBE_FLAG
718 mov ax
, # VBE_DISPI_ID4
721 #if defined(USE_BX_INFO) || defined(DEBUG)
722 mov bx
, #msg_vbe_init
730 ; VBE Display Info
- Display information on screen about the VBE
733 call _vbe_has_vbe_display
738 mov si
, #_vbebios_info_string
743 mov si
, #_no_vbebios_info_string
747 /** Function 00h - Return VBE Controller Information
751 * ES:DI = Pointer to buffer in which to place VbeInfoBlock structure
752 * (VbeSignature should be VBE2 when VBE 2.0 information is desired and
753 * the info block is 512 bytes in size)
755 * AX = VBE Return Status
758 void vbe_biosfn_return_controller_information(AX
, ES
, DI
)
759 Bit16u
*AX
;Bit16u ES
;Bit16u DI
;
762 VbeInfoBlock vbe_info_block
;
768 ModeInfoListItem
*cur_info
=&mode_info_list
;
770 status
= read_word(ss
, AX
);
773 printf("VBE vbe_biosfn_return_vbe_info ES%x DI%x AX%x\n",ES
,DI
,status
);
777 #ifdef VBE2_NO_VESA_CHECK
779 // get vbe_info_block into local variable
780 memcpyb(ss
, &vbe_info_block
, ES
, DI
, sizeof(vbe_info_block
));
782 // check for VBE2 signature
783 if (((vbe_info_block
.VbeSignature
[0] == 'V') &&
784 (vbe_info_block
.VbeSignature
[1] == 'B') &&
785 (vbe_info_block
.VbeSignature
[2] == 'E') &&
786 (vbe_info_block
.VbeSignature
[3] == '2')) ||
788 ((vbe_info_block
.VbeSignature
[0] == 'V') &&
789 (vbe_info_block
.VbeSignature
[1] == 'E') &&
790 (vbe_info_block
.VbeSignature
[2] == 'S') &&
791 (vbe_info_block
.VbeSignature
[3] == 'A')) )
795 printf("VBE correct VESA/VBE2 signature found\n");
801 vbe_info_block
.VbeSignature
[0] = 'V';
802 vbe_info_block
.VbeSignature
[1] = 'E';
803 vbe_info_block
.VbeSignature
[2] = 'S';
804 vbe_info_block
.VbeSignature
[3] = 'A';
806 // VBE Version supported
807 vbe_info_block
.VbeVersion
= 0x0200;
810 vbe_info_block
.OemStringPtr_Seg
= 0xc000;
811 vbe_info_block
.OemStringPtr_Off
= &vbebios_copyright
;
814 vbe_info_block
.Capabilities
[0] = VBE_CAPABILITY_8BIT_DAC
;
815 vbe_info_block
.Capabilities
[1] = 0;
816 vbe_info_block
.Capabilities
[2] = 0;
817 vbe_info_block
.Capabilities
[3] = 0;
819 // VBE Video Mode Pointer (dynamicly generated from the mode_info_list)
820 vbe_info_block
.VideoModePtr_Seg
= ES
;
821 vbe_info_block
.VideoModePtr_Off
= DI
+ 34;
823 // VBE Total Memory (in 64b blocks)
824 vbe_info_block
.TotalMemory
= VBE_TOTAL_VIDEO_MEMORY_DIV_64K
;
829 vbe_info_block
.OemSoftwareRev
= VBE_OEM_SOFTWARE_REV
;
830 vbe_info_block
.OemVendorNamePtr_Seg
= 0xc000;
831 vbe_info_block
.OemVendorNamePtr_Off
= &vbebios_vendor_name
;
832 vbe_info_block
.OemProductNamePtr_Seg
= 0xc000;
833 vbe_info_block
.OemProductNamePtr_Off
= &vbebios_product_name
;
834 vbe_info_block
.OemProductRevPtr_Seg
= 0xc000;
835 vbe_info_block
.OemProductRevPtr_Off
= &vbebios_product_revision
;
837 // copy updates in vbe_info_block back
838 memcpyb(ES
, DI
, ss
, &vbe_info_block
, sizeof(vbe_info_block
));
842 // copy updates in vbe_info_block back (VBE 1.x compatibility)
843 memcpyb(ES
, DI
, ss
, &vbe_info_block
, 256);
848 if ((cur_info
->info
.XResolution
<= dispi_get_max_xres()) &&
849 (cur_info
->info
.BitsPerPixel
<= dispi_get_max_bpp())) {
851 printf("VBE found mode %x => %x\n", cur_info
->mode
,cur_mode
);
853 write_word(ES
, DI
+ cur_ptr
, cur_info
->mode
);
858 printf("VBE mode %x (xres=%x / bpp=%02x) not supported by display\n", cur_info
->mode
,cur_info
->info
.XResolution
,cur_info
->info
.BitsPerPixel
);
862 } while (cur_info
->mode
!= VBE_VESA_MODE_END_OF_LIST
);
864 // Add vesa mode list terminator
865 write_word(ES
, DI
+ cur_ptr
, cur_info
->mode
);
869 write_word(ss
, AX
, result
);
873 /** Function 01h - Return VBE Mode Information
878 * ES:DI = Pointer to buffer in which to place ModeInfoBlock structure
880 * AX = VBE Return Status
883 void vbe_biosfn_return_mode_information(AX
, CX
, ES
, DI
)
884 Bit16u
*AX
;Bit16u CX
; Bit16u ES
;Bit16u DI
;
886 Bit16u result
=0x0100;
889 ModeInfoListItem
*cur_info
;
893 printf("VBE vbe_biosfn_return_mode_information ES%x DI%x CX%x\n",ES
,DI
,CX
);
896 using_lfb
=((CX
& VBE_MODE_LINEAR_FRAME_BUFFER
) == VBE_MODE_LINEAR_FRAME_BUFFER
);
900 cur_info
= mode_info_find_mode(CX
, using_lfb
, &cur_info
);
905 printf("VBE found mode %x\n",CX
);
907 memsetb(ss
, &info
, 0, sizeof(ModeInfoBlock
));
908 memcpyb(ss
, &info
, 0xc000, &(cur_info
->info
), sizeof(ModeInfoBlockCompact
));
910 info
.NumberOfBanks
= 1;
912 if (info
.WinAAttributes
& VBE_WINDOW_ATTRIBUTE_RELOCATABLE
) {
913 info
.WinFuncPtr
= 0xC0000000UL
;
914 *(Bit16u
*)&(info
.WinFuncPtr
) = (Bit16u
)(dispi_set_bank_farcall
);
922 printf("VBE *NOT* found mode %x\n",CX
);
929 // copy updates in mode_info_block back
930 memcpyb(ES
, DI
, ss
, &info
, sizeof(info
));
933 write_word(ss
, AX
, result
);
936 /** Function 02h - Set VBE Mode
940 * BX = Desired Mode to set
941 * ES:DI = Pointer to CRTCInfoBlock structure
943 * AX = VBE Return Status
946 void vbe_biosfn_set_mode(AX
, BX
, ES
, DI
)
947 Bit16u
*AX
;Bit16u BX
; Bit16u ES
;Bit16u DI
;
949 Bit16u ss
= get_SS();
951 ModeInfoListItem
*cur_info
;
956 using_lfb
=((BX
& VBE_MODE_LINEAR_FRAME_BUFFER
) == VBE_MODE_LINEAR_FRAME_BUFFER
);
957 lfb_flag
=using_lfb
?VBE_DISPI_LFB_ENABLED
:0;
958 no_clear
=((BX
& VBE_MODE_PRESERVE_DISPLAY_MEMORY
) == VBE_MODE_PRESERVE_DISPLAY_MEMORY
)?VBE_DISPI_NOCLEARMEM
:0;
962 //result=read_word(ss,AX);
964 // check for non vesa mode
965 if (BX
<VBE_MODE_VESA_DEFINED
)
969 dispi_set_enable(VBE_DISPI_DISABLED
);
970 // call the vgabios in order to set the video mode
971 // this allows for going back to textmode with a VBE call (some applications expect that to work)
974 biosfn_set_video_mode(mode
);
978 cur_info
= mode_info_find_mode(BX
, using_lfb
, &cur_info
);
983 printf("VBE found mode %x, setting:\n", BX
);
984 printf("\txres%x yres%x bpp%x\n",
985 cur_info
->info
.XResolution
,
986 cur_info
->info
.YResolution
,
987 cur_info
->info
.BitsPerPixel
);
990 // first disable current mode (when switching between vesa modi)
991 dispi_set_enable(VBE_DISPI_DISABLED
);
993 if (cur_info
->info
.BitsPerPixel
== 4)
995 biosfn_set_video_mode(0x6a);
998 dispi_set_bpp(cur_info
->info
.BitsPerPixel
);
999 dispi_set_xres(cur_info
->info
.XResolution
);
1000 dispi_set_yres(cur_info
->info
.YResolution
);
1002 dispi_set_enable(VBE_DISPI_ENABLED
| no_clear
| lfb_flag
);
1005 write_word(BIOSMEM_SEG
,BIOSMEM_VBE_MODE
,BX
);
1006 write_byte(BIOSMEM_SEG
,BIOSMEM_VIDEO_CTL
,(0x60 | no_clear
));
1013 printf("VBE *NOT* found mode %x\n" , BX
);
1017 // FIXME: redirect non VBE modi to normal VGA bios operation
1018 // (switch back to VGA mode
1023 write_word(ss
, AX
, result
);
1026 /** Function 03h - Return Current VBE Mode
1031 * AX = VBE Return Status
1032 * BX = Current VBE Mode
1036 vbe_biosfn_return_current_mode
:
1038 mov ax
, # BIOSMEM_SEG
1040 call dispi_get_enable
1041 and ax
, # VBE_DISPI_ENABLED
1043 mov bx
, # BIOSMEM_VBE_MODE
1048 mov bx
, # BIOSMEM_CURRENT_MODE
1059 Bit16u
vbe_biosfn_read_video_state_size()
1064 void vbe_biosfn_save_video_state(ES
, BX
)
1065 Bit16u ES
; Bit16u BX
;
1069 outw(VBE_DISPI_IOPORT_INDEX
,VBE_DISPI_INDEX_ENABLE
);
1070 enable
= inw(VBE_DISPI_IOPORT_DATA
);
1071 write_word(ES
, BX
, enable
);
1073 if (!(enable
& VBE_DISPI_ENABLED
))
1075 for(i
= VBE_DISPI_INDEX_XRES
; i
<= VBE_DISPI_INDEX_Y_OFFSET
; i
++) {
1076 if (i
!= VBE_DISPI_INDEX_ENABLE
) {
1077 outw(VBE_DISPI_IOPORT_INDEX
, i
);
1078 write_word(ES
, BX
, inw(VBE_DISPI_IOPORT_DATA
));
1085 void vbe_biosfn_restore_video_state(ES
, BX
)
1086 Bit16u ES
; Bit16u BX
;
1090 enable
= read_word(ES
, BX
);
1093 if (!(enable
& VBE_DISPI_ENABLED
)) {
1094 outw(VBE_DISPI_IOPORT_INDEX
,VBE_DISPI_INDEX_ENABLE
);
1095 outw(VBE_DISPI_IOPORT_DATA
, enable
);
1097 outw(VBE_DISPI_IOPORT_INDEX
, VBE_DISPI_INDEX_XRES
);
1098 outw(VBE_DISPI_IOPORT_DATA
, read_word(ES
, BX
));
1100 outw(VBE_DISPI_IOPORT_INDEX
, VBE_DISPI_INDEX_YRES
);
1101 outw(VBE_DISPI_IOPORT_DATA
, read_word(ES
, BX
));
1103 outw(VBE_DISPI_IOPORT_INDEX
, VBE_DISPI_INDEX_BPP
);
1104 outw(VBE_DISPI_IOPORT_DATA
, read_word(ES
, BX
));
1106 outw(VBE_DISPI_IOPORT_INDEX
,VBE_DISPI_INDEX_ENABLE
);
1107 outw(VBE_DISPI_IOPORT_DATA
, enable
);
1109 for(i
= VBE_DISPI_INDEX_BANK
; i
<= VBE_DISPI_INDEX_Y_OFFSET
; i
++) {
1110 outw(VBE_DISPI_IOPORT_INDEX
, i
);
1111 outw(VBE_DISPI_IOPORT_DATA
, read_word(ES
, BX
));
1117 /** Function 04h - Save/Restore State
1121 * DL = 00h Return Save/Restore State buffer size
1124 * CX = Requested states
1125 * ES:BX = Pointer to buffer (if DL <> 00h)
1127 * AX = VBE Return Status
1128 * BX = Number of 64-byte blocks to hold the state buffer (if DL=00h)
1131 void vbe_biosfn_save_restore_state(AX
, CX
, DX
, ES
, BX
)
1132 Bit16u
*AX
; Bit16u CX
; Bit16u DX
; Bit16u ES
; Bit16u
*BX
;
1140 val
= biosfn_read_video_state_size2(CX
);
1142 printf("VGA state size=%x\n", val
);
1145 val
+= vbe_biosfn_read_video_state_size();
1146 write_word(ss
, BX
, val
);
1149 val
= read_word(ss
, BX
);
1150 val
= biosfn_save_video_state(CX
, ES
, val
);
1152 printf("VGA save_state offset=%x\n", val
);
1155 vbe_biosfn_save_video_state(ES
, val
);
1158 val
= read_word(ss
, BX
);
1159 val
= biosfn_restore_video_state(CX
, ES
, val
);
1161 printf("VGA restore_state offset=%x\n", val
);
1164 vbe_biosfn_restore_video_state(ES
, val
);
1171 write_word(ss
, AX
, result
);
1174 /** Function 05h - Display Window Control
1178 * (16-bit) BH = 00h Set memory window
1179 * = 01h Get memory window
1180 * BL = Window number
1183 * DX = Window number in video memory in window
1184 * granularity units (Set Memory Window only)
1186 * If this function is called while in a linear frame buffer mode,
1187 * this function must fail with completion code AH=03h
1190 * AX = VBE Return Status
1191 * DX = Window number in window granularity units
1192 * (Get Memory Window only)
1195 vbe_biosfn_display_window_control
:
1199 je get_display_window
1200 jb set_display_window
1205 call _dispi_set_bank
1222 /** Function 06h - Set/Get Logical Scan Line Length
1226 * BL = 00h Set Scan Line Length in Pixels
1227 * = 01h Get Scan Line Length
1228 * = 02h Set Scan Line Length in Bytes
1229 * = 03h Get Maximum Scan Line Length
1230 * CX = If BL=00h Desired Width in Pixels
1231 * If BL=02h Desired Width in Bytes
1232 * (Ignored for Get Functions)
1235 * AX = VBE Return Status
1236 * BX = Bytes Per Scan Line
1237 * CX = Actual Pixels Per Scan Line
1238 * (truncated to nearest complete pixel)
1239 * DX = Maximum Number of Scan Lines
1242 vbe_biosfn_set_get_logical_scan_line_length
:
1245 je get_logical_scan_line_length
1247 je set_logical_scan_line_bytes
1248 jb set_logical_scan_line_pixels
1251 set_logical_scan_line_bytes
:
1264 set_logical_scan_line_pixels
:
1265 call dispi_set_virt_width
1266 get_logical_scan_line_length
:
1270 call dispi_get_virt_width
1279 call dispi_get_virt_height
1286 /** Function 07h - Set/Get Display Start
1290 * BH = 00h Reserved and must be 00h
1291 * BL = 00h Set Display Start
1292 * = 01h Get Display Start
1293 * = 02h Schedule Display Start (Alternate)
1294 * = 03h Schedule Stereoscopic Display Start
1295 * = 04h Get Scheduled Display Start Status
1296 * = 05h Enable Stereoscopic Mode
1297 * = 06h Disable Stereoscopic Mode
1298 * = 80h Set Display Start during Vertical Retrace
1299 * = 82h Set Display Start during Vertical Retrace (Alternate)
1300 * = 83h Set Stereoscopic Display Start during Vertical Retrace
1301 * ECX = If BL=02h/82h Display Start Address in bytes
1302 * If BL=03h/83h Left Image Start Address in bytes
1303 * EDX = If BL=03h/83h Right Image Start Address in bytes
1304 * CX = If BL=00h/80h First Displayed Pixel In Scan Line
1305 * DX = If BL=00h/80h First Displayed Scan Line
1308 * AX = VBE Return Status
1309 * BH = If BL=01h Reserved and will be 0
1310 * CX = If BL=01h First Displayed Pixel In Scan Line
1311 * If BL=04h 0 if flip has not occurred, not 0 if it has
1312 * DX = If BL=01h First Displayed Scan Line
1315 * BH = 00h Reserved and must be 00h
1316 * BL = 00h Set Display Start
1317 * = 80h Set Display Start during Vertical Retrace
1318 * CX = Bits 0-15 of display start address
1319 * DX = Bits 16-31 of display start address
1320 * ES = Selector for memory mapped registers
1323 vbe_biosfn_set_get_display_start
:
1325 je set_display_start
1327 je get_display_start
1328 jb set_display_start
1333 call dispi_set_x_offset
1335 call dispi_set_y_offset
1339 call dispi_get_x_offset
1341 call dispi_get_y_offset
1349 /** Function 08h - Set/Get Dac Palette Format
1353 * BL = 00h set DAC palette width
1354 * = 01h get DAC palette width
1355 * BH = If BL=00h: desired number of bits per primary color
1357 * AX = VBE Return Status
1358 * BH = current number of bits per primary color (06h = standard VGA)
1361 vbe_biosfn_set_get_dac_palette_format
:
1363 je get_dac_palette_format
1364 jb set_dac_palette_format
1367 set_dac_palette_format
:
1368 call dispi_get_enable
1372 jne vbe_08_unsupported
1373 or ax
, # VBE_DISPI_8BIT_DAC
1376 and ax
, #~ VBE_DISPI_8BIT_DAC
1378 call _dispi_set_enable
1379 get_dac_palette_format
:
1381 call dispi_get_enable
1382 and ax
, # VBE_DISPI_8BIT_DAC
1394 /** Function 09h - Set/Get Palette Data
1399 * AX = VBE Return Status
1401 * FIXME: incomplete API description, Input & Output
1403 void vbe_biosfn_set_get_palette_data(AX
)
1407 /** Function 0Ah - Return VBE Protected Mode Interface
1408 * Input: AX = 4F0Ah VBE 2.0 Protected Mode Interface
1409 * BL = 00h Return protected mode table
1412 * Output: AX = Status
1413 * ES = Real Mode Segment of Table
1414 * DI = Offset of Table
1415 * CX = Length of Table including protected mode code
1416 * (for copying purposes)
1419 vbe_biosfn_return_protected_mode_interface
:
1424 mov di
, # vesa_pm_start
1425 mov cx
, # vesa_pm_end