userlibandfileserver/fileserver/sfat32/inc/sl_bpb.inl
changeset 0 a41df078684a
child 22 2f92ad2dc5db
equal deleted inserted replaced
-1:000000000000 0:a41df078684a
       
     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\sfat32\inc\sl_bpb.inl
       
    15 // 
       
    16 //
       
    17 
       
    18 #ifndef SL_BPB_INL
       
    19 #define SL_BPB_INL
       
    20 
       
    21 
       
    22 /**
       
    23 Defined cast of Fat directory entry data read to structure allowing
       
    24 access to data
       
    25 
       
    26 @internalTechnology
       
    27 */
       
    28 #define pDir ((SFatDirEntry*)&iData[0])
       
    29 
       
    30 /**
       
    31 Returns Sectors in Fat table for 32 bit volume
       
    32 
       
    33 @return iFatSectors32
       
    34 */
       
    35 inline TUint32 TFatBootSector::FatSectors32() const	
       
    36 	{return iFatSectors32;}
       
    37 /**
       
    38 Fat flags
       
    39 
       
    40 @return iFATFlags
       
    41 */
       
    42 inline TUint16 TFatBootSector::FATFlags() const		
       
    43 	{return iFATFlags;}
       
    44 /**
       
    45 Version number of the file system
       
    46 
       
    47 @return iVersionNumber
       
    48 */
       
    49 inline TUint16 TFatBootSector::VersionNumber() const		
       
    50 	{return iVersionNumber;}
       
    51 /**
       
    52 Cluster number of the root directory
       
    53 
       
    54 @return iRootClusterNum
       
    55 */
       
    56 inline TUint32 TFatBootSector::RootClusterNum() const	
       
    57 	{return iRootClusterNum;}
       
    58 /**
       
    59 Sector number containing the FSIInfo structure
       
    60 
       
    61 @return iFSInfoSectorNum
       
    62 */
       
    63 inline TUint16 TFatBootSector::FSInfoSectorNum() const
       
    64 	{return iFSInfoSectorNum;}
       
    65 /**
       
    66 Backup boot sector
       
    67 
       
    68 @return iBkBootRecSector
       
    69 */
       
    70 inline TUint16 TFatBootSector::BkBootRecSector() const
       
    71 	{return iBkBootRecSector;}
       
    72 /**
       
    73 Sets the number of sectors in Fat table for 32 bit volume
       
    74 
       
    75 @param aFatSectors32
       
    76 */
       
    77 inline void TFatBootSector::SetFatSectors32(TUint32	aFatSectors32)
       
    78 	{iFatSectors32 = aFatSectors32;}
       
    79 /**
       
    80 Sets the Fat flags
       
    81 
       
    82 @param aFATFlags
       
    83 */
       
    84 inline void TFatBootSector::SetFATFlags(TUint16 aFATFlags)
       
    85 	{iFATFlags = aFATFlags;}
       
    86 /**
       
    87 Sets the version number of the file system
       
    88 
       
    89 @param aVersionNumber
       
    90 */
       
    91 inline void TFatBootSector::SetVersionNumber(TUint16 aVersionNumber)
       
    92 	{iVersionNumber = aVersionNumber;}
       
    93 /**
       
    94 Sets the cluster number of the root directory
       
    95 
       
    96 @param aRootClusterNum
       
    97 */
       
    98 inline void TFatBootSector::SetRootClusterNum(TUint32 aRootClusterNum)	
       
    99 	{iRootClusterNum = aRootClusterNum;}
       
   100 /**
       
   101 Set the sector number containing the FSIInfo structure
       
   102 
       
   103 @param aFSInfoSectorNum
       
   104 */
       
   105 inline void TFatBootSector::SetFSInfoSectorNum(TUint16 aFSInfoSectorNum)
       
   106 	{iFSInfoSectorNum = aFSInfoSectorNum;}
       
   107 /**
       
   108 Set the backup boot sector
       
   109 
       
   110 @param aBkBootRecSector
       
   111 */
       
   112 inline void TFatBootSector::SetBkBootRecSector(TUint16 aBkBootRecSector)
       
   113 	{iBkBootRecSector = aBkBootRecSector;}	
       
   114 
       
   115 /**
       
   116 Returns the vendor ID of the file system that formatted the volume
       
   117 
       
   118 @return A descriptor containing the vendor ID 
       
   119 */
       
   120 inline const TPtrC8 TFatBootSector::VendorId() const
       
   121 	{return TPtrC8(iVendorId,KVendorIdSize);}
       
   122 /**
       
   123 Return the bytes per sector
       
   124 
       
   125 @return iBytesPerSector
       
   126 */
       
   127 inline TUint16 TFatBootSector::BytesPerSector() const
       
   128 	{return iBytesPerSector;}
       
   129 /**
       
   130 Returns the sectors per cluster ratio
       
   131 
       
   132 @return iSectorsPerCluster
       
   133 */
       
   134 inline TInt TFatBootSector::SectorsPerCluster() const
       
   135 	{return iSectorsPerCluster;}
       
   136 /**
       
   137 Returns the number of reserved sectors on the volume
       
   138 
       
   139 @return iReservedSectors
       
   140 */
       
   141 inline TInt TFatBootSector::ReservedSectors() const
       
   142 	{return iReservedSectors;}
       
   143 /**
       
   144 Returns the number of Fats on the volume
       
   145 
       
   146 @return iNumberOfFats
       
   147 */
       
   148 inline TInt TFatBootSector::NumberOfFats() const
       
   149 	{return iNumberOfFats;}
       
   150 /**
       
   151 Returns the number of entries allowed in the root directory, specific to Fat12/16, zero for FAT32
       
   152 
       
   153 @return iRootDirEntries
       
   154 */
       
   155 inline TInt TFatBootSector::RootDirEntries() const
       
   156 	{return iRootDirEntries;}
       
   157 /**
       
   158 Returns the total sectors on the volume, zero for FAT32
       
   159 
       
   160 @return iTotalSectors
       
   161 */
       
   162 inline TInt TFatBootSector::TotalSectors() const
       
   163 	{return iTotalSectors;}
       
   164 /**
       
   165 Returns the media descriptor
       
   166 
       
   167 @return iMediaDescriptor
       
   168 */
       
   169 inline TUint8 TFatBootSector::MediaDescriptor() const
       
   170 	{return iMediaDescriptor;}
       
   171 /**
       
   172 Returns sectors used for the Fat table, zero for FAT32
       
   173 
       
   174 @return iFatSectors
       
   175 */
       
   176 inline TInt TFatBootSector::FatSectors() const
       
   177 	{return iFatSectors;}
       
   178 /**
       
   179 Returns sectors per track
       
   180 
       
   181 @return iSectorsPerTrack
       
   182 */
       
   183 inline TInt TFatBootSector::SectorsPerTrack() const
       
   184 	{return iSectorsPerTrack;}
       
   185 /**
       
   186 Returns the number of heads 
       
   187 
       
   188 @return iNumberOfHeads
       
   189 */
       
   190 inline TInt TFatBootSector::NumberOfHeads() const
       
   191 	{return iNumberOfHeads;}
       
   192 /**
       
   193 Returns the number of hidden sectors in the volume
       
   194 
       
   195 @return iHiddenSectors
       
   196 */
       
   197 inline TInt TFatBootSector::HiddenSectors() const
       
   198 	{return iHiddenSectors;}
       
   199 /**
       
   200 Returns total sectors in the volume, Used if totalSectors > 65535
       
   201 
       
   202 @return iHugeSectors
       
   203 */
       
   204 inline TInt TFatBootSector::HugeSectors() const
       
   205 	{return iHugeSectors;}
       
   206 /**
       
   207 Returns the physical drive number, not used in Symbian OS
       
   208 
       
   209 @return iPhysicalDriveNumber
       
   210 */
       
   211 inline TInt TFatBootSector::PhysicalDriveNumber() const
       
   212 	{return iPhysicalDriveNumber;}
       
   213 /**
       
   214 Returns the extended boot signiture
       
   215 
       
   216 @return iExtendedBootSignature
       
   217 */
       
   218 inline TInt TFatBootSector::ExtendedBootSignature() const
       
   219 	{return iExtendedBootSignature;}
       
   220 /**
       
   221 Returns the unique volume ID
       
   222 
       
   223 @return iUniqueID
       
   224 */
       
   225 inline TUint32 TFatBootSector::UniqueID() const
       
   226 	{return iUniqueID;}
       
   227 /**
       
   228 Returns the volume's label
       
   229 
       
   230 @return A descriptor containing the volume label
       
   231 */
       
   232 inline const TPtrC8 TFatBootSector::VolumeLabel() const
       
   233 	{return TPtrC8(iVolumeLabel,KVolumeLabelSize);}
       
   234 /**
       
   235 Returns the file system type
       
   236 
       
   237 @return A descriptor containing the file system type
       
   238 */
       
   239 inline const TPtrC8 TFatBootSector::FileSysType() const
       
   240 	{return TPtrC8(iFileSysType,KFileSysTypeSize);}
       
   241 /**
       
   242 Returns the boot sector signiture
       
   243 
       
   244 @return KBootSectorSignature
       
   245 */
       
   246 inline TInt TFatBootSector::BootSectorSignature() const
       
   247 	{return KBootSectorSignature;}
       
   248 /**
       
   249 Set the jump instruction 
       
   250 */
       
   251 inline void TFatBootSector::SetJumpInstruction()
       
   252 	{iJumpInstruction[0]=0xE9;iJumpInstruction[2]=0x90;}
       
   253 /**
       
   254 Set the vendor ID of the file system that formatted the volume
       
   255 
       
   256 @param aDes Descriptor containing the Vendor ID
       
   257 */
       
   258 inline void TFatBootSector::SetVendorID(const TDesC8& aDes)
       
   259 	{
       
   260 	__ASSERT_DEBUG(aDes.Length()<=KVendorIdSize,Fault(EFatBadBootSectorParameter));
       
   261 	TPtr8 buf(iVendorId,KVendorIdSize);
       
   262 	buf=aDes;
       
   263 	}
       
   264 /**
       
   265 Sets the bytes per sector 
       
   266 
       
   267 @param aBytesPerSector Number of bytes per sector
       
   268 */
       
   269 inline void TFatBootSector::SetBytesPerSector(TInt aBytesPerSector)
       
   270 	{
       
   271 	__ASSERT_DEBUG(!(aBytesPerSector&~KMaxTUint16),Fault(EFatBadBootSectorParameter));
       
   272 	iBytesPerSector=(TUint16)aBytesPerSector;
       
   273 	}
       
   274 /**
       
   275 Set the sectors per cluster ratio
       
   276 
       
   277 @param aSectorsPerCluster Number of sectors per cluster
       
   278 */
       
   279 inline void TFatBootSector::SetSectorsPerCluster(TInt aSectorsPerCluster)
       
   280 	{
       
   281 	__ASSERT_DEBUG(!(aSectorsPerCluster&~KMaxTUint8),Fault(EFatBadBootSectorParameter));
       
   282 	iSectorsPerCluster=(TUint8)aSectorsPerCluster;
       
   283 	}
       
   284 /**
       
   285 Sets the number of reserved sectors on the volume
       
   286 
       
   287 @param aReservedSectors Number of reserved sectors
       
   288 */
       
   289 inline void TFatBootSector::SetReservedSectors(TInt aReservedSectors)
       
   290 	{
       
   291 	__ASSERT_DEBUG(!(aReservedSectors&~KMaxTUint16),Fault(EFatBadBootSectorParameter));
       
   292 	iReservedSectors=(TUint16)aReservedSectors;
       
   293 	}
       
   294 /**
       
   295 Sets the number of Fats on the volume
       
   296 
       
   297 @param aNumberOfFats Number of fats
       
   298 */
       
   299 inline void TFatBootSector::SetNumberOfFats(TInt aNumberOfFats)
       
   300 	{
       
   301 	__ASSERT_DEBUG(!(aNumberOfFats&~KMaxTUint8),Fault(EFatBadBootSectorParameter));
       
   302 	iNumberOfFats=(TUint8)aNumberOfFats;
       
   303 	}
       
   304 /**
       
   305 Number of entries allowed in the root directory, specific to Fat12/16, zero for FAT32
       
   306 
       
   307 @param aRootDirEntries
       
   308 */
       
   309 inline void TFatBootSector::SetRootDirEntries(TInt aRootDirEntries)
       
   310 	{
       
   311 	__ASSERT_DEBUG(!(aRootDirEntries&~KMaxTUint16),Fault(EFatBadBootSectorParameter));
       
   312 	iRootDirEntries=(TUint16)aRootDirEntries;
       
   313 	}
       
   314 /**
       
   315 Total sectors on the volume, zero for FAT32
       
   316 
       
   317 @param aTotalSectors Total number of sectors
       
   318 */
       
   319 inline void TFatBootSector::SetTotalSectors(TInt aTotalSectors)
       
   320 	{
       
   321 	__ASSERT_DEBUG(!(aTotalSectors&~KMaxTUint16),Fault(EFatBadBootSectorParameter));
       
   322 	iTotalSectors=(TUint16)aTotalSectors;
       
   323 	}
       
   324 /**
       
   325 Set the media descriptor
       
   326 
       
   327 @param aMediaDescriptor
       
   328 */
       
   329 inline void TFatBootSector::SetMediaDescriptor(TUint8 aMediaDescriptor)
       
   330 	{iMediaDescriptor=aMediaDescriptor;}
       
   331 /**
       
   332 Sectors used for the Fat table, zero for FAT32
       
   333 
       
   334 @param aFatSectors Number of Fat sectors
       
   335 */
       
   336 inline void TFatBootSector::SetFatSectors(TInt aFatSectors)
       
   337 	{
       
   338 	__ASSERT_DEBUG(!(aFatSectors&~KMaxTUint16),Fault(EFatBadBootSectorParameter));
       
   339 	iFatSectors=(TUint16)aFatSectors;
       
   340 	}
       
   341 /**
       
   342 Set the sectors per track
       
   343 
       
   344 @param aSectorsPerTrack Number of sectors per track
       
   345 */
       
   346 inline void TFatBootSector::SetSectorsPerTrack(TInt aSectorsPerTrack)
       
   347 	{
       
   348 	__ASSERT_DEBUG(!(aSectorsPerTrack&~KMaxTUint16),Fault(EFatBadBootSectorParameter));
       
   349 	iSectorsPerTrack=(TUint16)aSectorsPerTrack;
       
   350 	}
       
   351 /**
       
   352 Set the number of heads
       
   353 
       
   354 @param aNumberOfHeads Number of heads
       
   355 */
       
   356 inline void TFatBootSector::SetNumberOfHeads(TInt aNumberOfHeads)
       
   357 	{
       
   358 	__ASSERT_DEBUG(!(aNumberOfHeads&~KMaxTUint16),Fault(EFatBadBootSectorParameter));
       
   359 	iNumberOfHeads=(TUint16)aNumberOfHeads;
       
   360 	}
       
   361 /**
       
   362 Set the number of hidden sectors in the volume
       
   363 
       
   364 @param aHiddenSectors Number of hidden sectors
       
   365 */
       
   366 inline void TFatBootSector::SetHiddenSectors(TUint32 aHiddenSectors)
       
   367 	{
       
   368 	iHiddenSectors=aHiddenSectors;
       
   369 	}
       
   370 /**
       
   371 Set the total sectors in the volume, Used if totalSectors > 65535
       
   372 
       
   373 @param aHugeSectors
       
   374 */
       
   375 inline void TFatBootSector::SetHugeSectors(TUint32 aHugeSectors)
       
   376 	{iHugeSectors=aHugeSectors;}
       
   377 /**
       
   378 Physical drive number, not used in Symbian OS
       
   379 
       
   380 @param aPhysicalDriveNumber Physical drive number 
       
   381 */
       
   382 inline void TFatBootSector::SetPhysicalDriveNumber(TInt aPhysicalDriveNumber)
       
   383 	{
       
   384 	__ASSERT_DEBUG(!(aPhysicalDriveNumber&~KMaxTUint8),Fault(EFatBadBootSectorParameter));
       
   385 	iPhysicalDriveNumber=(TUint8)aPhysicalDriveNumber;
       
   386 	}
       
   387 /**
       
   388 Set the reserved byte value
       
   389 
       
   390 @param aReservedByte Value for reserved byte
       
   391 */
       
   392 inline void TFatBootSector::SetReservedByte(TUint8 aReservedByte)
       
   393 	{iReserved=aReservedByte;}
       
   394 /**
       
   395 Set the extended boot signiture
       
   396 
       
   397 @param anExtendedBootSignature The extended boot signiture
       
   398 */
       
   399 inline void TFatBootSector::SetExtendedBootSignature(TInt anExtendedBootSignature)
       
   400 	{
       
   401 	__ASSERT_DEBUG(!(anExtendedBootSignature&~KMaxTUint8),Fault(EFatBadBootSectorParameter));
       
   402 	iExtendedBootSignature=(TUint8)anExtendedBootSignature;
       
   403 	}
       
   404 /**
       
   405 Set the unique volume ID
       
   406 
       
   407 @param anUniqueID Set the unique ID
       
   408 */
       
   409 inline void TFatBootSector::SetUniqueID(TUint32 anUniqueID)
       
   410 	{iUniqueID=anUniqueID;}
       
   411 /**
       
   412 Set the volume's label
       
   413 
       
   414 @param aDes A descriptor containg the volume label
       
   415 */
       
   416 inline void TFatBootSector::SetVolumeLabel(const TDesC8& aDes)
       
   417 	{
       
   418 	__ASSERT_DEBUG(aDes.Length()<=KVolumeLabelSize,Fault(EFatBadBootSectorParameter));
       
   419 	TPtr8 buf(iVolumeLabel,KVolumeLabelSize);
       
   420 	buf=aDes;
       
   421 	}
       
   422 /**
       
   423 Set the file system type
       
   424 
       
   425 @param aDes A descriptor containing the file system type
       
   426 */
       
   427 inline void TFatBootSector::SetFileSysType(const TDesC8& aDes)
       
   428 	{
       
   429 	__ASSERT_DEBUG(aDes.Length()<=8,Fault(EFatBadBootSectorParameter));
       
   430 	TPtr8 buf(iFileSysType,8);
       
   431 	buf=aDes;
       
   432 	}
       
   433 
       
   434 
       
   435 /**
       
   436 Returns the number of free clusters
       
   437 
       
   438 @return iFreeCount
       
   439 */
       
   440 inline TUint32 TFSInfo::FreeClusterCount() const
       
   441 	{return iFreeCount;}
       
   442 /**
       
   443 Returns the next free cluster
       
   444 
       
   445 @return iNextFree
       
   446 */
       
   447 inline TUint32 TFSInfo::NextFreeCluster() const
       
   448 	{return iNextFree;}
       
   449 /**
       
   450 Sets the number of free clusters
       
   451 
       
   452 @param aFreeCount Number of free clusters
       
   453 */
       
   454 inline void TFSInfo::SetFreeClusterCount(TUint32 aFreeCount)
       
   455 	{iFreeCount = aFreeCount;}
       
   456 /**
       
   457 Sets the next free cluster
       
   458 
       
   459 @param aNextCluster Cluster number of the next free cluster 
       
   460 */
       
   461 inline void TFSInfo::SetNextFreeCluster(TUint32 aNextCluster)
       
   462 	{iNextFree = aNextCluster;}
       
   463 
       
   464 #endif //SL_BPB_INL