1 | /* $Id: internal-r0drv-nt.h 93115 2022-01-01 11:31:46Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * IPRT - Internal Header for the NT Ring-0 Driver Code.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2008-2022 Oracle Corporation
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | * available from http://www.virtualbox.org. This file is free software;
|
---|
11 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
12 | * General Public License (GPL) as published by the Free Software
|
---|
13 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
14 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
15 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | *
|
---|
17 | * The contents of this file may alternatively be used under the terms
|
---|
18 | * of the Common Development and Distribution License Version 1.0
|
---|
19 | * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
|
---|
20 | * VirtualBox OSE distribution, in which case the provisions of the
|
---|
21 | * CDDL are applicable instead of those of the GPL.
|
---|
22 | *
|
---|
23 | * You may elect to license modified versions of this file under the
|
---|
24 | * terms and conditions of either the GPL or the CDDL or both.
|
---|
25 | */
|
---|
26 |
|
---|
27 | #ifndef IPRT_INCLUDED_SRC_r0drv_nt_internal_r0drv_nt_h
|
---|
28 | #define IPRT_INCLUDED_SRC_r0drv_nt_internal_r0drv_nt_h
|
---|
29 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
30 | # pragma once
|
---|
31 | #endif
|
---|
32 |
|
---|
33 | #include <iprt/cpuset.h>
|
---|
34 | #include <iprt/nt/nt.h>
|
---|
35 |
|
---|
36 | RT_C_DECLS_BEGIN
|
---|
37 |
|
---|
38 | /*********************************************************************************************************************************
|
---|
39 | * Structures and Typedefs *
|
---|
40 | *********************************************************************************************************************************/
|
---|
41 | typedef ULONG (__stdcall *PFNMYEXSETTIMERRESOLUTION)(ULONG, BOOLEAN);
|
---|
42 | typedef VOID (__stdcall *PFNMYKEFLUSHQUEUEDDPCS)(VOID);
|
---|
43 | typedef VOID (__stdcall *PFNHALSENDSOFTWAREINTERRUPT)(ULONG ProcessorNumber, KIRQL Irql);
|
---|
44 | typedef int (__stdcall *PFNRTSENDIPI)(RTCPUID idCpu);
|
---|
45 | typedef ULONG_PTR (__stdcall *PFNRTKEIPIGENERICCALL)(PKIPI_BROADCAST_WORKER BroadcastFunction, ULONG_PTR Context);
|
---|
46 | typedef ULONG (__stdcall *PFNRTRTLGETVERSION)(PRTL_OSVERSIONINFOEXW pVerInfo);
|
---|
47 | #ifndef RT_ARCH_AMD64
|
---|
48 | typedef ULONGLONG (__stdcall *PFNRTKEQUERYINTERRUPTTIME)(VOID);
|
---|
49 | typedef VOID (__stdcall *PFNRTKEQUERYSYSTEMTIME)(PLARGE_INTEGER pTime);
|
---|
50 | #endif
|
---|
51 | typedef ULONG64 (__stdcall *PFNRTKEQUERYINTERRUPTTIMEPRECISE)(PULONG64 pQpcTS);
|
---|
52 | typedef VOID (__stdcall *PFNRTKEQUERYSYSTEMTIMEPRECISE)(PLARGE_INTEGER pTime);
|
---|
53 | typedef PMDL (__stdcall *PFNMMALLOCATEPAGESFORMDLEX)(PHYSICAL_ADDRESS, PHYSICAL_ADDRESS, PHYSICAL_ADDRESS,
|
---|
54 | SIZE_T, MEMORY_CACHING_TYPE, ULONG);
|
---|
55 |
|
---|
56 | #ifndef EX_TIMER_HIGH_RESOLUTION /* Too old DDK, so add missing bits. */
|
---|
57 | # define EX_TIMER_NO_WAKE RT_BIT_32(3)
|
---|
58 | # define EX_TIMER_HIGH_RESOLUTION RT_BIT_32(2)
|
---|
59 | # define EX_TIMER_NOTIFICATION RT_BIT_32(31)
|
---|
60 | typedef struct _EX_TIMER *PEX_TIMER;
|
---|
61 | typedef VOID (__stdcall *PEXT_CALLBACK)(PEX_TIMER, void *);
|
---|
62 | typedef PEX_TIMER (__stdcall *PFNEXALLOCATETIMER)(PEXT_CALLBACK pfnCallback, void *pvUser, ULONG fFlags);
|
---|
63 |
|
---|
64 | typedef VOID (__stdcall *PEXT_DELETE_CALLBACK)(void *);
|
---|
65 | typedef struct _EXT_DELETE_PARAMETERS
|
---|
66 | {
|
---|
67 | ULONG Version;
|
---|
68 | ULONG Reserved;
|
---|
69 | PEXT_DELETE_CALLBACK DeleteCallback;
|
---|
70 | void *DeleteContext;
|
---|
71 | } EXT_DELETE_PARAMETERS;
|
---|
72 | typedef EXT_DELETE_PARAMETERS *PEXT_DELETE_PARAMETERS;
|
---|
73 | DECLINLINE(void) ExInitializeDeleteTimerParameters(PEXT_DELETE_PARAMETERS pParams)
|
---|
74 | {
|
---|
75 | pParams->Version = 0;
|
---|
76 | pParams->Reserved = 0;
|
---|
77 | pParams->DeleteCallback = NULL;
|
---|
78 | pParams->DeleteContext = NULL;
|
---|
79 | }
|
---|
80 | typedef BOOLEAN (__stdcall *PFNEXDELETETIMER)(PEX_TIMER pTimer, BOOLEAN fCancel, BOOLEAN fWait, PEXT_DELETE_PARAMETERS pParams);
|
---|
81 |
|
---|
82 | typedef struct _EXT_SET_PARAMETERS_V0
|
---|
83 | {
|
---|
84 | ULONG Version;
|
---|
85 | ULONG Reserved;
|
---|
86 | LONGLONG NoWakeTolerance;
|
---|
87 | } EXT_SET_PARAMETERS;
|
---|
88 | typedef EXT_SET_PARAMETERS *PEXT_SET_PARAMETERS;
|
---|
89 | DECLINLINE(void) ExInitializeSetTimerParameters(PEXT_SET_PARAMETERS pParams)
|
---|
90 | {
|
---|
91 | pParams->Version = 0;
|
---|
92 | pParams->Reserved = 0;
|
---|
93 | pParams->NoWakeTolerance = 0;
|
---|
94 | }
|
---|
95 | typedef BOOLEAN (__stdcall *PFNEXSETTIMER)(PEX_TIMER pTimer, LONGLONG DueTime, LONGLONG Period, PEXT_SET_PARAMETERS pParams);
|
---|
96 |
|
---|
97 | typedef BOOLEAN (__stdcall *PFNEXCANCELTIMER)(PEX_TIMER pTimer, void *pvReserved);
|
---|
98 |
|
---|
99 | #else
|
---|
100 | typedef decltype(ExAllocateTimer) *PFNEXALLOCATETIMER;
|
---|
101 | typedef decltype(ExDeleteTimer) *PFNEXDELETETIMER;
|
---|
102 | typedef decltype(ExSetTimer) *PFNEXSETTIMER;
|
---|
103 | typedef decltype(ExCancelTimer) *PFNEXCANCELTIMER;
|
---|
104 | #endif
|
---|
105 |
|
---|
106 |
|
---|
107 | /*********************************************************************************************************************************
|
---|
108 | * Global Variables *
|
---|
109 | *********************************************************************************************************************************/
|
---|
110 | extern RTCPUSET g_rtMpNtCpuSet;
|
---|
111 | extern uint32_t g_cRtMpNtMaxGroups;
|
---|
112 | extern uint32_t g_cRtMpNtMaxCpus;
|
---|
113 | extern RTCPUID g_aidRtMpNtByCpuSetIdx[RTCPUSET_MAX_CPUS];
|
---|
114 |
|
---|
115 | extern decltype(ExAllocatePoolWithTag) *g_pfnrtExAllocatePoolWithTag;
|
---|
116 | extern decltype(ExFreePoolWithTag) *g_pfnrtExFreePoolWithTag;
|
---|
117 | extern PFNMYEXSETTIMERRESOLUTION g_pfnrtNtExSetTimerResolution;
|
---|
118 | extern PFNEXALLOCATETIMER g_pfnrtExAllocateTimer;
|
---|
119 | extern PFNEXDELETETIMER g_pfnrtExDeleteTimer;
|
---|
120 | extern PFNEXSETTIMER g_pfnrtExSetTimer;
|
---|
121 | extern PFNEXCANCELTIMER g_pfnrtExCancelTimer;
|
---|
122 | extern PFNMYKEFLUSHQUEUEDDPCS g_pfnrtNtKeFlushQueuedDpcs;
|
---|
123 | extern PFNHALREQUESTIPI_W7PLUS g_pfnrtHalRequestIpiW7Plus;
|
---|
124 | extern PFNHALREQUESTIPI_PRE_W7 g_pfnrtHalRequestIpiPreW7;
|
---|
125 | extern PFNHALSENDSOFTWAREINTERRUPT g_pfnrtNtHalSendSoftwareInterrupt;
|
---|
126 | extern PFNRTSENDIPI g_pfnrtMpPokeCpuWorker;
|
---|
127 | extern PFNRTKEIPIGENERICCALL g_pfnrtKeIpiGenericCall;
|
---|
128 | extern PFNKESETTARGETPROCESSORDPCEX g_pfnrtKeSetTargetProcessorDpcEx;
|
---|
129 | extern PFNKEINITIALIZEAFFINITYEX g_pfnrtKeInitializeAffinityEx;
|
---|
130 | extern PFNKEADDPROCESSORAFFINITYEX g_pfnrtKeAddProcessorAffinityEx;
|
---|
131 | extern PFNKEGETPROCESSORINDEXFROMNUMBER g_pfnrtKeGetProcessorIndexFromNumber;
|
---|
132 | extern PFNKEGETPROCESSORNUMBERFROMINDEX g_pfnrtKeGetProcessorNumberFromIndex;
|
---|
133 | extern PFNKEGETCURRENTPROCESSORNUMBEREX g_pfnrtKeGetCurrentProcessorNumberEx;
|
---|
134 | extern PFNKEQUERYACTIVEPROCESSORS g_pfnrtKeQueryActiveProcessors;
|
---|
135 | extern PFNKEQUERYMAXIMUMPROCESSORCOUNT g_pfnrtKeQueryMaximumProcessorCount;
|
---|
136 | extern PFNKEQUERYMAXIMUMPROCESSORCOUNTEX g_pfnrtKeQueryMaximumProcessorCountEx;
|
---|
137 | extern PFNKEQUERYMAXIMUMGROUPCOUNT g_pfnrtKeQueryMaximumGroupCount;
|
---|
138 | extern PFNKEQUERYACTIVEPROCESSORCOUNT g_pfnrtKeQueryActiveProcessorCount;
|
---|
139 | extern PFNKEQUERYACTIVEPROCESSORCOUNTEX g_pfnrtKeQueryActiveProcessorCountEx;
|
---|
140 | extern PFNKEQUERYLOGICALPROCESSORRELATIONSHIP g_pfnrtKeQueryLogicalProcessorRelationship;
|
---|
141 | extern PFNKEREGISTERPROCESSORCHANGECALLBACK g_pfnrtKeRegisterProcessorChangeCallback;
|
---|
142 | extern PFNKEDEREGISTERPROCESSORCHANGECALLBACK g_pfnrtKeDeregisterProcessorChangeCallback;
|
---|
143 | extern decltype(KeSetImportanceDpc) *g_pfnrtKeSetImportanceDpc;
|
---|
144 | extern decltype(KeSetTargetProcessorDpc) *g_pfnrtKeSetTargetProcessorDpc;
|
---|
145 | extern decltype(KeInitializeTimerEx) *g_pfnrtKeInitializeTimerEx;
|
---|
146 | extern PFNKESHOULDYIELDPROCESSOR g_pfnrtKeShouldYieldProcessor;
|
---|
147 | extern decltype(MmProtectMdlSystemAddress) *g_pfnrtMmProtectMdlSystemAddress;
|
---|
148 | extern decltype(MmAllocatePagesForMdl) *g_pfnrtMmAllocatePagesForMdl;
|
---|
149 | extern PFNMMALLOCATEPAGESFORMDLEX g_pfnrtMmAllocatePagesForMdlEx;
|
---|
150 | extern decltype(MmFreePagesFromMdl) *g_pfnrtMmFreePagesFromMdl;
|
---|
151 | extern decltype(MmMapLockedPagesSpecifyCache) *g_pfnrtMmMapLockedPagesSpecifyCache;
|
---|
152 | extern decltype(MmAllocateContiguousMemorySpecifyCache) *g_pfnrtMmAllocateContiguousMemorySpecifyCache;
|
---|
153 | extern decltype(MmSecureVirtualMemory) *g_pfnrtMmSecureVirtualMemory;
|
---|
154 | extern decltype(MmUnsecureVirtualMemory) *g_pfnrtMmUnsecureVirtualMemory;
|
---|
155 | extern decltype(PsIsThreadTerminating) *g_pfnrtPsIsThreadTerminating;
|
---|
156 |
|
---|
157 | extern PFNRTRTLGETVERSION g_pfnrtRtlGetVersion;
|
---|
158 | #ifdef RT_ARCH_X86
|
---|
159 | extern PFNRTKEQUERYINTERRUPTTIME g_pfnrtKeQueryInterruptTime;
|
---|
160 | #endif
|
---|
161 | extern PFNRTKEQUERYINTERRUPTTIMEPRECISE g_pfnrtKeQueryInterruptTimePrecise;
|
---|
162 | extern PFNRTKEQUERYSYSTEMTIMEPRECISE g_pfnrtKeQuerySystemTimePrecise;
|
---|
163 |
|
---|
164 | extern uint32_t g_offrtNtPbQuantumEnd;
|
---|
165 | extern uint32_t g_cbrtNtPbQuantumEnd;
|
---|
166 | extern uint32_t g_offrtNtPbDpcQueueDepth;
|
---|
167 |
|
---|
168 | /** Makes an NT version for checking against g_uRtNtVersion. */
|
---|
169 | #define RTNT_MAKE_VERSION(uMajor, uMinor) RT_MAKE_U32(uMinor, uMajor)
|
---|
170 |
|
---|
171 | extern uint32_t g_uRtNtVersion;
|
---|
172 | extern uint8_t g_uRtNtMajorVer;
|
---|
173 | extern uint8_t g_uRtNtMinorVer;
|
---|
174 | extern uint32_t g_uRtNtBuildNo;
|
---|
175 |
|
---|
176 | extern uintptr_t const *g_puRtMmHighestUserAddress;
|
---|
177 | extern uintptr_t const *g_puRtMmSystemRangeStart;
|
---|
178 |
|
---|
179 |
|
---|
180 | int __stdcall rtMpPokeCpuUsingFailureNotSupported(RTCPUID idCpu);
|
---|
181 | int __stdcall rtMpPokeCpuUsingDpc(RTCPUID idCpu);
|
---|
182 | int __stdcall rtMpPokeCpuUsingBroadcastIpi(RTCPUID idCpu);
|
---|
183 | int __stdcall rtMpPokeCpuUsingHalRequestIpiW7Plus(RTCPUID idCpu);
|
---|
184 | int __stdcall rtMpPokeCpuUsingHalRequestIpiPreW7(RTCPUID idCpu);
|
---|
185 |
|
---|
186 | struct RTNTSDBOSVER;
|
---|
187 | DECLHIDDEN(int) rtR0MpNtInit(struct RTNTSDBOSVER const *pOsVerInfo);
|
---|
188 | DECLHIDDEN(void) rtR0MpNtTerm(void);
|
---|
189 | DECLHIDDEN(int) rtMpNtSetTargetProcessorDpc(KDPC *pDpc, RTCPUID idCpu);
|
---|
190 | #if defined(RT_ARCH_X86) && defined(NIL_RTDBGKRNLINFO)
|
---|
191 | DECLHIDDEN(int) rtR0Nt3InitSymbols(RTDBGKRNLINFO hKrnlInfo);
|
---|
192 | #endif
|
---|
193 |
|
---|
194 | RT_C_DECLS_END
|
---|
195 |
|
---|
196 | #endif /* !IPRT_INCLUDED_SRC_r0drv_nt_internal_r0drv_nt_h */
|
---|
197 |
|
---|