|
|
1.1 root 1: Index: Makefile
2: ===================================================================
1.1.1.2 root 3: RCS file: /sources/vgabios/vgabios/Makefile,v
4: retrieving revision 1.17
5: diff -u -w -r1.17 Makefile
6: --- Makefile 6 Mar 2005 13:06:47 -0000 1.17
1.1.1.3 ! root 7: +++ Makefile 14 Jun 2006 00:51:06 -0000
! 8: @@ -22,7 +22,7 @@
! 9: cirrus-bios: vgabios-cirrus.bin vgabios-cirrus.debug.bin
1.1.1.2 root 10:
1.1.1.3 ! root 11: clean:
! 12: - /bin/rm -f biossums *.o *.s *.ld86 \
! 13: + /bin/rm -f biossums vbetables-gen vbetables.h *.o *.s *.ld86 \
! 14: temp.awk.* vgabios*.orig _vgabios_* _vgabios-debug_* core vgabios*.bin vgabios*.txt $(RELEASE).bin *.bak
1.1.1.2 root 15:
1.1.1.3 ! root 16: dist-clean: clean
! 17: @@ -79,3 +79,9 @@
1.1.1.2 root 18:
1.1.1.3 ! root 19: biossums: biossums.c
! 20: $(CC) -o biossums biossums.c
! 21: +
! 22: +vbetables-gen: vbetables-gen.c
! 23: + $(CC) -o vbetables-gen vbetables-gen.c
! 24: +
! 25: +vbetables.h: vbetables-gen
! 26: + ./vbetables-gen > $@
1.1 root 27: Index: clext.c
28: ===================================================================
1.1.1.2 root 29: RCS file: /sources/vgabios/vgabios/clext.c,v
1.1.1.3 ! root 30: retrieving revision 1.10
! 31: diff -u -w -r1.10 clext.c
! 32: --- clext.c 25 Mar 2006 10:19:15 -0000 1.10
! 33: +++ clext.c 14 Jun 2006 00:51:06 -0000
! 34: @@ -544,6 +544,13 @@
! 35: cirrus_set_video_mode_extended:
! 36: call cirrus_switch_mode
! 37: pop ax ;; mode
! 38: + test al, #0x80
! 39: + jnz cirrus_set_video_mode_extended_1
! 40: + push ax
! 41: + mov ax, #0xffff ; set to 0xff to keep win 2K happy
! 42: + call cirrus_clear_vram
! 43: + pop ax
! 44: +cirrus_set_video_mode_extended_1:
! 45: and al, #0x7f
! 46:
! 47: push ds
! 48: @@ -1011,6 +1018,13 @@
! 49: jnz cirrus_vesa_02h_3
! 50: call cirrus_enable_16k_granularity
! 51: cirrus_vesa_02h_3:
! 52: + test bx, #0x8000 ;; no clear
! 53: + jnz cirrus_vesa_02h_4
! 54: + push ax
! 55: + xor ax,ax
! 56: + call cirrus_clear_vram
! 57: + pop ax
! 58: +cirrus_vesa_02h_4:
! 59: pop ax
! 60: push ds
! 61: #ifdef CIRRUS_VESA3_PMINFO
! 62: @@ -1479,6 +1493,38 @@
! 63: pop bx
! 64: ret
! 65:
! 66: +cirrus_clear_vram:
! 67: + pusha
! 68: + push es
! 69: + mov si, ax
! 70: +
! 71: + call cirrus_enable_16k_granularity
! 72: + call cirrus_extbios_85h
! 73: + shl al, #2
! 74: + mov bl, al
! 75: + xor ah,ah
! 76: +cirrus_clear_vram_1:
! 77: + mov al, #0x09
! 78: + mov dx, #0x3ce
! 79: + out dx, ax
! 80: + push ax
! 81: + mov cx, #0xa000
! 82: + mov es, cx
! 83: + xor di, di
! 84: + mov ax, si
! 85: + mov cx, #8192
! 86: + cld
! 87: + rep
! 88: + stosw
! 89: + pop ax
! 90: + inc ah
! 91: + cmp ah, bl
! 92: + jne cirrus_clear_vram_1
! 93: +
! 94: + pop es
! 95: + popa
! 96: + ret
! 97: +
! 98: cirrus_extbios_handlers:
! 99: ;; 80h
! 100: dw cirrus_extbios_80h
! 101: Index: vbe.c
! 102: ===================================================================
! 103: RCS file: /sources/vgabios/vgabios/vbe.c,v
! 104: retrieving revision 1.48
! 105: diff -u -w -r1.48 vbe.c
! 106: --- vbe.c 26 Dec 2005 19:50:26 -0000 1.48
! 107: +++ vbe.c 14 Jun 2006 00:51:07 -0000
! 108: @@ -118,21 +118,114 @@
! 109: .word VBE_VESA_MODE_END_OF_LIST
! 110: #endif
! 111:
! 112: + .align 2
! 113: vesa_pm_start:
! 114: dw vesa_pm_set_window - vesa_pm_start
! 115: - dw vesa_pm_set_display_strt - vesa_pm_start
! 116: + dw vesa_pm_set_display_start - vesa_pm_start
! 117: dw vesa_pm_unimplemented - vesa_pm_start
! 118: - dw 0
! 119: + dw vesa_pm_io_ports_table - vesa_pm_start
! 120: +vesa_pm_io_ports_table:
! 121: + dw VBE_DISPI_IOPORT_INDEX
! 122: + dw VBE_DISPI_IOPORT_INDEX + 1
! 123: + dw VBE_DISPI_IOPORT_DATA
! 124: + dw VBE_DISPI_IOPORT_DATA + 1
! 125: + dw 0xffff
! 126: + dw 0xffff
! 127:
! 128: USE32
! 129: vesa_pm_set_window:
! 130: - mov ax, #0x4f05
! 131: - int #0x10
! 132: + cmp bx, #0x00
! 133: + je vesa_pm_set_display_window1
! 134: + mov ax, #0x0100
! 135: + ret
! 136: +vesa_pm_set_display_window1:
! 137: + mov ax, dx
! 138: + push dx
! 139: + push ax
! 140: + mov dx, # VBE_DISPI_IOPORT_INDEX
! 141: + mov ax, # VBE_DISPI_INDEX_BANK
! 142: + out dx, ax
! 143: + pop ax
! 144: + mov dx, # VBE_DISPI_IOPORT_DATA
! 145: + out dx, ax
! 146: + pop dx
! 147: + mov ax, #0x004f
! 148: ret
! 149:
! 150: vesa_pm_set_display_start:
! 151: - mov ax, #0x4f07
! 152: - int #0x10
! 153: + cmp bl, #0x80
! 154: + je vesa_pm_set_display_start1
! 155: + cmp bl, #0x00
! 156: + je vesa_pm_set_display_start1
! 157: + mov ax, #0x0100
! 158: + ret
! 159: +vesa_pm_set_display_start1:
! 160: +; convert offset to (X, Y) coordinate
! 161: +; (would be simpler to change Bochs VBE API...)
! 162: + push eax
! 163: + push ecx
! 164: + push edx
! 165: + push esi
! 166: + push edi
! 167: + shl edx, #16
! 168: + and ecx, #0xffff
! 169: + or ecx, edx
! 170: + shl ecx, #2
! 171: + mov eax, ecx
! 172: +
! 173: + push eax
! 174: + mov dx, # VBE_DISPI_IOPORT_INDEX
! 175: + mov ax, # VBE_DISPI_INDEX_VIRT_WIDTH
! 176: + out dx, ax
! 177: + mov dx, # VBE_DISPI_IOPORT_DATA
! 178: + in ax, dx
! 179: + movzx ecx, ax
! 180: +
! 181: + mov dx, # VBE_DISPI_IOPORT_INDEX
! 182: + mov ax, # VBE_DISPI_INDEX_BPP
! 183: + out dx, ax
! 184: + mov dx, # VBE_DISPI_IOPORT_DATA
! 185: + in ax, dx
! 186: + movzx esi, ax
! 187: + pop eax
! 188: +
! 189: + add esi, #7
! 190: + shr esi, #3
! 191: + imul ecx, esi
! 192: + xor edx, edx
! 193: + div ecx
! 194: + mov edi, eax
! 195: + mov eax, edx
! 196: + xor edx, edx
! 197: + div esi
! 198: +
! 199: + push dx
! 200: + push ax
! 201: + mov dx, # VBE_DISPI_IOPORT_INDEX
! 202: + mov ax, # VBE_DISPI_INDEX_X_OFFSET
! 203: + out dx, ax
! 204: + pop ax
! 205: + mov dx, # VBE_DISPI_IOPORT_DATA
! 206: + out dx, ax
! 207: + pop dx
! 208: +
! 209: + mov ax, di
! 210: + push dx
! 211: + push ax
! 212: + mov dx, # VBE_DISPI_IOPORT_INDEX
! 213: + mov ax, # VBE_DISPI_INDEX_Y_OFFSET
! 214: + out dx, ax
! 215: + pop ax
! 216: + mov dx, # VBE_DISPI_IOPORT_DATA
! 217: + out dx, ax
! 218: + pop dx
! 219: +
! 220: + pop edi
! 221: + pop esi
! 222: + pop edx
! 223: + pop ecx
! 224: + pop eax
! 225: + mov ax, #0x004f
! 226: ret
! 227:
! 228: vesa_pm_unimplemented:
! 229: @@ -835,6 +928,64 @@
! 230: ASM_END
1.1 root 231:
1.1.1.3 ! root 232:
! 233: +Bit16u vbe_biosfn_read_video_state_size()
! 234: +{
! 235: + return 9 * 2;
! 236: +}
! 237: +
! 238: +void vbe_biosfn_save_video_state(ES, BX)
! 239: + Bit16u ES; Bit16u BX;
! 240: +{
! 241: + Bit16u enable, i;
! 242: +
! 243: + outw(VBE_DISPI_IOPORT_INDEX,VBE_DISPI_INDEX_ENABLE);
! 244: + enable = inw(VBE_DISPI_IOPORT_DATA);
! 245: + write_word(ES, BX, enable);
! 246: + BX += 2;
! 247: + if (!(enable & VBE_DISPI_ENABLED))
! 248: + return;
! 249: + for(i = VBE_DISPI_INDEX_XRES; i <= VBE_DISPI_INDEX_Y_OFFSET; i++) {
! 250: + if (i != VBE_DISPI_INDEX_ENABLE) {
! 251: + outw(VBE_DISPI_IOPORT_INDEX, i);
! 252: + write_word(ES, BX, inw(VBE_DISPI_IOPORT_DATA));
! 253: + BX += 2;
! 254: + }
! 255: + }
! 256: +}
! 257: +
! 258: +
! 259: +void vbe_biosfn_restore_video_state(ES, BX)
! 260: + Bit16u ES; Bit16u BX;
! 261: +{
! 262: + Bit16u enable, i;
! 263: +
! 264: + enable = read_word(ES, BX);
! 265: + BX += 2;
! 266: +
! 267: + if (!(enable & VBE_DISPI_ENABLED)) {
! 268: + outw(VBE_DISPI_IOPORT_INDEX,VBE_DISPI_INDEX_ENABLE);
! 269: + outw(VBE_DISPI_IOPORT_DATA, enable);
! 270: + } else {
! 271: + outw(VBE_DISPI_IOPORT_INDEX, VBE_DISPI_INDEX_XRES);
! 272: + outw(VBE_DISPI_IOPORT_DATA, read_word(ES, BX));
! 273: + BX += 2;
! 274: + outw(VBE_DISPI_IOPORT_INDEX, VBE_DISPI_INDEX_YRES);
! 275: + outw(VBE_DISPI_IOPORT_DATA, read_word(ES, BX));
! 276: + BX += 2;
! 277: + outw(VBE_DISPI_IOPORT_INDEX, VBE_DISPI_INDEX_BPP);
! 278: + outw(VBE_DISPI_IOPORT_DATA, read_word(ES, BX));
! 279: + BX += 2;
! 280: + outw(VBE_DISPI_IOPORT_INDEX,VBE_DISPI_INDEX_ENABLE);
! 281: + outw(VBE_DISPI_IOPORT_DATA, enable);
! 282: +
! 283: + for(i = VBE_DISPI_INDEX_BANK; i <= VBE_DISPI_INDEX_Y_OFFSET; i++) {
! 284: + outw(VBE_DISPI_IOPORT_INDEX, i);
! 285: + outw(VBE_DISPI_IOPORT_DATA, read_word(ES, BX));
! 286: + BX += 2;
! 287: + }
! 288: + }
! 289: +}
! 290: +
! 291: /** Function 04h - Save/Restore State
! 292: *
! 293: * Input:
! 294: @@ -849,10 +1000,48 @@
! 295: * BX = Number of 64-byte blocks to hold the state buffer (if DL=00h)
! 296: *
! 297: */
! 298: -void vbe_biosfn_save_restore_state(AX, DL, CX, ES, BX)
! 299: +void vbe_biosfn_save_restore_state(AX, CX, DX, ES, BX)
! 300: +Bit16u *AX; Bit16u CX; Bit16u DX; Bit16u ES; Bit16u *BX;
1.1 root 301: {
1.1.1.3 ! root 302: -}
! 303: + Bit16u ss=get_SS();
! 304: + Bit16u result, val;
! 305:
! 306: + result = 0x4f;
! 307: + switch(GET_DL()) {
! 308: + case 0x00:
! 309: + val = biosfn_read_video_state_size2(CX);
! 310: +#ifdef DEBUG
! 311: + printf("VGA state size=%x\n", val);
! 312: +#endif
! 313: + if (CX & 8)
! 314: + val += vbe_biosfn_read_video_state_size();
! 315: + write_word(ss, BX, val);
! 316: + break;
! 317: + case 0x01:
! 318: + val = read_word(ss, BX);
! 319: + val = biosfn_save_video_state(CX, ES, val);
! 320: +#ifdef DEBUG
! 321: + printf("VGA save_state offset=%x\n", val);
! 322: +#endif
! 323: + if (CX & 8)
! 324: + vbe_biosfn_save_video_state(ES, val);
! 325: + break;
! 326: + case 0x02:
! 327: + val = read_word(ss, BX);
! 328: + val = biosfn_restore_video_state(CX, ES, val);
! 329: +#ifdef DEBUG
! 330: + printf("VGA restore_state offset=%x\n", val);
! 331: +#endif
! 332: + if (CX & 8)
! 333: + vbe_biosfn_restore_video_state(ES, val);
! 334: + break;
! 335: + default:
! 336: + // function failed
! 337: + result = 0x100;
! 338: + break;
! 339: + }
! 340: + write_word(ss, AX, result);
! 341: +}
! 342:
! 343: /** Function 05h - Display Window Control
! 344: *
! 345: @@ -1090,7 +1279,7 @@
! 346: */
! 347: ASM_START
! 348: vbe_biosfn_return_protected_mode_interface:
! 349: - test bx, bx
! 350: + test bl, bl
! 351: jnz _fail
! 352: mov di, #0xc000
! 353: mov es, di
! 354: Index: vbe.h
! 355: ===================================================================
! 356: RCS file: /sources/vgabios/vgabios/vbe.h,v
! 357: retrieving revision 1.24
! 358: diff -u -w -r1.24 vbe.h
! 359: --- vbe.h 9 May 2004 20:31:31 -0000 1.24
! 360: +++ vbe.h 14 Jun 2006 00:51:07 -0000
! 361: @@ -14,7 +14,7 @@
! 362: void vbe_biosfn_return_controller_information(AX, ES, DI);
! 363: void vbe_biosfn_return_mode_information(AX, CX, ES, DI);
! 364: void vbe_biosfn_set_mode(AX, BX, ES, DI);
! 365: -void vbe_biosfn_save_restore_state(AX, DL, CX, ES, BX);
! 366: +void vbe_biosfn_save_restore_state(AX, CX, DX, ES, BX);
! 367: void vbe_biosfn_set_get_palette_data(AX);
! 368: void vbe_biosfn_return_protected_mode_interface(AX);
! 369:
! 370: @@ -151,6 +151,12 @@
! 371: Bit8u Reserved[189];
! 372: } ModeInfoBlock;
! 373:
! 374: +typedef struct ModeInfoListItem
! 375: +{
! 376: + Bit16u mode;
! 377: + ModeInfoBlockCompact info;
! 378: +} ModeInfoListItem;
! 379: +
! 380: // VBE Return Status Info
! 381: // AL
! 382: #define VBE_RETURN_STATUS_SUPPORTED 0x4F
! 383: @@ -193,6 +199,10 @@
! 384: #define VBE_VESA_MODE_1280X1024X1555 0x119
! 385: #define VBE_VESA_MODE_1280X1024X565 0x11A
! 386: #define VBE_VESA_MODE_1280X1024X888 0x11B
! 387: +#define VBE_VESA_MODE_1600X1200X8 0x11C
! 388: +#define VBE_VESA_MODE_1600X1200X1555 0x11D
! 389: +#define VBE_VESA_MODE_1600X1200X565 0x11E
! 390: +#define VBE_VESA_MODE_1600X1200X888 0x11F
! 391:
! 392: // BOCHS/PLEX86 'own' mode numbers
! 393: #define VBE_OWN_MODE_320X200X8888 0x140
! 394: @@ -202,6 +212,12 @@
! 395: #define VBE_OWN_MODE_1024X768X8888 0x144
! 396: #define VBE_OWN_MODE_1280X1024X8888 0x145
! 397: #define VBE_OWN_MODE_320X200X8 0x146
! 398: +#define VBE_OWN_MODE_1600X1200X8888 0x147
! 399: +#define VBE_OWN_MODE_1152X864X8 0x148
! 400: +#define VBE_OWN_MODE_1152X864X1555 0x149
! 401: +#define VBE_OWN_MODE_1152X864X565 0x14a
! 402: +#define VBE_OWN_MODE_1152X864X888 0x14b
! 403: +#define VBE_OWN_MODE_1152X864X8888 0x14c
! 404:
! 405: #define VBE_VESA_MODE_END_OF_LIST 0xFFFF
! 406:
! 407: @@ -259,7 +275,7 @@
! 408: // like 0xE0000000
! 409:
! 410:
! 411: - #define VBE_DISPI_TOTAL_VIDEO_MEMORY_MB 4
! 412: + #define VBE_DISPI_TOTAL_VIDEO_MEMORY_MB 8
! 413:
! 414: #define VBE_DISPI_BANK_ADDRESS 0xA0000
! 415: #define VBE_DISPI_BANK_SIZE_KB 64
1.1.1.2 root 416: Index: vgabios.c
417: ===================================================================
418: RCS file: /sources/vgabios/vgabios/vgabios.c,v
1.1.1.3 ! root 419: retrieving revision 1.64
! 420: diff -u -w -r1.64 vgabios.c
! 421: --- vgabios.c 25 Mar 2006 10:19:16 -0000 1.64
! 422: +++ vgabios.c 14 Jun 2006 00:51:07 -0000
! 423: @@ -109,8 +109,8 @@
! 424: static void biosfn_write_string();
! 425: static void biosfn_read_state_info();
1.1.1.2 root 426: static void biosfn_read_video_state_size();
1.1.1.3 ! root 427: -static void biosfn_save_video_state();
! 428: -static void biosfn_restore_video_state();
! 429: +static Bit16u biosfn_save_video_state();
! 430: +static Bit16u biosfn_restore_video_state();
! 431: extern Bit8u video_save_pointer_table[];
1.1.1.2 root 432:
433: // This is for compiling with gcc2 and gcc3
1.1.1.3 ! root 434: @@ -748,12 +748,7 @@
! 435: vbe_biosfn_set_mode(&AX,BX,ES,DI);
! 436: break;
! 437: case 0x04:
! 438: - //FIXME
! 439: -#ifdef DEBUG
! 440: - unimplemented();
! 441: -#endif
! 442: - // function failed
! 443: - AX=0x100;
! 444: + vbe_biosfn_save_restore_state(&AX, CX, DX, ES, &BX);
! 445: break;
! 446: case 0x09:
! 447: //FIXME
! 448: @@ -3138,23 +3133,215 @@
! 449: }
1.1.1.2 root 450:
1.1.1.3 ! root 451: // --------------------------------------------------------------------------------------------
! 452: -static void biosfn_read_video_state_size (CX,ES,BX) Bit16u CX;Bit16u ES;Bit16u BX;
! 453: +// --------------------------------------------------------------------------------------------
! 454: +static Bit16u biosfn_read_video_state_size2 (CX)
! 455: + Bit16u CX;
! 456: {
! 457: -#ifdef DEBUG
! 458: - unimplemented();
! 459: -#endif
! 460: + Bit16u size;
! 461: + size = 0;
! 462: + if (CX & 1) {
! 463: + size += 0x46;
! 464: + }
! 465: + if (CX & 2) {
! 466: + size += (5 + 8 + 5) * 2 + 6;
! 467: + }
! 468: + if (CX & 4) {
! 469: + size += 3 + 256 * 3 + 1;
! 470: }
! 471: -static void biosfn_save_video_state (CX,ES,BX) Bit16u CX;Bit16u ES;Bit16u BX;
! 472: + return size;
! 473: +}
1.1.1.2 root 474: +
1.1.1.3 ! root 475: +static void biosfn_read_video_state_size (CX, BX)
! 476: + Bit16u CX; Bit16u *BX;
! 477: {
! 478: -#ifdef DEBUG
! 479: - unimplemented();
! 480: -#endif
! 481: + Bit16u ss=get_SS();
! 482: + write_word(ss, BX, biosfn_read_video_state_size2(CX));
! 483: }
! 484: -static void biosfn_restore_video_state (CX,ES,BX) Bit16u CX;Bit16u ES;Bit16u BX;
1.1.1.2 root 485: +
1.1.1.3 ! root 486: +static Bit16u biosfn_save_video_state (CX,ES,BX)
! 487: + Bit16u CX;Bit16u ES;Bit16u BX;
! 488: {
! 489: -#ifdef DEBUG
! 490: - unimplemented();
! 491: -#endif
! 492: + Bit16u i, v, crtc_addr, ar_index;
! 493: +
! 494: + crtc_addr = read_word(BIOSMEM_SEG, BIOSMEM_CRTC_ADDRESS);
! 495: + if (CX & 1) {
! 496: + write_byte(ES, BX, inb(VGAREG_SEQU_ADDRESS)); BX++;
! 497: + write_byte(ES, BX, inb(crtc_addr)); BX++;
! 498: + write_byte(ES, BX, inb(VGAREG_GRDC_ADDRESS)); BX++;
! 499: + inb(VGAREG_ACTL_RESET);
! 500: + ar_index = inb(VGAREG_ACTL_ADDRESS);
! 501: + write_byte(ES, BX, ar_index); BX++;
! 502: + write_byte(ES, BX, inb(VGAREG_READ_FEATURE_CTL)); BX++;
! 503: +
! 504: + for(i=1;i<=4;i++){
! 505: + outb(VGAREG_SEQU_ADDRESS, i);
! 506: + write_byte(ES, BX, inb(VGAREG_SEQU_DATA)); BX++;
! 507: + }
! 508: + outb(VGAREG_SEQU_ADDRESS, 0);
! 509: + write_byte(ES, BX, inb(VGAREG_SEQU_DATA)); BX++;
! 510: +
! 511: + for(i=0;i<=0x18;i++) {
! 512: + outb(crtc_addr,i);
! 513: + write_byte(ES, BX, inb(crtc_addr+1)); BX++;
! 514: + }
! 515: +
! 516: + for(i=0;i<=0x13;i++) {
! 517: + inb(VGAREG_ACTL_RESET);
! 518: + outb(VGAREG_ACTL_ADDRESS, i | (ar_index & 0x20));
! 519: + write_byte(ES, BX, inb(VGAREG_ACTL_READ_DATA)); BX++;
! 520: + }
! 521: + inb(VGAREG_ACTL_RESET);
! 522: +
! 523: + for(i=0;i<=8;i++) {
! 524: + outb(VGAREG_GRDC_ADDRESS,i);
! 525: + write_byte(ES, BX, inb(VGAREG_GRDC_DATA)); BX++;
! 526: + }
! 527: +
! 528: + write_word(ES, BX, crtc_addr); BX+= 2;
! 529: +
! 530: + /* XXX: read plane latches */
! 531: + write_byte(ES, BX, 0); BX++;
! 532: + write_byte(ES, BX, 0); BX++;
! 533: + write_byte(ES, BX, 0); BX++;
! 534: + write_byte(ES, BX, 0); BX++;
! 535: + }
! 536: + if (CX & 2) {
! 537: + write_byte(ES, BX, read_byte(BIOSMEM_SEG,BIOSMEM_CURRENT_MODE)); BX++;
! 538: + write_word(ES, BX, read_word(BIOSMEM_SEG,BIOSMEM_NB_COLS)); BX += 2;
! 539: + write_word(ES, BX, read_word(BIOSMEM_SEG,BIOSMEM_PAGE_SIZE)); BX += 2;
! 540: + write_word(ES, BX, read_word(BIOSMEM_SEG,BIOSMEM_CRTC_ADDRESS)); BX += 2;
! 541: + write_byte(ES, BX, read_byte(BIOSMEM_SEG,BIOSMEM_NB_ROWS)); BX++;
! 542: + write_word(ES, BX, read_word(BIOSMEM_SEG,BIOSMEM_CHAR_HEIGHT)); BX += 2;
! 543: + write_byte(ES, BX, read_byte(BIOSMEM_SEG,BIOSMEM_VIDEO_CTL)); BX++;
! 544: + write_byte(ES, BX, read_byte(BIOSMEM_SEG,BIOSMEM_SWITCHES)); BX++;
! 545: + write_byte(ES, BX, read_byte(BIOSMEM_SEG,BIOSMEM_MODESET_CTL)); BX++;
! 546: + write_word(ES, BX, read_word(BIOSMEM_SEG,BIOSMEM_CURSOR_TYPE)); BX += 2;
! 547: + for(i=0;i<8;i++) {
! 548: + write_word(ES, BX, read_word(BIOSMEM_SEG, BIOSMEM_CURSOR_POS+2*i));
! 549: + BX += 2;
! 550: + }
! 551: + write_word(ES, BX, read_word(BIOSMEM_SEG,BIOSMEM_CURRENT_START)); BX += 2;
! 552: + write_byte(ES, BX, read_byte(BIOSMEM_SEG,BIOSMEM_CURRENT_PAGE)); BX++;
! 553: + /* current font */
! 554: + write_word(ES, BX, read_word(0, 0x1f * 4)); BX += 2;
! 555: + write_word(ES, BX, read_word(0, 0x1f * 4 + 2)); BX += 2;
! 556: + write_word(ES, BX, read_word(0, 0x43 * 4)); BX += 2;
! 557: + write_word(ES, BX, read_word(0, 0x43 * 4 + 2)); BX += 2;
! 558: + }
! 559: + if (CX & 4) {
! 560: + /* XXX: check this */
! 561: + write_byte(ES, BX, inb(VGAREG_DAC_STATE)); BX++; /* read/write mode dac */
! 562: + write_byte(ES, BX, inb(VGAREG_DAC_WRITE_ADDRESS)); BX++; /* pix address */
! 563: + write_byte(ES, BX, inb(VGAREG_PEL_MASK)); BX++;
! 564: + // Set the whole dac always, from 0
! 565: + outb(VGAREG_DAC_WRITE_ADDRESS,0x00);
! 566: + for(i=0;i<256*3;i++) {
! 567: + write_byte(ES, BX, inb(VGAREG_DAC_DATA)); BX++;
! 568: + }
! 569: + write_byte(ES, BX, 0); BX++; /* color select register */
! 570: + }
! 571: + return BX;
! 572: +}
! 573: +
! 574: +static Bit16u biosfn_restore_video_state (CX,ES,BX)
! 575: + Bit16u CX;Bit16u ES;Bit16u BX;
! 576: +{
! 577: + Bit16u i, crtc_addr, v, addr1, ar_index;
! 578: +
! 579: + if (CX & 1) {
! 580: + // Reset Attribute Ctl flip-flop
! 581: + inb(VGAREG_ACTL_RESET);
! 582: +
! 583: + crtc_addr = read_word(ES, BX + 0x40);
! 584: + addr1 = BX;
! 585: + BX += 5;
! 586: +
! 587: + for(i=1;i<=4;i++){
! 588: + outb(VGAREG_SEQU_ADDRESS, i);
! 589: + outb(VGAREG_SEQU_DATA, read_byte(ES, BX)); BX++;
! 590: + }
! 591: + outb(VGAREG_SEQU_ADDRESS, 0);
! 592: + outb(VGAREG_SEQU_DATA, read_byte(ES, BX)); BX++;
! 593: +
! 594: + // Disable CRTC write protection
! 595: + outw(crtc_addr,0x0011);
! 596: + // Set CRTC regs
! 597: + for(i=0;i<=0x18;i++) {
! 598: + if (i != 0x11) {
! 599: + outb(crtc_addr,i);
! 600: + outb(crtc_addr+1, read_byte(ES, BX));
! 601: + }
! 602: + BX++;
! 603: + }
! 604: + // select crtc base address
! 605: + v = inb(VGAREG_READ_MISC_OUTPUT) & ~0x01;
! 606: + if (crtc_addr = 0x3d4)
! 607: + v |= 0x01;
! 608: + outb(VGAREG_WRITE_MISC_OUTPUT, v);
! 609: +
! 610: + // enable write protection if needed
! 611: + outb(crtc_addr, 0x11);
! 612: + outb(crtc_addr+1, read_byte(ES, BX - 0x18 + 0x11));
! 613: +
! 614: + // Set Attribute Ctl
! 615: + ar_index = read_byte(ES, addr1 + 0x03);
! 616: + inb(VGAREG_ACTL_RESET);
! 617: + for(i=0;i<=0x13;i++) {
! 618: + outb(VGAREG_ACTL_ADDRESS, i | (ar_index & 0x20));
! 619: + outb(VGAREG_ACTL_WRITE_DATA, read_byte(ES, BX)); BX++;
! 620: + }
! 621: + outb(VGAREG_ACTL_ADDRESS, ar_index);
! 622: + inb(VGAREG_ACTL_RESET);
! 623: +
! 624: + for(i=0;i<=8;i++) {
! 625: + outb(VGAREG_GRDC_ADDRESS,i);
! 626: + outb(VGAREG_GRDC_DATA, read_byte(ES, BX)); BX++;
! 627: + }
! 628: + BX += 2; /* crtc_addr */
! 629: + BX += 4; /* plane latches */
! 630: +
! 631: + outb(VGAREG_SEQU_ADDRESS, read_byte(ES, addr1)); addr1++;
! 632: + outb(crtc_addr, read_byte(ES, addr1)); addr1++;
! 633: + outb(VGAREG_GRDC_ADDRESS, read_byte(ES, addr1)); addr1++;
! 634: + addr1++;
! 635: + outb(crtc_addr - 0x4 + 0xa, read_byte(ES, addr1)); addr1++;
! 636: + }
! 637: + if (CX & 2) {
! 638: + write_byte(BIOSMEM_SEG,BIOSMEM_CURRENT_MODE, read_byte(ES, BX)); BX++;
! 639: + write_word(BIOSMEM_SEG,BIOSMEM_NB_COLS, read_word(ES, BX)); BX += 2;
! 640: + write_word(BIOSMEM_SEG,BIOSMEM_PAGE_SIZE, read_word(ES, BX)); BX += 2;
! 641: + write_word(BIOSMEM_SEG,BIOSMEM_CRTC_ADDRESS, read_word(ES, BX)); BX += 2;
! 642: + write_byte(BIOSMEM_SEG,BIOSMEM_NB_ROWS, read_byte(ES, BX)); BX++;
! 643: + write_word(BIOSMEM_SEG,BIOSMEM_CHAR_HEIGHT, read_word(ES, BX)); BX += 2;
! 644: + write_byte(BIOSMEM_SEG,BIOSMEM_VIDEO_CTL, read_byte(ES, BX)); BX++;
! 645: + write_byte(BIOSMEM_SEG,BIOSMEM_SWITCHES, read_byte(ES, BX)); BX++;
! 646: + write_byte(BIOSMEM_SEG,BIOSMEM_MODESET_CTL, read_byte(ES, BX)); BX++;
! 647: + write_word(BIOSMEM_SEG,BIOSMEM_CURSOR_TYPE, read_word(ES, BX)); BX += 2;
! 648: + for(i=0;i<8;i++) {
! 649: + write_word(BIOSMEM_SEG, BIOSMEM_CURSOR_POS+2*i, read_word(ES, BX));
! 650: + BX += 2;
! 651: + }
! 652: + write_word(BIOSMEM_SEG,BIOSMEM_CURRENT_START, read_word(ES, BX)); BX += 2;
! 653: + write_byte(BIOSMEM_SEG,BIOSMEM_CURRENT_PAGE, read_byte(ES, BX)); BX++;
! 654: + /* current font */
! 655: + write_word(0, 0x1f * 4, read_word(ES, BX)); BX += 2;
! 656: + write_word(0, 0x1f * 4 + 2, read_word(ES, BX)); BX += 2;
! 657: + write_word(0, 0x43 * 4, read_word(ES, BX)); BX += 2;
! 658: + write_word(0, 0x43 * 4 + 2, read_word(ES, BX)); BX += 2;
! 659: + }
! 660: + if (CX & 4) {
! 661: + BX++;
! 662: + v = read_byte(ES, BX); BX++;
! 663: + outb(VGAREG_PEL_MASK, read_byte(ES, BX)); BX++;
! 664: + // Set the whole dac always, from 0
! 665: + outb(VGAREG_DAC_WRITE_ADDRESS,0x00);
! 666: + for(i=0;i<256*3;i++) {
! 667: + outb(VGAREG_DAC_DATA, read_byte(ES, BX)); BX++;
! 668: + }
! 669: + BX++;
! 670: + outb(VGAREG_DAC_WRITE_ADDRESS, v);
! 671: + }
! 672: + return BX;
! 673: }
! 674:
! 675: // ============================================================================================
! 676: diff -u -w vbetables-gen.c
! 677: --- vbetables-gen.c 1970-01-01 01:00:00.000000000 +0100
! 678: +++ vbetables-gen.c 2006-06-14 00:52:18.000000000 +0200
! 679: @@ -0,0 +1,217 @@
! 680: +/* Generate the VGABIOS VBE Tables */
! 681: +#include <stdlib.h>
! 682: +#include <stdio.h>
1.1.1.2 root 683: +
684: +typedef struct {
1.1.1.3 ! root 685: + int width;
! 686: + int height;
! 687: + int depth;
! 688: + int mode;
! 689: +} ModeInfo;
! 690: +
! 691: +ModeInfo modes[] = {
! 692: + /* standard VESA modes */
! 693: +{ 640, 400, 8 , 0x100},
! 694: +{ 640, 480, 8 , 0x101},
! 695: +{ 800, 600, 4 , 0x102},
! 696: +{ 800, 600, 8 , 0x103},
! 697: + //{ 1024, 768, 4 , 0x104},
! 698: +{ 1024, 768, 8 , 0x105},
! 699: + //{ 1280, 1024, 4 , 0x106},
! 700: +{ 1280, 1024, 8 , 0x107},
! 701: +{ 320, 200, 15 , 0x10D},
! 702: +{ 320, 200, 16 , 0x10E},
! 703: +{ 320, 200, 24 , 0x10F},
! 704: +{ 640, 480, 15 , 0x110},
! 705: +{ 640, 480, 16 , 0x111},
! 706: +{ 640, 480, 24 , 0x112},
! 707: +{ 800, 600, 15 , 0x113},
! 708: +{ 800, 600, 16 , 0x114},
! 709: +{ 800, 600, 24 , 0x115},
! 710: +{ 1024, 768, 15 , 0x116},
! 711: +{ 1024, 768, 16 , 0x117},
! 712: +{ 1024, 768, 24 , 0x118},
! 713: +{ 1280, 1024, 15 , 0x119},
! 714: +{ 1280, 1024, 16 , 0x11A},
! 715: +{ 1280, 1024, 24 , 0x11B},
! 716: +{ 1600, 1200, 8 , 0x11C},
! 717: +{ 1600, 1200, 15 , 0x11D},
! 718: +{ 1600, 1200, 16 , 0x11E},
! 719: +{ 1600, 1200, 24 , 0x11F},
! 720: +
! 721: + /* BOCHS/PLE, 86 'own' mode numbers */
! 722: +{ 320, 200, 32 , 0x140},
! 723: +{ 640, 400, 32 , 0x141},
! 724: +{ 640, 480, 32 , 0x142},
! 725: +{ 800, 600, 32 , 0x143},
! 726: +{ 1024, 768, 32 , 0x144},
! 727: +{ 1280, 1024, 32 , 0x145},
! 728: +{ 320, 200, 8 , 0x146},
! 729: +{ 1600, 1200, 32 , 0x147},
! 730: +{ 1152, 864, 8 , 0x148},
! 731: +{ 1152, 864, 15 , 0x149},
! 732: +{ 1152, 864, 16 , 0x14a},
! 733: +{ 1152, 864, 24 , 0x14b},
! 734: +{ 1152, 864, 32 , 0x14c},
! 735: +{ 0, },
1.1.1.2 root 736: +};
737: +
1.1.1.3 ! root 738: +int main(int argc, char **argv)
! 739: +{
! 740: + const ModeInfo *pm;
! 741: + int pitch, r_size, r_pos, g_size, g_pos, b_size, b_pos, a_size, a_pos;
! 742: + const char *str;
! 743: +
! 744: + printf("/* THIS FILE IS AUTOMATICALLY GENERATED - DO NOT EDIT */\n");
! 745: + printf("static ModeInfoListItem mode_info_list[]=\n");
! 746: + printf("{\n");
! 747: + for(pm = modes; pm->mode != 0; pm++) {
! 748: + printf("{ 0x%04x, /* %dx%dx%d */\n",
! 749: + pm->mode, pm->width, pm->height, pm->depth);
! 750: + printf("{ /*Bit16u ModeAttributes*/ %s,\n",
! 751: + "VBE_MODE_ATTRIBUTE_SUPPORTED | "
! 752: + "VBE_MODE_ATTRIBUTE_EXTENDED_INFORMATION_AVAILABLE | "
! 753: + "VBE_MODE_ATTRIBUTE_COLOR_MODE | "
! 754: + "VBE_MODE_ATTRIBUTE_LINEAR_FRAME_BUFFER_MODE | "
! 755: + "VBE_MODE_ATTRIBUTE_GRAPHICS_MODE");
! 756: +
! 757: + printf("/*Bit8u WinAAttributes*/ %s,\n",
! 758: + "VBE_WINDOW_ATTRIBUTE_RELOCATABLE | "
! 759: + "VBE_WINDOW_ATTRIBUTE_READABLE | "
! 760: + "VBE_WINDOW_ATTRIBUTE_WRITEABLE");
! 761: +
! 762: + printf("/*Bit8u WinBAttributes*/ %d,\n", 0);
! 763: +
! 764: + printf("/*Bit16u WinGranularity*/ %s,\n", "VBE_DISPI_BANK_SIZE_KB");
! 765: +
! 766: + printf("/*Bit16u WinSize*/ %s,\n", "VBE_DISPI_BANK_SIZE_KB");
! 767: +
! 768: + printf("/*Bit16u WinASegment*/ %s,\n", "VGAMEM_GRAPH");
! 769: +
! 770: + printf("/*Bit16u WinBSegment*/ 0x%04x,\n", 0);
! 771: +
! 772: + printf("/*Bit32u WinFuncPtr*/ %d,\n", 0);
! 773: +
! 774: + if (pm->depth == 4)
! 775: + pitch = (pm->width + 7) / 8;
! 776: + else
! 777: + pitch = pm->width * ((pm->depth + 7) / 8);
! 778: + printf("/*Bit16u BytesPerScanLine*/ %d,\n", pitch);
! 779: +
! 780: + // Mandatory information for VBE 1.2 and above
! 781: + printf("/*Bit16u XResolution*/ %d,\n", pm->width);
! 782: + printf("/*Bit16u YResolution*/ %d,\n", pm->height);
! 783: + printf("/*Bit8u XCharSize*/ %d,\n", 8);
! 784: + printf("/*Bit8u YCharSize*/ %d,\n", 16);
! 785: + if (pm->depth == 4) {
! 786: + printf("/*Bit8u NumberOfPlanes*/ %d,\n", 4);
! 787: + printf("/*Bit8u BitsPerPixel*/ %d,\n", pm->depth);
! 788: + } else {
! 789: + printf("/*Bit8u NumberOfPlanes*/ %d,\n", 1);
! 790: + printf("/*Bit8u BitsPerPixel*/ %d,\n", pm->depth);
! 791: + }
! 792: + printf("/*Bit8u NumberOfBanks*/ %d,\n",
! 793: + (pm->height * pitch + 65535) / 65536);
! 794: +
! 795: + if (pm->depth == 4)
! 796: + str = "VBE_MEMORYMODEL_PLANAR";
! 797: + else if (pm->depth == 8)
! 798: + str = "VBE_MEMORYMODEL_PACKED_PIXEL";
! 799: + else
! 800: + str = "VBE_MEMORYMODEL_DIRECT_COLOR";
! 801: + printf("/*Bit8u MemoryModel*/ %s,\n", str);
! 802: + printf("/*Bit8u BankSize*/ %d,\n", 0);
! 803: + /* XXX: check */
! 804: + printf("/*Bit8u NumberOfImagePages*/ %d,\n", 0);
! 805: + printf("/*Bit8u Reserved_page*/ %d,\n", 0);
! 806: +
! 807: + // Direct Color fields (required for direct/6 and YUV/7 memory models)
! 808: + switch(pm->depth) {
! 809: + case 15:
! 810: + r_size = 5;
! 811: + r_pos = 10;
! 812: + g_size = 5;
! 813: + g_pos = 5;
! 814: + b_size = 5;
! 815: + b_pos = 0;
! 816: + a_size = 1;
! 817: + a_pos = 15;
! 818: + break;
! 819: + case 16:
! 820: + r_size = 5;
! 821: + r_pos = 11;
! 822: + g_size = 6;
! 823: + g_pos = 5;
! 824: + b_size = 5;
! 825: + b_pos = 0;
! 826: + a_size = 0;
! 827: + a_pos = 0;
! 828: + break;
! 829: + case 24:
! 830: + r_size = 8;
! 831: + r_pos = 16;
! 832: + g_size = 8;
! 833: + g_pos = 8;
! 834: + b_size = 8;
! 835: + b_pos = 0;
! 836: + a_size = 0;
! 837: + a_pos = 0;
! 838: + break;
! 839: + case 32:
! 840: + r_size = 8;
! 841: + r_pos = 16;
! 842: + g_size = 8;
! 843: + g_pos = 8;
! 844: + b_size = 8;
! 845: + b_pos = 0;
! 846: + a_size = 8;
! 847: + a_pos = 24;
! 848: + break;
! 849: + default:
! 850: + r_size = 0;
! 851: + r_pos = 0;
! 852: + g_size = 0;
! 853: + g_pos = 0;
! 854: + b_size = 0;
! 855: + b_pos = 0;
! 856: + a_size = 0;
! 857: + a_pos = 0;
! 858: + break;
! 859: + }
! 860: +
! 861: + printf("/*Bit8u RedMaskSize*/ %d,\n", r_size);
! 862: + printf("/*Bit8u RedFieldPosition*/ %d,\n", r_pos);
! 863: + printf("/*Bit8u GreenMaskSize*/ %d,\n", g_size);
! 864: + printf("/*Bit8u GreenFieldPosition*/ %d,\n", g_pos);
! 865: + printf("/*Bit8u BlueMaskSize*/ %d,\n", b_size);
! 866: + printf("/*Bit8u BlueFieldPosition*/ %d,\n", b_pos);
! 867: + printf("/*Bit8u RsvdMaskSize*/ %d,\n", a_size);
! 868: + printf("/*Bit8u RsvdFieldPosition*/ %d,\n", a_pos);
! 869: + printf("/*Bit8u DirectColorModeInfo*/ %d,\n", 0);
! 870: +
! 871: +// Mandatory information for VBE 2.0 and above
! 872: + printf("/*Bit32u PhysBasePtr*/ %s,\n",
! 873: + "VBE_DISPI_LFB_PHYSICAL_ADDRESS");
! 874: + printf("/*Bit32u OffScreenMemOffset*/ %d,\n", 0);
! 875: + printf("/*Bit16u OffScreenMemSize*/ %d,\n", 0);
! 876: + // Mandatory information for VBE 3.0 and above
! 877: + printf("/*Bit16u LinBytesPerScanLine*/ %d,\n", pitch);
! 878: + printf("/*Bit8u BnkNumberOfPages*/ %d,\n", 0);
! 879: + printf("/*Bit8u LinNumberOfPages*/ %d,\n", 0);
! 880: + printf("/*Bit8u LinRedMaskSize*/ %d,\n", r_size);
! 881: + printf("/*Bit8u LinRedFieldPosition*/ %d,\n", r_pos);
! 882: + printf("/*Bit8u LinGreenMaskSize*/ %d,\n", g_size);
! 883: + printf("/*Bit8u LinGreenFieldPosition*/ %d,\n", g_pos);
! 884: + printf("/*Bit8u LinBlueMaskSize*/ %d,\n", b_size);
! 885: + printf("/*Bit8u LinBlueFieldPosition*/ %d,\n", b_pos);
! 886: + printf("/*Bit8u LinRsvdMaskSize*/ %d,\n", a_size);
! 887: + printf("/*Bit8u LinRsvdFieldPosition*/ %d,\n", a_pos);
! 888: + printf("/*Bit32u MaxPixelClock*/ %d,\n", 0);
! 889: + printf("} },\n");
! 890: + }
! 891: + printf("{ VBE_VESA_MODE_END_OF_LIST,\n");
! 892: + printf("{ 0,\n");
! 893: + printf("} },\n");
! 894: + printf("};\n");
! 895: + return 0;
! 896: +}
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.