VirtualBox

Changeset 3721 in vbox for trunk/src/VBox/Devices


Ignore:
Timestamp:
Jul 19, 2007 5:49:50 PM (18 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
23020
Message:

Applied patch moving the logo from MMIO to port I/O space. 0xd000..0xdfff is now free again.

Location:
trunk/src/VBox/Devices/PC
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/PC/BIOS/logo.c

    r2913 r3721  
    1212#define F12_SCAN_CODE   0x86
    1313#define F12_WAIT_TIME   (3 * WAIT_HZ)   /* 3 seconds. Used only if logo disabled. */
     14
     15#define LOGO_IO_PORT    0x506
    1416
    1517typedef struct
     
    132134static Bit8u         wait(ticks, stop_on_key);
    133135static void          write_pixel();
     136static Bit8u         read_logo_byte();
     137static Bit16u        read_logo_word();
    134138
    135139/**
     
    331335}
    332336
    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;
     337void read_palette(pal_seg, bmp_off, size, type)
    365338  Bit16u pal_seg;
    366339  Bit16u bmp_off;
     
    377350        Bit8u pal;
    378351
    379         pal = read_byte(bmp_seg, bmp_off);
     352        pal = read_logo_byte(bmp_off);
    380353        write_byte(pal_seg, &palette->Blue, pal);
    381354        bmp_off++;
    382355
    383         pal = read_byte(bmp_seg, bmp_off);
     356        pal = read_logo_byte(bmp_off);
    384357        write_byte(pal_seg, &palette->Green, pal);
    385358        bmp_off++;
    386359
    387         pal = read_byte(bmp_seg, bmp_off);
     360        pal = read_logo_byte(bmp_off);
    388361        write_byte(pal_seg, &palette->Red, pal);
    389362        bmp_off++;
     
    556529}
    557530
     531Bit8u 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
     542Bit16u 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}
    558552
    559553#define VID_SEG         0xA000
    560 #define ROM_SEG         0xD000
    561554#define TMP_SEG         0x1000
    562 
    563555
    564556void show_logo()
     
    571563    OS22HDR     *os22_head;
    572564    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;
    574566    Bit32u       hdr_size;
    575567    Bit8u        vid_mode;
     
    591583    is_logo_failed = 0;
    592584
    593     // Switch to ROM bank 0
    594     write_byte(ROM_SEG, 0, logo_bank);
    595 
    596     rom_seg = bmp_seg = ROM_SEG;
    597585    logo_hdr = 0;
    598586    logo_hdr_size = sizeof(LOGOHDR);
    599587
    600588    // Get main signature
    601     tmp = read_word(rom_seg, &logo_hdr->Signature);
     589    tmp = read_logo_word(&logo_hdr->Signature);
    602590    if (tmp != 0x66BB)
    603591        goto done;
    604592
    605593    // 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);
    610598
    611599    // Is Logo disabled?
     
    620608
    621609    // Check bitmap ID
    622     tmp = read_word(rom_seg, &bmp_info->Type);
     610    tmp = read_logo_word(&bmp_info->Type);
    623611    if (tmp != 0x4D42) // 'BM'
    624612    {
     
    635623        // Check the size of the information header that indicates
    636624        // 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
    638628        if (hdr_size == BMP_HEADER_OS21) // OS2 1.x header
    639629        {
    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);
    644634            compr = COMPRESS_NONE;
    645635            clr_used = 0;
     
    648638        if (hdr_size == BMP_HEADER_OS22) // OS2 2.0 header
    649639        {
    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);
    656646        }
    657647        else
    658648        if (hdr_size == BMP_HEADER_WIN3) // Windows 3.x header
    659649        {
    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);
    666656        }
    667657        else
     
    710700        palette_data = logo_hdr_size + sizeof(BMPINFO) + hdr_size;
    711701
    712         read_palette(bmp_seg, pal_seg, palette_data, palette_size, hdr_size);
     702        read_palette(pal_seg, palette_data, palette_size, hdr_size);
    713703
    714704        //  Get current video mode
     
    728718
    729719        // 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);
    732722
    733723        switch(depth)
     
    755745                        Bit8u c;
    756746
    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);
    764748
    765749                        for (z = 0; z < 2; z++)
     
    789773                    for (z = 0; z < pad_bytes; z++)
    790774                    {
    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);
    796776                    }
    797777                }
     
    812792                        Bit16u new_bank;
    813793
    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);
    821795
    822796                        offset = (((Bit32u)start_y + (Bit32u)y) * (Bit32u)scr_width) + ((Bit32u)start_x + (Bit32u)x);
     
    835809                    for (z = 0; z < pad_bytes; z++)
    836810                    {
    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);
    842812                    }
    843813                }
     
    860830                            Bit16u new_bank;
    861831
    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);
    869833
    870834                            offset = (((Bit32u)start_y + (Bit32u)y) * (Bit32u)scr_width*3) + (((Bit32u)start_x + (Bit32u)x) * (Bit32u)3 + z);
     
    884848                    for (z = 0; z < pad_bytes; z++)
    885849                    {
    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);
    891851                    }
    892852                }
     
    997957    }
    998958
    999     // Clear video memory
    1000 #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 #endif
    1006959    goto done;
    1007960
     
    1013966        logo_hdr_size = 0;
    1014967
    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);
    1017970
    1018971        goto show_bmp;
  • trunk/src/VBox/Devices/PC/DevPcBios.cpp

    r3646 r3721  
    7777    /** Bios message buffer index. */
    7878    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;
    8183    /** The size of the BIOS logo data. */
    8284    uint32_t        cbLogo;
     
    106108typedef struct LOGOHDR
    107109{
    108     /** Signature (0x66BB). */
     110    /** Signature (LOGO_HDR_MAGIC/0x66BB). */
    109111    uint16_t        u16Signature;
    110112    /** Fade in - boolean. */
     
    121123#pragma pack()
    122124
     125/** PC port for Logo I/O */
     126#define LOGO_IO_PORT        0x506
     127
    123128/** 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
    134136
    135137#pragma pack(1)
     
    259261__BEGIN_DECLS
    260262
    261 static DECLCALLBACK(int) logoMMIORead(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS GCPhysAddr, void *pv, unsigned cb);
    262 static DECLCALLBACK(int) logoMMIOWrite(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS GCPhysAddr, void *pv, unsigned cb);
     263static DECLCALLBACK(int) logoIOPortRead(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t *pu32, unsigned cb);
     264static DECLCALLBACK(int) logoIOPortWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t u32, unsigned cb);
    263265
    264266__END_DECLS
     
    642644
    643645/**
    644  * Legacy LOGO memory (0xd0000 - 0xdffff) read hook, to be called from IOM.
     646 * LOGO port I/O Handler for IN operations.
    645647 *
    646648 * @returns VBox status code.
    647  * @param   pDevIns     Pointer device instance.
     649 *
     650 * @param   pDevIns     The device instance.
    648651 * @param   pvUser      User argument - ignored.
    649  * @param   GCPhysAddr  Physical address of memory to read.
    650  * @param   pv          Where to store readed data.
    651  * @param   cb          Bytes to read.
    652  */
    653 static DECLCALLBACK(int) logoMMIORead(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 */
     656static DECLCALLBACK(int) logoIOPortRead(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t *pu32, unsigned cb)
    654657{
    655658    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)
    677663    {
    678664        /*
    679665         * Default bios logo.
    680666         */
    681         if (offLogo > g_cbPcDefBiosLogo || offLogo + cb > g_cbPcDefBiosLogo)
    682         {
    683             Log(("logoMMIORead: 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));
    685671            return VINF_SUCCESS;
    686672        }
    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;
    691699
    692700    return VINF_SUCCESS;
     
    695703
    696704/**
    697  * Legacy LOGO memory (0xd0000 - 0xdffff) write hook, to be called from IOM.
     705 * LOGO port I/O Handler for OUT operations.
    698706 *
    699707 * @returns VBox status code.
    700  * @param   pDevIns     Pointer device instance.
     708 *
     709 * @param   pDevIns     The device instance.
    701710 * @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) logoMMIOWrite(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 */
     715static DECLCALLBACK(int) logoIOPortWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t u32, unsigned cb)
    707716{
    708717    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;
    728729
    729730    return VINF_SUCCESS;
     
    932933    LogFlow(("pcbiosReset:\n"));
    933934
    934     pData->u8LogoBank = 0;
     935    pData->fDefaultLogo = false;
     936    pData->offLogoData = 0;
    935937    /** @todo Should we perhaps do pcbiosInitComplete() on reset? */
    936938
     
    11731175
    11741176    /*
    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");
    11791180    if (VBOX_FAILURE(rc))
    11801181        return rc;
     
    11831184     * Construct the logo header.
    11841185     */
    1185     LOGOHDR LogoHdr = { LOGOHDR_MAGIC, 0, 0, 0, 0, 0 };
     1186    LOGOHDR LogoHdr = { LOGO_HDR_MAGIC, 0, 0, 0, 0, 0 };
    11861187
    11871188    rc = CFGMR3QueryU8(pCfgHandle, "FadeIn", &LogoHdr.u8FadeIn);
     
    12441245            {
    12451246                if (    cbFile > 0
    1246                     &&  cbFile < ((LOGO_BANK_LAST + 1) * LOGO_BANK_SIZE) - sizeof(LogoHdr))
     1247                    &&  cbFile < LOGO_MAX_SIZE)
    12471248                    LogoHdr.cbLogo = (uint32_t)cbFile;
    12481249                else
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette