61 iFatSize = aOwner->FatSizeInBytes(); |
61 iFatSize = aOwner->FatSizeInBytes(); |
62 iNumFATs = (TUint16)aOwner->NumberOfFats(); |
62 iNumFATs = (TUint16)aOwner->NumberOfFats(); |
63 iFatSecSzLog2 = (TUint16)aOwner->SectorSizeLog2(); |
63 iFatSecSzLog2 = (TUint16)aOwner->SectorSizeLog2(); |
64 iFatClustSzLog2 = (TUint16)aOwner->ClusterSizeLog2(); |
64 iFatClustSzLog2 = (TUint16)aOwner->ClusterSizeLog2(); |
65 |
65 |
|
66 //-- obtain maximal number of entries in the FAT table, count FAT[0] and FAT[1] as well, though they must not be accessed via cache |
|
67 iMaxFatEntries = aOwner->UsableClusters()+KFatFirstSearchCluster; |
|
68 |
66 __ASSERT_ALWAYS(iNumFATs >=1, User::Leave(KErrCorrupt)); |
69 __ASSERT_ALWAYS(iNumFATs >=1, User::Leave(KErrCorrupt)); |
67 |
70 |
68 __PRINT3(_L("#-CFatCacheBase::InitialiseL() FatStart:%u, FatSz:%d, drv:%d"),iFatStartPos, iFatSize, aOwner->DriveNumber()); |
71 __PRINT3(_L("#-CFatCacheBase::InitialiseL() FatStart:%u, FatSz:%d, drv:%d"),iFatStartPos, iFatSize, aOwner->DriveNumber()); |
|
72 |
69 } |
73 } |
70 |
74 |
71 //----------------------------------------------------------------------------- |
75 //----------------------------------------------------------------------------- |
72 /** |
76 /** |
73 This method shall be called to check if we are allowed to invalidate dirty cache, i.e. discard non-flushed data. |
77 This method shall be called to check if we are allowed to invalidate dirty cache, i.e. discard non-flushed data. |
392 @return FAT entry value at the index "aIndex" |
396 @return FAT entry value at the index "aIndex" |
393 */ |
397 */ |
394 TUint32 CFat16FixedCache::ReadEntryL(TUint32 aIndex) |
398 TUint32 CFat16FixedCache::ReadEntryL(TUint32 aIndex) |
395 { |
399 { |
396 //__PRINT1(_L("#-CFat16FixedCache::ReadEntryL() FAT idx:%d"), aIndex); |
400 //__PRINT1(_L("#-CFat16FixedCache::ReadEntryL() FAT idx:%d"), aIndex); |
397 ASSERT(aIndex >= KFatFirstSearchCluster && aIndex < (FatSize() >> KFat16EntrySzLog2)); |
401 ASSERT(FatIndexValid(aIndex)); |
398 |
402 |
399 //-- calculate page index in the array. Theoretically, aIndex can't be wrong because it is checked by the caller; |
403 //-- calculate page index in the array. Theoretically, aIndex can't be wrong because it is checked by the caller; |
400 //-- but in some strange situations (malformed volume ?) aIndex might get bigger than number of usable clusters. |
404 //-- but in some strange situations (malformed volume ?) aIndex might get bigger than number of usable clusters. |
401 const TUint pgIdx = aIndex >> (PageSizeLog2()-KFat16EntrySzLog2); |
405 const TUint pgIdx = aIndex >> (PageSizeLog2()-KFat16EntrySzLog2); |
402 |
406 |
439 */ |
443 */ |
440 void CFat16FixedCache::WriteEntryL(TUint32 aIndex, TUint32 aEntry) |
444 void CFat16FixedCache::WriteEntryL(TUint32 aIndex, TUint32 aEntry) |
441 { |
445 { |
442 //__PRINT2(_L("#-CFat16FixedCache::WriteEntryL() FAT idx:%d, val:%d"), aIndex, aEntry); |
446 //__PRINT2(_L("#-CFat16FixedCache::WriteEntryL() FAT idx:%d, val:%d"), aIndex, aEntry); |
443 |
447 |
444 ASSERT(aIndex >= KFatFirstSearchCluster && aIndex < (FatSize() >> KFat16EntrySzLog2)); |
448 ASSERT(FatIndexValid(aIndex)); |
445 |
449 |
446 SetDirty(ETrue); |
450 SetDirty(ETrue); |
447 |
451 |
448 //-- calculate page index in the array. Theoretically, aIndex can't be wrong because it is checked by the caller; |
452 //-- calculate page index in the array. Theoretically, aIndex can't be wrong because it is checked by the caller; |
449 //-- but in some strange situations (malformed volume ?) aIndex might get bigger than number of usable clusters. |
453 //-- but in some strange situations (malformed volume ?) aIndex might get bigger than number of usable clusters. |
559 @return always KErrNone |
563 @return always KErrNone |
560 */ |
564 */ |
561 TInt CFat16FixedCache::InvalidateRegion(TUint32 aStartIndex, TUint32 aNumEntries) |
565 TInt CFat16FixedCache::InvalidateRegion(TUint32 aStartIndex, TUint32 aNumEntries) |
562 { |
566 { |
563 __PRINT2(_L("#-CFat16FixedCache::InvalidateRegion() startIndex:%d, entries:%d"),aStartIndex, aNumEntries); |
567 __PRINT2(_L("#-CFat16FixedCache::InvalidateRegion() startIndex:%d, entries:%d"),aStartIndex, aNumEntries); |
564 ASSERT(aStartIndex >= KFatFirstSearchCluster && aStartIndex < (FatSize() >> KFat16EntrySzLog2)); |
568 ASSERT(FatIndexValid(aStartIndex)); |
|
569 ASSERT(FatIndexValid(aStartIndex+aNumEntries-1)); |
565 |
570 |
566 if(!aNumEntries) |
571 if(!aNumEntries) |
567 { |
572 { |
568 ASSERT(0); |
573 ASSERT(0); |
569 return KErrNone; |
574 return KErrNone; |
903 @return FAT entry value at the index "aIndex" |
908 @return FAT entry value at the index "aIndex" |
904 */ |
909 */ |
905 TUint32 CFat12Cache::ReadEntryL(TUint32 aIndex) |
910 TUint32 CFat12Cache::ReadEntryL(TUint32 aIndex) |
906 { |
911 { |
907 //__PRINT1(_L("#-CFat12Cache::ReadEntryL() FAT idx:%d"), aIndex); |
912 //__PRINT1(_L("#-CFat12Cache::ReadEntryL() FAT idx:%d"), aIndex); |
908 ASSERT(aIndex >= KFatFirstSearchCluster && aIndex < (FatSize() + FatSize()/2)); //-- FAT12 entry is 1.5 bytes long |
913 ASSERT(FatIndexValid(aIndex)); |
909 |
914 |
910 TUint32 entry; |
915 TUint32 entry; |
911 |
916 |
912 if(aIndex & 0x01) |
917 if(aIndex & 0x01) |
913 {//-- odd index |
918 {//-- odd index |
936 @param aEntry FAT entry value |
941 @param aEntry FAT entry value |
937 */ |
942 */ |
938 void CFat12Cache::WriteEntryL(TUint32 aIndex, TUint32 aEntry) |
943 void CFat12Cache::WriteEntryL(TUint32 aIndex, TUint32 aEntry) |
939 { |
944 { |
940 //__PRINT2(_L("#-CFat12Cache::WriteEntryL() FAT idx:%d, entry:%u"), aIndex, aEntry); |
945 //__PRINT2(_L("#-CFat12Cache::WriteEntryL() FAT idx:%d, entry:%u"), aIndex, aEntry); |
941 ASSERT(aIndex >= KFatFirstSearchCluster && aIndex < (FatSize() + FatSize()/2)); //-- FAT12 entry is 1.5 bytes long |
946 ASSERT(FatIndexValid(aIndex)); |
942 |
947 |
943 aEntry &= KFat12EntryMask; |
948 aEntry &= KFat12EntryMask; |
944 |
949 |
945 TUint32 byteIdx = 0; |
950 TUint32 byteIdx = 0; |
946 TUint8 tmp; |
951 TUint8 tmp; |
1077 @return Media read result code. |
1082 @return Media read result code. |
1078 */ |
1083 */ |
1079 TInt CFat12Cache::InvalidateRegion(TUint32 aStartIndex, TUint32 aNumEntries) |
1084 TInt CFat12Cache::InvalidateRegion(TUint32 aStartIndex, TUint32 aNumEntries) |
1080 { |
1085 { |
1081 __PRINT2(_L("#-CFat12Cache::InvalidateRegion() startIndex:%d, entries:%d"),aStartIndex, aNumEntries); |
1086 __PRINT2(_L("#-CFat12Cache::InvalidateRegion() startIndex:%d, entries:%d"),aStartIndex, aNumEntries); |
1082 ASSERT(aStartIndex >= KFatFirstSearchCluster && aStartIndex < (FatSize() + FatSize()/2)); //-- FAT12 entry is 1.5 bytes long |
1087 |
|
1088 ASSERT(FatIndexValid(aStartIndex)); |
|
1089 ASSERT(FatIndexValid(aStartIndex+aNumEntries-1)); |
|
1090 |
1083 (void)aStartIndex; |
1091 (void)aStartIndex; |
1084 (void)aNumEntries; |
1092 (void)aNumEntries; |
1085 |
1093 |
1086 //-- just re-read all FAT12, it is just 6K max and isn't worth calculating invalid sectors |
1094 //-- just re-read all FAT12, it is just 6K max and isn't worth calculating invalid sectors |
1087 return Invalidate(); |
1095 return Invalidate(); |