author | hgs |
Thu, 10 Jun 2010 11:48:01 +0100 | |
changeset 149 | d9f1e5bfe28c |
parent 90 | 947f0dc9f7a8 |
permissions | -rw-r--r-- |
0 | 1 |
// Copyright (c) 1996-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\sfat32\inc\sl_bpb.h |
|
15 |
// @file |
|
16 |
// @internalTechnology |
|
17 |
// |
|
18 |
// |
|
19 |
||
20 |
||
21 |
||
22 |
#ifndef SL_BPB_H |
|
23 |
#define SL_BPB_H |
|
24 |
||
25 |
#include "filesystem_fat.h" |
|
26 |
using FileSystem_FAT::TFatSubType; |
|
27 |
typedef TFatSubType TFatType; |
|
28 |
||
29 |
||
30 |
const TInt KVolumeLabelSize =11; ///< Volume lable size |
|
31 |
const TInt KFileSysTypeSize =8; ///< File system type parameter size |
|
32 |
const TInt KVendorIdSize =8; ///< Vendor ID parameter size |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
33 |
const TUint16 KBootSectorSignature =0xAA55;///< File system Boot sector signiture |
0 | 34 |
const TInt KFat16VolumeLabelPos =43; ///< Position of volume lable in BPB for Fat12/16 |
35 |
const TInt KFat32VolumeLabelPos =71; ///< Position of volume lable in BPB for Fat32 |
|
36 |
const TInt KSizeOfFatBootSector = 90; ///< Size in bytes of Boot sector parameter block (BPB) |
|
37 |
||
38 |
const TUint32 KBootSectorNum =0; ///< Main Boot Sector number (always 0) |
|
39 |
const TUint32 KFSInfoSectorNum =1; ///< Main FSInfo sector number. This is a default value. The actual value shall be taken from the BPB |
|
40 |
const TUint32 KReservedBootSectorNum=2; ///< Reserved Boot Sector (always 2) |
|
41 |
||
42 |
const TUint32 KBkBootSectorNum =6; ///< Backup Boot Sector number (must be 6 by default) |
|
43 |
const TUint32 KBkFSInfoSectorNum =KBkBootSectorNum+1; ///< Backup FSInfo sector number, follows the backup bpb sector |
|
44 |
const TUint32 KBkReservedBootSectorNum=KBkBootSectorNum+2; ///< Backup Reserved Boot Sector number, follows the backup FSInfo sector number |
|
45 |
||
46 |
||
47 |
||
48 |
//------------------------------------------------------------------------------------------------------------------- |
|
49 |
||
50 |
/** |
|
51 |
Boot sector parameter block, enables access to all file system parameters. |
|
52 |
Data is populated at mount time from the BPB sector |
|
53 |
*/ |
|
54 |
class TFatBootSector |
|
55 |
{ |
|
56 |
public: |
|
57 |
//-- simple getters / setters |
|
58 |
inline const TPtrC8 VendorId() const; |
|
59 |
inline TUint16 BytesPerSector() const; |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
60 |
inline TUint8 SectorsPerCluster() const; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
61 |
inline TUint16 ReservedSectors() const; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
62 |
inline TUint8 NumberOfFats() const; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
63 |
inline TUint16 RootDirEntries() const; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
64 |
inline TUint16 TotalSectors() const; |
0 | 65 |
inline TUint8 MediaDescriptor() const; |
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
66 |
inline TUint16 FatSectors() const; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
67 |
inline TUint16 SectorsPerTrack() const; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
68 |
inline TUint16 NumberOfHeads() const; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
69 |
inline TUint32 HiddenSectors() const; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
70 |
inline TUint32 HugeSectors() const; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
71 |
inline TUint8 PhysicalDriveNumber() const; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
72 |
inline TUint8 ExtendedBootSignature() const; |
0 | 73 |
inline TUint32 UniqueID() const; |
74 |
inline const TPtrC8 VolumeLabel() const; |
|
75 |
inline const TPtrC8 FileSysType() const; |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
76 |
inline TUint16 BootSectorSignature() const; |
0 | 77 |
inline TUint32 FatSectors32() const; |
78 |
inline TUint16 FATFlags() const; |
|
79 |
inline TUint16 VersionNumber() const; |
|
80 |
inline TUint32 RootClusterNum() const; |
|
81 |
inline TUint16 FSInfoSectorNum() const; |
|
82 |
inline TUint16 BkBootRecSector() const; |
|
83 |
||
84 |
inline void SetJumpInstruction(); |
|
85 |
inline void SetVendorID(const TDesC8& aDes); |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
86 |
inline void SetBytesPerSector(TUint16 aBytesPerSector); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
87 |
inline void SetSectorsPerCluster(TUint aSectorsPerCluster); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
88 |
inline void SetReservedSectors(TUint aReservedSectors); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
89 |
inline void SetNumberOfFats(TUint8 aNumberOfFats); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
90 |
inline void SetRootDirEntries(TUint16 aRootDirEntries); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
91 |
inline void SetTotalSectors(TUint aTotalSectors); |
0 | 92 |
inline void SetMediaDescriptor(TUint8 aMediaDescriptor); |
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
93 |
inline void SetFatSectors(TUint aFatSectors); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
94 |
inline void SetSectorsPerTrack(TUint16 aSectorsPerTrack); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
95 |
inline void SetNumberOfHeads(TUint16 aNumberOfHeads); |
0 | 96 |
inline void SetHiddenSectors(TUint32 aHiddenSectors); |
97 |
inline void SetHugeSectors(TUint32 aTotalSectors); |
|
98 |
inline void SetPhysicalDriveNumber(TInt aPhysicalDriveNumber); |
|
99 |
inline void SetReservedByte(TUint8 aReservedByte); |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
100 |
inline void SetExtendedBootSignature(TUint8 anExtendedBootSignature); |
0 | 101 |
inline void SetUniqueID(TUint32 anUniqueID); |
102 |
inline void SetVolumeLabel(const TDesC8& aDes); |
|
103 |
inline void SetFileSysType(const TDesC8& aDes); |
|
104 |
inline void SetFatSectors32(TUint32 aFatSectors32); |
|
105 |
inline void SetFATFlags(TUint16 aFATFlags); |
|
106 |
inline void SetVersionNumber(TUint16 aVersionNumber); |
|
107 |
inline void SetRootClusterNum(TUint32 aRootCusterNum); |
|
108 |
inline void SetFSInfoSectorNum(TUint16 aFSInfoSectorNum); |
|
109 |
inline void SetBkBootRecSector(TUint16 aBkBootRecSector); |
|
110 |
||
111 |
public: |
|
112 |
TFatBootSector(); |
|
113 |
||
114 |
void Initialise(); |
|
115 |
TBool IsValid() const; |
|
116 |
TFatType FatType(void) const; |
|
117 |
||
118 |
void Internalize(const TDesC8& aBuf); |
|
119 |
void Externalize(TDes8& aBuf) const; |
|
120 |
void PrintDebugInfo() const; |
|
121 |
||
122 |
//-- more advanced API, works for all FAT types |
|
123 |
TInt FirstFatSector() const; |
|
124 |
TInt RootDirStartSector() const; |
|
125 |
TInt FirstDataSector() const; |
|
126 |
||
127 |
TUint32 VolumeTotalSectorNumber() const; |
|
128 |
TUint32 TotalFatSectors() const; |
|
129 |
TUint32 RootDirSectors() const; |
|
130 |
||
131 |
protected: |
|
132 |
||
133 |
TUint8 iJumpInstruction[3]; ///< +0 Jump instruction used for bootable volumes |
|
134 |
TUint8 iVendorId[KVendorIdSize]; ///< +3 Vendor ID of the file system that formatted the volume |
|
135 |
TUint16 iBytesPerSector; ///< +11/0x0b Bytes per sector |
|
136 |
TUint8 iSectorsPerCluster; ///< +13/0x0d Sectors per cluster ratio |
|
137 |
TUint16 iReservedSectors; ///< +14/0x0e Number of reserved sectors on the volume |
|
138 |
TUint8 iNumberOfFats; ///< +16/0x10 Number of Fats on the volume |
|
139 |
TUint16 iRootDirEntries; ///< +17/0x11 Number of entries allowed in the root directory, specific to Fat12/16, zero for FAT32 |
|
140 |
TUint16 iTotalSectors; ///< +19/0x13 Total sectors on the volume, zero for FAT32 |
|
141 |
TUint8 iMediaDescriptor; ///< +12/0x15 Media descriptor |
|
142 |
TUint16 iFatSectors; ///< +22/0x16 Sectors used for the Fat table, zero for FAT32 |
|
143 |
TUint16 iSectorsPerTrack; ///< +24/0x18 Sectors per track |
|
144 |
TUint16 iNumberOfHeads; ///< +26/0x1a Number of heads |
|
145 |
TUint32 iHiddenSectors; ///< +28/0x1c Number of hidden sectors in the volume |
|
146 |
TUint32 iHugeSectors; ///< +32/0x20 Total sectors in the volume, Used if totalSectors > 65535 |
|
147 |
TUint32 iFatSectors32; ///< +36/0x24 Start of additional elements @ offset 36 for FAT32, Sectors in Fat table for 32 bit volume |
|
148 |
TUint16 iFATFlags; ///< +40/0x28 Fat flags |
|
149 |
TUint16 iVersionNumber; ///< +42/0x2a Version number of the file system |
|
150 |
TUint32 iRootClusterNum; ///< +44/0x2c Cluster number of the root directory |
|
151 |
TUint16 iFSInfoSectorNum; ///< +48/0x30 Sector number containing the FSIInfo structure |
|
152 |
TUint16 iBkBootRecSector; ///< +50/0x32 Backup boot sector |
|
153 |
TUint8 iReserved2[12]; ///< +52/0x34 Reserved space, End of Fat32 Only parameters section |
|
154 |
TUint8 iPhysicalDriveNumber; ///< +64/0x40 Physical drive number, not used in Symbian OS |
|
155 |
TUint8 iReserved; ///< +65/0x41 Reserved byte |
|
156 |
TUint8 iExtendedBootSignature; ///< +66/0x42 Extended boot signiture |
|
157 |
TUint32 iUniqueID; ///< +67/0x43 Unique volume ID |
|
158 |
TUint8 iVolumeLabel[KVolumeLabelSize]; ///< +71/0x47 The volume's label |
|
159 |
TUint8 iFileSysType[KFileSysTypeSize]; ///< +82/0x52 File system type |
|
160 |
}; |
|
161 |
||
162 |
||
163 |
||
164 |
||
165 |
//------------------------------------------------------------------------------------------------------------------- |
|
166 |
||
167 |
const TUint32 KSizeOfFSInfo = 0x200; ///< Size in bytes of the FSInfo structures |
|
168 |
const TUint32 KFSInfoReserved1Size= 480; ///< Size of first reserved area in FSInfo |
|
169 |
const TUint32 KFSInfoReserved2Size= 12; ///< Size of second reserved area in FSInfo |
|
170 |
||
171 |
/** |
|
172 |
TFSinfo hold the File system information comprising the free cluster count |
|
173 |
and next free cluster. It is found in the sector after the BPB and contains |
|
174 |
several identification signitures along with resverved space. It is not |
|
175 |
mandatory to support this feature. |
|
176 |
*/ |
|
177 |
class TFSInfo |
|
178 |
{ |
|
179 |
||
180 |
public: |
|
181 |
TFSInfo(); |
|
182 |
||
183 |
void Initialise(); |
|
184 |
TBool IsValid() const; |
|
185 |
void Internalize(const TDesC8& aBuf); |
|
186 |
void Externalize(TDes8& aBuf) const; |
|
187 |
void PrintDebugInfo() const; |
|
188 |
||
189 |
public: |
|
190 |
||
191 |
inline TUint32 FreeClusterCount() const; |
|
192 |
inline TUint32 NextFreeCluster() const; |
|
193 |
||
194 |
inline void SetFreeClusterCount(TUint32 aFreeCount); |
|
195 |
inline void SetNextFreeCluster(TUint32 aNextCluster); |
|
196 |
||
197 |
protected: |
|
198 |
TUint32 iLeadSig; ///< +0 lead in signature, should always equal 0x41615252 |
|
199 |
TUint8 iReserved1[KFSInfoReserved1Size]; ///< +4 First reserved region of 480 bytes |
|
200 |
TUint32 iStructureSig; ///< +484/0x1e4 Structure signature, should equal 0x61417272 |
|
201 |
TUint32 iFreeCount; ///< +488/0x1e8 last known free cluster count |
|
202 |
TUint32 iNextFree; ///< +492/0x1ec hint to file system as to where to start looking for free clusters |
|
203 |
TUint8 iReserved2[KFSInfoReserved2Size]; ///< +496/0x1f0 Second reserved region of 12 bytes |
|
204 |
TUint32 iTrainlingSig; ///< +508/0x1fc Trailing Signature (Bytes 510 and 511 = 55 and AA respectively) |
|
205 |
}; |
|
206 |
||
207 |
||
208 |
||
209 |
#endif //SL_BPB_H |