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