Initial revision
[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 typedef ULONG INTERFACE_TYPE;
20 typedef INTERFACE_TYPE* PINTERFACE_TYPE;
21 typedef ULONG CONFIGURATION_TYPE;
22 typedef CONFIGURATION_TYPE* PCONFIGURATION_TYPE;
23
24 /*
25 * FIXME: Definition needed
26 */
27 typedef struct _SHARE_ACCESS
28 {
29 } SHARE_ACCESS, *PSHARE_ACCESS;
30
31 /* FUNCTION TYPES ************************************************************/
32
33 typedef VOID (*PDRIVER_REINITIALIZE)(struct _DRIVER_OBJECT* DriverObject,
34 PVOID Context,
35 ULONG Count);
36
37 typedef NTSTATUS (*PIO_QUERY_DEVICE_ROUTINE)(PVOID Context,
38 PUNICODE_STRING Pathname,
39 INTERFACE_TYPE BusType,
40 ULONG BusNumber,
41 PKEY_VALUE_FULL_INFORMATION* BI,
42 CONFIGURATION_TYPE ControllerType,
43 ULONG ControllerNumber,
44 PKEY_VALUE_FULL_INFORMATION* CI,
45 CONFIGURATION_TYPE PeripheralType,
46 ULONG PeripheralNumber,
47 PKEY_VALUE_FULL_INFORMATION* PI);
48
49 typedef NTSTATUS (*PIO_COMPLETION_ROUTINE)(struct _DEVICE_OBJECT* DeviceObject,
50 struct _IRP* Irp,
51 PVOID Context);
52
53 typedef VOID (*PIO_APC_ROUTINE) (PVOID ApcContext,
54 struct _IO_STATUS_BLOCK* IoStatusBlock,
55 ULONG Reserved);
56
57
58 /* STRUCTURE TYPES ***********************************************************/
59
60 /*
61 * PURPOSE: Special timer associated with each device
62 */
63 typedef struct _IO_TIMER
64 {
65 } IO_TIMER, PIO_TIMER;
66
67
68 /*
69 * PURPOSE: IRP stack location
70 */
71 typedef struct _IO_STACK_LOCATION
72 {
73 /*
74 * Type of request
75 */
76 UCHAR MajorFunction;
77
78 /*
79 * Further information about request type
80 */
81 UCHAR MinorFunction;
82
83 /*
84 *
85 */
86 UCHAR Flags;
87
88 /*
89 * FUNCTION: Various flags including for the io completion routine
90 */
91 UCHAR Control;
92
93 /*
94 * Parameters for request
95 */
96 union
97 {
98 struct
99 {
100 /*
101 * Number of bytes to be transferrred
102 */
103 ULONG Length;
104
105 /*
106 * Possibly used to sort incoming request (to be documented)
107 */
108 ULONG Key;
109
110 /*
111 * Optional starting offset for read
112 */
113 LARGE_INTEGER ByteOffset;
114 } Read;
115 struct
116 {
117 ULONG Length;
118 ULONG Key;
119 LARGE_INTEGER ByteOffset;
120 } Write;
121 struct
122 {
123 ULONG OutputBufferLength;
124 ULONG InputBufferLength;
125 ULONG IoControlCode;
126 PVOID Type3InputBuffer;
127 } DeviceIoControl;
128
129 } Parameters;
130
131 /*
132 * PURPOSE: Completion routine
133 * NOTE: If this is the nth stack location (where the 1st is passed to the
134 * highest level driver) then this is the completion routine set by
135 * the (n-1)th driver
136 */
137 PIO_COMPLETION_ROUTINE CompletionRoutine;
138 PVOID CompletionContext;
139 BOOLEAN InvokeOnSuccess;
140 BOOLEAN InvokeOnError;
141 BOOLEAN InvokeOnCancel;
142
143 /*
144 * Driver created device object representing the target device
145 */
146 struct _DEVICE_OBJECT* DeviceObject;
147
148 /*
149 * File object (if any) associated with DeviceObject
150 */
151 struct _FILE_OBJECT* FileObject;
152 } IO_STACK_LOCATION, *PIO_STACK_LOCATION;
153
154 typedef struct _IO_STATUS_BLOCK
155 {
156 /*
157 * Is the completion status
158 */
159 NTSTATUS Status;
160
161 /*
162 * Is a request dependant value
163 */
164 ULONG Information;
165 } IO_STATUS_BLOCK, *PIO_STATUS_BLOCK;
166
167 /*
168 * Driver entry point declaration
169 */
170 typedef NTSTATUS (*PDRIVER_INITIALIZE)(struct _DRIVER_OBJECT* DriverObject,
171 PUNICODE_STRING RegistryPath);
172
173 /*
174 * Driver cancel declaration
175 */
176 typedef NTSTATUS (*PDRIVER_CANCEL)(struct _DRIVER_OBJECT* DriverObject,
177 PUNICODE_STRING RegistryPath);
178
179 typedef struct _IRP
180 {
181 PMDL MdlAddress;
182 ULONG Flags;
183 union
184 {
185 struct _IRP* MasterIrp;
186 LONG IrpCount;
187 PVOID SystemBuffer;
188 } AssociatedIrp;
189 LIST_ENTRY ThreadListEntry;
190 IO_STATUS_BLOCK IoStatus;
191 KPROCESSOR_MODE RequestorMode;
192 BOOLEAN PendingReturned;
193 BOOLEAN Cancel;
194 KIRQL CancelIrql;
195 PDRIVER_CANCEL CancelRoutine;
196 PVOID UserBuffer;
197 PVOID ApcEnvironment;
198 ULONG AllocationFlags;
199 PIO_STATUS_BLOCK UserIosb;
200 PKEVENT UserEvent;
201 union
202 {
203 struct
204 {
205 PIO_APC_ROUTINE UserApcRoutine;
206 PVOID UserApcContext;
207 } AsynchronousParameters;
208 LARGE_INTEGER AllocationSize;
209 } Overlay;
210 union
211 {
212 struct
213 {
214 KDEVICE_QUEUE_ENTRY DeviceQueueEntry;
215 // PETHREAD Thread;
216 PVOID Thread;
217 PCHAR AuxiliaryBuffer;
218 LIST_ENTRY ListEntry;
219 struct _IO_STACK_LOCATION* CurrentStackLocation;
220 // PFILE_OBJECT OriginalFileObject;
221 PVOID OriginalFileObject;
222 } Overlay;
223 KAPC Apc;
224 ULONG CompletionKey;
225 } Tail;
226 ULONG CurrentLocation;
227 IO_STACK_LOCATION Stack[1];
228 } IRP, *PIRP;
229
230
231 typedef struct _VPB
232 {
233 CSHORT Type;
234 CSHORT Size;
235 USHORT Flags;
236 USHORT VolumeLabelLength;
237 struct _DEVICE_OBJECT* DeviceObject;
238 struct _DEVICE_OBJECT* RealDevice;
239 ULONG SerialNumber;
240 ULONG ReferenceCount;
241 WCHAR VolumeLabel[MAXIMUM_VOLUME_LABEL_LENGTH / sizeof(WCHAR)];
242 } VPB, *PVPB;
243
244
245 typedef struct _DEVICE_OBJECT
246 {
247 CSHORT Type;
248 CSHORT Size;
249 LONG ReferenceCount;
250 struct _DRIVER_OBJECT* DriverObject;
251 struct _DEVICE_OBJECT* NextDevice;
252 struct _DEVICE_OBJECT* AttachedDevice;
253 struct _IRP* CurrentIrp;
254 PIO_TIMER Timer;
255 ULONG Flags;
256 ULONG Characteristics;
257 PVPB Vpb;
258 PVOID DeviceExtension;
259 DEVICE_TYPE DeviceType;
260 CCHAR StackSize;
261 union
262 {
263 LIST_ENTRY ListHead;
264 WAIT_CONTEXT_BLOCK Wcb;
265 } Queue;
266 ULONG AlignmentRequirement;
267 KDEVICE_QUEUE DeviceQueue;
268 KDPC Dpc;
269 ULONG ActiveThreadCount;
270 PSECURITY_DESCRIPTOR SecurityDescriptor;
271 KEVENT DeviceLock;
272 USHORT SectorSize;
273 USHORT Spare1;
274 struct _DEVOBJ_EXTENSION* DeviceObjectExtension;
275 PVOID Reserved;
276 } DEVICE_OBJECT, *PDEVICE_OBJECT;
277
278 /*
279 * Dispatch routine type declaration
280 */
281 typedef NTSTATUS (*PDRIVER_DISPATCH)(struct _DEVICE_OBJECT*, IRP*);
282
283 /*
284 * Fast i/o routine type declaration
285 */
286 typedef NTSTATUS (*PFAST_IO_DISPATCH)(struct _DEVICE_OBJECT*, IRP*);
287
288 /*
289 * Dispatch routine type declaration
290 */
291 typedef NTSTATUS (*PDRIVER_STARTIO)(struct _DEVICE_OBJECT*, IRP*);
292
293 /*
294 * Dispatch routine type declaration
295 */
296 typedef NTSTATUS (*PDRIVER_UNLOAD)(struct _DRIVER_OBJECT*);
297
298 typedef struct _DRIVER_EXTENSION
299 {
300 struct _DRIVER_OBJECT* DriverObject;
301 PDRIVER_ADD_DEVICE AddDevice;
302 ULONG Count;
303 UNICODE_STRING ServiceKeyName;
304 } DRIVER_EXTENSION, *PDRIVER_EXTENSION;
305
306 typedef struct _DRIVER_OBJECT
307 {
308 /*
309 * PURPOSE: Magic values for debugging
310 */
311 CSHORT Type;
312 CSHORT Size;
313 PDEVICE_OBJECT DeviceObject;
314 ULONG Flags;
315 PVOID DriverStart;
316 ULONG DriverSize;
317 PVOID DriverSection;
318 PDRIVER_EXTENSION DriverExtension;
319 UNICODE_STRING DriverName;
320 PUNICODE_STRING HardwareDatabase;
321 PFAST_IO_DISPATCH FastIoDispatch;
322 PDRIVER_INITIALIZE DriverInit;
323 PDRIVER_STARTIO DriverStartIo;
324 PDRIVER_UNLOAD DriverUnload;
325 PDRIVER_DISPATCH MajorFunction[IRP_MJ_MAXIMUM_FUNCTION + 1];
326 } DRIVER_OBJECT, *PDRIVER_OBJECT;
327
328
329
330
331 typedef struct _FILE_OBJECT
332 {
333 PDEVICE_OBJECT DeviceObject;
334 PVOID FsContext;
335 } FILE_OBJECT, *PFILE_OBJECT;
336
337 typedef struct _CONFIGURATION_INFORMATION
338 {
339 ULONG DiskCount;
340 ULONG FloppyCount;
341 ULONG CDRomCount;
342 ULONG TapeCount;
343 ULONG ScsiPortCount;
344 ULONG SerialCount;
345 ULONG ParallelCount;
346 BOOLEAN AtDiskPrimaryAddressClaimed;
347 BOOLEAN AtDiskSecondaryAddressClaimed;
348 } CONFIGURATION_INFORMATION, *PCONFIGURATION_INFORMATION;
349
350 typedef VOID (*PIO_DPC_ROUTINE)(PKDPC Dpc,
351 PDEVICE_OBJECT DeviceObject,
352 PIRP Irp,
353 PVOID Context);
354
355 typedef VOID (*PIO_TIMER_ROUTINE)(PDEVICE_OBJECT DeviceObject,
356 PVOID Context);
357
358 #if PKEY_VALUE_FULL_INFORMATION_DEFINED
359 typedef NTSTATUS (*PIO_QUERY_DEVICE_ROUTINE)(PVOID Context,
360 PUNICODE_STRING PathName,
361 INTERFACE_TYPE BusType,
362 ULONG BusNumber,
363 PKEY_VALUE_FULL_INFORMATION* BusKey,
364 CONFIGURATION_TYPE ControllerType,
365 ULONG ControllerNumber,
366 PKEY_VALUE_FULL_INFORMATION* CtrlKey,
367 CONFIGURATION_TYPE PeripheralType,
368 ULONG PeripheralNumber,
369 PKEY_VALUE_FULL_INFORMATION* PrphKey);
370 #endif
371
372 #if WINDOWS_STRUCTS_DOESNT_ALREADY_DEFINE_THIS
373 typedef struct _PARTITION_INFORMATION
374 {
375 LARGE_INTEGER StartingOffset;
376 LARGE_INTEGER PartitionLength;
377 ULONG HiddenSectors;
378 ULONG PartitionNumber;
379 UCHAR PartitionType;
380 BOOLEAN BootIndicator;
381 BOOLEAN RecognizedPartition;
382 BOOLEAN RewritePartition;
383 } PARTITION_INFORMATION, *PPARTITION_INFORMATION;
384 #endif
385
386 typedef struct _DRIVER_LAYOUT_INFORMATION
387 {
388 ULONG PartitionCount;
389 ULONG Signature;
390 PARTITION_INFORMATION PartitionEntry[1];
391 } DRIVER_LAYOUT_INFORMATION, *PDRIVER_LAYOUT_INFORMATION;
392
393 #endif __INCLUDE_DDK_IOTYPES_H