VirtualBox

source: vbox/trunk/src/VBox/Runtime/r0drv/nt/internal-r0drv-nt.h@ 98102

Last change on this file since 98102 was 96407, checked in by vboxsync, 2 years ago

scm copyright and license note update

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

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette