userlibandfileserver/fileserver/sfat/sl_disk.cpp
changeset 15 4122176ea935
parent 0 a41df078684a
--- a/userlibandfileserver/fileserver/sfat/sl_disk.cpp	Mon Oct 19 15:55:17 2009 +0100
+++ b/userlibandfileserver/fileserver/sfat/sl_disk.cpp	Mon Dec 21 16:14:42 2009 +0000
@@ -15,6 +15,14 @@
 // 
 //
 
+//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+//!!
+//!! WARNING!! DO NOT edit this file !! '\sfat' component is obsolete and is not being used. '\sfat32'replaces it
+//!!
+//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
 #include "sl_disk.h"
 #include "sl_cache.h"
 #include "sl_dir_cache.h"
@@ -72,9 +80,9 @@
 
 
 TInt CRawDisk::GetLastErrorInfo(TDes8& /*aErrorInfo*/) const
-	{
-	return KErrNotSupported;
-	}
+    {
+    return KErrNotSupported;
+    }
 
 //################################################################################################################################
 //##    CAtaDisk class implementation
@@ -82,8 +90,8 @@
 
 CAtaDisk::CAtaDisk(CFatMountCB& aFatMount)
          :CRawDisk(aFatMount), iDrive(aFatMount.DriveInterface())
