Changeset 1956 in vbox for trunk/src/VBox/VMM
- Timestamp:
- Apr 5, 2007 3:26:03 PM (18 years ago)
- Location:
- trunk/src/VBox/VMM
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/TM.cpp
r1876 r1956 217 217 if (rc == VERR_CFGM_VALUE_NOT_FOUND) 218 218 { 219 #if 0 /* when tmCpuTickGetRawVirtual is done */220 219 pVM->tm.s.cTSCTicksPerSecond = tmR3Calibrate(); 221 #else 222 if (pVM->tm.s.fTSCUseRealTSC) 223 pVM->tm.s.cTSCTicksPerSecond = tmR3Calibrate(); 224 else 225 pVM->tm.s.cTSCTicksPerSecond = TMCLOCK_FREQ_VIRTUAL;/* same as the virtual clock. */ 226 #endif 220 if ( !pVM->tm.s.fTSCUseRealTSC 221 && pVM->tm.s.cTSCTicksPerSecond >= _4G) 222 pVM->tm.s.cTSCTicksPerSecond = _4G - 1; /* (A limitation of our math code) */ 227 223 } 228 224 else if (VBOX_FAILURE(rc)) 229 225 return VMSetError(pVM, rc, RT_SRC_POS, 230 226 N_("Configuration error: Failed to querying uint64_t value \"TSCTicksPerSecond\". (%Vrc)"), rc); 231 #if 0 /* when tmCpuTickGetRawVirtual is done */232 227 else if ( pVM->tm.s.cTSCTicksPerSecond < _1M 233 || pVM->tm.s.cTSCTicksPerSecond > _1E)228 || pVM->tm.s.cTSCTicksPerSecond >= _4G) 234 229 return VMSetError(pVM, VERR_INVALID_PARAMETER, RT_SRC_POS, 235 N_("Configuration error: \"TSCTicksPerSecond\" = %RI64 is not in the range 1MHz.. 1EHz!"),230 N_("Configuration error: \"TSCTicksPerSecond\" = %RI64 is not in the range 1MHz..4GHz-1!"), 236 231 pVM->tm.s.cTSCTicksPerSecond); 237 #else238 else if (pVM->tm.s.cTSCTicksPerSecond != TMCLOCK_FREQ_VIRTUAL)239 return VMSetError(pVM, VERR_INVALID_PARAMETER, RT_SRC_POS,240 N_("Configuration error: \"TSCTicksPerSecond\" = %RI64 is not 1GHz! (temporary restriction)"),241 pVM->tm.s.cTSCTicksPerSecond);242 #endif243 232 else 244 233 { … … 636 625 /* the cpu tick clock. */ 637 626 pVM->tm.s.fTSCTicking = false; 627 SSMR3GetU64(pSSM, &pVM->tm.s.u64TSC); 638 628 rc = SSMR3GetU64(pSSM, &u64Hz); 639 629 if (VBOX_FAILURE(rc)) 640 630 return rc; 641 SSMR3GetU64(pSSM, &pVM->tm.s.u64TSC); 642 /** @todo check TSC frequency and virtualize the TSC properly! */ 643 pVM->tm.s.u64TSCOffset = 0; 631 if (pVM->tm.s.fTSCUseRealTSC) 632 pVM->tm.s.u64TSCOffset = 0; /** @todo TSC restore stuff and HWACC. */ 633 else 634 pVM->tm.s.cTSCTicksPerSecond = u64Hz; 635 LogRel(("TM: cTSCTicksPerSecond=%#RX64 (%RU64) fTSCVirtualized=%RTbool fTSCUseRealTSC=%RTbool (state load)\n", 636 pVM->tm.s.cTSCTicksPerSecond, pVM->tm.s.cTSCTicksPerSecond, pVM->tm.s.fTSCVirtualized, pVM->tm.s.fTSCUseRealTSC)); 644 637 645 638 /* … … 1286 1279 if (pVM->tm.s.fTSCUseRealTSC) 1287 1280 { 1288 pHlp->pfnPrintf(pHlp, " - real tsc");1281 pHlp->pfnPrintf(pHlp, " - real tsc"); 1289 1282 if (pVM->tm.s.u64TSCOffset) 1290 1283 pHlp->pfnPrintf(pHlp, "\n offset %#RX64", pVM->tm.s.u64TSCOffset); 1291 1284 } 1292 1285 else 1293 pHlp->pfnPrintf(pHlp, " - virtual clock");1286 pHlp->pfnPrintf(pHlp, " - virtual clock"); 1294 1287 pHlp->pfnPrintf(pHlp, "\n"); 1295 1288 -
trunk/src/VBox/VMM/VMMAll/TMAllCpu.cpp
r1057 r1956 42 42 { 43 43 uint64_t u64 = TMVirtualGet(pVM); 44 /** @todo calc tsc from virtual time. */ 44 if (u64 != TMCLOCK_FREQ_VIRTUAL) 45 u64 = ASMMultU64ByU32DivByU32(u64, pVM->tm.s.cTSCTicksPerSecond, TMCLOCK_FREQ_VIRTUAL); 45 46 return u64; 46 47 } … … 82 83 if (pVM->tm.s.fTSCTicking) 83 84 { 84 if (!pVM->tm.s.fTSCVirtualized) 85 { 86 if (pVM->tm.s.fTSCUseRealTSC) 87 pVM->tm.s.u64TSC = ASMReadTSC() - pVM->tm.s.u64TSCOffset; 88 else 89 pVM->tm.s.u64TSC = tmCpuTickGetRawVirtual(pVM) - pVM->tm.s.u64TSCOffset; 90 } 85 pVM->tm.s.u64TSC = TMCpuTickGet(pVM); 91 86 pVM->tm.s.fTSCTicking = false; 92 87 return VINF_SUCCESS; … … 107 102 { 108 103 uint64_t u64; 109 if (pVM->tm.s.fTSCUseRealTSC) 110 u64 = ASMReadTSC(); 111 else 104 if (RT_LIKELY(pVM->tm.s.fTSCTicking)) 112 105 { 113 if (pVM->tm.s.fTSC Ticking)106 if (pVM->tm.s.fTSCVirtualized) 114 107 { 115 108 if (pVM->tm.s.fTSCUseRealTSC) 116 u64 = ASMReadTSC() - pVM->tm.s.u64TSCOffset;109 u64 = ASMReadTSC(); 117 110 else 118 u64 = tmCpuTickGetRawVirtual(pVM) - pVM->tm.s.u64TSCOffset; 111 u64 = tmCpuTickGetRawVirtual(pVM); 112 u64 -= pVM->tm.s.u64TSCOffset; 119 113 } 120 114 else 121 u64 = pVM->tm.s.u64TSC;115 u64 = ASMReadTSC(); 122 116 } 117 else 118 u64 = pVM->tm.s.u64TSC; 123 119 return u64; 124 120 }
Note:
See TracChangeset
for help on using the changeset viewer.