VirtualBox

Changeset 26376 in vbox for trunk/src/VBox/Devices/PC


Ignore:
Timestamp:
Feb 9, 2010 2:25:28 PM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
57469
Message:

HPET: reworking locking per Knut suggestions

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/PC/DevHPET.cpp

    r26329 r26376  
    177177    /* main counter */
    178178    uint64_t             u64HpetCounter;
     179
     180    /* Global device lock */
     181    PDMCRITSECT          csLock;
    179182} HpetState;
    180183
     
    199202static const bool fHpetLocking = true;
    200203
    201 DECLINLINE(int) hpetLock(HpetState* pThis)
     204DECLINLINE(int) hpetLock(HpetState* pThis, int rcBusy)
    202205{
    203206    if (!fHpetLocking)
    204         return 0;
    205 
    206     return pThis->CTX_SUFF(pHpetHlp)->pfnLock(pThis->CTX_SUFF(pDevIns),
    207                                               VERR_INTERNAL_ERROR);
     207        return VINF_SUCCESS;
     208
     209    return PDMCritSectEnter(&pThis->csLock, rcBusy);
    208210}
    209211
     
    213215        return;
    214216
    215     pThis->CTX_SUFF(pHpetHlp)->pfnUnlock(pThis->CTX_SUFF(pDevIns));
     217    PDMCritSectLeave(&pThis->csLock);
    216218}
    217219
     
    706708    LogFlow(("hpetMMIORead: %llx (%x)\n", (uint64_t)GCPhysAddr, iIndex));
    707709
    708     rc = hpetLock(pThis);
    709     AssertLogRelRCReturn(rc, rc);
     710    rc = hpetLock(pThis, VINF_IOM_HC_MMIO_READ);
     711    if (RT_UNLIKELY(rc != VINF_SUCCESS))
     712        return rc;
    710713
    711714    switch (cb)
     
    748751             (uint64_t)GCPhysAddr, iIndex, *(uint32_t*)pv));
    749752
    750     rc = hpetLock(pThis);
    751     AssertLogRelRCReturn(rc, rc);
     753    rc = hpetLock(pThis, VINF_IOM_HC_MMIO_WRITE);
     754    if (RT_UNLIKELY(rc != VINF_SUCCESS))
     755        return rc;
    752756
    753757    switch (cb)
     
    921925        return;
    922926
    923     rc = hpetLock(pThis);
     927    /* Lock in R3 must either block or succeed */
     928    rc = hpetLock(pThis, VERR_IGNORED);
     929   
    924930    AssertLogRelRCReturnVoid(rc);
    925931
     
    11221128        return rc;
    11231129    }
     1130
     1131    /*
     1132     * Initialize critical section.
     1133     */
     1134    rc = PDMDevHlpCritSectInit(pDevIns, &pThis->csLock, RT_SRC_POS, "HPET");
     1135    if (RT_FAILURE(rc))
     1136        return PDMDEV_SET_ERROR(pDevIns, rc, N_("HPET cannot initialize critical section"));
     1137
    11241138    /*
    11251139     * Register the MMIO range, PDM API requests page aligned
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