xref: /reactos/drivers/filesystems/udfs/env_spec.h (revision c334c17d)
1 ////////////////////////////////////////////////////////////////////
2 // Copyright (C) Alexander Telyatnikov, Ivan Keliukh, Yegor Anchishkin, SKIF Software, 1999-2013. Kiev, Ukraine
3 // All rights reserved
4 // This file was released under the GPLv2 on June 2015.
5 ////////////////////////////////////////////////////////////////////
6 /*************************************************************************
7 *
8 * File: sys_spec.h
9 *
10 * Module: UDF File System Driver (Kernel mode execution only)
11 *
12 * Description:
13 *   The main include file for the UDF file system driver.
14 *
15 * Author: Alter
16 *
17 *************************************************************************/
18 
19 #ifndef _UDF_ENV_SPEC_H_
20 #define _UDF_ENV_SPEC_H_
21 
22 extern NTSTATUS NTAPI UDFPhReadSynchronous(
23                    PDEVICE_OBJECT      DeviceObject,
24                    PVOID           Buffer,
25                    SIZE_T          Length,
26                    LONGLONG        Offset,
27                    PSIZE_T         ReadBytes,
28                    ULONG           Flags);
29 
30 extern NTSTATUS NTAPI UDFPhWriteSynchronous(
31                    PDEVICE_OBJECT  DeviceObject,   // the physical device object
32                    PVOID           Buffer,
33                    SIZE_T          Length,
34                    LONGLONG        Offset,
35                    PSIZE_T         WrittenBytes,
36                    ULONG           Flags);
37 /*
38 extern NTSTATUS UDFPhWriteVerifySynchronous(
39                    PDEVICE_OBJECT  DeviceObject,   // the physical device object
40                    PVOID           Buffer,
41                    SIZE_T          Length,
42                    LONGLONG        Offset,
43                    PSIZE_T         WrittenBytes,
44                    ULONG           Flags);
45 */
46 #define UDFPhWriteVerifySynchronous UDFPhWriteSynchronous
47 
48 extern NTSTATUS NTAPI
49 UDFTSendIOCTL(
50     IN ULONG IoControlCode,
51     IN PVCB Vcb,
52     IN PVOID InputBuffer ,
53     IN ULONG InputBufferLength,
54     OUT PVOID OutputBuffer ,
55     IN ULONG OutputBufferLength,
56     IN BOOLEAN OverrideVerify,
57     OUT PIO_STATUS_BLOCK Iosb OPTIONAL
58     );
59 
60 extern NTSTATUS NTAPI UDFPhSendIOCTL(
61     IN ULONG IoControlCode,
62     IN PDEVICE_OBJECT DeviceObject,
63     IN PVOID InputBuffer ,
64     IN ULONG InputBufferLength,
65     OUT PVOID OutputBuffer ,
66     IN ULONG OutputBufferLength,
67     IN BOOLEAN OverrideVerify,
68     OUT PIO_STATUS_BLOCK Iosb OPTIONAL);
69 /*
70 // This routine performs low-level write (asynchronously if possible)
71 extern NTSTATUS UDFTWriteAsync(
72     IN PVOID _Vcb,
73     IN PVOID Buffer,     // Target buffer
74     IN ULONG Length,
75     IN ULONG LBA,
76     OUT PULONG WrittenBytes,
77     IN BOOLEAN FreeBuffer);
78 
79 extern VOID UDFBGWrite(
80     IN PVOID Context);
81 */
82 
83 /*#define UDFNotifyFullReportChange(V,FI,E,A)  \
84     FsRtlNotifyFullReportChange( (V)->NotifyIRPMutex, &((V)->NextNotifyIRP),        \
85                                  ((FI)->ParentFile) ? (PSTRING)&((FI)->Fcb->FCBName->ObjectName) : (PSTRING)&(UDFGlobalData.UnicodeStrRoot),  \
86                                  ((FI)->ParentFile) ? ((FI)->ParentFile->Fcb->FCBName->ObjectName.Length + sizeof(WCHAR)) : 0,  \
87                                  NULL,NULL,                                         \
88                                  E, A,                                              \
89                                  NULL);*/
90 
91 #ifdef UDF_DBG
92 VOID UDFNotifyFullReportChange(PVCB V,
93                                PUDF_FILE_INFO FI,
94                                ULONG E,
95                                ULONG A);
96 VOID UDFNotifyVolumeEvent(IN PFILE_OBJECT FileObject,
97                           IN ULONG EventCode);
98 #else // UDF_DBG
UDFNotifyFullReportChange(PVCB V,PUDF_FILE_INFO FI,ULONG E,ULONG A)99 __inline VOID UDFNotifyFullReportChange(
100     PVCB V,
101     PUDF_FILE_INFO FI,
102     ULONG E,
103     ULONG A
104     )
105 {
106     FsRtlNotifyFullReportChange( (V)->NotifyIRPMutex, &((V)->NextNotifyIRP),
107                                  (PSTRING)&((FI)->Fcb->FCBName->ObjectName),
108                                  ((FI)->ParentFile) ? ((FI)->ParentFile->Fcb->FCBName->ObjectName.Length + sizeof(WCHAR)) : 0,
109                                  NULL,NULL,
110                                  E, A,
111                                  NULL);
112 }
113 
114 #define UDFNotifyVolumeEvent(FileObject, EventCode) \
115     {/*if(FsRtlNotifyVolumeEvent) FsRtlNotifyVolumeEvent(FileObject, EventCode)*/;}
116 
117 #endif // UDF_DBG
118 
119 
120 #define CollectStatistics(VCB, Field) {                                      \
121     ((VCB)->Statistics[KeGetCurrentProcessorNumber()].Common.##Field) ++;    \
122 }
123 
124 #define CollectStatisticsEx(VCB, Field, a) {                                 \
125     ((VCB)->Statistics[KeGetCurrentProcessorNumber()].Common.##Field) += (ULONG)a;  \
126 }
127 
128 #define CollectStatistics2(VCB, Field) {                                     \
129     ((VCB)->Statistics[KeGetCurrentProcessorNumber()].Fat.##Field) ++;       \
130 }
131 
132 #define CollectStatistics2Ex(VCB, Field, a) {                                \
133     ((VCB)->Statistics[KeGetCurrentProcessorNumber()].Fat.##Field) += a;     \
134 }
135 
136 NTSTATUS NTAPI UDFAsyncCompletionRoutine(IN PDEVICE_OBJECT DeviceObject,
137                                          IN PIRP Irp,
138                                          IN PVOID Contxt);
139 
140 NTSTATUS NTAPI UDFSyncCompletionRoutine(IN PDEVICE_OBJECT DeviceObject,
141                                         IN PIRP Irp,
142                                         IN PVOID Contxt);
143 
144 NTSTATUS NTAPI UDFSyncCompletionRoutine2(IN PDEVICE_OBJECT DeviceObject,
145                                          IN PIRP Irp,
146                                          IN PVOID Contxt);
147 
148 #define UDFGetDevType(DevObj)    (DevObj->DeviceType)
149 
150 #define OSGetCurrentThread()     PsGetCurrentThread()
151 
152 #define GetCurrentPID()   HandleToUlong(PsGetCurrentProcessId())
153 
154 
155 #endif  // _UDF_ENV_SPEC_H_
156