VirtualBox

Ignore:
Timestamp:
May 27, 2009 3:19:32 PM (16 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
47839
Message:

DevAPIC,PDM: timer critsect.

File:
1 edited

Legend:

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

    r20087 r20092  
    5959/** @def APIC_LOCK
    6060 * Acquires the PDM lock. */
    61 #define APIC_LOCK(pThis, rc) \
     61#define APIC_LOCK(pThis, rcBusy) \
    6262    do { \
    63         int rc2 = (pThis)->CTX_SUFF(pApicHlp)->pfnLock((pThis)->CTX_SUFF(pDevIns), rc); \
     63        int rc2 = PDMCritSectEnter((pThis)->CTX_SUFF(pCritSect), (rcBusy)); \
    6464        if (rc2 != VINF_SUCCESS) \
    6565            return rc2; \
     
    6868/** @def APIC_LOCK_VOID
    6969 * Acquires the PDM lock and does not expect failure (i.e. ring-3 only!). */
    70 #define APIC_LOCK_VOID(pThis, rc) \
     70#define APIC_LOCK_VOID(pThis, rcBusy) \
    7171    do { \
    72         int rc2 = (pThis)->CTX_SUFF(pApicHlp)->pfnLock((pThis)->CTX_SUFF(pDevIns), rc); \
     72        int rc2 = PDMCritSectEnter((pThis)->CTX_SUFF(pCritSect), (rcBusy)); \
    7373        AssertLogRelRCReturnVoid(rc2); \
    7474    } while (0)
     
    7777 * Releases the PDM lock. */
    7878#define APIC_UNLOCK(pThis) \
    79     (pThis)->CTX_SUFF(pApicHlp)->pfnUnlock((pThis)->CTX_SUFF(pDevIns))
     79    PDMCritSectLeave((pThis)->CTX_SUFF(pCritSect))
    8080
    8181/** @def IOAPIC_LOCK
     
    281281{
    282282    /** The device instance - R3 Ptr. */
    283     PPDMDEVINSR3    pDevInsR3;
     283    PPDMDEVINSR3            pDevInsR3;
    284284    /** The APIC helpers - R3 Ptr. */
    285     PCPDMAPICHLPR3  pApicHlpR3;
     285    PCPDMAPICHLPR3          pApicHlpR3;
    286286    /** LAPICs states - R3 Ptr */
    287     RTR3PTR         pLapicsR3;
     287    RTR3PTR                 pLapicsR3;
     288    /** The critical section - R3 Ptr. */
     289    R3PTRTYPE(PPDMCRITSECT) pCritSectR3;
    288290
    289291    /** The device instance - R0 Ptr. */
    290     PPDMDEVINSR0    pDevInsR0;
     292    PPDMDEVINSR0            pDevInsR0;
    291293    /** The APIC helpers - R0 Ptr. */
    292     PCPDMAPICHLPR0  pApicHlpR0;
     294    PCPDMAPICHLPR0          pApicHlpR0;
    293295    /** LAPICs states - R0 Ptr */
    294     RTR0PTR         pLapicsR0;
     296    RTR0PTR                 pLapicsR0;
     297    /** The critical section - R3 Ptr. */
     298    R0PTRTYPE(PPDMCRITSECT) pCritSectR0;
    295299
    296300    /** The device instance - RC Ptr. */
    297     PPDMDEVINSRC    pDevInsRC;
     301    PPDMDEVINSRC            pDevInsRC;
    298302    /** The APIC helpers - RC Ptr. */
    299     PCPDMAPICHLPRC  pApicHlpRC;
     303    PCPDMAPICHLPRC          pApicHlpRC;
    300304    /** LAPICs states - RC Ptr */
    301     RTRCPTR         pLapicsRC;
     305    RTRCPTR                 pLapicsRC;
     306    /** The critical section - R3 Ptr. */
     307    RCPTRTYPE(PPDMCRITSECT) pCritSectRC;
     308    RTRCPTR                 Padding0;
    302309
    303310    /** APIC specification version in this virtual hardware configuration. */
    304     PDMAPICVERSION  enmVersion;
     311    PDMAPICVERSION          enmVersion;
    305312
    306313    /** Number of attempts made to optimize TPR accesses. */
    307     uint32_t        ulTPRPatchAttempts;
     314    uint32_t                cTPRPatchAttempts;
    308315
    309316    /** Number of CPUs on the system (same as LAPIC count). */
    310     uint32_t        cCpus;
     317    uint32_t                cCpus;
    311318
    312319# ifdef VBOX_WITH_STATISTICS
     
    13061313    APICState *s = (APICState *)pvUser;
    13071314    Assert(s->pTimerR3 == pTimer);
    1308 
    1309     APIC_LOCK_VOID(dev, VERR_INTERNAL_ERROR);
    13101315# endif /* VBOX */
    13111316
     
    13151320    }
    13161321    apic_timer_update(dev, s, s->next_time);
    1317 
    1318 # ifdef VBOX
    1319     APIC_UNLOCK(dev);
    1320 # endif
    13211322}
    13221323#endif /* IN_RING3 */
     
    20572058
    20582059            if (    index == 0x08 /* TPR */
    2059                 &&  ++s->ulTPRPatchAttempts < APIC_MAX_PATCH_ATTEMPTS)
     2060                &&  ++s->cTPRPatchAttempts < APIC_MAX_PATCH_ATTEMPTS)
    20602061            {
    20612062#ifdef IN_RC
     
    21782179static DECLCALLBACK(void) apicRelocate(PPDMDEVINS pDevIns, RTGCINTPTR offDelta)
    21792180{
    2180     APICDeviceInfo *dev = PDMINS_2_DATA(pDevIns, APICDeviceInfo *);
    2181     dev->pDevInsRC  = PDMDEVINS_2_RCPTR(pDevIns);
    2182     dev->pApicHlpRC = dev->pApicHlpR3->pfnGetRCHelpers(pDevIns);
    2183     dev->pLapicsRC  = MMHyperR3ToRC(PDMDevHlpGetVM(pDevIns), dev->pLapicsR3);
    2184     foreach_apic(dev, 0xffffffff,
     2181    APICDeviceInfo *pThis = PDMINS_2_DATA(pDevIns, APICDeviceInfo *);
     2182    pThis->pDevInsRC   = PDMDEVINS_2_RCPTR(pDevIns);
     2183    pThis->pApicHlpRC  = pThis->pApicHlpR3->pfnGetRCHelpers(pDevIns);
     2184    pThis->pLapicsRC   = MMHyperR3ToRC(PDMDevHlpGetVM(pDevIns), pThis->pLapicsR3);
     2185    pThis->pCritSectRC = pThis->pApicHlpR3->pfnGetRCCritSect(pDevIns);
     2186    foreach_apic(pThis, 0xffffffff,
    21852187                 apic->pTimerRC = TMTimerRCPtr(apic->CTX_SUFF(pTimer)));
    21862188}
     
    23462348        return rc;
    23472349    }
     2350    pThis->pCritSectR3 = pThis->pApicHlpR3->pfnGetR3CritSect(pDevIns);
    23482351
    23492352    /*
     
    23762379
    23772380    if (fGCEnabled) {
    2378         pThis->pApicHlpRC = pThis->pApicHlpR3->pfnGetRCHelpers(pDevIns);
     2381        pThis->pApicHlpRC  = pThis->pApicHlpR3->pfnGetRCHelpers(pDevIns);
     2382        pThis->pCritSectRC = pThis->pApicHlpR3->pfnGetRCCritSect(pDevIns);
    23792383
    23802384        rc = PDMDevHlpMMIORegisterGC(pDevIns, LAPIC_BASE(pThis)->apicbase & ~0xfff, 0x1000, 0,
     
    23852389
    23862390    if (fR0Enabled) {
    2387         pThis->pApicHlpR0 = pThis->pApicHlpR3->pfnGetR0Helpers(pDevIns);
     2391        pThis->pApicHlpR0  = pThis->pApicHlpR3->pfnGetR0Helpers(pDevIns);
     2392        pThis->pCritSectR0 = pThis->pApicHlpR3->pfnGetR0CritSect(pDevIns);
    23882393
    23892394        rc = PDMDevHlpMMIORegisterR0(pDevIns, LAPIC_BASE(pThis)->apicbase & ~0xfff, 0x1000, 0,
     
    24042409        apic->pTimerR0 = TMTimerR0Ptr(apic->pTimerR3);
    24052410        apic->pTimerRC = TMTimerRCPtr(apic->pTimerR3);
    2406         /// @todo TMTimerSetCritSect(apic->pTimerR3, pThis->pApicHlpR3->pfnGetCritSect(..));
     2411        TMR3TimerSetCritSect(apic->pTimerR3, pThis->pCritSectR3);
    24072412        apic++;
    24082413    }
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