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