VirtualBox

Changeset 37534 in vbox


Ignore:
Timestamp:
Jun 17, 2011 12:22:31 PM (14 years ago)
Author:
vboxsync
Message:

DevHPET: Frequency hinting.

File:
1 edited

Legend:

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

    r37526 r37534  
    400400    Log4(("HPET: next IRQ in %lld ticks (%lld ns)\n", u64Diff, hpetTicksToNs(pHpetTimer->CTX_SUFF(pHpet), u64Diff)));
    401401    TMTimerSetNano(pHpetTimer->CTX_SUFF(pTimer), hpetTicksToNs(pHpetTimer->CTX_SUFF(pHpet), u64Diff));
     402    if (pHpetTimer->u64Config & HPET_TN_PERIODIC)
     403    {
     404        uint64_t const u64Period = pHpetTimer->u64Period;
     405        uint32_t const u32Freq   = RT_HI_U32(pHpetTimer->CTX_SUFF(pHpet)->u64Capabilities);
     406        if (u64Period > 0 && u64Period < u32Freq)
     407            TMTimerSetFrequencyHint(pHpetTimer->CTX_SUFF(pTimer), u32Freq / (uint32_t)u64Period);
     408    }
    402409}
    403410
     
    11021109    pHlp->pfnPrintf(pHlp,
    11031110                    "HPET status:\n"
    1104                     " config = %016RX64\n"
    1105                     " offset = %016RX64 counter = %016RX64 isr = %016RX64\n"
    1106                     " legacy mode is %s\n",
    1107                     pThis->u64HpetConfig,
    1108                     pThis->u64HpetOffset, pThis->u64HpetCounter, pThis->u64Isr,
    1109                     !!(pThis->u64HpetConfig & HPET_CFG_LEGACY) ? "on" : "off");
     1111                    " config=%016RX64     isr=%016RX64\n"
     1112                    " offset=%016RX64 counter=%016RX64 frequency=%08x\n"
     1113                    " legacy-mode=%s  timer-count=%u\n",
     1114                    pThis->u64HpetConfig, pThis->u64Isr,
     1115                    pThis->u64HpetOffset, pThis->u64HpetCounter, RT_HI_U32(pThis->u64Capabilities),
     1116                    !!(pThis->u64HpetConfig & HPET_CFG_LEGACY) ? "on " : "off",
     1117                    (unsigned)((pThis->u64Capabilities >> 8) & 0x1f));
    11101118    pHlp->pfnPrintf(pHlp,
    11111119                    "Timers:\n");
     
    12171225    SSMR3GetU64(pSSM, &pThis->u64HpetConfig);
    12181226    SSMR3GetU64(pSSM, &pThis->u64Isr);
    1219     return SSMR3GetU64(pSSM, &pThis->u64HpetCounter);
     1227    rc = SSMR3GetU64(pSSM, &pThis->u64HpetCounter);
     1228    if (RT_FAILURE(rc))
     1229        return rc;
     1230
     1231    /*
     1232     * Set the timer frequency hints.
     1233     */
     1234    PDMCritSectEnter(&pThis->csLock, VERR_IGNORED);
     1235    for (uint32_t iTimer = 0; iTimer < HPET_NUM_TIMERS; iTimer++)
     1236    {
     1237        HpetTimer *pHpetTimer = &pThis->aTimers[iTimer];
     1238        if (   (pHpetTimer->u64Config & HPET_TN_PERIODIC)
     1239            && TMTimerIsActive(pHpetTimer->CTX_SUFF(pTimer)))
     1240        {
     1241            uint64_t const u64Period = pHpetTimer->u64Period;
     1242            uint32_t const u32Freq   = RT_HI_U32(pHpetTimer->CTX_SUFF(pHpet)->u64Capabilities);
     1243            if (u64Period > 0 && u64Period < u32Freq)
     1244                TMTimerSetFrequencyHint(pHpetTimer->CTX_SUFF(pTimer), u32Freq / (uint32_t)u64Period);
     1245        }
     1246    }
     1247    PDMCritSectLeave(&pThis->csLock);
     1248    return VINF_SUCCESS;
    12201249}
    12211250
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