VirtualBox

Changeset 27627 in vbox


Ignore:
Timestamp:
Mar 23, 2010 1:36:42 PM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
59181
Message:

HPET: nitpicking

File:
1 edited

Legend:

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

    r27254 r27627  
    171171    uint64_t             u64Capabilities;
    172172    /* configuration */
    173     uint64_t             u64Config;
     173    uint64_t             u64HpetConfig;
    174174    /* interrupt status register */
    175175    uint64_t             u64Isr;
     
    197197
    198198/*
    199  * Temporary control to disble locking if problems found
     199 * Temporary control to disable locking if problems found
    200200 */
    201201static const bool fHpetLocking = true;
     
    247247}
    248248
    249 static uint64_t updateMasked(uint64_t u64NewValue,
    250                              uint64_t u64OldValue,
    251                              uint64_t u64Mask)
     249static uint64_t hpetUpdateMasked(uint64_t u64NewValue,
     250                                 uint64_t u64OldValue,
     251                                 uint64_t u64Mask)
    252252{
    253253    u64NewValue &= u64Mask;
    254     u64NewValue |= u64OldValue & ~u64Mask;
     254    u64NewValue |= (u64OldValue & ~u64Mask);
    255255    return u64NewValue;
    256256}
    257257
    258 static bool isBitJustSet(uint64_t u64OldValue,
    259                          uint64_t u64NewValue,
    260                          uint64_t u64Mask)
     258static bool hpetBitJustSet(uint64_t u64OldValue,
     259                           uint64_t u64NewValue,
     260                           uint64_t u64Mask)
    261261{
    262262    return (!(u64OldValue & u64Mask) && (u64NewValue & u64Mask));
    263263}
    264264
    265 static bool isBitJustCleared(uint64_t u64OldValue,
    266                              uint64_t u64NewValue,
    267                              uint64_t u64Mask)
    268 {
    269     return ((u64OldValue & u64Mask) && !(u64NewValue & u64Mask));
     265static bool hpetBitJustCleared(uint64_t u64OldValue,
     266                               uint64_t u64NewValue,
     267                               uint64_t u64Mask)
     268{
     269    return (!!(u64OldValue & u64Mask) && !(u64NewValue & u64Mask));
    270270}
    271271
     
    356356     *   timer 1: IRQ8 for both PIC and APIC
    357357     *
    358      * ISA IRQ delivery logic will take care of correct delivery 
     358     * ISA IRQ delivery logic will take care of correct delivery
    359359     * to the different ICs.
    360360     */
    361361    if ((pTimer->u8TimerNumber <= 1) &&
    362         (pTimer->CTX_SUFF(pHpet)->u64Config & HPET_CFG_LEGACY))
     362        (pTimer->CTX_SUFF(pHpet)->u64HpetConfig & HPET_CFG_LEGACY))
    363363        return (pTimer->u8TimerNumber == 0) ? 0 : 8;
    364364    else
     
    366366}
    367367
    368 static int timerRegRead32(HpetState* pThis,
    369                           uint32_t   iTimerNo,
    370                           uint32_t   iTimerReg,
    371                           uint32_t * pValue)
     368static int hpetTimerRegRead32(HpetState* pThis,
     369                              uint32_t   iTimerNo,
     370                              uint32_t   iTimerReg,
     371                              uint32_t * pValue)
    372372{
    373373    HpetTimer *pTimer;
     
    411411}
    412412
    413 static int configRegRead32(HpetState* pThis,
    414                            uint32_t   iIndex,
    415                            uint32_t  *pValue)
     413static int hpetConfigRegRead32(HpetState* pThis,
     414                               uint32_t   iIndex,
     415                               uint32_t  *pValue)
    416416{
    417417    switch (iIndex)
     
    427427        case HPET_CFG:
    428428            Log(("read HPET_CFG\n"));
    429             *pValue = (uint32_t)(pThis->u64Config);
     429            *pValue = (uint32_t)(pThis->u64HpetConfig);
    430430            break;
    431431        case HPET_CFG + 4:
    432432            Log(("read of HPET_CFG + 4\n"));
    433             *pValue = (uint32_t)(pThis->u64Config >> 32);
     433            *pValue = (uint32_t)(pThis->u64HpetConfig >> 32);
    434434            break;
    435435        case HPET_COUNTER:
     
    438438            uint64_t u64Ticks;
    439439            Log(("read HPET_COUNTER\n"));
    440             if (pThis->u64Config & HPET_CFG_ENABLE)
     440            if (pThis->u64HpetConfig & HPET_CFG_ENABLE)
    441441                u64Ticks = hpetGetTicks(pThis);
    442442            else
     
    457457}
    458458
    459 static int timerRegWrite32(HpetState* pThis,
    460                            uint32_t   iTimerNo,
    461                            uint32_t   iTimerReg,
    462                            uint32_t   iNewValue)
     459static int hpetTimerRegWrite32(HpetState* pThis,
     460                               uint32_t   iTimerNo,
     461                               uint32_t   iTimerReg,
     462                               uint32_t   iNewValue)
    463463{
    464464    HpetTimer * pTimer;
     
    474474    pTimer = &pThis->aTimers[iTimerNo];
    475475
    476     rc = timerRegRead32(pThis, iTimerNo, iTimerReg, &u32Temp);
     476    rc = hpetTimerRegRead32(pThis, iTimerNo, iTimerReg, &u32Temp);
    477477    if (RT_FAILURE(rc))
    478478        return rc;
     
    496496            /** We only care about lower 32-bits so far */
    497497            pTimer->u64Config =
    498                     updateMasked(iNewValue, iOldValue, HPET_TN_CFG_WRITE_MASK);
     498                    hpetUpdateMasked(iNewValue, iOldValue, HPET_TN_CFG_WRITE_MASK);
    499499            break;
    500500        }
     
    527527            Log2(("after HPET_TN_CMP cmp=%llx per=%llx\n", pTimer->u64Cmp, pTimer->u64Period));
    528528
    529             if (pThis->u64Config & HPET_CFG_ENABLE)
     529            if (pThis->u64HpetConfig & HPET_CFG_ENABLE)
    530530                hpetProgramTimer(pTimer);
    531531            break;
     
    552552            Log2(("after HPET_TN_CMP+4 cmp=%llx per=%llx\n", pTimer->u64Cmp, pTimer->u64Period));
    553553
    554             if (pThis->u64Config & HPET_CFG_ENABLE)
     554            if (pThis->u64HpetConfig & HPET_CFG_ENABLE)
    555555                hpetProgramTimer(pTimer);
    556556            break;
     
    590590}
    591591
    592 static int configRegWrite32(HpetState* pThis,
    593                             uint32_t   iIndex,
    594                             uint32_t   iNewValue)
     592static int hpetConfigRegWrite32(HpetState* pThis,
     593                                uint32_t   iIndex,
     594                                uint32_t   iNewValue)
    595595{
    596596    int rc = VINF_SUCCESS;
     
    610610            Log(("write HPET_CFG: %x\n", iNewValue));
    611611
    612             iOldValue = (uint32_t)(pThis->u64Config);
     612            iOldValue = (uint32_t)(pThis->u64HpetConfig);
    613613
    614614            /*
     
    616616             * may request retry in R3 - so we must keep state intact.
    617617             */
    618             if (isBitJustSet(iOldValue, iNewValue, HPET_CFG_LEGACY))
     618            if (hpetBitJustSet(iOldValue, iNewValue, HPET_CFG_LEGACY))
    619619            {
    620620                rc = hpetLegacyMode(pThis, true);
    621621            }
    622             else if (isBitJustCleared(iOldValue, iNewValue, HPET_CFG_LEGACY))
     622            else if (hpetBitJustCleared(iOldValue, iNewValue, HPET_CFG_LEGACY))
    623623            {
    624624                rc = hpetLegacyMode(pThis, false);
     
    627627                return rc;
    628628
    629             pThis->u64Config = updateMasked(iNewValue, iOldValue, HPET_CFG_WRITE_MASK);
    630             if (isBitJustSet(iOldValue, iNewValue, HPET_CFG_ENABLE))
     629            pThis->u64HpetConfig = hpetUpdateMasked(iNewValue, iOldValue, HPET_CFG_WRITE_MASK);
     630            if (hpetBitJustSet(iOldValue, iNewValue, HPET_CFG_ENABLE))
    631631            {
    632632                /* Enable main counter and interrupt generation. */
     
    637637                        hpetProgramTimer(&pThis->aTimers[i]);
    638638            }
    639             else if (isBitJustCleared(iOldValue, iNewValue, HPET_CFG_ENABLE))
     639            else if (hpetBitJustCleared(iOldValue, iNewValue, HPET_CFG_ENABLE))
    640640            {
    641641                /* Halt main counter and disable interrupt generation. */
     
    649649        {
    650650            Log(("write HPET_CFG + 4: %x\n", iNewValue));
    651             pThis->u64Config = updateMasked((uint64_t)iNewValue << 32,
    652                                             pThis->u64Config,
    653                                             0xffffffff00000000ULL);
     651            pThis->u64HpetConfig = hpetUpdateMasked((uint64_t)iNewValue << 32,
     652                                                    pThis->u64HpetConfig,
     653                                                    0xffffffff00000000ULL);
    654654            break;
    655655        }
     
    717717        {
    718718            if ((iIndex >= 0x100) && (iIndex < 0x400))
    719                 rc = timerRegRead32(pThis, (iIndex - 0x100) / 0x20, (iIndex - 0x100) % 0x20, (uint32_t*)pv);
     719                rc = hpetTimerRegRead32(pThis, (iIndex - 0x100) / 0x20, (iIndex - 0x100) % 0x20, (uint32_t*)pv);
    720720            else
    721                 rc = configRegRead32(pThis, iIndex, (uint32_t*)pv);
     721                rc = hpetConfigRegRead32(pThis, iIndex, (uint32_t*)pv);
    722722            break;
    723723        }
     
    742742                uint32_t iTimerReg = (iIndex - 0x100) % 0x20;
    743743
    744                 rc = timerRegRead32(pThis, iTimer, iTimerReg, &value.u32[0]);
     744                rc = hpetTimerRegRead32(pThis, iTimer, iTimerReg, &value.u32[0]);
    745745                if (RT_UNLIKELY(rc != VINF_SUCCESS))
    746746                    break;
    747                 rc = timerRegRead32(pThis, iTimer, iTimerReg + 4, &value.u32[1]);
     747                rc = hpetTimerRegRead32(pThis, iTimer, iTimerReg + 4, &value.u32[1]);
    748748            }
    749749            else
    750750            {
    751                 rc = configRegRead32(pThis, iIndex, &value.u32[0]);
     751                rc = hpetConfigRegRead32(pThis, iIndex, &value.u32[0]);
    752752                if (RT_UNLIKELY(rc != VINF_SUCCESS))
    753753                    break;
    754                 rc = configRegRead32(pThis, iIndex+4, &value.u32[1]);
     754                rc = hpetConfigRegRead32(pThis, iIndex+4, &value.u32[1]);
    755755            }
    756756            if (rc == VINF_SUCCESS)
     
    796796        {
    797797            if ((iIndex >= 0x100) && (iIndex < 0x400))
    798                 rc = timerRegWrite32(pThis,
    799                                      (iIndex - 0x100) / 0x20,
    800                                      (iIndex - 0x100) % 0x20,
    801                                      *(uint32_t*)pv);
     798                rc = hpetTimerRegWrite32(pThis,
     799                                         (iIndex - 0x100) / 0x20,
     800                                         (iIndex - 0x100) % 0x20,
     801                                         *(uint32_t*)pv);
    802802            else
    803                 rc = configRegWrite32(pThis, iIndex, *(uint32_t*)pv);
     803                rc = hpetConfigRegWrite32(pThis, iIndex, *(uint32_t*)pv);
    804804            break;
    805805        }
     
    825825                uint32_t iTimerReg = (iIndex - 0x100) % 0x20;
    826826
    827                 rc = timerRegWrite32(pThis, iTimer, iTimerReg, value.u32[0]);
     827                rc = hpetTimerRegWrite32(pThis, iTimer, iTimerReg, value.u32[0]);
    828828                if (RT_UNLIKELY(rc != VINF_SUCCESS))
    829829                    break;
    830                 rc = timerRegWrite32(pThis, iTimer, iTimerReg + 4, value.u32[1]);
     830                rc = hpetTimerRegWrite32(pThis, iTimer, iTimerReg + 4, value.u32[1]);
    831831            }
    832832            else
    833833            {
    834                 rc = configRegWrite32(pThis, iIndex, value.u32[0]);
     834                rc = hpetConfigRegWrite32(pThis, iIndex, value.u32[0]);
    835835                if (RT_UNLIKELY(rc != VINF_SUCCESS))
    836836                    break;
    837                 rc = configRegWrite32(pThis, iIndex+4, value.u32[1]);
     837                rc = hpetConfigRegWrite32(pThis, iIndex+4, value.u32[1]);
    838838            }
    839839            break;
     
    915915    SSMR3PutU64(pSSM, pThis->u64HpetOffset);
    916916    SSMR3PutU64(pSSM, pThis->u64Capabilities);
    917     SSMR3PutU64(pSSM, pThis->u64Config);
     917    SSMR3PutU64(pSSM, pThis->u64HpetConfig);
    918918    SSMR3PutU64(pSSM, pThis->u64Isr);
    919919    SSMR3PutU64(pSSM, pThis->u64HpetCounter);
     
    963963    SSMR3GetU64(pSSM, &pThis->u64HpetOffset);
    964964    SSMR3GetU64(pSSM, &pThis->u64Capabilities);
    965     SSMR3GetU64(pSSM, &pThis->u64Config);
     965    SSMR3GetU64(pSSM, &pThis->u64HpetConfig);
    966966    SSMR3GetU64(pSSM, &pThis->u64Isr);
    967967    SSMR3GetU64(pSSM, &pThis->u64HpetCounter);
     
    970970}
    971971
    972 static void irqUpdate(struct HpetTimer *pTimer)
     972static void hpetIrqUpdate(struct HpetTimer *pTimer)
    973973{
    974974    uint32_t irq    = getTimerIrq(pTimer);
     
    976976
    977977    /** @todo: is it correct? */
    978     if ((pTimer->u64Config & HPET_TN_ENABLE) &&
    979         (pThis->u64Config & HPET_CFG_ENABLE))
     978    if (!!(pTimer->u64Config & HPET_TN_ENABLE) &&
     979        !!(pThis->u64HpetConfig & HPET_CFG_ENABLE))
    980980    {
    981981        Log4(("HPET: raising IRQ %d\n", irq));
     
    10411041
    10421042    /* Should it really be under lock, does it really matter? */
    1043     irqUpdate(pTimer);
     1043    hpetIrqUpdate(pTimer);
    10441044
    10451045    hpetUnlock(pThis);
     
    10841084    LogFlow(("hpetReset:\n"));
    10851085
    1086     pThis->u64Config = 0;
     1086    pThis->u64HpetConfig = 0;
    10871087    for (i = 0; i < HPET_NUM_TIMERS; i++)
    10881088    {
     
    10941094        /* We can do all IRQs */
    10951095        uint32_t u32RoutingCap = 0xffffffff;
    1096         pTimer->u64Config |=   ((uint64_t)u32RoutingCap) << 32;
     1096        pTimer->u64Config |= ((uint64_t)u32RoutingCap) << 32;
    10971097        pTimer->u64Period = 0ULL;
    10981098        pTimer->u8Wrap = 0;
     
    11091109    pThis->u64Capabilities = (u32Vendor << 16) | u32Caps;
    11101110    pThis->u64Capabilities |= ((uint64_t)(HPET_CLK_PERIOD) << 32);
     1111
     1112    /* Notify PIT/RTC devices */
     1113    hpetLegacyMode(pThis, false);
    11111114}
    11121115
     
    11681171                    " offset = %016RX64 counter = %016RX64 isr = %016RX64\n"
    11691172                    " legacy mode is %s\n",
    1170                     pThis->u64Config,
     1173                    pThis->u64HpetConfig,
    11711174                    pThis->u64HpetOffset, pThis->u64HpetCounter, pThis->u64Isr,
    1172                     (pThis->u64Config & HPET_CFG_LEGACY) ? "on" : "off");
     1175                    !!(pThis->u64HpetConfig & HPET_CFG_LEGACY) ? "on" : "off");
    11731176    pHlp->pfnPrintf(pHlp,
    11741177                    "Timers:\n");
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