userlibandfileserver/fileserver/estart/estart.h
changeset 0 a41df078684a
equal deleted inserted replaced
-1:000000000000 0:a41df078684a
       
     1 // Copyright (c) 2004-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\estart\estart.h
       
    15 // 
       
    16 //
       
    17 
       
    18 /**
       
    19  @file
       
    20  @internalComponent
       
    21 */
       
    22 
       
    23 #ifndef __ESTART_H__
       
    24 #define __ESTART_H__
       
    25 
       
    26 #include <f32file.h>
       
    27 #include <d32locd.h>
       
    28 
       
    29 GLREF_D TBool gMountRofsAlone;
       
    30 GLREF_D TBool gMountComposite;
       
    31 
       
    32 //#define AUTO_PROFILE
       
    33 //#define LOAD_PATCH_LDD
       
    34 
       
    35 #ifdef _DEBUG
       
    36 extern TBool DebugTraceEnabled();
       
    37 #define ____IF_DEBUG(s)			if (DebugTraceEnabled()) {s;}
       
    38 #else
       
    39 #define ____IF_DEBUG(s)
       
    40 #endif
       
    41 
       
    42 #define	DEBUGPRINT(s)			____IF_DEBUG(RDebug::Print(_L(s)))
       
    43 #define	DEBUGPRINT1(s,a)		____IF_DEBUG(RDebug::Print(_L(s),(a)))
       
    44 #define	DEBUGPRINT2(s,a,b)		____IF_DEBUG(RDebug::Print(_L(s),(a),(b)))
       
    45 #define	DEBUGPRINT3(s,a,b,c)	____IF_DEBUG(RDebug::Print(_L(s),(a),(b),(c)))
       
    46 #define	DEBUGPRINT4(s,a,b,c,d)	____IF_DEBUG(RDebug::Print(_L(s),(a),(b),(c),(d)))
       
    47 #define	DEBUGPRINT5(s,a,b,c,d,e)	____IF_DEBUG(RDebug::Print(_L(s),(a),(b),(c),(d),(e)))
       
    48 #define	DEBUGPRINT6(s,a,b,c,d,e,f)	____IF_DEBUG(RDebug::Print(_L(s),(a),(b),(c),(d),(e),(f)))
       
    49 #define	DEBUGPRINT7(s,a,b,c,d,e,f,g)	____IF_DEBUG(RDebug::Print(_L(s),(a),(b),(c),(d),(e),(f),(g)))
       
    50 
       
    51 const TInt KMaxLineLen=256;
       
    52 
       
    53 #define FS_FORMAT_ALWAYS		0x001	// Format the drive once mounted
       
    54 #define FS_FORMAT_COLD			0x002	// Format the drive on a cold boot
       
    55 #define FS_FORMAT_CORRUPT 		0x004  	// Format only if corrupt
       
    56 #define	FS_DISMNT_CORRUPT		0x008	// Dismount if corrupt
       
    57 #define FS_SWAP_CORRUPT			0x010	// Swap drive mappings with another (specified) drive if corrupt
       
    58 #define FS_SYNC_DRIVE			0x020	// Mount as a synchronous drive 
       
    59 #define FS_SCANDRIVE			0x040	// Run scandrive once mounted (if rugged file system enabled)
       
    60 #define FS_COMPOSITE			0x080	// Mount the composite FSY on this drive
       
    61 #define FS_NO_MOUNT				0x100	// Add the FSY, map the drive but don't actually mount the drive
       
    62 #define FS_ALLOW_REM_ACC  		0x200	// Allow this drive to be accessed directly via a remote host
       
    63 #define FS_NOT_RUGGED  			0x400	// The FAT mount is not rugged
       
    64 #define FS_SYSTEM_DRIVE			0x800	// The drive is System Drive
       
    65 
       
    66 const TInt KFsDetectMappingChangeReturnOffset=0x10;
       
    67 typedef TInt (*TFsDetect)(RLocalDrive, TInt, TLocalDriveCapsV2&);
       
    68 struct SFsMountInfo
       
    69 	{
       
    70 	const TText* iFsyName;		// Filename of .FSY without extension
       
    71 	const TText* iObjName;		// Object name of file system (NULL = same as iFsyName)
       
    72 	const TText* iExtName;     	// Name of primary extension if applicable
       
    73 	TUint32 iFlags;				// Mount options
       
    74 	};
       
    75 
       
    76 struct SFileSystemInfo
       
    77 	{
       
    78 	TFsDetect iDetect;			// Detection function
       
    79 	SFsMountInfo iFsInfo;
       
    80 	};
       
    81 
       
    82 struct SLocalDriveMappingInfo
       
    83 	{
       
    84 	TInt iDriveNumber;
       
    85 	TInt iLocalDriveNumber;
       
    86 	SFsMountInfo iFsInfo;
       
    87 	TInt iSpare;
       
    88 	TInt iCapsRetCode;
       
    89 	TBool iRemovable;
       
    90 	};
       
    91 	
       
    92 class TText8FileReader
       
    93 	{
       
    94 public:
       
    95 	TText8FileReader();
       
    96 	~TText8FileReader();
       
    97 	TInt Set(RFile& aFile);
       
    98 	TInt Read(TPtr& aPtr);	
       
    99 public:
       
   100 	RFile iFile;
       
   101 	TBuf8<KMaxLineLen> iBuf;
       
   102 	TInt iBufPos;
       
   103 	TText* iFileDataBuf;
       
   104 	TInt iFileSize;	
       
   105 	};	
       
   106 
       
   107 
       
   108 /**
       
   109 A class that implements the behaviour provided by ESTART.
       
   110 
       
   111 The class defines a number of virtual functions, which may be overridden
       
   112 by a customised versions of ESTART.  
       
   113 */
       
   114 class TFSStartup
       
   115 	{
       
   116 public:	
       
   117 	TFSStartup();
       
   118 	virtual void Init();
       
   119 	virtual TInt Run();
       
   120 	virtual TInt LocalDriveInit();
       
   121 	virtual TInt InitialiseHAL();
       
   122 	virtual TInt LoadLocale();
       
   123 	virtual TInt StartSystem();
       
   124 	virtual TInt ParseCustomMountFlags(TPtrC* aFlagPtr,TUint32& aFlags,TInt& aSpare);
       
   125 	virtual TInt HandleCustomMountFlags(TInt& aMountRet,TInt& aFlags,TInt& aSpare,TInt aDrive);
       
   126 	virtual TInt DefaultLocalDrive(TInt aLocalDrive);
       
   127 	virtual TPtrC LocalDriveMappingFileName();
       
   128     virtual void ShowFormatProgress(TInt aPercent, TInt aDrive);
       
   129 	virtual void Close();
       
   130 protected:
       
   131 	virtual TInt GetStartupMode();
       
   132     virtual TInt GetStartupModeFromFile();
       
   133 	virtual TInt SysFileNames(RArray<TPtrC>& aFileNames);
       
   134 public:
       
   135 	TInt ProcessLocalDriveMappingFile();
       
   136 	TInt ParseMappingFileFlags(const TPtrC& aFlagDesc,TUint32& aFlagVar,TInt& aSpare);
       
   137 	TInt ParseMappingRecord(TPtr& aTextLine,SLocalDriveMappingInfo& anInfo);
       
   138 	void CheckAndReOrderArrayForSwapping(TInt aTotalEntries);
       
   139 	void SwapDriveMappings(TInt aCurrentEntry,TInt aTotalEntries);
       
   140 	TInt MountFileSystem(SLocalDriveMappingInfo& anInfo);
       
   141 	void SetFServLocalDriveMapping();
       
   142 	void SwapFServLocalDriveMapping(TInt aFirstDrive,TInt aSecondDrive);
       
   143 	TInt InitCompositeFileSystem();
       
   144 	void LoadCompositeFileSystem(TInt aDrive);
       
   145 	void LoadCompositeFileSystem(SLocalDriveMappingInfo& anInfo);
       
   146 	TBool CreateServer(const TDriveList& aDrives, const TDesC& aRootName);
       
   147 	TInt FormatDrive(TInt aDrive);
       
   148     TInt MountRemovableDrives();
       
   149     TInt ParseMappingFileLocalDrive(const TPtrC& aDriveDesc,TUint32 (&aDrives)[KMaxLocalDrives],TInt& aCount);
       
   150 	void LocalFSInitialisation();
       
   151 	TInt SearchForUnusedDriveNumber(TInt& aDrvNum);
       
   152 #if !defined(AUTODETECT_DISABLE)
       
   153 	virtual TInt GetNextStandardFSInfoEntry(const SFileSystemInfo** anEntry,TInt aPos);
       
   154 	TInt DetectFileSystem(TInt aLocalDriveNumber,SLocalDriveMappingInfo& anInfo);
       
   155 	TInt DetectAndMountFileSystems();
       
   156 #endif		
       
   157 #if defined(_LOCKABLE_MEDIA)
       
   158 	TInt WriteLocalPwStore(RFile& aFile);
       
   159 	TInt InitializeLocalPwStore();	
       
   160 #endif
       
   161 #ifdef LOAD_PATCH_LDD	
       
   162 	void LoadPatchLDDs();
       
   163 #endif	
       
   164 #ifdef AUTO_PROFILE
       
   165 	void StartProfiler();
       
   166 #endif
       
   167 private:
       
   168 	void SetSystemDrive();
       
   169 public:
       
   170     TInt iStartupMode;                                              
       
   171 	TInt iMuid;                                                     
       
   172 	RFs iFs;                                                        
       
   173 	TInt iTotalSupportedDrives;                                     
       
   174 	TInt iRuggedFileSystem;                                         
       
   175 	TUint iRegisteredDriveBitmask;                                  
       
   176 	TInt iLocalDriveList[KMaxLocalDrives];                          
       
   177 	SLocalDriveMappingInfo iDriveMappingInfo[KMaxLocalDrives];		
       
   178 	TInt iDriveSwapCount;                                           
       
   179 	TBool iColdStart;                                               
       
   180 	TUint iUnmountedDriveBitmask;                                   
       
   181     TInt iMapCount;                                                 
       
   182     TText8FileReader* iMapFile;                                     
       
   183 	};
       
   184 
       
   185 TInt StartSysAgt2(); // launch system agent 2 server
       
   186 
       
   187 
       
   188 #if !defined(AUTODETECT_DISABLE)	
       
   189 GLREF_C TInt DetectELocal(RLocalDrive ld, TInt cr, TLocalDriveCapsV2& caps);
       
   190 GLREF_C TInt DetectIRam(RLocalDrive ld, TInt cr, TLocalDriveCapsV2& caps);
       
   191 GLREF_C TInt DetectRofs(RLocalDrive ld, TInt cr, TLocalDriveCapsV2& caps);
       
   192 GLREF_C TInt DetectComposite(RLocalDrive ld, TInt cr, TLocalDriveCapsV2& caps);
       
   193 GLREF_C TInt DetectEneaLFFS(RLocalDrive ld, TInt cr, TLocalDriveCapsV2& caps);
       
   194 GLREF_C TInt DetectIso9660(RLocalDrive ld, TInt cr, TLocalDriveCapsV2& caps);
       
   195 GLREF_C TInt DetectNtfs(RLocalDrive ld, TInt cr, TLocalDriveCapsV2& caps);
       
   196 GLREF_C TInt DetectFtl(RLocalDrive ld, TInt cr, TLocalDriveCapsV2& caps);
       
   197 #endif
       
   198 
       
   199 #endif