VirtualBox

Changeset 37453 in vbox


Ignore:
Timestamp:
Jun 14, 2011 6:15:11 PM (14 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
72260
Message:

DevApic: working on getting the locking right...

File:
1 edited

Legend:

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

    r37324 r37453  
    338338*   Internal Functions                                                         *
    339339*******************************************************************************/
    340 RT_C_DECLS_BEGIN
    341 PDMBOTHCBDECL(int)  apicMMIORead(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS GCPhysAddr, void *pv, unsigned cb);
    342 PDMBOTHCBDECL(int)  apicMMIOWrite(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS GCPhysAddr, void *pv, unsigned cb);
    343 PDMBOTHCBDECL(int)  apicGetInterrupt(PPDMDEVINS pDevIns);
    344 PDMBOTHCBDECL(bool) apicHasPendingIrq(PPDMDEVINS pDevIns);
    345 PDMBOTHCBDECL(void) apicSetBase(PPDMDEVINS pDevIns, uint64_t val);
    346 PDMBOTHCBDECL(uint64_t) apicGetBase(PPDMDEVINS pDevIns);
    347 PDMBOTHCBDECL(void) apicSetTPR(PPDMDEVINS pDevIns, VMCPUID idCpu, uint8_t val);
    348 PDMBOTHCBDECL(uint8_t) apicGetTPR(PPDMDEVINS pDevIns, VMCPUID idCpu);
    349 PDMBOTHCBDECL(int)  apicBusDeliverCallback(PPDMDEVINS pDevIns, uint8_t u8Dest, uint8_t u8DestMode,
    350                                            uint8_t u8DeliveryMode, uint8_t iVector, uint8_t u8Polarity,
    351                                            uint8_t u8TriggerMode);
    352 PDMBOTHCBDECL(int)  apicLocalInterrupt(PPDMDEVINS pDevIns, uint8_t u8Pin, uint8_t u8Level);
    353 PDMBOTHCBDECL(int)  apicWriteMSR(PPDMDEVINS pDevIns, VMCPUID iCpu, uint32_t u32Reg, uint64_t u64Value);
    354 PDMBOTHCBDECL(int)  apicReadMSR(PPDMDEVINS pDevIns, VMCPUID iCpu, uint32_t u32Reg, uint64_t *pu64Value);
    355 PDMBOTHCBDECL(int)  ioapicMMIORead(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS GCPhysAddr, void *pv, unsigned cb);
    356 PDMBOTHCBDECL(int)  ioapicMMIOWrite(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS GCPhysAddr, void *pv, unsigned cb);
    357 PDMBOTHCBDECL(void) ioapicSetIrq(PPDMDEVINS pDevIns, int iIrq, int iLevel);
    358 PDMBOTHCBDECL(void) ioapicSendMsi(PPDMDEVINS pDevIns, RTGCPHYS GCAddr, uint32_t uValue);
    359 
    360340static void apic_update_tpr(APICDeviceInfo *dev, APICState* s, uint32_t val);
    361 RT_C_DECLS_END
    362341
    363342static void apic_eoi(APICDeviceInfo *dev, APICState* s); /*  */
     
    720699        return VERR_EM_INTERPRETER;
    721700
    722     uint32_t index = (u32Reg - MSR_IA32_APIC_START) & 0xff;
    723     APICState* apic = getLapicById(dev, idCpu);
    724     uint64_t val = 0;
     701    uint32_t    index = (u32Reg - MSR_IA32_APIC_START) & 0xff;
     702    APICState  *apic = getLapicById(dev, idCpu);
     703    uint64_t    val = 0;
     704    int         rc = VINF_SUCCESS;
    725705
    726706    switch (index)
     
    730710            break;
    731711        case 0x03: /* version */
    732             val =   APIC_HW_VERSION                                     |
    733                     ((APIC_LVT_NB - 1) << 16) /* Max LVT index */       |
    734                     (0 << 24) /* Support for EOI broadcast suppression */;
     712            val = APIC_HW_VERSION
     713                | ((APIC_LVT_NB - 1) << 16) /* Max LVT index */
     714                | (0 << 24) /* Support for EOI broadcast suppression */;
    735715            break;
    736716        case 0x08:
     
    756736        case 0x0f:
    757737            val = apic->spurious_vec;
    758         break;
     738            break;
    759739        case 0x10: case 0x11: case 0x12: case 0x13: case 0x14: case 0x15: case 0x16: case 0x17:
    760740            val = apic->isr[index & 7];
     
    804784    }
    805785    *pu64Value = val;
    806     return VINF_SUCCESS;
     786    return rc;
    807787}
    808788
     
    12201200}
    12211201
     1202/**
     1203 * May return to ring-3 to acquire the TM and PDM lock.
     1204 */
    12221205static uint32_t apic_get_current_count(APICDeviceInfo *dev, APICState *s)
    12231206{
    12241207    int64_t d;
    12251208    uint32_t val;
     1209
     1210    /* Acquire the timer lock w/ lock order kludge. */
     1211    PDMCritSectLeave(dev->CTX_SUFF(pCritSect));
     1212    TMTimerLock(s->CTX_SUFF(pTimer), VINF_SUCCESS);
     1213    PDMCritSectEnter(dev->CTX_SUFF(pCritSect), VINF_SUCCESS);
    12261214
    12271215    d = (TMTimerGet(s->CTX_SUFF(pTimer)) - s->initial_count_load_time) >>
     
    12371225            val = s->initial_count - d;
    12381226    }
     1227
     1228    TMTimerUnlock(s->CTX_SUFF(pTimer));
     1229
    12391230    return val;
    12401231}
     
    13251316{
    13261317    STAM_COUNTER_INC(&pThis->StatTimerSetLvt);
     1318
     1319    /* Acquire the timer lock w/ lock order kludge. */
     1320    PDMCritSectLeave(dev->CTX_SUFF(pCritSect));
     1321    TMTimerLock(pThis->CTX_SUFF(pTimer), VINF_SUCCESS);
     1322    PDMCritSectEnter(dev->CTX_SUFF(pCritSect), VINF_SUCCESS);
    13271323
    13281324    /*
     
    14111407    else
    14121408        STAM_COUNTER_INC(&pThis->StatTimerSetLvtNoRelevantChange);
     1409
     1410    TMTimerUnlock(pThis->CTX_SUFF(pTimer));
    14131411}
    14141412
     
    14281426    Assert(pThis->fTimerArmed);
    14291427    Assert(PDMCritSectIsOwned(dev->pCritSectR3));
     1428    Assert(TMTimerIsLockOwner(pTimer));
    14301429
    14311430    if (!(pThis->lvt[APIC_LVT_TIMER] & APIC_LVT_MASKED)) {
     
    23782377    pThis->enmVersion = PDMAPICVERSION_APIC;
    23792378
     2379    /* Disable locking in this device. */
     2380    pDevIns->pCritSectR3 = PDMDevHlpCritSectGetNop(pDevIns);
     2381
    23802382    PVM pVM = PDMDevHlpGetVM(pDevIns);
     2383
    23812384    /*
    23822385     * We are not freeing this memory, as it's automatically released when guest exits.
Note: See TracChangeset for help on using the changeset viewer.

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