test: fsrtlp.h Source File

Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

# fsrtlp.h

Go to the documentation of this file.

    00001 /*++
    00002
    00003 Copyright (c) 1989  Microsoft Corporation
    00004
    00005 Module Name:
    00006
    00007     FsRtlP.h
    00008
    00009 Abstract:
    00010
    00011     This module defines private part of the File System Rtl component
    00012
    00013 Author:
    00014
    00015     Gary Kimura     [GaryKi]    30-Jul-1990
    00016
    00017 Revision History:
    00018
    00019 --*/
    00020
    00021 #ifndef _FSRTLP_
    00022 #define _FSRTLP_
    00023
    00024 #include <ntos.h>
    00025 #include <FsRtl.h>
    00026 #include <NtDdFt.h>
    00027 #include <zwapi.h>
    00028
    00029 #define FsRtlAllocatePool(PoolType, NumberOfBytes )                \
    00030     ExAllocatePoolWithTag((POOL_TYPE)((PoolType) | POOL_RAISE_IF_ALLOCATION_FAILURE), \
    00031                           NumberOfBytes,                                      \
    00032                           'trSF')
    00033
    00034
    00035 #define FsRtlAllocatePoolWithQuota(PoolType, NumberOfBytes )           \
    00036     ExAllocatePoolWithQuotaTag((POOL_TYPE)((PoolType) | POOL_RAISE_IF_ALLOCATION_FAILURE), \
    00037                                NumberOfBytes,                                 \
    00038                                'trSF')
    00039
    00040 #define FsRtlpAllocatePool(a,b)  FsRtlAllocatePoolWithTag((a),(b),MODULE_POOL_TAG)
    00041
    00042 //
    00043 //  The global FsRtl debug level variable, its values are:
    00044 //
    00045 //      0x00000000      Always gets printed (used when about to bug check)
    00046 //
    00047 //      0x00000001      Error conditions
    00048 //      0x00000002      Debug hooks
    00049 //      0x00000004
    00050 //      0x00000008
    00051 //
    00052 //      0x00000010
    00053 //      0x00000020
    00054 //      0x00000040
    00055 //      0x00000080
    00056 //
    00057 //      0x00000100
    00058 //      0x00000200
    00059 //      0x00000400
    00060 //      0x00000800
    00061 //
    00062 //      0x00001000
    00063 //      0x00002000
    00064 //      0x00004000
    00065 //      0x00008000
    00066 //
    00067 //      0x00010000
    00068 //      0x00020000
    00069 //      0x00040000
    00070 //      0x00080000
    00071 //
    00072 //      0x00100000
    00073 //      0x00200000
    00074 //      0x00400000
    00075 //      0x00800000
    00076 //
    00077 //      0x01000000
    00078 //      0x02000000
    00079 //      0x04000000      NotifyChange routines
    00080 //      0x08000000      Oplock routines
    00081 //
    00082 //      0x10000000      Name routines
    00083 //      0x20000000      FileLock routines
    00084 //      0x40000000      Vmcb routines
    00085 //      0x80000000      Mcb routines
    00086 //
    00087
    00088 //
    00089 //  Debug trace support
    00090 //
    00091
    00092 #ifdef FSRTLDBG
    00093
    00094 extern LONG FsRtlDebugTraceLevel;
    00095 extern LONG FsRtlDebugTraceIndent;
    00096
    00097 #define DebugTrace(INDENT,LEVEL,X,Y) {                        \
    00098     LONG _i;                                                  \
    00099     if (((LEVEL) == 0) || (FsRtlDebugTraceLevel & (LEVEL))) { \
    00100         _i = (ULONG)PsGetCurrentThread();                     \
    00101         DbgPrint("%08lx:",_i);                                 \
    00102         if ((INDENT) < 0) {                                   \
    00103             FsRtlDebugTraceIndent += (INDENT);                \
    00104         }                                                     \
    00105         if (FsRtlDebugTraceIndent < 0) {                      \
    00106             FsRtlDebugTraceIndent = 0;                        \
    00107         }                                                     \
    00108         for (_i=0; _i<FsRtlDebugTraceIndent; _i+=1) {         \
    00109             DbgPrint(" ");                                     \
    00110         }                                                     \
    00111         DbgPrint(X,Y);                                         \
    00112         if ((INDENT) > 0) {                                   \
    00113             FsRtlDebugTraceIndent += (INDENT);                \
    00114         }                                                     \
    00115     }                                                         \
    00116 }
    00117
    00118 #define DebugDump(STR,LEVEL,PTR) {                            \
    00119     ULONG _i;                                                 \
    00120     VOID FsRtlDump();                                         \
    00121     if (((LEVEL) == 0) || (FsRtlDebugTraceLevel & (LEVEL))) { \
    00122         _i = (ULONG)PsGetCurrentThread();                     \
    00123         DbgPrint("%08lx:",_i);                                 \
    00124         DbgPrint(STR);                                         \
    00125         if (PTR != NULL) {FsRtlDump(PTR);}                    \
    00126         DbgBreakPoint();                                      \
    00127     }                                                         \
    00128 }
    00129
    00130 #else
    00131
    00132 #define DebugTrace(INDENT,LEVEL,X,Y)     {NOTHING;}
    00133
    00134 #define DebugDump(STR,LEVEL,PTR)         {NOTHING;}
    00135
    00136 #endif // FSRTLDBG
    00137
    00138
    00139 //
    00140 //  Miscellaneous support routines
    00141 //
    00142
    00143 VOID
    00144 FsRtlInitializeFileLocks (
    00145     VOID
    00146     );
    00147
    00148 VOID
    00149 FsRtlInitializeLargeMcbs (
    00150     VOID
    00151     );
    00152
    00153 VOID
    00154 FsRtlInitializeTunnels(
    00155     VOID
    00156     );
    00157
    00158 NTSTATUS
    00159 FsRtlInitializeWorkerThread (
    00160     VOID
    00161     );
    00162
    00163 //
    00164 //  This macro returns TRUE if a flag in a set of flags is on and FALSE
    00165 //  otherwise
    00166 //
    00167
    00168 #define FlagOn(Flags,SingleFlag)        ((Flags) & (SingleFlag))
    00169
    00170 #define BooleanFlagOn(Flags,SingleFlag) ((BOOLEAN)(((Flags) & (SingleFlag)) != 0))
    00171
    00172 #define SetFlag(F,SF) { \
    00173     (F) |= (SF);        \
    00174 }
    00175
    00176 #define ClearFlag(F,SF) { \
    00177     (F) &= ~(SF);         \
    00178 }
    00179
    00180 //
    00181 //  This macro takes a pointer (or ulong) and returns its rounded up word
    00182 //  value
    00183 //
    00184
    00185 #define WordAlign(Ptr) (                \
    00186     ((((ULONG_PTR)(Ptr)) + 1) & -2) \
    00187     )
    00188
    00189 //
    00190 //  This macro takes a pointer (or ulong) and returns its rounded up longword
    00191 //  value
    00192 //
    00193
    00194 #define LongAlign(Ptr) (                \
    00195     ((((ULONG_PTR)(Ptr)) + 3) & -4) \
    00196     )
    00197
    00198 //
    00199 //  This macro takes a pointer (or ulong) and returns its rounded up quadword
    00200 //  value
    00201 //
    00202
    00203 #define QuadAlign(Ptr) (                \
    00204     ((((ULONG_PTR)(Ptr)) + 7) & -8) \
    00205     )
    00206
    00207 //
    00208 //  This macro takes a ulong and returns its value rounded up to a sector
    00209 //  boundary
    00210 //
    00211
    00212 #define SectorAlign(Ptr) (                \
    00213     ((((ULONG_PTR)(Ptr)) + 511) & -512) \
    00214     )
    00215
    00216 //
    00217 //  This macro takes a number of bytes and returns the number of sectors
    00218 //  required to contain that many bytes, i.e., it sector aligns and divides
    00219 //  by the size of a sector.
    00220 //
    00221
    00222 #define SectorsFromBytes(bytes) ( \
    00223     ((bytes) + 511) / 512         \
    00224     )
    00225
    00226 //
    00227 //  This macro takes a number of sectors and returns the number of bytes
    00228 //  contained in that many sectors.
    00229 //
    00230
    00231 #define BytesFromSectors(sectors) ( \
    00232     (sectors) * 512                 \
    00233     )
    00234
    00235 //
    00236 //  The following types and macros are used to help unpack the packed and
    00237 //  misaligned fields found in the Bios parameter block
    00238 //
    00239
    00240 typedef union _UCHAR1 {
    00241     UCHAR  Uchar[1];
    00242     UCHAR  ForceAlignment;
    00243 } UCHAR1, *PUCHAR1;
    00244
    00245 typedef union _UCHAR2 {
    00246     UCHAR  Uchar[2];
    00247     USHORT ForceAlignment;
    00248 } UCHAR2, *PUCHAR2;
    00249
    00250 typedef union _UCHAR4 {
    00251     UCHAR  Uchar[4];
    00252     ULONG  ForceAlignment;
    00253 } UCHAR4, *PUCHAR4;
    00254
    00255 //
    00256 //  This macro copies an unaligned src byte to an aligned dst byte
    00257 //
    00258
    00259 #define CopyUchar1(Dst,Src) {                                \
    00260     *((UCHAR1 *)(Dst)) = *((UNALIGNED UCHAR1 *)(Src)); \
    00261     }
    00262
    00263 //
    00264 //  This macro copies an unaligned src word to an aligned dst word
    00265 //
    00266
    00267 #define CopyUchar2(Dst,Src) {                                \
    00268     *((UCHAR2 *)(Dst)) = *((UNALIGNED UCHAR2 *)(Src)); \
    00269     }
    00270
    00271 //
    00272 //  This macro copies an unaligned src longword to an aligned dsr longword
    00273 //
    00274
    00275 #define CopyUchar4(Dst,Src) {                                \
    00276     *((UCHAR4 *)(Dst)) = *((UNALIGNED UCHAR4 *)(Src)); \
    00277     }
    00278
    00279
    00280 //
    00281 //  The following macros are used to establish the semantics needed
    00282 //  to do a return from within a try-finally clause.  As a rule every
    00283 //  try clause must end with a label call try_exit.  For example,
    00284 //
    00285 //      try {
    00286 //              :
    00287 //              :
    00288 //
    00289 //      try_exit: NOTHING;
    00290 //      } finally {
    00291 //
    00292 //              :
    00293 //              :
    00294 //      }
    00295 //
    00296 //  Every return statement executed inside of a try clause should use the
    00297 //  try_return macro.  If the compiler fully supports the try-finally construct
    00298 //  then the macro should be
    00299 //
    00300 //      #define try_return(S)  { return(S); }
    00301 //
    00302 //  If the compiler does not support the try-finally construct then the macro
    00303 //  should be
    00304 //
    00305 //      #define try_return(S)  { S; goto try_exit; }
    00306 //
    00307
    00308 #define try_return(S) { S; goto try_exit; }
    00309
    00310 #endif // _FSRTLP_