os/kernelhwsrv/userlibandfileserver/fileserver/sfat/inc/sl_bpb.h
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/kernelhwsrv/userlibandfileserver/fileserver/sfat/inc/sl_bpb.h	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,156 @@
     1.4 +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of the License "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +// f32\sfat\inc\sl_bpb.h
    1.18 +// @file
    1.19 +// @internalTechnology
    1.20 +// 
    1.21 +//
    1.22 +
    1.23 +//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    1.24 +//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    1.25 +//!!
    1.26 +//!! WARNING!! DO NOT edit this file !! '\sfat' component is obsolete and is not being used. '\sfat32'replaces it
    1.27 +//!!
    1.28 +//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    1.29 +//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    1.30 +
    1.31 +
    1.32 +#ifndef SL_BPB_H 
    1.33 +#define SL_BPB_H
    1.34 +
    1.35 +
    1.36 +#include "filesystem_fat.h"
    1.37 +using FileSystem_FAT::TFatSubType;
    1.38 +typedef TFatSubType TFatType;
    1.39 +
    1.40 +
    1.41 +const TInt KVolumeLabelSize         =11;    ///< Volume lable size
    1.42 +const TInt KFileSysTypeSize         =8;     ///< File system type parameter size
    1.43 +const TInt KVendorIdSize            =8;     ///< Vendor ID parameter size
    1.44 +const TInt KBootSectorSignature     =0xAA55;///< File system Boot sector signiture
    1.45 +
    1.46 +const TInt KSizeOfFatBootSector     =62;    ///< Size in bytes of Boot sector parameter block (BPB), 62 for fat16|12
    1.47 +const TInt KFat16VolumeLabelPos     =43;    ///< Position of volume lable in BPB for Fat12/16
    1.48 +
    1.49 +const TUint32 KBootSectorNum        =0;     ///< Main Boot Sector number (always 0)
    1.50 +
    1.51 +//-------------------------------------------------------------------------------------------------------------------
    1.52 +
    1.53 +/**
    1.54 +Boot sector parameter block, enables access to all file system parameters.
    1.55 +Data is populated at mount time from the BPB sector
    1.56 +*/
    1.57 +class TFatBootSector
    1.58 +    {
    1.59 +public:
    1.60 +    //-- simple getters / setters
    1.61 +    inline const TPtrC8 VendorId() const;
    1.62 +    inline TInt BytesPerSector() const;
    1.63 +    inline TInt SectorsPerCluster() const;
    1.64 +    inline TInt ReservedSectors() const;
    1.65 +    inline TInt NumberOfFats() const;
    1.66 +    inline TInt RootDirEntries() const;
    1.67 +    inline TInt TotalSectors() const;
    1.68 +    inline TUint8 MediaDescriptor() const;
    1.69 +    inline TInt FatSectors() const;
    1.70 +    inline TInt SectorsPerTrack() const;
    1.71 +    inline TInt NumberOfHeads() const;
    1.72 +    inline TInt HiddenSectors() const;
    1.73 +    inline TInt HugeSectors() const;
    1.74 +    inline TInt PhysicalDriveNumber() const;
    1.75 +    inline TInt ExtendedBootSignature() const;
    1.76 +    inline TUint32 UniqueID() const;
    1.77 +    inline const TPtrC8 VolumeLabel() const;
    1.78 +    inline const TPtrC8 FileSysType() const;
    1.79 +    inline TInt BootSectorSignature() const;
    1.80 +
    1.81 +    inline TUint32 RootClusterNum() const  {return 0;} //-- dummy   
    1.82 +    inline TUint16 FSInfoSectorNum() const {return 0;} //-- dummy   
    1.83 +    inline TUint16 BkBootRecSector() const {return 0;} //-- dummy   
    1.84 +
    1.85 +
    1.86 +    inline void SetJumpInstruction();
    1.87 +    inline void SetVendorID(const TDesC8& aDes);
    1.88 +    inline void SetBytesPerSector(TInt aBytesPerSector);
    1.89 +    inline void SetSectorsPerCluster(TInt aSectorsPerCluster);
    1.90 +    inline void SetReservedSectors(TInt aReservedSectors);
    1.91 +    inline void SetNumberOfFats(TInt aNumberOfFats);
    1.92 +    inline void SetRootDirEntries(TInt aRootDirEntries);
    1.93 +    inline void SetTotalSectors(TInt aTotalSectors);
    1.94 +    inline void SetMediaDescriptor(TUint8 aMediaDescriptor);
    1.95 +    inline void SetFatSectors(TInt aFatSectors);
    1.96 +    inline void SetSectorsPerTrack(TInt aSectorsPerTrack);
    1.97 +    inline void SetNumberOfHeads(TInt aNumberOfHeads);
    1.98 +    inline void SetHiddenSectors(TUint32 aHiddenSectors);
    1.99 +    inline void SetHugeSectors(TUint32 aTotalSectors);
   1.100 +    inline void SetPhysicalDriveNumber(TInt aPhysicalDriveNumber);
   1.101 +    inline void SetReservedByte(TUint8 aReservedByte);
   1.102 +    inline void SetExtendedBootSignature(TInt anExtendedBootSignature);
   1.103 +    inline void SetUniqueID(TUint32 anUniqueID);
   1.104 +    inline void SetVolumeLabel(const TDesC8& aDes);
   1.105 +    inline void SetFileSysType(const TDesC8& aDes);
   1.106 +
   1.107 +public:
   1.108 +
   1.109 +    TFatBootSector();
   1.110 +
   1.111 +    void Initialise();
   1.112 +    TBool IsValid() const;
   1.113 +    TFatType FatType(void) const;
   1.114 +    
   1.115 +    void Internalize(const TDesC8& aBuf);
   1.116 +    void Externalize(TDes8& aBuf) const;
   1.117 +    void PrintDebugInfo() const;
   1.118 +
   1.119 +    //-- more advanced API, works for all FAT types
   1.120 +    TInt FirstFatSector() const;
   1.121 +    TInt RootDirStartSector() const;
   1.122 +    TInt FirstDataSector() const;
   1.123 +    
   1.124 +    TUint32 VolumeTotalSectorNumber() const;
   1.125 +    TUint32 TotalFatSectors() const;
   1.126 +    TUint32 RootDirSectors() const;
   1.127 +
   1.128 +
   1.129 +protected:
   1.130 +    
   1.131 +    TUint8  iJumpInstruction[3];            ///< +0         Jump instruction used for bootable volumes
   1.132 +    TUint8  iVendorId[KVendorIdSize];       ///< +3         Vendor ID of the file system that formatted the volume
   1.133 +    TUint16 iBytesPerSector;                ///< +11/0x0b   Bytes per sector 
   1.134 +    TUint8  iSectorsPerCluster;             ///< +13/0x0d   Sectors per cluster ratio
   1.135 +    TUint16 iReservedSectors;               ///< +14/0x0e   Number of reserved sectors on the volume
   1.136 +    TUint8  iNumberOfFats;                  ///< +16/0x10   Number of Fats on the volume
   1.137 +    TUint16 iRootDirEntries;                ///< +17/0x11   Number of entries allowed in the root directory, specific to Fat12/16, zero for FAT32
   1.138 +    TUint16 iTotalSectors;                  ///< +19/0x13   Total sectors on the volume, zero for FAT32
   1.139 +    TUint8  iMediaDescriptor;               ///< +12/0x15   Media descriptor
   1.140 +    TUint16 iFatSectors;                    ///< +22/0x16   Sectors used for the Fat table, zero for FAT32
   1.141 +    TUint16 iSectorsPerTrack;               ///< +24/0x18   Sectors per track
   1.142 +    TUint16 iNumberOfHeads;                 ///< +26/0x1a   Number of heads 
   1.143 +    TUint32 iHiddenSectors;                 ///< +28/0x1c   Number of hidden sectors in the volume
   1.144 +    TUint32 iHugeSectors;                   ///< +32/0x20   Total sectors in the volume, Used if totalSectors > 65535
   1.145 +    //this is (boot sector) offset 36 for FAT12 and 16 but comes after additional FAT36 elements
   1.146 +    TUint8 iPhysicalDriveNumber;            ///< +36/0x24   Physical drive number, not used in Symbian OS
   1.147 +    TUint8 iReserved;                       ///< +37/0x25   Reserved byte
   1.148 +    TUint8 iExtendedBootSignature;          ///< +38/0x26   Extended boot signiture
   1.149 +    TUint32 iUniqueID;                      ///< +39/0x27   Unique volume ID
   1.150 +    TUint8 iVolumeLabel[KVolumeLabelSize];  ///< +43/0x2b   The volume's label
   1.151 +    TUint8 iFileSysType[KFileSysTypeSize];  ///< +54/0x36   File system type
   1.152 +    };
   1.153 +
   1.154 +
   1.155 +
   1.156 +
   1.157 +
   1.158 +#endif //SL_BPB_H
   1.159 +