xref: /reactos/sdk/include/ddk/nt_vdd.h (revision c2c66aff)
1*c2c66affSColin Finck /*
2*c2c66affSColin Finck  * nt_vdd.h
3*c2c66affSColin Finck  *
4*c2c66affSColin Finck  * Windows NT Device Driver Kit
5*c2c66affSColin Finck  *
6*c2c66affSColin Finck  * This file is part of the ReactOS DDK package.
7*c2c66affSColin Finck  *
8*c2c66affSColin Finck  * Contributors:
9*c2c66affSColin Finck  *   Hermes Belusca-Maito (hermes.belusca@sfr.fr)
10*c2c66affSColin Finck  *
11*c2c66affSColin Finck  * THIS SOFTWARE IS NOT COPYRIGHTED
12*c2c66affSColin Finck  *
13*c2c66affSColin Finck  * This source code is offered for use in the public domain. You may
14*c2c66affSColin Finck  * use, modify or distribute it freely.
15*c2c66affSColin Finck  *
16*c2c66affSColin Finck  * This code is distributed in the hope that it will be useful but
17*c2c66affSColin Finck  * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
18*c2c66affSColin Finck  * DISCLAIMED. This includes but is not limited to warranties of
19*c2c66affSColin Finck  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
20*c2c66affSColin Finck  *
21*c2c66affSColin Finck  */
22*c2c66affSColin Finck 
23*c2c66affSColin Finck #pragma once
24*c2c66affSColin Finck 
25*c2c66affSColin Finck #define _NT_VDD
26*c2c66affSColin Finck 
27*c2c66affSColin Finck #ifdef __cplusplus
28*c2c66affSColin Finck extern "C" {
29*c2c66affSColin Finck #endif
30*c2c66affSColin Finck 
31*c2c66affSColin Finck /* VDM Control */
32*c2c66affSColin Finck 
33*c2c66affSColin Finck VOID
34*c2c66affSColin Finck WINAPI
35*c2c66affSColin Finck VDDSimulate16(VOID);
36*c2c66affSColin Finck 
37*c2c66affSColin Finck VOID
38*c2c66affSColin Finck WINAPI
39*c2c66affSColin Finck VDDTerminateVDM(VOID);
40*c2c66affSColin Finck 
41*c2c66affSColin Finck 
42*c2c66affSColin Finck /* VDD User Hooks */
43*c2c66affSColin Finck 
44*c2c66affSColin Finck typedef VOID
45*c2c66affSColin Finck (WINAPI *PFNVDD_UCREATE)(USHORT DosPDB);
46*c2c66affSColin Finck 
47*c2c66affSColin Finck typedef VOID
48*c2c66affSColin Finck (WINAPI *PFNVDD_UTERMINATE)(USHORT DosPDB);
49*c2c66affSColin Finck 
50*c2c66affSColin Finck typedef VOID
51*c2c66affSColin Finck (WINAPI *PFNVDD_UBLOCK)(VOID);
52*c2c66affSColin Finck 
53*c2c66affSColin Finck typedef VOID
54*c2c66affSColin Finck (WINAPI *PFNVDD_URESUME)(VOID);
55*c2c66affSColin Finck 
56*c2c66affSColin Finck // NOTE: Kept there for WinDDK compatibility, but it is in any case unused.
57*c2c66affSColin Finck #ifndef NO_NTVDD_COMPAT
58*c2c66affSColin Finck typedef struct _VDD_USER_HANDLERS {
59*c2c66affSColin Finck   HANDLE hvdd;
60*c2c66affSColin Finck   PFNVDD_UCREATE ucr_handler;
61*c2c66affSColin Finck   PFNVDD_UTERMINATE uterm_handler;
62*c2c66affSColin Finck   PFNVDD_UBLOCK ublock_handler;
63*c2c66affSColin Finck   PFNVDD_URESUME uresume_handler;
64*c2c66affSColin Finck   struct _VDD_USER_HANDLERS* next;
65*c2c66affSColin Finck } VDD_USER_HANDLERS, *PVDD_USER_HANDLERS;
66*c2c66affSColin Finck #endif
67*c2c66affSColin Finck 
68*c2c66affSColin Finck BOOL
69*c2c66affSColin Finck WINAPI
70*c2c66affSColin Finck VDDInstallUserHook(
71*c2c66affSColin Finck   _In_ HANDLE hVdd,
72*c2c66affSColin Finck   _In_ PFNVDD_UCREATE Ucr_Handler,
73*c2c66affSColin Finck   _In_ PFNVDD_UTERMINATE Uterm_Handler,
74*c2c66affSColin Finck   _In_ PFNVDD_UBLOCK Ublock_Handler,
75*c2c66affSColin Finck   _In_ PFNVDD_URESUME Uresume_Handler);
76*c2c66affSColin Finck 
77*c2c66affSColin Finck BOOL
78*c2c66affSColin Finck WINAPI
79*c2c66affSColin Finck VDDDeInstallUserHook(
80*c2c66affSColin Finck   _In_ HANDLE hVdd);
81*c2c66affSColin Finck 
82*c2c66affSColin Finck 
83*c2c66affSColin Finck /* IRQ services */
84*c2c66affSColin Finck 
85*c2c66affSColin Finck WORD
86*c2c66affSColin Finck WINAPI
87*c2c66affSColin Finck VDDReserveIrqLine(
88*c2c66affSColin Finck   _In_ HANDLE hVdd,
89*c2c66affSColin Finck   _In_ WORD IrqLine);
90*c2c66affSColin Finck 
91*c2c66affSColin Finck BOOL
92*c2c66affSColin Finck WINAPI
93*c2c66affSColin Finck VDDReleaseIrqLine(
94*c2c66affSColin Finck   _In_ HANDLE hVdd,
95*c2c66affSColin Finck   _In_ WORD IrqLine);
96*c2c66affSColin Finck 
97*c2c66affSColin Finck 
98*c2c66affSColin Finck /* I/O Port services */
99*c2c66affSColin Finck 
100*c2c66affSColin Finck typedef VOID
101*c2c66affSColin Finck (WINAPI *PFNVDD_INB)(
102*c2c66affSColin Finck   WORD iport,
103*c2c66affSColin Finck   PBYTE data);
104*c2c66affSColin Finck 
105*c2c66affSColin Finck typedef VOID
106*c2c66affSColin Finck (WINAPI *PFNVDD_INW)(
107*c2c66affSColin Finck   WORD iport,
108*c2c66affSColin Finck   PWORD data);
109*c2c66affSColin Finck 
110*c2c66affSColin Finck typedef VOID
111*c2c66affSColin Finck (WINAPI *PFNVDD_INSB)(
112*c2c66affSColin Finck   WORD iport,
113*c2c66affSColin Finck   PBYTE data,
114*c2c66affSColin Finck   WORD count);
115*c2c66affSColin Finck 
116*c2c66affSColin Finck typedef VOID
117*c2c66affSColin Finck (WINAPI *PFNVDD_INSW)(
118*c2c66affSColin Finck   WORD iport,
119*c2c66affSColin Finck   PWORD data,
120*c2c66affSColin Finck   WORD count);
121*c2c66affSColin Finck 
122*c2c66affSColin Finck typedef VOID
123*c2c66affSColin Finck (WINAPI *PFNVDD_OUTB)(
124*c2c66affSColin Finck   WORD iport,
125*c2c66affSColin Finck   BYTE data);
126*c2c66affSColin Finck 
127*c2c66affSColin Finck typedef VOID
128*c2c66affSColin Finck (WINAPI *PFNVDD_OUTW)(
129*c2c66affSColin Finck   WORD iport,
130*c2c66affSColin Finck   WORD data);
131*c2c66affSColin Finck 
132*c2c66affSColin Finck typedef VOID
133*c2c66affSColin Finck (WINAPI *PFNVDD_OUTSB)(
134*c2c66affSColin Finck   WORD iport,
135*c2c66affSColin Finck   PBYTE data,
136*c2c66affSColin Finck   WORD count);
137*c2c66affSColin Finck 
138*c2c66affSColin Finck typedef VOID
139*c2c66affSColin Finck (WINAPI *PFNVDD_OUTSW)(
140*c2c66affSColin Finck   WORD iport,
141*c2c66affSColin Finck   PWORD data,
142*c2c66affSColin Finck   WORD count);
143*c2c66affSColin Finck 
144*c2c66affSColin Finck typedef struct _VDD_IO_HANDLERS {
145*c2c66affSColin Finck   PFNVDD_INB inb_handler;
146*c2c66affSColin Finck   PFNVDD_INW inw_handler;
147*c2c66affSColin Finck   PFNVDD_INSB insb_handler;
148*c2c66affSColin Finck   PFNVDD_INSW insw_handler;
149*c2c66affSColin Finck   PFNVDD_OUTB outb_handler;
150*c2c66affSColin Finck   PFNVDD_OUTW outw_handler;
151*c2c66affSColin Finck   PFNVDD_OUTSB outsb_handler;
152*c2c66affSColin Finck   PFNVDD_OUTSW outsw_handler;
153*c2c66affSColin Finck } VDD_IO_HANDLERS, *PVDD_IO_HANDLERS;
154*c2c66affSColin Finck 
155*c2c66affSColin Finck typedef struct _VDD_IO_PORTRANGE {
156*c2c66affSColin Finck   WORD First;
157*c2c66affSColin Finck   WORD Last;
158*c2c66affSColin Finck } VDD_IO_PORTRANGE, *PVDD_IO_PORTRANGE;
159*c2c66affSColin Finck 
160*c2c66affSColin Finck BOOL
161*c2c66affSColin Finck WINAPI
162*c2c66affSColin Finck VDDInstallIOHook(
163*c2c66affSColin Finck   _In_ HANDLE hVdd,
164*c2c66affSColin Finck   _In_ WORD cPortRange,
165*c2c66affSColin Finck   _In_ PVDD_IO_PORTRANGE pPortRange,
166*c2c66affSColin Finck   _In_ PVDD_IO_HANDLERS IoHandlers);
167*c2c66affSColin Finck 
168*c2c66affSColin Finck VOID
169*c2c66affSColin Finck WINAPI
170*c2c66affSColin Finck VDDDeInstallIOHook(
171*c2c66affSColin Finck   _In_ HANDLE hVdd,
172*c2c66affSColin Finck   _In_ WORD cPortRange,
173*c2c66affSColin Finck   _In_ PVDD_IO_PORTRANGE pPortRange);
174*c2c66affSColin Finck 
175*c2c66affSColin Finck 
176*c2c66affSColin Finck /* DMA services */
177*c2c66affSColin Finck 
178*c2c66affSColin Finck typedef struct _VDD_DMA_INFO {
179*c2c66affSColin Finck   WORD addr;
180*c2c66affSColin Finck   WORD count;
181*c2c66affSColin Finck   WORD page;
182*c2c66affSColin Finck   BYTE status;
183*c2c66affSColin Finck   BYTE mode;
184*c2c66affSColin Finck   BYTE mask;
185*c2c66affSColin Finck } VDD_DMA_INFO, *PVDD_DMA_INFO;
186*c2c66affSColin Finck 
187*c2c66affSColin Finck #define VDD_DMA_ADDR   0x01
188*c2c66affSColin Finck #define VDD_DMA_COUNT  0x02
189*c2c66affSColin Finck #define VDD_DMA_PAGE   0x04
190*c2c66affSColin Finck #define VDD_DMA_STATUS 0x08
191*c2c66affSColin Finck #define VDD_DMA_ALL    (VDD_DMA_ADDR | VDD_DMA_COUNT | VDD_DMA_PAGE | VDD_DMA_STATUS)
192*c2c66affSColin Finck 
193*c2c66affSColin Finck DWORD
194*c2c66affSColin Finck WINAPI
195*c2c66affSColin Finck VDDRequestDMA(
196*c2c66affSColin Finck   _In_ HANDLE hVdd,
197*c2c66affSColin Finck   _In_ WORD iChannel,
198*c2c66affSColin Finck   _Inout_ PVOID Buffer,
199*c2c66affSColin Finck   _In_ DWORD length);
200*c2c66affSColin Finck 
201*c2c66affSColin Finck BOOL
202*c2c66affSColin Finck WINAPI
203*c2c66affSColin Finck VDDQueryDMA(
204*c2c66affSColin Finck   _In_ HANDLE hVdd,
205*c2c66affSColin Finck   _In_ WORD iChannel,
206*c2c66affSColin Finck   _In_ PVDD_DMA_INFO pDmaInfo);
207*c2c66affSColin Finck 
208*c2c66affSColin Finck BOOL
209*c2c66affSColin Finck WINAPI
210*c2c66affSColin Finck VDDSetDMA(
211*c2c66affSColin Finck   _In_ HANDLE hVdd,
212*c2c66affSColin Finck   _In_ WORD iChannel,
213*c2c66affSColin Finck   _In_ WORD fDMA,
214*c2c66affSColin Finck   _In_ PVDD_DMA_INFO pDmaInfo);
215*c2c66affSColin Finck 
216*c2c66affSColin Finck 
217*c2c66affSColin Finck /* Memory services */
218*c2c66affSColin Finck 
219*c2c66affSColin Finck typedef enum {
220*c2c66affSColin Finck   VDM_V86,
221*c2c66affSColin Finck   VDM_PM
222*c2c66affSColin Finck } VDM_MODE;
223*c2c66affSColin Finck 
224*c2c66affSColin Finck #ifndef MSW_PE
225*c2c66affSColin Finck #define MSW_PE 0x0001
226*c2c66affSColin Finck #endif
227*c2c66affSColin Finck 
228*c2c66affSColin Finck #define getMODE() ((getMSW() & MSW_PE) ? VDM_PM : VDM_V86)
229*c2c66affSColin Finck 
230*c2c66affSColin Finck typedef VOID
231*c2c66affSColin Finck (WINAPI *PVDD_MEMORY_HANDLER)(
232*c2c66affSColin Finck   PVOID FaultAddress,
233*c2c66affSColin Finck   ULONG RWMode);
234*c2c66affSColin Finck 
235*c2c66affSColin Finck PVOID
236*c2c66affSColin Finck WINAPI
237*c2c66affSColin Finck VdmMapFlat(
238*c2c66affSColin Finck   _In_ USHORT Segment,
239*c2c66affSColin Finck   _In_ ULONG Offset,
240*c2c66affSColin Finck   _In_ VDM_MODE Mode);
241*c2c66affSColin Finck 
242*c2c66affSColin Finck #ifdef _X86_
243*c2c66affSColin Finck 
244*c2c66affSColin Finck #define VdmFlushCache(sel, off, len, mode) TRUE
245*c2c66affSColin Finck #define VdmUnmapFlat(sel, off, buf, mode) TRUE
246*c2c66affSColin Finck 
247*c2c66affSColin Finck #else
248*c2c66affSColin Finck 
249*c2c66affSColin Finck BOOL
250*c2c66affSColin Finck WINAPI
251*c2c66affSColin Finck VdmFlushCache(
252*c2c66affSColin Finck   _In_ USHORT Segment,
253*c2c66affSColin Finck   _In_ ULONG Offset,
254*c2c66affSColin Finck   _In_ ULONG Size,
255*c2c66affSColin Finck   _In_ VDM_MODE Mode);
256*c2c66affSColin Finck 
257*c2c66affSColin Finck BOOL
258*c2c66affSColin Finck WINAPI
259*c2c66affSColin Finck VdmUnmapFlat(
260*c2c66affSColin Finck   _In_ USHORT Segment,
261*c2c66affSColin Finck   _In_ ULONG Offset,
262*c2c66affSColin Finck   _In_ PVOID Buffer,
263*c2c66affSColin Finck   _In_ VDM_MODE Mode);
264*c2c66affSColin Finck 
265*c2c66affSColin Finck #endif
266*c2c66affSColin Finck 
267*c2c66affSColin Finck BOOL
268*c2c66affSColin Finck WINAPI
269*c2c66affSColin Finck VDDInstallMemoryHook(
270*c2c66affSColin Finck   _In_ HANDLE hVdd,
271*c2c66affSColin Finck   _In_ PVOID pStart,
272*c2c66affSColin Finck   _In_ DWORD dwCount,
273*c2c66affSColin Finck   _In_ PVDD_MEMORY_HANDLER MemoryHandler);
274*c2c66affSColin Finck 
275*c2c66affSColin Finck BOOL
276*c2c66affSColin Finck WINAPI
277*c2c66affSColin Finck VDDDeInstallMemoryHook(
278*c2c66affSColin Finck   _In_ HANDLE hVdd,
279*c2c66affSColin Finck   _In_ PVOID pStart,
280*c2c66affSColin Finck   _In_ DWORD dwCount);
281*c2c66affSColin Finck 
282*c2c66affSColin Finck BOOL
283*c2c66affSColin Finck WINAPI
284*c2c66affSColin Finck VDDAllocMem(
285*c2c66affSColin Finck   _In_ HANDLE hVdd,
286*c2c66affSColin Finck   _In_ PVOID Address,
287*c2c66affSColin Finck   _In_ ULONG Size);
288*c2c66affSColin Finck 
289*c2c66affSColin Finck BOOL
290*c2c66affSColin Finck WINAPI
291*c2c66affSColin Finck VDDFreeMem(
292*c2c66affSColin Finck   _In_ HANDLE hVdd,
293*c2c66affSColin Finck   _In_ PVOID Address,
294*c2c66affSColin Finck   _In_ ULONG Size);
295*c2c66affSColin Finck 
296*c2c66affSColin Finck BOOL
297*c2c66affSColin Finck WINAPI
298*c2c66affSColin Finck VDDIncludeMem(
299*c2c66affSColin Finck   _In_ HANDLE hVdd,
300*c2c66affSColin Finck   _In_ PVOID Address,
301*c2c66affSColin Finck   _In_ ULONG Size);
302*c2c66affSColin Finck 
303*c2c66affSColin Finck BOOL
304*c2c66affSColin Finck WINAPI
305*c2c66affSColin Finck VDDExcludeMem(
306*c2c66affSColin Finck   _In_ HANDLE hVdd,
307*c2c66affSColin Finck   _In_ PVOID Address,
308*c2c66affSColin Finck   _In_ ULONG Size);
309*c2c66affSColin Finck 
310*c2c66affSColin Finck #ifdef __cplusplus
311*c2c66affSColin Finck }
312*c2c66affSColin Finck #endif
313*c2c66affSColin Finck 
314*c2c66affSColin Finck /* EOF */
315