Changeset 5450 in vbox for trunk/src/VBox/Devices/Graphics/BIOS/vbe.c
- Timestamp:
- Oct 23, 2007 7:03:55 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Graphics/BIOS/vbe.c
r3290 r5450 31 31 32 32 // defines available 33 // enable LFB support34 #define VBE_HAVE_LFB35 33 36 34 // disable VESA/VBE2 check in vbe info 37 35 //#define VBE2_NO_VESA_CHECK 38 39 // dynamicly generate a mode_info list40 #define DYN_LIST41 36 42 37 // use bytewise i/o by default (Longhorn issue) … … 50 45 51 46 #include "vbe.h" 52 #include "vbetables.h"53 47 54 48 … … 60 54 extern char vbebios_product_name; 61 55 extern char vbebios_product_revision; 62 63 #ifndef DYN_LIST64 extern Bit16u vbebios_mode_list;65 #endif66 56 67 57 ASM_START … … 104 94 105 95 106 #ifndef DYN_LIST 107 // FIXME: for each new mode add a statement here 108 // at least until dynamic list creation is working 109 _vbebios_mode_list: 110 111 .word VBE_VESA_MODE_640X400X8 112 .word VBE_VESA_MODE_640X480X8 113 .word VBE_VESA_MODE_800X600X4 114 .word VBE_VESA_MODE_800X600X8 115 .word VBE_VESA_MODE_1024X768X8 116 .word VBE_VESA_MODE_640X480X1555 117 .word VBE_VESA_MODE_640X480X565 118 .word VBE_VESA_MODE_640X480X888 119 .word VBE_VESA_MODE_800X600X1555 120 .word VBE_VESA_MODE_800X600X565 121 .word VBE_VESA_MODE_800X600X888 122 .word VBE_VESA_MODE_1024X768X1555 123 .word VBE_VESA_MODE_1024X768X565 124 .word VBE_VESA_MODE_1024X768X888 125 .word VBE_OWN_MODE_640X480X8888 126 .word VBE_OWN_MODE_800X600X8888 127 .word VBE_OWN_MODE_1024X768X8888 128 .word VBE_OWN_MODE_320X200X8 129 .word VBE_VESA_MODE_END_OF_LIST 130 #endif 96 .align 2 97 vesa_pm_start: 98 dw vesa_pm_set_window - vesa_pm_start 99 dw vesa_pm_set_display_start - vesa_pm_start 100 dw vesa_pm_unimplemented - vesa_pm_start 101 dw vesa_pm_io_ports_table - vesa_pm_start 102 vesa_pm_io_ports_table: 103 dw VBE_DISPI_IOPORT_INDEX 104 dw VBE_DISPI_IOPORT_INDEX + 1 105 dw VBE_DISPI_IOPORT_DATA 106 dw VBE_DISPI_IOPORT_DATA + 1 107 dw 0xffff 108 dw 0xffff 109 110 USE32 111 vesa_pm_set_window: 112 cmp bx, #0x00 113 je vesa_pm_set_display_window1 114 mov ax, #0x0100 115 ret 116 vesa_pm_set_display_window1: 117 mov ax, dx 118 push dx 119 push ax 120 mov dx, # VBE_DISPI_IOPORT_INDEX 121 mov ax, # VBE_DISPI_INDEX_BANK 122 out dx, ax 123 pop ax 124 mov dx, # VBE_DISPI_IOPORT_DATA 125 out dx, ax 126 in ax, dx 127 pop dx 128 cmp dx, ax 129 jne illegal_window 130 mov ax, #0x004f 131 ret 132 illegal_window: 133 mov ax, #0x014f 134 ret 135 vesa_pm_set_display_start: 136 cmp bl, #0x80 137 je vesa_pm_set_display_start1 138 cmp bl, #0x00 139 je vesa_pm_set_display_start1 140 mov ax, #0x0100 141 ret 142 vesa_pm_set_display_start1: 143 ; convert offset to (X, Y) coordinate 144 ; (would be simpler to change Bochs VBE API...) 145 push eax 146 push ecx 147 push edx 148 push esi 149 push edi 150 shl edx, #16 151 and ecx, #0xffff 152 or ecx, edx 153 shl ecx, #2 154 mov eax, ecx 155 push eax 156 mov dx, # VBE_DISPI_IOPORT_INDEX 157 mov ax, # VBE_DISPI_INDEX_VIRT_WIDTH 158 out dx, ax 159 mov dx, # VBE_DISPI_IOPORT_DATA 160 in ax, dx 161 movzx ecx, ax 162 mov dx, # VBE_DISPI_IOPORT_INDEX 163 mov ax, # VBE_DISPI_INDEX_BPP 164 out dx, ax 165 mov dx, # VBE_DISPI_IOPORT_DATA 166 in ax, dx 167 movzx esi, ax 168 pop eax 169 170 cmp esi, #4 171 jz bpp4_mode 172 add esi, #7 173 shr esi, #3 174 imul ecx, esi 175 xor edx, edx 176 div ecx 177 mov edi, eax 178 mov eax, edx 179 xor edx, edx 180 div esi 181 jmp set_xy_regs 182 183 bpp4_mode: 184 shr ecx, #1 185 xor edx, edx 186 div ecx 187 mov edi, eax 188 mov eax, edx 189 shl eax, #1 190 191 set_xy_regs: 192 push dx 193 push ax 194 mov dx, # VBE_DISPI_IOPORT_INDEX 195 mov ax, # VBE_DISPI_INDEX_X_OFFSET 196 out dx, ax 197 pop ax 198 mov dx, # VBE_DISPI_IOPORT_DATA 199 out dx, ax 200 pop dx 201 202 mov ax, di 203 push dx 204 push ax 205 mov dx, # VBE_DISPI_IOPORT_INDEX 206 mov ax, # VBE_DISPI_INDEX_Y_OFFSET 207 out dx, ax 208 pop ax 209 mov dx, # VBE_DISPI_IOPORT_DATA 210 out dx, ax 211 pop dx 212 213 pop edi 214 pop esi 215 pop edx 216 pop ecx 217 pop eax 218 mov ax, #0x004f 219 ret 220 221 vesa_pm_unimplemented: 222 mov ax, #0x014f 223 ret 224 USE16 225 vesa_pm_end: 131 226 132 227 ;; Bytewise in/out … … 210 305 out dx, ax 211 306 #endif 212 push ax213 mov dx, #0x03d4214 mov ax, #0x0011215 #ifdef VBE_BYTEWISE_IO216 call out_dx_ax217 #else218 out dx, ax219 #endif220 mov dx, #0x03d4221 pop ax222 push ax223 shr ax, #3224 dec ax225 mov ah, al226 mov al, #0x01227 #ifdef VBE_BYTEWISE_IO228 call out_dx_ax229 #else230 out dx, ax231 #endif232 pop ax233 call vga_set_virt_width234 235 307 pop dx 236 308 pop ax … … 333 405 ret 334 406 407 ; get display capabilities 408 409 _dispi_get_max_xres: 410 push dx 411 push bx 412 call dispi_get_enable 413 mov bx, ax 414 or ax, # VBE_DISPI_GETCAPS 415 call _dispi_set_enable 416 mov dx, # VBE_DISPI_IOPORT_INDEX 417 mov ax, # VBE_DISPI_INDEX_XRES 418 #ifdef VBE_BYTEWISE_IO 419 call out_dx_ax 420 #else 421 out dx, ax 422 #endif 423 mov dx, # VBE_DISPI_IOPORT_DATA 424 #ifdef VBE_BYTEWISE_IO 425 call in_ax_dx 426 #else 427 in ax, dx 428 #endif 429 push ax 430 mov ax, bx 431 call _dispi_set_enable 432 pop ax 433 pop bx 434 pop dx 435 ret 436 335 437 _dispi_get_max_bpp: 336 438 push dx … … 445 547 or bx,bx 446 548 jnz dispi_set_bank_farcall_error 447 push dx 549 mov ax, dx 550 push dx 551 push ax 448 552 mov ax,# VBE_DISPI_INDEX_BANK 449 553 mov dx,# VBE_DISPI_IOPORT_INDEX … … 460 564 out dx,ax 461 565 #endif 566 #ifdef VBE_BYTEWISE_IO 567 call in_ax_dx 568 #else 569 in ax,dx 570 #endif 571 pop dx 572 cmp dx,ax 573 jne dispi_set_bank_farcall_error 574 mov ax, #0x004f 462 575 retf 463 576 dispi_set_bank_farcall_get: … … 568 681 cmp al, #0x04 569 682 ja set_width_svga 570 shr bx, # 2683 shr bx, #1 571 684 set_width_svga: 572 shr bx, # 2573 mov dx, # 0x03d4685 shr bx, #3 686 mov dx, # VGAREG_VGA_CRTC_ADDRESS 574 687 mov ah, bl 575 688 mov al, #0x13 … … 640 753 pop dx 641 754 ret 755 756 _vga_compat_setup: 757 push ax 758 push dx 759 760 ; set CRT X resolution 761 mov dx, # VBE_DISPI_IOPORT_INDEX 762 mov ax, # VBE_DISPI_INDEX_XRES 763 #ifdef VBE_BYTEWISE_IO 764 call out_dx_ax 765 #else 766 out dx, ax 767 #endif 768 mov dx, # VBE_DISPI_IOPORT_DATA 769 #ifdef VBE_BYTEWISE_IO 770 call in_ax_dx 771 #else 772 in ax, dx 773 #endif 774 push ax 775 mov dx, # VGAREG_VGA_CRTC_ADDRESS 776 mov ax, #0x0011 777 #ifdef VBE_BYTEWISE_IO 778 call out_dx_ax 779 #else 780 out dx, ax 781 #endif 782 pop ax 783 push ax 784 shr ax, #3 785 dec ax 786 mov ah, al 787 mov al, #0x01 788 #ifdef VBE_BYTEWISE_IO 789 call out_dx_ax 790 #else 791 out dx, ax 792 #endif 793 pop ax 794 call vga_set_virt_width 795 796 ; set CRT Y resolution 797 mov dx, # VBE_DISPI_IOPORT_INDEX 798 mov ax, # VBE_DISPI_INDEX_YRES 799 #ifdef VBE_BYTEWISE_IO 800 call out_dx_ax 801 #else 802 out dx, ax 803 #endif 804 mov dx, # VBE_DISPI_IOPORT_DATA 805 #ifdef VBE_BYTEWISE_IO 806 call in_ax_dx 807 #else 808 in ax, dx 809 #endif 810 dec ax 811 push ax 812 mov dx, # VGAREG_VGA_CRTC_ADDRESS 813 mov ah, al 814 mov al, #0x12 815 #ifdef VBE_BYTEWISE_IO 816 call out_dx_ax 817 #else 818 out dx, ax 819 #endif 820 pop ax 821 mov al, #0x07 822 out dx, al 823 inc dx 824 in al, dx 825 and al, #0xbd 826 test ah, #0x01 827 jz bit8_clear 828 or al, #0x02 829 bit8_clear: 830 test ah, #0x02 831 jz bit9_clear 832 or al, #0x40 833 bit9_clear: 834 out dx, al 835 836 ; other settings 837 mov dx, # VGAREG_VGA_CRTC_ADDRESS 838 mov ax, #0x0009 839 #ifdef VBE_BYTEWISE_IO 840 call out_dx_ax 841 #else 842 out dx, ax 843 #endif 844 mov al, #0x17 845 out dx, al 846 mov dx, # VGAREG_VGA_CRTC_DATA 847 in al, dx 848 or al, #0x03 849 out dx, al 850 mov dx, # VGAREG_ACTL_RESET 851 in al, dx 852 mov dx, # VGAREG_ACTL_ADDRESS 853 mov al, #0x10 854 out dx, al 855 mov dx, # VGAREG_ACTL_READ_DATA 856 in al, dx 857 or al, #0x01 858 mov dx, # VGAREG_ACTL_ADDRESS 859 out dx, al 860 mov al, #0x20 861 out dx, al 862 mov dx, # VGAREG_GRDC_ADDRESS 863 mov ax, #0x0506 864 #ifdef VBE_BYTEWISE_IO 865 call out_dx_ax 866 #else 867 out dx, ax 868 #endif 869 mov dx, # VGAREG_SEQU_ADDRESS 870 mov ax, #0x0f02 871 #ifdef VBE_BYTEWISE_IO 872 call out_dx_ax 873 #else 874 out dx, ax 875 #endif 876 877 ; settings for >= 8bpp 878 mov dx, # VBE_DISPI_IOPORT_INDEX 879 mov ax, # VBE_DISPI_INDEX_BPP 880 #ifdef VBE_BYTEWISE_IO 881 call out_dx_ax 882 #else 883 out dx, ax 884 #endif 885 mov dx, # VBE_DISPI_IOPORT_DATA 886 #ifdef VBE_BYTEWISE_IO 887 call in_ax_dx 888 #else 889 in ax, dx 890 #endif 891 cmp al, #0x08 892 jb vga_compat_end 893 mov dx, # VGAREG_VGA_CRTC_ADDRESS 894 mov al, #0x14 895 out dx, al 896 mov dx, # VGAREG_VGA_CRTC_DATA 897 in al, dx 898 or al, #0x40 899 out dx, al 900 mov dx, # VGAREG_ACTL_RESET 901 in al, dx 902 mov dx, # VGAREG_ACTL_ADDRESS 903 mov al, #0x10 904 out dx, al 905 mov dx, # VGAREG_ACTL_READ_DATA 906 in al, dx 907 or al, #0x40 908 mov dx, # VGAREG_ACTL_ADDRESS 909 out dx, al 910 mov al, #0x20 911 out dx, al 912 mov dx, # VGAREG_SEQU_ADDRESS 913 mov al, #0x04 914 out dx, al 915 mov dx, # VGAREG_SEQU_DATA 916 in al, dx 917 or al, #0x08 918 out dx, al 919 mov dx, # VGAREG_GRDC_ADDRESS 920 mov al, #0x05 921 out dx, al 922 mov dx, # VGAREG_GRDC_DATA 923 in al, dx 924 and al, #0x9f 925 or al, #0x40 926 out dx, al 927 928 vga_compat_end: 929 pop dx 930 pop ax 642 931 ASM_END 643 932 … … 769 1058 pop bx 770 1059 pop ds 771 mov ax, # VBE_DISPI_ID3 1060 ; mov ax, # VBE_DISPI_ID3 1061 mov ax, # VBE_DISPI_ID4 772 1062 call dispi_set_id 773 1063 no_vbe_interface: 1064 #if defined(DEBUG) 774 1065 mov bx, #msg_vbe_init 775 1066 push bx … … 777 1068 inc sp 778 1069 inc sp 779 ret 780 1070 #endif 1071 ret 1072 1073 #ifndef VBOX 781 1074 ; VBE Display Info - Display information on screen about the VBE 782 1075 … … 794 1087 mov si, #_no_vbebios_info_string 795 1088 jmp _display_string 1089 #endif 1090 796 1091 ASM_END 797 1092 … … 820 1115 ModeInfoListItem *cur_info; /* used to get the mode list offset. */ 821 1116 Bit16u sig, vmode; 1117 Bit16u max_bpp=dispi_get_max_bpp(); 822 1118 #else 823 1119 ModeInfoListItem *cur_info=&mode_info_list; 824 #endif825 #ifdef DYN_LIST826 Bit16u max_bpp=dispi_get_max_bpp();827 1120 #endif 828 1121 … … 890 1183 vbe_info_block.Capabilities[3] = 0; 891 1184 892 #ifdef DYN_LIST893 1185 // VBE Video Mode Pointer (dynamicly generated from the mode_info_list) 894 1186 vbe_info_block.VideoModePtr_Seg= ES ; 895 1187 vbe_info_block.VideoModePtr_Off= DI + 34; 896 #else897 // VBE Video Mode Pointer (staticly in rom)898 vbe_info_block.VideoModePtr_Seg = 0xc000;899 vbe_info_block.VideoModePtr_Off = &vbebios_mode_list;900 #endif901 1188 902 1189 // VBE Total Memory (in 64b blocks) … … 947 1234 write_word(ES, DI + cur_ptr, vmode); 948 1235 #else 949 #ifdef DYN_LIST950 1236 do 951 1237 { … … 963 1249 // Add vesa mode list terminator 964 1250 write_word(ES, DI + cur_ptr, cur_info->mode); 965 #endif966 1251 #endif // VBE_NEW_DYN_LIST 967 1252 … … 1095 1380 Bit16u data; 1096 1381 Bit8u data_b; 1097 #ifdef DEBUG1098 1382 Bit16u x, y; 1099 1383 Bit8u bpp; … … 1103 1387 bpp = in_byte(VBE_EXTRA_PORT, &cur_info->info.BitsPerPixel); 1104 1388 1389 #ifdef DEBUG 1105 1390 printf("VBE found mode %x, setting:\n", BX); 1106 1391 printf("\txres%x yres%x bpp%x\n", x, y, bpp); … … 1143 1428 dispi_set_bank(0); 1144 1429 dispi_set_enable(VBE_DISPI_ENABLED | no_clear | lfb_flag); 1430 vga_compat_setup(); 1145 1431 1146 1432 write_word(BIOSMEM_SEG,BIOSMEM_VBE_MODE,BX); … … 1193 1479 ASM_END 1194 1480 1481 Bit16u vbe_biosfn_read_video_state_size() 1482 { 1483 return 9 * 2; 1484 } 1485 1486 void vbe_biosfn_save_video_state(ES, BX) 1487 Bit16u ES; Bit16u BX; 1488 { 1489 Bit16u enable, i; 1490 1491 outw(VBE_DISPI_IOPORT_INDEX,VBE_DISPI_INDEX_ENABLE); 1492 enable = inw(VBE_DISPI_IOPORT_DATA); 1493 write_word(ES, BX, enable); 1494 BX += 2; 1495 if (!(enable & VBE_DISPI_ENABLED)) 1496 return; 1497 for(i = VBE_DISPI_INDEX_XRES; i <= VBE_DISPI_INDEX_Y_OFFSET; i++) { 1498 if (i != VBE_DISPI_INDEX_ENABLE) { 1499 outw(VBE_DISPI_IOPORT_INDEX, i); 1500 write_word(ES, BX, inw(VBE_DISPI_IOPORT_DATA)); 1501 BX += 2; 1502 } 1503 } 1504 } 1505 1506 1507 void vbe_biosfn_restore_video_state(ES, BX) 1508 Bit16u ES; Bit16u BX; 1509 { 1510 Bit16u enable, i; 1511 1512 enable = read_word(ES, BX); 1513 BX += 2; 1514 1515 if (!(enable & VBE_DISPI_ENABLED)) { 1516 outw(VBE_DISPI_IOPORT_INDEX,VBE_DISPI_INDEX_ENABLE); 1517 outw(VBE_DISPI_IOPORT_DATA, enable); 1518 } else { 1519 outw(VBE_DISPI_IOPORT_INDEX, VBE_DISPI_INDEX_XRES); 1520 outw(VBE_DISPI_IOPORT_DATA, read_word(ES, BX)); 1521 BX += 2; 1522 outw(VBE_DISPI_IOPORT_INDEX, VBE_DISPI_INDEX_YRES); 1523 outw(VBE_DISPI_IOPORT_DATA, read_word(ES, BX)); 1524 BX += 2; 1525 outw(VBE_DISPI_IOPORT_INDEX, VBE_DISPI_INDEX_BPP); 1526 outw(VBE_DISPI_IOPORT_DATA, read_word(ES, BX)); 1527 BX += 2; 1528 outw(VBE_DISPI_IOPORT_INDEX,VBE_DISPI_INDEX_ENABLE); 1529 outw(VBE_DISPI_IOPORT_DATA, enable); 1530 1531 for(i = VBE_DISPI_INDEX_BANK; i <= VBE_DISPI_INDEX_Y_OFFSET; i++) { 1532 outw(VBE_DISPI_IOPORT_INDEX, i); 1533 outw(VBE_DISPI_IOPORT_DATA, read_word(ES, BX)); 1534 BX += 2; 1535 } 1536 } 1537 } 1195 1538 1196 1539 /** Function 04h - Save/Restore State … … 1208 1551 * 1209 1552 */ 1210 void vbe_biosfn_save_restore_state(AX, DL, CX, ES, BX) 1553 void vbe_biosfn_save_restore_state(AX, CX, DX, ES, BX) 1554 Bit16u *AX; Bit16u CX; Bit16u DX; Bit16u ES; Bit16u *BX; 1211 1555 { 1556 Bit16u ss=get_SS(); 1557 Bit16u result, val; 1558 1559 result = 0x4f; 1560 switch(GET_DL()) { 1561 case 0x00: 1562 val = biosfn_read_video_state_size2(CX); 1563 #ifdef DEBUG 1564 printf("VGA state size=%x\n", val); 1565 #endif 1566 if (CX & 8) 1567 val += vbe_biosfn_read_video_state_size(); 1568 write_word(ss, BX, val); 1569 break; 1570 case 0x01: 1571 val = read_word(ss, BX); 1572 val = biosfn_save_video_state(CX, ES, val); 1573 #ifdef DEBUG 1574 printf("VGA save_state offset=%x\n", val); 1575 #endif 1576 if (CX & 8) 1577 vbe_biosfn_save_video_state(ES, val); 1578 break; 1579 case 0x02: 1580 val = read_word(ss, BX); 1581 val = biosfn_restore_video_state(CX, ES, val); 1582 #ifdef DEBUG 1583 printf("VGA restore_state offset=%x\n", val); 1584 #endif 1585 if (CX & 8) 1586 vbe_biosfn_restore_video_state(ES, val); 1587 break; 1588 default: 1589 // function failed 1590 result = 0x100; 1591 break; 1592 } 1593 write_word(ss, AX, result); 1212 1594 } 1213 1595 … … 1295 1677 xor bh, bh 1296 1678 mov bl, ah 1679 or bl, bl 1680 jnz no_4bpp_1 1681 shl ax, #3 1682 mov bl, #1 1683 no_4bpp_1: 1297 1684 xor dx, dx 1298 1685 pop ax … … 1306 1693 call dispi_get_virt_width 1307 1694 mov cx, ax 1695 or bl, bl 1696 jnz no_4bpp_2 1697 shr ax, #3 1698 mov bl, #1 1699 no_4bpp_2: 1308 1700 mul bx 1309 1701 mov bx, ax … … 1522 1914 ASM_END 1523 1915 1916 1524 1917 /** Function 0Ah - Return VBE Protected Mode Interface 1525 1918 * 1526 * Input: 1527 * AX = 4F0Ah 1528 * Output: 1529 * AX = VBE Return Status 1530 * 1531 * FIXME: incomplete API description, Input & Output 1919 * Input: AX = 4F0Ah VBE 2.0 Protected Mode Interface 1920 * BL = 00h Return protected mode table 1921 * Output: AX = Status 1922 * ES = Real Mode Segment of Table 1923 * DI = Offset of Table 1924 * CX = Length of Table including protected mode code 1925 * (for copying purposes) 1532 1926 */ 1533 void vbe_biosfn_return_protected_mode_interface(AX) 1534 { 1535 } 1927 ASM_START 1928 vbe_biosfn_return_protected_mode_interface: 1929 test bl, bl 1930 jnz _fail 1931 mov di, #0xc000 1932 mov es, di 1933 mov di, # vesa_pm_start 1934 mov cx, # vesa_pm_end 1935 sub cx, di 1936 mov ax, #0x004f 1937 ret 1938 _fail: 1939 mov ax, #0x014f 1940 ret 1941 ASM_END
Note:
See TracChangeset
for help on using the changeset viewer.