imgtools/imglib/filesystem/include/fatbasebootsector.h
changeset 0 044383f39525
child 590 360bd6b35136
equal deleted inserted replaced
-1:000000000000 0:044383f39525
       
     1 /*
       
     2 * Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the License "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 * FAT base boot sector class for FileSystem component
       
    16 * @internalComponent
       
    17 * @released
       
    18 *
       
    19 */
       
    20 
       
    21 
       
    22 #ifndef FATBPBSECTOR_H
       
    23 #define FATBPBSECTOR_H
       
    24 
       
    25 #include "errorhandler.h"
       
    26 #include <string>
       
    27 #include <time.h>
       
    28 
       
    29 using namespace std;
       
    30 
       
    31 /**
       
    32 Class representing common fields of Boot Sector of all three fat system volume type.
       
    33 
       
    34 @internalComponent
       
    35 @released
       
    36 */
       
    37 class TFATBaseBootSector
       
    38 
       
    39 {
       
    40 protected:
       
    41 	//jump instruction to boot code
       
    42 	unsigned char iJmpBoot[3];
       
    43 	unsigned char iOEMName[8] ;
       
    44 	unsigned short iBytesPerSector;
       
    45 	unsigned int  iHiddenSectors;
       
    46 	unsigned char iMedia; //Media Type
       
    47 	unsigned char iNumberOfFats;
       
    48 	unsigned short  iNumHeads; //number of heads for interrupt 0x13
       
    49 	unsigned short  iSectorsPerTrack; //sector per track for interrupt ox13
       
    50 	unsigned short iTotalSectors; //16 bit total count of sectors on the volume
       
    51 	unsigned int iTotalSectors32; //32 bit total count of sectors on the volume
       
    52 	unsigned char iPhysicalDriveNumber;
       
    53 	unsigned char iReservedByte;
       
    54 	unsigned char iBootSign; //extended boot signature
       
    55 	unsigned int  iVolumeId;
       
    56 	unsigned char iVolumeLabel[KMaxVolumeLabel];
       
    57 	unsigned short iRootDirEntries;
       
    58 	unsigned short iReservedSectors;
       
    59 	unsigned char  iSectorsPerCluster;
       
    60 	unsigned int  iFatSectors; //count of sectors occupied by FAT in FAT16 volume
       
    61 	unsigned int  iFatSectors32; //count of sectors occupied by FAT in FAT32 volume
       
    62 	unsigned char iFileSysType[KFileSysTypeLength];
       
    63 public:	
       
    64 	TFATBaseBootSector();
       
    65 	virtual ~TFATBaseBootSector();
       
    66 	//Get methods
       
    67 	unsigned char* JumpInstruction() ;
       
    68 	unsigned char* OEMName() ;
       
    69 	unsigned int BytesPerSector() const;
       
    70 	unsigned int FatSectors32() const;
       
    71 	unsigned short FatSectors() const;
       
    72 	unsigned char NumberOfFats() const;
       
    73 	unsigned short ReservedSectors() const;
       
    74 	unsigned short RootDirEntries() const;
       
    75 	unsigned char  SectorsPerCluster() const;
       
    76 	unsigned int TotalSectors(Long64 aPartitionSize) const;
       
    77 	unsigned short LowSectorsCount() const;
       
    78 	unsigned int HighSectorsCount() const;
       
    79 	unsigned char Media() const;
       
    80 	unsigned short SectorsPerTrack() const;
       
    81 	unsigned short NumberOfHeads() const;
       
    82 	unsigned int HiddenSectors() const;
       
    83 	unsigned char BootSectorDriveNumber() const;
       
    84 	unsigned char ReservedByte() const;
       
    85 	unsigned char BootSignature() const;
       
    86 	unsigned char* VolumeLab() ;
       
    87 	unsigned int VolumeId() const;
       
    88 	//utility functions
       
    89 	int Log2(int aNum);
       
    90 	//Set methods
       
    91 	void SetJumpInstruction();
       
    92 	void SetOEMName();
       
    93 	void SetBytesPerSector(unsigned int aDriveSectorSize);
       
    94 	void SetNumberOfFats(unsigned int aDriveNoOfFATs);
       
    95 	void ComputeTotalSectors(Long64 aPartitionSize);
       
    96 	void SetMedia();
       
    97 	void SetSectorsPerTrack();
       
    98 	void SetNumberOfHeads();
       
    99 	void SetHiddenSectors();
       
   100 	void SetBootSectorDriveNumber();
       
   101 	void SetReservedByte();
       
   102 	void SetBootSignature();
       
   103 	void SetVolumeId();
       
   104 	void SetVolumeLab(String aVolumeLable);
       
   105 	//virtual methods
       
   106 	virtual void SetRootDirEntries()=0;
       
   107 	virtual void SetFileSysType()=0;
       
   108 	virtual void SetReservedSectors()=0;
       
   109 	virtual void ComputeSectorsPerCluster(Long64 aPartitionSize)=0;
       
   110 	virtual void ComputeFatSectors(Long64 aPartitionSize)=0;	
       
   111 };
       
   112 
       
   113 #endif //FATBPBSECTOR_H