Changeset 97028 in vbox for trunk/src/VBox/Devices/PC
- Timestamp:
- Oct 6, 2022 9:57:05 AM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/PC/DevHPET.cpp
r97027 r97028 101 101 #define FS_PER_NS 1000000 102 102 103 /** 104 * Femtoseconds in a day. Still fits within uint64_t. 105 */ 106 #define FS_PER_DAY (1000000000ULL * 60 * 60 * 24 * FS_PER_NS) 107 108 /** 109 * Number of HPET ticks in 100 years, ICH9 frequency. 110 */ 111 #define HPET_TICKS_IN_100YR_ICH9 (FS_PER_DAY / HPET_CLK_PERIOD_ICH9 * 365 * 100) 112 113 /** 114 * Number of HPET ticks in 100 years, made-up PIIX frequency. 115 */ 116 #define HPET_TICKS_IN_100YR_PIIX (FS_PER_DAY / HPET_CLK_PERIOD_PIIX * 365 * 100) 103 /** Number of HPET ticks per second (Hz), ICH9 frequency. 104 * Value: 14318179 */ 105 #define HPET_TICKS_PER_SEC_ICH9 ((RT_NS_1SEC * FS_PER_NS) / HPET_CLK_PERIOD_ICH9) 106 107 /** Number of HPET ticks per second (Hz), made-up PIIX frequency. 108 * Value: 100000000 */ 109 #define HPET_TICKS_PER_SEC_PIIX ((RT_NS_1SEC * FS_PER_NS) / HPET_CLK_PERIOD_PIIX) 110 111 /** Number of HPET ticks in 100 years, ICH9 frequency. 112 * Value: 45153809294400000 (0x00A06B26'7B3F9A00) */ 113 #define HPET_TICKS_IN_100YR_ICH9 (HPET_TICKS_PER_SEC_ICH9 * RT_SEC_1DAY_64 * 365 * 100) 114 115 /** Number of HPET ticks in 100 years, made-up PIIX frequency. 116 * Value: 315360000000000000 (0x0460623F'C85E0000) */ 117 #define HPET_TICKS_IN_100YR_PIIX (HPET_TICKS_PER_SEC_PIIX * RT_SEC_1DAY_64 * 365 * 100) 117 118 118 119 /** @name Interrupt type … … 385 386 } 386 387 388 389 /** 390 * @note The caller shall do overflow checks! See @bugref{10301}. 391 */ 387 392 DECLINLINE(uint64_t) hpetTicksToNs(PHPET pThis, uint64_t value) 388 393 { … … 465 470 uint64_t fConfig, uint64_t uPeriod) 466 471 { 467 if ((fConfig & HPET_TN_PERIODIC) && uPeriod && (uPeriod < UINT32_MAX)) 472 if ( (fConfig & HPET_TN_PERIODIC) 473 && uPeriod > 0 474 && uPeriod < (pThis->fIch9 ? HPET_TICKS_PER_SEC_ICH9 : HPET_TICKS_PER_SEC_PIIX) / 10 /* 100 ns */) 468 475 { 469 476 uint64_t const nsPeriod = hpetTicksToNs(pThis, uPeriod); 470 if (nsPeriod < RT_NS_100MS) 471 PDMDevHlpTimerSetFrequencyHint(pDevIns, pHpetTimer->hTimer, RT_NS_1SEC / (uint32_t)nsPeriod); 477 PDMDevHlpTimerSetFrequencyHint(pDevIns, pHpetTimer->hTimer, RT_NS_1SEC / (uint32_t)nsPeriod); 472 478 } 473 479 } … … 1451 1457 pThis->aTimers[i].u64Cmp, 1452 1458 pThis->aTimers[i].u64Period, 1453 hpetTicksToNs(pThis, pThis->aTimers[i].u64Period), 1459 pThis->aTimers[i].u64Period < (pThis->fIch9 ? HPET_TICKS_IN_100YR_ICH9 : HPET_TICKS_IN_100YR_PIIX) 1460 ? hpetTicksToNs(pThis, pThis->aTimers[i].u64Period) : UINT64_MAX, 1454 1461 pThis->aTimers[i].u64Config, 1455 1462 hpetR3TimerGetIrq(pThis, &pThis->aTimers[i], pThis->aTimers[i].u64Config),
Note:
See TracChangeset
for help on using the changeset viewer.