-	{
-	}
+    {
+    }
 
 CAtaDisk::~CAtaDisk()
     {
@@ -102,8 +110,8 @@
     @return pointer to the constructed object.
 */
 CAtaDisk* CAtaDisk::NewL(CFatMountCB& aFatMount)
-	{
-	__PRINT1(_L("CAtaDisk::NewL() drv:%d"), aFatMount.DriveNumber());
+    {
+    __PRINT1(_L("CAtaDisk::NewL() drv:%d"), aFatMount.DriveNumber());
 
     CAtaDisk* pSelf = new (ELeave) CAtaDisk(aFatMount);
     
@@ -114,8 +122,8 @@
     
     CleanupStack::Pop();
 
-	return pSelf;
-	}
+    return pSelf;
+    }
 
 //-------------------------------------------------------------------------------------
 
@@ -155,43 +163,43 @@
     //=========================== create Demand Paging type of the directory cache
 
     // initialize cache memory manager as all file systems have mounted by now
-	if(CCacheMemoryManagerFactory::CacheMemoryManager())
-		{
-		// Note: the configuration data of min and max cache size are aligned with the memory size it
-		//	occupies in kernel as we are using demand paging subsystem for dynamic cache size support. 
-		//  Therefore, they are refered as 'Mem Size' in following calculation.
-		//  However, 'Data Size' refers to the logical size of a page, i.e. the actual data size each page
-		//  contains.
-		// The constraints we have to consider when setting up the dynamic cache:
-		// 	1. each page's data size is aligned with cluster size, unless cluster size is bigger than
-		//  	the default maximum page size allowed (typically 32 KB).
-		// 	2. if page's data size is smaller than segment size (typically 4 KB), i.e. the unit size of 
-		//     	demand paging subsystem's page management, we will still use up the whole segment for
-		// 		that page.
-		//  3. the default min and max cache's memory size is pre-defined in  fat_config.cpp file.
-		// 		(see KDef_DynamicDirCacheMin & KDef_DynamicDirCacheMax).
+    if(CCacheMemoryManagerFactory::CacheMemoryManager())
+        {
+        // Note: the configuration data of min and max cache size are aligned with the memory size it
+        //  occupies in kernel as we are using demand paging subsystem for dynamic cache size support. 
+        //  Therefore, they are refered as 'Mem Size' in following calculation.
+        //  However, 'Data Size' refers to the logical size of a page, i.e. the actual data size each page
+        //  contains.
+        // The constraints we have to consider when setting up the dynamic cache:
+        //  1. each page's data size is aligned with cluster size, unless cluster size is bigger than
+        //      the default maximum page size allowed (typically 32 KB).
+        //  2. if page's data size is smaller than segment size (typically 4 KB), i.e. the unit size of 
+        //      demand paging subsystem's page management, we will still use up the whole segment for
+        //      that page.
+        //  3. the default min and max cache's memory size is pre-defined in  fat_config.cpp file.
+        //      (see KDef_DynamicDirCacheMin & KDef_DynamicDirCacheMax).
 
-		// calculate page data size (logical view of page size)
-	    const TUint32 DefMaxCachePageLog2 = iFatMount->FatConfig().DynamicDirCacheMaxPageSizeLog2();
-	    const TUint32 PageDataSizeLog2 = clustSizeLog2 < DefMaxCachePageLog2 ? clustSizeLog2 : DefMaxCachePageLog2;
-	    
-		// calculate page number, based on memory size we have reserved
-	    const TUint32 SegmentSizeLog2 = CCacheMemoryManagerFactory::CacheMemoryManager()->SegmentSizeInBytesLog2();
-	    const TUint32 PageMemSizeLog2 = PageDataSizeLog2 < SegmentSizeLog2 ? SegmentSizeLog2 : PageDataSizeLog2;
-	    TUint32 CacheSizeMinInPages = iFatMount->FatConfig().DynamicDirCacheSizeMin() >> PageMemSizeLog2;
-	    TUint32 CacheSizeMaxInPages = iFatMount->FatConfig().DynamicDirCacheSizeMax() >> PageMemSizeLog2;
+        // calculate page data size (logical view of page size)
+        const TUint32 DefMaxCachePageLog2 = iFatMount->FatConfig().DynamicDirCacheMaxPageSizeLog2();
+        const TUint32 PageDataSizeLog2 = clustSizeLog2 < DefMaxCachePageLog2 ? clustSizeLog2 : DefMaxCachePageLog2;
+        
+        // calculate page number, based on memory size we have reserved
+        const TUint32 SegmentSizeLog2 = CCacheMemoryManagerFactory::CacheMemoryManager()->SegmentSizeInBytesLog2();
+        const TUint32 PageMemSizeLog2 = PageDataSizeLog2 < SegmentSizeLog2 ? SegmentSizeLog2 : PageDataSizeLog2;
+        TUint32 CacheSizeMinInPages = iFatMount->FatConfig().DynamicDirCacheSizeMin() >> PageMemSizeLog2;
+        TUint32 CacheSizeMaxInPages = iFatMount->FatConfig().DynamicDirCacheSizeMax() >> PageMemSizeLog2;
 
-	    // cache memory client is connected via name 
-	    TBuf<0x20> clientName = _L("CACHE_MEM_CLIENT:");
-		clientName.Append('A'+iFatMount->DriveNumber());
+        // cache memory client is connected via name 
+        TBuf<0x20> clientName = _L("CACHE_MEM_CLIENT:");
+        clientName.Append('A'+iFatMount->DriveNumber());
 
-		TRAPD(err, ipDirCache = CDynamicDirCache::NewL(iDrive, CacheSizeMinInPages, CacheSizeMaxInPages, PageDataSizeLog2, clientName));
-		if (err == KErrNone)
-	    	{
-	    	__PRINT4(_L("CDynamicDirCache::NewL(drv:%C, minPageNum:%u, maxPageNum:%u, pageDataSize:%u)\n"), 'A'+iFatMount->DriveNumber(), CacheSizeMinInPages, CacheSizeMaxInPages, 1<<PageDataSizeLog2);
-	    	return;
-	    	}
-		}
+        TRAPD(err, ipDirCache = CDynamicDirCache::NewL(iDrive, CacheSizeMinInPages, CacheSizeMaxInPages, PageDataSizeLog2, clientName));
+        if (err == KErrNone)
+            {
+            __PRINT4(_L("CDynamicDirCache::NewL(drv:%C, minPageNum:%u, maxPageNum:%u, pageDataSize:%u)\n"), 'A'+iFatMount->DriveNumber(), CacheSizeMinInPages, CacheSizeMaxInPages, 1<<PageDataSizeLog2);
+            return;
+            }
+        }
 #endif // USE_DP_DIR_CACHE
 
     //=========================== create legacy type of the directory cache
@@ -250,10 +258,10 @@
     @leave on error
 */
 void CAtaDisk::ReadCachedL(TInt64 aPos,TInt aLength,TDes8& aDes) const
-	{
+    {
     __PRINT3(_L("CAtaDisk::ReadL() pos:%u:%u, len:%u"), I64HIGH(aPos), I64LOW(aPos), aLength);
     iUidCache->ReadL(aPos, aLength, aDes);
-	}
+    }
 
 //-------------------------------------------------------------------------------------
 
@@ -266,10 +274,10 @@
     @leave on error
 */
 void CAtaDisk::WriteCachedL(TInt64 aPos, const TDesC8& aDes)
-	{
+    {
     __PRINT3(_L("CAtaDisk::WriteL() pos:%u:%u, len:%u"), I64HIGH(aPos), I64LOW(aPos), aDes.Size());
     iUidCache->WriteL(aPos, aDes);
-	}
+    }
 
 
 //-------------------------------------------------------------------------------------
@@ -280,18 +288,18 @@
 
     @param  aPos        absolute media position
     @param  aLength     how many bytes to read
-	@param  aTrg		Pointer to the data descriptor, i.e. (const TAny*)(&TDes8)
-	@param  aMessage	Refrence to server message from request
-	@param  anOffset	Offset into read data to write
+    @param  aTrg        Pointer to the data descriptor, i.e. (const TAny*)(&TDes8)
+    @param  aMessage    Refrence to server message from request
+    @param  anOffset    Offset into read data to write
 
     @leave on error
 */
 void CAtaDisk::ReadL(TInt64 aPos,TInt aLength,const TAny* aTrg,const RMessagePtr2 &aMessage,TInt anOffset) const
-	{
+    {
 
-	__PRINT4(_L("CAtaDisk::ReadL() pos:%u:%u, len:%u, offset:%u"), I64HIGH(aPos), I64LOW(aPos), aLength, anOffset);
-	User::LeaveIfError(iDrive.ReadNonCritical(aPos,aLength,aTrg,aMessage,anOffset));
-	}
+    __PRINT4(_L("CAtaDisk::ReadL() pos:%u:%u, len:%u, offset:%u"), I64HIGH(aPos), I64LOW(aPos), aLength, anOffset);
+    User::LeaveIfError(iDrive.ReadNonCritical(aPos,aLength,aTrg,aMessage,anOffset));
+    }
 
 //-------------------------------------------------------------------------------------
 
@@ -301,19 +309,19 @@
 
     This method shall invalidate some data caches to keep them in synch with the media.
 
-    @param aPos		Media position in bytes
-    @param aLength	Length in bytes of write
-	@param aTrg		Pointer to the data descriptor, i.e. (const TAny*)(&TDes8)
-	@param aMessage	Refrence to server message from request, contains data
-	@param anOffset	Offset into write data to use in write
+    @param aPos     Media position in bytes
+    @param aLength  Length in bytes of write
+    @param aTrg     Pointer to the data descriptor, i.e. (const TAny*)(&TDes8)
+    @param aMessage Refrence to server message from request, contains data
+    @param anOffset Offset into write data to use in write
 
     @leave on error
 */
 void CAtaDisk::WriteL(TInt64 aPos,TInt aLength,const TAny* aSrc,const RMessagePtr2 &aMessage,TInt anOffset)
-	{
+    {
     __PRINT4(_L("CAtaDisk::WriteL() pos:%u:%u, len:%u, offset:%u"), I64HIGH(aPos), I64LOW(aPos), aLength, anOffset);
 
-	//-- write data to the media directly
+    //-- write data to the media directly
     User::LeaveIfError(iDrive.WriteNonCritical(aPos,aLength,aSrc,aMessage,anOffset));
 
     //-- we need to invalidate UID cache page that corresponds to aPos (if any). This is UID caching specific. UID is stored in the first few bytes of 
@@ -324,15 +332,15 @@
     //-- invalidate affected(if any) part of the FAT cache in the case if someone used to write data to FAT area, which usually do not happen 
     iFatMount->FAT().InvalidateCacheL(aPos,aLength);
 
-	}
+    }
 
 //-------------------------------------------------------------------------------------
 
 /** Get information for last disk error */
 TInt CAtaDisk::GetLastErrorInfo(TDes8& aErrorInfo) const
-	{
-	return iDrive.GetLastErrorInfo(aErrorInfo);
-	}
+    {
+    return iDrive.GetLastErrorInfo(aErrorInfo);
+    }
 
 
 //-------------------------------------------------------------------------------------
@@ -367,9 +375,9 @@
     @return pointer to the constructed object.
 */
 CRamDisk* CRamDisk::NewL(CFatMountCB& aFatMount)
-	{
+    {
     __PRINT1(_L("CRamDisk::NewL() drv:%d"), aFatMount.DriveNumber());
-	CRamDisk* pSelf = new(ELeave)CRamDisk(aFatMount);
+    CRamDisk* pSelf = new(ELeave)CRamDisk(aFatMount);
 
     CleanupStack::PushL(pSelf);
   
@@ -377,13 +385,13 @@
     
     CleanupStack::Pop();
 
-	return pSelf;
-	}
+    return pSelf;
+    }
 
 CRamDisk::CRamDisk(CFatMountCB& aFatMount)
-	     :CRawDisk(aFatMount)
+         :CRawDisk(aFatMount)
     {
-	}
+    }
 
 //-------------------------------------------------------------------------------------
 
