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