4 This class is to generate Autogen.h and Autogen.c according to module surface area
5 or library surface area.
7 Copyright (c) 2006, Intel Corporation
8 All rights reserved. This program and the accompanying materials
9 are licensed and made available under the terms and conditions of the BSD License
10 which accompanies this distribution. The full text of the license may be found at
11 http://opensource.org/licenses/bsd-license.php
13 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
14 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
18 package org
.tianocore
.build
.autogen
;
20 import org
.tianocore
.build
.global
.GlobalData
;
21 import org
.tianocore
.build
.global
.Spd
;
22 import org
.tianocore
.build
.global
.SurfaceAreaQuery
;
23 import org
.tianocore
.build
.id
.ModuleIdentification
;
24 import org
.tianocore
.build
.id
.PackageIdentification
;
25 import org
.tianocore
.GuidsDocument
;
26 import org
.tianocore
.LibraryClassDocument
.LibraryClass
;
27 import org
.tianocore
.PPIsDocument
;
28 import org
.tianocore
.ProtocolsDocument
;
29 import org
.tianocore
.build
.pcd
.action
.PCDAutoGenAction
;
30 import org
.tianocore
.build
.exception
.*;
31 import org
.tianocore
.logger
.EdkLog
;
32 import org
.apache
.tools
.ant
.BuildException
;
33 import org
.apache
.xmlbeans
.XmlObject
;
36 import java
.io
.FileReader
;
37 import java
.io
.FileWriter
;
38 import java
.util
.ArrayList
;
39 import java
.util
.HashSet
;
40 import java
.util
.Iterator
;
41 import java
.util
.LinkedList
;
42 import java
.util
.List
;
47 * This class is to generate Autogen.h and Autogen.c according to module surface
48 * area or library surface area.
50 public class AutoGen
{
52 // / The output path of Autogen.h and Autogen.c
54 private String outputPath
;
57 // / The base name of module or library.
59 private ModuleIdentification moduleId
;
62 // / The build architecture
67 // / PcdAutogen instance which is used to manage how to generate the PCD
70 private PCDAutoGenAction myPcdAutogen
;
73 // / The protocl list which records in module or library surface area and
74 // / it's dependence on library instance surface area.
76 private Set
<String
> mProtocolList
= new HashSet
<String
>();
79 // / The Ppi list which recorded in module or library surface area and its
80 // / dependency on library instance surface area.
82 private Set
<String
> mPpiList
= new HashSet
<String
>();
85 // / The Guid list which recoreded in module or library surface area and it's
86 // / dependence on library instance surface area.
88 private Set
<String
> mGuidList
= new HashSet
<String
>();
91 // The dependence package list which recoreded in module or library surface
92 // area and it's dependence on library instance surface are.
94 private List
<PackageIdentification
> mDepPkgList
= new LinkedList
<PackageIdentification
>();
98 * This function mainly initialize some member variable.
101 * Output path of AutoGen file.
105 * Target architecture.
107 public AutoGen(String outputPath
, ModuleIdentification moduleId
, String arch
) {
108 this.outputPath
= outputPath
;
109 this.moduleId
= moduleId
;
117 * This function save the content in stringBuffer to file.
122 * The content of AutoGen file in buffer.
123 * @return "true" successful, "false" failed.
125 private boolean saveFile(String fileName
, StringBuffer fileBuffer
) {
127 File autoGenH
= new File(fileName
);
130 // if the file exists, compare their content
132 if (autoGenH
.exists()) {
133 FileReader fIn
= new FileReader(autoGenH
);
134 char[] oldFileBuffer
= new char[(int) autoGenH
.length()];
135 fIn
.read(oldFileBuffer
, 0, (int) autoGenH
.length());
139 // if we got the same file, don't re-generate it to prevent
140 // sources depending on it from re-building
142 if (fileBuffer
.toString().compareTo(new String(oldFileBuffer
)) == 0) {
146 FileWriter fOut
= new FileWriter(autoGenH
);
147 fOut
.write(fileBuffer
.toString());
149 } catch (Exception e
) {
156 * genAutogen function
158 * This function call libGenAutoGen or moduleGenAutogen function, which
159 * dependence on generate library autogen or module autogen.
161 * @throws BuildException
162 * Failed to creat AutoGen.c & AutoGen.h.
164 public void genAutogen() throws BuildException
{
167 // If outputPath do not exist, create it.
169 File path
= new File(outputPath
);
173 // Check current is library or not, then call the corresponding
176 if (this.moduleId
.isLibrary()) {
182 } catch (Exception e
) {
183 throw new BuildException(
184 "Failed to create AutoGen.c & AutoGen.h!\n"
190 * moduleGenAutogen function
192 * This function generates AutoGen.c & AutoGen.h for module.
194 * @throws BuildException
195 * Faile to create module AutoGen.c & AutoGen.h.
197 void moduleGenAutogen() throws BuildException
{
202 } catch (Exception e
) {
203 throw new BuildException(
204 "Faile to create module AutoGen.c & AutoGen.h!\n"
210 * libGenAutogen function
212 * This function generates AutoGen.c & AutoGen.h for library.
214 * @throws BuildException
215 * Faile to create library AutoGen.c & AutoGen.h
217 void libGenAutogen() throws BuildException
{
221 } catch (Exception e
) {
222 throw new BuildException(
223 "Faile to create library AutoGen.c & AutoGen.h!\n"
231 * This function generates AutoGen.h for module.
233 * @throws BuildException
234 * Failed to generate AutoGen.h.
236 void moduleGenAutogenH() throws AutoGenException
{
238 Set
<String
> libClassIncludeH
;
240 // List<String> headerFileList;
241 List
<String
> headerFileList
;
243 StringBuffer fileBuffer
= new StringBuffer(8192);
246 // Write Autogen.h header notation
248 fileBuffer
.append(CommonDefinition
.autogenHNotation
);
251 // Add #ifndef ${BaseName}_AUTOGENH
252 // #def ${BseeName}_AUTOGENH
254 fileBuffer
.append("#ifndef " + this.moduleId
.getName().toUpperCase()
256 fileBuffer
.append("#define " + this.moduleId
.getName().toUpperCase()
257 + "_AUTOGENH\r\n\r\n");
260 // Write the specification version and release version at the begine
261 // of autogen.h file.
262 // Note: the specification version and release version should
263 // be got from module surface area instead of hard code by it's
266 moduleType
= SurfaceAreaQuery
.getModuleType();
267 // switch (CommonDefinition.getModuleType(moduleType)) {
268 // case CommonDefinition.ModuleTypeDxeCore:
269 // case CommonDefinition.ModuleTypeDxeDriver:
270 // case CommonDefinition.ModuleTypeDxeRuntimeDriver:
271 // case CommonDefinition.ModuleTypeDxeSmmDriver:
272 // case CommonDefinition.ModuleTypeDxeSalDriver:
273 // case CommonDefinition.ModuleTypeUefiDriver:
274 // case CommonDefinition.ModuleTypeUefiApplication:
275 // fileBuffer.append(CommonDefinition.autoGenHLine1);
278 // fileBuffer.append(CommonDefinition.autoGenHVersionDefault);
281 // switch (CommonDefinition.getModuleType(moduleType)) {
282 // case CommonDefinition.ModuleTypeUefiDriver:
283 // case CommonDefinition.ModuleTypeUefiApplication:
284 // fileBuffer.append(CommonDefinition.autoGenHReleaseDefault);
287 // fileBuffer.append(CommonDefinition.autoGenHLine2);
292 // Add "extern int __make_me_compile_correctly;" at begin of
295 fileBuffer
.append(CommonDefinition
.autoGenHbegin
);
298 // Put EFI_SPECIFICATION_VERSION, and EDK_RELEASE_VERSION.
300 String
[] specList
= SurfaceAreaQuery
.getExternSpecificaiton();
301 for (int i
= 0; i
< specList
.length
; i
++) {
302 fileBuffer
.append(CommonDefinition
.marcDefineStr
+ specList
[i
]
306 // Write consumed package's mdouleInfo related .h file to autogen.h
308 // PackageIdentification[] consumedPkgIdList = SurfaceAreaQuery
309 // .getDependencePkg(this.arch);
310 PackageIdentification
[] consumedPkgIdList
= SurfaceAreaQuery
311 .getDependencePkg(null);
312 if (consumedPkgIdList
!= null) {
313 headerFileList
= depPkgToAutogenH(consumedPkgIdList
, moduleType
);
314 item
= headerFileList
.iterator();
315 while (item
.hasNext()) {
316 fileBuffer
.append(item
.next().toString());
321 // Write library class's related *.h file to autogen.h.
323 String
[] libClassList
= SurfaceAreaQuery
324 .getLibraryClasses(CommonDefinition
.AlwaysConsumed
);
325 if (libClassList
!= null) {
326 libClassIncludeH
= LibraryClassToAutogenH(libClassList
);
327 item
= libClassIncludeH
.iterator();
328 while (item
.hasNext()) {
329 fileBuffer
.append(item
.next().toString());
333 libClassList
= SurfaceAreaQuery
334 .getLibraryClasses(CommonDefinition
.AlwaysProduced
);
335 if (libClassList
!= null) {
336 libClassIncludeH
= LibraryClassToAutogenH(libClassList
);
337 item
= libClassIncludeH
.iterator();
338 while (item
.hasNext()) {
339 fileBuffer
.append(item
.next().toString());
342 fileBuffer
.append("\r\n");
345 // Write PCD autogen information to AutoGen.h.
347 if (this.myPcdAutogen
!= null) {
348 fileBuffer
.append("\r\n");
349 fileBuffer
.append(this.myPcdAutogen
.OutputH());
353 // Append the #endif at AutoGen.h
355 fileBuffer
.append("#endif\r\n");
358 // Save string buffer content in AutoGen.h.
360 if (!saveFile(outputPath
+ File
.separatorChar
+ "AutoGen.h", fileBuffer
)) {
361 throw new BuildException("Failed to generate AutoGen.h !!!");
368 * This function generates AutoGen.c for module.
370 * @throws BuildException
371 * Failed to generate AutoGen.c.
373 void moduleGenAutogenC() throws AutoGenException
{
375 StringBuffer fileBuffer
= new StringBuffer(8192);
377 // Write Autogen.c header notation
379 fileBuffer
.append(CommonDefinition
.autogenCNotation
);
382 // Write #include <AutoGen.h> at beginning of AutoGen.c
384 fileBuffer
.append(CommonDefinition
.includeAutogenH
);
387 // Get the native MSA file infomation. Since before call autogen,
388 // the MSA native <Externs> information were overrided. So before
389 // process <Externs> it should be set the DOC as the Native MSA info.
391 Map
<String
, XmlObject
> doc
= GlobalData
.getNativeMsa(this.moduleId
);
392 SurfaceAreaQuery
.push(doc
);
395 // DriverBinding/ComponentName/DriverConfiguration/DriverDialog
399 ExternsDriverBindingToAutoGenC(fileBuffer
);
402 // Write DriverExitBootServicesEvent/DriverSetVirtualAddressMapEvent
405 ExternCallBackToAutoGenC(fileBuffer
);
408 // Write EntryPoint to autgoGen.c
410 String
[] entryPointList
= SurfaceAreaQuery
.getModuleEntryPointArray();
411 EntryPointToAutoGen(CommonDefinition
.remDupString(entryPointList
), fileBuffer
);
415 // Restore the DOC which include the FPD module info.
417 SurfaceAreaQuery
.pop();
420 // Write Guid to autogen.c
422 String guid
= CommonDefinition
.formatGuidName(SurfaceAreaQuery
426 .append("GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiCallerIdGuid = {");
428 throw new AutoGenException("Guid value must set!\n");
432 // Formate Guid as ANSI c form.Example:
433 // {0xd2b2b828, 0x826, 0x48a7,{0xb3, 0xdf, 0x98, 0x3c, 0x0, 0x60, 0x24,
437 fileBuffer
.append(guid
);
438 fileBuffer
.append("};\r\n");
441 // Generate library instance consumed protocol, guid, ppi, pcd list.
442 // Save those to this.protocolList, this.ppiList, this.pcdList,
443 // this.guidList. Write Consumed library constructor and desconstuct to
446 LibInstanceToAutogenC(fileBuffer
);
449 // Get module dependent Package identification.
451 PackageIdentification
[] packages
= SurfaceAreaQuery
.getDependencePkg(this.arch
);
452 for (int i
= 0; i
< packages
.length
; i
++){
453 if (!this.mDepPkgList
.contains(packages
[i
])){
454 this.mDepPkgList
.add(packages
[i
]);
460 // Write consumed ppi, guid, protocol to autogen.c
462 ProtocolGuidToAutogenC(fileBuffer
);
463 PpiGuidToAutogenC(fileBuffer
);
464 GuidGuidToAutogenC(fileBuffer
);
467 // Call pcd autogen. PCDAutoGenAction tool only need module name and
468 // isPcdEmulatedDriver as parameter. Library inherits PCD and module's
469 // PCD information has been collected in FPDParser task by
471 // Note : when PCD image tool ready,
472 // isPCDEmulatedDriver parameter will be removed.
475 // this.myPcdAutogen = new PCDAutoGenAction(moduleId.getName(),
476 // moduleId.getGuid(), moduleId.getPackage().getName(), moduleId.getPackage().getGuid(),this.arch,moduleId.getVersion(),false, null);
477 this.myPcdAutogen
= new PCDAutoGenAction(moduleId
.getName(),null,null,null, this.arch
,null,false, null);
478 this.myPcdAutogen
.execute();
479 } catch (Exception e
) {
480 throw new BuildException("PCD Autogen failed:" + e
.getMessage());
483 if (this.myPcdAutogen
!= null) {
484 fileBuffer
.append("\r\n");
485 fileBuffer
.append(this.myPcdAutogen
.OutputC());
488 if (!saveFile(outputPath
+ File
.separatorChar
+ "AutoGen.c", fileBuffer
)) {
489 throw new BuildException("Failed to generate AutoGen.c !!!");
497 * This function generates AutoGen.h for library.
499 * @throws BuildException
500 * Failed to generate AutoGen.c.
502 void libGenAutogenH() throws AutoGenException
{
504 Set
<String
> libClassIncludeH
;
506 List
<String
> headerFileList
;
508 StringBuffer fileBuffer
= new StringBuffer(10240);
511 // Write Autogen.h header notation
513 fileBuffer
.append(CommonDefinition
.autogenHNotation
);
516 // Add #ifndef ${BaseName}_AUTOGENH
517 // #def ${BseeName}_AUTOGENH
519 fileBuffer
.append("#ifndef " + this.moduleId
.getName().toUpperCase()
521 fileBuffer
.append("#define " + this.moduleId
.getName().toUpperCase()
522 + "_AUTOGENH\r\n\r\n");
525 // Write EFI_SPECIFICATION_VERSION and EDK_RELEASE_VERSION
526 // to autogen.h file.
527 // Note: the specification version and release version should
528 // be get from module surface area instead of hard code.
530 fileBuffer
.append(CommonDefinition
.autoGenHbegin
);
531 String
[] specList
= SurfaceAreaQuery
.getExternSpecificaiton();
532 for (int i
= 0; i
< specList
.length
; i
++) {
533 fileBuffer
.append(CommonDefinition
.marcDefineStr
+ specList
[i
]
536 // fileBuffer.append(CommonDefinition.autoGenHLine1);
537 // fileBuffer.append(CommonDefinition.autoGenHLine2);
540 // Write consumed package's mdouleInfo related *.h file to autogen.h.
542 moduleType
= SurfaceAreaQuery
.getModuleType();
543 PackageIdentification
[] cosumedPkglist
= SurfaceAreaQuery
544 .getDependencePkg(this.arch
);
545 headerFileList
= depPkgToAutogenH(cosumedPkglist
, moduleType
);
546 item
= headerFileList
.iterator();
547 while (item
.hasNext()) {
548 fileBuffer
.append(item
.next().toString());
551 // Write library class's related *.h file to autogen.h
553 String
[] libClassList
= SurfaceAreaQuery
554 .getLibraryClasses(CommonDefinition
.AlwaysConsumed
);
555 if (libClassList
!= null) {
556 libClassIncludeH
= LibraryClassToAutogenH(libClassList
);
557 item
= libClassIncludeH
.iterator();
558 while (item
.hasNext()) {
559 fileBuffer
.append(item
.next().toString());
563 libClassList
= SurfaceAreaQuery
564 .getLibraryClasses(CommonDefinition
.AlwaysProduced
);
565 if (libClassList
!= null) {
566 libClassIncludeH
= LibraryClassToAutogenH(libClassList
);
567 item
= libClassIncludeH
.iterator();
568 while (item
.hasNext()) {
569 fileBuffer
.append(item
.next().toString());
572 fileBuffer
.append("\r\n");
575 // Write PCD information to library AutoGen.h.
577 if (this.myPcdAutogen
!= null) {
578 fileBuffer
.append("\r\n");
579 fileBuffer
.append(this.myPcdAutogen
.OutputH());
583 // Append the #endif at AutoGen.h
585 fileBuffer
.append("#endif\r\n");
588 // Save content of string buffer to AutoGen.h file.
590 if (!saveFile(outputPath
+ File
.separatorChar
+ "AutoGen.h", fileBuffer
)) {
591 throw new BuildException("Failed to generate AutoGen.h !!!");
598 * This function generates AutoGen.h for library.
600 * @throws BuildException
601 * Failed to generate AutoGen.c.
603 void libGenAutogenC() throws BuildException
{
604 StringBuffer fileBuffer
= new StringBuffer(10240);
607 // Write Autogen.c header notation
609 fileBuffer
.append(CommonDefinition
.autogenCNotation
);
611 fileBuffer
.append(CommonDefinition
.autoGenCLine1
);
612 fileBuffer
.append("\r\n");
615 // Call pcd autogen. PCDAutoGenAction tool only need module name and
616 // isPcdEmulatedDriver as parameter. Library inherit PCD and module's
617 // PCD information has been collected in FPDParser task by
619 // Note : when PCD image tool ready,
620 // isPCDEmulatedDriver parameter will be removed.
623 // this.myPcdAutogen = new PCDAutoGenAction(this.moduleId.getName(),
624 // this.moduleId.getGuid(),moduleId.getPackage().getName(),moduleId.getPackage().getGuid(), this.arch, moduleId.getVersion(),true, SurfaceAreaQuery.getModulePcdEntryNameArray());
625 this.myPcdAutogen
= new PCDAutoGenAction(this.moduleId
.getName(),
632 SurfaceAreaQuery
.getModulePcdEntryNameArray());
634 this.myPcdAutogen
.execute();
635 } catch (Exception e
) {
636 throw new BuildException(e
.getMessage());
639 if (this.myPcdAutogen
!= null) {
640 fileBuffer
.append("\r\n");
641 fileBuffer
.append(this.myPcdAutogen
.OutputC());
644 if (!saveFile(outputPath
+ File
.separatorChar
+ "AutoGen.c", fileBuffer
)) {
645 throw new BuildException("Failed to generate AutoGen.c !!!");
650 * LibraryClassToAutogenH
652 * This function returns *.h files declared by library classes which are
653 * consumed or produced by current build module or library.
655 * @param libClassList
656 * List of library class which consumed or produce by current
657 * build module or library.
658 * @return includeStrList List of *.h file.
660 Set
<String
> LibraryClassToAutogenH(String
[] libClassList
)
661 throws AutoGenException
{
662 Set
<String
> includStrList
= new HashSet
<String
>();
663 String includerName
[];
667 // Get include file from GlobalData's SPDTable according to
668 // library class name.
671 for (int i
= 0; i
< libClassList
.length
; i
++) {
672 includerName
= GlobalData
.getLibraryClassHeaderFiles(
673 SurfaceAreaQuery
.getDependencePkg(this.arch
),
675 if (includerName
== null) {
676 throw new AutoGenException("Can not find library class ["
677 + libClassList
[i
] + "] declaration in every packages. ");
679 for (int j
= 0; j
< includerName
.length
; j
++) {
680 String includeNameStr
= includerName
[j
];
681 if (includeNameStr
!= null) {
682 str
= CommonDefinition
.include
+ " " + "<";
683 str
= str
+ includeNameStr
+ ">\r\n";
684 includStrList
.add(str
);
685 includeNameStr
= null;
689 return includStrList
;
695 * This function add include file in AutoGen.h file.
697 * @param packageNameList
698 * List of module depended package.
703 List
<String
> depPkgToAutogenH(PackageIdentification
[] packageNameList
,
704 String moduleType
) throws AutoGenException
{
706 List
<String
> includeStrList
= new LinkedList
<String
>();
708 String includeStr
= "";
711 // Get include file from moduleInfo file
713 for (int i
= 0; i
< packageNameList
.length
; i
++) {
714 pkgHeader
= GlobalData
.getPackageHeaderFiles(packageNameList
[i
],
716 if (pkgHeader
== null) {
717 throw new AutoGenException("Can not find package ["
719 + "] declaration in every packages. ");
720 } else if (!pkgHeader
.equalsIgnoreCase("")) {
721 includeStr
= CommonDefinition
.include
+ " <" + pkgHeader
723 includeStrList
.add(includeStr
);
727 return includeStrList
;
731 * EntryPointToAutoGen
733 * This function convert <ModuleEntryPoint> & <ModuleUnloadImage>
734 * information in mas to AutoGen.c
736 * @param entryPointList
737 * List of entry point.
739 * String buffer fo AutoGen.c.
742 void EntryPointToAutoGen(String
[] entryPointList
, StringBuffer fileBuffer
)
743 throws BuildException
{
745 String typeStr
= SurfaceAreaQuery
.getModuleType();
748 // The parameters and return value of entryPoint is difference
749 // for difference module type.
751 switch (CommonDefinition
.getModuleType(typeStr
)) {
753 case CommonDefinition
.ModuleTypePeiCore
:
754 if (entryPointList
== null ||entryPointList
.length
!= 1 ) {
755 throw new BuildException(
756 "Module type = 'PEI_CORE', only have one module entry point!");
758 fileBuffer
.append("EFI_STATUS\r\n");
759 fileBuffer
.append("EFIAPI\r\n");
760 fileBuffer
.append(entryPointList
[0]);
761 fileBuffer
.append(" (\r\n");
763 .append(" IN EFI_PEI_STARTUP_DESCRIPTOR *PeiStartupDescriptor,\r\n");
765 .append(" IN VOID *OldCoreData\r\n");
766 fileBuffer
.append(" );\r\n\r\n");
768 fileBuffer
.append("EFI_STATUS\r\n");
769 fileBuffer
.append("EFIAPI\r\n");
770 fileBuffer
.append("ProcessModuleEntryPointList (\r\n");
772 .append(" IN EFI_PEI_STARTUP_DESCRIPTOR *PeiStartupDescriptor,\r\n");
774 .append(" IN VOID *OldCoreData\r\n");
775 fileBuffer
.append(" )\r\n\r\n");
776 fileBuffer
.append("{\r\n");
777 fileBuffer
.append(" return ");
778 fileBuffer
.append(entryPointList
[0]);
779 fileBuffer
.append(" (PeiStartupDescriptor, OldCoreData);\r\n");
780 fileBuffer
.append("}\r\n\r\n");
784 case CommonDefinition
.ModuleTypeDxeCore
:
785 fileBuffer
.append("const UINT32 _gUefiDriverRevision = 0;\r\n");
786 if (entryPointList
== null || entryPointList
.length
!= 1) {
787 throw new BuildException(
788 "Module type = 'DXE_CORE', only have one module entry point!");
791 fileBuffer
.append("VOID\r\n");
792 fileBuffer
.append("EFIAPI\r\n");
793 fileBuffer
.append(entryPointList
[0]);
794 fileBuffer
.append(" (\n");
795 fileBuffer
.append(" IN VOID *HobStart\r\n");
796 fileBuffer
.append(" );\r\n\r\n");
798 fileBuffer
.append("VOID\r\n");
799 fileBuffer
.append("EFIAPI\r\n");
800 fileBuffer
.append("ProcessModuleEntryPointList (\r\n");
801 fileBuffer
.append(" IN VOID *HobStart\r\n");
802 fileBuffer
.append(" )\r\n\r\n");
803 fileBuffer
.append("{\r\n");
804 fileBuffer
.append(" ");
805 fileBuffer
.append(entryPointList
[0]);
806 fileBuffer
.append(" (HobStart);\r\n");
807 fileBuffer
.append("}\r\n\r\n");
811 case CommonDefinition
.ModuleTypePeim
:
812 int entryPointCount
= 0;
814 .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT32 _gPeimRevision = 0;\r\n");
815 if (entryPointList
== null || entryPointList
.length
== 0) {
816 fileBuffer
.append("EFI_STATUS\r\n");
817 fileBuffer
.append("EFIAPI\r\n");
818 fileBuffer
.append("ProcessModuleEntryPointList (\r\n");
819 fileBuffer
.append(" IN EFI_FFS_FILE_HEADER *FfsHeader,\r\n");
820 fileBuffer
.append(" IN EFI_PEI_SERVICES **PeiServices\r\n");
821 fileBuffer
.append(" )\r\n\r\n");
822 fileBuffer
.append("{\r\n");
823 fileBuffer
.append(" return EFI_SUCCESS;\r\n");
824 fileBuffer
.append("}\r\n\r\n");
827 for (int i
= 0; i
< entryPointList
.length
; i
++) {
828 fileBuffer
.append("EFI_STATUS\r\n");
829 fileBuffer
.append("EFIAPI\r\n");
830 fileBuffer
.append(entryPointList
[i
]);
831 fileBuffer
.append(" (\r\n");
833 .append(" IN EFI_FFS_FILE_HEADER *FfsHeader,\r\n");
835 .append(" IN EFI_PEI_SERVICES **PeiServices\r\n");
836 fileBuffer
.append(" );\r\n");
841 fileBuffer
.append("EFI_STATUS\r\n");
842 fileBuffer
.append("EFIAPI\r\n");
843 fileBuffer
.append("ProcessModuleEntryPointList (\r\n");
844 fileBuffer
.append(" IN EFI_FFS_FILE_HEADER *FfsHeader,\r\n");
845 fileBuffer
.append(" IN EFI_PEI_SERVICES **PeiServices\r\n");
846 fileBuffer
.append(" )\r\n\r\n");
847 fileBuffer
.append("{\r\n");
848 if (entryPointCount
== 1) {
849 fileBuffer
.append(" return ");
850 fileBuffer
.append(entryPointList
[0]);
851 fileBuffer
.append(" (FfsHeader, PeiServices);\r\n");
853 fileBuffer
.append(" EFI_STATUS Status;\r\n");
854 fileBuffer
.append(" EFI_STATUS CombinedStatus;\r\n\r\n");
855 fileBuffer
.append(" CombinedStatus = EFI_LOAD_ERROR;\r\n\r\n");
856 for (int i
= 0; i
< entryPointList
.length
; i
++) {
857 if (!entryPointList
[i
].equals("")) {
858 fileBuffer
.append(" Status = ");
859 fileBuffer
.append(entryPointList
[i
]);
860 fileBuffer
.append(" (FfsHeader, PeiServices);\r\n");
862 .append(" if (!EFI_ERROR (Status) || EFI_ERROR (CombinedStatus)) {\r\n");
863 fileBuffer
.append(" CombinedStatus = Status;\r\n");
864 fileBuffer
.append(" }\r\n\r\n");
869 fileBuffer
.append(" return CombinedStatus;\r\n");
871 fileBuffer
.append("}\r\n\r\n");
874 case CommonDefinition
.ModuleTypeDxeSmmDriver
:
877 // If entryPoint is null, create an empty ProcessModuleEntryPointList
880 if (entryPointList
== null || entryPointList
.length
== 0){
882 .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gDriverEntryPointCount = ");
883 fileBuffer
.append(Integer
.toString(entryPointCount
));
884 fileBuffer
.append(";\r\n");
885 fileBuffer
.append("EFI_STATUS\r\n");
886 fileBuffer
.append("EFIAPI\r\n");
887 fileBuffer
.append("ProcessModuleEntryPointList (\r\n");
888 fileBuffer
.append(" IN EFI_HANDLE ImageHandle,\r\n");
889 fileBuffer
.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");
890 fileBuffer
.append(" )\r\n\r\n");
891 fileBuffer
.append("{\r\n");
892 fileBuffer
.append(" return EFI_SUCCESS;\r\n");
893 fileBuffer
.append("}\r\n\r\n");
896 for (int i
= 0; i
< entryPointList
.length
; i
++) {
897 if (!entryPointList
[i
].equals("")) {
898 fileBuffer
.append("EFI_STATUS\r\n");
899 fileBuffer
.append("EFIAPI\r\n");
900 fileBuffer
.append(entryPointList
[i
]);
901 fileBuffer
.append(" (\r\n");
902 fileBuffer
.append(" IN EFI_HANDLE ImageHandle,\r\n");
903 fileBuffer
.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");
904 fileBuffer
.append(" );\r\n");
911 .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gDriverEntryPointCount = ");
912 fileBuffer
.append(Integer
.toString(entryPointCount
));
913 fileBuffer
.append(";\r\n");
915 .append("static BASE_LIBRARY_JUMP_BUFFER mJumpContext;\r\n");
917 .append("static EFI_STATUS mDriverEntryPointStatus = EFI_LOAD_ERROR;\r\n\r\n");
919 fileBuffer
.append("EFI_STATUS\r\n");
920 fileBuffer
.append("EFIAPI\r\n");
921 fileBuffer
.append("ProcessModuleEntryPointList (\r\n");
922 fileBuffer
.append(" IN EFI_HANDLE ImageHandle,\r\n");
923 fileBuffer
.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");
924 fileBuffer
.append(" )\r\n\r\n");
925 fileBuffer
.append("{\r\n");
928 for (int i
= 0; i
< entryPointList
.length
; i
++) {
930 .append(" if (SetJump (&mJumpContext) == 0) {\r\n");
931 fileBuffer
.append(" ExitDriver (");
932 fileBuffer
.append(entryPointList
[i
]);
933 fileBuffer
.append(" (ImageHandle, SystemTable));\r\n");
934 fileBuffer
.append(" ASSERT (FALSE);\r\n");
935 fileBuffer
.append(" }\r\n");
938 fileBuffer
.append(" return mDriverEntryPointStatus;\r\n");
939 fileBuffer
.append("}\r\n\r\n");
941 fileBuffer
.append("VOID\r\n");
942 fileBuffer
.append("EFIAPI\r\n");
943 fileBuffer
.append("ExitDriver (\r\n");
944 fileBuffer
.append(" IN EFI_STATUS Status\n");
945 fileBuffer
.append(" )\r\n\r\n");
946 fileBuffer
.append("{\r\n");
948 .append(" if (!EFI_ERROR (Status) || EFI_ERROR (mDriverEntryPointStatus)) {\r\n");
949 fileBuffer
.append(" mDriverEntryPointStatus = Status;\r\n");
950 fileBuffer
.append(" }\r\n");
951 fileBuffer
.append(" LongJump (&mJumpContext, (UINTN)-1);\r\n");
952 fileBuffer
.append(" ASSERT (FALSE);\r\n");
953 fileBuffer
.append("}\r\n\r\n");
959 // Add "ModuleUnloadImage" for DxeSmmDriver module type;
961 entryPointList
= SurfaceAreaQuery
.getModuleUnloadImageArray();
962 entryPointList
= CommonDefinition
.remDupString(entryPointList
);
966 .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gDriverUnloadImageCount = ");
967 fileBuffer
.append(Integer
.toString(entryPointCount
));
968 fileBuffer
.append(";\r\n\r\n");
970 if (entryPointList
!= null) {
971 for (int i
= 0; i
< entryPointList
.length
; i
++) {
972 if (!entryPointList
[i
].equals("")) {
973 fileBuffer
.append("EFI_STATUS\r\n");
974 fileBuffer
.append("EFIAPI\r\n");
975 fileBuffer
.append(entryPointList
[i
]);
976 fileBuffer
.append(" (\r\n");
978 .append(" IN EFI_HANDLE ImageHandle\r\n");
979 fileBuffer
.append(" );\r\n");
986 fileBuffer
.append("EFI_STATUS\r\n");
987 fileBuffer
.append("EFIAPI\r\n");
988 fileBuffer
.append("ProcessModuleUnloadList (\r\n");
989 fileBuffer
.append(" IN EFI_HANDLE ImageHandle\r\n");
990 fileBuffer
.append(" )\r\n");
991 fileBuffer
.append("{\r\n");
993 if (entryPointCount
== 0) {
994 fileBuffer
.append(" return EFI_SUCCESS;\r\n");
995 } else if (entryPointCount
== 1) {
996 fileBuffer
.append(" return ");
997 fileBuffer
.append(entryPointList
[0]);
998 fileBuffer
.append("(ImageHandle);\r\n");
1000 fileBuffer
.append(" EFI_STATUS Status;\r\n\r\n");
1001 fileBuffer
.append(" Status = EFI_SUCCESS;\r\n\r\n");
1002 for (int i
= 0; i
< entryPointList
.length
; i
++) {
1004 fileBuffer
.append(" Status = ");
1005 fileBuffer
.append(entryPointList
[i
]);
1006 fileBuffer
.append("(ImageHandle);\r\n");
1008 fileBuffer
.append(" if (EFI_ERROR (Status)) {\r\n");
1009 fileBuffer
.append(" ");
1010 fileBuffer
.append(entryPointList
[i
]);
1011 fileBuffer
.append("(ImageHandle);\r\n");
1012 fileBuffer
.append(" } else {\r\n");
1013 fileBuffer
.append(" Status = ");
1014 fileBuffer
.append(entryPointList
[i
]);
1015 fileBuffer
.append("(ImageHandle);\r\n");
1016 fileBuffer
.append(" }\r\n");
1019 fileBuffer
.append(" return Status;\r\n");
1021 fileBuffer
.append("}\r\n\r\n");
1024 case CommonDefinition
.ModuleTypeDxeRuntimeDriver
:
1025 case CommonDefinition
.ModuleTypeDxeDriver
:
1026 case CommonDefinition
.ModuleTypeDxeSalDriver
:
1027 case CommonDefinition
.ModuleTypeUefiDriver
:
1028 case CommonDefinition
.ModuleTypeUefiApplication
:
1029 entryPointCount
= 0;
1030 fileBuffer
.append("const UINT32 _gUefiDriverRevision = 0;\r\n");
1032 // If entry point is null, create a empty ProcessModuleEntryPointList function.
1034 if (entryPointList
== null || entryPointList
.length
== 0){
1036 .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gDriverEntryPointCount = 0;\r\n");
1037 fileBuffer
.append("EFI_STATUS\r\n");
1038 fileBuffer
.append("EFIAPI\r\n");
1039 fileBuffer
.append("ProcessModuleEntryPointList (\r\n");
1040 fileBuffer
.append(" IN EFI_HANDLE ImageHandle,\r\n");
1041 fileBuffer
.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");
1042 fileBuffer
.append(" )\r\n\r\n");
1043 fileBuffer
.append("{\r\n");
1044 fileBuffer
.append(" return EFI_SUCCESS;\r\n");
1045 fileBuffer
.append("}\r\n");
1048 for (int i
= 0; i
< entryPointList
.length
; i
++) {
1050 fileBuffer
.append("EFI_STATUS\r\n");
1051 fileBuffer
.append("EFIAPI\r\n");
1052 fileBuffer
.append(entryPointList
[i
]);
1053 fileBuffer
.append(" (\r\n");
1054 fileBuffer
.append(" IN EFI_HANDLE ImageHandle,\r\n");
1055 fileBuffer
.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");
1056 fileBuffer
.append(" );\r\n");
1061 .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gDriverEntryPointCount = ");
1062 fileBuffer
.append(Integer
.toString(entryPointCount
));
1063 fileBuffer
.append(";\r\n");
1064 if (entryPointCount
> 1) {
1066 .append("static BASE_LIBRARY_JUMP_BUFFER mJumpContext;\r\n");
1068 .append("static EFI_STATUS mDriverEntryPointStatus = EFI_LOAD_ERROR;\r\n");
1070 fileBuffer
.append("\n");
1072 fileBuffer
.append("EFI_STATUS\r\n");
1073 fileBuffer
.append("EFIAPI\r\n");
1074 fileBuffer
.append("ProcessModuleEntryPointList (\r\n");
1075 fileBuffer
.append(" IN EFI_HANDLE ImageHandle,\r\n");
1076 fileBuffer
.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");
1077 fileBuffer
.append(" )\r\n\r\n");
1078 fileBuffer
.append("{\r\n");
1080 if (entryPointCount
== 1) {
1081 fileBuffer
.append(" return (");
1082 fileBuffer
.append(entryPointList
[0]);
1083 fileBuffer
.append(" (ImageHandle, SystemTable));\r\n");
1085 for (int i
= 0; i
< entryPointList
.length
; i
++) {
1086 if (!entryPointList
[i
].equals("")) {
1088 .append(" if (SetJump (&mJumpContext) == 0) {\r\n");
1089 fileBuffer
.append(" ExitDriver (");
1090 fileBuffer
.append(entryPointList
[i
]);
1091 fileBuffer
.append(" (ImageHandle, SystemTable));\r\n");
1092 fileBuffer
.append(" ASSERT (FALSE);\r\n");
1093 fileBuffer
.append(" }\r\n");
1098 fileBuffer
.append(" return mDriverEntryPointStatus;\r\n");
1100 fileBuffer
.append("}\r\n\r\n");
1102 fileBuffer
.append("VOID\n");
1103 fileBuffer
.append("EFIAPI\n");
1104 fileBuffer
.append("ExitDriver (\r\n");
1105 fileBuffer
.append(" IN EFI_STATUS Status\n");
1106 fileBuffer
.append(" )\r\n\r\n");
1107 fileBuffer
.append("{\r\n");
1108 if (entryPointCount
<= 1) {
1109 fileBuffer
.append(" if (EFI_ERROR (Status)) {\r\n");
1111 .append(" ProcessLibraryDestructorList (gImageHandle, gST);\r\n");
1112 fileBuffer
.append(" }\r\n");
1114 .append(" gBS->Exit (gImageHandle, Status, 0, NULL);\r\n");
1117 .append(" if (!EFI_ERROR (Status) || EFI_ERROR (mDriverEntryPointStatus)) {\r\n");
1118 fileBuffer
.append(" mDriverEntryPointStatus = Status;\r\n");
1119 fileBuffer
.append(" }\r\n");
1120 fileBuffer
.append(" LongJump (&mJumpContext, (UINTN)-1);\r\n");
1121 fileBuffer
.append(" ASSERT (FALSE);\r\n");
1123 fileBuffer
.append("}\r\n\r\n");
1128 // Add ModuleUnloadImage for DxeDriver and UefiDriver module type.
1130 entryPointList
= SurfaceAreaQuery
.getModuleUnloadImageArray();
1132 // Remover duplicate unload entry point.
1134 entryPointList
= CommonDefinition
.remDupString(entryPointList
);
1135 entryPointCount
= 0;
1136 if (entryPointList
!= null) {
1137 for (int i
= 0; i
< entryPointList
.length
; i
++) {
1138 if (!entryPointList
[i
].equals("")) {
1139 fileBuffer
.append("EFI_STATUS\r\n");
1140 fileBuffer
.append("EFIAPI\r\n");
1141 fileBuffer
.append(entryPointList
[i
]);
1142 fileBuffer
.append(" (\r\n");
1144 .append(" IN EFI_HANDLE ImageHandle\r\n");
1145 fileBuffer
.append(" );\r\n");
1154 .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gDriverUnloadImageCount = ");
1155 fileBuffer
.append(Integer
.toString(entryPointCount
));
1156 fileBuffer
.append(";\r\n\r\n");
1158 if (entryPointList
!= null) {
1159 for (int i
= 0; i
< entryPointList
.length
; i
++) {
1160 if (!entryPointList
[i
].equals("")) {
1161 fileBuffer
.append("EFI_STATUS\r\n");
1162 fileBuffer
.append("EFIAPI\r\n");
1163 fileBuffer
.append(entryPointList
[i
]);
1164 fileBuffer
.append(" (\r\n");
1166 .append(" IN EFI_HANDLE ImageHandle\r\n");
1167 fileBuffer
.append(" );\r\n");
1174 fileBuffer
.append("EFI_STATUS\n");
1175 fileBuffer
.append("EFIAPI\r\n");
1176 fileBuffer
.append("ProcessModuleUnloadList (\r\n");
1177 fileBuffer
.append(" IN EFI_HANDLE ImageHandle\r\n");
1178 fileBuffer
.append(" )\r\n");
1179 fileBuffer
.append("{\r\n");
1181 if (entryPointCount
== 0) {
1182 fileBuffer
.append(" return EFI_SUCCESS;\r\n");
1183 } else if (entryPointCount
== 1) {
1184 fileBuffer
.append(" return ");
1185 fileBuffer
.append(entryPointList
[0]);
1186 fileBuffer
.append("(ImageHandle);\r\n");
1188 fileBuffer
.append(" EFI_STATUS Status;\r\n\r\n");
1189 fileBuffer
.append(" Status = EFI_SUCCESS;\r\n\r\n");
1190 for (int i
= 0; i
< entryPointList
.length
; i
++) {
1192 fileBuffer
.append(" Status = ");
1193 fileBuffer
.append(entryPointList
[i
]);
1194 fileBuffer
.append("(ImageHandle);\r\n");
1196 fileBuffer
.append(" if (EFI_ERROR (Status)) {\r\n");
1197 fileBuffer
.append(" ");
1198 fileBuffer
.append(entryPointList
[i
]);
1199 fileBuffer
.append("(ImageHandle);\r\n");
1200 fileBuffer
.append(" } else {\r\n");
1201 fileBuffer
.append(" Status = ");
1202 fileBuffer
.append(entryPointList
[i
]);
1203 fileBuffer
.append("(ImageHandle);\r\n");
1204 fileBuffer
.append(" }\r\n");
1207 fileBuffer
.append(" return Status;\r\n");
1209 fileBuffer
.append("}\r\n\r\n");
1217 * This function gets GUIDs from SPD file accrodeing to <PPIs> information
1218 * and write those GUIDs to AutoGen.c.
1221 * String Buffer for Autogen.c file.
1222 * @throws BuildException
1223 * Guid must set value!
1225 void PpiGuidToAutogenC(StringBuffer fileBuffer
) throws AutoGenException
{
1226 String
[] cNameGuid
= null;
1229 // Get the all PPI adn PPI Notify from MSA file,
1230 // then add those PPI ,and PPI Notify name to list.
1233 String
[] ppiList
= SurfaceAreaQuery
.getPpiArray(this.arch
);
1234 for (int i
= 0; i
< ppiList
.length
; i
++) {
1235 this.mPpiList
.add(ppiList
[i
]);
1238 String
[] ppiNotifyList
= SurfaceAreaQuery
.getPpiNotifyArray(this.arch
);
1239 for (int i
= 0; i
< ppiNotifyList
.length
; i
++) {
1240 this.mPpiList
.add(ppiNotifyList
[i
]);
1244 // Find CNAME and GUID from dependence SPD file and write to Autogen.c
1246 Iterator ppiIterator
= this.mPpiList
.iterator();
1247 String ppiKeyWord
= null;
1248 while (ppiIterator
.hasNext()) {
1249 ppiKeyWord
= ppiIterator
.next().toString();
1250 cNameGuid
= GlobalData
.getPpiGuid(this.mDepPkgList
, ppiKeyWord
);
1251 if (cNameGuid
!= null) {
1253 .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID ");
1254 fileBuffer
.append(cNameGuid
[0]);
1255 fileBuffer
.append(" = { ");
1256 fileBuffer
.append(CommonDefinition
.formatGuidName(cNameGuid
[1]));
1257 fileBuffer
.append(" } ;");
1260 // If can't find Ppi GUID declaration in every package
1262 throw new AutoGenException("Can not find Ppi GUID ["
1263 + ppiKeyWord
+ "] declaration in every packages. ");
1269 * ProtocolGuidToAutogenc
1271 * This function gets GUIDs from SPD file accrodeing to <Protocol>
1272 * information and write those GUIDs to AutoGen.c.
1275 * String Buffer for Autogen.c file.
1276 * @throws BuildException
1277 * Protocol name must set.
1279 void ProtocolGuidToAutogenC(StringBuffer fileBuffer
) throws BuildException
{
1280 String
[] cNameGuid
= null;
1282 String
[] protocolList
= SurfaceAreaQuery
.getProtocolArray(this.arch
);
1285 // Add result to Autogen global list.
1287 for (int i
= 0; i
< protocolList
.length
; i
++) {
1288 this.mProtocolList
.add(protocolList
[i
]);
1291 String
[] protocolNotifyList
= SurfaceAreaQuery
1292 .getProtocolNotifyArray(this.arch
);
1294 for (int i
= 0; i
< protocolNotifyList
.length
; i
++) {
1295 this.mProtocolList
.add(protocolNotifyList
[i
]);
1299 // Get the NAME and GUID from dependence SPD and write to Autogen.c
1301 Iterator protocolIterator
= this.mProtocolList
.iterator();
1302 String protocolKeyWord
= null;
1305 while (protocolIterator
.hasNext()) {
1306 protocolKeyWord
= protocolIterator
.next().toString();
1307 cNameGuid
= GlobalData
.getProtocolGuid(this.mDepPkgList
, protocolKeyWord
);
1308 if (cNameGuid
!= null) {
1310 .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID ");
1311 fileBuffer
.append(cNameGuid
[0]);
1312 fileBuffer
.append(" = { ");
1313 fileBuffer
.append(CommonDefinition
.formatGuidName(cNameGuid
[1]));
1314 fileBuffer
.append(" } ;");
1317 // If can't find protocol GUID declaration in every package
1319 throw new BuildException("Can not find protocol Guid ["
1320 + protocolKeyWord
+ "] declaration in every packages. ");
1326 * GuidGuidToAutogenc
1328 * This function gets GUIDs from SPD file accrodeing to <Guids> information
1329 * and write those GUIDs to AutoGen.c.
1332 * String Buffer for Autogen.c file.
1335 void GuidGuidToAutogenC(StringBuffer fileBuffer
) throws AutoGenException
{
1336 String
[] cNameGuid
= null;
1337 String guidKeyWord
= null;
1339 String
[] guidList
= SurfaceAreaQuery
.getGuidEntryArray(this.arch
);
1341 for (int i
= 0; i
< guidList
.length
; i
++) {
1342 this.mGuidList
.add(guidList
[i
]);
1346 Iterator guidIterator
= this.mGuidList
.iterator();
1347 while (guidIterator
.hasNext()) {
1348 guidKeyWord
= guidIterator
.next().toString();
1349 cNameGuid
= GlobalData
.getGuid(this.mDepPkgList
, guidKeyWord
);
1351 if (cNameGuid
!= null) {
1353 .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID ");
1354 fileBuffer
.append(cNameGuid
[0]);
1355 fileBuffer
.append(" = { ");
1356 fileBuffer
.append(CommonDefinition
.formatGuidName(cNameGuid
[1]));
1357 fileBuffer
.append("} ;");
1360 // If can't find GUID declaration in every package
1362 throw new AutoGenException("Can not find Guid [" + guidKeyWord
1363 + "] declaration in every packages. ");
1370 * LibInstanceToAutogenC
1372 * This function adds dependent library instance to autogen.c,which
1373 * includeing library's constructor, destructor, and library dependent ppi,
1374 * protocol, guid, pcd information.
1377 * String buffer for AutoGen.c
1378 * @throws BuildException
1380 void LibInstanceToAutogenC(StringBuffer fileBuffer
) throws BuildException
{
1383 String moduleType
= SurfaceAreaQuery
.getModuleType();
1384 List
<String
> libConstructList
= new ArrayList
<String
>();
1385 List
<String
> libDestructList
= new ArrayList
<String
>();
1387 String libConstructName
= null;
1388 String libDestructName
= null;
1389 ModuleIdentification
[] libraryIdList
= SurfaceAreaQuery
1390 .getLibraryInstance(this.arch
);
1393 if (libraryIdList
!= null) {
1395 // Reorder library instance sequence.
1397 AutogenLibOrder libOrder
= new AutogenLibOrder(libraryIdList
,
1399 List
<ModuleIdentification
> orderList
= libOrder
1400 .orderLibInstance();
1402 if (orderList
!= null) {
1404 // Process library instance one by one.
1406 for (int i
= 0; i
< orderList
.size(); i
++) {
1409 // Get library instance basename.
1411 ModuleIdentification libInstanceId
= orderList
.get(i
);
1417 Map
<String
, XmlObject
> libDoc
= GlobalData
.getDoc(
1418 libInstanceId
, this.arch
);
1419 SurfaceAreaQuery
.push(libDoc
);
1422 // Get <PPis>, <Protocols>, <Guids> list of this library
1425 String
[] ppiList
= SurfaceAreaQuery
.getPpiArray(this.arch
);
1426 String
[] ppiNotifyList
= SurfaceAreaQuery
1427 .getPpiNotifyArray(this.arch
);
1428 String
[] protocolList
= SurfaceAreaQuery
1429 .getProtocolArray(this.arch
);
1430 String
[] protocolNotifyList
= SurfaceAreaQuery
1431 .getProtocolNotifyArray(this.arch
);
1432 String
[] guidList
= SurfaceAreaQuery
1433 .getGuidEntryArray(this.arch
);
1434 PackageIdentification
[] pkgList
= SurfaceAreaQuery
.getDependencePkg(this.arch
);
1437 // Add those ppi, protocol, guid in global ppi,
1441 for (index
= 0; index
< ppiList
.length
; index
++) {
1442 this.mPpiList
.add(ppiList
[index
]);
1445 for (index
= 0; index
< ppiNotifyList
.length
; index
++) {
1446 this.mPpiList
.add(ppiNotifyList
[index
]);
1449 for (index
= 0; index
< protocolList
.length
; index
++) {
1450 this.mProtocolList
.add(protocolList
[index
]);
1453 for (index
= 0; index
< protocolNotifyList
.length
; index
++) {
1454 this.mProtocolList
.add(protocolNotifyList
[index
]);
1457 for (index
= 0; index
< guidList
.length
; index
++) {
1458 this.mGuidList
.add(guidList
[index
]);
1460 for (index
= 0; index
< pkgList
.length
; index
++){
1461 if (!this.mDepPkgList
.contains(pkgList
[index
])){
1462 this.mDepPkgList
.add(pkgList
[index
]);
1467 // If not yet parse this library instance's constructor
1468 // element,parse it.
1470 libConstructName
= SurfaceAreaQuery
1471 .getLibConstructorName();
1472 libDestructName
= SurfaceAreaQuery
1473 .getLibDestructorName();
1475 SurfaceAreaQuery
.pop();
1477 // Add dependent library instance constructor function.
1479 if (libConstructName
!= null) {
1480 libConstructList
.add(libConstructName
);
1483 // Add dependent library instance destructor fuction.
1485 if (libDestructName
!= null) {
1486 libDestructList
.add(libDestructName
);
1493 // Add library constructor to AutoGen.c
1495 LibConstructorToAutogenC(libConstructList
, moduleType
,
1496 fileBuffer
/* autogenC */);
1498 // Add library destructor to AutoGen.c
1500 LibDestructorToAutogenC(libDestructList
, moduleType
, fileBuffer
/* autogenC */);
1503 } catch (Exception e
) {
1504 throw new BuildException(e
.getMessage());
1509 * LibConstructorToAutogenc
1511 * This function writes library constructor list to AutoGen.c. The library
1512 * constructor's parameter and return value depend on module type.
1514 * @param libInstanceList
1515 * List of library construct name.
1519 * String buffer for AutoGen.c
1522 void LibConstructorToAutogenC(List
<String
> libInstanceList
,
1523 String moduleType
, StringBuffer fileBuffer
) throws Exception
{
1524 boolean isFirst
= true;
1527 // The library constructor's parameter and return value depend on
1530 for (int i
= 0; i
< libInstanceList
.size(); i
++) {
1531 switch (CommonDefinition
.getModuleType(moduleType
)) {
1532 case CommonDefinition
.ModuleTypeBase
:
1533 fileBuffer
.append("RETURN_STATUS\r\n");
1534 fileBuffer
.append(libInstanceList
.get(i
));
1535 fileBuffer
.append(" (\r\n");
1536 fileBuffer
.append(" VOID\r\n");
1537 fileBuffer
.append(" );\r\n");
1540 case CommonDefinition
.ModuleTypePeiCore
:
1541 case CommonDefinition
.ModuleTypePeim
:
1542 fileBuffer
.append("EFI_STATUS\r\n");
1543 fileBuffer
.append(libInstanceList
.get(i
));
1544 fileBuffer
.append(" (\r\n");
1546 .append(" IN EFI_FFS_FILE_HEADER *FfsHeader,\r\n");
1548 .append(" IN EFI_PEI_SERVICES **PeiServices\r\n");
1549 fileBuffer
.append(" );\r\n");
1552 case CommonDefinition
.ModuleTypeDxeCore
:
1553 case CommonDefinition
.ModuleTypeDxeDriver
:
1554 case CommonDefinition
.ModuleTypeDxeRuntimeDriver
:
1555 case CommonDefinition
.ModuleTypeDxeSmmDriver
:
1556 case CommonDefinition
.ModuleTypeDxeSalDriver
:
1557 case CommonDefinition
.ModuleTypeUefiDriver
:
1558 case CommonDefinition
.ModuleTypeUefiApplication
:
1559 fileBuffer
.append("EFI_STATUS\r\n");
1560 fileBuffer
.append(libInstanceList
.get(i
));
1561 fileBuffer
.append(" (\r\n");
1562 fileBuffer
.append(" IN EFI_HANDLE ImageHandle,\r\n");
1563 fileBuffer
.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");
1564 fileBuffer
.append(" );\r\n");
1570 // Add ProcessLibraryConstructorList in AutoGen.c
1572 fileBuffer
.append("VOID\r\n");
1573 fileBuffer
.append("ProcessLibraryConstructorList (\r\n");
1574 switch (CommonDefinition
.getModuleType(moduleType
)) {
1575 case CommonDefinition
.ModuleTypeBase
:
1576 fileBuffer
.append(" VOID\r\n");
1579 case CommonDefinition
.ModuleTypePeiCore
:
1580 case CommonDefinition
.ModuleTypePeim
:
1581 fileBuffer
.append(" IN EFI_FFS_FILE_HEADER *FfsHeader,\r\n");
1583 .append(" IN EFI_PEI_SERVICES **PeiServices\r\n");
1586 case CommonDefinition
.ModuleTypeDxeCore
:
1587 case CommonDefinition
.ModuleTypeDxeDriver
:
1588 case CommonDefinition
.ModuleTypeDxeRuntimeDriver
:
1589 case CommonDefinition
.ModuleTypeDxeSmmDriver
:
1590 case CommonDefinition
.ModuleTypeDxeSalDriver
:
1591 case CommonDefinition
.ModuleTypeUefiDriver
:
1592 case CommonDefinition
.ModuleTypeUefiApplication
:
1593 fileBuffer
.append(" IN EFI_HANDLE ImageHandle,\r\n");
1594 fileBuffer
.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");
1598 fileBuffer
.append(" )\r\n");
1599 fileBuffer
.append("{\r\n");
1601 // If no constructor function, return EFI_SUCCESS.
1603 //if (libInstanceList.size() == 0){
1604 // fileBuffer.append(" return EFI_SUCCESS;\r\n");
1606 for (int i
= 0; i
< libInstanceList
.size(); i
++) {
1608 fileBuffer
.append(" EFI_STATUS Status;\r\n");
1609 fileBuffer
.append(" Status = EFI_SUCCESS;\r\n");
1610 fileBuffer
.append("\r\n");
1613 switch (CommonDefinition
.getModuleType(moduleType
)) {
1614 case CommonDefinition
.ModuleTypeBase
:
1615 fileBuffer
.append(" Status = ");
1616 fileBuffer
.append(libInstanceList
.get(i
));
1617 fileBuffer
.append("();\r\n");
1618 fileBuffer
.append(" VOID\r\n");
1620 case CommonDefinition
.ModuleTypePeiCore
:
1621 case CommonDefinition
.ModuleTypePeim
:
1622 fileBuffer
.append(" Status = ");
1623 fileBuffer
.append(libInstanceList
.get(i
));
1624 fileBuffer
.append(" (FfsHeader, PeiServices);\r\n");
1626 case CommonDefinition
.ModuleTypeDxeCore
:
1627 case CommonDefinition
.ModuleTypeDxeDriver
:
1628 case CommonDefinition
.ModuleTypeDxeRuntimeDriver
:
1629 case CommonDefinition
.ModuleTypeDxeSmmDriver
:
1630 case CommonDefinition
.ModuleTypeDxeSalDriver
:
1631 case CommonDefinition
.ModuleTypeUefiDriver
:
1632 case CommonDefinition
.ModuleTypeUefiApplication
:
1633 fileBuffer
.append(" Status = ");
1634 fileBuffer
.append(libInstanceList
.get(i
));
1635 fileBuffer
.append(" (ImageHandle, SystemTable);\r\n");
1638 EdkLog
.log(EdkLog
.EDK_INFO
,"Autogen don't know how to deal with module type -"+ moduleType
+ " !");
1640 fileBuffer
.append(" ASSERT_EFI_ERROR (Status);\r\n");
1642 fileBuffer
.append("}\r\n");
1646 * LibDestructorToAutogenc
1648 * This function writes library destructor list to AutoGen.c. The library
1649 * destructor's parameter and return value depend on module type.
1651 * @param libInstanceList
1652 * List of library destructor name.
1656 * String buffer for AutoGen.c
1659 void LibDestructorToAutogenC(List
<String
> libInstanceList
,
1660 String moduleType
, StringBuffer fileBuffer
) throws Exception
{
1661 boolean isFirst
= true;
1662 for (int i
= 0; i
< libInstanceList
.size(); i
++) {
1663 switch (CommonDefinition
.getModuleType(moduleType
)) {
1664 case CommonDefinition
.ModuleTypeBase
:
1665 fileBuffer
.append("RETURN_STATUS\n");
1666 fileBuffer
.append(libInstanceList
.get(i
));
1667 fileBuffer
.append(" (\r\n");
1668 fileBuffer
.append(" VOID\r\n");
1669 fileBuffer
.append(" );\r\n");
1671 case CommonDefinition
.ModuleTypePeiCore
:
1672 case CommonDefinition
.ModuleTypePeim
:
1673 fileBuffer
.append("EFI_STATUS\r\n");
1674 fileBuffer
.append(libInstanceList
.get(i
));
1675 fileBuffer
.append(" (\r\n");
1677 .append(" IN EFI_FFS_FILE_HEADER *FfsHeader,\r\n");
1679 .append(" IN EFI_PEI_SERVICES **PeiServices\r\n");
1680 fileBuffer
.append(" );\r\n");
1682 case CommonDefinition
.ModuleTypeDxeCore
:
1683 case CommonDefinition
.ModuleTypeDxeDriver
:
1684 case CommonDefinition
.ModuleTypeDxeRuntimeDriver
:
1685 case CommonDefinition
.ModuleTypeDxeSmmDriver
:
1686 case CommonDefinition
.ModuleTypeDxeSalDriver
:
1687 case CommonDefinition
.ModuleTypeUefiDriver
:
1688 case CommonDefinition
.ModuleTypeUefiApplication
:
1689 fileBuffer
.append("EFI_STATUS\r\n");
1690 fileBuffer
.append(libInstanceList
.get(i
));
1691 fileBuffer
.append(" (\r\n");
1692 fileBuffer
.append(" IN EFI_HANDLE ImageHandle,\r\n");
1693 fileBuffer
.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");
1694 fileBuffer
.append(" );\r\n");
1700 // Write ProcessLibraryDestructor list to autogen.c
1702 switch (CommonDefinition
.getModuleType(moduleType
)) {
1703 case CommonDefinition
.ModuleTypeBase
:
1704 case CommonDefinition
.ModuleTypePeiCore
:
1705 case CommonDefinition
.ModuleTypePeim
:
1707 case CommonDefinition
.ModuleTypeDxeCore
:
1708 case CommonDefinition
.ModuleTypeDxeDriver
:
1709 case CommonDefinition
.ModuleTypeDxeRuntimeDriver
:
1710 case CommonDefinition
.ModuleTypeDxeSmmDriver
:
1711 case CommonDefinition
.ModuleTypeDxeSalDriver
:
1712 case CommonDefinition
.ModuleTypeUefiDriver
:
1713 case CommonDefinition
.ModuleTypeUefiApplication
:
1714 fileBuffer
.append("VOID\r\n");
1715 fileBuffer
.append("ProcessLibraryDestructorList (\r\n");
1716 fileBuffer
.append(" IN EFI_HANDLE ImageHandle,\r\n");
1717 fileBuffer
.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");
1718 fileBuffer
.append(" )\r\n");
1719 fileBuffer
.append("{\r\n");
1721 // If no library destructor function, return EFI_SUCCESS.
1724 for (int i
= 0; i
< libInstanceList
.size(); i
++) {
1726 fileBuffer
.append(" EFI_STATUS Status;\r\n");
1727 fileBuffer
.append(" Status = EFI_SUCCESS;\r\n");
1728 fileBuffer
.append("\r\n");
1731 fileBuffer
.append(" Status = ");
1732 fileBuffer
.append(libInstanceList
.get(i
));
1733 fileBuffer
.append("(ImageHandle, SystemTable);\r\n");
1734 fileBuffer
.append(" ASSERT_EFI_ERROR (Status);\r\n");
1736 fileBuffer
.append("}\r\n");
1742 * ExternsDriverBindingToAutoGenC
1744 * This function is to write DRIVER_BINDING, COMPONENT_NAME,
1745 * DRIVER_CONFIGURATION, DRIVER_DIAGNOSTIC in AutoGen.c.
1748 * String buffer for AutoGen.c
1750 void ExternsDriverBindingToAutoGenC(StringBuffer fileBuffer
)
1751 throws BuildException
{
1754 // Check what <extern> contains. And the number of following elements
1755 // under <extern> should be same. 1. DRIVER_BINDING 2. COMPONENT_NAME
1756 // 3.DRIVER_CONFIGURATION 4. DRIVER_DIAGNOSTIC
1759 String
[] drvBindList
= SurfaceAreaQuery
.getDriverBindingArray();
1762 // If component name protocol,component configuration protocol,
1763 // component diagnostic protocol is not null or empty, check
1764 // if every one have the same number of the driver binding protocol.
1766 if (drvBindList
== null || drvBindList
.length
== 0) {
1770 String
[] compNamList
= SurfaceAreaQuery
.getComponentNameArray();
1771 String
[] compConfList
= SurfaceAreaQuery
.getDriverConfigArray();
1772 String
[] compDiagList
= SurfaceAreaQuery
.getDriverDiagArray();
1777 // Write driver binding protocol extern to autogen.c
1779 for (int i
= 0; i
< drvBindList
.length
; i
++) {
1780 fileBuffer
.append("extern EFI_DRIVER_BINDING_PROTOCOL ");
1781 fileBuffer
.append(drvBindList
[i
]);
1782 fileBuffer
.append(";\r\n");
1786 // Write component name protocol extern to autogen.c
1788 if (compNamList
!= null && compNamList
.length
!= 0) {
1789 if (drvBindList
.length
!= compNamList
.length
) {
1790 throw new BuildException(
1791 "Different number of Driver Binding and Component Name protocols!");
1795 for (int i
= 0; i
< compNamList
.length
; i
++) {
1796 fileBuffer
.append("extern EFI_COMPONENT_NAME_PROTOCOL ");
1797 fileBuffer
.append(compNamList
[i
]);
1798 fileBuffer
.append(";\r\n");
1803 // Write driver configration protocol extern to autogen.c
1805 if (compConfList
!= null && compConfList
.length
!= 0) {
1806 if (drvBindList
.length
!= compConfList
.length
) {
1807 throw new BuildException(
1808 "Different number of Driver Binding and Driver Configuration protocols!");
1812 for (int i
= 0; i
< compConfList
.length
; i
++) {
1813 fileBuffer
.append("extern EFI_DRIVER_CONFIGURATION_PROTOCOL ");
1814 fileBuffer
.append(compConfList
[i
]);
1815 fileBuffer
.append(";\r\n");
1820 // Write driver dignastic protocol extern to autogen.c
1822 if (compDiagList
!= null && compDiagList
.length
!= 0) {
1823 if (drvBindList
.length
!= compDiagList
.length
) {
1824 throw new BuildException(
1825 "Different number of Driver Binding and Driver Configuration protocols!");
1829 for (int i
= 0; i
< compDiagList
.length
; i
++) {
1830 fileBuffer
.append("extern EFI_DRIVER_DIAGNOSTICS_PROTOCOL ");
1831 fileBuffer
.append(compDiagList
[i
]);
1832 fileBuffer
.append(";\r\n");
1837 // Write driver module protocol bitmask.
1840 .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gDriverModelProtocolBitmask = ");
1841 fileBuffer
.append(Integer
.toString(BitMask
));
1842 fileBuffer
.append(";\r\n");
1845 // Write driver module protocol list entry
1848 .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINTN _gDriverModelProtocolListEntries = ");
1850 fileBuffer
.append(Integer
.toString(drvBindList
.length
));
1851 fileBuffer
.append(";\r\n");
1854 // Write drive module protocol list to autogen.c
1857 .append("GLOBAL_REMOVE_IF_UNREFERENCED const EFI_DRIVER_MODEL_PROTOCOL_LIST _gDriverModelProtocolList[] = {");
1858 for (int i
= 0; i
< drvBindList
.length
; i
++) {
1860 fileBuffer
.append(",");
1862 fileBuffer
.append("\r\n {\r\n");
1863 fileBuffer
.append(" &");
1864 fileBuffer
.append(drvBindList
[i
]);
1865 fileBuffer
.append(", \r\n");
1867 if (compNamList
!= null) {
1868 fileBuffer
.append(" &");
1869 fileBuffer
.append(compNamList
[i
]);
1870 fileBuffer
.append(", \r\n");
1872 fileBuffer
.append(" NULL, \r\n");
1875 if (compConfList
!= null) {
1876 fileBuffer
.append(" &");
1877 fileBuffer
.append(compConfList
[i
]);
1878 fileBuffer
.append(", \r\n");
1880 fileBuffer
.append(" NULL, \r\n");
1883 if (compDiagList
!= null) {
1884 fileBuffer
.append(" &");
1885 fileBuffer
.append(compDiagList
[i
]);
1886 fileBuffer
.append(", \r\n");
1888 fileBuffer
.append(" NULL, \r\n");
1890 fileBuffer
.append(" }");
1892 fileBuffer
.append("\r\n};\r\n");
1896 * ExternCallBackToAutoGenC
1898 * This function adds <SetVirtualAddressMapCallBack> and
1899 * <ExitBootServicesCallBack> infomation to AutoGen.c
1902 * String buffer for AutoGen.c
1903 * @throws BuildException
1905 void ExternCallBackToAutoGenC(StringBuffer fileBuffer
)
1906 throws BuildException
{
1907 String
[] setVirtualList
= SurfaceAreaQuery
1908 .getSetVirtualAddressMapCallBackArray();
1909 String
[] exitBootList
= SurfaceAreaQuery
1910 .getExitBootServicesCallBackArray();
1911 String moduleType
= SurfaceAreaQuery
.getModuleType();
1912 boolean UefiOrDxeModule
= false;
1916 switch (CommonDefinition
.getModuleType(moduleType
)) {
1917 case CommonDefinition
.ModuleTypeDxeDriver
:
1918 case CommonDefinition
.ModuleTypeDxeRuntimeDriver
:
1919 case CommonDefinition
.ModuleTypeDxeSalDriver
:
1920 case CommonDefinition
.ModuleTypeUefiDriver
:
1921 case CommonDefinition
.ModuleTypeUefiApplication
:
1923 // Entry point lib for these module types needs to know the count
1926 UefiOrDxeModule
= true;
1928 .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED const UINTN _gDriverSetVirtualAddressMapEventCount = ");
1931 // If the list is not valid or has no entries set count to zero else
1932 // set count to the number of valid entries
1935 if (setVirtualList
!= null) {
1936 for (i
= 0; i
< setVirtualList
.length
; i
++) {
1937 if (setVirtualList
[i
].equalsIgnoreCase("")) {
1944 fileBuffer
.append(Integer
.toString(Count
));
1945 fileBuffer
.append(";\r\n\r\n");
1951 if (setVirtualList
== null) {
1952 if (UefiOrDxeModule
) {
1954 // No data so make a NULL list
1957 .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED const EFI_EVENT_NOTIFY _gDriverSetVirtualAddressMapEvent[] = {\r\n");
1958 fileBuffer
.append(" NULL\r\n");
1959 fileBuffer
.append("};\r\n\r\n");
1963 // Write SetVirtualAddressMap function definition.
1965 for (i
= 0; i
< setVirtualList
.length
; i
++) {
1966 if (setVirtualList
[i
].equalsIgnoreCase("")) {
1969 fileBuffer
.append("VOID\r\n");
1970 fileBuffer
.append("EFIAPI\r\n");
1971 fileBuffer
.append(setVirtualList
[i
]);
1972 fileBuffer
.append(" (\r\n");
1973 fileBuffer
.append(" IN EFI_EVENT Event,\r\n");
1974 fileBuffer
.append(" IN VOID *Context\r\n");
1975 fileBuffer
.append(" );\r\n\r\n");
1979 // Write SetVirtualAddressMap entry point array.
1982 .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED const EFI_EVENT_NOTIFY _gDriverSetVirtualAddressMapEvent[] = {");
1983 for (i
= 0; i
< setVirtualList
.length
; i
++) {
1984 if (setVirtualList
[i
].equalsIgnoreCase("")) {
1989 fileBuffer
.append("\r\n ");
1991 fileBuffer
.append(",\r\n ");
1994 fileBuffer
.append(setVirtualList
[i
]);
1997 // If module is not DXE_DRIVER, DXE_RUNTIME_DIRVER, UEFI_DRIVER
1998 // UEFI_APPLICATION and DXE_SAL_DRIVER add the NULL at the end of
1999 // _gDriverSetVirtualAddressMapEvent list.
2001 if (!UefiOrDxeModule
) {
2002 fileBuffer
.append(",\r\n NULL");
2004 fileBuffer
.append("\r\n};\r\n\r\n");
2007 if (UefiOrDxeModule
) {
2009 // Entry point lib for these module types needs to know the count.
2012 .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED const UINTN _gDriverExitBootServicesEventCount = ");
2015 // If the list is not valid or has no entries set count to zero else
2016 // set count to the number of valid entries.
2019 if (exitBootList
!= null) {
2020 if (setVirtualList
!= null) {
2021 for (i
= 0; i
< exitBootList
.length
; i
++) {
2022 if (exitBootList
[i
].equalsIgnoreCase("")) {
2029 fileBuffer
.append(Integer
.toString(Count
));
2030 fileBuffer
.append(";\r\n\r\n");
2033 if (exitBootList
== null) {
2034 if (UefiOrDxeModule
) {
2036 // No data so make a NULL list.
2039 .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED const EFI_EVENT_NOTIFY _gDriverExitBootServicesEvent[] = {\r\n");
2040 fileBuffer
.append(" NULL\r\n");
2041 fileBuffer
.append("};\r\n\r\n");
2045 // Write DriverExitBootServices function definition.
2047 for (i
= 0; i
< exitBootList
.length
; i
++) {
2048 if (exitBootList
[i
].equalsIgnoreCase("")) {
2052 fileBuffer
.append("VOID\r\n");
2053 fileBuffer
.append("EFIAPI\r\n");
2054 fileBuffer
.append(exitBootList
[i
]);
2055 fileBuffer
.append(" (\r\n");
2056 fileBuffer
.append(" IN EFI_EVENT Event,\r\n");
2057 fileBuffer
.append(" IN VOID *Context\r\n");
2058 fileBuffer
.append(" );\r\n\r\n");
2062 // Write DriverExitBootServices entry point array.
2065 .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED const EFI_EVENT_NOTIFY _gDriverExitBootServicesEvent[] = {");
2066 for (i
= 0; i
< exitBootList
.length
; i
++) {
2067 if (exitBootList
[i
].equalsIgnoreCase("")) {
2072 fileBuffer
.append("\r\n ");
2074 fileBuffer
.append(",\r\n ");
2076 fileBuffer
.append(exitBootList
[i
]);
2078 if (!UefiOrDxeModule
) {
2079 fileBuffer
.append(",\r\n NULL");
2081 fileBuffer
.append("\r\n};\r\n\r\n");