imgtools/romtools/rofsbuild/r_rofs.cpp
changeset 708 0757c2976f96
parent 698 e3ee96a3961c
equal deleted inserted replaced
707:ccd52fece6ff 708:0757c2976f96
    30 #include "symbolgenerator.h"
    30 #include "symbolgenerator.h"
    31 extern TInt gLogLevel;
    31 extern TInt gLogLevel;
    32 extern TBool gLowMem;
    32 extern TBool gLowMem;
    33 extern TInt gThreadNum;
    33 extern TInt gThreadNum;
    34 extern TBool gGenSymbols;
    34 extern TBool gGenSymbols;
       
    35 extern TBool gGenBsymbols;
    35 ////////////////////////////////////////////////////////////////////////
    36 ////////////////////////////////////////////////////////////////////////
    36 
    37 
    37 
    38 
    38 
    39 
    39 inline TUint32 AlignData(TUint32 anAddr) {
    40 inline TUint32 AlignData(TUint32 anAddr) {
    47 //
    48 //
    48 // Constructor
    49 // Constructor
    49 //
    50 //
    50 	: iObey( aObey ), iOverhead(0)
    51 	: iObey( aObey ), iOverhead(0)
    51 	{
    52 	{
    52 	if(gGenSymbols)
    53 	if(gGenSymbols || gGenBsymbols) {
    53 		iSymGen = SymbolGenerator::GetInstance();
    54 		iSymGen = SymbolGenerator::GetInstance();
       
    55 		iSymGen->SetImageType(ERofsImage);
       
    56 	}
    54 	else
    57 	else
    55 		iSymGen = NULL;
    58 		iSymGen = NULL;
    56 
    59 
    57 	iSize=aObey->iRomSize;
    60 	iSize=aObey->iRomSize;
    58 	if(gLowMem) {
    61 	if(gLowMem) {
   261 	Print(ELog, "Vendor ID:               %08x\n", aHdr->iS.iVendorId);
   264 	Print(ELog, "Vendor ID:               %08x\n", aHdr->iS.iVendorId);
   262 	Print(ELog, "Priority:                %d\n\n", aHdr->iProcessPriority);
   265 	Print(ELog, "Priority:                %d\n\n", aHdr->iProcessPriority);
   263 }
   266 }
   264 class Worker : public boost::thread {
   267 class Worker : public boost::thread {
   265     public:
   268     public:
       
   269     static boost::mutex iMutexOut;
   266     static void thrd_func(E32Rofs* rofs){
   270     static void thrd_func(E32Rofs* rofs){
   267         CBytePair bpe;
   271         CBytePair bpe;
   268 
   272 
   269         bool deferred = false;
   273         bool deferred = false;
   270         TPlacingSection* p = rofs->GetFileNode(deferred);
   274         TPlacingSection* p = rofs->GetFileNode(deferred);
   271         while(p) {
   275         while(p) {
   272             if(!deferred) {
   276             if(!deferred) {
   273                 p->len = p->node->PlaceFile(p->buf, (TUint32)-1, 0, &bpe);
   277                 p->len = p->node->PlaceFile(p->buf, (TUint32)-1, 0, &bpe);
   274                 //no symbol for hidden file
   278                 //no symbol for hidden file
   275                 if(rofs->iSymGen && !p->node->iEntry->iHidden)
   279                 if(rofs->iSymGen && !p->node->iEntry->iHidden)
   276                     rofs->iSymGen->AddFile(p->node->iEntry->iFileName,(p->node->iEntry->iCompressEnabled|| p->node->iEntry->iExecutable));
   280 		{
       
   281 		    char* fullsystemname= p->node->iEntry->GetSystemFullName();
       
   282 		    TPlacedEntry tmpEntry(p->node->iEntry->iFileName, fullsystemname, (p->node->iEntry->iCompressEnabled|| p->node->iEntry->iExecutable));
       
   283 		    rofs->iSymGen->AddEntry(tmpEntry);
       
   284 		    delete[] fullsystemname; 
       
   285 		}
       
   286 		iMutexOut.lock();
       
   287 		p->node->FlushLogMessages();
       
   288 		iMutexOut.unlock();
   277             }
   289             }
   278             p = rofs->GetFileNode(deferred);
   290             p = rofs->GetFileNode(deferred);
   279         }
   291         }
   280         rofs->ArriveDeferPoint();
   292         rofs->ArriveDeferPoint();
   281         p = rofs->GetDeferredJob();
   293         p = rofs->GetDeferredJob();
   285         }
   297         }
   286     }
   298     }
   287     Worker(E32Rofs* rofs) : boost::thread(thrd_func,rofs) {
   299     Worker(E32Rofs* rofs) : boost::thread(thrd_func,rofs) {
   288     }
   300     }
   289 };
   301 };
       
   302 
       
   303 boost::mutex Worker::iMutexOut;
   290 
   304 
   291 TPlacingSection* E32Rofs::GetFileNode(bool &aDeferred) {
   305 TPlacingSection* E32Rofs::GetFileNode(bool &aDeferred) {
   292 	//get a node from the node list, the node list is protected by mutex iMuxTree.
   306 	//get a node from the node list, the node list is protected by mutex iMuxTree.
   293 	//The iMuxTree also helps to make sure the order in iVPS is consistent with the node list.
   307 	//The iMuxTree also helps to make sure the order in iVPS is consistent with the node list.
   294 	//And this is the guarantee of same outputs regardless of how many threads being used.
   308 	//And this is the guarantee of same outputs regardless of how many threads being used.