kerneltest/f32test/shostmassstorage/testclient/usbtestmsclient/inc/cmassstoragemountcb.h
branchRCL_3
changeset 21 e7d2d738d3c2
parent 0 a41df078684a
equal deleted inserted replaced
20:597aaf25e343 21:e7d2d738d3c2
    23 */
    23 */
    24 
    24 
    25 #ifndef __CMASSSTORAGEMOUNTCB_H__
    25 #ifndef __CMASSSTORAGEMOUNTCB_H__
    26 #define __CMASSSTORAGEMOUNTCB_H__
    26 #define __CMASSSTORAGEMOUNTCB_H__
    27 
    27 
    28 #include <f32fsys.h>
       
    29 
    28 
    30 /**
    29 /**
    31 Mass Storage Mount.
    30 Mass Storage Mount.
    32 Only the MountL, Dismounted and Unlock methods are supported. All other methods
    31 Only the MountL, Dismounted and Unlock methods are supported. All other methods
    33 leave with KErrNotReady.
    32 leave with KErrNotReady.
    34 ControlIO is also supported for debug builds and returns KErrNotSupported for Release builds.
    33 ControlIO is also supported for debug builds and returns KErrNotSupported for Release builds.
    35 @internalTechnology
    34 @internalTechnology
    36 */
    35 */
    37 class TFatBootSector;
       
    38 class CMassStorageMountCB : public CLocDrvMountCB
    36 class CMassStorageMountCB : public CLocDrvMountCB
    39 	{
    37 	{
    40 public:
    38 public:
    41 	static CMassStorageMountCB* NewL(const TLunToDriveMap& aDriveMapping);
    39 	static CMassStorageMountCB* NewL(const TLunToDriveMap& aDriveMapping);
    42 	void MountL(TBool aForceMount);
    40 	void MountL(TBool aForceMount);
    63 
    61 
    64 private:
    62 private:
    65 	CMassStorageMountCB(const TLunToDriveMap& aDriveMapping);
    63 	CMassStorageMountCB(const TLunToDriveMap& aDriveMapping);
    66 	void WritePasswordData();
    64 	void WritePasswordData();
    67 	TInt DriveNumberToLun(TInt aDriveNumber);
    65 	TInt DriveNumberToLun(TInt aDriveNumber);
    68 	TBool ValidateBootSector();
       
    69 	TInt ReadBootSector(TFatBootSector& aBootSector);
       
    70 	TInt DetermineFatType(TFatBootSector& aBootSector);
       
    71 	TInt CheckDriveNumberL();
    66 	TInt CheckDriveNumberL();
    72 
    67 
    73     TBool IsPowerOfTwo(TInt aNum);
    68     TBool IsPowerOfTwo(TInt aNum);
    74     TInt Log2(TInt aNum);
    69     TInt Log2(TInt aNum);
    75 
    70 
    76 private:
    71 private:
    77 	TBool iIs16BitFat;
       
    78 	TBool iIs32BitFat;
       
    79 	const TLunToDriveMap& iDriveMapping;
    72 	const TLunToDriveMap& iDriveMapping;
    80 	};
    73 	};
    81 
    74 
    82 const TInt KSizeOfFatBootSector	= 90;
       
    83 const TInt KVendorIdSize = 8;
       
    84 const TInt KVolumeLabelSize = 11;
       
    85 const TInt KFileSysTypeSize = 8;
       
    86 const TInt KBootSectorSignature = 0xAA55;
       
    87 const TInt KSizeOfFatDirEntry = 32;
       
    88 
       
    89 /**
       
    90 Boot sector parameter block, enables access to all file system parameters.
       
    91 Data is populated at mount time from the BPB sector
       
    92 @internalTechnology
       
    93 */
       
    94 class TFatBootSector
       
    95 	{
       
    96 public:
       
    97 	inline const TPtrC8 VendorId() const;
       
    98 	inline TUint16 BytesPerSector() const;
       
    99 	inline TInt SectorsPerCluster() const;
       
   100 	inline TInt ReservedSectors() const;
       
   101 	inline TInt NumberOfFats() const;
       
   102 	inline TInt RootDirEntries() const;
       
   103 	inline TInt TotalSectors() const;
       
   104 	inline TUint8 MediaDescriptor() const;
       
   105 	inline TInt FatSectors() const;
       
   106 	inline TInt SectorsPerTrack() const;
       
   107 	inline TInt NumberOfHeads() const;
       
   108 	inline TInt HiddenSectors() const;
       
   109 	inline TInt HugeSectors() const;
       
   110 	inline TInt PhysicalDriveNumber() const;
       
   111 	inline TInt ExtendedBootSignature() const;
       
   112 	inline TUint32 UniqueID() const;
       
   113 	inline const TPtrC8 VolumeLabel() const;
       
   114 	inline const TPtrC8 FileSysType() const;
       
   115 	inline TInt BootSectorSignature() const;
       
   116 	inline void SetJumpInstruction();
       
   117 	inline void SetVendorID(const TDesC8& aDes);
       
   118 	inline void SetBytesPerSector(TInt aBytesPerSector);
       
   119 	inline void SetSectorsPerCluster(TInt aSectorsPerCluster);
       
   120 	inline void SetReservedSectors(TInt aReservedSectors);
       
   121 	inline void SetNumberOfFats(TInt aNumberOfFats);
       
   122 	inline void SetRootDirEntries(TInt aRootDirEntries);
       
   123 	inline void SetTotalSectors(TInt aTotalSectors);
       
   124 	inline void SetMediaDescriptor(TUint8 aMediaDescriptor);
       
   125 	inline void SetFatSectors(TInt aFatSectors);
       
   126 	inline void SetSectorsPerTrack(TInt aSectorsPerTrack);
       
   127 	inline void SetNumberOfHeads(TInt aNumberOfHeads);
       
   128 	inline void SetHiddenSectors(TUint32 aHiddenSectors);
       
   129 	inline void SetHugeSectors(TUint32 aTotalSectors);
       
   130 	inline void SetPhysicalDriveNumber(TInt aPhysicalDriveNumber);
       
   131 	inline void SetReservedByte(TUint8 aReservedByte);
       
   132 	inline void SetExtendedBootSignature(TInt anExtendedBootSignature);
       
   133 	inline void SetUniqueID(TUint32 anUniqueID);
       
   134 	inline void SetVolumeLabel(const TDesC8& aDes);
       
   135 	inline void SetFileSysType(const TDesC8& aDes);
       
   136 
       
   137 	inline void SetFatSectors32(TUint32	aFatSectors32);
       
   138 	inline void SetFATFlags(TUint16 aFATFlags);
       
   139 	inline void SetVersionNumber(TUint16	aVersionNumber);
       
   140 	inline void SetRootClusterNum(TUint32 aRootCusterNum);
       
   141 	inline void SetFSInfoSectorNum(TUint16 aFSInfoSectorNum);
       
   142 	inline void SetBkBootRecSector(TUint16 aBkBootRecSector);
       
   143 	inline TUint32 FatSectors32() const;
       
   144 	inline TUint16 FATFlags() const;
       
   145 	inline TUint16 VersionNumber() const;
       
   146 	inline TUint32 RootClusterNum() const;
       
   147 	inline TUint16 FSInfoSectorNum() const;
       
   148 	inline TUint16 BkBootRecSector() const;
       
   149 public:
       
   150 	inline TBool Is16BitFat();
       
   151 	inline TBool Is32BitFat();
       
   152 	inline TInt FirstFatSectorPos();
       
   153 	inline TInt RootDirStartSector();
       
   154 	inline TInt FirstFreeSector();
       
   155 public:
       
   156 	/**
       
   157 	Jump instruction used for bootable volumes
       
   158 	*/
       
   159     TUint8 iJumpInstruction[3];
       
   160 	/**
       
   161 	Vendor ID of the file system that formatted the volume
       
   162 	*/
       
   163     TUint8 iVendorId[KVendorIdSize];
       
   164 	/**
       
   165 	Bytes per sector
       
   166 	*/
       
   167     TUint16 iBytesPerSector;
       
   168 	/**
       
   169 	Sectors per cluster ratio
       
   170 	*/
       
   171     TUint8 iSectorsPerCluster;
       
   172 	/**
       
   173 	Number of reserved sectors on the volume
       
   174 	*/
       
   175     TUint16 iReservedSectors;
       
   176 	/**
       
   177 	Number of Fats on the volume
       
   178 	*/
       
   179     TUint8 iNumberOfFats;
       
   180 	/**
       
   181 	Number of entries allowed in the root directory, specific to Fat12/16, zero for FAT32
       
   182 	*/
       
   183     TUint16 iRootDirEntries;
       
   184 	/**
       
   185 	Total sectors on the volume, zero for FAT32
       
   186 	*/
       
   187     TUint16 iTotalSectors;
       
   188 	/**
       
   189 	Media descriptor
       
   190 	*/
       
   191     TUint8 iMediaDescriptor;
       
   192 	/**
       
   193 	Sectors used for the Fat table, zero for FAT32
       
   194 	*/
       
   195     TUint16 iFatSectors;
       
   196 	/**
       
   197 	Sectors per track
       
   198 	*/
       
   199     TUint16 iSectorsPerTrack;
       
   200 	/**
       
   201 	Number of heads
       
   202 	*/
       
   203     TUint16 iNumberOfHeads;
       
   204 	/**
       
   205 	Number of hidden sectors in the volume
       
   206 	*/
       
   207     TUint32 iHiddenSectors;
       
   208 	/**
       
   209 	Total sectors in the volume, Used if totalSectors > 65535
       
   210 	*/
       
   211     TUint32 iHugeSectors;
       
   212 
       
   213 	/**
       
   214 	Start of additional elements @ offset 36 for FAT32
       
   215 	Sectors in Fat table for 32 bit volume
       
   216 	*/
       
   217 	TUint32	iFatSectors32;
       
   218 	/**
       
   219 	Fat flags
       
   220 	*/
       
   221 	TUint16 iFATFlags;
       
   222 	/**
       
   223 	Version number of the file system
       
   224 	*/
       
   225 	TUint16	iVersionNumber;
       
   226 	/**
       
   227 	Cluster number of the root directory
       
   228 	*/
       
   229 	TUint32 iRootClusterNum;
       
   230 	/**
       
   231 	Sector number containing the FSIInfo structure
       
   232 	*/
       
   233 	TUint16 iFSInfoSectorNum;
       
   234 	/**
       
   235 	Backup boot sector
       
   236 	*/
       
   237 	TUint16 iBkBootRecSector;
       
   238 	/**
       
   239 	Reserved space
       
   240 	End of Fat32 Only parameters section
       
   241 	*/
       
   242 	TUint8	iReserved2[12];
       
   243 
       
   244 	/**
       
   245 	Physical drive number, not used in Symbian OS
       
   246 	*/
       
   247 	TUint8 iPhysicalDriveNumber;
       
   248 	/**
       
   249 	Reserved byte
       
   250 	*/
       
   251     TUint8 iReserved;
       
   252 	/**
       
   253 	Extended boot signiture
       
   254 	*/
       
   255     TUint8 iExtendedBootSignature;
       
   256 	/**
       
   257 	Unique volume ID
       
   258 	*/
       
   259     TUint32 iUniqueID;
       
   260 	/**
       
   261 	The volume's label
       
   262 	*/
       
   263     TUint8 iVolumeLabel[KVolumeLabelSize];
       
   264 	/**
       
   265 	File system type
       
   266 	*/
       
   267 	TUint8 iFileSysType[KFileSysTypeSize];
       
   268 	};
       
   269 
       
   270 #include "tfatbootsector.inl"
       
   271 
    75 
   272 #endif //__CMASSSTORAGEMOUNTCB_H__
    76 #endif //__CMASSSTORAGEMOUNTCB_H__