@@ -410,61 +418,61 @@
 
 /** @return the start address of the Ram Drive in low memory */
 TUint8* CRamDisk::RamDiskBase() const
-	{
-	return iRamDiskBase;
-	}
+    {
+    return iRamDiskBase;
+    }
 
 //-------------------------------------------------------------------------------------
 //
 // Read aLength of data from the disk
 //
 void CRamDisk::ReadCachedL(TInt64 aPos,TInt aLength,TDes8& aDes) const
-	{
-	
-	__PRINT3(_L("CRamDisk::ReadL Base 0x%x Pos 0x%x, Len %d"),RamDiskBase(),I64LOW(aPos),aLength);
-	__ASSERT_ALWAYS((aPos+aLength<=I64INT(iFatMount->Size())) && (aLength>=0),User::Leave(KErrCorrupt));
-	Mem::Copy((TUint8*)aDes.Ptr(),RamDiskBase()+I64LOW(aPos),aLength);
-	aDes.SetLength(aLength);
-	}
+    {
+    
+    __PRINT3(_L("CRamDisk::ReadL Base 0x%x Pos 0x%x, Len %d"),RamDiskBase(),I64LOW(aPos),aLength);
+    __ASSERT_ALWAYS((aPos+aLength<=I64INT(iFatMount->Size())) && (aLength>=0),User::Leave(KErrCorrupt));
+    Mem::Copy((TUint8*)aDes.Ptr(),RamDiskBase()+I64LOW(aPos),aLength);
+    aDes.SetLength(aLength);
+    }
 
 //-------------------------------------------------------------------------------------
 //
 // Write aLength of data to the disk
 //
 void CRamDisk::WriteCachedL(TInt64 aPos,const TDesC8& aDes)
