|
1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of the License "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #include <string.h> |
|
17 #include <stdlib.h> |
|
18 |
|
19 #include "h_utl.h" |
|
20 #include "h_ver.h" |
|
21 |
|
22 #include "r_global.h" |
|
23 #include "r_rom.h" |
|
24 #include "r_obey.h" |
|
25 #include "parameterfileprocessor.h" |
|
26 |
|
27 #include "r_dir.h" |
|
28 #include "r_coreimage.h" |
|
29 |
|
30 const TInt KRomLoaderHeaderNone=0; |
|
31 const TInt KRomLoaderHeaderEPOC=1; |
|
32 const TInt KRomLoaderHeaderCOFF=2; |
|
33 |
|
34 static const TInt RombuildMajorVersion=2; |
|
35 static const TInt RombuildMinorVersion=14; |
|
36 static const TInt RombuildPatchVersion=0; |
|
37 static TBool SizeSummary=EFalse; |
|
38 static TPrintType SizeWhere=EAlways; |
|
39 static char *CompareRom=NULL; |
|
40 static TInt MAXIMUM_THREADS = 128; |
|
41 static TInt DEFAULT_THREADS = 8; |
|
42 |
|
43 string filename; // to store oby filename passed to Rombuild. |
|
44 TBool reallyHelp=EFalse; |
|
45 TInt gCPUNum = 0; |
|
46 TInt gThreadNum = 0; |
|
47 char* g_pCharCPUNum = NULL; |
|
48 TBool gGenDepGraph = EFalse; |
|
49 char* gDepInfoFile = NULL; |
|
50 |
|
51 void PrintVersion() |
|
52 { |
|
53 Print(EAlways,"\nROMBUILD - Rom builder"); |
|
54 Print(EAlways, " V%d.%d.%d\n", RombuildMajorVersion, RombuildMinorVersion, RombuildPatchVersion); |
|
55 Print(EAlways,Copyright); |
|
56 } |
|
57 |
|
58 char HelpText[] = |
|
59 "Syntax: ROMBUILD [options] obeyfilename\n" |
|
60 "Option: -v verbose, -? \n" |
|
61 " -type-safe-link \n" |
|
62 " -s[log|screen|both] size summary\n" |
|
63 " -r<FileName> compare a sectioned Rom image\n" |
|
64 " -no-header suppress the image loader header\n" |
|
65 " -gendep generate the dependence graph for paged part\n" |
|
66 " -coff-header use a PE-COFF header rather than an EPOC header\n" |
|
67 " -d<bitmask> set trace mask (DEB build only)\n" |
|
68 " -compress[[=]paged|unpaged] compress the ROM Image\n" |
|
69 " without any argumentum compress both sections\n" |
|
70 " paged compress paged section only\n" |
|
71 " unpaged compress unpaged section only\n" |
|
72 " -fastcompress compress files with faster bytepair and tradeoff of compress ratio\n" |
|
73 " -j<digit> do the main job with <digit> threads\n" |
|
74 " -compressionmethod <method> method one of none|inflate|bytepair to set the compression\n" |
|
75 " -no-sorted-romfs do not add sorted entries arrays (6.1 compatible)\n" |
|
76 " -geninc to generate include file for licensee tools to use\n" // DEF095619 |
|
77 " -loglevel<level> level of information to log (valid levels are 0,1,2,3,4).\n" //Tools like Visual ROM builder need the host/ROM filenames, size & if the file is hidden. |
|
78 " -wstdpath warn if destination path provided for a file is not a standard path\n" |
|
79 " -argfile=<fileName> specify argument-file name containing list of command-line arguments to rombuild\n" |
|
80 " -lowmem use memory-mapped file for image build to reduce physical memory consumption\n" |
|
81 " -coreimage=<core image file> to pass the core image as input for extension ROM image generation\n"; |
|
82 |
|
83 |
|
84 char ReallyHelpText[] = |
|
85 "Priorities:\n" |
|
86 " low background foreground high windowserver\n" |
|
87 " fileserver realtimeserver supervisor\n" |
|
88 "Languages:\n" |
|
89 " Test English French German Spanish Italian Swedish Danish\n" |
|
90 " Norwegian Finnish American SwissFrench SwissGerman Portuguese\n" |
|
91 " Turkish Icelandic Russian Hungarian Dutch BelgianFlemish\n" |
|
92 " Australian BelgianFrench\n" |
|
93 "Compression methods:\n" |
|
94 " none no compression on the individual executable image.\n" |
|
95 " inflate compress the individual executable image.\n" |
|
96 " bytepair compress the individual executable image.\n" |
|
97 "Log Level:\n" |
|
98 " 0 produce the default logs\n" |
|
99 " 1 produce file detail logs in addition to the default logs\n" |
|
100 " 2 logs e32 header attributes(same as default log) in addition to the level 1 details\n"; |
|
101 |
|
102 void processParamfile(string aFileName); |
|
103 |
|
104 void processCommandLine(int argc, char *argv[], TBool paramFileFlag=EFalse) |
|
105 // |
|
106 // Process the command line arguments, printing a helpful message if none are supplied |
|
107 // |
|
108 { |
|
109 |
|
110 // If "-argfile" option is passed to Rombuild, then process the parameters |
|
111 // specified in parameter-file first and then the options passed from the |
|
112 // command-line. |
|
113 string ParamFileArg("-ARGFILE="); |
|
114 if(paramFileFlag == EFalse) |
|
115 { |
|
116 for (int count=1; count<argc; count++) |
|
117 { |
|
118 string paramFile; |
|
119 if (count < argc - 1) { |
|
120 strupr(argv[count]); |
|
121 } |
|
122 if(strncmp(argv[count],ParamFileArg.c_str(),ParamFileArg.length())==0) |
|
123 { |
|
124 paramFile.assign(&argv[count][ParamFileArg.length()]); |
|
125 processParamfile(paramFile); |
|
126 } |
|
127 } |
|
128 } |
|
129 |
|
130 for (int i=1; i<argc; i++) |
|
131 { |
|
132 if (i < argc - 1) { |
|
133 strupr(argv[i]); |
|
134 } |
|
135 if ((argv[i][0] == '-') || (argv[i][0] == '/')) |
|
136 { // switch |
|
137 if (argv[i][1] == 'V') |
|
138 H.iVerbose = ETrue; |
|
139 else if (argv[i][1] == 'S') |
|
140 { |
|
141 SizeSummary=ETrue; |
|
142 if (argv[i][2] == 'L') |
|
143 SizeWhere=ELog; |
|
144 if (argv[i][2] == 'S') |
|
145 SizeWhere=EScreen; |
|
146 } |
|
147 else if (strcmp(argv[i], "-FASTCOMPRESS")==0) |
|
148 gFastCompress = ETrue; |
|
149 else if (strcmp(argv[i], "-GENDEP")==0) |
|
150 gGenDepGraph = ETrue; |
|
151 else if (strncmp(argv[i], "-J", 2)==0) |
|
152 { |
|
153 if(argv[i][2]) |
|
154 gThreadNum = atoi(&argv[i][2]); |
|
155 else |
|
156 { |
|
157 Print(EWarning, "The option should be like '-j4'.\n"); |
|
158 gThreadNum = 0; |
|
159 } |
|
160 if(gThreadNum <= 0 || gThreadNum > MAXIMUM_THREADS) |
|
161 { |
|
162 if(gCPUNum > 0 && gCPUNum <= MAXIMUM_THREADS) |
|
163 { |
|
164 Print(EWarning, "The number of concurrent jobs set by -j should be between 1 and 128. And the number of processors %d will be used as the number of concurrent jobs.\n", gCPUNum); |
|
165 gThreadNum = gCPUNum; |
|
166 } |
|
167 else if(g_pCharCPUNum) |
|
168 { |
|
169 Print(EWarning, "The number of concurrent jobs set by -j should be between 1 and 128. And the NUMBER_OF_PROCESSORS is invalid, so the default value %d will be used.\n", DEFAULT_THREADS); |
|
170 gThreadNum = DEFAULT_THREADS; |
|
171 } |
|
172 else |
|
173 { |
|
174 Print(EWarning, "The number of concurrent jobs set by -j should be between 1 and 128. And the NUMBER_OF_PROCESSORS is not available, so the default value %d will be used.\n", DEFAULT_THREADS); |
|
175 gThreadNum = DEFAULT_THREADS; |
|
176 } |
|
177 } |
|
178 } |
|
179 else if (strncmp(argv[i],ParamFileArg.c_str(),ParamFileArg.length())==0) |
|
180 { |
|
181 // If "-argfile" option is specified within parameter-file then process it |
|
182 // otherwise ignore the option. |
|
183 if (paramFileFlag) |
|
184 { |
|
185 String paramFile; |
|
186 paramFile.assign(&argv[i][ParamFileArg.length()]); |
|
187 processParamfile(paramFile); |
|
188 } |
|
189 else |
|
190 { |
|
191 continue; |
|
192 } |
|
193 } |
|
194 else if (argv[i][1] == 'T') |
|
195 TypeSafeLink=ETrue; |
|
196 else if (argv[i][1] == '?') |
|
197 reallyHelp=ETrue; |
|
198 else if (argv[i][1] == 'R') |
|
199 CompareRom=strdup(&argv[i][2]); |
|
200 else if (strcmp(argv[i], "-NO-HEADER")==0) |
|
201 gHeaderType=KRomLoaderHeaderNone; |
|
202 else if (strcmp(argv[i], "-EPOC-HEADER")==0) |
|
203 gHeaderType=KRomLoaderHeaderEPOC; |
|
204 else if (strcmp(argv[i], "-COFF-HEADER")==0) |
|
205 gHeaderType=KRomLoaderHeaderCOFF; |
|
206 else if (strcmp(argv[i], "-COMPRESS")==0) |
|
207 { |
|
208 if( (i+1) >= argc || argv[i+1][0] == '-') |
|
209 { |
|
210 // No argument, compress both parts with default compression method |
|
211 // un-paged part compressed by Deflate |
|
212 gCompressUnpaged = ETrue; |
|
213 gCompressUnpagedMethod = KUidCompressionDeflate; |
|
214 // paged part compressed by the Bytepiar |
|
215 gEnableCompress=ETrue; |
|
216 gCompressionMethod = KUidCompressionBytePair; |
|
217 } |
|
218 else |
|
219 { |
|
220 // An argument exists |
|
221 i++; |
|
222 strupr(argv[i]); |
|
223 if( strcmp(argv[i], "PAGED") == 0) |
|
224 { |
|
225 gEnableCompress=ETrue; |
|
226 gCompressionMethod = KUidCompressionBytePair; |
|
227 } |
|
228 else if( strcmp(argv[i], "UNPAGED") == 0) |
|
229 { |
|
230 gCompressUnpaged=ETrue; |
|
231 gCompressUnpagedMethod = KUidCompressionDeflate; |
|
232 } |
|
233 else |
|
234 { |
|
235 Print (EError, "Unknown -compression argument! Set it to default (no compression)!"); |
|
236 gEnableCompress=EFalse; |
|
237 gCompressionMethod = 0; |
|
238 gCompressUnpaged = EFalse; |
|
239 gCompressUnpagedMethod = 0; |
|
240 } |
|
241 } |
|
242 } |
|
243 else if( strcmp(argv[i], "-COMPRESSIONMETHOD") == 0 ) |
|
244 { |
|
245 // next argument should be a method |
|
246 if( (i+1) >= argc || argv[i+1][0] == '-') |
|
247 { |
|
248 Print (EError, "Missing compression method! Set it to default (no compression)!"); |
|
249 gEnableCompress=EFalse; |
|
250 gCompressionMethod = 0; |
|
251 } |
|
252 else |
|
253 { |
|
254 i++; |
|
255 strupr(argv[i]); |
|
256 if( strcmp(argv[i], "INFLATE") == 0) |
|
257 { |
|
258 gEnableCompress=ETrue; |
|
259 gCompressionMethod = KUidCompressionDeflate; |
|
260 } |
|
261 else if( strcmp(argv[i], "BYTEPAIR") == 0) |
|
262 { |
|
263 gEnableCompress=ETrue; |
|
264 gCompressionMethod = KUidCompressionBytePair; |
|
265 } |
|
266 else |
|
267 { |
|
268 if( strcmp(argv[i], "NONE") != 0) |
|
269 { |
|
270 Print (EError, "Unknown compression method! Set it to default (no compression)!"); |
|
271 } |
|
272 gEnableCompress=EFalse; |
|
273 gCompressionMethod = 0; |
|
274 } |
|
275 } |
|
276 |
|
277 } |
|
278 else if (strcmp(argv[i], "-NO-SORTED-ROMFS")==0) |
|
279 gSortedRomFs=EFalse; |
|
280 else if (strcmp(argv[i], "-GENINC")==0) // DEF095619 |
|
281 gGenInc=ETrue; |
|
282 else if (strcmp(argv[i], "-WSTDPATH")==0) // Warn if destination path provided for a file |
|
283 gEnableStdPathWarning=ETrue; // is not a standard path as per platsec |
|
284 else if( strcmp(argv[i], "-LOGLEVEL") == 0) |
|
285 { |
|
286 // next argument should a be loglevel |
|
287 if( (i+1) >= argc || argv[i+1][0] == '-') |
|
288 { |
|
289 Print (EError, "Missing loglevel!"); |
|
290 gLogLevel = DEFAULT_LOG_LEVEL; |
|
291 } |
|
292 else |
|
293 { |
|
294 i++; |
|
295 if (strcmp(argv[i], "4") == 0) |
|
296 gLogLevel = (LOG_LEVEL_FILE_DETAILS | LOG_LEVEL_FILE_ATTRIBUTES | LOG_LEVEL_COMPRESSION_INFO | LOG_LEVEL_SMP_INFO); |
|
297 else if (strcmp(argv[i], "3") == 0) |
|
298 gLogLevel = (LOG_LEVEL_FILE_DETAILS | LOG_LEVEL_FILE_ATTRIBUTES | LOG_LEVEL_COMPRESSION_INFO); |
|
299 else if (strcmp(argv[i], "2") == 0) |
|
300 gLogLevel = (LOG_LEVEL_FILE_DETAILS | LOG_LEVEL_FILE_ATTRIBUTES); |
|
301 else if (strcmp(argv[i], "1") == 0) |
|
302 gLogLevel = LOG_LEVEL_FILE_DETAILS; |
|
303 else if (strcmp(argv[i], "0") == 0) |
|
304 gLogLevel = DEFAULT_LOG_LEVEL; |
|
305 else |
|
306 Print(EError, "Only loglevel 0, 1, 2, 3 or 4 is allowed!"); |
|
307 } |
|
308 } |
|
309 else if( strcmp(argv[i], "-LOGLEVEL4") == 0) |
|
310 gLogLevel = (LOG_LEVEL_FILE_DETAILS | LOG_LEVEL_FILE_ATTRIBUTES | LOG_LEVEL_COMPRESSION_INFO | LOG_LEVEL_SMP_INFO); |
|
311 else if( strcmp(argv[i], "-LOGLEVEL3") == 0) |
|
312 gLogLevel = (LOG_LEVEL_FILE_DETAILS | LOG_LEVEL_FILE_ATTRIBUTES | LOG_LEVEL_COMPRESSION_INFO); |
|
313 else if( strcmp(argv[i], "-LOGLEVEL2") == 0) |
|
314 gLogLevel = (LOG_LEVEL_FILE_DETAILS | LOG_LEVEL_FILE_ATTRIBUTES); |
|
315 else if( strcmp(argv[i], "-LOGLEVEL1") == 0) |
|
316 gLogLevel = LOG_LEVEL_FILE_DETAILS; |
|
317 else if( strcmp(argv[i], "-LOGLEVEL0") == 0) |
|
318 gLogLevel = DEFAULT_LOG_LEVEL; |
|
319 else if (argv[i][1] == 'D') |
|
320 { |
|
321 TraceMask=strtoul(argv[i]+2, 0, 0); |
|
322 } |
|
323 else if (strcmp(argv[i], "-LOWMEM") == 0) |
|
324 gLowMem = ETrue; |
|
325 else if (strncmp(argv[i], "-COREIMAGE=",11) ==0) |
|
326 { |
|
327 if(argv[i][11]) |
|
328 { |
|
329 gUseCoreImage = ETrue; |
|
330 gImageFilename = (TText*)strdup(&argv[i][11]); |
|
331 } |
|
332 else |
|
333 { |
|
334 Print (EError, "Core ROM image file is missing\n"); |
|
335 } |
|
336 } |
|
337 else |
|
338 cout << "Unrecognised option " << argv[i] << "\n"; |
|
339 } |
|
340 else // Must be the obey filename |
|
341 filename=argv[i]; |
|
342 } |
|
343 if (paramFileFlag) |
|
344 return; |
|
345 if (filename.empty()) |
|
346 { |
|
347 PrintVersion(); |
|
348 cout << HelpText; |
|
349 if (reallyHelp) |
|
350 { |
|
351 ObeyFileReader::KeywordHelp(); |
|
352 cout << ReallyHelpText; |
|
353 } |
|
354 else |
|
355 Print(EError, "Obey filename is missing\n"); |
|
356 } |
|
357 } |
|
358 |
|
359 /** |
|
360 Function to process parameter-file. |
|
361 |
|
362 @param aFileName parameter-file name. |
|
363 */ |
|
364 void processParamfile(string aFileName) |
|
365 { |
|
366 CParameterFileProcessor parameterFile(aFileName); |
|
367 |
|
368 // Invoke fuction "ParameterFileProcessor" to process parameter-file. |
|
369 if(parameterFile.ParameterFileProcessor()) |
|
370 { |
|
371 TUint noOfParameters = parameterFile.GetNoOfArguments(); |
|
372 char** parameters = parameterFile.GetParameters(); |
|
373 TBool paramFileFlag=ETrue; |
|
374 |
|
375 // Invoke function "processCommandLine" to process parameters read from parameter-file. |
|
376 processCommandLine(noOfParameters, parameters, paramFileFlag); |
|
377 } |
|
378 } |
|
379 |
|
380 void GenerateIncludeFile(char* aRomName, TInt aUnpagedSize, TInt aPagedSize ) |
|
381 { |
|
382 |
|
383 const char * incFileNameExt = ".inc"; |
|
384 |
|
385 TText* incFileName; |
|
386 incFileName=new TText[strlen(aRomName) + strlen(incFileNameExt) + 1]; // Place for include file name and ".inc" extension and '\0' |
|
387 strcpy((char *)incFileName, aRomName); |
|
388 |
|
389 char *p = (char*)strrchr((const char *)incFileName, '.'); |
|
390 if( NULL != p) |
|
391 { |
|
392 strncpy(p, incFileNameExt, strlen(incFileNameExt) + 1); // copy extension and the '\0' |
|
393 } |
|
394 else |
|
395 { |
|
396 strcat((char *)incFileName, incFileNameExt); //Doesn't cotains extension, add to it. |
|
397 } |
|
398 |
|
399 Print(EAlways," (%s)\n", (const char *)incFileName); |
|
400 |
|
401 ofstream incFile((const char*)incFileName, ios::out); |
|
402 if(!incFile) |
|
403 { |
|
404 Print(EError,"Cannot open include file %s for output\n",(const char *)incFileName); |
|
405 } |
|
406 else |
|
407 { |
|
408 const char * incContent = |
|
409 "/** Size of the unpaged part of ROM.\n" |
|
410 "This part is at the start of the ROM image. */\n" |
|
411 "#define SYMBIAN_ROM_UNPAGED_SIZE 0x%08x\n" |
|
412 "\n" |
|
413 "/** Size of the demand paged part of ROM.\n" |
|
414 "This part is stored immediately after the unpaged part in the ROM image. */\n" |
|
415 "#define SYMBIAN_ROM_PAGED_SIZE 0x%08x\n"; |
|
416 |
|
417 TText* temp = new TText[strlen(incContent)+ 2 * 8 + 1]; // for place of two hex representated values and '\0' |
|
418 |
|
419 sprintf((char *)temp,incContent, aUnpagedSize, aPagedSize); |
|
420 incFile.write((const char *)temp, strlen((const char *)temp)); |
|
421 |
|
422 incFile.close(); |
|
423 delete[] temp; |
|
424 } |
|
425 delete[] incFileName; |
|
426 |
|
427 } |
|
428 |
|
429 int main(int argc, char *argv[]) |
|
430 { |
|
431 H.SetLogFile((unsigned char *)"ROMBUILD.LOG"); |
|
432 TInt r = 0; |
|
433 g_pCharCPUNum = getenv("NUMBER_OF_PROCESSORS"); |
|
434 if(g_pCharCPUNum != NULL) |
|
435 gCPUNum = atoi(g_pCharCPUNum); |
|
436 |
|
437 // initialise set of all capabilities |
|
438 ParseCapabilitiesArg(gPlatSecAllCaps, "all"); |
|
439 |
|
440 processCommandLine(argc, argv); |
|
441 if(filename.empty()) |
|
442 return KErrGeneral; |
|
443 |
|
444 if(gThreadNum == 0) |
|
445 { |
|
446 if(gCPUNum > 0 && gCPUNum <= MAXIMUM_THREADS) |
|
447 { |
|
448 Print(EAlways, "The number of processors (%d) is used as the number of concurrent jobs.\n", gCPUNum); |
|
449 gThreadNum = gCPUNum; |
|
450 } |
|
451 else if(g_pCharCPUNum) |
|
452 { |
|
453 Print(EWarning, "The NUMBER_OF_PROCESSORS is invalid, and the default value %d will be used.\n", DEFAULT_THREADS); |
|
454 gThreadNum = DEFAULT_THREADS; |
|
455 } |
|
456 else |
|
457 { |
|
458 Print(EWarning, "The NUMBER_OF_PROCESSORS is not available, and the default value %d will be used.\n", DEFAULT_THREADS); |
|
459 gThreadNum = DEFAULT_THREADS; |
|
460 } |
|
461 } |
|
462 TText *obeyFileName= (TText*)filename.c_str(); |
|
463 |
|
464 PrintVersion(); |
|
465 |
|
466 ObeyFileReader *reader=new ObeyFileReader(obeyFileName); |
|
467 if (!reader->Open()) |
|
468 { |
|
469 delete reader; |
|
470 return KErrGeneral; |
|
471 } |
|
472 |
|
473 E32Rom* kernelRom=0; // for image from obey file |
|
474 CoreRomImage *core= 0; // for image from core image file |
|
475 MRomImage* imageInfo=0; |
|
476 CObeyFile *mainObeyFile=new CObeyFile(*reader); |
|
477 |
|
478 // need check if obey file has coreimage keyword |
|
479 TText *file = mainObeyFile->ProcessCoreImage(); |
|
480 if (file) |
|
481 { |
|
482 // hase coreimage keyword but only use if command line option |
|
483 // for coreimage not already selected |
|
484 if (!gUseCoreImage) |
|
485 { |
|
486 gUseCoreImage = ETrue; |
|
487 gImageFilename = file; |
|
488 } |
|
489 } |
|
490 |
|
491 if (!gUseCoreImage) |
|
492 { |
|
493 r=mainObeyFile->ProcessKernelRom(); |
|
494 if (r==KErrNone) |
|
495 { |
|
496 // Build a kernel ROM using the description compiled into the |
|
497 // CObeyFile object |
|
498 |
|
499 kernelRom = new E32Rom(mainObeyFile); |
|
500 if (kernelRom == 0 || kernelRom->iData == 0) |
|
501 return KErrNoMemory; |
|
502 |
|
503 r=kernelRom->Create(); |
|
504 if (r!=KErrNone) |
|
505 { |
|
506 delete kernelRom; |
|
507 delete mainObeyFile; |
|
508 return r; |
|
509 } |
|
510 if (SizeSummary) |
|
511 kernelRom->DisplaySizes(SizeWhere); |
|
512 |
|
513 r=kernelRom->WriteImages(gHeaderType); |
|
514 if (r!=KErrNone) |
|
515 { |
|
516 delete kernelRom; |
|
517 delete mainObeyFile; |
|
518 return r; |
|
519 } |
|
520 |
|
521 if (CompareRom) |
|
522 { |
|
523 r=kernelRom->Compare(CompareRom, gHeaderType); |
|
524 if (r!=KErrNone) |
|
525 { |
|
526 delete kernelRom; |
|
527 delete mainObeyFile; |
|
528 return r; |
|
529 } |
|
530 } |
|
531 imageInfo = kernelRom; |
|
532 mainObeyFile->Release(); |
|
533 } |
|
534 else if (r!=KErrNotFound) |
|
535 return r; |
|
536 } |
|
537 else |
|
538 { |
|
539 // need to use core image |
|
540 core = new CoreRomImage((char*)gImageFilename); |
|
541 if (!core) |
|
542 { |
|
543 return KErrNoMemory; |
|
544 } |
|
545 if (!core->ProcessImage(gLowMem)) |
|
546 { |
|
547 delete core; |
|
548 delete mainObeyFile; |
|
549 return KErrGeneral; |
|
550 } |
|
551 |
|
552 NumberOfVariants = core->VariantCount(); |
|
553 TVariantList::SetNumVariants(NumberOfVariants); |
|
554 TVariantList::SetVariants(core->VariantList()); |
|
555 |
|
556 core->SetRomAlign(mainObeyFile->iRomAlign); |
|
557 core->SetDataRunAddress(mainObeyFile->iDataRunAddress); |
|
558 |
|
559 gCompressionMethod = core->CompressionType(); |
|
560 if(gCompressionMethod) |
|
561 { |
|
562 gEnableCompress = ETrue; |
|
563 } |
|
564 |
|
565 imageInfo = core; |
|
566 if(!mainObeyFile->SkipToExtension()) |
|
567 { |
|
568 delete core; |
|
569 delete mainObeyFile; |
|
570 return KErrGeneral; |
|
571 } |
|
572 } |
|
573 |
|
574 if(gGenInc) |
|
575 { |
|
576 Print(EAlways,"Generating include file for ROM image post-processors "); |
|
577 if( gPagedRom ) |
|
578 { |
|
579 Print(EAlways,"Paged ROM"); |
|
580 GenerateIncludeFile((char*)mainObeyFile->iRomFileName, kernelRom->iHeader->iPageableRomStart, kernelRom->iHeader->iPageableRomSize); |
|
581 } |
|
582 else |
|
583 { |
|
584 Print(EAlways,"Unpaged ROM"); |
|
585 int headersize=(kernelRom->iExtensionRomHeader ? sizeof(TExtensionRomHeader) : sizeof(TRomHeader)) - sizeof(TRomLoaderHeader); |
|
586 GenerateIncludeFile((char*)mainObeyFile->iRomFileName, kernelRom->iHeader->iCompressedSize + headersize, kernelRom->iHeader->iPageableRomSize); |
|
587 } |
|
588 } |
|
589 |
|
590 do |
|
591 { |
|
592 CObeyFile* extensionObeyFile = 0; |
|
593 E32Rom* extensionRom = 0; |
|
594 |
|
595 extensionObeyFile = new CObeyFile(*reader); |
|
596 r = extensionObeyFile->ProcessExtensionRom(imageInfo); |
|
597 if (r==KErrEof) |
|
598 { |
|
599 delete imageInfo; |
|
600 delete mainObeyFile; |
|
601 delete extensionObeyFile; |
|
602 return KErrNone; |
|
603 } |
|
604 if (r!=KErrNone) |
|
605 { |
|
606 delete extensionObeyFile; |
|
607 break; |
|
608 } |
|
609 |
|
610 extensionRom = new E32Rom(extensionObeyFile); |
|
611 r=extensionRom->CreateExtension(imageInfo); |
|
612 if (r!=KErrNone) |
|
613 { |
|
614 delete extensionRom; |
|
615 delete extensionObeyFile; |
|
616 break; |
|
617 } |
|
618 if (SizeSummary) |
|
619 extensionRom->DisplaySizes(SizeWhere); |
|
620 |
|
621 r=extensionRom->WriteImages(0); // always a raw image |
|
622 |
|
623 delete extensionRom; |
|
624 delete extensionObeyFile; |
|
625 } |
|
626 while (r==KErrNone); |
|
627 |
|
628 delete imageInfo; |
|
629 delete mainObeyFile; |
|
630 free(gDepInfoFile); |
|
631 return r; |
|
632 } |