VirtualBox

Ignore:
Timestamp:
Apr 6, 2012 9:05:19 PM (13 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
77321
Message:

RTSpinlock: Redid the interface, eliminating NoInts and Tmp. Whether a spinlock is interrupt safe or not is now defined at creation time, preventing stupid bugs arrising from calling the wrong acquire and/or release methods somewhere. The saved flags are stored in the spinlock strucutre, eliminating the annoying Tmp variable. Needs testing on each platform before fixing the build burn.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostDrivers/VBoxPci/VBoxPci.c

    r37423 r40806  
    7474    return NULL;
    7575}
    76 DECLINLINE(int) vboxPciDevLock(PVBOXRAWPCIINS pThis,
    77                                PRTSPINLOCKTMP pTmp)
     76DECLINLINE(int) vboxPciDevLock(PVBOXRAWPCIINS pThis)
    7877{
    7978#ifdef VBOX_WITH_SHARED_PCI_INTERRUPTS
    80     RTSpinlockAcquireNoInts(pThis->hSpinlock, pTmp);
     79    RTSpinlockAcquire(pThis->hSpinlock);
    8180    return VINF_SUCCESS;
    8281#else
     
    8988}
    9089
    91 DECLINLINE(void) vboxPciDevUnlock(PVBOXRAWPCIINS pThis,
    92                                   PRTSPINLOCKTMP pTmp)
     90DECLINLINE(void) vboxPciDevUnlock(PVBOXRAWPCIINS pThis)
    9391{
    9492#ifdef VBOX_WITH_SHARED_PCI_INTERRUPTS
    95     RTSpinlockReleaseNoInts(pThis->hSpinlock, pTmp);
     93    RTSpinlockReleaseNoInts(pThis->hSpinlock);
    9694#else
    9795    NOREF(pTmp);
     
    184182    PVBOXRAWPCIINS pThis = DEVPORT_2_VBOXRAWPCIINS(pPort);
    185183    int rc;
    186     RTSPINLOCKTMP aTmp;
    187 
    188     vboxPciDevLock(pThis, &aTmp);
     184
     185    vboxPciDevLock(pThis);
    189186
    190187    rc = vboxPciOsDevInit(pThis, fFlags);
    191188
    192     vboxPciDevUnlock(pThis, &aTmp);
     189    vboxPciDevUnlock(pThis);
    193190
    194191    return rc;
     
    202199    PVBOXRAWPCIINS pThis = DEVPORT_2_VBOXRAWPCIINS(pPort);
    203200    int            rc;
    204     RTSPINLOCKTMP  aTmp;
    205 
    206     vboxPciDevLock(pThis, &aTmp);
     201
     202    vboxPciDevLock(pThis);
    207203
    208204    if (pThis->IrqHandler.pfnIrqHandler)
     
    215211    rc = vboxPciOsDevDeinit(pThis, fFlags);
    216212
    217     vboxPciDevUnlock(pThis, &aTmp);
     213    vboxPciDevUnlock(pThis);
    218214
    219215    return rc;
     
    265261    PVBOXRAWPCIINS pThis = DEVPORT_2_VBOXRAWPCIINS(pPort);
    266262    int            rc;
    267     RTSPINLOCKTMP  aTmp;
    268 
    269     vboxPciDevLock(pThis, &aTmp);
     263
     264    vboxPciDevLock(pThis);
    270265
    271266    rc = vboxPciOsDevGetRegionInfo(pThis, iRegion,
    272267                                   pRegionStart, pu64RegionSize,
    273268                                   pfPresent, pfFlags);
    274     vboxPciDevUnlock(pThis, &aTmp);
     269    vboxPciDevUnlock(pThis);
    275270
    276271    return rc;
     
    289284    PVBOXRAWPCIINS pThis = DEVPORT_2_VBOXRAWPCIINS(pPort);
    290285    int            rc;
    291     RTSPINLOCKTMP  aTmp;
    292 
    293     vboxPciDevLock(pThis, &aTmp);
     286
     287    vboxPciDevLock(pThis);
    294288
    295289    rc = vboxPciOsDevMapRegion(pThis, iRegion, RegionStart, u64RegionSize, fFlags, pRegionBase);
    296290
    297     vboxPciDevUnlock(pThis, &aTmp);
     291    vboxPciDevUnlock(pThis);
    298292
    299293    return rc;
     
    311305    PVBOXRAWPCIINS pThis = DEVPORT_2_VBOXRAWPCIINS(pPort);
    312306    int            rc;
    313     RTSPINLOCKTMP  aTmp;
    314 
    315     vboxPciDevLock(pThis, &aTmp);
     307
     308    vboxPciDevLock(pThis);
    316309
    317310    rc = vboxPciOsDevUnmapRegion(pThis, iRegion, RegionStart, u64RegionSize, RegionBase);
    318311
    319     vboxPciDevUnlock(pThis, &aTmp);
     312    vboxPciDevUnlock(pThis);
    320313
    321314    return rc;
     
    330323{
    331324    PVBOXRAWPCIINS pThis = DEVPORT_2_VBOXRAWPCIINS(pPort);
    332     RTSPINLOCKTMP  aTmp;
    333     int            rc;
    334 
    335     vboxPciDevLock(pThis, &aTmp);
     325    int            rc;
     326
     327    vboxPciDevLock(pThis);
    336328
    337329    rc = vboxPciOsDevPciCfgRead(pThis, Register, pValue);
    338330
    339     vboxPciDevUnlock(pThis, &aTmp);
     331    vboxPciDevUnlock(pThis);
    340332
    341333    return rc;
     
    351343    PVBOXRAWPCIINS pThis = DEVPORT_2_VBOXRAWPCIINS(pPort);
    352344    int            rc;
    353     RTSPINLOCKTMP  aTmp;
    354 
    355     vboxPciDevLock(pThis, &aTmp);
     345
     346    vboxPciDevLock(pThis);
    356347
    357348    rc = vboxPciOsDevPciCfgWrite(pThis, Register, pValue);
    358349
    359     vboxPciDevUnlock(pThis, &aTmp);
     350    vboxPciDevUnlock(pThis);
    360351
    361352    return rc;
     
    370361    int            rc;
    371362    int32_t        iHostIrq = 0;
    372     RTSPINLOCKTMP  aTmp;
    373363
    374364    if (pfnHandler == NULL)
    375365        return VERR_INVALID_PARAMETER;
    376366
    377     vboxPciDevLock(pThis, &aTmp);
     367    vboxPciDevLock(pThis);
    378368
    379369    if (pThis->IrqHandler.pfnIrqHandler)
     
    393383    }
    394384
    395     vboxPciDevUnlock(pThis, &aTmp);
     385    vboxPciDevUnlock(pThis);
    396386
    397387    return rc;
     
    403393    PVBOXRAWPCIINS pThis = DEVPORT_2_VBOXRAWPCIINS(pPort);
    404394    int            rc;
    405     RTSPINLOCKTMP  aTmp;
    406395
    407396    if (hIsr != 0xcafe0000)
    408397        return VERR_INVALID_PARAMETER;
    409398
    410     vboxPciDevLock(pThis, &aTmp);
     399    vboxPciDevLock(pThis);
    411400
    412401    rc = vboxPciOsDevUnregisterIrqHandler(pThis, pThis->IrqHandler.iHostIrq);
     
    417406        pThis->IrqHandler.iHostIrq = 0;
    418407    }
    419     vboxPciDevUnlock(pThis, &aTmp);
     408    vboxPciDevUnlock(pThis);
    420409
    421410    return rc;
     
    428417    PVBOXRAWPCIINS pThis = DEVPORT_2_VBOXRAWPCIINS(pPort);
    429418    int            rc;
    430     RTSPINLOCKTMP  aTmp;
    431 
    432     vboxPciDevLock(pThis, &aTmp);
     419
     420    vboxPciDevLock(pThis);
    433421
    434422    rc = vboxPciOsDevPowerStateChange(pThis, aState);
     
    448436
    449437
    450     vboxPciDevUnlock(pThis, &aTmp);
     438    vboxPciDevUnlock(pThis);
    451439
    452440    return rc;
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