VirtualBox

Changeset 88352 in vbox for trunk/src


Ignore:
Timestamp:
Apr 2, 2021 9:51:40 PM (4 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
143596
Message:

Forward ported r143587+r143588 from 6.1: DevHPET: Dropped the u32Period field in favor of picking the constant accorting to fIch9. ​Nits. oem2ticketref:40

File:
1 edited

Legend:

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

    r88351 r88352  
    2828#include <VBox/vmm/stam.h>
    2929#include <VBox/log.h>
    30 #include <iprt/assert.h>
     30#include <VBox/AssertGuest.h>
    3131#include <iprt/asm-math.h>
    3232#include <iprt/string.h>
     
    231231    /** @name Hidden register state.
    232232     * @{ */
    233     /** Last value written to comparator. */
     233    /** Accumulator / Last value written to comparator. */
    234234    uint64_t                    u64Period;
    235235    /** @} */
     
    261261    /** Capabilities. */
    262262    uint32_t                    u32Capabilities;
    263     /** HPET_PERIOD - . */
    264     uint32_t                    u32Period;
     263    /** Used to be u32Period.  We only implement two period values depending on
     264     * fIch9, and since we usually would have to RT_MIN(u32Period,1) we could
     265     * just as well select between HPET_CLK_PERIOD_ICH9 and HPET_CLK_PERIOD_PIIX. */
     266    uint32_t                    u32Padding;
    265267    /** Configuration. */
    266268    uint64_t                    u64HpetConfig;
     
    360362DECLINLINE(uint64_t) hpetTicksToNs(PHPET pThis, uint64_t value)
    361363{
    362     return ASMMultU64ByU32DivByU32(value,  pThis->u32Period, FS_PER_NS);
     364    return ASMMultU64ByU32DivByU32(value, pThis->fIch9 ? HPET_CLK_PERIOD_ICH9 : HPET_CLK_PERIOD_PIIX, FS_PER_NS);
    363365}
    364366
    365367DECLINLINE(uint64_t) nsToHpetTicks(PCHPET pThis, uint64_t u64Value)
    366368{
    367     return ASMMultU64ByU32DivByU32(u64Value, FS_PER_NS, RT_MAX(pThis->u32Period, 1 /* no div/zero */));
     369    return ASMMultU64ByU32DivByU32(u64Value, FS_PER_NS, pThis->fIch9 ? HPET_CLK_PERIOD_ICH9 : HPET_CLK_PERIOD_PIIX);
    368370}
    369371
     
    693695                    {
    694696                        Log(("HPET[%u]: Changing timer to 32-bit mode.\n", iTimerNo));
     697                        /* Clear the top bits of the comparator and period to be on the safe side. */
    695698                        ASMAtomicUoWriteU64(&pHpetTimer->u64Cmp,    (uint32_t)pHpetTimer->u64Cmp);
    696699                        ASMAtomicUoWriteU64(&pHpetTimer->u64Period, (uint32_t)pHpetTimer->u64Period);
     
    707710                    {
    708711                        LogRelMax(10, ("HPET[%u]: Level-triggered config not yet supported\n", iTimerNo));
    709                         AssertFailed();
     712                        ASSERT_GUEST_MSG_FAILED(("Level-triggered config not yet supported"));
    710713                    }
    711714                }
     
    876879
    877880        case HPET_PERIOD:
    878             DEVHPET_LOCK_RETURN(pDevIns, pThis, VINF_IOM_R3_MMIO_READ);
    879             u32Value = pThis->u32Period;
    880             DEVHPET_UNLOCK(pDevIns, pThis);
     881            u32Value = pThis->fIch9 ? HPET_CLK_PERIOD_ICH9 : HPET_CLK_PERIOD_PIIX;
    881882            Log(("read HPET_PERIOD: %#x\n", u32Value));
    882883            break;
     
    13691370                    "HPET status:\n"
    13701371                    " config=%016RX64     isr=%016RX64\n"
    1371                     " offset=%016RX64 counter=%016RX64 frequency=%08x\n"
     1372                    " offset=%016RX64 counter=%016RX64 frequency=%u fs\n"
    13721373                    " legacy-mode=%s  timer-count=%u\n",
    13731374                    pThis->u64HpetConfig, pThis->u64Isr,
    1374                     pThis->u64HpetOffset, pThis->u64HpetCounter, pThis->u32Period,
     1375                    pThis->u64HpetOffset, pThis->u64HpetCounter, pThis->fIch9 ? HPET_CLK_PERIOD_ICH9 : HPET_CLK_PERIOD_PIIX,
    13751376                    !!(pThis->u64HpetConfig & HPET_CFG_LEGACY) ? "on " : "off",
    13761377                    HPET_CAP_GET_TIMERS(pThis->u32Capabilities));
     
    14361437
    14371438    pHlp->pfnSSMPutU64(pSSM, pThis->u64HpetOffset);
    1438     uint64_t u64CapPer = RT_MAKE_U64(pThis->u32Capabilities, pThis->u32Period);
     1439    uint64_t u64CapPer = RT_MAKE_U64(pThis->u32Capabilities, pThis->fIch9 ? HPET_CLK_PERIOD_ICH9 : HPET_CLK_PERIOD_PIIX);
    14391440    pHlp->pfnSSMPutU64(pSSM, u64CapPer);
    14401441    pHlp->pfnSSMPutU64(pSSM, pThis->u64HpetConfig);
     
    15121513
    15131514    pThis->u32Capabilities  = RT_LO_U32(u64CapPer);
    1514     pThis->u32Period        = RT_HI_U32(u64CapPer);
     1515    uint32_t const uExpectedPeriod = pThis->fIch9 ? HPET_CLK_PERIOD_ICH9 : HPET_CLK_PERIOD_PIIX;
     1516    if (RT_HI_U32(u64CapPer) != uExpectedPeriod)
     1517        return pHlp->pfnSSMSetCfgError(pSSM, RT_SRC_POS, N_("Config mismatch - Expected period %RU32 fs, loaded %RU32 fs"),
     1518                                       uExpectedPeriod, RT_HI_U32(u64CapPer));
    15151519
    15161520    /*
     
    15991603    AssertCompile(HPET_NUM_TIMERS_PIIX <= RT_ELEMENTS(pThis->aTimers));
    16001604
    1601     pThis->u32Period = pThis->fIch9 ? HPET_CLK_PERIOD_ICH9 : HPET_CLK_PERIOD_PIIX;
    16021605
    16031606    /*
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