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