]> git.proxmox.com Git - mirror_edk2.git/blame_incremental - Tools/Java/Source/GenBuild/org/tianocore/build/autogen/AutoGen.java
Get the Include/ tree also.
[mirror_edk2.git] / Tools / Java / Source / GenBuild / org / tianocore / build / autogen / AutoGen.java
... / ...
CommitLineData
1/** @file\r
2 AutoGen class.\r
3\r
4 This class is to generate Autogen.h and Autogen.c according to module surface area\r
5 or library surface area.\r
6\r
7 Copyright (c) 2006, Intel Corporation\r
8 All rights reserved. This program and the accompanying materials\r
9 are licensed and made available under the terms and conditions of the BSD License\r
10 which accompanies this distribution. The full text of the license may be found at\r
11 http://opensource.org/licenses/bsd-license.php\r
12\r
13 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
14 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
15\r
16 **/\r
17\r
18package org.tianocore.build.autogen;\r
19\r
20import java.io.File;\r
21import java.io.FileInputStream;\r
22import java.io.FileOutputStream;\r
23import java.io.FileReader;\r
24import java.io.FileWriter;\r
25import java.io.IOException;\r
26import java.util.ArrayList;\r
27import java.util.HashSet;\r
28import java.util.Iterator;\r
29import java.util.LinkedHashSet;\r
30import java.util.LinkedList;\r
31import java.util.List;\r
32import java.util.Map;\r
33import java.util.Set;\r
34\r
35import org.apache.tools.ant.BuildException;\r
36import org.apache.xmlbeans.XmlObject;\r
37import org.tianocore.build.exception.AutoGenException;\r
38import org.tianocore.build.global.GlobalData;\r
39import org.tianocore.build.global.SurfaceAreaQuery;\r
40import org.tianocore.build.id.ModuleIdentification;\r
41import org.tianocore.build.id.PackageIdentification;\r
42import org.tianocore.build.pcd.action.PCDAutoGenAction;\r
43import org.tianocore.common.definitions.ToolDefinitions;\r
44import org.tianocore.common.definitions.EdkDefinitions;\r
45import org.tianocore.common.exception.EdkException;\r
46import org.tianocore.common.logger.EdkLog;\r
47\r
48/**\r
49 This class is to generate Autogen.h and Autogen.c according to module surface\r
50 area or library surface area.\r
51**/\r
52public class AutoGen {\r
53 ///\r
54 /// The output path of Autogen.h and Autogen.c\r
55 ///\r
56 private String outputPath;\r
57\r
58 ///\r
59 /// The name of FV directory\r
60 ///\r
61 private String fvDir;\r
62\r
63 ///\r
64 /// The base name of module or library.\r
65 ///\r
66 private ModuleIdentification moduleId;\r
67\r
68 ///\r
69 /// The build architecture\r
70 ///\r
71 private String arch;\r
72\r
73 ///\r
74 /// PcdAutogen instance which is used to manage how to generate the PCD\r
75 /// information.\r
76 ///\r
77 private PCDAutoGenAction myPcdAutogen;\r
78\r
79 ///\r
80 /// the one of type : NOT_PCD_DRIVER, PEI_PCD_DRIVER, DXE_PCD_DRIVER\r
81 /// \r
82 private CommonDefinition.PCD_DRIVER_TYPE pcdDriverType;\r
83\r
84 ///\r
85 /// The protocl list which records in module or library surface area and\r
86 /// it's dependence on library instance surface area.\r
87 ///\r
88 private Set<String> mProtocolList = new HashSet<String>();\r
89\r
90 ///\r
91 /// The Ppi list which recorded in module or library surface area and its\r
92 /// dependency on library instance surface area.\r
93 ///\r
94 private Set<String> mPpiList = new HashSet<String>();\r
95\r
96 ///\r
97 /// The Guid list which recoreded in module or library surface area and it's\r
98 /// dependence on library instance surface area.\r
99 ///\r
100 private Set<String> mGuidList = new HashSet<String>();\r
101\r
102 ///\r
103 /// The dependence package list which recoreded in module or library surface\r
104 /// area and it's dependence on library instance surface area.\r
105 ///\r
106 private List<PackageIdentification> mDepPkgList = new LinkedList<PackageIdentification>();\r
107\r
108 ///\r
109 /// For non library module, add its library instance's construct and destructor to\r
110 /// list. String[0] recode LibConstructor name, String[1] recode Lib instance \r
111 /// module type.\r
112 ///\r
113 private List<String[]> libConstructList = new ArrayList<String[]>();\r
114 private List<String[]> libDestructList = new ArrayList<String[]>();\r
115\r
116 ///\r
117 /// List to store SetVirtalAddressMapCallBack, ExitBootServiceCallBack\r
118 ///\r
119 private List<String> setVirtalAddList = new ArrayList<String>();\r
120 private List<String> exitBootServiceList = new ArrayList<String>();\r
121\r
122 //\r
123 // flag of PcdComponentNameDisable, PcdDriverDiagnosticDisable \r
124 //\r
125 private boolean componentNamePcd = false;\r
126 private boolean driverDiagnostPcd = false;\r
127\r
128 //\r
129 // Instance of SurfaceAreaQuery\r
130 //\r
131 private SurfaceAreaQuery saq = null;\r
132\r
133 private ModuleIdentification parentId = null;\r
134\r
135 /**\r
136 Construct function\r
137 \r
138 This function mainly initialize some member variable.\r
139 \r
140 @param fvDir\r
141 Absolute path of FV directory.\r
142 @param outputPath\r
143 Output path of AutoGen file.\r
144 @param moduleId\r
145 Module identification.\r
146 @param arch\r
147 Target architecture.\r
148 **/\r
149 public AutoGen(String fvDir, String outputPath, ModuleIdentification moduleId, String arch, SurfaceAreaQuery saq, ModuleIdentification parentId) {\r
150 this.outputPath = outputPath;\r
151 this.moduleId = moduleId;\r
152 this.arch = arch;\r
153 this.fvDir = fvDir;\r
154 this.saq = saq;\r
155 this.parentId = parentId;\r
156 }\r
157\r
158 /**\r
159 saveFile function\r
160 \r
161 This function save the content in stringBuffer to file.\r
162 \r
163 @param fileName\r
164 The name of file.\r
165 @param fileBuffer\r
166 The content of AutoGen file in buffer.\r
167 @return boolean \r
168 "true" successful\r
169 "false" failed\r
170 **/\r
171 private boolean saveFile(String fileName, StringBuffer fileBuffer) {\r
172\r
173 File autoGenH = new File(fileName);\r
174\r
175 //\r
176 // if the file exists, compare their content\r
177 //\r
178 if (autoGenH.exists()) {\r
179 char[] oldFileBuffer = new char[(int) autoGenH.length()];\r
180 try {\r
181 FileReader fIn = new FileReader(autoGenH);\r
182 fIn.read(oldFileBuffer, 0, (int) autoGenH.length());\r
183 fIn.close();\r
184 } catch (IOException e) {\r
185 EdkLog.log(EdkLog.EDK_INFO, this.moduleId.getName() \r
186 + "'s " \r
187 + fileName \r
188 + " is exist, but can't be open!!");\r
189 return false;\r
190 }\r
191\r
192 //\r
193 // if we got the same file, don't re-generate it to prevent\r
194 // sources depending on it from re-building\r
195 //\r
196 if (fileBuffer.toString().compareTo(new String(oldFileBuffer)) == 0) {\r
197 return true;\r
198 }\r
199 }\r
200\r
201 try {\r
202 FileWriter fOut = new FileWriter(autoGenH);\r
203 fOut.write(fileBuffer.toString());\r
204 fOut.flush();\r
205 fOut.close();\r
206 } catch (IOException e) {\r
207 EdkLog.log(EdkLog.EDK_INFO, this.moduleId.getName() \r
208 + "'s " \r
209 + fileName \r
210 + " can't be create!!");\r
211 return false;\r
212 }\r
213 return true;\r
214 }\r
215\r
216 /**\r
217 genAutogen function\r
218 \r
219 This function call libGenAutoGen or moduleGenAutogen function, which\r
220 dependence on generate library autogen or module autogen.\r
221 \r
222 @throws BuildException\r
223 Failed to creat AutoGen.c & AutoGen.h.\r
224 **/\r
225 public void genAutogen() throws EdkException {\r
226 //\r
227 // If outputPath do not exist, create it.\r
228 //\r
229 File path = new File(outputPath);\r
230 path.mkdirs();\r
231\r
232 //\r
233 // Check current is library or not, then call the corresponding\r
234 // function.\r
235 //\r
236 if (this.moduleId.isLibrary()) {\r
237 libGenAutogen();\r
238 } else {\r
239 moduleGenAutogen();\r
240 }\r
241 }\r
242\r
243 /**\r
244 moduleGenAutogen function\r
245 \r
246 This function generates AutoGen.c & AutoGen.h for module.\r
247 \r
248 @throws BuildException\r
249 Faile to create module AutoGen.c & AutoGen.h.\r
250 **/\r
251 void moduleGenAutogen() throws EdkException {\r
252 setPcdComponentName();\r
253 setPcdDriverDiagnostic();\r
254 collectLibInstanceInfo();\r
255 moduleGenAutogenC();\r
256 moduleGenAutogenH();\r
257 }\r
258\r
259 /**\r
260 libGenAutogen function\r
261 \r
262 This function generates AutoGen.c & AutoGen.h for library.\r
263 \r
264 @throws BuildException\r
265 Faile to create library AutoGen.c & AutoGen.h\r
266 **/\r
267 void libGenAutogen() throws EdkException {\r
268 libGenAutogenC();\r
269 libGenAutogenH();\r
270 }\r
271\r
272 /**\r
273 moduleGenAutogenH\r
274 \r
275 This function generates AutoGen.h for module.\r
276 \r
277 @throws BuildException\r
278 Failed to generate AutoGen.h.\r
279 **/\r
280 void moduleGenAutogenH() throws EdkException {\r
281\r
282 Set<String> libClassIncludeH;\r
283 String moduleType;\r
284 // List<String> headerFileList;\r
285 List<String> headerFileList;\r
286 Iterator item;\r
287 StringBuffer fileBuffer = new StringBuffer(8192);\r
288\r
289 //\r
290 // Write Autogen.h header notation\r
291 //\r
292 fileBuffer.append(CommonDefinition.AUTOGENHNOTATION);\r
293\r
294 //\r
295 // Add #ifndef ${BaseName}_AUTOGENH\r
296 // #def ${BseeName}_AUTOGENH\r
297 //\r
298 fileBuffer.append(CommonDefinition.IFNDEF \r
299 + CommonDefinition.AUTOGENH\r
300 + this.moduleId.getGuid().replaceAll("-", "_") \r
301 + ToolDefinitions.LINE_SEPARATOR);\r
302 fileBuffer.append(CommonDefinition.DEFINE \r
303 + CommonDefinition.AUTOGENH\r
304 + this.moduleId.getGuid().replaceAll("-", "_") \r
305 + ToolDefinitions.LINE_SEPARATOR \r
306 + ToolDefinitions.LINE_SEPARATOR);\r
307\r
308 //\r
309 // Write the specification version and release version at the begine\r
310 // of autogen.h file.\r
311 // Note: the specification version and release version should\r
312 // be got from module surface area instead of hard code by it's\r
313 // moduleType.\r
314 //\r
315 moduleType = saq.getModuleType();\r
316\r
317 //\r
318 // Add "extern int __make_me_compile_correctly;" at begin of\r
319 // AutoGen.h.\r
320 //\r
321 fileBuffer.append(CommonDefinition.AUTOGENHBEGIN);\r
322\r
323 //\r
324 // Put EFI_SPECIFICATION_VERSION, and EDK_RELEASE_VERSION.\r
325 //\r
326 String[] specList = saq.getExternSpecificaiton();\r
327 for (int i = 0; i < specList.length; i++) {\r
328 fileBuffer.append(CommonDefinition.DEFINE + specList[i]\r
329 + "\r\n");\r
330 }\r
331 //\r
332 // Write consumed package's mdouleInfo related .h file to autogen.h\r
333 //\r
334 // PackageIdentification[] consumedPkgIdList = SurfaceAreaQuery\r
335 // .getDependencePkg(this.arch);\r
336 PackageIdentification[] consumedPkgIdList = saq.getDependencePkg(this.arch);\r
337 if (consumedPkgIdList != null) {\r
338 headerFileList = depPkgToAutogenH(consumedPkgIdList, moduleType);\r
339 item = headerFileList.iterator();\r
340 while (item.hasNext()) {\r
341 fileBuffer.append(item.next().toString());\r
342 }\r
343 }\r
344\r
345 //\r
346 // Write library class's related *.h file to autogen.h.\r
347 //\r
348 String[] libClassList = saq.getLibraryClasses(CommonDefinition.ALWAYSCONSUMED,this.arch);\r
349 if (libClassList != null) {\r
350 libClassIncludeH = LibraryClassToAutogenH(libClassList);\r
351 item = libClassIncludeH.iterator();\r
352 while (item.hasNext()) {\r
353 fileBuffer.append(item.next().toString());\r
354 }\r
355 }\r
356\r
357 libClassList = saq.getLibraryClasses(CommonDefinition.ALWAYSPRODUCED, this.arch);\r
358 if (libClassList != null) {\r
359 libClassIncludeH = LibraryClassToAutogenH(libClassList);\r
360 item = libClassIncludeH.iterator();\r
361 while (item.hasNext()) {\r
362 fileBuffer.append(item.next().toString());\r
363 }\r
364 }\r
365 fileBuffer.append("\r\n");\r
366\r
367 //\r
368 // If is TianoR8FlashMap, copy {Fv_DIR}/FlashMap.h to\r
369 // {DEST_DIR_DRBUG}/FlashMap.h\r
370 //\r
371 if (saq.isHaveTianoR8FlashMap()) {\r
372 fileBuffer.append(CommonDefinition.INCLUDE);\r
373 fileBuffer.append(" <");\r
374 fileBuffer.append(CommonDefinition.TIANOR8PLASHMAPH + ">\r\n");\r
375 copyFlashMapHToDebugDir();\r
376 }\r
377\r
378 // Write PCD autogen information to AutoGen.h.\r
379 //\r
380 if (this.myPcdAutogen != null) {\r
381 fileBuffer.append("\r\n");\r
382 fileBuffer.append(this.myPcdAutogen.getHAutoGenString());\r
383 }\r
384\r
385 //\r
386 // Append the #endif at AutoGen.h\r
387 //\r
388 fileBuffer.append("#endif\r\n");\r
389\r
390 //\r
391 // Save string buffer content in AutoGen.h.\r
392 //\r
393 if (!saveFile(outputPath + File.separatorChar + "AutoGen.h", fileBuffer)) {\r
394 throw new AutoGenException("Failed to generate AutoGen.h !!!");\r
395 }\r
396 }\r
397\r
398 /**\r
399 moduleGenAutogenC\r
400 \r
401 This function generates AutoGen.c for module.\r
402 \r
403 @throws BuildException\r
404 Failed to generate AutoGen.c.\r
405 **/\r
406 void moduleGenAutogenC() throws EdkException {\r
407\r
408 StringBuffer fileBuffer = new StringBuffer(8192);\r
409 //\r
410 // Write Autogen.c header notation\r
411 //\r
412 fileBuffer.append(CommonDefinition.AUTOGENCNOTATION);\r
413\r
414 //\r
415 // Write #include <AutoGen.h> at beginning of AutoGen.c\r
416 //\r
417 fileBuffer.append(CommonDefinition.INCLUDEAUTOGENH);\r
418\r
419 //\r
420 // Get the native MSA file infomation. Since before call autogen,\r
421 // the MSA native <Externs> information were overrided. So before\r
422 // process <Externs> it should be set the DOC as the Native MSA info.\r
423 //\r
424 Map<String, XmlObject> doc = GlobalData.getNativeMsa(this.moduleId);\r
425 saq.push(doc);\r
426 //\r
427 // Write <Extern>\r
428 // DriverBinding/ComponentName/DriverConfiguration/DriverDialog\r
429 // to AutoGen.c\r
430 //\r
431\r
432 ExternsDriverBindingToAutoGenC(fileBuffer);\r
433\r
434 //\r
435 // Write DriverExitBootServicesEvent/DriverSetVirtualAddressMapEvent\r
436 // to Autogen.c\r
437 //\r
438 ExternCallBackToAutoGenC(fileBuffer);\r
439\r
440 //\r
441 // Write EntryPoint to autgoGen.c\r
442 //\r
443 String[] entryPointList = saq.getModuleEntryPointArray();\r
444 String[] unloadImageList = saq.getModuleUnloadImageArray();\r
445 EntryPointToAutoGen(CommonDefinition.remDupString(entryPointList), \r
446 CommonDefinition.remDupString(unloadImageList),\r
447 fileBuffer);\r
448\r
449 pcdDriverType = saq.getPcdDriverType();\r
450\r
451 //\r
452 // Restore the DOC which include the FPD module info.\r
453 //\r
454 saq.pop();\r
455\r
456 //\r
457 // Write Guid to autogen.c\r
458 //\r
459 String guid = CommonDefinition.formatGuidName(saq.getModuleGuid());\r
460 if (this.moduleId.getModuleType().equalsIgnoreCase(EdkDefinitions.MODULE_TYPE_BASE)) {\r
461 fileBuffer.append("GLOBAL_REMOVE_IF_UNREFERENCED GUID gEfiCallerIdGuid = {");\r
462 } else {\r
463 fileBuffer.append("GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiCallerIdGuid = {");\r
464 }\r
465\r
466 if (guid == null) {\r
467 throw new AutoGenException("Guid value must set!\n");\r
468 }\r
469\r
470 //\r
471 // Formate Guid as ANSI c form.Example:\r
472 // {0xd2b2b828, 0x826, 0x48a7,{0xb3, 0xdf, 0x98, 0x3c, 0x0, 0x60, 0x24,\r
473 // 0xf0}}\r
474 //\r
475\r
476 fileBuffer.append(guid);\r
477 fileBuffer.append("};\r\n");\r
478\r
479 //\r
480 // Generate library instance consumed protocol, guid, ppi, pcd list.\r
481 // Save those to this.protocolList, this.ppiList, this.pcdList,\r
482 // this.guidList. Write Consumed library constructor and desconstuct to\r
483 // autogen.c\r
484 //\r
485 LibInstanceToAutogenC(fileBuffer);\r
486\r
487 //\r
488 // Get module dependent Package identification.\r
489 //\r
490 PackageIdentification[] packages = saq.getDependencePkg(this.arch);\r
491 for (int i = 0; i < packages.length; i++) {\r
492 if (!this.mDepPkgList.contains(packages[i])) {\r
493 this.mDepPkgList.add(packages[i]);\r
494 }\r
495\r
496 }\r
497\r
498 //\r
499 // Write consumed ppi, guid, protocol to autogen.c\r
500 //\r
501 ProtocolGuidToAutogenC(fileBuffer);\r
502 PpiGuidToAutogenC(fileBuffer);\r
503 GuidGuidToAutogenC(fileBuffer);\r
504\r
505 //\r
506 // Call pcd autogen.\r
507 //\r
508 this.myPcdAutogen = new PCDAutoGenAction(moduleId, \r
509 arch, \r
510 false, \r
511 null,\r
512 pcdDriverType, \r
513 parentId);\r
514\r
515 this.myPcdAutogen.execute();\r
516 if (this.myPcdAutogen != null) {\r
517 fileBuffer.append("\r\n");\r
518 fileBuffer.append(this.myPcdAutogen.getCAutoGenString());\r
519 }\r
520\r
521 if (!saveFile(outputPath + File.separatorChar + "AutoGen.c", fileBuffer)) {\r
522 throw new AutoGenException("Failed to generate AutoGen.c !!!");\r
523 }\r
524\r
525 }\r
526\r
527 /**\r
528 libGenAutogenH\r
529 \r
530 This function generates AutoGen.h for library.\r
531 \r
532 @throws BuildException\r
533 Failed to generate AutoGen.c.\r
534 **/\r
535 void libGenAutogenH() throws EdkException {\r
536\r
537 Set<String> libClassIncludeH;\r
538 String moduleType;\r
539 List<String> headerFileList;\r
540 Iterator item;\r
541 StringBuffer fileBuffer = new StringBuffer(10240);\r
542\r
543 //\r
544 // Write Autogen.h header notation\r
545 //\r
546 fileBuffer.append(CommonDefinition.AUTOGENHNOTATION);\r
547\r
548 //\r
549 // Add #ifndef ${BaseName}_AUTOGENH\r
550 // #def ${BseeName}_AUTOGENH\r
551 //\r
552 fileBuffer.append(CommonDefinition.IFNDEF \r
553 + CommonDefinition.AUTOGENH\r
554 + this.moduleId.getGuid().replaceAll("-", "_") \r
555 + ToolDefinitions.LINE_SEPARATOR);\r
556 fileBuffer.append(CommonDefinition.DEFINE \r
557 + CommonDefinition.AUTOGENH\r
558 + this.moduleId.getGuid().replaceAll("-", "_") \r
559 + ToolDefinitions.LINE_SEPARATOR \r
560 + ToolDefinitions.LINE_SEPARATOR);\r
561\r
562 //\r
563 // Write EFI_SPECIFICATION_VERSION and EDK_RELEASE_VERSION\r
564 // to autogen.h file.\r
565 // Note: the specification version and release version should\r
566 // be get from module surface area instead of hard code.\r
567 //\r
568 fileBuffer.append(CommonDefinition.AUTOGENHBEGIN);\r
569 String[] specList = saq.getExternSpecificaiton();\r
570 for (int i = 0; i < specList.length; i++) {\r
571 fileBuffer.append(CommonDefinition.DEFINE + specList[i]\r
572 + "\r\n");\r
573 }\r
574 // fileBuffer.append(CommonDefinition.autoGenHLine1);\r
575 // fileBuffer.append(CommonDefinition.autoGenHLine2);\r
576\r
577 //\r
578 // Write consumed package's mdouleInfo related *.h file to autogen.h.\r
579 //\r
580 moduleType = saq.getModuleType();\r
581 PackageIdentification[] cosumedPkglist = saq\r
582 .getDependencePkg(this.arch);\r
583 headerFileList = depPkgToAutogenH(cosumedPkglist, moduleType);\r
584 item = headerFileList.iterator();\r
585 while (item.hasNext()) {\r
586 fileBuffer.append(item.next().toString());\r
587 }\r
588 //\r
589 // Write library class's related *.h file to autogen.h\r
590 //\r
591 String[] libClassList = saq.getLibraryClasses(CommonDefinition.ALWAYSCONSUMED, this.arch);\r
592 if (libClassList != null) {\r
593 libClassIncludeH = LibraryClassToAutogenH(libClassList);\r
594 item = libClassIncludeH.iterator();\r
595 while (item.hasNext()) {\r
596 fileBuffer.append(item.next().toString());\r
597 }\r
598 }\r
599\r
600 libClassList = saq.getLibraryClasses(CommonDefinition.ALWAYSPRODUCED, this.arch);\r
601 if (libClassList != null) {\r
602 libClassIncludeH = LibraryClassToAutogenH(libClassList);\r
603 item = libClassIncludeH.iterator();\r
604 while (item.hasNext()) {\r
605 fileBuffer.append(item.next().toString());\r
606 }\r
607 }\r
608 fileBuffer.append(ToolDefinitions.LINE_SEPARATOR);\r
609\r
610 //\r
611 // If is TianoR8FlashMap, copy {Fv_DIR}/FlashMap.h to\r
612 // {DEST_DIR_DRBUG}/FlashMap.h\r
613 //\r
614 if (saq.isHaveTianoR8FlashMap()) {\r
615 fileBuffer.append(CommonDefinition.INCLUDE);\r
616 fileBuffer.append(" <");\r
617 fileBuffer.append(CommonDefinition.TIANOR8PLASHMAPH + ">\r\n");\r
618 copyFlashMapHToDebugDir();\r
619 }\r
620\r
621 //\r
622 // Write PCD information to library AutoGen.h.\r
623 //\r
624 if (this.myPcdAutogen != null) {\r
625 fileBuffer.append("\r\n");\r
626 fileBuffer.append(this.myPcdAutogen.getHAutoGenString());\r
627 }\r
628\r
629 //\r
630 // Append the #endif at AutoGen.h\r
631 //\r
632 fileBuffer.append("#endif\r\n");\r
633\r
634 //\r
635 // Save content of string buffer to AutoGen.h file.\r
636 //\r
637 if (!saveFile(outputPath + File.separatorChar + "AutoGen.h", fileBuffer)) {\r
638 throw new AutoGenException("Failed to generate AutoGen.h !!!");\r
639 }\r
640 }\r
641\r
642 /**\r
643 libGenAutogenC\r
644 \r
645 This function generates AutoGen.h for library.\r
646 \r
647 @throws BuildException\r
648 Failed to generate AutoGen.c.\r
649 **/\r
650 void libGenAutogenC() throws EdkException {\r
651 StringBuffer fileBuffer = new StringBuffer(10240);\r
652\r
653 //\r
654 // Write Autogen.c header notation\r
655 //\r
656 fileBuffer.append(CommonDefinition.AUTOGENCNOTATION);\r
657\r
658 fileBuffer.append(ToolDefinitions.LINE_SEPARATOR);\r
659 fileBuffer.append(ToolDefinitions.LINE_SEPARATOR);\r
660\r
661 //\r
662 // Call pcd autogen.\r
663 //\r
664 this.myPcdAutogen = new PCDAutoGenAction(moduleId,\r
665 arch,\r
666 true,\r
667 saq.getModulePcdEntryNameArray(this.arch),\r
668 pcdDriverType, \r
669 parentId);\r
670 this.myPcdAutogen.execute();\r
671 if (this.myPcdAutogen != null) {\r
672 fileBuffer.append(ToolDefinitions.LINE_SEPARATOR);\r
673 fileBuffer.append(this.myPcdAutogen.getCAutoGenString());\r
674 }\r
675\r
676 if (!saveFile(outputPath + File.separatorChar + "AutoGen.c", fileBuffer)) {\r
677 throw new AutoGenException("Failed to generate AutoGen.c !!!");\r
678 }\r
679 }\r
680\r
681 /**\r
682 LibraryClassToAutogenH\r
683 \r
684 This function returns *.h files declared by library classes which are\r
685 consumed or produced by current build module or library.\r
686 \r
687 @param libClassList\r
688 List of library class which consumed or produce by current\r
689 build module or library.\r
690 @return includeStrList List of *.h file.\r
691 **/\r
692 Set<String> LibraryClassToAutogenH(String[] libClassList)\r
693 throws EdkException {\r
694 Set<String> includeStrList = new LinkedHashSet<String>();\r
695 String includeName[];\r
696 String str = "";\r
697\r
698 //\r
699 // Get include file from GlobalData's SPDTable according to\r
700 // library class name.\r
701 //\r
702 for (int i = 0; i < libClassList.length; i++) {\r
703 includeName = GlobalData.getLibraryClassHeaderFiles(\r
704 saq.getDependencePkg(this.arch),\r
705 libClassList[i]);\r
706 if (includeName == null) {\r
707 throw new AutoGenException("Can not find library class ["\r
708 + libClassList[i] + "] declaration in any SPD package. ");\r
709 }\r
710 for (int j = 0; j < includeName.length; j++) {\r
711 String includeNameStr = includeName[j];\r
712 if (includeNameStr != null) {\r
713 str = CommonDefinition.INCLUDE + " " + "<";\r
714 str = str + includeNameStr + ">\r\n";\r
715 includeStrList.add(str);\r
716 includeNameStr = null;\r
717 }\r
718 }\r
719 }\r
720 return includeStrList;\r
721 }\r
722\r
723 /**\r
724 IncludesToAutogenH\r
725 \r
726 This function add include file in AutoGen.h file.\r
727 \r
728 @param packageNameList\r
729 List of module depended package.\r
730 @param moduleType\r
731 Module type.\r
732 @return\r
733 **/\r
734 List<String> depPkgToAutogenH(PackageIdentification[] packageNameList,\r
735 String moduleType) throws AutoGenException {\r
736\r
737 List<String> includeStrList = new LinkedList<String>();\r
738 String pkgHeader;\r
739 String includeStr = "";\r
740\r
741 //\r
742 // Get include file from moduleInfo file\r
743 //\r
744 for (int i = 0; i < packageNameList.length; i++) {\r
745 pkgHeader = GlobalData.getPackageHeaderFiles(packageNameList[i],\r
746 moduleType);\r
747 if (pkgHeader == null) {\r
748 throw new AutoGenException("Can not find package ["\r
749 + packageNameList[i]\r
750 + "] declaration in any SPD package. ");\r
751 } else if (!pkgHeader.equalsIgnoreCase("")) {\r
752 includeStr = CommonDefinition.INCLUDE + " <" + pkgHeader\r
753 + ">\r\n";\r
754 includeStrList.add(includeStr);\r
755 }\r
756 }\r
757\r
758 return includeStrList;\r
759 }\r
760\r
761 /**\r
762 EntryPointToAutoGen\r
763 \r
764 This function convert <ModuleEntryPoint> & <ModuleUnloadImage>\r
765 information in mas to AutoGen.c\r
766 \r
767 @param entryPointList\r
768 List of entry point.\r
769 @param fileBuffer\r
770 String buffer fo AutoGen.c.\r
771 @throws Exception\r
772 **/\r
773 void EntryPointToAutoGen(String[] entryPointList, String[] unloadImageList, StringBuffer fileBuffer)\r
774 throws EdkException {\r
775\r
776 String typeStr = saq.getModuleType();\r
777 String debugStr = "DEBUG ((EFI_D_INFO | EFI_D_LOAD, \"Module Entry Point (%s) 0x%%p\\n\", (VOID *)(UINTN)%s));\n";\r
778 int unloadImageCount = 0;\r
779 int entryPointCount = 0;\r
780\r
781 //\r
782 // The parameters and return value of entryPoint is difference\r
783 // for difference module type.\r
784 //\r
785 switch (CommonDefinition.getModuleType(typeStr)) {\r
786 \r
787 case CommonDefinition.ModuleTypePeiCore:\r
788 if (entryPointList == null ||entryPointList.length != 1 ) {\r
789 throw new AutoGenException(\r
790 "Module type = 'PEI_CORE', can have only one module entry point!");\r
791 } else {\r
792 fileBuffer.append("EFI_STATUS\r\n");\r
793 fileBuffer.append(entryPointList[0]);\r
794 fileBuffer.append(" (\r\n");\r
795 fileBuffer.append(" IN EFI_PEI_STARTUP_DESCRIPTOR *PeiStartupDescriptor,\r\n");\r
796 fileBuffer.append(" IN VOID *OldCoreData\r\n");\r
797 fileBuffer.append(" );\r\n\r\n");\r
798\r
799 fileBuffer.append("EFI_STATUS\r\n");\r
800 fileBuffer.append("EFIAPI\r\n");\r
801 fileBuffer.append("ProcessModuleEntryPointList (\r\n");\r
802 fileBuffer.append(" IN EFI_PEI_STARTUP_DESCRIPTOR *PeiStartupDescriptor,\r\n");\r
803 fileBuffer.append(" IN VOID *OldCoreData\r\n");\r
804 fileBuffer.append(" )\r\n\r\n");\r
805 fileBuffer.append("{\r\n");\r
806 fileBuffer.append(" return ");\r
807 fileBuffer.append(entryPointList[0]);\r
808 fileBuffer.append(" (PeiStartupDescriptor, OldCoreData);\r\n");\r
809 fileBuffer.append("}\r\n\r\n");\r
810 }\r
811 break;\r
812\r
813 case CommonDefinition.ModuleTypeDxeCore:\r
814 fileBuffer.append("const UINT32 _gUefiDriverRevision = 0;\r\n");\r
815 if (entryPointList == null || entryPointList.length != 1) {\r
816 throw new AutoGenException("Module type = 'DXE_CORE', can have only one module entry point!");\r
817 } else {\r
818 fileBuffer.append("VOID\r\n");\r
819 fileBuffer.append(entryPointList[0]);\r
820 fileBuffer.append(" (\n");\r
821 fileBuffer.append(" IN VOID *HobStart\r\n");\r
822 fileBuffer.append(" );\r\n\r\n");\r
823\r
824 fileBuffer.append("VOID\r\n");\r
825 fileBuffer.append("EFIAPI\r\n");\r
826 fileBuffer.append("ProcessModuleEntryPointList (\r\n");\r
827 fileBuffer.append(" IN VOID *HobStart\r\n");\r
828 fileBuffer.append(" )\r\n\r\n");\r
829 fileBuffer.append("{\r\n");\r
830 fileBuffer.append(" ");\r
831 fileBuffer.append(entryPointList[0]);\r
832 fileBuffer.append(" (HobStart);\r\n");\r
833 fileBuffer.append("}\r\n\r\n");\r
834 }\r
835 break;\r
836\r
837 case CommonDefinition.ModuleTypePeim:\r
838 entryPointCount = 0;\r
839 fileBuffer.append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT32 _gPeimRevision = 0;\r\n");\r
840 if (entryPointList == null || entryPointList.length == 0) {\r
841 fileBuffer.append("EFI_STATUS\r\n");\r
842 fileBuffer.append("EFIAPI\r\n");\r
843 fileBuffer.append("ProcessModuleEntryPointList (\r\n");\r
844 fileBuffer.append(" IN EFI_FFS_FILE_HEADER *FfsHeader,\r\n");\r
845 fileBuffer.append(" IN EFI_PEI_SERVICES **PeiServices\r\n");\r
846 fileBuffer.append(" )\r\n\r\n");\r
847 fileBuffer.append("{\r\n");\r
848 fileBuffer.append(" return EFI_SUCCESS;\r\n");\r
849 fileBuffer.append("}\r\n\r\n");\r
850 break;\r
851 }\r
852 for (int i = 0; i < entryPointList.length; i++) {\r
853 fileBuffer.append("EFI_STATUS\r\n");\r
854 fileBuffer.append(entryPointList[i]);\r
855 fileBuffer.append(" (\r\n");\r
856 fileBuffer.append(" IN EFI_FFS_FILE_HEADER *FfsHeader,\r\n");\r
857 fileBuffer.append(" IN EFI_PEI_SERVICES **PeiServices\r\n");\r
858 fileBuffer.append(" );\r\n");\r
859 entryPointCount++;\r
860 }\r
861\r
862 fileBuffer.append("EFI_STATUS\r\n");\r
863 fileBuffer.append("EFIAPI\r\n");\r
864 fileBuffer.append("ProcessModuleEntryPointList (\r\n");\r
865 fileBuffer.append(" IN EFI_FFS_FILE_HEADER *FfsHeader,\r\n");\r
866 fileBuffer.append(" IN EFI_PEI_SERVICES **PeiServices\r\n");\r
867 fileBuffer.append(" )\r\n\r\n");\r
868 fileBuffer.append("{\r\n");\r
869 if (entryPointCount == 1) {\r
870 fileBuffer.append(String.format(" " + debugStr, entryPointList[0], entryPointList[0]));\r
871 fileBuffer.append(" return ");\r
872 fileBuffer.append(entryPointList[0]);\r
873 fileBuffer.append(" (FfsHeader, PeiServices);\r\n");\r
874 } else {\r
875 fileBuffer.append(" EFI_STATUS Status;\r\n");\r
876 fileBuffer.append(" EFI_STATUS CombinedStatus;\r\n\r\n");\r
877 fileBuffer.append(" CombinedStatus = EFI_LOAD_ERROR;\r\n\r\n");\r
878 for (int i = 0; i < entryPointList.length; i++) {\r
879 if (!entryPointList[i].equals("")) {\r
880 fileBuffer.append(String.format(" " + debugStr, entryPointList[i], entryPointList[i]));\r
881 fileBuffer.append(" Status = ");\r
882 fileBuffer.append(entryPointList[i]);\r
883 fileBuffer.append(" (FfsHeader, PeiServices);\r\n");\r
884 fileBuffer.append(" if (!EFI_ERROR (Status) || EFI_ERROR (CombinedStatus)) {\r\n");\r
885 fileBuffer.append(" CombinedStatus = Status;\r\n");\r
886 fileBuffer.append(" }\r\n\r\n");\r
887 } else {\r
888 break;\r
889 }\r
890 }\r
891 fileBuffer.append(" return CombinedStatus;\r\n");\r
892 }\r
893 fileBuffer.append("}\r\n\r\n");\r
894 break;\r
895\r
896 case CommonDefinition.ModuleTypeDxeSmmDriver:\r
897 entryPointCount = 0;\r
898 //\r
899 // If entryPoint is null, create an empty ProcessModuleEntryPointList\r
900 // function.\r
901 //\r
902 if (entryPointList == null || entryPointList.length == 0) {\r
903 fileBuffer.append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gDriverEntryPointCount = ");\r
904 fileBuffer.append(Integer.toString(entryPointCount));\r
905 fileBuffer.append(";\r\n");\r
906 fileBuffer.append("EFI_STATUS\r\n");\r
907 fileBuffer.append("EFIAPI\r\n");\r
908 fileBuffer.append("ProcessModuleEntryPointList (\r\n");\r
909 fileBuffer.append(" IN EFI_HANDLE ImageHandle,\r\n");\r
910 fileBuffer.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");\r
911 fileBuffer.append(" )\r\n\r\n");\r
912 fileBuffer.append("{\r\n");\r
913 fileBuffer.append(" return EFI_SUCCESS;\r\n");\r
914 fileBuffer.append("}\r\n\r\n");\r
915\r
916 } else {\r
917 for (int i = 0; i < entryPointList.length; i++) {\r
918 fileBuffer.append("EFI_STATUS\r\n");\r
919 fileBuffer.append(entryPointList[i]);\r
920 fileBuffer.append(" (\r\n");\r
921 fileBuffer.append(" IN EFI_HANDLE ImageHandle,\r\n");\r
922 fileBuffer.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");\r
923 fileBuffer.append(" );\r\n");\r
924 entryPointCount++;\r
925 }\r
926 fileBuffer.append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gDriverEntryPointCount = ");\r
927 fileBuffer.append(Integer.toString(entryPointCount));\r
928 fileBuffer.append(";\r\n");\r
929 fileBuffer.append("static BASE_LIBRARY_JUMP_BUFFER mJumpContext;\r\n");\r
930 fileBuffer.append("static EFI_STATUS mDriverEntryPointStatus = EFI_LOAD_ERROR;\r\n\r\n");\r
931\r
932 fileBuffer.append("EFI_STATUS\r\n");\r
933 fileBuffer.append("EFIAPI\r\n");\r
934 fileBuffer.append("ProcessModuleEntryPointList (\r\n");\r
935 fileBuffer.append(" IN EFI_HANDLE ImageHandle,\r\n");\r
936 fileBuffer.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");\r
937 fileBuffer.append(" )\r\n\r\n");\r
938 fileBuffer.append("{\r\n");\r
939\r
940 for (int i = 0; i < entryPointList.length; i++) {\r
941 fileBuffer.append(" if (SetJump (&mJumpContext) == 0) {\r\n");\r
942 fileBuffer.append(String.format(" " + debugStr, entryPointList[i], entryPointList[i]));\r
943 fileBuffer.append(" ExitDriver (");\r
944 fileBuffer.append(entryPointList[i]);\r
945 fileBuffer.append(" (ImageHandle, SystemTable));\r\n");\r
946 fileBuffer.append(" ASSERT (FALSE);\r\n");\r
947 fileBuffer.append(" }\r\n");\r
948 }\r
949 fileBuffer.append(" return mDriverEntryPointStatus;\r\n");\r
950 fileBuffer.append("}\r\n\r\n");\r
951\r
952 fileBuffer.append("VOID\r\n");\r
953 fileBuffer.append("EFIAPI\r\n");\r
954 fileBuffer.append("ExitDriver (\r\n");\r
955 fileBuffer.append(" IN EFI_STATUS Status\n");\r
956 fileBuffer.append(" )\r\n\r\n");\r
957 fileBuffer.append("{\r\n");\r
958 fileBuffer.append(" if (!EFI_ERROR (Status) || EFI_ERROR (mDriverEntryPointStatus)) {\r\n");\r
959 fileBuffer.append(" mDriverEntryPointStatus = Status;\r\n");\r
960 fileBuffer.append(" }\r\n");\r
961 fileBuffer.append(" LongJump (&mJumpContext, (UINTN)-1);\r\n");\r
962 fileBuffer.append(" ASSERT (FALSE);\r\n");\r
963 fileBuffer.append("}\r\n\r\n");\r
964 }\r
965\r
966\r
967 //\r
968 // Add "ModuleUnloadImage" for DxeSmmDriver module type;\r
969 //\r
970 //entryPointList = SurfaceAreaQuery.getModuleUnloadImageArray();\r
971 //entryPointList = CommonDefinition.remDupString(entryPointList);\r
972 //entryPointCount = 0;\r
973\r
974 unloadImageCount = 0;\r
975 if (unloadImageList != null) {\r
976 for (int i = 0; i < unloadImageList.length; i++) {\r
977 fileBuffer.append("EFI_STATUS\r\n");\r
978 fileBuffer.append(unloadImageList[i]);\r
979 fileBuffer.append(" (\r\n");\r
980 fileBuffer.append(" IN EFI_HANDLE ImageHandle\r\n");\r
981 fileBuffer.append(" );\r\n");\r
982 unloadImageCount++;\r
983 }\r
984 }\r
985\r
986 fileBuffer.append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gDriverUnloadImageCount = ");\r
987 fileBuffer.append(Integer.toString(unloadImageCount));\r
988 fileBuffer.append(";\r\n\r\n");\r
989\r
990 fileBuffer.append("EFI_STATUS\r\n");\r
991 fileBuffer.append("EFIAPI\r\n");\r
992 fileBuffer.append("ProcessModuleUnloadList (\r\n");\r
993 fileBuffer.append(" IN EFI_HANDLE ImageHandle\r\n");\r
994 fileBuffer.append(" )\r\n");\r
995 fileBuffer.append("{\r\n");\r
996\r
997 if (unloadImageCount == 0) {\r
998 fileBuffer.append(" return EFI_SUCCESS;\r\n");\r
999 } else if (unloadImageCount == 1) {\r
1000 fileBuffer.append(" return ");\r
1001 fileBuffer.append(unloadImageList[0]);\r
1002 fileBuffer.append("(ImageHandle);\r\n");\r
1003 } else {\r
1004 fileBuffer.append(" EFI_STATUS Status;\r\n\r\n");\r
1005 fileBuffer.append(" Status = EFI_SUCCESS;\r\n\r\n");\r
1006 for (int i = 0; i < unloadImageList.length; i++) {\r
1007 if (i == 0) {\r
1008 fileBuffer.append(" Status = ");\r
1009 fileBuffer.append(unloadImageList[i]);\r
1010 fileBuffer.append("(ImageHandle);\r\n");\r
1011 } else {\r
1012 fileBuffer.append(" if (EFI_ERROR (Status)) {\r\n");\r
1013 fileBuffer.append(" ");\r
1014 fileBuffer.append(unloadImageList[i]);\r
1015 fileBuffer.append("(ImageHandle);\r\n");\r
1016 fileBuffer.append(" } else {\r\n");\r
1017 fileBuffer.append(" Status = ");\r
1018 fileBuffer.append(unloadImageList[i]);\r
1019 fileBuffer.append("(ImageHandle);\r\n");\r
1020 fileBuffer.append(" }\r\n");\r
1021 }\r
1022 }\r
1023 fileBuffer.append(" return Status;\r\n");\r
1024 }\r
1025 fileBuffer.append("}\r\n\r\n");\r
1026 break;\r
1027\r
1028 case CommonDefinition.ModuleTypeDxeRuntimeDriver:\r
1029 case CommonDefinition.ModuleTypeDxeDriver:\r
1030 case CommonDefinition.ModuleTypeDxeSalDriver:\r
1031 case CommonDefinition.ModuleTypeUefiDriver:\r
1032 case CommonDefinition.ModuleTypeUefiApplication:\r
1033 entryPointCount = 0;\r
1034 fileBuffer.append("const UINT32 _gUefiDriverRevision = 0;\r\n");\r
1035 //\r
1036 // If entry point is null, create a empty ProcessModuleEntryPointList function.\r
1037 //\r
1038 if (entryPointList == null || entryPointList.length == 0) {\r
1039 fileBuffer.append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gDriverEntryPointCount = 0;\r\n");\r
1040 fileBuffer.append("EFI_STATUS\r\n");\r
1041 fileBuffer.append("EFIAPI\r\n");\r
1042 fileBuffer.append("ProcessModuleEntryPointList (\r\n");\r
1043 fileBuffer.append(" IN EFI_HANDLE ImageHandle,\r\n");\r
1044 fileBuffer.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");\r
1045 fileBuffer.append(" )\r\n\r\n");\r
1046 fileBuffer.append("{\r\n");\r
1047 fileBuffer.append(" return EFI_SUCCESS;\r\n");\r
1048 fileBuffer.append("}\r\n");\r
1049\r
1050 } else {\r
1051 for (int i = 0; i < entryPointList.length; i++) {\r
1052\r
1053 fileBuffer.append("EFI_STATUS\r\n");\r
1054 fileBuffer.append(entryPointList[i]);\r
1055 fileBuffer.append(" (\r\n");\r
1056 fileBuffer.append(" IN EFI_HANDLE ImageHandle,\r\n");\r
1057 fileBuffer.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");\r
1058 fileBuffer.append(" );\r\n");\r
1059 entryPointCount++;\r
1060 }\r
1061\r
1062 fileBuffer.append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gDriverEntryPointCount = ");\r
1063 fileBuffer.append(Integer.toString(entryPointCount));\r
1064 fileBuffer.append(";\r\n");\r
1065 if (entryPointCount > 1) {\r
1066 fileBuffer.append("static BASE_LIBRARY_JUMP_BUFFER mJumpContext;\r\n");\r
1067 fileBuffer.append("static EFI_STATUS mDriverEntryPointStatus = EFI_LOAD_ERROR;\r\n");\r
1068 }\r
1069 fileBuffer.append("\n");\r
1070\r
1071 fileBuffer.append("EFI_STATUS\r\n");\r
1072 fileBuffer.append("EFIAPI\r\n");\r
1073 fileBuffer.append("ProcessModuleEntryPointList (\r\n");\r
1074 fileBuffer.append(" IN EFI_HANDLE ImageHandle,\r\n");\r
1075 fileBuffer.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");\r
1076 fileBuffer.append(" )\r\n\r\n");\r
1077 fileBuffer.append("{\r\n");\r
1078\r
1079 if (entryPointCount == 1) {\r
1080 fileBuffer.append(String.format(" " + debugStr, entryPointList[0], entryPointList[0]));\r
1081 fileBuffer.append(" return ");\r
1082 fileBuffer.append(entryPointList[0]);\r
1083 fileBuffer.append(" (ImageHandle, SystemTable);\r\n");\r
1084 } else {\r
1085 for (int i = 0; i < entryPointList.length; i++) {\r
1086 if (!entryPointList[i].equals("")) {\r
1087 fileBuffer.append(" if (SetJump (&mJumpContext) == 0) {\r\n");\r
1088 fileBuffer.append(String.format(" " + debugStr, entryPointList[i], entryPointList[i]));\r
1089 fileBuffer.append(" ExitDriver (");\r
1090 fileBuffer.append(entryPointList[i]);\r
1091 fileBuffer.append(" (ImageHandle, SystemTable));\r\n");\r
1092 fileBuffer.append(" ASSERT (FALSE);\r\n");\r
1093 fileBuffer.append(" }\r\n");\r
1094 } else {\r
1095 break;\r
1096 }\r
1097 }\r
1098 fileBuffer.append(" return mDriverEntryPointStatus;\r\n");\r
1099 }\r
1100 fileBuffer.append("}\r\n\r\n");\r
1101\r
1102 fileBuffer.append("VOID\r\n");\r
1103 fileBuffer.append("EFIAPI\r\n");\r
1104 fileBuffer.append("ExitDriver (\r\n");\r
1105 fileBuffer.append(" IN EFI_STATUS Status\r\n");\r
1106 fileBuffer.append(" )\r\n\r\n");\r
1107 fileBuffer.append("{\r\n");\r
1108 if (entryPointCount <= 1) {\r
1109 fileBuffer.append(" if (EFI_ERROR (Status)) {\r\n");\r
1110 fileBuffer.append(" ProcessLibraryDestructorList (gImageHandle, gST);\r\n");\r
1111 fileBuffer.append(" }\r\n");\r
1112 fileBuffer\r
1113 .append(" gBS->Exit (gImageHandle, Status, 0, NULL);\r\n");\r
1114 } else {\r
1115 fileBuffer.append(" if (!EFI_ERROR (Status) || EFI_ERROR (mDriverEntryPointStatus)) {\r\n");\r
1116 fileBuffer.append(" mDriverEntryPointStatus = Status;\r\n");\r
1117 fileBuffer.append(" }\r\n");\r
1118 fileBuffer.append(" LongJump (&mJumpContext, (UINTN)-1);\r\n");\r
1119 fileBuffer.append(" ASSERT (FALSE);\r\n");\r
1120 }\r
1121 fileBuffer.append("}\r\n\r\n");\r
1122 }\r
1123\r
1124 //\r
1125 // Add ModuleUnloadImage for DxeDriver and UefiDriver module type.\r
1126 //\r
1127 //entryPointList = SurfaceAreaQuery.getModuleUnloadImageArray();\r
1128 //\r
1129 // Remover duplicate unload entry point.\r
1130 //\r
1131 //entryPointList = CommonDefinition.remDupString(entryPointList);\r
1132 //entryPointCount = 0;\r
1133 unloadImageCount = 0;\r
1134 if (unloadImageList != null) {\r
1135 for (int i = 0; i < unloadImageList.length; i++) {\r
1136 fileBuffer.append("EFI_STATUS\r\n");\r
1137 fileBuffer.append("EFIAPI\r\n");\r
1138 fileBuffer.append(unloadImageList[i]);\r
1139 fileBuffer.append(" (\r\n");\r
1140 fileBuffer.append(" IN EFI_HANDLE ImageHandle\r\n");\r
1141 fileBuffer.append(" );\r\n");\r
1142 unloadImageCount++;\r
1143 }\r
1144 }\r
1145\r
1146 fileBuffer.append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gDriverUnloadImageCount = ");\r
1147 fileBuffer.append(Integer.toString(unloadImageCount));\r
1148 fileBuffer.append(";\r\n\r\n");\r
1149\r
1150 fileBuffer.append("EFI_STATUS\n");\r
1151 fileBuffer.append("EFIAPI\r\n");\r
1152 fileBuffer.append("ProcessModuleUnloadList (\r\n");\r
1153 fileBuffer.append(" IN EFI_HANDLE ImageHandle\r\n");\r
1154 fileBuffer.append(" )\r\n");\r
1155 fileBuffer.append("{\r\n");\r
1156\r
1157 if (unloadImageCount == 0) {\r
1158 fileBuffer.append(" return EFI_SUCCESS;\r\n");\r
1159 } else if (unloadImageCount == 1) {\r
1160 fileBuffer.append(" return ");\r
1161 fileBuffer.append(unloadImageList[0]);\r
1162 fileBuffer.append("(ImageHandle);\r\n");\r
1163 } else {\r
1164 fileBuffer.append(" EFI_STATUS Status;\r\n\r\n");\r
1165 fileBuffer.append(" Status = EFI_SUCCESS;\r\n\r\n");\r
1166 for (int i = 0; i < unloadImageList.length; i++) {\r
1167 if (i == 0) {\r
1168 fileBuffer.append(" Status = ");\r
1169 fileBuffer.append(unloadImageList[i]);\r
1170 fileBuffer.append("(ImageHandle);\r\n");\r
1171 } else {\r
1172 fileBuffer.append(" if (EFI_ERROR (Status)) {\r\n");\r
1173 fileBuffer.append(" ");\r
1174 fileBuffer.append(unloadImageList[i]);\r
1175 fileBuffer.append("(ImageHandle);\r\n");\r
1176 fileBuffer.append(" } else {\r\n");\r
1177 fileBuffer.append(" Status = ");\r
1178 fileBuffer.append(unloadImageList[i]);\r
1179 fileBuffer.append("(ImageHandle);\r\n");\r
1180 fileBuffer.append(" }\r\n");\r
1181 }\r
1182 }\r
1183 fileBuffer.append(" return Status;\r\n");\r
1184 }\r
1185 fileBuffer.append("}\r\n\r\n");\r
1186 break;\r
1187 }\r
1188 }\r
1189\r
1190 /**\r
1191 PpiGuidToAutogenc\r
1192 \r
1193 This function gets GUIDs from SPD file accrodeing to <PPIs> information\r
1194 and write those GUIDs to AutoGen.c.\r
1195 \r
1196 @param fileBuffer\r
1197 String Buffer for Autogen.c file.\r
1198 @throws BuildException\r
1199 Guid must set value!\r
1200 **/\r
1201 void PpiGuidToAutogenC(StringBuffer fileBuffer) throws AutoGenException {\r
1202 String[] cNameGuid = null;\r
1203\r
1204 //\r
1205 // Get the all PPI adn PPI Notify from MSA file,\r
1206 // then add those PPI ,and PPI Notify name to list.\r
1207 //\r
1208\r
1209 String[] ppiList = saq.getPpiArray(this.arch);\r
1210 for (int i = 0; i < ppiList.length; i++) {\r
1211 this.mPpiList.add(ppiList[i]);\r
1212 }\r
1213\r
1214 String[] ppiNotifyList = saq.getPpiNotifyArray(this.arch);\r
1215 for (int i = 0; i < ppiNotifyList.length; i++) {\r
1216 this.mPpiList.add(ppiNotifyList[i]);\r
1217 }\r
1218\r
1219 //\r
1220 // Find CNAME and GUID from dependence SPD file and write to Autogen.c\r
1221 //\r
1222 Iterator ppiIterator = this.mPpiList.iterator();\r
1223 String ppiKeyWord = null;\r
1224 while (ppiIterator.hasNext()) {\r
1225 ppiKeyWord = ppiIterator.next().toString();\r
1226 cNameGuid = GlobalData.getPpiGuid(this.mDepPkgList, ppiKeyWord);\r
1227 if (cNameGuid != null) {\r
1228 fileBuffer.append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID ");\r
1229 fileBuffer.append(cNameGuid[0]);\r
1230 fileBuffer.append(" = { ");\r
1231 fileBuffer.append(CommonDefinition.formatGuidName(cNameGuid[1]));\r
1232 fileBuffer.append(" } ;");\r
1233 } else {\r
1234 //\r
1235 // If can't find Ppi GUID declaration in every package\r
1236 //\r
1237 throw new AutoGenException("Can not find Ppi GUID ["\r
1238 + ppiKeyWord + "] declaration in any SPD package!");\r
1239 }\r
1240 }\r
1241 }\r
1242\r
1243 /**\r
1244 ProtocolGuidToAutogenc\r
1245 \r
1246 This function gets GUIDs from SPD file accrodeing to <Protocol>\r
1247 information and write those GUIDs to AutoGen.c.\r
1248 \r
1249 @param fileBuffer\r
1250 String Buffer for Autogen.c file.\r
1251 @throws BuildException\r
1252 Protocol name must set.\r
1253 **/\r
1254 void ProtocolGuidToAutogenC(StringBuffer fileBuffer) throws EdkException {\r
1255 String[] cNameGuid = null;\r
1256\r
1257 String[] protocolList = saq.getProtocolArray(this.arch);\r
1258\r
1259 //\r
1260 // Add result to Autogen global list.\r
1261 //\r
1262 for (int i = 0; i < protocolList.length; i++) {\r
1263 this.mProtocolList.add(protocolList[i]);\r
1264 }\r
1265\r
1266 String[] protocolNotifyList = saq.getProtocolNotifyArray(this.arch);\r
1267\r
1268 for (int i = 0; i < protocolNotifyList.length; i++) {\r
1269 this.mProtocolList.add(protocolNotifyList[i]);\r
1270 }\r
1271\r
1272 //\r
1273 // Get the NAME and GUID from dependence SPD and write to Autogen.c\r
1274 //\r
1275 Iterator protocolIterator = this.mProtocolList.iterator();\r
1276 String protocolKeyWord = null;\r
1277\r
1278\r
1279 while (protocolIterator.hasNext()) {\r
1280 protocolKeyWord = protocolIterator.next().toString();\r
1281 cNameGuid = GlobalData.getProtocolGuid(this.mDepPkgList, protocolKeyWord);\r
1282 if (cNameGuid != null) {\r
1283 fileBuffer.append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID ");\r
1284 fileBuffer.append(cNameGuid[0]);\r
1285 fileBuffer.append(" = { ");\r
1286 fileBuffer.append(CommonDefinition.formatGuidName(cNameGuid[1]));\r
1287 fileBuffer.append(" } ;");\r
1288 } else {\r
1289 //\r
1290 // If can't find protocol GUID declaration in every package\r
1291 //\r
1292 throw new AutoGenException("Can not find protocol Guid ["\r
1293 + protocolKeyWord + "] declaration in any SPD package!");\r
1294 }\r
1295 }\r
1296 }\r
1297\r
1298 /**\r
1299 GuidGuidToAutogenc\r
1300 \r
1301 This function gets GUIDs from SPD file accrodeing to <Guids> information\r
1302 and write those GUIDs to AutoGen.c.\r
1303 \r
1304 @param fileBuffer\r
1305 String Buffer for Autogen.c file.\r
1306 \r
1307 **/\r
1308 void GuidGuidToAutogenC(StringBuffer fileBuffer) throws AutoGenException {\r
1309 String[] cNameGuid = null;\r
1310 String guidKeyWord = null;\r
1311\r
1312 String[] guidList = saq.getGuidEntryArray(this.arch);\r
1313\r
1314 for (int i = 0; i < guidList.length; i++) {\r
1315 this.mGuidList.add(guidList[i]);\r
1316 }\r
1317\r
1318\r
1319 Iterator guidIterator = this.mGuidList.iterator();\r
1320 while (guidIterator.hasNext()) {\r
1321 guidKeyWord = guidIterator.next().toString();\r
1322 cNameGuid = GlobalData.getGuid(this.mDepPkgList, guidKeyWord);\r
1323\r
1324 if (cNameGuid != null) {\r
1325 fileBuffer.append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID ");\r
1326 fileBuffer.append(cNameGuid[0]);\r
1327 fileBuffer.append(" = { ");\r
1328 fileBuffer.append(CommonDefinition.formatGuidName(cNameGuid[1]));\r
1329 fileBuffer.append("} ;");\r
1330 } else {\r
1331 //\r
1332 // If can't find GUID declaration in every package\r
1333 //\r
1334 throw new AutoGenException("Can not find Guid [" + guidKeyWord\r
1335 + "] declaration in any SPD package. ");\r
1336 }\r
1337\r
1338 }\r
1339 }\r
1340\r
1341 /**\r
1342 LibInstanceToAutogenC\r
1343 \r
1344 This function adds dependent library instance to autogen.c,which\r
1345 includeing library's constructor, destructor, and library dependent ppi,\r
1346 protocol, guid, pcd information.\r
1347 \r
1348 @param fileBuffer\r
1349 String buffer for AutoGen.c\r
1350 @throws BuildException\r
1351 **/\r
1352 void LibInstanceToAutogenC(StringBuffer fileBuffer) throws EdkException {\r
1353 String moduleType = this.moduleId.getModuleType();\r
1354 //\r
1355 // Add library constructor to AutoGen.c\r
1356 //\r
1357 LibConstructorToAutogenC(libConstructList, moduleType,\r
1358 fileBuffer/* autogenC */);\r
1359 //\r
1360 // Add library destructor to AutoGen.c\r
1361 //\r
1362 LibDestructorToAutogenC(libDestructList, moduleType, fileBuffer/* autogenC */);\r
1363 }\r
1364\r
1365 /**\r
1366 LibConstructorToAutogenc\r
1367 \r
1368 This function writes library constructor list to AutoGen.c. The library\r
1369 constructor's parameter and return value depend on module type.\r
1370 \r
1371 @param libInstanceList\r
1372 List of library construct name.\r
1373 @param moduleType\r
1374 Module type.\r
1375 @param fileBuffer\r
1376 String buffer for AutoGen.c\r
1377 @throws Exception\r
1378 **/\r
1379 void LibConstructorToAutogenC(List<String[]> libInstanceList,\r
1380 String moduleType, StringBuffer fileBuffer) throws EdkException {\r
1381 boolean isFirst = true;\r
1382\r
1383 //\r
1384 // The library constructor's parameter and return value depend on\r
1385 // module type.\r
1386 //\r
1387 for (int i = 0; i < libInstanceList.size(); i++) {\r
1388 if (libInstanceList.get(i)[1].equalsIgnoreCase(EdkDefinitions.MODULE_TYPE_BASE)) {\r
1389 fileBuffer.append("RETURN_STATUS\r\n");\r
1390 fileBuffer.append("EFIAPI\r\n");\r
1391 fileBuffer.append(libInstanceList.get(i)[0]);\r
1392 fileBuffer.append(" (\r\n");\r
1393 fileBuffer.append(" VOID\r\n");\r
1394 fileBuffer.append(" );\r\n");\r
1395 } else {\r
1396 switch (CommonDefinition.getModuleType(moduleType)) {\r
1397 case CommonDefinition.ModuleTypeBase:\r
1398 fileBuffer.append("RETURN_STATUS\r\n");\r
1399 fileBuffer.append("EFIAPI\r\n");\r
1400 fileBuffer.append(libInstanceList.get(i)[0]);\r
1401 fileBuffer.append(" (\r\n");\r
1402 fileBuffer.append(" VOID\r\n");\r
1403 fileBuffer.append(" );\r\n");\r
1404 break;\r
1405\r
1406 case CommonDefinition.ModuleTypePeiCore:\r
1407 case CommonDefinition.ModuleTypePeim:\r
1408 fileBuffer.append("EFI_STATUS\r\n");\r
1409 fileBuffer.append("EFIAPI\r\n");\r
1410 fileBuffer.append(libInstanceList.get(i)[0]);\r
1411 fileBuffer.append(" (\r\n");\r
1412 fileBuffer.append(" IN EFI_FFS_FILE_HEADER *FfsHeader,\r\n");\r
1413 fileBuffer.append(" IN EFI_PEI_SERVICES **PeiServices\r\n");\r
1414 fileBuffer.append(" );\r\n");\r
1415 break;\r
1416\r
1417 case CommonDefinition.ModuleTypeDxeCore:\r
1418 case CommonDefinition.ModuleTypeDxeDriver:\r
1419 case CommonDefinition.ModuleTypeDxeRuntimeDriver:\r
1420 case CommonDefinition.ModuleTypeDxeSmmDriver:\r
1421 case CommonDefinition.ModuleTypeDxeSalDriver:\r
1422 case CommonDefinition.ModuleTypeUefiDriver:\r
1423 case CommonDefinition.ModuleTypeUefiApplication:\r
1424 fileBuffer.append("EFI_STATUS\r\n");\r
1425 fileBuffer.append("EFIAPI\r\n");\r
1426 fileBuffer.append(libInstanceList.get(i)[0]);\r
1427 fileBuffer.append(" (\r\n");\r
1428 fileBuffer.append(" IN EFI_HANDLE ImageHandle,\r\n");\r
1429 fileBuffer.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");\r
1430 fileBuffer.append(" );\r\n");\r
1431 break;\r
1432\r
1433 }\r
1434 }\r
1435 }\r
1436\r
1437 //\r
1438 // Add ProcessLibraryConstructorList in AutoGen.c\r
1439 //\r
1440 fileBuffer.append("VOID\r\n");\r
1441 fileBuffer.append("EFIAPI\r\n");\r
1442 fileBuffer.append("ProcessLibraryConstructorList (\r\n");\r
1443 switch (CommonDefinition.getModuleType(moduleType)) {\r
1444 case CommonDefinition.ModuleTypeBase:\r
1445 fileBuffer.append(" VOID\r\n");\r
1446 break;\r
1447\r
1448 case CommonDefinition.ModuleTypePeiCore:\r
1449 case CommonDefinition.ModuleTypePeim:\r
1450 fileBuffer.append(" IN EFI_FFS_FILE_HEADER *FfsHeader,\r\n");\r
1451 fileBuffer\r
1452 .append(" IN EFI_PEI_SERVICES **PeiServices\r\n");\r
1453 break;\r
1454\r
1455 case CommonDefinition.ModuleTypeDxeCore:\r
1456 case CommonDefinition.ModuleTypeDxeDriver:\r
1457 case CommonDefinition.ModuleTypeDxeRuntimeDriver:\r
1458 case CommonDefinition.ModuleTypeDxeSmmDriver:\r
1459 case CommonDefinition.ModuleTypeDxeSalDriver:\r
1460 case CommonDefinition.ModuleTypeUefiDriver:\r
1461 case CommonDefinition.ModuleTypeUefiApplication:\r
1462 fileBuffer.append(" IN EFI_HANDLE ImageHandle,\r\n");\r
1463 fileBuffer.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");\r
1464 break;\r
1465 }\r
1466\r
1467 fileBuffer.append(" )\r\n");\r
1468 fileBuffer.append("{\r\n");\r
1469 //\r
1470 // If no constructor function, return EFI_SUCCESS.\r
1471 //\r
1472 //if (libInstanceList.size() == 0){\r
1473 // fileBuffer.append(" return EFI_SUCCESS;\r\n");\r
1474 //}\r
1475 for (int i = 0; i < libInstanceList.size(); i++) {\r
1476 if (isFirst) {\r
1477 fileBuffer.append(" EFI_STATUS Status;\r\n");\r
1478 fileBuffer.append(" Status = EFI_SUCCESS;\r\n");\r
1479 fileBuffer.append("\r\n");\r
1480 isFirst = false;\r
1481 }\r
1482 if (libInstanceList.get(i)[1].equalsIgnoreCase(EdkDefinitions.MODULE_TYPE_BASE)) {\r
1483 fileBuffer.append(" Status = ");\r
1484 fileBuffer.append(libInstanceList.get(i)[0]);\r
1485 fileBuffer.append("();\r\n");\r
1486 } else {\r
1487 switch (CommonDefinition.getModuleType(moduleType)) {\r
1488 case CommonDefinition.ModuleTypeBase:\r
1489 fileBuffer.append(" Status = ");\r
1490 fileBuffer.append(libInstanceList.get(i)[0]);\r
1491 fileBuffer.append("();\r\n");\r
1492 break;\r
1493 case CommonDefinition.ModuleTypePeiCore:\r
1494 case CommonDefinition.ModuleTypePeim:\r
1495 fileBuffer.append(" Status = ");\r
1496 fileBuffer.append(libInstanceList.get(i)[0]);\r
1497 fileBuffer.append(" (FfsHeader, PeiServices);\r\n");\r
1498 break;\r
1499 case CommonDefinition.ModuleTypeDxeCore:\r
1500 case CommonDefinition.ModuleTypeDxeDriver:\r
1501 case CommonDefinition.ModuleTypeDxeRuntimeDriver:\r
1502 case CommonDefinition.ModuleTypeDxeSmmDriver:\r
1503 case CommonDefinition.ModuleTypeDxeSalDriver:\r
1504 case CommonDefinition.ModuleTypeUefiDriver:\r
1505 case CommonDefinition.ModuleTypeUefiApplication:\r
1506 fileBuffer.append(" Status = ");\r
1507 fileBuffer.append(libInstanceList.get(i)[0]);\r
1508 fileBuffer.append(" (ImageHandle, SystemTable);\r\n");\r
1509 break;\r
1510 default:\r
1511 EdkLog.log(EdkLog.EDK_INFO,"Autogen doesn't know how to deal with module type - " + moduleType + "!");\r
1512 }\r
1513\r
1514 }\r
1515 fileBuffer.append(" ASSERT_EFI_ERROR (Status);\r\n");\r
1516 }\r
1517 fileBuffer.append("}\r\n");\r
1518 }\r
1519\r
1520 /**\r
1521 LibDestructorToAutogenc\r
1522 \r
1523 This function writes library destructor list to AutoGen.c. The library\r
1524 destructor's parameter and return value depend on module type.\r
1525 \r
1526 @param libInstanceList\r
1527 List of library destructor name.\r
1528 @param moduleType\r
1529 Module type.\r
1530 @param fileBuffer\r
1531 String buffer for AutoGen.c\r
1532 @throws Exception\r
1533 **/\r
1534 void LibDestructorToAutogenC(List<String[]> libInstanceList,\r
1535 String moduleType, StringBuffer fileBuffer) throws EdkException {\r
1536 boolean isFirst = true;\r
1537 for (int i = 0; i < libInstanceList.size(); i++) {\r
1538 if (libInstanceList.get(i)[1].equalsIgnoreCase(EdkDefinitions.MODULE_TYPE_BASE)) {\r
1539 fileBuffer.append("RETURN_STATUS\r\n");\r
1540 fileBuffer.append("EFIAPI\r\n");\r
1541 fileBuffer.append(libInstanceList.get(i)[0]);\r
1542 fileBuffer.append(" (\r\n");\r
1543 fileBuffer.append(" VOID\r\n");\r
1544 fileBuffer.append(" );\r\n");\r
1545 } else {\r
1546 switch (CommonDefinition.getModuleType(moduleType)) {\r
1547 case CommonDefinition.ModuleTypeBase:\r
1548 fileBuffer.append("RETURN_STATUS\r\n");\r
1549 fileBuffer.append("EFIAPI\r\n");\r
1550 fileBuffer.append(libInstanceList.get(i)[0]);\r
1551 fileBuffer.append(" (\r\n");\r
1552 fileBuffer.append(" VOID\r\n");\r
1553 fileBuffer.append(" );\r\n");\r
1554 break;\r
1555 case CommonDefinition.ModuleTypePeiCore:\r
1556 case CommonDefinition.ModuleTypePeim:\r
1557 fileBuffer.append("EFI_STATUS\r\n");\r
1558 fileBuffer.append("EFIAPI\r\n");\r
1559 fileBuffer.append(libInstanceList.get(i)[0]);\r
1560 fileBuffer.append(" (\r\n");\r
1561 fileBuffer.append(" IN EFI_FFS_FILE_HEADER *FfsHeader,\r\n");\r
1562 fileBuffer.append(" IN EFI_PEI_SERVICES **PeiServices\r\n");\r
1563 fileBuffer.append(" );\r\n");\r
1564 break;\r
1565 case CommonDefinition.ModuleTypeDxeCore:\r
1566 case CommonDefinition.ModuleTypeDxeDriver:\r
1567 case CommonDefinition.ModuleTypeDxeRuntimeDriver:\r
1568 case CommonDefinition.ModuleTypeDxeSmmDriver:\r
1569 case CommonDefinition.ModuleTypeDxeSalDriver:\r
1570 case CommonDefinition.ModuleTypeUefiDriver:\r
1571 case CommonDefinition.ModuleTypeUefiApplication:\r
1572 fileBuffer.append("EFI_STATUS\r\n");\r
1573 fileBuffer.append("EFIAPI\r\n");\r
1574 fileBuffer.append(libInstanceList.get(i)[0]);\r
1575 fileBuffer.append(" (\r\n");\r
1576 fileBuffer.append(" IN EFI_HANDLE ImageHandle,\r\n");\r
1577 fileBuffer.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");\r
1578 fileBuffer.append(" );\r\n");\r
1579 break;\r
1580 }\r
1581 }\r
1582 }\r
1583\r
1584 //\r
1585 // Write ProcessLibraryDestructor list to autogen.c\r
1586 //\r
1587 switch (CommonDefinition.getModuleType(moduleType)) {\r
1588 case CommonDefinition.ModuleTypeBase:\r
1589 case CommonDefinition.ModuleTypePeiCore:\r
1590 case CommonDefinition.ModuleTypePeim:\r
1591 break;\r
1592 case CommonDefinition.ModuleTypeDxeCore:\r
1593 case CommonDefinition.ModuleTypeDxeDriver:\r
1594 case CommonDefinition.ModuleTypeDxeRuntimeDriver:\r
1595 case CommonDefinition.ModuleTypeDxeSmmDriver:\r
1596 case CommonDefinition.ModuleTypeDxeSalDriver:\r
1597 case CommonDefinition.ModuleTypeUefiDriver:\r
1598 case CommonDefinition.ModuleTypeUefiApplication:\r
1599 fileBuffer.append("VOID\r\n");\r
1600 fileBuffer.append("EFIAPI\r\n");\r
1601 fileBuffer.append("ProcessLibraryDestructorList (\r\n");\r
1602 fileBuffer.append(" IN EFI_HANDLE ImageHandle,\r\n");\r
1603 fileBuffer.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");\r
1604 fileBuffer.append(" )\r\n");\r
1605 fileBuffer.append("{\r\n");\r
1606 //\r
1607 // If no library destructor function, return EFI_SUCCESS.\r
1608 //\r
1609\r
1610 for (int i = 0; i < libInstanceList.size(); i++) {\r
1611 if (isFirst) {\r
1612 fileBuffer.append(" EFI_STATUS Status;\r\n");\r
1613 fileBuffer.append(" Status = EFI_SUCCESS;\r\n");\r
1614 fileBuffer.append("\r\n");\r
1615 isFirst = false;\r
1616 }\r
1617 if (libInstanceList.get(i)[1].equalsIgnoreCase(EdkDefinitions.MODULE_TYPE_BASE)) {\r
1618 fileBuffer.append(" Status = ");\r
1619 fileBuffer.append(libInstanceList.get(i)[0]);\r
1620 fileBuffer.append("();\r\n");\r
1621 fileBuffer.append(" VOID\r\n");\r
1622 } else {\r
1623 fileBuffer.append(" Status = ");\r
1624 fileBuffer.append(libInstanceList.get(i)[0]);\r
1625 fileBuffer.append("(ImageHandle, SystemTable);\r\n");\r
1626 fileBuffer.append(" ASSERT_EFI_ERROR (Status);\r\n");\r
1627 }\r
1628 }\r
1629 fileBuffer.append("}\r\n");\r
1630 break;\r
1631 }\r
1632 }\r
1633\r
1634 /**\r
1635 ExternsDriverBindingToAutoGenC\r
1636 \r
1637 This function is to write DRIVER_BINDING, COMPONENT_NAME,\r
1638 DRIVER_CONFIGURATION, DRIVER_DIAGNOSTIC in AutoGen.c.\r
1639 \r
1640 @param fileBuffer\r
1641 String buffer for AutoGen.c\r
1642 **/\r
1643 void ExternsDriverBindingToAutoGenC(StringBuffer fileBuffer)\r
1644 throws EdkException {\r
1645 //\r
1646 // Get the arry of extern. The driverBindingGroup is a 2 dimension array.\r
1647 // The second dimension is include following element: DriverBinding, \r
1648 // ComponentName, DriverConfiguration, DriverDiag;\r
1649 // \r
1650 String[][] driverBindingGroup = this.saq.getExternProtocolGroup();\r
1651\r
1652\r
1653 //\r
1654 // inital BitMask;\r
1655 // \r
1656 int BitMask = 0;\r
1657\r
1658 //\r
1659 // Write driver binding protocol extern to autogen.c\r
1660 //\r
1661 for (int i = 0; i < driverBindingGroup.length; i++) {\r
1662 if (driverBindingGroup[i][0] != null) {\r
1663 fileBuffer.append("extern EFI_DRIVER_BINDING_PROTOCOL ");\r
1664 fileBuffer.append(driverBindingGroup[i][0]);\r
1665 fileBuffer.append(";\r\n");\r
1666 }\r
1667 }\r
1668\r
1669 //\r
1670 // Write component name protocol extern to autogen.c\r
1671 //\r
1672 if (!componentNamePcd) {\r
1673 for (int i = 0; i < driverBindingGroup.length; i++) {\r
1674 if (driverBindingGroup[i][1]!= null) {\r
1675 if (driverBindingGroup[i][0] != null) {\r
1676 BitMask |= 0x01;\r
1677 fileBuffer.append("extern EFI_COMPONENT_NAME_PROTOCOL ");\r
1678 fileBuffer.append(driverBindingGroup[i][1]);\r
1679 fileBuffer.append(";\r\n");\r
1680 } else {\r
1681 throw new AutoGenException("DriverBinding can't be empty!!");\r
1682 }\r
1683 }\r
1684 }\r
1685 }\r
1686\r
1687 //\r
1688 // Write driver configration protocol extern to autogen.c\r
1689 //\r
1690 for (int i = 0; i < driverBindingGroup.length; i++) {\r
1691 if (driverBindingGroup[i][2] != null) {\r
1692 if (driverBindingGroup[i][0] != null) {\r
1693 BitMask |= 0x02;\r
1694 fileBuffer.append("extern EFI_DRIVER_CONFIGURATION_PROTOCOL ");\r
1695 fileBuffer.append(driverBindingGroup[i][2]);\r
1696 fileBuffer.append(";\r\n");\r
1697 } else {\r
1698 throw new AutoGenException("DriverBinding can't be empty!!");\r
1699 }\r
1700 }\r
1701 }\r
1702\r
1703 //\r
1704 // Write driver dignastic protocol extern to autogen.c\r
1705 //\r
1706 if (!driverDiagnostPcd) {\r
1707 for (int i = 0; i < driverBindingGroup.length; i++) {\r
1708 if (driverBindingGroup[i][3] != null) {\r
1709 if (driverBindingGroup[i][0] != null) {\r
1710 BitMask |= 0x04;\r
1711 fileBuffer.append("extern EFI_DRIVER_DIAGNOSTICS_PROTOCOL ");\r
1712 fileBuffer.append(driverBindingGroup[i][3]);\r
1713 fileBuffer.append(";\r\n");\r
1714 } else {\r
1715 throw new AutoGenException("DriverBinding can't be empty!!");\r
1716 }\r
1717 }\r
1718 }\r
1719 }\r
1720\r
1721\r
1722 //\r
1723 // Write driver module protocol bitmask.\r
1724 //\r
1725 fileBuffer.append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gDriverModelProtocolBitmask = ");\r
1726 fileBuffer.append(Integer.toString(BitMask));\r
1727 fileBuffer.append(";\r\n");\r
1728\r
1729 //\r
1730 // Write driver module protocol list entry\r
1731 //\r
1732 fileBuffer.append("GLOBAL_REMOVE_IF_UNREFERENCED const UINTN _gDriverModelProtocolListEntries = ");\r
1733\r
1734 fileBuffer.append(Integer.toString(driverBindingGroup.length));\r
1735 fileBuffer.append(";\r\n");\r
1736\r
1737 //\r
1738 // Write drive module protocol list to autogen.c\r
1739 //\r
1740 if (driverBindingGroup.length > 0) {\r
1741 fileBuffer.append("GLOBAL_REMOVE_IF_UNREFERENCED const EFI_DRIVER_MODEL_PROTOCOL_LIST _gDriverModelProtocolList[] = {");\r
1742 }\r
1743\r
1744\r
1745 for (int i = 0; i < driverBindingGroup.length; i++) {\r
1746 if (i != 0) {\r
1747 fileBuffer.append(",");\r
1748 }\r
1749 //\r
1750 // DriverBinding\r
1751 // \r
1752 fileBuffer.append("\r\n {\r\n");\r
1753 fileBuffer.append(" &");\r
1754 fileBuffer.append(driverBindingGroup[i][0]);\r
1755 fileBuffer.append(", \r\n");\r
1756\r
1757 //\r
1758 // ComponentName\r
1759 // \r
1760 if (driverBindingGroup[i][1] != null && componentNamePcd != true) {\r
1761 fileBuffer.append(" &");\r
1762 fileBuffer.append(driverBindingGroup[i][1]);\r
1763 fileBuffer.append(", \r\n");\r
1764 } else {\r
1765 fileBuffer.append(" NULL, \r\n");\r
1766 }\r
1767\r
1768 //\r
1769 // DriverConfiguration\r
1770 // \r
1771 if (driverBindingGroup[i][2] != null) {\r
1772 fileBuffer.append(" &");\r
1773 fileBuffer.append(driverBindingGroup[i][2]);\r
1774 fileBuffer.append(", \r\n");\r
1775 } else {\r
1776 fileBuffer.append(" NULL, \r\n");\r
1777 }\r
1778\r
1779 //\r
1780 // DriverDiagnostic\r
1781 // \r
1782 if (driverBindingGroup[i][3] != null && driverDiagnostPcd != true) {\r
1783 fileBuffer.append(" &");\r
1784 fileBuffer.append(driverBindingGroup[i][3]);\r
1785 fileBuffer.append(", \r\n");\r
1786 } else {\r
1787 fileBuffer.append(" NULL, \r\n");\r
1788 }\r
1789 fileBuffer.append(" }");\r
1790 }\r
1791\r
1792 if (driverBindingGroup.length > 0) {\r
1793 fileBuffer.append("\r\n};\r\n");\r
1794 }\r
1795 }\r
1796\r
1797 /**\r
1798 ExternCallBackToAutoGenC\r
1799 \r
1800 This function adds <SetVirtualAddressMapCallBack> and\r
1801 <ExitBootServicesCallBack> infomation to AutoGen.c\r
1802 \r
1803 @param fileBuffer\r
1804 String buffer for AutoGen.c\r
1805 @throws BuildException\r
1806 **/\r
1807 void ExternCallBackToAutoGenC(StringBuffer fileBuffer)\r
1808 throws EdkException {\r
1809 //\r
1810 // Collect module's <SetVirtualAddressMapCallBack> and\r
1811 // <ExitBootServiceCallBack> and add to setVirtualAddList\r
1812 // exitBootServiceList.\r
1813 //\r
1814 String[] setVirtuals = saq.getSetVirtualAddressMapCallBackArray();\r
1815 String[] exitBoots = saq.getExitBootServicesCallBackArray();\r
1816 if (setVirtuals != null) {\r
1817 for (int j = 0; j < setVirtuals.length; j++) {\r
1818 this.setVirtalAddList.add(setVirtuals[j]);\r
1819 }\r
1820 }\r
1821 if (exitBoots != null) {\r
1822 for (int k = 0; k < exitBoots.length; k++) {\r
1823 this.exitBootServiceList.add(exitBoots[k]);\r
1824 }\r
1825 }\r
1826 //\r
1827 // Add c code in autogen.c which relate to <SetVirtualAddressMapCallBack>\r
1828 // and <ExitBootServicesCallBack>\r
1829 //\r
1830 String moduleType = this.moduleId.getModuleType();\r
1831 switch (CommonDefinition.getModuleType(moduleType)) {\r
1832 case CommonDefinition.ModuleTypeDxeDriver:\r
1833 case CommonDefinition.ModuleTypeDxeRuntimeDriver:\r
1834 case CommonDefinition.ModuleTypeDxeSalDriver:\r
1835 case CommonDefinition.ModuleTypeUefiDriver:\r
1836 case CommonDefinition.ModuleTypeUefiApplication:\r
1837 //\r
1838 // If moduleType is one of above, call setVirtualAddressToAutogenC,\r
1839 // and setExitBootServiceToAutogenC.\r
1840 // \r
1841 setVirtualAddressToAutogenC(fileBuffer);\r
1842 setExitBootServiceToAutogenC(fileBuffer);\r
1843 break;\r
1844 default:\r
1845 break;\r
1846 }\r
1847 }\r
1848\r
1849 /**\r
1850 copyFlashMapHToDebugDir\r
1851 \r
1852 This function is to copy the falshmap.h to debug directory and change \r
1853 its name to TianoR8FlashMap.h\r
1854 \r
1855 @param \r
1856 @return\r
1857 **/\r
1858 private void copyFlashMapHToDebugDir() throws AutoGenException{\r
1859\r
1860 File inFile = new File(fvDir + File.separatorChar + CommonDefinition.FLASHMAPH);\r
1861 int size = (int)inFile.length();\r
1862 byte[] buffer = new byte[size];\r
1863 File outFile = new File (this.outputPath + File.separatorChar + CommonDefinition.TIANOR8PLASHMAPH);\r
1864 //\r
1865 // If TianoR8FlashMap.h existed and the flashMap.h don't change,\r
1866 // do nothing.\r
1867 //\r
1868 if ((!outFile.exists()) ||(inFile.lastModified() - outFile.lastModified()) >= 0) {\r
1869 if (inFile.exists()) {\r
1870 try {\r
1871 FileInputStream fis = new FileInputStream (inFile);\r
1872 fis.read(buffer);\r
1873 FileOutputStream fos = new FileOutputStream(outFile);\r
1874 fos.write(buffer);\r
1875 fis.close();\r
1876 fos.close();\r
1877 } catch (IOException e) {\r
1878 throw new AutoGenException("The file, flashMap.h can't be open!");\r
1879 }\r
1880\r
1881 } else {\r
1882 throw new AutoGenException("The file, flashMap.h doesn't exist!");\r
1883 }\r
1884 }\r
1885 }\r
1886\r
1887 /**\r
1888 This function first order the library instances, then collect\r
1889 library instance 's PPI, Protocol, GUID,\r
1890 SetVirtalAddressMapCallBack, ExitBootServiceCallBack, and\r
1891 Destructor, Constructor.\r
1892 \r
1893 @param\r
1894 @return \r
1895 **/\r
1896 private void collectLibInstanceInfo() throws EdkException{\r
1897 int index;\r
1898\r
1899 String libConstructName = null;\r
1900 String libDestructName = null;\r
1901 String libModuleType = null;\r
1902 String[] setVirtuals = null;\r
1903 String[] exitBoots = null;\r
1904\r
1905 ModuleIdentification[] libraryIdList = saq.getLibraryInstance(this.arch);\r
1906\r
1907 if (libraryIdList != null) {\r
1908 //\r
1909 // Reorder library instance sequence.\r
1910 //\r
1911 AutogenLibOrder libOrder = new AutogenLibOrder(libraryIdList,\r
1912 this.arch);\r
1913 List<ModuleIdentification> orderList = libOrder\r
1914 .orderLibInstance();\r
1915\r
1916 if (orderList != null) {\r
1917 //\r
1918 // Process library instance one by one.\r
1919 //\r
1920 for (int i = 0; i < orderList.size(); i++) {\r
1921 //\r
1922 // Get library instance basename.\r
1923 //\r
1924 ModuleIdentification libInstanceId = orderList.get(i);\r
1925\r
1926 //\r
1927 // Get override map\r
1928 //\r
1929\r
1930 Map<String, XmlObject> libDoc = GlobalData.getDoc(libInstanceId, this.arch);\r
1931 saq.push(libDoc);\r
1932 //\r
1933 // Get <PPis>, <Protocols>, <Guids> list of this library\r
1934 // instance.\r
1935 //\r
1936 String[] ppiList = saq.getPpiArray(this.arch);\r
1937 String[] ppiNotifyList = saq.getPpiNotifyArray(this.arch);\r
1938 String[] protocolList = saq.getProtocolArray(this.arch);\r
1939 String[] protocolNotifyList = saq.getProtocolNotifyArray(this.arch);\r
1940 String[] guidList = saq.getGuidEntryArray(this.arch);\r
1941 PackageIdentification[] pkgList = saq.getDependencePkg(this.arch);\r
1942\r
1943 //\r
1944 // Add those ppi, protocol, guid in global ppi,\r
1945 // protocol, guid\r
1946 // list.\r
1947 //\r
1948 for (index = 0; index < ppiList.length; index++) {\r
1949 this.mPpiList.add(ppiList[index]);\r
1950 }\r
1951\r
1952 for (index = 0; index < ppiNotifyList.length; index++) {\r
1953 this.mPpiList.add(ppiNotifyList[index]);\r
1954 }\r
1955\r
1956 for (index = 0; index < protocolList.length; index++) {\r
1957 this.mProtocolList.add(protocolList[index]);\r
1958 }\r
1959\r
1960 for (index = 0; index < protocolNotifyList.length; index++) {\r
1961 this.mProtocolList.add(protocolNotifyList[index]);\r
1962 }\r
1963\r
1964 for (index = 0; index < guidList.length; index++) {\r
1965 this.mGuidList.add(guidList[index]);\r
1966 }\r
1967 for (index = 0; index < pkgList.length; index++) {\r
1968 if (!this.mDepPkgList.contains(pkgList[index])) {\r
1969 this.mDepPkgList.add(pkgList[index]);\r
1970 }\r
1971 }\r
1972\r
1973 //\r
1974 // If not yet parse this library instance's constructor\r
1975 // element,parse it.\r
1976 //\r
1977 libConstructName = saq.getLibConstructorName();\r
1978 libDestructName = saq.getLibDestructorName();\r
1979 libModuleType = saq.getModuleType();\r
1980\r
1981 //\r
1982 // Collect SetVirtualAddressMapCallBack and\r
1983 // ExitBootServiceCallBack.\r
1984 //\r
1985 setVirtuals = saq.getSetVirtualAddressMapCallBackArray();\r
1986 exitBoots = saq.getExitBootServicesCallBackArray();\r
1987 if (setVirtuals != null) {\r
1988 for (int j = 0; j < setVirtuals.length; j++) {\r
1989 this.setVirtalAddList.add(setVirtuals[j]);\r
1990 }\r
1991 }\r
1992 if (exitBoots != null) {\r
1993 for (int k = 0; k < exitBoots.length; k++) {\r
1994 this.exitBootServiceList.add(exitBoots[k]);\r
1995 }\r
1996 }\r
1997 saq.pop();\r
1998 //\r
1999 // Add dependent library instance constructor function.\r
2000 //\r
2001 if (libConstructName != null) {\r
2002 this.libConstructList.add(new String[] {libConstructName, libModuleType});\r
2003 }\r
2004 //\r
2005 // Add dependent library instance destructor fuction.\r
2006 //\r
2007 if (libDestructName != null) {\r
2008 this.libDestructList.add(new String[] {libDestructName, libModuleType});\r
2009 }\r
2010 }\r
2011 }\r
2012 }\r
2013 }\r
2014 private void setVirtualAddressToAutogenC(StringBuffer fileBuffer){\r
2015 //\r
2016 // Entry point lib for these module types needs to know the count\r
2017 // of entryPoint.\r
2018 //\r
2019 fileBuffer.append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED const UINTN _gDriverSetVirtualAddressMapEventCount = ");\r
2020\r
2021 //\r
2022 // If the list is not valid or has no entries set count to zero else\r
2023 // set count to the number of valid entries\r
2024 //\r
2025 int Count = 0;\r
2026 int i = 0;\r
2027 if (this.setVirtalAddList != null) {\r
2028 for (i = 0; i < this.setVirtalAddList.size(); i++) {\r
2029 if (this.setVirtalAddList.get(i).equalsIgnoreCase("")) {\r
2030 break;\r
2031 }\r
2032 }\r
2033 Count = i;\r
2034 }\r
2035\r
2036 fileBuffer.append(Integer.toString(Count));\r
2037 fileBuffer.append(";\r\n\r\n");\r
2038 if (this.setVirtalAddList == null || this.setVirtalAddList.size() == 0) {\r
2039 //\r
2040 // No data so make a NULL list\r
2041 //\r
2042 fileBuffer.append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED const EFI_EVENT_NOTIFY _gDriverSetVirtualAddressMapEvent[] = {\r\n");\r
2043 fileBuffer.append(" NULL\r\n");\r
2044 fileBuffer.append("};\r\n\r\n");\r
2045 } else {\r
2046 //\r
2047 // Write SetVirtualAddressMap function definition.\r
2048 //\r
2049 for (i = 0; i < this.setVirtalAddList.size(); i++) {\r
2050 if (this.setVirtalAddList.get(i).equalsIgnoreCase("")) {\r
2051 break;\r
2052 }\r
2053 fileBuffer.append("VOID\r\n");\r
2054 fileBuffer.append("EFIAPI\r\n");\r
2055 fileBuffer.append(this.setVirtalAddList.get(i));\r
2056 fileBuffer.append(" (\r\n");\r
2057 fileBuffer.append(" IN EFI_EVENT Event,\r\n");\r
2058 fileBuffer.append(" IN VOID *Context\r\n");\r
2059 fileBuffer.append(" );\r\n\r\n");\r
2060 }\r
2061\r
2062 //\r
2063 // Write SetVirtualAddressMap entry point array.\r
2064 //\r
2065 fileBuffer.append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED const EFI_EVENT_NOTIFY _gDriverSetVirtualAddressMapEvent[] = {");\r
2066 for (i = 0; i < this.setVirtalAddList.size(); i++) {\r
2067 if (this.setVirtalAddList.get(i).equalsIgnoreCase("")) {\r
2068 break;\r
2069 }\r
2070\r
2071 if (i == 0) {\r
2072 fileBuffer.append("\r\n ");\r
2073 } else {\r
2074 fileBuffer.append(",\r\n ");\r
2075 }\r
2076\r
2077 fileBuffer.append(this.setVirtalAddList.get(i));\r
2078 }\r
2079 //\r
2080 // add the NULL at the end of _gDriverSetVirtualAddressMapEvent list.\r
2081 //\r
2082 fileBuffer.append(",\r\n NULL");\r
2083 fileBuffer.append("\r\n};\r\n\r\n");\r
2084 }\r
2085 }\r
2086\r
2087\r
2088 private void setExitBootServiceToAutogenC(StringBuffer fileBuffer){\r
2089 //\r
2090 // Entry point lib for these module types needs to know the count.\r
2091 //\r
2092 fileBuffer\r
2093 .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED const UINTN _gDriverExitBootServicesEventCount = ");\r
2094\r
2095 //\r
2096 // If the list is not valid or has no entries set count to zero else\r
2097 // set count to the number of valid entries.\r
2098 //\r
2099 int Count = 0;\r
2100 int i = 0; \r
2101 if (this.exitBootServiceList != null) {\r
2102 for (i = 0; i < this.exitBootServiceList.size(); i++) {\r
2103 if (this.exitBootServiceList.get(i).equalsIgnoreCase("")) {\r
2104 break;\r
2105 }\r
2106 }\r
2107 Count = i;\r
2108 }\r
2109 fileBuffer.append(Integer.toString(Count));\r
2110 fileBuffer.append(";\r\n\r\n");\r
2111\r
2112 if (this.exitBootServiceList == null || this.exitBootServiceList.size() == 0) {\r
2113 // \r
2114 // No data so make a NULL list.\r
2115 //\r
2116 fileBuffer.append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED const EFI_EVENT_NOTIFY _gDriverExitBootServicesEvent[] = {\r\n");\r
2117 fileBuffer.append(" NULL\r\n");\r
2118 fileBuffer.append("};\r\n\r\n");\r
2119 } else {\r
2120 //\r
2121 // Write DriverExitBootServices function definition.\r
2122 //\r
2123 for (i = 0; i < this.exitBootServiceList.size(); i++) {\r
2124 if (this.exitBootServiceList.get(i).equalsIgnoreCase("")) {\r
2125 break;\r
2126 }\r
2127\r
2128 fileBuffer.append("VOID\r\n");\r
2129 fileBuffer.append("EFIAPI\r\n");\r
2130 fileBuffer.append(this.exitBootServiceList.get(i));\r
2131 fileBuffer.append(" (\r\n");\r
2132 fileBuffer.append(" IN EFI_EVENT Event,\r\n");\r
2133 fileBuffer.append(" IN VOID *Context\r\n");\r
2134 fileBuffer.append(" );\r\n\r\n");\r
2135 }\r
2136\r
2137 //\r
2138 // Write DriverExitBootServices entry point array.\r
2139 //\r
2140 fileBuffer.append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED const EFI_EVENT_NOTIFY _gDriverExitBootServicesEvent[] = {");\r
2141 for (i = 0; i < this.exitBootServiceList.size(); i++) {\r
2142 if (this.exitBootServiceList.get(i).equalsIgnoreCase("")) {\r
2143 break;\r
2144 }\r
2145\r
2146 if (i == 0) {\r
2147 fileBuffer.append("\r\n ");\r
2148 } else {\r
2149 fileBuffer.append(",\r\n ");\r
2150 }\r
2151 fileBuffer.append(this.exitBootServiceList.get(i));\r
2152 }\r
2153\r
2154 fileBuffer.append(",\r\n NULL");\r
2155 fileBuffer.append("\r\n};\r\n\r\n");\r
2156 } \r
2157 }\r
2158 /**\r
2159 setPcdComponentName\r
2160 \r
2161 Get the Pcd Value of ComponentName to \r
2162 decide whether need to disable the componentName. \r
2163 \r
2164 **/\r
2165 public void setPcdComponentName (){\r
2166 String pcdValue = null;\r
2167 pcdValue = saq.getPcdValueBycName("PcdComponentNameDisable");\r
2168 if (pcdValue != null && pcdValue.equalsIgnoreCase("true")) {\r
2169 this.componentNamePcd = true;\r
2170 }\r
2171 }\r
2172\r
2173 /**\r
2174 setPcdDriverDiagnostic \r
2175 \r
2176 Get the Pcd Value of DriverDiagnostic to \r
2177 decide whether need to disable DriverDiagnostic.\r
2178 \r
2179 **/\r
2180 public void setPcdDriverDiagnostic (){\r
2181 String pcdValue = null;\r
2182 pcdValue = saq.getPcdValueBycName("PcdDriverDiagnosticsDisable");\r
2183 if (pcdValue != null && pcdValue.equalsIgnoreCase("true")) {\r
2184 this.driverDiagnostPcd = true;\r
2185 }\r
2186 } \r
2187\r
2188}\r