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