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