Small changes to include files
[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
156 struct
157 {
158 ULONG Length;
159 PUNICODE_STRING FileName;
160 FILE_INFORMATION_CLASS FileInformationClass;
161 ULONG FileIndex;
162 } QueryDirectory;
163 } Parameters;
164
165 PIO_COMPLETION_ROUTINE CompletionRoutine;
166 PVOID CompletionContext;
167
168 struct _DEVICE_OBJECT* DeviceObject;
169
170 struct _FILE_OBJECT* FileObject;
171 } IO_STACK_LOCATION, *PIO_STACK_LOCATION;
172
173 typedef struct _IO_STATUS_BLOCK
174 {
175 /*
176 * Is the completion status
177 */
178 NTSTATUS Status;
179
180 /*
181 * Is a request dependant value
182 */
183 ULONG Information;
184 } IO_STATUS_BLOCK, *PIO_STATUS_BLOCK;
185
186 /*
187 * Driver entry point declaration
188 */
189 typedef NTSTATUS (*PDRIVER_INITIALIZE)(struct _DRIVER_OBJECT* DriverObject,
190 PUNICODE_STRING RegistryPath);
191
192 /*
193 * Driver cancel declaration
194 */
195 typedef NTSTATUS (*PDRIVER_CANCEL)(struct _DRIVER_OBJECT* DriverObject,
196 PUNICODE_STRING RegistryPath);
197
198
199 typedef struct _SECTION_OBJECT_POINTERS
200 {
201 PVOID DataSectionObject;
202 PVOID SharedCacheMap;
203 PVOID ImageSectionObject;
204 } SECTION_OBJECT_POINTERS, *PSECTION_OBJECT_POINTERS;
205
206 typedef struct _IO_COMPLETION_CONTEXT
207 {
208 PVOID Port;
209 ULONG Key;
210 } IO_COMPLETION_CONTEXT, *PIO_COMPLETION_CONTEXT;
211
212 #define FO_FILE_OPEN 0x00000001
213 #define FO_SYNCHRONOUS_IO 0x00000002
214 #define FO_ALERTABLE_IO 0x00000004
215 #define FO_NO_INTERMEDIATE_BUFFERING 0x00000008
216 #define FO_WRITE_THROUGH 0x00000010
217 #define FO_SEQUENTIAL_ONLY 0x00000020
218 #define FO_CACHE_SUPPORTED 0x00000040
219 #define FO_NAMED_PIPE 0x00000080
220 #define FO_STREAM_FILE 0x00000100
221 #define FO_MAILSLOT 0x00000200
222 #define FO_GENERATE_AUDIT_ON_CLOSE 0x00000400
223 #define FO_DIRECT_DEVICE_OPEN 0x00000800
224 #define FO_FILE_MODIFIED 0x00001000
225 #define FO_FILE_SIZE_CHANGED 0x00002000
226 #define FO_CLEANUP_COMPLETE 0x00004000
227 #define FO_TEMPORARY_FILE 0x00008000
228 #define FO_DELETE_ON_CLOSE 0x00010000
229 #define FO_OPENED_CASE_SENSITIVE 0x00020000
230 #define FO_HANDLE_CREATED 0x00040000
231 #define FO_FILE_FAST_IO_READ 0x00080000
232
233 typedef struct _FILE_OBJECT
234 {
235 CSHORT Type;
236 CSHORT Size;
237 struct _DEVICE_OBJECT* DeviceObject;
238 struct _VPB* Vpb;
239 PVOID FsContext;
240 PVOID FsContext2;
241 PSECTION_OBJECT_POINTERS SectionObjectPointers;
242 PVOID PrivateCacheMap;
243 NTSTATUS FinalStatus;
244 struct _FILE_OBJECT* RelatedFileObject;
245 BOOLEAN LockOperation;
246 BOOLEAN DeletePending;
247 BOOLEAN ReadAccess;
248 BOOLEAN WriteAccess;
249 BOOLEAN DeleteAccess;
250 BOOLEAN SharedRead;
251 BOOLEAN SharedWrite;
252 BOOLEAN SharedDelete;
253 ULONG Flags;
254 UNICODE_STRING FileName;
255 LARGE_INTEGER CurrentByteOffset;
256 ULONG Waiters;
257 ULONG Busy;
258 PVOID LastLock;
259 KEVENT Lock;
260 KEVENT Event;
261 PIO_COMPLETION_CONTEXT CompletionContext;
262 } FILE_OBJECT, *PFILE_OBJECT;
263
264
265 typedef struct _IRP
266 {
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 typedef struct _DRIVER_OBJECT
396 {
397 CSHORT Type;
398 CSHORT Size;
399 PDEVICE_OBJECT DeviceObject;
400 ULONG Flags;
401 PVOID DriverStart;
402 ULONG DriverSize;
403 PVOID DriverSection;
404 PDRIVER_EXTENSION DriverExtension;
405 UNICODE_STRING DriverName;
406 PUNICODE_STRING HardwareDatabase;
407 PFAST_IO_DISPATCH FastIoDispatch;
408 PDRIVER_INITIALIZE DriverInit;
409 PDRIVER_STARTIO DriverStartIo;
410 PDRIVER_UNLOAD DriverUnload;
411 PDRIVER_DISPATCH MajorFunction[IRP_MJ_MAXIMUM_FUNCTION + 1];
412 } DRIVER_OBJECT, *PDRIVER_OBJECT;
413
414
415 typedef struct _CONFIGURATION_INFORMATION
416 {
417 ULONG DiskCount;
418 ULONG FloppyCount;
419 ULONG CDRomCount;
420 ULONG TapeCount;
421 ULONG ScsiPortCount;
422 ULONG SerialCount;
423 ULONG ParallelCount;
424 BOOLEAN AtDiskPrimaryAddressClaimed;
425 BOOLEAN AtDiskSecondaryAddressClaimed;
426 } CONFIGURATION_INFORMATION, *PCONFIGURATION_INFORMATION;
427
428 typedef VOID (*PIO_DPC_ROUTINE)(PKDPC Dpc,
429 PDEVICE_OBJECT DeviceObject,
430 PIRP Irp,
431 PVOID Context);
432
433 typedef VOID (*PIO_TIMER_ROUTINE)(PDEVICE_OBJECT DeviceObject,
434 PVOID Context);
435
436 #if WINDOWS_STRUCTS_DOESNT_ALREADY_DEFINE_THIS
437 typedef struct _PARTITION_INFORMATION
438 {
439 LARGE_INTEGER StartingOffset;
440 LARGE_INTEGER PartitionLength;
441 ULONG HiddenSectors;
442 ULONG PartitionNumber;
443 UCHAR PartitionType;
444 BOOLEAN BootIndicator;
445 BOOLEAN RecognizedPartition;
446 BOOLEAN RewritePartition;
447 } PARTITION_INFORMATION, *PPARTITION_INFORMATION;
448 #endif
449
450 typedef struct _DRIVER_LAYOUT_INFORMATION
451 {
452 ULONG PartitionCount;
453 ULONG Signature;
454 PARTITION_INFORMATION PartitionEntry[1];
455 } DRIVER_LAYOUT_INFORMATION, *PDRIVER_LAYOUT_INFORMATION;
456
457
458
459
460
461 typedef struct _IO_RESOURCE_DESCRIPTOR
462 {
463 UCHAR Option;
464 UCHAR Type;
465 UCHAR SharedDisposition;
466
467 /*
468 * Reserved for system use
469 */
470 UCHAR Spare1;
471
472 USHORT Flags;
473
474 /*
475 * Reserved for system use
476 */
477 UCHAR Spare2;
478
479 union
480 {
481 struct
482 {
483 ULONG Length;
484 ULONG Alignment;
485 PHYSICAL_ADDRESS MinimumAddress;
486 PHYSICAL_ADDRESS MaximumAddress;
487 } Port;
488 struct
489 {
490 ULONG Length;
491 ULONG Alignment;
492 PHYSICAL_ADDRESS MinimumAddress;
493 PHYSICAL_ADDRESS MaximumAddress;
494 } Memory;
495 struct
496 {
497 ULONG MinimumVector;
498 ULONG MaximumVector;
499 } Interrupt;
500 struct
501 {
502 ULONG MinimumChannel;
503 ULONG MaximumChannel;
504 } Dma;
505 } u;
506 } IO_RESOURCE_DESCRIPTOR, *PIO_RESOURCE_DESCRIPTOR;
507
508 typedef struct _IO_RESOURCE_LIST
509 {
510 USHORT Version;
511 USHORT Revision;
512 ULONG Count;
513 IO_RESOURCE_DESCRIPTOR Descriptors[1];
514 } IO_RESOURCE_LIST, *PIO_RESOURCE_LIST;
515
516 typedef struct _IO_RESOURCES_REQUIREMENTS_LIST
517 {
518 /*
519 * List size in bytes
520 */
521 ULONG ListSize;
522
523 /*
524 * System defined enum for the bus
525 */
526 INTERFACE_TYPE InterfaceType;
527
528 ULONG BusNumber;
529 ULONG SlotNumber;
530 ULONG Reserved[3];
531 ULONG AlternativeLists;
532 IO_RESOURCE_LIST List[1];
533 } IO_RESOURCES_REQUIREMENTS_LIST, *PIO_RESOURCE_REQUIREMENTS_LIST;
534
535 typedef struct
536 {
537 UCHAR Type;
538 UCHAR ShareDisposition;
539 USHORT Flags;
540 union
541 {
542 struct
543 {
544 PHYSICAL_ADDRESS Start;
545 ULONG Length;
546 } Port;
547 struct
548 {
549 ULONG Level;
550 ULONG Vector;
551 ULONG Affinity;
552 } Interrupt;
553 struct
554 {
555 PHYSICAL_ADDRESS Start;
556 ULONG Length;
557 } Memory;
558 struct
559 {
560 ULONG Channel;
561 ULONG Port;
562 ULONG Reserved1;
563 } Dma;
564 struct
565 {
566 ULONG DataSize;
567 ULONG Reserved1;
568 ULONG Reserved2;
569 } DeviceSpecificData;
570 } u;
571 } CM_PARTIAL_RESOURCE_DESCRIPTOR, *PCM_PARTIAL_RESOURCE_DESCRIPTOR;
572
573 typedef struct
574 {
575 USHORT Version;
576 USHORT Revision;
577 ULONG Count;
578 CM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptors[1];
579 } CM_PARTIAL_RESOURCE_LIST;
580
581 typedef struct
582 {
583 INTERFACE_TYPE InterfaceType;
584 ULONG BusNumber;
585 CM_PARTIAL_RESOURCE_LIST PartialResourceList;
586 } CM_FULL_RESOURCE_DESCRIPTOR;
587
588 typedef struct
589 {
590 ULONG Count;
591 CM_FULL_RESOURCE_DESCRIPTOR List[1];
592 } CM_RESOURCE_LIST, *PCM_RESOURCE_LIST;
593
594
595 #endif __INCLUDE_DDK_IOTYPES_H