source:
trunk/packages/xen-common/xen-common/tools/ioemu/pc-bios/vgabios.diff
@
34
Last change on this file since 34 was 34, checked in by hartmans, 17 years ago | |
---|---|
File size: 28.0 KB |
-
Makefile
RCS file: /sources/vgabios/vgabios/Makefile,v retrieving revision 1.17 diff -u -w -r1.17 Makefile
22 22 cirrus-bios: vgabios-cirrus.bin vgabios-cirrus.debug.bin 23 23 24 24 clean: 25 /bin/rm -f biossums *.o *.s *.ld86 \25 /bin/rm -f biossums vbetables-gen vbetables.h *.o *.s *.ld86 \ 26 26 temp.awk.* vgabios*.orig _vgabios_* _vgabios-debug_* core vgabios*.bin vgabios*.txt $(RELEASE).bin *.bak 27 27 28 28 dist-clean: clean … … 79 79 80 80 biossums: biossums.c 81 81 $(CC) -o biossums biossums.c 82 83 vbetables-gen: vbetables-gen.c 84 $(CC) -o vbetables-gen vbetables-gen.c 85 86 vbetables.h: vbetables-gen 87 ./vbetables-gen > $@ -
clext.c
RCS file: /sources/vgabios/vgabios/clext.c,v retrieving revision 1.10 diff -u -w -r1.10 clext.c
544 544 cirrus_set_video_mode_extended: 545 545 call cirrus_switch_mode 546 546 pop ax ;; mode 547 test al, #0x80 548 jnz cirrus_set_video_mode_extended_1 549 push ax 550 mov ax, #0xffff ; set to 0xff to keep win 2K happy 551 call cirrus_clear_vram 552 pop ax 553 cirrus_set_video_mode_extended_1: 547 554 and al, #0x7f 548 555 549 556 push ds … … 1011 1018 jnz cirrus_vesa_02h_3 1012 1019 call cirrus_enable_16k_granularity 1013 1020 cirrus_vesa_02h_3: 1021 test bx, #0x8000 ;; no clear 1022 jnz cirrus_vesa_02h_4 1023 push ax 1024 xor ax,ax 1025 call cirrus_clear_vram 1026 pop ax 1027 cirrus_vesa_02h_4: 1014 1028 pop ax 1015 1029 push ds 1016 1030 #ifdef CIRRUS_VESA3_PMINFO … … 1479 1493 pop bx 1480 1494 ret 1481 1495 1496 cirrus_clear_vram: 1497 pusha 1498 push es 1499 mov si, ax 1500 1501 call cirrus_enable_16k_granularity 1502 call cirrus_extbios_85h 1503 shl al, #2 1504 mov bl, al 1505 xor ah,ah 1506 cirrus_clear_vram_1: 1507 mov al, #0x09 1508 mov dx, #0x3ce 1509 out dx, ax 1510 push ax 1511 mov cx, #0xa000 1512 mov es, cx 1513 xor di, di 1514 mov ax, si 1515 mov cx, #8192 1516 cld 1517 rep 1518 stosw 1519 pop ax 1520 inc ah 1521 cmp ah, bl 1522 jne cirrus_clear_vram_1 1523 1524 pop es 1525 popa 1526 ret 1527 1482 1528 cirrus_extbios_handlers: 1483 1529 ;; 80h 1484 1530 dw cirrus_extbios_80h -
vbe.c
RCS file: /sources/vgabios/vgabios/vbe.c,v retrieving revision 1.48 diff -u -w -r1.48 vbe.c
118 118 .word VBE_VESA_MODE_END_OF_LIST 119 119 #endif 120 120 121 .align 2 121 122 vesa_pm_start: 122 123 dw vesa_pm_set_window - vesa_pm_start 123 dw vesa_pm_set_display_st rt - vesa_pm_start124 dw vesa_pm_set_display_start - vesa_pm_start 124 125 dw vesa_pm_unimplemented - vesa_pm_start 125 dw 0 126 dw vesa_pm_io_ports_table - vesa_pm_start 127 vesa_pm_io_ports_table: 128 dw VBE_DISPI_IOPORT_INDEX 129 dw VBE_DISPI_IOPORT_INDEX + 1 130 dw VBE_DISPI_IOPORT_DATA 131 dw VBE_DISPI_IOPORT_DATA + 1 132 dw 0xffff 133 dw 0xffff 126 134 127 135 USE32 128 136 vesa_pm_set_window: 129 mov ax, #0x4f05 130 int #0x10 137 cmp bx, #0x00 138 je vesa_pm_set_display_window1 139 mov ax, #0x0100 140 ret 141 vesa_pm_set_display_window1: 142 mov ax, dx 143 push dx 144 push ax 145 mov dx, # VBE_DISPI_IOPORT_INDEX 146 mov ax, # VBE_DISPI_INDEX_BANK 147 out dx, ax 148 pop ax 149 mov dx, # VBE_DISPI_IOPORT_DATA 150 out dx, ax 151 pop dx 152 mov ax, #0x004f 131 153 ret 132 154 133 155 vesa_pm_set_display_start: 134 mov ax, #0x4f07 135 int #0x10 156 cmp bl, #0x80 157 je vesa_pm_set_display_start1 158 cmp bl, #0x00 159 je vesa_pm_set_display_start1 160 mov ax, #0x0100 161 ret 162 vesa_pm_set_display_start1: 163 ; convert offset to (X, Y) coordinate 164 ; (would be simpler to change Bochs VBE API...) 165 push eax 166 push ecx 167 push edx 168 push esi 169 push edi 170 shl edx, #16 171 and ecx, #0xffff 172 or ecx, edx 173 shl ecx, #2 174 mov eax, ecx 175 176 push eax 177 mov dx, # VBE_DISPI_IOPORT_INDEX 178 mov ax, # VBE_DISPI_INDEX_VIRT_WIDTH 179 out dx, ax 180 mov dx, # VBE_DISPI_IOPORT_DATA 181 in ax, dx 182 movzx ecx, ax 183 184 mov dx, # VBE_DISPI_IOPORT_INDEX 185 mov ax, # VBE_DISPI_INDEX_BPP 186 out dx, ax 187 mov dx, # VBE_DISPI_IOPORT_DATA 188 in ax, dx 189 movzx esi, ax 190 pop eax 191 192 add esi, #7 193 shr esi, #3 194 imul ecx, esi 195 xor edx, edx 196 div ecx 197 mov edi, eax 198 mov eax, edx 199 xor edx, edx 200 div esi 201 202 push dx 203 push ax 204 mov dx, # VBE_DISPI_IOPORT_INDEX 205 mov ax, # VBE_DISPI_INDEX_X_OFFSET 206 out dx, ax 207 pop ax 208 mov dx, # VBE_DISPI_IOPORT_DATA 209 out dx, ax 210 pop dx 211 212 mov ax, di 213 push dx 214 push ax 215 mov dx, # VBE_DISPI_IOPORT_INDEX 216 mov ax, # VBE_DISPI_INDEX_Y_OFFSET 217 out dx, ax 218 pop ax 219 mov dx, # VBE_DISPI_IOPORT_DATA 220 out dx, ax 221 pop dx 222 223 pop edi 224 pop esi 225 pop edx 226 pop ecx 227 pop eax 228 mov ax, #0x004f 136 229 ret 137 230 138 231 vesa_pm_unimplemented: … … 835 928 ASM_END 836 929 837 930 931 Bit16u vbe_biosfn_read_video_state_size() 932 { 933 return 9 * 2; 934 } 935 936 void vbe_biosfn_save_video_state(ES, BX) 937 Bit16u ES; Bit16u BX; 938 { 939 Bit16u enable, i; 940 941 outw(VBE_DISPI_IOPORT_INDEX,VBE_DISPI_INDEX_ENABLE); 942 enable = inw(VBE_DISPI_IOPORT_DATA); 943 write_word(ES, BX, enable); 944 BX += 2; 945 if (!(enable & VBE_DISPI_ENABLED)) 946 return; 947 for(i = VBE_DISPI_INDEX_XRES; i <= VBE_DISPI_INDEX_Y_OFFSET; i++) { 948 if (i != VBE_DISPI_INDEX_ENABLE) { 949 outw(VBE_DISPI_IOPORT_INDEX, i); 950 write_word(ES, BX, inw(VBE_DISPI_IOPORT_DATA)); 951 BX += 2; 952 } 953 } 954 } 955 956 957 void vbe_biosfn_restore_video_state(ES, BX) 958 Bit16u ES; Bit16u BX; 959 { 960 Bit16u enable, i; 961 962 enable = read_word(ES, BX); 963 BX += 2; 964 965 if (!(enable & VBE_DISPI_ENABLED)) { 966 outw(VBE_DISPI_IOPORT_INDEX,VBE_DISPI_INDEX_ENABLE); 967 outw(VBE_DISPI_IOPORT_DATA, enable); 968 } else { 969 outw(VBE_DISPI_IOPORT_INDEX, VBE_DISPI_INDEX_XRES); 970 outw(VBE_DISPI_IOPORT_DATA, read_word(ES, BX)); 971 BX += 2; 972 outw(VBE_DISPI_IOPORT_INDEX, VBE_DISPI_INDEX_YRES); 973 outw(VBE_DISPI_IOPORT_DATA, read_word(ES, BX)); 974 BX += 2; 975 outw(VBE_DISPI_IOPORT_INDEX, VBE_DISPI_INDEX_BPP); 976 outw(VBE_DISPI_IOPORT_DATA, read_word(ES, BX)); 977 BX += 2; 978 outw(VBE_DISPI_IOPORT_INDEX,VBE_DISPI_INDEX_ENABLE); 979 outw(VBE_DISPI_IOPORT_DATA, enable); 980 981 for(i = VBE_DISPI_INDEX_BANK; i <= VBE_DISPI_INDEX_Y_OFFSET; i++) { 982 outw(VBE_DISPI_IOPORT_INDEX, i); 983 outw(VBE_DISPI_IOPORT_DATA, read_word(ES, BX)); 984 BX += 2; 985 } 986 } 987 } 988 838 989 /** Function 04h - Save/Restore State 839 990 * 840 991 * Input: … … 849 1000 * BX = Number of 64-byte blocks to hold the state buffer (if DL=00h) 850 1001 * 851 1002 */ 852 void vbe_biosfn_save_restore_state(AX, DL, CX, ES, BX) 1003 void vbe_biosfn_save_restore_state(AX, CX, DX, ES, BX) 1004 Bit16u *AX; Bit16u CX; Bit16u DX; Bit16u ES; Bit16u *BX; 853 1005 { 854 } 1006 Bit16u ss=get_SS(); 1007 Bit16u result, val; 855 1008 1009 result = 0x4f; 1010 switch(GET_DL()) { 1011 case 0x00: 1012 val = biosfn_read_video_state_size2(CX); 1013 #ifdef DEBUG 1014 printf("VGA state size=%x\n", val); 1015 #endif 1016 if (CX & 8) 1017 val += vbe_biosfn_read_video_state_size(); 1018 write_word(ss, BX, val); 1019 break; 1020 case 0x01: 1021 val = read_word(ss, BX); 1022 val = biosfn_save_video_state(CX, ES, val); 1023 #ifdef DEBUG 1024 printf("VGA save_state offset=%x\n", val); 1025 #endif 1026 if (CX & 8) 1027 vbe_biosfn_save_video_state(ES, val); 1028 break; 1029 case 0x02: 1030 val = read_word(ss, BX); 1031 val = biosfn_restore_video_state(CX, ES, val); 1032 #ifdef DEBUG 1033 printf("VGA restore_state offset=%x\n", val); 1034 #endif 1035 if (CX & 8) 1036 vbe_biosfn_restore_video_state(ES, val); 1037 break; 1038 default: 1039 // function failed 1040 result = 0x100; 1041 break; 1042 } 1043 write_word(ss, AX, result); 1044 } 856 1045 857 1046 /** Function 05h - Display Window Control 858 1047 * … … 1090 1279 */ 1091 1280 ASM_START 1092 1281 vbe_biosfn_return_protected_mode_interface: 1093 test b x, bx1282 test bl, bl 1094 1283 jnz _fail 1095 1284 mov di, #0xc000 1096 1285 mov es, di -
vbe.h
RCS file: /sources/vgabios/vgabios/vbe.h,v retrieving revision 1.24 diff -u -w -r1.24 vbe.h
14 14 void vbe_biosfn_return_controller_information(AX, ES, DI); 15 15 void vbe_biosfn_return_mode_information(AX, CX, ES, DI); 16 16 void vbe_biosfn_set_mode(AX, BX, ES, DI); 17 void vbe_biosfn_save_restore_state(AX, DL, CX, ES, BX);17 void vbe_biosfn_save_restore_state(AX, CX, DX, ES, BX); 18 18 void vbe_biosfn_set_get_palette_data(AX); 19 19 void vbe_biosfn_return_protected_mode_interface(AX); 20 20 … … 151 151 Bit8u Reserved[189]; 152 152 } ModeInfoBlock; 153 153 154 typedef struct ModeInfoListItem 155 { 156 Bit16u mode; 157 ModeInfoBlockCompact info; 158 } ModeInfoListItem; 159 154 160 // VBE Return Status Info 155 161 // AL 156 162 #define VBE_RETURN_STATUS_SUPPORTED 0x4F … … 193 199 #define VBE_VESA_MODE_1280X1024X1555 0x119 194 200 #define VBE_VESA_MODE_1280X1024X565 0x11A 195 201 #define VBE_VESA_MODE_1280X1024X888 0x11B 202 #define VBE_VESA_MODE_1600X1200X8 0x11C 203 #define VBE_VESA_MODE_1600X1200X1555 0x11D 204 #define VBE_VESA_MODE_1600X1200X565 0x11E 205 #define VBE_VESA_MODE_1600X1200X888 0x11F 196 206 197 207 // BOCHS/PLEX86 'own' mode numbers 198 208 #define VBE_OWN_MODE_320X200X8888 0x140 … … 202 212 #define VBE_OWN_MODE_1024X768X8888 0x144 203 213 #define VBE_OWN_MODE_1280X1024X8888 0x145 204 214 #define VBE_OWN_MODE_320X200X8 0x146 215 #define VBE_OWN_MODE_1600X1200X8888 0x147 216 #define VBE_OWN_MODE_1152X864X8 0x148 217 #define VBE_OWN_MODE_1152X864X1555 0x149 218 #define VBE_OWN_MODE_1152X864X565 0x14a 219 #define VBE_OWN_MODE_1152X864X888 0x14b 220 #define VBE_OWN_MODE_1152X864X8888 0x14c 205 221 206 222 #define VBE_VESA_MODE_END_OF_LIST 0xFFFF 207 223 … … 259 275 // like 0xE0000000 260 276 261 277 262 #define VBE_DISPI_TOTAL_VIDEO_MEMORY_MB 4278 #define VBE_DISPI_TOTAL_VIDEO_MEMORY_MB 8 263 279 264 280 #define VBE_DISPI_BANK_ADDRESS 0xA0000 265 281 #define VBE_DISPI_BANK_SIZE_KB 64 -
vgabios.c
RCS file: /sources/vgabios/vgabios/vgabios.c,v retrieving revision 1.64 diff -u -w -r1.64 vgabios.c
109 109 static void biosfn_write_string(); 110 110 static void biosfn_read_state_info(); 111 111 static void biosfn_read_video_state_size(); 112 static voidbiosfn_save_video_state();113 static voidbiosfn_restore_video_state();112 static Bit16u biosfn_save_video_state(); 113 static Bit16u biosfn_restore_video_state(); 114 114 extern Bit8u video_save_pointer_table[]; 115 115 116 116 // This is for compiling with gcc2 and gcc3 … … 748 748 vbe_biosfn_set_mode(&AX,BX,ES,DI); 749 749 break; 750 750 case 0x04: 751 //FIXME 752 #ifdef DEBUG 753 unimplemented(); 754 #endif 755 // function failed 756 AX=0x100; 751 vbe_biosfn_save_restore_state(&AX, CX, DX, ES, &BX); 757 752 break; 758 753 case 0x09: 759 754 //FIXME … … 3138 3133 } 3139 3134 3140 3135 // -------------------------------------------------------------------------------------------- 3141 static void biosfn_read_video_state_size (CX,ES,BX) Bit16u CX;Bit16u ES;Bit16u BX; 3136 // -------------------------------------------------------------------------------------------- 3137 static Bit16u biosfn_read_video_state_size2 (CX) 3138 Bit16u CX; 3142 3139 { 3143 #ifdef DEBUG 3144 unimplemented(); 3145 #endif 3140 Bit16u size; 3141 size = 0; 3142 if (CX & 1) { 3143 size += 0x46; 3144 } 3145 if (CX & 2) { 3146 size += (5 + 8 + 5) * 2 + 6; 3147 } 3148 if (CX & 4) { 3149 size += 3 + 256 * 3 + 1; 3146 3150 } 3147 static void biosfn_save_video_state (CX,ES,BX) Bit16u CX;Bit16u ES;Bit16u BX; 3151 return size; 3152 } 3153 3154 static void biosfn_read_video_state_size (CX, BX) 3155 Bit16u CX; Bit16u *BX; 3148 3156 { 3149 #ifdef DEBUG 3150 unimplemented(); 3151 #endif 3157 Bit16u ss=get_SS(); 3158 write_word(ss, BX, biosfn_read_video_state_size2(CX)); 3152 3159 } 3153 static void biosfn_restore_video_state (CX,ES,BX) Bit16u CX;Bit16u ES;Bit16u BX; 3160 3161 static Bit16u biosfn_save_video_state (CX,ES,BX) 3162 Bit16u CX;Bit16u ES;Bit16u BX; 3154 3163 { 3155 #ifdef DEBUG 3156 unimplemented(); 3157 #endif 3164 Bit16u i, v, crtc_addr, ar_index; 3165 3166 crtc_addr = read_word(BIOSMEM_SEG, BIOSMEM_CRTC_ADDRESS); 3167 if (CX & 1) { 3168 write_byte(ES, BX, inb(VGAREG_SEQU_ADDRESS)); BX++; 3169 write_byte(ES, BX, inb(crtc_addr)); BX++; 3170 write_byte(ES, BX, inb(VGAREG_GRDC_ADDRESS)); BX++; 3171 inb(VGAREG_ACTL_RESET); 3172 ar_index = inb(VGAREG_ACTL_ADDRESS); 3173 write_byte(ES, BX, ar_index); BX++; 3174 write_byte(ES, BX, inb(VGAREG_READ_FEATURE_CTL)); BX++; 3175 3176 for(i=1;i<=4;i++){ 3177 outb(VGAREG_SEQU_ADDRESS, i); 3178 write_byte(ES, BX, inb(VGAREG_SEQU_DATA)); BX++; 3179 } 3180 outb(VGAREG_SEQU_ADDRESS, 0); 3181 write_byte(ES, BX, inb(VGAREG_SEQU_DATA)); BX++; 3182 3183 for(i=0;i<=0x18;i++) { 3184 outb(crtc_addr,i); 3185 write_byte(ES, BX, inb(crtc_addr+1)); BX++; 3186 } 3187 3188 for(i=0;i<=0x13;i++) { 3189 inb(VGAREG_ACTL_RESET); 3190 outb(VGAREG_ACTL_ADDRESS, i | (ar_index & 0x20)); 3191 write_byte(ES, BX, inb(VGAREG_ACTL_READ_DATA)); BX++; 3192 } 3193 inb(VGAREG_ACTL_RESET); 3194 3195 for(i=0;i<=8;i++) { 3196 outb(VGAREG_GRDC_ADDRESS,i); 3197 write_byte(ES, BX, inb(VGAREG_GRDC_DATA)); BX++; 3198 } 3199 3200 write_word(ES, BX, crtc_addr); BX+= 2; 3201 3202 /* XXX: read plane latches */ 3203 write_byte(ES, BX, 0); BX++; 3204 write_byte(ES, BX, 0); BX++; 3205 write_byte(ES, BX, 0); BX++; 3206 write_byte(ES, BX, 0); BX++; 3207 } 3208 if (CX & 2) { 3209 write_byte(ES, BX, read_byte(BIOSMEM_SEG,BIOSMEM_CURRENT_MODE)); BX++; 3210 write_word(ES, BX, read_word(BIOSMEM_SEG,BIOSMEM_NB_COLS)); BX += 2; 3211 write_word(ES, BX, read_word(BIOSMEM_SEG,BIOSMEM_PAGE_SIZE)); BX += 2; 3212 write_word(ES, BX, read_word(BIOSMEM_SEG,BIOSMEM_CRTC_ADDRESS)); BX += 2; 3213 write_byte(ES, BX, read_byte(BIOSMEM_SEG,BIOSMEM_NB_ROWS)); BX++; 3214 write_word(ES, BX, read_word(BIOSMEM_SEG,BIOSMEM_CHAR_HEIGHT)); BX += 2; 3215 write_byte(ES, BX, read_byte(BIOSMEM_SEG,BIOSMEM_VIDEO_CTL)); BX++; 3216 write_byte(ES, BX, read_byte(BIOSMEM_SEG,BIOSMEM_SWITCHES)); BX++; 3217 write_byte(ES, BX, read_byte(BIOSMEM_SEG,BIOSMEM_MODESET_CTL)); BX++; 3218 write_word(ES, BX, read_word(BIOSMEM_SEG,BIOSMEM_CURSOR_TYPE)); BX += 2; 3219 for(i=0;i<8;i++) { 3220 write_word(ES, BX, read_word(BIOSMEM_SEG, BIOSMEM_CURSOR_POS+2*i)); 3221 BX += 2; 3222 } 3223 write_word(ES, BX, read_word(BIOSMEM_SEG,BIOSMEM_CURRENT_START)); BX += 2; 3224 write_byte(ES, BX, read_byte(BIOSMEM_SEG,BIOSMEM_CURRENT_PAGE)); BX++; 3225 /* current font */ 3226 write_word(ES, BX, read_word(0, 0x1f * 4)); BX += 2; 3227 write_word(ES, BX, read_word(0, 0x1f * 4 + 2)); BX += 2; 3228 write_word(ES, BX, read_word(0, 0x43 * 4)); BX += 2; 3229 write_word(ES, BX, read_word(0, 0x43 * 4 + 2)); BX += 2; 3230 } 3231 if (CX & 4) { 3232 /* XXX: check this */ 3233 write_byte(ES, BX, inb(VGAREG_DAC_STATE)); BX++; /* read/write mode dac */ 3234 write_byte(ES, BX, inb(VGAREG_DAC_WRITE_ADDRESS)); BX++; /* pix address */ 3235 write_byte(ES, BX, inb(VGAREG_PEL_MASK)); BX++; 3236 // Set the whole dac always, from 0 3237 outb(VGAREG_DAC_WRITE_ADDRESS,0x00); 3238 for(i=0;i<256*3;i++) { 3239 write_byte(ES, BX, inb(VGAREG_DAC_DATA)); BX++; 3240 } 3241 write_byte(ES, BX, 0); BX++; /* color select register */ 3242 } 3243 return BX; 3244 } 3245 3246 static Bit16u biosfn_restore_video_state (CX,ES,BX) 3247 Bit16u CX;Bit16u ES;Bit16u BX; 3248 { 3249 Bit16u i, crtc_addr, v, addr1, ar_index; 3250 3251 if (CX & 1) { 3252 // Reset Attribute Ctl flip-flop 3253 inb(VGAREG_ACTL_RESET); 3254 3255 crtc_addr = read_word(ES, BX + 0x40); 3256 addr1 = BX; 3257 BX += 5; 3258 3259 for(i=1;i<=4;i++){ 3260 outb(VGAREG_SEQU_ADDRESS, i); 3261 outb(VGAREG_SEQU_DATA, read_byte(ES, BX)); BX++; 3262 } 3263 outb(VGAREG_SEQU_ADDRESS, 0); 3264 outb(VGAREG_SEQU_DATA, read_byte(ES, BX)); BX++; 3265 3266 // Disable CRTC write protection 3267 outw(crtc_addr,0x0011); 3268 // Set CRTC regs 3269 for(i=0;i<=0x18;i++) { 3270 if (i != 0x11) { 3271 outb(crtc_addr,i); 3272 outb(crtc_addr+1, read_byte(ES, BX)); 3273 } 3274 BX++; 3275 } 3276 // select crtc base address 3277 v = inb(VGAREG_READ_MISC_OUTPUT) & ~0x01; 3278 if (crtc_addr = 0x3d4) 3279 v |= 0x01; 3280 outb(VGAREG_WRITE_MISC_OUTPUT, v); 3281 3282 // enable write protection if needed 3283 outb(crtc_addr, 0x11); 3284 outb(crtc_addr+1, read_byte(ES, BX - 0x18 + 0x11)); 3285 3286 // Set Attribute Ctl 3287 ar_index = read_byte(ES, addr1 + 0x03); 3288 inb(VGAREG_ACTL_RESET); 3289 for(i=0;i<=0x13;i++) { 3290 outb(VGAREG_ACTL_ADDRESS, i | (ar_index & 0x20)); 3291 outb(VGAREG_ACTL_WRITE_DATA, read_byte(ES, BX)); BX++; 3292 } 3293 outb(VGAREG_ACTL_ADDRESS, ar_index); 3294 inb(VGAREG_ACTL_RESET); 3295 3296 for(i=0;i<=8;i++) { 3297 outb(VGAREG_GRDC_ADDRESS,i); 3298 outb(VGAREG_GRDC_DATA, read_byte(ES, BX)); BX++; 3299 } 3300 BX += 2; /* crtc_addr */ 3301 BX += 4; /* plane latches */ 3302 3303 outb(VGAREG_SEQU_ADDRESS, read_byte(ES, addr1)); addr1++; 3304 outb(crtc_addr, read_byte(ES, addr1)); addr1++; 3305 outb(VGAREG_GRDC_ADDRESS, read_byte(ES, addr1)); addr1++; 3306 addr1++; 3307 outb(crtc_addr - 0x4 + 0xa, read_byte(ES, addr1)); addr1++; 3308 } 3309 if (CX & 2) { 3310 write_byte(BIOSMEM_SEG,BIOSMEM_CURRENT_MODE, read_byte(ES, BX)); BX++; 3311 write_word(BIOSMEM_SEG,BIOSMEM_NB_COLS, read_word(ES, BX)); BX += 2; 3312 write_word(BIOSMEM_SEG,BIOSMEM_PAGE_SIZE, read_word(ES, BX)); BX += 2; 3313 write_word(BIOSMEM_SEG,BIOSMEM_CRTC_ADDRESS, read_word(ES, BX)); BX += 2; 3314 write_byte(BIOSMEM_SEG,BIOSMEM_NB_ROWS, read_byte(ES, BX)); BX++; 3315 write_word(BIOSMEM_SEG,BIOSMEM_CHAR_HEIGHT, read_word(ES, BX)); BX += 2; 3316 write_byte(BIOSMEM_SEG,BIOSMEM_VIDEO_CTL, read_byte(ES, BX)); BX++; 3317 write_byte(BIOSMEM_SEG,BIOSMEM_SWITCHES, read_byte(ES, BX)); BX++; 3318 write_byte(BIOSMEM_SEG,BIOSMEM_MODESET_CTL, read_byte(ES, BX)); BX++; 3319 write_word(BIOSMEM_SEG,BIOSMEM_CURSOR_TYPE, read_word(ES, BX)); BX += 2; 3320 for(i=0;i<8;i++) { 3321 write_word(BIOSMEM_SEG, BIOSMEM_CURSOR_POS+2*i, read_word(ES, BX)); 3322 BX += 2; 3323 } 3324 write_word(BIOSMEM_SEG,BIOSMEM_CURRENT_START, read_word(ES, BX)); BX += 2; 3325 write_byte(BIOSMEM_SEG,BIOSMEM_CURRENT_PAGE, read_byte(ES, BX)); BX++; 3326 /* current font */ 3327 write_word(0, 0x1f * 4, read_word(ES, BX)); BX += 2; 3328 write_word(0, 0x1f * 4 + 2, read_word(ES, BX)); BX += 2; 3329 write_word(0, 0x43 * 4, read_word(ES, BX)); BX += 2; 3330 write_word(0, 0x43 * 4 + 2, read_word(ES, BX)); BX += 2; 3331 } 3332 if (CX & 4) { 3333 BX++; 3334 v = read_byte(ES, BX); BX++; 3335 outb(VGAREG_PEL_MASK, read_byte(ES, BX)); BX++; 3336 // Set the whole dac always, from 0 3337 outb(VGAREG_DAC_WRITE_ADDRESS,0x00); 3338 for(i=0;i<256*3;i++) { 3339 outb(VGAREG_DAC_DATA, read_byte(ES, BX)); BX++; 3340 } 3341 BX++; 3342 outb(VGAREG_DAC_WRITE_ADDRESS, v); 3343 } 3344 return BX; 3158 3345 } 3159 3346 3160 3347 // ============================================================================================ -
vbetables-gen.c
diff -u -w vbetables-gen.c
1 /* Generate the VGABIOS VBE Tables */ 2 #include <stdlib.h> 3 #include <stdio.h> 4 5 typedef struct { 6 int width; 7 int height; 8 int depth; 9 int mode; 10 } ModeInfo; 11 12 ModeInfo modes[] = { 13 /* standard VESA modes */ 14 { 640, 400, 8 , 0x100}, 15 { 640, 480, 8 , 0x101}, 16 { 800, 600, 4 , 0x102}, 17 { 800, 600, 8 , 0x103}, 18 //{ 1024, 768, 4 , 0x104}, 19 { 1024, 768, 8 , 0x105}, 20 //{ 1280, 1024, 4 , 0x106}, 21 { 1280, 1024, 8 , 0x107}, 22 { 320, 200, 15 , 0x10D}, 23 { 320, 200, 16 , 0x10E}, 24 { 320, 200, 24 , 0x10F}, 25 { 640, 480, 15 , 0x110}, 26 { 640, 480, 16 , 0x111}, 27 { 640, 480, 24 , 0x112}, 28 { 800, 600, 15 , 0x113}, 29 { 800, 600, 16 , 0x114}, 30 { 800, 600, 24 , 0x115}, 31 { 1024, 768, 15 , 0x116}, 32 { 1024, 768, 16 , 0x117}, 33 { 1024, 768, 24 , 0x118}, 34 { 1280, 1024, 15 , 0x119}, 35 { 1280, 1024, 16 , 0x11A}, 36 { 1280, 1024, 24 , 0x11B}, 37 { 1600, 1200, 8 , 0x11C}, 38 { 1600, 1200, 15 , 0x11D}, 39 { 1600, 1200, 16 , 0x11E}, 40 { 1600, 1200, 24 , 0x11F}, 41 42 /* BOCHS/PLE, 86 'own' mode numbers */ 43 { 320, 200, 32 , 0x140}, 44 { 640, 400, 32 , 0x141}, 45 { 640, 480, 32 , 0x142}, 46 { 800, 600, 32 , 0x143}, 47 { 1024, 768, 32 , 0x144}, 48 { 1280, 1024, 32 , 0x145}, 49 { 320, 200, 8 , 0x146}, 50 { 1600, 1200, 32 , 0x147}, 51 { 1152, 864, 8 , 0x148}, 52 { 1152, 864, 15 , 0x149}, 53 { 1152, 864, 16 , 0x14a}, 54 { 1152, 864, 24 , 0x14b}, 55 { 1152, 864, 32 , 0x14c}, 56 { 0, }, 57 }; 58 59 int main(int argc, char **argv) 60 { 61 const ModeInfo *pm; 62 int pitch, r_size, r_pos, g_size, g_pos, b_size, b_pos, a_size, a_pos; 63 const char *str; 64 65 printf("/* THIS FILE IS AUTOMATICALLY GENERATED - DO NOT EDIT */\n"); 66 printf("static ModeInfoListItem mode_info_list[]=\n"); 67 printf("{\n"); 68 for(pm = modes; pm->mode != 0; pm++) { 69 printf("{ 0x%04x, /* %dx%dx%d */\n", 70 pm->mode, pm->width, pm->height, pm->depth); 71 printf("{ /*Bit16u ModeAttributes*/ %s,\n", 72 "VBE_MODE_ATTRIBUTE_SUPPORTED | " 73 "VBE_MODE_ATTRIBUTE_EXTENDED_INFORMATION_AVAILABLE | " 74 "VBE_MODE_ATTRIBUTE_COLOR_MODE | " 75 "VBE_MODE_ATTRIBUTE_LINEAR_FRAME_BUFFER_MODE | " 76 "VBE_MODE_ATTRIBUTE_GRAPHICS_MODE"); 77 78 printf("/*Bit8u WinAAttributes*/ %s,\n", 79 "VBE_WINDOW_ATTRIBUTE_RELOCATABLE | " 80 "VBE_WINDOW_ATTRIBUTE_READABLE | " 81 "VBE_WINDOW_ATTRIBUTE_WRITEABLE"); 82 83 printf("/*Bit8u WinBAttributes*/ %d,\n", 0); 84 85 printf("/*Bit16u WinGranularity*/ %s,\n", "VBE_DISPI_BANK_SIZE_KB"); 86 87 printf("/*Bit16u WinSize*/ %s,\n", "VBE_DISPI_BANK_SIZE_KB"); 88 89 printf("/*Bit16u WinASegment*/ %s,\n", "VGAMEM_GRAPH"); 90 91 printf("/*Bit16u WinBSegment*/ 0x%04x,\n", 0); 92 93 printf("/*Bit32u WinFuncPtr*/ %d,\n", 0); 94 95 if (pm->depth == 4) 96 pitch = (pm->width + 7) / 8; 97 else 98 pitch = pm->width * ((pm->depth + 7) / 8); 99 printf("/*Bit16u BytesPerScanLine*/ %d,\n", pitch); 100 101 // Mandatory information for VBE 1.2 and above 102 printf("/*Bit16u XResolution*/ %d,\n", pm->width); 103 printf("/*Bit16u YResolution*/ %d,\n", pm->height); 104 printf("/*Bit8u XCharSize*/ %d,\n", 8); 105 printf("/*Bit8u YCharSize*/ %d,\n", 16); 106 if (pm->depth == 4) { 107 printf("/*Bit8u NumberOfPlanes*/ %d,\n", 4); 108 printf("/*Bit8u BitsPerPixel*/ %d,\n", pm->depth); 109 } else { 110 printf("/*Bit8u NumberOfPlanes*/ %d,\n", 1); 111 printf("/*Bit8u BitsPerPixel*/ %d,\n", pm->depth); 112 } 113 printf("/*Bit8u NumberOfBanks*/ %d,\n", 114 (pm->height * pitch + 65535) / 65536); 115 116 if (pm->depth == 4) 117 str = "VBE_MEMORYMODEL_PLANAR"; 118 else if (pm->depth == 8) 119 str = "VBE_MEMORYMODEL_PACKED_PIXEL"; 120 else 121 str = "VBE_MEMORYMODEL_DIRECT_COLOR"; 122 printf("/*Bit8u MemoryModel*/ %s,\n", str); 123 printf("/*Bit8u BankSize*/ %d,\n", 0); 124 /* XXX: check */ 125 printf("/*Bit8u NumberOfImagePages*/ %d,\n", 0); 126 printf("/*Bit8u Reserved_page*/ %d,\n", 0); 127 128 // Direct Color fields (required for direct/6 and YUV/7 memory models) 129 switch(pm->depth) { 130 case 15: 131 r_size = 5; 132 r_pos = 10; 133 g_size = 5; 134 g_pos = 5; 135 b_size = 5; 136 b_pos = 0; 137 a_size = 1; 138 a_pos = 15; 139 break; 140 case 16: 141 r_size = 5; 142 r_pos = 11; 143 g_size = 6; 144 g_pos = 5; 145 b_size = 5; 146 b_pos = 0; 147 a_size = 0; 148 a_pos = 0; 149 break; 150 case 24: 151 r_size = 8; 152 r_pos = 16; 153 g_size = 8; 154 g_pos = 8; 155 b_size = 8; 156 b_pos = 0; 157 a_size = 0; 158 a_pos = 0; 159 break; 160 case 32: 161 r_size = 8; 162 r_pos = 16; 163 g_size = 8; 164 g_pos = 8; 165 b_size = 8; 166 b_pos = 0; 167 a_size = 8; 168 a_pos = 24; 169 break; 170 default: 171 r_size = 0; 172 r_pos = 0; 173 g_size = 0; 174 g_pos = 0; 175 b_size = 0; 176 b_pos = 0; 177 a_size = 0; 178 a_pos = 0; 179 break; 180 } 181 182 printf("/*Bit8u RedMaskSize*/ %d,\n", r_size); 183 printf("/*Bit8u RedFieldPosition*/ %d,\n", r_pos); 184 printf("/*Bit8u GreenMaskSize*/ %d,\n", g_size); 185 printf("/*Bit8u GreenFieldPosition*/ %d,\n", g_pos); 186 printf("/*Bit8u BlueMaskSize*/ %d,\n", b_size); 187 printf("/*Bit8u BlueFieldPosition*/ %d,\n", b_pos); 188 printf("/*Bit8u RsvdMaskSize*/ %d,\n", a_size); 189 printf("/*Bit8u RsvdFieldPosition*/ %d,\n", a_pos); 190 printf("/*Bit8u DirectColorModeInfo*/ %d,\n", 0); 191 192 // Mandatory information for VBE 2.0 and above 193 printf("/*Bit32u PhysBasePtr*/ %s,\n", 194 "VBE_DISPI_LFB_PHYSICAL_ADDRESS"); 195 printf("/*Bit32u OffScreenMemOffset*/ %d,\n", 0); 196 printf("/*Bit16u OffScreenMemSize*/ %d,\n", 0); 197 // Mandatory information for VBE 3.0 and above 198 printf("/*Bit16u LinBytesPerScanLine*/ %d,\n", pitch); 199 printf("/*Bit8u BnkNumberOfPages*/ %d,\n", 0); 200 printf("/*Bit8u LinNumberOfPages*/ %d,\n", 0); 201 printf("/*Bit8u LinRedMaskSize*/ %d,\n", r_size); 202 printf("/*Bit8u LinRedFieldPosition*/ %d,\n", r_pos); 203 printf("/*Bit8u LinGreenMaskSize*/ %d,\n", g_size); 204 printf("/*Bit8u LinGreenFieldPosition*/ %d,\n", g_pos); 205 printf("/*Bit8u LinBlueMaskSize*/ %d,\n", b_size); 206 printf("/*Bit8u LinBlueFieldPosition*/ %d,\n", b_pos); 207 printf("/*Bit8u LinRsvdMaskSize*/ %d,\n", a_size); 208 printf("/*Bit8u LinRsvdFieldPosition*/ %d,\n", a_pos); 209 printf("/*Bit32u MaxPixelClock*/ %d,\n", 0); 210 printf("} },\n"); 211 } 212 printf("{ VBE_VESA_MODE_END_OF_LIST,\n"); 213 printf("{ 0,\n"); 214 printf("} },\n"); 215 printf("};\n"); 216 return 0; 217 }
Note: See TracBrowser
for help on using the repository browser.