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());
457 .append("GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiCallerIdGuid = {");
459 throw new AutoGenException("Guid value must set!\n");
463 // Formate Guid as ANSI c form.Example:
464 // {0xd2b2b828, 0x826, 0x48a7,{0xb3, 0xdf, 0x98, 0x3c, 0x0, 0x60, 0x24,
468 fileBuffer
.append(guid
);
469 fileBuffer
.append("};\r\n");
472 // Generate library instance consumed protocol, guid, ppi, pcd list.
473 // Save those to this.protocolList, this.ppiList, this.pcdList,
474 // this.guidList. Write Consumed library constructor and desconstuct to
477 LibInstanceToAutogenC(fileBuffer
);
480 // Get module dependent Package identification.
482 PackageIdentification
[] packages
= saq
.getDependencePkg(this.arch
);
483 for (int i
= 0; i
< packages
.length
; i
++) {
484 if (!this.mDepPkgList
.contains(packages
[i
])) {
485 this.mDepPkgList
.add(packages
[i
]);
491 // Write consumed ppi, guid, protocol to autogen.c
493 ProtocolGuidToAutogenC(fileBuffer
);
494 PpiGuidToAutogenC(fileBuffer
);
495 GuidGuidToAutogenC(fileBuffer
);
500 this.myPcdAutogen
= new PCDAutoGenAction(moduleId
,
507 this.myPcdAutogen
.execute();
508 if (this.myPcdAutogen
!= null) {
509 fileBuffer
.append("\r\n");
510 fileBuffer
.append(this.myPcdAutogen
.getCAutoGenString());
513 if (!saveFile(outputPath
+ File
.separatorChar
+ "AutoGen.c", fileBuffer
)) {
514 throw new AutoGenException("Failed to generate AutoGen.c !!!");
522 This function generates AutoGen.h for library.
524 @throws BuildException
525 Failed to generate AutoGen.c.
527 void libGenAutogenH() throws EdkException
{
529 Set
<String
> libClassIncludeH
;
531 List
<String
> headerFileList
;
533 StringBuffer fileBuffer
= new StringBuffer(10240);
536 // Write Autogen.h header notation
538 fileBuffer
.append(CommonDefinition
.AUTOGENHNOTATION
);
541 // Add #ifndef ${BaseName}_AUTOGENH
542 // #def ${BseeName}_AUTOGENH
544 fileBuffer
.append(CommonDefinition
.IFNDEF
545 + CommonDefinition
.AUTOGENH
546 + this.moduleId
.getGuid().replaceAll("-", "_")
547 + ToolDefinitions
.LINE_SEPARATOR
);
548 fileBuffer
.append(CommonDefinition
.DEFINE
549 + CommonDefinition
.AUTOGENH
550 + this.moduleId
.getGuid().replaceAll("-", "_")
551 + ToolDefinitions
.LINE_SEPARATOR
552 + ToolDefinitions
.LINE_SEPARATOR
);
555 // Write EFI_SPECIFICATION_VERSION and EDK_RELEASE_VERSION
556 // to autogen.h file.
557 // Note: the specification version and release version should
558 // be get from module surface area instead of hard code.
560 fileBuffer
.append(CommonDefinition
.AUTOGENHBEGIN
);
561 String
[] specList
= saq
.getExternSpecificaiton();
562 for (int i
= 0; i
< specList
.length
; i
++) {
563 fileBuffer
.append(CommonDefinition
.DEFINE
+ specList
[i
]
566 // fileBuffer.append(CommonDefinition.autoGenHLine1);
567 // fileBuffer.append(CommonDefinition.autoGenHLine2);
570 // Write consumed package's mdouleInfo related *.h file to autogen.h.
572 moduleType
= saq
.getModuleType();
573 PackageIdentification
[] cosumedPkglist
= saq
574 .getDependencePkg(this.arch
);
575 headerFileList
= depPkgToAutogenH(cosumedPkglist
, moduleType
);
576 item
= headerFileList
.iterator();
577 while (item
.hasNext()) {
578 fileBuffer
.append(item
.next().toString());
581 // Write library class's related *.h file to autogen.h
583 String
[] libClassList
= saq
584 .getLibraryClasses(CommonDefinition
.ALWAYSCONSUMED
, this.arch
);
585 if (libClassList
!= null) {
586 libClassIncludeH
= LibraryClassToAutogenH(libClassList
);
587 item
= libClassIncludeH
.iterator();
588 while (item
.hasNext()) {
589 fileBuffer
.append(item
.next().toString());
594 .getLibraryClasses(CommonDefinition
.ALWAYSPRODUCED
, this.arch
);
595 if (libClassList
!= null) {
596 libClassIncludeH
= LibraryClassToAutogenH(libClassList
);
597 item
= libClassIncludeH
.iterator();
598 while (item
.hasNext()) {
599 fileBuffer
.append(item
.next().toString());
602 fileBuffer
.append(ToolDefinitions
.LINE_SEPARATOR
);
605 // If is TianoR8FlashMap, copy {Fv_DIR}/FlashMap.h to
606 // {DEST_DIR_DRBUG}/FlashMap.h
608 if (saq
.isHaveTianoR8FlashMap()) {
609 fileBuffer
.append(CommonDefinition
.INCLUDE
);
610 fileBuffer
.append(" <");
611 fileBuffer
.append(CommonDefinition
.TIANOR8PLASHMAPH
+ ">\r\n");
612 copyFlashMapHToDebugDir();
616 // Write PCD information to library AutoGen.h.
618 if (this.myPcdAutogen
!= null) {
619 fileBuffer
.append("\r\n");
620 fileBuffer
.append(this.myPcdAutogen
.getHAutoGenString());
624 // Append the #endif at AutoGen.h
626 fileBuffer
.append("#endif\r\n");
629 // Save content of string buffer to AutoGen.h file.
631 if (!saveFile(outputPath
+ File
.separatorChar
+ "AutoGen.h", fileBuffer
)) {
632 throw new AutoGenException("Failed to generate AutoGen.h !!!");
639 This function generates AutoGen.h for library.
641 @throws BuildException
642 Failed to generate AutoGen.c.
644 void libGenAutogenC() throws EdkException
{
645 StringBuffer fileBuffer
= new StringBuffer(10240);
648 // Write Autogen.c header notation
650 fileBuffer
.append(CommonDefinition
.AUTOGENCNOTATION
);
652 fileBuffer
.append(ToolDefinitions
.LINE_SEPARATOR
);
653 fileBuffer
.append(ToolDefinitions
.LINE_SEPARATOR
);
658 this.myPcdAutogen
= new PCDAutoGenAction(moduleId
,
661 saq
.getModulePcdEntryNameArray(),
664 this.myPcdAutogen
.execute();
665 if (this.myPcdAutogen
!= null) {
666 fileBuffer
.append(ToolDefinitions
.LINE_SEPARATOR
);
667 fileBuffer
.append(this.myPcdAutogen
.getCAutoGenString());
670 if (!saveFile(outputPath
+ File
.separatorChar
+ "AutoGen.c", fileBuffer
)) {
671 throw new AutoGenException("Failed to generate AutoGen.c !!!");
676 LibraryClassToAutogenH
678 This function returns *.h files declared by library classes which are
679 consumed or produced by current build module or library.
682 List of library class which consumed or produce by current
683 build module or library.
684 @return includeStrList List of *.h file.
686 Set
<String
> LibraryClassToAutogenH(String
[] libClassList
)
687 throws EdkException
{
688 Set
<String
> includeStrList
= new LinkedHashSet
<String
>();
689 String includeName
[];
693 // Get include file from GlobalData's SPDTable according to
694 // library class name.
696 for (int i
= 0; i
< libClassList
.length
; i
++) {
697 includeName
= GlobalData
.getLibraryClassHeaderFiles(
698 saq
.getDependencePkg(this.arch
),
700 if (includeName
== null) {
701 throw new AutoGenException("Can not find library class ["
702 + libClassList
[i
] + "] declaration in any SPD package. ");
704 for (int j
= 0; j
< includeName
.length
; j
++) {
705 String includeNameStr
= includeName
[j
];
706 if (includeNameStr
!= null) {
707 str
= CommonDefinition
.INCLUDE
+ " " + "<";
708 str
= str
+ includeNameStr
+ ">\r\n";
709 includeStrList
.add(str
);
710 includeNameStr
= null;
714 return includeStrList
;
720 This function add include file in AutoGen.h file.
722 @param packageNameList
723 List of module depended package.
728 List
<String
> depPkgToAutogenH(PackageIdentification
[] packageNameList
,
729 String moduleType
) throws AutoGenException
{
731 List
<String
> includeStrList
= new LinkedList
<String
>();
733 String includeStr
= "";
736 // Get include file from moduleInfo file
738 for (int i
= 0; i
< packageNameList
.length
; i
++) {
739 pkgHeader
= GlobalData
.getPackageHeaderFiles(packageNameList
[i
],
741 if (pkgHeader
== null) {
742 throw new AutoGenException("Can not find package ["
744 + "] declaration in any SPD package. ");
745 } else if (!pkgHeader
.equalsIgnoreCase("")) {
746 includeStr
= CommonDefinition
.INCLUDE
+ " <" + pkgHeader
748 includeStrList
.add(includeStr
);
752 return includeStrList
;
758 This function convert <ModuleEntryPoint> & <ModuleUnloadImage>
759 information in mas to AutoGen.c
761 @param entryPointList
764 String buffer fo AutoGen.c.
767 void EntryPointToAutoGen(String
[] entryPointList
, String
[] unloadImageList
, StringBuffer fileBuffer
)
768 throws EdkException
{
770 String typeStr
= saq
.getModuleType();
771 int unloadImageCount
= 0;
772 int entryPointCount
= 0;
775 // The parameters and return value of entryPoint is difference
776 // for difference module type.
778 switch (CommonDefinition
.getModuleType(typeStr
)) {
780 case CommonDefinition
.ModuleTypePeiCore
:
781 if (entryPointList
== null ||entryPointList
.length
!= 1 ) {
782 throw new AutoGenException(
783 "Module type = 'PEI_CORE', can have only one module entry point!");
785 fileBuffer
.append("EFI_STATUS\r\n");
786 fileBuffer
.append(entryPointList
[0]);
787 fileBuffer
.append(" (\r\n");
789 .append(" IN EFI_PEI_STARTUP_DESCRIPTOR *PeiStartupDescriptor,\r\n");
791 .append(" IN VOID *OldCoreData\r\n");
792 fileBuffer
.append(" );\r\n\r\n");
794 fileBuffer
.append("EFI_STATUS\r\n");
795 fileBuffer
.append("EFIAPI\r\n");
796 fileBuffer
.append("ProcessModuleEntryPointList (\r\n");
798 .append(" IN EFI_PEI_STARTUP_DESCRIPTOR *PeiStartupDescriptor,\r\n");
800 .append(" IN VOID *OldCoreData\r\n");
801 fileBuffer
.append(" )\r\n\r\n");
802 fileBuffer
.append("{\r\n");
803 fileBuffer
.append(" return ");
804 fileBuffer
.append(entryPointList
[0]);
805 fileBuffer
.append(" (PeiStartupDescriptor, OldCoreData);\r\n");
806 fileBuffer
.append("}\r\n\r\n");
810 case CommonDefinition
.ModuleTypeDxeCore
:
811 fileBuffer
.append("const UINT32 _gUefiDriverRevision = 0;\r\n");
812 if (entryPointList
== null || entryPointList
.length
!= 1) {
813 throw new AutoGenException(
814 "Module type = 'DXE_CORE', can have only one module entry point!");
817 fileBuffer
.append("VOID\r\n");
818 fileBuffer
.append(entryPointList
[0]);
819 fileBuffer
.append(" (\n");
820 fileBuffer
.append(" IN VOID *HobStart\r\n");
821 fileBuffer
.append(" );\r\n\r\n");
823 fileBuffer
.append("VOID\r\n");
824 fileBuffer
.append("EFIAPI\r\n");
825 fileBuffer
.append("ProcessModuleEntryPointList (\r\n");
826 fileBuffer
.append(" IN VOID *HobStart\r\n");
827 fileBuffer
.append(" )\r\n\r\n");
828 fileBuffer
.append("{\r\n");
829 fileBuffer
.append(" ");
830 fileBuffer
.append(entryPointList
[0]);
831 fileBuffer
.append(" (HobStart);\r\n");
832 fileBuffer
.append("}\r\n\r\n");
836 case CommonDefinition
.ModuleTypePeim
:
839 .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT32 _gPeimRevision = 0;\r\n");
840 if (entryPointList
== null || entryPointList
.length
== 0) {
841 fileBuffer
.append("EFI_STATUS\r\n");
842 fileBuffer
.append("EFIAPI\r\n");
843 fileBuffer
.append("ProcessModuleEntryPointList (\r\n");
844 fileBuffer
.append(" IN EFI_FFS_FILE_HEADER *FfsHeader,\r\n");
845 fileBuffer
.append(" IN EFI_PEI_SERVICES **PeiServices\r\n");
846 fileBuffer
.append(" )\r\n\r\n");
847 fileBuffer
.append("{\r\n");
848 fileBuffer
.append(" return EFI_SUCCESS;\r\n");
849 fileBuffer
.append("}\r\n\r\n");
852 for (int i
= 0; i
< entryPointList
.length
; i
++) {
853 fileBuffer
.append("EFI_STATUS\r\n");
854 fileBuffer
.append(entryPointList
[i
]);
855 fileBuffer
.append(" (\r\n");
857 .append(" IN EFI_FFS_FILE_HEADER *FfsHeader,\r\n");
859 .append(" IN EFI_PEI_SERVICES **PeiServices\r\n");
860 fileBuffer
.append(" );\r\n");
865 fileBuffer
.append("EFI_STATUS\r\n");
866 fileBuffer
.append("EFIAPI\r\n");
867 fileBuffer
.append("ProcessModuleEntryPointList (\r\n");
868 fileBuffer
.append(" IN EFI_FFS_FILE_HEADER *FfsHeader,\r\n");
869 fileBuffer
.append(" IN EFI_PEI_SERVICES **PeiServices\r\n");
870 fileBuffer
.append(" )\r\n\r\n");
871 fileBuffer
.append("{\r\n");
872 if (entryPointCount
== 1) {
873 fileBuffer
.append(" return ");
874 fileBuffer
.append(entryPointList
[0]);
875 fileBuffer
.append(" (FfsHeader, PeiServices);\r\n");
877 fileBuffer
.append(" EFI_STATUS Status;\r\n");
878 fileBuffer
.append(" EFI_STATUS CombinedStatus;\r\n\r\n");
879 fileBuffer
.append(" CombinedStatus = EFI_LOAD_ERROR;\r\n\r\n");
880 for (int i
= 0; i
< entryPointList
.length
; i
++) {
881 if (!entryPointList
[i
].equals("")) {
882 fileBuffer
.append(" Status = ");
883 fileBuffer
.append(entryPointList
[i
]);
884 fileBuffer
.append(" (FfsHeader, PeiServices);\r\n");
886 .append(" if (!EFI_ERROR (Status) || EFI_ERROR (CombinedStatus)) {\r\n");
887 fileBuffer
.append(" CombinedStatus = Status;\r\n");
888 fileBuffer
.append(" }\r\n\r\n");
893 fileBuffer
.append(" return CombinedStatus;\r\n");
895 fileBuffer
.append("}\r\n\r\n");
898 case CommonDefinition
.ModuleTypeDxeSmmDriver
:
901 // If entryPoint is null, create an empty ProcessModuleEntryPointList
904 if (entryPointList
== null || entryPointList
.length
== 0) {
906 .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gDriverEntryPointCount = ");
907 fileBuffer
.append(Integer
.toString(entryPointCount
));
908 fileBuffer
.append(";\r\n");
909 fileBuffer
.append("EFI_STATUS\r\n");
910 fileBuffer
.append("EFIAPI\r\n");
911 fileBuffer
.append("ProcessModuleEntryPointList (\r\n");
912 fileBuffer
.append(" IN EFI_HANDLE ImageHandle,\r\n");
913 fileBuffer
.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");
914 fileBuffer
.append(" )\r\n\r\n");
915 fileBuffer
.append("{\r\n");
916 fileBuffer
.append(" return EFI_SUCCESS;\r\n");
917 fileBuffer
.append("}\r\n\r\n");
920 for (int i
= 0; i
< entryPointList
.length
; i
++) {
921 fileBuffer
.append("EFI_STATUS\r\n");
922 fileBuffer
.append(entryPointList
[i
]);
923 fileBuffer
.append(" (\r\n");
924 fileBuffer
.append(" IN EFI_HANDLE ImageHandle,\r\n");
925 fileBuffer
.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");
926 fileBuffer
.append(" );\r\n");
930 .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gDriverEntryPointCount = ");
931 fileBuffer
.append(Integer
.toString(entryPointCount
));
932 fileBuffer
.append(";\r\n");
934 .append("static BASE_LIBRARY_JUMP_BUFFER mJumpContext;\r\n");
936 .append("static EFI_STATUS mDriverEntryPointStatus = EFI_LOAD_ERROR;\r\n\r\n");
938 fileBuffer
.append("EFI_STATUS\r\n");
939 fileBuffer
.append("EFIAPI\r\n");
940 fileBuffer
.append("ProcessModuleEntryPointList (\r\n");
941 fileBuffer
.append(" IN EFI_HANDLE ImageHandle,\r\n");
942 fileBuffer
.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");
943 fileBuffer
.append(" )\r\n\r\n");
944 fileBuffer
.append("{\r\n");
947 for (int i
= 0; i
< entryPointList
.length
; i
++) {
949 .append(" if (SetJump (&mJumpContext) == 0) {\r\n");
950 fileBuffer
.append(" ExitDriver (");
951 fileBuffer
.append(entryPointList
[i
]);
952 fileBuffer
.append(" (ImageHandle, SystemTable));\r\n");
953 fileBuffer
.append(" ASSERT (FALSE);\r\n");
954 fileBuffer
.append(" }\r\n");
957 fileBuffer
.append(" return mDriverEntryPointStatus;\r\n");
958 fileBuffer
.append("}\r\n\r\n");
960 fileBuffer
.append("VOID\r\n");
961 fileBuffer
.append("EFIAPI\r\n");
962 fileBuffer
.append("ExitDriver (\r\n");
963 fileBuffer
.append(" IN EFI_STATUS Status\n");
964 fileBuffer
.append(" )\r\n\r\n");
965 fileBuffer
.append("{\r\n");
967 .append(" if (!EFI_ERROR (Status) || EFI_ERROR (mDriverEntryPointStatus)) {\r\n");
968 fileBuffer
.append(" mDriverEntryPointStatus = Status;\r\n");
969 fileBuffer
.append(" }\r\n");
970 fileBuffer
.append(" LongJump (&mJumpContext, (UINTN)-1);\r\n");
971 fileBuffer
.append(" ASSERT (FALSE);\r\n");
972 fileBuffer
.append("}\r\n\r\n");
978 // Add "ModuleUnloadImage" for DxeSmmDriver module type;
980 //entryPointList = SurfaceAreaQuery.getModuleUnloadImageArray();
981 //entryPointList = CommonDefinition.remDupString(entryPointList);
982 //entryPointCount = 0;
984 unloadImageCount
= 0;
985 if (unloadImageList
!= null) {
986 for (int i
= 0; i
< unloadImageList
.length
; i
++) {
987 fileBuffer
.append("EFI_STATUS\r\n");
988 fileBuffer
.append(unloadImageList
[i
]);
989 fileBuffer
.append(" (\r\n");
991 .append(" IN EFI_HANDLE ImageHandle\r\n");
992 fileBuffer
.append(" );\r\n");
998 .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gDriverUnloadImageCount = ");
999 fileBuffer
.append(Integer
.toString(unloadImageCount
));
1000 fileBuffer
.append(";\r\n\r\n");
1002 fileBuffer
.append("EFI_STATUS\r\n");
1003 fileBuffer
.append("EFIAPI\r\n");
1004 fileBuffer
.append("ProcessModuleUnloadList (\r\n");
1005 fileBuffer
.append(" IN EFI_HANDLE ImageHandle\r\n");
1006 fileBuffer
.append(" )\r\n");
1007 fileBuffer
.append("{\r\n");
1009 if (unloadImageCount
== 0) {
1010 fileBuffer
.append(" return EFI_SUCCESS;\r\n");
1011 } else if (unloadImageCount
== 1) {
1012 fileBuffer
.append(" return ");
1013 fileBuffer
.append(unloadImageList
[0]);
1014 fileBuffer
.append("(ImageHandle);\r\n");
1016 fileBuffer
.append(" EFI_STATUS Status;\r\n\r\n");
1017 fileBuffer
.append(" Status = EFI_SUCCESS;\r\n\r\n");
1018 for (int i
= 0; i
< unloadImageList
.length
; i
++) {
1020 fileBuffer
.append(" Status = ");
1021 fileBuffer
.append(unloadImageList
[i
]);
1022 fileBuffer
.append("(ImageHandle);\r\n");
1024 fileBuffer
.append(" if (EFI_ERROR (Status)) {\r\n");
1025 fileBuffer
.append(" ");
1026 fileBuffer
.append(unloadImageList
[i
]);
1027 fileBuffer
.append("(ImageHandle);\r\n");
1028 fileBuffer
.append(" } else {\r\n");
1029 fileBuffer
.append(" Status = ");
1030 fileBuffer
.append(unloadImageList
[i
]);
1031 fileBuffer
.append("(ImageHandle);\r\n");
1032 fileBuffer
.append(" }\r\n");
1035 fileBuffer
.append(" return Status;\r\n");
1037 fileBuffer
.append("}\r\n\r\n");
1040 case CommonDefinition
.ModuleTypeDxeRuntimeDriver
:
1041 case CommonDefinition
.ModuleTypeDxeDriver
:
1042 case CommonDefinition
.ModuleTypeDxeSalDriver
:
1043 case CommonDefinition
.ModuleTypeUefiDriver
:
1044 case CommonDefinition
.ModuleTypeUefiApplication
:
1045 entryPointCount
= 0;
1046 fileBuffer
.append("const UINT32 _gUefiDriverRevision = 0;\r\n");
1048 // If entry point is null, create a empty ProcessModuleEntryPointList function.
1050 if (entryPointList
== null || entryPointList
.length
== 0) {
1052 .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gDriverEntryPointCount = 0;\r\n");
1053 fileBuffer
.append("EFI_STATUS\r\n");
1054 fileBuffer
.append("EFIAPI\r\n");
1055 fileBuffer
.append("ProcessModuleEntryPointList (\r\n");
1056 fileBuffer
.append(" IN EFI_HANDLE ImageHandle,\r\n");
1057 fileBuffer
.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");
1058 fileBuffer
.append(" )\r\n\r\n");
1059 fileBuffer
.append("{\r\n");
1060 fileBuffer
.append(" return EFI_SUCCESS;\r\n");
1061 fileBuffer
.append("}\r\n");
1064 for (int i
= 0; i
< entryPointList
.length
; i
++) {
1066 fileBuffer
.append("EFI_STATUS\r\n");
1067 fileBuffer
.append(entryPointList
[i
]);
1068 fileBuffer
.append(" (\r\n");
1069 fileBuffer
.append(" IN EFI_HANDLE ImageHandle,\r\n");
1070 fileBuffer
.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");
1071 fileBuffer
.append(" );\r\n");
1076 .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gDriverEntryPointCount = ");
1077 fileBuffer
.append(Integer
.toString(entryPointCount
));
1078 fileBuffer
.append(";\r\n");
1079 if (entryPointCount
> 1) {
1081 .append("static BASE_LIBRARY_JUMP_BUFFER mJumpContext;\r\n");
1083 .append("static EFI_STATUS mDriverEntryPointStatus = EFI_LOAD_ERROR;\r\n");
1085 fileBuffer
.append("\n");
1087 fileBuffer
.append("EFI_STATUS\r\n");
1088 fileBuffer
.append("EFIAPI\r\n");
1089 fileBuffer
.append("ProcessModuleEntryPointList (\r\n");
1090 fileBuffer
.append(" IN EFI_HANDLE ImageHandle,\r\n");
1091 fileBuffer
.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");
1092 fileBuffer
.append(" )\r\n\r\n");
1093 fileBuffer
.append("{\r\n");
1095 if (entryPointCount
== 1) {
1096 fileBuffer
.append(" return (");
1097 fileBuffer
.append(entryPointList
[0]);
1098 fileBuffer
.append(" (ImageHandle, SystemTable));\r\n");
1100 for (int i
= 0; i
< entryPointList
.length
; i
++) {
1101 if (!entryPointList
[i
].equals("")) {
1103 .append(" if (SetJump (&mJumpContext) == 0) {\r\n");
1104 fileBuffer
.append(" ExitDriver (");
1105 fileBuffer
.append(entryPointList
[i
]);
1106 fileBuffer
.append(" (ImageHandle, SystemTable));\r\n");
1107 fileBuffer
.append(" ASSERT (FALSE);\r\n");
1108 fileBuffer
.append(" }\r\n");
1113 fileBuffer
.append(" return mDriverEntryPointStatus;\r\n");
1115 fileBuffer
.append("}\r\n\r\n");
1117 fileBuffer
.append("VOID\r\n");
1118 fileBuffer
.append("EFIAPI\r\n");
1119 fileBuffer
.append("ExitDriver (\r\n");
1120 fileBuffer
.append(" IN EFI_STATUS Status\r\n");
1121 fileBuffer
.append(" )\r\n\r\n");
1122 fileBuffer
.append("{\r\n");
1123 if (entryPointCount
<= 1) {
1124 fileBuffer
.append(" if (EFI_ERROR (Status)) {\r\n");
1126 .append(" ProcessLibraryDestructorList (gImageHandle, gST);\r\n");
1127 fileBuffer
.append(" }\r\n");
1129 .append(" gBS->Exit (gImageHandle, Status, 0, NULL);\r\n");
1132 .append(" if (!EFI_ERROR (Status) || EFI_ERROR (mDriverEntryPointStatus)) {\r\n");
1133 fileBuffer
.append(" mDriverEntryPointStatus = Status;\r\n");
1134 fileBuffer
.append(" }\r\n");
1135 fileBuffer
.append(" LongJump (&mJumpContext, (UINTN)-1);\r\n");
1136 fileBuffer
.append(" ASSERT (FALSE);\r\n");
1138 fileBuffer
.append("}\r\n\r\n");
1143 // Add ModuleUnloadImage for DxeDriver and UefiDriver module type.
1145 //entryPointList = SurfaceAreaQuery.getModuleUnloadImageArray();
1147 // Remover duplicate unload entry point.
1149 //entryPointList = CommonDefinition.remDupString(entryPointList);
1150 //entryPointCount = 0;
1151 unloadImageCount
= 0;
1152 if (unloadImageList
!= null) {
1153 for (int i
= 0; i
< unloadImageList
.length
; i
++) {
1154 fileBuffer
.append("EFI_STATUS\r\n");
1155 fileBuffer
.append("EFIAPI\r\n");
1156 fileBuffer
.append(unloadImageList
[i
]);
1157 fileBuffer
.append(" (\r\n");
1159 .append(" IN EFI_HANDLE ImageHandle\r\n");
1160 fileBuffer
.append(" );\r\n");
1166 .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gDriverUnloadImageCount = ");
1167 fileBuffer
.append(Integer
.toString(unloadImageCount
));
1168 fileBuffer
.append(";\r\n\r\n");
1170 fileBuffer
.append("EFI_STATUS\n");
1171 fileBuffer
.append("EFIAPI\r\n");
1172 fileBuffer
.append("ProcessModuleUnloadList (\r\n");
1173 fileBuffer
.append(" IN EFI_HANDLE ImageHandle\r\n");
1174 fileBuffer
.append(" )\r\n");
1175 fileBuffer
.append("{\r\n");
1177 if (unloadImageCount
== 0) {
1178 fileBuffer
.append(" return EFI_SUCCESS;\r\n");
1179 } else if (unloadImageCount
== 1) {
1180 fileBuffer
.append(" return ");
1181 fileBuffer
.append(unloadImageList
[0]);
1182 fileBuffer
.append("(ImageHandle);\r\n");
1184 fileBuffer
.append(" EFI_STATUS Status;\r\n\r\n");
1185 fileBuffer
.append(" Status = EFI_SUCCESS;\r\n\r\n");
1186 for (int i
= 0; i
< unloadImageList
.length
; i
++) {
1188 fileBuffer
.append(" Status = ");
1189 fileBuffer
.append(unloadImageList
[i
]);
1190 fileBuffer
.append("(ImageHandle);\r\n");
1192 fileBuffer
.append(" if (EFI_ERROR (Status)) {\r\n");
1193 fileBuffer
.append(" ");
1194 fileBuffer
.append(unloadImageList
[i
]);
1195 fileBuffer
.append("(ImageHandle);\r\n");
1196 fileBuffer
.append(" } else {\r\n");
1197 fileBuffer
.append(" Status = ");
1198 fileBuffer
.append(unloadImageList
[i
]);
1199 fileBuffer
.append("(ImageHandle);\r\n");
1200 fileBuffer
.append(" }\r\n");
1203 fileBuffer
.append(" return Status;\r\n");
1205 fileBuffer
.append("}\r\n\r\n");
1213 This function gets GUIDs from SPD file accrodeing to <PPIs> information
1214 and write those GUIDs to AutoGen.c.
1217 String Buffer for Autogen.c file.
1218 @throws BuildException
1219 Guid must set value!
1221 void PpiGuidToAutogenC(StringBuffer fileBuffer
) throws AutoGenException
{
1222 String
[] cNameGuid
= null;
1225 // Get the all PPI adn PPI Notify from MSA file,
1226 // then add those PPI ,and PPI Notify name to list.
1229 String
[] ppiList
= saq
.getPpiArray(this.arch
);
1230 for (int i
= 0; i
< ppiList
.length
; i
++) {
1231 this.mPpiList
.add(ppiList
[i
]);
1234 String
[] ppiNotifyList
= saq
.getPpiNotifyArray(this.arch
);
1235 for (int i
= 0; i
< ppiNotifyList
.length
; i
++) {
1236 this.mPpiList
.add(ppiNotifyList
[i
]);
1240 // Find CNAME and GUID from dependence SPD file and write to Autogen.c
1242 Iterator ppiIterator
= this.mPpiList
.iterator();
1243 String ppiKeyWord
= null;
1244 while (ppiIterator
.hasNext()) {
1245 ppiKeyWord
= ppiIterator
.next().toString();
1246 cNameGuid
= GlobalData
.getPpiGuid(this.mDepPkgList
, ppiKeyWord
);
1247 if (cNameGuid
!= null) {
1249 .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID ");
1250 fileBuffer
.append(cNameGuid
[0]);
1251 fileBuffer
.append(" = { ");
1252 fileBuffer
.append(CommonDefinition
.formatGuidName(cNameGuid
[1]));
1253 fileBuffer
.append(" } ;");
1256 // If can't find Ppi GUID declaration in every package
1258 throw new AutoGenException("Can not find Ppi GUID ["
1259 + ppiKeyWord
+ "] declaration in any SPD package!");
1265 ProtocolGuidToAutogenc
1267 This function gets GUIDs from SPD file accrodeing to <Protocol>
1268 information and write those GUIDs to AutoGen.c.
1271 String Buffer for Autogen.c file.
1272 @throws BuildException
1273 Protocol name must set.
1275 void ProtocolGuidToAutogenC(StringBuffer fileBuffer
) throws EdkException
{
1276 String
[] cNameGuid
= null;
1278 String
[] protocolList
= saq
.getProtocolArray(this.arch
);
1281 // Add result to Autogen global list.
1283 for (int i
= 0; i
< protocolList
.length
; i
++) {
1284 this.mProtocolList
.add(protocolList
[i
]);
1287 String
[] protocolNotifyList
= saq
1288 .getProtocolNotifyArray(this.arch
);
1290 for (int i
= 0; i
< protocolNotifyList
.length
; i
++) {
1291 this.mProtocolList
.add(protocolNotifyList
[i
]);
1295 // Get the NAME and GUID from dependence SPD and write to Autogen.c
1297 Iterator protocolIterator
= this.mProtocolList
.iterator();
1298 String protocolKeyWord
= null;
1301 while (protocolIterator
.hasNext()) {
1302 protocolKeyWord
= protocolIterator
.next().toString();
1303 cNameGuid
= GlobalData
.getProtocolGuid(this.mDepPkgList
, protocolKeyWord
);
1304 if (cNameGuid
!= null) {
1306 .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID ");
1307 fileBuffer
.append(cNameGuid
[0]);
1308 fileBuffer
.append(" = { ");
1309 fileBuffer
.append(CommonDefinition
.formatGuidName(cNameGuid
[1]));
1310 fileBuffer
.append(" } ;");
1313 // If can't find protocol GUID declaration in every package
1315 throw new AutoGenException("Can not find protocol Guid ["
1316 + protocolKeyWord
+ "] declaration in any SPD package!");
1324 This function gets GUIDs from SPD file accrodeing to <Guids> information
1325 and write those GUIDs to AutoGen.c.
1328 String Buffer for Autogen.c file.
1331 void GuidGuidToAutogenC(StringBuffer fileBuffer
) throws AutoGenException
{
1332 String
[] cNameGuid
= null;
1333 String guidKeyWord
= null;
1335 String
[] guidList
= saq
.getGuidEntryArray(this.arch
);
1337 for (int i
= 0; i
< guidList
.length
; i
++) {
1338 this.mGuidList
.add(guidList
[i
]);
1342 Iterator guidIterator
= this.mGuidList
.iterator();
1343 while (guidIterator
.hasNext()) {
1344 guidKeyWord
= guidIterator
.next().toString();
1345 cNameGuid
= GlobalData
.getGuid(this.mDepPkgList
, guidKeyWord
);
1347 if (cNameGuid
!= null) {
1349 .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID ");
1350 fileBuffer
.append(cNameGuid
[0]);
1351 fileBuffer
.append(" = { ");
1352 fileBuffer
.append(CommonDefinition
.formatGuidName(cNameGuid
[1]));
1353 fileBuffer
.append("} ;");
1356 // If can't find GUID declaration in every package
1358 throw new AutoGenException("Can not find Guid [" + guidKeyWord
1359 + "] declaration in any SPD package. ");
1366 LibInstanceToAutogenC
1368 This function adds dependent library instance to autogen.c,which
1369 includeing library's constructor, destructor, and library dependent ppi,
1370 protocol, guid, pcd information.
1373 String buffer for AutoGen.c
1374 @throws BuildException
1376 void LibInstanceToAutogenC(StringBuffer fileBuffer
) throws EdkException
{
1377 String moduleType
= this.moduleId
.getModuleType();
1379 // Add library constructor to AutoGen.c
1381 LibConstructorToAutogenC(libConstructList
, moduleType
,
1382 fileBuffer
/* autogenC */);
1384 // Add library destructor to AutoGen.c
1386 LibDestructorToAutogenC(libDestructList
, moduleType
, fileBuffer
/* autogenC */);
1390 LibConstructorToAutogenc
1392 This function writes library constructor list to AutoGen.c. The library
1393 constructor's parameter and return value depend on module type.
1395 @param libInstanceList
1396 List of library construct name.
1400 String buffer for AutoGen.c
1403 void LibConstructorToAutogenC(List
<String
[]> libInstanceList
,
1404 String moduleType
, StringBuffer fileBuffer
) throws EdkException
{
1405 boolean isFirst
= true;
1408 // The library constructor's parameter and return value depend on
1411 for (int i
= 0; i
< libInstanceList
.size(); i
++) {
1412 if (libInstanceList
.get(i
)[1].equalsIgnoreCase(EdkDefinitions
.MODULE_TYPE_BASE
)) {
1413 fileBuffer
.append("RETURN_STATUS\r\n");
1414 fileBuffer
.append("EFIAPI\r\n");
1415 fileBuffer
.append(libInstanceList
.get(i
)[0]);
1416 fileBuffer
.append(" (\r\n");
1417 fileBuffer
.append(" VOID\r\n");
1418 fileBuffer
.append(" );\r\n");
1420 switch (CommonDefinition
.getModuleType(moduleType
)) {
1421 case CommonDefinition
.ModuleTypeBase
:
1422 fileBuffer
.append("RETURN_STATUS\r\n");
1423 fileBuffer
.append("EFIAPI\r\n");
1424 fileBuffer
.append(libInstanceList
.get(i
)[0]);
1425 fileBuffer
.append(" (\r\n");
1426 fileBuffer
.append(" VOID\r\n");
1427 fileBuffer
.append(" );\r\n");
1430 case CommonDefinition
.ModuleTypePeiCore
:
1431 case CommonDefinition
.ModuleTypePeim
:
1432 fileBuffer
.append("EFI_STATUS\r\n");
1433 fileBuffer
.append("EFIAPI\r\n");
1434 fileBuffer
.append(libInstanceList
.get(i
)[0]);
1435 fileBuffer
.append(" (\r\n");
1437 .append(" IN EFI_FFS_FILE_HEADER *FfsHeader,\r\n");
1439 .append(" IN EFI_PEI_SERVICES **PeiServices\r\n");
1440 fileBuffer
.append(" );\r\n");
1443 case CommonDefinition
.ModuleTypeDxeCore
:
1444 case CommonDefinition
.ModuleTypeDxeDriver
:
1445 case CommonDefinition
.ModuleTypeDxeRuntimeDriver
:
1446 case CommonDefinition
.ModuleTypeDxeSmmDriver
:
1447 case CommonDefinition
.ModuleTypeDxeSalDriver
:
1448 case CommonDefinition
.ModuleTypeUefiDriver
:
1449 case CommonDefinition
.ModuleTypeUefiApplication
:
1450 fileBuffer
.append("EFI_STATUS\r\n");
1451 fileBuffer
.append("EFIAPI\r\n");
1452 fileBuffer
.append(libInstanceList
.get(i
)[0]);
1453 fileBuffer
.append(" (\r\n");
1454 fileBuffer
.append(" IN EFI_HANDLE ImageHandle,\r\n");
1455 fileBuffer
.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");
1456 fileBuffer
.append(" );\r\n");
1464 // Add ProcessLibraryConstructorList in AutoGen.c
1466 fileBuffer
.append("VOID\r\n");
1467 fileBuffer
.append("EFIAPI\r\n");
1468 fileBuffer
.append("ProcessLibraryConstructorList (\r\n");
1469 switch (CommonDefinition
.getModuleType(moduleType
)) {
1470 case CommonDefinition
.ModuleTypeBase
:
1471 fileBuffer
.append(" VOID\r\n");
1474 case CommonDefinition
.ModuleTypePeiCore
:
1475 case CommonDefinition
.ModuleTypePeim
:
1476 fileBuffer
.append(" IN EFI_FFS_FILE_HEADER *FfsHeader,\r\n");
1478 .append(" IN EFI_PEI_SERVICES **PeiServices\r\n");
1481 case CommonDefinition
.ModuleTypeDxeCore
:
1482 case CommonDefinition
.ModuleTypeDxeDriver
:
1483 case CommonDefinition
.ModuleTypeDxeRuntimeDriver
:
1484 case CommonDefinition
.ModuleTypeDxeSmmDriver
:
1485 case CommonDefinition
.ModuleTypeDxeSalDriver
:
1486 case CommonDefinition
.ModuleTypeUefiDriver
:
1487 case CommonDefinition
.ModuleTypeUefiApplication
:
1488 fileBuffer
.append(" IN EFI_HANDLE ImageHandle,\r\n");
1489 fileBuffer
.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");
1493 fileBuffer
.append(" )\r\n");
1494 fileBuffer
.append("{\r\n");
1496 // If no constructor function, return EFI_SUCCESS.
1498 //if (libInstanceList.size() == 0){
1499 // fileBuffer.append(" return EFI_SUCCESS;\r\n");
1501 for (int i
= 0; i
< libInstanceList
.size(); i
++) {
1503 fileBuffer
.append(" EFI_STATUS Status;\r\n");
1504 fileBuffer
.append(" Status = EFI_SUCCESS;\r\n");
1505 fileBuffer
.append("\r\n");
1508 if (libInstanceList
.get(i
)[1].equalsIgnoreCase(EdkDefinitions
.MODULE_TYPE_BASE
)) {
1509 fileBuffer
.append(" Status = ");
1510 fileBuffer
.append(libInstanceList
.get(i
)[0]);
1511 fileBuffer
.append("();\r\n");
1512 fileBuffer
.append(" VOID\r\n");
1514 switch (CommonDefinition
.getModuleType(moduleType
)) {
1515 case CommonDefinition
.ModuleTypeBase
:
1516 fileBuffer
.append(" Status = ");
1517 fileBuffer
.append(libInstanceList
.get(i
)[0]);
1518 fileBuffer
.append("();\r\n");
1519 fileBuffer
.append(" VOID\r\n");
1521 case CommonDefinition
.ModuleTypePeiCore
:
1522 case CommonDefinition
.ModuleTypePeim
:
1523 fileBuffer
.append(" Status = ");
1524 fileBuffer
.append(libInstanceList
.get(i
)[0]);
1525 fileBuffer
.append(" (FfsHeader, PeiServices);\r\n");
1527 case CommonDefinition
.ModuleTypeDxeCore
:
1528 case CommonDefinition
.ModuleTypeDxeDriver
:
1529 case CommonDefinition
.ModuleTypeDxeRuntimeDriver
:
1530 case CommonDefinition
.ModuleTypeDxeSmmDriver
:
1531 case CommonDefinition
.ModuleTypeDxeSalDriver
:
1532 case CommonDefinition
.ModuleTypeUefiDriver
:
1533 case CommonDefinition
.ModuleTypeUefiApplication
:
1534 fileBuffer
.append(" Status = ");
1535 fileBuffer
.append(libInstanceList
.get(i
)[0]);
1536 fileBuffer
.append(" (ImageHandle, SystemTable);\r\n");
1539 EdkLog
.log(EdkLog
.EDK_INFO
,"Autogen doesn't know how to deal with module type - " + moduleType
+ "!");
1543 fileBuffer
.append(" ASSERT_EFI_ERROR (Status);\r\n");
1545 fileBuffer
.append("}\r\n");
1549 LibDestructorToAutogenc
1551 This function writes library destructor list to AutoGen.c. The library
1552 destructor's parameter and return value depend on module type.
1554 @param libInstanceList
1555 List of library destructor name.
1559 String buffer for AutoGen.c
1562 void LibDestructorToAutogenC(List
<String
[]> libInstanceList
,
1563 String moduleType
, StringBuffer fileBuffer
) throws EdkException
{
1564 boolean isFirst
= true;
1565 for (int i
= 0; i
< libInstanceList
.size(); i
++) {
1566 if (libInstanceList
.get(i
)[1].equalsIgnoreCase(EdkDefinitions
.MODULE_TYPE_BASE
)) {
1567 fileBuffer
.append("RETURN_STATUS\r\n");
1568 fileBuffer
.append("EFIAPI\r\n");
1569 fileBuffer
.append(libInstanceList
.get(i
)[0]);
1570 fileBuffer
.append(" (\r\n");
1571 fileBuffer
.append(" VOID\r\n");
1572 fileBuffer
.append(" );\r\n");
1574 switch (CommonDefinition
.getModuleType(moduleType
)) {
1575 case CommonDefinition
.ModuleTypeBase
:
1576 fileBuffer
.append("RETURN_STATUS\r\n");
1577 fileBuffer
.append("EFIAPI\r\n");
1578 fileBuffer
.append(libInstanceList
.get(i
)[0]);
1579 fileBuffer
.append(" (\r\n");
1580 fileBuffer
.append(" VOID\r\n");
1581 fileBuffer
.append(" );\r\n");
1583 case CommonDefinition
.ModuleTypePeiCore
:
1584 case CommonDefinition
.ModuleTypePeim
:
1585 fileBuffer
.append("EFI_STATUS\r\n");
1586 fileBuffer
.append("EFIAPI\r\n");
1587 fileBuffer
.append(libInstanceList
.get(i
)[0]);
1588 fileBuffer
.append(" (\r\n");
1590 .append(" IN EFI_FFS_FILE_HEADER *FfsHeader,\r\n");
1592 .append(" IN EFI_PEI_SERVICES **PeiServices\r\n");
1593 fileBuffer
.append(" );\r\n");
1595 case CommonDefinition
.ModuleTypeDxeCore
:
1596 case CommonDefinition
.ModuleTypeDxeDriver
:
1597 case CommonDefinition
.ModuleTypeDxeRuntimeDriver
:
1598 case CommonDefinition
.ModuleTypeDxeSmmDriver
:
1599 case CommonDefinition
.ModuleTypeDxeSalDriver
:
1600 case CommonDefinition
.ModuleTypeUefiDriver
:
1601 case CommonDefinition
.ModuleTypeUefiApplication
:
1602 fileBuffer
.append("EFI_STATUS\r\n");
1603 fileBuffer
.append("EFIAPI\r\n");
1604 fileBuffer
.append(libInstanceList
.get(i
)[0]);
1605 fileBuffer
.append(" (\r\n");
1606 fileBuffer
.append(" IN EFI_HANDLE ImageHandle,\r\n");
1607 fileBuffer
.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");
1608 fileBuffer
.append(" );\r\n");
1615 // Write ProcessLibraryDestructor list to autogen.c
1617 switch (CommonDefinition
.getModuleType(moduleType
)) {
1618 case CommonDefinition
.ModuleTypeBase
:
1619 case CommonDefinition
.ModuleTypePeiCore
:
1620 case CommonDefinition
.ModuleTypePeim
:
1622 case CommonDefinition
.ModuleTypeDxeCore
:
1623 case CommonDefinition
.ModuleTypeDxeDriver
:
1624 case CommonDefinition
.ModuleTypeDxeRuntimeDriver
:
1625 case CommonDefinition
.ModuleTypeDxeSmmDriver
:
1626 case CommonDefinition
.ModuleTypeDxeSalDriver
:
1627 case CommonDefinition
.ModuleTypeUefiDriver
:
1628 case CommonDefinition
.ModuleTypeUefiApplication
:
1629 fileBuffer
.append("VOID\r\n");
1630 fileBuffer
.append("EFIAPI\r\n");
1631 fileBuffer
.append("ProcessLibraryDestructorList (\r\n");
1632 fileBuffer
.append(" IN EFI_HANDLE ImageHandle,\r\n");
1633 fileBuffer
.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");
1634 fileBuffer
.append(" )\r\n");
1635 fileBuffer
.append("{\r\n");
1637 // If no library destructor function, return EFI_SUCCESS.
1640 for (int i
= 0; i
< libInstanceList
.size(); i
++) {
1642 fileBuffer
.append(" EFI_STATUS Status;\r\n");
1643 fileBuffer
.append(" Status = EFI_SUCCESS;\r\n");
1644 fileBuffer
.append("\r\n");
1647 if (libInstanceList
.get(i
)[1].equalsIgnoreCase(EdkDefinitions
.MODULE_TYPE_BASE
)) {
1648 fileBuffer
.append(" Status = ");
1649 fileBuffer
.append(libInstanceList
.get(i
)[0]);
1650 fileBuffer
.append("();\r\n");
1651 fileBuffer
.append(" VOID\r\n");
1653 fileBuffer
.append(" Status = ");
1654 fileBuffer
.append(libInstanceList
.get(i
)[0]);
1655 fileBuffer
.append("(ImageHandle, SystemTable);\r\n");
1656 fileBuffer
.append(" ASSERT_EFI_ERROR (Status);\r\n");
1659 fileBuffer
.append("}\r\n");
1665 ExternsDriverBindingToAutoGenC
1667 This function is to write DRIVER_BINDING, COMPONENT_NAME,
1668 DRIVER_CONFIGURATION, DRIVER_DIAGNOSTIC in AutoGen.c.
1671 String buffer for AutoGen.c
1673 void ExternsDriverBindingToAutoGenC(StringBuffer fileBuffer
)
1674 throws EdkException
{
1677 // Get the arry of extern. The driverBindingGroup is a 2 dimension array.
1678 // The second dimension is include following element: DriverBinding,
1679 // ComponentName, DriverConfiguration, DriverDiag;
1681 String
[][] driverBindingGroup
= this.saq
.getExternProtocolGroup();
1689 // Write driver binding protocol extern to autogen.c
1691 for (int i
= 0; i
< driverBindingGroup
.length
; i
++) {
1692 if (driverBindingGroup
[i
][0] != null) {
1693 fileBuffer
.append("extern EFI_DRIVER_BINDING_PROTOCOL ");
1694 fileBuffer
.append(driverBindingGroup
[i
][0]);
1695 fileBuffer
.append(";\r\n");
1700 // Write component name protocol extern to autogen.c
1702 for (int i
= 0; i
< driverBindingGroup
.length
; i
++) {
1703 if (driverBindingGroup
[i
][1]!= null) {
1704 if (driverBindingGroup
[i
][0] != null) {
1706 fileBuffer
.append("extern EFI_COMPONENT_NAME_PROTOCOL ");
1707 fileBuffer
.append(driverBindingGroup
[i
][1]);
1708 fileBuffer
.append(";\r\n");
1710 throw new AutoGenException("DriverBinding can't be empty!!");
1716 // Write driver configration protocol extern to autogen.c
1718 for (int i
= 0; i
< driverBindingGroup
.length
; i
++) {
1719 if (driverBindingGroup
[i
][2] != null) {
1720 if (driverBindingGroup
[i
][0] != null) {
1722 fileBuffer
.append("extern EFI_DRIVER_CONFIGURATION_PROTOCOL ");
1723 fileBuffer
.append(driverBindingGroup
[i
][2]);
1724 fileBuffer
.append(";\r\n");
1726 throw new AutoGenException("DriverBinding can't be empty!!");
1732 // Write driver dignastic protocol extern to autogen.c
1734 for (int i
= 0; i
< driverBindingGroup
.length
; i
++) {
1735 if (driverBindingGroup
[i
][3] != null) {
1736 if (driverBindingGroup
[i
][0] != null) {
1738 fileBuffer
.append("extern EFI_DRIVER_DIAGNOSTICS_PROTOCOL ");
1739 fileBuffer
.append(driverBindingGroup
[i
][3]);
1740 fileBuffer
.append(";\r\n");
1742 throw new AutoGenException("DriverBinding can't be empty!!");
1748 // Write driver module protocol bitmask.
1751 .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gDriverModelProtocolBitmask = ");
1752 fileBuffer
.append(Integer
.toString(BitMask
));
1753 fileBuffer
.append(";\r\n");
1756 // Write driver module protocol list entry
1759 .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINTN _gDriverModelProtocolListEntries = ");
1761 fileBuffer
.append(Integer
.toString(driverBindingGroup
.length
));
1762 fileBuffer
.append(";\r\n");
1765 // Write drive module protocol list to autogen.c
1767 if (driverBindingGroup
.length
> 0) {
1769 .append("GLOBAL_REMOVE_IF_UNREFERENCED const EFI_DRIVER_MODEL_PROTOCOL_LIST _gDriverModelProtocolList[] = {");
1773 for (int i
= 0; i
< driverBindingGroup
.length
; i
++) {
1775 fileBuffer
.append(",");
1778 fileBuffer
.append("\r\n {\r\n");
1779 fileBuffer
.append(" &");
1780 fileBuffer
.append(driverBindingGroup
[i
][0]);
1781 fileBuffer
.append(", \r\n");
1784 if (driverBindingGroup
[i
][1] != null) {
1785 fileBuffer
.append(" &");
1786 fileBuffer
.append(driverBindingGroup
[i
][1]);
1787 fileBuffer
.append(", \r\n");
1789 fileBuffer
.append(" NULL, \r\n");
1792 if (driverBindingGroup
[i
][2] != null) {
1793 fileBuffer
.append(" &");
1794 fileBuffer
.append(driverBindingGroup
[i
][2]);
1795 fileBuffer
.append(", \r\n");
1797 fileBuffer
.append(" NULL, \r\n");
1800 if (driverBindingGroup
[i
][3] != null) {
1801 fileBuffer
.append(" &");
1802 fileBuffer
.append(driverBindingGroup
[i
][3]);
1803 fileBuffer
.append(", \r\n");
1805 fileBuffer
.append(" NULL, \r\n");
1807 fileBuffer
.append(" }");
1810 if (driverBindingGroup
.length
> 0) {
1811 fileBuffer
.append("\r\n};\r\n");
1816 ExternCallBackToAutoGenC
1818 This function adds <SetVirtualAddressMapCallBack> and
1819 <ExitBootServicesCallBack> infomation to AutoGen.c
1822 String buffer for AutoGen.c
1823 @throws BuildException
1825 void ExternCallBackToAutoGenC(StringBuffer fileBuffer
)
1826 throws EdkException
{
1828 // Collect module's <SetVirtualAddressMapCallBack> and
1829 // <ExitBootServiceCallBack> and add to setVirtualAddList
1830 // exitBootServiceList.
1832 String
[] setVirtuals
= saq
.getSetVirtualAddressMapCallBackArray();
1833 String
[] exitBoots
= saq
.getExitBootServicesCallBackArray();
1834 if (setVirtuals
!= null) {
1835 for (int j
= 0; j
< setVirtuals
.length
; j
++) {
1836 this.setVirtalAddList
.add(setVirtuals
[j
]);
1839 if (exitBoots
!= null) {
1840 for (int k
= 0; k
< exitBoots
.length
; k
++) {
1841 this.exitBootServiceList
.add(exitBoots
[k
]);
1845 // Add c code in autogen.c which relate to <SetVirtualAddressMapCallBack>
1846 // and <ExitBootServicesCallBack>
1848 String moduleType
= this.moduleId
.getModuleType();
1849 switch (CommonDefinition
.getModuleType(moduleType
)) {
1850 case CommonDefinition
.ModuleTypeDxeDriver
:
1851 case CommonDefinition
.ModuleTypeDxeRuntimeDriver
:
1852 case CommonDefinition
.ModuleTypeDxeSalDriver
:
1853 case CommonDefinition
.ModuleTypeUefiDriver
:
1854 case CommonDefinition
.ModuleTypeUefiApplication
:
1856 // If moduleType is one of above, call setVirtualAddressToAutogenC,
1857 // and setExitBootServiceToAutogenC.
1859 setVirtualAddressToAutogenC(fileBuffer
);
1860 setExitBootServiceToAutogenC(fileBuffer
);
1868 copyFlashMapHToDebugDir
1870 This function is to copy the falshmap.h to debug directory and change
1871 its name to TianoR8FlashMap.h
1876 private void copyFlashMapHToDebugDir() throws AutoGenException
{
1878 File inFile
= new File(fvDir
+ File
.separatorChar
+ CommonDefinition
.FLASHMAPH
);
1879 int size
= (int)inFile
.length();
1880 byte[] buffer
= new byte[size
];
1881 File outFile
= new File (this.outputPath
+ File
.separatorChar
+ CommonDefinition
.TIANOR8PLASHMAPH
);
1883 // If TianoR8FlashMap.h existed and the flashMap.h don't change,
1886 if ((!outFile
.exists()) ||(inFile
.lastModified() - outFile
.lastModified()) >= 0) {
1887 if (inFile
.exists()) {
1889 FileInputStream fis
= new FileInputStream (inFile
);
1891 FileOutputStream fos
= new FileOutputStream(outFile
);
1895 } catch (IOException e
){
1896 throw new AutoGenException("The file, flashMap.h can't be open!");
1900 throw new AutoGenException("The file, flashMap.h doesn't exist!");
1906 This function first order the library instances, then collect
1907 library instance 's PPI, Protocol, GUID,
1908 SetVirtalAddressMapCallBack, ExitBootServiceCallBack, and
1909 Destructor, Constructor.
1914 private void collectLibInstanceInfo() throws EdkException
{
1917 String libConstructName
= null;
1918 String libDestructName
= null;
1919 String libModuleType
= null;
1920 String
[] setVirtuals
= null;
1921 String
[] exitBoots
= null;
1923 ModuleIdentification
[] libraryIdList
= saq
.getLibraryInstance(this.arch
);
1925 if (libraryIdList
!= null) {
1927 // Reorder library instance sequence.
1929 AutogenLibOrder libOrder
= new AutogenLibOrder(libraryIdList
,
1931 List
<ModuleIdentification
> orderList
= libOrder
1932 .orderLibInstance();
1934 if (orderList
!= null) {
1936 // Process library instance one by one.
1938 for (int i
= 0; i
< orderList
.size(); i
++) {
1941 // Get library instance basename.
1943 ModuleIdentification libInstanceId
= orderList
.get(i
);
1949 Map
<String
, XmlObject
> libDoc
= GlobalData
.getDoc(libInstanceId
, this.arch
);
1952 // Get <PPis>, <Protocols>, <Guids> list of this library
1955 String
[] ppiList
= saq
.getPpiArray(this.arch
);
1956 String
[] ppiNotifyList
= saq
.getPpiNotifyArray(this.arch
);
1957 String
[] protocolList
= saq
.getProtocolArray(this.arch
);
1958 String
[] protocolNotifyList
= saq
.getProtocolNotifyArray(this.arch
);
1959 String
[] guidList
= saq
.getGuidEntryArray(this.arch
);
1960 PackageIdentification
[] pkgList
= saq
.getDependencePkg(this.arch
);
1963 // Add those ppi, protocol, guid in global ppi,
1967 for (index
= 0; index
< ppiList
.length
; index
++) {
1968 this.mPpiList
.add(ppiList
[index
]);
1971 for (index
= 0; index
< ppiNotifyList
.length
; index
++) {
1972 this.mPpiList
.add(ppiNotifyList
[index
]);
1975 for (index
= 0; index
< protocolList
.length
; index
++) {
1976 this.mProtocolList
.add(protocolList
[index
]);
1979 for (index
= 0; index
< protocolNotifyList
.length
; index
++) {
1980 this.mProtocolList
.add(protocolNotifyList
[index
]);
1983 for (index
= 0; index
< guidList
.length
; index
++) {
1984 this.mGuidList
.add(guidList
[index
]);
1986 for (index
= 0; index
< pkgList
.length
; index
++) {
1987 if (!this.mDepPkgList
.contains(pkgList
[index
])) {
1988 this.mDepPkgList
.add(pkgList
[index
]);
1993 // If not yet parse this library instance's constructor
1994 // element,parse it.
1996 libConstructName
= saq
.getLibConstructorName();
1997 libDestructName
= saq
.getLibDestructorName();
1998 libModuleType
= saq
.getModuleType();
2001 // Collect SetVirtualAddressMapCallBack and
2002 // ExitBootServiceCallBack.
2004 setVirtuals
= saq
.getSetVirtualAddressMapCallBackArray();
2005 exitBoots
= saq
.getExitBootServicesCallBackArray();
2006 if (setVirtuals
!= null) {
2007 for (int j
= 0; j
< setVirtuals
.length
; j
++) {
2008 this.setVirtalAddList
.add(setVirtuals
[j
]);
2011 if (exitBoots
!= null) {
2012 for (int k
= 0; k
< exitBoots
.length
; k
++) {
2013 this.exitBootServiceList
.add(exitBoots
[k
]);
2018 // Add dependent library instance constructor function.
2020 if (libConstructName
!= null) {
2021 this.libConstructList
.add(new String
[] {libConstructName
, libModuleType
});
2024 // Add dependent library instance destructor fuction.
2026 if (libDestructName
!= null) {
2027 this.libDestructList
.add(new String
[] {libDestructName
, libModuleType
});
2034 private void setVirtualAddressToAutogenC(StringBuffer fileBuffer
){
2036 // Entry point lib for these module types needs to know the count
2040 .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED const UINTN _gDriverSetVirtualAddressMapEventCount = ");
2043 // If the list is not valid or has no entries set count to zero else
2044 // set count to the number of valid entries
2048 if (this.setVirtalAddList
!= null) {
2049 for (i
= 0; i
< this.setVirtalAddList
.size(); i
++) {
2050 if (this.setVirtalAddList
.get(i
).equalsIgnoreCase("")) {
2057 fileBuffer
.append(Integer
.toString(Count
));
2058 fileBuffer
.append(";\r\n\r\n");
2059 if (this.setVirtalAddList
== null || this.setVirtalAddList
.size() == 0) {
2061 // No data so make a NULL list
2064 .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED const EFI_EVENT_NOTIFY _gDriverSetVirtualAddressMapEvent[] = {\r\n");
2065 fileBuffer
.append(" NULL\r\n");
2066 fileBuffer
.append("};\r\n\r\n");
2069 // Write SetVirtualAddressMap function definition.
2071 for (i
= 0; i
< this.setVirtalAddList
.size(); i
++) {
2072 if (this.setVirtalAddList
.get(i
).equalsIgnoreCase("")) {
2075 fileBuffer
.append("VOID\r\n");
2076 fileBuffer
.append("EFIAPI\r\n");
2077 fileBuffer
.append(this.setVirtalAddList
.get(i
));
2078 fileBuffer
.append(" (\r\n");
2079 fileBuffer
.append(" IN EFI_EVENT Event,\r\n");
2080 fileBuffer
.append(" IN VOID *Context\r\n");
2081 fileBuffer
.append(" );\r\n\r\n");
2085 // Write SetVirtualAddressMap entry point array.
2088 .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED const EFI_EVENT_NOTIFY _gDriverSetVirtualAddressMapEvent[] = {");
2089 for (i
= 0; i
< this.setVirtalAddList
.size(); i
++) {
2090 if (this.setVirtalAddList
.get(i
).equalsIgnoreCase("")) {
2095 fileBuffer
.append("\r\n ");
2097 fileBuffer
.append(",\r\n ");
2100 fileBuffer
.append(this.setVirtalAddList
.get(i
));
2103 // add the NULL at the end of _gDriverSetVirtualAddressMapEvent list.
2105 fileBuffer
.append(",\r\n NULL");
2106 fileBuffer
.append("\r\n};\r\n\r\n");
2111 private void setExitBootServiceToAutogenC(StringBuffer fileBuffer
){
2113 // Entry point lib for these module types needs to know the count.
2116 .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED const UINTN _gDriverExitBootServicesEventCount = ");
2119 // If the list is not valid or has no entries set count to zero else
2120 // set count to the number of valid entries.
2124 if (this.exitBootServiceList
!= null) {
2125 for (i
= 0; i
< this.exitBootServiceList
.size(); i
++) {
2126 if (this.exitBootServiceList
.get(i
).equalsIgnoreCase("")) {
2132 fileBuffer
.append(Integer
.toString(Count
));
2133 fileBuffer
.append(";\r\n\r\n");
2135 if (this.exitBootServiceList
== null || this.exitBootServiceList
.size() == 0) {
2137 // No data so make a NULL list.
2140 .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED const EFI_EVENT_NOTIFY _gDriverExitBootServicesEvent[] = {\r\n");
2141 fileBuffer
.append(" NULL\r\n");
2142 fileBuffer
.append("};\r\n\r\n");
2145 // Write DriverExitBootServices function definition.
2147 for (i
= 0; i
< this.exitBootServiceList
.size(); i
++) {
2148 if (this.exitBootServiceList
.get(i
).equalsIgnoreCase("")) {
2152 fileBuffer
.append("VOID\r\n");
2153 fileBuffer
.append("EFIAPI\r\n");
2154 fileBuffer
.append(this.exitBootServiceList
.get(i
));
2155 fileBuffer
.append(" (\r\n");
2156 fileBuffer
.append(" IN EFI_EVENT Event,\r\n");
2157 fileBuffer
.append(" IN VOID *Context\r\n");
2158 fileBuffer
.append(" );\r\n\r\n");
2162 // Write DriverExitBootServices entry point array.
2165 .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED const EFI_EVENT_NOTIFY _gDriverExitBootServicesEvent[] = {");
2166 for (i
= 0; i
< this.exitBootServiceList
.size(); i
++) {
2167 if (this.exitBootServiceList
.get(i
).equalsIgnoreCase("")) {
2172 fileBuffer
.append("\r\n ");
2174 fileBuffer
.append(",\r\n ");
2176 fileBuffer
.append(this.exitBootServiceList
.get(i
));
2179 fileBuffer
.append(",\r\n NULL");
2180 fileBuffer
.append("\r\n};\r\n\r\n");