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
.definitions
.EdkDefinitions
;
45 import org
.tianocore
.common
.exception
.EdkException
;
46 import org
.tianocore
.common
.logger
.EdkLog
;
49 This class is to generate Autogen.h and Autogen.c according to module surface
50 area or library surface area.
52 public class AutoGen
{
54 /// The output path of Autogen.h and Autogen.c
56 private String outputPath
;
59 /// The name of FV directory
64 /// The base name of module or library.
66 private ModuleIdentification moduleId
;
69 /// The build architecture
74 /// PcdAutogen instance which is used to manage how to generate the PCD
77 private PCDAutoGenAction myPcdAutogen
;
80 /// the one of type : NOT_PCD_DRIVER, PEI_PCD_DRIVER, DXE_PCD_DRIVER
82 private CommonDefinition
.PCD_DRIVER_TYPE pcdDriverType
;
85 /// The protocl list which records in module or library surface area and
86 /// it's dependence on library instance surface area.
88 private Set
<String
> mProtocolList
= new HashSet
<String
>();
91 /// The Ppi list which recorded in module or library surface area and its
92 /// dependency on library instance surface area.
94 private Set
<String
> mPpiList
= new HashSet
<String
>();
97 /// The Guid list which recoreded in module or library surface area and it's
98 /// dependence on library instance surface area.
100 private Set
<String
> mGuidList
= new HashSet
<String
>();
103 /// The dependence package list which recoreded in module or library surface
104 /// area and it's dependence on library instance surface area.
106 private List
<PackageIdentification
> mDepPkgList
= new LinkedList
<PackageIdentification
>();
109 /// For non library module, add its library instance's construct and destructor to
110 /// list. String[0] recode LibConstructor name, String[1] recode Lib instance
113 private List
<String
[]> libConstructList
= new ArrayList
<String
[]>();
114 private List
<String
[]> libDestructList
= new ArrayList
<String
[]>();
117 /// List to store SetVirtalAddressMapCallBack, ExitBootServiceCallBack
119 private List
<String
> setVirtalAddList
= new ArrayList
<String
>();
120 private List
<String
> exitBootServiceList
= new ArrayList
<String
>();
122 private SurfaceAreaQuery saq
= null;
124 private ModuleIdentification parentId
= null;
129 This function mainly initialize some member variable.
132 Absolute path of FV directory.
134 Output path of AutoGen file.
136 Module identification.
140 public AutoGen(String fvDir
, String outputPath
, ModuleIdentification moduleId
, String arch
, SurfaceAreaQuery saq
, ModuleIdentification parentId
) {
141 this.outputPath
= outputPath
;
142 this.moduleId
= moduleId
;
146 this.parentId
= parentId
;
152 This function save the content in stringBuffer to file.
157 The content of AutoGen file in buffer.
162 private boolean saveFile(String fileName
, StringBuffer fileBuffer
) {
164 File autoGenH
= new File(fileName
);
167 // if the file exists, compare their content
169 if (autoGenH
.exists()) {
170 char[] oldFileBuffer
= new char[(int) autoGenH
.length()];
172 FileReader fIn
= new FileReader(autoGenH
);
173 fIn
.read(oldFileBuffer
, 0, (int) autoGenH
.length());
175 } catch (IOException e
) {
176 EdkLog
.log(EdkLog
.EDK_INFO
, this.moduleId
.getName()
179 + " is exist, but can't be open!!");
184 // if we got the same file, don't re-generate it to prevent
185 // sources depending on it from re-building
187 if (fileBuffer
.toString().compareTo(new String(oldFileBuffer
)) == 0) {
193 FileWriter fOut
= new FileWriter(autoGenH
);
194 fOut
.write(fileBuffer
.toString());
197 } catch (IOException e
) {
198 EdkLog
.log(EdkLog
.EDK_INFO
, this.moduleId
.getName()
201 + " can't be create!!");
210 This function call libGenAutoGen or moduleGenAutogen function, which
211 dependence on generate library autogen or module autogen.
213 @throws BuildException
214 Failed to creat AutoGen.c & AutoGen.h.
216 public void genAutogen() throws EdkException
{
219 // If outputPath do not exist, create it.
221 File path
= new File(outputPath
);
223 } catch (Exception e
) {
224 throw new AutoGenException(
226 + outputPath
+ " directory");
230 // Check current is library or not, then call the corresponding
233 if (this.moduleId
.isLibrary()) {
241 moduleGenAutogen function
243 This function generates AutoGen.c & AutoGen.h for module.
245 @throws BuildException
246 Faile to create module AutoGen.c & AutoGen.h.
248 void moduleGenAutogen() throws EdkException
{
249 collectLibInstanceInfo();
255 libGenAutogen function
257 This function generates AutoGen.c & AutoGen.h for library.
259 @throws BuildException
260 Faile to create library AutoGen.c & AutoGen.h
262 void libGenAutogen() throws EdkException
{
270 This function generates AutoGen.h for module.
272 @throws BuildException
273 Failed to generate AutoGen.h.
275 void moduleGenAutogenH() throws EdkException
{
277 Set
<String
> libClassIncludeH
;
279 // List<String> headerFileList;
280 List
<String
> headerFileList
;
282 StringBuffer fileBuffer
= new StringBuffer(8192);
285 // Write Autogen.h header notation
287 fileBuffer
.append(CommonDefinition
.AUTOGENHNOTATION
);
290 // Add #ifndef ${BaseName}_AUTOGENH
291 // #def ${BseeName}_AUTOGENH
293 fileBuffer
.append(CommonDefinition
.IFNDEF
294 + CommonDefinition
.AUTOGENH
295 + this.moduleId
.getGuid().replaceAll("-", "_")
296 + ToolDefinitions
.LINE_SEPARATOR
);
297 fileBuffer
.append(CommonDefinition
.DEFINE
298 + CommonDefinition
.AUTOGENH
299 + this.moduleId
.getGuid().replaceAll("-", "_")
300 + ToolDefinitions
.LINE_SEPARATOR
301 + ToolDefinitions
.LINE_SEPARATOR
);
304 // Write the specification version and release version at the begine
305 // of autogen.h file.
306 // Note: the specification version and release version should
307 // be got from module surface area instead of hard code by it's
310 moduleType
= saq
.getModuleType();
313 // Add "extern int __make_me_compile_correctly;" at begin of
316 fileBuffer
.append(CommonDefinition
.AUTOGENHBEGIN
);
319 // Put EFI_SPECIFICATION_VERSION, and EDK_RELEASE_VERSION.
321 String
[] specList
= saq
.getExternSpecificaiton();
322 for (int i
= 0; i
< specList
.length
; i
++) {
323 fileBuffer
.append(CommonDefinition
.DEFINE
+ specList
[i
]
327 // Write consumed package's mdouleInfo related .h file to autogen.h
329 // PackageIdentification[] consumedPkgIdList = SurfaceAreaQuery
330 // .getDependencePkg(this.arch);
331 PackageIdentification
[] consumedPkgIdList
= saq
.getDependencePkg(this.arch
);
332 if (consumedPkgIdList
!= null) {
333 headerFileList
= depPkgToAutogenH(consumedPkgIdList
, moduleType
);
334 item
= headerFileList
.iterator();
335 while (item
.hasNext()) {
336 fileBuffer
.append(item
.next().toString());
341 // Write library class's related *.h file to autogen.h.
343 String
[] libClassList
= saq
.getLibraryClasses(CommonDefinition
.ALWAYSCONSUMED
,this.arch
);
344 if (libClassList
!= null) {
345 libClassIncludeH
= LibraryClassToAutogenH(libClassList
);
346 item
= libClassIncludeH
.iterator();
347 while (item
.hasNext()) {
348 fileBuffer
.append(item
.next().toString());
352 libClassList
= saq
.getLibraryClasses(CommonDefinition
.ALWAYSPRODUCED
, this.arch
);
353 if (libClassList
!= null) {
354 libClassIncludeH
= LibraryClassToAutogenH(libClassList
);
355 item
= libClassIncludeH
.iterator();
356 while (item
.hasNext()) {
357 fileBuffer
.append(item
.next().toString());
360 fileBuffer
.append("\r\n");
363 // If is TianoR8FlashMap, copy {Fv_DIR}/FlashMap.h to
364 // {DEST_DIR_DRBUG}/FlashMap.h
366 if (saq
.isHaveTianoR8FlashMap()) {
367 fileBuffer
.append(CommonDefinition
.INCLUDE
);
368 fileBuffer
.append(" <");
369 fileBuffer
.append(CommonDefinition
.TIANOR8PLASHMAPH
+ ">\r\n");
370 copyFlashMapHToDebugDir();
373 // Write PCD autogen information to AutoGen.h.
375 if (this.myPcdAutogen
!= null) {
376 fileBuffer
.append("\r\n");
377 fileBuffer
.append(this.myPcdAutogen
.getHAutoGenString());
381 // Append the #endif at AutoGen.h
383 fileBuffer
.append("#endif\r\n");
386 // Save string buffer content in AutoGen.h.
388 if (!saveFile(outputPath
+ File
.separatorChar
+ "AutoGen.h", fileBuffer
)) {
389 throw new AutoGenException("Failed to generate AutoGen.h !!!");
396 This function generates AutoGen.c for module.
398 @throws BuildException
399 Failed to generate AutoGen.c.
401 void moduleGenAutogenC() throws EdkException
{
403 StringBuffer fileBuffer
= new StringBuffer(8192);
405 // Write Autogen.c header notation
407 fileBuffer
.append(CommonDefinition
.AUTOGENCNOTATION
);
410 // Write #include <AutoGen.h> at beginning of AutoGen.c
412 fileBuffer
.append(CommonDefinition
.INCLUDEAUTOGENH
);
415 // Get the native MSA file infomation. Since before call autogen,
416 // the MSA native <Externs> information were overrided. So before
417 // process <Externs> it should be set the DOC as the Native MSA info.
419 Map
<String
, XmlObject
> doc
= GlobalData
.getNativeMsa(this.moduleId
);
423 // DriverBinding/ComponentName/DriverConfiguration/DriverDialog
427 ExternsDriverBindingToAutoGenC(fileBuffer
);
430 // Write DriverExitBootServicesEvent/DriverSetVirtualAddressMapEvent
433 ExternCallBackToAutoGenC(fileBuffer
);
436 // Write EntryPoint to autgoGen.c
438 String
[] entryPointList
= saq
.getModuleEntryPointArray();
439 String
[] unloadImageList
= saq
.getModuleUnloadImageArray();
440 EntryPointToAutoGen(CommonDefinition
.remDupString(entryPointList
),
441 CommonDefinition
.remDupString(unloadImageList
),
444 pcdDriverType
= saq
.getPcdDriverType();
447 // Restore the DOC which include the FPD module info.
452 // Write Guid to autogen.c
454 String guid
= CommonDefinition
.formatGuidName(saq
.getModuleGuid());
455 if (this.moduleId
.getModuleType().equalsIgnoreCase(EdkDefinitions
.MODULE_TYPE_BASE
)) {
457 .append("GLOBAL_REMOVE_IF_UNREFERENCED GUID gEfiCallerIdGuid = {");
460 .append("GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiCallerIdGuid = {");
464 throw new AutoGenException("Guid value must set!\n");
468 // Formate Guid as ANSI c form.Example:
469 // {0xd2b2b828, 0x826, 0x48a7,{0xb3, 0xdf, 0x98, 0x3c, 0x0, 0x60, 0x24,
473 fileBuffer
.append(guid
);
474 fileBuffer
.append("};\r\n");
477 // Generate library instance consumed protocol, guid, ppi, pcd list.
478 // Save those to this.protocolList, this.ppiList, this.pcdList,
479 // this.guidList. Write Consumed library constructor and desconstuct to
482 LibInstanceToAutogenC(fileBuffer
);
485 // Get module dependent Package identification.
487 PackageIdentification
[] packages
= saq
.getDependencePkg(this.arch
);
488 for (int i
= 0; i
< packages
.length
; i
++) {
489 if (!this.mDepPkgList
.contains(packages
[i
])) {
490 this.mDepPkgList
.add(packages
[i
]);
496 // Write consumed ppi, guid, protocol to autogen.c
498 ProtocolGuidToAutogenC(fileBuffer
);
499 PpiGuidToAutogenC(fileBuffer
);
500 GuidGuidToAutogenC(fileBuffer
);
505 this.myPcdAutogen
= new PCDAutoGenAction(moduleId
,
512 this.myPcdAutogen
.execute();
513 if (this.myPcdAutogen
!= null) {
514 fileBuffer
.append("\r\n");
515 fileBuffer
.append(this.myPcdAutogen
.getCAutoGenString());
518 if (!saveFile(outputPath
+ File
.separatorChar
+ "AutoGen.c", fileBuffer
)) {
519 throw new AutoGenException("Failed to generate AutoGen.c !!!");
527 This function generates AutoGen.h for library.
529 @throws BuildException
530 Failed to generate AutoGen.c.
532 void libGenAutogenH() throws EdkException
{
534 Set
<String
> libClassIncludeH
;
536 List
<String
> headerFileList
;
538 StringBuffer fileBuffer
= new StringBuffer(10240);
541 // Write Autogen.h header notation
543 fileBuffer
.append(CommonDefinition
.AUTOGENHNOTATION
);
546 // Add #ifndef ${BaseName}_AUTOGENH
547 // #def ${BseeName}_AUTOGENH
549 fileBuffer
.append(CommonDefinition
.IFNDEF
550 + CommonDefinition
.AUTOGENH
551 + this.moduleId
.getGuid().replaceAll("-", "_")
552 + ToolDefinitions
.LINE_SEPARATOR
);
553 fileBuffer
.append(CommonDefinition
.DEFINE
554 + CommonDefinition
.AUTOGENH
555 + this.moduleId
.getGuid().replaceAll("-", "_")
556 + ToolDefinitions
.LINE_SEPARATOR
557 + ToolDefinitions
.LINE_SEPARATOR
);
560 // Write EFI_SPECIFICATION_VERSION and EDK_RELEASE_VERSION
561 // to autogen.h file.
562 // Note: the specification version and release version should
563 // be get from module surface area instead of hard code.
565 fileBuffer
.append(CommonDefinition
.AUTOGENHBEGIN
);
566 String
[] specList
= saq
.getExternSpecificaiton();
567 for (int i
= 0; i
< specList
.length
; i
++) {
568 fileBuffer
.append(CommonDefinition
.DEFINE
+ specList
[i
]
571 // fileBuffer.append(CommonDefinition.autoGenHLine1);
572 // fileBuffer.append(CommonDefinition.autoGenHLine2);
575 // Write consumed package's mdouleInfo related *.h file to autogen.h.
577 moduleType
= saq
.getModuleType();
578 PackageIdentification
[] cosumedPkglist
= saq
579 .getDependencePkg(this.arch
);
580 headerFileList
= depPkgToAutogenH(cosumedPkglist
, moduleType
);
581 item
= headerFileList
.iterator();
582 while (item
.hasNext()) {
583 fileBuffer
.append(item
.next().toString());
586 // Write library class's related *.h file to autogen.h
588 String
[] libClassList
= saq
589 .getLibraryClasses(CommonDefinition
.ALWAYSCONSUMED
, this.arch
);
590 if (libClassList
!= null) {
591 libClassIncludeH
= LibraryClassToAutogenH(libClassList
);
592 item
= libClassIncludeH
.iterator();
593 while (item
.hasNext()) {
594 fileBuffer
.append(item
.next().toString());
599 .getLibraryClasses(CommonDefinition
.ALWAYSPRODUCED
, this.arch
);
600 if (libClassList
!= null) {
601 libClassIncludeH
= LibraryClassToAutogenH(libClassList
);
602 item
= libClassIncludeH
.iterator();
603 while (item
.hasNext()) {
604 fileBuffer
.append(item
.next().toString());
607 fileBuffer
.append(ToolDefinitions
.LINE_SEPARATOR
);
610 // If is TianoR8FlashMap, copy {Fv_DIR}/FlashMap.h to
611 // {DEST_DIR_DRBUG}/FlashMap.h
613 if (saq
.isHaveTianoR8FlashMap()) {
614 fileBuffer
.append(CommonDefinition
.INCLUDE
);
615 fileBuffer
.append(" <");
616 fileBuffer
.append(CommonDefinition
.TIANOR8PLASHMAPH
+ ">\r\n");
617 copyFlashMapHToDebugDir();
621 // Write PCD information to library AutoGen.h.
623 if (this.myPcdAutogen
!= null) {
624 fileBuffer
.append("\r\n");
625 fileBuffer
.append(this.myPcdAutogen
.getHAutoGenString());
629 // Append the #endif at AutoGen.h
631 fileBuffer
.append("#endif\r\n");
634 // Save content of string buffer to AutoGen.h file.
636 if (!saveFile(outputPath
+ File
.separatorChar
+ "AutoGen.h", fileBuffer
)) {
637 throw new AutoGenException("Failed to generate AutoGen.h !!!");
644 This function generates AutoGen.h for library.
646 @throws BuildException
647 Failed to generate AutoGen.c.
649 void libGenAutogenC() throws EdkException
{
650 StringBuffer fileBuffer
= new StringBuffer(10240);
653 // Write Autogen.c header notation
655 fileBuffer
.append(CommonDefinition
.AUTOGENCNOTATION
);
657 fileBuffer
.append(ToolDefinitions
.LINE_SEPARATOR
);
658 fileBuffer
.append(ToolDefinitions
.LINE_SEPARATOR
);
663 this.myPcdAutogen
= new PCDAutoGenAction(moduleId
,
666 saq
.getModulePcdEntryNameArray(),
669 this.myPcdAutogen
.execute();
670 if (this.myPcdAutogen
!= null) {
671 fileBuffer
.append(ToolDefinitions
.LINE_SEPARATOR
);
672 fileBuffer
.append(this.myPcdAutogen
.getCAutoGenString());
675 if (!saveFile(outputPath
+ File
.separatorChar
+ "AutoGen.c", fileBuffer
)) {
676 throw new AutoGenException("Failed to generate AutoGen.c !!!");
681 LibraryClassToAutogenH
683 This function returns *.h files declared by library classes which are
684 consumed or produced by current build module or library.
687 List of library class which consumed or produce by current
688 build module or library.
689 @return includeStrList List of *.h file.
691 Set
<String
> LibraryClassToAutogenH(String
[] libClassList
)
692 throws EdkException
{
693 Set
<String
> includeStrList
= new LinkedHashSet
<String
>();
694 String includeName
[];
698 // Get include file from GlobalData's SPDTable according to
699 // library class name.
701 for (int i
= 0; i
< libClassList
.length
; i
++) {
702 includeName
= GlobalData
.getLibraryClassHeaderFiles(
703 saq
.getDependencePkg(this.arch
),
705 if (includeName
== null) {
706 throw new AutoGenException("Can not find library class ["
707 + libClassList
[i
] + "] declaration in any SPD package. ");
709 for (int j
= 0; j
< includeName
.length
; j
++) {
710 String includeNameStr
= includeName
[j
];
711 if (includeNameStr
!= null) {
712 str
= CommonDefinition
.INCLUDE
+ " " + "<";
713 str
= str
+ includeNameStr
+ ">\r\n";
714 includeStrList
.add(str
);
715 includeNameStr
= null;
719 return includeStrList
;
725 This function add include file in AutoGen.h file.
727 @param packageNameList
728 List of module depended package.
733 List
<String
> depPkgToAutogenH(PackageIdentification
[] packageNameList
,
734 String moduleType
) throws AutoGenException
{
736 List
<String
> includeStrList
= new LinkedList
<String
>();
738 String includeStr
= "";
741 // Get include file from moduleInfo file
743 for (int i
= 0; i
< packageNameList
.length
; i
++) {
744 pkgHeader
= GlobalData
.getPackageHeaderFiles(packageNameList
[i
],
746 if (pkgHeader
== null) {
747 throw new AutoGenException("Can not find package ["
749 + "] declaration in any SPD package. ");
750 } else if (!pkgHeader
.equalsIgnoreCase("")) {
751 includeStr
= CommonDefinition
.INCLUDE
+ " <" + pkgHeader
753 includeStrList
.add(includeStr
);
757 return includeStrList
;
763 This function convert <ModuleEntryPoint> & <ModuleUnloadImage>
764 information in mas to AutoGen.c
766 @param entryPointList
769 String buffer fo AutoGen.c.
772 void EntryPointToAutoGen(String
[] entryPointList
, String
[] unloadImageList
, StringBuffer fileBuffer
)
773 throws EdkException
{
775 String typeStr
= saq
.getModuleType();
776 int unloadImageCount
= 0;
777 int entryPointCount
= 0;
780 // The parameters and return value of entryPoint is difference
781 // for difference module type.
783 switch (CommonDefinition
.getModuleType(typeStr
)) {
785 case CommonDefinition
.ModuleTypePeiCore
:
786 if (entryPointList
== null ||entryPointList
.length
!= 1 ) {
787 throw new AutoGenException(
788 "Module type = 'PEI_CORE', can have only one module entry point!");
790 fileBuffer
.append("EFI_STATUS\r\n");
791 fileBuffer
.append(entryPointList
[0]);
792 fileBuffer
.append(" (\r\n");
794 .append(" IN EFI_PEI_STARTUP_DESCRIPTOR *PeiStartupDescriptor,\r\n");
796 .append(" IN VOID *OldCoreData\r\n");
797 fileBuffer
.append(" );\r\n\r\n");
799 fileBuffer
.append("EFI_STATUS\r\n");
800 fileBuffer
.append("EFIAPI\r\n");
801 fileBuffer
.append("ProcessModuleEntryPointList (\r\n");
803 .append(" IN EFI_PEI_STARTUP_DESCRIPTOR *PeiStartupDescriptor,\r\n");
805 .append(" IN VOID *OldCoreData\r\n");
806 fileBuffer
.append(" )\r\n\r\n");
807 fileBuffer
.append("{\r\n");
808 fileBuffer
.append(" return ");
809 fileBuffer
.append(entryPointList
[0]);
810 fileBuffer
.append(" (PeiStartupDescriptor, OldCoreData);\r\n");
811 fileBuffer
.append("}\r\n\r\n");
815 case CommonDefinition
.ModuleTypeDxeCore
:
816 fileBuffer
.append("const UINT32 _gUefiDriverRevision = 0;\r\n");
817 if (entryPointList
== null || entryPointList
.length
!= 1) {
818 throw new AutoGenException(
819 "Module type = 'DXE_CORE', can have only one module entry point!");
822 fileBuffer
.append("VOID\r\n");
823 fileBuffer
.append(entryPointList
[0]);
824 fileBuffer
.append(" (\n");
825 fileBuffer
.append(" IN VOID *HobStart\r\n");
826 fileBuffer
.append(" );\r\n\r\n");
828 fileBuffer
.append("VOID\r\n");
829 fileBuffer
.append("EFIAPI\r\n");
830 fileBuffer
.append("ProcessModuleEntryPointList (\r\n");
831 fileBuffer
.append(" IN VOID *HobStart\r\n");
832 fileBuffer
.append(" )\r\n\r\n");
833 fileBuffer
.append("{\r\n");
834 fileBuffer
.append(" ");
835 fileBuffer
.append(entryPointList
[0]);
836 fileBuffer
.append(" (HobStart);\r\n");
837 fileBuffer
.append("}\r\n\r\n");
841 case CommonDefinition
.ModuleTypePeim
:
844 .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT32 _gPeimRevision = 0;\r\n");
845 if (entryPointList
== null || entryPointList
.length
== 0) {
846 fileBuffer
.append("EFI_STATUS\r\n");
847 fileBuffer
.append("EFIAPI\r\n");
848 fileBuffer
.append("ProcessModuleEntryPointList (\r\n");
849 fileBuffer
.append(" IN EFI_FFS_FILE_HEADER *FfsHeader,\r\n");
850 fileBuffer
.append(" IN EFI_PEI_SERVICES **PeiServices\r\n");
851 fileBuffer
.append(" )\r\n\r\n");
852 fileBuffer
.append("{\r\n");
853 fileBuffer
.append(" return EFI_SUCCESS;\r\n");
854 fileBuffer
.append("}\r\n\r\n");
857 for (int i
= 0; i
< entryPointList
.length
; i
++) {
858 fileBuffer
.append("EFI_STATUS\r\n");
859 fileBuffer
.append(entryPointList
[i
]);
860 fileBuffer
.append(" (\r\n");
862 .append(" IN EFI_FFS_FILE_HEADER *FfsHeader,\r\n");
864 .append(" IN EFI_PEI_SERVICES **PeiServices\r\n");
865 fileBuffer
.append(" );\r\n");
870 fileBuffer
.append("EFI_STATUS\r\n");
871 fileBuffer
.append("EFIAPI\r\n");
872 fileBuffer
.append("ProcessModuleEntryPointList (\r\n");
873 fileBuffer
.append(" IN EFI_FFS_FILE_HEADER *FfsHeader,\r\n");
874 fileBuffer
.append(" IN EFI_PEI_SERVICES **PeiServices\r\n");
875 fileBuffer
.append(" )\r\n\r\n");
876 fileBuffer
.append("{\r\n");
877 if (entryPointCount
== 1) {
878 fileBuffer
.append(" return ");
879 fileBuffer
.append(entryPointList
[0]);
880 fileBuffer
.append(" (FfsHeader, PeiServices);\r\n");
882 fileBuffer
.append(" EFI_STATUS Status;\r\n");
883 fileBuffer
.append(" EFI_STATUS CombinedStatus;\r\n\r\n");
884 fileBuffer
.append(" CombinedStatus = EFI_LOAD_ERROR;\r\n\r\n");
885 for (int i
= 0; i
< entryPointList
.length
; i
++) {
886 if (!entryPointList
[i
].equals("")) {
887 fileBuffer
.append(" Status = ");
888 fileBuffer
.append(entryPointList
[i
]);
889 fileBuffer
.append(" (FfsHeader, PeiServices);\r\n");
891 .append(" if (!EFI_ERROR (Status) || EFI_ERROR (CombinedStatus)) {\r\n");
892 fileBuffer
.append(" CombinedStatus = Status;\r\n");
893 fileBuffer
.append(" }\r\n\r\n");
898 fileBuffer
.append(" return CombinedStatus;\r\n");
900 fileBuffer
.append("}\r\n\r\n");
903 case CommonDefinition
.ModuleTypeDxeSmmDriver
:
906 // If entryPoint is null, create an empty ProcessModuleEntryPointList
909 if (entryPointList
== null || entryPointList
.length
== 0) {
911 .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gDriverEntryPointCount = ");
912 fileBuffer
.append(Integer
.toString(entryPointCount
));
913 fileBuffer
.append(";\r\n");
914 fileBuffer
.append("EFI_STATUS\r\n");
915 fileBuffer
.append("EFIAPI\r\n");
916 fileBuffer
.append("ProcessModuleEntryPointList (\r\n");
917 fileBuffer
.append(" IN EFI_HANDLE ImageHandle,\r\n");
918 fileBuffer
.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");
919 fileBuffer
.append(" )\r\n\r\n");
920 fileBuffer
.append("{\r\n");
921 fileBuffer
.append(" return EFI_SUCCESS;\r\n");
922 fileBuffer
.append("}\r\n\r\n");
925 for (int i
= 0; i
< entryPointList
.length
; i
++) {
926 fileBuffer
.append("EFI_STATUS\r\n");
927 fileBuffer
.append(entryPointList
[i
]);
928 fileBuffer
.append(" (\r\n");
929 fileBuffer
.append(" IN EFI_HANDLE ImageHandle,\r\n");
930 fileBuffer
.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");
931 fileBuffer
.append(" );\r\n");
935 .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gDriverEntryPointCount = ");
936 fileBuffer
.append(Integer
.toString(entryPointCount
));
937 fileBuffer
.append(";\r\n");
939 .append("static BASE_LIBRARY_JUMP_BUFFER mJumpContext;\r\n");
941 .append("static EFI_STATUS mDriverEntryPointStatus = EFI_LOAD_ERROR;\r\n\r\n");
943 fileBuffer
.append("EFI_STATUS\r\n");
944 fileBuffer
.append("EFIAPI\r\n");
945 fileBuffer
.append("ProcessModuleEntryPointList (\r\n");
946 fileBuffer
.append(" IN EFI_HANDLE ImageHandle,\r\n");
947 fileBuffer
.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");
948 fileBuffer
.append(" )\r\n\r\n");
949 fileBuffer
.append("{\r\n");
952 for (int i
= 0; i
< entryPointList
.length
; i
++) {
954 .append(" if (SetJump (&mJumpContext) == 0) {\r\n");
955 fileBuffer
.append(" ExitDriver (");
956 fileBuffer
.append(entryPointList
[i
]);
957 fileBuffer
.append(" (ImageHandle, SystemTable));\r\n");
958 fileBuffer
.append(" ASSERT (FALSE);\r\n");
959 fileBuffer
.append(" }\r\n");
962 fileBuffer
.append(" return mDriverEntryPointStatus;\r\n");
963 fileBuffer
.append("}\r\n\r\n");
965 fileBuffer
.append("VOID\r\n");
966 fileBuffer
.append("EFIAPI\r\n");
967 fileBuffer
.append("ExitDriver (\r\n");
968 fileBuffer
.append(" IN EFI_STATUS Status\n");
969 fileBuffer
.append(" )\r\n\r\n");
970 fileBuffer
.append("{\r\n");
972 .append(" if (!EFI_ERROR (Status) || EFI_ERROR (mDriverEntryPointStatus)) {\r\n");
973 fileBuffer
.append(" mDriverEntryPointStatus = Status;\r\n");
974 fileBuffer
.append(" }\r\n");
975 fileBuffer
.append(" LongJump (&mJumpContext, (UINTN)-1);\r\n");
976 fileBuffer
.append(" ASSERT (FALSE);\r\n");
977 fileBuffer
.append("}\r\n\r\n");
983 // Add "ModuleUnloadImage" for DxeSmmDriver module type;
985 //entryPointList = SurfaceAreaQuery.getModuleUnloadImageArray();
986 //entryPointList = CommonDefinition.remDupString(entryPointList);
987 //entryPointCount = 0;
989 unloadImageCount
= 0;
990 if (unloadImageList
!= null) {
991 for (int i
= 0; i
< unloadImageList
.length
; i
++) {
992 fileBuffer
.append("EFI_STATUS\r\n");
993 fileBuffer
.append(unloadImageList
[i
]);
994 fileBuffer
.append(" (\r\n");
996 .append(" IN EFI_HANDLE ImageHandle\r\n");
997 fileBuffer
.append(" );\r\n");
1003 .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gDriverUnloadImageCount = ");
1004 fileBuffer
.append(Integer
.toString(unloadImageCount
));
1005 fileBuffer
.append(";\r\n\r\n");
1007 fileBuffer
.append("EFI_STATUS\r\n");
1008 fileBuffer
.append("EFIAPI\r\n");
1009 fileBuffer
.append("ProcessModuleUnloadList (\r\n");
1010 fileBuffer
.append(" IN EFI_HANDLE ImageHandle\r\n");
1011 fileBuffer
.append(" )\r\n");
1012 fileBuffer
.append("{\r\n");
1014 if (unloadImageCount
== 0) {
1015 fileBuffer
.append(" return EFI_SUCCESS;\r\n");
1016 } else if (unloadImageCount
== 1) {
1017 fileBuffer
.append(" return ");
1018 fileBuffer
.append(unloadImageList
[0]);
1019 fileBuffer
.append("(ImageHandle);\r\n");
1021 fileBuffer
.append(" EFI_STATUS Status;\r\n\r\n");
1022 fileBuffer
.append(" Status = EFI_SUCCESS;\r\n\r\n");
1023 for (int i
= 0; i
< unloadImageList
.length
; i
++) {
1025 fileBuffer
.append(" Status = ");
1026 fileBuffer
.append(unloadImageList
[i
]);
1027 fileBuffer
.append("(ImageHandle);\r\n");
1029 fileBuffer
.append(" if (EFI_ERROR (Status)) {\r\n");
1030 fileBuffer
.append(" ");
1031 fileBuffer
.append(unloadImageList
[i
]);
1032 fileBuffer
.append("(ImageHandle);\r\n");
1033 fileBuffer
.append(" } else {\r\n");
1034 fileBuffer
.append(" Status = ");
1035 fileBuffer
.append(unloadImageList
[i
]);
1036 fileBuffer
.append("(ImageHandle);\r\n");
1037 fileBuffer
.append(" }\r\n");
1040 fileBuffer
.append(" return Status;\r\n");
1042 fileBuffer
.append("}\r\n\r\n");
1045 case CommonDefinition
.ModuleTypeDxeRuntimeDriver
:
1046 case CommonDefinition
.ModuleTypeDxeDriver
:
1047 case CommonDefinition
.ModuleTypeDxeSalDriver
:
1048 case CommonDefinition
.ModuleTypeUefiDriver
:
1049 case CommonDefinition
.ModuleTypeUefiApplication
:
1050 entryPointCount
= 0;
1051 fileBuffer
.append("const UINT32 _gUefiDriverRevision = 0;\r\n");
1053 // If entry point is null, create a empty ProcessModuleEntryPointList function.
1055 if (entryPointList
== null || entryPointList
.length
== 0) {
1057 .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gDriverEntryPointCount = 0;\r\n");
1058 fileBuffer
.append("EFI_STATUS\r\n");
1059 fileBuffer
.append("EFIAPI\r\n");
1060 fileBuffer
.append("ProcessModuleEntryPointList (\r\n");
1061 fileBuffer
.append(" IN EFI_HANDLE ImageHandle,\r\n");
1062 fileBuffer
.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");
1063 fileBuffer
.append(" )\r\n\r\n");
1064 fileBuffer
.append("{\r\n");
1065 fileBuffer
.append(" return EFI_SUCCESS;\r\n");
1066 fileBuffer
.append("}\r\n");
1069 for (int i
= 0; i
< entryPointList
.length
; i
++) {
1071 fileBuffer
.append("EFI_STATUS\r\n");
1072 fileBuffer
.append(entryPointList
[i
]);
1073 fileBuffer
.append(" (\r\n");
1074 fileBuffer
.append(" IN EFI_HANDLE ImageHandle,\r\n");
1075 fileBuffer
.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");
1076 fileBuffer
.append(" );\r\n");
1081 .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gDriverEntryPointCount = ");
1082 fileBuffer
.append(Integer
.toString(entryPointCount
));
1083 fileBuffer
.append(";\r\n");
1084 if (entryPointCount
> 1) {
1086 .append("static BASE_LIBRARY_JUMP_BUFFER mJumpContext;\r\n");
1088 .append("static EFI_STATUS mDriverEntryPointStatus = EFI_LOAD_ERROR;\r\n");
1090 fileBuffer
.append("\n");
1092 fileBuffer
.append("EFI_STATUS\r\n");
1093 fileBuffer
.append("EFIAPI\r\n");
1094 fileBuffer
.append("ProcessModuleEntryPointList (\r\n");
1095 fileBuffer
.append(" IN EFI_HANDLE ImageHandle,\r\n");
1096 fileBuffer
.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");
1097 fileBuffer
.append(" )\r\n\r\n");
1098 fileBuffer
.append("{\r\n");
1100 if (entryPointCount
== 1) {
1101 fileBuffer
.append(" return (");
1102 fileBuffer
.append(entryPointList
[0]);
1103 fileBuffer
.append(" (ImageHandle, SystemTable));\r\n");
1105 for (int i
= 0; i
< entryPointList
.length
; i
++) {
1106 if (!entryPointList
[i
].equals("")) {
1108 .append(" if (SetJump (&mJumpContext) == 0) {\r\n");
1109 fileBuffer
.append(" ExitDriver (");
1110 fileBuffer
.append(entryPointList
[i
]);
1111 fileBuffer
.append(" (ImageHandle, SystemTable));\r\n");
1112 fileBuffer
.append(" ASSERT (FALSE);\r\n");
1113 fileBuffer
.append(" }\r\n");
1118 fileBuffer
.append(" return mDriverEntryPointStatus;\r\n");
1120 fileBuffer
.append("}\r\n\r\n");
1122 fileBuffer
.append("VOID\r\n");
1123 fileBuffer
.append("EFIAPI\r\n");
1124 fileBuffer
.append("ExitDriver (\r\n");
1125 fileBuffer
.append(" IN EFI_STATUS Status\r\n");
1126 fileBuffer
.append(" )\r\n\r\n");
1127 fileBuffer
.append("{\r\n");
1128 if (entryPointCount
<= 1) {
1129 fileBuffer
.append(" if (EFI_ERROR (Status)) {\r\n");
1131 .append(" ProcessLibraryDestructorList (gImageHandle, gST);\r\n");
1132 fileBuffer
.append(" }\r\n");
1134 .append(" gBS->Exit (gImageHandle, Status, 0, NULL);\r\n");
1137 .append(" if (!EFI_ERROR (Status) || EFI_ERROR (mDriverEntryPointStatus)) {\r\n");
1138 fileBuffer
.append(" mDriverEntryPointStatus = Status;\r\n");
1139 fileBuffer
.append(" }\r\n");
1140 fileBuffer
.append(" LongJump (&mJumpContext, (UINTN)-1);\r\n");
1141 fileBuffer
.append(" ASSERT (FALSE);\r\n");
1143 fileBuffer
.append("}\r\n\r\n");
1148 // Add ModuleUnloadImage for DxeDriver and UefiDriver module type.
1150 //entryPointList = SurfaceAreaQuery.getModuleUnloadImageArray();
1152 // Remover duplicate unload entry point.
1154 //entryPointList = CommonDefinition.remDupString(entryPointList);
1155 //entryPointCount = 0;
1156 unloadImageCount
= 0;
1157 if (unloadImageList
!= null) {
1158 for (int i
= 0; i
< unloadImageList
.length
; i
++) {
1159 fileBuffer
.append("EFI_STATUS\r\n");
1160 fileBuffer
.append("EFIAPI\r\n");
1161 fileBuffer
.append(unloadImageList
[i
]);
1162 fileBuffer
.append(" (\r\n");
1164 .append(" IN EFI_HANDLE ImageHandle\r\n");
1165 fileBuffer
.append(" );\r\n");
1171 .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gDriverUnloadImageCount = ");
1172 fileBuffer
.append(Integer
.toString(unloadImageCount
));
1173 fileBuffer
.append(";\r\n\r\n");
1175 fileBuffer
.append("EFI_STATUS\n");
1176 fileBuffer
.append("EFIAPI\r\n");
1177 fileBuffer
.append("ProcessModuleUnloadList (\r\n");
1178 fileBuffer
.append(" IN EFI_HANDLE ImageHandle\r\n");
1179 fileBuffer
.append(" )\r\n");
1180 fileBuffer
.append("{\r\n");
1182 if (unloadImageCount
== 0) {
1183 fileBuffer
.append(" return EFI_SUCCESS;\r\n");
1184 } else if (unloadImageCount
== 1) {
1185 fileBuffer
.append(" return ");
1186 fileBuffer
.append(unloadImageList
[0]);
1187 fileBuffer
.append("(ImageHandle);\r\n");
1189 fileBuffer
.append(" EFI_STATUS Status;\r\n\r\n");
1190 fileBuffer
.append(" Status = EFI_SUCCESS;\r\n\r\n");
1191 for (int i
= 0; i
< unloadImageList
.length
; i
++) {
1193 fileBuffer
.append(" Status = ");
1194 fileBuffer
.append(unloadImageList
[i
]);
1195 fileBuffer
.append("(ImageHandle);\r\n");
1197 fileBuffer
.append(" if (EFI_ERROR (Status)) {\r\n");
1198 fileBuffer
.append(" ");
1199 fileBuffer
.append(unloadImageList
[i
]);
1200 fileBuffer
.append("(ImageHandle);\r\n");
1201 fileBuffer
.append(" } else {\r\n");
1202 fileBuffer
.append(" Status = ");
1203 fileBuffer
.append(unloadImageList
[i
]);
1204 fileBuffer
.append("(ImageHandle);\r\n");
1205 fileBuffer
.append(" }\r\n");
1208 fileBuffer
.append(" return Status;\r\n");
1210 fileBuffer
.append("}\r\n\r\n");
1218 This function gets GUIDs from SPD file accrodeing to <PPIs> information
1219 and write those GUIDs to AutoGen.c.
1222 String Buffer for Autogen.c file.
1223 @throws BuildException
1224 Guid must set value!
1226 void PpiGuidToAutogenC(StringBuffer fileBuffer
) throws AutoGenException
{
1227 String
[] cNameGuid
= null;
1230 // Get the all PPI adn PPI Notify from MSA file,
1231 // then add those PPI ,and PPI Notify name to list.
1234 String
[] ppiList
= saq
.getPpiArray(this.arch
);
1235 for (int i
= 0; i
< ppiList
.length
; i
++) {
1236 this.mPpiList
.add(ppiList
[i
]);
1239 String
[] ppiNotifyList
= saq
.getPpiNotifyArray(this.arch
);
1240 for (int i
= 0; i
< ppiNotifyList
.length
; i
++) {
1241 this.mPpiList
.add(ppiNotifyList
[i
]);
1245 // Find CNAME and GUID from dependence SPD file and write to Autogen.c
1247 Iterator ppiIterator
= this.mPpiList
.iterator();
1248 String ppiKeyWord
= null;
1249 while (ppiIterator
.hasNext()) {
1250 ppiKeyWord
= ppiIterator
.next().toString();
1251 cNameGuid
= GlobalData
.getPpiGuid(this.mDepPkgList
, ppiKeyWord
);
1252 if (cNameGuid
!= null) {
1254 .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID ");
1255 fileBuffer
.append(cNameGuid
[0]);
1256 fileBuffer
.append(" = { ");
1257 fileBuffer
.append(CommonDefinition
.formatGuidName(cNameGuid
[1]));
1258 fileBuffer
.append(" } ;");
1261 // If can't find Ppi GUID declaration in every package
1263 throw new AutoGenException("Can not find Ppi GUID ["
1264 + ppiKeyWord
+ "] declaration in any SPD package!");
1270 ProtocolGuidToAutogenc
1272 This function gets GUIDs from SPD file accrodeing to <Protocol>
1273 information and write those GUIDs to AutoGen.c.
1276 String Buffer for Autogen.c file.
1277 @throws BuildException
1278 Protocol name must set.
1280 void ProtocolGuidToAutogenC(StringBuffer fileBuffer
) throws EdkException
{
1281 String
[] cNameGuid
= null;
1283 String
[] protocolList
= saq
.getProtocolArray(this.arch
);
1286 // Add result to Autogen global list.
1288 for (int i
= 0; i
< protocolList
.length
; i
++) {
1289 this.mProtocolList
.add(protocolList
[i
]);
1292 String
[] protocolNotifyList
= saq
1293 .getProtocolNotifyArray(this.arch
);
1295 for (int i
= 0; i
< protocolNotifyList
.length
; i
++) {
1296 this.mProtocolList
.add(protocolNotifyList
[i
]);
1300 // Get the NAME and GUID from dependence SPD and write to Autogen.c
1302 Iterator protocolIterator
= this.mProtocolList
.iterator();
1303 String protocolKeyWord
= null;
1306 while (protocolIterator
.hasNext()) {
1307 protocolKeyWord
= protocolIterator
.next().toString();
1308 cNameGuid
= GlobalData
.getProtocolGuid(this.mDepPkgList
, protocolKeyWord
);
1309 if (cNameGuid
!= null) {
1311 .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID ");
1312 fileBuffer
.append(cNameGuid
[0]);
1313 fileBuffer
.append(" = { ");
1314 fileBuffer
.append(CommonDefinition
.formatGuidName(cNameGuid
[1]));
1315 fileBuffer
.append(" } ;");
1318 // If can't find protocol GUID declaration in every package
1320 throw new AutoGenException("Can not find protocol Guid ["
1321 + protocolKeyWord
+ "] declaration in any SPD package!");
1329 This function gets GUIDs from SPD file accrodeing to <Guids> information
1330 and write those GUIDs to AutoGen.c.
1333 String Buffer for Autogen.c file.
1336 void GuidGuidToAutogenC(StringBuffer fileBuffer
) throws AutoGenException
{
1337 String
[] cNameGuid
= null;
1338 String guidKeyWord
= null;
1340 String
[] guidList
= saq
.getGuidEntryArray(this.arch
);
1342 for (int i
= 0; i
< guidList
.length
; i
++) {
1343 this.mGuidList
.add(guidList
[i
]);
1347 Iterator guidIterator
= this.mGuidList
.iterator();
1348 while (guidIterator
.hasNext()) {
1349 guidKeyWord
= guidIterator
.next().toString();
1350 cNameGuid
= GlobalData
.getGuid(this.mDepPkgList
, guidKeyWord
);
1352 if (cNameGuid
!= null) {
1354 .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID ");
1355 fileBuffer
.append(cNameGuid
[0]);
1356 fileBuffer
.append(" = { ");
1357 fileBuffer
.append(CommonDefinition
.formatGuidName(cNameGuid
[1]));
1358 fileBuffer
.append("} ;");
1361 // If can't find GUID declaration in every package
1363 throw new AutoGenException("Can not find Guid [" + guidKeyWord
1364 + "] declaration in any SPD package. ");
1371 LibInstanceToAutogenC
1373 This function adds dependent library instance to autogen.c,which
1374 includeing library's constructor, destructor, and library dependent ppi,
1375 protocol, guid, pcd information.
1378 String buffer for AutoGen.c
1379 @throws BuildException
1381 void LibInstanceToAutogenC(StringBuffer fileBuffer
) throws EdkException
{
1382 String moduleType
= this.moduleId
.getModuleType();
1384 // Add library constructor to AutoGen.c
1386 LibConstructorToAutogenC(libConstructList
, moduleType
,
1387 fileBuffer
/* autogenC */);
1389 // Add library destructor to AutoGen.c
1391 LibDestructorToAutogenC(libDestructList
, moduleType
, fileBuffer
/* autogenC */);
1395 LibConstructorToAutogenc
1397 This function writes library constructor list to AutoGen.c. The library
1398 constructor's parameter and return value depend on module type.
1400 @param libInstanceList
1401 List of library construct name.
1405 String buffer for AutoGen.c
1408 void LibConstructorToAutogenC(List
<String
[]> libInstanceList
,
1409 String moduleType
, StringBuffer fileBuffer
) throws EdkException
{
1410 boolean isFirst
= true;
1413 // The library constructor's parameter and return value depend on
1416 for (int i
= 0; i
< libInstanceList
.size(); i
++) {
1417 if (libInstanceList
.get(i
)[1].equalsIgnoreCase(EdkDefinitions
.MODULE_TYPE_BASE
)) {
1418 fileBuffer
.append("RETURN_STATUS\r\n");
1419 fileBuffer
.append("EFIAPI\r\n");
1420 fileBuffer
.append(libInstanceList
.get(i
)[0]);
1421 fileBuffer
.append(" (\r\n");
1422 fileBuffer
.append(" VOID\r\n");
1423 fileBuffer
.append(" );\r\n");
1425 switch (CommonDefinition
.getModuleType(moduleType
)) {
1426 case CommonDefinition
.ModuleTypeBase
:
1427 fileBuffer
.append("RETURN_STATUS\r\n");
1428 fileBuffer
.append("EFIAPI\r\n");
1429 fileBuffer
.append(libInstanceList
.get(i
)[0]);
1430 fileBuffer
.append(" (\r\n");
1431 fileBuffer
.append(" VOID\r\n");
1432 fileBuffer
.append(" );\r\n");
1435 case CommonDefinition
.ModuleTypePeiCore
:
1436 case CommonDefinition
.ModuleTypePeim
:
1437 fileBuffer
.append("EFI_STATUS\r\n");
1438 fileBuffer
.append("EFIAPI\r\n");
1439 fileBuffer
.append(libInstanceList
.get(i
)[0]);
1440 fileBuffer
.append(" (\r\n");
1442 .append(" IN EFI_FFS_FILE_HEADER *FfsHeader,\r\n");
1444 .append(" IN EFI_PEI_SERVICES **PeiServices\r\n");
1445 fileBuffer
.append(" );\r\n");
1448 case CommonDefinition
.ModuleTypeDxeCore
:
1449 case CommonDefinition
.ModuleTypeDxeDriver
:
1450 case CommonDefinition
.ModuleTypeDxeRuntimeDriver
:
1451 case CommonDefinition
.ModuleTypeDxeSmmDriver
:
1452 case CommonDefinition
.ModuleTypeDxeSalDriver
:
1453 case CommonDefinition
.ModuleTypeUefiDriver
:
1454 case CommonDefinition
.ModuleTypeUefiApplication
:
1455 fileBuffer
.append("EFI_STATUS\r\n");
1456 fileBuffer
.append("EFIAPI\r\n");
1457 fileBuffer
.append(libInstanceList
.get(i
)[0]);
1458 fileBuffer
.append(" (\r\n");
1459 fileBuffer
.append(" IN EFI_HANDLE ImageHandle,\r\n");
1460 fileBuffer
.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");
1461 fileBuffer
.append(" );\r\n");
1469 // Add ProcessLibraryConstructorList in AutoGen.c
1471 fileBuffer
.append("VOID\r\n");
1472 fileBuffer
.append("EFIAPI\r\n");
1473 fileBuffer
.append("ProcessLibraryConstructorList (\r\n");
1474 switch (CommonDefinition
.getModuleType(moduleType
)) {
1475 case CommonDefinition
.ModuleTypeBase
:
1476 fileBuffer
.append(" VOID\r\n");
1479 case CommonDefinition
.ModuleTypePeiCore
:
1480 case CommonDefinition
.ModuleTypePeim
:
1481 fileBuffer
.append(" IN EFI_FFS_FILE_HEADER *FfsHeader,\r\n");
1483 .append(" IN EFI_PEI_SERVICES **PeiServices\r\n");
1486 case CommonDefinition
.ModuleTypeDxeCore
:
1487 case CommonDefinition
.ModuleTypeDxeDriver
:
1488 case CommonDefinition
.ModuleTypeDxeRuntimeDriver
:
1489 case CommonDefinition
.ModuleTypeDxeSmmDriver
:
1490 case CommonDefinition
.ModuleTypeDxeSalDriver
:
1491 case CommonDefinition
.ModuleTypeUefiDriver
:
1492 case CommonDefinition
.ModuleTypeUefiApplication
:
1493 fileBuffer
.append(" IN EFI_HANDLE ImageHandle,\r\n");
1494 fileBuffer
.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");
1498 fileBuffer
.append(" )\r\n");
1499 fileBuffer
.append("{\r\n");
1501 // If no constructor function, return EFI_SUCCESS.
1503 //if (libInstanceList.size() == 0){
1504 // fileBuffer.append(" return EFI_SUCCESS;\r\n");
1506 for (int i
= 0; i
< libInstanceList
.size(); i
++) {
1508 fileBuffer
.append(" EFI_STATUS Status;\r\n");
1509 fileBuffer
.append(" Status = EFI_SUCCESS;\r\n");
1510 fileBuffer
.append("\r\n");
1513 if (libInstanceList
.get(i
)[1].equalsIgnoreCase(EdkDefinitions
.MODULE_TYPE_BASE
)) {
1514 fileBuffer
.append(" Status = ");
1515 fileBuffer
.append(libInstanceList
.get(i
)[0]);
1516 fileBuffer
.append("();\r\n");
1518 switch (CommonDefinition
.getModuleType(moduleType
)) {
1519 case CommonDefinition
.ModuleTypeBase
:
1520 fileBuffer
.append(" Status = ");
1521 fileBuffer
.append(libInstanceList
.get(i
)[0]);
1522 fileBuffer
.append("();\r\n");
1524 case CommonDefinition
.ModuleTypePeiCore
:
1525 case CommonDefinition
.ModuleTypePeim
:
1526 fileBuffer
.append(" Status = ");
1527 fileBuffer
.append(libInstanceList
.get(i
)[0]);
1528 fileBuffer
.append(" (FfsHeader, PeiServices);\r\n");
1530 case CommonDefinition
.ModuleTypeDxeCore
:
1531 case CommonDefinition
.ModuleTypeDxeDriver
:
1532 case CommonDefinition
.ModuleTypeDxeRuntimeDriver
:
1533 case CommonDefinition
.ModuleTypeDxeSmmDriver
:
1534 case CommonDefinition
.ModuleTypeDxeSalDriver
:
1535 case CommonDefinition
.ModuleTypeUefiDriver
:
1536 case CommonDefinition
.ModuleTypeUefiApplication
:
1537 fileBuffer
.append(" Status = ");
1538 fileBuffer
.append(libInstanceList
.get(i
)[0]);
1539 fileBuffer
.append(" (ImageHandle, SystemTable);\r\n");
1542 EdkLog
.log(EdkLog
.EDK_INFO
,"Autogen doesn't know how to deal with module type - " + moduleType
+ "!");
1546 fileBuffer
.append(" ASSERT_EFI_ERROR (Status);\r\n");
1548 fileBuffer
.append("}\r\n");
1552 LibDestructorToAutogenc
1554 This function writes library destructor list to AutoGen.c. The library
1555 destructor's parameter and return value depend on module type.
1557 @param libInstanceList
1558 List of library destructor name.
1562 String buffer for AutoGen.c
1565 void LibDestructorToAutogenC(List
<String
[]> libInstanceList
,
1566 String moduleType
, StringBuffer fileBuffer
) throws EdkException
{
1567 boolean isFirst
= true;
1568 for (int i
= 0; i
< libInstanceList
.size(); i
++) {
1569 if (libInstanceList
.get(i
)[1].equalsIgnoreCase(EdkDefinitions
.MODULE_TYPE_BASE
)) {
1570 fileBuffer
.append("RETURN_STATUS\r\n");
1571 fileBuffer
.append("EFIAPI\r\n");
1572 fileBuffer
.append(libInstanceList
.get(i
)[0]);
1573 fileBuffer
.append(" (\r\n");
1574 fileBuffer
.append(" VOID\r\n");
1575 fileBuffer
.append(" );\r\n");
1577 switch (CommonDefinition
.getModuleType(moduleType
)) {
1578 case CommonDefinition
.ModuleTypeBase
:
1579 fileBuffer
.append("RETURN_STATUS\r\n");
1580 fileBuffer
.append("EFIAPI\r\n");
1581 fileBuffer
.append(libInstanceList
.get(i
)[0]);
1582 fileBuffer
.append(" (\r\n");
1583 fileBuffer
.append(" VOID\r\n");
1584 fileBuffer
.append(" );\r\n");
1586 case CommonDefinition
.ModuleTypePeiCore
:
1587 case CommonDefinition
.ModuleTypePeim
:
1588 fileBuffer
.append("EFI_STATUS\r\n");
1589 fileBuffer
.append("EFIAPI\r\n");
1590 fileBuffer
.append(libInstanceList
.get(i
)[0]);
1591 fileBuffer
.append(" (\r\n");
1593 .append(" IN EFI_FFS_FILE_HEADER *FfsHeader,\r\n");
1595 .append(" IN EFI_PEI_SERVICES **PeiServices\r\n");
1596 fileBuffer
.append(" );\r\n");
1598 case CommonDefinition
.ModuleTypeDxeCore
:
1599 case CommonDefinition
.ModuleTypeDxeDriver
:
1600 case CommonDefinition
.ModuleTypeDxeRuntimeDriver
:
1601 case CommonDefinition
.ModuleTypeDxeSmmDriver
:
1602 case CommonDefinition
.ModuleTypeDxeSalDriver
:
1603 case CommonDefinition
.ModuleTypeUefiDriver
:
1604 case CommonDefinition
.ModuleTypeUefiApplication
:
1605 fileBuffer
.append("EFI_STATUS\r\n");
1606 fileBuffer
.append("EFIAPI\r\n");
1607 fileBuffer
.append(libInstanceList
.get(i
)[0]);
1608 fileBuffer
.append(" (\r\n");
1609 fileBuffer
.append(" IN EFI_HANDLE ImageHandle,\r\n");
1610 fileBuffer
.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");
1611 fileBuffer
.append(" );\r\n");
1618 // Write ProcessLibraryDestructor list to autogen.c
1620 switch (CommonDefinition
.getModuleType(moduleType
)) {
1621 case CommonDefinition
.ModuleTypeBase
:
1622 case CommonDefinition
.ModuleTypePeiCore
:
1623 case CommonDefinition
.ModuleTypePeim
:
1625 case CommonDefinition
.ModuleTypeDxeCore
:
1626 case CommonDefinition
.ModuleTypeDxeDriver
:
1627 case CommonDefinition
.ModuleTypeDxeRuntimeDriver
:
1628 case CommonDefinition
.ModuleTypeDxeSmmDriver
:
1629 case CommonDefinition
.ModuleTypeDxeSalDriver
:
1630 case CommonDefinition
.ModuleTypeUefiDriver
:
1631 case CommonDefinition
.ModuleTypeUefiApplication
:
1632 fileBuffer
.append("VOID\r\n");
1633 fileBuffer
.append("EFIAPI\r\n");
1634 fileBuffer
.append("ProcessLibraryDestructorList (\r\n");
1635 fileBuffer
.append(" IN EFI_HANDLE ImageHandle,\r\n");
1636 fileBuffer
.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");
1637 fileBuffer
.append(" )\r\n");
1638 fileBuffer
.append("{\r\n");
1640 // If no library destructor function, return EFI_SUCCESS.
1643 for (int i
= 0; i
< libInstanceList
.size(); i
++) {
1645 fileBuffer
.append(" EFI_STATUS Status;\r\n");
1646 fileBuffer
.append(" Status = EFI_SUCCESS;\r\n");
1647 fileBuffer
.append("\r\n");
1650 if (libInstanceList
.get(i
)[1].equalsIgnoreCase(EdkDefinitions
.MODULE_TYPE_BASE
)) {
1651 fileBuffer
.append(" Status = ");
1652 fileBuffer
.append(libInstanceList
.get(i
)[0]);
1653 fileBuffer
.append("();\r\n");
1654 fileBuffer
.append(" VOID\r\n");
1656 fileBuffer
.append(" Status = ");
1657 fileBuffer
.append(libInstanceList
.get(i
)[0]);
1658 fileBuffer
.append("(ImageHandle, SystemTable);\r\n");
1659 fileBuffer
.append(" ASSERT_EFI_ERROR (Status);\r\n");
1662 fileBuffer
.append("}\r\n");
1668 ExternsDriverBindingToAutoGenC
1670 This function is to write DRIVER_BINDING, COMPONENT_NAME,
1671 DRIVER_CONFIGURATION, DRIVER_DIAGNOSTIC in AutoGen.c.
1674 String buffer for AutoGen.c
1676 void ExternsDriverBindingToAutoGenC(StringBuffer fileBuffer
)
1677 throws EdkException
{
1680 // Get the arry of extern. The driverBindingGroup is a 2 dimension array.
1681 // The second dimension is include following element: DriverBinding,
1682 // ComponentName, DriverConfiguration, DriverDiag;
1684 String
[][] driverBindingGroup
= this.saq
.getExternProtocolGroup();
1692 // Write driver binding protocol extern to autogen.c
1694 for (int i
= 0; i
< driverBindingGroup
.length
; i
++) {
1695 if (driverBindingGroup
[i
][0] != null) {
1696 fileBuffer
.append("extern EFI_DRIVER_BINDING_PROTOCOL ");
1697 fileBuffer
.append(driverBindingGroup
[i
][0]);
1698 fileBuffer
.append(";\r\n");
1703 // Write component name protocol extern to autogen.c
1705 for (int i
= 0; i
< driverBindingGroup
.length
; i
++) {
1706 if (driverBindingGroup
[i
][1]!= null) {
1707 if (driverBindingGroup
[i
][0] != null) {
1709 fileBuffer
.append("extern EFI_COMPONENT_NAME_PROTOCOL ");
1710 fileBuffer
.append(driverBindingGroup
[i
][1]);
1711 fileBuffer
.append(";\r\n");
1713 throw new AutoGenException("DriverBinding can't be empty!!");
1719 // Write driver configration protocol extern to autogen.c
1721 for (int i
= 0; i
< driverBindingGroup
.length
; i
++) {
1722 if (driverBindingGroup
[i
][2] != null) {
1723 if (driverBindingGroup
[i
][0] != null) {
1725 fileBuffer
.append("extern EFI_DRIVER_CONFIGURATION_PROTOCOL ");
1726 fileBuffer
.append(driverBindingGroup
[i
][2]);
1727 fileBuffer
.append(";\r\n");
1729 throw new AutoGenException("DriverBinding can't be empty!!");
1735 // Write driver dignastic protocol extern to autogen.c
1737 for (int i
= 0; i
< driverBindingGroup
.length
; i
++) {
1738 if (driverBindingGroup
[i
][3] != null) {
1739 if (driverBindingGroup
[i
][0] != null) {
1741 fileBuffer
.append("extern EFI_DRIVER_DIAGNOSTICS_PROTOCOL ");
1742 fileBuffer
.append(driverBindingGroup
[i
][3]);
1743 fileBuffer
.append(";\r\n");
1745 throw new AutoGenException("DriverBinding can't be empty!!");
1751 // Write driver module protocol bitmask.
1754 .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gDriverModelProtocolBitmask = ");
1755 fileBuffer
.append(Integer
.toString(BitMask
));
1756 fileBuffer
.append(";\r\n");
1759 // Write driver module protocol list entry
1762 .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINTN _gDriverModelProtocolListEntries = ");
1764 fileBuffer
.append(Integer
.toString(driverBindingGroup
.length
));
1765 fileBuffer
.append(";\r\n");
1768 // Write drive module protocol list to autogen.c
1770 if (driverBindingGroup
.length
> 0) {
1772 .append("GLOBAL_REMOVE_IF_UNREFERENCED const EFI_DRIVER_MODEL_PROTOCOL_LIST _gDriverModelProtocolList[] = {");
1776 for (int i
= 0; i
< driverBindingGroup
.length
; i
++) {
1778 fileBuffer
.append(",");
1781 fileBuffer
.append("\r\n {\r\n");
1782 fileBuffer
.append(" &");
1783 fileBuffer
.append(driverBindingGroup
[i
][0]);
1784 fileBuffer
.append(", \r\n");
1787 if (driverBindingGroup
[i
][1] != null) {
1788 fileBuffer
.append(" &");
1789 fileBuffer
.append(driverBindingGroup
[i
][1]);
1790 fileBuffer
.append(", \r\n");
1792 fileBuffer
.append(" NULL, \r\n");
1795 if (driverBindingGroup
[i
][2] != null) {
1796 fileBuffer
.append(" &");
1797 fileBuffer
.append(driverBindingGroup
[i
][2]);
1798 fileBuffer
.append(", \r\n");
1800 fileBuffer
.append(" NULL, \r\n");
1803 if (driverBindingGroup
[i
][3] != null) {
1804 fileBuffer
.append(" &");
1805 fileBuffer
.append(driverBindingGroup
[i
][3]);
1806 fileBuffer
.append(", \r\n");
1808 fileBuffer
.append(" NULL, \r\n");
1810 fileBuffer
.append(" }");
1813 if (driverBindingGroup
.length
> 0) {
1814 fileBuffer
.append("\r\n};\r\n");
1819 ExternCallBackToAutoGenC
1821 This function adds <SetVirtualAddressMapCallBack> and
1822 <ExitBootServicesCallBack> infomation to AutoGen.c
1825 String buffer for AutoGen.c
1826 @throws BuildException
1828 void ExternCallBackToAutoGenC(StringBuffer fileBuffer
)
1829 throws EdkException
{
1831 // Collect module's <SetVirtualAddressMapCallBack> and
1832 // <ExitBootServiceCallBack> and add to setVirtualAddList
1833 // exitBootServiceList.
1835 String
[] setVirtuals
= saq
.getSetVirtualAddressMapCallBackArray();
1836 String
[] exitBoots
= saq
.getExitBootServicesCallBackArray();
1837 if (setVirtuals
!= null) {
1838 for (int j
= 0; j
< setVirtuals
.length
; j
++) {
1839 this.setVirtalAddList
.add(setVirtuals
[j
]);
1842 if (exitBoots
!= null) {
1843 for (int k
= 0; k
< exitBoots
.length
; k
++) {
1844 this.exitBootServiceList
.add(exitBoots
[k
]);
1848 // Add c code in autogen.c which relate to <SetVirtualAddressMapCallBack>
1849 // and <ExitBootServicesCallBack>
1851 String moduleType
= this.moduleId
.getModuleType();
1852 switch (CommonDefinition
.getModuleType(moduleType
)) {
1853 case CommonDefinition
.ModuleTypeDxeDriver
:
1854 case CommonDefinition
.ModuleTypeDxeRuntimeDriver
:
1855 case CommonDefinition
.ModuleTypeDxeSalDriver
:
1856 case CommonDefinition
.ModuleTypeUefiDriver
:
1857 case CommonDefinition
.ModuleTypeUefiApplication
:
1859 // If moduleType is one of above, call setVirtualAddressToAutogenC,
1860 // and setExitBootServiceToAutogenC.
1862 setVirtualAddressToAutogenC(fileBuffer
);
1863 setExitBootServiceToAutogenC(fileBuffer
);
1871 copyFlashMapHToDebugDir
1873 This function is to copy the falshmap.h to debug directory and change
1874 its name to TianoR8FlashMap.h
1879 private void copyFlashMapHToDebugDir() throws AutoGenException
{
1881 File inFile
= new File(fvDir
+ File
.separatorChar
+ CommonDefinition
.FLASHMAPH
);
1882 int size
= (int)inFile
.length();
1883 byte[] buffer
= new byte[size
];
1884 File outFile
= new File (this.outputPath
+ File
.separatorChar
+ CommonDefinition
.TIANOR8PLASHMAPH
);
1886 // If TianoR8FlashMap.h existed and the flashMap.h don't change,
1889 if ((!outFile
.exists()) ||(inFile
.lastModified() - outFile
.lastModified()) >= 0) {
1890 if (inFile
.exists()) {
1892 FileInputStream fis
= new FileInputStream (inFile
);
1894 FileOutputStream fos
= new FileOutputStream(outFile
);
1898 } catch (IOException e
){
1899 throw new AutoGenException("The file, flashMap.h can't be open!");
1903 throw new AutoGenException("The file, flashMap.h doesn't exist!");
1909 This function first order the library instances, then collect
1910 library instance 's PPI, Protocol, GUID,
1911 SetVirtalAddressMapCallBack, ExitBootServiceCallBack, and
1912 Destructor, Constructor.
1917 private void collectLibInstanceInfo() throws EdkException
{
1920 String libConstructName
= null;
1921 String libDestructName
= null;
1922 String libModuleType
= null;
1923 String
[] setVirtuals
= null;
1924 String
[] exitBoots
= null;
1926 ModuleIdentification
[] libraryIdList
= saq
.getLibraryInstance(this.arch
);
1928 if (libraryIdList
!= null) {
1930 // Reorder library instance sequence.
1932 AutogenLibOrder libOrder
= new AutogenLibOrder(libraryIdList
,
1934 List
<ModuleIdentification
> orderList
= libOrder
1935 .orderLibInstance();
1937 if (orderList
!= null) {
1939 // Process library instance one by one.
1941 for (int i
= 0; i
< orderList
.size(); i
++) {
1944 // Get library instance basename.
1946 ModuleIdentification libInstanceId
= orderList
.get(i
);
1952 Map
<String
, XmlObject
> libDoc
= GlobalData
.getDoc(libInstanceId
, this.arch
);
1955 // Get <PPis>, <Protocols>, <Guids> list of this library
1958 String
[] ppiList
= saq
.getPpiArray(this.arch
);
1959 String
[] ppiNotifyList
= saq
.getPpiNotifyArray(this.arch
);
1960 String
[] protocolList
= saq
.getProtocolArray(this.arch
);
1961 String
[] protocolNotifyList
= saq
.getProtocolNotifyArray(this.arch
);
1962 String
[] guidList
= saq
.getGuidEntryArray(this.arch
);
1963 PackageIdentification
[] pkgList
= saq
.getDependencePkg(this.arch
);
1966 // Add those ppi, protocol, guid in global ppi,
1970 for (index
= 0; index
< ppiList
.length
; index
++) {
1971 this.mPpiList
.add(ppiList
[index
]);
1974 for (index
= 0; index
< ppiNotifyList
.length
; index
++) {
1975 this.mPpiList
.add(ppiNotifyList
[index
]);
1978 for (index
= 0; index
< protocolList
.length
; index
++) {
1979 this.mProtocolList
.add(protocolList
[index
]);
1982 for (index
= 0; index
< protocolNotifyList
.length
; index
++) {
1983 this.mProtocolList
.add(protocolNotifyList
[index
]);
1986 for (index
= 0; index
< guidList
.length
; index
++) {
1987 this.mGuidList
.add(guidList
[index
]);
1989 for (index
= 0; index
< pkgList
.length
; index
++) {
1990 if (!this.mDepPkgList
.contains(pkgList
[index
])) {
1991 this.mDepPkgList
.add(pkgList
[index
]);
1996 // If not yet parse this library instance's constructor
1997 // element,parse it.
1999 libConstructName
= saq
.getLibConstructorName();
2000 libDestructName
= saq
.getLibDestructorName();
2001 libModuleType
= saq
.getModuleType();
2004 // Collect SetVirtualAddressMapCallBack and
2005 // ExitBootServiceCallBack.
2007 setVirtuals
= saq
.getSetVirtualAddressMapCallBackArray();
2008 exitBoots
= saq
.getExitBootServicesCallBackArray();
2009 if (setVirtuals
!= null) {
2010 for (int j
= 0; j
< setVirtuals
.length
; j
++) {
2011 this.setVirtalAddList
.add(setVirtuals
[j
]);
2014 if (exitBoots
!= null) {
2015 for (int k
= 0; k
< exitBoots
.length
; k
++) {
2016 this.exitBootServiceList
.add(exitBoots
[k
]);
2021 // Add dependent library instance constructor function.
2023 if (libConstructName
!= null) {
2024 this.libConstructList
.add(new String
[] {libConstructName
, libModuleType
});
2027 // Add dependent library instance destructor fuction.
2029 if (libDestructName
!= null) {
2030 this.libDestructList
.add(new String
[] {libDestructName
, libModuleType
});
2037 private void setVirtualAddressToAutogenC(StringBuffer fileBuffer
){
2039 // Entry point lib for these module types needs to know the count
2043 .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED const UINTN _gDriverSetVirtualAddressMapEventCount = ");
2046 // If the list is not valid or has no entries set count to zero else
2047 // set count to the number of valid entries
2051 if (this.setVirtalAddList
!= null) {
2052 for (i
= 0; i
< this.setVirtalAddList
.size(); i
++) {
2053 if (this.setVirtalAddList
.get(i
).equalsIgnoreCase("")) {
2060 fileBuffer
.append(Integer
.toString(Count
));
2061 fileBuffer
.append(";\r\n\r\n");
2062 if (this.setVirtalAddList
== null || this.setVirtalAddList
.size() == 0) {
2064 // No data so make a NULL list
2067 .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED const EFI_EVENT_NOTIFY _gDriverSetVirtualAddressMapEvent[] = {\r\n");
2068 fileBuffer
.append(" NULL\r\n");
2069 fileBuffer
.append("};\r\n\r\n");
2072 // Write SetVirtualAddressMap function definition.
2074 for (i
= 0; i
< this.setVirtalAddList
.size(); i
++) {
2075 if (this.setVirtalAddList
.get(i
).equalsIgnoreCase("")) {
2078 fileBuffer
.append("VOID\r\n");
2079 fileBuffer
.append("EFIAPI\r\n");
2080 fileBuffer
.append(this.setVirtalAddList
.get(i
));
2081 fileBuffer
.append(" (\r\n");
2082 fileBuffer
.append(" IN EFI_EVENT Event,\r\n");
2083 fileBuffer
.append(" IN VOID *Context\r\n");
2084 fileBuffer
.append(" );\r\n\r\n");
2088 // Write SetVirtualAddressMap entry point array.
2091 .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED const EFI_EVENT_NOTIFY _gDriverSetVirtualAddressMapEvent[] = {");
2092 for (i
= 0; i
< this.setVirtalAddList
.size(); i
++) {
2093 if (this.setVirtalAddList
.get(i
).equalsIgnoreCase("")) {
2098 fileBuffer
.append("\r\n ");
2100 fileBuffer
.append(",\r\n ");
2103 fileBuffer
.append(this.setVirtalAddList
.get(i
));
2106 // add the NULL at the end of _gDriverSetVirtualAddressMapEvent list.
2108 fileBuffer
.append(",\r\n NULL");
2109 fileBuffer
.append("\r\n};\r\n\r\n");
2114 private void setExitBootServiceToAutogenC(StringBuffer fileBuffer
){
2116 // Entry point lib for these module types needs to know the count.
2119 .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED const UINTN _gDriverExitBootServicesEventCount = ");
2122 // If the list is not valid or has no entries set count to zero else
2123 // set count to the number of valid entries.
2127 if (this.exitBootServiceList
!= null) {
2128 for (i
= 0; i
< this.exitBootServiceList
.size(); i
++) {
2129 if (this.exitBootServiceList
.get(i
).equalsIgnoreCase("")) {
2135 fileBuffer
.append(Integer
.toString(Count
));
2136 fileBuffer
.append(";\r\n\r\n");
2138 if (this.exitBootServiceList
== null || this.exitBootServiceList
.size() == 0) {
2140 // No data so make a NULL list.
2143 .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED const EFI_EVENT_NOTIFY _gDriverExitBootServicesEvent[] = {\r\n");
2144 fileBuffer
.append(" NULL\r\n");
2145 fileBuffer
.append("};\r\n\r\n");
2148 // Write DriverExitBootServices function definition.
2150 for (i
= 0; i
< this.exitBootServiceList
.size(); i
++) {
2151 if (this.exitBootServiceList
.get(i
).equalsIgnoreCase("")) {
2155 fileBuffer
.append("VOID\r\n");
2156 fileBuffer
.append("EFIAPI\r\n");
2157 fileBuffer
.append(this.exitBootServiceList
.get(i
));
2158 fileBuffer
.append(" (\r\n");
2159 fileBuffer
.append(" IN EFI_EVENT Event,\r\n");
2160 fileBuffer
.append(" IN VOID *Context\r\n");
2161 fileBuffer
.append(" );\r\n\r\n");
2165 // Write DriverExitBootServices entry point array.
2168 .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED const EFI_EVENT_NOTIFY _gDriverExitBootServicesEvent[] = {");
2169 for (i
= 0; i
< this.exitBootServiceList
.size(); i
++) {
2170 if (this.exitBootServiceList
.get(i
).equalsIgnoreCase("")) {
2175 fileBuffer
.append("\r\n ");
2177 fileBuffer
.append(",\r\n ");
2179 fileBuffer
.append(this.exitBootServiceList
.get(i
));
2182 fileBuffer
.append(",\r\n NULL");
2183 fileBuffer
.append("\r\n};\r\n\r\n");