Commit a41bc9af8fc6fe89a7539f1c00e743f69643d744
1 parent
3bfd9da1
explicited S3 specific code - added more debug code
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@497 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
1 changed file
with
43 additions
and
3 deletions
hw/vga.c
| @@ -50,6 +50,10 @@ | @@ -50,6 +50,10 @@ | ||
| 50 | 50 | ||
| 51 | //#define DEBUG_VGA | 51 | //#define DEBUG_VGA |
| 52 | //#define DEBUG_VGA_MEM | 52 | //#define DEBUG_VGA_MEM |
| 53 | +//#define DEBUG_VGA_REG | ||
| 54 | + | ||
| 55 | +//#define DEBUG_S3 | ||
| 56 | +#define CONFIG_S3VGA | ||
| 53 | 57 | ||
| 54 | #define MSR_COLOR_EMULATION 0x01 | 58 | #define MSR_COLOR_EMULATION 0x01 |
| 55 | #define MSR_PAGE_SELECT 0x20 | 59 | #define MSR_PAGE_SELECT 0x20 |
| @@ -252,6 +256,9 @@ static uint32_t vga_ioport_read(CPUX86State *env, uint32_t addr) | @@ -252,6 +256,9 @@ static uint32_t vga_ioport_read(CPUX86State *env, uint32_t addr) | ||
| 252 | break; | 256 | break; |
| 253 | case 0x3c5: | 257 | case 0x3c5: |
| 254 | val = s->sr[s->sr_index]; | 258 | val = s->sr[s->sr_index]; |
| 259 | +#ifdef DEBUG_VGA_REG | ||
| 260 | + printf("vga: read SR%x = 0x%02x\n", s->sr_index, val); | ||
| 261 | +#endif | ||
| 255 | break; | 262 | break; |
| 256 | case 0x3c7: | 263 | case 0x3c7: |
| 257 | val = s->dac_state; | 264 | val = s->dac_state; |
| @@ -274,6 +281,9 @@ static uint32_t vga_ioport_read(CPUX86State *env, uint32_t addr) | @@ -274,6 +281,9 @@ static uint32_t vga_ioport_read(CPUX86State *env, uint32_t addr) | ||
| 274 | break; | 281 | break; |
| 275 | case 0x3cf: | 282 | case 0x3cf: |
| 276 | val = s->gr[s->gr_index]; | 283 | val = s->gr[s->gr_index]; |
| 284 | +#ifdef DEBUG_VGA_REG | ||
| 285 | + printf("vga: read GR%x = 0x%02x\n", s->gr_index, val); | ||
| 286 | +#endif | ||
| 277 | break; | 287 | break; |
| 278 | case 0x3b4: | 288 | case 0x3b4: |
| 279 | case 0x3d4: | 289 | case 0x3d4: |
| @@ -282,6 +292,14 @@ static uint32_t vga_ioport_read(CPUX86State *env, uint32_t addr) | @@ -282,6 +292,14 @@ static uint32_t vga_ioport_read(CPUX86State *env, uint32_t addr) | ||
| 282 | case 0x3b5: | 292 | case 0x3b5: |
| 283 | case 0x3d5: | 293 | case 0x3d5: |
| 284 | val = s->cr[s->cr_index]; | 294 | val = s->cr[s->cr_index]; |
| 295 | +#ifdef DEBUG_VGA_REG | ||
| 296 | + printf("vga: read CR%x = 0x%02x\n", s->cr_index, val); | ||
| 297 | +#endif | ||
| 298 | +#ifdef DEBUG_S3 | ||
| 299 | + if (s->cr_index >= 0x20) | ||
| 300 | + printf("S3: CR read index=0x%x val=0x%x\n", | ||
| 301 | + s->cr_index, val); | ||
| 302 | +#endif | ||
| 285 | break; | 303 | break; |
| 286 | case 0x3ba: | 304 | case 0x3ba: |
| 287 | case 0x3da: | 305 | case 0x3da: |
| @@ -354,6 +372,9 @@ static void vga_ioport_write(CPUX86State *env, uint32_t addr, uint32_t val) | @@ -354,6 +372,9 @@ static void vga_ioport_write(CPUX86State *env, uint32_t addr, uint32_t val) | ||
| 354 | s->sr_index = val & 7; | 372 | s->sr_index = val & 7; |
| 355 | break; | 373 | break; |
| 356 | case 0x3c5: | 374 | case 0x3c5: |
| 375 | +#ifdef DEBUG_VGA_REG | ||
| 376 | + printf("vga: write SR%x = 0x%02x\n", s->sr_index, val); | ||
| 377 | +#endif | ||
| 357 | s->sr[s->sr_index] = val & sr_mask[s->sr_index]; | 378 | s->sr[s->sr_index] = val & sr_mask[s->sr_index]; |
| 358 | break; | 379 | break; |
| 359 | case 0x3c7: | 380 | case 0x3c7: |
| @@ -378,6 +399,9 @@ static void vga_ioport_write(CPUX86State *env, uint32_t addr, uint32_t val) | @@ -378,6 +399,9 @@ static void vga_ioport_write(CPUX86State *env, uint32_t addr, uint32_t val) | ||
| 378 | s->gr_index = val & 0x0f; | 399 | s->gr_index = val & 0x0f; |
| 379 | break; | 400 | break; |
| 380 | case 0x3cf: | 401 | case 0x3cf: |
| 402 | +#ifdef DEBUG_VGA_REG | ||
| 403 | + printf("vga: write GR%x = 0x%02x\n", s->gr_index, val); | ||
| 404 | +#endif | ||
| 381 | s->gr[s->gr_index] = val & gr_mask[s->gr_index]; | 405 | s->gr[s->gr_index] = val & gr_mask[s->gr_index]; |
| 382 | break; | 406 | break; |
| 383 | case 0x3b4: | 407 | case 0x3b4: |
| @@ -386,6 +410,9 @@ static void vga_ioport_write(CPUX86State *env, uint32_t addr, uint32_t val) | @@ -386,6 +410,9 @@ static void vga_ioport_write(CPUX86State *env, uint32_t addr, uint32_t val) | ||
| 386 | break; | 410 | break; |
| 387 | case 0x3b5: | 411 | case 0x3b5: |
| 388 | case 0x3d5: | 412 | case 0x3d5: |
| 413 | +#ifdef DEBUG_VGA_REG | ||
| 414 | + printf("vga: write CR%x = 0x%02x\n", s->cr_index, val); | ||
| 415 | +#endif | ||
| 389 | /* handle CR0-7 protection */ | 416 | /* handle CR0-7 protection */ |
| 390 | if ((s->cr[11] & 0x80) && s->cr_index <= 7) { | 417 | if ((s->cr[11] & 0x80) && s->cr_index <= 7) { |
| 391 | /* can always write bit 4 of CR7 */ | 418 | /* can always write bit 4 of CR7 */ |
| @@ -403,6 +430,7 @@ static void vga_ioport_write(CPUX86State *env, uint32_t addr, uint32_t val) | @@ -403,6 +430,7 @@ static void vga_ioport_write(CPUX86State *env, uint32_t addr, uint32_t val) | ||
| 403 | s->cr[s->cr_index] = val; | 430 | s->cr[s->cr_index] = val; |
| 404 | break; | 431 | break; |
| 405 | 432 | ||
| 433 | +#ifdef CONFIG_S3VGA | ||
| 406 | /* S3 registers */ | 434 | /* S3 registers */ |
| 407 | case 0x2d: | 435 | case 0x2d: |
| 408 | case 0x2e: | 436 | case 0x2e: |
| @@ -422,10 +450,16 @@ static void vga_ioport_write(CPUX86State *env, uint32_t addr, uint32_t val) | @@ -422,10 +450,16 @@ static void vga_ioport_write(CPUX86State *env, uint32_t addr, uint32_t val) | ||
| 422 | v = val & 3; | 450 | v = val & 3; |
| 423 | s->cr[0x69] = (s->cr[69] & ~0x0c) | (v << 2); | 451 | s->cr[0x69] = (s->cr[69] & ~0x0c) | (v << 2); |
| 424 | break; | 452 | break; |
| 453 | +#endif | ||
| 425 | default: | 454 | default: |
| 426 | s->cr[s->cr_index] = val; | 455 | s->cr[s->cr_index] = val; |
| 427 | break; | 456 | break; |
| 428 | } | 457 | } |
| 458 | +#ifdef DEBUG_S3 | ||
| 459 | + if (s->cr_index >= 0x20) | ||
| 460 | + printf("S3: CR write index=0x%x val=0x%x\n", | ||
| 461 | + s->cr_index, val); | ||
| 462 | +#endif | ||
| 429 | break; | 463 | break; |
| 430 | case 0x3ba: | 464 | case 0x3ba: |
| 431 | case 0x3da: | 465 | case 0x3da: |
| @@ -507,7 +541,6 @@ static uint32_t vga_mem_readl(uint32_t addr) | @@ -507,7 +541,6 @@ static uint32_t vga_mem_readl(uint32_t addr) | ||
| 507 | return v; | 541 | return v; |
| 508 | } | 542 | } |
| 509 | 543 | ||
| 510 | - | ||
| 511 | /* called for accesses between 0xa0000 and 0xc0000 */ | 544 | /* called for accesses between 0xa0000 and 0xc0000 */ |
| 512 | void vga_mem_writeb(uint32_t addr, uint32_t val) | 545 | void vga_mem_writeb(uint32_t addr, uint32_t val) |
| 513 | { | 546 | { |
| @@ -588,7 +621,7 @@ void vga_mem_writeb(uint32_t addr, uint32_t val) | @@ -588,7 +621,7 @@ void vga_mem_writeb(uint32_t addr, uint32_t val) | ||
| 588 | case 3: | 621 | case 3: |
| 589 | /* rotate */ | 622 | /* rotate */ |
| 590 | b = s->gr[3] & 7; | 623 | b = s->gr[3] & 7; |
| 591 | - val = ((val >> b) | (val << (8 - b))); | 624 | + val = (val >> b) | (val << (8 - b)); |
| 592 | 625 | ||
| 593 | bit_mask = s->gr[8] & val; | 626 | bit_mask = s->gr[8] & val; |
| 594 | val = mask16[s->gr[0]]; | 627 | val = mask16[s->gr[0]]; |
| @@ -787,15 +820,20 @@ static int update_basic_params(VGAState *s) | @@ -787,15 +820,20 @@ static int update_basic_params(VGAState *s) | ||
| 787 | 820 | ||
| 788 | full_update = 0; | 821 | full_update = 0; |
| 789 | /* compute line_offset in bytes */ | 822 | /* compute line_offset in bytes */ |
| 823 | + line_offset = s->cr[0x13]; | ||
| 824 | +#ifdef CONFIG_S3VGA | ||
| 790 | v = (s->cr[0x51] >> 4) & 3; /* S3 extension */ | 825 | v = (s->cr[0x51] >> 4) & 3; /* S3 extension */ |
| 791 | if (v == 0) | 826 | if (v == 0) |
| 792 | v = (s->cr[0x43] >> 2) & 1; /* S3 extension */ | 827 | v = (s->cr[0x43] >> 2) & 1; /* S3 extension */ |
| 793 | - line_offset = s->cr[0x13] | (v << 8); | 828 | + line_offset |= (v << 8); |
| 829 | +#endif | ||
| 794 | line_offset <<= 3; | 830 | line_offset <<= 3; |
| 795 | 831 | ||
| 796 | /* starting address */ | 832 | /* starting address */ |
| 797 | start_addr = s->cr[0x0d] | (s->cr[0x0c] << 8); | 833 | start_addr = s->cr[0x0d] | (s->cr[0x0c] << 8); |
| 834 | +#ifdef CONFIG_S3VGA | ||
| 798 | start_addr |= (s->cr[0x69] & 0x1f) << 16; /* S3 extension */ | 835 | start_addr |= (s->cr[0x69] & 0x1f) << 16; /* S3 extension */ |
| 836 | +#endif | ||
| 799 | 837 | ||
| 800 | /* line compare */ | 838 | /* line compare */ |
| 801 | line_compare = s->cr[0x18] | | 839 | line_compare = s->cr[0x18] | |
| @@ -1290,11 +1328,13 @@ void vga_update_display(void) | @@ -1290,11 +1328,13 @@ void vga_update_display(void) | ||
| 1290 | void vga_reset(VGAState *s) | 1328 | void vga_reset(VGAState *s) |
| 1291 | { | 1329 | { |
| 1292 | memset(s, 0, sizeof(VGAState)); | 1330 | memset(s, 0, sizeof(VGAState)); |
| 1331 | +#ifdef CONFIG_S3VGA | ||
| 1293 | /* chip ID for 8c968 */ | 1332 | /* chip ID for 8c968 */ |
| 1294 | s->cr[0x2d] = 0x88; | 1333 | s->cr[0x2d] = 0x88; |
| 1295 | s->cr[0x2e] = 0xb0; | 1334 | s->cr[0x2e] = 0xb0; |
| 1296 | s->cr[0x2f] = 0x01; /* XXX: check revision code */ | 1335 | s->cr[0x2f] = 0x01; /* XXX: check revision code */ |
| 1297 | s->cr[0x30] = 0xe1; | 1336 | s->cr[0x30] = 0xe1; |
| 1337 | +#endif | ||
| 1298 | s->graphic_mode = -1; /* force full update */ | 1338 | s->graphic_mode = -1; /* force full update */ |
| 1299 | } | 1339 | } |
| 1300 | 1340 |