VirtualBox

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

Last change on this file since 94176 was 93115, checked in by vboxsync, 3 years ago

scm --update-copyright-year

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 10.1 KB
Line 
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
36RT_C_DECLS_BEGIN
37
38/*********************************************************************************************************************************
39* Structures and Typedefs *
40*********************************************************************************************************************************/
41typedef ULONG (__stdcall *PFNMYEXSETTIMERRESOLUTION)(ULONG, BOOLEAN);
42typedef VOID (__stdcall *PFNMYKEFLUSHQUEUEDDPCS)(VOID);
43typedef VOID (__stdcall *PFNHALSENDSOFTWAREINTERRUPT)(ULONG ProcessorNumber, KIRQL Irql);
44typedef int (__stdcall *PFNRTSENDIPI)(RTCPUID idCpu);
45typedef ULONG_PTR (__stdcall *PFNRTKEIPIGENERICCALL)(PKIPI_BROADCAST_WORKER BroadcastFunction, ULONG_PTR Context);
46typedef ULONG (__stdcall *PFNRTRTLGETVERSION)(PRTL_OSVERSIONINFOEXW pVerInfo);
47#ifndef RT_ARCH_AMD64
48typedef ULONGLONG (__stdcall *PFNRTKEQUERYINTERRUPTTIME)(VOID);
49typedef VOID (__stdcall *PFNRTKEQUERYSYSTEMTIME)(PLARGE_INTEGER pTime);
50#endif
51typedef ULONG64 (__stdcall *PFNRTKEQUERYINTERRUPTTIMEPRECISE)(PULONG64 pQpcTS);
52typedef VOID (__stdcall *PFNRTKEQUERYSYSTEMTIMEPRECISE)(PLARGE_INTEGER pTime);
53typedef 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)
60typedef struct _EX_TIMER *PEX_TIMER;
61typedef VOID (__stdcall *PEXT_CALLBACK)(PEX_TIMER, void *);
62typedef PEX_TIMER (__stdcall *PFNEXALLOCATETIMER)(PEXT_CALLBACK pfnCallback, void *pvUser, ULONG fFlags);
63
64typedef VOID (__stdcall *PEXT_DELETE_CALLBACK)(void *);
65typedef struct _EXT_DELETE_PARAMETERS
66{
67 ULONG Version;
68 ULONG Reserved;
69 PEXT_DELETE_CALLBACK DeleteCallback;
70 void *DeleteContext;
71} EXT_DELETE_PARAMETERS;
72typedef EXT_DELETE_PARAMETERS *PEXT_DELETE_PARAMETERS;
73DECLINLINE(void) ExInitializeDeleteTimerParameters(PEXT_DELETE_PARAMETERS pParams)
74{
75 pParams->Version = 0;
76 pParams->Reserved = 0;
77 pParams->DeleteCallback = NULL;
78 pParams->DeleteContext = NULL;
79}
80typedef BOOLEAN (__stdcall *PFNEXDELETETIMER)(PEX_TIMER pTimer, BOOLEAN fCancel, BOOLEAN fWait, PEXT_DELETE_PARAMETERS pParams);
81
82typedef struct _EXT_SET_PARAMETERS_V0
83{
84 ULONG Version;
85 ULONG Reserved;
86 LONGLONG NoWakeTolerance;
87} EXT_SET_PARAMETERS;
88typedef EXT_SET_PARAMETERS *PEXT_SET_PARAMETERS;
89DECLINLINE(void) ExInitializeSetTimerParameters(PEXT_SET_PARAMETERS pParams)
90{
91 pParams->Version = 0;
92 pParams->Reserved = 0;
93 pParams->NoWakeTolerance = 0;
94}
95typedef BOOLEAN (__stdcall *PFNEXSETTIMER)(PEX_TIMER pTimer, LONGLONG DueTime, LONGLONG Period, PEXT_SET_PARAMETERS pParams);
96
97typedef BOOLEAN (__stdcall *PFNEXCANCELTIMER)(PEX_TIMER pTimer, void *pvReserved);
98
99#else
100typedef decltype(ExAllocateTimer) *PFNEXALLOCATETIMER;
101typedef decltype(ExDeleteTimer) *PFNEXDELETETIMER;
102typedef decltype(ExSetTimer) *PFNEXSETTIMER;
103typedef decltype(ExCancelTimer) *PFNEXCANCELTIMER;
104#endif
105
106
107/*********************************************************************************************************************************
108* Global Variables *
109*********************************************************************************************************************************/
110extern RTCPUSET g_rtMpNtCpuSet;
111extern uint32_t g_cRtMpNtMaxGroups;
112extern uint32_t g_cRtMpNtMaxCpus;
113extern RTCPUID g_aidRtMpNtByCpuSetIdx[RTCPUSET_MAX_CPUS];
114
115extern decltype(ExAllocatePoolWithTag) *g_pfnrtExAllocatePoolWithTag;
116extern decltype(ExFreePoolWithTag) *g_pfnrtExFreePoolWithTag;
117extern PFNMYEXSETTIMERRESOLUTION g_pfnrtNtExSetTimerResolution;
118extern PFNEXALLOCATETIMER g_pfnrtExAllocateTimer;
119extern PFNEXDELETETIMER g_pfnrtExDeleteTimer;
120extern PFNEXSETTIMER g_pfnrtExSetTimer;
121extern PFNEXCANCELTIMER g_pfnrtExCancelTimer;
122extern PFNMYKEFLUSHQUEUEDDPCS g_pfnrtNtKeFlushQueuedDpcs;
123extern PFNHALREQUESTIPI_W7PLUS g_pfnrtHalRequestIpiW7Plus;
124extern PFNHALREQUESTIPI_PRE_W7 g_pfnrtHalRequestIpiPreW7;
125extern PFNHALSENDSOFTWAREINTERRUPT g_pfnrtNtHalSendSoftwareInterrupt;
126extern PFNRTSENDIPI g_pfnrtMpPokeCpuWorker;
127extern PFNRTKEIPIGENERICCALL g_pfnrtKeIpiGenericCall;
128extern PFNKESETTARGETPROCESSORDPCEX g_pfnrtKeSetTargetProcessorDpcEx;
129extern PFNKEINITIALIZEAFFINITYEX g_pfnrtKeInitializeAffinityEx;
130extern PFNKEADDPROCESSORAFFINITYEX g_pfnrtKeAddProcessorAffinityEx;
131extern PFNKEGETPROCESSORINDEXFROMNUMBER g_pfnrtKeGetProcessorIndexFromNumber;
132extern PFNKEGETPROCESSORNUMBERFROMINDEX g_pfnrtKeGetProcessorNumberFromIndex;
133extern PFNKEGETCURRENTPROCESSORNUMBEREX g_pfnrtKeGetCurrentProcessorNumberEx;
134extern PFNKEQUERYACTIVEPROCESSORS g_pfnrtKeQueryActiveProcessors;
135extern PFNKEQUERYMAXIMUMPROCESSORCOUNT g_pfnrtKeQueryMaximumProcessorCount;
136extern PFNKEQUERYMAXIMUMPROCESSORCOUNTEX g_pfnrtKeQueryMaximumProcessorCountEx;
137extern PFNKEQUERYMAXIMUMGROUPCOUNT g_pfnrtKeQueryMaximumGroupCount;
138extern PFNKEQUERYACTIVEPROCESSORCOUNT g_pfnrtKeQueryActiveProcessorCount;
139extern PFNKEQUERYACTIVEPROCESSORCOUNTEX g_pfnrtKeQueryActiveProcessorCountEx;
140extern PFNKEQUERYLOGICALPROCESSORRELATIONSHIP g_pfnrtKeQueryLogicalProcessorRelationship;
141extern PFNKEREGISTERPROCESSORCHANGECALLBACK g_pfnrtKeRegisterProcessorChangeCallback;
142extern PFNKEDEREGISTERPROCESSORCHANGECALLBACK g_pfnrtKeDeregisterProcessorChangeCallback;
143extern decltype(KeSetImportanceDpc) *g_pfnrtKeSetImportanceDpc;
144extern decltype(KeSetTargetProcessorDpc) *g_pfnrtKeSetTargetProcessorDpc;
145extern decltype(KeInitializeTimerEx) *g_pfnrtKeInitializeTimerEx;
146extern PFNKESHOULDYIELDPROCESSOR g_pfnrtKeShouldYieldProcessor;
147extern decltype(MmProtectMdlSystemAddress) *g_pfnrtMmProtectMdlSystemAddress;
148extern decltype(MmAllocatePagesForMdl) *g_pfnrtMmAllocatePagesForMdl;
149extern PFNMMALLOCATEPAGESFORMDLEX g_pfnrtMmAllocatePagesForMdlEx;
150extern decltype(MmFreePagesFromMdl) *g_pfnrtMmFreePagesFromMdl;
151extern decltype(MmMapLockedPagesSpecifyCache) *g_pfnrtMmMapLockedPagesSpecifyCache;
152extern decltype(MmAllocateContiguousMemorySpecifyCache) *g_pfnrtMmAllocateContiguousMemorySpecifyCache;
153extern decltype(MmSecureVirtualMemory) *g_pfnrtMmSecureVirtualMemory;
154extern decltype(MmUnsecureVirtualMemory) *g_pfnrtMmUnsecureVirtualMemory;
155extern decltype(PsIsThreadTerminating) *g_pfnrtPsIsThreadTerminating;
156
157extern PFNRTRTLGETVERSION g_pfnrtRtlGetVersion;
158#ifdef RT_ARCH_X86
159extern PFNRTKEQUERYINTERRUPTTIME g_pfnrtKeQueryInterruptTime;
160#endif
161extern PFNRTKEQUERYINTERRUPTTIMEPRECISE g_pfnrtKeQueryInterruptTimePrecise;
162extern PFNRTKEQUERYSYSTEMTIMEPRECISE g_pfnrtKeQuerySystemTimePrecise;
163
164extern uint32_t g_offrtNtPbQuantumEnd;
165extern uint32_t g_cbrtNtPbQuantumEnd;
166extern 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
171extern uint32_t g_uRtNtVersion;
172extern uint8_t g_uRtNtMajorVer;
173extern uint8_t g_uRtNtMinorVer;
174extern uint32_t g_uRtNtBuildNo;
175
176extern uintptr_t const *g_puRtMmHighestUserAddress;
177extern uintptr_t const *g_puRtMmSystemRangeStart;
178
179
180int __stdcall rtMpPokeCpuUsingFailureNotSupported(RTCPUID idCpu);
181int __stdcall rtMpPokeCpuUsingDpc(RTCPUID idCpu);
182int __stdcall rtMpPokeCpuUsingBroadcastIpi(RTCPUID idCpu);
183int __stdcall rtMpPokeCpuUsingHalRequestIpiW7Plus(RTCPUID idCpu);
184int __stdcall rtMpPokeCpuUsingHalRequestIpiPreW7(RTCPUID idCpu);
185
186struct RTNTSDBOSVER;
187DECLHIDDEN(int) rtR0MpNtInit(struct RTNTSDBOSVER const *pOsVerInfo);
188DECLHIDDEN(void) rtR0MpNtTerm(void);
189DECLHIDDEN(int) rtMpNtSetTargetProcessorDpc(KDPC *pDpc, RTCPUID idCpu);
190#if defined(RT_ARCH_X86) && defined(NIL_RTDBGKRNLINFO)
191DECLHIDDEN(int) rtR0Nt3InitSymbols(RTDBGKRNLINFO hKrnlInfo);
192#endif
193
194RT_C_DECLS_END
195
196#endif /* !IPRT_INCLUDED_SRC_r0drv_nt_internal_r0drv_nt_h */
197
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