Changeset 36870 in vbox
- Timestamp:
- Apr 28, 2011 7:44:09 AM (14 years ago)
- svn:sync-xref-src-repo-rev:
- 71447
- Location:
- trunk/src/VBox/Devices
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/PC/DevHPET.cpp
r36837 r36870 58 58 59 59 /* 60 * 69841279 femtoseconds == 69.84 ns 60 * 69841279 femtoseconds == 69.84 ns (1 / 14.31818MHz) 61 61 */ 62 62 #define HPET_CLK_PERIOD_ICH9 69841279UL … … 259 259 * with the same speed. 260 260 */ 261 return 262 pThis->u64HpetOffset);261 return nsToHpetTicks(pThis, TMTimerGet(pThis->aTimers[0].CTX_SUFF(pTimer)) + 262 pThis->u64HpetOffset); 263 263 } 264 264 … … 297 297 u32Diff = ((int32_t)u32Diff > 0) ? u32Diff : (uint32_t)0; 298 298 return (uint64_t)u32Diff; 299 } else { 299 } 300 else 301 { 300 302 uint64_t u64Diff; 301 303 … … 311 313 { 312 314 uint64_t u64Period = pTimer->u64Period; 313 if ((pTimer->u64Config & HPET_TN_PERIODIC) && (u64Period != 0)) 315 if ( (pTimer->u64Config & HPET_TN_PERIODIC) 316 && (u64Period != 0)) 314 317 { 315 318 /* While loop is suboptimal */ … … 348 351 if (!pTimer->CTX_SUFF(pHpet)->fIch9) 349 352 { 350 if ((pTimer->u64Config & HPET_TN_32BIT) && !(pTimer->u64Config & HPET_TN_PERIODIC)) 353 if ( (pTimer->u64Config & HPET_TN_32BIT) 354 && !(pTimer->u64Config & HPET_TN_PERIODIC)) 351 355 { 352 356 u32TillWrap = 0xffffffff - (uint32_t)u64Ticks; … … 381 385 * to the different ICs. 382 386 */ 383 if ( (pTimer->u8TimerNumber <= 1) &&384 (pTimer->CTX_SUFF(pHpet)->u64HpetConfig & HPET_CFG_LEGACY))387 if ( (pTimer->u8TimerNumber <= 1) 388 && (pTimer->CTX_SUFF(pHpet)->u64HpetConfig & HPET_CFG_LEGACY)) 385 389 return (pTimer->u8TimerNumber == 0) ? 0 : 8; 386 else387 388 } 389 390 static int hpetTimerRegRead32(HpetState *pThis,390 391 return (pTimer->u64Config & HPET_TN_INT_ROUTE_MASK) >> HPET_TN_INT_ROUTE_SHIFT; 392 } 393 394 static int hpetTimerRegRead32(HpetState *pThis, 391 395 uint32_t iTimerNo, 392 396 uint32_t iTimerReg, 393 uint32_t *pValue)397 uint32_t *pValue) 394 398 { 395 399 HpetTimer *pTimer; … … 434 438 } 435 439 436 static int hpetConfigRegRead32(HpetState *pThis,440 static int hpetConfigRegRead32(HpetState *pThis, 437 441 uint32_t iIndex, 438 442 uint32_t *pValue) … … 540 544 if (pTimer->u64Config & HPET_TN_32BIT) 541 545 pTimer->u64Config &= ~HPET_TN_SETVAL; 542 } else if (pTimer->u64Config & HPET_TN_PERIODIC) 546 } 547 else if (pTimer->u64Config & HPET_TN_PERIODIC) 543 548 { 544 549 iNewValue &= (pTimer->u64Config & HPET_TN_32BIT ? ~0U : ~0ULL) >> 1; 545 550 pTimer->u64Period = (pTimer->u64Period & 0xffffffff00000000ULL) 546 | iNewValue;551 | iNewValue; 547 552 } 548 553 549 554 pTimer->u64Cmp = (pTimer->u64Cmp & 0xffffffff00000000ULL) 550 | iNewValue;555 | iNewValue; 551 556 552 557 Log2(("after HPET_TN_CMP cmp=%llx per=%llx\n", pTimer->u64Cmp, pTimer->u64Period)); … … 566 571 /* HPET_TN_SETVAL allows to adjust comparator w/o updating period, and it's cleared on access */ 567 572 pTimer->u64Config &= ~HPET_TN_SETVAL; 568 } else if (pTimer->u64Config & HPET_TN_PERIODIC) 573 } 574 else if (pTimer->u64Config & HPET_TN_PERIODIC) 569 575 { 570 576 pTimer->u64Period = (pTimer->u64Period & 0xffffffffULL) 571 | ((uint64_t)iNewValue << 32);577 | ((uint64_t)iNewValue << 32); 572 578 } 573 579 574 580 pTimer->u64Cmp = (pTimer->u64Cmp & 0xffffffffULL) 575 | ((uint64_t)iNewValue << 32);581 | ((uint64_t)iNewValue << 32); 576 582 577 583 Log2(("after HPET_TN_CMP+4 cmp=%llx per=%llx\n", pTimer->u64Cmp, pTimer->u64Period)); … … 741 747 case 4: 742 748 { 743 if ( (iIndex >= 0x100) && (iIndex < 0x400))749 if (iIndex >= 0x100 && iIndex < 0x400) 744 750 rc = hpetTimerRegRead32(pThis, (iIndex - 0x100) / 0x20, (iIndex - 0x100) % 0x20, (uint32_t*)pv); 745 751 else … … 749 755 case 8: 750 756 { 751 union { 757 union 758 { 752 759 uint32_t u32[2]; 753 760 uint64_t u64; … … 761 768 break; 762 769 } 763 if ( (iIndex >= 0x100) && (iIndex < 0x400))770 if (iIndex >= 0x100 && iIndex < 0x400) 764 771 { 765 772 uint32_t iTimer = (iIndex - 0x100) / 0x20; … … 778 785 /* When reading HPET counter we must read it in a single read, 779 786 to avoid unexpected time jumps on 32-bit overflow. */ 780 value.u64 = 781 (pThis->u64HpetConfig & HPET_CFG_ENABLE) != 0 782 ? 783 hpetGetTicks(pThis) 784 : 785 pThis->u64HpetCounter; 787 value.u64 = (pThis->u64HpetConfig & HPET_CFG_ENABLE) != 0 788 ? hpetGetTicks(pThis) 789 : pThis->u64HpetCounter; 786 790 rc = VINF_SUCCESS; 787 791 } … … 837 841 case 4: 838 842 { 839 if ( (iIndex >= 0x100) && (iIndex < 0x400))843 if (iIndex >= 0x100 && iIndex < 0x400) 840 844 rc = hpetTimerRegWrite32(pThis, 841 845 (iIndex - 0x100) / 0x20, … … 848 852 case 8: 849 853 { 850 union { 854 union 855 { 851 856 uint32_t u32[2]; 852 857 uint64_t u64; … … 862 867 value.u64 = *(uint64_t*)pv; 863 868 // for 8-byte accesses we just split them, happens under lock anyway 864 if ( (iIndex >= 0x100) && (iIndex < 0x400))869 if (iIndex >= 0x100 && iIndex < 0x400) 865 870 { 866 871 uint32_t iTimer = (iIndex - 0x100) / 0x20; … … 1018 1023 1019 1024 /** @todo: is it correct? */ 1020 if ( !!(pTimer->u64Config & HPET_TN_ENABLE) &&1021 !!(pThis->u64HpetConfig & HPET_CFG_ENABLE))1025 if ( !!(pTimer->u64Config & HPET_TN_ENABLE) 1026 && !!(pThis->u64HpetConfig & HPET_CFG_ENABLE)) 1022 1027 { 1023 1028 Log4(("HPET: raising IRQ %d\n", irq)); … … 1071 1076 TMTimerSetNano(pTmTimer, hpetTicksToNs(pThis, u64Diff)); 1072 1077 } 1073 else if ( (pTimer->u64Config & HPET_TN_32BIT) &&1074 !(pTimer->u64Config & HPET_TN_PERIODIC))1078 else if ( (pTimer->u64Config & HPET_TN_32BIT) 1079 && !(pTimer->u64Config & HPET_TN_PERIODIC)) 1075 1080 { 1076 1081 if (pTimer->u8Wrap) -
trunk/src/VBox/Devices/testcase/tstDeviceStructSizeRC.cpp
r36273 r36870 1675 1675 GEN_CHECK_OFF(HpetState, u64Isr); 1676 1676 GEN_CHECK_OFF(HpetState, u64HpetCounter); 1677 GEN_CHECK_OFF(HpetState, csLock); 1678 GEN_CHECK_OFF(HpetState, fIch9); 1677 1679 1678 1680 GEN_CHECK_SIZE(HpetTimer);
Note:
See TracChangeset
for help on using the changeset viewer.