imgtools/romtools/rofsbuild/r_rofs.h
changeset 0 044383f39525
child 590 360bd6b35136
equal deleted inserted replaced
-1:000000000000 0:044383f39525
       
     1 /*
       
     2 * Copyright (c) 1995-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 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef __R_ROFS_H__
       
    20 #define __R_ROFS_H__
       
    21 
       
    22 #include <e32rom.h>
       
    23 
       
    24 #if defined(__MSVCDOTNET__) || defined(__TOOLS2__)
       
    25 #include <fstream>
       
    26 #else //!__MSVCDOTNET__
       
    27 #include <fstream.h>
       
    28 #endif //__MSVCDOTNET__
       
    29 
       
    30 #include "h_utl.h"
       
    31 #include "r_coreimage.h"
       
    32 #include <boost/thread/thread.hpp>
       
    33 #include <boost/thread/condition.hpp>
       
    34 #include <queue>
       
    35 
       
    36 #define DEFAULT_LOG_LEVEL 0x0
       
    37 #define LOG_LEVEL_FILE_DETAILS	0x00000001       // Destination file name (loglevel1)
       
    38 #define LOG_LEVEL_FILE_ATTRIBUTES 0x00000002     // File attributes (loglevel2)
       
    39 
       
    40 
       
    41 class CObeyFile;
       
    42 class MRofsImage;
       
    43 class Memmap;
       
    44 
       
    45 struct TPlacingSection {
       
    46     TUint8* buf;
       
    47     TInt len;
       
    48     TRomNode* node;
       
    49     TPlacingSection(TRomNode* anode){
       
    50         node = anode;
       
    51         buf = NULL;
       
    52         len = 0;
       
    53     }
       
    54 };
       
    55 class E32Rofs : public MRofsImage
       
    56 	{
       
    57 public:
       
    58 	E32Rofs(CObeyFile *aObey);
       
    59 	virtual ~E32Rofs();
       
    60 	TInt Create();
       
    61 
       
    62 	TInt CreateExtension(MRofsImage* info);
       
    63 	TInt WriteImage( TInt aHeaderType );
       
    64 
       
    65 	TRomNode* CopyDirectory(TRomNode*& aLastExecutable);
       
    66 	TRomNode* RootDirectory();
       
    67 	void SetRootDirectory(TRomNode* aDir);
       
    68 	TText* RomFileName();
       
    69 	TInt Size();
       
    70 	void MakeAutomaticSize(TUint32 aSize);
       
    71 
       
    72         //Get a node to handle, if there is no more, NULL returns.
       
    73         //For alias node, it will be deferred to later phase to handle.
       
    74 	TPlacingSection* GetFileNode(bool &aDeferred);
       
    75         TPlacingSection* GetDeferredJob();
       
    76         void ArriveDeferPoint();
       
    77 	void DisplaySizes(TPrintType aWhere);
       
    78 private:
       
    79 	TInt PlaceFiles( TRomNode* aRootDir, TUint8* aDestBase, TUint aBaseOffset, TInt aCoreSize = 0 );
       
    80 	TInt LayoutDirectory( TRomNode* aRootDir, TUint aBaseOffset );
       
    81 	TInt PlaceDirectory( TRomNode* aRootDir, TUint8* aDest );
       
    82 	void LogExecutableAttributes(E32ImageHeaderV *aHdr);
       
    83 
       
    84 
       
    85 	void Write(ofstream &of, TInt aHeaderType);		// main ROM image
       
    86 	Memmap* iImageMap;
       
    87 
       
    88 public:
       
    89 	char *iData;
       
    90 	TInt iSize;
       
    91 
       
    92 	TRofsHeader *iHeader;
       
    93 	TExtensionRofsHeader *iExtensionRofsHeader;	
       
    94 	//
       
    95 	CObeyFile *iObey;
       
    96 
       
    97 	//
       
    98 	TInt iSizeUsed;
       
    99 	TInt iOverhead;
       
   100 	TInt iDirectorySize;
       
   101 
       
   102 	TInt iTotalDirectoryBlockSize;
       
   103 	TInt iTotalFileBlockSize;
       
   104 	//
       
   105 
       
   106 private:
       
   107 	TRomNode *iLastNode;
       
   108         int iWorkerArrived;
       
   109         boost::mutex iMuxTree;
       
   110         std::vector<TPlacingSection*> iVPS;
       
   111         std::queue<TPlacingSection*> iQueueAliasNode;
       
   112 };
       
   113 
       
   114 
       
   115 class TRofsDirStructure
       
   116 	{
       
   117 	public:
       
   118 		TRofsDirStructure( TRomEntry* aRootDirectory );
       
   119 
       
   120 		TInt CalculateDirectorySize();
       
   121 
       
   122 	private:
       
   123 		TRomEntry* iRootDirectory;
       
   124 	};
       
   125 #endif