imgtools/romtools/rombuild/r_areaset.cpp
changeset 590 360bd6b35136
parent 0 044383f39525
child 617 3a747a240983
equal deleted inserted replaced
588:c7c26511138f 590:360bd6b35136
    20 #include "r_areaset.h"
    20 #include "r_areaset.h"
    21 #include "r_global.h"
    21 #include "r_global.h"
    22 #include "r_rom.h"
    22 #include "r_rom.h"
    23 
    23 
    24 extern TBool gGenDepGraph;
    24 extern TBool gGenDepGraph;
    25 extern char* gDepInfoFile;
    25 extern string gDepInfoFile;
    26 
    26 
    27 using namespace std;
    27 using namespace std;
    28 
    28 
    29 ////////////////////////////////////////////////////////////////////////
    29 ////////////////////////////////////////////////////////////////////////
    30 
    30 
    31 Area::Area(const char* aName, TLinAddr aDestBaseAddr, TUint aMaxSize, Area* aNext)
    31 Area::Area(const char* aName, TLinAddr aDestBaseAddr, TUint aMaxSize, Area* aNext)
    32 	: iFirstPagedCode(0),
    32 : iFirstPagedCode(0),
    33 	  iName(strdup(aName)),
    33 iName(0),
    34 	  iDestBaseAddr(aDestBaseAddr),
    34 iDestBaseAddr(aDestBaseAddr),
    35 	  iSrcBaseAddr(0),
    35 iSrcBaseAddr(0),
    36 	  iSrcLimitAddr(0),
    36 iSrcLimitAddr(0),
    37 	  iMaxSize(aMaxSize),
    37 iMaxSize(aMaxSize),
    38 	  iIsDefault(strcmp(aName, AreaSet::KDefaultAreaName) == 0),
    38 iIsDefault(strcmp(aName, AreaSet::KDefaultAreaName) == 0),
    39 	  iFiles(0),
    39 iFiles(0),
    40 	  iNextFilePtrPtr(&iFiles),
    40 iNextFilePtrPtr(&iFiles),
    41 	  iNextArea(aNext)
    41 iNextArea(aNext)	   
    42 	  
    42 {
    43 	{
    43 	size_t len = strlen(aName) + 1;
    44 	}
    44 	iName = new char[len];
    45 
    45 	memcpy(iName,aName,len);
    46 
    46 
    47 Area::~Area()
    47 }
    48 	{
    48 
       
    49 
       
    50 Area::~Area() {
    49 	ReleaseAllFiles();
    51 	ReleaseAllFiles();
    50 	free(const_cast<char*>(iName));	// allocated with strdup()
    52 	if(iName)
    51 	}
    53 		delete []iName;
       
    54 }
    52 
    55 
    53 
    56 
    54 /**
    57 /**
    55  Increase the size of the area.
    58 Increase the size of the area.
    56 
    59 
    57  The reallocation must not exceed the area maximum size.
    60 The reallocation must not exceed the area maximum size.
    58 
    61 
    59  @param aSrcLimitAddr New source top address
    62 @param aSrcLimitAddr New source top address
    60 
    63 
    61  @param aOverflow Number of overflow bytes if failure.
    64 @param aOverflow Number of overflow bytes if failure.
    62 
    65 
    63  @return success indication
    66 @return success indication
    64 */
    67 */
    65 
    68 
    66 TBool Area::ExtendSrcLimitAddr(TLinAddr aSrcLimitAddr, TUint& aOverflow)
    69 TBool Area::ExtendSrcLimitAddr(TLinAddr aSrcLimitAddr, TUint& aOverflow) {
    67 	{
       
    68 	// must have been set before
    70 	// must have been set before
    69 	assert(iSrcBaseAddr != 0);
    71 	assert(iSrcBaseAddr != 0);
    70 	// can only allocate more
    72 	// can only allocate more
    71 	assert(aSrcLimitAddr > iSrcBaseAddr);
    73 	assert(aSrcLimitAddr > iSrcBaseAddr);
    72 
    74 
    73 	if (aSrcLimitAddr-iSrcBaseAddr > iMaxSize)
    75 	if (aSrcLimitAddr-iSrcBaseAddr > iMaxSize) {
    74 		{
       
    75 		aOverflow = aSrcLimitAddr-iSrcBaseAddr-iMaxSize;
    76 		aOverflow = aSrcLimitAddr-iSrcBaseAddr-iMaxSize;
    76 		return EFalse;
    77 		return EFalse;
    77 		}
    78 	}
    78 
    79 
    79 	iSrcLimitAddr = aSrcLimitAddr;
    80 	iSrcLimitAddr = aSrcLimitAddr;
    80 	return ETrue;
    81 	return ETrue;
    81 	}
    82 }
    82 
    83 
    83 
    84 
    84 /**
    85 /**
    85  Add a file at end of the list of files contained in this area.
    86 Add a file at end of the list of files contained in this area.
    86 
    87 
    87  @param aFile File to add.  Must be allocated on the heap.  Ownership
    88 @param aFile File to add.  Must be allocated on the heap.  Ownership
    88  is transfered from the caller to the callee.
    89 is transfered from the caller to the callee.
    89 */
    90 */
    90 
    91 
    91 void Area::AddFile(TRomBuilderEntry* aFile)
    92 void Area::AddFile(TRomBuilderEntry* aFile) {
    92 	{
       
    93 	assert(aFile != 0);
    93 	assert(aFile != 0);
    94 
    94 
    95 	*iNextFilePtrPtr = aFile;
    95 	*iNextFilePtrPtr = aFile; 
    96 	iNextFilePtrPtr = &(aFile->iNextInArea);
    96 	iNextFilePtrPtr = &(aFile->iNextInArea);
    97 	}
    97 }
    98 
    98 
    99 
    99 
   100 void Area::ReleaseAllFiles()
   100 void Area::ReleaseAllFiles() {
   101 	{
       
   102 	for (TRomBuilderEntry *next = 0, *current = iFiles;
   101 	for (TRomBuilderEntry *next = 0, *current = iFiles;
   103 		 current != 0;
   102 		current != 0;
   104 		 current = next)
   103 		current = next) {
   105 		{
   104 		next = current->iNextInArea; 
   106 		next = current->iNextInArea;
       
   107 		delete current;
   105 		delete current;
   108 		}
   106 	}
   109 
   107 
   110 	iFiles = 0;
   108 	iFiles = 0;
   111 	iNextFilePtrPtr = &iFiles;
   109 	iNextFilePtrPtr = &iFiles;
   112 	}
   110 }
   113 
   111 
   114 ////////////////////////////////////////////////////////////////////////
   112 ////////////////////////////////////////////////////////////////////////
   115 
   113 
   116 void FilesInAreaIterator::GoToNext()
   114 void FilesInAreaIterator::GoToNext() {
   117 	{
       
   118 	assert(iCurrentFile!=0);
   115 	assert(iCurrentFile!=0);
   119 	iCurrentFile = iCurrentFile->iNextInArea;
   116 	iCurrentFile = iCurrentFile->iNextInArea;
   120 	}
   117 }
   121 
   118 
   122 ////////////////////////////////////////////////////////////////////////
   119 ////////////////////////////////////////////////////////////////////////
   123 
   120 
   124 const char AreaSet::KDefaultAreaName[] = "DEFAULT AREA";
   121 const char AreaSet::KDefaultAreaName[] = "DEFAULT AREA";
   125 
   122 
   126 AreaSet::AreaSet()
   123 AreaSet::AreaSet()
   127 	: iNonDefaultAreas(0),
   124 : iNonDefaultAreas(0),
   128 	  iDefaultArea(0),
   125 iDefaultArea(0),
   129 	  iAreaCount(0)
   126 iAreaCount(0) {
   130 	{
   127 }
   131 	}
   128 
   132 
   129 
   133 
   130 AreaSet::~AreaSet() {
   134 AreaSet::~AreaSet()
       
   135 	{
       
   136 	ReleaseAllAreas();
   131 	ReleaseAllAreas();
   137 	}
   132 }
   138 
   133 
   139 
   134 
   140 inline TBool IsInRange(TLinAddr aAddr, TLinAddr aDestBaseAddr, TLinAddr aEndAddr)
   135 inline TBool IsInRange(TLinAddr aAddr, TLinAddr aDestBaseAddr, TLinAddr aEndAddr) {
   141 	{
       
   142 	return aDestBaseAddr <= aAddr && aAddr <= aEndAddr;
   136 	return aDestBaseAddr <= aAddr && aAddr <= aEndAddr;
   143 	}
   137 }
   144 
   138 
   145 
   139 
   146 /**
   140 /**
   147  Add a new area.
   141 Add a new area.
   148 
   142 
   149  Areas must have unique name, not overlap one another and not overflow
   143 Areas must have unique name, not overlap one another and not overflow
   150  the 32-bit address range.  
   144 the 32-bit address range.  
   151 
   145 
   152  @param aOverlappingArea On return ptr to name of overlapping area if
   146 @param aOverlappingArea On return ptr to name of overlapping area if
   153  any, 0 otherwise.
   147 any, 0 otherwise.
   154 
   148 
   155  @return EAdded if success, an error code otherwise.  
   149 @return EAdded if success, an error code otherwise.  
   156 */
   150 */
   157 
   151 
   158 AreaSet::TAddResult AreaSet::AddArea(const char* aNewName,
   152 AreaSet::TAddResult AreaSet::AddArea(const char* aNewName,
   159 									 TLinAddr aNewDestBaseAddr,
   153 									 TLinAddr aNewDestBaseAddr,
   160 									 TUint aNewMaxSize,
   154 									 TUint aNewMaxSize,
   161 									 const char*& aOverlappingArea)
   155 									 const char*& aOverlappingArea) {
   162 	{
       
   163 	assert(aNewName != 0 && strlen(aNewName) > 0);
   156 	assert(aNewName != 0 && strlen(aNewName) > 0);
   164 	assert(aNewMaxSize > 0);
   157 	assert(aNewMaxSize > 0);
   165 
   158 
   166 	aOverlappingArea = 0;
   159 	aOverlappingArea = 0;
   167 
   160 
   174 
   167 
   175 	TLinAddr newEndAddr = aNewDestBaseAddr+aNewMaxSize-1;
   168 	TLinAddr newEndAddr = aNewDestBaseAddr+aNewMaxSize-1;
   176 
   169 
   177 	// iterate non default areas first, then the default one if any
   170 	// iterate non default areas first, then the default one if any
   178 	Area* area=iNonDefaultAreas; 
   171 	Area* area=iNonDefaultAreas; 
   179 	while (area != 0)
   172 	while (area != 0) {
   180 		{
       
   181 		if (strcmp(area->Name(), aNewName) == 0)
   173 		if (strcmp(area->Name(), aNewName) == 0)
   182 			return EDuplicateName;
   174 			return EDuplicateName;
   183 
   175 
   184 		TLinAddr curDestBaseAddr = area->DestBaseAddr();
   176 		TLinAddr curDestBaseAddr = area->DestBaseAddr();
   185 		TLinAddr curEndAddr = area->DestBaseAddr()+area->MaxSize()-1;
   177 		TLinAddr curEndAddr = area->DestBaseAddr()+area->MaxSize()-1;
   186 
   178 
   187 		if (IsInRange(newEndAddr, curDestBaseAddr, curEndAddr) ||
   179 		if (IsInRange(newEndAddr, curDestBaseAddr, curEndAddr) ||
   188 			IsInRange(aNewDestBaseAddr, curDestBaseAddr, curEndAddr) ||
   180 			IsInRange(aNewDestBaseAddr, curDestBaseAddr, curEndAddr) ||
   189 			IsInRange(curDestBaseAddr, aNewDestBaseAddr, newEndAddr))
   181 			IsInRange(curDestBaseAddr, aNewDestBaseAddr, newEndAddr)) {
   190 			{
       
   191 			aOverlappingArea = area->Name();
   182 			aOverlappingArea = area->Name();
   192 			return EOverlap;
   183 			return EOverlap;
   193 			}
   184 		}
   194 
   185 
   195 		if (area->iNextArea == 0 && area != iDefaultArea)
   186 		if (area->iNextArea == 0 && area != iDefaultArea)
   196 			area = iDefaultArea;
   187 			area = iDefaultArea;
   197 		else
   188 		else
   198 			area = area->iNextArea;
   189 			area = area->iNextArea;
   199 		}
   190 	}
   200 	
   191 
   201 	//
   192 	//
   202 	// Adding new area
   193 	// Adding new area
   203 	//
   194 	//
   204 
   195 
   205 	if (strcmp(KDefaultAreaName, aNewName) == 0)
   196 	if (strcmp(KDefaultAreaName, aNewName) == 0)
   207 	else
   198 	else
   208 		iNonDefaultAreas = new Area(aNewName, aNewDestBaseAddr, aNewMaxSize, iNonDefaultAreas);
   199 		iNonDefaultAreas = new Area(aNewName, aNewDestBaseAddr, aNewMaxSize, iNonDefaultAreas);
   209 	++iAreaCount;
   200 	++iAreaCount;
   210 
   201 
   211 	return EAdded;
   202 	return EAdded;
   212 	}
   203 }
   213 
   204 
   214 
   205 
   215 /**
   206 /**
   216  Remove every area added to the set.
   207 Remove every area added to the set.
   217 
   208 
   218  As a side-effect every file added to the areas is deleted.
   209 As a side-effect every file added to the areas is deleted.
   219 */
   210 */
   220 
   211 
   221 void AreaSet::ReleaseAllAreas()
   212 void AreaSet::ReleaseAllAreas() {
   222 	{
   213 	for (Area *next = 0, *current = iNonDefaultAreas; current != 0; current = next) {
   223 	for (Area *next = 0, *current = iNonDefaultAreas; current != 0; current = next)
       
   224 		{
       
   225 		next = current->iNextArea;
   214 		next = current->iNextArea;
   226 		delete current;
   215 		delete current;
   227 		}
   216 	}
   228 
   217 
   229 	iNonDefaultAreas = 0;
   218 	iNonDefaultAreas = 0;
   230 
   219 	if(iDefaultArea){
   231 	delete iDefaultArea;
   220 		delete iDefaultArea;
   232 	iDefaultArea = 0;
   221 		iDefaultArea = 0;
   233 	}
   222 	}
       
   223 }
   234 
   224 
   235 
   225 
   236 /**
   226 /**
   237  Find an area from its name.
   227 Find an area from its name.
   238 
   228 
   239  @return A pointer to the area or 0 if the name is unknown.  The
   229 @return A pointer to the area or 0 if the name is unknown.  The
   240  returned pointer becomes invalid when "this" is destructed.
   230 returned pointer becomes invalid when "this" is destructed.
   241 */
   231 */
   242 
   232 
   243 Area* AreaSet::FindByName(const char* aName) const
   233 Area* AreaSet::FindByName(const char* aName) const {
   244 	{
       
   245 	assert(aName != 0 && strlen(aName) > 0);
   234 	assert(aName != 0 && strlen(aName) > 0);
   246 
   235 
   247 	if (iDefaultArea && strcmp(iDefaultArea->Name(), aName) == 0)
   236 	if (iDefaultArea && strcmp(iDefaultArea->Name(), aName) == 0)
   248 		return iDefaultArea;
   237 		return iDefaultArea;
   249 
   238 
   250 	for (Area* area=iNonDefaultAreas; area != 0; area = area->iNextArea)
   239 	for (Area* area=iNonDefaultAreas; area != 0; area = area->iNextArea) {
   251 		{
       
   252 		if (strcmp(area->Name(), aName) == 0)
   240 		if (strcmp(area->Name(), aName) == 0)
   253 			return area;
   241 			return area;
   254 		}
   242 	}
   255 
   243 
   256 	return 0;
   244 	return 0;
   257 	}
   245 }
   258 
   246 
   259 
   247 
   260 ////////////////////////////////////////////////////////////////////////
   248 ////////////////////////////////////////////////////////////////////////
   261 
   249 
   262 void NonDefaultAreasIterator::GoToNext()
   250 void NonDefaultAreasIterator::GoToNext() {
   263 	{
       
   264 	assert(iCurrentArea!=0);
   251 	assert(iCurrentArea!=0);
   265 	iCurrentArea = iCurrentArea->iNextArea;
   252 	iCurrentArea = iCurrentArea->iNextArea;
   266 	}
   253 }
   267 
   254 
   268 TInt Area::SortFilesForPagedRom()
   255 TInt Area::SortFilesForPagedRom() {
   269 	{
       
   270 	Print(ELog,"Sorting files to paged/unpaged.\n");
   256 	Print(ELog,"Sorting files to paged/unpaged.\n");
   271 	TRomBuilderEntry* extention[2] = {0,0};
   257 	TRomBuilderEntry* extention[2] = {0,0};
   272 	TRomBuilderEntry* unpaged[2] = {0,0};
   258 	TRomBuilderEntry* unpaged[2] = {0,0};
   273 	TRomBuilderEntry* normal[2] = {0,0};
   259 	TRomBuilderEntry* normal[2] = {0,0};
   274 	TRomBuilderEntry* current = iFiles;
   260 	TRomBuilderEntry* current = iFiles;
   275 	while(current)
   261 	while(current) {
   276 		{
       
   277 		TRomBuilderEntry** list;
   262 		TRomBuilderEntry** list;
   278 		if((current->iRomImageFlags & (KRomImageFlagPrimary|KRomImageFlagVariant|KRomImageFlagExtension|KRomImageFlagDevice)) ||
   263 		if((current->iRomImageFlags & (KRomImageFlagPrimary|KRomImageFlagVariant|KRomImageFlagExtension|KRomImageFlagDevice)) ||
   279 			current->HCRDataFile())
   264 			current->HCRDataFile())
   280 			list = extention;
   265 			list = extention;
   281 		else if(current->iRomImageFlags&(KRomImageFlagCodeUnpaged))
   266 		else if(current->iRomImageFlags&(KRomImageFlagCodeUnpaged))
   283 		else if(current->iResource && (current->iOverrideFlags&KOverrideCodeUnpaged) && gPagedRom)
   268 		else if(current->iResource && (current->iOverrideFlags&KOverrideCodeUnpaged) && gPagedRom)
   284 			list = unpaged;
   269 			list = unpaged;
   285 		else
   270 		else
   286 			list = normal;
   271 			list = normal;
   287 
   272 
   288 		if(list!=normal)
   273 		if(list!=normal) {
   289 			{
       
   290 			Print(ELog, "Unpaged file %s\n",current->iRomNode->BareName());
   274 			Print(ELog, "Unpaged file %s\n",current->iRomNode->BareName());
   291 			}
   275 		}
   292 
   276 
   293 		if(!list[0])
   277 		if(!list[0])
   294 			list[0] = current;
   278 			list[0] = current;
   295 		else
   279 		else
   296 			list[1]->iNextInArea = current;
   280 			list[1]->iNextInArea = current;
   297 		list[1] = current;
   281 		list[1] = current;
   298 
   282 
   299 		current = current->iNext;
   283 		current = current->iNext;
   300 		}
   284 	}
   301 
   285 
   302 	if(extention[1])
   286 	if(extention[1]) {
   303 		{
   287 		if(unpaged[0]) {
   304 		if(unpaged[0])
       
   305 			{
       
   306 			extention[1]->iNextInArea = unpaged[0];
   288 			extention[1]->iNextInArea = unpaged[0];
   307 			unpaged[1]->iNextInArea = normal[0];
   289 			unpaged[1]->iNextInArea = normal[0];
   308 			}
   290 		}
   309 		else
   291 		else
   310 			extention[1]->iNextInArea = normal[0];
   292 			extention[1]->iNextInArea = normal[0];
   311 
   293 
   312 		if (normal[1])
   294 		if (normal[1])
   313 			normal[1]->iNextInArea = 0;
   295 			normal[1]->iNextInArea = 0;
   314 
   296 
   315 		iFiles = extention[0];
   297 		iFiles = extention[0];
   316 		}
   298 	}
   317 	else{
   299 	else{
   318 		Print(EError,"No primary files.\n");
   300 		Print(EError,"No primary files.\n");
   319 		return KErrGeneral;
   301 		return KErrGeneral;
   320 	}
   302 	}
   321 
   303 
   322 	iFirstPagedCode = normal[0];
   304 	iFirstPagedCode = normal[0];
   323 	Print(ELog,"\n");
   305 	Print(ELog,"\n");
   324 	if(gGenDepGraph)
   306 	if(gGenDepGraph)
   325 		WriteDependenceGraph();
   307 		WriteDependenceGraph();
   326 	return KErrNone;
   308 	return KErrNone;
   327 	}
   309 }
   328 
   310 
   329 
   311 
   330 void Area::WriteDependenceGraph()
   312 void Area::WriteDependenceGraph() {
   331 {
       
   332 	TDepInfoList::iterator infoIt;
   313 	TDepInfoList::iterator infoIt;
   333 	TStringList::iterator strIt;
   314 	TStringList::iterator strIt;
   334 	TDepInfoList myDepInfoList;
   315 	TDepInfoList myDepInfoList;
   335 	TRomBuilderEntry* e = iFirstPagedCode;
   316 	TRomBuilderEntry* e = iFirstPagedCode;
   336 	char buffer[255];
   317 	char buffer[255];
   337 	TInt count = 0;
   318 	TInt count = 0;
   338 	TStringList nameList;
   319 	TStringList nameList;
   339 	while(e)
   320 	while(e) {
   340 	{
       
   341 		DepInfo tmpDepInfo;
   321 		DepInfo tmpDepInfo;
   342 		TRomNode* rn = e->iRomNode;
   322 		TRomNode* rn = e->iRomNode;
   343 		TInt ll = rn->FullNameLength();
   323 		TInt ll = rn->FullNameLength();
   344 		char* mm = (char*) malloc(ll+1);
   324 		char* mm = new char[ll+1];
   345 		rn->GetFullName(mm);
   325 		rn->GetFullName(mm);
   346 		sprintf(buffer, "f%d", count);
   326 		sprintf(buffer, "f%d", count);
   347 		tmpDepInfo.portName = buffer;
   327 		tmpDepInfo.portName = buffer;
   348 		tmpDepInfo.index = count;
   328 		tmpDepInfo.index = count;
   349 		myDepInfoList[mm] = tmpDepInfo;
   329 		myDepInfoList[mm] = tmpDepInfo;
   350 		nameList.push_back(mm);
   330 		nameList.push_back(mm);
   351 		free(mm);
   331 		delete []mm;
   352 		e = e->iNextInArea;
   332 		e = e->iNextInArea;
   353 		count++;
   333 		count++;
   354 	}
   334 	}
   355 	e = iFirstPagedCode;
   335 	e = iFirstPagedCode;
   356 	count = 0;
   336 	count = 0;
   357 	while(e)
   337 	while(e) {
   358 	{
       
   359 		TRomNode* rn = e->iRomNode;
   338 		TRomNode* rn = e->iRomNode;
   360 		TRomFile* rf = rn->iRomFile;
   339 		TRomFile* rf = rn->iRomFile;
   361 		TInt j;
   340 		TInt j;
   362 		TStringList depFiles;
   341 		TStringList depFiles;
   363 		for(j=0; j < rf->iNumDeps; ++j)
   342 		for(j=0; j < rf->iNumDeps; ++j) {
   364 		{
       
   365 			TRomFile* f=rf->iDeps[j];
   343 			TRomFile* f=rf->iDeps[j];
   366 			TRomBuilderEntry* start = iFiles;
   344 			TRomBuilderEntry* start = iFiles;
   367 			while(start && start->iRomNode->iRomFile != f)
   345 			while(start && start->iRomNode->iRomFile != f)
   368 				start = start->iNextInArea;
   346 				start = start->iNextInArea;
   369 			if(start && (start->iRomNode->iRomFile == f))
   347 			if(start && (start->iRomNode->iRomFile == f)) {
   370 			{
       
   371 				TRomNode* target = start->iRomNode;
   348 				TRomNode* target = start->iRomNode;
   372 				TInt l = target->FullNameLength();
   349 				TInt l = target->FullNameLength();
   373 				char* fname = (char *) malloc(l+1);
   350 				char* fname = new char[l+1];
   374 				target->GetFullName(fname);
   351 				target->GetFullName(fname);
   375 				if(myDepInfoList.find(fname) != myDepInfoList.end())
   352 				if(myDepInfoList.find(fname) != myDepInfoList.end()) {
   376 				{
       
   377 					depFiles.push_back(fname);
   353 					depFiles.push_back(fname);
   378 					myDepInfoList[fname].beenDepended = ETrue;
   354 					myDepInfoList[fname].beenDepended = ETrue;
   379 				}
   355 				}
   380 				free(fname);
   356 				delete []fname;
   381 			}
   357 			}
   382 		}
   358 		}
   383 		if(depFiles.size() > 0)
   359 		if(depFiles.size() > 0) {
   384 		{
       
   385 			myDepInfoList[nameList[count]].depFilesList=depFiles;
   360 			myDepInfoList[nameList[count]].depFilesList=depFiles;
   386 			myDepInfoList[nameList[count]].dependOthers = ETrue;
   361 			myDepInfoList[nameList[count]].dependOthers = ETrue;
   387 		}
   362 		}
   388 		count++;
   363 		count++;
   389 		e=e->iNextInArea;
   364 		e=e->iNextInArea;
   390 	}
   365 	}
   391 	ofstream os;
   366 	ofstream os;
   392 	string filename(gDepInfoFile, strlen(gDepInfoFile) - 3);
   367 	string filename(gDepInfoFile.c_str(), gDepInfoFile.length() - 3);
   393 	filename = filename + "dot";
   368 	filename = filename + "dot";
   394 	os.open(filename.c_str());
   369 	os.open(filename.c_str());
   395 	os << "digraph ROM {\n";
   370 	os << "digraph ROM {\n";
   396 	os << "rankdir = LR;\n";
   371 	os << "rankdir = LR;\n";
   397 	os << "fontsize = 10;\n";
   372 	os << "fontsize = 10;\n";
   399 	os << "label = \"ROM DEPENDENCE GRAPH DOT FILE\";\n";
   374 	os << "label = \"ROM DEPENDENCE GRAPH DOT FILE\";\n";
   400 	os << "node[shape = plaintext];\n";
   375 	os << "node[shape = plaintext];\n";
   401 	os << "dependence[label=<<FONT FACE=\"Courier new\" POINT-SIZE=\"10pt\">\n";
   376 	os << "dependence[label=<<FONT FACE=\"Courier new\" POINT-SIZE=\"10pt\">\n";
   402 	os << "<TABLE BORDER=\"0\" CELLBORDER=\"1\" CELLSPACING=\"0\">\n";
   377 	os << "<TABLE BORDER=\"0\" CELLBORDER=\"1\" CELLSPACING=\"0\">\n";
   403 	//for(infoIt = myDepInfoList.begin(); infoIt != myDepInfoList.end(); infoIt++)
   378 	//for(infoIt = myDepInfoList.begin(); infoIt != myDepInfoList.end(); infoIt++)
   404 	for(strIt = nameList.begin(); strIt != nameList.end(); strIt++)
   379 	for(strIt = nameList.begin(); strIt != nameList.end(); strIt++) {
   405 	{
       
   406 		string tmp = *strIt;
   380 		string tmp = *strIt;
   407 		string::iterator charIt;
   381 		string::iterator charIt;
   408 		for(charIt=tmp.begin(); charIt != tmp.end(); charIt++)
   382 		for(charIt=tmp.begin(); charIt != tmp.end(); charIt++) {
   409 		{
       
   410 			if(*charIt == '\\')
   383 			if(*charIt == '\\')
   411 				*charIt = '/';
   384 				*charIt = '/';
   412 		}
   385 		}
   413 		if(myDepInfoList[*strIt].beenDepended && myDepInfoList[*strIt].dependOthers)
   386 		if(myDepInfoList[*strIt].beenDepended && myDepInfoList[*strIt].dependOthers) {
   414 		{
       
   415 			os << "\t<TR><TD PORT=\"" << myDepInfoList[*strIt].portName << "\" ALIGN=\"LEFT\" BGCOLOR=\"yellow\">\n";
   387 			os << "\t<TR><TD PORT=\"" << myDepInfoList[*strIt].portName << "\" ALIGN=\"LEFT\" BGCOLOR=\"yellow\">\n";
   416 			os << "\t<FONT COLOR=\"red\">" << tmp << "</FONT>\n";
   388 			os << "\t<FONT COLOR=\"red\">" << tmp << "</FONT>\n";
   417 			os << "\t</TD></TR>\n";
   389 			os << "\t</TD></TR>\n";
   418 		}
   390 		}
   419 		else if(myDepInfoList[*strIt].beenDepended)
   391 		else if(myDepInfoList[*strIt].beenDepended) {
   420 		{
       
   421 			os << "\t<TR><TD PORT=\"" << myDepInfoList[*strIt].portName << "\" ALIGN=\"LEFT\" BGCOLOR=\"gray\">\n";
   392 			os << "\t<TR><TD PORT=\"" << myDepInfoList[*strIt].portName << "\" ALIGN=\"LEFT\" BGCOLOR=\"gray\">\n";
   422 			os << "\t<FONT COLOR=\"red\">" << tmp << "</FONT>\n";
   393 			os << "\t<FONT COLOR=\"red\">" << tmp << "</FONT>\n";
   423 			os << "\t</TD></TR>\n";
   394 			os << "\t</TD></TR>\n";
   424 		}
   395 		}
   425 		else if(myDepInfoList[*strIt].dependOthers)
   396 		else if(myDepInfoList[*strIt].dependOthers) {
   426 		{
       
   427 			os << "\t<TR><TD PORT=\"" << myDepInfoList[*strIt].portName << "\" ALIGN=\"LEFT\" BGCOLOR=\"cyan\">\n";
   397 			os << "\t<TR><TD PORT=\"" << myDepInfoList[*strIt].portName << "\" ALIGN=\"LEFT\" BGCOLOR=\"cyan\">\n";
   428 			os << "\t<FONT COLOR=\"blue\">" << tmp << "</FONT>\n";
   398 			os << "\t<FONT COLOR=\"blue\">" << tmp << "</FONT>\n";
   429 			os << "\t</TD></TR>\n";
   399 			os << "\t</TD></TR>\n";
   430 		}
   400 		}
   431 		else
   401 		else {
   432 		{
       
   433 			os << "\t<TR><TD PORT=\"" << myDepInfoList[*strIt].portName << "\" ALIGN=\"LEFT\">";
   402 			os << "\t<TR><TD PORT=\"" << myDepInfoList[*strIt].portName << "\" ALIGN=\"LEFT\">";
   434 			os << tmp;
   403 			os << tmp;
   435 			os << "</TD></TR>\n";
   404 			os << "</TD></TR>\n";
   436 		}
   405 		}
   437 	}
   406 	}
   438 	os << "</TABLE>\n";
   407 	os << "</TABLE>\n";
   439 	os << "</FONT>>]\n";
   408 	os << "</FONT>>]\n";
   440 	TBool lastEdge = ETrue;
   409 	TBool lastEdge = ETrue;
   441 	TBool first = ETrue;
   410 	TBool first = ETrue;
   442 	for(infoIt = myDepInfoList.begin(); infoIt != myDepInfoList.end(); infoIt++)
   411 	for(infoIt = myDepInfoList.begin(); infoIt != myDepInfoList.end(); infoIt++) {
   443 	{
   412 		if(!infoIt->second.dependOthers) {
   444 		if(!infoIt->second.dependOthers)
       
   445 		{
       
   446 			continue;
   413 			continue;
   447 		}
   414 		}
   448 		for(strIt = infoIt->second.depFilesList.begin(); strIt != infoIt->second.depFilesList.end(); strIt++)
   415 		for(strIt = infoIt->second.depFilesList.begin(); strIt != infoIt->second.depFilesList.end(); strIt++) {
   449 		{
       
   450 			TBool tmpEdge = ETrue;
   416 			TBool tmpEdge = ETrue;
   451 			if(infoIt->second.index < myDepInfoList[*strIt].index)
   417 			if(infoIt->second.index < myDepInfoList[*strIt].index)
   452 			{	
   418 			{	
   453 				tmpEdge = EFalse;
   419 				tmpEdge = EFalse;
   454 			}
   420 			}
   455 			if(first)
   421 			if(first) {
   456 			{
       
   457 				lastEdge = tmpEdge;
   422 				lastEdge = tmpEdge;
   458 				first = EFalse;
   423 				first = EFalse;
   459 				if(lastEdge)
   424 				if(lastEdge) {
   460 				{
       
   461 					os << "edge[color=forestgreen];\n";
   425 					os << "edge[color=forestgreen];\n";
   462 				}
   426 				}
   463 				else
   427 				else {
   464 				{
       
   465 					os << "edge[color=red];\n";
   428 					os << "edge[color=red];\n";
   466 				}
   429 				}
   467 			}
   430 			}
   468 			else
   431 			else {
   469 			{
   432 				if(lastEdge != tmpEdge) {
   470 				if(lastEdge != tmpEdge)
       
   471 				{
       
   472 					lastEdge = tmpEdge;
   433 					lastEdge = tmpEdge;
   473 					if(lastEdge)
   434 					if(lastEdge) {
   474 					{
       
   475 						os << "edge[color=forestgreen];\n";
   435 						os << "edge[color=forestgreen];\n";
   476 					}
   436 					}
   477 					else
   437 					else {
   478 					{
       
   479 						os << "edge[color=red];\n";
   438 						os << "edge[color=red];\n";
   480 					}
   439 					}
   481 				}
   440 				}
   482 			}
   441 			}
   483 			os << "dependence: " << infoIt->second.portName << " -> dependence: " << myDepInfoList[*strIt].portName << ";\n";
   442 			os << "dependence: " << infoIt->second.portName << " -> dependence: " << myDepInfoList[*strIt].portName << ";\n";
   495 	os << "label = \"ROM FORWARD DEPENDENCE GRAPH DOT FILE\";\n";
   454 	os << "label = \"ROM FORWARD DEPENDENCE GRAPH DOT FILE\";\n";
   496 	os << "node[shape = plaintext];\n";
   455 	os << "node[shape = plaintext];\n";
   497 	os << "dependence[label=<<FONT FACE=\"Courier new\" POINT-SIZE=\"10pt\">\n";
   456 	os << "dependence[label=<<FONT FACE=\"Courier new\" POINT-SIZE=\"10pt\">\n";
   498 	os << "<TABLE BORDER=\"0\" CELLBORDER=\"1\" CELLSPACING=\"0\">\n";
   457 	os << "<TABLE BORDER=\"0\" CELLBORDER=\"1\" CELLSPACING=\"0\">\n";
   499 	//for(infoIt = myDepInfoList.begin(); infoIt != myDepInfoList.end(); infoIt++)
   458 	//for(infoIt = myDepInfoList.begin(); infoIt != myDepInfoList.end(); infoIt++)
   500 	for(strIt = nameList.begin(); strIt != nameList.end(); strIt++)
   459 	for(strIt = nameList.begin(); strIt != nameList.end(); strIt++) {
   501 	{
       
   502 		string tmp = *strIt;
   460 		string tmp = *strIt;
   503 		string::iterator charIt;
   461 		string::iterator charIt;
   504 		for(charIt=tmp.begin(); charIt != tmp.end(); charIt++)
   462 		for(charIt=tmp.begin(); charIt != tmp.end(); charIt++) {
   505 		{
       
   506 			if(*charIt == '\\')
   463 			if(*charIt == '\\')
   507 				*charIt = '/';
   464 				*charIt = '/';
   508 		}
   465 		}
   509 		if(myDepInfoList[*strIt].beenDepended && myDepInfoList[*strIt].dependOthers)
   466 		if(myDepInfoList[*strIt].beenDepended && myDepInfoList[*strIt].dependOthers) {
   510 		{
       
   511 			os << "\t<TR><TD PORT=\"" << myDepInfoList[*strIt].portName << "\" ALIGN=\"LEFT\" BGCOLOR=\"yellow\">\n";
   467 			os << "\t<TR><TD PORT=\"" << myDepInfoList[*strIt].portName << "\" ALIGN=\"LEFT\" BGCOLOR=\"yellow\">\n";
   512 			os << "\t<FONT COLOR=\"red\">" << tmp << "</FONT>\n";
   468 			os << "\t<FONT COLOR=\"red\">" << tmp << "</FONT>\n";
   513 			os << "\t</TD></TR>\n";
   469 			os << "\t</TD></TR>\n";
   514 		}
   470 		}
   515 		else if(myDepInfoList[*strIt].beenDepended)
   471 		else if(myDepInfoList[*strIt].beenDepended) {
   516 		{
       
   517 			os << "\t<TR><TD PORT=\"" << myDepInfoList[*strIt].portName << "\" ALIGN=\"LEFT\" BGCOLOR=\"gray\">\n";
   472 			os << "\t<TR><TD PORT=\"" << myDepInfoList[*strIt].portName << "\" ALIGN=\"LEFT\" BGCOLOR=\"gray\">\n";
   518 			os << "\t<FONT COLOR=\"red\">" << tmp << "</FONT>\n";
   473 			os << "\t<FONT COLOR=\"red\">" << tmp << "</FONT>\n";
   519 			os << "\t</TD></TR>\n";
   474 			os << "\t</TD></TR>\n";
   520 		}
   475 		}
   521 		else if(myDepInfoList[*strIt].dependOthers)
   476 		else if(myDepInfoList[*strIt].dependOthers) {
   522 		{
       
   523 			os << "\t<TR><TD PORT=\"" << myDepInfoList[*strIt].portName << "\" ALIGN=\"LEFT\" BGCOLOR=\"cyan\">\n";
   477 			os << "\t<TR><TD PORT=\"" << myDepInfoList[*strIt].portName << "\" ALIGN=\"LEFT\" BGCOLOR=\"cyan\">\n";
   524 			os << "\t<FONT COLOR=\"blue\">" << tmp << "</FONT>\n";
   478 			os << "\t<FONT COLOR=\"blue\">" << tmp << "</FONT>\n";
   525 			os << "\t</TD></TR>\n";
   479 			os << "\t</TD></TR>\n";
   526 		}
   480 		}
   527 		else
   481 		else {
   528 		{
       
   529 			os << "\t<TR><TD PORT=\"" << myDepInfoList[*strIt].portName << "\" ALIGN=\"LEFT\">";
   482 			os << "\t<TR><TD PORT=\"" << myDepInfoList[*strIt].portName << "\" ALIGN=\"LEFT\">";
   530 			os << tmp;
   483 			os << tmp;
   531 			os << "</TD></TR>\n";
   484 			os << "</TD></TR>\n";
   532 		}
   485 		}
   533 	}
   486 	}
   534 	os << "</TABLE>\n";
   487 	os << "</TABLE>\n";
   535 	os << "</FONT>>]\n";
   488 	os << "</FONT>>]\n";
   536 	os << "edge[color=red];\n";
   489 	os << "edge[color=red];\n";
   537 	for(infoIt = myDepInfoList.begin(); infoIt != myDepInfoList.end(); infoIt++)
   490 	for(infoIt = myDepInfoList.begin(); infoIt != myDepInfoList.end(); infoIt++) {
   538 	{
   491 		if(!infoIt->second.dependOthers) {
   539 		if(!infoIt->second.dependOthers)
       
   540 		{
       
   541 			continue;
   492 			continue;
   542 		}
   493 		}
   543 		for(strIt = infoIt->second.depFilesList.begin(); strIt != infoIt->second.depFilesList.end(); strIt++)
   494 		for(strIt = infoIt->second.depFilesList.begin(); strIt != infoIt->second.depFilesList.end(); strIt++) {
   544 		{
       
   545 			if(infoIt->second.index < myDepInfoList[*strIt].index)
   495 			if(infoIt->second.index < myDepInfoList[*strIt].index)
   546 			{	
   496 			{	
   547 				os << "dependence: " << infoIt->second.portName << " -> dependence: " << myDepInfoList[*strIt].portName << ";\n";
   497 				os << "dependence: " << infoIt->second.portName << " -> dependence: " << myDepInfoList[*strIt].portName << ";\n";
   548 			}
   498 			}
   549 		}
   499 		}