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
;
21 import java
.io
.FileInputStream
;
22 import java
.io
.FileOutputStream
;
23 import java
.io
.FileReader
;
24 import java
.io
.FileWriter
;
25 import java
.io
.IOException
;
26 import java
.util
.ArrayList
;
27 import java
.util
.HashSet
;
28 import java
.util
.Iterator
;
29 import java
.util
.LinkedHashSet
;
30 import java
.util
.LinkedList
;
31 import java
.util
.List
;
35 import org
.apache
.tools
.ant
.BuildException
;
36 import org
.apache
.xmlbeans
.XmlObject
;
37 import org
.tianocore
.build
.exception
.AutoGenException
;
38 import org
.tianocore
.build
.global
.GlobalData
;
39 import org
.tianocore
.build
.global
.SurfaceAreaQuery
;
40 import org
.tianocore
.build
.id
.ModuleIdentification
;
41 import org
.tianocore
.build
.id
.PackageIdentification
;
42 import org
.tianocore
.build
.pcd
.action
.PCDAutoGenAction
;
43 import org
.tianocore
.common
.definitions
.ToolDefinitions
;
44 import org
.tianocore
.common
.exception
.EdkException
;
45 import org
.tianocore
.common
.logger
.EdkLog
;
48 This class is to generate Autogen.h and Autogen.c according to module surface
49 area or library surface area.
51 public class AutoGen
{
53 /// The output path of Autogen.h and Autogen.c
55 private String outputPath
;
58 /// The name of FV directory
63 /// The base name of module or library.
65 private ModuleIdentification moduleId
;
68 /// The build architecture
73 /// PcdAutogen instance which is used to manage how to generate the PCD
76 private PCDAutoGenAction myPcdAutogen
;
79 /// the one of type : NOT_PCD_DRIVER, PEI_PCD_DRIVER, DXE_PCD_DRIVER
81 private CommonDefinition
.PCD_DRIVER_TYPE pcdDriverType
;
84 /// The protocl list which records in module or library surface area and
85 /// it's dependence on library instance surface area.
87 private Set
<String
> mProtocolList
= new HashSet
<String
>();
90 /// The Ppi list which recorded in module or library surface area and its
91 /// dependency on library instance surface area.
93 private Set
<String
> mPpiList
= new HashSet
<String
>();
96 /// The Guid list which recoreded in module or library surface area and it's
97 /// dependence on library instance surface area.
99 private Set
<String
> mGuidList
= new HashSet
<String
>();
102 /// The dependence package list which recoreded in module or library surface
103 /// area and it's dependence on library instance surface area.
105 private List
<PackageIdentification
> mDepPkgList
= new LinkedList
<PackageIdentification
>();
108 /// For non library module, add its library instance's construct and destructor to
111 private List
<String
> libConstructList
= new ArrayList
<String
>();
112 private List
<String
> libDestructList
= new ArrayList
<String
>();
115 /// List to store SetVirtalAddressMapCallBack, ExitBootServiceCallBack
117 private List
<String
> setVirtalAddList
= new ArrayList
<String
>();
118 private List
<String
> exitBootServiceList
= new ArrayList
<String
>();
120 private SurfaceAreaQuery saq
= null;
122 private ModuleIdentification parentId
= null;
127 This function mainly initialize some member variable.
130 Absolute path of FV directory.
132 Output path of AutoGen file.
134 Module identification.
138 public AutoGen(String fvDir
, String outputPath
, ModuleIdentification moduleId
, String arch
, SurfaceAreaQuery saq
, ModuleIdentification parentId
) {
139 this.outputPath
= outputPath
;
140 this.moduleId
= moduleId
;
144 this.parentId
= parentId
;
150 This function save the content in stringBuffer to file.
155 The content of AutoGen file in buffer.
160 private boolean saveFile(String fileName
, StringBuffer fileBuffer
) {
162 File autoGenH
= new File(fileName
);
165 // if the file exists, compare their content
167 if (autoGenH
.exists()) {
168 char[] oldFileBuffer
= new char[(int) autoGenH
.length()];
170 FileReader fIn
= new FileReader(autoGenH
);
171 fIn
.read(oldFileBuffer
, 0, (int) autoGenH
.length());
173 } catch (IOException e
) {
174 EdkLog
.log(EdkLog
.EDK_INFO
, this.moduleId
.getName()
177 + " is exist, but can't be open!!");
182 // if we got the same file, don't re-generate it to prevent
183 // sources depending on it from re-building
185 if (fileBuffer
.toString().compareTo(new String(oldFileBuffer
)) == 0) {
191 FileWriter fOut
= new FileWriter(autoGenH
);
192 fOut
.write(fileBuffer
.toString());
195 } catch (IOException e
) {
196 EdkLog
.log(EdkLog
.EDK_INFO
, this.moduleId
.getName()
199 + " can't be create!!");
208 This function call libGenAutoGen or moduleGenAutogen function, which
209 dependence on generate library autogen or module autogen.
211 @throws BuildException
212 Failed to creat AutoGen.c & AutoGen.h.
214 public void genAutogen() throws EdkException
{
217 // If outputPath do not exist, create it.
219 File path
= new File(outputPath
);
221 } catch (Exception e
) {
222 throw new AutoGenException(
224 + outputPath
+ " directory");
228 // Check current is library or not, then call the corresponding
231 if (this.moduleId
.isLibrary()) {
239 moduleGenAutogen function
241 This function generates AutoGen.c & AutoGen.h for module.
243 @throws BuildException
244 Faile to create module AutoGen.c & AutoGen.h.
246 void moduleGenAutogen() throws EdkException
{
247 collectLibInstanceInfo();
253 libGenAutogen function
255 This function generates AutoGen.c & AutoGen.h for library.
257 @throws BuildException
258 Faile to create library AutoGen.c & AutoGen.h
260 void libGenAutogen() throws EdkException
{
268 This function generates AutoGen.h for module.
270 @throws BuildException
271 Failed to generate AutoGen.h.
273 void moduleGenAutogenH() throws EdkException
{
275 Set
<String
> libClassIncludeH
;
277 // List<String> headerFileList;
278 List
<String
> headerFileList
;
280 StringBuffer fileBuffer
= new StringBuffer(8192);
283 // Write Autogen.h header notation
285 fileBuffer
.append(CommonDefinition
.AUTOGENHNOTATION
);
288 // Add #ifndef ${BaseName}_AUTOGENH
289 // #def ${BseeName}_AUTOGENH
291 fileBuffer
.append(CommonDefinition
.IFNDEF
292 + CommonDefinition
.AUTOGENH
293 + this.moduleId
.getGuid().replaceAll("-", "_")
294 + ToolDefinitions
.LINE_SEPARATOR
);
295 fileBuffer
.append(CommonDefinition
.DEFINE
296 + CommonDefinition
.AUTOGENH
297 + this.moduleId
.getGuid().replaceAll("-", "_")
298 + ToolDefinitions
.LINE_SEPARATOR
299 + ToolDefinitions
.LINE_SEPARATOR
);
302 // Write the specification version and release version at the begine
303 // of autogen.h file.
304 // Note: the specification version and release version should
305 // be got from module surface area instead of hard code by it's
308 moduleType
= saq
.getModuleType();
311 // Add "extern int __make_me_compile_correctly;" at begin of
314 fileBuffer
.append(CommonDefinition
.AUTOGENHBEGIN
);
317 // Put EFI_SPECIFICATION_VERSION, and EDK_RELEASE_VERSION.
319 String
[] specList
= saq
.getExternSpecificaiton();
320 for (int i
= 0; i
< specList
.length
; i
++) {
321 fileBuffer
.append(CommonDefinition
.DEFINE
+ specList
[i
]
325 // Write consumed package's mdouleInfo related .h file to autogen.h
327 // PackageIdentification[] consumedPkgIdList = SurfaceAreaQuery
328 // .getDependencePkg(this.arch);
329 PackageIdentification
[] consumedPkgIdList
= saq
.getDependencePkg(this.arch
);
330 if (consumedPkgIdList
!= null) {
331 headerFileList
= depPkgToAutogenH(consumedPkgIdList
, moduleType
);
332 item
= headerFileList
.iterator();
333 while (item
.hasNext()) {
334 fileBuffer
.append(item
.next().toString());
339 // Write library class's related *.h file to autogen.h.
341 String
[] libClassList
= saq
.getLibraryClasses(CommonDefinition
.ALWAYSCONSUMED
,this.arch
);
342 if (libClassList
!= null) {
343 libClassIncludeH
= LibraryClassToAutogenH(libClassList
);
344 item
= libClassIncludeH
.iterator();
345 while (item
.hasNext()) {
346 fileBuffer
.append(item
.next().toString());
350 libClassList
= saq
.getLibraryClasses(CommonDefinition
.ALWAYSPRODUCED
, this.arch
);
351 if (libClassList
!= null) {
352 libClassIncludeH
= LibraryClassToAutogenH(libClassList
);
353 item
= libClassIncludeH
.iterator();
354 while (item
.hasNext()) {
355 fileBuffer
.append(item
.next().toString());
358 fileBuffer
.append("\r\n");
361 // If is TianoR8FlashMap, copy {Fv_DIR}/FlashMap.h to
362 // {DEST_DIR_DRBUG}/FlashMap.h
364 if (saq
.isHaveTianoR8FlashMap()) {
365 fileBuffer
.append(CommonDefinition
.INCLUDE
);
366 fileBuffer
.append(" <");
367 fileBuffer
.append(CommonDefinition
.TIANOR8PLASHMAPH
+ ">\r\n");
368 copyFlashMapHToDebugDir();
371 // Write PCD autogen information to AutoGen.h.
373 if (this.myPcdAutogen
!= null) {
374 fileBuffer
.append("\r\n");
375 fileBuffer
.append(this.myPcdAutogen
.getHAutoGenString());
379 // Append the #endif at AutoGen.h
381 fileBuffer
.append("#endif\r\n");
384 // Save string buffer content in AutoGen.h.
386 if (!saveFile(outputPath
+ File
.separatorChar
+ "AutoGen.h", fileBuffer
)) {
387 throw new AutoGenException("Failed to generate AutoGen.h !!!");
394 This function generates AutoGen.c for module.
396 @throws BuildException
397 Failed to generate AutoGen.c.
399 void moduleGenAutogenC() throws EdkException
{
401 StringBuffer fileBuffer
= new StringBuffer(8192);
403 // Write Autogen.c header notation
405 fileBuffer
.append(CommonDefinition
.AUTOGENCNOTATION
);
408 // Write #include <AutoGen.h> at beginning of AutoGen.c
410 fileBuffer
.append(CommonDefinition
.INCLUDEAUTOGENH
);
413 // Get the native MSA file infomation. Since before call autogen,
414 // the MSA native <Externs> information were overrided. So before
415 // process <Externs> it should be set the DOC as the Native MSA info.
417 Map
<String
, XmlObject
> doc
= GlobalData
.getNativeMsa(this.moduleId
);
421 // DriverBinding/ComponentName/DriverConfiguration/DriverDialog
425 ExternsDriverBindingToAutoGenC(fileBuffer
);
428 // Write DriverExitBootServicesEvent/DriverSetVirtualAddressMapEvent
431 ExternCallBackToAutoGenC(fileBuffer
);
434 // Write EntryPoint to autgoGen.c
436 String
[] entryPointList
= saq
.getModuleEntryPointArray();
437 String
[] unloadImageList
= saq
.getModuleUnloadImageArray();
438 EntryPointToAutoGen(CommonDefinition
.remDupString(entryPointList
),
439 CommonDefinition
.remDupString(unloadImageList
),
442 pcdDriverType
= saq
.getPcdDriverType();
445 // Restore the DOC which include the FPD module info.
450 // Write Guid to autogen.c
452 String guid
= CommonDefinition
.formatGuidName(saq
.getModuleGuid());
455 .append("GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiCallerIdGuid = {");
457 throw new AutoGenException("Guid value must set!\n");
461 // Formate Guid as ANSI c form.Example:
462 // {0xd2b2b828, 0x826, 0x48a7,{0xb3, 0xdf, 0x98, 0x3c, 0x0, 0x60, 0x24,
466 fileBuffer
.append(guid
);
467 fileBuffer
.append("};\r\n");
470 // Generate library instance consumed protocol, guid, ppi, pcd list.
471 // Save those to this.protocolList, this.ppiList, this.pcdList,
472 // this.guidList. Write Consumed library constructor and desconstuct to
475 LibInstanceToAutogenC(fileBuffer
);
478 // Get module dependent Package identification.
480 PackageIdentification
[] packages
= saq
.getDependencePkg(this.arch
);
481 for (int i
= 0; i
< packages
.length
; i
++) {
482 if (!this.mDepPkgList
.contains(packages
[i
])) {
483 this.mDepPkgList
.add(packages
[i
]);
489 // Write consumed ppi, guid, protocol to autogen.c
491 ProtocolGuidToAutogenC(fileBuffer
);
492 PpiGuidToAutogenC(fileBuffer
);
493 GuidGuidToAutogenC(fileBuffer
);
498 this.myPcdAutogen
= new PCDAutoGenAction(moduleId
,
505 this.myPcdAutogen
.execute();
506 if (this.myPcdAutogen
!= null) {
507 fileBuffer
.append("\r\n");
508 fileBuffer
.append(this.myPcdAutogen
.getCAutoGenString());
511 if (!saveFile(outputPath
+ File
.separatorChar
+ "AutoGen.c", fileBuffer
)) {
512 throw new AutoGenException("Failed to generate AutoGen.c !!!");
520 This function generates AutoGen.h for library.
522 @throws BuildException
523 Failed to generate AutoGen.c.
525 void libGenAutogenH() throws EdkException
{
527 Set
<String
> libClassIncludeH
;
529 List
<String
> headerFileList
;
531 StringBuffer fileBuffer
= new StringBuffer(10240);
534 // Write Autogen.h header notation
536 fileBuffer
.append(CommonDefinition
.AUTOGENHNOTATION
);
539 // Add #ifndef ${BaseName}_AUTOGENH
540 // #def ${BseeName}_AUTOGENH
542 fileBuffer
.append(CommonDefinition
.IFNDEF
543 + CommonDefinition
.AUTOGENH
544 + this.moduleId
.getGuid().replaceAll("-", "_")
545 + ToolDefinitions
.LINE_SEPARATOR
);
546 fileBuffer
.append(CommonDefinition
.DEFINE
547 + CommonDefinition
.AUTOGENH
548 + this.moduleId
.getGuid().replaceAll("-", "_")
549 + ToolDefinitions
.LINE_SEPARATOR
550 + ToolDefinitions
.LINE_SEPARATOR
);
553 // Write EFI_SPECIFICATION_VERSION and EDK_RELEASE_VERSION
554 // to autogen.h file.
555 // Note: the specification version and release version should
556 // be get from module surface area instead of hard code.
558 fileBuffer
.append(CommonDefinition
.AUTOGENHBEGIN
);
559 String
[] specList
= saq
.getExternSpecificaiton();
560 for (int i
= 0; i
< specList
.length
; i
++) {
561 fileBuffer
.append(CommonDefinition
.DEFINE
+ specList
[i
]
564 // fileBuffer.append(CommonDefinition.autoGenHLine1);
565 // fileBuffer.append(CommonDefinition.autoGenHLine2);
568 // Write consumed package's mdouleInfo related *.h file to autogen.h.
570 moduleType
= saq
.getModuleType();
571 PackageIdentification
[] cosumedPkglist
= saq
572 .getDependencePkg(this.arch
);
573 headerFileList
= depPkgToAutogenH(cosumedPkglist
, moduleType
);
574 item
= headerFileList
.iterator();
575 while (item
.hasNext()) {
576 fileBuffer
.append(item
.next().toString());
579 // Write library class's related *.h file to autogen.h
581 String
[] libClassList
= saq
582 .getLibraryClasses(CommonDefinition
.ALWAYSCONSUMED
, this.arch
);
583 if (libClassList
!= null) {
584 libClassIncludeH
= LibraryClassToAutogenH(libClassList
);
585 item
= libClassIncludeH
.iterator();
586 while (item
.hasNext()) {
587 fileBuffer
.append(item
.next().toString());
592 .getLibraryClasses(CommonDefinition
.ALWAYSPRODUCED
, this.arch
);
593 if (libClassList
!= null) {
594 libClassIncludeH
= LibraryClassToAutogenH(libClassList
);
595 item
= libClassIncludeH
.iterator();
596 while (item
.hasNext()) {
597 fileBuffer
.append(item
.next().toString());
600 fileBuffer
.append(ToolDefinitions
.LINE_SEPARATOR
);
603 // If is TianoR8FlashMap, copy {Fv_DIR}/FlashMap.h to
604 // {DEST_DIR_DRBUG}/FlashMap.h
606 if (saq
.isHaveTianoR8FlashMap()) {
607 fileBuffer
.append(CommonDefinition
.INCLUDE
);
608 fileBuffer
.append(" <");
609 fileBuffer
.append(CommonDefinition
.TIANOR8PLASHMAPH
+ ">\r\n");
610 copyFlashMapHToDebugDir();
614 // Write PCD information to library AutoGen.h.
616 if (this.myPcdAutogen
!= null) {
617 fileBuffer
.append("\r\n");
618 fileBuffer
.append(this.myPcdAutogen
.getHAutoGenString());
622 // Append the #endif at AutoGen.h
624 fileBuffer
.append("#endif\r\n");
627 // Save content of string buffer to AutoGen.h file.
629 if (!saveFile(outputPath
+ File
.separatorChar
+ "AutoGen.h", fileBuffer
)) {
630 throw new AutoGenException("Failed to generate AutoGen.h !!!");
637 This function generates AutoGen.h for library.
639 @throws BuildException
640 Failed to generate AutoGen.c.
642 void libGenAutogenC() throws EdkException
{
643 StringBuffer fileBuffer
= new StringBuffer(10240);
646 // Write Autogen.c header notation
648 fileBuffer
.append(CommonDefinition
.AUTOGENCNOTATION
);
650 fileBuffer
.append(ToolDefinitions
.LINE_SEPARATOR
);
651 fileBuffer
.append(ToolDefinitions
.LINE_SEPARATOR
);
656 this.myPcdAutogen
= new PCDAutoGenAction(moduleId
,
659 saq
.getModulePcdEntryNameArray(),
662 this.myPcdAutogen
.execute();
663 if (this.myPcdAutogen
!= null) {
664 fileBuffer
.append(ToolDefinitions
.LINE_SEPARATOR
);
665 fileBuffer
.append(this.myPcdAutogen
.getCAutoGenString());
668 if (!saveFile(outputPath
+ File
.separatorChar
+ "AutoGen.c", fileBuffer
)) {
669 throw new AutoGenException("Failed to generate AutoGen.c !!!");
674 LibraryClassToAutogenH
676 This function returns *.h files declared by library classes which are
677 consumed or produced by current build module or library.
680 List of library class which consumed or produce by current
681 build module or library.
682 @return includeStrList List of *.h file.
684 Set
<String
> LibraryClassToAutogenH(String
[] libClassList
)
685 throws EdkException
{
686 Set
<String
> includeStrList
= new LinkedHashSet
<String
>();
687 String includeName
[];
691 // Get include file from GlobalData's SPDTable according to
692 // library class name.
694 for (int i
= 0; i
< libClassList
.length
; i
++) {
695 includeName
= GlobalData
.getLibraryClassHeaderFiles(
696 saq
.getDependencePkg(this.arch
),
698 if (includeName
== null) {
699 throw new AutoGenException("Can not find library class ["
700 + libClassList
[i
] + "] declaration in any SPD package. ");
702 for (int j
= 0; j
< includeName
.length
; j
++) {
703 String includeNameStr
= includeName
[j
];
704 if (includeNameStr
!= null) {
705 str
= CommonDefinition
.INCLUDE
+ " " + "<";
706 str
= str
+ includeNameStr
+ ">\r\n";
707 includeStrList
.add(str
);
708 includeNameStr
= null;
712 return includeStrList
;
718 This function add include file in AutoGen.h file.
720 @param packageNameList
721 List of module depended package.
726 List
<String
> depPkgToAutogenH(PackageIdentification
[] packageNameList
,
727 String moduleType
) throws AutoGenException
{
729 List
<String
> includeStrList
= new LinkedList
<String
>();
731 String includeStr
= "";
734 // Get include file from moduleInfo file
736 for (int i
= 0; i
< packageNameList
.length
; i
++) {
737 pkgHeader
= GlobalData
.getPackageHeaderFiles(packageNameList
[i
],
739 if (pkgHeader
== null) {
740 throw new AutoGenException("Can not find package ["
742 + "] declaration in any SPD package. ");
743 } else if (!pkgHeader
.equalsIgnoreCase("")) {
744 includeStr
= CommonDefinition
.INCLUDE
+ " <" + pkgHeader
746 includeStrList
.add(includeStr
);
750 return includeStrList
;
756 This function convert <ModuleEntryPoint> & <ModuleUnloadImage>
757 information in mas to AutoGen.c
759 @param entryPointList
762 String buffer fo AutoGen.c.
765 void EntryPointToAutoGen(String
[] entryPointList
, String
[] unloadImageList
, StringBuffer fileBuffer
)
766 throws EdkException
{
768 String typeStr
= saq
.getModuleType();
769 int unloadImageCount
= 0;
770 int entryPointCount
= 0;
773 // The parameters and return value of entryPoint is difference
774 // for difference module type.
776 switch (CommonDefinition
.getModuleType(typeStr
)) {
778 case CommonDefinition
.ModuleTypePeiCore
:
779 if (entryPointList
== null ||entryPointList
.length
!= 1 ) {
780 throw new AutoGenException(
781 "Module type = 'PEI_CORE', can have only one module entry point!");
783 fileBuffer
.append("EFI_STATUS\r\n");
784 //fileBuffer.append("EFIAPI\r\n");
785 fileBuffer
.append(entryPointList
[0]);
786 fileBuffer
.append(" (\r\n");
788 .append(" IN EFI_PEI_STARTUP_DESCRIPTOR *PeiStartupDescriptor,\r\n");
790 .append(" IN VOID *OldCoreData\r\n");
791 fileBuffer
.append(" );\r\n\r\n");
793 fileBuffer
.append("EFI_STATUS\r\n");
794 fileBuffer
.append("EFIAPI\r\n");
795 fileBuffer
.append("ProcessModuleEntryPointList (\r\n");
797 .append(" IN EFI_PEI_STARTUP_DESCRIPTOR *PeiStartupDescriptor,\r\n");
799 .append(" IN VOID *OldCoreData\r\n");
800 fileBuffer
.append(" )\r\n\r\n");
801 fileBuffer
.append("{\r\n");
802 fileBuffer
.append(" return ");
803 fileBuffer
.append(entryPointList
[0]);
804 fileBuffer
.append(" (PeiStartupDescriptor, OldCoreData);\r\n");
805 fileBuffer
.append("}\r\n\r\n");
809 case CommonDefinition
.ModuleTypeDxeCore
:
810 fileBuffer
.append("const UINT32 _gUefiDriverRevision = 0;\r\n");
811 if (entryPointList
== null || entryPointList
.length
!= 1) {
812 throw new AutoGenException(
813 "Module type = 'DXE_CORE', can have only one module entry point!");
816 fileBuffer
.append("VOID\r\n");
817 //fileBuffer.append("EFIAPI\r\n");
818 fileBuffer
.append(entryPointList
[0]);
819 fileBuffer
.append(" (\n");
820 fileBuffer
.append(" IN VOID *HobStart\r\n");
821 fileBuffer
.append(" );\r\n\r\n");
823 fileBuffer
.append("VOID\r\n");
824 fileBuffer
.append("EFIAPI\r\n");
825 fileBuffer
.append("ProcessModuleEntryPointList (\r\n");
826 fileBuffer
.append(" IN VOID *HobStart\r\n");
827 fileBuffer
.append(" )\r\n\r\n");
828 fileBuffer
.append("{\r\n");
829 fileBuffer
.append(" ");
830 fileBuffer
.append(entryPointList
[0]);
831 fileBuffer
.append(" (HobStart);\r\n");
832 fileBuffer
.append("}\r\n\r\n");
836 case CommonDefinition
.ModuleTypePeim
:
839 .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT32 _gPeimRevision = 0;\r\n");
840 if (entryPointList
== null || entryPointList
.length
== 0) {
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 fileBuffer
.append(" return EFI_SUCCESS;\r\n");
849 fileBuffer
.append("}\r\n\r\n");
852 for (int i
= 0; i
< entryPointList
.length
; i
++) {
853 fileBuffer
.append("EFI_STATUS\r\n");
854 //fileBuffer.append("EFIAPI\r\n");
855 fileBuffer
.append(entryPointList
[i
]);
856 fileBuffer
.append(" (\r\n");
858 .append(" IN EFI_FFS_FILE_HEADER *FfsHeader,\r\n");
860 .append(" IN EFI_PEI_SERVICES **PeiServices\r\n");
861 fileBuffer
.append(" );\r\n");
866 fileBuffer
.append("EFI_STATUS\r\n");
867 fileBuffer
.append("EFIAPI\r\n");
868 fileBuffer
.append("ProcessModuleEntryPointList (\r\n");
869 fileBuffer
.append(" IN EFI_FFS_FILE_HEADER *FfsHeader,\r\n");
870 fileBuffer
.append(" IN EFI_PEI_SERVICES **PeiServices\r\n");
871 fileBuffer
.append(" )\r\n\r\n");
872 fileBuffer
.append("{\r\n");
873 if (entryPointCount
== 1) {
874 fileBuffer
.append(" return ");
875 fileBuffer
.append(entryPointList
[0]);
876 fileBuffer
.append(" (FfsHeader, PeiServices);\r\n");
878 fileBuffer
.append(" EFI_STATUS Status;\r\n");
879 fileBuffer
.append(" EFI_STATUS CombinedStatus;\r\n\r\n");
880 fileBuffer
.append(" CombinedStatus = EFI_LOAD_ERROR;\r\n\r\n");
881 for (int i
= 0; i
< entryPointList
.length
; i
++) {
882 if (!entryPointList
[i
].equals("")) {
883 fileBuffer
.append(" Status = ");
884 fileBuffer
.append(entryPointList
[i
]);
885 fileBuffer
.append(" (FfsHeader, PeiServices);\r\n");
887 .append(" if (!EFI_ERROR (Status) || EFI_ERROR (CombinedStatus)) {\r\n");
888 fileBuffer
.append(" CombinedStatus = Status;\r\n");
889 fileBuffer
.append(" }\r\n\r\n");
894 fileBuffer
.append(" return CombinedStatus;\r\n");
896 fileBuffer
.append("}\r\n\r\n");
899 case CommonDefinition
.ModuleTypeDxeSmmDriver
:
902 // If entryPoint is null, create an empty ProcessModuleEntryPointList
905 if (entryPointList
== null || entryPointList
.length
== 0) {
907 .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gDriverEntryPointCount = ");
908 fileBuffer
.append(Integer
.toString(entryPointCount
));
909 fileBuffer
.append(";\r\n");
910 fileBuffer
.append("EFI_STATUS\r\n");
911 fileBuffer
.append("EFIAPI\r\n");
912 fileBuffer
.append("ProcessModuleEntryPointList (\r\n");
913 fileBuffer
.append(" IN EFI_HANDLE ImageHandle,\r\n");
914 fileBuffer
.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");
915 fileBuffer
.append(" )\r\n\r\n");
916 fileBuffer
.append("{\r\n");
917 fileBuffer
.append(" return EFI_SUCCESS;\r\n");
918 fileBuffer
.append("}\r\n\r\n");
921 for (int i
= 0; i
< entryPointList
.length
; i
++) {
922 fileBuffer
.append("EFI_STATUS\r\n");
923 //fileBuffer.append("EFIAPI\r\n");
924 fileBuffer
.append(entryPointList
[i
]);
925 fileBuffer
.append(" (\r\n");
926 fileBuffer
.append(" IN EFI_HANDLE ImageHandle,\r\n");
927 fileBuffer
.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");
928 fileBuffer
.append(" );\r\n");
932 .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gDriverEntryPointCount = ");
933 fileBuffer
.append(Integer
.toString(entryPointCount
));
934 fileBuffer
.append(";\r\n");
936 .append("static BASE_LIBRARY_JUMP_BUFFER mJumpContext;\r\n");
938 .append("static EFI_STATUS mDriverEntryPointStatus = EFI_LOAD_ERROR;\r\n\r\n");
940 fileBuffer
.append("EFI_STATUS\r\n");
941 fileBuffer
.append("EFIAPI\r\n");
942 fileBuffer
.append("ProcessModuleEntryPointList (\r\n");
943 fileBuffer
.append(" IN EFI_HANDLE ImageHandle,\r\n");
944 fileBuffer
.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");
945 fileBuffer
.append(" )\r\n\r\n");
946 fileBuffer
.append("{\r\n");
949 for (int i
= 0; i
< entryPointList
.length
; i
++) {
951 .append(" if (SetJump (&mJumpContext) == 0) {\r\n");
952 fileBuffer
.append(" ExitDriver (");
953 fileBuffer
.append(entryPointList
[i
]);
954 fileBuffer
.append(" (ImageHandle, SystemTable));\r\n");
955 fileBuffer
.append(" ASSERT (FALSE);\r\n");
956 fileBuffer
.append(" }\r\n");
959 fileBuffer
.append(" return mDriverEntryPointStatus;\r\n");
960 fileBuffer
.append("}\r\n\r\n");
962 fileBuffer
.append("VOID\r\n");
963 fileBuffer
.append("EFIAPI\r\n");
964 fileBuffer
.append("ExitDriver (\r\n");
965 fileBuffer
.append(" IN EFI_STATUS Status\n");
966 fileBuffer
.append(" )\r\n\r\n");
967 fileBuffer
.append("{\r\n");
969 .append(" if (!EFI_ERROR (Status) || EFI_ERROR (mDriverEntryPointStatus)) {\r\n");
970 fileBuffer
.append(" mDriverEntryPointStatus = Status;\r\n");
971 fileBuffer
.append(" }\r\n");
972 fileBuffer
.append(" LongJump (&mJumpContext, (UINTN)-1);\r\n");
973 fileBuffer
.append(" ASSERT (FALSE);\r\n");
974 fileBuffer
.append("}\r\n\r\n");
980 // Add "ModuleUnloadImage" for DxeSmmDriver module type;
982 //entryPointList = SurfaceAreaQuery.getModuleUnloadImageArray();
983 //entryPointList = CommonDefinition.remDupString(entryPointList);
984 //entryPointCount = 0;
986 unloadImageCount
= 0;
987 if (unloadImageList
!= null) {
988 for (int i
= 0; i
< unloadImageList
.length
; i
++) {
989 fileBuffer
.append("EFI_STATUS\r\n");
990 //fileBuffer.append("EFIAPI\r\n");
991 fileBuffer
.append(unloadImageList
[i
]);
992 fileBuffer
.append(" (\r\n");
994 .append(" IN EFI_HANDLE ImageHandle\r\n");
995 fileBuffer
.append(" );\r\n");
1001 .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gDriverUnloadImageCount = ");
1002 fileBuffer
.append(Integer
.toString(unloadImageCount
));
1003 fileBuffer
.append(";\r\n\r\n");
1005 fileBuffer
.append("EFI_STATUS\r\n");
1006 fileBuffer
.append("EFIAPI\r\n");
1007 fileBuffer
.append("ProcessModuleUnloadList (\r\n");
1008 fileBuffer
.append(" IN EFI_HANDLE ImageHandle\r\n");
1009 fileBuffer
.append(" )\r\n");
1010 fileBuffer
.append("{\r\n");
1012 if (unloadImageCount
== 0) {
1013 fileBuffer
.append(" return EFI_SUCCESS;\r\n");
1014 } else if (unloadImageCount
== 1) {
1015 fileBuffer
.append(" return ");
1016 fileBuffer
.append(unloadImageList
[0]);
1017 fileBuffer
.append("(ImageHandle);\r\n");
1019 fileBuffer
.append(" EFI_STATUS Status;\r\n\r\n");
1020 fileBuffer
.append(" Status = EFI_SUCCESS;\r\n\r\n");
1021 for (int i
= 0; i
< unloadImageList
.length
; i
++) {
1023 fileBuffer
.append(" Status = ");
1024 fileBuffer
.append(unloadImageList
[i
]);
1025 fileBuffer
.append("(ImageHandle);\r\n");
1027 fileBuffer
.append(" if (EFI_ERROR (Status)) {\r\n");
1028 fileBuffer
.append(" ");
1029 fileBuffer
.append(unloadImageList
[i
]);
1030 fileBuffer
.append("(ImageHandle);\r\n");
1031 fileBuffer
.append(" } else {\r\n");
1032 fileBuffer
.append(" Status = ");
1033 fileBuffer
.append(unloadImageList
[i
]);
1034 fileBuffer
.append("(ImageHandle);\r\n");
1035 fileBuffer
.append(" }\r\n");
1038 fileBuffer
.append(" return Status;\r\n");
1040 fileBuffer
.append("}\r\n\r\n");
1043 case CommonDefinition
.ModuleTypeDxeRuntimeDriver
:
1044 case CommonDefinition
.ModuleTypeDxeDriver
:
1045 case CommonDefinition
.ModuleTypeDxeSalDriver
:
1046 case CommonDefinition
.ModuleTypeUefiDriver
:
1047 case CommonDefinition
.ModuleTypeUefiApplication
:
1048 entryPointCount
= 0;
1049 fileBuffer
.append("const UINT32 _gUefiDriverRevision = 0;\r\n");
1051 // If entry point is null, create a empty ProcessModuleEntryPointList function.
1053 if (entryPointList
== null || entryPointList
.length
== 0) {
1055 .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gDriverEntryPointCount = 0;\r\n");
1056 fileBuffer
.append("EFI_STATUS\r\n");
1057 fileBuffer
.append("EFIAPI\r\n");
1058 fileBuffer
.append("ProcessModuleEntryPointList (\r\n");
1059 fileBuffer
.append(" IN EFI_HANDLE ImageHandle,\r\n");
1060 fileBuffer
.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");
1061 fileBuffer
.append(" )\r\n\r\n");
1062 fileBuffer
.append("{\r\n");
1063 fileBuffer
.append(" return EFI_SUCCESS;\r\n");
1064 fileBuffer
.append("}\r\n");
1067 for (int i
= 0; i
< entryPointList
.length
; i
++) {
1069 fileBuffer
.append("EFI_STATUS\r\n");
1070 //fileBuffer.append("EFIAPI\r\n");
1071 fileBuffer
.append(entryPointList
[i
]);
1072 fileBuffer
.append(" (\r\n");
1073 fileBuffer
.append(" IN EFI_HANDLE ImageHandle,\r\n");
1074 fileBuffer
.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");
1075 fileBuffer
.append(" );\r\n");
1080 .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gDriverEntryPointCount = ");
1081 fileBuffer
.append(Integer
.toString(entryPointCount
));
1082 fileBuffer
.append(";\r\n");
1083 if (entryPointCount
> 1) {
1085 .append("static BASE_LIBRARY_JUMP_BUFFER mJumpContext;\r\n");
1087 .append("static EFI_STATUS mDriverEntryPointStatus = EFI_LOAD_ERROR;\r\n");
1089 fileBuffer
.append("\n");
1091 fileBuffer
.append("EFI_STATUS\r\n");
1092 fileBuffer
.append("EFIAPI\r\n");
1093 fileBuffer
.append("ProcessModuleEntryPointList (\r\n");
1094 fileBuffer
.append(" IN EFI_HANDLE ImageHandle,\r\n");
1095 fileBuffer
.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");
1096 fileBuffer
.append(" )\r\n\r\n");
1097 fileBuffer
.append("{\r\n");
1099 if (entryPointCount
== 1) {
1100 fileBuffer
.append(" return (");
1101 fileBuffer
.append(entryPointList
[0]);
1102 fileBuffer
.append(" (ImageHandle, SystemTable));\r\n");
1104 for (int i
= 0; i
< entryPointList
.length
; i
++) {
1105 if (!entryPointList
[i
].equals("")) {
1107 .append(" if (SetJump (&mJumpContext) == 0) {\r\n");
1108 fileBuffer
.append(" ExitDriver (");
1109 fileBuffer
.append(entryPointList
[i
]);
1110 fileBuffer
.append(" (ImageHandle, SystemTable));\r\n");
1111 fileBuffer
.append(" ASSERT (FALSE);\r\n");
1112 fileBuffer
.append(" }\r\n");
1117 fileBuffer
.append(" return mDriverEntryPointStatus;\r\n");
1119 fileBuffer
.append("}\r\n\r\n");
1121 fileBuffer
.append("VOID\r\n");
1122 fileBuffer
.append("EFIAPI\r\n");
1123 fileBuffer
.append("ExitDriver (\r\n");
1124 fileBuffer
.append(" IN EFI_STATUS Status\r\n");
1125 fileBuffer
.append(" )\r\n\r\n");
1126 fileBuffer
.append("{\r\n");
1127 if (entryPointCount
<= 1) {
1128 fileBuffer
.append(" if (EFI_ERROR (Status)) {\r\n");
1130 .append(" ProcessLibraryDestructorList (gImageHandle, gST);\r\n");
1131 fileBuffer
.append(" }\r\n");
1133 .append(" gBS->Exit (gImageHandle, Status, 0, NULL);\r\n");
1136 .append(" if (!EFI_ERROR (Status) || EFI_ERROR (mDriverEntryPointStatus)) {\r\n");
1137 fileBuffer
.append(" mDriverEntryPointStatus = Status;\r\n");
1138 fileBuffer
.append(" }\r\n");
1139 fileBuffer
.append(" LongJump (&mJumpContext, (UINTN)-1);\r\n");
1140 fileBuffer
.append(" ASSERT (FALSE);\r\n");
1142 fileBuffer
.append("}\r\n\r\n");
1147 // Add ModuleUnloadImage for DxeDriver and UefiDriver module type.
1150 unloadImageCount
= 0;
1151 if (unloadImageList
!= null) {
1152 for (int i
= 0; i
< unloadImageList
.length
; i
++) {
1153 fileBuffer
.append("EFI_STATUS\r\n");
1154 //fileBuffer.append("EFIAPI\r\n");
1155 fileBuffer
.append(unloadImageList
[i
]);
1156 fileBuffer
.append(" (\r\n");
1158 .append(" IN EFI_HANDLE ImageHandle\r\n");
1159 fileBuffer
.append(" );\r\n");
1165 .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gDriverUnloadImageCount = ");
1166 fileBuffer
.append(Integer
.toString(unloadImageCount
));
1167 fileBuffer
.append(";\r\n\r\n");
1169 fileBuffer
.append("EFI_STATUS\n");
1170 fileBuffer
.append("EFIAPI\r\n");
1171 fileBuffer
.append("ProcessModuleUnloadList (\r\n");
1172 fileBuffer
.append(" IN EFI_HANDLE ImageHandle\r\n");
1173 fileBuffer
.append(" )\r\n");
1174 fileBuffer
.append("{\r\n");
1176 if (unloadImageCount
== 0) {
1177 fileBuffer
.append(" return EFI_SUCCESS;\r\n");
1178 } else if (unloadImageCount
== 1) {
1179 fileBuffer
.append(" return ");
1180 fileBuffer
.append(unloadImageList
[0]);
1181 fileBuffer
.append("(ImageHandle);\r\n");
1183 fileBuffer
.append(" EFI_STATUS Status;\r\n\r\n");
1184 fileBuffer
.append(" Status = EFI_SUCCESS;\r\n\r\n");
1185 for (int i
= 0; i
< unloadImageList
.length
; i
++) {
1187 fileBuffer
.append(" Status = ");
1188 fileBuffer
.append(unloadImageList
[i
]);
1189 fileBuffer
.append("(ImageHandle);\r\n");
1191 fileBuffer
.append(" if (EFI_ERROR (Status)) {\r\n");
1192 fileBuffer
.append(" ");
1193 fileBuffer
.append(unloadImageList
[i
]);
1194 fileBuffer
.append("(ImageHandle);\r\n");
1195 fileBuffer
.append(" } else {\r\n");
1196 fileBuffer
.append(" Status = ");
1197 fileBuffer
.append(unloadImageList
[i
]);
1198 fileBuffer
.append("(ImageHandle);\r\n");
1199 fileBuffer
.append(" }\r\n");
1202 fileBuffer
.append(" return Status;\r\n");
1204 fileBuffer
.append("}\r\n\r\n");
1212 This function gets GUIDs from SPD file accrodeing to <PPIs> information
1213 and write those GUIDs to AutoGen.c.
1216 String Buffer for Autogen.c file.
1217 @throws BuildException
1218 Guid must set value!
1220 void PpiGuidToAutogenC(StringBuffer fileBuffer
) throws AutoGenException
{
1221 String
[] cNameGuid
= null;
1224 // Get the all PPI adn PPI Notify from MSA file,
1225 // then add those PPI ,and PPI Notify name to list.
1228 String
[] ppiList
= saq
.getPpiArray(this.arch
);
1229 for (int i
= 0; i
< ppiList
.length
; i
++) {
1230 this.mPpiList
.add(ppiList
[i
]);
1233 String
[] ppiNotifyList
= saq
.getPpiNotifyArray(this.arch
);
1234 for (int i
= 0; i
< ppiNotifyList
.length
; i
++) {
1235 this.mPpiList
.add(ppiNotifyList
[i
]);
1239 // Find CNAME and GUID from dependence SPD file and write to Autogen.c
1241 Iterator ppiIterator
= this.mPpiList
.iterator();
1242 String ppiKeyWord
= null;
1243 while (ppiIterator
.hasNext()) {
1244 ppiKeyWord
= ppiIterator
.next().toString();
1245 cNameGuid
= GlobalData
.getPpiGuid(this.mDepPkgList
, ppiKeyWord
);
1246 if (cNameGuid
!= null) {
1248 .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID ");
1249 fileBuffer
.append(cNameGuid
[0]);
1250 fileBuffer
.append(" = { ");
1251 fileBuffer
.append(CommonDefinition
.formatGuidName(cNameGuid
[1]));
1252 fileBuffer
.append(" } ;");
1255 // If can't find Ppi GUID declaration in every package
1257 throw new AutoGenException("Can not find Ppi GUID ["
1258 + ppiKeyWord
+ "] declaration in any SPD package!");
1264 ProtocolGuidToAutogenc
1266 This function gets GUIDs from SPD file accrodeing to <Protocol>
1267 information and write those GUIDs to AutoGen.c.
1270 String Buffer for Autogen.c file.
1271 @throws BuildException
1272 Protocol name must set.
1274 void ProtocolGuidToAutogenC(StringBuffer fileBuffer
) throws EdkException
{
1275 String
[] cNameGuid
= null;
1277 String
[] protocolList
= saq
.getProtocolArray(this.arch
);
1280 // Add result to Autogen global list.
1282 for (int i
= 0; i
< protocolList
.length
; i
++) {
1283 this.mProtocolList
.add(protocolList
[i
]);
1286 String
[] protocolNotifyList
= saq
1287 .getProtocolNotifyArray(this.arch
);
1289 for (int i
= 0; i
< protocolNotifyList
.length
; i
++) {
1290 this.mProtocolList
.add(protocolNotifyList
[i
]);
1294 // Get the NAME and GUID from dependence SPD and write to Autogen.c
1296 Iterator protocolIterator
= this.mProtocolList
.iterator();
1297 String protocolKeyWord
= null;
1300 while (protocolIterator
.hasNext()) {
1301 protocolKeyWord
= protocolIterator
.next().toString();
1302 cNameGuid
= GlobalData
.getProtocolGuid(this.mDepPkgList
, protocolKeyWord
);
1303 if (cNameGuid
!= null) {
1305 .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID ");
1306 fileBuffer
.append(cNameGuid
[0]);
1307 fileBuffer
.append(" = { ");
1308 fileBuffer
.append(CommonDefinition
.formatGuidName(cNameGuid
[1]));
1309 fileBuffer
.append(" } ;");
1312 // If can't find protocol GUID declaration in every package
1314 throw new AutoGenException("Can not find protocol Guid ["
1315 + protocolKeyWord
+ "] declaration in any SPD package!");
1323 This function gets GUIDs from SPD file accrodeing to <Guids> information
1324 and write those GUIDs to AutoGen.c.
1327 String Buffer for Autogen.c file.
1330 void GuidGuidToAutogenC(StringBuffer fileBuffer
) throws AutoGenException
{
1331 String
[] cNameGuid
= null;
1332 String guidKeyWord
= null;
1334 String
[] guidList
= saq
.getGuidEntryArray(this.arch
);
1336 for (int i
= 0; i
< guidList
.length
; i
++) {
1337 this.mGuidList
.add(guidList
[i
]);
1341 Iterator guidIterator
= this.mGuidList
.iterator();
1342 while (guidIterator
.hasNext()) {
1343 guidKeyWord
= guidIterator
.next().toString();
1344 cNameGuid
= GlobalData
.getGuid(this.mDepPkgList
, guidKeyWord
);
1346 if (cNameGuid
!= null) {
1348 .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID ");
1349 fileBuffer
.append(cNameGuid
[0]);
1350 fileBuffer
.append(" = { ");
1351 fileBuffer
.append(CommonDefinition
.formatGuidName(cNameGuid
[1]));
1352 fileBuffer
.append("} ;");
1355 // If can't find GUID declaration in every package
1357 throw new AutoGenException("Can not find Guid [" + guidKeyWord
1358 + "] declaration in any SPD package. ");
1365 LibInstanceToAutogenC
1367 This function adds dependent library instance to autogen.c,which
1368 includeing library's constructor, destructor, and library dependent ppi,
1369 protocol, guid, pcd information.
1372 String buffer for AutoGen.c
1373 @throws BuildException
1375 void LibInstanceToAutogenC(StringBuffer fileBuffer
) throws EdkException
{
1376 String moduleType
= this.moduleId
.getModuleType();
1378 // Add library constructor to AutoGen.c
1380 LibConstructorToAutogenC(libConstructList
, moduleType
,
1381 fileBuffer
/* autogenC */);
1383 // Add library destructor to AutoGen.c
1385 LibDestructorToAutogenC(libDestructList
, moduleType
, fileBuffer
/* autogenC */);
1389 LibConstructorToAutogenc
1391 This function writes library constructor list to AutoGen.c. The library
1392 constructor's parameter and return value depend on module type.
1394 @param libInstanceList
1395 List of library construct name.
1399 String buffer for AutoGen.c
1402 void LibConstructorToAutogenC(List
<String
> libInstanceList
,
1403 String moduleType
, StringBuffer fileBuffer
) throws EdkException
{
1404 boolean isFirst
= true;
1407 // The library constructor's parameter and return value depend on
1410 for (int i
= 0; i
< libInstanceList
.size(); i
++) {
1411 switch (CommonDefinition
.getModuleType(moduleType
)) {
1412 case CommonDefinition
.ModuleTypeBase
:
1413 fileBuffer
.append("RETURN_STATUS\r\n");
1414 fileBuffer
.append("EFIAPI\r\n");
1415 fileBuffer
.append(libInstanceList
.get(i
));
1416 fileBuffer
.append(" (\r\n");
1417 fileBuffer
.append(" VOID\r\n");
1418 fileBuffer
.append(" );\r\n");
1421 case CommonDefinition
.ModuleTypePeiCore
:
1422 case CommonDefinition
.ModuleTypePeim
:
1423 fileBuffer
.append("EFI_STATUS\r\n");
1424 fileBuffer
.append("EFIAPI\r\n");
1425 fileBuffer
.append(libInstanceList
.get(i
));
1426 fileBuffer
.append(" (\r\n");
1428 .append(" IN EFI_FFS_FILE_HEADER *FfsHeader,\r\n");
1430 .append(" IN EFI_PEI_SERVICES **PeiServices\r\n");
1431 fileBuffer
.append(" );\r\n");
1434 case CommonDefinition
.ModuleTypeDxeCore
:
1435 case CommonDefinition
.ModuleTypeDxeDriver
:
1436 case CommonDefinition
.ModuleTypeDxeRuntimeDriver
:
1437 case CommonDefinition
.ModuleTypeDxeSmmDriver
:
1438 case CommonDefinition
.ModuleTypeDxeSalDriver
:
1439 case CommonDefinition
.ModuleTypeUefiDriver
:
1440 case CommonDefinition
.ModuleTypeUefiApplication
:
1441 fileBuffer
.append("EFI_STATUS\r\n");
1442 fileBuffer
.append("EFIAPI\r\n");
1443 fileBuffer
.append(libInstanceList
.get(i
));
1444 fileBuffer
.append(" (\r\n");
1445 fileBuffer
.append(" IN EFI_HANDLE ImageHandle,\r\n");
1446 fileBuffer
.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");
1447 fileBuffer
.append(" );\r\n");
1453 // Add ProcessLibraryConstructorList in AutoGen.c
1455 fileBuffer
.append("VOID\r\n");
1456 fileBuffer
.append("EFIAPI\r\n");
1457 fileBuffer
.append("ProcessLibraryConstructorList (\r\n");
1458 switch (CommonDefinition
.getModuleType(moduleType
)) {
1459 case CommonDefinition
.ModuleTypeBase
:
1460 fileBuffer
.append(" VOID\r\n");
1463 case CommonDefinition
.ModuleTypePeiCore
:
1464 case CommonDefinition
.ModuleTypePeim
:
1465 fileBuffer
.append(" IN EFI_FFS_FILE_HEADER *FfsHeader,\r\n");
1467 .append(" IN EFI_PEI_SERVICES **PeiServices\r\n");
1470 case CommonDefinition
.ModuleTypeDxeCore
:
1471 case CommonDefinition
.ModuleTypeDxeDriver
:
1472 case CommonDefinition
.ModuleTypeDxeRuntimeDriver
:
1473 case CommonDefinition
.ModuleTypeDxeSmmDriver
:
1474 case CommonDefinition
.ModuleTypeDxeSalDriver
:
1475 case CommonDefinition
.ModuleTypeUefiDriver
:
1476 case CommonDefinition
.ModuleTypeUefiApplication
:
1477 fileBuffer
.append(" IN EFI_HANDLE ImageHandle,\r\n");
1478 fileBuffer
.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");
1482 fileBuffer
.append(" )\r\n");
1483 fileBuffer
.append("{\r\n");
1485 // If no constructor function, return EFI_SUCCESS.
1487 //if (libInstanceList.size() == 0){
1488 // fileBuffer.append(" return EFI_SUCCESS;\r\n");
1490 for (int i
= 0; i
< libInstanceList
.size(); i
++) {
1492 fileBuffer
.append(" EFI_STATUS Status;\r\n");
1493 fileBuffer
.append(" Status = EFI_SUCCESS;\r\n");
1494 fileBuffer
.append("\r\n");
1497 switch (CommonDefinition
.getModuleType(moduleType
)) {
1498 case CommonDefinition
.ModuleTypeBase
:
1499 fileBuffer
.append(" Status = ");
1500 fileBuffer
.append(libInstanceList
.get(i
));
1501 fileBuffer
.append("();\r\n");
1502 fileBuffer
.append(" VOID\r\n");
1504 case CommonDefinition
.ModuleTypePeiCore
:
1505 case CommonDefinition
.ModuleTypePeim
:
1506 fileBuffer
.append(" Status = ");
1507 fileBuffer
.append(libInstanceList
.get(i
));
1508 fileBuffer
.append(" (FfsHeader, PeiServices);\r\n");
1510 case CommonDefinition
.ModuleTypeDxeCore
:
1511 case CommonDefinition
.ModuleTypeDxeDriver
:
1512 case CommonDefinition
.ModuleTypeDxeRuntimeDriver
:
1513 case CommonDefinition
.ModuleTypeDxeSmmDriver
:
1514 case CommonDefinition
.ModuleTypeDxeSalDriver
:
1515 case CommonDefinition
.ModuleTypeUefiDriver
:
1516 case CommonDefinition
.ModuleTypeUefiApplication
:
1517 fileBuffer
.append(" Status = ");
1518 fileBuffer
.append(libInstanceList
.get(i
));
1519 fileBuffer
.append(" (ImageHandle, SystemTable);\r\n");
1522 EdkLog
.log(EdkLog
.EDK_INFO
,"Autogen doesn't know how to deal with module type - " + moduleType
+ "!");
1524 fileBuffer
.append(" ASSERT_EFI_ERROR (Status);\r\n");
1526 fileBuffer
.append("}\r\n");
1530 LibDestructorToAutogenc
1532 This function writes library destructor list to AutoGen.c. The library
1533 destructor's parameter and return value depend on module type.
1535 @param libInstanceList
1536 List of library destructor name.
1540 String buffer for AutoGen.c
1543 void LibDestructorToAutogenC(List
<String
> libInstanceList
,
1544 String moduleType
, StringBuffer fileBuffer
) throws EdkException
{
1545 boolean isFirst
= true;
1546 for (int i
= 0; i
< libInstanceList
.size(); i
++) {
1547 switch (CommonDefinition
.getModuleType(moduleType
)) {
1548 case CommonDefinition
.ModuleTypeBase
:
1549 fileBuffer
.append("RETURN_STATUS\r\n");
1550 fileBuffer
.append("EFIAPI\r\n");
1551 fileBuffer
.append(libInstanceList
.get(i
));
1552 fileBuffer
.append(" (\r\n");
1553 fileBuffer
.append(" VOID\r\n");
1554 fileBuffer
.append(" );\r\n");
1556 case CommonDefinition
.ModuleTypePeiCore
:
1557 case CommonDefinition
.ModuleTypePeim
:
1558 fileBuffer
.append("EFI_STATUS\r\n");
1559 fileBuffer
.append("EFIAPI\r\n");
1560 fileBuffer
.append(libInstanceList
.get(i
));
1561 fileBuffer
.append(" (\r\n");
1563 .append(" IN EFI_FFS_FILE_HEADER *FfsHeader,\r\n");
1565 .append(" IN EFI_PEI_SERVICES **PeiServices\r\n");
1566 fileBuffer
.append(" );\r\n");
1568 case CommonDefinition
.ModuleTypeDxeCore
:
1569 case CommonDefinition
.ModuleTypeDxeDriver
:
1570 case CommonDefinition
.ModuleTypeDxeRuntimeDriver
:
1571 case CommonDefinition
.ModuleTypeDxeSmmDriver
:
1572 case CommonDefinition
.ModuleTypeDxeSalDriver
:
1573 case CommonDefinition
.ModuleTypeUefiDriver
:
1574 case CommonDefinition
.ModuleTypeUefiApplication
:
1575 fileBuffer
.append("EFI_STATUS\r\n");
1576 fileBuffer
.append("EFIAPI\r\n");
1577 fileBuffer
.append(libInstanceList
.get(i
));
1578 fileBuffer
.append(" (\r\n");
1579 fileBuffer
.append(" IN EFI_HANDLE ImageHandle,\r\n");
1580 fileBuffer
.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");
1581 fileBuffer
.append(" );\r\n");
1587 // Write ProcessLibraryDestructor list to autogen.c
1589 switch (CommonDefinition
.getModuleType(moduleType
)) {
1590 case CommonDefinition
.ModuleTypeBase
:
1591 case CommonDefinition
.ModuleTypePeiCore
:
1592 case CommonDefinition
.ModuleTypePeim
:
1594 case CommonDefinition
.ModuleTypeDxeCore
:
1595 case CommonDefinition
.ModuleTypeDxeDriver
:
1596 case CommonDefinition
.ModuleTypeDxeRuntimeDriver
:
1597 case CommonDefinition
.ModuleTypeDxeSmmDriver
:
1598 case CommonDefinition
.ModuleTypeDxeSalDriver
:
1599 case CommonDefinition
.ModuleTypeUefiDriver
:
1600 case CommonDefinition
.ModuleTypeUefiApplication
:
1601 fileBuffer
.append("VOID\r\n");
1602 fileBuffer
.append("EFIAPI\r\n");
1603 fileBuffer
.append("ProcessLibraryDestructorList (\r\n");
1604 fileBuffer
.append(" IN EFI_HANDLE ImageHandle,\r\n");
1605 fileBuffer
.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");
1606 fileBuffer
.append(" )\r\n");
1607 fileBuffer
.append("{\r\n");
1609 // If no library destructor function, return EFI_SUCCESS.
1612 for (int i
= 0; i
< libInstanceList
.size(); i
++) {
1614 fileBuffer
.append(" EFI_STATUS Status;\r\n");
1615 fileBuffer
.append(" Status = EFI_SUCCESS;\r\n");
1616 fileBuffer
.append("\r\n");
1619 fileBuffer
.append(" Status = ");
1620 fileBuffer
.append(libInstanceList
.get(i
));
1621 fileBuffer
.append("(ImageHandle, SystemTable);\r\n");
1622 fileBuffer
.append(" ASSERT_EFI_ERROR (Status);\r\n");
1624 fileBuffer
.append("}\r\n");
1630 ExternsDriverBindingToAutoGenC
1632 This function is to write DRIVER_BINDING, COMPONENT_NAME,
1633 DRIVER_CONFIGURATION, DRIVER_DIAGNOSTIC in AutoGen.c.
1636 String buffer for AutoGen.c
1638 void ExternsDriverBindingToAutoGenC(StringBuffer fileBuffer
)
1639 throws EdkException
{
1642 // Check what <extern> contains. And the number of following elements
1643 // under <extern> should be same. 1. DRIVER_BINDING 2. COMPONENT_NAME
1644 // 3.DRIVER_CONFIGURATION 4. DRIVER_DIAGNOSTIC
1647 String
[] drvBindList
= saq
.getDriverBindingArray();
1650 // If component name protocol,component configuration protocol,
1651 // component diagnostic protocol is not null or empty, check
1652 // if every one have the same number of the driver binding protocol.
1654 if (drvBindList
== null || drvBindList
.length
== 0) {
1658 String
[] compNamList
= saq
.getComponentNameArray();
1659 String
[] compConfList
= saq
.getDriverConfigArray();
1660 String
[] compDiagList
= saq
.getDriverDiagArray();
1665 // Write driver binding protocol extern to autogen.c
1667 for (int i
= 0; i
< drvBindList
.length
; i
++) {
1668 fileBuffer
.append("extern EFI_DRIVER_BINDING_PROTOCOL ");
1669 fileBuffer
.append(drvBindList
[i
]);
1670 fileBuffer
.append(";\r\n");
1674 // Write component name protocol extern to autogen.c
1676 if (compNamList
!= null && compNamList
.length
!= 0) {
1677 if (drvBindList
.length
!= compNamList
.length
) {
1678 throw new AutoGenException(
1679 "Different number of Driver Binding and Component Name protocols!");
1683 for (int i
= 0; i
< compNamList
.length
; i
++) {
1684 fileBuffer
.append("extern EFI_COMPONENT_NAME_PROTOCOL ");
1685 fileBuffer
.append(compNamList
[i
]);
1686 fileBuffer
.append(";\r\n");
1691 // Write driver configration protocol extern to autogen.c
1693 if (compConfList
!= null && compConfList
.length
!= 0) {
1694 if (drvBindList
.length
!= compConfList
.length
) {
1695 throw new AutoGenException(
1696 "Different number of Driver Binding and Driver Configuration protocols!");
1700 for (int i
= 0; i
< compConfList
.length
; i
++) {
1701 fileBuffer
.append("extern EFI_DRIVER_CONFIGURATION_PROTOCOL ");
1702 fileBuffer
.append(compConfList
[i
]);
1703 fileBuffer
.append(";\r\n");
1708 // Write driver dignastic protocol extern to autogen.c
1710 if (compDiagList
!= null && compDiagList
.length
!= 0) {
1711 if (drvBindList
.length
!= compDiagList
.length
) {
1712 throw new AutoGenException(
1713 "Different number of Driver Binding and Driver Diagnosis protocols!");
1717 for (int i
= 0; i
< compDiagList
.length
; i
++) {
1718 fileBuffer
.append("extern EFI_DRIVER_DIAGNOSTICS_PROTOCOL ");
1719 fileBuffer
.append(compDiagList
[i
]);
1720 fileBuffer
.append(";\r\n");
1725 // Write driver module protocol bitmask.
1728 .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gDriverModelProtocolBitmask = ");
1729 fileBuffer
.append(Integer
.toString(BitMask
));
1730 fileBuffer
.append(";\r\n");
1733 // Write driver module protocol list entry
1736 .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINTN _gDriverModelProtocolListEntries = ");
1738 fileBuffer
.append(Integer
.toString(drvBindList
.length
));
1739 fileBuffer
.append(";\r\n");
1742 // Write drive module protocol list to autogen.c
1745 .append("GLOBAL_REMOVE_IF_UNREFERENCED const EFI_DRIVER_MODEL_PROTOCOL_LIST _gDriverModelProtocolList[] = {");
1746 for (int i
= 0; i
< drvBindList
.length
; i
++) {
1748 fileBuffer
.append(",");
1750 fileBuffer
.append("\r\n {\r\n");
1751 fileBuffer
.append(" &");
1752 fileBuffer
.append(drvBindList
[i
]);
1753 fileBuffer
.append(", \r\n");
1755 if (compNamList
!= null) {
1756 fileBuffer
.append(" &");
1757 fileBuffer
.append(compNamList
[i
]);
1758 fileBuffer
.append(", \r\n");
1760 fileBuffer
.append(" NULL, \r\n");
1763 if (compConfList
!= null) {
1764 fileBuffer
.append(" &");
1765 fileBuffer
.append(compConfList
[i
]);
1766 fileBuffer
.append(", \r\n");
1768 fileBuffer
.append(" NULL, \r\n");
1771 if (compDiagList
!= null) {
1772 fileBuffer
.append(" &");
1773 fileBuffer
.append(compDiagList
[i
]);
1774 fileBuffer
.append(", \r\n");
1776 fileBuffer
.append(" NULL, \r\n");
1778 fileBuffer
.append(" }");
1780 fileBuffer
.append("\r\n};\r\n");
1784 ExternCallBackToAutoGenC
1786 This function adds <SetVirtualAddressMapCallBack> and
1787 <ExitBootServicesCallBack> infomation to AutoGen.c
1790 String buffer for AutoGen.c
1791 @throws BuildException
1793 void ExternCallBackToAutoGenC(StringBuffer fileBuffer
)
1794 throws EdkException
{
1796 // Collect module's <SetVirtualAddressMapCallBack> and
1797 // <ExitBootServiceCallBack> and add to setVirtualAddList
1798 // exitBootServiceList.
1800 String
[] setVirtuals
= saq
.getSetVirtualAddressMapCallBackArray();
1801 String
[] exitBoots
= saq
.getExitBootServicesCallBackArray();
1802 if (setVirtuals
!= null) {
1803 for (int j
= 0; j
< setVirtuals
.length
; j
++) {
1804 this.setVirtalAddList
.add(setVirtuals
[j
]);
1807 if (exitBoots
!= null) {
1808 for (int k
= 0; k
< exitBoots
.length
; k
++) {
1809 this.exitBootServiceList
.add(exitBoots
[k
]);
1813 // Add c code in autogen.c which relate to <SetVirtualAddressMapCallBack>
1814 // and <ExitBootServicesCallBack>
1816 String moduleType
= this.moduleId
.getModuleType();
1817 switch (CommonDefinition
.getModuleType(moduleType
)) {
1818 case CommonDefinition
.ModuleTypeDxeDriver
:
1819 case CommonDefinition
.ModuleTypeDxeRuntimeDriver
:
1820 case CommonDefinition
.ModuleTypeDxeSalDriver
:
1821 case CommonDefinition
.ModuleTypeUefiDriver
:
1822 case CommonDefinition
.ModuleTypeUefiApplication
:
1824 // If moduleType is one of above, call setVirtualAddressToAutogenC,
1825 // and setExitBootServiceToAutogenC.
1827 setVirtualAddressToAutogenC(fileBuffer
);
1828 setExitBootServiceToAutogenC(fileBuffer
);
1836 copyFlashMapHToDebugDir
1838 This function is to copy the falshmap.h to debug directory and change
1839 its name to TianoR8FlashMap.h
1844 private void copyFlashMapHToDebugDir() throws AutoGenException
{
1846 File inFile
= new File(fvDir
+ File
.separatorChar
+ CommonDefinition
.FLASHMAPH
);
1847 int size
= (int)inFile
.length();
1848 byte[] buffer
= new byte[size
];
1849 File outFile
= new File (this.outputPath
+ File
.separatorChar
+ CommonDefinition
.TIANOR8PLASHMAPH
);
1851 // If TianoR8FlashMap.h existed and the flashMap.h don't change,
1854 if ((!outFile
.exists()) ||(inFile
.lastModified() - outFile
.lastModified()) >= 0) {
1855 if (inFile
.exists()) {
1857 FileInputStream fis
= new FileInputStream (inFile
);
1859 FileOutputStream fos
= new FileOutputStream(outFile
);
1863 } catch (IOException e
){
1864 throw new AutoGenException("The file, flashMap.h can't be open!");
1868 throw new AutoGenException("The file, flashMap.h doesn't exist!");
1874 This function first order the library instances, then collect
1875 library instance 's PPI, Protocol, GUID,
1876 SetVirtalAddressMapCallBack, ExitBootServiceCallBack, and
1877 Destructor, Constructor.
1882 private void collectLibInstanceInfo() throws EdkException
{
1885 String libConstructName
= null;
1886 String libDestructName
= null;
1887 String
[] setVirtuals
= null;
1888 String
[] exitBoots
= null;
1890 ModuleIdentification
[] libraryIdList
= saq
.getLibraryInstance(this.arch
);
1892 if (libraryIdList
!= null) {
1894 // Reorder library instance sequence.
1896 AutogenLibOrder libOrder
= new AutogenLibOrder(libraryIdList
,
1898 List
<ModuleIdentification
> orderList
= libOrder
1899 .orderLibInstance();
1901 if (orderList
!= null) {
1903 // Process library instance one by one.
1905 for (int i
= 0; i
< orderList
.size(); i
++) {
1908 // Get library instance basename.
1910 ModuleIdentification libInstanceId
= orderList
.get(i
);
1916 Map
<String
, XmlObject
> libDoc
= GlobalData
.getDoc(libInstanceId
, this.arch
);
1919 // Get <PPis>, <Protocols>, <Guids> list of this library
1922 String
[] ppiList
= saq
.getPpiArray(this.arch
);
1923 String
[] ppiNotifyList
= saq
.getPpiNotifyArray(this.arch
);
1924 String
[] protocolList
= saq
.getProtocolArray(this.arch
);
1925 String
[] protocolNotifyList
= saq
.getProtocolNotifyArray(this.arch
);
1926 String
[] guidList
= saq
.getGuidEntryArray(this.arch
);
1927 PackageIdentification
[] pkgList
= saq
.getDependencePkg(this.arch
);
1930 // Add those ppi, protocol, guid in global ppi,
1934 for (index
= 0; index
< ppiList
.length
; index
++) {
1935 this.mPpiList
.add(ppiList
[index
]);
1938 for (index
= 0; index
< ppiNotifyList
.length
; index
++) {
1939 this.mPpiList
.add(ppiNotifyList
[index
]);
1942 for (index
= 0; index
< protocolList
.length
; index
++) {
1943 this.mProtocolList
.add(protocolList
[index
]);
1946 for (index
= 0; index
< protocolNotifyList
.length
; index
++) {
1947 this.mProtocolList
.add(protocolNotifyList
[index
]);
1950 for (index
= 0; index
< guidList
.length
; index
++) {
1951 this.mGuidList
.add(guidList
[index
]);
1953 for (index
= 0; index
< pkgList
.length
; index
++) {
1954 if (!this.mDepPkgList
.contains(pkgList
[index
])) {
1955 this.mDepPkgList
.add(pkgList
[index
]);
1960 // If not yet parse this library instance's constructor
1961 // element,parse it.
1963 libConstructName
= saq
.getLibConstructorName();
1964 libDestructName
= saq
.getLibDestructorName();
1967 // Collect SetVirtualAddressMapCallBack and
1968 // ExitBootServiceCallBack.
1970 setVirtuals
= saq
.getSetVirtualAddressMapCallBackArray();
1971 exitBoots
= saq
.getExitBootServicesCallBackArray();
1972 if (setVirtuals
!= null) {
1973 for (int j
= 0; j
< setVirtuals
.length
; j
++) {
1974 this.setVirtalAddList
.add(setVirtuals
[j
]);
1977 if (exitBoots
!= null) {
1978 for (int k
= 0; k
< exitBoots
.length
; k
++) {
1979 this.exitBootServiceList
.add(exitBoots
[k
]);
1984 // Add dependent library instance constructor function.
1986 if (libConstructName
!= null) {
1987 this.libConstructList
.add(libConstructName
);
1990 // Add dependent library instance destructor fuction.
1992 if (libDestructName
!= null) {
1993 this.libDestructList
.add(libDestructName
);
2000 private void setVirtualAddressToAutogenC(StringBuffer fileBuffer
){
2002 // Entry point lib for these module types needs to know the count
2006 .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED const UINTN _gDriverSetVirtualAddressMapEventCount = ");
2009 // If the list is not valid or has no entries set count to zero else
2010 // set count to the number of valid entries
2014 if (this.setVirtalAddList
!= null) {
2015 for (i
= 0; i
< this.setVirtalAddList
.size(); i
++) {
2016 if (this.setVirtalAddList
.get(i
).equalsIgnoreCase("")) {
2023 fileBuffer
.append(Integer
.toString(Count
));
2024 fileBuffer
.append(";\r\n\r\n");
2025 if (this.setVirtalAddList
== null || this.setVirtalAddList
.size() == 0) {
2027 // No data so make a NULL list
2030 .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED const EFI_EVENT_NOTIFY _gDriverSetVirtualAddressMapEvent[] = {\r\n");
2031 fileBuffer
.append(" NULL\r\n");
2032 fileBuffer
.append("};\r\n\r\n");
2035 // Write SetVirtualAddressMap function definition.
2037 for (i
= 0; i
< this.setVirtalAddList
.size(); i
++) {
2038 if (this.setVirtalAddList
.get(i
).equalsIgnoreCase("")) {
2041 fileBuffer
.append("VOID\r\n");
2042 fileBuffer
.append("EFIAPI\r\n");
2043 fileBuffer
.append(this.setVirtalAddList
.get(i
));
2044 fileBuffer
.append(" (\r\n");
2045 fileBuffer
.append(" IN EFI_EVENT Event,\r\n");
2046 fileBuffer
.append(" IN VOID *Context\r\n");
2047 fileBuffer
.append(" );\r\n\r\n");
2051 // Write SetVirtualAddressMap entry point array.
2054 .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED const EFI_EVENT_NOTIFY _gDriverSetVirtualAddressMapEvent[] = {");
2055 for (i
= 0; i
< this.setVirtalAddList
.size(); i
++) {
2056 if (this.setVirtalAddList
.get(i
).equalsIgnoreCase("")) {
2061 fileBuffer
.append("\r\n ");
2063 fileBuffer
.append(",\r\n ");
2066 fileBuffer
.append(this.setVirtalAddList
.get(i
));
2069 // add the NULL at the end of _gDriverSetVirtualAddressMapEvent list.
2071 fileBuffer
.append(",\r\n NULL");
2072 fileBuffer
.append("\r\n};\r\n\r\n");
2077 private void setExitBootServiceToAutogenC(StringBuffer fileBuffer
){
2079 // Entry point lib for these module types needs to know the count.
2082 .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED const UINTN _gDriverExitBootServicesEventCount = ");
2085 // If the list is not valid or has no entries set count to zero else
2086 // set count to the number of valid entries.
2090 if (this.exitBootServiceList
!= null) {
2091 for (i
= 0; i
< this.exitBootServiceList
.size(); i
++) {
2092 if (this.exitBootServiceList
.get(i
).equalsIgnoreCase("")) {
2098 fileBuffer
.append(Integer
.toString(Count
));
2099 fileBuffer
.append(";\r\n\r\n");
2101 if (this.exitBootServiceList
== null || this.exitBootServiceList
.size() == 0) {
2103 // No data so make a NULL list.
2106 .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED const EFI_EVENT_NOTIFY _gDriverExitBootServicesEvent[] = {\r\n");
2107 fileBuffer
.append(" NULL\r\n");
2108 fileBuffer
.append("};\r\n\r\n");
2111 // Write DriverExitBootServices function definition.
2113 for (i
= 0; i
< this.exitBootServiceList
.size(); i
++) {
2114 if (this.exitBootServiceList
.get(i
).equalsIgnoreCase("")) {
2118 fileBuffer
.append("VOID\r\n");
2119 fileBuffer
.append("EFIAPI\r\n");
2120 fileBuffer
.append(this.exitBootServiceList
.get(i
));
2121 fileBuffer
.append(" (\r\n");
2122 fileBuffer
.append(" IN EFI_EVENT Event,\r\n");
2123 fileBuffer
.append(" IN VOID *Context\r\n");
2124 fileBuffer
.append(" );\r\n\r\n");
2128 // Write DriverExitBootServices entry point array.
2131 .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED const EFI_EVENT_NOTIFY _gDriverExitBootServicesEvent[] = {");
2132 for (i
= 0; i
< this.exitBootServiceList
.size(); i
++) {
2133 if (this.exitBootServiceList
.get(i
).equalsIgnoreCase("")) {
2138 fileBuffer
.append("\r\n ");
2140 fileBuffer
.append(",\r\n ");
2142 fileBuffer
.append(this.exitBootServiceList
.get(i
));
2145 fileBuffer
.append(",\r\n NULL");
2146 fileBuffer
.append("\r\n};\r\n\r\n");