sl@0: // Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of the License "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // f32\sfat\inc\sl_bpb.h sl@0: // @file sl@0: // @internalTechnology sl@0: // sl@0: // sl@0: sl@0: //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! sl@0: //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! sl@0: //!! sl@0: //!! WARNING!! DO NOT edit this file !! '\sfat' component is obsolete and is not being used. '\sfat32'replaces it sl@0: //!! sl@0: //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! sl@0: //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! sl@0: sl@0: sl@0: #ifndef SL_BPB_H sl@0: #define SL_BPB_H sl@0: sl@0: sl@0: #include "filesystem_fat.h" sl@0: using FileSystem_FAT::TFatSubType; sl@0: typedef TFatSubType TFatType; sl@0: sl@0: sl@0: const TInt KVolumeLabelSize =11; ///< Volume lable size sl@0: const TInt KFileSysTypeSize =8; ///< File system type parameter size sl@0: const TInt KVendorIdSize =8; ///< Vendor ID parameter size sl@0: const TInt KBootSectorSignature =0xAA55;///< File system Boot sector signiture sl@0: sl@0: const TInt KSizeOfFatBootSector =62; ///< Size in bytes of Boot sector parameter block (BPB), 62 for fat16|12 sl@0: const TInt KFat16VolumeLabelPos =43; ///< Position of volume lable in BPB for Fat12/16 sl@0: sl@0: const TUint32 KBootSectorNum =0; ///< Main Boot Sector number (always 0) sl@0: sl@0: //------------------------------------------------------------------------------------------------------------------- sl@0: sl@0: /** sl@0: Boot sector parameter block, enables access to all file system parameters. sl@0: Data is populated at mount time from the BPB sector sl@0: */ sl@0: class TFatBootSector sl@0: { sl@0: public: sl@0: //-- simple getters / setters sl@0: inline const TPtrC8 VendorId() const; sl@0: inline TInt BytesPerSector() const; sl@0: inline TInt SectorsPerCluster() const; sl@0: inline TInt ReservedSectors() const; sl@0: inline TInt NumberOfFats() const; sl@0: inline TInt RootDirEntries() const; sl@0: inline TInt TotalSectors() const; sl@0: inline TUint8 MediaDescriptor() const; sl@0: inline TInt FatSectors() const; sl@0: inline TInt SectorsPerTrack() const; sl@0: inline TInt NumberOfHeads() const; sl@0: inline TInt HiddenSectors() const; sl@0: inline TInt HugeSectors() const; sl@0: inline TInt PhysicalDriveNumber() const; sl@0: inline TInt ExtendedBootSignature() const; sl@0: inline TUint32 UniqueID() const; sl@0: inline const TPtrC8 VolumeLabel() const; sl@0: inline const TPtrC8 FileSysType() const; sl@0: inline TInt BootSectorSignature() const; sl@0: sl@0: inline TUint32 RootClusterNum() const {return 0;} //-- dummy sl@0: inline TUint16 FSInfoSectorNum() const {return 0;} //-- dummy sl@0: inline TUint16 BkBootRecSector() const {return 0;} //-- dummy sl@0: sl@0: sl@0: inline void SetJumpInstruction(); sl@0: inline void SetVendorID(const TDesC8& aDes); sl@0: inline void SetBytesPerSector(TInt aBytesPerSector); sl@0: inline void SetSectorsPerCluster(TInt aSectorsPerCluster); sl@0: inline void SetReservedSectors(TInt aReservedSectors); sl@0: inline void SetNumberOfFats(TInt aNumberOfFats); sl@0: inline void SetRootDirEntries(TInt aRootDirEntries); sl@0: inline void SetTotalSectors(TInt aTotalSectors); sl@0: inline void SetMediaDescriptor(TUint8 aMediaDescriptor); sl@0: inline void SetFatSectors(TInt aFatSectors); sl@0: inline void SetSectorsPerTrack(TInt aSectorsPerTrack); sl@0: inline void SetNumberOfHeads(TInt aNumberOfHeads); sl@0: inline void SetHiddenSectors(TUint32 aHiddenSectors); sl@0: inline void SetHugeSectors(TUint32 aTotalSectors); sl@0: inline void SetPhysicalDriveNumber(TInt aPhysicalDriveNumber); sl@0: inline void SetReservedByte(TUint8 aReservedByte); sl@0: inline void SetExtendedBootSignature(TInt anExtendedBootSignature); sl@0: inline void SetUniqueID(TUint32 anUniqueID); sl@0: inline void SetVolumeLabel(const TDesC8& aDes); sl@0: inline void SetFileSysType(const TDesC8& aDes); sl@0: sl@0: public: sl@0: sl@0: TFatBootSector(); sl@0: sl@0: void Initialise(); sl@0: TBool IsValid() const; sl@0: TFatType FatType(void) const; sl@0: sl@0: void Internalize(const TDesC8& aBuf); sl@0: void Externalize(TDes8& aBuf) const; sl@0: void PrintDebugInfo() const; sl@0: sl@0: //-- more advanced API, works for all FAT types sl@0: TInt FirstFatSector() const; sl@0: TInt RootDirStartSector() const; sl@0: TInt FirstDataSector() const; sl@0: sl@0: TUint32 VolumeTotalSectorNumber() const; sl@0: TUint32 TotalFatSectors() const; sl@0: TUint32 RootDirSectors() const; sl@0: sl@0: sl@0: protected: sl@0: sl@0: TUint8 iJumpInstruction[3]; ///< +0 Jump instruction used for bootable volumes sl@0: TUint8 iVendorId[KVendorIdSize]; ///< +3 Vendor ID of the file system that formatted the volume sl@0: TUint16 iBytesPerSector; ///< +11/0x0b Bytes per sector sl@0: TUint8 iSectorsPerCluster; ///< +13/0x0d Sectors per cluster ratio sl@0: TUint16 iReservedSectors; ///< +14/0x0e Number of reserved sectors on the volume sl@0: TUint8 iNumberOfFats; ///< +16/0x10 Number of Fats on the volume sl@0: TUint16 iRootDirEntries; ///< +17/0x11 Number of entries allowed in the root directory, specific to Fat12/16, zero for FAT32 sl@0: TUint16 iTotalSectors; ///< +19/0x13 Total sectors on the volume, zero for FAT32 sl@0: TUint8 iMediaDescriptor; ///< +12/0x15 Media descriptor sl@0: TUint16 iFatSectors; ///< +22/0x16 Sectors used for the Fat table, zero for FAT32 sl@0: TUint16 iSectorsPerTrack; ///< +24/0x18 Sectors per track sl@0: TUint16 iNumberOfHeads; ///< +26/0x1a Number of heads sl@0: TUint32 iHiddenSectors; ///< +28/0x1c Number of hidden sectors in the volume sl@0: TUint32 iHugeSectors; ///< +32/0x20 Total sectors in the volume, Used if totalSectors > 65535 sl@0: //this is (boot sector) offset 36 for FAT12 and 16 but comes after additional FAT36 elements sl@0: TUint8 iPhysicalDriveNumber; ///< +36/0x24 Physical drive number, not used in Symbian OS sl@0: TUint8 iReserved; ///< +37/0x25 Reserved byte sl@0: TUint8 iExtendedBootSignature; ///< +38/0x26 Extended boot signiture sl@0: TUint32 iUniqueID; ///< +39/0x27 Unique volume ID sl@0: TUint8 iVolumeLabel[KVolumeLabelSize]; ///< +43/0x2b The volume's label sl@0: TUint8 iFileSysType[KFileSysTypeSize]; ///< +54/0x36 File system type sl@0: }; sl@0: sl@0: sl@0: sl@0: sl@0: sl@0: #endif //SL_BPB_H sl@0: