Changeset 79686 in vbox for trunk/src/VBox/Devices/PC
- Timestamp:
- Jul 11, 2019 8:49:11 AM (6 years ago)
- svn:sync-xref-src-repo-rev:
- 132017
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/PC/DevHPET.cpp
r76553 r79686 75 75 */ 76 76 #define FS_PER_NS 1000000 77 78 /** 79 * Femtoseconds in a day. Still fits within int64_t. 80 */ 81 #define FS_PER_DAY (1000000LL * 60 * 60 * 24 * FS_PER_NS) 82 83 /** 84 * Number of HPET ticks in 100 years, ICH9 frequency. 85 */ 86 #define HPET_TICKS_IN_100YR_ICH9 (FS_PER_DAY / HPET_CLK_PERIOD_ICH9 * 365 * 100) 87 88 /** 89 * Number of HPET ticks in 100 years, made-up PIIX frequency. 90 */ 91 #define HPET_TICKS_IN_100YR_PIIX (FS_PER_DAY / HPET_CLK_PERIOD_PIIX * 365 * 100) 77 92 78 93 /** @name Interrupt type … … 385 400 386 401 387 static void hpetProgramTimer(HPET TIMER *pHpetTimer)402 static void hpetProgramTimer(HPET *pThis, HPETTIMER *pHpetTimer) 388 403 { 389 404 /* no wrapping on new timers */ … … 420 435 #endif 421 436 422 Log4(("HPET: next IRQ in %lld ticks (%lld ns)\n", u64Diff, hpetTicksToNs(pHpetTimer->CTX_SUFF(pHpet), u64Diff))); 423 TMTimerSetNano(pHpetTimer->CTX_SUFF(pTimer), hpetTicksToNs(pHpetTimer->CTX_SUFF(pHpet), u64Diff)); 437 uint64_t u64TickLimit = pThis->fIch9 ? HPET_TICKS_IN_100YR_ICH9 : HPET_TICKS_IN_100YR_PIIX; 438 if (u64Diff <= u64TickLimit) 439 { 440 Log4(("HPET: next IRQ in %lld ticks (%lld ns)\n", u64Diff, hpetTicksToNs(pHpetTimer->CTX_SUFF(pHpet), u64Diff))); 441 TMTimerSetNano(pHpetTimer->CTX_SUFF(pTimer), hpetTicksToNs(pHpetTimer->CTX_SUFF(pHpet), u64Diff)); 442 } 443 else 444 { 445 LogRelMax(10, ("HPET: Not scheduling an interrupt more than 100 years in the future.\n")); 446 } 424 447 hpetTimerSetFrequencyHint(pHpetTimer->CTX_SUFF(pHpet), pHpetTimer); 425 448 } … … 568 591 569 592 if (pThis->u64HpetConfig & HPET_CFG_ENABLE) 570 hpetProgramTimer(p HpetTimer);593 hpetProgramTimer(pThis, pHpetTimer); 571 594 DEVHPET_UNLOCK_BOTH(pThis); 572 595 break; … … 588 611 589 612 if (pThis->u64HpetConfig & HPET_CFG_ENABLE) 590 hpetProgramTimer(p HpetTimer);613 hpetProgramTimer(pThis, pHpetTimer); 591 614 } 592 615 DEVHPET_UNLOCK_BOTH(pThis); … … 755 778 /** @todo Only get the time stamp once when reprogramming? */ 756 779 /* Enable main counter and interrupt generation. */ 757 pThis->u64HpetOffset = hpetTicksToNs(pThis, pThis->u64HpetCounter) 758 - TMTimerGet(pThis->aTimers[0].CTX_SUFF(pTimer)); 780 uint64_t u64TickLimit = pThis->fIch9 ? HPET_TICKS_IN_100YR_ICH9 : HPET_TICKS_IN_100YR_PIIX; 781 if (pThis->u64HpetCounter <= u64TickLimit) 782 { 783 pThis->u64HpetOffset = hpetTicksToNs(pThis, pThis->u64HpetCounter) 784 - TMTimerGet(pThis->aTimers[0].CTX_SUFF(pTimer)); 785 } 786 else 787 { 788 LogRelMax(10, ("HPET: Counter set more than 100 years in the future, reducing.\n")); 789 pThis->u64HpetOffset = 1000000LL * 60 * 60 * 24 * 365 * 100 790 - TMTimerGet(pThis->aTimers[0].CTX_SUFF(pTimer)); 791 } 759 792 for (uint32_t i = 0; i < cTimers; i++) 760 793 if (pThis->aTimers[i].u64Cmp != hpetInvalidValue(&pThis->aTimers[i])) 761 hpetProgramTimer( &pThis->aTimers[i]);794 hpetProgramTimer(pThis, &pThis->aTimers[i]); 762 795 } 763 796 else if (hpetBitJustCleared(iOldValue, u32NewValue, HPET_CFG_ENABLE)) … … 1038 1071 u64Diff = hpetComputeDiff(pHpetTimer, u64CurTick); 1039 1072 1040 Log4(("HPET: periodic: next in %llu\n", hpetTicksToNs(pThis, u64Diff))); 1041 TMTimerSetNano(pTimer, hpetTicksToNs(pThis, u64Diff)); 1073 uint64_t u64TickLimit = pThis->fIch9 ? HPET_TICKS_IN_100YR_ICH9 : HPET_TICKS_IN_100YR_PIIX; 1074 if (u64Diff <= u64TickLimit) 1075 { 1076 Log4(("HPET: periodic: next in %llu\n", hpetTicksToNs(pThis, u64Diff))); 1077 TMTimerSetNano(pTimer, hpetTicksToNs(pThis, u64Diff)); 1078 } 1079 else 1080 { 1081 LogRelMax(10, ("HPET: Not scheduling periodic interrupt more than 100 years in the future.\n")); 1082 } 1042 1083 } 1043 1084 } … … 1268 1309 /* We can do all IRQs */ 1269 1310 uint32_t u32RoutingCap = 0xffffffff; 1270 pHpetTimer->u64Config |= ((uint64_t)u32RoutingCap) << 32;1311 pHpetTimer->u64Config |= ((uint64_t)u32RoutingCap) << HPET_TN_INT_ROUTE_CAP_SHIFT; 1271 1312 pHpetTimer->u64Period = 0; 1272 1313 pHpetTimer->u8Wrap = 0;
Note:
See TracChangeset
for help on using the changeset viewer.