imgtools/romtools/readimage/inc/rom_image_reader.h
changeset 0 044383f39525
child 590 360bd6b35136
equal deleted inserted replaced
-1:000000000000 0:044383f39525
       
     1 /*
       
     2 * Copyright (c) 2005-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 * @internalComponent
       
    16 * @released
       
    17 *
       
    18 */
       
    19 
       
    20 
       
    21 #ifndef __ROM_IMAGE_READER__
       
    22 #define __ROM_IMAGE_READER__
       
    23 
       
    24 #include "image_reader.h"
       
    25 
       
    26 class TRomLoaderHeader;
       
    27 #include <wchar.h>
       
    28 class RomImageFSEntry 
       
    29 {
       
    30 public:
       
    31 	RomImageFSEntry (const char* aName) ;
       
    32 	virtual ~RomImageFSEntry() ;
       
    33 	virtual bool IsDirectory() = 0;
       
    34 	const char *Name() { return iName.c_str();}
       
    35 
       
    36 	string iName;
       
    37 	string iPath;
       
    38 	RomImageFSEntry 	*iSibling;
       
    39 	RomImageFSEntry 	*iChildren;
       
    40 };
       
    41 
       
    42 class RomImageFileEntry : public RomImageFSEntry 
       
    43 {
       
    44 public:
       
    45 	RomImageFileEntry(const char* aName) : RomImageFSEntry(aName), iExecutable(true)
       
    46 	{
       
    47 	}
       
    48 
       
    49 	bool IsDirectory() {
       
    50 		return false;
       
    51 	}
       
    52 	
       
    53 	union ImagePtr
       
    54 	{
       
    55 		TRomImageHeader		*iRomFileEntry;
       
    56 		TLinAddr			iDataFileAddr;
       
    57 	}ImagePtr;
       
    58 
       
    59 	TRomEntry		*iTRomEntryPtr;
       
    60 
       
    61 	bool iExecutable;
       
    62 };
       
    63 
       
    64 class RomImageDirEntry : public RomImageFSEntry
       
    65 {
       
    66 public:
       
    67 	RomImageDirEntry(const char* aName) : RomImageFSEntry(aName)
       
    68 	{
       
    69 	}
       
    70 
       
    71 	bool IsDirectory()
       
    72 	{
       
    73 		return true;
       
    74 	}
       
    75 
       
    76 };
       
    77 
       
    78 
       
    79 class RomImageHeader
       
    80 {
       
    81 public:
       
    82 	RomImageHeader(char* aHdr, EImageType aImgType = EROM_IMAGE );
       
    83 	TRomLoaderHeader	*iLoaderHdr;
       
    84 	TRomHeader			*iRomHdr;
       
    85 	TExtensionRomHeader	*iExtRomHdr;
       
    86 	
       
    87 	void DumpRomHdr();
       
    88 	void DumpRomXHdr();
       
    89 };
       
    90 
       
    91 class RomImageReader : public ImageReader
       
    92 {
       
    93 public:
       
    94 	RomImageReader(const char* aFile, EImageType aImgType = EROM_IMAGE );
       
    95 	~RomImageReader();
       
    96 
       
    97 	void ReadImage();
       
    98 	void ProcessImage();
       
    99 	void BuildDir(TRomDir *aDir, RomImageFSEntry* aPaFSEntry); 
       
   100 
       
   101 	void AddChild(RomImageFSEntry *aParent, RomImageFSEntry *aChild, TRomEntry* aRomEntry);
       
   102 	void Name(string& aName, const wchar_t* aUnicodeName, TUint aLen);
       
   103 	void Validate();
       
   104 	void Dump();
       
   105 	void DumpTree();
       
   106 	void DumpSubTree(RomImageFSEntry* aFsEntry);
       
   107 	void DumpImage(RomImageFileEntry*);
       
   108 	void DumpAttribs(RomImageFSEntry* aFsEntry);
       
   109 	void DumpDirStructure();
       
   110 	void DumpDirStructure(RomImageFSEntry*, int &aPadding);
       
   111 	void ExtractImageContents();
       
   112 	void TraverseImage(RomImageFSEntry*  aEntity,ofstream& aFile);
       
   113 	void CheckFileExtension(RomImageFSEntry*  aEntity,ofstream& aFile);
       
   114 	void LogRomEnrtyToFile(const char* aPath,const char* aEntityName,ofstream& aFile);
       
   115 
       
   116 	void GetFileInfo(FILEINFOMAP &aFileMap);
       
   117 	void ProcessDirectory(RomImageFSEntry *aEntity, FILEINFOMAP &aFileMap);
       
   118 	TUint32 GetImageSize();
       
   119 	
       
   120 	TUint32 GetImageCompressionType(); 
       
   121 
       
   122 	TLinAddr GetRomBase();
       
   123 	TUint GetHdrSize();
       
   124 	TLinAddr GetRootDirList();
       
   125 
       
   126 	RomImageHeader			*iImageHeader; 
       
   127 	RomImageFSEntry			*iRomImageRootDirEntry;
       
   128 
       
   129 protected:	
       
   130 	void					ReadData(char* aBuffer, TUint aLength);	
       
   131 
       
   132 	ifstream				iFile ;
       
   133 	TUint32					iRomSize ;
       
   134 	char*					iHeaderBuffer ;
       
   135 	char*					iRomLayoutData ; 
       
   136 	EImageType				iImgType; 
       
   137 
       
   138 };
       
   139 
       
   140 #endif //__ROM_IMAGE_READER__
       
   141