- Timestamp:
- Apr 2, 2021 9:51:40 PM (4 years ago)
- svn:sync-xref-src-repo-rev:
- 143596
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/PC/DevHPET.cpp
r88351 r88352 28 28 #include <VBox/vmm/stam.h> 29 29 #include <VBox/log.h> 30 #include < iprt/assert.h>30 #include <VBox/AssertGuest.h> 31 31 #include <iprt/asm-math.h> 32 32 #include <iprt/string.h> … … 231 231 /** @name Hidden register state. 232 232 * @{ */ 233 /** Last value written to comparator. */233 /** Accumulator / Last value written to comparator. */ 234 234 uint64_t u64Period; 235 235 /** @} */ … … 261 261 /** Capabilities. */ 262 262 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; 265 267 /** Configuration. */ 266 268 uint64_t u64HpetConfig; … … 360 362 DECLINLINE(uint64_t) hpetTicksToNs(PHPET pThis, uint64_t value) 361 363 { 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); 363 365 } 364 366 365 367 DECLINLINE(uint64_t) nsToHpetTicks(PCHPET pThis, uint64_t u64Value) 366 368 { 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); 368 370 } 369 371 … … 693 695 { 694 696 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. */ 695 698 ASMAtomicUoWriteU64(&pHpetTimer->u64Cmp, (uint32_t)pHpetTimer->u64Cmp); 696 699 ASMAtomicUoWriteU64(&pHpetTimer->u64Period, (uint32_t)pHpetTimer->u64Period); … … 707 710 { 708 711 LogRelMax(10, ("HPET[%u]: Level-triggered config not yet supported\n", iTimerNo)); 709 A ssertFailed();712 ASSERT_GUEST_MSG_FAILED(("Level-triggered config not yet supported")); 710 713 } 711 714 } … … 876 879 877 880 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; 881 882 Log(("read HPET_PERIOD: %#x\n", u32Value)); 882 883 break; … … 1369 1370 "HPET status:\n" 1370 1371 " config=%016RX64 isr=%016RX64\n" 1371 " offset=%016RX64 counter=%016RX64 frequency=% 08x\n"1372 " offset=%016RX64 counter=%016RX64 frequency=%u fs\n" 1372 1373 " legacy-mode=%s timer-count=%u\n", 1373 1374 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, 1375 1376 !!(pThis->u64HpetConfig & HPET_CFG_LEGACY) ? "on " : "off", 1376 1377 HPET_CAP_GET_TIMERS(pThis->u32Capabilities)); … … 1436 1437 1437 1438 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); 1439 1440 pHlp->pfnSSMPutU64(pSSM, u64CapPer); 1440 1441 pHlp->pfnSSMPutU64(pSSM, pThis->u64HpetConfig); … … 1512 1513 1513 1514 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)); 1515 1519 1516 1520 /* … … 1599 1603 AssertCompile(HPET_NUM_TIMERS_PIIX <= RT_ELEMENTS(pThis->aTimers)); 1600 1604 1601 pThis->u32Period = pThis->fIch9 ? HPET_CLK_PERIOD_ICH9 : HPET_CLK_PERIOD_PIIX;1602 1605 1603 1606 /*
Note:
See TracChangeset
for help on using the changeset viewer.