userlibandfileserver/fileserver/sfat32/sl_bpb32.cpp
changeset 90 947f0dc9f7a8
parent 0 a41df078684a
child 291 206a6eaaeb71
equal deleted inserted replaced
52:2d65c2f76d7b 90:947f0dc9f7a8
    60     else //-- FAT12/16
    60     else //-- FAT12/16
    61     {
    61     {
    62         if(TotalSectors() >0 && HugeSectors() >0 )
    62         if(TotalSectors() >0 && HugeSectors() >0 )
    63             goto Invalid; //-- values clash
    63             goto Invalid; //-- values clash
    64 
    64 
    65         const TUint32 totSectors = Max(TotalSectors(), HugeSectors());
    65         const TUint32 totSectors = Max((TUint32)TotalSectors(), HugeSectors());
    66         const TUint32 rootDirStartSec =  ReservedSectors() + FatSectors()*NumberOfFats(); //-- root directory start sector
    66         const TUint32 rootDirStartSec =  ReservedSectors() + FatSectors()*NumberOfFats(); //-- root directory start sector
    67 
    67 
    68         if(FatSectors() < 1 || rootDirStartSec < 3 || RootDirEntries() < 1 || totSectors < 5)
    68         if(FatSectors() < 1 || rootDirStartSec < 3 || RootDirEntries() < 1 || totSectors < 5)
    69             goto Invalid; //-- these values are not compliant with FAT specs
    69             goto Invalid; //-- these values are not compliant with FAT specs
    70     }
    70     }
   226     __PRINT1(_L("Total Sectors:%d"),TotalSectors());
   226     __PRINT1(_L("Total Sectors:%d"),TotalSectors());
   227     __PRINT1(_L("MediaDescriptor:0x%x"),MediaDescriptor());
   227     __PRINT1(_L("MediaDescriptor:0x%x"),MediaDescriptor());
   228     __PRINT1(_L("FatSectors:%d"),FatSectors());
   228     __PRINT1(_L("FatSectors:%d"),FatSectors());
   229     __PRINT1(_L("SectorsPerTrack:%d"),SectorsPerTrack());
   229     __PRINT1(_L("SectorsPerTrack:%d"),SectorsPerTrack());
   230     __PRINT1(_L("NumberOfHeads:%d"),NumberOfHeads());
   230     __PRINT1(_L("NumberOfHeads:%d"),NumberOfHeads());
   231     __PRINT1(_L("HugeSectors:%d"),HugeSectors());
   231     __PRINT1(_L("HugeSectors:%u"),HugeSectors());
   232     __PRINT1(_L("Fat32 Sectors:%d"),FatSectors32());
   232     __PRINT1(_L("Fat32 Sectors:%u"),FatSectors32());
   233     __PRINT1(_L("Fat32 Flags:%d"),FATFlags());
   233     __PRINT1(_L("Fat32 Flags:%d"),FATFlags());
   234     __PRINT1(_L("Fat32 Version Number:%d"),VersionNumber());
   234     __PRINT1(_L("Fat32 Version Number:%d"),VersionNumber());
   235     __PRINT1(_L("Root Cluster Number:%d"),RootClusterNum());
   235     __PRINT1(_L("Root Cluster Number:%u"),RootClusterNum());
   236     __PRINT1(_L("FSInfo Sector Number:%d"),FSInfoSectorNum());
   236     __PRINT1(_L("FSInfo Sector Number:%d"),FSInfoSectorNum());
   237     __PRINT1(_L("Backup Boot Rec Sector Number:%d"),BkBootRecSector());
   237     __PRINT1(_L("Backup Boot Rec Sector Number:%d"),BkBootRecSector());
   238     __PRINT1(_L("PhysicalDriveNumber:%d"),PhysicalDriveNumber());
   238     __PRINT1(_L("PhysicalDriveNumber:%d"),PhysicalDriveNumber());
   239     __PRINT1(_L("ExtendedBootSignature:%d"),ExtendedBootSignature());
   239     __PRINT1(_L("ExtendedBootSignature:%d"),ExtendedBootSignature());
   240     __PRINT1(_L("UniqueID:0x%x"),UniqueID());
   240     __PRINT1(_L("UniqueID:0x%x"),UniqueID());
   254 */
   254 */
   255 TFatType TFatBootSector::FatType(void) const
   255 TFatType TFatBootSector::FatType(void) const
   256     {
   256     {
   257 
   257 
   258     //-- check iBytesPerSector validity; it shall be one of: 512,1024,2048,4096
   258     //-- check iBytesPerSector validity; it shall be one of: 512,1024,2048,4096
   259     if(!IsPowerOf2(iBytesPerSector) || iBytesPerSector < 512 ||  iBytesPerSector > 4096)
   259     if(iBytesPerSector < 512 ||  iBytesPerSector > 4096 || !IsPowerOf2(iBytesPerSector))
   260         return EInvalid; //-- invalid iBytesPerSector value
   260         return EInvalid; //-- invalid iBytesPerSector value
   261 
   261 
   262     //-- check iSectorsPerCluster validity, it shall be one of: 1,2,4,8...128
   262     //-- check iSectorsPerCluster validity, it shall be one of: 1,2,4,8...128
   263     if(!IsPowerOf2(iSectorsPerCluster) || iSectorsPerCluster > 128)
   263     if(!IsPowerOf2(iSectorsPerCluster) || iSectorsPerCluster > 128)
   264         return EInvalid; //-- invalid iSectorsPerCluster value
   264         return EInvalid; //-- invalid iSectorsPerCluster value
   324 
   324 
   325 /** @return FAT-type independent sector count on the volume */
   325 /** @return FAT-type independent sector count on the volume */
   326 TUint32 TFatBootSector::VolumeTotalSectorNumber() const
   326 TUint32 TFatBootSector::VolumeTotalSectorNumber() const
   327 {
   327 {
   328     __ASSERT_DEBUG(IsValid(), Fault(EFatBadBootSectorParameter));
   328     __ASSERT_DEBUG(IsValid(), Fault(EFatBadBootSectorParameter));
   329     return TotalSectors() >0 ? (TUint32)TotalSectors() : (TUint32)HugeSectors();
   329     return TotalSectors() >0 ? TotalSectors() : HugeSectors();
   330 }
   330 }
   331 
   331 
   332 /** @return FAT-type independent number of sectors in one FAT */
   332 /** @return FAT-type independent number of sectors in one FAT */
   333 TUint32 TFatBootSector::TotalFatSectors() const
   333 TUint32 TFatBootSector::TotalFatSectors() const
   334 {
   334 {
   335     __ASSERT_DEBUG(IsValid(), Fault(EFatBadBootSectorParameter));
   335     __ASSERT_DEBUG(IsValid(), Fault(EFatBadBootSectorParameter));
   336     return FatSectors() >0 ? (TUint32)FatSectors() : FatSectors32();
   336     return FatSectors() >0 ? FatSectors() : FatSectors32();
   337 }
   337 }
   338 
   338 
   339 
   339 
   340 
   340 
   341 
   341