|
1 // Copyright (c) 1998-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\sfat\inc\fat_table.h |
|
15 // FAT12/16 File Allocation Table classes definitions |
|
16 // |
|
17 // |
|
18 |
|
19 /** |
|
20 @file |
|
21 @internalTechnology |
|
22 */ |
|
23 |
|
24 #ifndef FAT_TABLE_H |
|
25 #define FAT_TABLE_H |
|
26 |
|
27 |
|
28 //--------------------------------------------------------------------------------------------------------------------------------------- |
|
29 |
|
30 /** |
|
31 Fat table used for all media except RAM, manages the Fat table for all cluster requests. |
|
32 */ |
|
33 class CAtaFatTable : public CFatTable |
|
34 { |
|
35 public: |
|
36 static CAtaFatTable* NewL(CFatMountCB& aOwner); |
|
37 |
|
38 //-- overrides from the base class |
|
39 void FlushL(); |
|
40 void Dismount(TBool aDiscardDirtyData); |
|
41 void ReMountL(); |
|
42 void InvalidateCacheL(TInt64 aPos, TUint32 aLength); |
|
43 void InvalidateCacheL(); |
|
44 |
|
45 TUint32 ReadL(TUint32 aFatIndex) const; |
|
46 void WriteL(TUint32 aFatIndex, TUint32 aValue); |
|
47 |
|
48 TInt64 DataPositionInBytes(TUint32 aCluster) const; |
|
49 |
|
50 private: |
|
51 CAtaFatTable(CFatMountCB& aOwner); |
|
52 void InitializeL(); |
|
53 void CreateCacheL(); |
|
54 |
|
55 private: |
|
56 CFatCacheBase* iCache; ///< FAT cache, fixed or LRU depending on the FAT type |
|
57 }; |
|
58 |
|
59 //--------------------------------------------------------------------------------------------------------------------------------------- |
|
60 |
|
61 /** |
|
62 Fat table used for RAM media, manages the Fat table for all cluster requests. |
|
63 RAM media only supports Fat12/16. |
|
64 */ |
|
65 class CRamFatTable : public CFatTable |
|
66 { |
|
67 public: |
|
68 static CRamFatTable* NewL(CFatMountCB& aOwner); |
|
69 |
|
70 void ReMountL(); |
|
71 TUint32 ReadL(TUint32 aFatIndex) const; |
|
72 void WriteL(TUint32 aFatIndex, TUint32 aValue); |
|
73 TInt64 DataPositionInBytes(TUint32 aCluster) const; |
|
74 void FreeClusterListL(TUint32 aCluster); |
|
75 TUint32 AllocateSingleClusterL(TUint32 aNearestCluster); |
|
76 void ExtendClusterListL(TUint32 aNumber,TInt& aCluster); |
|
77 |
|
78 private: |
|
79 CRamFatTable(CFatMountCB& aOwner); |
|
80 |
|
81 void InitializeL(); |
|
82 |
|
83 inline TUint8 *RamDiskBase() const; |
|
84 inline TInt AllocateClusterNumber(); |
|
85 inline void WriteFatTable(TInt aFatIndex,TInt aValue); |
|
86 inline void WriteFatTable(TInt aFatIndex,TInt aFatValue,TInt anIndirectionTableValue); |
|
87 inline void ReadIndirectionTable(TUint32& aCluster) const; |
|
88 inline void WriteIndirectionTable(TInt aFatIndex,TInt aValue); |
|
89 inline TUint8* MemCopy(TAny* aTrg,const TAny* aSrc,TInt aLength); |
|
90 inline TUint8* MemCopyFillZ(TAny* aTrg, TAny* aSrc, TInt aLength); |
|
91 inline void ZeroFillCluster(TInt aCluster); |
|
92 |
|
93 void UpdateIndirectionTable(TUint32 aStartCluster,TUint32 anEndCluster,TInt aNum); |
|
94 |
|
95 protected: |
|
96 |
|
97 TInt iFatTablePos; ///< Current position in the fat table |
|
98 TInt iIndirectionTablePos; ///< Current position in indirection table, second fat used for this |
|
99 TUint8* iRamDiskBase; ///< Pointer to the Ram disk base |
|
100 }; |
|
101 |
|
102 |
|
103 |
|
104 //--------------------------------------------------------------------------------------------------------------------------------- |
|
105 |
|
106 |
|
107 #endif //FAT_TABLE_H |
|
108 |
|
109 |
|
110 |
|
111 |
|
112 |
|
113 |
|
114 |
|
115 |
|
116 |
|
117 |
|
118 |
|
119 |
|
120 |
|
121 |
|
122 |
|
123 |
|
124 |
|
125 |
|
126 |
|
127 |
|
128 |
|
129 |
|
130 |