VirtualBox

Changeset 34163 in vbox for trunk/src/VBox/VMM


Ignore:
Timestamp:
Nov 18, 2010 12:16:43 PM (14 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
67884
Message:

PGMR3PhysRomRegister/PDMDevHlpROMRegister: Added cbBinary argument to allow specifying a binary smaller than the range (no alignment restrictions either). Untested.

Location:
trunk/src/VBox/VMM
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/PDMDevHlp.cpp

    r33799 r34163  
    506506
    507507/** @interface_method_impl{PDMDEVHLPR3,pfnROMRegister} */
    508 static DECLCALLBACK(int) pdmR3DevHlp_ROMRegister(PPDMDEVINS pDevIns, RTGCPHYS GCPhysStart, RTUINT cbRange, const void *pvBinary, uint32_t fFlags, const char *pszDesc)
     508static DECLCALLBACK(int) pdmR3DevHlp_ROMRegister(PPDMDEVINS pDevIns, RTGCPHYS GCPhysStart, RTUINT cbRange,
     509                                                 const void *pvBinary, uint32_t cbBinary, uint32_t fFlags, const char *pszDesc)
    509510{
    510511    PDMDEV_ASSERT_DEVINS(pDevIns);
    511512    VM_ASSERT_EMT(pDevIns->Internal.s.pVMR3);
    512     LogFlow(("pdmR3DevHlp_ROMRegister: caller='%s'/%d: GCPhysStart=%RGp cbRange=%#x pvBinary=%p fFlags=%#RX32 pszDesc=%p:{%s}\n",
    513              pDevIns->pReg->szName, pDevIns->iInstance, GCPhysStart, cbRange, pvBinary, fFlags, pszDesc, pszDesc));
     513    LogFlow(("pdmR3DevHlp_ROMRegister: caller='%s'/%d: GCPhysStart=%RGp cbRange=%#x pvBinary=%p cbBinary=%#x fFlags=%#RX32 pszDesc=%p:{%s}\n",
     514             pDevIns->pReg->szName, pDevIns->iInstance, GCPhysStart, cbRange, pvBinary, cbBinary, fFlags, pszDesc, pszDesc));
    514515
    515516/** @todo can we mangle pszDesc? */
    516     int rc = PGMR3PhysRomRegister(pDevIns->Internal.s.pVMR3, pDevIns, GCPhysStart, cbRange, pvBinary, fFlags, pszDesc);
     517    int rc = PGMR3PhysRomRegister(pDevIns->Internal.s.pVMR3, pDevIns, GCPhysStart, cbRange, pvBinary, cbBinary, fFlags, pszDesc);
    517518
    518519    LogFlow(("pdmR3DevHlp_ROMRegister: caller='%s'/%d: returns %Rrc\n", pDevIns->pReg->szName, pDevIns->iInstance, rc));
  • trunk/src/VBox/VMM/PGMInternal.h

    r34149 r34163  
    13891389    uint8_t                             au8Alignment[3];
    13901390    /** Alignment padding ensuring that aPages is sizeof(PGMROMPAGE) aligned. */
    1391     uint32_t                            au32Alignemnt[HC_ARCH_BITS == 32 ? 6 : 2];
     1391    uint32_t                            au32Alignemnt[HC_ARCH_BITS == 32 ? 5 : 1];
     1392    /** The size bits pvOriginal points to. */
     1393    uint32_t                            cbOriginal;
    13921394    /** Pointer to the original bits when PGMPHYS_ROM_FLAGS_PERMANENT_BINARY was specified.
    13931395     * This is used for strictness checks. */
  • trunk/src/VBox/VMM/PGMPhys.cpp

    r33780 r34163  
    27682768 * @param   GCPhys              First physical address in the range.
    27692769 *                              Must be page aligned!
    2770  * @param   cbRange             The size of the range (in bytes).
     2770 * @param   cb                  The size of the range (in bytes).
    27712771 *                              Must be page aligned!
    27722772 * @param   pvBinary            Pointer to the binary data backing the ROM image.
    2773  *                              This must be exactly \a cbRange in size.
     2773 * @param   cbBinary            The size of the binary data pvBinary points to.
     2774 *                              This must be less or equal to @a cb.
    27742775 * @param   fFlags              Mask of flags. PGMPHYS_ROM_FLAGS_SHADOWED
    27752776 *                              and/or PGMPHYS_ROM_FLAGS_PERMANENT_BINARY.
     
    27812782 */
    27822783VMMR3DECL(int) PGMR3PhysRomRegister(PVM pVM, PPDMDEVINS pDevIns, RTGCPHYS GCPhys, RTGCPHYS cb,
    2783                                     const void *pvBinary, uint32_t fFlags, const char *pszDesc)
    2784 {
    2785     Log(("PGMR3PhysRomRegister: pDevIns=%p GCPhys=%RGp(-%RGp) cb=%RGp pvBinary=%p fFlags=%#x pszDesc=%s\n",
    2786          pDevIns, GCPhys, GCPhys + cb, cb, pvBinary, fFlags, pszDesc));
     2784                                    const void *pvBinary, uint32_t cbBinary, uint32_t fFlags, const char *pszDesc)
     2785{
     2786    Log(("PGMR3PhysRomRegister: pDevIns=%p GCPhys=%RGp(-%RGp) cb=%RGp pvBinary=%p cbBinary=%#x fFlags=%#x pszDesc=%s\n",
     2787         pDevIns, GCPhys, GCPhys + cb, cb, pvBinary, cbBinary, fFlags, pszDesc));
    27872788
    27882789    /*
     
    30163017                 * This must be done after linking in the RAM range.
    30173018                 */
    3018                 PPGMPAGE pRamPage = &pRamNew->aPages[(GCPhys - pRamNew->GCPhys) >> PAGE_SHIFT];
     3019                size_t          cbBinaryLeft = cbBinary;
     3020                PPGMPAGE        pRamPage     = &pRamNew->aPages[(GCPhys - pRamNew->GCPhys) >> PAGE_SHIFT];
    30193021                for (uint32_t iPage = 0; iPage < cPages; iPage++, pRamPage++)
    30203022                {
     
    30263028                        break;
    30273029                    }
    3028                     memcpy(pvDstPage, (const uint8_t *)pvBinary + (iPage << PAGE_SHIFT), PAGE_SIZE);
     3030                    if (cbBinary >= PAGE_SIZE)
     3031                    {
     3032                        memcpy(pvDstPage, (uint8_t const *)pvBinary + ((size_t)iPage << PAGE_SHIFT), PAGE_SIZE);
     3033                        cbBinaryLeft -= PAGE_SIZE;
     3034                    }
     3035                    else
     3036                    {
     3037                        ASMMemZeroPage(pvDstPage); /* (shouldn't be necessary, but can't hurt either) */
     3038                        if (cbBinaryLeft > 0)
     3039                        {
     3040                            memcpy(pvDstPage, (uint8_t const *)pvBinary + ((size_t)iPage << PAGE_SHIFT), cbBinaryLeft);
     3041                            cbBinaryLeft = 0;
     3042                        }
     3043                    }
    30293044                }
    30303045                if (RT_SUCCESS(rc))
     
    30343049                     * Note that the Virgin member of the pages has already been initialized above.
    30353050                     */
    3036                     pRomNew->GCPhys = GCPhys;
     3051                    pRomNew->GCPhys     = GCPhys;
    30373052                    pRomNew->GCPhysLast = GCPhysLast;
    3038                     pRomNew->cb = cb;
    3039                     pRomNew->fFlags = fFlags;
     3053                    pRomNew->cb         = cb;
     3054                    pRomNew->fFlags     = fFlags;
    30403055                    pRomNew->idSavedState = UINT8_MAX;
     3056                    pRomNew->cbOriginal = cbBinary;
    30413057#ifdef VBOX_STRICT
    30423058                    pRomNew->pvOriginal = fFlags & PGMPHYS_ROM_FLAGS_PERMANENT_BINARY
    3043                                         ? pvBinary : RTMemDup(pvBinary, cPages * PAGE_SIZE);
     3059                                        ? pvBinary : RTMemDup(pvBinary, cbBinary);
    30443060#else
    30453061                    pRomNew->pvOriginal = fFlags & PGMPHYS_ROM_FLAGS_PERMANENT_BINARY ? pvBinary : NULL;
    30463062#endif
    3047                     pRomNew->pszDesc = pszDesc;
     3063                    pRomNew->pszDesc    = pszDesc;
    30483064
    30493065                    for (unsigned iPage = 0; iPage < cPages; iPage++)
     
    32913307        if (pRom->pvOriginal)
    32923308        {
     3309            size_t         cbSrcLeft = pRom->cbOriginal;
    32933310            uint8_t const *pbSrcPage = (uint8_t const *)pRom->pvOriginal;
    3294             for (uint32_t iPage = 0; iPage < cPages; iPage++, pbSrcPage += PAGE_SIZE)
     3311            for (uint32_t iPage = 0; iPage < cPages && cbSrcLeft > 0; iPage++, pbSrcPage += PAGE_SIZE)
    32953312            {
    32963313                const RTGCPHYS GCPhys = pRom->GCPhys + (iPage << PAGE_SHIFT);
     
    32993316                if (RT_FAILURE(rc))
    33003317                    break;
    3301                 if (memcmp(pvDstPage, pbSrcPage, PAGE_SIZE))
     3318
     3319                if (memcmp(pvDstPage, pbSrcPage, RT_MIN(cbSrcLeft, PAGE_SIZE)))
    33023320                    LogRel(("pgmR3PhysRomReset: %RGp rom page changed (%s) - loaded saved state?\n",
    33033321                            GCPhys, pRom->pszDesc));
     3322                cbSrcLeft -= RT_MIN(cbSrcLeft, PAGE_SIZE);
    33043323            }
    33053324        }
  • trunk/src/VBox/VMM/testcase/tstVMStructRC.cpp

    r32489 r34163  
    694694    GEN_CHECK_OFF(PGMROMRANGE, cb);
    695695    GEN_CHECK_OFF(PGMROMRANGE, fFlags);
     696    GEN_CHECK_OFF(PGMROMRANGE, cbOriginal);
    696697    GEN_CHECK_OFF(PGMROMRANGE, pvOriginal);
    697698    GEN_CHECK_OFF(PGMROMRANGE, pszDesc);
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