userlibandfileserver/fileserver/sfat/common_constants.h
changeset 0 a41df078684a
child 15 4122176ea935
equal deleted inserted replaced
-1:000000000000 0:a41df078684a
       
     1 // Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of the License "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // f32\sfat\common_constants.h
       
    15 // Declarations of the constants etc. commom for FAT16/32 Fsy.
       
    16 // 
       
    17 //
       
    18 
       
    19 /**
       
    20  @file
       
    21  @internalTechnology
       
    22 */
       
    23 
       
    24 #ifndef COMMON_CONSTANTS_H
       
    25 #define COMMON_CONSTANTS_H
       
    26 
       
    27 
       
    28 
       
    29 #include <f32fsys.h>
       
    30 #include <f32dbg.h>
       
    31 
       
    32 
       
    33 IMPORT_C TUint32 DebugRegister();
       
    34 
       
    35 
       
    36 //-- define this for having logs disregarding DebugRegister() settings
       
    37 //#define FORCE_LOGS
       
    38 
       
    39 
       
    40 #if defined(_DEBUG) || defined(_DEBUG_RELEASE)
       
    41 
       
    42 #ifndef FORCE_LOGS
       
    43     #define __PRINT(t)          		{if (DebugRegister()&KFSYS) RDebug::Print(t);}
       
    44     #define __PRINT1(t,a)       		{if (DebugRegister()&KFSYS) RDebug::Print(t,a);}
       
    45     #define __PRINT2(t,a,b)     		{if (DebugRegister()&KFSYS) RDebug::Print(t,a,b);}
       
    46     #define __PRINT3(t,a,b,c)   		{if (DebugRegister()&KFSYS) RDebug::Print(t,a,b,c);}
       
    47     #define __PRINT4(t,a,b,c,d) 		{if (DebugRegister()&KFSYS) RDebug::Print(t,a,b,c,d);}
       
    48     #define __PRINT5(t,a,b,c,d,e) 		{if (DebugRegister()&KFSYS) RDebug::Print(t,a,b,c,d,e);}
       
    49     #define __PRINT6(t,a,b,c,d,e,f) 	{if (DebugRegister()&KFSYS) RDebug::Print(t,a,b,c,d,e,f);}
       
    50     #define __PRINT7(t,a,b,c,d,e,f,g)	{if (DebugRegister()&KFSYS) RDebug::Print(t,a,b,c,d,e,f,g);}
       
    51     #define __PRINT8BIT1(t,a)           {if (DebugRegister()&KFSYS){TFileName temp;temp.Copy(a);RDebug::Print(t,&temp);}}
       
    52     #define __PRINT1TEMP(t,a)           {if (DebugRegister()&KFSERV) {TBuf<KMaxFileName>temp(a);RDebug::Print(t,&temp);}}
       
    53 #else //FORCE_LOGS
       
    54     #define __PRINT(t)          		{RDebug::Print(t);}
       
    55     #define __PRINT1(t,a)       		{RDebug::Print(t,a);}
       
    56     #define __PRINT2(t,a,b)     		{RDebug::Print(t,a,b);}
       
    57     #define __PRINT3(t,a,b,c)   		{RDebug::Print(t,a,b,c);}
       
    58     #define __PRINT4(t,a,b,c,d) 		{RDebug::Print(t,a,b,c,d);}
       
    59     #define __PRINT5(t,a,b,c,d,e) 		{RDebug::Print(t,a,b,c,d,e);}
       
    60     #define __PRINT6(t,a,b,c,d,e,f) 	{RDebug::Print(t,a,b,c,d,e,f);}
       
    61     #define __PRINT7(t,a,b,c,d,e,f,g)	{RDebug::Print(t,a,b,c,d,e,f,g);}
       
    62     #define __PRINT8BIT1(t,a)           {{TFileName temp;temp.Copy(a);RDebug::Print(t,&temp);}}
       
    63     #define __PRINT1TEMP(t,a)           {{TBuf<KMaxFileName>temp(a);RDebug::Print(t,&temp);}}
       
    64 #endif//FORCE_LOGS
       
    65 
       
    66 #define DBG_STATEMENT(text) text
       
    67 
       
    68 #else
       
    69 
       
    70 #define __PRINT(t)
       
    71 #define __PRINT1(t,a)
       
    72 #define __PRINT2(t,a,b)
       
    73 #define __PRINT3(t,a,b,c)
       
    74 #define __PRINT4(t,a,b,c,d)
       
    75 #define __PRINT5(t,a,b,c,d,e)
       
    76 #define __PRINT6(t,a,b,c,d,e,f)
       
    77 #define __PRINT7(t,a,b,c,d,e,f,g)
       
    78 #define __PRINT8BIT1(t,a)
       
    79 #define __PRINT1TEMP(t,a)
       
    80 
       
    81 #define DBG_STATEMENT(text)
       
    82 
       
    83 #endif
       
    84 
       
    85 //-----------------------------------------------------------------------------
       
    86 
       
    87 //-- define this macro in order to enable the DEMAND PAGING DIRECTORY CACHE.
       
    88 #define USE_DP_DIR_CACHE
       
    89 
       
    90 //-----------------------------------------------------------------------------
       
    91 
       
    92 typedef TUint32 TLinAddr;
       
    93 typedef TUint32 TFat32Entry;
       
    94 typedef TUint16 TFat16Entry;
       
    95 
       
    96 const TUint16 K1KiloByteLog2 = 10;
       
    97 const TUint32 K1KiloByte = 1<<10; 
       
    98 const TUint32 K1MegaByte = 1<<20; 
       
    99 
       
   100 const TUint32 K1uSec = 1;               ///< 1 misrosecond in TTimeIntervalMicroSeconds32
       
   101 const TUint32 K1mSec = 1000;            ///< 1 millisecond in TTimeIntervalMicroSeconds32
       
   102 const TUint32 K1Sec  = 1000*K1mSec;     ///< 1 second in TTimeIntervalMicroSeconds32
       
   103 
       
   104 _LIT8(KLit8ReplacementForUnconvertibleUnicodeCharacters, "_");
       
   105 _LIT8(KFileSystemName12,"FAT12   ");    ///< Name in BPB given to a Fat12 volume
       
   106 _LIT8(KFileSystemName16,"FAT16   ");    ///< Name in BPB given to a Fat16 volume
       
   107 _LIT8(KFileSystemName32,"FAT32   ");    ///< Name in BPB given to a Fat32 volume
       
   108 _LIT8(KDefaultVendorID, "EPOC");        ///< Vendor Name for BPB for any volume formated using a Symbian OS device
       
   109 
       
   110 const TInt KMaxFatFileNameExt=3;		///< Maximum Fat file system file/directory name extension length
       
   111 const TInt KNumberOfFatsInternal=1;     ///< Number of FATs for an internal drive
       
   112 const TInt KNumberOfFatsExternal=2;     ///< Number of FATs for an internal drive
       
   113 const TInt KMaxFatFileName=12;          ///< Maximum Fat file system file/directory name length
       
   114 const TInt KMaxFatFileNameWithoutExt=8; ///< Maximum Fat file system file/directory name length without extension
       
   115 const TInt KMaxDuplicateShortName=0xFFFF;
       
   116 const TInt KMaxVFatEntryName=13;        ///< Maximum entries in a VFat name
       
   117 const TInt KMaxFAT16Entries=0xFFF0;	    ///< Maximum number of clusters in a Fat16 Fat table, 65520
       
   118 const TInt KMaxFAT12Entries=0xFF0;	    ///< Maximum number of clusters in a Fat12 Fat table, 4080
       
   119 const TUint8 KBootSectorMediaDescriptor=0xF8;   ///< Media descriptor for a Fat volume, Generic disk
       
   120 const TUint8 KEntryErasedMarker=0xE5;           ///< Erased entry marker for a directory entry
       
   121 
       
   122 const TUint KDefSectorSzLog2=9;                         ///< Log2 of the default sector size for FAT
       
   123 const TUint KDefaultSectorSize = 1 << KDefSectorSzLog2; ///< Default sector size for FAT, 512 bytes
       
   124 
       
   125 
       
   126 const TInt EOF_32Bit =0x0fffffff;   ///< End of cluster chain value for Fat32
       
   127 const TInt EOF_16Bit =0xffff;       ///< End of cluster chain value for Fat16
       
   128 const TInt EOF_12Bit =0xfff;        ///< End of cluster chain value for Fat12
       
   129 const TInt KBad_32Bit=0x0ffffff7;   ///< Bad cluster value for Fat32
       
   130 const TInt KBad_16Bit=0xfff7;       ///< Bad cluster value for Fat16
       
   131 const TInt KBad_12Bit=0xff7;        ///< bad cluster value for Fat12
       
   132 
       
   133 const TUint   KSpareCluster = 0;          ///< FAT entry value for the spare cluster
       
   134 const TUint32 KFatFirstSearchCluster = 2; ///< FAT usable clusters start from 2; FAT[0] and FAT[1] are reserved
       
   135 
       
   136 const TUint   KFat16EntrySzLog2 = 1;      ///< Log2(sizeof(TFat16Entry)); FAT16 entry is 2 bytes
       
   137 const TUint   KFat32EntrySzLog2 = 2;      ///< Log2(sizeof(TFat32Entry)); FAT32 entry is 4 bytes
       
   138 
       
   139 
       
   140 
       
   141 //-----------------------------------------------------------------------------
       
   142 
       
   143 /**
       
   144 Internal fault codes for FAT fsy
       
   145 */
       
   146 enum TFault
       
   147 	{
       
   148 	EVFatNoLongName,                // 0
       
   149 	EFatBadParameter,               // 1
       
   150 	EFatBadLocalDrive,              // 2
       
   151 	EFatBadBootSectorParameter,     // 3
       
   152 	EFatBadDirEntryParameter,       // 4
       
   153 	EFatBadStdFormatName,           // 5
       
   154 	EFatBadDosFormatName,           // 6
       
   155 	EFatCorrupt,                    // 7
       
   156 	EFatChkDskIllegalClusterNumber, // 8
       
   157 	EFatChkDskClusterAlreadyInUse,  // 9
       
   158 	EFatChkDskBadCluster,           // 10
       
   159 	EFatChkDskInvalidEntrySize,     // 11
       
   160 	EFatFilePosBeyondEnd,			// 12
       
   161 	EFatFileSeekIndexTooSmall,      // 13
       
   162 	EFatFileSeekIndexTooSmall2,     // 14
       
   163 	ELruCacheBadGranularity,        // 15
       
   164 	EFatRawReadTooBig,              // 16
       
   165 	EFatReadUidFailed,              // 17
       
   166 	ELruCacheFlushNotSupported,     // 18
       
   167 	EReadFileSectionFailed,         // 19
       
   168 	EBadReplacementForUnconvertibleUnicodeCharacters, // 20
       
   169 
       
   170     EFatRAMDriveSizeInvalid,        // 21
       
   171 	EFatRAMDriveFreeInvalid,        // 22
       
   172     ECheckFatIndexZero,             // 23
       
   173 
       
   174     EFatCache_BadGranularity,       // 24
       
   175     EFatCache_DiscardingDirtyData,  // 25
       
   176     EFatCache_NotImplemented,       // 26
       
   177     EFatCache_BadFatType,           // 27
       
   178 
       
   179     EFatTable_InvalidIndex,         // 28
       
   180 
       
   181 	};
       
   182 
       
   183 //-----------------------------------------------------------------------------
       
   184 
       
   185 
       
   186 #if defined(_DEBUG)
       
   187 
       
   188 /** debug IO control functions */
       
   189 enum TControlIO
       
   190 {
       
   191     ECriticalWriteFailOn,   ///< 0
       
   192     ECriticalWriteFailOff,  ///< 1
       
   193     ERuggedFSysOn,          ///< 2
       
   194     ERuggedFSysOff,         ///< 3
       
   195     EIsRuggedFSys,          ///< 4
       
   196     ENCNotifierHang,        ///< 5
       
   197     ENCNotifierClear,       ///< 6
       
   198     ECNotifier,             ///< 7
       
   199     ECNotifierCancel,       ///< 8
       
   200 	ENCNotifierRepeat,      ///< 9
       
   201 
       
   202 	ELocalTimeForRemovableMediaOn,  ///< 10
       
   203 	ELocalTimeForRemovableMediaOff, ///< 11
       
   204 	ELocalTimeUsedOnRemovableMedia, ///< 12
       
   205 	ECreationTime,                  ///< 13
       
   206 
       
   207 	EDisableFATDirCache,			///<14
       
   208 	EDumpFATDirCache,				///<15
       
   209 	EFATDirCacheInfo,				///<16
       
   210 	
       
   211     EExtCustom=KMaxTInt/2
       
   212     };
       
   213 
       
   214 
       
   215 const TUid KSID_Test1={0x10210EB3}; ///< SID of the test that will define and set test property to control volume mounting
       
   216 
       
   217 //-- bit flags passed by test property value. Used to control some volume mounting features.
       
   218 const TUint32 KMntDisable_FsInfo       = 0x00000001; //-- mask for disabling/enabling FSInfo information
       
   219 const TUint32 KMntDisable_FatBkGndScan = 0x00000002; //-- mask for disabling/enabling FAT background scanner
       
   220 
       
   221 #endif //#if defined(_DEBUG)
       
   222 
       
   223 
       
   224 
       
   225 
       
   226 #endif //COMMON_CONSTANTS_H
       
   227 
       
   228 
       
   229 
       
   230 
       
   231 
       
   232 
       
   233 
       
   234 
       
   235 
       
   236 
       
   237 
       
   238 
       
   239 
       
   240 
       
   241 
       
   242 
       
   243 
       
   244