:pserver:cvsanon@mok.lvcm.com:/CVS/ReactOS reactos
[reactos.git] / include / ddk / iofuncs.h
1 #ifndef _INCLUDE_DDK_IOFUNCS_H
2 #define _INCLUDE_DDK_IOFUNCS_H
3 /* $Id$ */
4
5 /* --- EXPORTED BY NTOSKRNL --- */
6
7 /**********************************************************************
8  * NAME                                                 EXPORTED
9  *      IoAcquireCancelSpinLock@4
10  *      
11  * DESCRIPTION
12  *      Synchronizes cancelable-state transistions for IRPs in a 
13  *      multiprocessor-safe way.
14  *      
15  * ARGUMENTS
16  *      Irpl
17  *              Variable to store the current IRQ level.
18  *
19  * RETURN VALUE
20  *      None.
21  *
22  * REVISIONS
23  *
24  */
25 VOID
26 STDCALL
27 IoAcquireCancelSpinLock (
28         PKIRQL  Irpl
29         );
30 VOID
31 STDCALL
32 IoAcquireVpbSpinLock (
33         PKIRQL  Irpl
34         );
35 /**********************************************************************
36  * NAME                                                 EXPORTED
37  *      IoAllocateAdapterChannel@
38  *      
39  * DESCRIPTION
40  *      Allocates an adaptor object for a DMA operation on the target
41  *      device.
42  *      
43  * ARGUMENTS
44  *      Adaptor
45  *              Adapter channel or busmaster adapter to be allocated;
46  *              
47  *      DeviceObject
48  *              Target device for DMA;
49  *              
50  *      NumberOfMapRegisters
51  *              Number of map registers;
52  *              
53  *      ExecutionRoutine
54  *              Routine to be called when the adaptor is available;
55  *              
56  *      Context
57  *              Driver defined contex that will be passed to the
58  *              execution routine.
59  *              
60  * RETURN VALUE
61  *      Success or failure code.
62  *
63  * REVISIONS
64  *
65  */
66 NTSTATUS
67 STDCALL
68 IoAllocateAdapterChannel (
69         PADAPTER_OBJECT AdaperObject,
70         PDEVICE_OBJECT  DeviceObject,
71         ULONG           NumberOfMapRegisters,
72         PDRIVER_CONTROL ExecutionRoutine,
73         PVOID           Context
74         );
75 /**********************************************************************
76  * NAME                                                 EXPORTED
77  *      IoAllocateController@16
78  *
79  * DESCRIPTION
80  *      Sets up a call to a driver supplied controller object as 
81  *      soon as it is available.
82  *
83  * ARGUMENTS
84  *      ControllerObject
85  *              Driver created controller object;
86  *
87  *      DeviceObject
88  *              Target device;
89  *
90  *      ExecutionObject
91  *              Routine to be called;
92  *
93  *      Context
94  *              Driver determined context to be based to the
95  *              routine.
96  *
97  * RETURN VALUE
98  *      None.
99  *
100  * REVISIONS
101  *
102  */
103 VOID
104 STDCALL
105 IoAllocateController (
106         PCONTROLLER_OBJECT      ControllerObject,
107         PDEVICE_OBJECT          DeviceObject,
108         PDRIVER_CONTROL         ExecutionRoutine,
109         PVOID                   Context
110         );
111 /**********************************************************************
112  * NAME                                                 EXPORTED
113  *      IoAllocateErrorLogEntry@8
114  *      
115  * DESCRIPTION
116  *      Allocates an error log packet.
117  *
118  * ARGUMENTS
119  *      IoObject
120  *              Object which found the error;
121  *              
122  *      EntrySize
123  *              Size in bytes of the packet to be allocated.
124  *
125  * RETURN VALUE
126  *      On success, a pointer to the allocated packet.
127  *      On failure, it returns NULL.
128  */
129 PVOID
130 STDCALL
131 IoAllocateErrorLogEntry (
132         PVOID   IoObject,
133         UCHAR   EntrySize
134         );
135 /**********************************************************************
136  * NAME                                                 EXPORTED
137  *      IoAllocateIrp@8
138  *      
139  * DESCRIPTION
140  *      Allocates an IRP.
141  *      
142  * ARGUMENTS
143  *      StackSize
144  *              Number of stack locations to allocate;
145  *              
146  *      ChargeQuota
147  *              Who knows.
148  *              
149  * RETURN VALUE
150  *      On success, the allocated IRP. On failure, NULL.
151  */
152 PIRP
153 STDCALL
154 IoAllocateIrp (
155         CCHAR   StackSize,
156         BOOLEAN ChargeQuota
157         );
158 /**********************************************************************
159  * NAME                                                 EXPORTED
160  *      IoAllocateMdl@20
161  *
162  * DESCRIPTION
163  *      Allocates an MDL large enough to map the supplied buffer.
164  *      
165  * ARGUMENTS
166  *      VirtualAddress
167  *              Base virtual address of the buffer to be mapped;
168  *              
169  *      Length
170  *              Length of the buffer to be mapped;
171  *              
172  *      SecondaryBuffer
173  *              Whether the buffer is primary or secondary;
174  *              
175  *      ChargeQuota
176  *              Charge non-paged pool quota to current thread;
177  *              
178  *      Irp
179  *              Optional irp to be associated with the MDL.
180  *      
181  * RETURN VALUE
182  *      On success, the allocated MDL; on failure, NULL.
183  */
184 PMDL
185 STDCALL
186 IoAllocateMdl (
187         PVOID   VirtualAddress,
188         ULONG   Length,
189         BOOLEAN SecondaryBuffer,
190         BOOLEAN ChargeQuota,
191         PIRP    Irp
192         );
193
194 /**********************************************************************
195  * NAME                                                 MACRO
196  *      IoAssignArcName
197  *
198  * DESCRIPTION
199  *      Creates a symbolic link between the ARC name of a physical
200  *      device and the name of the corresponding device object
201  *
202  * ARGUMENTS
203  *      ArcName
204  *              ARC name of the device
205  *
206  *      DeviceName
207  *              Name of the device object
208  *
209  * NOTES
210  *      VOID
211  *      IoAssignArcName (
212  *              PUNICODE_STRING ArcName,
213  *              PUNICODE_STRING DeviceName
214  *              );
215  */
216 #define IoAssignArcName(ArcName,DeviceName) \
217         (IoCreateSymbolicLink((ArcName),(DeviceName)))
218
219 /**********************************************************************
220  * NAME                                                 EXPORTED
221  *      IoAssignResources@24
222  *
223  * DESCRIPTION
224  *      Takes a list of requested hardware resources and allocates
225  *      them.
226  *
227  * ARGUMENTS
228  *      RegisterPath
229  *              ?
230  *
231  *      DriverClassName
232  *              ?
233  *
234  *      DriverObject
235  *              Driver object passed to the DriverEntry routine;
236  *
237  *      DeviceObject
238  *              ?
239  *
240  *      RequestedResources
241  *              List of resources.
242  *
243  * RETURN VALUE
244  */
245 NTSTATUS
246 STDCALL
247 IoAssignResources (
248         PUNICODE_STRING                 RegistryPath,
249         PUNICODE_STRING                 DriverClassName,
250         PDRIVER_OBJECT                  DriverObject,
251         PDEVICE_OBJECT                  DeviceObject,
252         PIO_RESOURCE_REQUIREMENTS_LIST  RequestedResources,
253         PCM_RESOURCE_LIST               * AllocatedResources
254         );
255 /*
256  * FUNCTION: Attaches the callers device object to a named target device
257  * ARGUMENTS:
258  *        SourceDevice = caller's device
259  *        TargetDevice = Name of the target device
260  *        AttachedDevice = Caller allocated storage. On return contains
261  *                         a pointer to the target device
262  * RETURNS: Success or failure code
263  */
264 NTSTATUS
265 STDCALL
266 IoAttachDevice (
267         PDEVICE_OBJECT  SourceDevice,
268         PUNICODE_STRING TargetDevice,
269         PDEVICE_OBJECT  * AttachedDevice
270         );
271 /*
272  * FUNCTION: Obsolete
273  * ARGUMENTS:
274  *       SourceDevice = device to attach
275  *       TargetDevice = device to be attached to
276  * RETURNS: Success or failure code
277  */
278 NTSTATUS
279 STDCALL
280 IoAttachDeviceByPointer (
281         PDEVICE_OBJECT  SourceDevice,
282         PDEVICE_OBJECT  TargetDevice
283         );
284 /*
285  * FUNCTION: Attaches the callers device to the highest device in the chain
286  * ARGUMENTS:
287  *       SourceDevice = caller's device
288  *       TargetDevice = Device to attach
289  * RETURNS: On success the previously highest device
290  *          On failure NULL
291  */
292 PDEVICE_OBJECT
293 STDCALL
294 IoAttachDeviceToDeviceStack (
295         PDEVICE_OBJECT  SourceDevice,
296         PDEVICE_OBJECT  TargetDevice
297         );
298 /*
299  * FUNCTION: Builds a irp to be sent to lower level drivers
300  * ARGUMENTS:
301  *       MajorFunction = Major function code to be set in the IRP
302  *       DeviceObject = Next lower device object
303  *       Buffer = Buffer (only required for some major function codes)
304  *       Length = Length in bytes of the buffer 
305  *       StartingOffset = Starting offset on the target device
306  *       IoStatusBlock = Storage for status about the operation (optional)
307  * RETURNS: On success the IRP allocated
308  *          On failure NULL
309  */
310 PIRP
311 STDCALL
312 IoBuildAsynchronousFsdRequest (
313         ULONG                   MajorFunction,
314         PDEVICE_OBJECT          DeviceObject,
315         PVOID                   Buffer,
316         ULONG                   Length,
317         PLARGE_INTEGER          StartingOffset,
318         PIO_STATUS_BLOCK        IoStatusBlock
319         );
320 /*
321  * FUNCTION: Allocates and sets up an IRP for a device control request
322  * ARGUMENTS:
323  *        IoControlCode = Type of request
324  *        DeviceObject = Target device
325  *        InputBuffer = Optional input buffer to the driver
326  *        InputBufferLength = Length of the input buffer
327  *        OutputBuffer = Optional output buffer
328  *        OutputBufferLength = Length of the output buffer
329  *        InternalDeviceIoControl = TRUE if the request is internal
330  *        Event = Initialized event for the caller to wait for the request
331  *                to be completed
332  *        IoStatusBlock = I/O status block to be set when the request is
333  *                        completed
334  * RETURNS: Returns the IRP created
335  */
336 PIRP
337 STDCALL
338 IoBuildDeviceIoControlRequest (
339         ULONG                   IoControlCode,
340         PDEVICE_OBJECT          DeviceObject,
341         PVOID                   InputBuffer,
342         ULONG                   InputBufferLength,
343         PVOID                   OutputBuffer,
344         ULONG                   OutputBufferLength,
345         BOOLEAN                 InternalDeviceIoControl,
346         PKEVENT                 Event,
347         PIO_STATUS_BLOCK        IoStatusBlock
348         );
349 VOID
350 STDCALL
351 IoBuildPartialMdl (
352         PMDL    SourceMdl,
353         PMDL    TargetMdl,
354         PVOID   VirtualAddress,
355         ULONG   Length
356         );
357 PIRP
358 STDCALL
359 IoBuildSynchronousFsdRequest (
360         ULONG                   MajorFunction,
361         PDEVICE_OBJECT          DeviceObject,
362         PVOID                   Buffer,
363         ULONG                   Length,
364         PLARGE_INTEGER          StartingOffset,
365         PKEVENT                 Event,
366         PIO_STATUS_BLOCK        IoStatusBlock
367         );
368 NTSTATUS
369 STDCALL
370 IoCallDriver (
371         PDEVICE_OBJECT  DeviceObject,
372         PIRP            Irp
373         );
374 BOOLEAN
375 STDCALL
376 IoCancelIrp (
377         PIRP    Irp
378         );
379
380 NTSTATUS STDCALL
381 IoCheckDesiredAccess(IN OUT PACCESS_MASK DesiredAccess,
382                      IN ACCESS_MASK GrantedAccess);
383
384 NTSTATUS STDCALL
385 IoCheckEaBufferValidity(IN PFILE_FULL_EA_INFORMATION EaBuffer,
386                         IN ULONG EaLength,
387                         OUT PULONG ErrorOffset);
388
389 NTSTATUS STDCALL
390 IoCheckFunctionAccess(IN ACCESS_MASK GrantedAccess,
391                       IN UCHAR MajorFunction,
392                       IN UCHAR MinorFunction,
393                       IN ULONG IoControlCode,
394                       IN PFILE_INFORMATION_CLASS FileInformationClass OPTIONAL,
395                       IN PFS_INFORMATION_CLASS FsInformationClass OPTIONAL);
396
397 NTSTATUS
398 STDCALL
399 IoCheckShareAccess (
400         ACCESS_MASK     DesiredAccess,
401         ULONG           DesiredShareAccess,
402         PFILE_OBJECT    FileObject,
403         PSHARE_ACCESS   ShareAccess,
404         BOOLEAN         Update
405         );
406 VOID
407 STDCALL
408 IoCompleteRequest (
409         PIRP    Irp,
410         CCHAR   PriorityBoost
411         );
412 NTSTATUS
413 STDCALL
414 IoConnectInterrupt (
415         PKINTERRUPT             * InterruptObject,
416         PKSERVICE_ROUTINE       ServiceRoutine,
417         PVOID                   ServiceContext,
418         PKSPIN_LOCK             SpinLock,
419         ULONG                   Vector,
420         KIRQL                   Irql,
421         KIRQL                   SynchronizeIrql,
422         KINTERRUPT_MODE         InterruptMode,
423         BOOLEAN                 ShareVector,
424         KAFFINITY               ProcessorEnableMask,
425         BOOLEAN                 FloatingSave
426         );
427
428 PCONTROLLER_OBJECT
429 STDCALL
430 IoCreateController (
431         ULONG   Size
432         );
433 /*
434  * FUNCTION: Allocates memory for and intializes a device object for use for
435  * a driver
436  * ARGUMENTS:
437  *         DriverObject : Driver object passed by iomgr when the driver was
438  *                        loaded
439  *         DeviceExtensionSize : Number of bytes for the device extension
440  *         DeviceName : Unicode name of device
441  *         DeviceType : Device type
442  *         DeviceCharacteristics : Bit mask of device characteristics
443  *         Exclusive : True if only one thread can access the device at a
444  *                     time
445  * RETURNS:
446  *         Success or failure
447  *         DeviceObject : Contains a pointer to allocated device object
448  *                        if the call succeeded
449  * NOTES: See the DDK documentation for more information        
450  */
451 NTSTATUS
452 STDCALL
453 IoCreateDevice (
454         PDRIVER_OBJECT  DriverObject,
455         ULONG           DeviceExtensionSize,
456         PUNICODE_STRING DeviceName,
457         DEVICE_TYPE     DeviceType,
458         ULONG           DeviceCharacteristics,
459         BOOLEAN         Exclusive,
460         PDEVICE_OBJECT  * DeviceObject
461         );
462 NTSTATUS
463 STDCALL
464 IoCreateFile (
465         OUT     PHANDLE                 FileHandle,
466         IN      ACCESS_MASK             DesiredAccess,
467         IN      POBJECT_ATTRIBUTES      ObjectAttributes,
468         OUT     PIO_STATUS_BLOCK        IoStatusBlock,
469         IN      PLARGE_INTEGER          AllocationSize          OPTIONAL,
470         IN      ULONG                   FileAttributes,
471         IN      ULONG                   ShareAccess,
472         IN      ULONG                   CreateDisposition,
473         IN      ULONG                   CreateOptions,
474         IN      PVOID                   EaBuffer                OPTIONAL,
475         IN      ULONG                   EaLength,
476         IN      CREATE_FILE_TYPE        CreateFileType,
477         IN      PVOID                   ExtraCreateParameters   OPTIONAL,
478         IN      ULONG                   Options
479         );
480 PKEVENT
481 STDCALL
482 IoCreateNotificationEvent (
483         PUNICODE_STRING EventName,
484         PHANDLE EventHandle
485         );
486 PFILE_OBJECT
487 STDCALL
488 IoCreateStreamFileObject (
489         PFILE_OBJECT    FileObject,
490         PDEVICE_OBJECT  DeviceObject
491         );
492 NTSTATUS
493 STDCALL
494 IoCreateSymbolicLink (
495         PUNICODE_STRING SymbolicLinkName,
496         PUNICODE_STRING DeviceName
497         );
498 PKEVENT
499 STDCALL
500 IoCreateSynchronizationEvent (
501         PUNICODE_STRING EventName,
502         PHANDLE EventHandle
503         );
504 NTSTATUS
505 STDCALL
506 IoCreateUnprotectedSymbolicLink (
507         PUNICODE_STRING SymbolicLinkName,
508         PUNICODE_STRING DeviceName
509         );
510
511 /*
512  * FUNCTION:
513  *      Deletes a symbolic link between the ARC name of a physical
514  *      device and the name of the corresponding device object
515  *
516  * ARGUMENTS:
517  *      ArcName = ARC name of the device
518  *
519  * NOTES:
520  *      VOID
521  *      IoDeassignArcName (
522  *              PUNICODE_STRING ArcName
523  *              );
524  */
525 #define IoDeassignArcName(ArcName) \
526         (IoDeleteSymbolicLink((ArcName)))
527
528 VOID
529 STDCALL
530 IoDeleteController (
531         PCONTROLLER_OBJECT      ControllerObject
532         );
533 VOID
534 STDCALL
535 IoDeleteDevice (
536         PDEVICE_OBJECT  DeviceObject
537         );
538 NTSTATUS
539 STDCALL
540 IoDeleteSymbolicLink (
541         PUNICODE_STRING SymbolicLinkName
542         );
543 VOID
544 STDCALL
545 IoDetachDevice (
546         PDEVICE_OBJECT  TargetDevice
547         );
548 VOID
549 STDCALL
550 IoDisconnectInterrupt (
551         PKINTERRUPT     InterruptObject
552         );
553 VOID
554 STDCALL
555 IoEnqueueIrp (
556         PIRP    Irp
557         );
558
559 BOOLEAN STDCALL
560 IoFastQueryNetworkAttributes(IN POBJECT_ATTRIBUTES ObjectAttributes,
561                              IN ACCESS_MASK DesiredAccess,
562                              IN ULONG OpenOptions,
563                              OUT PIO_STATUS_BLOCK IoStatus,
564                              OUT PFILE_NETWORK_OPEN_INFORMATION Buffer);
565
566 VOID
567 STDCALL
568 IoFreeController (
569         PCONTROLLER_OBJECT      ControllerObject
570         );
571 VOID
572 STDCALL
573 IoFreeIrp (
574         PIRP    Irp
575         );
576 VOID
577 STDCALL
578 IoFreeMdl (
579         PMDL    Mdl
580         );
581 PDEVICE_OBJECT
582 STDCALL
583 IoGetAttachedDevice (
584         PDEVICE_OBJECT  DeviceObject
585         );
586 PDEVICE_OBJECT
587 STDCALL
588 IoGetAttachedDeviceReference (
589         PDEVICE_OBJECT  DeviceObject
590         );
591 PDEVICE_OBJECT
592 STDCALL
593 IoGetBaseFileSystemDeviceObject (
594         IN      PFILE_OBJECT    FileObject
595         );
596 PCONFIGURATION_INFORMATION
597 STDCALL
598 IoGetConfigurationInformation (
599         VOID
600         );
601
602 /*
603  * FUNCTION: Gets a pointer to the callers location in the I/O stack in
604  * the given IRP
605  * ARGUMENTS:
606  *         Irp = Points to the IRP
607  * RETURNS: A pointer to the stack location
608  *
609  * NOTES:
610  *      PIO_STACK_LOCATION
611  *      IoGetCurrentIrpStackLocation (PIRP Irp)
612  */
613 #define IoGetCurrentIrpStackLocation(Irp) \
614         ((Irp)->Tail.Overlay.CurrentStackLocation)
615
616 #define IoSetNextIrpStackLocation(Irp) { \
617   (Irp)->CurrentLocation--; \
618   (Irp)->Tail.Overlay.CurrentStackLocation--; }
619
620 #define IoCopyCurrentIrpStackLocationToNext(Irp) { \
621   PIO_STACK_LOCATION IrpSp; \
622   PIO_STACK_LOCATION NextIrpSp; \
623   IrpSp = IoGetCurrentIrpStackLocation((Irp)); \
624   NextIrpSp = IoGetNextIrpStackLocation((Irp)); \
625   RtlCopyMemory(NextIrpSp, IrpSp, \
626     FIELD_OFFSET(IO_STACK_LOCATION, CompletionRoutine)); \
627   NextIrpSp->Control = 0; }
628
629 #define IoSkipCurrentIrpStackLocation(Irp) \
630   (Irp)->CurrentLocation++; \
631   (Irp)->Tail.Overlay.CurrentStackLocation++;
632
633 struct _EPROCESS*
634 STDCALL
635 IoGetCurrentProcess (
636         VOID
637         );
638 NTSTATUS
639 STDCALL
640 IoGetDeviceObjectPointer (
641         PUNICODE_STRING ObjectName,
642         ACCESS_MASK     DesiredAccess,
643         PFILE_OBJECT    * FileObject,
644         PDEVICE_OBJECT  * DeviceObject
645         );
646 PDEVICE_OBJECT
647 STDCALL
648 IoGetDeviceToVerify (
649         struct _ETHREAD*        Thread
650         );
651 PGENERIC_MAPPING
652 STDCALL
653 IoGetFileObjectGenericMapping (
654         VOID
655         );
656
657 #define IoGetFunctionCodeFromCtlCode(ControlCode) \
658         ((ControlCode >> 2) & 0x00000FFF)
659
660 PVOID
661 STDCALL
662 IoGetInitialStack (
663         VOID
664         );
665
666 /*
667  * FUNCTION: Gives a higher level driver access to the next lower driver's 
668  * I/O stack location
669  * ARGUMENTS: 
670  *           Irp = points to the irp
671  * RETURNS: A pointer to the stack location
672  *
673  * NOTES:
674  *      PIO_STACK_LOCATION
675  *      IoGetNextIrpStackLocation (PIRP Irp)
676  */
677 #define IoGetNextIrpStackLocation(Irp) \
678         ((Irp)->Tail.Overlay.CurrentStackLocation-1)
679
680
681 PDEVICE_OBJECT
682 STDCALL
683 IoGetRelatedDeviceObject (
684         PFILE_OBJECT    FileObject
685         );
686 struct _EPROCESS*
687 STDCALL
688 IoGetRequestorProcess (
689         IN      PIRP    Irp
690         );
691
692 VOID
693 STDCALL
694 IoGetStackLimits (
695         PULONG  LowLimit,
696         PULONG  HighLimit
697         );
698
699 PIRP
700 STDCALL
701 IoGetTopLevelIrp (
702         VOID
703         );
704
705 #define IoInitializeDpcRequest(DeviceObject,DpcRoutine) \
706         (KeInitializeDpc(&(DeviceObject)->Dpc, \
707                          (PKDEFERRED_ROUTINE)(DpcRoutine), \
708                          (DeviceObject)))
709
710 /*
711  * FUNCTION: Initalizes an irp allocated by the caller
712  * ARGUMENTS:
713  *          Irp = IRP to initalize
714  *          PacketSize = Size in bytes of the IRP
715  *          StackSize = Number of stack locations in the IRP
716  */
717 VOID
718 STDCALL
719 IoInitializeIrp (
720         PIRP    Irp,
721         USHORT  PacketSize,
722         CCHAR   StackSize
723         );
724 NTSTATUS
725 STDCALL
726 IoInitializeTimer (
727         PDEVICE_OBJECT          DeviceObject,
728         PIO_TIMER_ROUTINE       TimerRoutine,
729         PVOID                   Context
730         );
731
732 /*
733  * NOTES:
734  *      BOOLEAN
735  *      IsErrorUserInduced (NTSTATUS Status)
736  */
737 #define IoIsErrorUserInduced(Status) \
738         ((BOOLEAN)(((Status) == STATUS_DEVICE_NOT_READY) || \
739                    ((Status) == STATUS_IO_TIMEOUT) || \
740                    ((Status) == STATUS_MEDIA_WRITE_PROTECTED) || \
741                    ((Status) == STATUS_NO_MEDIA_IN_DRIVE) || \
742                    ((Status) == STATUS_VERIFY_REQUIRED) || \
743                    ((Status) == STATUS_UNRECOGNIZED_MEDIA) || \
744                    ((Status) == STATUS_WRONG_VOLUME)))
745
746 BOOLEAN
747 STDCALL
748 IoIsOperationSynchronous (
749         IN      PIRP    Irp
750         );
751 BOOLEAN
752 STDCALL
753 IoIsSystemThread (
754         PVOID   Unknown0
755         );
756 PIRP
757 STDCALL
758 IoMakeAssociatedIrp (
759         PIRP    Irp,
760         CCHAR   StackSize
761         );
762
763 /*
764  * FUNCTION: Marks the specified irp, indicating further processing will
765  * be required by other driver routines
766  * ARGUMENTS:
767  *      Irp = Irp to mark
768  * NOTES:
769  *      VOID
770  *      IoMarkIrpPending (PIRP Irp)
771  */
772 #define IoMarkIrpPending(Irp) \
773         (IoGetCurrentIrpStackLocation(Irp)->Control |= SL_PENDING_RETURNED)
774
775
776 NTSTATUS
777 STDCALL
778 IoOpenDeviceInstanceKey (
779         DWORD   Unknown0,
780         DWORD   Unknown1,
781         DWORD   Unknown2,
782         DWORD   Unknown3,
783         DWORD   Unknown4
784         );
785 NTSTATUS
786 STDCALL
787 IoQueryDeviceDescription (
788         PINTERFACE_TYPE                 BusType,
789         PULONG                          BusNumber,
790         PCONFIGURATION_TYPE             ControllerType,
791         PULONG                          ControllerNumber,
792         PCONFIGURATION_TYPE             PeripheralType,
793         PULONG                          PeripheralNumber,
794         PIO_QUERY_DEVICE_ROUTINE        CalloutRoutine,
795         PVOID                           Context
796         );
797 DWORD
798 STDCALL
799 IoQueryDeviceEnumInfo (
800         DWORD   Unknown0,
801         DWORD   Unknown1
802         );
803 // IoQueryFileInformation: confirmed - Undocumented because it does not require a valid file handle 
804 NTSTATUS 
805 STDCALL
806 IoQueryFileInformation (
807         IN      PFILE_OBJECT            FileObject,
808         IN      FILE_INFORMATION_CLASS  FileInformationClass,
809         IN      ULONG                   Length,
810         OUT     PVOID                   FileInformation,
811         OUT     PULONG                  ReturnedLength  
812         );
813 NTSTATUS
814 STDCALL
815 IoQueryVolumeInformation (
816         IN      PFILE_OBJECT            FileObject,
817         IN      FS_INFORMATION_CLASS    FsInformationClass,
818         IN      ULONG                   Length,
819         OUT     PVOID                   FsInformation,
820         OUT     PULONG                  ReturnedLength
821         );
822 VOID
823 STDCALL
824 IoQueueThreadIrp (
825         IN      PIRP    Irp
826         );
827
828 VOID
829 STDCALL
830 IoQueueWorkItem(
831     IN PIO_WORKITEM IoWorkItem, 
832         IN PIO_WORKITEM_ROUTINE WorkerRoutine, 
833         IN WORK_QUEUE_TYPE QueueType, 
834         IN PVOID Context
835         );
836
837 VOID
838 STDCALL
839 IoFreeWorkItem(
840     PIO_WORKITEM IoWorkItem
841         );
842
843 PIO_WORKITEM
844 STDCALL
845 IoAllocateWorkItem(
846         PDEVICE_OBJECT DeviceObject
847         );
848
849 VOID
850 STDCALL
851 IoRaiseHardError (
852         PIRP            Irp,
853         PVPB            Vpb,
854         PDEVICE_OBJECT  RealDeviceObject
855         );
856 BOOLEAN
857 STDCALL
858 IoRaiseInformationalHardError (
859         NTSTATUS        ErrorStatus,
860         PUNICODE_STRING String,
861         struct _KTHREAD*        Thread
862         );
863 VOID
864 STDCALL
865 IoRegisterDriverReinitialization (
866         PDRIVER_OBJECT          DriverObject,
867         PDRIVER_REINITIALIZE    ReinitRoutine,
868         PVOID                   Context
869         );
870 VOID
871 STDCALL
872 IoRegisterFileSystem (
873         PDEVICE_OBJECT  DeviceObject
874         );
875 #if (_WIN32_WINNT >= 0x0400)
876 NTSTATUS
877 STDCALL
878 IoRegisterFsRegistrationChange (
879         IN      PDRIVER_OBJECT          DriverObject,
880         IN      PFSDNOTIFICATIONPROC    FSDNotificationProc
881         );
882 #endif // (_WIN32_WINNT >= 0x0400)
883 NTSTATUS
884 STDCALL
885 IoRegisterShutdownNotification (
886         PDEVICE_OBJECT  DeviceObject
887         );
888 VOID
889 STDCALL
890 IoReleaseCancelSpinLock (
891         IN      KIRQL   Irql
892         );
893 VOID
894 STDCALL
895 IoReleaseVpbSpinLock (
896         IN      KIRQL   Irql
897         );
898 VOID
899 STDCALL
900 IoRemoveShareAccess (
901         PFILE_OBJECT    FileObject,
902         PSHARE_ACCESS   ShareAccess
903         );
904 NTSTATUS
905 STDCALL
906 IoReportHalResourceUsage (
907         IN      PUNICODE_STRING         HalDescription,
908         IN      PCM_RESOURCE_LIST       RawList,
909         IN      PCM_RESOURCE_LIST       TranslatedList,
910         IN      ULONG                   ListSize
911         );
912 NTSTATUS
913 STDCALL
914 IoReportResourceUsage (
915         PUNICODE_STRING         DriverClassName,
916         PDRIVER_OBJECT          DriverObject,
917         PCM_RESOURCE_LIST       DriverList,
918         ULONG                   DriverListSize,
919         PDEVICE_OBJECT          DeviceObject,
920         PCM_RESOURCE_LIST       DeviceList,
921         ULONG                   DeviceListSize,
922         BOOLEAN                 OverrideConflict,
923         PBOOLEAN                ConflictDetected
924         );
925
926 #define IoRequestDpc(DeviceObject,Irp,Context) \
927         (KeInsertQueueDpc(&(DeviceObject)->Dpc,(Irp),(Context)))
928
929 #define IoSetCancelRoutine(Irp,NewCancelRoutine) \
930         ((PDRIVER_CANCEL)InterlockedExchange((PULONG)&(Irp)->CancelRoutine, \
931                                              (ULONG)(NewCancelRoutine)));
932
933 #define IoSetCompletionRoutine(Irp,Routine,Context,Success,Error,Cancel) \
934         { \
935                 PIO_STACK_LOCATION param; \
936                 assert((Success)||(Error)||(Cancel)?(Routine)!=NULL:TRUE); \
937                 param = IoGetNextIrpStackLocation((Irp)); \
938                 param->CompletionRoutine=(Routine); \
939                 param->CompletionContext=(Context); \
940                 param->Control = 0; \
941                 if ((Success)) \
942                         param->Control = SL_INVOKE_ON_SUCCESS; \
943                 if ((Error)) \
944                         param->Control |= SL_INVOKE_ON_ERROR; \
945                 if ((Cancel)) \
946                         param->Control |= SL_INVOKE_ON_CANCEL; \
947         } 
948
949 VOID STDCALL
950 IoSetDeviceToVerify (IN struct _ETHREAD* Thread,
951                      IN PDEVICE_OBJECT DeviceObject);
952 VOID
953 STDCALL
954 IoSetHardErrorOrVerifyDevice (
955         IN      PIRP            Irp,
956         IN      PDEVICE_OBJECT  DeviceObject
957         );
958 NTSTATUS
959 STDCALL
960 IoSetInformation (
961         IN      PFILE_OBJECT            FileObject,
962         IN      FILE_INFORMATION_CLASS  FileInformationClass,
963         IN      ULONG                   Length,
964         OUT     PVOID                   FileInformation
965         );
966
967 #define IoSetNextIrpStackLocation(Irp) \
968 { \
969         (Irp)->CurrentLocation--; \
970         (Irp)->Tail.Overlay.CurrentStackLocation--; \
971
972
973 VOID
974 STDCALL
975 IoSetShareAccess (
976         ACCESS_MASK     DesiredAccess,
977         ULONG           DesiredShareAccess,
978         PFILE_OBJECT    FileObject,
979         PSHARE_ACCESS   ShareAccess
980         );
981 BOOLEAN
982 STDCALL
983 IoSetThreadHardErrorMode (
984         IN      BOOLEAN HardErrorEnabled
985         );
986 VOID
987 STDCALL
988 IoSetTopLevelIrp (
989         IN      PIRP    Irp
990         );
991
992 /*
993  * FUNCTION:  Determines the size of an IRP
994  * ARGUMENTS: 
995  *           StackSize = number of stack locations in the IRP
996  * RETURNS: The size of the IRP in bytes 
997 USHORT
998 IoSizeOfIrp (CCHAR StackSize)
999  */
1000 #define IoSizeOfIrp(StackSize) \
1001         ((USHORT)(sizeof(IRP)+(((StackSize)-1)*sizeof(IO_STACK_LOCATION))))
1002
1003 /* original macro */
1004 /*
1005 #define IoSizeOfIrp(StackSize) \
1006         ((USHORT)(sizeof(IRP)+((StackSize)*sizeof(IO_STACK_LOCATION))))
1007 */
1008
1009 /*
1010  * FUNCTION: Dequeues the next IRP from the device's associated queue and
1011  * calls its StartIo routine
1012  * ARGUMENTS:
1013  *          DeviceObject = Device object
1014  *          Cancelable = True if IRPs in the queue can be cancelled
1015  */
1016 VOID
1017 STDCALL
1018 IoStartNextPacket (
1019         PDEVICE_OBJECT  DeviceObject,
1020         BOOLEAN         Cancelable
1021         );
1022 VOID
1023 STDCALL
1024 IoStartNextPacketByKey (
1025         PDEVICE_OBJECT  DeviceObject,
1026         BOOLEAN         Cancelable,
1027         ULONG           Key
1028         );
1029 /*
1030  * FUNCTION: Calls the drivers StartIO routine with the IRP or queues it if
1031  * the device is busy
1032  * ARGUMENTS:
1033  *         DeviceObject = Device to pass the IRP to 
1034  *         Irp = Irp to be processed
1035  *         Key = Optional value for where to insert the IRP
1036  *         CancelFunction = Entry point for a driver supplied cancel function
1037  */
1038 VOID
1039 STDCALL
1040 IoStartPacket (
1041         PDEVICE_OBJECT  DeviceObject,
1042         PIRP            Irp,
1043         PULONG          Key,
1044         PDRIVER_CANCEL  CancelFunction
1045         );
1046 VOID
1047 STDCALL
1048 IoStartTimer (
1049         PDEVICE_OBJECT  DeviceObject
1050         );
1051 VOID
1052 STDCALL
1053 IoStopTimer (
1054         PDEVICE_OBJECT  DeviceObject
1055         );
1056
1057 NTSTATUS STDCALL
1058 IoPageRead(PFILE_OBJECT         FileObject,
1059            PMDL                 Mdl,
1060            PLARGE_INTEGER       Offset,
1061            PKEVENT              Event,
1062            PIO_STATUS_BLOCK     StatusBlock);
1063
1064 NTSTATUS STDCALL 
1065 IoSynchronousPageWrite (PFILE_OBJECT        FileObject,
1066                         PMDL                Mdl,
1067                         PLARGE_INTEGER      Offset,
1068                         PKEVENT             Event,
1069                         PIO_STATUS_BLOCK    StatusBlock);
1070
1071 struct _EPROCESS* STDCALL IoThreadToProcess (struct _ETHREAD*   Thread);
1072 VOID
1073 STDCALL
1074 IoUnregisterFileSystem (
1075         IN      PDEVICE_OBJECT  DeviceObject
1076         );
1077 #if (_WIN32_WINNT >= 0x0400)
1078 VOID
1079 STDCALL
1080 IoUnregisterFsRegistrationChange (
1081         IN      PDRIVER_OBJECT          DriverObject,
1082         IN      PFSDNOTIFICATIONPROC    FSDNotificationProc
1083         );
1084 #endif // (_WIN32_WINNT >= 0x0400)
1085 VOID
1086 STDCALL
1087 IoUnregisterShutdownNotification (
1088         IN      PDEVICE_OBJECT  DeviceObject
1089         );
1090 VOID
1091 STDCALL
1092 IoUpdateShareAccess (
1093         IN      PFILE_OBJECT    FileObject,
1094         IN      PSHARE_ACCESS   ShareAccess
1095         );
1096 NTSTATUS
1097 STDCALL
1098 IoVerifyVolume (
1099         IN      PDEVICE_OBJECT  DeviceObject,
1100         IN      BOOLEAN         AllowRawMount
1101         );
1102 VOID
1103 STDCALL
1104 IoWriteErrorLogEntry (
1105         PVOID   ElEntry
1106         );
1107 /*
1108  * FUNCTION: Sends an irp to the next lower driver
1109  */
1110 NTSTATUS
1111 FASTCALL
1112 IofCallDriver (
1113         PDEVICE_OBJECT  DeviceObject,
1114         PIRP            Irp
1115         );
1116 /*
1117  * FUNCTION: Indicates the caller has finished all processing for a given
1118  * I/O request and is returning the given IRP to the I/O manager
1119  * ARGUMENTS:
1120  *         Irp = Irp to be cancelled
1121  *         PriorityBoost = Increment by which to boost the priority of the
1122  *                         thread making the request
1123  */
1124 VOID
1125 FASTCALL
1126 IofCompleteRequest (
1127         PIRP    Irp,
1128         CCHAR   PriorityBoost
1129         );
1130
1131 /* --- EXPORTED BY HAL --- */
1132
1133 VOID
1134 STDCALL
1135 IoAssignDriveLetters (
1136         IN      PLOADER_PARAMETER_BLOCK LoaderBlock,
1137         IN      PSTRING                 NtDeviceName,
1138         OUT     PUCHAR                  NtSystemPath,
1139         OUT     PSTRING                 NtSystemPathString
1140         );
1141
1142 BOOLEAN
1143 STDCALL
1144 IoFlushAdapterBuffers (
1145         PADAPTER_OBJECT AdapterObject,
1146         PMDL            Mdl,
1147         PVOID           MapRegisterBase,
1148         PVOID           CurrentVa,
1149         ULONG           Length,
1150         BOOLEAN         WriteToDevice
1151         );
1152
1153 VOID
1154 STDCALL
1155 IoFreeAdapterChannel (
1156         PADAPTER_OBJECT AdapterObject
1157         );
1158
1159 VOID
1160 STDCALL
1161 IoFreeMapRegisters (
1162         PADAPTER_OBJECT AdapterObject,
1163         PVOID           MapRegisterBase,
1164         ULONG           NumberOfMapRegisters
1165         );
1166
1167 PHYSICAL_ADDRESS
1168 STDCALL
1169 IoMapTransfer (
1170         PADAPTER_OBJECT AdapterObject,
1171         PMDL            Mdl,
1172         PVOID           MapRegisterBase,
1173         PVOID           CurrentVa,
1174         PULONG          Length,
1175         BOOLEAN         WriteToDevice
1176         );
1177
1178 NTSTATUS
1179 STDCALL
1180 IoReadPartitionTable (
1181         PDEVICE_OBJECT                  DeviceObject,
1182         ULONG                           SectorSize,
1183         BOOLEAN                         ReturnedRecognizedPartitions,
1184         PDRIVE_LAYOUT_INFORMATION       * PartitionBuffer
1185         );
1186
1187 NTSTATUS
1188 STDCALL
1189 IoSetPartitionInformation (
1190         PDEVICE_OBJECT  DeviceObject,
1191         ULONG           SectorSize,
1192         ULONG           PartitionNumber,
1193         ULONG           PartitionType
1194         );
1195
1196 NTSTATUS
1197 STDCALL
1198 IoWritePartitionTable (
1199         PDEVICE_OBJECT                  DeviceObject,
1200         ULONG                           SectorSize,
1201         ULONG                           SectorsPerTrack,
1202         ULONG                           NumberOfHeads,
1203         PDRIVE_LAYOUT_INFORMATION       PartitionBuffer
1204         );
1205
1206
1207 /* --- --- --- INTERNAL or REACTOS ONLY --- --- --- */
1208
1209 /*
1210  * FUNCTION: Registers the driver with WMI
1211  * ARGUMENTS:
1212  *          DeviceObject = Device to register
1213  *          Action = Action to take
1214  * RETURNS: Status (?)
1215  */
1216 /*
1217 NTSTATUS
1218 IoWMIRegistrationControl (
1219         PDEVICE_OBJECT DeviceObject,
1220         WMIREGACTION Action);
1221 */
1222
1223 BOOLEAN
1224 IoIsTotalDeviceFailure (
1225         NTSTATUS        Status
1226         );
1227
1228
1229 #endif /* ndef _INCLUDE_DDK_IOFUNCS_H */