Changeset 53456 in vbox
- Timestamp:
- Dec 5, 2014 12:52:46 PM (10 years ago)
- Location:
- trunk/src/VBox/Runtime/r0drv/nt
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/r0drv/nt/initterm-r0drv-nt.cpp
r48935 r53456 50 50 * and update this variable as CPUs comes online. (The code is done already.) 51 51 */ 52 RTCPUSET g_rtMpNtCpuSet;52 RTCPUSET g_rtMpNtCpuSet; 53 53 54 54 /** ExSetTimerResolution, introduced in W2K. */ 55 PFNMYEXSETTIMERRESOLUTION g_pfnrtNtExSetTimerResolution;55 PFNMYEXSETTIMERRESOLUTION g_pfnrtNtExSetTimerResolution; 56 56 /** KeFlushQueuedDpcs, introduced in XP. */ 57 PFNMYKEFLUSHQUEUEDDPCS g_pfnrtNtKeFlushQueuedDpcs;57 PFNMYKEFLUSHQUEUEDDPCS g_pfnrtNtKeFlushQueuedDpcs; 58 58 /** HalRequestIpi, introduced in ??. */ 59 PFNHALREQUESTIPI g_pfnrtNtHalRequestIpi;59 PFNHALREQUESTIPI g_pfnrtNtHalRequestIpi; 60 60 /** HalSendSoftwareInterrupt */ 61 PFNHALSENDSOFTWAREINTERRUPT g_pfnrtNtHalSendSoftwareInterrupt;61 PFNHALSENDSOFTWAREINTERRUPT g_pfnrtNtHalSendSoftwareInterrupt; 62 62 /** SendIpi handler based on Windows version */ 63 PFNRTSENDIPI g_pfnrtSendIpi;63 PFNRTSENDIPI g_pfnrtSendIpi; 64 64 /** KeIpiGenericCall - Windows Server 2003+ only */ 65 PFNRTKEIPIGENERICCALL g_pfnrtKeIpiGenericCall;65 PFNRTKEIPIGENERICCALL g_pfnrtKeIpiGenericCall; 66 66 /** RtlGetVersion, introduced in ??. */ 67 PFNRTRTLGETVERSION g_pfnrtRtlGetVersion; 67 PFNRTRTLGETVERSION g_pfnrtRtlGetVersion; 68 #ifndef RT_ARCH_AMD64 69 /** KeQueryInterruptTime - exported/new in Windows 2000. */ 70 PFNRTKEQUERYINTERRUPTTIME g_pfnrtKeQueryInterruptTime; 71 /** KeQuerySystemTime - exported/new in Windows 2000. */ 72 PFNRTKEQUERYSYSTEMTIME g_pfnrtKeQuerySystemTime; 73 #endif 74 /** KeQueryInterruptTimePrecise - new in Windows 8. */ 75 PFNRTKEQUERYINTERRUPTTIMEPRECISE g_pfnrtKeQueryInterruptTimePrecise; 76 /** KeQuerySystemTimePrecise - new in Windows 8. */ 77 PFNRTKEQUERYSYSTEMTIMEPRECISE g_pfnrtKeQuerySystemTimePrecise; 68 78 69 79 /** Offset of the _KPRCB::QuantumEnd field. 0 if not found. */ 70 uint32_t g_offrtNtPbQuantumEnd;80 uint32_t g_offrtNtPbQuantumEnd; 71 81 /** Size of the _KPRCB::QuantumEnd field. 0 if not found. */ 72 uint32_t g_cbrtNtPbQuantumEnd;82 uint32_t g_cbrtNtPbQuantumEnd; 73 83 /** Offset of the _KPRCB::DpcQueueDepth field. 0 if not found. */ 74 uint32_t g_offrtNtPbDpcQueueDepth;84 uint32_t g_offrtNtPbDpcQueueDepth; 75 85 76 86 … … 200 210 /** @todo Port to W2K8 with > 64 cpus/threads. */ 201 211 212 /* 213 * Initialize the function pointers. 214 */ 202 215 #ifdef IPRT_TARGET_NT4 203 216 g_pfnrtNtExSetTimerResolution = NULL; … … 207 220 g_pfnrtKeIpiGenericCall = NULL; 208 221 g_pfnrtRtlGetVersion = NULL; 222 g_pfnrtKeQueryInterruptTime = NULL; 223 g_pfnrtKeQueryInterruptTimePrecise = NULL; 224 g_pfnrtKeQuerySystemTime = NULL; 225 g_pfnrtKeQuerySystemTimePrecise = NULL; 209 226 #else 210 /*211 * Initialize the function pointers.212 */213 227 UNICODE_STRING RoutineName; 214 228 RtlInitUnicodeString(&RoutineName, L"ExSetTimerResolution"); … … 229 243 RtlInitUnicodeString(&RoutineName, L"RtlGetVersion"); 230 244 g_pfnrtRtlGetVersion = (PFNRTRTLGETVERSION)MmGetSystemRoutineAddress(&RoutineName); 245 # ifndef RT_ARCH_AMD64 246 RtlInitUnicodeString(&RoutineName, L"KeQueryInterruptTime"); 247 g_pfnrtKeQueryInterruptTime = (PFNRTKEQUERYINTERRUPTTIME)MmGetSystemRoutineAddress(&RoutineName); 248 249 RtlInitUnicodeString(&RoutineName, L"KeQuerySystemTime"); 250 g_pfnrtKeQuerySystemTime = (PFNRTKEQUERYSYSTEMTIME)MmGetSystemRoutineAddress(&RoutineName); 251 # endif 252 RtlInitUnicodeString(&RoutineName, L"KeQueryInterruptTimePrecise"); 253 g_pfnrtKeQueryInterruptTimePrecise = (PFNRTKEQUERYINTERRUPTTIMEPRECISE)MmGetSystemRoutineAddress(&RoutineName); 254 255 RtlInitUnicodeString(&RoutineName, L"KeQuerySystemTimePrecise"); 256 g_pfnrtKeQuerySystemTimePrecise = (PFNRTKEQUERYSYSTEMTIMEPRECISE)MmGetSystemRoutineAddress(&RoutineName); 231 257 #endif 232 258 -
trunk/src/VBox/Runtime/r0drv/nt/internal-r0drv-nt.h
r45443 r53456 42 42 typedef ULONG_PTR (__stdcall *PFNRTKEIPIGENERICCALL)(PKIPI_BROADCAST_WORKER BroadcastFunction, ULONG_PTR Context); 43 43 typedef ULONG (__stdcall *PFNRTRTLGETVERSION)(PRTL_OSVERSIONINFOEXW pVerInfo); 44 #ifndef RT_ARCH_AMD64 45 typedef ULONGLONG (__stdcall *PFNRTKEQUERYINTERRUPTTIME)(VOID); 46 typedef VOID (__stdcall *PFNRTKEQUERYSYSTEMTIME)(PLARGE_INTEGER pTime); 47 #endif 48 typedef ULONG64 (__stdcall *PFNRTKEQUERYINTERRUPTTIMEPRECISE)(PULONG64 pQpcTS); 49 typedef VOID (__stdcall *PFNRTKEQUERYSYSTEMTIMEPRECISE)(PLARGE_INTEGER pTime); 50 44 51 45 52 /******************************************************************************* 46 53 * Global Variables * 47 54 *******************************************************************************/ 48 extern RTCPUSET g_rtMpNtCpuSet; 49 extern PFNMYEXSETTIMERRESOLUTION g_pfnrtNtExSetTimerResolution; 50 extern PFNMYKEFLUSHQUEUEDDPCS g_pfnrtNtKeFlushQueuedDpcs; 51 extern PFNHALREQUESTIPI g_pfnrtNtHalRequestIpi; 52 extern PFNHALSENDSOFTWAREINTERRUPT g_pfnrtNtHalSendSoftwareInterrupt; 53 extern PFNRTSENDIPI g_pfnrtSendIpi; 54 extern PFNRTKEIPIGENERICCALL g_pfnrtKeIpiGenericCall; 55 extern PFNRTRTLGETVERSION g_pfnrtRtlGetVersion; 56 extern uint32_t g_offrtNtPbQuantumEnd; 57 extern uint32_t g_cbrtNtPbQuantumEnd; 58 extern uint32_t g_offrtNtPbDpcQueueDepth; 55 extern RTCPUSET g_rtMpNtCpuSet; 56 extern PFNMYEXSETTIMERRESOLUTION g_pfnrtNtExSetTimerResolution; 57 extern PFNMYKEFLUSHQUEUEDDPCS g_pfnrtNtKeFlushQueuedDpcs; 58 extern PFNHALREQUESTIPI g_pfnrtNtHalRequestIpi; 59 extern PFNHALSENDSOFTWAREINTERRUPT g_pfnrtNtHalSendSoftwareInterrupt; 60 extern PFNRTSENDIPI g_pfnrtSendIpi; 61 extern PFNRTKEIPIGENERICCALL g_pfnrtKeIpiGenericCall; 62 extern PFNRTRTLGETVERSION g_pfnrtRtlGetVersion; 63 #ifndef RT_ARCH_AMD64 64 extern PFNRTKEQUERYINTERRUPTTIME g_pfnrtKeQueryInterruptTime; 65 extern PFNRTKEQUERYSYSTEMTIME g_pfnrtKeQuerySystemTime; 66 #endif 67 extern PFNRTKEQUERYINTERRUPTTIMEPRECISE g_pfnrtKeQueryInterruptTimePrecise; 68 extern PFNRTKEQUERYSYSTEMTIMEPRECISE g_pfnrtKeQuerySystemTimePrecise; 69 extern uint32_t g_offrtNtPbQuantumEnd; 70 extern uint32_t g_cbrtNtPbQuantumEnd; 71 extern uint32_t g_offrtNtPbDpcQueueDepth; 59 72 60 73 -
trunk/src/VBox/Runtime/r0drv/nt/time-r0drv-nt.cpp
r52822 r53456 31 31 #define LOG_GROUP RTLOGGROUP_TIME 32 32 #include "the-nt-kernel.h" 33 #include "internal-r0drv-nt.h" 33 34 #include <iprt/time.h> 34 35 … … 49 50 */ 50 51 #if 1 51 /* Interrupt time. (NT4 doesn't have an API for it.) */ 52 # ifndef IPRT_TARGET_NT4 53 ULONGLONG InterruptTime = KeQueryInterruptTime(); 54 return (uint64_t)InterruptTime * 100; /* The value is in 100ns, convert to ns units. */ 52 /* Interrupt time. */ 53 LARGE_INTEGER InterruptTime; 54 if (g_pfnrtKeQueryInterruptTimePrecise) 55 { 56 ULONG64 QpcTsIgnored; 57 InterruptTime.QuadPart = g_pfnrtKeQueryInterruptTimePrecise(&QpcTsIgnored); 58 } 59 # ifdef RT_ARCH_AMD64 60 else 61 InterruptTime.QuadPart = KeQueryInterruptTime(); /* macro */ 55 62 # else 56 LARGE_INTEGER InterruptTime; 57 do 63 else if (g_pfnrtKeQueryInterruptTime) 64 InterruptTime.QuadPart = g_pfnrtKeQueryInterruptTime(); 65 else 58 66 { 59 InterruptTime.HighPart = ((KUSER_SHARED_DATA volatile *)SharedUserData)->InterruptTime.High1Time; 60 InterruptTime.LowPart = ((KUSER_SHARED_DATA volatile *)SharedUserData)->InterruptTime.LowPart; 61 } while (((KUSER_SHARED_DATA volatile *)SharedUserData)->InterruptTime.High2Time != InterruptTime.HighPart); 62 67 /* NT4 (no API) and pre-init fallback. */ 68 do 69 { 70 InterruptTime.HighPart = ((KUSER_SHARED_DATA volatile *)SharedUserData)->InterruptTime.High1Time; 71 InterruptTime.LowPart = ((KUSER_SHARED_DATA volatile *)SharedUserData)->InterruptTime.LowPart; 72 } while (((KUSER_SHARED_DATA volatile *)SharedUserData)->InterruptTime.High2Time != InterruptTime.HighPart); 73 } 74 # endif 63 75 return (uint64_t)InterruptTime.QuadPart * 100; 64 # endif65 76 #else 66 77 /* Tick Count (NT4 SP1 has these APIs, haven't got SP0 to check). */ … … 99 110 { 100 111 LARGE_INTEGER SystemTime; 101 #ifndef IPRT_TARGET_NT4 102 KeQuerySystemTime(&SystemTime); 112 if (g_pfnrtKeQuerySystemTimePrecise) 113 g_pfnrtKeQuerySystemTimePrecise(&SystemTime); 114 #ifdef RT_ARCH_AMD64 115 else 116 KeQuerySystemTime(&SystemTime); /* macro */ 103 117 #else 104 do 118 else if (g_pfnrtKeQuerySystemTime) 119 g_pfnrtKeQuerySystemTime(&SystemTime); 120 else 105 121 { 106 SystemTime.HighPart = ((KUSER_SHARED_DATA volatile *)SharedUserData)->SystemTime.High1Time; 107 SystemTime.LowPart = ((KUSER_SHARED_DATA volatile *)SharedUserData)->SystemTime.LowPart; 108 } while (((KUSER_SHARED_DATA volatile *)SharedUserData)->SystemTime.High2Time != SystemTime.HighPart); 122 do 123 { 124 SystemTime.HighPart = ((KUSER_SHARED_DATA volatile *)SharedUserData)->SystemTime.High1Time; 125 SystemTime.LowPart = ((KUSER_SHARED_DATA volatile *)SharedUserData)->SystemTime.LowPart; 126 } while (((KUSER_SHARED_DATA volatile *)SharedUserData)->SystemTime.High2Time != SystemTime.HighPart); 127 } 109 128 #endif 110 129 return RTTimeSpecSetNtTime(pTime, SystemTime.QuadPart);
Note:
See TracChangeset
for help on using the changeset viewer.