xref: /reactos/drivers/filesystems/cdfs/cddata.h (revision 4561998a)
1 /*++
2 
3 Copyright (c) 1989-2000 Microsoft Corporation
4 
5 Module Name:
6 
7     CdData.c
8 
9 Abstract:
10 
11     This module declares the global data used by the Cdfs file system.
12 
13 
14 --*/
15 
16 #ifndef _CDDATA_
17 #define _CDDATA_
18 
19 //
20 //  Global data structures
21 //
22 
23 extern CD_DATA CdData;
24 extern FAST_IO_DISPATCH CdFastIoDispatch;
25 
26 //
27 //  Global constants
28 //
29 
30 //
31 //  This is the number of times a mounted Vcb will be referenced on behalf
32 //  of the system.  The counts include the following references.
33 //
34 //      1 reference - shows the volume is mounted
35 //      1 reference - 1 for VolumeDasdFcb.
36 //      2 references - 1 for RootIndexFcb, 1 for internal stream.
37 //      2 references - 1 for PathTableFcb, 1 for internal stream.
38 //
39 //  For user references we add one for the reference in each of the internal
40 //  Fcb's.
41 //
42 
43 #define CDFS_RESIDUAL_REFERENCE                     (6)
44 #define CDFS_RESIDUAL_USER_REFERENCE                (3)
45 
46 //
47 //  Reserved directory strings
48 //
49 
50 extern WCHAR CdUnicodeSelfArray[];
51 extern WCHAR CdUnicodeParentArray[];
52 
53 extern UNICODE_STRING CdUnicodeDirectoryNames[];
54 
55 //
56 //  Volume descriptor identifier strings.
57 //
58 
59 extern CHAR CdHsgId[];
60 extern CHAR CdIsoId[];
61 extern CHAR CdXaId[];
62 
63 //
64 //  Volume label for audio disks.
65 //
66 
67 extern WCHAR CdAudioLabel[];
68 extern USHORT CdAudioLabelLength;
69 
70 //
71 //  Pseudo file names for audio disks.
72 //
73 
74 extern CHAR CdAudioFileName[];
75 extern UCHAR CdAudioFileNameLength;
76 extern ULONG CdAudioDirentSize;
77 extern ULONG CdAudioDirentsPerSector;
78 extern ULONG CdAudioSystemUseOffset;
79 
80 #define AUDIO_NAME_ONES_OFFSET              (6)
81 #define AUDIO_NAME_TENS_OFFSET              (5)
82 
83 //
84 //  Escape sequences for mounting Unicode volumes.
85 //
86 
87 extern PCHAR CdJolietEscape[];
88 
89 //
90 //  Hardcoded header for RIFF files.
91 //
92 
93 extern LONG CdXAFileHeader[];
94 extern LONG CdAudioPlayHeader[];
95 extern LONG CdXAAudioPhileHeader[];
96 
97 #ifdef CDFS_TELEMETRY_DATA
98 
99 //
100 //  Globals for Telemetry data.
101 //
102 
103 extern CDFS_TELEMETRY_DATA_CONTEXT CdTelemetryData;
104 
105 #endif // CDFS_TELEMETRY_DATA
106 
107 //
108 //  The following assertion macros ensure that the indicated structure
109 //  is valid
110 //
111 //      ASSERT_STRUCT( _In_ PVOID Struct, _In_ CSHORT NodeType );
112 //      ASSERT_OPTIONAL_STRUCT( _In_opt_ PVOID Struct, _In_ CSHORT NodeType );
113 //
114 //      ASSERT_VCB( _In_ PVCB Vcb );
115 //      ASSERT_OPTIONAL_VCB( _In_opt_ PVCB Vcb );
116 //
117 //      ASSERT_FCB( _In_ PFCB Fcb );
118 //      ASSERT_OPTIONAL_FCB( _In_opt_ PFCB Fcb );
119 //
120 //      ASSERT_FCB_NONPAGED( _In_ PFCB_NONPAGED FcbNonpaged );
121 //      ASSERT_OPTIONAL_FCB( _In_opt_ PFCB_NONPAGED FcbNonpaged );
122 //
123 //      ASSERT_CCB( _In_ PSCB Ccb );
124 //      ASSERT_OPTIONAL_CCB( _In_opt_ PSCB Ccb );
125 //
126 //      ASSERT_IRP_CONTEXT( _In_ PIRP_CONTEXT IrpContext );
127 //      ASSERT_OPTIONAL_IRP_CONTEXT( _In_opt_ PIRP_CONTEXT IrpContext );
128 //
129 //      ASSERT_IRP( _In_ PIRP Irp );
130 //      ASSERT_OPTIONAL_IRP( _In_opt_ PIRP Irp );
131 //
132 //      ASSERT_FILE_OBJECT( _In_ PFILE_OBJECT FileObject );
133 //      ASSERT_OPTIONAL_FILE_OBJECT( _In_opt_ PFILE_OBJECT FileObject );
134 //
135 //  The following macros are used to check the current thread owns
136 //  the indicated resource
137 //
138 //      ASSERT_EXCLUSIVE_RESOURCE( _In_ PERESOURCE Resource );
139 //
140 //      ASSERT_SHARED_RESOURCE( _In_ PERESOURCE Resource );
141 //
142 //      ASSERT_RESOURCE_NOT_MINE( _In_ PERESOURCE Resource );
143 //
144 //  The following macros are used to check whether the current thread
145 //  owns the resoures in the given structures.
146 //
147 //      ASSERT_EXCLUSIVE_CDDATA
148 //
149 //      ASSERT_EXCLUSIVE_VCB( _In_ PVCB Vcb );
150 //
151 //      ASSERT_SHARED_VCB( _In_ PVCB Vcb );
152 //
153 //      ASSERT_EXCLUSIVE_FCB( _In_ PFCB Fcb );
154 //
155 //      ASSERT_SHARED_FCB( _In_ PFCB Fcb );
156 //
157 //      ASSERT_EXCLUSIVE_FILE( _In_ PFCB Fcb );
158 //
159 //      ASSERT_SHARED_FILE( _In_ PFCB Fcb );
160 //
161 //      ASSERT_LOCKED_VCB( _In_ PVCB Vcb );
162 //
163 //      ASSERT_NOT_LOCKED_VCB( _In_ PVCB Vcb );
164 //
165 //      ASSERT_LOCKED_FCB( _In_ PFCB Fcb );
166 //
167 //      ASSERT_NOT_LOCKED_FCB( _In_ PFCB Fcb );
168 //
169 
170 //
171 //  Turn on the sanity checks if this is DBG or CD_FREE_ASSERTS
172 //
173 
174 #if DBG
175 #undef CD_SANITY
176 #define CD_SANITY
177 #endif
178 
179 #ifdef CD_SANITY
180 
181 #define ASSERT_STRUCT(S,T)                  NT_ASSERT( SafeNodeType( S ) == (T) )
182 #define ASSERT_OPTIONAL_STRUCT(S,T)         NT_ASSERT( ((S) == NULL) ||  (SafeNodeType( S ) == (T)) )
183 
184 #define ASSERT_VCB(V)                       ASSERT_STRUCT( (V), CDFS_NTC_VCB )
185 #define ASSERT_OPTIONAL_VCB(V)              ASSERT_OPTIONAL_STRUCT( (V), CDFS_NTC_VCB )
186 
187 #define ASSERT_FCB(F)                                           \
188     NT_ASSERT( (SafeNodeType( F ) == CDFS_NTC_FCB_DATA ) ||        \
189             (SafeNodeType( F ) == CDFS_NTC_FCB_INDEX ) ||       \
190             (SafeNodeType( F ) == CDFS_NTC_FCB_PATH_TABLE ) )
191 
192 #define ASSERT_OPTIONAL_FCB(F)                                  \
193     NT_ASSERT( ((F) == NULL) ||                                    \
194             (SafeNodeType( F ) == CDFS_NTC_FCB_DATA ) ||        \
195             (SafeNodeType( F ) == CDFS_NTC_FCB_INDEX ) ||       \
196             (SafeNodeType( F ) == CDFS_NTC_FCB_PATH_TABLE ) )
197 
198 #define ASSERT_FCB_NONPAGED(FN)             ASSERT_STRUCT( (FN), CDFS_NTC_FCB_NONPAGED )
199 #define ASSERT_OPTIONAL_FCB_NONPAGED(FN)    ASSERT_OPTIONAL_STRUCT( (FN), CDFS_NTC_FCB_NONPAGED )
200 
201 #define ASSERT_CCB(C)                       ASSERT_STRUCT( (C), CDFS_NTC_CCB )
202 #define ASSERT_OPTIONAL_CCB(C)              ASSERT_OPTIONAL_STRUCT( (C), CDFS_NTC_CCB )
203 
204 #define ASSERT_IRP_CONTEXT(IC)              ASSERT_STRUCT( (IC), CDFS_NTC_IRP_CONTEXT )
205 #define ASSERT_OPTIONAL_IRP_CONTEXT(IC)     ASSERT_OPTIONAL_STRUCT( (IC), CDFS_NTC_IRP_CONTEXT )
206 
207 #define ASSERT_IRP(I)                       ASSERT_STRUCT( (I), IO_TYPE_IRP )
208 #define ASSERT_OPTIONAL_IRP(I)              ASSERT_OPTIONAL_STRUCT( (I), IO_TYPE_IRP )
209 
210 #define ASSERT_FILE_OBJECT(FO)              ASSERT_STRUCT( (FO), IO_TYPE_FILE )
211 #define ASSERT_OPTIONAL_FILE_OBJECT(FO)     ASSERT_OPTIONAL_STRUCT( (FO), IO_TYPE_FILE )
212 
213 #define ASSERT_EXCLUSIVE_RESOURCE(R)        NT_ASSERT( ExIsResourceAcquiredExclusiveLite( R ))
214 
215 #define ASSERT_SHARED_RESOURCE(R)           NT_ASSERT( ExIsResourceAcquiredSharedLite( R ))
216 
217 #define ASSERT_RESOURCE_NOT_MINE(R)         NT_ASSERT( !ExIsResourceAcquiredSharedLite( R ))
218 
219 #define ASSERT_EXCLUSIVE_CDDATA             NT_ASSERT( ExIsResourceAcquiredExclusiveLite( &CdData.DataResource ))
220 #define ASSERT_EXCLUSIVE_VCB(V)             NT_ASSERT( ExIsResourceAcquiredExclusiveLite( &(V)->VcbResource ))
221 #define ASSERT_SHARED_VCB(V)                NT_ASSERT( ExIsResourceAcquiredSharedLite( &(V)->VcbResource ))
222 
223 #define ASSERT_EXCLUSIVE_FCB(F)             NT_ASSERT( ExIsResourceAcquiredExclusiveLite( &(F)->FcbNonpaged->FcbResource ))
224 #define ASSERT_SHARED_FCB(F)                NT_ASSERT( ExIsResourceAcquiredSharedLite( &(F)->FcbNonpaged->FcbResource ))
225 
226 #define ASSERT_EXCLUSIVE_FILE(F)            NT_ASSERT( ExIsResourceAcquiredExclusiveLite( (F)->Resource ))
227 #define ASSERT_SHARED_FILE(F)               NT_ASSERT( ExIsResourceAcquiredSharedLite( (F)->Resource ))
228 
229 #define ASSERT_LOCKED_VCB(V)                NT_ASSERT( (V)->VcbLockThread == PsGetCurrentThread() )
230 #define ASSERT_NOT_LOCKED_VCB(V)            NT_ASSERT( (V)->VcbLockThread != PsGetCurrentThread() )
231 
232 #define ASSERT_LOCKED_FCB(F)                NT_ASSERT( !FlagOn( (F)->FcbState, FCB_STATE_IN_FCB_TABLE) || ((F)->FcbLockThread == PsGetCurrentThread()))
233 #define ASSERT_NOT_LOCKED_FCB(F)            NT_ASSERT( (F)->FcbLockThread != PsGetCurrentThread() )
234 
235 #else
236 
237 #define DebugBreakOnStatus(S)           { NOTHING; }
238 
239 #define ASSERT_STRUCT(S,T)              { NOTHING; }
240 #define ASSERT_OPTIONAL_STRUCT(S,T)     { NOTHING; }
241 #define ASSERT_VCB(V)                   { NOTHING; }
242 #define ASSERT_OPTIONAL_VCB(V)          { NOTHING; }
243 #define ASSERT_FCB(F)                   { NOTHING; }
244 #define ASSERT_OPTIONAL_FCB(F)          { NOTHING; }
245 #define ASSERT_FCB_NONPAGED(FN)         { NOTHING; }
246 #define ASSERT_OPTIONAL_FCB(FN)         { NOTHING; }
247 #define ASSERT_CCB(C)                   { NOTHING; }
248 #define ASSERT_OPTIONAL_CCB(C)          { NOTHING; }
249 #define ASSERT_IRP_CONTEXT(IC)          { NOTHING; }
250 #define ASSERT_OPTIONAL_IRP_CONTEXT(IC) { NOTHING; }
251 #define ASSERT_IRP(I)                   { NOTHING; }
252 #define ASSERT_OPTIONAL_IRP(I)          { NOTHING; }
253 #define ASSERT_FILE_OBJECT(FO)          { NOTHING; }
254 #define ASSERT_OPTIONAL_FILE_OBJECT(FO) { NOTHING; }
255 #define ASSERT_EXCLUSIVE_RESOURCE(R)    { NOTHING; }
256 #define ASSERT_SHARED_RESOURCE(R)       { NOTHING; }
257 #define ASSERT_RESOURCE_NOT_MINE(R)     { NOTHING; }
258 #define ASSERT_EXCLUSIVE_CDDATA         { NOTHING; }
259 #define ASSERT_EXCLUSIVE_VCB(V)         { NOTHING; }
260 #define ASSERT_SHARED_VCB(V)            { NOTHING; }
261 #define ASSERT_EXCLUSIVE_FCB(F)         { NOTHING; }
262 #define ASSERT_SHARED_FCB(F)            { NOTHING; }
263 #define ASSERT_EXCLUSIVE_FILE(F)        { NOTHING; }
264 #define ASSERT_SHARED_FILE(F)           { NOTHING; }
265 #define ASSERT_LOCKED_VCB(V)            { NOTHING; }
266 #define ASSERT_NOT_LOCKED_VCB(V)        { NOTHING; }
267 #define ASSERT_LOCKED_FCB(F)            { NOTHING; }
268 #define ASSERT_NOT_LOCKED_FCB(F)        { NOTHING; }
269 
270 #endif
271 
272 #endif // _CDDATA_
273 
274