[XDK]
[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 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 };
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 union {
674 ULONG Signature;
675 GUID DeviceId;
676 };
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)
2033
2034 #if _MSC_VER >= 1200
2035 #pragma warning(push)
2036 #endif
2037 #pragma warning(disable:4200)
2038 typedef struct _SCATTER_GATHER_LIST {
2039 ULONG NumberOfElements;
2040 ULONG_PTR Reserved;
2041 SCATTER_GATHER_ELEMENT Elements[1];
2042 } SCATTER_GATHER_LIST, *PSCATTER_GATHER_LIST;
2043
2044 #if _MSC_VER >= 1200
2045 #pragma warning(pop)
2046 #else
2047 #pragma warning(default:4200)
2048 #endif
2049
2050 #else
2051
2052 struct _SCATTER_GATHER_LIST;
2053 typedef struct _SCATTER_GATHER_LIST SCATTER_GATHER_LIST, *PSCATTER_GATHER_LIST;
2054
2055 #endif
2056
2057 typedef NTSTATUS
2058 (NTAPI DRIVER_ADD_DEVICE)(
2059 IN struct _DRIVER_OBJECT *DriverObject,
2060 IN struct _DEVICE_OBJECT *PhysicalDeviceObject);
2061 typedef DRIVER_ADD_DEVICE *PDRIVER_ADD_DEVICE;
2062
2063 typedef struct _DRIVER_EXTENSION {
2064 struct _DRIVER_OBJECT *DriverObject;
2065 PDRIVER_ADD_DEVICE AddDevice;
2066 ULONG Count;
2067 UNICODE_STRING ServiceKeyName;
2068 } DRIVER_EXTENSION, *PDRIVER_EXTENSION;
2069
2070 #define DRVO_UNLOAD_INVOKED 0x00000001
2071 #define DRVO_LEGACY_DRIVER 0x00000002
2072 #define DRVO_BUILTIN_DRIVER 0x00000004
2073
2074 typedef NTSTATUS
2075 (NTAPI DRIVER_INITIALIZE)(
2076 IN struct _DRIVER_OBJECT *DriverObject,
2077 IN PUNICODE_STRING RegistryPath);
2078 typedef DRIVER_INITIALIZE *PDRIVER_INITIALIZE;
2079
2080 typedef VOID
2081 (NTAPI DRIVER_STARTIO)(
2082 IN struct _DEVICE_OBJECT *DeviceObject,
2083 IN struct _IRP *Irp);
2084 typedef DRIVER_STARTIO *PDRIVER_STARTIO;
2085
2086 typedef VOID
2087 (NTAPI DRIVER_UNLOAD)(
2088 IN struct _DRIVER_OBJECT *DriverObject);
2089 typedef DRIVER_UNLOAD *PDRIVER_UNLOAD;
2090
2091 typedef NTSTATUS
2092 (NTAPI DRIVER_DISPATCH)(
2093 IN struct _DEVICE_OBJECT *DeviceObject,
2094 IN struct _IRP *Irp);
2095 typedef DRIVER_DISPATCH *PDRIVER_DISPATCH;
2096
2097 typedef struct _DRIVER_OBJECT {
2098 CSHORT Type;
2099 CSHORT Size;
2100 PDEVICE_OBJECT DeviceObject;
2101 ULONG Flags;
2102 PVOID DriverStart;
2103 ULONG DriverSize;
2104 PVOID DriverSection;
2105 PDRIVER_EXTENSION DriverExtension;
2106 UNICODE_STRING DriverName;
2107 PUNICODE_STRING HardwareDatabase;
2108 struct _FAST_IO_DISPATCH *FastIoDispatch;
2109 PDRIVER_INITIALIZE DriverInit;
2110 PDRIVER_STARTIO DriverStartIo;
2111 PDRIVER_UNLOAD DriverUnload;
2112 PDRIVER_DISPATCH MajorFunction[IRP_MJ_MAXIMUM_FUNCTION + 1];
2113 } DRIVER_OBJECT, *PDRIVER_OBJECT;
2114
2115 typedef struct _DMA_ADAPTER {
2116 USHORT Version;
2117 USHORT Size;
2118 struct _DMA_OPERATIONS* DmaOperations;
2119 } DMA_ADAPTER, *PDMA_ADAPTER;
2120
2121 typedef VOID
2122 (NTAPI *PPUT_DMA_ADAPTER)(
2123 IN PDMA_ADAPTER DmaAdapter);
2124
2125 typedef PVOID
2126 (NTAPI *PALLOCATE_COMMON_BUFFER)(
2127 IN PDMA_ADAPTER DmaAdapter,
2128 IN ULONG Length,
2129 OUT PPHYSICAL_ADDRESS LogicalAddress,
2130 IN BOOLEAN CacheEnabled);
2131
2132 typedef VOID
2133 (NTAPI *PFREE_COMMON_BUFFER)(
2134 IN PDMA_ADAPTER DmaAdapter,
2135 IN ULONG Length,
2136 IN PHYSICAL_ADDRESS LogicalAddress,
2137 IN PVOID VirtualAddress,
2138 IN BOOLEAN CacheEnabled);
2139
2140 typedef NTSTATUS
2141 (NTAPI *PALLOCATE_ADAPTER_CHANNEL)(
2142 IN PDMA_ADAPTER DmaAdapter,
2143 IN PDEVICE_OBJECT DeviceObject,
2144 IN ULONG NumberOfMapRegisters,
2145 IN PDRIVER_CONTROL ExecutionRoutine,
2146 IN PVOID Context);
2147
2148 typedef BOOLEAN
2149 (NTAPI *PFLUSH_ADAPTER_BUFFERS)(
2150 IN PDMA_ADAPTER DmaAdapter,
2151 IN PMDL Mdl,
2152 IN PVOID MapRegisterBase,
2153 IN PVOID CurrentVa,
2154 IN ULONG Length,
2155 IN BOOLEAN WriteToDevice);
2156
2157 typedef VOID
2158 (NTAPI *PFREE_ADAPTER_CHANNEL)(
2159 IN PDMA_ADAPTER DmaAdapter);
2160
2161 typedef VOID
2162 (NTAPI *PFREE_MAP_REGISTERS)(
2163 IN PDMA_ADAPTER DmaAdapter,
2164 PVOID MapRegisterBase,
2165 ULONG NumberOfMapRegisters);
2166
2167 typedef PHYSICAL_ADDRESS
2168 (NTAPI *PMAP_TRANSFER)(
2169 IN PDMA_ADAPTER DmaAdapter,
2170 IN PMDL Mdl,
2171 IN PVOID MapRegisterBase,
2172 IN PVOID CurrentVa,
2173 IN OUT PULONG Length,
2174 IN BOOLEAN WriteToDevice);
2175
2176 typedef ULONG
2177 (NTAPI *PGET_DMA_ALIGNMENT)(
2178 IN PDMA_ADAPTER DmaAdapter);
2179
2180 typedef ULONG
2181 (NTAPI *PREAD_DMA_COUNTER)(
2182 IN PDMA_ADAPTER DmaAdapter);
2183
2184 typedef VOID
2185 (NTAPI DRIVER_LIST_CONTROL)(
2186 IN struct _DEVICE_OBJECT *DeviceObject,
2187 IN struct _IRP *Irp,
2188 IN struct _SCATTER_GATHER_LIST *ScatterGather,
2189 IN PVOID Context);
2190 typedef DRIVER_LIST_CONTROL *PDRIVER_LIST_CONTROL;
2191
2192 typedef NTSTATUS
2193 (NTAPI *PGET_SCATTER_GATHER_LIST)(
2194 IN PDMA_ADAPTER DmaAdapter,
2195 IN PDEVICE_OBJECT DeviceObject,
2196 IN PMDL Mdl,
2197 IN PVOID CurrentVa,
2198 IN ULONG Length,
2199 IN PDRIVER_LIST_CONTROL ExecutionRoutine,
2200 IN PVOID Context,
2201 IN BOOLEAN WriteToDevice);
2202
2203 typedef VOID
2204 (NTAPI *PPUT_SCATTER_GATHER_LIST)(
2205 IN PDMA_ADAPTER DmaAdapter,
2206 IN PSCATTER_GATHER_LIST ScatterGather,
2207 IN BOOLEAN WriteToDevice);
2208
2209 typedef NTSTATUS
2210 (NTAPI *PCALCULATE_SCATTER_GATHER_LIST_SIZE)(
2211 IN PDMA_ADAPTER DmaAdapter,
2212 IN PMDL Mdl OPTIONAL,
2213 IN PVOID CurrentVa,
2214 IN ULONG Length,
2215 OUT PULONG ScatterGatherListSize,
2216 OUT PULONG pNumberOfMapRegisters OPTIONAL);
2217
2218 typedef NTSTATUS
2219 (NTAPI *PBUILD_SCATTER_GATHER_LIST)(
2220 IN PDMA_ADAPTER DmaAdapter,
2221 IN PDEVICE_OBJECT DeviceObject,
2222 IN PMDL Mdl,
2223 IN PVOID CurrentVa,
2224 IN ULONG Length,
2225 IN PDRIVER_LIST_CONTROL ExecutionRoutine,
2226 IN PVOID Context,
2227 IN BOOLEAN WriteToDevice,
2228 IN PVOID ScatterGatherBuffer,
2229 IN ULONG ScatterGatherLength);
2230
2231 typedef NTSTATUS
2232 (NTAPI *PBUILD_MDL_FROM_SCATTER_GATHER_LIST)(
2233 IN PDMA_ADAPTER DmaAdapter,
2234 IN PSCATTER_GATHER_LIST ScatterGather,
2235 IN PMDL OriginalMdl,
2236 OUT PMDL *TargetMdl);
2237
2238 typedef struct _DMA_OPERATIONS {
2239 ULONG Size;
2240 PPUT_DMA_ADAPTER PutDmaAdapter;
2241 PALLOCATE_COMMON_BUFFER AllocateCommonBuffer;
2242 PFREE_COMMON_BUFFER FreeCommonBuffer;
2243 PALLOCATE_ADAPTER_CHANNEL AllocateAdapterChannel;
2244 PFLUSH_ADAPTER_BUFFERS FlushAdapterBuffers;
2245 PFREE_ADAPTER_CHANNEL FreeAdapterChannel;
2246 PFREE_MAP_REGISTERS FreeMapRegisters;
2247 PMAP_TRANSFER MapTransfer;
2248 PGET_DMA_ALIGNMENT GetDmaAlignment;
2249 PREAD_DMA_COUNTER ReadDmaCounter;
2250 PGET_SCATTER_GATHER_LIST GetScatterGatherList;
2251 PPUT_SCATTER_GATHER_LIST PutScatterGatherList;
2252 PCALCULATE_SCATTER_GATHER_LIST_SIZE CalculateScatterGatherList;
2253 PBUILD_SCATTER_GATHER_LIST BuildScatterGatherList;
2254 PBUILD_MDL_FROM_SCATTER_GATHER_LIST BuildMdlFromScatterGatherList;
2255 } DMA_OPERATIONS, *PDMA_OPERATIONS;
2256
2257 typedef struct _IO_RESOURCE_DESCRIPTOR {
2258 UCHAR Option;
2259 UCHAR Type;
2260 UCHAR ShareDisposition;
2261 UCHAR Spare1;
2262 USHORT Flags;
2263 USHORT Spare2;
2264 union {
2265 struct {
2266 ULONG Length;
2267 ULONG Alignment;
2268 PHYSICAL_ADDRESS MinimumAddress;
2269 PHYSICAL_ADDRESS MaximumAddress;
2270 } Port;
2271 struct {
2272 ULONG Length;
2273 ULONG Alignment;
2274 PHYSICAL_ADDRESS MinimumAddress;
2275 PHYSICAL_ADDRESS MaximumAddress;
2276 } Memory;
2277 struct {
2278 ULONG MinimumVector;
2279 ULONG MaximumVector;
2280 } Interrupt;
2281 struct {
2282 ULONG MinimumChannel;
2283 ULONG MaximumChannel;
2284 } Dma;
2285 struct {
2286 ULONG Length;
2287 ULONG Alignment;
2288 PHYSICAL_ADDRESS MinimumAddress;
2289 PHYSICAL_ADDRESS MaximumAddress;
2290 } Generic;
2291 struct {
2292 ULONG Data[3];
2293 } DevicePrivate;
2294 struct {
2295 ULONG Length;
2296 ULONG MinBusNumber;
2297 ULONG MaxBusNumber;
2298 ULONG Reserved;
2299 } BusNumber;
2300 struct {
2301 ULONG Priority;
2302 ULONG Reserved1;
2303 ULONG Reserved2;
2304 } ConfigData;
2305 } u;
2306 } IO_RESOURCE_DESCRIPTOR, *PIO_RESOURCE_DESCRIPTOR;
2307
2308 typedef struct _IO_RESOURCE_LIST {
2309 USHORT Version;
2310 USHORT Revision;
2311 ULONG Count;
2312 IO_RESOURCE_DESCRIPTOR Descriptors[1];
2313 } IO_RESOURCE_LIST, *PIO_RESOURCE_LIST;
2314
2315 typedef struct _IO_RESOURCE_REQUIREMENTS_LIST {
2316 ULONG ListSize;
2317 INTERFACE_TYPE InterfaceType;
2318 ULONG BusNumber;
2319 ULONG SlotNumber;
2320 ULONG Reserved[3];
2321 ULONG AlternativeLists;
2322 IO_RESOURCE_LIST List[1];
2323 } IO_RESOURCE_REQUIREMENTS_LIST, *PIO_RESOURCE_REQUIREMENTS_LIST;
2324
2325 typedef VOID
2326 (NTAPI DRIVER_CANCEL)(
2327 IN struct _DEVICE_OBJECT *DeviceObject,
2328 IN struct _IRP *Irp);
2329 typedef DRIVER_CANCEL *PDRIVER_CANCEL;
2330
2331 typedef struct _IRP {
2332 CSHORT Type;
2333 USHORT Size;
2334 struct _MDL *MdlAddress;
2335 ULONG Flags;
2336 union {
2337 struct _IRP *MasterIrp;
2338 volatile LONG IrpCount;
2339 PVOID SystemBuffer;
2340 } AssociatedIrp;
2341 LIST_ENTRY ThreadListEntry;
2342 IO_STATUS_BLOCK IoStatus;
2343 KPROCESSOR_MODE RequestorMode;
2344 BOOLEAN PendingReturned;
2345 CHAR StackCount;
2346 CHAR CurrentLocation;
2347 BOOLEAN Cancel;
2348 KIRQL CancelIrql;
2349 CCHAR ApcEnvironment;
2350 UCHAR AllocationFlags;
2351 PIO_STATUS_BLOCK UserIosb;
2352 PKEVENT UserEvent;
2353 union {
2354 struct {
2355 _ANONYMOUS_UNION union {
2356 PIO_APC_ROUTINE UserApcRoutine;
2357 PVOID IssuingProcess;
2358 } DUMMYUNIONNAME;
2359 PVOID UserApcContext;
2360 } AsynchronousParameters;
2361 LARGE_INTEGER AllocationSize;
2362 } Overlay;
2363 volatile PDRIVER_CANCEL CancelRoutine;
2364 PVOID UserBuffer;
2365 union {
2366 struct {
2367 _ANONYMOUS_UNION union {
2368 KDEVICE_QUEUE_ENTRY DeviceQueueEntry;
2369 _ANONYMOUS_STRUCT struct {
2370 PVOID DriverContext[4];
2371 } DUMMYSTRUCTNAME;
2372 } DUMMYUNIONNAME;
2373 PETHREAD Thread;
2374 PCHAR AuxiliaryBuffer;
2375 _ANONYMOUS_STRUCT struct {
2376 LIST_ENTRY ListEntry;
2377 _ANONYMOUS_UNION union {
2378 struct _IO_STACK_LOCATION *CurrentStackLocation;
2379 ULONG PacketType;
2380 } DUMMYUNIONNAME;
2381 } DUMMYSTRUCTNAME;
2382 struct _FILE_OBJECT *OriginalFileObject;
2383 } Overlay;
2384 KAPC Apc;
2385 PVOID CompletionKey;
2386 } Tail;
2387 } IRP, *PIRP;
2388
2389 typedef enum _IO_PAGING_PRIORITY {
2390 IoPagingPriorityInvalid,
2391 IoPagingPriorityNormal,
2392 IoPagingPriorityHigh,
2393 IoPagingPriorityReserved1,
2394 IoPagingPriorityReserved2
2395 } IO_PAGING_PRIORITY;
2396
2397 typedef NTSTATUS
2398 (NTAPI IO_COMPLETION_ROUTINE)(
2399 IN struct _DEVICE_OBJECT *DeviceObject,
2400 IN struct _IRP *Irp,
2401 IN PVOID Context);
2402 typedef IO_COMPLETION_ROUTINE *PIO_COMPLETION_ROUTINE;
2403
2404 typedef VOID
2405 (NTAPI IO_DPC_ROUTINE)(
2406 IN struct _KDPC *Dpc,
2407 IN struct _DEVICE_OBJECT *DeviceObject,
2408 IN struct _IRP *Irp,
2409 IN PVOID Context);
2410 typedef IO_DPC_ROUTINE *PIO_DPC_ROUTINE;
2411
2412 typedef NTSTATUS
2413 (NTAPI *PMM_DLL_INITIALIZE)(
2414 IN PUNICODE_STRING RegistryPath);
2415
2416 typedef NTSTATUS
2417 (NTAPI *PMM_DLL_UNLOAD)(
2418 VOID);
2419
2420 typedef VOID
2421 (NTAPI IO_TIMER_ROUTINE)(
2422 IN struct _DEVICE_OBJECT *DeviceObject,
2423 IN PVOID Context);
2424 typedef IO_TIMER_ROUTINE *PIO_TIMER_ROUTINE;
2425
2426 typedef struct _IO_SECURITY_CONTEXT {
2427 PSECURITY_QUALITY_OF_SERVICE SecurityQos;
2428 PACCESS_STATE AccessState;
2429 ACCESS_MASK DesiredAccess;
2430 ULONG FullCreateOptions;
2431 } IO_SECURITY_CONTEXT, *PIO_SECURITY_CONTEXT;
2432
2433 struct _IO_CSQ;
2434
2435 typedef struct _IO_CSQ_IRP_CONTEXT {
2436 ULONG Type;
2437 struct _IRP *Irp;
2438 struct _IO_CSQ *Csq;
2439 } IO_CSQ_IRP_CONTEXT, *PIO_CSQ_IRP_CONTEXT;
2440
2441 typedef VOID
2442 (NTAPI *PIO_CSQ_INSERT_IRP)(
2443 IN struct _IO_CSQ *Csq,
2444 IN PIRP Irp);
2445
2446 typedef NTSTATUS
2447 (NTAPI IO_CSQ_INSERT_IRP_EX)(
2448 IN struct _IO_CSQ *Csq,
2449 IN PIRP Irp,
2450 IN PVOID InsertContext);
2451 typedef IO_CSQ_INSERT_IRP_EX *PIO_CSQ_INSERT_IRP_EX;
2452
2453 typedef VOID
2454 (NTAPI *PIO_CSQ_REMOVE_IRP)(
2455 IN struct _IO_CSQ *Csq,
2456 IN PIRP Irp);
2457
2458 typedef PIRP
2459 (NTAPI *PIO_CSQ_PEEK_NEXT_IRP)(
2460 IN struct _IO_CSQ *Csq,
2461 IN PIRP Irp,
2462 IN PVOID PeekContext);
2463
2464 typedef VOID
2465 (NTAPI *PIO_CSQ_ACQUIRE_LOCK)(
2466 IN struct _IO_CSQ *Csq,
2467 OUT PKIRQL Irql);
2468
2469 typedef VOID
2470 (NTAPI *PIO_CSQ_RELEASE_LOCK)(
2471 IN struct _IO_CSQ *Csq,
2472 IN KIRQL Irql);
2473
2474 typedef VOID
2475 (NTAPI *PIO_CSQ_COMPLETE_CANCELED_IRP)(
2476 IN struct _IO_CSQ *Csq,
2477 IN PIRP Irp);
2478
2479 typedef struct _IO_CSQ {
2480 ULONG Type;
2481 PIO_CSQ_INSERT_IRP CsqInsertIrp;
2482 PIO_CSQ_REMOVE_IRP CsqRemoveIrp;
2483 PIO_CSQ_PEEK_NEXT_IRP CsqPeekNextIrp;
2484 PIO_CSQ_ACQUIRE_LOCK CsqAcquireLock;
2485 PIO_CSQ_RELEASE_LOCK CsqReleaseLock;
2486 PIO_CSQ_COMPLETE_CANCELED_IRP CsqCompleteCanceledIrp;
2487 PVOID ReservePointer;
2488 } IO_CSQ, *PIO_CSQ;
2489
2490 typedef enum _BUS_QUERY_ID_TYPE {
2491 BusQueryDeviceID,
2492 BusQueryHardwareIDs,
2493 BusQueryCompatibleIDs,
2494 BusQueryInstanceID,
2495 BusQueryDeviceSerialNumber
2496 } BUS_QUERY_ID_TYPE, *PBUS_QUERY_ID_TYPE;
2497
2498 typedef enum _DEVICE_TEXT_TYPE {
2499 DeviceTextDescription,
2500 DeviceTextLocationInformation
2501 } DEVICE_TEXT_TYPE, *PDEVICE_TEXT_TYPE;
2502
2503 typedef BOOLEAN
2504 (NTAPI *PGPE_SERVICE_ROUTINE)(
2505 PVOID,
2506 PVOID);
2507
2508 typedef NTSTATUS
2509 (NTAPI *PGPE_CONNECT_VECTOR)(
2510 PDEVICE_OBJECT,
2511 ULONG,
2512 KINTERRUPT_MODE,
2513 BOOLEAN,
2514 PGPE_SERVICE_ROUTINE,
2515 PVOID,
2516 PVOID);
2517
2518 typedef NTSTATUS
2519 (NTAPI *PGPE_DISCONNECT_VECTOR)(
2520 PVOID);
2521
2522 typedef NTSTATUS
2523 (NTAPI *PGPE_ENABLE_EVENT)(
2524 PDEVICE_OBJECT,
2525 PVOID);
2526
2527 typedef NTSTATUS
2528 (NTAPI *PGPE_DISABLE_EVENT)(
2529 PDEVICE_OBJECT,
2530 PVOID);
2531
2532 typedef NTSTATUS
2533 (NTAPI *PGPE_CLEAR_STATUS)(
2534 PDEVICE_OBJECT,
2535 PVOID);
2536
2537 typedef VOID
2538 (NTAPI *PDEVICE_NOTIFY_CALLBACK)(
2539 PVOID,
2540 ULONG);
2541
2542 typedef NTSTATUS
2543 (NTAPI *PREGISTER_FOR_DEVICE_NOTIFICATIONS)(
2544 PDEVICE_OBJECT,
2545 PDEVICE_NOTIFY_CALLBACK,
2546 PVOID);
2547
2548 typedef VOID
2549 (NTAPI *PUNREGISTER_FOR_DEVICE_NOTIFICATIONS)(
2550 PDEVICE_OBJECT,
2551 PDEVICE_NOTIFY_CALLBACK);
2552
2553 typedef struct _ACPI_INTERFACE_STANDARD {
2554 USHORT Size;
2555 USHORT Version;
2556 PVOID Context;
2557 PINTERFACE_REFERENCE InterfaceReference;
2558 PINTERFACE_DEREFERENCE InterfaceDereference;
2559 PGPE_CONNECT_VECTOR GpeConnectVector;
2560 PGPE_DISCONNECT_VECTOR GpeDisconnectVector;
2561 PGPE_ENABLE_EVENT GpeEnableEvent;
2562 PGPE_DISABLE_EVENT GpeDisableEvent;
2563 PGPE_CLEAR_STATUS GpeClearStatus;
2564 PREGISTER_FOR_DEVICE_NOTIFICATIONS RegisterForDeviceNotifications;
2565 PUNREGISTER_FOR_DEVICE_NOTIFICATIONS UnregisterForDeviceNotifications;
2566 } ACPI_INTERFACE_STANDARD, *PACPI_INTERFACE_STANDARD;
2567
2568 typedef BOOLEAN
2569 (NTAPI *PGPE_SERVICE_ROUTINE2)(
2570 PVOID ObjectContext,
2571 PVOID ServiceContext);
2572
2573 typedef NTSTATUS
2574 (NTAPI *PGPE_CONNECT_VECTOR2)(
2575 PVOID Context,
2576 ULONG GpeNumber,
2577 KINTERRUPT_MODE Mode,
2578 BOOLEAN Shareable,
2579 PGPE_SERVICE_ROUTINE ServiceRoutine,
2580 PVOID ServiceContext,
2581 PVOID *ObjectContext);
2582
2583 typedef NTSTATUS
2584 (NTAPI *PGPE_DISCONNECT_VECTOR2)(
2585 PVOID Context,
2586 PVOID ObjectContext);
2587
2588 typedef NTSTATUS
2589 (NTAPI *PGPE_ENABLE_EVENT2)(
2590 PVOID Context,
2591 PVOID ObjectContext);
2592
2593 typedef NTSTATUS
2594 (NTAPI *PGPE_DISABLE_EVENT2)(
2595 PVOID Context,
2596 PVOID ObjectContext);
2597
2598 typedef NTSTATUS
2599 (NTAPI *PGPE_CLEAR_STATUS2)(
2600 PVOID Context,
2601 PVOID ObjectContext);
2602
2603 typedef VOID
2604 (NTAPI *PDEVICE_NOTIFY_CALLBACK2)(
2605 PVOID NotificationContext,
2606 ULONG NotifyCode);
2607
2608 typedef NTSTATUS
2609 (NTAPI *PREGISTER_FOR_DEVICE_NOTIFICATIONS2)(
2610 PVOID Context,
2611 PDEVICE_NOTIFY_CALLBACK2 NotificationHandler,
2612 PVOID NotificationContext);
2613
2614 typedef VOID
2615 (NTAPI *PUNREGISTER_FOR_DEVICE_NOTIFICATIONS2)(
2616 PVOID Context);
2617
2618 typedef struct _ACPI_INTERFACE_STANDARD2 {
2619 USHORT Size;
2620 USHORT Version;
2621 PVOID Context;
2622 PINTERFACE_REFERENCE InterfaceReference;
2623 PINTERFACE_DEREFERENCE InterfaceDereference;
2624 PGPE_CONNECT_VECTOR2 GpeConnectVector;
2625 PGPE_DISCONNECT_VECTOR2 GpeDisconnectVector;
2626 PGPE_ENABLE_EVENT2 GpeEnableEvent;
2627 PGPE_DISABLE_EVENT2 GpeDisableEvent;
2628 PGPE_CLEAR_STATUS2 GpeClearStatus;
2629 PREGISTER_FOR_DEVICE_NOTIFICATIONS2 RegisterForDeviceNotifications;
2630 PUNREGISTER_FOR_DEVICE_NOTIFICATIONS2 UnregisterForDeviceNotifications;
2631 } ACPI_INTERFACE_STANDARD2, *PACPI_INTERFACE_STANDARD2;
2632
2633 #if !defined(_AMD64_) && !defined(_IA64_)
2634 #include <pshpack4.h>
2635 #endif
2636 typedef struct _IO_STACK_LOCATION {
2637 UCHAR MajorFunction;
2638 UCHAR MinorFunction;
2639 UCHAR Flags;
2640 UCHAR Control;
2641 union {
2642 struct {
2643 PIO_SECURITY_CONTEXT SecurityContext;
2644 ULONG Options;
2645 USHORT POINTER_ALIGNMENT FileAttributes;
2646 USHORT ShareAccess;
2647 ULONG POINTER_ALIGNMENT EaLength;
2648 } Create;
2649 struct {
2650 ULONG Length;
2651 ULONG POINTER_ALIGNMENT Key;
2652 LARGE_INTEGER ByteOffset;
2653 } Read;
2654 struct {
2655 ULONG Length;
2656 ULONG POINTER_ALIGNMENT Key;
2657 LARGE_INTEGER ByteOffset;
2658 } Write;
2659 struct {
2660 ULONG Length;
2661 PUNICODE_STRING FileName;
2662 FILE_INFORMATION_CLASS FileInformationClass;
2663 ULONG FileIndex;
2664 } QueryDirectory;
2665 struct {
2666 ULONG Length;
2667 ULONG CompletionFilter;
2668 } NotifyDirectory;
2669 struct {
2670 ULONG Length;
2671 FILE_INFORMATION_CLASS POINTER_ALIGNMENT FileInformationClass;
2672 } QueryFile;
2673 struct {
2674 ULONG Length;
2675 FILE_INFORMATION_CLASS POINTER_ALIGNMENT FileInformationClass;
2676 PFILE_OBJECT FileObject;
2677 _ANONYMOUS_UNION union {
2678 _ANONYMOUS_STRUCT struct {
2679 BOOLEAN ReplaceIfExists;
2680 BOOLEAN AdvanceOnly;
2681 } DUMMYSTRUCTNAME;
2682 ULONG ClusterCount;
2683 HANDLE DeleteHandle;
2684 } DUMMYUNIONNAME;
2685 } SetFile;
2686 struct {
2687 ULONG Length;
2688 PVOID EaList;
2689 ULONG EaListLength;
2690 ULONG EaIndex;
2691 } QueryEa;
2692 struct {
2693 ULONG Length;
2694 } SetEa;
2695 struct {
2696 ULONG Length;
2697 FS_INFORMATION_CLASS POINTER_ALIGNMENT FsInformationClass;
2698 } QueryVolume;
2699 struct {
2700 ULONG Length;
2701 FS_INFORMATION_CLASS FsInformationClass;
2702 } SetVolume;
2703 struct {
2704 ULONG OutputBufferLength;
2705 ULONG InputBufferLength;
2706 ULONG FsControlCode;
2707 PVOID Type3InputBuffer;
2708 } FileSystemControl;
2709 struct {
2710 PLARGE_INTEGER Length;
2711 ULONG Key;
2712 LARGE_INTEGER ByteOffset;
2713 } LockControl;
2714 struct {
2715 ULONG OutputBufferLength;
2716 ULONG POINTER_ALIGNMENT InputBufferLength;
2717 ULONG POINTER_ALIGNMENT IoControlCode;
2718 PVOID Type3InputBuffer;
2719 } DeviceIoControl;
2720 struct {
2721 SECURITY_INFORMATION SecurityInformation;
2722 ULONG POINTER_ALIGNMENT Length;
2723 } QuerySecurity;
2724 struct {
2725 SECURITY_INFORMATION SecurityInformation;
2726 PSECURITY_DESCRIPTOR SecurityDescriptor;
2727 } SetSecurity;
2728 struct {
2729 PVPB Vpb;
2730 PDEVICE_OBJECT DeviceObject;
2731 } MountVolume;
2732 struct {
2733 PVPB Vpb;
2734 PDEVICE_OBJECT DeviceObject;
2735 } VerifyVolume;
2736 struct {
2737 struct _SCSI_REQUEST_BLOCK *Srb;
2738 } Scsi;
2739 struct {
2740 ULONG Length;
2741 PSID StartSid;
2742 struct _FILE_GET_QUOTA_INFORMATION *SidList;
2743 ULONG SidListLength;
2744 } QueryQuota;
2745 struct {
2746 ULONG Length;
2747 } SetQuota;
2748 struct {
2749 DEVICE_RELATION_TYPE Type;
2750 } QueryDeviceRelations;
2751 struct {
2752 CONST GUID *InterfaceType;
2753 USHORT Size;
2754 USHORT Version;
2755 PINTERFACE Interface;
2756 PVOID InterfaceSpecificData;
2757 } QueryInterface;
2758 struct {
2759 PDEVICE_CAPABILITIES Capabilities;
2760 } DeviceCapabilities;
2761 struct {
2762 PIO_RESOURCE_REQUIREMENTS_LIST IoResourceRequirementList;
2763 } FilterResourceRequirements;
2764 struct {
2765 ULONG WhichSpace;
2766 PVOID Buffer;
2767 ULONG Offset;
2768 ULONG POINTER_ALIGNMENT Length;
2769 } ReadWriteConfig;
2770 struct {
2771 BOOLEAN Lock;
2772 } SetLock;
2773 struct {
2774 BUS_QUERY_ID_TYPE IdType;
2775 } QueryId;
2776 struct {
2777 DEVICE_TEXT_TYPE DeviceTextType;
2778 LCID POINTER_ALIGNMENT LocaleId;
2779 } QueryDeviceText;
2780 struct {
2781 BOOLEAN InPath;
2782 BOOLEAN Reserved[3];
2783 DEVICE_USAGE_NOTIFICATION_TYPE POINTER_ALIGNMENT Type;
2784 } UsageNotification;
2785 struct {
2786 SYSTEM_POWER_STATE PowerState;
2787 } WaitWake;
2788 struct {
2789 PPOWER_SEQUENCE PowerSequence;
2790 } PowerSequence;
2791 struct {
2792 ULONG SystemContext;
2793 POWER_STATE_TYPE POINTER_ALIGNMENT Type;
2794 POWER_STATE POINTER_ALIGNMENT State;
2795 POWER_ACTION POINTER_ALIGNMENT ShutdownType;
2796 } Power;
2797 struct {
2798 PCM_RESOURCE_LIST AllocatedResources;
2799 PCM_RESOURCE_LIST AllocatedResourcesTranslated;
2800 } StartDevice;
2801 struct {
2802 ULONG_PTR ProviderId;
2803 PVOID DataPath;
2804 ULONG BufferSize;
2805 PVOID Buffer;
2806 } WMI;
2807 struct {
2808 PVOID Argument1;
2809 PVOID Argument2;
2810 PVOID Argument3;
2811 PVOID Argument4;
2812 } Others;
2813 } Parameters;
2814 PDEVICE_OBJECT DeviceObject;
2815 PFILE_OBJECT FileObject;
2816 PIO_COMPLETION_ROUTINE CompletionRoutine;
2817 PVOID Context;
2818 } IO_STACK_LOCATION, *PIO_STACK_LOCATION;
2819 #if !defined(_AMD64_) && !defined(_IA64_)
2820 #include <poppack.h>
2821 #endif
2822
2823 /* IO_STACK_LOCATION.Control */
2824
2825 #define SL_PENDING_RETURNED 0x01
2826 #define SL_ERROR_RETURNED 0x02
2827 #define SL_INVOKE_ON_CANCEL 0x20
2828 #define SL_INVOKE_ON_SUCCESS 0x40
2829 #define SL_INVOKE_ON_ERROR 0x80
2830
2831 $endif (_WDMDDK_)
2832 $if (_WDMDDK_ || _DEVIOCTL_)
2833 #define METHOD_BUFFERED 0
2834 #define METHOD_IN_DIRECT 1
2835 #define METHOD_OUT_DIRECT 2
2836 #define METHOD_NEITHER 3
2837
2838 #define METHOD_DIRECT_TO_HARDWARE METHOD_IN_DIRECT
2839 #define METHOD_DIRECT_FROM_HARDWARE METHOD_OUT_DIRECT
2840
2841 $endif (_WDMDDK_ || _DEVIOCTL_)
2842 $if (_WDMDDK_)
2843 #define FILE_SUPERSEDED 0x00000000
2844 #define FILE_OPENED 0x00000001
2845 #define FILE_CREATED 0x00000002
2846 #define FILE_OVERWRITTEN 0x00000003
2847 #define FILE_EXISTS 0x00000004
2848 #define FILE_DOES_NOT_EXIST 0x00000005
2849
2850 #define FILE_USE_FILE_POINTER_POSITION 0xfffffffe
2851 #define FILE_WRITE_TO_END_OF_FILE 0xffffffff
2852
2853 /* also in winnt.h */
2854 #define FILE_LIST_DIRECTORY 0x00000001
2855 #define FILE_READ_DATA 0x00000001
2856 #define FILE_ADD_FILE 0x00000002
2857 #define FILE_WRITE_DATA 0x00000002
2858 #define FILE_ADD_SUBDIRECTORY 0x00000004
2859 #define FILE_APPEND_DATA 0x00000004
2860 #define FILE_CREATE_PIPE_INSTANCE 0x00000004
2861 #define FILE_READ_EA 0x00000008
2862 #define FILE_WRITE_EA 0x00000010
2863 #define FILE_EXECUTE 0x00000020
2864 #define FILE_TRAVERSE 0x00000020
2865 #define FILE_DELETE_CHILD 0x00000040
2866 #define FILE_READ_ATTRIBUTES 0x00000080
2867 #define FILE_WRITE_ATTRIBUTES 0x00000100
2868
2869 #define FILE_SHARE_READ 0x00000001
2870 #define FILE_SHARE_WRITE 0x00000002
2871 #define FILE_SHARE_DELETE 0x00000004
2872 #define FILE_SHARE_VALID_FLAGS 0x00000007
2873
2874 #define FILE_ATTRIBUTE_READONLY 0x00000001
2875 #define FILE_ATTRIBUTE_HIDDEN 0x00000002
2876 #define FILE_ATTRIBUTE_SYSTEM 0x00000004
2877 #define FILE_ATTRIBUTE_DIRECTORY 0x00000010
2878 #define FILE_ATTRIBUTE_ARCHIVE 0x00000020
2879 #define FILE_ATTRIBUTE_DEVICE 0x00000040
2880 #define FILE_ATTRIBUTE_NORMAL 0x00000080
2881 #define FILE_ATTRIBUTE_TEMPORARY 0x00000100
2882 #define FILE_ATTRIBUTE_SPARSE_FILE 0x00000200
2883 #define FILE_ATTRIBUTE_REPARSE_POINT 0x00000400
2884 #define FILE_ATTRIBUTE_COMPRESSED 0x00000800
2885 #define FILE_ATTRIBUTE_OFFLINE 0x00001000
2886 #define FILE_ATTRIBUTE_NOT_CONTENT_INDEXED 0x00002000
2887 #define FILE_ATTRIBUTE_ENCRYPTED 0x00004000
2888 #define FILE_ATTRIBUTE_VIRTUAL 0x00010000
2889
2890 #define FILE_ATTRIBUTE_VALID_FLAGS 0x00007fb7
2891 #define FILE_ATTRIBUTE_VALID_SET_FLAGS 0x000031a7
2892
2893 #define FILE_VALID_OPTION_FLAGS 0x00ffffff
2894 #define FILE_VALID_PIPE_OPTION_FLAGS 0x00000032
2895 #define FILE_VALID_MAILSLOT_OPTION_FLAGS 0x00000032
2896 #define FILE_VALID_SET_FLAGS 0x00000036
2897
2898 #define FILE_SUPERSEDE 0x00000000
2899 #define FILE_OPEN 0x00000001
2900 #define FILE_CREATE 0x00000002
2901 #define FILE_OPEN_IF 0x00000003
2902 #define FILE_OVERWRITE 0x00000004
2903 #define FILE_OVERWRITE_IF 0x00000005
2904 #define FILE_MAXIMUM_DISPOSITION 0x00000005
2905
2906 #define FILE_DIRECTORY_FILE 0x00000001
2907 #define FILE_WRITE_THROUGH 0x00000002
2908 #define FILE_SEQUENTIAL_ONLY 0x00000004
2909 #define FILE_NO_INTERMEDIATE_BUFFERING 0x00000008
2910 #define FILE_SYNCHRONOUS_IO_ALERT 0x00000010
2911 #define FILE_SYNCHRONOUS_IO_NONALERT 0x00000020
2912 #define FILE_NON_DIRECTORY_FILE 0x00000040
2913 #define FILE_CREATE_TREE_CONNECTION 0x00000080
2914 #define FILE_COMPLETE_IF_OPLOCKED 0x00000100
2915 #define FILE_NO_EA_KNOWLEDGE 0x00000200
2916 #define FILE_OPEN_REMOTE_INSTANCE 0x00000400
2917 #define FILE_RANDOM_ACCESS 0x00000800
2918 #define FILE_DELETE_ON_CLOSE 0x00001000
2919 #define FILE_OPEN_BY_FILE_ID 0x00002000
2920 #define FILE_OPEN_FOR_BACKUP_INTENT 0x00004000
2921 #define FILE_NO_COMPRESSION 0x00008000
2922 #if (NTDDI_VERSION >= NTDDI_WIN7)
2923 #define FILE_OPEN_REQUIRING_OPLOCK 0x00010000
2924 #define FILE_DISALLOW_EXCLUSIVE 0x00020000
2925 #endif /* (NTDDI_VERSION >= NTDDI_WIN7) */
2926 #define FILE_RESERVE_OPFILTER 0x00100000
2927 #define FILE_OPEN_REPARSE_POINT 0x00200000
2928 #define FILE_OPEN_NO_RECALL 0x00400000
2929 #define FILE_OPEN_FOR_FREE_SPACE_QUERY 0x00800000
2930
2931 $endif (_WDMDDK_)
2932 $if (_WDMDDK_ || _DEVIOCTL_)
2933 #define FILE_ANY_ACCESS 0x00000000
2934 #define FILE_SPECIAL_ACCESS FILE_ANY_ACCESS
2935 #define FILE_READ_ACCESS 0x00000001
2936 #define FILE_WRITE_ACCESS 0x00000002
2937
2938 $endif (_WDMDDK_ || _DEVIOCTL_)
2939 $if (_WDMDDK_)
2940 #define FILE_ALL_ACCESS \
2941 (STANDARD_RIGHTS_REQUIRED | \
2942 SYNCHRONIZE | \
2943 0x1FF)
2944
2945 #define FILE_GENERIC_EXECUTE \
2946 (STANDARD_RIGHTS_EXECUTE | \
2947 FILE_READ_ATTRIBUTES | \
2948 FILE_EXECUTE | \
2949 SYNCHRONIZE)
2950
2951 #define FILE_GENERIC_READ \
2952 (STANDARD_RIGHTS_READ | \
2953 FILE_READ_DATA | \
2954 FILE_READ_ATTRIBUTES | \
2955 FILE_READ_EA | \
2956 SYNCHRONIZE)
2957
2958 #define FILE_GENERIC_WRITE \
2959 (STANDARD_RIGHTS_WRITE | \
2960 FILE_WRITE_DATA | \
2961 FILE_WRITE_ATTRIBUTES | \
2962 FILE_WRITE_EA | \
2963 FILE_APPEND_DATA | \
2964 SYNCHRONIZE)
2965
2966 /* end winnt.h */
2967
2968 #define WMIREG_ACTION_REGISTER 1
2969 #define WMIREG_ACTION_DEREGISTER 2
2970 #define WMIREG_ACTION_REREGISTER 3
2971 #define WMIREG_ACTION_UPDATE_GUIDS 4
2972 #define WMIREG_ACTION_BLOCK_IRPS 5
2973
2974 #define WMIREGISTER 0
2975 #define WMIUPDATE 1
2976
2977 typedef VOID
2978 (NTAPI FWMI_NOTIFICATION_CALLBACK)(
2979 PVOID Wnode,
2980 PVOID Context);
2981 typedef FWMI_NOTIFICATION_CALLBACK *WMI_NOTIFICATION_CALLBACK;
2982
2983 #ifndef _PCI_X_
2984 #define _PCI_X_
2985
2986 typedef struct _PCI_SLOT_NUMBER {
2987 union {
2988 struct {
2989 ULONG DeviceNumber:5;
2990 ULONG FunctionNumber:3;
2991 ULONG Reserved:24;
2992 } bits;
2993 ULONG AsULONG;
2994 } u;
2995 } PCI_SLOT_NUMBER, *PPCI_SLOT_NUMBER;
2996
2997 #define PCI_TYPE0_ADDRESSES 6
2998 #define PCI_TYPE1_ADDRESSES 2
2999 #define PCI_TYPE2_ADDRESSES 5
3000
3001 typedef struct _PCI_COMMON_HEADER {
3002 PCI_COMMON_HEADER_LAYOUT
3003 } PCI_COMMON_HEADER, *PPCI_COMMON_HEADER;
3004
3005 #ifdef __cplusplus
3006 typedef struct _PCI_COMMON_CONFIG {
3007 PCI_COMMON_HEADER_LAYOUT
3008 UCHAR DeviceSpecific[192];
3009 } PCI_COMMON_CONFIG, *PPCI_COMMON_CONFIG;
3010 #else
3011 typedef struct _PCI_COMMON_CONFIG {
3012 PCI_COMMON_HEADER DUMMYSTRUCTNAME;
3013 UCHAR DeviceSpecific[192];
3014 } PCI_COMMON_CONFIG, *PPCI_COMMON_CONFIG;
3015 #endif
3016
3017 #define PCI_COMMON_HDR_LENGTH (FIELD_OFFSET(PCI_COMMON_CONFIG, DeviceSpecific))
3018
3019 #define PCI_EXTENDED_CONFIG_LENGTH 0x1000
3020
3021 #define PCI_MAX_DEVICES 32
3022 #define PCI_MAX_FUNCTION 8
3023 #define PCI_MAX_BRIDGE_NUMBER 0xFF
3024 #define PCI_INVALID_VENDORID 0xFFFF
3025
3026 /* PCI_COMMON_CONFIG.HeaderType */
3027 #define PCI_MULTIFUNCTION 0x80
3028 #define PCI_DEVICE_TYPE 0x00
3029 #define PCI_BRIDGE_TYPE 0x01
3030 #define PCI_CARDBUS_BRIDGE_TYPE 0x02
3031
3032 #define PCI_CONFIGURATION_TYPE(PciData) \
3033 (((PPCI_COMMON_CONFIG) (PciData))->HeaderType & ~PCI_MULTIFUNCTION)
3034
3035 #define PCI_MULTIFUNCTION_DEVICE(PciData) \
3036 ((((PPCI_COMMON_CONFIG) (PciData))->HeaderType & PCI_MULTIFUNCTION) != 0)
3037
3038 /* PCI_COMMON_CONFIG.Command */
3039 #define PCI_ENABLE_IO_SPACE 0x0001
3040 #define PCI_ENABLE_MEMORY_SPACE 0x0002
3041 #define PCI_ENABLE_BUS_MASTER 0x0004
3042 #define PCI_ENABLE_SPECIAL_CYCLES 0x0008
3043 #define PCI_ENABLE_WRITE_AND_INVALIDATE 0x0010
3044 #define PCI_ENABLE_VGA_COMPATIBLE_PALETTE 0x0020
3045 #define PCI_ENABLE_PARITY 0x0040
3046 #define PCI_ENABLE_WAIT_CYCLE 0x0080
3047 #define PCI_ENABLE_SERR 0x0100
3048 #define PCI_ENABLE_FAST_BACK_TO_BACK 0x0200
3049 #define PCI_DISABLE_LEVEL_INTERRUPT 0x0400
3050
3051 /* PCI_COMMON_CONFIG.Status */
3052 #define PCI_STATUS_INTERRUPT_PENDING 0x0008
3053 #define PCI_STATUS_CAPABILITIES_LIST 0x0010
3054 #define PCI_STATUS_66MHZ_CAPABLE 0x0020
3055 #define PCI_STATUS_UDF_SUPPORTED 0x0040
3056 #define PCI_STATUS_FAST_BACK_TO_BACK 0x0080
3057 #define PCI_STATUS_DATA_PARITY_DETECTED 0x0100
3058 #define PCI_STATUS_DEVSEL 0x0600
3059 #define PCI_STATUS_SIGNALED_TARGET_ABORT 0x0800
3060 #define PCI_STATUS_RECEIVED_TARGET_ABORT 0x1000
3061 #define PCI_STATUS_RECEIVED_MASTER_ABORT 0x2000
3062 #define PCI_STATUS_SIGNALED_SYSTEM_ERROR 0x4000
3063 #define PCI_STATUS_DETECTED_PARITY_ERROR 0x8000
3064
3065 /* IO_STACK_LOCATION.Parameters.ReadWriteControl.WhichSpace */
3066
3067 #define PCI_WHICHSPACE_CONFIG 0x0
3068 #define PCI_WHICHSPACE_ROM 0x52696350 /* 'PciR' */
3069
3070 #define PCI_CAPABILITY_ID_POWER_MANAGEMENT 0x01
3071 #define PCI_CAPABILITY_ID_AGP 0x02
3072 #define PCI_CAPABILITY_ID_VPD 0x03
3073 #define PCI_CAPABILITY_ID_SLOT_ID 0x04
3074 #define PCI_CAPABILITY_ID_MSI 0x05
3075 #define PCI_CAPABILITY_ID_CPCI_HOTSWAP 0x06
3076 #define PCI_CAPABILITY_ID_PCIX 0x07
3077 #define PCI_CAPABILITY_ID_HYPERTRANSPORT 0x08
3078 #define PCI_CAPABILITY_ID_VENDOR_SPECIFIC 0x09
3079 #define PCI_CAPABILITY_ID_DEBUG_PORT 0x0A
3080 #define PCI_CAPABILITY_ID_CPCI_RES_CTRL 0x0B
3081 #define PCI_CAPABILITY_ID_SHPC 0x0C
3082 #define PCI_CAPABILITY_ID_P2P_SSID 0x0D
3083 #define PCI_CAPABILITY_ID_AGP_TARGET 0x0E
3084 #define PCI_CAPABILITY_ID_SECURE 0x0F
3085 #define PCI_CAPABILITY_ID_PCI_EXPRESS 0x10
3086 #define PCI_CAPABILITY_ID_MSIX 0x11
3087
3088 typedef struct _PCI_CAPABILITIES_HEADER {
3089 UCHAR CapabilityID;
3090 UCHAR Next;
3091 } PCI_CAPABILITIES_HEADER, *PPCI_CAPABILITIES_HEADER;
3092
3093 typedef struct _PCI_PMC {
3094 UCHAR Version:3;
3095 UCHAR PMEClock:1;
3096 UCHAR Rsvd1:1;
3097 UCHAR DeviceSpecificInitialization:1;
3098 UCHAR Rsvd2:2;
3099 struct _PM_SUPPORT {
3100 UCHAR Rsvd2:1;
3101 UCHAR D1:1;
3102 UCHAR D2:1;
3103 UCHAR PMED0:1;
3104 UCHAR PMED1:1;
3105 UCHAR PMED2:1;
3106 UCHAR PMED3Hot:1;
3107 UCHAR PMED3Cold:1;
3108 } Support;
3109 } PCI_PMC, *PPCI_PMC;
3110
3111 typedef struct _PCI_PMCSR {
3112 USHORT PowerState:2;
3113 USHORT Rsvd1:6;
3114 USHORT PMEEnable:1;
3115 USHORT DataSelect:4;
3116 USHORT DataScale:2;
3117 USHORT PMEStatus:1;
3118 } PCI_PMCSR, *PPCI_PMCSR;
3119
3120 typedef struct _PCI_PMCSR_BSE {
3121 UCHAR Rsvd1:6;
3122 UCHAR D3HotSupportsStopClock:1;
3123 UCHAR BusPowerClockControlEnabled:1;
3124 } PCI_PMCSR_BSE, *PPCI_PMCSR_BSE;
3125
3126 typedef struct _PCI_PM_CAPABILITY {
3127 PCI_CAPABILITIES_HEADER Header;
3128 union {
3129 PCI_PMC Capabilities;
3130 USHORT AsUSHORT;
3131 } PMC;
3132 union {
3133 PCI_PMCSR ControlStatus;
3134 USHORT AsUSHORT;
3135 } PMCSR;
3136 union {
3137 PCI_PMCSR_BSE BridgeSupport;
3138 UCHAR AsUCHAR;
3139 } PMCSR_BSE;
3140 UCHAR Data;
3141 } PCI_PM_CAPABILITY, *PPCI_PM_CAPABILITY;
3142
3143 typedef struct {
3144 PCI_CAPABILITIES_HEADER Header;
3145 union {
3146 struct {
3147 USHORT DataParityErrorRecoveryEnable:1;
3148 USHORT EnableRelaxedOrdering:1;
3149 USHORT MaxMemoryReadByteCount:2;
3150 USHORT MaxOutstandingSplitTransactions:3;
3151 USHORT Reserved:9;
3152 } bits;
3153 USHORT AsUSHORT;
3154 } Command;
3155 union {
3156 struct {
3157 ULONG FunctionNumber:3;
3158 ULONG DeviceNumber:5;
3159 ULONG BusNumber:8;
3160 ULONG Device64Bit:1;
3161 ULONG Capable133MHz:1;
3162 ULONG SplitCompletionDiscarded:1;
3163 ULONG UnexpectedSplitCompletion:1;
3164 ULONG DeviceComplexity:1;
3165 ULONG DesignedMaxMemoryReadByteCount:2;
3166 ULONG DesignedMaxOutstandingSplitTransactions:3;
3167 ULONG DesignedMaxCumulativeReadSize:3;
3168 ULONG ReceivedSplitCompletionErrorMessage:1;
3169 ULONG CapablePCIX266:1;
3170 ULONG CapablePCIX533:1;
3171 } bits;
3172 ULONG AsULONG;
3173 } Status;
3174 } PCI_X_CAPABILITY, *PPCI_X_CAPABILITY;
3175
3176 #define PCI_EXPRESS_ADVANCED_ERROR_REPORTING_CAP_ID 0x0001
3177 #define PCI_EXPRESS_VIRTUAL_CHANNEL_CAP_ID 0x0002
3178 #define PCI_EXPRESS_DEVICE_SERIAL_NUMBER_CAP_ID 0x0003
3179 #define PCI_EXPRESS_POWER_BUDGETING_CAP_ID 0x0004
3180 #define PCI_EXPRESS_RC_LINK_DECLARATION_CAP_ID 0x0005
3181 #define PCI_EXPRESS_RC_INTERNAL_LINK_CONTROL_CAP_ID 0x0006
3182 #define PCI_EXPRESS_RC_EVENT_COLLECTOR_ENDPOINT_ASSOCIATION_CAP_ID 0x0007
3183 #define PCI_EXPRESS_MFVC_CAP_ID 0x0008
3184 #define PCI_EXPRESS_VC_AND_MFVC_CAP_ID 0x0009
3185 #define PCI_EXPRESS_RCRB_HEADER_CAP_ID 0x000A
3186 #define PCI_EXPRESS_SINGLE_ROOT_IO_VIRTUALIZATION_CAP_ID 0x0010
3187
3188 typedef struct _PCI_EXPRESS_ENHANCED_CAPABILITY_HEADER {
3189 USHORT CapabilityID;
3190 USHORT Version:4;
3191 USHORT Next:12;
3192 } PCI_EXPRESS_ENHANCED_CAPABILITY_HEADER, *PPCI_EXPRESS_ENHANCED_CAPABILITY_HEADER;
3193
3194 typedef struct _PCI_EXPRESS_SERIAL_NUMBER_CAPABILITY {
3195 PCI_EXPRESS_ENHANCED_CAPABILITY_HEADER Header;
3196 ULONG LowSerialNumber;
3197 ULONG HighSerialNumber;
3198 } PCI_EXPRESS_SERIAL_NUMBER_CAPABILITY, *PPCI_EXPRESS_SERIAL_NUMBER_CAPABILITY;
3199
3200 typedef union _PCI_EXPRESS_UNCORRECTABLE_ERROR_STATUS {
3201 struct {
3202 ULONG Undefined:1;
3203 ULONG Reserved1:3;
3204 ULONG DataLinkProtocolError:1;
3205 ULONG SurpriseDownError:1;
3206 ULONG Reserved2:6;
3207 ULONG PoisonedTLP:1;
3208 ULONG FlowControlProtocolError:1;
3209 ULONG CompletionTimeout:1;
3210 ULONG CompleterAbort:1;
3211 ULONG UnexpectedCompletion:1;
3212 ULONG ReceiverOverflow:1;
3213 ULONG MalformedTLP:1;
3214 ULONG ECRCError:1;
3215 ULONG UnsupportedRequestError:1;
3216 ULONG Reserved3:11;
3217 } DUMMYSTRUCTNAME;
3218 ULONG AsULONG;
3219 } PCI_EXPRESS_UNCORRECTABLE_ERROR_STATUS, *PPCI_EXPRESS_UNCORRECTABLE_ERROR_STATUS;
3220
3221 typedef union _PCI_EXPRESS_UNCORRECTABLE_ERROR_MASK {
3222 struct {
3223 ULONG Undefined:1;
3224 ULONG Reserved1:3;
3225 ULONG DataLinkProtocolError:1;
3226 ULONG SurpriseDownError:1;
3227 ULONG Reserved2:6;
3228 ULONG PoisonedTLP:1;
3229 ULONG FlowControlProtocolError:1;
3230 ULONG CompletionTimeout:1;
3231 ULONG CompleterAbort:1;
3232 ULONG UnexpectedCompletion:1;
3233 ULONG ReceiverOverflow:1;
3234 ULONG MalformedTLP:1;
3235 ULONG ECRCError:1;
3236 ULONG UnsupportedRequestError:1;
3237 ULONG Reserved3:11;
3238 } DUMMYSTRUCTNAME;
3239 ULONG AsULONG;
3240 } PCI_EXPRESS_UNCORRECTABLE_ERROR_MASK, *PPCI_EXPRESS_UNCORRECTABLE_ERROR_MASK;
3241
3242 typedef union _PCI_EXPRESS_UNCORRECTABLE_ERROR_SEVERITY {
3243 struct {
3244 ULONG Undefined:1;
3245 ULONG Reserved1:3;
3246 ULONG DataLinkProtocolError:1;
3247 ULONG SurpriseDownError:1;
3248 ULONG Reserved2:6;
3249 ULONG PoisonedTLP:1;
3250 ULONG FlowControlProtocolError:1;
3251 ULONG CompletionTimeout:1;
3252 ULONG CompleterAbort:1;
3253 ULONG UnexpectedCompletion:1;
3254 ULONG ReceiverOverflow:1;
3255 ULONG MalformedTLP:1;
3256 ULONG ECRCError:1;
3257 ULONG UnsupportedRequestError:1;
3258 ULONG Reserved3:11;
3259 } DUMMYSTRUCTNAME;
3260 ULONG AsULONG;
3261 } PCI_EXPRESS_UNCORRECTABLE_ERROR_SEVERITY, *PPCI_EXPRESS_UNCORRECTABLE_ERROR_SEVERITY;
3262
3263 typedef union _PCI_EXPRESS_CORRECTABLE_ERROR_STATUS {
3264 struct {
3265 ULONG ReceiverError:1;
3266 ULONG Reserved1:5;
3267 ULONG BadTLP:1;
3268 ULONG BadDLLP:1;
3269 ULONG ReplayNumRollover:1;
3270 ULONG Reserved2:3;
3271 ULONG ReplayTimerTimeout:1;
3272 ULONG AdvisoryNonFatalError:1;
3273 ULONG Reserved3:18;
3274 } DUMMYSTRUCTNAME;
3275 ULONG AsULONG;
3276 } PCI_EXPRESS_CORRECTABLE_ERROR_STATUS, *PPCI_CORRECTABLE_ERROR_STATUS;
3277
3278 typedef union _PCI_EXPRESS_CORRECTABLE_ERROR_MASK {
3279 struct {
3280 ULONG ReceiverError:1;
3281 ULONG Reserved1:5;
3282 ULONG BadTLP:1;
3283 ULONG BadDLLP:1;
3284 ULONG ReplayNumRollover:1;
3285 ULONG Reserved2:3;
3286 ULONG ReplayTimerTimeout:1;
3287 ULONG AdvisoryNonFatalError:1;
3288 ULONG Reserved3:18;
3289 } DUMMYSTRUCTNAME;
3290 ULONG AsULONG;
3291 } PCI_EXPRESS_CORRECTABLE_ERROR_MASK, *PPCI_CORRECTABLE_ERROR_MASK;
3292
3293 typedef union _PCI_EXPRESS_AER_CAPABILITIES {
3294 struct {
3295 ULONG FirstErrorPointer:5;
3296 ULONG ECRCGenerationCapable:1;
3297 ULONG ECRCGenerationEnable:1;
3298 ULONG ECRCCheckCapable:1;
3299 ULONG ECRCCheckEnable:1;
3300 ULONG Reserved:23;
3301 } DUMMYSTRUCTNAME;
3302 ULONG AsULONG;
3303 } PCI_EXPRESS_AER_CAPABILITIES, *PPCI_EXPRESS_AER_CAPABILITIES;
3304
3305 typedef union _PCI_EXPRESS_ROOT_ERROR_COMMAND {
3306 struct {
3307 ULONG CorrectableErrorReportingEnable:1;
3308 ULONG NonFatalErrorReportingEnable:1;
3309 ULONG FatalErrorReportingEnable:1;
3310 ULONG Reserved:29;
3311 } DUMMYSTRUCTNAME;
3312 ULONG AsULONG;
3313 } PCI_EXPRESS_ROOT_ERROR_COMMAND, *PPCI_EXPRESS_ROOT_ERROR_COMMAND;
3314
3315 typedef union _PCI_EXPRESS_ROOT_ERROR_STATUS {
3316 struct {
3317 ULONG CorrectableErrorReceived:1;
3318 ULONG MultipleCorrectableErrorsReceived:1;
3319 ULONG UncorrectableErrorReceived:1;
3320 ULONG MultipleUncorrectableErrorsReceived:1;
3321 ULONG FirstUncorrectableFatal:1;
3322 ULONG NonFatalErrorMessagesReceived:1;
3323 ULONG FatalErrorMessagesReceived:1;
3324 ULONG Reserved:20;
3325 ULONG AdvancedErrorInterruptMessageNumber:5;
3326 } DUMMYSTRUCTNAME;
3327 ULONG AsULONG;
3328 } PCI_EXPRESS_ROOT_ERROR_STATUS, *PPCI_EXPRESS_ROOT_ERROR_STATUS;
3329
3330 typedef union _PCI_EXPRESS_ERROR_SOURCE_ID {
3331 struct {
3332 USHORT CorrectableSourceIdFun:3;
3333 USHORT CorrectableSourceIdDev:5;
3334 USHORT CorrectableSourceIdBus:8;
3335 USHORT UncorrectableSourceIdFun:3;
3336 USHORT UncorrectableSourceIdDev:5;
3337 USHORT UncorrectableSourceIdBus:8;
3338 } DUMMYSTRUCTNAME;
3339 ULONG AsULONG;
3340 } PCI_EXPRESS_ERROR_SOURCE_ID, *PPCI_EXPRESS_ERROR_SOURCE_ID;
3341
3342 typedef union _PCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_STATUS {
3343 struct {
3344 ULONG TargetAbortOnSplitCompletion:1;
3345 ULONG MasterAbortOnSplitCompletion:1;
3346 ULONG ReceivedTargetAbort:1;
3347 ULONG ReceivedMasterAbort:1;
3348 ULONG RsvdZ:1;
3349 ULONG UnexpectedSplitCompletionError:1;
3350 ULONG UncorrectableSplitCompletion:1;
3351 ULONG UncorrectableDataError:1;
3352 ULONG UncorrectableAttributeError:1;
3353 ULONG UncorrectableAddressError:1;
3354 ULONG DelayedTransactionDiscardTimerExpired:1;
3355 ULONG PERRAsserted:1;
3356 ULONG SERRAsserted:1;
3357 ULONG InternalBridgeError:1;
3358 ULONG Reserved:18;
3359 } DUMMYSTRUCTNAME;
3360 ULONG AsULONG;
3361 } PCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_STATUS, *PPCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_STATUS;
3362
3363 typedef union _PCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_MASK {
3364 struct {
3365 ULONG TargetAbortOnSplitCompletion:1;
3366 ULONG MasterAbortOnSplitCompletion:1;
3367 ULONG ReceivedTargetAbort:1;
3368 ULONG ReceivedMasterAbort:1;
3369 ULONG RsvdZ:1;
3370 ULONG UnexpectedSplitCompletionError:1;
3371 ULONG UncorrectableSplitCompletion:1;
3372 ULONG UncorrectableDataError:1;
3373 ULONG UncorrectableAttributeError:1;
3374 ULONG UncorrectableAddressError:1;
3375 ULONG DelayedTransactionDiscardTimerExpired:1;
3376 ULONG PERRAsserted:1;
3377 ULONG SERRAsserted:1;
3378 ULONG InternalBridgeError:1;
3379 ULONG Reserved:18;
3380 } DUMMYSTRUCTNAME;
3381 ULONG AsULONG;
3382 } PCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_MASK, *PPCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_MASK;
3383
3384 typedef union _PCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_SEVERITY {
3385 struct {
3386 ULONG TargetAbortOnSplitCompletion:1;
3387 ULONG MasterAbortOnSplitCompletion:1;
3388 ULONG ReceivedTargetAbort:1;
3389 ULONG ReceivedMasterAbort:1;
3390 ULONG RsvdZ:1;
3391 ULONG UnexpectedSplitCompletionError:1;
3392 ULONG UncorrectableSplitCompletion:1;
3393 ULONG UncorrectableDataError:1;
3394 ULONG UncorrectableAttributeError:1;
3395 ULONG UncorrectableAddressError:1;
3396 ULONG DelayedTransactionDiscardTimerExpired:1;
3397 ULONG PERRAsserted:1;
3398 ULONG SERRAsserted:1;
3399 ULONG InternalBridgeError:1;
3400 ULONG Reserved:18;
3401 } DUMMYSTRUCTNAME;
3402 ULONG AsULONG;
3403 } PCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_SEVERITY, *PPCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_SEVERITY;
3404
3405 typedef union _PCI_EXPRESS_SEC_AER_CAPABILITIES {
3406 struct {
3407 ULONG SecondaryUncorrectableFirstErrorPtr:5;
3408 ULONG Reserved:27;
3409 } DUMMYSTRUCTNAME;
3410 ULONG AsULONG;
3411 } PCI_EXPRESS_SEC_AER_CAPABILITIES, *PPCI_EXPRESS_SEC_AER_CAPABILITIES;
3412
3413 #define ROOT_CMD_ENABLE_CORRECTABLE_ERROR_REPORTING 0x00000001
3414 #define ROOT_CMD_ENABLE_NONFATAL_ERROR_REPORTING 0x00000002
3415 #define ROOT_CMD_ENABLE_FATAL_ERROR_REPORTING 0x00000004
3416
3417 #define ROOT_CMD_ERROR_REPORTING_ENABLE_MASK \
3418 (ROOT_CMD_ENABLE_FATAL_ERROR_REPORTING | \
3419 ROOT_CMD_ENABLE_NONFATAL_ERROR_REPORTING | \
3420 ROOT_CMD_ENABLE_CORRECTABLE_ERROR_REPORTING)
3421
3422 typedef struct _PCI_EXPRESS_AER_CAPABILITY {
3423 PCI_EXPRESS_ENHANCED_CAPABILITY_HEADER Header;
3424 PCI_EXPRESS_UNCORRECTABLE_ERROR_STATUS UncorrectableErrorStatus;
3425 PCI_EXPRESS_UNCORRECTABLE_ERROR_MASK UncorrectableErrorMask;
3426 PCI_EXPRESS_UNCORRECTABLE_ERROR_SEVERITY UncorrectableErrorSeverity;
3427 PCI_EXPRESS_CORRECTABLE_ERROR_STATUS CorrectableErrorStatus;
3428 PCI_EXPRESS_CORRECTABLE_ERROR_MASK CorrectableErrorMask;
3429 PCI_EXPRESS_AER_CAPABILITIES CapabilitiesAndControl;
3430 ULONG HeaderLog[4];
3431 PCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_STATUS SecUncorrectableErrorStatus;
3432 PCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_MASK SecUncorrectableErrorMask;
3433 PCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_SEVERITY SecUncorrectableErrorSeverity;
3434 PCI_EXPRESS_SEC_AER_CAPABILITIES SecCapabilitiesAndControl;
3435 ULONG SecHeaderLog[4];
3436 } PCI_EXPRESS_AER_CAPABILITY, *PPCI_EXPRESS_AER_CAPABILITY;
3437
3438 typedef struct _PCI_EXPRESS_ROOTPORT_AER_CAPABILITY {
3439 PCI_EXPRESS_ENHANCED_CAPABILITY_HEADER Header;
3440 PCI_EXPRESS_UNCORRECTABLE_ERROR_STATUS UncorrectableErrorStatus;
3441 PCI_EXPRESS_UNCORRECTABLE_ERROR_MASK UncorrectableErrorMask;
3442 PCI_EXPRESS_UNCORRECTABLE_ERROR_SEVERITY UncorrectableErrorSeverity;
3443 PCI_EXPRESS_CORRECTABLE_ERROR_STATUS CorrectableErrorStatus;
3444 PCI_EXPRESS_CORRECTABLE_ERROR_MASK CorrectableErrorMask;
3445 PCI_EXPRESS_AER_CAPABILITIES CapabilitiesAndControl;
3446 ULONG HeaderLog[4];
3447 PCI_EXPRESS_ROOT_ERROR_COMMAND RootErrorCommand;
3448 PCI_EXPRESS_ROOT_ERROR_STATUS RootErrorStatus;
3449 PCI_EXPRESS_ERROR_SOURCE_ID ErrorSourceId;
3450 } PCI_EXPRESS_ROOTPORT_AER_CAPABILITY, *PPCI_EXPRESS_ROOTPORT_AER_CAPABILITY;
3451
3452 typedef struct _PCI_EXPRESS_BRIDGE_AER_CAPABILITY {
3453 PCI_EXPRESS_ENHANCED_CAPABILITY_HEADER Header;
3454 PCI_EXPRESS_UNCORRECTABLE_ERROR_STATUS UncorrectableErrorStatus;
3455 PCI_EXPRESS_UNCORRECTABLE_ERROR_MASK UncorrectableErrorMask;
3456 PCI_EXPRESS_UNCORRECTABLE_ERROR_SEVERITY UncorrectableErrorSeverity;
3457 PCI_EXPRESS_CORRECTABLE_ERROR_STATUS CorrectableErrorStatus;
3458 PCI_EXPRESS_CORRECTABLE_ERROR_MASK CorrectableErrorMask;
3459 PCI_EXPRESS_AER_CAPABILITIES CapabilitiesAndControl;
3460 ULONG HeaderLog[4];
3461 PCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_STATUS SecUncorrectableErrorStatus;
3462 PCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_MASK SecUncorrectableErrorMask;
3463 PCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_SEVERITY SecUncorrectableErrorSeverity;
3464 PCI_EXPRESS_SEC_AER_CAPABILITIES SecCapabilitiesAndControl;
3465 ULONG SecHeaderLog[4];
3466 } PCI_EXPRESS_BRIDGE_AER_CAPABILITY, *PPCI_EXPRESS_BRIDGE_AER_CAPABILITY;
3467
3468 typedef union _PCI_EXPRESS_SRIOV_CAPS {
3469 struct {
3470 ULONG VFMigrationCapable:1;
3471 ULONG Reserved1:20;
3472 ULONG VFMigrationInterruptNumber:11;
3473 } DUMMYSTRUCTNAME;
3474 ULONG AsULONG;
3475 } PCI_EXPRESS_SRIOV_CAPS, *PPCI_EXPRESS_SRIOV_CAPS;
3476
3477 typedef union _PCI_EXPRESS_SRIOV_CONTROL {
3478 struct {
3479 USHORT VFEnable:1;
3480 USHORT VFMigrationEnable:1;
3481 USHORT VFMigrationInterruptEnable:1;
3482 USHORT VFMemorySpaceEnable:1;
3483 USHORT ARICapableHierarchy:1;
3484 USHORT Reserved1:11;
3485 } DUMMYSTRUCTNAME;
3486 USHORT AsUSHORT;
3487 } PCI_EXPRESS_SRIOV_CONTROL, *PPCI_EXPRESS_SRIOV_CONTROL;
3488
3489 typedef union _PCI_EXPRESS_SRIOV_STATUS {
3490 struct {
3491 USHORT VFMigrationStatus:1;
3492 USHORT Reserved1:15;
3493 } DUMMYSTRUCTNAME;
3494 USHORT AsUSHORT;
3495 } PCI_EXPRESS_SRIOV_STATUS, *PPCI_EXPRESS_SRIOV_STATUS;
3496
3497 typedef union _PCI_EXPRESS_SRIOV_MIGRATION_STATE_ARRAY {
3498 struct {
3499 ULONG VFMigrationStateBIR:3;
3500 ULONG VFMigrationStateOffset:29;
3501 } DUMMYSTRUCTNAME;
3502 ULONG AsULONG;
3503 } PCI_EXPRESS_SRIOV_MIGRATION_STATE_ARRAY, *PPCI_EXPRESS_SRIOV_MIGRATION_STATE_ARRAY;
3504
3505 typedef struct _PCI_EXPRESS_SRIOV_CAPABILITY {
3506 PCI_EXPRESS_ENHANCED_CAPABILITY_HEADER Header;
3507 PCI_EXPRESS_SRIOV_CAPS SRIOVCapabilities;
3508 PCI_EXPRESS_SRIOV_CONTROL SRIOVControl;
3509 PCI_EXPRESS_SRIOV_STATUS SRIOVStatus;
3510 USHORT InitialVFs;
3511 USHORT TotalVFs;
3512 USHORT NumVFs;
3513 UCHAR FunctionDependencyLink;
3514 UCHAR RsvdP1;
3515 USHORT FirstVFOffset;
3516 USHORT VFStride;
3517 USHORT RsvdP2;
3518 USHORT VFDeviceId;
3519 ULONG SupportedPageSizes;
3520 ULONG SystemPageSize;
3521 ULONG BaseAddresses[PCI_TYPE0_ADDRESSES];
3522 PCI_EXPRESS_SRIOV_MIGRATION_STATE_ARRAY VFMigrationStateArrayOffset;
3523 } PCI_EXPRESS_SRIOV_CAPABILITY, *PPCI_EXPRESS_SRIOV_CAPABILITY;
3524
3525 /* PCI device classes */
3526 #define PCI_CLASS_PRE_20 0x00
3527 #define PCI_CLASS_MASS_STORAGE_CTLR 0x01
3528 #define PCI_CLASS_NETWORK_CTLR 0x02
3529 #define PCI_CLASS_DISPLAY_CTLR 0x03
3530 #define PCI_CLASS_MULTIMEDIA_DEV 0x04
3531 #define PCI_CLASS_MEMORY_CTLR 0x05
3532 #define PCI_CLASS_BRIDGE_DEV 0x06
3533 #define PCI_CLASS_SIMPLE_COMMS_CTLR 0x07
3534 #define PCI_CLASS_BASE_SYSTEM_DEV 0x08
3535 #define PCI_CLASS_INPUT_DEV 0x09
3536 #define PCI_CLASS_DOCKING_STATION 0x0a
3537 #define PCI_CLASS_PROCESSOR 0x0b
3538 #define PCI_CLASS_SERIAL_BUS_CTLR 0x0c
3539 #define PCI_CLASS_WIRELESS_CTLR 0x0d
3540 #define PCI_CLASS_INTELLIGENT_IO_CTLR 0x0e
3541 #define PCI_CLASS_SATELLITE_COMMS_CTLR 0x0f
3542 #define PCI_CLASS_ENCRYPTION_DECRYPTION 0x10
3543 #define PCI_CLASS_DATA_ACQ_SIGNAL_PROC 0x11
3544 #define PCI_CLASS_NOT_DEFINED 0xff
3545
3546 /* PCI device subclasses for class 0 */
3547 #define PCI_SUBCLASS_PRE_20_NON_VGA 0x00
3548 #define PCI_SUBCLASS_PRE_20_VGA 0x01
3549
3550 /* PCI device subclasses for class 1 (mass storage controllers)*/
3551 #define PCI_SUBCLASS_MSC_SCSI_BUS_CTLR 0x00
3552 #define PCI_SUBCLASS_MSC_IDE_CTLR 0x01
3553 #define PCI_SUBCLASS_MSC_FLOPPY_CTLR 0x02
3554 #define PCI_SUBCLASS_MSC_IPI_CTLR 0x03
3555 #define PCI_SUBCLASS_MSC_RAID_CTLR 0x04
3556 #define PCI_SUBCLASS_MSC_OTHER 0x80
3557
3558 /* PCI device subclasses for class 2 (network controllers)*/
3559 #define PCI_SUBCLASS_NET_ETHERNET_CTLR 0x00
3560 #define PCI_SUBCLASS_NET_TOKEN_RING_CTLR 0x01
3561 #define PCI_SUBCLASS_NET_FDDI_CTLR 0x02
3562 #define PCI_SUBCLASS_NET_ATM_CTLR 0x03
3563 #define PCI_SUBCLASS_NET_ISDN_CTLR 0x04
3564 #define PCI_SUBCLASS_NET_OTHER 0x80
3565
3566 /* PCI device subclasses for class 3 (display controllers)*/
3567 #define PCI_SUBCLASS_VID_VGA_CTLR 0x00
3568 #define PCI_SUBCLASS_VID_XGA_CTLR 0x01
3569 #define PCI_SUBCLASS_VID_3D_CTLR 0x02
3570 #define PCI_SUBCLASS_VID_OTHER 0x80
3571
3572 /* PCI device subclasses for class 4 (multimedia device)*/
3573 #define PCI_SUBCLASS_MM_VIDEO_DEV 0x00
3574 #define PCI_SUBCLASS_MM_AUDIO_DEV 0x01
3575 #define PCI_SUBCLASS_MM_TELEPHONY_DEV 0x02
3576 #define PCI_SUBCLASS_MM_OTHER 0x80
3577
3578 /* PCI device subclasses for class 5 (memory controller)*/
3579 #define PCI_SUBCLASS_MEM_RAM 0x00
3580 #define PCI_SUBCLASS_MEM_FLASH 0x01
3581 #define PCI_SUBCLASS_MEM_OTHER 0x80
3582
3583 /* PCI device subclasses for class 6 (bridge device)*/
3584 #define PCI_SUBCLASS_BR_HOST 0x00
3585 #define PCI_SUBCLASS_BR_ISA 0x01
3586 #define PCI_SUBCLASS_BR_EISA 0x02
3587 #define PCI_SUBCLASS_BR_MCA 0x03
3588 #define PCI_SUBCLASS_BR_PCI_TO_PCI 0x04
3589 #define PCI_SUBCLASS_BR_PCMCIA 0x05
3590 #define PCI_SUBCLASS_BR_NUBUS 0x06
3591 #define PCI_SUBCLASS_BR_CARDBUS 0x07
3592 #define PCI_SUBCLASS_BR_RACEWAY 0x08
3593 #define PCI_SUBCLASS_BR_OTHER 0x80
3594
3595 #define PCI_SUBCLASS_COM_SERIAL 0x00
3596 #define PCI_SUBCLASS_COM_PARALLEL 0x01
3597 #define PCI_SUBCLASS_COM_MULTIPORT 0x02
3598 #define PCI_SUBCLASS_COM_MODEM 0x03
3599 #define PCI_SUBCLASS_COM_OTHER 0x80
3600
3601 #define PCI_SUBCLASS_SYS_INTERRUPT_CTLR 0x00
3602 #define PCI_SUBCLASS_SYS_DMA_CTLR 0x01
3603 #define PCI_SUBCLASS_SYS_SYSTEM_TIMER 0x02
3604 #define PCI_SUBCLASS_SYS_REAL_TIME_CLOCK 0x03
3605 #define PCI_SUBCLASS_SYS_GEN_HOTPLUG_CTLR 0x04
3606 #define PCI_SUBCLASS_SYS_SDIO_CTRL 0x05
3607 #define PCI_SUBCLASS_SYS_OTHER 0x80
3608
3609 #define PCI_SUBCLASS_INP_KEYBOARD 0x00
3610 #define PCI_SUBCLASS_INP_DIGITIZER 0x01
3611 #define PCI_SUBCLASS_INP_MOUSE 0x02
3612 #define PCI_SUBCLASS_INP_SCANNER 0x03
3613 #define PCI_SUBCLASS_INP_GAMEPORT 0x04
3614 #define PCI_SUBCLASS_INP_OTHER 0x80
3615
3616 #define PCI_SUBCLASS_DOC_GENERIC 0x00
3617 #define PCI_SUBCLASS_DOC_OTHER 0x80
3618
3619 #define PCI_SUBCLASS_PROC_386 0x00
3620 #define PCI_SUBCLASS_PROC_486 0x01
3621 #define PCI_SUBCLASS_PROC_PENTIUM 0x02
3622 #define PCI_SUBCLASS_PROC_ALPHA 0x10
3623 #define PCI_SUBCLASS_PROC_POWERPC 0x20
3624 #define PCI_SUBCLASS_PROC_COPROCESSOR 0x40
3625
3626 /* PCI device subclasses for class C (serial bus controller)*/
3627 #define PCI_SUBCLASS_SB_IEEE1394 0x00
3628 #define PCI_SUBCLASS_SB_ACCESS 0x01
3629 #define PCI_SUBCLASS_SB_SSA 0x02
3630 #define PCI_SUBCLASS_SB_USB 0x03
3631 #define PCI_SUBCLASS_SB_FIBRE_CHANNEL 0x04
3632 #define PCI_SUBCLASS_SB_SMBUS 0x05
3633
3634 #define PCI_SUBCLASS_WIRELESS_IRDA 0x00
3635 #define PCI_SUBCLASS_WIRELESS_CON_IR 0x01
3636 #define PCI_SUBCLASS_WIRELESS_RF 0x10
3637 #define PCI_SUBCLASS_WIRELESS_OTHER 0x80
3638
3639 #define PCI_SUBCLASS_INTIO_I2O 0x00
3640
3641 #define PCI_SUBCLASS_SAT_TV 0x01
3642 #define PCI_SUBCLASS_SAT_AUDIO 0x02
3643 #define PCI_SUBCLASS_SAT_VOICE 0x03
3644 #define PCI_SUBCLASS_SAT_DATA 0x04
3645
3646 #define PCI_SUBCLASS_CRYPTO_NET_COMP 0x00
3647 #define PCI_SUBCLASS_CRYPTO_ENTERTAINMENT 0x10
3648 #define PCI_SUBCLASS_CRYPTO_OTHER 0x80
3649
3650 #define PCI_SUBCLASS_DASP_DPIO 0x00
3651 #define PCI_SUBCLASS_DASP_OTHER 0x80
3652
3653 #define PCI_ADDRESS_IO_SPACE 0x00000001
3654 #define PCI_ADDRESS_MEMORY_TYPE_MASK 0x00000006
3655 #define PCI_ADDRESS_MEMORY_PREFETCHABLE 0x00000008
3656 #define PCI_ADDRESS_IO_ADDRESS_MASK 0xfffffffc
3657 #define PCI_ADDRESS_MEMORY_ADDRESS_MASK 0xfffffff0
3658 #define PCI_ADDRESS_ROM_ADDRESS_MASK 0xfffff800
3659
3660 #define PCI_TYPE_32BIT 0
3661 #define PCI_TYPE_20BIT 2
3662 #define PCI_TYPE_64BIT 4
3663
3664 #define PCI_ROMADDRESS_ENABLED 0x00000001
3665
3666 #endif /* _PCI_X_ */
3667
3668 #define PCI_EXPRESS_LINK_QUIESCENT_INTERFACE_VERSION 1
3669
3670 typedef NTSTATUS
3671 (NTAPI PCI_EXPRESS_ENTER_LINK_QUIESCENT_MODE)(
3672 IN OUT PVOID Context);
3673 typedef PCI_EXPRESS_ENTER_LINK_QUIESCENT_MODE *PPCI_EXPRESS_ENTER_LINK_QUIESCENT_MODE;
3674
3675 typedef NTSTATUS
3676 (NTAPI PCI_EXPRESS_EXIT_LINK_QUIESCENT_MODE)(
3677 IN OUT PVOID Context);
3678 typedef PCI_EXPRESS_EXIT_LINK_QUIESCENT_MODE *PPCI_EXPRESS_EXIT_LINK_QUIESCENT_MODE;
3679
3680 typedef struct _PCI_EXPRESS_LINK_QUIESCENT_INTERFACE {
3681 USHORT Size;
3682 USHORT Version;
3683 PVOID Context;
3684 PINTERFACE_REFERENCE InterfaceReference;
3685 PINTERFACE_DEREFERENCE InterfaceDereference;
3686 PPCI_EXPRESS_ENTER_LINK_QUIESCENT_MODE PciExpressEnterLinkQuiescentMode;
3687 PPCI_EXPRESS_EXIT_LINK_QUIESCENT_MODE PciExpressExitLinkQuiescentMode;
3688 } PCI_EXPRESS_LINK_QUIESCENT_INTERFACE, *PPCI_EXPRESS_LINK_QUIESCENT_INTERFACE;
3689
3690 #define PCI_EXPRESS_ROOT_PORT_INTERFACE_VERSION 1
3691
3692 typedef ULONG
3693 (NTAPI *PPCI_EXPRESS_ROOT_PORT_READ_CONFIG_SPACE)(
3694 IN PVOID Context,
3695 OUT PVOID Buffer,
3696 IN ULONG Offset,
3697 IN ULONG Length);
3698
3699 typedef ULONG
3700 (NTAPI *PPCI_EXPRESS_ROOT_PORT_WRITE_CONFIG_SPACE)(
3701 IN PVOID Context,
3702 IN PVOID Buffer,
3703 IN ULONG Offset,
3704 IN ULONG Length);
3705
3706 typedef struct _PCI_EXPRESS_ROOT_PORT_INTERFACE {
3707 USHORT Size;
3708 USHORT Version;
3709 PVOID Context;
3710 PINTERFACE_REFERENCE InterfaceReference;
3711 PINTERFACE_DEREFERENCE InterfaceDereference;
3712 PPCI_EXPRESS_ROOT_PORT_READ_CONFIG_SPACE ReadConfigSpace;
3713 PPCI_EXPRESS_ROOT_PORT_WRITE_CONFIG_SPACE WriteConfigSpace;
3714 } PCI_EXPRESS_ROOT_PORT_INTERFACE, *PPCI_EXPRESS_ROOT_PORT_INTERFACE;
3715
3716 #define PCI_MSIX_TABLE_CONFIG_INTERFACE_VERSION 1
3717
3718 typedef NTSTATUS
3719 (NTAPI PCI_MSIX_SET_ENTRY)(
3720 IN PVOID Context,
3721 IN ULONG TableEntry,
3722 IN ULONG MessageNumber);
3723 typedef PCI_MSIX_SET_ENTRY *PPCI_MSIX_SET_ENTRY;
3724
3725 typedef NTSTATUS
3726 (NTAPI PCI_MSIX_MASKUNMASK_ENTRY)(
3727 IN PVOID Context,
3728 IN ULONG TableEntry);
3729 typedef PCI_MSIX_MASKUNMASK_ENTRY *PPCI_MSIX_MASKUNMASK_ENTRY;
3730
3731 typedef NTSTATUS
3732 (NTAPI PCI_MSIX_GET_ENTRY)(
3733 IN PVOID Context,
3734 IN ULONG TableEntry,
3735 OUT PULONG MessageNumber,
3736 OUT PBOOLEAN Masked);
3737 typedef PCI_MSIX_GET_ENTRY *PPCI_MSIX_GET_ENTRY;
3738
3739 typedef NTSTATUS
3740 (NTAPI PCI_MSIX_GET_TABLE_SIZE)(
3741 IN PVOID Context,
3742 OUT PULONG TableSize);
3743 typedef PCI_MSIX_GET_TABLE_SIZE *PPCI_MSIX_GET_TABLE_SIZE;
3744
3745 typedef struct _PCI_MSIX_TABLE_CONFIG_INTERFACE {
3746 USHORT Size;
3747 USHORT Version;
3748 PVOID Context;
3749 PINTERFACE_REFERENCE InterfaceReference;
3750 PINTERFACE_DEREFERENCE InterfaceDereference;
3751 PPCI_MSIX_SET_ENTRY SetTableEntry;
3752 PPCI_MSIX_MASKUNMASK_ENTRY MaskTableEntry;
3753 PPCI_MSIX_MASKUNMASK_ENTRY UnmaskTableEntry;
3754 PPCI_MSIX_GET_ENTRY GetTableEntry;
3755 PPCI_MSIX_GET_TABLE_SIZE GetTableSize;