Merged mingw32 branch into main trunk
[reactos.git] / reactos / include / ddk / iotypes.h
1 /*
2 *
3 */
4
5 #ifndef __INCLUDE_DDK_IOTYPES_H
6 #define __INCLUDE_DDK_IOTYPES_H
7
8 /*
9 * These are referenced before they can be fully defined
10 */
11 struct _DRIVER_OBJECT;
12 struct _FILE_OBJECT;
13 struct _DEVICE_OBJECT;
14 struct _IRP;
15 struct _IO_STATUS_BLOCK;
16
17 /* SIMPLE TYPES *************************************************************/
18
19 enum
20 {
21 DeallocateObject,
22 KeepObject,
23 };
24
25 typedef ULONG INTERFACE_TYPE;
26 typedef INTERFACE_TYPE* PINTERFACE_TYPE;
27
28 /*
29 * FIXME: Definition needed
30 */
31 typedef struct _SHARE_ACCESS
32 {
33 } SHARE_ACCESS, *PSHARE_ACCESS;
34
35 /* FUNCTION TYPES ************************************************************/
36
37 typedef VOID (*PDRIVER_REINITIALIZE)(struct _DRIVER_OBJECT* DriverObject,
38 PVOID Context,
39 ULONG Count);
40
41 typedef NTSTATUS (*PIO_QUERY_DEVICE_ROUTINE)(PVOID Context,
42 PUNICODE_STRING Pathname,
43 INTERFACE_TYPE BusType,
44 ULONG BusNumber,
45 PKEY_VALUE_FULL_INFORMATION* BI,
46 CONFIGURATION_TYPE ControllerType,
47 ULONG ControllerNumber,
48 PKEY_VALUE_FULL_INFORMATION* CI,
49 CONFIGURATION_TYPE PeripheralType,
50 ULONG PeripheralNumber,
51 PKEY_VALUE_FULL_INFORMATION* PI);
52
53 typedef NTSTATUS (*PIO_COMPLETION_ROUTINE)(struct _DEVICE_OBJECT* DeviceObject,
54 struct _IRP* Irp,
55 PVOID Context);
56
57 typedef VOID (*PIO_APC_ROUTINE) (PVOID ApcContext,
58 struct _IO_STATUS_BLOCK* IoStatusBlock,
59 ULONG Reserved);
60
61
62 /* STRUCTURE TYPES ***********************************************************/
63
64 typedef struct _ADAPTER_OBJECT
65 {
66 } ADAPTER_OBJECT, *PADAPTER_OBJECT;
67
68 /*
69 * PURPOSE: Special timer associated with each device
70 * NOTES: This is a guess
71 */
72 typedef struct _IO_TIMER
73 {
74 KTIMER timer;
75 KDPC dpc;
76 } IO_TIMER, *PIO_TIMER;
77
78 typedef struct _IO_SECURITY_CONTEXT
79 {
80 PSECURITY_QUALITY_OF_SERVICE SecurityQos;
81 PACCESS_STATE AccessState;
82 ACCESS_MASK DesiredAccess;
83 ULONG FullCreateOptions;
84 } IO_SECURITY_CONTEXT, *PIO_SECURITY_CONTEXT;
85
86 /*
87 * PURPOSE: IRP stack location
88 */
89 typedef struct _IO_STACK_LOCATION
90 {
91 UCHAR MajorFunction;
92 UCHAR MinorFunction;
93 UCHAR Flags;
94 UCHAR Control;
95
96 union
97 {
98 struct
99 {
100 PIO_SECURITY_CONTEXT SecurityContext;
101 ULONG Options;
102 USHORT FileAttributes;
103 USHORT ShareAccess;
104 ULONG EaLength;
105 } Create;
106 struct
107 {
108 ULONG Length;
109 ULONG Key;
110 LARGE_INTEGER ByteOffset;
111 } Read;
112 struct
113 {
114 ULONG Length;
115 ULONG Key;
116 LARGE_INTEGER ByteOffset;
117 } Write;
118 struct
119 {
120 ULONG OutputBufferLength;
121 ULONG InputBufferLength;
122 ULONG IoControlCode;
123 PVOID Type3InputBuffer;
124 } DeviceIoControl;
125 struct
126 {
127 struct _VPB* Vpb;
128 struct _DEVICE_OBJECT* DeviceObject;
129 } Mount;
130 struct {
131 ULONG Length;
132 FILE_INFORMATION_CLASS FileInformationClass;
133 } QueryFile;
134 struct {
135 ULONG Length;
136 FS_INFORMATION_CLASS FileInformationClass;
137 } QueryVolume;
138 struct {
139 ULONG Length;
140 FS_INFORMATION_CLASS FileInformationClass;
141 } SetVolume;
142 struct {
143 ULONG Length;
144 FILE_INFORMATION_CLASS FileInformationClass;
145 struct FILE_OBJECT* FileObject;
146 union {
147 struct {
148 BOOLEAN ReplaceIfExists;
149 BOOLEAN AdvanceOnly;
150 } d;
151 ULONG ClusterCount;
152 HANDLE DeleteHandle;
153 } u;
154 } SetFile;
155 struct
156 {
157 ULONG Length;
158 PUNICODE_STRING FileName;
159 FILE_INFORMATION_CLASS FileInformationClass;
160 ULONG FileIndex;
161 } QueryDirectory;
162 } Parameters;
163
164 PIO_COMPLETION_ROUTINE CompletionRoutine;
165 PVOID CompletionContext;
166
167 struct _DEVICE_OBJECT* DeviceObject;
168
169 struct _FILE_OBJECT* FileObject;
170 } IO_STACK_LOCATION, *PIO_STACK_LOCATION;
171
172 typedef struct _IO_STATUS_BLOCK
173 {
174 NTSTATUS Status;
175 ULONG Information;
176 } IO_STATUS_BLOCK, *PIO_STATUS_BLOCK;
177
178 /*
179 * Driver entry point declaration
180 */
181 typedef NTSTATUS (*PDRIVER_INITIALIZE)(struct _DRIVER_OBJECT* DriverObject,
182 PUNICODE_STRING RegistryPath);
183
184 /*
185 * Driver cancel declaration
186 */
187 typedef NTSTATUS (*PDRIVER_CANCEL)(struct _DRIVER_OBJECT* DriverObject,
188 PUNICODE_STRING RegistryPath);
189
190
191 typedef struct _SECTION_OBJECT_POINTERS
192 {
193 PVOID DataSectionObject;
194 PVOID SharedCacheMap;
195 PVOID ImageSectionObject;
196 } SECTION_OBJECT_POINTERS, *PSECTION_OBJECT_POINTERS;
197
198 typedef struct _IO_COMPLETION_CONTEXT
199 {
200 PVOID Port;
201 ULONG Key;
202 } IO_COMPLETION_CONTEXT, *PIO_COMPLETION_CONTEXT;
203
204 #define FO_FILE_OPEN 0x00000001
205 #define FO_SYNCHRONOUS_IO 0x00000002
206 #define FO_ALERTABLE_IO 0x00000004
207 #define FO_NO_INTERMEDIATE_BUFFERING 0x00000008
208 #define FO_WRITE_THROUGH 0x00000010
209 #define FO_SEQUENTIAL_ONLY 0x00000020
210 #define FO_CACHE_SUPPORTED 0x00000040
211 #define FO_NAMED_PIPE 0x00000080
212 #define FO_STREAM_FILE 0x00000100
213 #define FO_MAILSLOT 0x00000200
214 #define FO_GENERATE_AUDIT_ON_CLOSE 0x00000400
215 #define FO_DIRECT_DEVICE_OPEN 0x00000800
216 #define FO_FILE_MODIFIED 0x00001000
217 #define FO_FILE_SIZE_CHANGED 0x00002000
218 #define FO_CLEANUP_COMPLETE 0x00004000
219 #define FO_TEMPORARY_FILE 0x00008000
220 #define FO_DELETE_ON_CLOSE 0x00010000
221 #define FO_OPENED_CASE_SENSITIVE 0x00020000
222 #define FO_HANDLE_CREATED 0x00040000
223 #define FO_FILE_FAST_IO_READ 0x00080000
224
225 typedef struct _FILE_OBJECT
226 {
227 CSHORT Type;
228 CSHORT Size;
229 struct _DEVICE_OBJECT* DeviceObject;
230 struct _VPB* Vpb;
231 PVOID FsContext;
232 PVOID FsContext2;
233 PSECTION_OBJECT_POINTERS SectionObjectPointers;
234 PVOID PrivateCacheMap;
235 NTSTATUS FinalStatus;
236 struct _FILE_OBJECT* RelatedFileObject;
237 BOOLEAN LockOperation;
238 BOOLEAN DeletePending;
239 BOOLEAN ReadAccess;
240 BOOLEAN WriteAccess;
241 BOOLEAN DeleteAccess;
242 BOOLEAN SharedRead;
243 BOOLEAN SharedWrite;
244 BOOLEAN SharedDelete;
245 ULONG Flags;
246 UNICODE_STRING FileName;
247 LARGE_INTEGER CurrentByteOffset;
248 ULONG Waiters;
249 ULONG Busy;
250 PVOID LastLock;
251 KEVENT Lock;
252 KEVENT Event;
253 PIO_COMPLETION_CONTEXT CompletionContext;
254 } FILE_OBJECT, *PFILE_OBJECT;
255
256
257 typedef struct _IRP
258 {
259 PMDL MdlAddress;
260 ULONG Flags;
261 union
262 {
263 struct _IRP* MasterIrp;
264 LONG IrpCount;
265 PVOID SystemBuffer;
266 } AssociatedIrp;
267 LIST_ENTRY ThreadListEntry;
268 IO_STATUS_BLOCK IoStatus;
269 KPROCESSOR_MODE RequestorMode;
270 BOOLEAN PendingReturned;
271 BOOLEAN Cancel;
272 KIRQL CancelIrql;
273 PDRIVER_CANCEL CancelRoutine;
274 PVOID UserBuffer;
275 PVOID ApcEnvironment;
276 ULONG AllocationFlags;
277 PIO_STATUS_BLOCK UserIosb;
278 PKEVENT UserEvent;
279 union
280 {
281 struct
282 {
283 PIO_APC_ROUTINE UserApcRoutine;
284 PVOID UserApcContext;
285 } AsynchronousParameters;
286 LARGE_INTEGER AllocationSize;
287 } Overlay;
288 union
289 {
290 struct
291 {
292 KDEVICE_QUEUE_ENTRY DeviceQueueEntry;
293 struct _ETHREAD* Thread;
294 PCHAR AuxiliaryBuffer;
295 LIST_ENTRY ListEntry;
296 struct _IO_STACK_LOCATION* CurrentStackLocation;
297 PFILE_OBJECT OriginalFileObject;
298 } Overlay;
299 KAPC Apc;
300 ULONG CompletionKey;
301 } Tail;
302 CHAR StackCount;
303 CHAR CurrentLocation;
304 IO_STACK_LOCATION Stack[1];
305 } IRP, *PIRP;
306
307 #define VPB_MOUNTED 0x00000001
308 #define VPB_LOCKED 0x00000002
309 #define VPB_PERSISTENT 0x00000004
310 #define VPB_REMOVE_PENDING 0x00000008
311
312 typedef struct _VPB
313 {
314 CSHORT Type;
315 CSHORT Size;
316 USHORT Flags;
317 USHORT VolumeLabelLength;
318 struct _DEVICE_OBJECT* DeviceObject;
319 struct _DEVICE_OBJECT* RealDevice;
320 ULONG SerialNumber;
321 ULONG ReferenceCount;
322 WCHAR VolumeLabel[MAXIMUM_VOLUME_LABEL_LENGTH];
323 } VPB, *PVPB;
324
325
326 typedef struct _DEVICE_OBJECT
327 {
328 CSHORT Type;
329 CSHORT Size;
330 LONG ReferenceCount;
331 struct _DRIVER_OBJECT* DriverObject;
332 struct _DEVICE_OBJECT* NextDevice;
333 struct _DEVICE_OBJECT* AttachedDevice;
334 struct _IRP* CurrentIrp;
335 PIO_TIMER Timer;
336 ULONG Flags;
337 ULONG Characteristics;
338 PVPB Vpb;
339 PVOID DeviceExtension;
340 DEVICE_TYPE DeviceType;
341 CCHAR StackSize;
342 union
343 {
344 LIST_ENTRY ListHead;
345 WAIT_CONTEXT_BLOCK Wcb;
346 } Queue;
347 ULONG AlignmentRequirement;
348 KDEVICE_QUEUE DeviceQueue;
349 KDPC Dpc;
350 ULONG ActiveThreadCount;
351 PSECURITY_DESCRIPTOR SecurityDescriptor;
352 KEVENT DeviceLock;
353 USHORT SectorSize;
354 USHORT Spare1;
355 struct _DEVOBJ_EXTENSION* DeviceObjectExtension;
356 PVOID Reserved;
357 } DEVICE_OBJECT, *PDEVICE_OBJECT;
358
359 /*
360 * Dispatch routine type declaration
361 */
362 typedef NTSTATUS (*PDRIVER_DISPATCH)(struct _DEVICE_OBJECT*, IRP*);
363
364 /*
365 * Fast i/o routine type declaration
366 */
367 typedef NTSTATUS (*PFAST_IO_DISPATCH)(struct _DEVICE_OBJECT*, IRP*);
368
369 /*
370 * Dispatch routine type declaration
371 */
372 typedef VOID (*PDRIVER_STARTIO)(struct _DEVICE_OBJECT*, IRP*);
373
374 /*
375 * Dispatch routine type declaration
376 */
377 typedef NTSTATUS (*PDRIVER_UNLOAD)(struct _DRIVER_OBJECT*);
378
379 typedef struct _DRIVER_EXTENSION
380 {
381 struct _DRIVER_OBJECT* DriverObject;
382 PDRIVER_ADD_DEVICE AddDevice;
383 ULONG Count;
384 UNICODE_STRING ServiceKeyName;
385 } DRIVER_EXTENSION, *PDRIVER_EXTENSION;
386
387 typedef struct _DRIVER_OBJECT
388 {
389 CSHORT Type;
390 CSHORT Size;
391 PDEVICE_OBJECT DeviceObject;
392 ULONG Flags;
393 PVOID DriverStart;
394 ULONG DriverSize;
395 PVOID DriverSection;
396 PDRIVER_EXTENSION DriverExtension;
397 UNICODE_STRING DriverName;
398 PUNICODE_STRING HardwareDatabase;
399 PFAST_IO_DISPATCH FastIoDispatch;
400 PDRIVER_INITIALIZE DriverInit;
401 PDRIVER_STARTIO DriverStartIo;
402 PDRIVER_UNLOAD DriverUnload;
403 PDRIVER_DISPATCH MajorFunction[IRP_MJ_MAXIMUM_FUNCTION + 1];
404 } DRIVER_OBJECT, *PDRIVER_OBJECT;
405
406
407 typedef struct _CONFIGURATION_INFORMATION
408 {
409 ULONG DiskCount;
410 ULONG FloppyCount;
411 ULONG CDRomCount;
412 ULONG TapeCount;
413 ULONG ScsiPortCount;
414 ULONG SerialCount;
415 ULONG ParallelCount;
416 BOOLEAN AtDiskPrimaryAddressClaimed;
417 BOOLEAN AtDiskSecondaryAddressClaimed;
418 } CONFIGURATION_INFORMATION, *PCONFIGURATION_INFORMATION;
419
420 typedef VOID (*PIO_DPC_ROUTINE)(PKDPC Dpc,
421 PDEVICE_OBJECT DeviceObject,
422 PIRP Irp,
423 PVOID Context);
424
425 typedef VOID (*PIO_TIMER_ROUTINE)(PDEVICE_OBJECT DeviceObject,
426 PVOID Context);
427
428 #if WINDOWS_STRUCTS_DOESNT_ALREADY_DEFINE_THIS
429 typedef struct _PARTITION_INFORMATION
430 {
431 LARGE_INTEGER StartingOffset;
432 LARGE_INTEGER PartitionLength;
433 ULONG HiddenSectors;
434 ULONG PartitionNumber;
435 UCHAR PartitionType;
436 BOOLEAN BootIndicator;
437 BOOLEAN RecognizedPartition;
438 BOOLEAN RewritePartition;
439 } PARTITION_INFORMATION, *PPARTITION_INFORMATION;
440 #endif
441
442 typedef struct _DRIVER_LAYOUT_INFORMATION
443 {
444 ULONG PartitionCount;
445 ULONG Signature;
446 PARTITION_INFORMATION PartitionEntry[1];
447 } DRIVER_LAYOUT_INFORMATION, *PDRIVER_LAYOUT_INFORMATION;
448
449
450
451
452
453 typedef struct _IO_RESOURCE_DESCRIPTOR
454 {
455 UCHAR Option;
456 UCHAR Type;
457 UCHAR SharedDisposition;
458
459 /*
460 * Reserved for system use
461 */
462 UCHAR Spare1;
463
464 USHORT Flags;
465
466 /*
467 * Reserved for system use
468 */
469 UCHAR Spare2;
470
471 union
472 {
473 struct
474 {
475 ULONG Length;
476 ULONG Alignment;
477 PHYSICAL_ADDRESS MinimumAddress;
478 PHYSICAL_ADDRESS MaximumAddress;
479 } Port;
480 struct
481 {
482 ULONG Length;
483 ULONG Alignment;
484 PHYSICAL_ADDRESS MinimumAddress;
485 PHYSICAL_ADDRESS MaximumAddress;
486 } Memory;
487 struct
488 {
489 ULONG MinimumVector;
490 ULONG MaximumVector;
491 } Interrupt;
492 struct
493 {
494 ULONG MinimumChannel;
495 ULONG MaximumChannel;
496 } Dma;
497 } u;
498 } IO_RESOURCE_DESCRIPTOR, *PIO_RESOURCE_DESCRIPTOR;
499
500 typedef struct _IO_RESOURCE_LIST
501 {
502 USHORT Version;
503 USHORT Revision;
504 ULONG Count;
505 IO_RESOURCE_DESCRIPTOR Descriptors[1];
506 } IO_RESOURCE_LIST, *PIO_RESOURCE_LIST;
507
508 typedef struct _IO_RESOURCES_REQUIREMENTS_LIST
509 {
510 /*
511 * List size in bytes
512 */
513 ULONG ListSize;
514
515 /*
516 * System defined enum for the bus
517 */
518 INTERFACE_TYPE InterfaceType;
519
520 ULONG BusNumber;
521 ULONG SlotNumber;
522 ULONG Reserved[3];
523 ULONG AlternativeLists;
524 IO_RESOURCE_LIST List[1];
525 } IO_RESOURCES_REQUIREMENTS_LIST, *PIO_RESOURCE_REQUIREMENTS_LIST;
526
527 typedef struct
528 {
529 UCHAR Type;
530 UCHAR ShareDisposition;
531 USHORT Flags;
532 union
533 {
534 struct
535 {
536 PHYSICAL_ADDRESS Start;
537 ULONG Length;
538 } Port;
539 struct
540 {
541 ULONG Level;
542 ULONG Vector;
543 ULONG Affinity;
544 } Interrupt;
545 struct
546 {
547 PHYSICAL_ADDRESS Start;
548 ULONG Length;
549 } Memory;
550 struct
551 {
552 ULONG Channel;
553 ULONG Port;
554 ULONG Reserved1;
555 } Dma;
556 struct
557 {
558 ULONG DataSize;
559 ULONG Reserved1;
560 ULONG Reserved2;
561 } DeviceSpecificData;
562 } u;
563 } CM_PARTIAL_RESOURCE_DESCRIPTOR, *PCM_PARTIAL_RESOURCE_DESCRIPTOR;
564
565 typedef struct
566 {
567 USHORT Version;
568 USHORT Revision;
569 ULONG Count;
570 CM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptors[1];
571 } CM_PARTIAL_RESOURCE_LIST;
572
573 typedef struct
574 {
575 INTERFACE_TYPE InterfaceType;
576 ULONG BusNumber;
577 CM_PARTIAL_RESOURCE_LIST PartialResourceList;
578 } CM_FULL_RESOURCE_DESCRIPTOR;
579
580 typedef struct
581 {
582 ULONG Count;
583 CM_FULL_RESOURCE_DESCRIPTOR List[1];
584 } CM_RESOURCE_LIST, *PCM_RESOURCE_LIST;
585
586
587 #endif __INCLUDE_DDK_IOTYPES_H