Changeset 3721 in vbox for trunk/src/VBox/Devices
- Timestamp:
- Jul 19, 2007 5:49:50 PM (18 years ago)
- svn:sync-xref-src-repo-rev:
- 23020
- Location:
- trunk/src/VBox/Devices/PC
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/PC/BIOS/logo.c
r2913 r3721 12 12 #define F12_SCAN_CODE 0x86 13 13 #define F12_WAIT_TIME (3 * WAIT_HZ) /* 3 seconds. Used only if logo disabled. */ 14 15 #define LOGO_IO_PORT 0x506 14 16 15 17 typedef struct … … 132 134 static Bit8u wait(ticks, stop_on_key); 133 135 static void write_pixel(); 136 static Bit8u read_logo_byte(); 137 static Bit16u read_logo_word(); 134 138 135 139 /** … … 331 335 } 332 336 333 void write_pixel(x,y,color) 334 unsigned short x; 335 unsigned short y; 336 unsigned char color; 337 { 338 ASM_START 339 push bp 340 mov bp, sp 341 342 push ax 343 push bx 344 push cx 345 push dx 346 347 mov ah, #0x0C 348 xor bh, bh 349 mov al, 8[bp] ; color 350 mov cx, 4[bp] ; x 351 mov dx, 6[bp] ; y 352 int #0x10 353 354 pop dx 355 pop cx 356 pop bx 357 pop ax 358 359 pop bp 360 ASM_END 361 } 362 363 void read_palette(bmp_seg, pal_seg, bmp_off, size, type) 364 Bit16u bmp_seg; 337 void read_palette(pal_seg, bmp_off, size, type) 365 338 Bit16u pal_seg; 366 339 Bit16u bmp_off; … … 377 350 Bit8u pal; 378 351 379 pal = read_ byte(bmp_seg,bmp_off);352 pal = read_logo_byte(bmp_off); 380 353 write_byte(pal_seg, &palette->Blue, pal); 381 354 bmp_off++; 382 355 383 pal = read_ byte(bmp_seg,bmp_off);356 pal = read_logo_byte(bmp_off); 384 357 write_byte(pal_seg, &palette->Green, pal); 385 358 bmp_off++; 386 359 387 pal = read_ byte(bmp_seg,bmp_off);360 pal = read_logo_byte(bmp_off); 388 361 write_byte(pal_seg, &palette->Red, pal); 389 362 bmp_off++; … … 556 529 } 557 530 531 Bit8u read_logo_byte(offset) 532 Bit16u offset; 533 { 534 if (offset) 535 { 536 outw(LOGO_IO_PORT, offset); 537 } 538 539 return inb(LOGO_IO_PORT); 540 } 541 542 Bit16u read_logo_word(offset) 543 Bit16u offset; 544 { 545 if (offset) 546 { 547 outw(LOGO_IO_PORT, offset); 548 } 549 550 return inw(LOGO_IO_PORT); 551 } 558 552 559 553 #define VID_SEG 0xA000 560 #define ROM_SEG 0xD000561 554 #define TMP_SEG 0x1000 562 563 555 564 556 void show_logo() … … 571 563 OS22HDR *os22_head; 572 564 WINHDR *win_head; 573 Bit16u rom_seg, bmp_seg,pal_seg, logo_hdr_size, tmp, i;565 Bit16u rom_seg, pal_seg, logo_hdr_size, tmp, i; 574 566 Bit32u hdr_size; 575 567 Bit8u vid_mode; … … 591 583 is_logo_failed = 0; 592 584 593 // Switch to ROM bank 0594 write_byte(ROM_SEG, 0, logo_bank);595 596 rom_seg = bmp_seg = ROM_SEG;597 585 logo_hdr = 0; 598 586 logo_hdr_size = sizeof(LOGOHDR); 599 587 600 588 // Get main signature 601 tmp = read_ word(rom_seg,&logo_hdr->Signature);589 tmp = read_logo_word(&logo_hdr->Signature); 602 590 if (tmp != 0x66BB) 603 591 goto done; 604 592 605 593 // Get options 606 is_fade_in = read_ byte(rom_seg,&logo_hdr->FadeIn);607 is_fade_out = read_ byte(rom_seg,&logo_hdr->FadeOut);608 logo_time = read_ word(rom_seg,&logo_hdr->LogoTime);609 uBootMenu = read_ byte(rom_seg,&logo_hdr->ShowBootMenu);594 is_fade_in = read_logo_byte(&logo_hdr->FadeIn); 595 is_fade_out = read_logo_byte(&logo_hdr->FadeOut); 596 logo_time = read_logo_word(&logo_hdr->LogoTime); 597 uBootMenu = read_logo_byte(&logo_hdr->ShowBootMenu); 610 598 611 599 // Is Logo disabled? … … 620 608 621 609 // Check bitmap ID 622 tmp = read_ word(rom_seg,&bmp_info->Type);610 tmp = read_logo_word(&bmp_info->Type); 623 611 if (tmp != 0x4D42) // 'BM' 624 612 { … … 635 623 // Check the size of the information header that indicates 636 624 // the structure type 637 hdr_size = read_dword(bmp_seg, &win_head->Size); 625 hdr_size = read_logo_word(&win_head->Size); 626 hdr_size |= read_logo_word(0) << 16; 627 638 628 if (hdr_size == BMP_HEADER_OS21) // OS2 1.x header 639 629 { 640 width = read_ word(bmp_seg,&os2_head->Width);641 height = read_ word(bmp_seg,&os2_head->Height);642 planes = read_ word(bmp_seg,&os2_head->Planes);643 depth = read_ word(bmp_seg,&os2_head->BitCount);630 width = read_logo_word(&os2_head->Width); 631 height = read_logo_word(&os2_head->Height); 632 planes = read_logo_word(&os2_head->Planes); 633 depth = read_logo_word(&os2_head->BitCount); 644 634 compr = COMPRESS_NONE; 645 635 clr_used = 0; … … 648 638 if (hdr_size == BMP_HEADER_OS22) // OS2 2.0 header 649 639 { 650 width = read_ word(bmp_seg,&os22_head->Width);651 height = read_ word(bmp_seg,&os22_head->Height);652 planes = read_ word(bmp_seg,&os22_head->Planes);653 depth = read_ word(bmp_seg,&os22_head->BitCount);654 compr = read_ word(bmp_seg,&os22_head->Compression);655 clr_used = read_ word(bmp_seg,&os22_head->ClrUsed);640 width = read_logo_word(&os22_head->Width); 641 height = read_logo_word(&os22_head->Height); 642 planes = read_logo_word(&os22_head->Planes); 643 depth = read_logo_word(&os22_head->BitCount); 644 compr = read_logo_word(&os22_head->Compression); 645 clr_used = read_logo_word(&os22_head->ClrUsed); 656 646 } 657 647 else 658 648 if (hdr_size == BMP_HEADER_WIN3) // Windows 3.x header 659 649 { 660 width = read_ word(bmp_seg,&win_head->Width);661 height = read_ word(bmp_seg,&win_head->Height);662 planes = read_ word(bmp_seg,&win_head->Planes);663 depth = read_ word(bmp_seg,&win_head->BitCount);664 compr = read_ word(bmp_seg,&win_head->Compression);665 clr_used = read_ word(bmp_seg,&win_head->ClrUsed);650 width = read_logo_word(&win_head->Width); 651 height = read_logo_word(&win_head->Height); 652 planes = read_logo_word(&win_head->Planes); 653 depth = read_logo_word(&win_head->BitCount); 654 compr = read_logo_word(&win_head->Compression); 655 clr_used = read_logo_word(&win_head->ClrUsed); 666 656 } 667 657 else … … 710 700 palette_data = logo_hdr_size + sizeof(BMPINFO) + hdr_size; 711 701 712 read_palette( bmp_seg,pal_seg, palette_data, palette_size, hdr_size);702 read_palette(pal_seg, palette_data, palette_size, hdr_size); 713 703 714 704 // Get current video mode … … 728 718 729 719 // Show bitmap 730 tmp = read_ word(bmp_seg,&bmp_info->Offset);731 bmp_data = logo_hdr_size + tmp;720 tmp = read_logo_word(&bmp_info->Offset); 721 outw(LOGO_IO_PORT, logo_hdr_size + tmp); 732 722 733 723 switch(depth) … … 755 745 Bit8u c; 756 746 757 c = read_byte(bmp_seg, bmp_data++); 758 759 if (bmp_data == 0xffff) 760 { 761 bmp_data = 0; 762 write_byte(ROM_SEG, 0, ++logo_bank); 763 } 747 c = read_logo_byte(0); 764 748 765 749 for (z = 0; z < 2; z++) … … 789 773 for (z = 0; z < pad_bytes; z++) 790 774 { 791 if (++bmp_data == 0xffff) 792 { 793 bmp_data = 0; 794 write_byte(ROM_SEG, 0, ++logo_bank); 795 } 775 c = read_logo_byte(0); 796 776 } 797 777 } … … 812 792 Bit16u new_bank; 813 793 814 c = read_byte(bmp_seg, bmp_data++); 815 816 if (bmp_data == 0xffff) 817 { 818 bmp_data = 0; 819 write_byte(ROM_SEG, 0, ++logo_bank); 820 } 794 c = read_logo_byte(0); 821 795 822 796 offset = (((Bit32u)start_y + (Bit32u)y) * (Bit32u)scr_width) + ((Bit32u)start_x + (Bit32u)x); … … 835 809 for (z = 0; z < pad_bytes; z++) 836 810 { 837 if (++bmp_data == 0xffff) 838 { 839 bmp_data = 0; 840 write_byte(ROM_SEG, 0, ++logo_bank); 841 } 811 c = read_logo_byte(0); 842 812 } 843 813 } … … 860 830 Bit16u new_bank; 861 831 862 color = read_byte(bmp_seg, bmp_data++); 863 864 if (bmp_data == 0xffff) 865 { 866 bmp_data = 0; 867 write_byte(ROM_SEG, 0, ++logo_bank); 868 } 832 color = read_logo_byte(0); 869 833 870 834 offset = (((Bit32u)start_y + (Bit32u)y) * (Bit32u)scr_width*3) + (((Bit32u)start_x + (Bit32u)x) * (Bit32u)3 + z); … … 884 848 for (z = 0; z < pad_bytes; z++) 885 849 { 886 if (++bmp_data == 0xffff) 887 { 888 bmp_data = 0; 889 write_byte(ROM_SEG, 0, ++logo_bank); 890 } 850 c = read_logo_byte(0); 891 851 } 892 852 } … … 997 957 } 998 958 999 // Clear video memory1000 #if 0 // Really need to clear VESA memory?1001 for (i = 0; i < 0x9600; i += 2)1002 {1003 write_word(VID_SEG, i, 0);1004 }1005 #endif1006 959 goto done; 1007 960 … … 1013 966 logo_hdr_size = 0; 1014 967 1015 // Switch to ROM bank 255 (default logo)1016 write_byte(ROM_SEG, 0, 255);968 // Switch to defaul logo 969 outw(LOGO_IO_PORT, 0xFFFF); 1017 970 1018 971 goto show_bmp; -
trunk/src/VBox/Devices/PC/DevPcBios.cpp
r3646 r3721 77 77 /** Bios message buffer index. */ 78 78 uint32_t iMsg; 79 /** Current logo data memory bank. */ 80 uint8_t u8LogoBank; 79 /** Current logo data offset. */ 80 uint32_t offLogoData; 81 /** Use built-in or loaded logo. */ 82 bool fDefaultLogo; 81 83 /** The size of the BIOS logo data. */ 82 84 uint32_t cbLogo; … … 106 108 typedef struct LOGOHDR 107 109 { 108 /** Signature ( 0x66BB). */110 /** Signature (LOGO_HDR_MAGIC/0x66BB). */ 109 111 uint16_t u16Signature; 110 112 /** Fade in - boolean. */ … … 121 123 #pragma pack() 122 124 125 /** PC port for Logo I/O */ 126 #define LOGO_IO_PORT 0x506 127 123 128 /** The value of the LOGOHDR::u16Signature field. */ 124 #define LOGOHDR_MAGIC 0x66BB 125 126 /** Size of a logo bank. */ 127 #define LOGO_BANK_SIZE 0xffff 128 /** Logo offset mask. */ 129 #define LOGO_BANK_OFFSET 0xffff 130 /** The last bank for custom logo data. */ 131 #define LOGO_BANK_LAST 254 132 /** The bank which will give you the default logo. */ 133 #define LOGO_BANK_DEFAULT_LOGO 255 129 #define LOGO_HDR_MAGIC 0x66BB 130 131 /** The value which will switch you the default logo. */ 132 #define LOGO_DEFAULT_LOGO 0xFFFF 133 134 /** The maximal logo size in bytes. (640x480x8bpp + header/palette) */ 135 #define LOGO_MAX_SIZE 640 * 480 + 0x442 134 136 135 137 #pragma pack(1) … … 259 261 __BEGIN_DECLS 260 262 261 static DECLCALLBACK(int) logo MMIORead(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS GCPhysAddr, void *pv, unsigned cb);262 static DECLCALLBACK(int) logo MMIOWrite(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS GCPhysAddr, void *pv, unsigned cb);263 static DECLCALLBACK(int) logoIOPortRead(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t *pu32, unsigned cb); 264 static DECLCALLBACK(int) logoIOPortWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t u32, unsigned cb); 263 265 264 266 __END_DECLS … … 642 644 643 645 /** 644 * L egacy LOGO memory (0xd0000 - 0xdffff) read hook, to be called from IOM.646 * LOGO port I/O Handler for IN operations. 645 647 * 646 648 * @returns VBox status code. 647 * @param pDevIns Pointer device instance. 649 * 650 * @param pDevIns The device instance. 648 651 * @param pvUser User argument - ignored. 649 * @param GCPhysAddr Physical address of memory to read.650 * @param p v Where to store readed data.651 * @param cb Bytes toread.652 */ 653 static DECLCALLBACK(int) logo MMIORead(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS GCPhysAddr, void *pv, unsigned cb)652 * @param uPort Port number used for the IN operation. 653 * @param pu32 Where to store the result. 654 * @param cb Number of bytes read. 655 */ 656 static DECLCALLBACK(int) logoIOPortRead(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t *pu32, unsigned cb) 654 657 { 655 658 PDEVPCBIOS pData = PDMINS2DATA(pDevIns, PDEVPCBIOS); 656 Log(("logoMMIORead call GCPhysAddr:%x pv:%x cb:%d (%d)\n", GCPhysAddr, pv, cb, pData->u8LogoBank)); 657 658 uint32_t offLogo = GCPhysAddr & LOGO_BANK_OFFSET; 659 if (pData->u8LogoBank != LOGO_BANK_DEFAULT_LOGO) 660 { 661 /* 662 * Banked logo. 663 */ 664 offLogo += pData->u8LogoBank * LOGO_BANK_SIZE; 665 if ( offLogo > pData->cbLogo 666 || offLogo + cb > pData->cbLogo) 667 { 668 Log(("logoMMIORead: Requested address is out of Logo data!!! offLogo=%#x(%d) cbLogo=%#x(%d)\n", 669 offLogo, offLogo, pData->cbLogo, pData->cbLogo)); 670 return VINF_SUCCESS; 671 } 672 673 memcpy(pv, &pData->pu8Logo[offLogo], cb); 674 Log(("logoMMIORead: offLogo=%#x(%d) cb=%#x %.*Vhxs\n", offLogo, offLogo, cb, cb, &pData->pu8Logo[offLogo])); 675 } 676 else 659 Log(("logoIOPortRead call Port:%x pu32:%x cb:%d (%d)\n", Port, pu32, cb, pData->offLogoData)); 660 661 PRTUINT64U p; 662 if (pData->fDefaultLogo) 677 663 { 678 664 /* 679 665 * Default bios logo. 680 666 */ 681 if ( offLogo > g_cbPcDefBiosLogo || offLogo+ cb > g_cbPcDefBiosLogo)682 { 683 Log(("logo MMIORead: Requested address is out of Logo data!!! offLogo=%#x(%d) max:%#x(%d)\n",684 offLogo, offLogo, g_cbPcDefBiosLogo, g_cbPcDefBiosLogo));667 if (pData->offLogoData + cb > g_cbPcDefBiosLogo) 668 { 669 Log(("logoIOPortRead: Requested address is out of Logo data!!! offLogoData=%#x(%d) cbLogo=%#x(%d)\n", 670 pData->offLogoData, pData->offLogoData, g_cbPcDefBiosLogo, g_cbPcDefBiosLogo)); 685 671 return VINF_SUCCESS; 686 672 } 687 688 memcpy(pv, &g_abPcDefBiosLogo[offLogo], cb); 689 Log(("logoMMIORead: offLogo=%#x(%d) cb=%#x %.*Vhxs\n", offLogo, offLogo, cb, cb, &g_abPcDefBiosLogo[offLogo])); 690 } 673 p = (PRTUINT64U)&g_abPcDefBiosLogo[pData->offLogoData]; 674 } 675 else 676 { 677 /* 678 * Custom logo. 679 */ 680 if (pData->offLogoData + cb > pData->cbLogo) 681 { 682 Log(("logoIOPortRead: Requested address is out of Logo data!!! offLogoData=%#x(%d) cbLogo=%#x(%d)\n", 683 pData->offLogoData, pData->offLogoData, pData->cbLogo, pData->cbLogo)); 684 return VINF_SUCCESS; 685 } 686 p = (PRTUINT64U)&pData->pu8Logo[pData->offLogoData]; 687 } 688 689 switch (cb) 690 { 691 case 1: *pu32 = p->au8[0]; break; 692 case 2: *pu32 = p->au16[0]; break; 693 case 4: *pu32 = p->au32[0]; break; 694 //case 8: *pu32 = p->au64[0]; break; 695 default: AssertFailed(); break; 696 } 697 Log(("logoIOPortRead: LogoOffset=%#x(%d) cb=%#x %.*Vhxs\n", pData->offLogoData, pData->offLogoData, cb, cb, pu32)); 698 pData->offLogoData += cb; 691 699 692 700 return VINF_SUCCESS; … … 695 703 696 704 /** 697 * L egacy LOGO memory (0xd0000 - 0xdffff) write hook, to be called from IOM.705 * LOGO port I/O Handler for OUT operations. 698 706 * 699 707 * @returns VBox status code. 700 * @param pDevIns Pointer device instance. 708 * 709 * @param pDevIns The device instance. 701 710 * @param pvUser User argument - ignored. 702 * @param GCPhysAddr Physical address of memory to write.703 * @param pv Pointer to data.704 * @param cb Bytes to write.705 */ 706 static DECLCALLBACK(int) logo MMIOWrite(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS GCPhysAddr, void *pv, unsigned cb)711 * @param uPort Port number used for the IN operation. 712 * @param u32 The value to output. 713 * @param cb The value size in bytes. 714 */ 715 static DECLCALLBACK(int) logoIOPortWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t u32, unsigned cb) 707 716 { 708 717 PDEVPCBIOS pData = PDMINS2DATA(pDevIns, PDEVPCBIOS); 709 Log(("logoMMIOWrite: GCPhysAddr=%x cb=%d pv[0]=%#04x (byte)\n", GCPhysAddr, pv, cb, *(uint8_t *)pv)); 710 711 /* 712 * Byte write to off 0: Switch the logo bank. 713 */ 714 if ((GCPhysAddr & LOGO_BANK_OFFSET) == 0 && cb == 1) 715 { 716 uint8_t u8Bank = *(uint8_t *)pv; 717 uint32_t off = u8Bank * LOGO_BANK_SIZE; 718 719 if ( u8Bank != LOGO_BANK_DEFAULT_LOGO 720 && off > pData->cbLogo) 721 { 722 Log(("logoMMIOWrite: The requested bank is outside the logo image! (cbLogo=%d off=%d)\n", pData->cbLogo, off)); 723 return VINF_SUCCESS; 724 } 725 726 pData->u8LogoBank = u8Bank; 727 } 718 Log(("logoIOPortWrite: Port=%x cb=%d u32=%#04x (byte)\n", Port, cb, u32)); 719 720 /* Switch to default BIOS logo or change logo data offset. */ 721 if ( cb == 2 722 && u32 == LOGO_DEFAULT_LOGO) 723 { 724 pData->fDefaultLogo = true; 725 pData->offLogoData = 0; 726 } 727 else 728 pData->offLogoData = u32; 728 729 729 730 return VINF_SUCCESS; … … 932 933 LogFlow(("pcbiosReset:\n")); 933 934 934 pData->u8LogoBank = 0; 935 pData->fDefaultLogo = false; 936 pData->offLogoData = 0; 935 937 /** @todo Should we perhaps do pcbiosInitComplete() on reset? */ 936 938 … … 1173 1175 1174 1176 /* 1175 * Register the MMIO region for the BIOS Logo: 0x000d0000 to 0x000dffff (64k) 1176 */ 1177 rc = PDMDevHlpMMIORegister(pDevIns, 0x000d0000, 0x00010000, 0, 1178 logoMMIOWrite, logoMMIORead, NULL, "PC BIOS - Logo Buffer"); 1177 * Register the BIOS Logo port 1178 */ 1179 rc = PDMDevHlpIOPortRegister(pDevIns, LOGO_IO_PORT, 1, NULL, logoIOPortWrite, logoIOPortRead, NULL, NULL, "PC BIOS - Logo port"); 1179 1180 if (VBOX_FAILURE(rc)) 1180 1181 return rc; … … 1183 1184 * Construct the logo header. 1184 1185 */ 1185 LOGOHDR LogoHdr = { LOGO HDR_MAGIC, 0, 0, 0, 0, 0 };1186 LOGOHDR LogoHdr = { LOGO_HDR_MAGIC, 0, 0, 0, 0, 0 }; 1186 1187 1187 1188 rc = CFGMR3QueryU8(pCfgHandle, "FadeIn", &LogoHdr.u8FadeIn); … … 1244 1245 { 1245 1246 if ( cbFile > 0 1246 && cbFile < ((LOGO_BANK_LAST + 1) * LOGO_BANK_SIZE) - sizeof(LogoHdr))1247 && cbFile < LOGO_MAX_SIZE) 1247 1248 LogoHdr.cbLogo = (uint32_t)cbFile; 1248 1249 else
Note:
See TracChangeset
for help on using the changeset viewer.