[PSDK]
[reactos.git] / include / xdk / iotypes.h
1 /******************************************************************************
2 * I/O Manager Types *
3 ******************************************************************************/
4
5 #define WDM_MAJORVERSION 0x06
6 #define WDM_MINORVERSION 0x00
7
8 #if defined(_WIN64)
9
10 #ifndef USE_DMA_MACROS
11 #define USE_DMA_MACROS
12 #endif
13
14 #ifndef NO_LEGACY_DRIVERS
15 #define NO_LEGACY_DRIVERS
16 #endif
17
18 #endif /* defined(_WIN64) */
19
20 #define STATUS_CONTINUE_COMPLETION STATUS_SUCCESS
21
22 #define CONNECT_FULLY_SPECIFIED 0x1
23 #define CONNECT_LINE_BASED 0x2
24 #define CONNECT_MESSAGE_BASED 0x3
25 #define CONNECT_FULLY_SPECIFIED_GROUP 0x4
26 #define CONNECT_CURRENT_VERSION 0x4
27
28 #define POOL_COLD_ALLOCATION 256
29 #define POOL_QUOTA_FAIL_INSTEAD_OF_RAISE 8
30 #define POOL_RAISE_IF_ALLOCATION_FAILURE 16
31
32 #define IO_TYPE_ADAPTER 1
33 #define IO_TYPE_CONTROLLER 2
34 #define IO_TYPE_DEVICE 3
35 #define IO_TYPE_DRIVER 4
36 #define IO_TYPE_FILE 5
37 #define IO_TYPE_IRP 6
38 #define IO_TYPE_MASTER_ADAPTER 7
39 #define IO_TYPE_OPEN_PACKET 8
40 #define IO_TYPE_TIMER 9
41 #define IO_TYPE_VPB 10
42 #define IO_TYPE_ERROR_LOG 11
43 #define IO_TYPE_ERROR_MESSAGE 12
44 #define IO_TYPE_DEVICE_OBJECT_EXTENSION 13
45
46 #define IO_TYPE_CSQ_IRP_CONTEXT 1
47 #define IO_TYPE_CSQ 2
48 #define IO_TYPE_CSQ_EX 3
49
50 /* IO_RESOURCE_DESCRIPTOR.Option */
51 #define IO_RESOURCE_PREFERRED 0x01
52 #define IO_RESOURCE_DEFAULT 0x02
53 #define IO_RESOURCE_ALTERNATIVE 0x08
54
55 /* DEVICE_OBJECT.Flags */
56 #define DO_VERIFY_VOLUME 0x00000002
57 #define DO_BUFFERED_IO 0x00000004
58 #define DO_EXCLUSIVE 0x00000008
59 #define DO_DIRECT_IO 0x00000010
60 #define DO_MAP_IO_BUFFER 0x00000020
61 #define DO_DEVICE_INITIALIZING 0x00000080
62 #define DO_SHUTDOWN_REGISTERED 0x00000800
63 #define DO_BUS_ENUMERATED_DEVICE 0x00001000
64 #define DO_POWER_PAGABLE 0x00002000
65 #define DO_POWER_INRUSH 0x00004000
66
67 /* DEVICE_OBJECT.Characteristics */
68 #define FILE_REMOVABLE_MEDIA 0x00000001
69 #define FILE_READ_ONLY_DEVICE 0x00000002
70 #define FILE_FLOPPY_DISKETTE 0x00000004
71 #define FILE_WRITE_ONCE_MEDIA 0x00000008
72 #define FILE_REMOTE_DEVICE 0x00000010
73 #define FILE_DEVICE_IS_MOUNTED 0x00000020
74 #define FILE_VIRTUAL_VOLUME 0x00000040
75 #define FILE_AUTOGENERATED_DEVICE_NAME 0x00000080
76 #define FILE_DEVICE_SECURE_OPEN 0x00000100
77 #define FILE_CHARACTERISTIC_PNP_DEVICE 0x00000800
78 #define FILE_CHARACTERISTIC_TS_DEVICE 0x00001000
79 #define FILE_CHARACTERISTIC_WEBDAV_DEVICE 0x00002000
80
81 /* DEVICE_OBJECT.AlignmentRequirement */
82 #define FILE_BYTE_ALIGNMENT 0x00000000
83 #define FILE_WORD_ALIGNMENT 0x00000001
84 #define FILE_LONG_ALIGNMENT 0x00000003
85 #define FILE_QUAD_ALIGNMENT 0x00000007
86 #define FILE_OCTA_ALIGNMENT 0x0000000f
87 #define FILE_32_BYTE_ALIGNMENT 0x0000001f
88 #define FILE_64_BYTE_ALIGNMENT 0x0000003f
89 #define FILE_128_BYTE_ALIGNMENT 0x0000007f
90 #define FILE_256_BYTE_ALIGNMENT 0x000000ff
91 #define FILE_512_BYTE_ALIGNMENT 0x000001ff
92
93 /* DEVICE_OBJECT.DeviceType */
94 #define DEVICE_TYPE ULONG
95
96 #define FILE_DEVICE_BEEP 0x00000001
97 #define FILE_DEVICE_CD_ROM 0x00000002
98 #define FILE_DEVICE_CD_ROM_FILE_SYSTEM 0x00000003
99 #define FILE_DEVICE_CONTROLLER 0x00000004
100 #define FILE_DEVICE_DATALINK 0x00000005
101 #define FILE_DEVICE_DFS 0x00000006
102 #define FILE_DEVICE_DISK 0x00000007
103 #define FILE_DEVICE_DISK_FILE_SYSTEM 0x00000008
104 #define FILE_DEVICE_FILE_SYSTEM 0x00000009
105 #define FILE_DEVICE_INPORT_PORT 0x0000000a
106 #define FILE_DEVICE_KEYBOARD 0x0000000b
107 #define FILE_DEVICE_MAILSLOT 0x0000000c
108 #define FILE_DEVICE_MIDI_IN 0x0000000d
109 #define FILE_DEVICE_MIDI_OUT 0x0000000e
110 #define FILE_DEVICE_MOUSE 0x0000000f
111 #define FILE_DEVICE_MULTI_UNC_PROVIDER 0x00000010
112 #define FILE_DEVICE_NAMED_PIPE 0x00000011
113 #define FILE_DEVICE_NETWORK 0x00000012
114 #define FILE_DEVICE_NETWORK_BROWSER 0x00000013
115 #define FILE_DEVICE_NETWORK_FILE_SYSTEM 0x00000014
116 #define FILE_DEVICE_NULL 0x00000015
117 #define FILE_DEVICE_PARALLEL_PORT 0x00000016
118 #define FILE_DEVICE_PHYSICAL_NETCARD 0x00000017
119 #define FILE_DEVICE_PRINTER 0x00000018
120 #define FILE_DEVICE_SCANNER 0x00000019
121 #define FILE_DEVICE_SERIAL_MOUSE_PORT 0x0000001a
122 #define FILE_DEVICE_SERIAL_PORT 0x0000001b
123 #define FILE_DEVICE_SCREEN 0x0000001c
124 #define FILE_DEVICE_SOUND 0x0000001d
125 #define FILE_DEVICE_STREAMS 0x0000001e
126 #define FILE_DEVICE_TAPE 0x0000001f
127 #define FILE_DEVICE_TAPE_FILE_SYSTEM 0x00000020
128 #define FILE_DEVICE_TRANSPORT 0x00000021
129 #define FILE_DEVICE_UNKNOWN 0x00000022
130 #define FILE_DEVICE_VIDEO 0x00000023
131 #define FILE_DEVICE_VIRTUAL_DISK 0x00000024
132 #define FILE_DEVICE_WAVE_IN 0x00000025
133 #define FILE_DEVICE_WAVE_OUT 0x00000026
134 #define FILE_DEVICE_8042_PORT 0x00000027
135 #define FILE_DEVICE_NETWORK_REDIRECTOR 0x00000028
136 #define FILE_DEVICE_BATTERY 0x00000029
137 #define FILE_DEVICE_BUS_EXTENDER 0x0000002a
138 #define FILE_DEVICE_MODEM 0x0000002b
139 #define FILE_DEVICE_VDM 0x0000002c
140 #define FILE_DEVICE_MASS_STORAGE 0x0000002d
141 #define FILE_DEVICE_SMB 0x0000002e
142 #define FILE_DEVICE_KS 0x0000002f
143 #define FILE_DEVICE_CHANGER 0x00000030
144 #define FILE_DEVICE_SMARTCARD 0x00000031
145 #define FILE_DEVICE_ACPI 0x00000032
146 #define FILE_DEVICE_DVD 0x00000033
147 #define FILE_DEVICE_FULLSCREEN_VIDEO 0x00000034
148 #define FILE_DEVICE_DFS_FILE_SYSTEM 0x00000035
149 #define FILE_DEVICE_DFS_VOLUME 0x00000036
150 #define FILE_DEVICE_SERENUM 0x00000037
151 #define FILE_DEVICE_TERMSRV 0x00000038
152 #define FILE_DEVICE_KSEC 0x00000039
153 #define FILE_DEVICE_FIPS 0x0000003A
154 #define FILE_DEVICE_INFINIBAND 0x0000003B
155 #define FILE_DEVICE_VMBUS 0x0000003E
156 #define FILE_DEVICE_CRYPT_PROVIDER 0x0000003F
157 #define FILE_DEVICE_WPD 0x00000040
158 #define FILE_DEVICE_BLUETOOTH 0x00000041
159 #define FILE_DEVICE_MT_COMPOSITE 0x00000042
160 #define FILE_DEVICE_MT_TRANSPORT 0x00000043
161 #define FILE_DEVICE_BIOMETRIC 0x00000044
162 #define FILE_DEVICE_PMI 0x00000045
163
164 #if defined(NT_PROCESSOR_GROUPS)
165
166 typedef USHORT IRQ_DEVICE_POLICY, *PIRQ_DEVICE_POLICY;
167
168 typedef enum _IRQ_DEVICE_POLICY_USHORT {
169 IrqPolicyMachineDefault = 0,
170 IrqPolicyAllCloseProcessors = 1,
171 IrqPolicyOneCloseProcessor = 2,
172 IrqPolicyAllProcessorsInMachine = 3,
173 IrqPolicyAllProcessorsInGroup = 3,
174 IrqPolicySpecifiedProcessors = 4,
175 IrqPolicySpreadMessagesAcrossAllProcessors = 5};
176
177 #else /* defined(NT_PROCESSOR_GROUPS) */
178
179 typedef enum _IRQ_DEVICE_POLICY {
180 IrqPolicyMachineDefault = 0,
181 IrqPolicyAllCloseProcessors,
182 IrqPolicyOneCloseProcessor,
183 IrqPolicyAllProcessorsInMachine,
184 IrqPolicySpecifiedProcessors,
185 IrqPolicySpreadMessagesAcrossAllProcessors
186 } IRQ_DEVICE_POLICY, *PIRQ_DEVICE_POLICY;
187
188 #endif
189
190 typedef enum _IRQ_PRIORITY {
191 IrqPriorityUndefined = 0,
192 IrqPriorityLow,
193 IrqPriorityNormal,
194 IrqPriorityHigh
195 } IRQ_PRIORITY, *PIRQ_PRIORITY;
196
197 typedef enum _IRQ_GROUP_POLICY {
198 GroupAffinityAllGroupZero = 0,
199 GroupAffinityDontCare
200 } IRQ_GROUP_POLICY, *PIRQ_GROUP_POLICY;
201
202 #define MAXIMUM_VOLUME_LABEL_LENGTH (32 * sizeof(WCHAR))
203
204 typedef struct _OBJECT_HANDLE_INFORMATION {
205 ULONG HandleAttributes;
206 ACCESS_MASK GrantedAccess;
207 } OBJECT_HANDLE_INFORMATION, *POBJECT_HANDLE_INFORMATION;
208
209 typedef struct _CLIENT_ID {
210 HANDLE UniqueProcess;
211 HANDLE UniqueThread;
212 } CLIENT_ID, *PCLIENT_ID;
213
214 typedef struct _VPB {
215 CSHORT Type;
216 CSHORT Size;
217 USHORT Flags;
218 USHORT VolumeLabelLength;
219 struct _DEVICE_OBJECT *DeviceObject;
220 struct _DEVICE_OBJECT *RealDevice;
221 ULONG SerialNumber;
222 ULONG ReferenceCount;
223 WCHAR VolumeLabel[MAXIMUM_VOLUME_LABEL_LENGTH / sizeof(WCHAR)];
224 } VPB, *PVPB;
225
226 typedef enum _IO_ALLOCATION_ACTION {
227 KeepObject = 1,
228 DeallocateObject,
229 DeallocateObjectKeepRegisters
230 } IO_ALLOCATION_ACTION, *PIO_ALLOCATION_ACTION;
231
232 typedef IO_ALLOCATION_ACTION
233 (NTAPI DRIVER_CONTROL)(
234 IN struct _DEVICE_OBJECT *DeviceObject,
235 IN struct _IRP *Irp,
236 IN PVOID MapRegisterBase,
237 IN PVOID Context);
238 typedef DRIVER_CONTROL *PDRIVER_CONTROL;
239
240 typedef struct _WAIT_CONTEXT_BLOCK {
241 KDEVICE_QUEUE_ENTRY WaitQueueEntry;
242 PDRIVER_CONTROL DeviceRoutine;
243 PVOID DeviceContext;
244 ULONG NumberOfMapRegisters;
245 PVOID DeviceObject;
246 PVOID CurrentIrp;
247 PKDPC BufferChainingDpc;
248 } WAIT_CONTEXT_BLOCK, *PWAIT_CONTEXT_BLOCK;
249
250 typedef struct _DEVICE_OBJECT {
251 CSHORT Type;
252 USHORT Size;
253 LONG ReferenceCount;
254 struct _DRIVER_OBJECT *DriverObject;
255 struct _DEVICE_OBJECT *NextDevice;
256 struct _DEVICE_OBJECT *AttachedDevice;
257 struct _IRP *CurrentIrp;
258 PIO_TIMER Timer;
259 ULONG Flags;
260 ULONG Characteristics;
261 volatile PVPB Vpb;
262 PVOID DeviceExtension;
263 DEVICE_TYPE DeviceType;
264 CCHAR StackSize;
265 union {
266 LIST_ENTRY ListEntry;
267 WAIT_CONTEXT_BLOCK Wcb;
268 } Queue;
269 ULONG AlignmentRequirement;
270 KDEVICE_QUEUE DeviceQueue;
271 KDPC Dpc;
272 ULONG ActiveThreadCount;
273 PSECURITY_DESCRIPTOR SecurityDescriptor;
274 KEVENT DeviceLock;
275 USHORT SectorSize;
276 USHORT Spare1;
277 struct _DEVOBJ_EXTENSION *DeviceObjectExtension;
278 PVOID Reserved;
279 } DEVICE_OBJECT, *PDEVICE_OBJECT;
280
281 typedef enum _IO_SESSION_STATE {
282 IoSessionStateCreated = 1,
283 IoSessionStateInitialized,
284 IoSessionStateConnected,
285 IoSessionStateDisconnected,
286 IoSessionStateDisconnectedLoggedOn,
287 IoSessionStateLoggedOn,
288 IoSessionStateLoggedOff,
289 IoSessionStateTerminated,
290 IoSessionStateMax
291 } IO_SESSION_STATE, *PIO_SESSION_STATE;
292
293 typedef enum _IO_COMPLETION_ROUTINE_RESULT {
294 ContinueCompletion = STATUS_CONTINUE_COMPLETION,
295 StopCompletion = STATUS_MORE_PROCESSING_REQUIRED
296 } IO_COMPLETION_ROUTINE_RESULT, *PIO_COMPLETION_ROUTINE_RESULT;
297
298 typedef struct _IO_INTERRUPT_MESSAGE_INFO_ENTRY {
299 PHYSICAL_ADDRESS MessageAddress;
300 KAFFINITY TargetProcessorSet;
301 PKINTERRUPT InterruptObject;
302 ULONG MessageData;
303 ULONG Vector;
304 KIRQL Irql;
305 KINTERRUPT_MODE Mode;
306 KINTERRUPT_POLARITY Polarity;
307 } IO_INTERRUPT_MESSAGE_INFO_ENTRY, *PIO_INTERRUPT_MESSAGE_INFO_ENTRY;
308
309 typedef struct _IO_INTERRUPT_MESSAGE_INFO {
310 KIRQL UnifiedIrql;
311 ULONG MessageCount;
312 IO_INTERRUPT_MESSAGE_INFO_ENTRY MessageInfo[1];
313 } IO_INTERRUPT_MESSAGE_INFO, *PIO_INTERRUPT_MESSAGE_INFO;
314
315 typedef struct _IO_CONNECT_INTERRUPT_FULLY_SPECIFIED_PARAMETERS {
316 IN PDEVICE_OBJECT PhysicalDeviceObject;
317 OUT PKINTERRUPT *InterruptObject;
318 IN PKSERVICE_ROUTINE ServiceRoutine;
319 IN PVOID ServiceContext;
320 IN PKSPIN_LOCK SpinLock OPTIONAL;
321 IN KIRQL SynchronizeIrql;
322 IN BOOLEAN FloatingSave;
323 IN BOOLEAN ShareVector;
324 IN ULONG Vector;
325 IN KIRQL Irql;
326 IN KINTERRUPT_MODE InterruptMode;
327 IN KAFFINITY ProcessorEnableMask;
328 IN USHORT Group;
329 } IO_CONNECT_INTERRUPT_FULLY_SPECIFIED_PARAMETERS, *PIO_CONNECT_INTERRUPT_FULLY_SPECIFIED_PARAMETERS;
330
331 typedef struct _IO_CONNECT_INTERRUPT_LINE_BASED_PARAMETERS {
332 IN PDEVICE_OBJECT PhysicalDeviceObject;
333 OUT PKINTERRUPT *InterruptObject;
334 IN PKSERVICE_ROUTINE ServiceRoutine;
335 IN PVOID ServiceContext;
336 IN PKSPIN_LOCK SpinLock OPTIONAL;
337 IN KIRQL SynchronizeIrql OPTIONAL;
338 IN BOOLEAN FloatingSave;
339 } IO_CONNECT_INTERRUPT_LINE_BASED_PARAMETERS, *PIO_CONNECT_INTERRUPT_LINE_BASED_PARAMETERS;
340
341 typedef struct _IO_CONNECT_INTERRUPT_MESSAGE_BASED_PARAMETERS {
342 IN PDEVICE_OBJECT PhysicalDeviceObject;
343 union {
344 OUT PVOID *Generic;
345 OUT PIO_INTERRUPT_MESSAGE_INFO *InterruptMessageTable;
346 OUT PKINTERRUPT *InterruptObject;
347 } ConnectionContext;
348 IN PKMESSAGE_SERVICE_ROUTINE MessageServiceRoutine;
349 IN PVOID ServiceContext;
350 IN PKSPIN_LOCK SpinLock OPTIONAL;
351 IN KIRQL SynchronizeIrql OPTIONAL;
352 IN BOOLEAN FloatingSave;
353 IN PKSERVICE_ROUTINE FallBackServiceRoutine OPTIONAL;
354 } IO_CONNECT_INTERRUPT_MESSAGE_BASED_PARAMETERS, *PIO_CONNECT_INTERRUPT_MESSAGE_BASED_PARAMETERS;
355
356 typedef struct _IO_CONNECT_INTERRUPT_PARAMETERS {
357 IN OUT ULONG Version;
358 union {
359 IO_CONNECT_INTERRUPT_FULLY_SPECIFIED_PARAMETERS FullySpecified;
360 IO_CONNECT_INTERRUPT_LINE_BASED_PARAMETERS LineBased;
361 IO_CONNECT_INTERRUPT_MESSAGE_BASED_PARAMETERS MessageBased;
362 };
363 } IO_CONNECT_INTERRUPT_PARAMETERS, *PIO_CONNECT_INTERRUPT_PARAMETERS;
364
365 typedef struct _IO_DISCONNECT_INTERRUPT_PARAMETERS {
366 IN ULONG Version;
367 union {
368 IN PVOID Generic;
369 IN PKINTERRUPT InterruptObject;
370 IN PIO_INTERRUPT_MESSAGE_INFO InterruptMessageTable;
371 } ConnectionContext;
372 } IO_DISCONNECT_INTERRUPT_PARAMETERS, *PIO_DISCONNECT_INTERRUPT_PARAMETERS;
373
374 typedef enum _IO_ACCESS_TYPE {
375 ReadAccess,
376 WriteAccess,
377 ModifyAccess
378 } IO_ACCESS_TYPE;
379
380 typedef enum _IO_ACCESS_MODE {
381 SequentialAccess,
382 RandomAccess
383 } IO_ACCESS_MODE;
384
385 typedef enum _IO_CONTAINER_NOTIFICATION_CLASS {
386 IoSessionStateNotification,
387 IoMaxContainerNotificationClass
388 } IO_CONTAINER_NOTIFICATION_CLASS;
389
390 typedef struct _IO_SESSION_STATE_NOTIFICATION {
391 ULONG Size;
392 ULONG Flags;
393 PVOID IoObject;
394 ULONG EventMask;
395 PVOID Context;
396 } IO_SESSION_STATE_NOTIFICATION, *PIO_SESSION_STATE_NOTIFICATION;
397
398 typedef enum _IO_CONTAINER_INFORMATION_CLASS {
399 IoSessionStateInformation,
400 IoMaxContainerInformationClass
401 } IO_CONTAINER_INFORMATION_CLASS;
402
403 typedef struct _IO_SESSION_STATE_INFORMATION {
404 ULONG SessionId;
405 IO_SESSION_STATE SessionState;
406 BOOLEAN LocalSession;
407 } IO_SESSION_STATE_INFORMATION, *PIO_SESSION_STATE_INFORMATION;
408
409 #if (NTDDI_VERSION >= NTDDI_WIN7)
410
411 typedef NTSTATUS
412 (NTAPI *PIO_CONTAINER_NOTIFICATION_FUNCTION)(
413 VOID);
414
415 typedef NTSTATUS
416 (NTAPI IO_SESSION_NOTIFICATION_FUNCTION)(
417 IN PVOID SessionObject,
418 IN PVOID IoObject,
419 IN ULONG Event,
420 IN PVOID Context,
421 IN PVOID NotificationPayload,
422 IN ULONG PayloadLength);
423
424 typedef IO_SESSION_NOTIFICATION_FUNCTION *PIO_SESSION_NOTIFICATION_FUNCTION;
425
426 #endif
427
428 typedef struct _IO_REMOVE_LOCK_TRACKING_BLOCK * PIO_REMOVE_LOCK_TRACKING_BLOCK;
429
430 typedef struct _IO_REMOVE_LOCK_COMMON_BLOCK {
431 BOOLEAN Removed;
432 BOOLEAN Reserved[3];
433 volatile LONG IoCount;
434 KEVENT RemoveEvent;
435 } IO_REMOVE_LOCK_COMMON_BLOCK;
436
437 typedef struct _IO_REMOVE_LOCK_DBG_BLOCK {
438 LONG Signature;
439 LONG HighWatermark;
440 LONGLONG MaxLockedTicks;
441 LONG AllocateTag;
442 LIST_ENTRY LockList;
443 KSPIN_LOCK Spin;
444 volatile LONG LowMemoryCount;
445 ULONG Reserved1[4];
446 PVOID Reserved2;
447 PIO_REMOVE_LOCK_TRACKING_BLOCK Blocks;
448 } IO_REMOVE_LOCK_DBG_BLOCK;
449
450 typedef struct _IO_REMOVE_LOCK {
451 IO_REMOVE_LOCK_COMMON_BLOCK Common;
452 #if DBG
453 IO_REMOVE_LOCK_DBG_BLOCK Dbg;
454 #endif
455 } IO_REMOVE_LOCK, *PIO_REMOVE_LOCK;
456
457 typedef struct _IO_WORKITEM *PIO_WORKITEM;
458
459 typedef VOID
460 (NTAPI IO_WORKITEM_ROUTINE)(
461 IN PDEVICE_OBJECT DeviceObject,
462 IN PVOID Context);
463 typedef IO_WORKITEM_ROUTINE *PIO_WORKITEM_ROUTINE;
464
465 typedef VOID
466 (NTAPI IO_WORKITEM_ROUTINE_EX)(
467 IN PVOID IoObject,
468 IN PVOID Context OPTIONAL,
469 IN PIO_WORKITEM IoWorkItem);
470 typedef IO_WORKITEM_ROUTINE_EX *PIO_WORKITEM_ROUTINE_EX;
471
472 typedef struct _SHARE_ACCESS {
473 ULONG OpenCount;
474 ULONG Readers;
475 ULONG Writers;
476 ULONG Deleters;
477 ULONG SharedRead;
478 ULONG SharedWrite;
479 ULONG SharedDelete;
480 } SHARE_ACCESS, *PSHARE_ACCESS;
481
482 /* While MS WDK uses inheritance in C++, we cannot do this with gcc, as
483 inheritance, even from a struct renders the type non-POD. So we use
484 this hack */
485 #define PCI_COMMON_HEADER_LAYOUT \
486 USHORT VendorID; \
487 USHORT DeviceID; \
488 USHORT Command; \
489 USHORT Status; \
490 UCHAR RevisionID; \
491 UCHAR ProgIf; \
492 UCHAR SubClass; \
493 UCHAR BaseClass; \
494 UCHAR CacheLineSize; \
495 UCHAR LatencyTimer; \
496 UCHAR HeaderType; \
497 UCHAR BIST; \
498 union { \
499 struct _PCI_HEADER_TYPE_0 { \
500 ULONG BaseAddresses[PCI_TYPE0_ADDRESSES]; \
501 ULONG CIS; \
502 USHORT SubVendorID; \
503 USHORT SubSystemID; \
504 ULONG ROMBaseAddress; \
505 UCHAR CapabilitiesPtr; \
506 UCHAR Reserved1[3]; \
507 ULONG Reserved2; \
508 UCHAR InterruptLine; \
509 UCHAR InterruptPin; \
510 UCHAR MinimumGrant; \
511 UCHAR MaximumLatency; \
512 } type0; \
513 struct _PCI_HEADER_TYPE_1 { \
514 ULONG BaseAddresses[PCI_TYPE1_ADDRESSES]; \
515 UCHAR PrimaryBus; \
516 UCHAR SecondaryBus; \
517 UCHAR SubordinateBus; \
518 UCHAR SecondaryLatency; \
519 UCHAR IOBase; \
520 UCHAR IOLimit; \
521 USHORT SecondaryStatus; \
522 USHORT MemoryBase; \
523 USHORT MemoryLimit; \
524 USHORT PrefetchBase; \
525 USHORT PrefetchLimit; \
526 ULONG PrefetchBaseUpper32; \
527 ULONG PrefetchLimitUpper32; \
528 USHORT IOBaseUpper16; \
529 USHORT IOLimitUpper16; \
530 UCHAR CapabilitiesPtr; \
531 UCHAR Reserved1[3]; \
532 ULONG ROMBaseAddress; \
533 UCHAR InterruptLine; \
534 UCHAR InterruptPin; \
535 USHORT BridgeControl; \
536 } type1; \
537 struct _PCI_HEADER_TYPE_2 { \
538 ULONG SocketRegistersBaseAddress; \
539 UCHAR CapabilitiesPtr; \
540 UCHAR Reserved; \
541 USHORT SecondaryStatus; \
542 UCHAR PrimaryBus; \
543 UCHAR SecondaryBus; \
544 UCHAR SubordinateBus; \
545 UCHAR SecondaryLatency; \
546 struct { \
547 ULONG Base; \
548 ULONG Limit; \
549 } Range[PCI_TYPE2_ADDRESSES-1]; \
550 UCHAR InterruptLine; \
551 UCHAR InterruptPin; \
552 USHORT BridgeControl; \
553 } type2; \
554 } u;
555
556 typedef enum _CREATE_FILE_TYPE {
557 CreateFileTypeNone,
558 CreateFileTypeNamedPipe,
559 CreateFileTypeMailslot
560 } CREATE_FILE_TYPE;
561
562 #define IO_FORCE_ACCESS_CHECK 0x001
563 #define IO_NO_PARAMETER_CHECKING 0x100
564
565 #define IO_REPARSE 0x0
566 #define IO_REMOUNT 0x1
567
568 typedef struct _IO_STATUS_BLOCK {
569 _ANONYMOUS_UNION union {
570 NTSTATUS Status;
571 PVOID Pointer;
572 } DUMMYUNIONNAME;
573 ULONG_PTR Information;
574 } IO_STATUS_BLOCK, *PIO_STATUS_BLOCK;
575
576 #if defined(_WIN64)
577 typedef struct _IO_STATUS_BLOCK32 {
578 NTSTATUS Status;
579 ULONG Information;
580 } IO_STATUS_BLOCK32, *PIO_STATUS_BLOCK32;
581 #endif
582
583 typedef VOID
584 (NTAPI *PIO_APC_ROUTINE)(
585 IN PVOID ApcContext,
586 IN PIO_STATUS_BLOCK IoStatusBlock,
587 IN ULONG Reserved);
588
589 #define PIO_APC_ROUTINE_DEFINED
590
591 typedef enum _IO_SESSION_EVENT {
592 IoSessionEventIgnore = 0,
593 IoSessionEventCreated,
594 IoSessionEventTerminated,
595 IoSessionEventConnected,
596 IoSessionEventDisconnected,
597 IoSessionEventLogon,
598 IoSessionEventLogoff,
599 IoSessionEventMax
600 } IO_SESSION_EVENT, *PIO_SESSION_EVENT;
601
602 #define IO_SESSION_STATE_ALL_EVENTS 0xffffffff
603 #define IO_SESSION_STATE_CREATION_EVENT 0x00000001
604 #define IO_SESSION_STATE_TERMINATION_EVENT 0x00000002
605 #define IO_SESSION_STATE_CONNECT_EVENT 0x00000004
606 #define IO_SESSION_STATE_DISCONNECT_EVENT 0x00000008
607 #define IO_SESSION_STATE_LOGON_EVENT 0x00000010
608 #define IO_SESSION_STATE_LOGOFF_EVENT 0x00000020
609
610 #define IO_SESSION_STATE_VALID_EVENT_MASK 0x0000003f
611
612 #define IO_SESSION_MAX_PAYLOAD_SIZE 256L
613
614 typedef struct _IO_SESSION_CONNECT_INFO {
615 ULONG SessionId;
616 BOOLEAN LocalSession;
617 } IO_SESSION_CONNECT_INFO, *PIO_SESSION_CONNECT_INFO;
618
619 #define EVENT_INCREMENT 1
620 #define IO_NO_INCREMENT 0
621 #define IO_CD_ROM_INCREMENT 1
622 #define IO_DISK_INCREMENT 1
623 #define IO_KEYBOARD_INCREMENT 6
624 #define IO_MAILSLOT_INCREMENT 2
625 #define IO_MOUSE_INCREMENT 6
626 #define IO_NAMED_PIPE_INCREMENT 2
627 #define IO_NETWORK_INCREMENT 2
628 #define IO_PARALLEL_INCREMENT 1
629 #define IO_SERIAL_INCREMENT 2
630 #define IO_SOUND_INCREMENT 8
631 #define IO_VIDEO_INCREMENT 1
632 #define SEMAPHORE_INCREMENT 1
633
634 #define MM_MAXIMUM_DISK_IO_SIZE (0x10000)
635
636 typedef struct _BOOTDISK_INFORMATION {
637 LONGLONG BootPartitionOffset;
638 LONGLONG SystemPartitionOffset;
639 ULONG BootDeviceSignature;
640 ULONG SystemDeviceSignature;
641 } BOOTDISK_INFORMATION, *PBOOTDISK_INFORMATION;
642
643 typedef struct _BOOTDISK_INFORMATION_EX {
644 LONGLONG BootPartitionOffset;
645 LONGLONG SystemPartitionOffset;
646 ULONG BootDeviceSignature;
647 ULONG SystemDeviceSignature;
648 GUID BootDeviceGuid;
649 GUID SystemDeviceGuid;
650 BOOLEAN BootDeviceIsGpt;
651 BOOLEAN SystemDeviceIsGpt;
652 } BOOTDISK_INFORMATION_EX, *PBOOTDISK_INFORMATION_EX;
653
654 #if (NTDDI_VERSION >= NTDDI_WIN7)
655
656 typedef struct _LOADER_PARTITION_INFORMATION_EX {
657 ULONG PartitionStyle;
658 ULONG PartitionNumber;
659 union {
660 ULONG Signature;
661 GUID DeviceId;
662 };
663 ULONG Flags;
664 } LOADER_PARTITION_INFORMATION_EX, *PLOADER_PARTITION_INFORMATION_EX;
665
666 typedef struct _BOOTDISK_INFORMATION_LITE {
667 ULONG NumberEntries;
668 LOADER_PARTITION_INFORMATION_EX Entries[1];
669 } BOOTDISK_INFORMATION_LITE, *PBOOTDISK_INFORMATION_LITE;
670
671 #else
672
673 #if (NTDDI_VERSION >= NTDDI_VISTA)
674 typedef struct _BOOTDISK_INFORMATION_LITE {
675 ULONG BootDeviceSignature;
676 ULONG SystemDeviceSignature;
677 GUID BootDeviceGuid;
678 GUID SystemDeviceGuid;
679 BOOLEAN BootDeviceIsGpt;
680 BOOLEAN SystemDeviceIsGpt;
681 } BOOTDISK_INFORMATION_LITE, *PBOOTDISK_INFORMATION_LITE;
682 #endif /* (NTDDI_VERSION >= NTDDI_VISTA) */
683
684 #endif /* (NTDDI_VERSION >= NTDDI_WIN7) */
685
686 #include <pshpack1.h>
687
688 typedef struct _EISA_MEMORY_TYPE {
689 UCHAR ReadWrite:1;
690 UCHAR Cached:1;
691 UCHAR Reserved0:1;
692 UCHAR Type:2;
693 UCHAR Shared:1;
694 UCHAR Reserved1:1;
695 UCHAR MoreEntries:1;
696 } EISA_MEMORY_TYPE, *PEISA_MEMORY_TYPE;
697
698 typedef struct _EISA_MEMORY_CONFIGURATION {
699 EISA_MEMORY_TYPE ConfigurationByte;
700 UCHAR DataSize;
701 USHORT AddressLowWord;
702 UCHAR AddressHighByte;
703 USHORT MemorySize;
704 } EISA_MEMORY_CONFIGURATION, *PEISA_MEMORY_CONFIGURATION;
705
706 typedef struct _EISA_IRQ_DESCRIPTOR {
707 UCHAR Interrupt:4;
708 UCHAR Reserved:1;
709 UCHAR LevelTriggered:1;
710 UCHAR Shared:1;
711 UCHAR MoreEntries:1;
712 } EISA_IRQ_DESCRIPTOR, *PEISA_IRQ_DESCRIPTOR;
713
714 typedef struct _EISA_IRQ_CONFIGURATION {
715 EISA_IRQ_DESCRIPTOR ConfigurationByte;
716 UCHAR Reserved;
717 } EISA_IRQ_CONFIGURATION, *PEISA_IRQ_CONFIGURATION;
718
719 typedef struct _DMA_CONFIGURATION_BYTE0 {
720 UCHAR Channel:3;
721 UCHAR Reserved:3;
722 UCHAR Shared:1;
723 UCHAR MoreEntries:1;
724 } DMA_CONFIGURATION_BYTE0;
725
726 typedef struct _DMA_CONFIGURATION_BYTE1 {
727 UCHAR Reserved0:2;
728 UCHAR TransferSize:2;
729 UCHAR Timing:2;
730 UCHAR Reserved1:2;
731 } DMA_CONFIGURATION_BYTE1;
732
733 typedef struct _EISA_DMA_CONFIGURATION {
734 DMA_CONFIGURATION_BYTE0 ConfigurationByte0;
735 DMA_CONFIGURATION_BYTE1 ConfigurationByte1;
736 } EISA_DMA_CONFIGURATION, *PEISA_DMA_CONFIGURATION;
737
738 typedef struct _EISA_PORT_DESCRIPTOR {
739 UCHAR NumberPorts:5;
740 UCHAR Reserved:1;
741 UCHAR Shared:1;
742 UCHAR MoreEntries:1;
743 } EISA_PORT_DESCRIPTOR, *PEISA_PORT_DESCRIPTOR;
744
745 typedef struct _EISA_PORT_CONFIGURATION {
746 EISA_PORT_DESCRIPTOR Configuration;
747 USHORT PortAddress;
748 } EISA_PORT_CONFIGURATION, *PEISA_PORT_CONFIGURATION;
749
750 typedef struct _CM_EISA_SLOT_INFORMATION {
751 UCHAR ReturnCode;
752 UCHAR ReturnFlags;
753 UCHAR MajorRevision;
754 UCHAR MinorRevision;
755 USHORT Checksum;
756 UCHAR NumberFunctions;
757 UCHAR FunctionInformation;
758 ULONG CompressedId;
759 } CM_EISA_SLOT_INFORMATION, *PCM_EISA_SLOT_INFORMATION;
760
761 typedef struct _CM_EISA_FUNCTION_INFORMATION {
762 ULONG CompressedId;
763 UCHAR IdSlotFlags1;
764 UCHAR IdSlotFlags2;
765 UCHAR MinorRevision;
766 UCHAR MajorRevision;
767 UCHAR Selections[26];
768 UCHAR FunctionFlags;
769 UCHAR TypeString[80];
770 EISA_MEMORY_CONFIGURATION EisaMemory[9];
771 EISA_IRQ_CONFIGURATION EisaIrq[7];
772 EISA_DMA_CONFIGURATION EisaDma[4];
773 EISA_PORT_CONFIGURATION EisaPort[20];
774 UCHAR InitializationData[60];
775 } CM_EISA_FUNCTION_INFORMATION, *PCM_EISA_FUNCTION_INFORMATION;
776
777 #include <poppack.h>
778
779 /* CM_EISA_FUNCTION_INFORMATION.FunctionFlags */
780
781 #define EISA_FUNCTION_ENABLED 0x80
782 #define EISA_FREE_FORM_DATA 0x40
783 #define EISA_HAS_PORT_INIT_ENTRY 0x20
784 #define EISA_HAS_PORT_RANGE 0x10
785 #define EISA_HAS_DMA_ENTRY 0x08
786 #define EISA_HAS_IRQ_ENTRY 0x04
787 #define EISA_HAS_MEMORY_ENTRY 0x02
788 #define EISA_HAS_TYPE_ENTRY 0x01
789 #define EISA_HAS_INFORMATION \
790 (EISA_HAS_PORT_RANGE + EISA_HAS_DMA_ENTRY + EISA_HAS_IRQ_ENTRY \
791 + EISA_HAS_MEMORY_ENTRY + EISA_HAS_TYPE_ENTRY)
792
793 #define EISA_MORE_ENTRIES 0x80
794 #define EISA_SYSTEM_MEMORY 0x00
795 #define EISA_MEMORY_TYPE_RAM 0x01
796
797 /* CM_EISA_SLOT_INFORMATION.ReturnCode */
798
799 #define EISA_INVALID_SLOT 0x80
800 #define EISA_INVALID_FUNCTION 0x81
801 #define EISA_INVALID_CONFIGURATION 0x82
802 #define EISA_EMPTY_SLOT 0x83
803 #define EISA_INVALID_BIOS_CALL 0x86
804
805 /*
806 ** Plug and Play structures
807 */
808
809 typedef VOID
810 (NTAPI *PINTERFACE_REFERENCE)(
811 PVOID Context);
812
813 typedef VOID
814 (NTAPI *PINTERFACE_DEREFERENCE)(
815 PVOID Context);
816
817 typedef BOOLEAN
818 (NTAPI TRANSLATE_BUS_ADDRESS)(
819 IN PVOID Context,
820 IN PHYSICAL_ADDRESS BusAddress,
821 IN ULONG Length,
822 IN OUT PULONG AddressSpace,
823 OUT PPHYSICAL_ADDRESS TranslatedAddress);
824 typedef TRANSLATE_BUS_ADDRESS *PTRANSLATE_BUS_ADDRESS;
825
826 typedef struct _DMA_ADAPTER*
827 (NTAPI GET_DMA_ADAPTER)(
828 IN PVOID Context,
829 IN struct _DEVICE_DESCRIPTION *DeviceDescriptor,
830 OUT PULONG NumberOfMapRegisters);
831 typedef GET_DMA_ADAPTER *PGET_DMA_ADAPTER;
832
833 typedef ULONG
834 (NTAPI GET_SET_DEVICE_DATA)(
835 IN PVOID Context,
836 IN ULONG DataType,
837 IN PVOID Buffer,
838 IN ULONG Offset,
839 IN ULONG Length);
840 typedef GET_SET_DEVICE_DATA *PGET_SET_DEVICE_DATA;
841
842 typedef enum _DEVICE_INSTALL_STATE {
843 InstallStateInstalled,
844 InstallStateNeedsReinstall,
845 InstallStateFailedInstall,
846 InstallStateFinishInstall
847 } DEVICE_INSTALL_STATE, *PDEVICE_INSTALL_STATE;
848
849 typedef struct _LEGACY_BUS_INFORMATION {
850 GUID BusTypeGuid;
851 INTERFACE_TYPE LegacyBusType;
852 ULONG BusNumber;
853 } LEGACY_BUS_INFORMATION, *PLEGACY_BUS_INFORMATION;
854
855 typedef enum _DEVICE_REMOVAL_POLICY {
856 RemovalPolicyExpectNoRemoval = 1,
857 RemovalPolicyExpectOrderlyRemoval = 2,
858 RemovalPolicyExpectSurpriseRemoval = 3
859 } DEVICE_REMOVAL_POLICY, *PDEVICE_REMOVAL_POLICY;
860
861 typedef VOID
862 (NTAPI*PREENUMERATE_SELF)(
863 IN PVOID Context);
864
865 typedef struct _REENUMERATE_SELF_INTERFACE_STANDARD {
866 USHORT Size;
867 USHORT Version;
868 PVOID Context;
869 PINTERFACE_REFERENCE InterfaceReference;
870 PINTERFACE_DEREFERENCE InterfaceDereference;
871 PREENUMERATE_SELF SurpriseRemoveAndReenumerateSelf;
872 } REENUMERATE_SELF_INTERFACE_STANDARD, *PREENUMERATE_SELF_INTERFACE_STANDARD;
873
874 typedef VOID
875 (NTAPI *PIO_DEVICE_EJECT_CALLBACK)(
876 IN NTSTATUS Status,
877 IN OUT PVOID Context OPTIONAL);
878
879 #define PCI_DEVICE_PRESENT_INTERFACE_VERSION 1
880
881 /* PCI_DEVICE_PRESENCE_PARAMETERS.Flags */
882 #define PCI_USE_SUBSYSTEM_IDS 0x00000001
883 #define PCI_USE_REVISION 0x00000002
884 #define PCI_USE_VENDEV_IDS 0x00000004
885 #define PCI_USE_CLASS_SUBCLASS 0x00000008
886 #define PCI_USE_PROGIF 0x00000010
887 #define PCI_USE_LOCAL_BUS 0x00000020
888 #define PCI_USE_LOCAL_DEVICE 0x00000040
889
890 typedef struct _PCI_DEVICE_PRESENCE_PARAMETERS {
891 ULONG Size;
892 ULONG Flags;
893 USHORT VendorID;
894 USHORT DeviceID;
895 UCHAR RevisionID;
896 USHORT SubVendorID;
897 USHORT SubSystemID;
898 UCHAR BaseClass;
899 UCHAR SubClass;
900 UCHAR ProgIf;
901 } PCI_DEVICE_PRESENCE_PARAMETERS, *PPCI_DEVICE_PRESENCE_PARAMETERS;
902
903 typedef BOOLEAN
904 (NTAPI PCI_IS_DEVICE_PRESENT)(
905 IN USHORT VendorID,
906 IN USHORT DeviceID,
907 IN UCHAR RevisionID,
908 IN USHORT SubVendorID,
909 IN USHORT SubSystemID,
910 IN ULONG Flags);
911 typedef PCI_IS_DEVICE_PRESENT *PPCI_IS_DEVICE_PRESENT;
912
913 typedef BOOLEAN
914 (NTAPI PCI_IS_DEVICE_PRESENT_EX)(
915 IN PVOID Context,
916 IN PPCI_DEVICE_PRESENCE_PARAMETERS Parameters);
917 typedef PCI_IS_DEVICE_PRESENT_EX *PPCI_IS_DEVICE_PRESENT_EX;
918
919 typedef struct _BUS_INTERFACE_STANDARD {
920 USHORT Size;
921 USHORT Version;
922 PVOID Context;
923 PINTERFACE_REFERENCE InterfaceReference;
924 PINTERFACE_DEREFERENCE InterfaceDereference;
925 PTRANSLATE_BUS_ADDRESS TranslateBusAddress;
926 PGET_DMA_ADAPTER GetDmaAdapter;
927 PGET_SET_DEVICE_DATA SetBusData;
928 PGET_SET_DEVICE_DATA GetBusData;
929 } BUS_INTERFACE_STANDARD, *PBUS_INTERFACE_STANDARD;
930
931 typedef struct _PCI_DEVICE_PRESENT_INTERFACE {
932 USHORT Size;
933 USHORT Version;
934 PVOID Context;
935 PINTERFACE_REFERENCE InterfaceReference;
936 PINTERFACE_DEREFERENCE InterfaceDereference;
937 PPCI_IS_DEVICE_PRESENT IsDevicePresent;
938 PPCI_IS_DEVICE_PRESENT_EX IsDevicePresentEx;
939 } PCI_DEVICE_PRESENT_INTERFACE, *PPCI_DEVICE_PRESENT_INTERFACE;
940
941 typedef struct _DEVICE_CAPABILITIES {
942 USHORT Size;
943 USHORT Version;
944 ULONG DeviceD1:1;
945 ULONG DeviceD2:1;
946 ULONG LockSupported:1;
947 ULONG EjectSupported:1;
948 ULONG Removable:1;
949 ULONG DockDevice:1;
950 ULONG UniqueID:1;
951 ULONG SilentInstall:1;
952 ULONG RawDeviceOK:1;
953 ULONG SurpriseRemovalOK:1;
954 ULONG WakeFromD0:1;
955 ULONG WakeFromD1:1;
956 ULONG WakeFromD2:1;
957 ULONG WakeFromD3:1;
958 ULONG HardwareDisabled:1;
959 ULONG NonDynamic:1;
960 ULONG WarmEjectSupported:1;
961 ULONG NoDisplayInUI:1;
962 ULONG Reserved:14;
963 ULONG Address;
964 ULONG UINumber;
965 DEVICE_POWER_STATE DeviceState[PowerSystemMaximum];
966 SYSTEM_POWER_STATE SystemWake;
967 DEVICE_POWER_STATE DeviceWake;
968 ULONG D1Latency;
969 ULONG D2Latency;
970 ULONG D3Latency;
971 } DEVICE_CAPABILITIES, *PDEVICE_CAPABILITIES;
972
973 typedef struct _DEVICE_INTERFACE_CHANGE_NOTIFICATION {
974 USHORT Version;
975 USHORT Size;
976 GUID Event;
977 GUID InterfaceClassGuid;
978 PUNICODE_STRING SymbolicLinkName;
979 } DEVICE_INTERFACE_CHANGE_NOTIFICATION, *PDEVICE_INTERFACE_CHANGE_NOTIFICATION;
980
981 typedef struct _HWPROFILE_CHANGE_NOTIFICATION {
982 USHORT Version;
983 USHORT Size;
984 GUID Event;
985 } HWPROFILE_CHANGE_NOTIFICATION, *PHWPROFILE_CHANGE_NOTIFICATION;
986
987 #undef INTERFACE
988
989 typedef struct _INTERFACE {
990 USHORT Size;
991 USHORT Version;
992 PVOID Context;
993 PINTERFACE_REFERENCE InterfaceReference;
994 PINTERFACE_DEREFERENCE InterfaceDereference;
995 } INTERFACE, *PINTERFACE;
996
997 typedef struct _PLUGPLAY_NOTIFICATION_HEADER {
998 USHORT Version;
999 USHORT Size;
1000 GUID Event;
1001 } PLUGPLAY_NOTIFICATION_HEADER, *PPLUGPLAY_NOTIFICATION_HEADER;
1002
1003 typedef ULONG PNP_DEVICE_STATE, *PPNP_DEVICE_STATE;
1004
1005 /* PNP_DEVICE_STATE */
1006
1007 #define PNP_DEVICE_DISABLED 0x00000001
1008 #define PNP_DEVICE_DONT_DISPLAY_IN_UI 0x00000002
1009 #define PNP_DEVICE_FAILED 0x00000004
1010 #define PNP_DEVICE_REMOVED 0x00000008
1011 #define PNP_DEVICE_RESOURCE_REQUIREMENTS_CHANGED 0x00000010
1012 #define PNP_DEVICE_NOT_DISABLEABLE 0x00000020
1013
1014 typedef struct _TARGET_DEVICE_CUSTOM_NOTIFICATION {
1015 USHORT Version;
1016 USHORT Size;
1017 GUID Event;
1018 struct _FILE_OBJECT *FileObject;
1019 LONG NameBufferOffset;
1020 UCHAR CustomDataBuffer[1];
1021 } TARGET_DEVICE_CUSTOM_NOTIFICATION, *PTARGET_DEVICE_CUSTOM_NOTIFICATION;
1022
1023 typedef struct _TARGET_DEVICE_REMOVAL_NOTIFICATION {
1024 USHORT Version;
1025 USHORT Size;
1026 GUID Event;
1027 struct _FILE_OBJECT *FileObject;
1028 } TARGET_DEVICE_REMOVAL_NOTIFICATION, *PTARGET_DEVICE_REMOVAL_NOTIFICATION;
1029
1030 #if (NTDDI_VERSION >= NTDDI_VISTA)
1031 #include <devpropdef.h>
1032 #define PLUGPLAY_PROPERTY_PERSISTENT 0x00000001
1033 #endif
1034
1035 #define PNP_REPLACE_NO_MAP MAXLONGLONG
1036
1037 typedef NTSTATUS
1038 (NTAPI *PREPLACE_MAP_MEMORY)(
1039 IN PHYSICAL_ADDRESS TargetPhysicalAddress,
1040 IN PHYSICAL_ADDRESS SparePhysicalAddress,
1041 IN OUT PLARGE_INTEGER NumberOfBytes,
1042 OUT PVOID *TargetAddress,
1043 OUT PVOID *SpareAddress);
1044
1045 typedef struct _PNP_REPLACE_MEMORY_LIST {
1046 ULONG AllocatedCount;
1047 ULONG Count;
1048 ULONGLONG TotalLength;
1049 struct {
1050 PHYSICAL_ADDRESS Address;
1051 ULONGLONG Length;
1052 } Ranges[ANYSIZE_ARRAY];
1053 } PNP_REPLACE_MEMORY_LIST, *PPNP_REPLACE_MEMORY_LIST;
1054
1055 typedef struct _PNP_REPLACE_PROCESSOR_LIST {
1056 PKAFFINITY Affinity;
1057 ULONG GroupCount;
1058 ULONG AllocatedCount;
1059 ULONG Count;
1060 ULONG ApicIds[ANYSIZE_ARRAY];
1061 } PNP_REPLACE_PROCESSOR_LIST, *PPNP_REPLACE_PROCESSOR_LIST;
1062
1063 typedef struct _PNP_REPLACE_PROCESSOR_LIST_V1 {
1064 KAFFINITY AffinityMask;
1065 ULONG AllocatedCount;
1066 ULONG Count;
1067 ULONG ApicIds[ANYSIZE_ARRAY];
1068 } PNP_REPLACE_PROCESSOR_LIST_V1, *PPNP_REPLACE_PROCESSOR_LIST_V1;
1069
1070 #define PNP_REPLACE_PARAMETERS_VERSION 2
1071
1072 typedef struct _PNP_REPLACE_PARAMETERS {
1073 ULONG Size;
1074 ULONG Version;
1075 ULONG64 Target;
1076 ULONG64 Spare;
1077 PPNP_REPLACE_PROCESSOR_LIST TargetProcessors;
1078 PPNP_REPLACE_PROCESSOR_LIST SpareProcessors;
1079 PPNP_REPLACE_MEMORY_LIST TargetMemory;
1080 PPNP_REPLACE_MEMORY_LIST SpareMemory;
1081 PREPLACE_MAP_MEMORY MapMemory;
1082 } PNP_REPLACE_PARAMETERS, *PPNP_REPLACE_PARAMETERS;
1083
1084 typedef VOID
1085 (NTAPI *PREPLACE_UNLOAD)(
1086 VOID);
1087
1088 typedef NTSTATUS
1089 (NTAPI *PREPLACE_BEGIN)(
1090 IN PPNP_REPLACE_PARAMETERS Parameters,
1091 OUT PVOID *Context);
1092
1093 typedef NTSTATUS
1094 (NTAPI *PREPLACE_END)(
1095 IN PVOID Context);
1096
1097 typedef NTSTATUS
1098 (NTAPI *PREPLACE_MIRROR_PHYSICAL_MEMORY)(
1099 IN PVOID Context,
1100 IN PHYSICAL_ADDRESS PhysicalAddress,
1101 IN LARGE_INTEGER ByteCount);
1102
1103 typedef NTSTATUS
1104 (NTAPI *PREPLACE_SET_PROCESSOR_ID)(
1105 IN PVOID Context,
1106 IN ULONG ApicId,
1107 IN BOOLEAN Target);
1108
1109 typedef NTSTATUS
1110 (NTAPI *PREPLACE_SWAP)(
1111 IN PVOID Context);
1112
1113 typedef NTSTATUS
1114 (NTAPI *PREPLACE_INITIATE_HARDWARE_MIRROR)(
1115 IN PVOID Context);
1116
1117 typedef NTSTATUS
1118 (NTAPI *PREPLACE_MIRROR_PLATFORM_MEMORY)(
1119 IN PVOID Context);
1120
1121 typedef NTSTATUS
1122 (NTAPI *PREPLACE_GET_MEMORY_DESTINATION)(
1123 IN PVOID Context,
1124 IN PHYSICAL_ADDRESS SourceAddress,
1125 OUT PPHYSICAL_ADDRESS DestinationAddress);
1126
1127 typedef NTSTATUS
1128 (NTAPI *PREPLACE_ENABLE_DISABLE_HARDWARE_QUIESCE)(
1129 IN PVOID Context,
1130 IN BOOLEAN Enable);
1131
1132 #define PNP_REPLACE_DRIVER_INTERFACE_VERSION 1
1133 #define PNP_REPLACE_DRIVER_INTERFACE_MINIMUM_SIZE \
1134 FIELD_OFFSET(PNP_REPLACE_DRIVER_INTERFACE, InitiateHardwareMirror)
1135
1136 #define PNP_REPLACE_MEMORY_SUPPORTED 0x0001
1137 #define PNP_REPLACE_PROCESSOR_SUPPORTED 0x0002
1138 #define PNP_REPLACE_HARDWARE_MEMORY_MIRRORING 0x0004
1139 #define PNP_REPLACE_HARDWARE_PAGE_COPY 0x0008
1140 #define PNP_REPLACE_HARDWARE_QUIESCE 0x0010
1141
1142 typedef struct _PNP_REPLACE_DRIVER_INTERFACE {
1143 ULONG Size;
1144 ULONG Version;
1145 ULONG Flags;
1146 PREPLACE_UNLOAD Unload;
1147 PREPLACE_BEGIN BeginReplace;
1148 PREPLACE_END EndReplace;
1149 PREPLACE_MIRROR_PHYSICAL_MEMORY MirrorPhysicalMemory;
1150 PREPLACE_SET_PROCESSOR_ID SetProcessorId;
1151 PREPLACE_SWAP Swap;
1152 PREPLACE_INITIATE_HARDWARE_MIRROR InitiateHardwareMirror;
1153 PREPLACE_MIRROR_PLATFORM_MEMORY MirrorPlatformMemory;
1154 PREPLACE_GET_MEMORY_DESTINATION GetMemoryDestination;
1155 PREPLACE_ENABLE_DISABLE_HARDWARE_QUIESCE EnableDisableHardwareQuiesce;
1156 } PNP_REPLACE_DRIVER_INTERFACE, *PPNP_REPLACE_DRIVER_INTERFACE;
1157
1158 typedef NTSTATUS
1159 (NTAPI *PREPLACE_DRIVER_INIT)(
1160 IN OUT PPNP_REPLACE_DRIVER_INTERFACE Interface,
1161 IN PVOID Unused);
1162
1163 typedef enum _DEVICE_USAGE_NOTIFICATION_TYPE {
1164 DeviceUsageTypeUndefined,
1165 DeviceUsageTypePaging,
1166 DeviceUsageTypeHibernation,
1167 DeviceUsageTypeDumpFile
1168 } DEVICE_USAGE_NOTIFICATION_TYPE;
1169
1170 typedef struct _POWER_SEQUENCE {
1171 ULONG SequenceD1;
1172 ULONG SequenceD2;
1173 ULONG SequenceD3;
1174 } POWER_SEQUENCE, *PPOWER_SEQUENCE;
1175
1176 typedef enum {
1177 DevicePropertyDeviceDescription = 0x0,
1178 DevicePropertyHardwareID = 0x1,
1179 DevicePropertyCompatibleIDs = 0x2,
1180 DevicePropertyBootConfiguration = 0x3,
1181 DevicePropertyBootConfigurationTranslated = 0x4,
1182 DevicePropertyClassName = 0x5,
1183 DevicePropertyClassGuid = 0x6,
1184 DevicePropertyDriverKeyName = 0x7,
1185 DevicePropertyManufacturer = 0x8,
1186 DevicePropertyFriendlyName = 0x9,
1187 DevicePropertyLocationInformation = 0xa,
1188 DevicePropertyPhysicalDeviceObjectName = 0xb,
1189 DevicePropertyBusTypeGuid = 0xc,
1190 DevicePropertyLegacyBusType = 0xd,
1191 DevicePropertyBusNumber = 0xe,
1192 DevicePropertyEnumeratorName = 0xf,
1193 DevicePropertyAddress = 0x10,
1194 DevicePropertyUINumber = 0x11,
1195 DevicePropertyInstallState = 0x12,
1196 DevicePropertyRemovalPolicy = 0x13,
1197 DevicePropertyResourceRequirements = 0x14,
1198 DevicePropertyAllocatedResources = 0x15,
1199 DevicePropertyContainerID = 0x16
1200 } DEVICE_REGISTRY_PROPERTY;
1201
1202 typedef enum _IO_NOTIFICATION_EVENT_CATEGORY {
1203 EventCategoryReserved,
1204 EventCategoryHardwareProfileChange,
1205 EventCategoryDeviceInterfaceChange,
1206 EventCategoryTargetDeviceChange
1207 } IO_NOTIFICATION_EVENT_CATEGORY;
1208
1209 typedef enum _IO_PRIORITY_HINT {
1210 IoPriorityVeryLow = 0,
1211 IoPriorityLow,
1212 IoPriorityNormal,
1213 IoPriorityHigh,
1214 IoPriorityCritical,
1215 MaxIoPriorityTypes
1216 } IO_PRIORITY_HINT;
1217
1218 #define PNPNOTIFY_DEVICE_INTERFACE_INCLUDE_EXISTING_INTERFACES 0x00000001
1219
1220 typedef NTSTATUS
1221 (NTAPI DRIVER_NOTIFICATION_CALLBACK_ROUTINE)(
1222 IN PVOID NotificationStructure,
1223 IN PVOID Context);
1224 typedef DRIVER_NOTIFICATION_CALLBACK_ROUTINE *PDRIVER_NOTIFICATION_CALLBACK_ROUTINE;
1225
1226 typedef VOID
1227 (NTAPI DEVICE_CHANGE_COMPLETE_CALLBACK)(
1228 IN PVOID Context);
1229 typedef DEVICE_CHANGE_COMPLETE_CALLBACK *PDEVICE_CHANGE_COMPLETE_CALLBACK;
1230
1231 typedef enum _FILE_INFORMATION_CLASS {
1232 FileDirectoryInformation = 1,
1233 FileFullDirectoryInformation,
1234 FileBothDirectoryInformation,
1235 FileBasicInformation,
1236 FileStandardInformation,
1237 FileInternalInformation,
1238 FileEaInformation,
1239 FileAccessInformation,
1240 FileNameInformation,
1241 FileRenameInformation,
1242 FileLinkInformation,
1243 FileNamesInformation,
1244 FileDispositionInformation,
1245 FilePositionInformation,
1246 FileFullEaInformation,
1247 FileModeInformation,
1248 FileAlignmentInformation,
1249 FileAllInformation,
1250 FileAllocationInformation,
1251 FileEndOfFileInformation,
1252 FileAlternateNameInformation,
1253 FileStreamInformation,
1254 FilePipeInformation,
1255 FilePipeLocalInformation,
1256 FilePipeRemoteInformation,
1257 FileMailslotQueryInformation,
1258 FileMailslotSetInformation,
1259 FileCompressionInformation,
1260 FileObjectIdInformation,
1261 FileCompletionInformation,
1262 FileMoveClusterInformation,
1263 FileQuotaInformation,
1264 FileReparsePointInformation,
1265 FileNetworkOpenInformation,
1266 FileAttributeTagInformation,
1267 FileTrackingInformation,
1268 FileIdBothDirectoryInformation,
1269 FileIdFullDirectoryInformation,
1270 FileValidDataLengthInformation,
1271 FileShortNameInformation,
1272 FileIoCompletionNotificationInformation,
1273 FileIoStatusBlockRangeInformation,
1274 FileIoPriorityHintInformation,
1275 FileSfioReserveInformation,
1276 FileSfioVolumeInformation,
1277 FileHardLinkInformation,
1278 FileProcessIdsUsingFileInformation,
1279 FileNormalizedNameInformation,
1280 FileNetworkPhysicalNameInformation,
1281 FileIdGlobalTxDirectoryInformation,
1282 FileIsRemoteDeviceInformation,
1283 FileAttributeCacheInformation,
1284 FileNumaNodeInformation,
1285 FileStandardLinkInformation,
1286 FileRemoteProtocolInformation,
1287 FileMaximumInformation
1288 } FILE_INFORMATION_CLASS, *PFILE_INFORMATION_CLASS;
1289
1290 typedef struct _FILE_POSITION_INFORMATION {
1291 LARGE_INTEGER CurrentByteOffset;
1292 } FILE_POSITION_INFORMATION, *PFILE_POSITION_INFORMATION;
1293
1294 typedef struct _FILE_BASIC_INFORMATION {
1295 LARGE_INTEGER CreationTime;
1296 LARGE_INTEGER LastAccessTime;
1297 LARGE_INTEGER LastWriteTime;
1298 LARGE_INTEGER ChangeTime;
1299 ULONG FileAttributes;
1300 } FILE_BASIC_INFORMATION, *PFILE_BASIC_INFORMATION;
1301
1302 typedef struct _FILE_IO_PRIORITY_HINT_INFORMATION {
1303 IO_PRIORITY_HINT PriorityHint;
1304 } FILE_IO_PRIORITY_HINT_INFORMATION, *PFILE_IO_PRIORITY_HINT_INFORMATION;
1305
1306 typedef struct _FILE_IO_COMPLETION_NOTIFICATION_INFORMATION {
1307 ULONG Flags;
1308 } FILE_IO_COMPLETION_NOTIFICATION_INFORMATION, *PFILE_IO_COMPLETION_NOTIFICATION_INFORMATION;
1309
1310 typedef struct _FILE_IOSTATUSBLOCK_RANGE_INFORMATION {
1311 PUCHAR IoStatusBlockRange;
1312 ULONG Length;
1313 } FILE_IOSTATUSBLOCK_RANGE_INFORMATION, *PFILE_IOSTATUSBLOCK_RANGE_INFORMATION;
1314
1315 typedef struct _FILE_IS_REMOTE_DEVICE_INFORMATION {
1316 BOOLEAN IsRemote;
1317 } FILE_IS_REMOTE_DEVICE_INFORMATION, *PFILE_IS_REMOTE_DEVICE_INFORMATION;
1318
1319 typedef struct _FILE_NUMA_NODE_INFORMATION {
1320 USHORT NodeNumber;
1321 } FILE_NUMA_NODE_INFORMATION, *PFILE_NUMA_NODE_INFORMATION;
1322
1323 typedef struct _FILE_PROCESS_IDS_USING_FILE_INFORMATION {
1324 ULONG NumberOfProcessIdsInList;
1325 ULONG_PTR ProcessIdList[1];
1326 } FILE_PROCESS_IDS_USING_FILE_INFORMATION, *PFILE_PROCESS_IDS_USING_FILE_INFORMATION;
1327
1328 typedef struct _FILE_STANDARD_INFORMATION {
1329 LARGE_INTEGER AllocationSize;
1330 LARGE_INTEGER EndOfFile;
1331 ULONG NumberOfLinks;
1332 BOOLEAN DeletePending;
1333 BOOLEAN Directory;
1334 } FILE_STANDARD_INFORMATION, *PFILE_STANDARD_INFORMATION;
1335
1336 typedef struct _FILE_NETWORK_OPEN_INFORMATION {
1337 LARGE_INTEGER CreationTime;
1338 LARGE_INTEGER LastAccessTime;
1339 LARGE_INTEGER LastWriteTime;
1340 LARGE_INTEGER ChangeTime;
1341 LARGE_INTEGER AllocationSize;
1342 LARGE_INTEGER EndOfFile;
1343 ULONG FileAttributes;
1344 } FILE_NETWORK_OPEN_INFORMATION, *PFILE_NETWORK_OPEN_INFORMATION;
1345
1346 typedef enum _FSINFOCLASS {
1347 FileFsVolumeInformation = 1,
1348 FileFsLabelInformation,
1349 FileFsSizeInformation,
1350 FileFsDeviceInformation,
1351 FileFsAttributeInformation,
1352 FileFsControlInformation,
1353 FileFsFullSizeInformation,
1354 FileFsObjectIdInformation,
1355 FileFsDriverPathInformation,
1356 FileFsVolumeFlagsInformation,
1357 FileFsMaximumInformation
1358 } FS_INFORMATION_CLASS, *PFS_INFORMATION_CLASS;
1359
1360 typedef struct _FILE_FS_DEVICE_INFORMATION {
1361 DEVICE_TYPE DeviceType;
1362 ULONG Characteristics;
1363 } FILE_FS_DEVICE_INFORMATION, *PFILE_FS_DEVICE_INFORMATION;
1364
1365 typedef struct _FILE_FULL_EA_INFORMATION {
1366 ULONG NextEntryOffset;
1367 UCHAR Flags;
1368 UCHAR EaNameLength;
1369 USHORT EaValueLength;
1370 CHAR EaName[1];
1371 } FILE_FULL_EA_INFORMATION, *PFILE_FULL_EA_INFORMATION;
1372
1373 typedef struct _FILE_SFIO_RESERVE_INFORMATION {
1374 ULONG RequestsPerPeriod;
1375 ULONG Period;
1376 BOOLEAN RetryFailures;
1377 BOOLEAN Discardable;
1378 ULONG RequestSize;
1379 ULONG NumOutstandingRequests;
1380 } FILE_SFIO_RESERVE_INFORMATION, *PFILE_SFIO_RESERVE_INFORMATION;
1381
1382 typedef struct _FILE_SFIO_VOLUME_INFORMATION {
1383 ULONG MaximumRequestsPerPeriod;
1384 ULONG MinimumPeriod;
1385 ULONG MinimumTransferSize;
1386 } FILE_SFIO_VOLUME_INFORMATION, *PFILE_SFIO_VOLUME_INFORMATION;
1387
1388 #define FILE_SKIP_COMPLETION_PORT_ON_SUCCESS 0x1
1389 #define FILE_SKIP_SET_EVENT_ON_HANDLE 0x2
1390 #define FILE_SKIP_SET_USER_EVENT_ON_FAST_IO 0x4
1391
1392 #define FM_LOCK_BIT (0x1)
1393 #define FM_LOCK_BIT_V (0x0)
1394 #define FM_LOCK_WAITER_WOKEN (0x2)
1395 #define FM_LOCK_WAITER_INC (0x4)
1396
1397 typedef BOOLEAN
1398 (NTAPI FAST_IO_CHECK_IF_POSSIBLE)(
1399 IN struct _FILE_OBJECT *FileObject,
1400 IN PLARGE_INTEGER FileOffset,
1401 IN ULONG Length,
1402 IN BOOLEAN Wait,
1403 IN ULONG LockKey,
1404 IN BOOLEAN CheckForReadOperation,
1405 OUT PIO_STATUS_BLOCK IoStatus,
1406 IN struct _DEVICE_OBJECT *DeviceObject);
1407 typedef FAST_IO_CHECK_IF_POSSIBLE *PFAST_IO_CHECK_IF_POSSIBLE;
1408
1409 typedef BOOLEAN
1410 (NTAPI FAST_IO_READ)(
1411 IN struct _FILE_OBJECT *FileObject,
1412 IN PLARGE_INTEGER FileOffset,
1413 IN ULONG Length,
1414 IN BOOLEAN Wait,
1415 IN ULONG LockKey,
1416 OUT PVOID Buffer,
1417 OUT PIO_STATUS_BLOCK IoStatus,
1418 IN struct _DEVICE_OBJECT *DeviceObject);
1419 typedef FAST_IO_READ *PFAST_IO_READ;
1420
1421 typedef BOOLEAN
1422 (NTAPI FAST_IO_WRITE)(
1423 IN struct _FILE_OBJECT *FileObject,
1424 IN PLARGE_INTEGER FileOffset,
1425 IN ULONG Length,
1426 IN BOOLEAN Wait,
1427 IN ULONG LockKey,
1428 IN PVOID Buffer,
1429 OUT PIO_STATUS_BLOCK IoStatus,
1430 IN struct _DEVICE_OBJECT *DeviceObject);
1431 typedef FAST_IO_WRITE *PFAST_IO_WRITE;
1432
1433 typedef BOOLEAN
1434 (NTAPI FAST_IO_QUERY_BASIC_INFO)(
1435 IN struct _FILE_OBJECT *FileObject,
1436 IN BOOLEAN Wait,
1437 OUT PFILE_BASIC_INFORMATION Buffer,
1438 OUT PIO_STATUS_BLOCK IoStatus,
1439 IN struct _DEVICE_OBJECT *DeviceObject);
1440 typedef FAST_IO_QUERY_BASIC_INFO *PFAST_IO_QUERY_BASIC_INFO;
1441
1442 typedef BOOLEAN
1443 (NTAPI FAST_IO_QUERY_STANDARD_INFO)(
1444 IN struct _FILE_OBJECT *FileObject,
1445 IN BOOLEAN Wait,
1446 OUT PFILE_STANDARD_INFORMATION Buffer,
1447 OUT PIO_STATUS_BLOCK IoStatus,
1448 IN struct _DEVICE_OBJECT *DeviceObject);
1449 typedef FAST_IO_QUERY_STANDARD_INFO *PFAST_IO_QUERY_STANDARD_INFO;
1450
1451 typedef BOOLEAN
1452 (NTAPI FAST_IO_LOCK)(
1453 IN struct _FILE_OBJECT *FileObject,
1454 IN PLARGE_INTEGER FileOffset,
1455 IN PLARGE_INTEGER Length,
1456 PEPROCESS ProcessId,
1457 ULONG Key,
1458 BOOLEAN FailImmediately,
1459 BOOLEAN ExclusiveLock,
1460 OUT PIO_STATUS_BLOCK IoStatus,
1461 IN struct _DEVICE_OBJECT *DeviceObject);
1462 typedef FAST_IO_LOCK *PFAST_IO_LOCK;
1463
1464 typedef BOOLEAN
1465 (NTAPI FAST_IO_UNLOCK_SINGLE)(
1466 IN struct _FILE_OBJECT *FileObject,
1467 IN PLARGE_INTEGER FileOffset,
1468 IN PLARGE_INTEGER Length,
1469 PEPROCESS ProcessId,
1470 ULONG Key,
1471 OUT PIO_STATUS_BLOCK IoStatus,
1472 IN struct _DEVICE_OBJECT *DeviceObject);
1473 typedef FAST_IO_UNLOCK_SINGLE *PFAST_IO_UNLOCK_SINGLE;
1474
1475 typedef BOOLEAN
1476 (NTAPI FAST_IO_UNLOCK_ALL)(
1477 IN struct _FILE_OBJECT *FileObject,
1478 PEPROCESS ProcessId,
1479 OUT PIO_STATUS_BLOCK IoStatus,
1480 IN struct _DEVICE_OBJECT *DeviceObject);
1481 typedef FAST_IO_UNLOCK_ALL *PFAST_IO_UNLOCK_ALL;
1482
1483 typedef BOOLEAN
1484 (NTAPI FAST_IO_UNLOCK_ALL_BY_KEY)(
1485 IN struct _FILE_OBJECT *FileObject,
1486 PVOID ProcessId,
1487 ULONG Key,
1488 OUT PIO_STATUS_BLOCK IoStatus,
1489 IN struct _DEVICE_OBJECT *DeviceObject);
1490 typedef FAST_IO_UNLOCK_ALL_BY_KEY *PFAST_IO_UNLOCK_ALL_BY_KEY;
1491
1492 typedef BOOLEAN
1493 (NTAPI FAST_IO_DEVICE_CONTROL)(
1494 IN struct _FILE_OBJECT *FileObject,
1495 IN BOOLEAN Wait,
1496 IN PVOID InputBuffer OPTIONAL,
1497 IN ULONG InputBufferLength,
1498 OUT PVOID OutputBuffer OPTIONAL,
1499 IN ULONG OutputBufferLength,
1500 IN ULONG IoControlCode,
1501 OUT PIO_STATUS_BLOCK IoStatus,
1502 IN struct _DEVICE_OBJECT *DeviceObject);
1503 typedef FAST_IO_DEVICE_CONTROL *PFAST_IO_DEVICE_CONTROL;
1504
1505 typedef VOID
1506 (NTAPI FAST_IO_ACQUIRE_FILE)(
1507 IN struct _FILE_OBJECT *FileObject);
1508 typedef FAST_IO_ACQUIRE_FILE *PFAST_IO_ACQUIRE_FILE;
1509
1510 typedef VOID
1511 (NTAPI FAST_IO_RELEASE_FILE)(
1512 IN struct _FILE_OBJECT *FileObject);
1513 typedef FAST_IO_RELEASE_FILE *PFAST_IO_RELEASE_FILE;
1514
1515 typedef VOID
1516 (NTAPI FAST_IO_DETACH_DEVICE)(
1517 IN struct _DEVICE_OBJECT *SourceDevice,
1518 IN struct _DEVICE_OBJECT *TargetDevice);
1519 typedef FAST_IO_DETACH_DEVICE *PFAST_IO_DETACH_DEVICE;
1520
1521 typedef BOOLEAN
1522 (NTAPI FAST_IO_QUERY_NETWORK_OPEN_INFO)(
1523 IN struct _FILE_OBJECT *FileObject,
1524 IN BOOLEAN Wait,
1525 OUT struct _FILE_NETWORK_OPEN_INFORMATION *Buffer,
1526 OUT struct _IO_STATUS_BLOCK *IoStatus,
1527 IN struct _DEVICE_OBJECT *DeviceObject);
1528 typedef FAST_IO_QUERY_NETWORK_OPEN_INFO *PFAST_IO_QUERY_NETWORK_OPEN_INFO;
1529
1530 typedef NTSTATUS
1531 (NTAPI FAST_IO_ACQUIRE_FOR_MOD_WRITE)(
1532 IN struct _FILE_OBJECT *FileObject,
1533 IN PLARGE_INTEGER EndingOffset,
1534 OUT struct _ERESOURCE **ResourceToRelease,
1535 IN struct _DEVICE_OBJECT *DeviceObject);
1536 typedef FAST_IO_ACQUIRE_FOR_MOD_WRITE *PFAST_IO_ACQUIRE_FOR_MOD_WRITE;
1537
1538 typedef BOOLEAN
1539 (NTAPI FAST_IO_MDL_READ)(
1540 IN struct _FILE_OBJECT *FileObject,
1541 IN PLARGE_INTEGER FileOffset,
1542 IN ULONG Length,
1543 IN ULONG LockKey,
1544 OUT PMDL *MdlChain,
1545 OUT PIO_STATUS_BLOCK IoStatus,
1546 IN struct _DEVICE_OBJECT *DeviceObject);
1547 typedef FAST_IO_MDL_READ *PFAST_IO_MDL_READ;
1548
1549 typedef BOOLEAN
1550 (NTAPI FAST_IO_MDL_READ_COMPLETE)(
1551 IN struct _FILE_OBJECT *FileObject,
1552 IN PMDL MdlChain,
1553 IN struct _DEVICE_OBJECT *DeviceObject);
1554 typedef FAST_IO_MDL_READ_COMPLETE *PFAST_IO_MDL_READ_COMPLETE;
1555
1556 typedef BOOLEAN
1557 (NTAPI FAST_IO_PREPARE_MDL_WRITE)(
1558 IN struct _FILE_OBJECT *FileObject,
1559 IN PLARGE_INTEGER FileOffset,
1560 IN ULONG Length,
1561 IN ULONG LockKey,
1562 OUT PMDL *MdlChain,
1563 OUT PIO_STATUS_BLOCK IoStatus,
1564 IN struct _DEVICE_OBJECT *DeviceObject);
1565 typedef FAST_IO_PREPARE_MDL_WRITE *PFAST_IO_PREPARE_MDL_WRITE;
1566
1567 typedef BOOLEAN
1568 (NTAPI FAST_IO_MDL_WRITE_COMPLETE)(
1569 IN struct _FILE_OBJECT *FileObject,
1570 IN PLARGE_INTEGER FileOffset,
1571 IN PMDL MdlChain,
1572 IN struct _DEVICE_OBJECT *DeviceObject);
1573 typedef FAST_IO_MDL_WRITE_COMPLETE *PFAST_IO_MDL_WRITE_COMPLETE;
1574
1575 typedef BOOLEAN
1576 (NTAPI FAST_IO_READ_COMPRESSED)(
1577 IN struct _FILE_OBJECT *FileObject,
1578 IN PLARGE_INTEGER FileOffset,
1579 IN ULONG Length,
1580 IN ULONG LockKey,
1581 OUT PVOID Buffer,
1582 OUT PMDL *MdlChain,
1583 OUT PIO_STATUS_BLOCK IoStatus,
1584 OUT struct _COMPRESSED_DATA_INFO *CompressedDataInfo,
1585 IN ULONG CompressedDataInfoLength,
1586 IN struct _DEVICE_OBJECT *DeviceObject);
1587 typedef FAST_IO_READ_COMPRESSED *PFAST_IO_READ_COMPRESSED;
1588
1589 typedef BOOLEAN
1590 (NTAPI FAST_IO_WRITE_COMPRESSED)(
1591 IN struct _FILE_OBJECT *FileObject,
1592 IN PLARGE_INTEGER FileOffset,
1593 IN ULONG Length,
1594 IN ULONG LockKey,
1595 IN PVOID Buffer,
1596 OUT PMDL *MdlChain,
1597 OUT PIO_STATUS_BLOCK IoStatus,
1598 IN struct _COMPRESSED_DATA_INFO *CompressedDataInfo,
1599 IN ULONG CompressedDataInfoLength,
1600 IN struct _DEVICE_OBJECT *DeviceObject);
1601 typedef FAST_IO_WRITE_COMPRESSED *PFAST_IO_WRITE_COMPRESSED;
1602
1603 typedef BOOLEAN
1604 (NTAPI FAST_IO_MDL_READ_COMPLETE_COMPRESSED)(
1605 IN struct _FILE_OBJECT *FileObject,
1606 IN PMDL MdlChain,
1607 IN struct _DEVICE_OBJECT *DeviceObject);
1608 typedef FAST_IO_MDL_READ_COMPLETE_COMPRESSED *PFAST_IO_MDL_READ_COMPLETE_COMPRESSED;
1609
1610 typedef BOOLEAN
1611 (NTAPI FAST_IO_MDL_WRITE_COMPLETE_COMPRESSED)(
1612 IN struct _FILE_OBJECT *FileObject,
1613 IN PLARGE_INTEGER FileOffset,
1614 IN PMDL MdlChain,
1615 IN struct _DEVICE_OBJECT *DeviceObject);
1616 typedef FAST_IO_MDL_WRITE_COMPLETE_COMPRESSED *PFAST_IO_MDL_WRITE_COMPLETE_COMPRESSED;
1617
1618 typedef BOOLEAN
1619 (NTAPI FAST_IO_QUERY_OPEN)(
1620 IN struct _IRP *Irp,
1621 OUT PFILE_NETWORK_OPEN_INFORMATION NetworkInformation,
1622 IN struct _DEVICE_OBJECT *DeviceObject);
1623 typedef FAST_IO_QUERY_OPEN *PFAST_IO_QUERY_OPEN;
1624
1625 typedef NTSTATUS
1626 (NTAPI FAST_IO_RELEASE_FOR_MOD_WRITE)(
1627 IN struct _FILE_OBJECT *FileObject,
1628 IN struct _ERESOURCE *ResourceToRelease,
1629 IN struct _DEVICE_OBJECT *DeviceObject);
1630 typedef FAST_IO_RELEASE_FOR_MOD_WRITE *PFAST_IO_RELEASE_FOR_MOD_WRITE;
1631
1632 typedef NTSTATUS
1633 (NTAPI FAST_IO_ACQUIRE_FOR_CCFLUSH)(
1634 IN struct _FILE_OBJECT *FileObject,
1635 IN struct _DEVICE_OBJECT *DeviceObject);
1636 typedef FAST_IO_ACQUIRE_FOR_CCFLUSH *PFAST_IO_ACQUIRE_FOR_CCFLUSH;
1637
1638 typedef NTSTATUS
1639 (NTAPI FAST_IO_RELEASE_FOR_CCFLUSH)(
1640 IN struct _FILE_OBJECT *FileObject,
1641 IN struct _DEVICE_OBJECT *DeviceObject);
1642 typedef FAST_IO_RELEASE_FOR_CCFLUSH *PFAST_IO_RELEASE_FOR_CCFLUSH;
1643
1644 typedef struct _FAST_IO_DISPATCH {
1645 ULONG SizeOfFastIoDispatch;
1646 PFAST_IO_CHECK_IF_POSSIBLE FastIoCheckIfPossible;
1647 PFAST_IO_READ FastIoRead;
1648 PFAST_IO_WRITE FastIoWrite;
1649 PFAST_IO_QUERY_BASIC_INFO FastIoQueryBasicInfo;
1650 PFAST_IO_QUERY_STANDARD_INFO FastIoQueryStandardInfo;
1651 PFAST_IO_LOCK FastIoLock;
1652 PFAST_IO_UNLOCK_SINGLE FastIoUnlockSingle;
1653 PFAST_IO_UNLOCK_ALL FastIoUnlockAll;
1654 PFAST_IO_UNLOCK_ALL_BY_KEY FastIoUnlockAllByKey;
1655 PFAST_IO_DEVICE_CONTROL FastIoDeviceControl;
1656 PFAST_IO_ACQUIRE_FILE AcquireFileForNtCreateSection;
1657 PFAST_IO_RELEASE_FILE ReleaseFileForNtCreateSection;
1658 PFAST_IO_DETACH_DEVICE FastIoDetachDevice;
1659 PFAST_IO_QUERY_NETWORK_OPEN_INFO FastIoQueryNetworkOpenInfo;
1660 PFAST_IO_ACQUIRE_FOR_MOD_WRITE AcquireForModWrite;
1661 PFAST_IO_MDL_READ MdlRead;
1662 PFAST_IO_MDL_READ_COMPLETE MdlReadComplete;
1663 PFAST_IO_PREPARE_MDL_WRITE PrepareMdlWrite;
1664 PFAST_IO_MDL_WRITE_COMPLETE MdlWriteComplete;
1665 PFAST_IO_READ_COMPRESSED FastIoReadCompressed;
1666 PFAST_IO_WRITE_COMPRESSED FastIoWriteCompressed;
1667 PFAST_IO_MDL_READ_COMPLETE_COMPRESSED MdlReadCompleteCompressed;
1668 PFAST_IO_MDL_WRITE_COMPLETE_COMPRESSED MdlWriteCompleteCompressed;
1669 PFAST_IO_QUERY_OPEN FastIoQueryOpen;
1670 PFAST_IO_RELEASE_FOR_MOD_WRITE ReleaseForModWrite;
1671 PFAST_IO_ACQUIRE_FOR_CCFLUSH AcquireForCcFlush;
1672 PFAST_IO_RELEASE_FOR_CCFLUSH ReleaseForCcFlush;
1673 } FAST_IO_DISPATCH, *PFAST_IO_DISPATCH;
1674
1675 typedef struct _SECTION_OBJECT_POINTERS {
1676 PVOID DataSectionObject;
1677 PVOID SharedCacheMap;
1678 PVOID ImageSectionObject;
1679 } SECTION_OBJECT_POINTERS, *PSECTION_OBJECT_POINTERS;
1680
1681 typedef struct _IO_COMPLETION_CONTEXT {
1682 PVOID Port;
1683 PVOID Key;
1684 } IO_COMPLETION_CONTEXT, *PIO_COMPLETION_CONTEXT;
1685
1686 /* FILE_OBJECT.Flags */
1687 #define FO_FILE_OPEN 0x00000001
1688 #define FO_SYNCHRONOUS_IO 0x00000002
1689 #define FO_ALERTABLE_IO 0x00000004
1690 #define FO_NO_INTERMEDIATE_BUFFERING 0x00000008
1691 #define FO_WRITE_THROUGH 0x00000010
1692 #define FO_SEQUENTIAL_ONLY 0x00000020
1693 #define FO_CACHE_SUPPORTED 0x00000040
1694 #define FO_NAMED_PIPE 0x00000080
1695 #define FO_STREAM_FILE 0x00000100
1696 #define FO_MAILSLOT 0x00000200
1697 #define FO_GENERATE_AUDIT_ON_CLOSE 0x00000400
1698 #define FO_QUEUE_IRP_TO_THREAD 0x00000400
1699 #define FO_DIRECT_DEVICE_OPEN 0x00000800
1700 #define FO_FILE_MODIFIED 0x00001000
1701 #define FO_FILE_SIZE_CHANGED 0x00002000
1702 #define FO_CLEANUP_COMPLETE 0x00004000
1703 #define FO_TEMPORARY_FILE 0x00008000
1704 #define FO_DELETE_ON_CLOSE 0x00010000
1705 #define FO_OPENED_CASE_SENSITIVE 0x00020000
1706 #define FO_HANDLE_CREATED 0x00040000
1707 #define FO_FILE_FAST_IO_READ 0x00080000
1708 #define FO_RANDOM_ACCESS 0x00100000
1709 #define FO_FILE_OPEN_CANCELLED 0x00200000
1710 #define FO_VOLUME_OPEN 0x00400000
1711 #define FO_REMOTE_ORIGIN 0x01000000
1712 #define FO_DISALLOW_EXCLUSIVE 0x02000000
1713 #define FO_SKIP_COMPLETION_PORT 0x02000000
1714 #define FO_SKIP_SET_EVENT 0x04000000
1715 #define FO_SKIP_SET_FAST_IO 0x08000000
1716 #define FO_FLAGS_VALID_ONLY_DURING_CREATE FO_DISALLOW_EXCLUSIVE
1717
1718 /* VPB.Flags */
1719 #define VPB_MOUNTED 0x0001
1720 #define VPB_LOCKED 0x0002
1721 #define VPB_PERSISTENT 0x0004
1722 #define VPB_REMOVE_PENDING 0x0008
1723 #define VPB_RAW_MOUNT 0x0010
1724 #define VPB_DIRECT_WRITES_ALLOWED 0x0020
1725
1726 /* IRP.Flags */
1727
1728 #define SL_FORCE_ACCESS_CHECK 0x01
1729 #define SL_OPEN_PAGING_FILE 0x02
1730 #define SL_OPEN_TARGET_DIRECTORY 0x04
1731 #define SL_STOP_ON_SYMLINK 0x08
1732 #define SL_CASE_SENSITIVE 0x80
1733
1734 #define SL_KEY_SPECIFIED 0x01
1735 #define SL_OVERRIDE_VERIFY_VOLUME 0x02
1736 #define SL_WRITE_THROUGH 0x04
1737 #define SL_FT_SEQUENTIAL_WRITE 0x08
1738 #define SL_FORCE_DIRECT_WRITE 0x10
1739 #define SL_REALTIME_STREAM 0x20
1740
1741 #define SL_READ_ACCESS_GRANTED 0x01
1742 #define SL_WRITE_ACCESS_GRANTED 0x04
1743
1744 #define SL_FAIL_IMMEDIATELY 0x01
1745 #define SL_EXCLUSIVE_LOCK 0x02
1746
1747 #define SL_RESTART_SCAN 0x01
1748 #define SL_RETURN_SINGLE_ENTRY 0x02
1749 #define SL_INDEX_SPECIFIED 0x04
1750
1751 #define SL_WATCH_TREE 0x01
1752
1753 #define SL_ALLOW_RAW_MOUNT 0x01
1754
1755 #define CTL_CODE(DeviceType, Function, Method, Access) \
1756 (((DeviceType) << 16) | ((Access) << 14) | ((Function) << 2) | (Method))
1757
1758 #define DEVICE_TYPE_FROM_CTL_CODE(ctl) (((ULONG) (ctl & 0xffff0000)) >> 16)
1759
1760 #define METHOD_FROM_CTL_CODE(ctrlCode) ((ULONG)(ctrlCode & 3))
1761
1762 #define IRP_NOCACHE 0x00000001
1763 #define IRP_PAGING_IO 0x00000002
1764 #define IRP_MOUNT_COMPLETION 0x00000002
1765 #define IRP_SYNCHRONOUS_API 0x00000004
1766 #define IRP_ASSOCIATED_IRP 0x00000008
1767 #define IRP_BUFFERED_IO 0x00000010
1768 #define IRP_DEALLOCATE_BUFFER 0x00000020
1769 #define IRP_INPUT_OPERATION 0x00000040
1770 #define IRP_SYNCHRONOUS_PAGING_IO 0x00000040
1771 #define IRP_CREATE_OPERATION 0x00000080
1772 #define IRP_READ_OPERATION 0x00000100
1773 #define IRP_WRITE_OPERATION 0x00000200
1774 #define IRP_CLOSE_OPERATION 0x00000400
1775 #define IRP_DEFER_IO_COMPLETION 0x00000800
1776 #define IRP_OB_QUERY_NAME 0x00001000
1777 #define IRP_HOLD_DEVICE_QUEUE 0x00002000
1778
1779 #define IRP_QUOTA_CHARGED 0x01
1780 #define IRP_ALLOCATED_MUST_SUCCEED 0x02
1781 #define IRP_ALLOCATED_FIXED_SIZE 0x04
1782 #define IRP_LOOKASIDE_ALLOCATION 0x08
1783
1784 /*
1785 ** IRP function codes
1786 */
1787
1788 #define IRP_MJ_CREATE 0x00
1789 #define IRP_MJ_CREATE_NAMED_PIPE 0x01
1790 #define IRP_MJ_CLOSE 0x02
1791 #define IRP_MJ_READ 0x03
1792 #define IRP_MJ_WRITE 0x04
1793 #define IRP_MJ_QUERY_INFORMATION 0x05
1794 #define IRP_MJ_SET_INFORMATION 0x06
1795 #define IRP_MJ_QUERY_EA 0x07
1796 #define IRP_MJ_SET_EA 0x08
1797 #define IRP_MJ_FLUSH_BUFFERS 0x09
1798 #define IRP_MJ_QUERY_VOLUME_INFORMATION 0x0a
1799 #define IRP_MJ_SET_VOLUME_INFORMATION 0x0b
1800 #define IRP_MJ_DIRECTORY_CONTROL 0x0c
1801 #define IRP_MJ_FILE_SYSTEM_CONTROL 0x0d
1802 #define IRP_MJ_DEVICE_CONTROL 0x0e
1803 #define IRP_MJ_INTERNAL_DEVICE_CONTROL 0x0f
1804 #define IRP_MJ_SCSI 0x0f
1805 #define IRP_MJ_SHUTDOWN 0x10
1806 #define IRP_MJ_LOCK_CONTROL 0x11
1807 #define IRP_MJ_CLEANUP 0x12
1808 #define IRP_MJ_CREATE_MAILSLOT 0x13
1809 #define IRP_MJ_QUERY_SECURITY 0x14
1810 #define IRP_MJ_SET_SECURITY 0x15
1811 #define IRP_MJ_POWER 0x16
1812 #define IRP_MJ_SYSTEM_CONTROL 0x17
1813 #define IRP_MJ_DEVICE_CHANGE 0x18
1814 #define IRP_MJ_QUERY_QUOTA 0x19
1815 #define IRP_MJ_SET_QUOTA 0x1a
1816 #define IRP_MJ_PNP 0x1b
1817 #define IRP_MJ_PNP_POWER 0x1b
1818 #define IRP_MJ_MAXIMUM_FUNCTION 0x1b
1819
1820 #define IRP_MN_SCSI_CLASS 0x01
1821
1822 #define IRP_MN_START_DEVICE 0x00
1823 #define IRP_MN_QUERY_REMOVE_DEVICE 0x01
1824 #define IRP_MN_REMOVE_DEVICE 0x02
1825 #define IRP_MN_CANCEL_REMOVE_DEVICE 0x03
1826 #define IRP_MN_STOP_DEVICE 0x04
1827 #define IRP_MN_QUERY_STOP_DEVICE 0x05
1828 #define IRP_MN_CANCEL_STOP_DEVICE 0x06
1829
1830 #define IRP_MN_QUERY_DEVICE_RELATIONS 0x07
1831 #define IRP_MN_QUERY_INTERFACE 0x08
1832 #define IRP_MN_QUERY_CAPABILITIES 0x09
1833 #define IRP_MN_QUERY_RESOURCES 0x0A
1834 #define IRP_MN_QUERY_RESOURCE_REQUIREMENTS 0x0B
1835 #define IRP_MN_QUERY_DEVICE_TEXT 0x0C
1836 #define IRP_MN_FILTER_RESOURCE_REQUIREMENTS 0x0D
1837
1838 #define IRP_MN_READ_CONFIG 0x0F
1839 #define IRP_MN_WRITE_CONFIG 0x10
1840 #define IRP_MN_EJECT 0x11
1841 #define IRP_MN_SET_LOCK 0x12
1842 #define IRP_MN_QUERY_ID 0x13
1843 #define IRP_MN_QUERY_PNP_DEVICE_STATE 0x14
1844 #define IRP_MN_QUERY_BUS_INFORMATION 0x15
1845 #define IRP_MN_DEVICE_USAGE_NOTIFICATION 0x16
1846 #define IRP_MN_SURPRISE_REMOVAL 0x17
1847 #if (NTDDI_VERSION >= NTDDI_WIN7)
1848 #define IRP_MN_DEVICE_ENUMERATED 0x19
1849 #endif
1850
1851 #define IRP_MN_WAIT_WAKE 0x00
1852 #define IRP_MN_POWER_SEQUENCE 0x01
1853 #define IRP_MN_SET_POWER 0x02
1854 #define IRP_MN_QUERY_POWER 0x03
1855
1856 #define IRP_MN_QUERY_ALL_DATA 0x00
1857 #define IRP_MN_QUERY_SINGLE_INSTANCE 0x01
1858 #define IRP_MN_CHANGE_SINGLE_INSTANCE 0x02
1859 #define IRP_MN_CHANGE_SINGLE_ITEM 0x03
1860 #define IRP_MN_ENABLE_EVENTS 0x04
1861 #define IRP_MN_DISABLE_EVENTS 0x05
1862 #define IRP_MN_ENABLE_COLLECTION 0x06
1863 #define IRP_MN_DISABLE_COLLECTION 0x07
1864 #define IRP_MN_REGINFO 0x08
1865 #define IRP_MN_EXECUTE_METHOD 0x09
1866
1867 #define IRP_MN_REGINFO_EX 0x0b
1868
1869 typedef struct _FILE_OBJECT {
1870 CSHORT Type;
1871 CSHORT Size;
1872 PDEVICE_OBJECT DeviceObject;
1873 PVPB Vpb;
1874 PVOID FsContext;
1875 PVOID FsContext2;
1876 PSECTION_OBJECT_POINTERS SectionObjectPointer;
1877 PVOID PrivateCacheMap;
1878 NTSTATUS FinalStatus;
1879 struct _FILE_OBJECT *RelatedFileObject;
1880 BOOLEAN LockOperation;
1881 BOOLEAN DeletePending;
1882 BOOLEAN ReadAccess;
1883 BOOLEAN WriteAccess;
1884 BOOLEAN DeleteAccess;
1885 BOOLEAN SharedRead;
1886 BOOLEAN SharedWrite;
1887 BOOLEAN SharedDelete;
1888 ULONG Flags;
1889 UNICODE_STRING FileName;
1890 LARGE_INTEGER CurrentByteOffset;
1891 volatile ULONG Waiters;
1892 volatile ULONG Busy;
1893 PVOID LastLock;
1894 KEVENT Lock;
1895 KEVENT Event;
1896 volatile PIO_COMPLETION_CONTEXT CompletionContext;
1897 KSPIN_LOCK IrpListLock;
1898 LIST_ENTRY IrpList;
1899 volatile PVOID FileObjectExtension;
1900 } FILE_OBJECT, *PFILE_OBJECT;
1901
1902 typedef struct _IO_ERROR_LOG_PACKET {
1903 UCHAR MajorFunctionCode;
1904 UCHAR RetryCount;
1905 USHORT DumpDataSize;
1906 USHORT NumberOfStrings;
1907 USHORT StringOffset;
1908 USHORT EventCategory;
1909 NTSTATUS ErrorCode;
1910 ULONG UniqueErrorValue;
1911 NTSTATUS FinalStatus;
1912 ULONG SequenceNumber;
1913 ULONG IoControlCode;
1914 LARGE_INTEGER DeviceOffset;
1915 ULONG DumpData[1];
1916 } IO_ERROR_LOG_PACKET, *PIO_ERROR_LOG_PACKET;
1917
1918 typedef struct _IO_ERROR_LOG_MESSAGE {
1919 USHORT Type;
1920 USHORT Size;
1921 USHORT DriverNameLength;
1922 LARGE_INTEGER TimeStamp;
1923 ULONG DriverNameOffset;
1924 IO_ERROR_LOG_PACKET EntryData;
1925 } IO_ERROR_LOG_MESSAGE, *PIO_ERROR_LOG_MESSAGE;
1926
1927 #define ERROR_LOG_LIMIT_SIZE 240
1928 #define IO_ERROR_LOG_MESSAGE_HEADER_LENGTH (sizeof(IO_ERROR_LOG_MESSAGE) - \
1929 sizeof(IO_ERROR_LOG_PACKET) + \
1930 (sizeof(WCHAR) * 40))
1931 #define ERROR_LOG_MESSAGE_LIMIT_SIZE \
1932 (ERROR_LOG_LIMIT_SIZE + IO_ERROR_LOG_MESSAGE_HEADER_LENGTH)
1933 #define IO_ERROR_LOG_MESSAGE_LENGTH \
1934 ((PORT_MAXIMUM_MESSAGE_LENGTH > ERROR_LOG_MESSAGE_LIMIT_SIZE) ? \
1935 ERROR_LOG_MESSAGE_LIMIT_SIZE : \
1936 PORT_MAXIMUM_MESSAGE_LENGTH)
1937 #define ERROR_LOG_MAXIMUM_SIZE (IO_ERROR_LOG_MESSAGE_LENGTH - \
1938 IO_ERROR_LOG_MESSAGE_HEADER_LENGTH)
1939
1940 #ifdef _WIN64
1941 #define PORT_MAXIMUM_MESSAGE_LENGTH 512
1942 #else
1943 #define PORT_MAXIMUM_MESSAGE_LENGTH 256
1944 #endif
1945
1946 typedef enum _DMA_WIDTH {
1947 Width8Bits,
1948 Width16Bits,
1949 Width32Bits,
1950 MaximumDmaWidth
1951 } DMA_WIDTH, *PDMA_WIDTH;
1952
1953 typedef enum _DMA_SPEED {
1954 Compatible,
1955 TypeA,
1956 TypeB,
1957 TypeC,
1958 TypeF,
1959 MaximumDmaSpeed
1960 } DMA_SPEED, *PDMA_SPEED;
1961
1962 /* DEVICE_DESCRIPTION.Version */
1963
1964 #define DEVICE_DESCRIPTION_VERSION 0x0000
1965 #define DEVICE_DESCRIPTION_VERSION1 0x0001
1966 #define DEVICE_DESCRIPTION_VERSION2 0x0002
1967
1968 typedef struct _DEVICE_DESCRIPTION {
1969 ULONG Version;
1970 BOOLEAN Master;
1971 BOOLEAN ScatterGather;
1972 BOOLEAN DemandMode;
1973 BOOLEAN AutoInitialize;
1974 BOOLEAN Dma32BitAddresses;
1975 BOOLEAN IgnoreCount;
1976 BOOLEAN Reserved1;
1977 BOOLEAN Dma64BitAddresses;
1978 ULONG BusNumber;
1979 ULONG DmaChannel;
1980 INTERFACE_TYPE InterfaceType;
1981 DMA_WIDTH DmaWidth;
1982 DMA_SPEED DmaSpeed;
1983 ULONG MaximumLength;
1984 ULONG DmaPort;
1985 } DEVICE_DESCRIPTION, *PDEVICE_DESCRIPTION;
1986
1987 typedef enum _DEVICE_RELATION_TYPE {
1988 BusRelations,
1989 EjectionRelations,
1990 PowerRelations,
1991 RemovalRelations,
1992 TargetDeviceRelation,
1993 SingleBusRelations,
1994 TransportRelations
1995 } DEVICE_RELATION_TYPE, *PDEVICE_RELATION_TYPE;
1996
1997 typedef struct _DEVICE_RELATIONS {
1998 ULONG Count;
1999 PDEVICE_OBJECT Objects[1];
2000 } DEVICE_RELATIONS, *PDEVICE_RELATIONS;
2001
2002 typedef struct _DEVOBJ_EXTENSION {
2003 CSHORT Type;
2004 USHORT Size;
2005 PDEVICE_OBJECT DeviceObject;
2006 } DEVOBJ_EXTENSION, *PDEVOBJ_EXTENSION;
2007
2008 typedef struct _SCATTER_GATHER_ELEMENT {
2009 PHYSICAL_ADDRESS Address;
2010 ULONG Length;
2011 ULONG_PTR Reserved;
2012 } SCATTER_GATHER_ELEMENT, *PSCATTER_GATHER_ELEMENT;
2013
2014 #if defined(_MSC_EXTENSIONS)
2015
2016 #if _MSC_VER >= 1200
2017 #pragma warning(push)
2018 #endif
2019 #pragma warning(disable:4200)
2020 typedef struct _SCATTER_GATHER_LIST {
2021 ULONG NumberOfElements;
2022 ULONG_PTR Reserved;
2023 SCATTER_GATHER_ELEMENT Elements[1];
2024 } SCATTER_GATHER_LIST, *PSCATTER_GATHER_LIST;
2025
2026 #if _MSC_VER >= 1200
2027 #pragma warning(pop)
2028 #else
2029 #pragma warning(default:4200)
2030 #endif
2031
2032 #else
2033
2034 struct _SCATTER_GATHER_LIST;
2035 typedef struct _SCATTER_GATHER_LIST SCATTER_GATHER_LIST, *PSCATTER_GATHER_LIST;
2036
2037 #endif
2038
2039 typedef NTSTATUS
2040 (NTAPI DRIVER_ADD_DEVICE)(
2041 IN struct _DRIVER_OBJECT *DriverObject,
2042 IN struct _DEVICE_OBJECT *PhysicalDeviceObject);
2043 typedef DRIVER_ADD_DEVICE *PDRIVER_ADD_DEVICE;
2044
2045 typedef struct _DRIVER_EXTENSION {
2046 struct _DRIVER_OBJECT *DriverObject;
2047 PDRIVER_ADD_DEVICE AddDevice;
2048 ULONG Count;
2049 UNICODE_STRING ServiceKeyName;
2050 } DRIVER_EXTENSION, *PDRIVER_EXTENSION;
2051
2052 #define DRVO_UNLOAD_INVOKED 0x00000001
2053 #define DRVO_LEGACY_DRIVER 0x00000002
2054 #define DRVO_BUILTIN_DRIVER 0x00000004
2055
2056 typedef NTSTATUS
2057 (NTAPI DRIVER_INITIALIZE)(
2058 IN struct _DRIVER_OBJECT *DriverObject,
2059 IN PUNICODE_STRING RegistryPath);
2060 typedef DRIVER_INITIALIZE *PDRIVER_INITIALIZE;
2061
2062 typedef VOID
2063 (NTAPI DRIVER_STARTIO)(
2064 IN struct _DEVICE_OBJECT *DeviceObject,
2065 IN struct _IRP *Irp);
2066 typedef DRIVER_STARTIO *PDRIVER_STARTIO;
2067
2068 typedef VOID
2069 (NTAPI DRIVER_UNLOAD)(
2070 IN struct _DRIVER_OBJECT *DriverObject);
2071 typedef DRIVER_UNLOAD *PDRIVER_UNLOAD;
2072
2073 typedef NTSTATUS
2074 (NTAPI DRIVER_DISPATCH)(
2075 IN struct _DEVICE_OBJECT *DeviceObject,
2076 IN struct _IRP *Irp);
2077 typedef DRIVER_DISPATCH *PDRIVER_DISPATCH;
2078
2079 typedef struct _DRIVER_OBJECT {
2080 CSHORT Type;
2081 CSHORT Size;
2082 PDEVICE_OBJECT DeviceObject;
2083 ULONG Flags;
2084 PVOID DriverStart;
2085 ULONG DriverSize;
2086 PVOID DriverSection;
2087 PDRIVER_EXTENSION DriverExtension;
2088 UNICODE_STRING DriverName;
2089 PUNICODE_STRING HardwareDatabase;
2090 struct _FAST_IO_DISPATCH *FastIoDispatch;
2091 PDRIVER_INITIALIZE DriverInit;
2092 PDRIVER_STARTIO DriverStartIo;
2093 PDRIVER_UNLOAD DriverUnload;
2094 PDRIVER_DISPATCH MajorFunction[IRP_MJ_MAXIMUM_FUNCTION + 1];
2095 } DRIVER_OBJECT, *PDRIVER_OBJECT;
2096
2097 typedef struct _DMA_ADAPTER {
2098 USHORT Version;
2099 USHORT Size;
2100 struct _DMA_OPERATIONS* DmaOperations;
2101 } DMA_ADAPTER, *PDMA_ADAPTER;
2102
2103 typedef VOID
2104 (NTAPI *PPUT_DMA_ADAPTER)(
2105 IN PDMA_ADAPTER DmaAdapter);
2106
2107 typedef PVOID
2108 (NTAPI *PALLOCATE_COMMON_BUFFER)(
2109 IN PDMA_ADAPTER DmaAdapter,
2110 IN ULONG Length,
2111 OUT PPHYSICAL_ADDRESS LogicalAddress,
2112 IN BOOLEAN CacheEnabled);
2113
2114 typedef VOID
2115 (NTAPI *PFREE_COMMON_BUFFER)(
2116 IN PDMA_ADAPTER DmaAdapter,
2117 IN ULONG Length,
2118 IN PHYSICAL_ADDRESS LogicalAddress,
2119 IN PVOID VirtualAddress,
2120 IN BOOLEAN CacheEnabled);
2121
2122 typedef NTSTATUS
2123 (NTAPI *PALLOCATE_ADAPTER_CHANNEL)(
2124 IN PDMA_ADAPTER DmaAdapter,
2125 IN PDEVICE_OBJECT DeviceObject,
2126 IN ULONG NumberOfMapRegisters,
2127 IN PDRIVER_CONTROL ExecutionRoutine,
2128 IN PVOID Context);
2129
2130 typedef BOOLEAN
2131 (NTAPI *PFLUSH_ADAPTER_BUFFERS)(
2132 IN PDMA_ADAPTER DmaAdapter,
2133 IN PMDL Mdl,
2134 IN PVOID MapRegisterBase,
2135 IN PVOID CurrentVa,
2136 IN ULONG Length,
2137 IN BOOLEAN WriteToDevice);
2138
2139 typedef VOID
2140 (NTAPI *PFREE_ADAPTER_CHANNEL)(
2141 IN PDMA_ADAPTER DmaAdapter);
2142
2143 typedef VOID
2144 (NTAPI *PFREE_MAP_REGISTERS)(
2145 IN PDMA_ADAPTER DmaAdapter,
2146 PVOID MapRegisterBase,
2147 ULONG NumberOfMapRegisters);
2148
2149 typedef PHYSICAL_ADDRESS
2150 (NTAPI *PMAP_TRANSFER)(
2151 IN PDMA_ADAPTER DmaAdapter,
2152 IN PMDL Mdl,
2153 IN PVOID MapRegisterBase,
2154 IN PVOID CurrentVa,
2155 IN OUT PULONG Length,
2156 IN BOOLEAN WriteToDevice);
2157
2158 typedef ULONG
2159 (NTAPI *PGET_DMA_ALIGNMENT)(
2160 IN PDMA_ADAPTER DmaAdapter);
2161
2162 typedef ULONG
2163 (NTAPI *PREAD_DMA_COUNTER)(
2164 IN PDMA_ADAPTER DmaAdapter);
2165
2166 typedef VOID
2167 (NTAPI DRIVER_LIST_CONTROL)(
2168 IN struct _DEVICE_OBJECT *DeviceObject,
2169 IN struct _IRP *Irp,
2170 IN struct _SCATTER_GATHER_LIST *ScatterGather,
2171 IN PVOID Context);
2172 typedef DRIVER_LIST_CONTROL *PDRIVER_LIST_CONTROL;
2173
2174 typedef NTSTATUS
2175 (NTAPI *PGET_SCATTER_GATHER_LIST)(
2176 IN PDMA_ADAPTER DmaAdapter,
2177 IN PDEVICE_OBJECT DeviceObject,
2178 IN PMDL Mdl,
2179 IN PVOID CurrentVa,
2180 IN ULONG Length,
2181 IN PDRIVER_LIST_CONTROL ExecutionRoutine,
2182 IN PVOID Context,
2183 IN BOOLEAN WriteToDevice);
2184
2185 typedef VOID
2186 (NTAPI *PPUT_SCATTER_GATHER_LIST)(
2187 IN PDMA_ADAPTER DmaAdapter,
2188 IN PSCATTER_GATHER_LIST ScatterGather,
2189 IN BOOLEAN WriteToDevice);
2190
2191 typedef NTSTATUS
2192 (NTAPI *PCALCULATE_SCATTER_GATHER_LIST_SIZE)(
2193 IN PDMA_ADAPTER DmaAdapter,
2194 IN PMDL Mdl OPTIONAL,
2195 IN PVOID CurrentVa,
2196 IN ULONG Length,
2197 OUT PULONG ScatterGatherListSize,
2198 OUT PULONG pNumberOfMapRegisters OPTIONAL);
2199
2200 typedef NTSTATUS
2201 (NTAPI *PBUILD_SCATTER_GATHER_LIST)(
2202 IN PDMA_ADAPTER DmaAdapter,
2203 IN PDEVICE_OBJECT DeviceObject,
2204 IN PMDL Mdl,
2205 IN PVOID CurrentVa,
2206 IN ULONG Length,
2207 IN PDRIVER_LIST_CONTROL ExecutionRoutine,
2208 IN PVOID Context,
2209 IN BOOLEAN WriteToDevice,
2210 IN PVOID ScatterGatherBuffer,
2211 IN ULONG ScatterGatherLength);
2212
2213 typedef NTSTATUS
2214 (NTAPI *PBUILD_MDL_FROM_SCATTER_GATHER_LIST)(
2215 IN PDMA_ADAPTER DmaAdapter,
2216 IN PSCATTER_GATHER_LIST ScatterGather,
2217 IN PMDL OriginalMdl,
2218 OUT PMDL *TargetMdl);
2219
2220 typedef struct _DMA_OPERATIONS {
2221 ULONG Size;
2222 PPUT_DMA_ADAPTER PutDmaAdapter;
2223 PALLOCATE_COMMON_BUFFER AllocateCommonBuffer;
2224 PFREE_COMMON_BUFFER FreeCommonBuffer;
2225 PALLOCATE_ADAPTER_CHANNEL AllocateAdapterChannel;
2226 PFLUSH_ADAPTER_BUFFERS FlushAdapterBuffers;
2227 PFREE_ADAPTER_CHANNEL FreeAdapterChannel;
2228 PFREE_MAP_REGISTERS FreeMapRegisters;
2229 PMAP_TRANSFER MapTransfer;
2230 PGET_DMA_ALIGNMENT GetDmaAlignment;
2231 PREAD_DMA_COUNTER ReadDmaCounter;
2232 PGET_SCATTER_GATHER_LIST GetScatterGatherList;
2233 PPUT_SCATTER_GATHER_LIST PutScatterGatherList;
2234 PCALCULATE_SCATTER_GATHER_LIST_SIZE CalculateScatterGatherList;
2235 PBUILD_SCATTER_GATHER_LIST BuildScatterGatherList;
2236 PBUILD_MDL_FROM_SCATTER_GATHER_LIST BuildMdlFromScatterGatherList;
2237 } DMA_OPERATIONS, *PDMA_OPERATIONS;
2238
2239 typedef struct _IO_RESOURCE_DESCRIPTOR {
2240 UCHAR Option;
2241 UCHAR Type;
2242 UCHAR ShareDisposition;
2243 UCHAR Spare1;
2244 USHORT Flags;
2245 USHORT Spare2;
2246 union {
2247 struct {
2248 ULONG Length;
2249 ULONG Alignment;
2250 PHYSICAL_ADDRESS MinimumAddress;
2251 PHYSICAL_ADDRESS MaximumAddress;
2252 } Port;
2253 struct {
2254 ULONG Length;
2255 ULONG Alignment;
2256 PHYSICAL_ADDRESS MinimumAddress;
2257 PHYSICAL_ADDRESS MaximumAddress;
2258 } Memory;
2259 struct {
2260 ULONG MinimumVector;
2261 ULONG MaximumVector;
2262 } Interrupt;
2263 struct {
2264 ULONG MinimumChannel;
2265 ULONG MaximumChannel;
2266 } Dma;
2267 struct {
2268 ULONG Length;
2269 ULONG Alignment;
2270 PHYSICAL_ADDRESS MinimumAddress;
2271 PHYSICAL_ADDRESS MaximumAddress;
2272 } Generic;
2273 struct {
2274 ULONG Data[3];
2275 } DevicePrivate;
2276 struct {
2277 ULONG Length;
2278 ULONG MinBusNumber;
2279 ULONG MaxBusNumber;
2280 ULONG Reserved;
2281 } BusNumber;
2282 struct {
2283 ULONG Priority;
2284 ULONG Reserved1;
2285 ULONG Reserved2;
2286 } ConfigData;
2287 } u;
2288 } IO_RESOURCE_DESCRIPTOR, *PIO_RESOURCE_DESCRIPTOR;
2289
2290 typedef struct _IO_RESOURCE_LIST {
2291 USHORT Version;
2292 USHORT Revision;
2293 ULONG Count;
2294 IO_RESOURCE_DESCRIPTOR Descriptors[1];
2295 } IO_RESOURCE_LIST, *PIO_RESOURCE_LIST;
2296
2297 typedef struct _IO_RESOURCE_REQUIREMENTS_LIST {
2298 ULONG ListSize;
2299 INTERFACE_TYPE InterfaceType;
2300 ULONG BusNumber;
2301 ULONG SlotNumber;
2302 ULONG Reserved[3];
2303 ULONG AlternativeLists;
2304 IO_RESOURCE_LIST List[1];
2305 } IO_RESOURCE_REQUIREMENTS_LIST, *PIO_RESOURCE_REQUIREMENTS_LIST;
2306
2307 typedef VOID
2308 (NTAPI DRIVER_CANCEL)(
2309 IN struct _DEVICE_OBJECT *DeviceObject,
2310 IN struct _IRP *Irp);
2311 typedef DRIVER_CANCEL *PDRIVER_CANCEL;
2312
2313 typedef struct _IRP {
2314 CSHORT Type;
2315 USHORT Size;
2316 struct _MDL *MdlAddress;
2317 ULONG Flags;
2318 union {
2319 struct _IRP *MasterIrp;
2320 volatile LONG IrpCount;
2321 PVOID SystemBuffer;
2322 } AssociatedIrp;
2323 LIST_ENTRY ThreadListEntry;
2324 IO_STATUS_BLOCK IoStatus;
2325 KPROCESSOR_MODE RequestorMode;
2326 BOOLEAN PendingReturned;
2327 CHAR StackCount;
2328 CHAR CurrentLocation;
2329 BOOLEAN Cancel;
2330 KIRQL CancelIrql;
2331 CCHAR ApcEnvironment;
2332 UCHAR AllocationFlags;
2333 PIO_STATUS_BLOCK UserIosb;
2334 PKEVENT UserEvent;
2335 union {
2336 struct {
2337 _ANONYMOUS_UNION union {
2338 PIO_APC_ROUTINE UserApcRoutine;
2339 PVOID IssuingProcess;
2340 } DUMMYUNIONNAME;
2341 PVOID UserApcContext;
2342 } AsynchronousParameters;
2343 LARGE_INTEGER AllocationSize;
2344 } Overlay;
2345 volatile PDRIVER_CANCEL CancelRoutine;
2346 PVOID UserBuffer;
2347 union {
2348 struct {
2349 _ANONYMOUS_UNION union {
2350 KDEVICE_QUEUE_ENTRY DeviceQueueEntry;
2351 _ANONYMOUS_STRUCT struct {
2352 PVOID DriverContext[4];
2353 } DUMMYSTRUCTNAME;
2354 } DUMMYUNIONNAME;
2355 PETHREAD Thread;
2356 PCHAR AuxiliaryBuffer;
2357 _ANONYMOUS_STRUCT struct {
2358 LIST_ENTRY ListEntry;
2359 _ANONYMOUS_UNION union {
2360 struct _IO_STACK_LOCATION *CurrentStackLocation;
2361 ULONG PacketType;
2362 } DUMMYUNIONNAME;
2363 } DUMMYSTRUCTNAME;
2364 struct _FILE_OBJECT *OriginalFileObject;
2365 } Overlay;
2366 KAPC Apc;
2367 PVOID CompletionKey;
2368 } Tail;
2369 } IRP, *PIRP;
2370
2371 typedef enum _IO_PAGING_PRIORITY {
2372 IoPagingPriorityInvalid,
2373 IoPagingPriorityNormal,
2374 IoPagingPriorityHigh,
2375 IoPagingPriorityReserved1,
2376 IoPagingPriorityReserved2
2377 } IO_PAGING_PRIORITY;
2378
2379 typedef NTSTATUS
2380 (NTAPI IO_COMPLETION_ROUTINE)(
2381 IN struct _DEVICE_OBJECT *DeviceObject,
2382 IN struct _IRP *Irp,
2383 IN PVOID Context);
2384 typedef IO_COMPLETION_ROUTINE *PIO_COMPLETION_ROUTINE;
2385
2386 typedef VOID
2387 (NTAPI IO_DPC_ROUTINE)(
2388 IN struct _KDPC *Dpc,
2389 IN struct _DEVICE_OBJECT *DeviceObject,
2390 IN struct _IRP *Irp,
2391 IN PVOID Context);
2392 typedef IO_DPC_ROUTINE *PIO_DPC_ROUTINE;
2393
2394 typedef NTSTATUS
2395 (NTAPI *PMM_DLL_INITIALIZE)(
2396 IN PUNICODE_STRING RegistryPath);
2397
2398 typedef NTSTATUS
2399 (NTAPI *PMM_DLL_UNLOAD)(
2400 VOID);
2401
2402 typedef VOID
2403 (NTAPI IO_TIMER_ROUTINE)(
2404 IN struct _DEVICE_OBJECT *DeviceObject,
2405 IN PVOID Context);
2406 typedef IO_TIMER_ROUTINE *PIO_TIMER_ROUTINE;
2407
2408 typedef struct _IO_SECURITY_CONTEXT {
2409 PSECURITY_QUALITY_OF_SERVICE SecurityQos;
2410 PACCESS_STATE AccessState;
2411 ACCESS_MASK DesiredAccess;
2412 ULONG FullCreateOptions;
2413 } IO_SECURITY_CONTEXT, *PIO_SECURITY_CONTEXT;
2414
2415 struct _IO_CSQ;
2416
2417 typedef struct _IO_CSQ_IRP_CONTEXT {
2418 ULONG Type;
2419 struct _IRP *Irp;
2420 struct _IO_CSQ *Csq;
2421 } IO_CSQ_IRP_CONTEXT, *PIO_CSQ_IRP_CONTEXT;
2422
2423 typedef VOID
2424 (NTAPI *PIO_CSQ_INSERT_IRP)(
2425 IN struct _IO_CSQ *Csq,
2426 IN PIRP Irp);
2427
2428 typedef NTSTATUS
2429 (NTAPI IO_CSQ_INSERT_IRP_EX)(
2430 IN struct _IO_CSQ *Csq,
2431 IN PIRP Irp,
2432 IN PVOID InsertContext);
2433 typedef IO_CSQ_INSERT_IRP_EX *PIO_CSQ_INSERT_IRP_EX;
2434
2435 typedef VOID
2436 (NTAPI *PIO_CSQ_REMOVE_IRP)(
2437 IN struct _IO_CSQ *Csq,
2438 IN PIRP Irp);
2439
2440 typedef PIRP
2441 (NTAPI *PIO_CSQ_PEEK_NEXT_IRP)(
2442 IN struct _IO_CSQ *Csq,
2443 IN PIRP Irp,
2444 IN PVOID PeekContext);
2445
2446 typedef VOID
2447 (NTAPI *PIO_CSQ_ACQUIRE_LOCK)(
2448 IN struct _IO_CSQ *Csq,
2449 OUT PKIRQL Irql);
2450
2451 typedef VOID
2452 (NTAPI *PIO_CSQ_RELEASE_LOCK)(
2453 IN struct _IO_CSQ *Csq,
2454 IN KIRQL Irql);
2455
2456 typedef VOID
2457 (NTAPI *PIO_CSQ_COMPLETE_CANCELED_IRP)(
2458 IN struct _IO_CSQ *Csq,
2459 IN PIRP Irp);
2460
2461 typedef struct _IO_CSQ {
2462 ULONG Type;
2463 PIO_CSQ_INSERT_IRP CsqInsertIrp;
2464 PIO_CSQ_REMOVE_IRP CsqRemoveIrp;
2465 PIO_CSQ_PEEK_NEXT_IRP CsqPeekNextIrp;
2466 PIO_CSQ_ACQUIRE_LOCK CsqAcquireLock;
2467 PIO_CSQ_RELEASE_LOCK CsqReleaseLock;
2468 PIO_CSQ_COMPLETE_CANCELED_IRP CsqCompleteCanceledIrp;
2469 PVOID ReservePointer;
2470 } IO_CSQ, *PIO_CSQ;
2471
2472 typedef enum _BUS_QUERY_ID_TYPE {
2473 BusQueryDeviceID,
2474 BusQueryHardwareIDs,
2475 BusQueryCompatibleIDs,
2476 BusQueryInstanceID,
2477 BusQueryDeviceSerialNumber
2478 } BUS_QUERY_ID_TYPE, *PBUS_QUERY_ID_TYPE;
2479
2480 typedef enum _DEVICE_TEXT_TYPE {
2481 DeviceTextDescription,
2482 DeviceTextLocationInformation
2483 } DEVICE_TEXT_TYPE, *PDEVICE_TEXT_TYPE;
2484
2485 typedef BOOLEAN
2486 (NTAPI *PGPE_SERVICE_ROUTINE)(
2487 PVOID,
2488 PVOID);
2489
2490 typedef NTSTATUS
2491 (NTAPI *PGPE_CONNECT_VECTOR)(
2492 PDEVICE_OBJECT,
2493 ULONG,
2494 KINTERRUPT_MODE,
2495 BOOLEAN,
2496 PGPE_SERVICE_ROUTINE,
2497 PVOID,
2498 PVOID);
2499
2500 typedef NTSTATUS
2501 (NTAPI *PGPE_DISCONNECT_VECTOR)(
2502 PVOID);
2503
2504 typedef NTSTATUS
2505 (NTAPI *PGPE_ENABLE_EVENT)(
2506 PDEVICE_OBJECT,
2507 PVOID);
2508
2509 typedef NTSTATUS
2510 (NTAPI *PGPE_DISABLE_EVENT)(
2511 PDEVICE_OBJECT,
2512 PVOID);
2513
2514 typedef NTSTATUS
2515 (NTAPI *PGPE_CLEAR_STATUS)(
2516 PDEVICE_OBJECT,
2517 PVOID);
2518
2519 typedef VOID
2520 (NTAPI *PDEVICE_NOTIFY_CALLBACK)(
2521 PVOID,
2522 ULONG);
2523
2524 typedef NTSTATUS
2525 (NTAPI *PREGISTER_FOR_DEVICE_NOTIFICATIONS)(
2526 PDEVICE_OBJECT,
2527 PDEVICE_NOTIFY_CALLBACK,
2528 PVOID);
2529
2530 typedef VOID
2531 (NTAPI *PUNREGISTER_FOR_DEVICE_NOTIFICATIONS)(
2532 PDEVICE_OBJECT,
2533 PDEVICE_NOTIFY_CALLBACK);
2534
2535 typedef struct _ACPI_INTERFACE_STANDARD {
2536 USHORT Size;
2537 USHORT Version;
2538 PVOID Context;
2539 PINTERFACE_REFERENCE InterfaceReference;
2540 PINTERFACE_DEREFERENCE InterfaceDereference;
2541 PGPE_CONNECT_VECTOR GpeConnectVector;
2542 PGPE_DISCONNECT_VECTOR GpeDisconnectVector;
2543 PGPE_ENABLE_EVENT GpeEnableEvent;
2544 PGPE_DISABLE_EVENT GpeDisableEvent;
2545 PGPE_CLEAR_STATUS GpeClearStatus;
2546 PREGISTER_FOR_DEVICE_NOTIFICATIONS RegisterForDeviceNotifications;
2547 PUNREGISTER_FOR_DEVICE_NOTIFICATIONS UnregisterForDeviceNotifications;
2548 } ACPI_INTERFACE_STANDARD, *PACPI_INTERFACE_STANDARD;
2549
2550 typedef BOOLEAN
2551 (NTAPI *PGPE_SERVICE_ROUTINE2)(
2552 PVOID ObjectContext,
2553 PVOID ServiceContext);
2554
2555 typedef NTSTATUS
2556 (NTAPI *PGPE_CONNECT_VECTOR2)(
2557 PVOID Context,
2558 ULONG GpeNumber,
2559 KINTERRUPT_MODE Mode,
2560 BOOLEAN Shareable,
2561 PGPE_SERVICE_ROUTINE2 ServiceRoutine,
2562 PVOID ServiceContext,
2563 PVOID *ObjectContext);
2564
2565 typedef NTSTATUS
2566 (NTAPI *PGPE_DISCONNECT_VECTOR2)(
2567 PVOID Context,
2568 PVOID ObjectContext);
2569
2570 typedef NTSTATUS
2571 (NTAPI *PGPE_ENABLE_EVENT2)(
2572 PVOID Context,
2573 PVOID ObjectContext);
2574
2575 typedef NTSTATUS
2576 (NTAPI *PGPE_DISABLE_EVENT2)(
2577 PVOID Context,
2578 PVOID ObjectContext);
2579
2580 typedef NTSTATUS
2581 (NTAPI *PGPE_CLEAR_STATUS2)(
2582 PVOID Context,
2583 PVOID ObjectContext);
2584
2585 typedef VOID
2586 (NTAPI *PDEVICE_NOTIFY_CALLBACK2)(
2587 PVOID NotificationContext,
2588 ULONG NotifyCode);
2589
2590 typedef NTSTATUS
2591 (NTAPI *PREGISTER_FOR_DEVICE_NOTIFICATIONS2)(
2592 PVOID Context,
2593 PDEVICE_NOTIFY_CALLBACK2 NotificationHandler,
2594 PVOID NotificationContext);
2595
2596 typedef VOID
2597 (NTAPI *PUNREGISTER_FOR_DEVICE_NOTIFICATIONS2)(
2598 PVOID Context);
2599
2600 typedef struct _ACPI_INTERFACE_STANDARD2 {
2601 USHORT Size;
2602 USHORT Version;
2603 PVOID Context;
2604 PINTERFACE_REFERENCE InterfaceReference;
2605 PINTERFACE_DEREFERENCE InterfaceDereference;
2606 PGPE_CONNECT_VECTOR2 GpeConnectVector;
2607 PGPE_DISCONNECT_VECTOR2 GpeDisconnectVector;
2608 PGPE_ENABLE_EVENT2 GpeEnableEvent;
2609 PGPE_DISABLE_EVENT2 GpeDisableEvent;
2610 PGPE_CLEAR_STATUS2 GpeClearStatus;
2611 PREGISTER_FOR_DEVICE_NOTIFICATIONS2 RegisterForDeviceNotifications;
2612 PUNREGISTER_FOR_DEVICE_NOTIFICATIONS2 UnregisterForDeviceNotifications;
2613 } ACPI_INTERFACE_STANDARD2, *PACPI_INTERFACE_STANDARD2;
2614
2615 #if !defined(_AMD64_) && !defined(_IA64_)
2616 #include <pshpack4.h>
2617 #endif
2618 typedef struct _IO_STACK_LOCATION {
2619 UCHAR MajorFunction;
2620 UCHAR MinorFunction;
2621 UCHAR Flags;
2622 UCHAR Control;
2623 union {
2624 struct {
2625 PIO_SECURITY_CONTEXT SecurityContext;
2626 ULONG Options;
2627 USHORT POINTER_ALIGNMENT FileAttributes;
2628 USHORT ShareAccess;
2629 ULONG POINTER_ALIGNMENT EaLength;
2630 } Create;
2631 struct {
2632 ULONG Length;
2633 ULONG POINTER_ALIGNMENT Key;
2634 LARGE_INTEGER ByteOffset;
2635 } Read;
2636 struct {
2637 ULONG Length;
2638 ULONG POINTER_ALIGNMENT Key;
2639 LARGE_INTEGER ByteOffset;
2640 } Write;
2641 struct {
2642 ULONG Length;
2643 PUNICODE_STRING FileName;
2644 FILE_INFORMATION_CLASS FileInformationClass;
2645 ULONG FileIndex;
2646 } QueryDirectory;
2647 struct {
2648 ULONG Length;
2649 ULONG CompletionFilter;
2650 } NotifyDirectory;
2651 struct {
2652 ULONG Length;
2653 FILE_INFORMATION_CLASS POINTER_ALIGNMENT FileInformationClass;
2654 } QueryFile;
2655 struct {
2656 ULONG Length;
2657 FILE_INFORMATION_CLASS POINTER_ALIGNMENT FileInformationClass;
2658 PFILE_OBJECT FileObject;
2659 _ANONYMOUS_UNION union {
2660 _ANONYMOUS_STRUCT struct {
2661 BOOLEAN ReplaceIfExists;
2662 BOOLEAN AdvanceOnly;
2663 } DUMMYSTRUCTNAME;
2664 ULONG ClusterCount;
2665 HANDLE DeleteHandle;
2666 } DUMMYUNIONNAME;
2667 } SetFile;
2668 struct {
2669 ULONG Length;
2670 PVOID EaList;
2671 ULONG EaListLength;
2672 ULONG EaIndex;
2673 } QueryEa;
2674 struct {
2675 ULONG Length;
2676 } SetEa;
2677 struct {
2678 ULONG Length;
2679 FS_INFORMATION_CLASS POINTER_ALIGNMENT FsInformationClass;
2680 } QueryVolume;
2681 struct {
2682 ULONG Length;
2683 FS_INFORMATION_CLASS FsInformationClass;
2684 } SetVolume;
2685 struct {
2686 ULONG OutputBufferLength;
2687 ULONG InputBufferLength;
2688 ULONG FsControlCode;
2689 PVOID Type3InputBuffer;
2690 } FileSystemControl;
2691 struct {
2692 PLARGE_INTEGER Length;
2693 ULONG Key;
2694 LARGE_INTEGER ByteOffset;
2695 } LockControl;
2696 struct {
2697 ULONG OutputBufferLength;
2698 ULONG POINTER_ALIGNMENT InputBufferLength;
2699 ULONG POINTER_ALIGNMENT IoControlCode;
2700 PVOID Type3InputBuffer;
2701 } DeviceIoControl;
2702 struct {
2703 SECURITY_INFORMATION SecurityInformation;
2704 ULONG POINTER_ALIGNMENT Length;
2705 } QuerySecurity;
2706 struct {
2707 SECURITY_INFORMATION SecurityInformation;
2708 PSECURITY_DESCRIPTOR SecurityDescriptor;
2709 } SetSecurity;
2710 struct {
2711 PVPB Vpb;
2712 PDEVICE_OBJECT DeviceObject;
2713 } MountVolume;
2714 struct {
2715 PVPB Vpb;
2716 PDEVICE_OBJECT DeviceObject;
2717 } VerifyVolume;
2718 struct {
2719 struct _SCSI_REQUEST_BLOCK *Srb;
2720 } Scsi;
2721 struct {
2722 ULONG Length;
2723 PSID StartSid;
2724 struct _FILE_GET_QUOTA_INFORMATION *SidList;
2725 ULONG SidListLength;
2726 } QueryQuota;
2727 struct {
2728 ULONG Length;
2729 } SetQuota;
2730 struct {
2731 DEVICE_RELATION_TYPE Type;
2732 } QueryDeviceRelations;
2733 struct {
2734 CONST GUID *InterfaceType;
2735 USHORT Size;
2736 USHORT Version;
2737 PINTERFACE Interface;
2738 PVOID InterfaceSpecificData;
2739 } QueryInterface;
2740 struct {
2741 PDEVICE_CAPABILITIES Capabilities;
2742 } DeviceCapabilities;
2743 struct {
2744 PIO_RESOURCE_REQUIREMENTS_LIST IoResourceRequirementList;
2745 } FilterResourceRequirements;
2746 struct {
2747 ULONG WhichSpace;
2748 PVOID Buffer;
2749 ULONG Offset;
2750 ULONG POINTER_ALIGNMENT Length;
2751 } ReadWriteConfig;
2752 struct {
2753 BOOLEAN Lock;
2754 } SetLock;
2755 struct {
2756 BUS_QUERY_ID_TYPE IdType;
2757 } QueryId;
2758 struct {
2759 DEVICE_TEXT_TYPE DeviceTextType;
2760 LCID POINTER_ALIGNMENT LocaleId;
2761 } QueryDeviceText;
2762 struct {
2763 BOOLEAN InPath;
2764 BOOLEAN Reserved[3];
2765 DEVICE_USAGE_NOTIFICATION_TYPE POINTER_ALIGNMENT Type;
2766 } UsageNotification;
2767 struct {
2768 SYSTEM_POWER_STATE PowerState;
2769 } WaitWake;
2770 struct {
2771 PPOWER_SEQUENCE PowerSequence;
2772 } PowerSequence;
2773 struct {
2774 ULONG SystemContext;
2775 POWER_STATE_TYPE POINTER_ALIGNMENT Type;
2776 POWER_STATE POINTER_ALIGNMENT State;
2777 POWER_ACTION POINTER_ALIGNMENT ShutdownType;
2778 } Power;
2779 struct {
2780 PCM_RESOURCE_LIST AllocatedResources;
2781 PCM_RESOURCE_LIST AllocatedResourcesTranslated;
2782 } StartDevice;
2783 struct {
2784 ULONG_PTR ProviderId;
2785 PVOID DataPath;
2786 ULONG BufferSize;
2787 PVOID Buffer;
2788 } WMI;
2789 struct {
2790 PVOID Argument1;
2791 PVOID Argument2;
2792 PVOID Argument3;
2793 PVOID Argument4;
2794 } Others;
2795 } Parameters;
2796 PDEVICE_OBJECT DeviceObject;
2797 PFILE_OBJECT FileObject;
2798 PIO_COMPLETION_ROUTINE CompletionRoutine;
2799 PVOID Context;
2800 } IO_STACK_LOCATION, *PIO_STACK_LOCATION;
2801 #if !defined(_AMD64_) && !defined(_IA64_)
2802 #include <poppack.h>
2803 #endif
2804
2805 /* IO_STACK_LOCATION.Control */
2806
2807 #define SL_PENDING_RETURNED 0x01
2808 #define SL_ERROR_RETURNED 0x02
2809 #define SL_INVOKE_ON_CANCEL 0x20
2810 #define SL_INVOKE_ON_SUCCESS 0x40
2811 #define SL_INVOKE_ON_ERROR 0x80
2812
2813 #define METHOD_BUFFERED 0
2814 #define METHOD_IN_DIRECT 1
2815 #define METHOD_OUT_DIRECT 2
2816 #define METHOD_NEITHER 3
2817
2818 #define METHOD_DIRECT_TO_HARDWARE METHOD_IN_DIRECT
2819 #define METHOD_DIRECT_FROM_HARDWARE METHOD_OUT_DIRECT
2820
2821 #define FILE_SUPERSEDED 0x00000000
2822 #define FILE_OPENED 0x00000001
2823 #define FILE_CREATED 0x00000002
2824 #define FILE_OVERWRITTEN 0x00000003
2825 #define FILE_EXISTS 0x00000004
2826 #define FILE_DOES_NOT_EXIST 0x00000005
2827
2828 #define FILE_USE_FILE_POINTER_POSITION 0xfffffffe
2829 #define FILE_WRITE_TO_END_OF_FILE 0xffffffff
2830
2831 /* also in winnt.h */
2832 #define FILE_LIST_DIRECTORY 0x00000001
2833 #define FILE_READ_DATA 0x00000001
2834 #define FILE_ADD_FILE 0x00000002
2835 #define FILE_WRITE_DATA 0x00000002
2836 #define FILE_ADD_SUBDIRECTORY 0x00000004
2837 #define FILE_APPEND_DATA 0x00000004
2838 #define FILE_CREATE_PIPE_INSTANCE 0x00000004
2839 #define FILE_READ_EA 0x00000008
2840 #define FILE_WRITE_EA 0x00000010
2841 #define FILE_EXECUTE 0x00000020
2842 #define FILE_TRAVERSE 0x00000020
2843 #define FILE_DELETE_CHILD 0x00000040
2844 #define FILE_READ_ATTRIBUTES 0x00000080
2845 #define FILE_WRITE_ATTRIBUTES 0x00000100
2846
2847 #define FILE_SHARE_READ 0x00000001
2848 #define FILE_SHARE_WRITE 0x00000002
2849 #define FILE_SHARE_DELETE 0x00000004
2850 #define FILE_SHARE_VALID_FLAGS 0x00000007
2851
2852 #define FILE_ATTRIBUTE_READONLY 0x00000001
2853 #define FILE_ATTRIBUTE_HIDDEN 0x00000002
2854 #define FILE_ATTRIBUTE_SYSTEM 0x00000004
2855 #define FILE_ATTRIBUTE_DIRECTORY 0x00000010
2856 #define FILE_ATTRIBUTE_ARCHIVE 0x00000020
2857 #define FILE_ATTRIBUTE_DEVICE 0x00000040
2858 #define FILE_ATTRIBUTE_NORMAL 0x00000080
2859 #define FILE_ATTRIBUTE_TEMPORARY 0x00000100
2860 #define FILE_ATTRIBUTE_SPARSE_FILE 0x00000200
2861 #define FILE_ATTRIBUTE_REPARSE_POINT 0x00000400
2862 #define FILE_ATTRIBUTE_COMPRESSED 0x00000800
2863 #define FILE_ATTRIBUTE_OFFLINE 0x00001000
2864 #define FILE_ATTRIBUTE_NOT_CONTENT_INDEXED 0x00002000
2865 #define FILE_ATTRIBUTE_ENCRYPTED 0x00004000
2866 #define FILE_ATTRIBUTE_VIRTUAL 0x00010000
2867
2868 #define FILE_ATTRIBUTE_VALID_FLAGS 0x00007fb7
2869 #define FILE_ATTRIBUTE_VALID_SET_FLAGS 0x000031a7
2870
2871 #define FILE_VALID_OPTION_FLAGS 0x00ffffff
2872 #define FILE_VALID_PIPE_OPTION_FLAGS 0x00000032
2873 #define FILE_VALID_MAILSLOT_OPTION_FLAGS 0x00000032
2874 #define FILE_VALID_SET_FLAGS 0x00000036
2875
2876 #define FILE_SUPERSEDE 0x00000000
2877 #define FILE_OPEN 0x00000001
2878 #define FILE_CREATE 0x00000002
2879 #define FILE_OPEN_IF 0x00000003
2880 #define FILE_OVERWRITE 0x00000004
2881 #define FILE_OVERWRITE_IF 0x00000005
2882 #define FILE_MAXIMUM_DISPOSITION 0x00000005
2883
2884 #define FILE_DIRECTORY_FILE 0x00000001
2885 #define FILE_WRITE_THROUGH 0x00000002
2886 #define FILE_SEQUENTIAL_ONLY 0x00000004
2887 #define FILE_NO_INTERMEDIATE_BUFFERING 0x00000008
2888 #define FILE_SYNCHRONOUS_IO_ALERT 0x00000010
2889 #define FILE_SYNCHRONOUS_IO_NONALERT 0x00000020
2890 #define FILE_NON_DIRECTORY_FILE 0x00000040
2891 #define FILE_CREATE_TREE_CONNECTION 0x00000080
2892 #define FILE_COMPLETE_IF_OPLOCKED 0x00000100
2893 #define FILE_NO_EA_KNOWLEDGE 0x00000200
2894 #define FILE_OPEN_REMOTE_INSTANCE 0x00000400
2895 #define FILE_RANDOM_ACCESS 0x00000800
2896 #define FILE_DELETE_ON_CLOSE 0x00001000
2897 #define FILE_OPEN_BY_FILE_ID 0x00002000
2898 #define FILE_OPEN_FOR_BACKUP_INTENT 0x00004000
2899 #define FILE_NO_COMPRESSION 0x00008000
2900 #if (NTDDI_VERSION >= NTDDI_WIN7)
2901 #define FILE_OPEN_REQUIRING_OPLOCK 0x00010000
2902 #define FILE_DISALLOW_EXCLUSIVE 0x00020000
2903 #endif /* (NTDDI_VERSION >= NTDDI_WIN7) */
2904 #define FILE_RESERVE_OPFILTER 0x00100000
2905 #define FILE_OPEN_REPARSE_POINT 0x00200000
2906 #define FILE_OPEN_NO_RECALL 0x00400000
2907 #define FILE_OPEN_FOR_FREE_SPACE_QUERY 0x00800000
2908
2909 #define FILE_ANY_ACCESS 0x00000000
2910 #define FILE_SPECIAL_ACCESS FILE_ANY_ACCESS
2911 #define FILE_READ_ACCESS 0x00000001
2912 #define FILE_WRITE_ACCESS 0x00000002
2913
2914 #define FILE_ALL_ACCESS \
2915 (STANDARD_RIGHTS_REQUIRED | \
2916 SYNCHRONIZE | \
2917 0x1FF)
2918
2919 #define FILE_GENERIC_EXECUTE \
2920 (STANDARD_RIGHTS_EXECUTE | \
2921 FILE_READ_ATTRIBUTES | \
2922 FILE_EXECUTE | \
2923 SYNCHRONIZE)
2924
2925 #define FILE_GENERIC_READ \
2926 (STANDARD_RIGHTS_READ | \
2927 FILE_READ_DATA | \
2928 FILE_READ_ATTRIBUTES | \
2929 FILE_READ_EA | \
2930 SYNCHRONIZE)
2931
2932 #define FILE_GENERIC_WRITE \
2933 (STANDARD_RIGHTS_WRITE | \
2934 FILE_WRITE_DATA | \
2935 FILE_WRITE_ATTRIBUTES | \
2936 FILE_WRITE_EA | \
2937 FILE_APPEND_DATA | \
2938 SYNCHRONIZE)
2939
2940 /* end winnt.h */
2941
2942 #define WMIREG_ACTION_REGISTER 1
2943 #define WMIREG_ACTION_DEREGISTER 2
2944 #define WMIREG_ACTION_REREGISTER 3
2945 #define WMIREG_ACTION_UPDATE_GUIDS 4
2946 #define WMIREG_ACTION_BLOCK_IRPS 5
2947
2948 #define WMIREGISTER 0
2949 #define WMIUPDATE 1
2950
2951 typedef VOID
2952 (NTAPI FWMI_NOTIFICATION_CALLBACK)(
2953 PVOID Wnode,
2954 PVOID Context);
2955 typedef FWMI_NOTIFICATION_CALLBACK *WMI_NOTIFICATION_CALLBACK;
2956
2957 #ifndef _PCI_X_
2958 #define _PCI_X_
2959
2960 typedef struct _PCI_SLOT_NUMBER {
2961 union {
2962 struct {
2963 ULONG DeviceNumber:5;
2964 ULONG FunctionNumber:3;
2965 ULONG Reserved:24;
2966 } bits;
2967 ULONG AsULONG;
2968 } u;
2969 } PCI_SLOT_NUMBER, *PPCI_SLOT_NUMBER;
2970
2971 #define PCI_TYPE0_ADDRESSES 6
2972 #define PCI_TYPE1_ADDRESSES 2
2973 #define PCI_TYPE2_ADDRESSES 5
2974
2975 typedef struct _PCI_COMMON_HEADER {
2976 PCI_COMMON_HEADER_LAYOUT
2977 } PCI_COMMON_HEADER, *PPCI_COMMON_HEADER;
2978
2979 #ifdef __cplusplus
2980 typedef struct _PCI_COMMON_CONFIG {
2981 PCI_COMMON_HEADER_LAYOUT
2982 UCHAR DeviceSpecific[192];
2983 } PCI_COMMON_CONFIG, *PPCI_COMMON_CONFIG;
2984 #else
2985 typedef struct _PCI_COMMON_CONFIG {
2986 PCI_COMMON_HEADER DUMMYSTRUCTNAME;
2987 UCHAR DeviceSpecific[192];
2988 } PCI_COMMON_CONFIG, *PPCI_COMMON_CONFIG;
2989 #endif
2990
2991 #define PCI_COMMON_HDR_LENGTH (FIELD_OFFSET(PCI_COMMON_CONFIG, DeviceSpecific))
2992
2993 #define PCI_EXTENDED_CONFIG_LENGTH 0x1000
2994
2995 #define PCI_MAX_DEVICES 32
2996 #define PCI_MAX_FUNCTION 8
2997 #define PCI_MAX_BRIDGE_NUMBER 0xFF
2998 #define PCI_INVALID_VENDORID 0xFFFF
2999
3000 /* PCI_COMMON_CONFIG.HeaderType */
3001 #define PCI_MULTIFUNCTION 0x80
3002 #define PCI_DEVICE_TYPE 0x00
3003 #define PCI_BRIDGE_TYPE 0x01
3004 #define PCI_CARDBUS_BRIDGE_TYPE 0x02
3005
3006 #define PCI_CONFIGURATION_TYPE(PciData) \
3007 (((PPCI_COMMON_CONFIG) (PciData))->HeaderType & ~PCI_MULTIFUNCTION)
3008
3009 #define PCI_MULTIFUNCTION_DEVICE(PciData) \
3010 ((((PPCI_COMMON_CONFIG) (PciData))->HeaderType & PCI_MULTIFUNCTION) != 0)
3011
3012 /* PCI_COMMON_CONFIG.Command */
3013 #define PCI_ENABLE_IO_SPACE 0x0001
3014 #define PCI_ENABLE_MEMORY_SPACE 0x0002
3015 #define PCI_ENABLE_BUS_MASTER 0x0004
3016 #define PCI_ENABLE_SPECIAL_CYCLES 0x0008
3017 #define PCI_ENABLE_WRITE_AND_INVALIDATE 0x0010
3018 #define PCI_ENABLE_VGA_COMPATIBLE_PALETTE 0x0020
3019 #define PCI_ENABLE_PARITY 0x0040
3020 #define PCI_ENABLE_WAIT_CYCLE 0x0080
3021 #define PCI_ENABLE_SERR 0x0100
3022 #define PCI_ENABLE_FAST_BACK_TO_BACK 0x0200
3023 #define PCI_DISABLE_LEVEL_INTERRUPT 0x0400
3024
3025 /* PCI_COMMON_CONFIG.Status */
3026 #define PCI_STATUS_INTERRUPT_PENDING 0x0008
3027 #define PCI_STATUS_CAPABILITIES_LIST 0x0010
3028 #define PCI_STATUS_66MHZ_CAPABLE 0x0020
3029 #define PCI_STATUS_UDF_SUPPORTED 0x0040
3030 #define PCI_STATUS_FAST_BACK_TO_BACK 0x0080
3031 #define PCI_STATUS_DATA_PARITY_DETECTED 0x0100
3032 #define PCI_STATUS_DEVSEL 0x0600
3033 #define PCI_STATUS_SIGNALED_TARGET_ABORT 0x0800
3034 #define PCI_STATUS_RECEIVED_TARGET_ABORT 0x1000
3035 #define PCI_STATUS_RECEIVED_MASTER_ABORT 0x2000
3036 #define PCI_STATUS_SIGNALED_SYSTEM_ERROR 0x4000
3037 #define PCI_STATUS_DETECTED_PARITY_ERROR 0x8000
3038
3039 /* IO_STACK_LOCATION.Parameters.ReadWriteControl.WhichSpace */
3040
3041 #define PCI_WHICHSPACE_CONFIG 0x0
3042 #define PCI_WHICHSPACE_ROM 0x52696350 /* 'PciR' */
3043
3044 #define PCI_CAPABILITY_ID_POWER_MANAGEMENT 0x01
3045 #define PCI_CAPABILITY_ID_AGP 0x02
3046 #define PCI_CAPABILITY_ID_VPD 0x03
3047 #define PCI_CAPABILITY_ID_SLOT_ID 0x04
3048 #define PCI_CAPABILITY_ID_MSI 0x05
3049 #define PCI_CAPABILITY_ID_CPCI_HOTSWAP 0x06
3050 #define PCI_CAPABILITY_ID_PCIX 0x07
3051 #define PCI_CAPABILITY_ID_HYPERTRANSPORT 0x08
3052 #define PCI_CAPABILITY_ID_VENDOR_SPECIFIC 0x09
3053 #define PCI_CAPABILITY_ID_DEBUG_PORT 0x0A
3054 #define PCI_CAPABILITY_ID_CPCI_RES_CTRL 0x0B
3055 #define PCI_CAPABILITY_ID_SHPC 0x0C
3056 #define PCI_CAPABILITY_ID_P2P_SSID 0x0D
3057 #define PCI_CAPABILITY_ID_AGP_TARGET 0x0E
3058 #define PCI_CAPABILITY_ID_SECURE 0x0F
3059 #define PCI_CAPABILITY_ID_PCI_EXPRESS 0x10
3060 #define PCI_CAPABILITY_ID_MSIX 0x11
3061
3062 typedef struct _PCI_CAPABILITIES_HEADER {
3063 UCHAR CapabilityID;
3064 UCHAR Next;
3065 } PCI_CAPABILITIES_HEADER, *PPCI_CAPABILITIES_HEADER;
3066
3067 typedef struct _PCI_PMC {
3068 UCHAR Version:3;
3069 UCHAR PMEClock:1;
3070 UCHAR Rsvd1:1;
3071 UCHAR DeviceSpecificInitialization:1;
3072 UCHAR Rsvd2:2;
3073 struct _PM_SUPPORT {
3074 UCHAR Rsvd2:1;
3075 UCHAR D1:1;
3076 UCHAR D2:1;
3077 UCHAR PMED0:1;
3078 UCHAR PMED1:1;
3079 UCHAR PMED2:1;
3080 UCHAR PMED3Hot:1;
3081 UCHAR PMED3Cold:1;
3082 } Support;
3083 } PCI_PMC, *PPCI_PMC;
3084
3085 typedef struct _PCI_PMCSR {
3086 USHORT PowerState:2;
3087 USHORT Rsvd1:6;
3088 USHORT PMEEnable:1;
3089 USHORT DataSelect:4;
3090 USHORT DataScale:2;
3091 USHORT PMEStatus:1;
3092 } PCI_PMCSR, *PPCI_PMCSR;
3093
3094 typedef struct _PCI_PMCSR_BSE {
3095 UCHAR Rsvd1:6;
3096 UCHAR D3HotSupportsStopClock:1;
3097 UCHAR BusPowerClockControlEnabled:1;
3098 } PCI_PMCSR_BSE, *PPCI_PMCSR_BSE;
3099
3100 typedef struct _PCI_PM_CAPABILITY {
3101 PCI_CAPABILITIES_HEADER Header;
3102 union {
3103 PCI_PMC Capabilities;
3104 USHORT AsUSHORT;
3105 } PMC;
3106 union {
3107 PCI_PMCSR ControlStatus;
3108 USHORT AsUSHORT;
3109 } PMCSR;
3110 union {
3111 PCI_PMCSR_BSE BridgeSupport;
3112 UCHAR AsUCHAR;
3113 } PMCSR_BSE;
3114 UCHAR Data;
3115 } PCI_PM_CAPABILITY, *PPCI_PM_CAPABILITY;
3116
3117 typedef struct {
3118 PCI_CAPABILITIES_HEADER Header;
3119 union {
3120 struct {
3121 USHORT DataParityErrorRecoveryEnable:1;
3122 USHORT EnableRelaxedOrdering:1;
3123 USHORT MaxMemoryReadByteCount:2;
3124 USHORT MaxOutstandingSplitTransactions:3;
3125 USHORT Reserved:9;
3126 } bits;
3127 USHORT AsUSHORT;
3128 } Command;
3129 union {
3130 struct {
3131 ULONG FunctionNumber:3;
3132 ULONG DeviceNumber:5;
3133 ULONG BusNumber:8;
3134 ULONG Device64Bit:1;
3135 ULONG Capable133MHz:1;
3136 ULONG SplitCompletionDiscarded:1;
3137 ULONG UnexpectedSplitCompletion:1;
3138 ULONG DeviceComplexity:1;
3139 ULONG DesignedMaxMemoryReadByteCount:2;
3140 ULONG DesignedMaxOutstandingSplitTransactions:3;
3141 ULONG DesignedMaxCumulativeReadSize:3;
3142 ULONG ReceivedSplitCompletionErrorMessage:1;
3143 ULONG CapablePCIX266:1;
3144 ULONG CapablePCIX533:1;
3145 } bits;
3146 ULONG AsULONG;
3147 } Status;
3148 } PCI_X_CAPABILITY, *PPCI_X_CAPABILITY;
3149
3150 #define PCI_EXPRESS_ADVANCED_ERROR_REPORTING_CAP_ID 0x0001
3151 #define PCI_EXPRESS_VIRTUAL_CHANNEL_CAP_ID 0x0002
3152 #define PCI_EXPRESS_DEVICE_SERIAL_NUMBER_CAP_ID 0x0003
3153 #define PCI_EXPRESS_POWER_BUDGETING_CAP_ID 0x0004
3154 #define PCI_EXPRESS_RC_LINK_DECLARATION_CAP_ID 0x0005
3155 #define PCI_EXPRESS_RC_INTERNAL_LINK_CONTROL_CAP_ID 0x0006
3156 #define PCI_EXPRESS_RC_EVENT_COLLECTOR_ENDPOINT_ASSOCIATION_CAP_ID 0x0007
3157 #define PCI_EXPRESS_MFVC_CAP_ID 0x0008
3158 #define PCI_EXPRESS_VC_AND_MFVC_CAP_ID 0x0009
3159 #define PCI_EXPRESS_RCRB_HEADER_CAP_ID 0x000A
3160 #define PCI_EXPRESS_SINGLE_ROOT_IO_VIRTUALIZATION_CAP_ID 0x0010
3161
3162 typedef struct _PCI_EXPRESS_ENHANCED_CAPABILITY_HEADER {
3163 USHORT CapabilityID;
3164 USHORT Version:4;
3165 USHORT Next:12;
3166 } PCI_EXPRESS_ENHANCED_CAPABILITY_HEADER, *PPCI_EXPRESS_ENHANCED_CAPABILITY_HEADER;
3167
3168 typedef struct _PCI_EXPRESS_SERIAL_NUMBER_CAPABILITY {
3169 PCI_EXPRESS_ENHANCED_CAPABILITY_HEADER Header;
3170 ULONG LowSerialNumber;
3171 ULONG HighSerialNumber;
3172 } PCI_EXPRESS_SERIAL_NUMBER_CAPABILITY, *PPCI_EXPRESS_SERIAL_NUMBER_CAPABILITY;
3173
3174 typedef union _PCI_EXPRESS_UNCORRECTABLE_ERROR_STATUS {
3175 struct {
3176 ULONG Undefined:1;
3177 ULONG Reserved1:3;
3178 ULONG DataLinkProtocolError:1;
3179 ULONG SurpriseDownError:1;
3180 ULONG Reserved2:6;
3181 ULONG PoisonedTLP:1;
3182 ULONG FlowControlProtocolError:1;
3183 ULONG CompletionTimeout:1;
3184 ULONG CompleterAbort:1;
3185 ULONG UnexpectedCompletion:1;
3186 ULONG ReceiverOverflow:1;
3187 ULONG MalformedTLP:1;
3188 ULONG ECRCError:1;
3189 ULONG UnsupportedRequestError:1;
3190 ULONG Reserved3:11;
3191 } DUMMYSTRUCTNAME;
3192 ULONG AsULONG;
3193 } PCI_EXPRESS_UNCORRECTABLE_ERROR_STATUS, *PPCI_EXPRESS_UNCORRECTABLE_ERROR_STATUS;
3194
3195 typedef union _PCI_EXPRESS_UNCORRECTABLE_ERROR_MASK {
3196 struct {
3197 ULONG Undefined:1;
3198 ULONG Reserved1:3;
3199 ULONG DataLinkProtocolError:1;
3200 ULONG SurpriseDownError:1;
3201 ULONG Reserved2:6;
3202 ULONG PoisonedTLP:1;
3203 ULONG FlowControlProtocolError:1;
3204 ULONG CompletionTimeout:1;
3205 ULONG CompleterAbort:1;
3206 ULONG UnexpectedCompletion:1;
3207 ULONG ReceiverOverflow:1;
3208 ULONG MalformedTLP:1;
3209 ULONG ECRCError:1;
3210 ULONG UnsupportedRequestError:1;
3211 ULONG Reserved3:11;
3212 } DUMMYSTRUCTNAME;
3213 ULONG AsULONG;
3214 } PCI_EXPRESS_UNCORRECTABLE_ERROR_MASK, *PPCI_EXPRESS_UNCORRECTABLE_ERROR_MASK;
3215
3216 typedef union _PCI_EXPRESS_UNCORRECTABLE_ERROR_SEVERITY {
3217 struct {
3218 ULONG Undefined:1;
3219 ULONG Reserved1:3;
3220 ULONG DataLinkProtocolError:1;
3221 ULONG SurpriseDownError:1;
3222 ULONG Reserved2:6;
3223 ULONG PoisonedTLP:1;
3224 ULONG FlowControlProtocolError:1;
3225 ULONG CompletionTimeout:1;
3226 ULONG CompleterAbort:1;
3227 ULONG UnexpectedCompletion:1;
3228 ULONG ReceiverOverflow:1;
3229 ULONG MalformedTLP:1;
3230 ULONG ECRCError:1;
3231 ULONG UnsupportedRequestError:1;
3232 ULONG Reserved3:11;
3233 } DUMMYSTRUCTNAME;
3234 ULONG AsULONG;
3235 } PCI_EXPRESS_UNCORRECTABLE_ERROR_SEVERITY, *PPCI_EXPRESS_UNCORRECTABLE_ERROR_SEVERITY;
3236
3237 typedef union _PCI_EXPRESS_CORRECTABLE_ERROR_STATUS {
3238 struct {
3239 ULONG ReceiverError:1;
3240 ULONG Reserved1:5;
3241 ULONG BadTLP:1;
3242 ULONG BadDLLP:1;
3243 ULONG ReplayNumRollover:1;
3244 ULONG Reserved2:3;
3245 ULONG ReplayTimerTimeout:1;
3246 ULONG AdvisoryNonFatalError:1;
3247 ULONG Reserved3:18;
3248 } DUMMYSTRUCTNAME;
3249 ULONG AsULONG;
3250 } PCI_EXPRESS_CORRECTABLE_ERROR_STATUS, *PPCI_CORRECTABLE_ERROR_STATUS;
3251
3252 typedef union _PCI_EXPRESS_CORRECTABLE_ERROR_MASK {
3253 struct {
3254 ULONG ReceiverError:1;
3255 ULONG Reserved1:5;
3256 ULONG BadTLP:1;
3257 ULONG BadDLLP:1;
3258 ULONG ReplayNumRollover:1;
3259 ULONG Reserved2:3;
3260 ULONG ReplayTimerTimeout:1;
3261 ULONG AdvisoryNonFatalError:1;
3262 ULONG Reserved3:18;
3263 } DUMMYSTRUCTNAME;
3264 ULONG AsULONG;
3265 } PCI_EXPRESS_CORRECTABLE_ERROR_MASK, *PPCI_CORRECTABLE_ERROR_MASK;
3266
3267 typedef union _PCI_EXPRESS_AER_CAPABILITIES {
3268 struct {
3269 ULONG FirstErrorPointer:5;
3270 ULONG ECRCGenerationCapable:1;
3271 ULONG ECRCGenerationEnable:1;
3272 ULONG ECRCCheckCapable:1;
3273 ULONG ECRCCheckEnable:1;
3274 ULONG Reserved:23;
3275 } DUMMYSTRUCTNAME;
3276 ULONG AsULONG;
3277 } PCI_EXPRESS_AER_CAPABILITIES, *PPCI_EXPRESS_AER_CAPABILITIES;
3278
3279 typedef union _PCI_EXPRESS_ROOT_ERROR_COMMAND {
3280 struct {
3281 ULONG CorrectableErrorReportingEnable:1;
3282 ULONG NonFatalErrorReportingEnable:1;
3283 ULONG FatalErrorReportingEnable:1;
3284 ULONG Reserved:29;
3285 } DUMMYSTRUCTNAME;
3286 ULONG AsULONG;
3287 } PCI_EXPRESS_ROOT_ERROR_COMMAND, *PPCI_EXPRESS_ROOT_ERROR_COMMAND;
3288
3289 typedef union _PCI_EXPRESS_ROOT_ERROR_STATUS {
3290 struct {
3291 ULONG CorrectableErrorReceived:1;
3292 ULONG MultipleCorrectableErrorsReceived:1;
3293 ULONG UncorrectableErrorReceived:1;
3294 ULONG MultipleUncorrectableErrorsReceived:1;
3295 ULONG FirstUncorrectableFatal:1;
3296 ULONG NonFatalErrorMessagesReceived:1;
3297 ULONG FatalErrorMessagesReceived:1;
3298 ULONG Reserved:20;
3299 ULONG AdvancedErrorInterruptMessageNumber:5;
3300 } DUMMYSTRUCTNAME;
3301 ULONG AsULONG;
3302 } PCI_EXPRESS_ROOT_ERROR_STATUS, *PPCI_EXPRESS_ROOT_ERROR_STATUS;
3303
3304 typedef union _PCI_EXPRESS_ERROR_SOURCE_ID {
3305 struct {
3306 USHORT CorrectableSourceIdFun:3;
3307 USHORT CorrectableSourceIdDev:5;
3308 USHORT CorrectableSourceIdBus:8;
3309 USHORT UncorrectableSourceIdFun:3;
3310 USHORT UncorrectableSourceIdDev:5;
3311 USHORT UncorrectableSourceIdBus:8;
3312 } DUMMYSTRUCTNAME;
3313 ULONG AsULONG;
3314 } PCI_EXPRESS_ERROR_SOURCE_ID, *PPCI_EXPRESS_ERROR_SOURCE_ID;
3315
3316 typedef union _PCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_STATUS {
3317 struct {
3318 ULONG TargetAbortOnSplitCompletion:1;
3319 ULONG MasterAbortOnSplitCompletion:1;
3320 ULONG ReceivedTargetAbort:1;
3321 ULONG ReceivedMasterAbort:1;
3322 ULONG RsvdZ:1;
3323 ULONG UnexpectedSplitCompletionError:1;
3324 ULONG UncorrectableSplitCompletion:1;
3325 ULONG UncorrectableDataError:1;
3326 ULONG UncorrectableAttributeError:1;
3327 ULONG UncorrectableAddressError:1;
3328 ULONG DelayedTransactionDiscardTimerExpired:1;
3329 ULONG PERRAsserted:1;
3330 ULONG SERRAsserted:1;
3331 ULONG InternalBridgeError:1;
3332 ULONG Reserved:18;
3333 } DUMMYSTRUCTNAME;
3334 ULONG AsULONG;
3335 } PCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_STATUS, *PPCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_STATUS;
3336
3337 typedef union _PCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_MASK {
3338 struct {
3339 ULONG TargetAbortOnSplitCompletion:1;
3340 ULONG MasterAbortOnSplitCompletion:1;
3341 ULONG ReceivedTargetAbort:1;
3342 ULONG ReceivedMasterAbort:1;
3343 ULONG RsvdZ:1;
3344 ULONG UnexpectedSplitCompletionError:1;
3345 ULONG UncorrectableSplitCompletion:1;
3346 ULONG UncorrectableDataError:1;
3347 ULONG UncorrectableAttributeError:1;
3348 ULONG UncorrectableAddressError:1;
3349 ULONG DelayedTransactionDiscardTimerExpired:1;
3350 ULONG PERRAsserted:1;
3351 ULONG SERRAsserted:1;
3352 ULONG InternalBridgeError:1;
3353 ULONG Reserved:18;
3354 } DUMMYSTRUCTNAME;
3355 ULONG AsULONG;
3356 } PCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_MASK, *PPCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_MASK;
3357
3358 typedef union _PCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_SEVERITY {
3359 struct {
3360 ULONG TargetAbortOnSplitCompletion:1;
3361 ULONG MasterAbortOnSplitCompletion:1;
3362 ULONG ReceivedTargetAbort:1;
3363 ULONG ReceivedMasterAbort:1;
3364 ULONG RsvdZ:1;
3365 ULONG UnexpectedSplitCompletionError:1;
3366 ULONG UncorrectableSplitCompletion:1;
3367 ULONG UncorrectableDataError:1;
3368 ULONG UncorrectableAttributeError:1;
3369 ULONG UncorrectableAddressError:1;
3370 ULONG DelayedTransactionDiscardTimerExpired:1;
3371 ULONG PERRAsserted:1;
3372 ULONG SERRAsserted:1;
3373 ULONG InternalBridgeError:1;
3374 ULONG Reserved:18;
3375 } DUMMYSTRUCTNAME;
3376 ULONG AsULONG;
3377 } PCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_SEVERITY, *PPCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_SEVERITY;
3378
3379 typedef union _PCI_EXPRESS_SEC_AER_CAPABILITIES {
3380 struct {
3381 ULONG SecondaryUncorrectableFirstErrorPtr:5;
3382 ULONG Reserved:27;
3383 } DUMMYSTRUCTNAME;
3384 ULONG AsULONG;
3385 } PCI_EXPRESS_SEC_AER_CAPABILITIES, *PPCI_EXPRESS_SEC_AER_CAPABILITIES;
3386
3387 #define ROOT_CMD_ENABLE_CORRECTABLE_ERROR_REPORTING 0x00000001
3388 #define ROOT_CMD_ENABLE_NONFATAL_ERROR_REPORTING 0x00000002
3389 #define ROOT_CMD_ENABLE_FATAL_ERROR_REPORTING 0x00000004
3390
3391 #define ROOT_CMD_ERROR_REPORTING_ENABLE_MASK \
3392 (ROOT_CMD_ENABLE_FATAL_ERROR_REPORTING | \
3393 ROOT_CMD_ENABLE_NONFATAL_ERROR_REPORTING | \
3394 ROOT_CMD_ENABLE_CORRECTABLE_ERROR_REPORTING)
3395
3396 typedef struct _PCI_EXPRESS_AER_CAPABILITY {
3397 PCI_EXPRESS_ENHANCED_CAPABILITY_HEADER Header;
3398 PCI_EXPRESS_UNCORRECTABLE_ERROR_STATUS UncorrectableErrorStatus;
3399 PCI_EXPRESS_UNCORRECTABLE_ERROR_MASK UncorrectableErrorMask;
3400 PCI_EXPRESS_UNCORRECTABLE_ERROR_SEVERITY UncorrectableErrorSeverity;
3401 PCI_EXPRESS_CORRECTABLE_ERROR_STATUS CorrectableErrorStatus;
3402 PCI_EXPRESS_CORRECTABLE_ERROR_MASK CorrectableErrorMask;
3403 PCI_EXPRESS_AER_CAPABILITIES CapabilitiesAndControl;
3404 ULONG HeaderLog[4];
3405 PCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_STATUS SecUncorrectableErrorStatus;
3406 PCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_MASK SecUncorrectableErrorMask;
3407 PCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_SEVERITY SecUncorrectableErrorSeverity;
3408 PCI_EXPRESS_SEC_AER_CAPABILITIES SecCapabilitiesAndControl;
3409 ULONG SecHeaderLog[4];
3410 } PCI_EXPRESS_AER_CAPABILITY, *PPCI_EXPRESS_AER_CAPABILITY;
3411
3412 typedef struct _PCI_EXPRESS_ROOTPORT_AER_CAPABILITY {
3413 PCI_EXPRESS_ENHANCED_CAPABILITY_HEADER Header;
3414 PCI_EXPRESS_UNCORRECTABLE_ERROR_STATUS UncorrectableErrorStatus;
3415 PCI_EXPRESS_UNCORRECTABLE_ERROR_MASK UncorrectableErrorMask;
3416 PCI_EXPRESS_UNCORRECTABLE_ERROR_SEVERITY UncorrectableErrorSeverity;
3417 PCI_EXPRESS_CORRECTABLE_ERROR_STATUS CorrectableErrorStatus;
3418 PCI_EXPRESS_CORRECTABLE_ERROR_MASK CorrectableErrorMask;
3419 PCI_EXPRESS_AER_CAPABILITIES CapabilitiesAndControl;
3420 ULONG HeaderLog[4];
3421 PCI_EXPRESS_ROOT_ERROR_COMMAND RootErrorCommand;
3422 PCI_EXPRESS_ROOT_ERROR_STATUS RootErrorStatus;
3423 PCI_EXPRESS_ERROR_SOURCE_ID ErrorSourceId;
3424 } PCI_EXPRESS_ROOTPORT_AER_CAPABILITY, *PPCI_EXPRESS_ROOTPORT_AER_CAPABILITY;
3425
3426 typedef struct _PCI_EXPRESS_BRIDGE_AER_CAPABILITY {
3427 PCI_EXPRESS_ENHANCED_CAPABILITY_HEADER Header;
3428 PCI_EXPRESS_UNCORRECTABLE_ERROR_STATUS UncorrectableErrorStatus;
3429 PCI_EXPRESS_UNCORRECTABLE_ERROR_MASK UncorrectableErrorMask;
3430 PCI_EXPRESS_UNCORRECTABLE_ERROR_SEVERITY UncorrectableErrorSeverity;
3431 PCI_EXPRESS_CORRECTABLE_ERROR_STATUS CorrectableErrorStatus;
3432 PCI_EXPRESS_CORRECTABLE_ERROR_MASK CorrectableErrorMask;
3433 PCI_EXPRESS_AER_CAPABILITIES CapabilitiesAndControl;
3434 ULONG HeaderLog[4];
3435 PCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_STATUS SecUncorrectableErrorStatus;
3436 PCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_MASK SecUncorrectableErrorMask;
3437 PCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_SEVERITY SecUncorrectableErrorSeverity;
3438 PCI_EXPRESS_SEC_AER_CAPABILITIES SecCapabilitiesAndControl;
3439 ULONG SecHeaderLog[4];
3440 } PCI_EXPRESS_BRIDGE_AER_CAPABILITY, *PPCI_EXPRESS_BRIDGE_AER_CAPABILITY;
3441
3442 typedef union _PCI_EXPRESS_SRIOV_CAPS {
3443 struct {
3444 ULONG VFMigrationCapable:1;
3445 ULONG Reserved1:20;
3446 ULONG VFMigrationInterruptNumber:11;
3447 } DUMMYSTRUCTNAME;
3448 ULONG AsULONG;
3449 } PCI_EXPRESS_SRIOV_CAPS, *PPCI_EXPRESS_SRIOV_CAPS;
3450
3451 typedef union _PCI_EXPRESS_SRIOV_CONTROL {
3452 struct {
3453 USHORT VFEnable:1;
3454 USHORT VFMigrationEnable:1;
3455 USHORT VFMigrationInterruptEnable:1;
3456 USHORT VFMemorySpaceEnable:1;
3457 USHORT ARICapableHierarchy:1;
3458 USHORT Reserved1:11;
3459 } DUMMYSTRUCTNAME;
3460 USHORT AsUSHORT;
3461 } PCI_EXPRESS_SRIOV_CONTROL, *PPCI_EXPRESS_SRIOV_CONTROL;
3462
3463 typedef union _PCI_EXPRESS_SRIOV_STATUS {
3464 struct {
3465 USHORT VFMigrationStatus:1;
3466 USHORT Reserved1:15;
3467 } DUMMYSTRUCTNAME;
3468 USHORT AsUSHORT;
3469 } PCI_EXPRESS_SRIOV_STATUS, *PPCI_EXPRESS_SRIOV_STATUS;
3470
3471 typedef union _PCI_EXPRESS_SRIOV_MIGRATION_STATE_ARRAY {
3472 struct {
3473 ULONG VFMigrationStateBIR:3;
3474 ULONG VFMigrationStateOffset:29;
3475 } DUMMYSTRUCTNAME;
3476 ULONG AsULONG;
3477 } PCI_EXPRESS_SRIOV_MIGRATION_STATE_ARRAY, *PPCI_EXPRESS_SRIOV_MIGRATION_STATE_ARRAY;
3478
3479 typedef struct _PCI_EXPRESS_SRIOV_CAPABILITY {
3480 PCI_EXPRESS_ENHANCED_CAPABILITY_HEADER Header;
3481 PCI_EXPRESS_SRIOV_CAPS SRIOVCapabilities;
3482 PCI_EXPRESS_SRIOV_CONTROL SRIOVControl;
3483 PCI_EXPRESS_SRIOV_STATUS SRIOVStatus;
3484 USHORT InitialVFs;
3485 USHORT TotalVFs;
3486 USHORT NumVFs;
3487 UCHAR FunctionDependencyLink;
3488 UCHAR RsvdP1;
3489 USHORT FirstVFOffset;
3490 USHORT VFStride;
3491 USHORT RsvdP2;
3492 USHORT VFDeviceId;
3493 ULONG SupportedPageSizes;
3494 ULONG SystemPageSize;
3495 ULONG BaseAddresses[PCI_TYPE0_ADDRESSES];
3496 PCI_EXPRESS_SRIOV_MIGRATION_STATE_ARRAY VFMigrationStateArrayOffset;
3497 } PCI_EXPRESS_SRIOV_CAPABILITY, *PPCI_EXPRESS_SRIOV_CAPABILITY;
3498
3499 /* PCI device classes */
3500 #define PCI_CLASS_PRE_20 0x00
3501 #define PCI_CLASS_MASS_STORAGE_CTLR 0x01
3502 #define PCI_CLASS_NETWORK_CTLR 0x02
3503 #define PCI_CLASS_DISPLAY_CTLR 0x03
3504 #define PCI_CLASS_MULTIMEDIA_DEV 0x04
3505 #define PCI_CLASS_MEMORY_CTLR 0x05
3506 #define PCI_CLASS_BRIDGE_DEV 0x06
3507 #define PCI_CLASS_SIMPLE_COMMS_CTLR 0x07
3508 #define PCI_CLASS_BASE_SYSTEM_DEV 0x08
3509 #define PCI_CLASS_INPUT_DEV 0x09
3510 #define PCI_CLASS_DOCKING_STATION 0x0a
3511 #define PCI_CLASS_PROCESSOR 0x0b
3512 #define PCI_CLASS_SERIAL_BUS_CTLR 0x0c
3513 #define PCI_CLASS_WIRELESS_CTLR 0x0d
3514 #define PCI_CLASS_INTELLIGENT_IO_CTLR 0x0e
3515 #define PCI_CLASS_SATELLITE_COMMS_CTLR 0x0f
3516 #define PCI_CLASS_ENCRYPTION_DECRYPTION 0x10
3517 #define PCI_CLASS_DATA_ACQ_SIGNAL_PROC 0x11
3518 #define PCI_CLASS_NOT_DEFINED 0xff
3519
3520 /* PCI device subclasses for class 0 */
3521 #define PCI_SUBCLASS_PRE_20_NON_VGA 0x00
3522 #define PCI_SUBCLASS_PRE_20_VGA 0x01
3523
3524 /* PCI device subclasses for class 1 (mass storage controllers)*/
3525 #define PCI_SUBCLASS_MSC_SCSI_BUS_CTLR 0x00
3526 #define PCI_SUBCLASS_MSC_IDE_CTLR 0x01
3527 #define PCI_SUBCLASS_MSC_FLOPPY_CTLR 0x02
3528 #define PCI_SUBCLASS_MSC_IPI_CTLR 0x03
3529 #define PCI_SUBCLASS_MSC_RAID_CTLR 0x04
3530 #define PCI_SUBCLASS_MSC_OTHER 0x80
3531
3532 /* PCI device subclasses for class 2 (network controllers)*/
3533 #define PCI_SUBCLASS_NET_ETHERNET_CTLR 0x00
3534 #define PCI_SUBCLASS_NET_TOKEN_RING_CTLR 0x01
3535 #define PCI_SUBCLASS_NET_FDDI_CTLR 0x02
3536 #define PCI_SUBCLASS_NET_ATM_CTLR 0x03
3537 #define PCI_SUBCLASS_NET_ISDN_CTLR 0x04
3538 #define PCI_SUBCLASS_NET_OTHER 0x80
3539
3540 /* PCI device subclasses for class 3 (display controllers)*/
3541 #define PCI_SUBCLASS_VID_VGA_CTLR 0x00
3542 #define PCI_SUBCLASS_VID_XGA_CTLR 0x01
3543 #define PCI_SUBCLASS_VID_3D_CTLR 0x02
3544 #define PCI_SUBCLASS_VID_OTHER 0x80
3545
3546 /* PCI device subclasses for class 4 (multimedia device)*/
3547 #define PCI_SUBCLASS_MM_VIDEO_DEV 0x00
3548 #define PCI_SUBCLASS_MM_AUDIO_DEV 0x01
3549 #define PCI_SUBCLASS_MM_TELEPHONY_DEV 0x02
3550 #define PCI_SUBCLASS_MM_OTHER 0x80
3551
3552 /* PCI device subclasses for class 5 (memory controller)*/
3553 #define PCI_SUBCLASS_MEM_RAM 0x00
3554 #define PCI_SUBCLASS_MEM_FLASH 0x01
3555 #define PCI_SUBCLASS_MEM_OTHER 0x80
3556
3557 /* PCI device subclasses for class 6 (bridge device)*/
3558 #define PCI_SUBCLASS_BR_HOST 0x00
3559 #define PCI_SUBCLASS_BR_ISA 0x01
3560 #define PCI_SUBCLASS_BR_EISA 0x02
3561 #define PCI_SUBCLASS_BR_MCA 0x03
3562 #define PCI_SUBCLASS_BR_PCI_TO_PCI 0x04
3563 #define PCI_SUBCLASS_BR_PCMCIA 0x05
3564 #define PCI_SUBCLASS_BR_NUBUS 0x06
3565 #define PCI_SUBCLASS_BR_CARDBUS 0x07
3566 #define PCI_SUBCLASS_BR_RACEWAY 0x08
3567 #define PCI_SUBCLASS_BR_OTHER 0x80
3568
3569 #define PCI_SUBCLASS_COM_SERIAL 0x00
3570 #define PCI_SUBCLASS_COM_PARALLEL 0x01
3571 #define PCI_SUBCLASS_COM_MULTIPORT 0x02
3572 #define PCI_SUBCLASS_COM_MODEM 0x03
3573 #define PCI_SUBCLASS_COM_OTHER 0x80
3574
3575 #define PCI_SUBCLASS_SYS_INTERRUPT_CTLR 0x00
3576 #define PCI_SUBCLASS_SYS_DMA_CTLR 0x01
3577 #define PCI_SUBCLASS_SYS_SYSTEM_TIMER 0x02
3578 #define PCI_SUBCLASS_SYS_REAL_TIME_CLOCK 0x03
3579 #define PCI_SUBCLASS_SYS_GEN_HOTPLUG_CTLR 0x04
3580 #define PCI_SUBCLASS_SYS_SDIO_CTRL 0x05
3581 #define PCI_SUBCLASS_SYS_OTHER 0x80
3582
3583 #define PCI_SUBCLASS_INP_KEYBOARD 0x00
3584 #define PCI_SUBCLASS_INP_DIGITIZER 0x01
3585 #define PCI_SUBCLASS_INP_MOUSE 0x02
3586 #define PCI_SUBCLASS_INP_SCANNER 0x03
3587 #define PCI_SUBCLASS_INP_GAMEPORT 0x04
3588 #define PCI_SUBCLASS_INP_OTHER 0x80
3589
3590 #define PCI_SUBCLASS_DOC_GENERIC 0x00
3591 #define PCI_SUBCLASS_DOC_OTHER 0x80
3592
3593 #define PCI_SUBCLASS_PROC_386 0x00
3594 #define PCI_SUBCLASS_PROC_486 0x01
3595 #define PCI_SUBCLASS_PROC_PENTIUM 0x02
3596 #define PCI_SUBCLASS_PROC_ALPHA 0x10
3597 #define PCI_SUBCLASS_PROC_POWERPC 0x20
3598 #define PCI_SUBCLASS_PROC_COPROCESSOR 0x40
3599
3600 /* PCI device subclasses for class C (serial bus controller)*/
3601 #define PCI_SUBCLASS_SB_IEEE1394 0x00
3602 #define PCI_SUBCLASS_SB_ACCESS 0x01
3603 #define PCI_SUBCLASS_SB_SSA 0x02
3604 #define PCI_SUBCLASS_SB_USB 0x03
3605 #define PCI_SUBCLASS_SB_FIBRE_CHANNEL 0x04
3606 #define PCI_SUBCLASS_SB_SMBUS 0x05
3607
3608 #define PCI_SUBCLASS_WIRELESS_IRDA 0x00
3609 #define PCI_SUBCLASS_WIRELESS_CON_IR 0x01
3610 #define PCI_SUBCLASS_WIRELESS_RF 0x10
3611 #define PCI_SUBCLASS_WIRELESS_OTHER 0x80
3612
3613 #define PCI_SUBCLASS_INTIO_I2O 0x00
3614
3615 #define PCI_SUBCLASS_SAT_TV 0x01
3616 #define PCI_SUBCLASS_SAT_AUDIO 0x02
3617 #define PCI_SUBCLASS_SAT_VOICE 0x03
3618 #define PCI_SUBCLASS_SAT_DATA 0x04
3619
3620 #define PCI_SUBCLASS_CRYPTO_NET_COMP 0x00
3621 #define PCI_SUBCLASS_CRYPTO_ENTERTAINMENT 0x10
3622 #define PCI_SUBCLASS_CRYPTO_OTHER 0x80
3623
3624 #define PCI_SUBCLASS_DASP_DPIO 0x00
3625 #define PCI_SUBCLASS_DASP_OTHER 0x80
3626
3627 #define PCI_ADDRESS_IO_SPACE 0x00000001
3628 #define PCI_ADDRESS_MEMORY_TYPE_MASK 0x00000006
3629 #define PCI_ADDRESS_MEMORY_PREFETCHABLE 0x00000008
3630 #define PCI_ADDRESS_IO_ADDRESS_MASK 0xfffffffc
3631 #define PCI_ADDRESS_MEMORY_ADDRESS_MASK 0xfffffff0
3632 #define PCI_ADDRESS_ROM_ADDRESS_MASK 0xfffff800
3633
3634 #define PCI_TYPE_32BIT 0
3635 #define PCI_TYPE_20BIT 2
3636 #define PCI_TYPE_64BIT 4
3637
3638 #define PCI_ROMADDRESS_ENABLED 0x00000001
3639
3640 #endif /* _PCI_X_ */
3641
3642 #define PCI_EXPRESS_LINK_QUIESCENT_INTERFACE_VERSION 1
3643
3644 typedef NTSTATUS
3645 (NTAPI PCI_EXPRESS_ENTER_LINK_QUIESCENT_MODE)(
3646 IN OUT PVOID Context);
3647 typedef PCI_EXPRESS_ENTER_LINK_QUIESCENT_MODE *PPCI_EXPRESS_ENTER_LINK_QUIESCENT_MODE;
3648
3649 typedef NTSTATUS
3650 (NTAPI PCI_EXPRESS_EXIT_LINK_QUIESCENT_MODE)(
3651 IN OUT PVOID Context);
3652 typedef PCI_EXPRESS_EXIT_LINK_QUIESCENT_MODE *PPCI_EXPRESS_EXIT_LINK_QUIESCENT_MODE;
3653
3654 typedef struct _PCI_EXPRESS_LINK_QUIESCENT_INTERFACE {
3655 USHORT Size;
3656 USHORT Version;
3657 PVOID Context;
3658 PINTERFACE_REFERENCE InterfaceReference;
3659 PINTERFACE_DEREFERENCE InterfaceDereference;
3660 PPCI_EXPRESS_ENTER_LINK_QUIESCENT_MODE PciExpressEnterLinkQuiescentMode;
3661 PPCI_EXPRESS_EXIT_LINK_QUIESCENT_MODE PciExpressExitLinkQuiescentMode;
3662 } PCI_EXPRESS_LINK_QUIESCENT_INTERFACE, *PPCI_EXPRESS_LINK_QUIESCENT_INTERFACE;
3663
3664 #define PCI_EXPRESS_ROOT_PORT_INTERFACE_VERSION 1
3665
3666 typedef ULONG
3667 (NTAPI *PPCI_EXPRESS_ROOT_PORT_READ_CONFIG_SPACE)(
3668 IN PVOID Context,
3669 OUT PVOID Buffer,
3670 IN ULONG Offset,
3671 IN ULONG Length);
3672
3673 typedef ULONG
3674 (NTAPI *PPCI_EXPRESS_ROOT_PORT_WRITE_CONFIG_SPACE)(
3675 IN PVOID Context,
3676 IN PVOID Buffer,
3677 IN ULONG Offset,
3678 IN ULONG Length);
3679
3680 typedef struct _PCI_EXPRESS_ROOT_PORT_INTERFACE {
3681 USHORT Size;
3682 USHORT Version;
3683 PVOID Context;
3684 PINTERFACE_REFERENCE InterfaceReference;
3685 PINTERFACE_DEREFERENCE InterfaceDereference;
3686 PPCI_EXPRESS_ROOT_PORT_READ_CONFIG_SPACE ReadConfigSpace;
3687 PPCI_EXPRESS_ROOT_PORT_WRITE_CONFIG_SPACE WriteConfigSpace;
3688 } PCI_EXPRESS_ROOT_PORT_INTERFACE, *PPCI_EXPRESS_ROOT_PORT_INTERFACE;
3689
3690 #define PCI_MSIX_TABLE_CONFIG_INTERFACE_VERSION 1
3691
3692 typedef NTSTATUS
3693 (NTAPI PCI_MSIX_SET_ENTRY)(
3694 IN PVOID Context,
3695 IN ULONG TableEntry,
3696 IN ULONG MessageNumber);
3697 typedef PCI_MSIX_SET_ENTRY *PPCI_MSIX_SET_ENTRY;
3698
3699 typedef NTSTATUS
3700 (NTAPI PCI_MSIX_MASKUNMASK_ENTRY)(
3701 IN PVOID Context,
3702 IN ULONG TableEntry);
3703 typedef PCI_MSIX_MASKUNMASK_ENTRY *PPCI_MSIX_MASKUNMASK_ENTRY;
3704
3705 typedef NTSTATUS
3706 (NTAPI PCI_MSIX_GET_ENTRY)(
3707 IN PVOID Context,
3708 IN ULONG TableEntry,
3709 OUT PULONG MessageNumber,
3710 OUT PBOOLEAN Masked);
3711 typedef PCI_MSIX_GET_ENTRY *PPCI_MSIX_GET_ENTRY;
3712
3713 typedef NTSTATUS
3714 (NTAPI PCI_MSIX_GET_TABLE_SIZE)(
3715 IN PVOID Context,
3716 OUT PULONG TableSize);
3717 typedef PCI_MSIX_GET_TABLE_SIZE *PPCI_MSIX_GET_TABLE_SIZE;
3718
3719 typedef struct _PCI_MSIX_TABLE_CONFIG_INTERFACE {
3720 USHORT Size;
3721 USHORT Version;
3722 PVOID Context;
3723 PINTERFACE_REFERENCE InterfaceReference;
3724 PINTERFACE_DEREFERENCE InterfaceDereference;
3725 PPCI_MSIX_SET_ENTRY SetTableEntry;
3726 PPCI_MSIX_MASKUNMASK_ENTRY MaskTableEntry;
3727 PPCI_MSIX_MASKUNMASK_ENTRY UnmaskTableEntry;
3728 PPCI_MSIX_GET_ENTRY GetTableEntry;
3729 PPCI_MSIX_GET_TABLE_SIZE GetTableSize;
3730 } PCI_MSIX_TABLE_CONFIG_INTERFACE, *PPCI_MSIX_TABLE_CONFIG_INTERFACE;
3731
3732 #define PCI_MSIX_TABLE_CONFIG_MINIMUM_SIZE \
3733 RTL_SIZEOF_THROUGH_FIELD(PCI_MSIX_TABLE_CONFIG_INTERFACE, UnmaskTableEntry)
3734