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