-	{
+    {
 
-	__PRINT3(_L("CRamDisk::WriteL Base 0x%x Pos 0x%x, Len %d"),RamDiskBase(),aPos,aDes.Length());
-	__ASSERT_ALWAYS(aPos+aDes.Length()<=I64INT(iFatMount->Size()),User::Leave(KErrCorrupt));
-	Mem::Copy(RamDiskBase()+I64LOW(aPos),(TUint8*)aDes.Ptr(),aDes.Length());
-	}
-	
+    __PRINT3(_L("CRamDisk::WriteL Base 0x%x Pos 0x%x, Len %d"),RamDiskBase(),aPos,aDes.Length());
+    __ASSERT_ALWAYS(aPos+aDes.Length()<=I64INT(iFatMount->Size()),User::Leave(KErrCorrupt));
+    Mem::Copy(RamDiskBase()+I64LOW(aPos),(TUint8*)aDes.Ptr(),aDes.Length());
+    }
+    
 
 //-------------------------------------------------------------------------------------
 //
 // Read from ramDrive into thread relative descriptor
 //
 void CRamDisk::ReadL(TInt64 aPos,TInt aLength,const TAny* /*aTrg*/,const RMessagePtr2 &aMessage,TInt anOffset) const
-	{
-	__PRINT2(_L("CRamDisk::ReadL TAny* Pos 0x%x, Len %d"),aPos,aLength);
-	__ASSERT_ALWAYS((aPos+aLength<=I64INT(iFatMount->Size())) && (aLength>=0),User::Leave(KErrCorrupt));
-	TUint8* pos=RamDiskBase()+I64LOW(aPos);
-	TPtrC8 buf(pos,aLength);
-	aMessage.WriteL(0,buf,anOffset);
-	}
+    {
+    __PRINT2(_L("CRamDisk::ReadL TAny* Pos 0x%x, Len %d"),aPos,aLength);
+    __ASSERT_ALWAYS((aPos+aLength<=I64INT(iFatMount->Size())) && (aLength>=0),User::Leave(KErrCorrupt));
+    TUint8* pos=RamDiskBase()+I64LOW(aPos);
+    TPtrC8 buf(pos,aLength);
+    aMessage.WriteL(0,buf,anOffset);
+    }
 
 //-------------------------------------------------------------------------------------
 //
 // Write from thread relative descriptor into ramDrive
 //
 void CRamDisk::WriteL(TInt64 aPos,TInt aLength,const TAny* /*aSrc*/,const RMessagePtr2 &aMessage,TInt anOffset)
-	{
-	__PRINT2(_L("CRamDisk::WriteL TAny* Pos 0x%x, Len %d"),aPos,aLength);
-	__ASSERT_ALWAYS(aPos+aLength<=I64INT(iFatMount->Size()),User::Leave(KErrCorrupt));
-	TUint8* pos=RamDiskBase()+I64LOW(aPos);
-	TPtr8 buf(pos,aLength);
-	aMessage.ReadL(0,buf,anOffset);
-	}
+    {
+    __PRINT2(_L("CRamDisk::WriteL TAny* Pos 0x%x, Len %d"),aPos,aLength);
+    __ASSERT_ALWAYS(aPos+aLength<=I64INT(iFatMount->Size()),User::Leave(KErrCorrupt));
+    TUint8* pos=RamDiskBase()+I64LOW(aPos);
+    TPtr8 buf(pos,aLength);
+    aMessage.ReadL(0,buf,anOffset);
+    }