userlibandfileserver/fileserver/sfat/sl_fatcache.cpp
changeset 2 4122176ea935
parent 0 a41df078684a
child 42 a179b74831c9
equal deleted inserted replaced
0:a41df078684a 2:4122176ea935
    18 
    18 
    19 /**
    19 /**
    20  @file
    20  @file
    21 */
    21 */
    22 
    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 
    23 #include "sl_std.h"
    32 #include "sl_std.h"
    24 #include "sl_fatcache.h"
    33 #include "sl_fatcache.h"
    25 
    34 
    26 
    35 
    27 //#################################################################################################################################
    36 //#################################################################################################################################
   334     //-- See FAT specs, and round up the limit to the FAT sector boundary
   343     //-- See FAT specs, and round up the limit to the FAT sector boundary
   335     const TUint32 KMaxFat16Size = ((65524*sizeof(TFat16Entry)+FAT_SectorSz()-1) >> FAT_SectorSzLog2()) << FAT_SectorSzLog2(); 
   344     const TUint32 KMaxFat16Size = ((65524*sizeof(TFat16Entry)+FAT_SectorSz()-1) >> FAT_SectorSzLog2()) << FAT_SectorSzLog2(); 
   336     const TUint32 KMinFat16Size = 4086*sizeof(TFat16Entry);  //-- See FAT specs
   345     const TUint32 KMinFat16Size = 4086*sizeof(TFat16Entry);  //-- See FAT specs
   337     
   346     
   338     bParamsValid = aFatSize >= KMinFat16Size && aFatSize <= KMaxFat16Size;
   347     bParamsValid = aFatSize >= KMinFat16Size && aFatSize <= KMaxFat16Size;
   339 	__ASSERT_ALWAYS(bParamsValid, User::Leave(KErrCorrupt));
   348     __ASSERT_ALWAYS(bParamsValid, User::Leave(KErrCorrupt));
   340 
   349 
   341     //-- cache page size is (2^aRdGranularityLog2) bytes and consists of 2^(aRdGranularityLog2-aWrGranularity) sectors.
   350     //-- cache page size is (2^aRdGranularityLog2) bytes and consists of 2^(aRdGranularityLog2-aWrGranularity) sectors.
   342     iPageSizeLog2 = aRdGranularityLog2;
   351     iPageSizeLog2 = aRdGranularityLog2;
   343     iSectorSizeLog2 = aWrGranularityLog2; //-- Log2(number of sectors in cache page)
   352     iSectorSizeLog2 = aWrGranularityLog2; //-- Log2(number of sectors in cache page)
   344     
   353     
   828     ASSERT(FatType() == EFat12);
   837     ASSERT(FatType() == EFat12);
   829 
   838 
   830     //-- see FAT specs; 4084 is a max. number of clusters, fat12 entry is 1.5 bytes; but we need to round up FAT12 size to the sector size
   839     //-- see FAT specs; 4084 is a max. number of clusters, fat12 entry is 1.5 bytes; but we need to round up FAT12 size to the sector size
   831     const TUint32 KMaxFat12Size = ( ((TUint32)(4084*1.5+FAT_SectorSz()-1)) >> FAT_SectorSzLog2()) << FAT_SectorSzLog2();
   840     const TUint32 KMaxFat12Size = ( ((TUint32)(4084*1.5+FAT_SectorSz()-1)) >> FAT_SectorSzLog2()) << FAT_SectorSzLog2();
   832     const TUint32 KMinFat12Size = FAT_SectorSz();  //-- 1 FAT sector
   841     const TUint32 KMinFat12Size = FAT_SectorSz();  //-- 1 FAT sector
   833 	__ASSERT_ALWAYS(aFatSize >= KMinFat12Size && aFatSize <= KMaxFat12Size, User::Leave(KErrCorrupt));
   842     __ASSERT_ALWAYS(aFatSize >= KMinFat12Size && aFatSize <= KMaxFat12Size, User::Leave(KErrCorrupt));
   834     (void)KMaxFat12Size;
   843     (void)KMaxFat12Size;
   835     (void)KMinFat12Size;
   844     (void)KMinFat12Size;
   836 
   845 
   837     //-- as soon as FAT12 max size is 4084 entries or 6126 bytes, the cache is contiguous and divided 
   846     //-- as soon as FAT12 max size is 4084 entries or 6126 bytes, the cache is contiguous and divided 
   838     //-- to logical sectors (write granularity). 
   847     //-- to logical sectors (write granularity).