[XDK] Move more stuff from ntddk.template.h into appropriate headers
[reactos.git] / include / xdk / ntddk.template.h
1 /*
2 * ntddk.h
3 *
4 * Windows NT Device Driver Kit
5 *
6 * This file is part of the ReactOS DDK package.
7 *
8 * Contributors:
9 * Amine Khaldi
10 * Timo Kreuzer (timo.kreuzer@reactos.org)
11 *
12 * THIS SOFTWARE IS NOT COPYRIGHTED
13 *
14 * This source code is offered for use in the public domain. You may
15 * use, modify or distribute it freely.
16 *
17 * This code is distributed in the hope that it will be useful but
18 * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
19 * DISCLAIMED. This includes but is not limited to warranties of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
21 *
22 */
23
24 #pragma once
25
26 #define _NTDDK_
27
28 #if !defined(_NTHAL_) && !defined(_NTIFS_)
29 #define _NTDDK_INCLUDED_
30 #define _DDK_DRIVER_
31 #endif
32
33 /* Dependencies */
34
35 #define NT_INCLUDED
36 #define _CTYPE_DISABLE_MACROS
37
38 #include <wdm.h>
39 #include <excpt.h>
40 #include <ntdef.h>
41 #include <ntstatus.h>
42 #include <mce.h>
43
44 /* FIXME
45 #include <bugcodes.h>
46 #include <ntiologc.h>
47 */
48
49 #include <stdarg.h> // FIXME
50 #include <basetyps.h> // FIXME
51
52
53 #ifdef __cplusplus
54 extern "C" {
55 #endif
56
57 /* GUID and UUID */
58 #ifndef _NTLSA_IFS_
59 #ifndef _NTLSA_AUDIT_
60 #define _NTLSA_AUDIT_
61
62 #ifndef GUID_DEFINED
63 #include <guiddef.h>
64 #endif
65
66 #endif /* _NTLSA_AUDIT_ */
67 #endif /* _NTLSA_IFS_ */
68
69 typedef GUID UUID;
70
71 struct _LOADER_PARAMETER_BLOCK;
72 struct _CREATE_DISK;
73 struct _DRIVE_LAYOUT_INFORMATION_EX;
74 struct _SET_PARTITION_INFORMATION_EX;
75
76 typedef struct _BUS_HANDLER *PBUS_HANDLER;
77 typedef struct _DEVICE_HANDLER_OBJECT *PDEVICE_HANDLER_OBJECT;
78 #if defined(_NTHAL_INCLUDED_)
79 typedef struct _KAFFINITY_EX *PKAFFINITY_EX;
80 #endif
81 typedef struct _PEB *PPEB;
82
83 #ifndef _NTIMAGE_
84
85 typedef struct _IMAGE_NT_HEADERS *PIMAGE_NT_HEADERS32;
86 typedef struct _IMAGE_NT_HEADERS64 *PIMAGE_NT_HEADERS64;
87
88 #ifdef _WIN64
89 typedef PIMAGE_NT_HEADERS64 PIMAGE_NT_HEADERS;
90 #else
91 typedef PIMAGE_NT_HEADERS32 PIMAGE_NT_HEADERS;
92 #endif
93
94 #endif /* _NTIMAGE_ */
95
96 $define (_NTDDK_)
97 $include (extypes.h)
98 $include (iotypes.h)
99 $include (haltypes.h)
100 $include (ketypes.h)
101 $include (kdtypes.h)
102 $include (mmtypes.h)
103 $include (pstypes.h)
104 $include (rtltypes.h)
105 $include (setypes.h)
106
107 #if defined(_M_IX86)
108 $include(x86/ke.h)
109 $include(x86/mm.h)
110 #elif defined(_M_AMD64)
111 $include(amd64/ke.h)
112 $include(amd64/mm.h)
113 #elif defined(_M_IA64)
114 $include(ia64/ke.h)
115 #elif defined(_M_PPC)
116 $include(ppc/ke.h)
117 #elif defined(_M_MIPS)
118 $include(mips/ke.h)
119 #elif defined(_M_ARM)
120 $include(arm/ke.h)
121 #else
122 #error Unknown Architecture
123 #endif
124
125 $include (exfuncs.h)
126 $include (halfuncs.h)
127 $include (iofuncs.h)
128 $include (kdfuncs.h)
129 $include (kefuncs.h)
130 $include (mmfuncs.h)
131 $include (psfuncs.h)
132 $include (rtlfuncs.h)
133 $include (sefuncs.h)
134 $include (zwfuncs.h)
135
136
137 /* UNSORTED */
138
139 #define VER_SET_CONDITION(ConditionMask, TypeBitMask, ComparisonType) \
140 ((ConditionMask) = VerSetConditionMask((ConditionMask), \
141 (TypeBitMask), (ComparisonType)))
142
143 #if (NTDDI_VERSION >= NTDDI_WIN2K)
144 NTSYSAPI
145 ULONGLONG
146 NTAPI
147 VerSetConditionMask(
148 IN ULONGLONG ConditionMask,
149 IN ULONG TypeMask,
150 IN UCHAR Condition);
151 #endif
152
153 typedef struct _KERNEL_USER_TIMES {
154 LARGE_INTEGER CreateTime;
155 LARGE_INTEGER ExitTime;
156 LARGE_INTEGER KernelTime;
157 LARGE_INTEGER UserTime;
158 } KERNEL_USER_TIMES, *PKERNEL_USER_TIMES;
159
160 /* NtXxx Functions */
161
162 typedef enum _SYSTEM_FIRMWARE_TABLE_ACTION {
163 SystemFirmwareTable_Enumerate,
164 SystemFirmwareTable_Get
165 } SYSTEM_FIRMWARE_TABLE_ACTION;
166
167 typedef struct _SYSTEM_FIRMWARE_TABLE_INFORMATION {
168 ULONG ProviderSignature;
169 SYSTEM_FIRMWARE_TABLE_ACTION Action;
170 ULONG TableID;
171 ULONG TableBufferLength;
172 UCHAR TableBuffer[ANYSIZE_ARRAY];
173 } SYSTEM_FIRMWARE_TABLE_INFORMATION, *PSYSTEM_FIRMWARE_TABLE_INFORMATION;
174
175 typedef NTSTATUS
176 (__cdecl *PFNFTH)(
177 IN OUT PSYSTEM_FIRMWARE_TABLE_INFORMATION SystemFirmwareTableInfo);
178
179 typedef struct _SYSTEM_FIRMWARE_TABLE_HANDLER {
180 ULONG ProviderSignature;
181 BOOLEAN Register;
182 PFNFTH FirmwareTableHandler;
183 PVOID DriverObject;
184 } SYSTEM_FIRMWARE_TABLE_HANDLER, *PSYSTEM_FIRMWARE_TABLE_HANDLER;
185
186 typedef ULONG_PTR
187 (NTAPI *PDRIVER_VERIFIER_THUNK_ROUTINE)(
188 IN PVOID Context);
189
190 typedef struct _DRIVER_VERIFIER_THUNK_PAIRS {
191 PDRIVER_VERIFIER_THUNK_ROUTINE PristineRoutine;
192 PDRIVER_VERIFIER_THUNK_ROUTINE NewRoutine;
193 } DRIVER_VERIFIER_THUNK_PAIRS, *PDRIVER_VERIFIER_THUNK_PAIRS;
194
195 #define DRIVER_VERIFIER_SPECIAL_POOLING 0x0001
196 #define DRIVER_VERIFIER_FORCE_IRQL_CHECKING 0x0002
197 #define DRIVER_VERIFIER_INJECT_ALLOCATION_FAILURES 0x0004
198 #define DRIVER_VERIFIER_TRACK_POOL_ALLOCATIONS 0x0008
199 #define DRIVER_VERIFIER_IO_CHECKING 0x0010
200
201 #define SHARED_GLOBAL_FLAGS_ERROR_PORT_V 0x0
202 #define SHARED_GLOBAL_FLAGS_ERROR_PORT (1UL << SHARED_GLOBAL_FLAGS_ERROR_PORT_V)
203
204 #define SHARED_GLOBAL_FLAGS_ELEVATION_ENABLED_V 0x1
205 #define SHARED_GLOBAL_FLAGS_ELEVATION_ENABLED (1UL << SHARED_GLOBAL_FLAGS_ELEVATION_ENABLED_V)
206
207 #define SHARED_GLOBAL_FLAGS_VIRT_ENABLED_V 0x2
208 #define SHARED_GLOBAL_FLAGS_VIRT_ENABLED (1UL << SHARED_GLOBAL_FLAGS_VIRT_ENABLED_V)
209
210 #define SHARED_GLOBAL_FLAGS_INSTALLER_DETECT_ENABLED_V 0x3
211 #define SHARED_GLOBAL_FLAGS_INSTALLER_DETECT_ENABLED \
212 (1UL << SHARED_GLOBAL_FLAGS_INSTALLER_DETECT_ENABLED_V)
213
214 #define SHARED_GLOBAL_FLAGS_SPARE_V 0x4
215 #define SHARED_GLOBAL_FLAGS_SPARE \
216 (1UL << SHARED_GLOBAL_FLAGS_SPARE_V)
217
218 #define SHARED_GLOBAL_FLAGS_DYNAMIC_PROC_ENABLED_V 0x5
219 #define SHARED_GLOBAL_FLAGS_DYNAMIC_PROC_ENABLED \
220 (1UL << SHARED_GLOBAL_FLAGS_DYNAMIC_PROC_ENABLED_V)
221
222 #define SHARED_GLOBAL_FLAGS_SEH_VALIDATION_ENABLED_V 0x6
223 #define SHARED_GLOBAL_FLAGS_SEH_VALIDATION_ENABLED \
224 (1UL << SHARED_GLOBAL_FLAGS_SEH_VALIDATION_ENABLED_V)
225
226 #define EX_INIT_BITS(Flags, Bit) \
227 *((Flags)) |= (Bit) // Safe to use before concurrently accessible
228
229 #define EX_TEST_SET_BIT(Flags, Bit) \
230 InterlockedBitTestAndSet ((PLONG)(Flags), (Bit))
231
232 #define EX_TEST_CLEAR_BIT(Flags, Bit) \
233 InterlockedBitTestAndReset ((PLONG)(Flags), (Bit))
234
235 #define PCCARD_MAP_ERROR 0x01
236 #define PCCARD_DEVICE_PCI 0x10
237
238 #define PCCARD_SCAN_DISABLED 0x01
239 #define PCCARD_MAP_ZERO 0x02
240 #define PCCARD_NO_TIMER 0x03
241 #define PCCARD_NO_PIC 0x04
242 #define PCCARD_NO_LEGACY_BASE 0x05
243 #define PCCARD_DUP_LEGACY_BASE 0x06
244 #define PCCARD_NO_CONTROLLERS 0x07
245
246 #define MAXIMUM_EXPANSION_SIZE (KERNEL_LARGE_STACK_SIZE - (PAGE_SIZE / 2))
247
248 /* Filesystem runtime library routines */
249
250 #if (NTDDI_VERSION >= NTDDI_WIN2K)
251 NTKERNELAPI
252 BOOLEAN
253 NTAPI
254 FsRtlIsTotalDeviceFailure(
255 IN NTSTATUS Status);
256 #endif
257
258 /* FIXME : These definitions below doesn't belong to NTDDK */
259
260 #ifdef __cplusplus
261 }
262 #endif