imgtools/romtools/rofsbuild/fatimagegenerator.h
author kelvzhu
Tue, 27 Jul 2010 13:00:43 +0800
changeset 621 96fee2635b19
parent 605 122d2b873fd1
child 626 ac03b93ca9c4
permissions -rw-r--r--
Fixed Bug 2413 for evalid
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
605
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
     1
/*
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
     2
* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
     3
* All rights reserved.
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
     4
* This component and the accompanying materials are made available
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
     5
* under the terms of the License "Eclipse Public License v1.0"
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
     6
* which accompanies this distribution, and is available
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
     8
*
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
     9
* Initial Contributors:
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    11
*
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    12
* Contributors:
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    13
*
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    14
* Description: 
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    15
*
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    16
*/
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    17
#ifndef __FAT_IMAGE_GENERATER_HEADER__
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    18
#define __FAT_IMAGE_GENERATER_HEADER__
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    19
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    20
#include "fatdefines.h"
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    21
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    22
#include <iostream>
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    23
#include <list>
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    24
#include <fstream>
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    25
using namespace std ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    26
const unsigned int KBufferedIOBytes = 0x800000 ; // 8M 
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    27
const unsigned int KMaxClusterBytes = 0x8000; // 32K
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    28
enum TSupportedFatType {
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    29
	EFatUnknown = 0,
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    30
	EFat16 = 1,
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    31
	EFat32 = 2
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    32
};
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    33
 
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    34
class TFSNode;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    35
class TFatCluster;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    36
typedef list<TFatCluster*> PFatClusterList ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    37
typedef list<TFatCluster*>::iterator Interator ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    38
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    39
class TFatImgGenerator
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    40
{
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    41
public :
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    42
	//The constructor ,
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    43
	//a TFatImgGenerator is created and initialized,
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    44
	//if the parameters breaks the FAT specification,
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    45
	// then iType is set to EFatUnknown and thus
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    46
	// IsValid return false
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    47
	TFatImgGenerator(TSupportedFatType aType , ConfigurableFatAttributes& aAttr  );
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    48
	~TFatImgGenerator();
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    49
	inline bool IsValid() const { return (EFatUnknown != iType);}
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    50
	
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    51
	//Create the FAT image, 
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    52
	//If FAT image is not valid, or error accurs, return false
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    53
	bool Execute(TFSNode* aRootDir , const char* aOutputFile);
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    54
protected :
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    55
	void InitAsFat16(TUint32 aTotalSectors,TUint8 aSecPerClus,TUint16 aBytsPerSec);
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    56
	void InitAsFat32(TUint32 aTotalSectors,TUint8 aSecPerClus,TUint16 aBytsPerSec);
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    57
	bool PrepareClusters(TUint& aNextClusIndex,TFSNode* aNode);
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    58
	TSupportedFatType iType ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    59
	char* iFatTable ; 
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    60
	TUint iFatTableBytes ;  
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    61
	TUint iTotalClusters ;	
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    62
	TUint iBytsPerClus ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    63
	TFATBootSector iBootSector ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    64
	TFAT32BSExt iFat32Ext ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    65
	TFATHeader iFatHeader ;	
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    66
	PFatClusterList iDataClusters ;
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    67
};
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    68
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    69
122d2b873fd1 Minor changes: rofsbuild
jjkang
parents:
diff changeset
    70
#endif