VirtualBox

Changeset 37526 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Jun 17, 2011 10:17:38 AM (14 years ago)
Author:
vboxsync
Message:

Dev*: Timer locking fixes.

Location:
trunk/src/VBox/Devices/PC
Files:
5 edited

Legend:

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

    r37519 r37526  
    20102010        if (RT_FAILURE(rc))
    20112011            return rc;
     2012        TMTimerLock(pThis->pPmTimerR3, VERR_IGNORED);
    20122013        acpiPmTimerReset(pThis, TMTimerGet(pThis->pPmTimerR3));
     2014        TMTimerUnlock(pThis->pPmTimerR3);
    20132015    }
    20142016    return rc;
     
    27422744    ACPIState *pThis = PDMINS_2_DATA(pDevIns, ACPIState *);
    27432745
     2746    TMTimerLock(pThis->pPmTimerR3, VERR_IGNORED);
    27442747    pThis->pm1a_en           = 0;
    27452748    pThis->pm1a_sts          = 0;
     
    27522755    pThis->gpe0_sts          = 0;
    27532756    pThis->uSleepState       = 0;
     2757    TMTimerUnlock(pThis->pPmTimerR3);
    27542758
    27552759    /** @todo Should we really reset PM base? */
     
    30623066     * Create the PM timer.
    30633067     */
     3068    PTMTIMER pTimer;
    30643069    rc = PDMDevHlpTMTimerCreate(pDevIns, TMCLOCK_VIRTUAL_SYNC, acpiPmTimer, &pThis->dev,
    3065                                 TMTIMER_FLAGS_NO_CRIT_SECT, "ACPI PM Timer", &pThis->pPmTimerR3);
    3066     if (RT_FAILURE(rc))
    3067     {
    3068         AssertMsgFailed(("pfnTMTimerCreate -> %Rrc\n", rc));
    3069         return rc;
    3070     }
    3071 
    3072     pThis->pPmTimerR0 = TMTimerR0Ptr(pThis->pPmTimerR3);
    3073     pThis->pPmTimerRC = TMTimerRCPtr(pThis->pPmTimerR3);
    3074     pThis->u64PmTimerInitial = TMTimerGet(pThis->pPmTimerR3);
     3070                                TMTIMER_FLAGS_NO_CRIT_SECT, "ACPI PM Timer", &pTimer);
     3071    AssertRCReturn(rc, rc);
     3072    pThis->pPmTimerR3 = pTimer;
     3073    pThis->pPmTimerR0 = TMTimerR0Ptr(pTimer);
     3074    pThis->pPmTimerRC = TMTimerRCPtr(pTimer);
     3075
     3076    rc = TMTimerLock(pTimer, VERR_IGNORED);
     3077    AssertRCReturn(rc, rc);
     3078    pThis->u64PmTimerInitial = TMTimerGet(pTimer);
    30753079    acpiPmTimerReset(pThis, pThis->u64PmTimerInitial);
     3080    TMTimerUnlock(pTimer);
    30763081
    30773082    /*
  • trunk/src/VBox/Devices/PC/DevAPIC.cpp

    r37481 r37526  
    19591959{
    19601960    APICDeviceInfo *pDev = PDMINS_2_DATA(pDevIns, APICDeviceInfo *);
    1961     APIC_LOCK_VOID(pDev, VERR_INTERNAL_ERROR);
     1961    TMTimerLock(pDev->paLapicsR3[0].pTimerR3, VERR_IGNORED);
     1962    APIC_LOCK_VOID(pDev, VERR_IGNORED);
    19621963
    19631964    /* Reset all APICs. */
     
    19841985
    19851986    APIC_UNLOCK(pDev);
     1987    TMTimerUnlock(pDev->paLapicsR3[0].pTimerR3);
    19861988}
    19871989
  • trunk/src/VBox/Devices/PC/DevHPET.cpp

    r37510 r37526  
    12531253    LogFlow(("hpetReset:\n"));
    12541254
    1255     pThis->u64HpetConfig = 0;
     1255    /*
     1256     * The timers first.
     1257     */
     1258    TMTimerLock(pThis->aTimers[0].pTimerR3, VERR_IGNORED);
    12561259    for (unsigned i = 0; i < HPET_NUM_TIMERS; i++)
    12571260    {
     
    12751278        pHpetTimer->u64Cmp     = hpetInvalidValue(pHpetTimer);
    12761279    }
     1280    TMTimerUnlock(pThis->aTimers[0].pTimerR3);
     1281
     1282    /*
     1283     * The HPET state.
     1284     */
     1285    pThis->u64HpetConfig  = 0;
    12771286    pThis->u64HpetCounter = 0;
    12781287    pThis->u64HpetOffset  = 0;
     
    12901299    pThis->u64Capabilities |= ((uint64_t)(pThis->fIch9 ? HPET_CLK_PERIOD_ICH9 : HPET_CLK_PERIOD) << 32);
    12911300
    1292     /* Notify PIT/RTC devices */
     1301    /*
     1302     * Notify the PIT/RTC devices.
     1303     */
    12931304    if (pThis->pHpetHlpR3)
    12941305        pThis->pHpetHlpR3->pfnSetLegacyMode(pDevIns, false /*fActive*/);
  • trunk/src/VBox/Devices/PC/DevPit-i8254.cpp

    r37515 r37526  
    977977            LogRel(("PIT: mode=%d count=%#x (%u) - %d.%02d Hz (ch=%d) (restore)\n",
    978978                    s->mode, s->count, s->count, PIT_FREQ / s->count, (PIT_FREQ * 100 / s->count) % 100, i));
     979            PDMCritSectEnter(&pThis->CritSect, VERR_IGNORED);
    979980            TMTimerSetFrequencyHint(s->CTX_SUFF(pTimer), PIT_FREQ / s->count);
     981            PDMCritSectLeave(&pThis->CritSect);
    980982        }
    981983        pThis->channels[i].cRelLogEntries = 0;
  • trunk/src/VBox/Devices/PC/DevRTC.cpp

    r37514 r37526  
    10581058
    10591059    /*
    1060      * Create timers, arm them, register I/O Ports and save state.
     1060     * Create timers.
    10611061     */
     1062    PTMTIMER pTimer;
     1063    /* Periodic timer. */
    10621064    rc = PDMDevHlpTMTimerCreate(pDevIns, TMCLOCK_VIRTUAL_SYNC, rtcTimerPeriodic, pThis,
    10631065                                TMTIMER_FLAGS_DEFAULT_CRIT_SECT, "MC146818 RTC/CMOS - Periodic",
    1064                                 &pThis->pPeriodicTimerR3);
     1066                                &pTimer);
    10651067    if (RT_FAILURE(rc))
    10661068        return rc;
    1067     pThis->pPeriodicTimerR0 = TMTimerR0Ptr(pThis->pPeriodicTimerR3);
    1068     pThis->pPeriodicTimerRC = TMTimerRCPtr(pThis->pPeriodicTimerR3);
    1069 
     1069    pThis->pPeriodicTimerR3 = pTimer;
     1070    pThis->pPeriodicTimerR0 = TMTimerR0Ptr(pTimer);
     1071    pThis->pPeriodicTimerRC = TMTimerRCPtr(pTimer);
     1072
     1073    /* Seconds timer. */
    10701074    rc = PDMDevHlpTMTimerCreate(pDevIns, TMCLOCK_VIRTUAL_SYNC, rtcTimerSecond, pThis,
    10711075                                TMTIMER_FLAGS_DEFAULT_CRIT_SECT, "MC146818 RTC/CMOS - Second",
    1072                                 &pThis->pSecondTimerR3);
     1076                                &pTimer);
    10731077    if (RT_FAILURE(rc))
    10741078        return rc;
    1075     pThis->pSecondTimerR0 = TMTimerR0Ptr(pThis->pSecondTimerR3);
    1076     pThis->pSecondTimerRC = TMTimerRCPtr(pThis->pSecondTimerR3);
    1077 
     1079    pThis->pSecondTimerR3 = pTimer;
     1080    pThis->pSecondTimerR0 = TMTimerR0Ptr(pTimer);
     1081    pThis->pSecondTimerRC = TMTimerRCPtr(pTimer);
     1082
     1083    /* The second2 timer, this is always active. */
    10781084    rc = PDMDevHlpTMTimerCreate(pDevIns, TMCLOCK_VIRTUAL_SYNC, rtcTimerSecond2, pThis,
    10791085                                TMTIMER_FLAGS_DEFAULT_CRIT_SECT, "MC146818 RTC/CMOS - Second2",
    1080                                 &pThis->pSecondTimer2R3);
     1086                                &pTimer);
    10811087    if (RT_FAILURE(rc))
    10821088        return rc;
    1083     pThis->pSecondTimer2R0  = TMTimerR0Ptr(pThis->pSecondTimer2R3);
    1084     pThis->pSecondTimer2RC  = TMTimerRCPtr(pThis->pSecondTimer2R3);
    1085     pThis->next_second_time = TMTimerGet(pThis->CTX_SUFF(pSecondTimer2))
    1086                             + (TMTimerGetFreq(pThis->CTX_SUFF(pSecondTimer2)) * 99) / 100;
    1087     rc = TMTimerSet(pThis->CTX_SUFF(pSecondTimer2), pThis->next_second_time);
    1088     if (RT_FAILURE(rc))
    1089         return rc;
    1090 
    1091 
     1089    pThis->pSecondTimer2R3  = pTimer;
     1090    pThis->pSecondTimer2R0  = TMTimerR0Ptr(pTimer);
     1091    pThis->pSecondTimer2RC  = TMTimerRCPtr(pTimer);
     1092    pThis->next_second_time = TMTimerGet(pTimer)
     1093                            + (TMTimerGetFreq(pTimer) * 99) / 100;
     1094    rc = TMTimerLock(pTimer, VERR_IGNORED);
     1095    AssertRCReturn(rc, rc);
     1096    rc = TMTimerSet(pTimer, pThis->next_second_time);
     1097    TMTimerUnlock(pTimer);
     1098    AssertRCReturn(rc, rc);
     1099
     1100    /*
     1101     * Register I/O ports.
     1102     */
    10921103    rc = PDMDevHlpIOPortRegister(pDevIns, pThis->IOPortBase, 4, NULL,
    10931104                                 rtcIOPortWrite, rtcIOPortRead, NULL, NULL, "MC146818 RTC/CMOS");
     
    11091120    }
    11101121
     1122    /*
     1123     * Register the saved state.
     1124     */
    11111125    rc = PDMDevHlpSSMRegister3(pDevIns, RTC_SAVED_STATE_VERSION, sizeof(*pThis), rtcLiveExec, rtcSaveExec, rtcLoadExec);
    11121126    if (RT_FAILURE(rc))
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