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
{
218 // If outputPath do not exist, create it.
220 File path
= new File(outputPath
);
224 // Check current is library or not, then call the corresponding
227 if (this.moduleId
.isLibrary()) {
235 moduleGenAutogen function
237 This function generates AutoGen.c & AutoGen.h for module.
239 @throws BuildException
240 Faile to create module AutoGen.c & AutoGen.h.
242 void moduleGenAutogen() throws EdkException
{
243 collectLibInstanceInfo();
249 libGenAutogen function
251 This function generates AutoGen.c & AutoGen.h for library.
253 @throws BuildException
254 Faile to create library AutoGen.c & AutoGen.h
256 void libGenAutogen() throws EdkException
{
264 This function generates AutoGen.h for module.
266 @throws BuildException
267 Failed to generate AutoGen.h.
269 void moduleGenAutogenH() throws EdkException
{
271 Set
<String
> libClassIncludeH
;
273 // List<String> headerFileList;
274 List
<String
> headerFileList
;
276 StringBuffer fileBuffer
= new StringBuffer(8192);
279 // Write Autogen.h header notation
281 fileBuffer
.append(CommonDefinition
.AUTOGENHNOTATION
);
284 // Add #ifndef ${BaseName}_AUTOGENH
285 // #def ${BseeName}_AUTOGENH
287 fileBuffer
.append(CommonDefinition
.IFNDEF
288 + CommonDefinition
.AUTOGENH
289 + this.moduleId
.getGuid().replaceAll("-", "_")
290 + ToolDefinitions
.LINE_SEPARATOR
);
291 fileBuffer
.append(CommonDefinition
.DEFINE
292 + CommonDefinition
.AUTOGENH
293 + this.moduleId
.getGuid().replaceAll("-", "_")
294 + ToolDefinitions
.LINE_SEPARATOR
295 + ToolDefinitions
.LINE_SEPARATOR
);
298 // Write the specification version and release version at the begine
299 // of autogen.h file.
300 // Note: the specification version and release version should
301 // be got from module surface area instead of hard code by it's
304 moduleType
= saq
.getModuleType();
307 // Add "extern int __make_me_compile_correctly;" at begin of
310 fileBuffer
.append(CommonDefinition
.AUTOGENHBEGIN
);
313 // Put EFI_SPECIFICATION_VERSION, and EDK_RELEASE_VERSION.
315 String
[] specList
= saq
.getExternSpecificaiton();
316 for (int i
= 0; i
< specList
.length
; i
++) {
317 fileBuffer
.append(CommonDefinition
.DEFINE
+ specList
[i
]
321 // Write consumed package's mdouleInfo related .h file to autogen.h
323 // PackageIdentification[] consumedPkgIdList = SurfaceAreaQuery
324 // .getDependencePkg(this.arch);
325 PackageIdentification
[] consumedPkgIdList
= saq
.getDependencePkg(this.arch
);
326 if (consumedPkgIdList
!= null) {
327 headerFileList
= depPkgToAutogenH(consumedPkgIdList
, moduleType
);
328 item
= headerFileList
.iterator();
329 while (item
.hasNext()) {
330 fileBuffer
.append(item
.next().toString());
335 // Write library class's related *.h file to autogen.h.
337 String
[] libClassList
= saq
.getLibraryClasses(CommonDefinition
.ALWAYSCONSUMED
,this.arch
);
338 if (libClassList
!= null) {
339 libClassIncludeH
= LibraryClassToAutogenH(libClassList
);
340 item
= libClassIncludeH
.iterator();
341 while (item
.hasNext()) {
342 fileBuffer
.append(item
.next().toString());
346 libClassList
= saq
.getLibraryClasses(CommonDefinition
.ALWAYSPRODUCED
, this.arch
);
347 if (libClassList
!= null) {
348 libClassIncludeH
= LibraryClassToAutogenH(libClassList
);
349 item
= libClassIncludeH
.iterator();
350 while (item
.hasNext()) {
351 fileBuffer
.append(item
.next().toString());
354 fileBuffer
.append("\r\n");
357 // If is TianoR8FlashMap, copy {Fv_DIR}/FlashMap.h to
358 // {DEST_DIR_DRBUG}/FlashMap.h
360 if (saq
.isHaveTianoR8FlashMap()) {
361 fileBuffer
.append(CommonDefinition
.INCLUDE
);
362 fileBuffer
.append(" <");
363 fileBuffer
.append(CommonDefinition
.TIANOR8PLASHMAPH
+ ">\r\n");
364 copyFlashMapHToDebugDir();
367 // Write PCD autogen information to AutoGen.h.
369 if (this.myPcdAutogen
!= null) {
370 fileBuffer
.append("\r\n");
371 fileBuffer
.append(this.myPcdAutogen
.getHAutoGenString());
375 // Append the #endif at AutoGen.h
377 fileBuffer
.append("#endif\r\n");
380 // Save string buffer content in AutoGen.h.
382 if (!saveFile(outputPath
+ File
.separatorChar
+ "AutoGen.h", fileBuffer
)) {
383 throw new AutoGenException("Failed to generate AutoGen.h !!!");
390 This function generates AutoGen.c for module.
392 @throws BuildException
393 Failed to generate AutoGen.c.
395 void moduleGenAutogenC() throws EdkException
{
397 StringBuffer fileBuffer
= new StringBuffer(8192);
399 // Write Autogen.c header notation
401 fileBuffer
.append(CommonDefinition
.AUTOGENCNOTATION
);
404 // Write #include <AutoGen.h> at beginning of AutoGen.c
406 fileBuffer
.append(CommonDefinition
.INCLUDEAUTOGENH
);
409 // Get the native MSA file infomation. Since before call autogen,
410 // the MSA native <Externs> information were overrided. So before
411 // process <Externs> it should be set the DOC as the Native MSA info.
413 Map
<String
, XmlObject
> doc
= GlobalData
.getNativeMsa(this.moduleId
);
417 // DriverBinding/ComponentName/DriverConfiguration/DriverDialog
421 ExternsDriverBindingToAutoGenC(fileBuffer
);
424 // Write DriverExitBootServicesEvent/DriverSetVirtualAddressMapEvent
427 ExternCallBackToAutoGenC(fileBuffer
);
430 // Write EntryPoint to autgoGen.c
432 String
[] entryPointList
= saq
.getModuleEntryPointArray();
433 String
[] unloadImageList
= saq
.getModuleUnloadImageArray();
434 EntryPointToAutoGen(CommonDefinition
.remDupString(entryPointList
),
435 CommonDefinition
.remDupString(unloadImageList
),
438 pcdDriverType
= saq
.getPcdDriverType();
441 // Restore the DOC which include the FPD module info.
446 // Write Guid to autogen.c
448 String guid
= CommonDefinition
.formatGuidName(saq
.getModuleGuid());
449 if (this.moduleId
.getModuleType().equalsIgnoreCase(EdkDefinitions
.MODULE_TYPE_BASE
)) {
451 .append("GLOBAL_REMOVE_IF_UNREFERENCED GUID gEfiCallerIdGuid = {");
454 .append("GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiCallerIdGuid = {");
458 throw new AutoGenException("Guid value must set!\n");
462 // Formate Guid as ANSI c form.Example:
463 // {0xd2b2b828, 0x826, 0x48a7,{0xb3, 0xdf, 0x98, 0x3c, 0x0, 0x60, 0x24,
467 fileBuffer
.append(guid
);
468 fileBuffer
.append("};\r\n");
471 // Generate library instance consumed protocol, guid, ppi, pcd list.
472 // Save those to this.protocolList, this.ppiList, this.pcdList,
473 // this.guidList. Write Consumed library constructor and desconstuct to
476 LibInstanceToAutogenC(fileBuffer
);
479 // Get module dependent Package identification.
481 PackageIdentification
[] packages
= saq
.getDependencePkg(this.arch
);
482 for (int i
= 0; i
< packages
.length
; i
++) {
483 if (!this.mDepPkgList
.contains(packages
[i
])) {
484 this.mDepPkgList
.add(packages
[i
]);
490 // Write consumed ppi, guid, protocol to autogen.c
492 ProtocolGuidToAutogenC(fileBuffer
);
493 PpiGuidToAutogenC(fileBuffer
);
494 GuidGuidToAutogenC(fileBuffer
);
499 this.myPcdAutogen
= new PCDAutoGenAction(moduleId
,
506 this.myPcdAutogen
.execute();
507 if (this.myPcdAutogen
!= null) {
508 fileBuffer
.append("\r\n");
509 fileBuffer
.append(this.myPcdAutogen
.getCAutoGenString());
512 if (!saveFile(outputPath
+ File
.separatorChar
+ "AutoGen.c", fileBuffer
)) {
513 throw new AutoGenException("Failed to generate AutoGen.c !!!");
521 This function generates AutoGen.h for library.
523 @throws BuildException
524 Failed to generate AutoGen.c.
526 void libGenAutogenH() throws EdkException
{
528 Set
<String
> libClassIncludeH
;
530 List
<String
> headerFileList
;
532 StringBuffer fileBuffer
= new StringBuffer(10240);
535 // Write Autogen.h header notation
537 fileBuffer
.append(CommonDefinition
.AUTOGENHNOTATION
);
540 // Add #ifndef ${BaseName}_AUTOGENH
541 // #def ${BseeName}_AUTOGENH
543 fileBuffer
.append(CommonDefinition
.IFNDEF
544 + CommonDefinition
.AUTOGENH
545 + this.moduleId
.getGuid().replaceAll("-", "_")
546 + ToolDefinitions
.LINE_SEPARATOR
);
547 fileBuffer
.append(CommonDefinition
.DEFINE
548 + CommonDefinition
.AUTOGENH
549 + this.moduleId
.getGuid().replaceAll("-", "_")
550 + ToolDefinitions
.LINE_SEPARATOR
551 + ToolDefinitions
.LINE_SEPARATOR
);
554 // Write EFI_SPECIFICATION_VERSION and EDK_RELEASE_VERSION
555 // to autogen.h file.
556 // Note: the specification version and release version should
557 // be get from module surface area instead of hard code.
559 fileBuffer
.append(CommonDefinition
.AUTOGENHBEGIN
);
560 String
[] specList
= saq
.getExternSpecificaiton();
561 for (int i
= 0; i
< specList
.length
; i
++) {
562 fileBuffer
.append(CommonDefinition
.DEFINE
+ specList
[i
]
565 // fileBuffer.append(CommonDefinition.autoGenHLine1);
566 // fileBuffer.append(CommonDefinition.autoGenHLine2);
569 // Write consumed package's mdouleInfo related *.h file to autogen.h.
571 moduleType
= saq
.getModuleType();
572 PackageIdentification
[] cosumedPkglist
= saq
573 .getDependencePkg(this.arch
);
574 headerFileList
= depPkgToAutogenH(cosumedPkglist
, moduleType
);
575 item
= headerFileList
.iterator();
576 while (item
.hasNext()) {
577 fileBuffer
.append(item
.next().toString());
580 // Write library class's related *.h file to autogen.h
582 String
[] libClassList
= saq
583 .getLibraryClasses(CommonDefinition
.ALWAYSCONSUMED
, this.arch
);
584 if (libClassList
!= null) {
585 libClassIncludeH
= LibraryClassToAutogenH(libClassList
);
586 item
= libClassIncludeH
.iterator();
587 while (item
.hasNext()) {
588 fileBuffer
.append(item
.next().toString());
593 .getLibraryClasses(CommonDefinition
.ALWAYSPRODUCED
, this.arch
);
594 if (libClassList
!= null) {
595 libClassIncludeH
= LibraryClassToAutogenH(libClassList
);
596 item
= libClassIncludeH
.iterator();
597 while (item
.hasNext()) {
598 fileBuffer
.append(item
.next().toString());
601 fileBuffer
.append(ToolDefinitions
.LINE_SEPARATOR
);
604 // If is TianoR8FlashMap, copy {Fv_DIR}/FlashMap.h to
605 // {DEST_DIR_DRBUG}/FlashMap.h
607 if (saq
.isHaveTianoR8FlashMap()) {
608 fileBuffer
.append(CommonDefinition
.INCLUDE
);
609 fileBuffer
.append(" <");
610 fileBuffer
.append(CommonDefinition
.TIANOR8PLASHMAPH
+ ">\r\n");
611 copyFlashMapHToDebugDir();
615 // Write PCD information to library AutoGen.h.
617 if (this.myPcdAutogen
!= null) {
618 fileBuffer
.append("\r\n");
619 fileBuffer
.append(this.myPcdAutogen
.getHAutoGenString());
623 // Append the #endif at AutoGen.h
625 fileBuffer
.append("#endif\r\n");
628 // Save content of string buffer to AutoGen.h file.
630 if (!saveFile(outputPath
+ File
.separatorChar
+ "AutoGen.h", fileBuffer
)) {
631 throw new AutoGenException("Failed to generate AutoGen.h !!!");
638 This function generates AutoGen.h for library.
640 @throws BuildException
641 Failed to generate AutoGen.c.
643 void libGenAutogenC() throws EdkException
{
644 StringBuffer fileBuffer
= new StringBuffer(10240);
647 // Write Autogen.c header notation
649 fileBuffer
.append(CommonDefinition
.AUTOGENCNOTATION
);
651 fileBuffer
.append(ToolDefinitions
.LINE_SEPARATOR
);
652 fileBuffer
.append(ToolDefinitions
.LINE_SEPARATOR
);
657 this.myPcdAutogen
= new PCDAutoGenAction(moduleId
,
660 saq
.getModulePcdEntryNameArray(),
663 this.myPcdAutogen
.execute();
664 if (this.myPcdAutogen
!= null) {
665 fileBuffer
.append(ToolDefinitions
.LINE_SEPARATOR
);
666 fileBuffer
.append(this.myPcdAutogen
.getCAutoGenString());
669 if (!saveFile(outputPath
+ File
.separatorChar
+ "AutoGen.c", fileBuffer
)) {
670 throw new AutoGenException("Failed to generate AutoGen.c !!!");
675 LibraryClassToAutogenH
677 This function returns *.h files declared by library classes which are
678 consumed or produced by current build module or library.
681 List of library class which consumed or produce by current
682 build module or library.
683 @return includeStrList List of *.h file.
685 Set
<String
> LibraryClassToAutogenH(String
[] libClassList
)
686 throws EdkException
{
687 Set
<String
> includeStrList
= new LinkedHashSet
<String
>();
688 String includeName
[];
692 // Get include file from GlobalData's SPDTable according to
693 // library class name.
695 for (int i
= 0; i
< libClassList
.length
; i
++) {
696 includeName
= GlobalData
.getLibraryClassHeaderFiles(
697 saq
.getDependencePkg(this.arch
),
699 if (includeName
== null) {
700 throw new AutoGenException("Can not find library class ["
701 + libClassList
[i
] + "] declaration in any SPD package. ");
703 for (int j
= 0; j
< includeName
.length
; j
++) {
704 String includeNameStr
= includeName
[j
];
705 if (includeNameStr
!= null) {
706 str
= CommonDefinition
.INCLUDE
+ " " + "<";
707 str
= str
+ includeNameStr
+ ">\r\n";
708 includeStrList
.add(str
);
709 includeNameStr
= null;
713 return includeStrList
;
719 This function add include file in AutoGen.h file.
721 @param packageNameList
722 List of module depended package.
727 List
<String
> depPkgToAutogenH(PackageIdentification
[] packageNameList
,
728 String moduleType
) throws AutoGenException
{
730 List
<String
> includeStrList
= new LinkedList
<String
>();
732 String includeStr
= "";
735 // Get include file from moduleInfo file
737 for (int i
= 0; i
< packageNameList
.length
; i
++) {
738 pkgHeader
= GlobalData
.getPackageHeaderFiles(packageNameList
[i
],
740 if (pkgHeader
== null) {
741 throw new AutoGenException("Can not find package ["
743 + "] declaration in any SPD package. ");
744 } else if (!pkgHeader
.equalsIgnoreCase("")) {
745 includeStr
= CommonDefinition
.INCLUDE
+ " <" + pkgHeader
747 includeStrList
.add(includeStr
);
751 return includeStrList
;
757 This function convert <ModuleEntryPoint> & <ModuleUnloadImage>
758 information in mas to AutoGen.c
760 @param entryPointList
763 String buffer fo AutoGen.c.
766 void EntryPointToAutoGen(String
[] entryPointList
, String
[] unloadImageList
, StringBuffer fileBuffer
)
767 throws EdkException
{
769 String typeStr
= saq
.getModuleType();
770 int unloadImageCount
= 0;
771 int entryPointCount
= 0;
774 // The parameters and return value of entryPoint is difference
775 // for difference module type.
777 switch (CommonDefinition
.getModuleType(typeStr
)) {
779 case CommonDefinition
.ModuleTypePeiCore
:
780 if (entryPointList
== null ||entryPointList
.length
!= 1 ) {
781 throw new AutoGenException(
782 "Module type = 'PEI_CORE', can have only one module entry point!");
784 fileBuffer
.append("EFI_STATUS\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(entryPointList
[0]);
818 fileBuffer
.append(" (\n");
819 fileBuffer
.append(" IN VOID *HobStart\r\n");
820 fileBuffer
.append(" );\r\n\r\n");
822 fileBuffer
.append("VOID\r\n");
823 fileBuffer
.append("EFIAPI\r\n");
824 fileBuffer
.append("ProcessModuleEntryPointList (\r\n");
825 fileBuffer
.append(" IN VOID *HobStart\r\n");
826 fileBuffer
.append(" )\r\n\r\n");
827 fileBuffer
.append("{\r\n");
828 fileBuffer
.append(" ");
829 fileBuffer
.append(entryPointList
[0]);
830 fileBuffer
.append(" (HobStart);\r\n");
831 fileBuffer
.append("}\r\n\r\n");
835 case CommonDefinition
.ModuleTypePeim
:
838 .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT32 _gPeimRevision = 0;\r\n");
839 if (entryPointList
== null || entryPointList
.length
== 0) {
840 fileBuffer
.append("EFI_STATUS\r\n");
841 fileBuffer
.append("EFIAPI\r\n");
842 fileBuffer
.append("ProcessModuleEntryPointList (\r\n");
843 fileBuffer
.append(" IN EFI_FFS_FILE_HEADER *FfsHeader,\r\n");
844 fileBuffer
.append(" IN EFI_PEI_SERVICES **PeiServices\r\n");
845 fileBuffer
.append(" )\r\n\r\n");
846 fileBuffer
.append("{\r\n");
847 fileBuffer
.append(" return EFI_SUCCESS;\r\n");
848 fileBuffer
.append("}\r\n\r\n");
851 for (int i
= 0; i
< entryPointList
.length
; i
++) {
852 fileBuffer
.append("EFI_STATUS\r\n");
853 fileBuffer
.append(entryPointList
[i
]);
854 fileBuffer
.append(" (\r\n");
856 .append(" IN EFI_FFS_FILE_HEADER *FfsHeader,\r\n");
858 .append(" IN EFI_PEI_SERVICES **PeiServices\r\n");
859 fileBuffer
.append(" );\r\n");
864 fileBuffer
.append("EFI_STATUS\r\n");
865 fileBuffer
.append("EFIAPI\r\n");
866 fileBuffer
.append("ProcessModuleEntryPointList (\r\n");
867 fileBuffer
.append(" IN EFI_FFS_FILE_HEADER *FfsHeader,\r\n");
868 fileBuffer
.append(" IN EFI_PEI_SERVICES **PeiServices\r\n");
869 fileBuffer
.append(" )\r\n\r\n");
870 fileBuffer
.append("{\r\n");
871 if (entryPointCount
== 1) {
872 fileBuffer
.append(" return ");
873 fileBuffer
.append(entryPointList
[0]);
874 fileBuffer
.append(" (FfsHeader, PeiServices);\r\n");
876 fileBuffer
.append(" EFI_STATUS Status;\r\n");
877 fileBuffer
.append(" EFI_STATUS CombinedStatus;\r\n\r\n");
878 fileBuffer
.append(" CombinedStatus = EFI_LOAD_ERROR;\r\n\r\n");
879 for (int i
= 0; i
< entryPointList
.length
; i
++) {
880 if (!entryPointList
[i
].equals("")) {
881 fileBuffer
.append(" Status = ");
882 fileBuffer
.append(entryPointList
[i
]);
883 fileBuffer
.append(" (FfsHeader, PeiServices);\r\n");
885 .append(" if (!EFI_ERROR (Status) || EFI_ERROR (CombinedStatus)) {\r\n");
886 fileBuffer
.append(" CombinedStatus = Status;\r\n");
887 fileBuffer
.append(" }\r\n\r\n");
892 fileBuffer
.append(" return CombinedStatus;\r\n");
894 fileBuffer
.append("}\r\n\r\n");
897 case CommonDefinition
.ModuleTypeDxeSmmDriver
:
900 // If entryPoint is null, create an empty ProcessModuleEntryPointList
903 if (entryPointList
== null || entryPointList
.length
== 0) {
905 .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gDriverEntryPointCount = ");
906 fileBuffer
.append(Integer
.toString(entryPointCount
));
907 fileBuffer
.append(";\r\n");
908 fileBuffer
.append("EFI_STATUS\r\n");
909 fileBuffer
.append("EFIAPI\r\n");
910 fileBuffer
.append("ProcessModuleEntryPointList (\r\n");
911 fileBuffer
.append(" IN EFI_HANDLE ImageHandle,\r\n");
912 fileBuffer
.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");
913 fileBuffer
.append(" )\r\n\r\n");
914 fileBuffer
.append("{\r\n");
915 fileBuffer
.append(" return EFI_SUCCESS;\r\n");
916 fileBuffer
.append("}\r\n\r\n");
919 for (int i
= 0; i
< entryPointList
.length
; i
++) {
920 fileBuffer
.append("EFI_STATUS\r\n");
921 fileBuffer
.append(entryPointList
[i
]);
922 fileBuffer
.append(" (\r\n");
923 fileBuffer
.append(" IN EFI_HANDLE ImageHandle,\r\n");
924 fileBuffer
.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");
925 fileBuffer
.append(" );\r\n");
929 .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gDriverEntryPointCount = ");
930 fileBuffer
.append(Integer
.toString(entryPointCount
));
931 fileBuffer
.append(";\r\n");
933 .append("static BASE_LIBRARY_JUMP_BUFFER mJumpContext;\r\n");
935 .append("static EFI_STATUS mDriverEntryPointStatus = EFI_LOAD_ERROR;\r\n\r\n");
937 fileBuffer
.append("EFI_STATUS\r\n");
938 fileBuffer
.append("EFIAPI\r\n");
939 fileBuffer
.append("ProcessModuleEntryPointList (\r\n");
940 fileBuffer
.append(" IN EFI_HANDLE ImageHandle,\r\n");
941 fileBuffer
.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");
942 fileBuffer
.append(" )\r\n\r\n");
943 fileBuffer
.append("{\r\n");
946 for (int i
= 0; i
< entryPointList
.length
; i
++) {
948 .append(" if (SetJump (&mJumpContext) == 0) {\r\n");
949 fileBuffer
.append(" ExitDriver (");
950 fileBuffer
.append(entryPointList
[i
]);
951 fileBuffer
.append(" (ImageHandle, SystemTable));\r\n");
952 fileBuffer
.append(" ASSERT (FALSE);\r\n");
953 fileBuffer
.append(" }\r\n");
956 fileBuffer
.append(" return mDriverEntryPointStatus;\r\n");
957 fileBuffer
.append("}\r\n\r\n");
959 fileBuffer
.append("VOID\r\n");
960 fileBuffer
.append("EFIAPI\r\n");
961 fileBuffer
.append("ExitDriver (\r\n");
962 fileBuffer
.append(" IN EFI_STATUS Status\n");
963 fileBuffer
.append(" )\r\n\r\n");
964 fileBuffer
.append("{\r\n");
966 .append(" if (!EFI_ERROR (Status) || EFI_ERROR (mDriverEntryPointStatus)) {\r\n");
967 fileBuffer
.append(" mDriverEntryPointStatus = Status;\r\n");
968 fileBuffer
.append(" }\r\n");
969 fileBuffer
.append(" LongJump (&mJumpContext, (UINTN)-1);\r\n");
970 fileBuffer
.append(" ASSERT (FALSE);\r\n");
971 fileBuffer
.append("}\r\n\r\n");
977 // Add "ModuleUnloadImage" for DxeSmmDriver module type;
979 //entryPointList = SurfaceAreaQuery.getModuleUnloadImageArray();
980 //entryPointList = CommonDefinition.remDupString(entryPointList);
981 //entryPointCount = 0;
983 unloadImageCount
= 0;
984 if (unloadImageList
!= null) {
985 for (int i
= 0; i
< unloadImageList
.length
; i
++) {
986 fileBuffer
.append("EFI_STATUS\r\n");
987 fileBuffer
.append(unloadImageList
[i
]);
988 fileBuffer
.append(" (\r\n");
990 .append(" IN EFI_HANDLE ImageHandle\r\n");
991 fileBuffer
.append(" );\r\n");
997 .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gDriverUnloadImageCount = ");
998 fileBuffer
.append(Integer
.toString(unloadImageCount
));
999 fileBuffer
.append(";\r\n\r\n");
1001 fileBuffer
.append("EFI_STATUS\r\n");
1002 fileBuffer
.append("EFIAPI\r\n");
1003 fileBuffer
.append("ProcessModuleUnloadList (\r\n");
1004 fileBuffer
.append(" IN EFI_HANDLE ImageHandle\r\n");
1005 fileBuffer
.append(" )\r\n");
1006 fileBuffer
.append("{\r\n");
1008 if (unloadImageCount
== 0) {
1009 fileBuffer
.append(" return EFI_SUCCESS;\r\n");
1010 } else if (unloadImageCount
== 1) {
1011 fileBuffer
.append(" return ");
1012 fileBuffer
.append(unloadImageList
[0]);
1013 fileBuffer
.append("(ImageHandle);\r\n");
1015 fileBuffer
.append(" EFI_STATUS Status;\r\n\r\n");
1016 fileBuffer
.append(" Status = EFI_SUCCESS;\r\n\r\n");
1017 for (int i
= 0; i
< unloadImageList
.length
; i
++) {
1019 fileBuffer
.append(" Status = ");
1020 fileBuffer
.append(unloadImageList
[i
]);
1021 fileBuffer
.append("(ImageHandle);\r\n");
1023 fileBuffer
.append(" if (EFI_ERROR (Status)) {\r\n");
1024 fileBuffer
.append(" ");
1025 fileBuffer
.append(unloadImageList
[i
]);
1026 fileBuffer
.append("(ImageHandle);\r\n");
1027 fileBuffer
.append(" } else {\r\n");
1028 fileBuffer
.append(" Status = ");
1029 fileBuffer
.append(unloadImageList
[i
]);
1030 fileBuffer
.append("(ImageHandle);\r\n");
1031 fileBuffer
.append(" }\r\n");
1034 fileBuffer
.append(" return Status;\r\n");
1036 fileBuffer
.append("}\r\n\r\n");
1039 case CommonDefinition
.ModuleTypeDxeRuntimeDriver
:
1040 case CommonDefinition
.ModuleTypeDxeDriver
:
1041 case CommonDefinition
.ModuleTypeDxeSalDriver
:
1042 case CommonDefinition
.ModuleTypeUefiDriver
:
1043 case CommonDefinition
.ModuleTypeUefiApplication
:
1044 entryPointCount
= 0;
1045 fileBuffer
.append("const UINT32 _gUefiDriverRevision = 0;\r\n");
1047 // If entry point is null, create a empty ProcessModuleEntryPointList function.
1049 if (entryPointList
== null || entryPointList
.length
== 0) {
1051 .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gDriverEntryPointCount = 0;\r\n");
1052 fileBuffer
.append("EFI_STATUS\r\n");
1053 fileBuffer
.append("EFIAPI\r\n");
1054 fileBuffer
.append("ProcessModuleEntryPointList (\r\n");
1055 fileBuffer
.append(" IN EFI_HANDLE ImageHandle,\r\n");
1056 fileBuffer
.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");
1057 fileBuffer
.append(" )\r\n\r\n");
1058 fileBuffer
.append("{\r\n");
1059 fileBuffer
.append(" return EFI_SUCCESS;\r\n");
1060 fileBuffer
.append("}\r\n");
1063 for (int i
= 0; i
< entryPointList
.length
; i
++) {
1065 fileBuffer
.append("EFI_STATUS\r\n");
1066 fileBuffer
.append(entryPointList
[i
]);
1067 fileBuffer
.append(" (\r\n");
1068 fileBuffer
.append(" IN EFI_HANDLE ImageHandle,\r\n");
1069 fileBuffer
.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");
1070 fileBuffer
.append(" );\r\n");
1075 .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gDriverEntryPointCount = ");
1076 fileBuffer
.append(Integer
.toString(entryPointCount
));
1077 fileBuffer
.append(";\r\n");
1078 if (entryPointCount
> 1) {
1080 .append("static BASE_LIBRARY_JUMP_BUFFER mJumpContext;\r\n");
1082 .append("static EFI_STATUS mDriverEntryPointStatus = EFI_LOAD_ERROR;\r\n");
1084 fileBuffer
.append("\n");
1086 fileBuffer
.append("EFI_STATUS\r\n");
1087 fileBuffer
.append("EFIAPI\r\n");
1088 fileBuffer
.append("ProcessModuleEntryPointList (\r\n");
1089 fileBuffer
.append(" IN EFI_HANDLE ImageHandle,\r\n");
1090 fileBuffer
.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");
1091 fileBuffer
.append(" )\r\n\r\n");
1092 fileBuffer
.append("{\r\n");
1094 if (entryPointCount
== 1) {
1095 fileBuffer
.append(" return (");
1096 fileBuffer
.append(entryPointList
[0]);
1097 fileBuffer
.append(" (ImageHandle, SystemTable));\r\n");
1099 for (int i
= 0; i
< entryPointList
.length
; i
++) {
1100 if (!entryPointList
[i
].equals("")) {
1102 .append(" if (SetJump (&mJumpContext) == 0) {\r\n");
1103 fileBuffer
.append(" ExitDriver (");
1104 fileBuffer
.append(entryPointList
[i
]);
1105 fileBuffer
.append(" (ImageHandle, SystemTable));\r\n");
1106 fileBuffer
.append(" ASSERT (FALSE);\r\n");
1107 fileBuffer
.append(" }\r\n");
1112 fileBuffer
.append(" return mDriverEntryPointStatus;\r\n");
1114 fileBuffer
.append("}\r\n\r\n");
1116 fileBuffer
.append("VOID\r\n");
1117 fileBuffer
.append("EFIAPI\r\n");
1118 fileBuffer
.append("ExitDriver (\r\n");
1119 fileBuffer
.append(" IN EFI_STATUS Status\r\n");
1120 fileBuffer
.append(" )\r\n\r\n");
1121 fileBuffer
.append("{\r\n");
1122 if (entryPointCount
<= 1) {
1123 fileBuffer
.append(" if (EFI_ERROR (Status)) {\r\n");
1125 .append(" ProcessLibraryDestructorList (gImageHandle, gST);\r\n");
1126 fileBuffer
.append(" }\r\n");
1128 .append(" gBS->Exit (gImageHandle, Status, 0, NULL);\r\n");
1131 .append(" if (!EFI_ERROR (Status) || EFI_ERROR (mDriverEntryPointStatus)) {\r\n");
1132 fileBuffer
.append(" mDriverEntryPointStatus = Status;\r\n");
1133 fileBuffer
.append(" }\r\n");
1134 fileBuffer
.append(" LongJump (&mJumpContext, (UINTN)-1);\r\n");
1135 fileBuffer
.append(" ASSERT (FALSE);\r\n");
1137 fileBuffer
.append("}\r\n\r\n");
1142 // Add ModuleUnloadImage for DxeDriver and UefiDriver module type.
1144 //entryPointList = SurfaceAreaQuery.getModuleUnloadImageArray();
1146 // Remover duplicate unload entry point.
1148 //entryPointList = CommonDefinition.remDupString(entryPointList);
1149 //entryPointCount = 0;
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 if (libInstanceList
.get(i
)[1].equalsIgnoreCase(EdkDefinitions
.MODULE_TYPE_BASE
)) {
1412 fileBuffer
.append("RETURN_STATUS\r\n");
1413 fileBuffer
.append("EFIAPI\r\n");
1414 fileBuffer
.append(libInstanceList
.get(i
)[0]);
1415 fileBuffer
.append(" (\r\n");
1416 fileBuffer
.append(" VOID\r\n");
1417 fileBuffer
.append(" );\r\n");
1419 switch (CommonDefinition
.getModuleType(moduleType
)) {
1420 case CommonDefinition
.ModuleTypeBase
:
1421 fileBuffer
.append("RETURN_STATUS\r\n");
1422 fileBuffer
.append("EFIAPI\r\n");
1423 fileBuffer
.append(libInstanceList
.get(i
)[0]);
1424 fileBuffer
.append(" (\r\n");
1425 fileBuffer
.append(" VOID\r\n");
1426 fileBuffer
.append(" );\r\n");
1429 case CommonDefinition
.ModuleTypePeiCore
:
1430 case CommonDefinition
.ModuleTypePeim
:
1431 fileBuffer
.append("EFI_STATUS\r\n");
1432 fileBuffer
.append("EFIAPI\r\n");
1433 fileBuffer
.append(libInstanceList
.get(i
)[0]);
1434 fileBuffer
.append(" (\r\n");
1436 .append(" IN EFI_FFS_FILE_HEADER *FfsHeader,\r\n");
1438 .append(" IN EFI_PEI_SERVICES **PeiServices\r\n");
1439 fileBuffer
.append(" );\r\n");
1442 case CommonDefinition
.ModuleTypeDxeCore
:
1443 case CommonDefinition
.ModuleTypeDxeDriver
:
1444 case CommonDefinition
.ModuleTypeDxeRuntimeDriver
:
1445 case CommonDefinition
.ModuleTypeDxeSmmDriver
:
1446 case CommonDefinition
.ModuleTypeDxeSalDriver
:
1447 case CommonDefinition
.ModuleTypeUefiDriver
:
1448 case CommonDefinition
.ModuleTypeUefiApplication
:
1449 fileBuffer
.append("EFI_STATUS\r\n");
1450 fileBuffer
.append("EFIAPI\r\n");
1451 fileBuffer
.append(libInstanceList
.get(i
)[0]);
1452 fileBuffer
.append(" (\r\n");
1453 fileBuffer
.append(" IN EFI_HANDLE ImageHandle,\r\n");
1454 fileBuffer
.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");
1455 fileBuffer
.append(" );\r\n");
1463 // Add ProcessLibraryConstructorList in AutoGen.c
1465 fileBuffer
.append("VOID\r\n");
1466 fileBuffer
.append("EFIAPI\r\n");
1467 fileBuffer
.append("ProcessLibraryConstructorList (\r\n");
1468 switch (CommonDefinition
.getModuleType(moduleType
)) {
1469 case CommonDefinition
.ModuleTypeBase
:
1470 fileBuffer
.append(" VOID\r\n");
1473 case CommonDefinition
.ModuleTypePeiCore
:
1474 case CommonDefinition
.ModuleTypePeim
:
1475 fileBuffer
.append(" IN EFI_FFS_FILE_HEADER *FfsHeader,\r\n");
1477 .append(" IN EFI_PEI_SERVICES **PeiServices\r\n");
1480 case CommonDefinition
.ModuleTypeDxeCore
:
1481 case CommonDefinition
.ModuleTypeDxeDriver
:
1482 case CommonDefinition
.ModuleTypeDxeRuntimeDriver
:
1483 case CommonDefinition
.ModuleTypeDxeSmmDriver
:
1484 case CommonDefinition
.ModuleTypeDxeSalDriver
:
1485 case CommonDefinition
.ModuleTypeUefiDriver
:
1486 case CommonDefinition
.ModuleTypeUefiApplication
:
1487 fileBuffer
.append(" IN EFI_HANDLE ImageHandle,\r\n");
1488 fileBuffer
.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");
1492 fileBuffer
.append(" )\r\n");
1493 fileBuffer
.append("{\r\n");
1495 // If no constructor function, return EFI_SUCCESS.
1497 //if (libInstanceList.size() == 0){
1498 // fileBuffer.append(" return EFI_SUCCESS;\r\n");
1500 for (int i
= 0; i
< libInstanceList
.size(); i
++) {
1502 fileBuffer
.append(" EFI_STATUS Status;\r\n");
1503 fileBuffer
.append(" Status = EFI_SUCCESS;\r\n");
1504 fileBuffer
.append("\r\n");
1507 if (libInstanceList
.get(i
)[1].equalsIgnoreCase(EdkDefinitions
.MODULE_TYPE_BASE
)) {
1508 fileBuffer
.append(" Status = ");
1509 fileBuffer
.append(libInstanceList
.get(i
)[0]);
1510 fileBuffer
.append("();\r\n");
1512 switch (CommonDefinition
.getModuleType(moduleType
)) {
1513 case CommonDefinition
.ModuleTypeBase
:
1514 fileBuffer
.append(" Status = ");
1515 fileBuffer
.append(libInstanceList
.get(i
)[0]);
1516 fileBuffer
.append("();\r\n");
1518 case CommonDefinition
.ModuleTypePeiCore
:
1519 case CommonDefinition
.ModuleTypePeim
:
1520 fileBuffer
.append(" Status = ");
1521 fileBuffer
.append(libInstanceList
.get(i
)[0]);
1522 fileBuffer
.append(" (FfsHeader, PeiServices);\r\n");
1524 case CommonDefinition
.ModuleTypeDxeCore
:
1525 case CommonDefinition
.ModuleTypeDxeDriver
:
1526 case CommonDefinition
.ModuleTypeDxeRuntimeDriver
:
1527 case CommonDefinition
.ModuleTypeDxeSmmDriver
:
1528 case CommonDefinition
.ModuleTypeDxeSalDriver
:
1529 case CommonDefinition
.ModuleTypeUefiDriver
:
1530 case CommonDefinition
.ModuleTypeUefiApplication
:
1531 fileBuffer
.append(" Status = ");
1532 fileBuffer
.append(libInstanceList
.get(i
)[0]);
1533 fileBuffer
.append(" (ImageHandle, SystemTable);\r\n");
1536 EdkLog
.log(EdkLog
.EDK_INFO
,"Autogen doesn't know how to deal with module type - " + moduleType
+ "!");
1540 fileBuffer
.append(" ASSERT_EFI_ERROR (Status);\r\n");
1542 fileBuffer
.append("}\r\n");
1546 LibDestructorToAutogenc
1548 This function writes library destructor list to AutoGen.c. The library
1549 destructor's parameter and return value depend on module type.
1551 @param libInstanceList
1552 List of library destructor name.
1556 String buffer for AutoGen.c
1559 void LibDestructorToAutogenC(List
<String
[]> libInstanceList
,
1560 String moduleType
, StringBuffer fileBuffer
) throws EdkException
{
1561 boolean isFirst
= true;
1562 for (int i
= 0; i
< libInstanceList
.size(); i
++) {
1563 if (libInstanceList
.get(i
)[1].equalsIgnoreCase(EdkDefinitions
.MODULE_TYPE_BASE
)) {
1564 fileBuffer
.append("RETURN_STATUS\r\n");
1565 fileBuffer
.append("EFIAPI\r\n");
1566 fileBuffer
.append(libInstanceList
.get(i
)[0]);
1567 fileBuffer
.append(" (\r\n");
1568 fileBuffer
.append(" VOID\r\n");
1569 fileBuffer
.append(" );\r\n");
1571 switch (CommonDefinition
.getModuleType(moduleType
)) {
1572 case CommonDefinition
.ModuleTypeBase
:
1573 fileBuffer
.append("RETURN_STATUS\r\n");
1574 fileBuffer
.append("EFIAPI\r\n");
1575 fileBuffer
.append(libInstanceList
.get(i
)[0]);
1576 fileBuffer
.append(" (\r\n");
1577 fileBuffer
.append(" VOID\r\n");
1578 fileBuffer
.append(" );\r\n");
1580 case CommonDefinition
.ModuleTypePeiCore
:
1581 case CommonDefinition
.ModuleTypePeim
:
1582 fileBuffer
.append("EFI_STATUS\r\n");
1583 fileBuffer
.append("EFIAPI\r\n");
1584 fileBuffer
.append(libInstanceList
.get(i
)[0]);
1585 fileBuffer
.append(" (\r\n");
1587 .append(" IN EFI_FFS_FILE_HEADER *FfsHeader,\r\n");
1589 .append(" IN EFI_PEI_SERVICES **PeiServices\r\n");
1590 fileBuffer
.append(" );\r\n");
1592 case CommonDefinition
.ModuleTypeDxeCore
:
1593 case CommonDefinition
.ModuleTypeDxeDriver
:
1594 case CommonDefinition
.ModuleTypeDxeRuntimeDriver
:
1595 case CommonDefinition
.ModuleTypeDxeSmmDriver
:
1596 case CommonDefinition
.ModuleTypeDxeSalDriver
:
1597 case CommonDefinition
.ModuleTypeUefiDriver
:
1598 case CommonDefinition
.ModuleTypeUefiApplication
:
1599 fileBuffer
.append("EFI_STATUS\r\n");
1600 fileBuffer
.append("EFIAPI\r\n");
1601 fileBuffer
.append(libInstanceList
.get(i
)[0]);
1602 fileBuffer
.append(" (\r\n");
1603 fileBuffer
.append(" IN EFI_HANDLE ImageHandle,\r\n");
1604 fileBuffer
.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");
1605 fileBuffer
.append(" );\r\n");
1612 // Write ProcessLibraryDestructor list to autogen.c
1614 switch (CommonDefinition
.getModuleType(moduleType
)) {
1615 case CommonDefinition
.ModuleTypeBase
:
1616 case CommonDefinition
.ModuleTypePeiCore
:
1617 case CommonDefinition
.ModuleTypePeim
:
1619 case CommonDefinition
.ModuleTypeDxeCore
:
1620 case CommonDefinition
.ModuleTypeDxeDriver
:
1621 case CommonDefinition
.ModuleTypeDxeRuntimeDriver
:
1622 case CommonDefinition
.ModuleTypeDxeSmmDriver
:
1623 case CommonDefinition
.ModuleTypeDxeSalDriver
:
1624 case CommonDefinition
.ModuleTypeUefiDriver
:
1625 case CommonDefinition
.ModuleTypeUefiApplication
:
1626 fileBuffer
.append("VOID\r\n");
1627 fileBuffer
.append("EFIAPI\r\n");
1628 fileBuffer
.append("ProcessLibraryDestructorList (\r\n");
1629 fileBuffer
.append(" IN EFI_HANDLE ImageHandle,\r\n");
1630 fileBuffer
.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");
1631 fileBuffer
.append(" )\r\n");
1632 fileBuffer
.append("{\r\n");
1634 // If no library destructor function, return EFI_SUCCESS.
1637 for (int i
= 0; i
< libInstanceList
.size(); i
++) {
1639 fileBuffer
.append(" EFI_STATUS Status;\r\n");
1640 fileBuffer
.append(" Status = EFI_SUCCESS;\r\n");
1641 fileBuffer
.append("\r\n");
1644 if (libInstanceList
.get(i
)[1].equalsIgnoreCase(EdkDefinitions
.MODULE_TYPE_BASE
)) {
1645 fileBuffer
.append(" Status = ");
1646 fileBuffer
.append(libInstanceList
.get(i
)[0]);
1647 fileBuffer
.append("();\r\n");
1648 fileBuffer
.append(" VOID\r\n");
1650 fileBuffer
.append(" Status = ");
1651 fileBuffer
.append(libInstanceList
.get(i
)[0]);
1652 fileBuffer
.append("(ImageHandle, SystemTable);\r\n");
1653 fileBuffer
.append(" ASSERT_EFI_ERROR (Status);\r\n");
1656 fileBuffer
.append("}\r\n");
1662 ExternsDriverBindingToAutoGenC
1664 This function is to write DRIVER_BINDING, COMPONENT_NAME,
1665 DRIVER_CONFIGURATION, DRIVER_DIAGNOSTIC in AutoGen.c.
1668 String buffer for AutoGen.c
1670 void ExternsDriverBindingToAutoGenC(StringBuffer fileBuffer
)
1671 throws EdkException
{
1674 // Get the arry of extern. The driverBindingGroup is a 2 dimension array.
1675 // The second dimension is include following element: DriverBinding,
1676 // ComponentName, DriverConfiguration, DriverDiag;
1678 String
[][] driverBindingGroup
= this.saq
.getExternProtocolGroup();
1686 // Write driver binding protocol extern to autogen.c
1688 for (int i
= 0; i
< driverBindingGroup
.length
; i
++) {
1689 if (driverBindingGroup
[i
][0] != null) {
1690 fileBuffer
.append("extern EFI_DRIVER_BINDING_PROTOCOL ");
1691 fileBuffer
.append(driverBindingGroup
[i
][0]);
1692 fileBuffer
.append(";\r\n");
1697 // Write component name protocol extern to autogen.c
1699 for (int i
= 0; i
< driverBindingGroup
.length
; i
++) {
1700 if (driverBindingGroup
[i
][1]!= null) {
1701 if (driverBindingGroup
[i
][0] != null) {
1703 fileBuffer
.append("extern EFI_COMPONENT_NAME_PROTOCOL ");
1704 fileBuffer
.append(driverBindingGroup
[i
][1]);
1705 fileBuffer
.append(";\r\n");
1707 throw new AutoGenException("DriverBinding can't be empty!!");
1713 // Write driver configration protocol extern to autogen.c
1715 for (int i
= 0; i
< driverBindingGroup
.length
; i
++) {
1716 if (driverBindingGroup
[i
][2] != null) {
1717 if (driverBindingGroup
[i
][0] != null) {
1719 fileBuffer
.append("extern EFI_DRIVER_CONFIGURATION_PROTOCOL ");
1720 fileBuffer
.append(driverBindingGroup
[i
][2]);
1721 fileBuffer
.append(";\r\n");
1723 throw new AutoGenException("DriverBinding can't be empty!!");
1729 // Write driver dignastic protocol extern to autogen.c
1731 for (int i
= 0; i
< driverBindingGroup
.length
; i
++) {
1732 if (driverBindingGroup
[i
][3] != null) {
1733 if (driverBindingGroup
[i
][0] != null) {
1735 fileBuffer
.append("extern EFI_DRIVER_DIAGNOSTICS_PROTOCOL ");
1736 fileBuffer
.append(driverBindingGroup
[i
][3]);
1737 fileBuffer
.append(";\r\n");
1739 throw new AutoGenException("DriverBinding can't be empty!!");
1745 // Write driver module protocol bitmask.
1748 .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gDriverModelProtocolBitmask = ");
1749 fileBuffer
.append(Integer
.toString(BitMask
));
1750 fileBuffer
.append(";\r\n");
1753 // Write driver module protocol list entry
1756 .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINTN _gDriverModelProtocolListEntries = ");
1758 fileBuffer
.append(Integer
.toString(driverBindingGroup
.length
));
1759 fileBuffer
.append(";\r\n");
1762 // Write drive module protocol list to autogen.c
1764 if (driverBindingGroup
.length
> 0) {
1766 .append("GLOBAL_REMOVE_IF_UNREFERENCED const EFI_DRIVER_MODEL_PROTOCOL_LIST _gDriverModelProtocolList[] = {");
1770 for (int i
= 0; i
< driverBindingGroup
.length
; i
++) {
1772 fileBuffer
.append(",");
1775 fileBuffer
.append("\r\n {\r\n");
1776 fileBuffer
.append(" &");
1777 fileBuffer
.append(driverBindingGroup
[i
][0]);
1778 fileBuffer
.append(", \r\n");
1781 if (driverBindingGroup
[i
][1] != null) {
1782 fileBuffer
.append(" &");
1783 fileBuffer
.append(driverBindingGroup
[i
][1]);
1784 fileBuffer
.append(", \r\n");
1786 fileBuffer
.append(" NULL, \r\n");
1789 if (driverBindingGroup
[i
][2] != null) {
1790 fileBuffer
.append(" &");
1791 fileBuffer
.append(driverBindingGroup
[i
][2]);
1792 fileBuffer
.append(", \r\n");
1794 fileBuffer
.append(" NULL, \r\n");
1797 if (driverBindingGroup
[i
][3] != null) {
1798 fileBuffer
.append(" &");
1799 fileBuffer
.append(driverBindingGroup
[i
][3]);
1800 fileBuffer
.append(", \r\n");
1802 fileBuffer
.append(" NULL, \r\n");
1804 fileBuffer
.append(" }");
1807 if (driverBindingGroup
.length
> 0) {
1808 fileBuffer
.append("\r\n};\r\n");
1813 ExternCallBackToAutoGenC
1815 This function adds <SetVirtualAddressMapCallBack> and
1816 <ExitBootServicesCallBack> infomation to AutoGen.c
1819 String buffer for AutoGen.c
1820 @throws BuildException
1822 void ExternCallBackToAutoGenC(StringBuffer fileBuffer
)
1823 throws EdkException
{
1825 // Collect module's <SetVirtualAddressMapCallBack> and
1826 // <ExitBootServiceCallBack> and add to setVirtualAddList
1827 // exitBootServiceList.
1829 String
[] setVirtuals
= saq
.getSetVirtualAddressMapCallBackArray();
1830 String
[] exitBoots
= saq
.getExitBootServicesCallBackArray();
1831 if (setVirtuals
!= null) {
1832 for (int j
= 0; j
< setVirtuals
.length
; j
++) {
1833 this.setVirtalAddList
.add(setVirtuals
[j
]);
1836 if (exitBoots
!= null) {
1837 for (int k
= 0; k
< exitBoots
.length
; k
++) {
1838 this.exitBootServiceList
.add(exitBoots
[k
]);
1842 // Add c code in autogen.c which relate to <SetVirtualAddressMapCallBack>
1843 // and <ExitBootServicesCallBack>
1845 String moduleType
= this.moduleId
.getModuleType();
1846 switch (CommonDefinition
.getModuleType(moduleType
)) {
1847 case CommonDefinition
.ModuleTypeDxeDriver
:
1848 case CommonDefinition
.ModuleTypeDxeRuntimeDriver
:
1849 case CommonDefinition
.ModuleTypeDxeSalDriver
:
1850 case CommonDefinition
.ModuleTypeUefiDriver
:
1851 case CommonDefinition
.ModuleTypeUefiApplication
:
1853 // If moduleType is one of above, call setVirtualAddressToAutogenC,
1854 // and setExitBootServiceToAutogenC.
1856 setVirtualAddressToAutogenC(fileBuffer
);
1857 setExitBootServiceToAutogenC(fileBuffer
);
1865 copyFlashMapHToDebugDir
1867 This function is to copy the falshmap.h to debug directory and change
1868 its name to TianoR8FlashMap.h
1873 private void copyFlashMapHToDebugDir() throws AutoGenException
{
1875 File inFile
= new File(fvDir
+ File
.separatorChar
+ CommonDefinition
.FLASHMAPH
);
1876 int size
= (int)inFile
.length();
1877 byte[] buffer
= new byte[size
];
1878 File outFile
= new File (this.outputPath
+ File
.separatorChar
+ CommonDefinition
.TIANOR8PLASHMAPH
);
1880 // If TianoR8FlashMap.h existed and the flashMap.h don't change,
1883 if ((!outFile
.exists()) ||(inFile
.lastModified() - outFile
.lastModified()) >= 0) {
1884 if (inFile
.exists()) {
1886 FileInputStream fis
= new FileInputStream (inFile
);
1888 FileOutputStream fos
= new FileOutputStream(outFile
);
1892 } catch (IOException e
){
1893 throw new AutoGenException("The file, flashMap.h can't be open!");
1897 throw new AutoGenException("The file, flashMap.h doesn't exist!");
1903 This function first order the library instances, then collect
1904 library instance 's PPI, Protocol, GUID,
1905 SetVirtalAddressMapCallBack, ExitBootServiceCallBack, and
1906 Destructor, Constructor.
1911 private void collectLibInstanceInfo() throws EdkException
{
1914 String libConstructName
= null;
1915 String libDestructName
= null;
1916 String libModuleType
= null;
1917 String
[] setVirtuals
= null;
1918 String
[] exitBoots
= null;
1920 ModuleIdentification
[] libraryIdList
= saq
.getLibraryInstance(this.arch
);
1922 if (libraryIdList
!= null) {
1924 // Reorder library instance sequence.
1926 AutogenLibOrder libOrder
= new AutogenLibOrder(libraryIdList
,
1928 List
<ModuleIdentification
> orderList
= libOrder
1929 .orderLibInstance();
1931 if (orderList
!= null) {
1933 // Process library instance one by one.
1935 for (int i
= 0; i
< orderList
.size(); i
++) {
1938 // Get library instance basename.
1940 ModuleIdentification libInstanceId
= orderList
.get(i
);
1946 Map
<String
, XmlObject
> libDoc
= GlobalData
.getDoc(libInstanceId
, this.arch
);
1949 // Get <PPis>, <Protocols>, <Guids> list of this library
1952 String
[] ppiList
= saq
.getPpiArray(this.arch
);
1953 String
[] ppiNotifyList
= saq
.getPpiNotifyArray(this.arch
);
1954 String
[] protocolList
= saq
.getProtocolArray(this.arch
);
1955 String
[] protocolNotifyList
= saq
.getProtocolNotifyArray(this.arch
);
1956 String
[] guidList
= saq
.getGuidEntryArray(this.arch
);
1957 PackageIdentification
[] pkgList
= saq
.getDependencePkg(this.arch
);
1960 // Add those ppi, protocol, guid in global ppi,
1964 for (index
= 0; index
< ppiList
.length
; index
++) {
1965 this.mPpiList
.add(ppiList
[index
]);
1968 for (index
= 0; index
< ppiNotifyList
.length
; index
++) {
1969 this.mPpiList
.add(ppiNotifyList
[index
]);
1972 for (index
= 0; index
< protocolList
.length
; index
++) {
1973 this.mProtocolList
.add(protocolList
[index
]);
1976 for (index
= 0; index
< protocolNotifyList
.length
; index
++) {
1977 this.mProtocolList
.add(protocolNotifyList
[index
]);
1980 for (index
= 0; index
< guidList
.length
; index
++) {
1981 this.mGuidList
.add(guidList
[index
]);
1983 for (index
= 0; index
< pkgList
.length
; index
++) {
1984 if (!this.mDepPkgList
.contains(pkgList
[index
])) {
1985 this.mDepPkgList
.add(pkgList
[index
]);
1990 // If not yet parse this library instance's constructor
1991 // element,parse it.
1993 libConstructName
= saq
.getLibConstructorName();
1994 libDestructName
= saq
.getLibDestructorName();
1995 libModuleType
= saq
.getModuleType();
1998 // Collect SetVirtualAddressMapCallBack and
1999 // ExitBootServiceCallBack.
2001 setVirtuals
= saq
.getSetVirtualAddressMapCallBackArray();
2002 exitBoots
= saq
.getExitBootServicesCallBackArray();
2003 if (setVirtuals
!= null) {
2004 for (int j
= 0; j
< setVirtuals
.length
; j
++) {
2005 this.setVirtalAddList
.add(setVirtuals
[j
]);
2008 if (exitBoots
!= null) {
2009 for (int k
= 0; k
< exitBoots
.length
; k
++) {
2010 this.exitBootServiceList
.add(exitBoots
[k
]);
2015 // Add dependent library instance constructor function.
2017 if (libConstructName
!= null) {
2018 this.libConstructList
.add(new String
[] {libConstructName
, libModuleType
});
2021 // Add dependent library instance destructor fuction.
2023 if (libDestructName
!= null) {
2024 this.libDestructList
.add(new String
[] {libDestructName
, libModuleType
});
2031 private void setVirtualAddressToAutogenC(StringBuffer fileBuffer
){
2033 // Entry point lib for these module types needs to know the count
2037 .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED const UINTN _gDriverSetVirtualAddressMapEventCount = ");
2040 // If the list is not valid or has no entries set count to zero else
2041 // set count to the number of valid entries
2045 if (this.setVirtalAddList
!= null) {
2046 for (i
= 0; i
< this.setVirtalAddList
.size(); i
++) {
2047 if (this.setVirtalAddList
.get(i
).equalsIgnoreCase("")) {
2054 fileBuffer
.append(Integer
.toString(Count
));
2055 fileBuffer
.append(";\r\n\r\n");
2056 if (this.setVirtalAddList
== null || this.setVirtalAddList
.size() == 0) {
2058 // No data so make a NULL list
2061 .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED const EFI_EVENT_NOTIFY _gDriverSetVirtualAddressMapEvent[] = {\r\n");
2062 fileBuffer
.append(" NULL\r\n");
2063 fileBuffer
.append("};\r\n\r\n");
2066 // Write SetVirtualAddressMap function definition.
2068 for (i
= 0; i
< this.setVirtalAddList
.size(); i
++) {
2069 if (this.setVirtalAddList
.get(i
).equalsIgnoreCase("")) {
2072 fileBuffer
.append("VOID\r\n");
2073 fileBuffer
.append("EFIAPI\r\n");
2074 fileBuffer
.append(this.setVirtalAddList
.get(i
));
2075 fileBuffer
.append(" (\r\n");
2076 fileBuffer
.append(" IN EFI_EVENT Event,\r\n");
2077 fileBuffer
.append(" IN VOID *Context\r\n");
2078 fileBuffer
.append(" );\r\n\r\n");
2082 // Write SetVirtualAddressMap entry point array.
2085 .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED const EFI_EVENT_NOTIFY _gDriverSetVirtualAddressMapEvent[] = {");
2086 for (i
= 0; i
< this.setVirtalAddList
.size(); i
++) {
2087 if (this.setVirtalAddList
.get(i
).equalsIgnoreCase("")) {
2092 fileBuffer
.append("\r\n ");
2094 fileBuffer
.append(",\r\n ");
2097 fileBuffer
.append(this.setVirtalAddList
.get(i
));
2100 // add the NULL at the end of _gDriverSetVirtualAddressMapEvent list.
2102 fileBuffer
.append(",\r\n NULL");
2103 fileBuffer
.append("\r\n};\r\n\r\n");
2108 private void setExitBootServiceToAutogenC(StringBuffer fileBuffer
){
2110 // Entry point lib for these module types needs to know the count.
2113 .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED const UINTN _gDriverExitBootServicesEventCount = ");
2116 // If the list is not valid or has no entries set count to zero else
2117 // set count to the number of valid entries.
2121 if (this.exitBootServiceList
!= null) {
2122 for (i
= 0; i
< this.exitBootServiceList
.size(); i
++) {
2123 if (this.exitBootServiceList
.get(i
).equalsIgnoreCase("")) {
2129 fileBuffer
.append(Integer
.toString(Count
));
2130 fileBuffer
.append(";\r\n\r\n");
2132 if (this.exitBootServiceList
== null || this.exitBootServiceList
.size() == 0) {
2134 // No data so make a NULL list.
2137 .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED const EFI_EVENT_NOTIFY _gDriverExitBootServicesEvent[] = {\r\n");
2138 fileBuffer
.append(" NULL\r\n");
2139 fileBuffer
.append("};\r\n\r\n");
2142 // Write DriverExitBootServices function definition.
2144 for (i
= 0; i
< this.exitBootServiceList
.size(); i
++) {
2145 if (this.exitBootServiceList
.get(i
).equalsIgnoreCase("")) {
2149 fileBuffer
.append("VOID\r\n");
2150 fileBuffer
.append("EFIAPI\r\n");
2151 fileBuffer
.append(this.exitBootServiceList
.get(i
));
2152 fileBuffer
.append(" (\r\n");
2153 fileBuffer
.append(" IN EFI_EVENT Event,\r\n");
2154 fileBuffer
.append(" IN VOID *Context\r\n");
2155 fileBuffer
.append(" );\r\n\r\n");
2159 // Write DriverExitBootServices entry point array.
2162 .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED const EFI_EVENT_NOTIFY _gDriverExitBootServicesEvent[] = {");
2163 for (i
= 0; i
< this.exitBootServiceList
.size(); i
++) {
2164 if (this.exitBootServiceList
.get(i
).equalsIgnoreCase("")) {
2169 fileBuffer
.append("\r\n ");
2171 fileBuffer
.append(",\r\n ");
2173 fileBuffer
.append(this.exitBootServiceList
.get(i
));
2176 fileBuffer
.append(",\r\n NULL");
2177 fileBuffer
.append("\r\n};\r\n\r\n");