userlibandfileserver/fileserver/sfat/inc/sl_bpb.h
changeset 15 4122176ea935
parent 0 a41df078684a
equal deleted inserted replaced
0:a41df078684a 15:4122176ea935
    15 // @file
    15 // @file
    16 // @internalTechnology
    16 // @internalTechnology
    17 // 
    17 // 
    18 //
    18 //
    19 
    19 
       
    20 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
       
    21 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
       
    22 //!!
       
    23 //!! WARNING!! DO NOT edit this file !! '\sfat' component is obsolete and is not being used. '\sfat32'replaces it
       
    24 //!!
       
    25 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
       
    26 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
       
    27 
    20 
    28 
    21 #ifndef SL_BPB_H 
    29 #ifndef SL_BPB_H 
    22 #define SL_BPB_H
    30 #define SL_BPB_H
    23 
    31 
    24 
    32 
    25 #include "filesystem_fat.h"
    33 #include "filesystem_fat.h"
    26 using FileSystem_FAT::TFatSubType;
    34 using FileSystem_FAT::TFatSubType;
    27 typedef TFatSubType TFatType;
    35 typedef TFatSubType TFatType;
    28 
    36 
    29 
    37 
    30 const TInt KVolumeLabelSize			=11;    ///< Volume lable size
    38 const TInt KVolumeLabelSize         =11;    ///< Volume lable size
    31 const TInt KFileSysTypeSize			=8;     ///< File system type parameter size
    39 const TInt KFileSysTypeSize         =8;     ///< File system type parameter size
    32 const TInt KVendorIdSize			=8;     ///< Vendor ID parameter size
    40 const TInt KVendorIdSize            =8;     ///< Vendor ID parameter size
    33 const TInt KBootSectorSignature		=0xAA55;///< File system Boot sector signiture
    41 const TInt KBootSectorSignature     =0xAA55;///< File system Boot sector signiture
    34 
    42 
    35 const TInt KSizeOfFatBootSector	    =62;    ///< Size in bytes of Boot sector parameter block (BPB), 62 for fat16|12
    43 const TInt KSizeOfFatBootSector     =62;    ///< Size in bytes of Boot sector parameter block (BPB), 62 for fat16|12
    36 const TInt KFat16VolumeLabelPos     =43;    ///< Position of volume lable in BPB for Fat12/16
    44 const TInt KFat16VolumeLabelPos     =43;    ///< Position of volume lable in BPB for Fat12/16
    37 
    45 
    38 const TUint32 KBootSectorNum        =0;     ///< Main Boot Sector number (always 0)
    46 const TUint32 KBootSectorNum        =0;     ///< Main Boot Sector number (always 0)
    39 
    47 
    40 //-------------------------------------------------------------------------------------------------------------------
    48 //-------------------------------------------------------------------------------------------------------------------
    42 /**
    50 /**
    43 Boot sector parameter block, enables access to all file system parameters.
    51 Boot sector parameter block, enables access to all file system parameters.
    44 Data is populated at mount time from the BPB sector
    52 Data is populated at mount time from the BPB sector
    45 */
    53 */
    46 class TFatBootSector
    54 class TFatBootSector
    47 	{
    55     {
    48 public:
    56 public:
    49     //-- simple getters / setters
    57     //-- simple getters / setters
    50 	inline const TPtrC8 VendorId() const;
    58     inline const TPtrC8 VendorId() const;
    51 	inline TInt BytesPerSector() const;
    59     inline TInt BytesPerSector() const;
    52 	inline TInt SectorsPerCluster() const;
    60     inline TInt SectorsPerCluster() const;
    53 	inline TInt ReservedSectors() const;
    61     inline TInt ReservedSectors() const;
    54 	inline TInt NumberOfFats() const;
    62     inline TInt NumberOfFats() const;
    55 	inline TInt RootDirEntries() const;
    63     inline TInt RootDirEntries() const;
    56 	inline TInt TotalSectors() const;
    64     inline TInt TotalSectors() const;
    57 	inline TUint8 MediaDescriptor() const;
    65     inline TUint8 MediaDescriptor() const;
    58 	inline TInt FatSectors() const;
    66     inline TInt FatSectors() const;
    59 	inline TInt SectorsPerTrack() const;
    67     inline TInt SectorsPerTrack() const;
    60 	inline TInt NumberOfHeads() const;
    68     inline TInt NumberOfHeads() const;
    61 	inline TInt HiddenSectors() const;
    69     inline TInt HiddenSectors() const;
    62 	inline TInt HugeSectors() const;
    70     inline TInt HugeSectors() const;
    63 	inline TInt PhysicalDriveNumber() const;
    71     inline TInt PhysicalDriveNumber() const;
    64 	inline TInt ExtendedBootSignature() const;
    72     inline TInt ExtendedBootSignature() const;
    65 	inline TUint32 UniqueID() const;
    73     inline TUint32 UniqueID() const;
    66 	inline const TPtrC8 VolumeLabel() const;
    74     inline const TPtrC8 VolumeLabel() const;
    67 	inline const TPtrC8 FileSysType() const;
    75     inline const TPtrC8 FileSysType() const;
    68 	inline TInt BootSectorSignature() const;
    76     inline TInt BootSectorSignature() const;
    69 
    77 
    70     inline TUint32 RootClusterNum() const  {return 0;} //-- dummy	
    78     inline TUint32 RootClusterNum() const  {return 0;} //-- dummy   
    71 	inline TUint16 FSInfoSectorNum() const {return 0;} //-- dummy	
    79     inline TUint16 FSInfoSectorNum() const {return 0;} //-- dummy   
    72 	inline TUint16 BkBootRecSector() const {return 0;} //-- dummy	
    80     inline TUint16 BkBootRecSector() const {return 0;} //-- dummy   
    73 
    81 
    74 
    82 
    75 	inline void SetJumpInstruction();
    83     inline void SetJumpInstruction();
    76 	inline void SetVendorID(const TDesC8& aDes);
    84     inline void SetVendorID(const TDesC8& aDes);
    77 	inline void SetBytesPerSector(TInt aBytesPerSector);
    85     inline void SetBytesPerSector(TInt aBytesPerSector);
    78 	inline void SetSectorsPerCluster(TInt aSectorsPerCluster);
    86     inline void SetSectorsPerCluster(TInt aSectorsPerCluster);
    79 	inline void SetReservedSectors(TInt aReservedSectors);
    87     inline void SetReservedSectors(TInt aReservedSectors);
    80 	inline void SetNumberOfFats(TInt aNumberOfFats);
    88     inline void SetNumberOfFats(TInt aNumberOfFats);
    81 	inline void SetRootDirEntries(TInt aRootDirEntries);
    89     inline void SetRootDirEntries(TInt aRootDirEntries);
    82 	inline void SetTotalSectors(TInt aTotalSectors);
    90     inline void SetTotalSectors(TInt aTotalSectors);
    83 	inline void SetMediaDescriptor(TUint8 aMediaDescriptor);
    91     inline void SetMediaDescriptor(TUint8 aMediaDescriptor);
    84 	inline void SetFatSectors(TInt aFatSectors);
    92     inline void SetFatSectors(TInt aFatSectors);
    85 	inline void SetSectorsPerTrack(TInt aSectorsPerTrack);
    93     inline void SetSectorsPerTrack(TInt aSectorsPerTrack);
    86 	inline void SetNumberOfHeads(TInt aNumberOfHeads);
    94     inline void SetNumberOfHeads(TInt aNumberOfHeads);
    87 	inline void SetHiddenSectors(TUint32 aHiddenSectors);
    95     inline void SetHiddenSectors(TUint32 aHiddenSectors);
    88 	inline void SetHugeSectors(TUint32 aTotalSectors);
    96     inline void SetHugeSectors(TUint32 aTotalSectors);
    89 	inline void SetPhysicalDriveNumber(TInt aPhysicalDriveNumber);
    97     inline void SetPhysicalDriveNumber(TInt aPhysicalDriveNumber);
    90 	inline void SetReservedByte(TUint8 aReservedByte);
    98     inline void SetReservedByte(TUint8 aReservedByte);
    91 	inline void SetExtendedBootSignature(TInt anExtendedBootSignature);
    99     inline void SetExtendedBootSignature(TInt anExtendedBootSignature);
    92 	inline void SetUniqueID(TUint32 anUniqueID);
   100     inline void SetUniqueID(TUint32 anUniqueID);
    93 	inline void SetVolumeLabel(const TDesC8& aDes);
   101     inline void SetVolumeLabel(const TDesC8& aDes);
    94 	inline void SetFileSysType(const TDesC8& aDes);
   102     inline void SetFileSysType(const TDesC8& aDes);
    95 
   103 
    96 public:
   104 public:
    97 
   105 
    98     TFatBootSector();
   106     TFatBootSector();
    99 
   107 
   100     void Initialise();
   108     void Initialise();
   101     TBool IsValid() const;
   109     TBool IsValid() const;
   102     TFatType FatType(void) const;
   110     TFatType FatType(void) const;
   103 	
   111     
   104     void Internalize(const TDesC8& aBuf);
   112     void Internalize(const TDesC8& aBuf);
   105     void Externalize(TDes8& aBuf) const;
   113     void Externalize(TDes8& aBuf) const;
   106 	void PrintDebugInfo() const;
   114     void PrintDebugInfo() const;
   107 
   115 
   108     //-- more advanced API, works for all FAT types
   116     //-- more advanced API, works for all FAT types
   109     TInt FirstFatSector() const;
   117     TInt FirstFatSector() const;
   110     TInt RootDirStartSector() const;
   118     TInt RootDirStartSector() const;
   111 	TInt FirstDataSector() const;
   119     TInt FirstDataSector() const;
   112     
   120     
   113     TUint32 VolumeTotalSectorNumber() const;
   121     TUint32 VolumeTotalSectorNumber() const;
   114     TUint32 TotalFatSectors() const;
   122     TUint32 TotalFatSectors() const;
   115     TUint32 RootDirSectors() const;
   123     TUint32 RootDirSectors() const;
   116 
   124 
   121     TUint8  iVendorId[KVendorIdSize];       ///< +3         Vendor ID of the file system that formatted the volume
   129     TUint8  iVendorId[KVendorIdSize];       ///< +3         Vendor ID of the file system that formatted the volume
   122     TUint16 iBytesPerSector;                ///< +11/0x0b   Bytes per sector 
   130     TUint16 iBytesPerSector;                ///< +11/0x0b   Bytes per sector 
   123     TUint8  iSectorsPerCluster;             ///< +13/0x0d   Sectors per cluster ratio
   131     TUint8  iSectorsPerCluster;             ///< +13/0x0d   Sectors per cluster ratio
   124     TUint16 iReservedSectors;               ///< +14/0x0e   Number of reserved sectors on the volume
   132     TUint16 iReservedSectors;               ///< +14/0x0e   Number of reserved sectors on the volume
   125     TUint8  iNumberOfFats;                  ///< +16/0x10   Number of Fats on the volume
   133     TUint8  iNumberOfFats;                  ///< +16/0x10   Number of Fats on the volume
   126     TUint16 iRootDirEntries;	            ///< +17/0x11   Number of entries allowed in the root directory, specific to Fat12/16, zero for FAT32
   134     TUint16 iRootDirEntries;                ///< +17/0x11   Number of entries allowed in the root directory, specific to Fat12/16, zero for FAT32
   127     TUint16 iTotalSectors;                  ///< +19/0x13   Total sectors on the volume, zero for FAT32
   135     TUint16 iTotalSectors;                  ///< +19/0x13   Total sectors on the volume, zero for FAT32
   128     TUint8  iMediaDescriptor;               ///< +12/0x15   Media descriptor
   136     TUint8  iMediaDescriptor;               ///< +12/0x15   Media descriptor
   129     TUint16 iFatSectors;                    ///< +22/0x16   Sectors used for the Fat table, zero for FAT32
   137     TUint16 iFatSectors;                    ///< +22/0x16   Sectors used for the Fat table, zero for FAT32
   130     TUint16 iSectorsPerTrack;               ///< +24/0x18   Sectors per track
   138     TUint16 iSectorsPerTrack;               ///< +24/0x18   Sectors per track
   131     TUint16 iNumberOfHeads;                 ///< +26/0x1a   Number of heads 
   139     TUint16 iNumberOfHeads;                 ///< +26/0x1a   Number of heads 
   132     TUint32 iHiddenSectors;                 ///< +28/0x1c   Number of hidden sectors in the volume
   140     TUint32 iHiddenSectors;                 ///< +28/0x1c   Number of hidden sectors in the volume
   133     TUint32 iHugeSectors;                   ///< +32/0x20   Total sectors in the volume, Used if totalSectors > 65535
   141     TUint32 iHugeSectors;                   ///< +32/0x20   Total sectors in the volume, Used if totalSectors > 65535
   134 	//this is (boot sector) offset 36 for FAT12 and 16 but comes after additional FAT36 elements
   142     //this is (boot sector) offset 36 for FAT12 and 16 but comes after additional FAT36 elements
   135 	TUint8 iPhysicalDriveNumber;            ///< +36/0x24   Physical drive number, not used in Symbian OS
   143     TUint8 iPhysicalDriveNumber;            ///< +36/0x24   Physical drive number, not used in Symbian OS
   136     TUint8 iReserved;                       ///< +37/0x25   Reserved byte
   144     TUint8 iReserved;                       ///< +37/0x25   Reserved byte
   137     TUint8 iExtendedBootSignature;          ///< +38/0x26   Extended boot signiture
   145     TUint8 iExtendedBootSignature;          ///< +38/0x26   Extended boot signiture
   138     TUint32 iUniqueID;                      ///< +39/0x27   Unique volume ID
   146     TUint32 iUniqueID;                      ///< +39/0x27   Unique volume ID
   139     TUint8 iVolumeLabel[KVolumeLabelSize];  ///< +43/0x2b   The volume's label
   147     TUint8 iVolumeLabel[KVolumeLabelSize];  ///< +43/0x2b   The volume's label
   140 	TUint8 iFileSysType[KFileSysTypeSize];  ///< +54/0x36   File system type
   148     TUint8 iFileSysType[KFileSysTypeSize];  ///< +54/0x36   File system type
   141 	};
   149     };
   142 
   150 
   143 
   151 
   144 
   152 
   145 
   153 
   146 
   154