Lots of changes to the kernel
[reactos.git] / reactos / include / ddk / iofuncs.h
1 /* IO MANAGER ***************************************************************/
2
3 BOOLEAN IoRaiseInformationalHardError(NTSTATUS ErrorStatus,
4 PUNICODE_STRING String,
5 PKTHREAD Thread);
6
7
8 /*
9 * FUNCTION: Registers the driver with WMI
10 * ARGUMENTS:
11 * DeviceObject = Device to register
12 * Action = Action to take
13 * RETURNS: Status (?)
14 */
15 //NTSTATUS IoWMIRegistrationControl(DeviceObject, WMIREGACTION Action);
16
17 /*
18 * FUNCTION: Synchronizes cancelable-state transistions for IRPs in a
19 * multiprocessor-safe way
20 * ARGUMENTS:
21 * Irpl = Variable to store the current IRQ level
22 */
23 VOID IoAcquireCancelSpinLock(PKIRQL Irpl);
24
25 typedef IO_ALLOCATION_ACTION (*PDRIVER_CONTROL)(PDEVICE_OBJECT DeviceObject,
26 PIRP irp,
27 PVOID MapRegisterBase,
28 PVOID Context);
29
30 /*
31 * FUNCTION: Allocates an adaptor object for a DMA operation on the target
32 * device
33 * ARGUMENTS:
34 * Adaptor = Adapter channel or busmaster adapter to be allocated
35 * DeviceObject = Target device for DMA
36 * NumberOfMapRegisters = Number of map registers
37 * ExecutionRoutine = Routine to be called when the adaptor is
38 * available
39 * Context = driver defined contex that will be passed to the
40 * execution routine
41 * RETURNS: Success or failure code
42 */
43 NTSTATUS IoAllocateAdapterChannel(PADAPTER_OBJECT AdaperObject,
44 PDEVICE_OBJECT DeviceObject,
45 ULONG NumberOfMapRegisters,
46 PDRIVER_CONTROL ExecutionRoutine,
47 PVOID Context);
48
49 /*
50 * FUNCTION: Sets up a call to a driver supplied controller object as
51 * soon as it is available
52 * ARGUMENTS:
53 * ControllerObject = Driver created controller object
54 * DeviceObject = target device
55 * ExecutionObject = Routine to be called
56 * Context = Driver determined context to be based to the routine
57 */
58 VOID IoAllocateController(PCONTROLLER_OBJECT ControllerObject,
59 PDEVICE_OBJECT DeviceObject,
60 PDRIVER_CONTROL ExecutionRoutine,
61 PVOID Context);
62
63 /*
64 * FUNCTION: Allocates an error log packet
65 * ARGUMENTS:
66 * IoObject = Object which found the error
67 * EntrySize = Size in bytes of the packet to be allocated
68 * RETURNS: On success a pointer to the allocated packet
69 * On failure returns NULL
70 */
71 PVOID IoAllocateErrorLogEntry(PVOID IoObject, UCHAR EntrySize);
72
73 /*
74 * FUNCTION: Allocates an IRP
75 * ARGUMENTS:
76 * StackSize = number of stack locations to allocate
77 * ChargeQuota = Who knows
78 * RETURNS: On success the allocated IRP
79 * On failure NULL
80 */
81 PIRP IoAllocateIrp(CCHAR StackSize, BOOLEAN ChargeQuota);
82
83 /*
84 * FUNCTION: Allocates an MDL large enough to map the supplied buffer
85 * ARGUMENTS:
86 * VirtualAddress = base virtual address of the buffer to be mapped
87 * Length = length of the buffer to be mapped
88 * SecondaryBuffer = Whether the buffer is primary or secondary
89 * ChargeQuota = Charge non-paged pool quota to current thread
90 * Irp = Optional irp to be associated with the MDL
91 * RETURNS: On the success the allocated MDL
92 * On failure NULL
93 */
94 PMDL IoAllocateMdl(PVOID VirtualAddress, ULONG Length,
95 BOOLEAN SecondaryBuffer, BOOLEAN ChargeQuota,
96 PIRP Irp);
97
98 /*
99 * FUNCTION: Creates a symbolic link between the ARC name of a physical
100 * device and the name of the corresponding device object
101 * ARGUMENTS:
102 * ArcName = ARC name of the device
103 * DeviceName = Name of the device object
104 */
105 VOID IoAssignArcName(PUNICODE_STRING ArcName, PUNICODE_STRING DeviceName);
106
107 enum
108 {
109 IO_NO_INCREMENT,
110 };
111
112 /*
113 * FUNCTION: Takes a list of requested hardware resources and allocates them
114 * ARGUMENTS:
115 * RegisterPath =
116 * DriverClassName =
117 * DriverObject = Driver object passed to the DriverEntry routine
118 * DeviceObject =
119 * RequestedResources = List of resources
120 * RETURNS:
121 */
122 NTSTATUS IoAssignResources(PUNICODE_STRING RegistryPath,
123 PUNICODE_STRING DriverClassName,
124 PDRIVER_OBJECT DriverObject,
125 PDEVICE_OBJECT DeviceObject,
126 PIO_RESOURCE_REQUIREMENTS_LIST RequestedResources,
127 PCM_RESOURCE_LIST* AllocatedResources);
128
129 /*
130 * FUNCTION: Attaches the callers device object to a named target device
131 * ARGUMENTS:
132 * SourceDevice = caller's device
133 * TargetDevice = Name of the target device
134 * AttachedDevice = Caller allocated storage. On return contains
135 * a pointer to the target device
136 * RETURNS: Success or failure code
137 */
138 NTSTATUS IoAttachDevice(PDEVICE_OBJECT SourceDevice,
139 PUNICODE_STRING TargetDevice,
140 PDEVICE_OBJECT* AttachedDevice);
141
142 /*
143 * FUNCTION: Obsolete
144 * ARGUMENTS:
145 * SourceDevice = device to attach
146 * TargetDevice = device to be attached to
147 * RETURNS: Success or failure code
148 */
149 NTSTATUS IoAttachDeviceByPointer(PDEVICE_OBJECT SourceDevice,
150 PDEVICE_OBJECT TargetDevice);
151
152 /*
153 * FUNCTION: Attaches the callers device to the highest device in the chain
154 * ARGUMENTS:
155 * SourceDevice = caller's device
156 * TargetDevice = Device to attach
157 * RETURNS: On success the previously highest device
158 * On failure NULL
159 */
160 PDEVICE_OBJECT IoAttachDeviceToDeviceStack(PDEVICE_OBJECT SourceDevice,
161 PDEVICE_OBJECT TargetDevice);
162
163 /*
164 * FUNCTION: Builds a irp to be sent to lower level drivers
165 * ARGUMENTS:
166 * MajorFunction = Major function code to be set in the IRP
167 * DeviceObject = Next lower device object
168 * Buffer = Buffer (only required for some major function codes)
169 * Length = Length in bytes of the buffer
170 * StartingOffset = Starting offset on the target device
171 * IoStatusBlock = Storage for status about the operation (optional)
172 * RETURNS: On success the IRP allocated
173 * On failure NULL
174 */
175 PIRP IoBuildAsynchronousFsdRequest(ULONG MajorFunction,
176 PDEVICE_OBJECT DeviceObject,
177 PVOID Buffer,
178 ULONG Length,
179 PLARGE_INTEGER StartingOffset,
180 PIO_STATUS_BLOCK IoStatusBlock);
181
182 /*
183 * FUNCTION: Allocates and sets up an IRP for a device control request
184 * ARGUMENTS:
185 * IoControlCode = Type of request
186 * DeviceObject = Target device
187 * InputBuffer = Optional input buffer to the driver
188 * InputBufferLength = Length of the input buffer
189 * OutputBuffer = Optional output buffer
190 * OutputBufferLength = Length of the output buffer
191 * InternalDeviceIoControl = TRUE if the request is internal
192 * Event = Initialized event for the caller to wait for the request
193 * to be completed
194 * IoStatusBlock = I/O status block to be set when the request is
195 * completed
196 * RETURNS: Returns the IRP created
197 */
198 PIRP IoBuildDeviceIoControlRequest(ULONG IoControlCode,
199 PDEVICE_OBJECT DeviceObject,
200 PVOID InputBuffer,
201 ULONG InputBufferLength,
202 PVOID OutputBuffer,
203 ULONG OutputBufferLength,
204 BOOLEAN InternalDeviceIoControl,
205 PKEVENT Event,
206 PIO_STATUS_BLOCK IoStatusBlock);
207
208
209 VOID IoBuildPartialMdl(PMDL SourceMdl,
210 PMDL TargetMdl,
211 PVOID VirtualAddress,
212 ULONG Length);
213
214 PIRP IoBuildSynchronousFsdRequest(ULONG MajorFunction,
215 PDEVICE_OBJECT DeviceObject,
216 PVOID Buffer,
217 ULONG Length,
218 PLARGE_INTEGER StartingOffset,
219 PKEVENT Event,
220 PIO_STATUS_BLOCK IoStatusBlock);
221
222 /*
223 * FUNCTION: Sends an irp to the next lower driver
224 */
225 NTSTATUS IoCallDriver(PDEVICE_OBJECT DeviceObject, PIRP irp);
226
227 BOOLEAN IoCancelIrp(PIRP Irp);
228
229 NTSTATUS IoCheckShareAccess(ACCESS_MASK DesiredAccess,
230 ULONG DesiredShareAccess,
231 PFILE_OBJECT FileObject,
232 PSHARE_ACCESS ShareAccess,
233 BOOLEAN Update);
234
235 /*
236 * FUNCTION: Indicates the caller has finished all processing for a given
237 * I/O request and is returning the given IRP to the I/O manager
238 * ARGUMENTS:
239 * Irp = Irp to be cancelled
240 * PriorityBoost = Increment by which to boost the priority of the
241 * thread making the request
242 */
243 VOID IoCompleteRequest(PIRP Irp, CCHAR PriorityBoost);
244
245 NTSTATUS IoConnectInterrupt(PKINTERRUPT* InterruptObject,
246 PKSERVICE_ROUTINE ServiceRoutine,
247 PVOID ServiceContext,
248 PKSPIN_LOCK SpinLock,
249 ULONG Vector,
250 KIRQL Irql,
251 KIRQL SynchronizeIrql,
252 KINTERRUPT_MODE InterruptMode,
253 BOOLEAN ShareVector,
254 KAFFINITY ProcessorEnableMask,
255 BOOLEAN FloatingSave);
256
257 PCONTROLLER_OBJECT IoCreateController(ULONG Size);
258
259 /*
260 * FUNCTION: Allocates memory for and intializes a device object for use for
261 * a driver
262 * ARGUMENTS:
263 * DriverObject : Driver object passed by iomgr when the driver was
264 * loaded
265 * DeviceExtensionSize : Number of bytes for the device extension
266 * DeviceName : Unicode name of device
267 * DeviceType : Device type
268 * DeviceCharacteristics : Bit mask of device characteristics
269 * Exclusive : True if only one thread can access the device at a
270 * time
271 * RETURNS:
272 * Success or failure
273 * DeviceObject : Contains a pointer to allocated device object
274 * if the call succeeded
275 * NOTES: See the DDK documentation for more information
276 */
277 NTSTATUS IoCreateDevice(PDRIVER_OBJECT DriverObject,
278 ULONG DeviceExtensionSize,
279 PUNICODE_STRING DeviceName,
280 DEVICE_TYPE DeviceType,
281 ULONG DeviceCharacteristics,
282 BOOLEAN Exclusive,
283 PDEVICE_OBJECT* DeviceObject);
284
285
286 PKEVENT IoCreateNotificationEvent(PUNICODE_STRING EventName,
287 PHANDLE EventHandle);
288
289 NTSTATUS IoCreateSymbolicLink(PUNICODE_STRING SymbolicLinkName,
290 PUNICODE_STRING DeviceName);
291
292 PKEVENT IoCreateSynchronizationEvent(PUNICODE_STRING EventName,
293 PHANDLE EventHandle);
294
295 NTSTATUS IoCreateUnprotectedSymbolicLink(PUNICODE_STRING SymbolicLinkName,
296 PUNICODE_STRING DeviceName);
297
298
299 VOID IoDeassignArcName(PUNICODE_STRING ArcName);
300
301 VOID IoDeleteController(PCONTROLLER_OBJECT ControllerObject);
302
303 VOID IoDeleteDevice(PDEVICE_OBJECT DeviceObject);
304
305 NTSTATUS IoDeleteSymbolicLink(PUNICODE_STRING SymbolicLinkName);
306
307 VOID IoDetachDevice(PDEVICE_OBJECT TargetDevice);
308
309 VOID IoDisconnectInterrupt(PKINTERRUPT InterruptObject);
310
311 BOOLEAN IoFlushAdapterBuffers(PADAPTER_OBJECT AdapterObject,
312 PMDL Mdl,
313 PVOID MapRegisterBase,
314 PVOID CurrentVa,
315 ULONG Length,
316 BOOLEAN WriteToDevice);
317
318 VOID IoFreeAdapterChannel(PADAPTER_OBJECT AdapterObject);
319 VOID IoFreeController(PCONTROLLER_OBJECT ControllerObject);
320 VOID IoFreeIrp(PIRP Irp);
321 VOID IoFreeMapRegisters(PADAPTER_OBJECT AdapterObject,
322 PVOID MapRegisterBase,
323 ULONG NumberOfMapRegisters);
324 VOID IoFreeMdl(PMDL Mdl);
325 PCONFIGURATION_INFORMATION IoGetConfigurationInformation(VOID);
326
327
328 /*
329 * FUNCTION: Returns a pointer to the callers stack location in the irp
330 */
331 PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(IRP* irp);
332
333 struct _EPROCESS* IoGetCurrentProcess(VOID);
334
335 NTSTATUS IoGetDeviceObjectPointer(PUNICODE_STRING ObjectName,
336 ACCESS_MASK DesiredAccess,
337 PFILE_OBJECT* FileObject,
338 PDEVICE_OBJECT* DeviceObject);
339
340 PDEVICE_OBJECT IoGetDeviceToVerify(PETHREAD Thread);
341
342 PGENERIC_MAPPING IoGetFileObjectGenericMapping(VOID);
343
344 ULONG IoGetFunctionCodeFromCtlCode(ULONG ControlCode);
345
346 PVOID IoGetInitialStack(VOID);
347
348 /*
349 * FUNCTION:
350 */
351 PIO_STACK_LOCATION IoGetNextIrpStackLocation(IRP* irp);
352
353 PDEVICE_OBJECT IoGetRelatedDeviceObject(PFILE_OBJECT FileObject);
354
355 VOID IoInitializeDpcRequest(PDEVICE_OBJECT DeviceObject,
356 PIO_DPC_ROUTINE DpcRoutine);
357
358 /*
359 * FUNCTION: Initalizes an irp allocated by the caller
360 * ARGUMENTS:
361 * Irp = IRP to initalize
362 * PacketSize = Size in bytes of the IRP
363 * StackSize = Number of stack locations in the IRP
364 */
365 VOID IoInitializeIrp(PIRP Irp, USHORT PacketSize, CCHAR StackSize);
366
367 NTSTATUS IoInitializeTimer(PDEVICE_OBJECT DeviceObject,
368 PIO_TIMER_ROUTINE TimerRoutine,
369 PVOID Context);
370
371 BOOLEAN IoIsErrorUserInduced(NTSTATUS Status);
372
373 BOOLEAN IoIsTotalDeviceFailure(NTSTATUS Status);
374
375 PIRP IoMakeAssociatedIrp(PIRP Irp, CCHAR StackSize);
376
377 PHYSICAL_ADDRESS IoMapTransfer(PADAPTER_OBJECT AdapterObject,
378 PMDL Mdl,
379 PVOID MapRegisterBase,
380 PVOID CurrentVa,
381 PULONG Length,
382 BOOLEAN WriteToDevice);
383
384 /*
385 * FUNCTION: Marks an IRP as pending
386 * ARGUMENTS:
387 * Irp = Irp to mark
388 * NOTE: If a driver doesn't complete the irp in its dispatch routine it
389 * must mark it pending otherwise the I/O manager will complete it on
390 * return from the dispatch routine.
391 */
392 VOID IoMarkIrpPending(PIRP Irp);
393
394 NTSTATUS IoQueryDeviceDescription(PINTERFACE_TYPE BusType,
395 PULONG BusNumber,
396 PCONFIGURATION_TYPE ControllerType,
397 PULONG ControllerNumber,
398 PCONFIGURATION_TYPE PeripheralType,
399 PULONG PeripheralNumber,
400 PIO_QUERY_DEVICE_ROUTINE CalloutRoutine,
401 PVOID Context);
402
403 VOID IoRaiseHardError(PIRP Irp, PVPB Vpb, PDEVICE_OBJECT RealDeviceObject);
404
405 BOOLEAN IoRaiseHardInformationalError(NTSTATUS ErrorStatus,
406 PUNICODE_STRING String,
407 PKTHREAD Thread);
408
409 NTSTATUS IoReadPartitionTable(PDEVICE_OBJECT DeviceObject,
410 ULONG SectorSize,
411 BOOLEAN ReturnedRecognizedPartitions,
412 struct _DRIVE_LAYOUT_INFORMATION** PBuffer);
413
414 VOID IoRegisterDriverReinitialization(PDRIVER_OBJECT DriverObject,
415 PDRIVER_REINITIALIZE ReinitRoutine,
416 PVOID Context);
417
418 NTSTATUS IoRegisterShutdownNotification(PDEVICE_OBJECT DeviceObject);
419
420 VOID IoReleaseCancelSpinLock(KIRQL Irql);
421
422 VOID IoRemoveShareAccess(PFILE_OBJECT FileObject,
423 PSHARE_ACCESS ShareAccess);
424
425 NTSTATUS IoReportResourceUsage(PUNICODE_STRING DriverClassName,
426 PDRIVER_OBJECT DriverObject,
427 PCM_RESOURCE_LIST DriverList,
428 ULONG DriverListSize,
429 PDEVICE_OBJECT DeviceObject,
430 PCM_RESOURCE_LIST DeviceList,
431 ULONG DeviceListSize,
432 BOOLEAN OverrideConflict,
433 PBOOLEAN ConflictDetected);
434
435 VOID IoRequestDpc(PDEVICE_OBJECT DeviceObject,
436 PIRP Irp,
437 PVOID Context);
438
439 PDRIVER_CANCEL IoSetCancelRoutine(PIRP Irp, PDRIVER_CANCEL CancelRoutine);
440
441 VOID IoSetCompletionRoutine(PIRP Irp,
442 PIO_COMPLETION_ROUTINE CompletionRoutine,
443 PVOID Context,
444 BOOLEAN InvokeOnSuccess,
445 BOOLEAN InvokeOnError,
446 BOOLEAN InvokeOnCancel);
447
448 VOID IoSetHardErrorOrVerifyDevice(PIRP Irp, PDEVICE_OBJECT DeviceObject);
449
450 VOID IoSetNextIrpStackLocation(PIRP Irp);
451
452 NTSTATUS IoSetPartitionInformation(PDEVICE_OBJECT DeviceObject,
453 ULONG SectorSize,
454 ULONG PartitionNumber,
455 ULONG PartitionType);
456
457 VOID IoSetShareAccess(ACCESS_MASK DesiredAccess,
458 ULONG DesiredShareAccess,
459 PFILE_OBJECT FileObject,
460 PSHARE_ACCESS ShareAccess);
461
462 /*
463 * FUNCTION: Determines the size of an IRP
464 * ARGUMENTS:
465 * StackSize = number of stack locations in the IRP
466 * RETURNS: The size of the IRP in bytes
467 */
468 USHORT IoSizeOfIrp(CCHAR StackSize);
469
470 /*
471 * FUNCTION: Dequeues the next IRP from the device's associated queue and
472 * calls its StartIo routine
473 * ARGUMENTS:
474 * DeviceObject = Device object
475 * Cancelable = True if IRPs in the queue can be cancelled
476 */
477 VOID IoStartNextPacket(PDEVICE_OBJECT DeviceObject, BOOLEAN Cancelable);
478
479 VOID IoStartNextPacketByKey(PDEVICE_OBJECT DeviceObject,
480 BOOLEAN Cancelable,
481 ULONG Key);
482
483 /*
484 * FUNCTION: Calls the drivers StartIO routine with the IRP or queues it if
485 * the device is busy
486 * ARGUMENTS:
487 * DeviceObject = Device to pass the IRP to
488 * Irp = Irp to be processed
489 * Key = Optional value for where to insert the IRP
490 * CancelFunction = Entry point for a driver supplied cancel function
491 */
492 VOID IoStartPacket(PDEVICE_OBJECT DeviceObject, PIRP Irp, PULONG Key,
493 PDRIVER_CANCEL CancelFunction);
494
495 VOID IoStartTimer(PDEVICE_OBJECT DeviceObject);
496
497 VOID IoStopTimer(PDEVICE_OBJECT DeviceObject);
498
499 VOID IoUnregisterShutdownNotification(PDEVICE_OBJECT DeviceObject);
500
501 VOID IoUpdateShareAccess(PFILE_OBJECT FileObject, PSHARE_ACCESS ShareAccess);
502
503 VOID IoWriteErrorLogEntry(PVOID ElEntry);
504
505 NTSTATUS IoWritePartitionTable(PDEVICE_OBJECT DeviceObject,
506 ULONG SectorSize,
507 ULONG SectorsPerTrack,
508 ULONG NumberOfHeads,
509 struct _DRIVE_LAYOUT_INFORMATION* PBuffer);
510
511
512 // Preliminary guess
513 NTKERNELAPI NTSTATUS IoQueryFileVolumeInformation(IN PFILE_OBJECT FileObject,
514 IN FS_INFORMATION_CLASS FsInformationClass,
515 IN ULONG Length,
516 OUT PVOID FsInformation,
517 OUT PULONG ReturnedLength);
518
519 NTKERNELAPI // confirmed - Undocumented because it does not require a valid file handle
520 NTSTATUS
521 IoQueryFileInformation(
522 IN PFILE_OBJECT FileObject,
523 IN FILE_INFORMATION_CLASS FileInformationClass,
524 IN ULONG Length,
525 OUT PVOID FileInformation,
526 OUT PULONG ReturnedLength
527 );
528 VOID IoRegisterFileSystem(PDEVICE_OBJECT DeviceObject);
529 PDEVICE_OBJECT IoGetAttachedDevice(PDEVICE_OBJECT DeviceObject);
530 PFILE_OBJECT IoCreateStreamFileObject(PFILE_OBJECT FileObject,
531 PDEVICE_OBJECT DeviceObject);