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");
1513 switch (CommonDefinition
.getModuleType(moduleType
)) {
1514 case CommonDefinition
.ModuleTypeBase
:
1515 fileBuffer
.append(" Status = ");
1516 fileBuffer
.append(libInstanceList
.get(i
)[0]);
1517 fileBuffer
.append("();\r\n");
1519 case CommonDefinition
.ModuleTypePeiCore
:
1520 case CommonDefinition
.ModuleTypePeim
:
1521 fileBuffer
.append(" Status = ");
1522 fileBuffer
.append(libInstanceList
.get(i
)[0]);
1523 fileBuffer
.append(" (FfsHeader, PeiServices);\r\n");
1525 case CommonDefinition
.ModuleTypeDxeCore
:
1526 case CommonDefinition
.ModuleTypeDxeDriver
:
1527 case CommonDefinition
.ModuleTypeDxeRuntimeDriver
:
1528 case CommonDefinition
.ModuleTypeDxeSmmDriver
:
1529 case CommonDefinition
.ModuleTypeDxeSalDriver
:
1530 case CommonDefinition
.ModuleTypeUefiDriver
:
1531 case CommonDefinition
.ModuleTypeUefiApplication
:
1532 fileBuffer
.append(" Status = ");
1533 fileBuffer
.append(libInstanceList
.get(i
)[0]);
1534 fileBuffer
.append(" (ImageHandle, SystemTable);\r\n");
1537 EdkLog
.log(EdkLog
.EDK_INFO
,"Autogen doesn't know how to deal with module type - " + moduleType
+ "!");
1541 fileBuffer
.append(" ASSERT_EFI_ERROR (Status);\r\n");
1543 fileBuffer
.append("}\r\n");
1547 LibDestructorToAutogenc
1549 This function writes library destructor list to AutoGen.c. The library
1550 destructor's parameter and return value depend on module type.
1552 @param libInstanceList
1553 List of library destructor name.
1557 String buffer for AutoGen.c
1560 void LibDestructorToAutogenC(List
<String
[]> libInstanceList
,
1561 String moduleType
, StringBuffer fileBuffer
) throws EdkException
{
1562 boolean isFirst
= true;
1563 for (int i
= 0; i
< libInstanceList
.size(); i
++) {
1564 if (libInstanceList
.get(i
)[1].equalsIgnoreCase(EdkDefinitions
.MODULE_TYPE_BASE
)) {
1565 fileBuffer
.append("RETURN_STATUS\r\n");
1566 fileBuffer
.append("EFIAPI\r\n");
1567 fileBuffer
.append(libInstanceList
.get(i
)[0]);
1568 fileBuffer
.append(" (\r\n");
1569 fileBuffer
.append(" VOID\r\n");
1570 fileBuffer
.append(" );\r\n");
1572 switch (CommonDefinition
.getModuleType(moduleType
)) {
1573 case CommonDefinition
.ModuleTypeBase
:
1574 fileBuffer
.append("RETURN_STATUS\r\n");
1575 fileBuffer
.append("EFIAPI\r\n");
1576 fileBuffer
.append(libInstanceList
.get(i
)[0]);
1577 fileBuffer
.append(" (\r\n");
1578 fileBuffer
.append(" VOID\r\n");
1579 fileBuffer
.append(" );\r\n");
1581 case CommonDefinition
.ModuleTypePeiCore
:
1582 case CommonDefinition
.ModuleTypePeim
:
1583 fileBuffer
.append("EFI_STATUS\r\n");
1584 fileBuffer
.append("EFIAPI\r\n");
1585 fileBuffer
.append(libInstanceList
.get(i
)[0]);
1586 fileBuffer
.append(" (\r\n");
1588 .append(" IN EFI_FFS_FILE_HEADER *FfsHeader,\r\n");
1590 .append(" IN EFI_PEI_SERVICES **PeiServices\r\n");
1591 fileBuffer
.append(" );\r\n");
1593 case CommonDefinition
.ModuleTypeDxeCore
:
1594 case CommonDefinition
.ModuleTypeDxeDriver
:
1595 case CommonDefinition
.ModuleTypeDxeRuntimeDriver
:
1596 case CommonDefinition
.ModuleTypeDxeSmmDriver
:
1597 case CommonDefinition
.ModuleTypeDxeSalDriver
:
1598 case CommonDefinition
.ModuleTypeUefiDriver
:
1599 case CommonDefinition
.ModuleTypeUefiApplication
:
1600 fileBuffer
.append("EFI_STATUS\r\n");
1601 fileBuffer
.append("EFIAPI\r\n");
1602 fileBuffer
.append(libInstanceList
.get(i
)[0]);
1603 fileBuffer
.append(" (\r\n");
1604 fileBuffer
.append(" IN EFI_HANDLE ImageHandle,\r\n");
1605 fileBuffer
.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");
1606 fileBuffer
.append(" );\r\n");
1613 // Write ProcessLibraryDestructor list to autogen.c
1615 switch (CommonDefinition
.getModuleType(moduleType
)) {
1616 case CommonDefinition
.ModuleTypeBase
:
1617 case CommonDefinition
.ModuleTypePeiCore
:
1618 case CommonDefinition
.ModuleTypePeim
:
1620 case CommonDefinition
.ModuleTypeDxeCore
:
1621 case CommonDefinition
.ModuleTypeDxeDriver
:
1622 case CommonDefinition
.ModuleTypeDxeRuntimeDriver
:
1623 case CommonDefinition
.ModuleTypeDxeSmmDriver
:
1624 case CommonDefinition
.ModuleTypeDxeSalDriver
:
1625 case CommonDefinition
.ModuleTypeUefiDriver
:
1626 case CommonDefinition
.ModuleTypeUefiApplication
:
1627 fileBuffer
.append("VOID\r\n");
1628 fileBuffer
.append("EFIAPI\r\n");
1629 fileBuffer
.append("ProcessLibraryDestructorList (\r\n");
1630 fileBuffer
.append(" IN EFI_HANDLE ImageHandle,\r\n");
1631 fileBuffer
.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");
1632 fileBuffer
.append(" )\r\n");
1633 fileBuffer
.append("{\r\n");
1635 // If no library destructor function, return EFI_SUCCESS.
1638 for (int i
= 0; i
< libInstanceList
.size(); i
++) {
1640 fileBuffer
.append(" EFI_STATUS Status;\r\n");
1641 fileBuffer
.append(" Status = EFI_SUCCESS;\r\n");
1642 fileBuffer
.append("\r\n");
1645 if (libInstanceList
.get(i
)[1].equalsIgnoreCase(EdkDefinitions
.MODULE_TYPE_BASE
)) {
1646 fileBuffer
.append(" Status = ");
1647 fileBuffer
.append(libInstanceList
.get(i
)[0]);
1648 fileBuffer
.append("();\r\n");
1649 fileBuffer
.append(" VOID\r\n");
1651 fileBuffer
.append(" Status = ");
1652 fileBuffer
.append(libInstanceList
.get(i
)[0]);
1653 fileBuffer
.append("(ImageHandle, SystemTable);\r\n");
1654 fileBuffer
.append(" ASSERT_EFI_ERROR (Status);\r\n");
1657 fileBuffer
.append("}\r\n");
1663 ExternsDriverBindingToAutoGenC
1665 This function is to write DRIVER_BINDING, COMPONENT_NAME,
1666 DRIVER_CONFIGURATION, DRIVER_DIAGNOSTIC in AutoGen.c.
1669 String buffer for AutoGen.c
1671 void ExternsDriverBindingToAutoGenC(StringBuffer fileBuffer
)
1672 throws EdkException
{
1675 // Get the arry of extern. The driverBindingGroup is a 2 dimension array.
1676 // The second dimension is include following element: DriverBinding,
1677 // ComponentName, DriverConfiguration, DriverDiag;
1679 String
[][] driverBindingGroup
= this.saq
.getExternProtocolGroup();
1687 // Write driver binding protocol extern to autogen.c
1689 for (int i
= 0; i
< driverBindingGroup
.length
; i
++) {
1690 if (driverBindingGroup
[i
][0] != null) {
1691 fileBuffer
.append("extern EFI_DRIVER_BINDING_PROTOCOL ");
1692 fileBuffer
.append(driverBindingGroup
[i
][0]);
1693 fileBuffer
.append(";\r\n");
1698 // Write component name protocol extern to autogen.c
1700 for (int i
= 0; i
< driverBindingGroup
.length
; i
++) {
1701 if (driverBindingGroup
[i
][1]!= null) {
1702 if (driverBindingGroup
[i
][0] != null) {
1704 fileBuffer
.append("extern EFI_COMPONENT_NAME_PROTOCOL ");
1705 fileBuffer
.append(driverBindingGroup
[i
][1]);
1706 fileBuffer
.append(";\r\n");
1708 throw new AutoGenException("DriverBinding can't be empty!!");
1714 // Write driver configration protocol extern to autogen.c
1716 for (int i
= 0; i
< driverBindingGroup
.length
; i
++) {
1717 if (driverBindingGroup
[i
][2] != null) {
1718 if (driverBindingGroup
[i
][0] != null) {
1720 fileBuffer
.append("extern EFI_DRIVER_CONFIGURATION_PROTOCOL ");
1721 fileBuffer
.append(driverBindingGroup
[i
][2]);
1722 fileBuffer
.append(";\r\n");
1724 throw new AutoGenException("DriverBinding can't be empty!!");
1730 // Write driver dignastic protocol extern to autogen.c
1732 for (int i
= 0; i
< driverBindingGroup
.length
; i
++) {
1733 if (driverBindingGroup
[i
][3] != null) {
1734 if (driverBindingGroup
[i
][0] != null) {
1736 fileBuffer
.append("extern EFI_DRIVER_DIAGNOSTICS_PROTOCOL ");
1737 fileBuffer
.append(driverBindingGroup
[i
][3]);
1738 fileBuffer
.append(";\r\n");
1740 throw new AutoGenException("DriverBinding can't be empty!!");
1746 // Write driver module protocol bitmask.
1749 .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gDriverModelProtocolBitmask = ");
1750 fileBuffer
.append(Integer
.toString(BitMask
));
1751 fileBuffer
.append(";\r\n");
1754 // Write driver module protocol list entry
1757 .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINTN _gDriverModelProtocolListEntries = ");
1759 fileBuffer
.append(Integer
.toString(driverBindingGroup
.length
));
1760 fileBuffer
.append(";\r\n");
1763 // Write drive module protocol list to autogen.c
1765 if (driverBindingGroup
.length
> 0) {
1767 .append("GLOBAL_REMOVE_IF_UNREFERENCED const EFI_DRIVER_MODEL_PROTOCOL_LIST _gDriverModelProtocolList[] = {");
1771 for (int i
= 0; i
< driverBindingGroup
.length
; i
++) {
1773 fileBuffer
.append(",");
1776 fileBuffer
.append("\r\n {\r\n");
1777 fileBuffer
.append(" &");
1778 fileBuffer
.append(driverBindingGroup
[i
][0]);
1779 fileBuffer
.append(", \r\n");
1782 if (driverBindingGroup
[i
][1] != null) {
1783 fileBuffer
.append(" &");
1784 fileBuffer
.append(driverBindingGroup
[i
][1]);
1785 fileBuffer
.append(", \r\n");
1787 fileBuffer
.append(" NULL, \r\n");
1790 if (driverBindingGroup
[i
][2] != null) {
1791 fileBuffer
.append(" &");
1792 fileBuffer
.append(driverBindingGroup
[i
][2]);
1793 fileBuffer
.append(", \r\n");
1795 fileBuffer
.append(" NULL, \r\n");
1798 if (driverBindingGroup
[i
][3] != null) {
1799 fileBuffer
.append(" &");
1800 fileBuffer
.append(driverBindingGroup
[i
][3]);
1801 fileBuffer
.append(", \r\n");
1803 fileBuffer
.append(" NULL, \r\n");
1805 fileBuffer
.append(" }");
1808 if (driverBindingGroup
.length
> 0) {
1809 fileBuffer
.append("\r\n};\r\n");
1814 ExternCallBackToAutoGenC
1816 This function adds <SetVirtualAddressMapCallBack> and
1817 <ExitBootServicesCallBack> infomation to AutoGen.c
1820 String buffer for AutoGen.c
1821 @throws BuildException
1823 void ExternCallBackToAutoGenC(StringBuffer fileBuffer
)
1824 throws EdkException
{
1826 // Collect module's <SetVirtualAddressMapCallBack> and
1827 // <ExitBootServiceCallBack> and add to setVirtualAddList
1828 // exitBootServiceList.
1830 String
[] setVirtuals
= saq
.getSetVirtualAddressMapCallBackArray();
1831 String
[] exitBoots
= saq
.getExitBootServicesCallBackArray();
1832 if (setVirtuals
!= null) {
1833 for (int j
= 0; j
< setVirtuals
.length
; j
++) {
1834 this.setVirtalAddList
.add(setVirtuals
[j
]);
1837 if (exitBoots
!= null) {
1838 for (int k
= 0; k
< exitBoots
.length
; k
++) {
1839 this.exitBootServiceList
.add(exitBoots
[k
]);
1843 // Add c code in autogen.c which relate to <SetVirtualAddressMapCallBack>
1844 // and <ExitBootServicesCallBack>
1846 String moduleType
= this.moduleId
.getModuleType();
1847 switch (CommonDefinition
.getModuleType(moduleType
)) {
1848 case CommonDefinition
.ModuleTypeDxeDriver
:
1849 case CommonDefinition
.ModuleTypeDxeRuntimeDriver
:
1850 case CommonDefinition
.ModuleTypeDxeSalDriver
:
1851 case CommonDefinition
.ModuleTypeUefiDriver
:
1852 case CommonDefinition
.ModuleTypeUefiApplication
:
1854 // If moduleType is one of above, call setVirtualAddressToAutogenC,
1855 // and setExitBootServiceToAutogenC.
1857 setVirtualAddressToAutogenC(fileBuffer
);
1858 setExitBootServiceToAutogenC(fileBuffer
);
1866 copyFlashMapHToDebugDir
1868 This function is to copy the falshmap.h to debug directory and change
1869 its name to TianoR8FlashMap.h
1874 private void copyFlashMapHToDebugDir() throws AutoGenException
{
1876 File inFile
= new File(fvDir
+ File
.separatorChar
+ CommonDefinition
.FLASHMAPH
);
1877 int size
= (int)inFile
.length();
1878 byte[] buffer
= new byte[size
];
1879 File outFile
= new File (this.outputPath
+ File
.separatorChar
+ CommonDefinition
.TIANOR8PLASHMAPH
);
1881 // If TianoR8FlashMap.h existed and the flashMap.h don't change,
1884 if ((!outFile
.exists()) ||(inFile
.lastModified() - outFile
.lastModified()) >= 0) {
1885 if (inFile
.exists()) {
1887 FileInputStream fis
= new FileInputStream (inFile
);
1889 FileOutputStream fos
= new FileOutputStream(outFile
);
1893 } catch (IOException e
){
1894 throw new AutoGenException("The file, flashMap.h can't be open!");
1898 throw new AutoGenException("The file, flashMap.h doesn't exist!");
1904 This function first order the library instances, then collect
1905 library instance 's PPI, Protocol, GUID,
1906 SetVirtalAddressMapCallBack, ExitBootServiceCallBack, and
1907 Destructor, Constructor.
1912 private void collectLibInstanceInfo() throws EdkException
{
1915 String libConstructName
= null;
1916 String libDestructName
= null;
1917 String libModuleType
= null;
1918 String
[] setVirtuals
= null;
1919 String
[] exitBoots
= null;
1921 ModuleIdentification
[] libraryIdList
= saq
.getLibraryInstance(this.arch
);
1923 if (libraryIdList
!= null) {
1925 // Reorder library instance sequence.
1927 AutogenLibOrder libOrder
= new AutogenLibOrder(libraryIdList
,
1929 List
<ModuleIdentification
> orderList
= libOrder
1930 .orderLibInstance();
1932 if (orderList
!= null) {
1934 // Process library instance one by one.
1936 for (int i
= 0; i
< orderList
.size(); i
++) {
1939 // Get library instance basename.
1941 ModuleIdentification libInstanceId
= orderList
.get(i
);
1947 Map
<String
, XmlObject
> libDoc
= GlobalData
.getDoc(libInstanceId
, this.arch
);
1950 // Get <PPis>, <Protocols>, <Guids> list of this library
1953 String
[] ppiList
= saq
.getPpiArray(this.arch
);
1954 String
[] ppiNotifyList
= saq
.getPpiNotifyArray(this.arch
);
1955 String
[] protocolList
= saq
.getProtocolArray(this.arch
);
1956 String
[] protocolNotifyList
= saq
.getProtocolNotifyArray(this.arch
);
1957 String
[] guidList
= saq
.getGuidEntryArray(this.arch
);
1958 PackageIdentification
[] pkgList
= saq
.getDependencePkg(this.arch
);
1961 // Add those ppi, protocol, guid in global ppi,
1965 for (index
= 0; index
< ppiList
.length
; index
++) {
1966 this.mPpiList
.add(ppiList
[index
]);
1969 for (index
= 0; index
< ppiNotifyList
.length
; index
++) {
1970 this.mPpiList
.add(ppiNotifyList
[index
]);
1973 for (index
= 0; index
< protocolList
.length
; index
++) {
1974 this.mProtocolList
.add(protocolList
[index
]);
1977 for (index
= 0; index
< protocolNotifyList
.length
; index
++) {
1978 this.mProtocolList
.add(protocolNotifyList
[index
]);
1981 for (index
= 0; index
< guidList
.length
; index
++) {
1982 this.mGuidList
.add(guidList
[index
]);
1984 for (index
= 0; index
< pkgList
.length
; index
++) {
1985 if (!this.mDepPkgList
.contains(pkgList
[index
])) {
1986 this.mDepPkgList
.add(pkgList
[index
]);
1991 // If not yet parse this library instance's constructor
1992 // element,parse it.
1994 libConstructName
= saq
.getLibConstructorName();
1995 libDestructName
= saq
.getLibDestructorName();
1996 libModuleType
= saq
.getModuleType();
1999 // Collect SetVirtualAddressMapCallBack and
2000 // ExitBootServiceCallBack.
2002 setVirtuals
= saq
.getSetVirtualAddressMapCallBackArray();
2003 exitBoots
= saq
.getExitBootServicesCallBackArray();
2004 if (setVirtuals
!= null) {
2005 for (int j
= 0; j
< setVirtuals
.length
; j
++) {
2006 this.setVirtalAddList
.add(setVirtuals
[j
]);
2009 if (exitBoots
!= null) {
2010 for (int k
= 0; k
< exitBoots
.length
; k
++) {
2011 this.exitBootServiceList
.add(exitBoots
[k
]);
2016 // Add dependent library instance constructor function.
2018 if (libConstructName
!= null) {
2019 this.libConstructList
.add(new String
[] {libConstructName
, libModuleType
});
2022 // Add dependent library instance destructor fuction.
2024 if (libDestructName
!= null) {
2025 this.libDestructList
.add(new String
[] {libDestructName
, libModuleType
});
2032 private void setVirtualAddressToAutogenC(StringBuffer fileBuffer
){
2034 // Entry point lib for these module types needs to know the count
2038 .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED const UINTN _gDriverSetVirtualAddressMapEventCount = ");
2041 // If the list is not valid or has no entries set count to zero else
2042 // set count to the number of valid entries
2046 if (this.setVirtalAddList
!= null) {
2047 for (i
= 0; i
< this.setVirtalAddList
.size(); i
++) {
2048 if (this.setVirtalAddList
.get(i
).equalsIgnoreCase("")) {
2055 fileBuffer
.append(Integer
.toString(Count
));
2056 fileBuffer
.append(";\r\n\r\n");
2057 if (this.setVirtalAddList
== null || this.setVirtalAddList
.size() == 0) {
2059 // No data so make a NULL list
2062 .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED const EFI_EVENT_NOTIFY _gDriverSetVirtualAddressMapEvent[] = {\r\n");
2063 fileBuffer
.append(" NULL\r\n");
2064 fileBuffer
.append("};\r\n\r\n");
2067 // Write SetVirtualAddressMap function definition.
2069 for (i
= 0; i
< this.setVirtalAddList
.size(); i
++) {
2070 if (this.setVirtalAddList
.get(i
).equalsIgnoreCase("")) {
2073 fileBuffer
.append("VOID\r\n");
2074 fileBuffer
.append("EFIAPI\r\n");
2075 fileBuffer
.append(this.setVirtalAddList
.get(i
));
2076 fileBuffer
.append(" (\r\n");
2077 fileBuffer
.append(" IN EFI_EVENT Event,\r\n");
2078 fileBuffer
.append(" IN VOID *Context\r\n");
2079 fileBuffer
.append(" );\r\n\r\n");
2083 // Write SetVirtualAddressMap entry point array.
2086 .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED const EFI_EVENT_NOTIFY _gDriverSetVirtualAddressMapEvent[] = {");
2087 for (i
= 0; i
< this.setVirtalAddList
.size(); i
++) {
2088 if (this.setVirtalAddList
.get(i
).equalsIgnoreCase("")) {
2093 fileBuffer
.append("\r\n ");
2095 fileBuffer
.append(",\r\n ");
2098 fileBuffer
.append(this.setVirtalAddList
.get(i
));
2101 // add the NULL at the end of _gDriverSetVirtualAddressMapEvent list.
2103 fileBuffer
.append(",\r\n NULL");
2104 fileBuffer
.append("\r\n};\r\n\r\n");
2109 private void setExitBootServiceToAutogenC(StringBuffer fileBuffer
){
2111 // Entry point lib for these module types needs to know the count.
2114 .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED const UINTN _gDriverExitBootServicesEventCount = ");
2117 // If the list is not valid or has no entries set count to zero else
2118 // set count to the number of valid entries.
2122 if (this.exitBootServiceList
!= null) {
2123 for (i
= 0; i
< this.exitBootServiceList
.size(); i
++) {
2124 if (this.exitBootServiceList
.get(i
).equalsIgnoreCase("")) {
2130 fileBuffer
.append(Integer
.toString(Count
));
2131 fileBuffer
.append(";\r\n\r\n");
2133 if (this.exitBootServiceList
== null || this.exitBootServiceList
.size() == 0) {
2135 // No data so make a NULL list.
2138 .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED const EFI_EVENT_NOTIFY _gDriverExitBootServicesEvent[] = {\r\n");
2139 fileBuffer
.append(" NULL\r\n");
2140 fileBuffer
.append("};\r\n\r\n");
2143 // Write DriverExitBootServices function definition.
2145 for (i
= 0; i
< this.exitBootServiceList
.size(); i
++) {
2146 if (this.exitBootServiceList
.get(i
).equalsIgnoreCase("")) {
2150 fileBuffer
.append("VOID\r\n");
2151 fileBuffer
.append("EFIAPI\r\n");
2152 fileBuffer
.append(this.exitBootServiceList
.get(i
));
2153 fileBuffer
.append(" (\r\n");
2154 fileBuffer
.append(" IN EFI_EVENT Event,\r\n");
2155 fileBuffer
.append(" IN VOID *Context\r\n");
2156 fileBuffer
.append(" );\r\n\r\n");
2160 // Write DriverExitBootServices entry point array.
2163 .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED const EFI_EVENT_NOTIFY _gDriverExitBootServicesEvent[] = {");
2164 for (i
= 0; i
< this.exitBootServiceList
.size(); i
++) {
2165 if (this.exitBootServiceList
.get(i
).equalsIgnoreCase("")) {
2170 fileBuffer
.append("\r\n ");
2172 fileBuffer
.append(",\r\n ");
2174 fileBuffer
.append(this.exitBootServiceList
.get(i
));
2177 fileBuffer
.append(",\r\n NULL");
2178 fileBuffer
.append("\r\n};\r\n\r\n");