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
.*;
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
.logger
.EdkLog
;
44 import org
.tianocore
.common
.definitions
.ToolDefinitions
;
47 This class is to generate Autogen.h and Autogen.c according to module surface
48 area or library surface area.
50 public class AutoGen
{
52 /// The output path of Autogen.h and Autogen.c
54 private String outputPath
;
57 /// The name of FV directory
62 /// The base name of module or library.
64 private ModuleIdentification moduleId
;
67 /// The build architecture
72 /// PcdAutogen instance which is used to manage how to generate the PCD
75 private PCDAutoGenAction myPcdAutogen
;
78 /// the one of type : NOT_PCD_DRIVER, PEI_PCD_DRIVER, DXE_PCD_DRIVER
80 private CommonDefinition
.PCD_DRIVER_TYPE pcdDriverType
;
83 /// The protocl list which records in module or library surface area and
84 /// it's dependence on library instance surface area.
86 private Set
<String
> mProtocolList
= new HashSet
<String
>();
89 /// The Ppi list which recorded in module or library surface area and its
90 /// dependency on library instance surface area.
92 private Set
<String
> mPpiList
= new HashSet
<String
>();
95 /// The Guid list which recoreded in module or library surface area and it's
96 /// dependence on library instance surface area.
98 private Set
<String
> mGuidList
= new HashSet
<String
>();
101 /// The dependence package list which recoreded in module or library surface
102 /// area and it's dependence on library instance surface area.
104 private List
<PackageIdentification
> mDepPkgList
= new LinkedList
<PackageIdentification
>();
107 /// For non library module, add its library instance's construct and destructor to
110 private List
<String
> libConstructList
= new ArrayList
<String
>();
111 private List
<String
> libDestructList
= new ArrayList
<String
>();
114 /// List to store SetVirtalAddressMapCallBack, ExitBootServiceCallBack
116 private List
<String
> setVirtalAddList
= new ArrayList
<String
>();
117 private List
<String
> exitBootServiceList
= new ArrayList
<String
>();
123 This function mainly initialize some member variable.
126 Absolute path of FV directory.
128 Output path of AutoGen file.
130 Module identification.
134 public AutoGen(String fvDir
, String outputPath
, ModuleIdentification moduleId
, String arch
) {
135 this.outputPath
= outputPath
;
136 this.moduleId
= moduleId
;
145 This function save the content in stringBuffer to file.
150 The content of AutoGen file in buffer.
155 private boolean saveFile(String fileName
, StringBuffer fileBuffer
) {
157 File autoGenH
= new File(fileName
);
160 // if the file exists, compare their content
162 if (autoGenH
.exists()) {
163 char[] oldFileBuffer
= new char[(int) autoGenH
.length()];
165 FileReader fIn
= new FileReader(autoGenH
);
166 fIn
.read(oldFileBuffer
, 0, (int) autoGenH
.length());
168 } catch (IOException e
) {
169 EdkLog
.log(EdkLog
.EDK_INFO
, this.moduleId
.getName()
172 + " is exist, but can't be open!!");
177 // if we got the same file, don't re-generate it to prevent
178 // sources depending on it from re-building
180 if (fileBuffer
.toString().compareTo(new String(oldFileBuffer
)) == 0) {
186 FileWriter fOut
= new FileWriter(autoGenH
);
187 fOut
.write(fileBuffer
.toString());
190 } catch (IOException e
) {
191 EdkLog
.log(EdkLog
.EDK_INFO
, this.moduleId
.getName()
194 + " can't be create!!");
203 This function call libGenAutoGen or moduleGenAutogen function, which
204 dependence on generate library autogen or module autogen.
206 @throws BuildException
207 Failed to creat AutoGen.c & AutoGen.h.
209 public void genAutogen() throws BuildException
{
212 // If outputPath do not exist, create it.
214 File path
= new File(outputPath
);
218 // Check current is library or not, then call the corresponding
221 if (this.moduleId
.isLibrary()) {
227 } catch (Exception e
) {
228 throw new BuildException(
229 "Failed to create AutoGen.c & AutoGen.h!\n"
235 moduleGenAutogen function
237 This function generates AutoGen.c & AutoGen.h for module.
239 @throws BuildException
240 Faile to create module AutoGen.c & AutoGen.h.
242 void moduleGenAutogen() throws BuildException
{
245 collectLibInstanceInfo();
248 } catch (Exception e
) {
249 throw new BuildException(
250 "Faile to create module AutoGen.c & AutoGen.h!\n"
256 libGenAutogen function
258 This function generates AutoGen.c & AutoGen.h for library.
260 @throws BuildException
261 Faile to create library AutoGen.c & AutoGen.h
263 void libGenAutogen() throws BuildException
{
267 } catch (Exception e
) {
268 throw new BuildException(
269 "Failed to create library AutoGen.c & AutoGen.h!\n"
277 This function generates AutoGen.h for module.
279 @throws BuildException
280 Failed to generate AutoGen.h.
282 void moduleGenAutogenH() throws AutoGenException
{
284 Set
<String
> libClassIncludeH
;
286 // List<String> headerFileList;
287 List
<String
> headerFileList
;
289 StringBuffer fileBuffer
= new StringBuffer(8192);
292 // Write Autogen.h header notation
294 fileBuffer
.append(CommonDefinition
.AUTOGENHNOTATION
);
297 // Add #ifndef ${BaseName}_AUTOGENH
298 // #def ${BseeName}_AUTOGENH
300 fileBuffer
.append(CommonDefinition
.IFNDEF
301 + CommonDefinition
.AUTOGENH
302 + this.moduleId
.getGuid().replaceAll("-", "_")
303 + ToolDefinitions
.LINE_SEPARATOR
);
304 fileBuffer
.append(CommonDefinition
.DEFINE
305 + CommonDefinition
.AUTOGENH
306 + this.moduleId
.getGuid().replaceAll("-", "_")
307 + ToolDefinitions
.LINE_SEPARATOR
308 + ToolDefinitions
.LINE_SEPARATOR
);
311 // Write the specification version and release version at the begine
312 // of autogen.h file.
313 // Note: the specification version and release version should
314 // be got from module surface area instead of hard code by it's
317 moduleType
= SurfaceAreaQuery
.getModuleType();
320 // Add "extern int __make_me_compile_correctly;" at begin of
323 fileBuffer
.append(CommonDefinition
.AUTOGENHBEGIN
);
326 // Put EFI_SPECIFICATION_VERSION, and EDK_RELEASE_VERSION.
328 String
[] specList
= SurfaceAreaQuery
.getExternSpecificaiton();
329 for (int i
= 0; i
< specList
.length
; i
++) {
330 fileBuffer
.append(CommonDefinition
.DEFINE
+ specList
[i
]
334 // Write consumed package's mdouleInfo related .h file to autogen.h
336 // PackageIdentification[] consumedPkgIdList = SurfaceAreaQuery
337 // .getDependencePkg(this.arch);
338 PackageIdentification
[] consumedPkgIdList
= SurfaceAreaQuery
339 .getDependencePkg(this.arch
);
340 if (consumedPkgIdList
!= null) {
341 headerFileList
= depPkgToAutogenH(consumedPkgIdList
, moduleType
);
342 item
= headerFileList
.iterator();
343 while (item
.hasNext()) {
344 fileBuffer
.append(item
.next().toString());
349 // Write library class's related *.h file to autogen.h.
351 String
[] libClassList
= SurfaceAreaQuery
352 .getLibraryClasses(CommonDefinition
.ALWAYSCONSUMED
,this.arch
);
353 if (libClassList
!= null) {
354 libClassIncludeH
= LibraryClassToAutogenH(libClassList
);
355 item
= libClassIncludeH
.iterator();
356 while (item
.hasNext()) {
357 fileBuffer
.append(item
.next().toString());
361 libClassList
= SurfaceAreaQuery
362 .getLibraryClasses(CommonDefinition
.ALWAYSPRODUCED
, this.arch
);
363 if (libClassList
!= null) {
364 libClassIncludeH
= LibraryClassToAutogenH(libClassList
);
365 item
= libClassIncludeH
.iterator();
366 while (item
.hasNext()) {
367 fileBuffer
.append(item
.next().toString());
370 fileBuffer
.append("\r\n");
373 // If is TianoR8FlashMap, copy {Fv_DIR}/FlashMap.h to
374 // {DEST_DIR_DRBUG}/FlashMap.h
376 if (SurfaceAreaQuery
.isHaveTianoR8FlashMap()) {
377 fileBuffer
.append(CommonDefinition
.INCLUDE
);
378 fileBuffer
.append(" <");
379 fileBuffer
.append(CommonDefinition
.TIANOR8PLASHMAPH
+ ">\r\n");
380 copyFlashMapHToDebugDir();
383 // Write PCD autogen information to AutoGen.h.
385 if (this.myPcdAutogen
!= null) {
386 fileBuffer
.append("\r\n");
387 fileBuffer
.append(this.myPcdAutogen
.getHAutoGenString());
391 // Append the #endif at AutoGen.h
393 fileBuffer
.append("#endif\r\n");
396 // Save string buffer content in AutoGen.h.
398 if (!saveFile(outputPath
+ File
.separatorChar
+ "AutoGen.h", fileBuffer
)) {
399 throw new BuildException("Failed to generate AutoGen.h !!!");
406 This function generates AutoGen.c for module.
408 @throws BuildException
409 Failed to generate AutoGen.c.
411 void moduleGenAutogenC() throws AutoGenException
{
413 StringBuffer fileBuffer
= new StringBuffer(8192);
415 // Write Autogen.c header notation
417 fileBuffer
.append(CommonDefinition
.AUTOGENCNOTATION
);
420 // Write #include <AutoGen.h> at beginning of AutoGen.c
422 fileBuffer
.append(CommonDefinition
.INCLUDEAUTOGENH
);
425 // Get the native MSA file infomation. Since before call autogen,
426 // the MSA native <Externs> information were overrided. So before
427 // process <Externs> it should be set the DOC as the Native MSA info.
429 Map
<String
, XmlObject
> doc
= GlobalData
.getNativeMsa(this.moduleId
);
430 SurfaceAreaQuery
.push(doc
);
433 // DriverBinding/ComponentName/DriverConfiguration/DriverDialog
437 ExternsDriverBindingToAutoGenC(fileBuffer
);
440 // Write DriverExitBootServicesEvent/DriverSetVirtualAddressMapEvent
443 ExternCallBackToAutoGenC(fileBuffer
);
446 // Write EntryPoint to autgoGen.c
448 String
[] entryPointList
= SurfaceAreaQuery
.getModuleEntryPointArray();
449 String
[] unloadImageList
= SurfaceAreaQuery
.getModuleUnloadImageArray();
450 EntryPointToAutoGen(CommonDefinition
.remDupString(entryPointList
),
451 CommonDefinition
.remDupString(unloadImageList
),
454 pcdDriverType
= SurfaceAreaQuery
.getPcdDriverType();
457 // Restore the DOC which include the FPD module info.
459 SurfaceAreaQuery
.pop();
462 // Write Guid to autogen.c
464 String guid
= CommonDefinition
.formatGuidName(SurfaceAreaQuery
468 .append("GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiCallerIdGuid = {");
470 throw new AutoGenException("Guid value must set!\n");
474 // Formate Guid as ANSI c form.Example:
475 // {0xd2b2b828, 0x826, 0x48a7,{0xb3, 0xdf, 0x98, 0x3c, 0x0, 0x60, 0x24,
479 fileBuffer
.append(guid
);
480 fileBuffer
.append("};\r\n");
483 // Generate library instance consumed protocol, guid, ppi, pcd list.
484 // Save those to this.protocolList, this.ppiList, this.pcdList,
485 // this.guidList. Write Consumed library constructor and desconstuct to
488 LibInstanceToAutogenC(fileBuffer
);
491 // Get module dependent Package identification.
493 PackageIdentification
[] packages
= SurfaceAreaQuery
.getDependencePkg(this.arch
);
494 for (int i
= 0; i
< packages
.length
; i
++) {
495 if (!this.mDepPkgList
.contains(packages
[i
])) {
496 this.mDepPkgList
.add(packages
[i
]);
502 // Write consumed ppi, guid, protocol to autogen.c
504 ProtocolGuidToAutogenC(fileBuffer
);
505 PpiGuidToAutogenC(fileBuffer
);
506 GuidGuidToAutogenC(fileBuffer
);
511 this.myPcdAutogen
= new PCDAutoGenAction(moduleId
,
517 this.myPcdAutogen
.execute();
518 } catch (Exception exp
) {
519 throw new PcdAutogenException (exp
.getMessage());
522 if (this.myPcdAutogen
!= null) {
523 fileBuffer
.append("\r\n");
524 fileBuffer
.append(this.myPcdAutogen
.getCAutoGenString());
527 if (!saveFile(outputPath
+ File
.separatorChar
+ "AutoGen.c", fileBuffer
)) {
528 throw new BuildException("Failed to generate AutoGen.c !!!");
536 This function generates AutoGen.h for library.
538 @throws BuildException
539 Failed to generate AutoGen.c.
541 void libGenAutogenH() throws AutoGenException
{
543 Set
<String
> libClassIncludeH
;
545 List
<String
> headerFileList
;
547 StringBuffer fileBuffer
= new StringBuffer(10240);
550 // Write Autogen.h header notation
552 fileBuffer
.append(CommonDefinition
.AUTOGENHNOTATION
);
555 // Add #ifndef ${BaseName}_AUTOGENH
556 // #def ${BseeName}_AUTOGENH
558 fileBuffer
.append(CommonDefinition
.IFNDEF
559 + CommonDefinition
.AUTOGENH
560 + this.moduleId
.getGuid().replaceAll("-", "_")
561 + ToolDefinitions
.LINE_SEPARATOR
);
562 fileBuffer
.append(CommonDefinition
.DEFINE
563 + CommonDefinition
.AUTOGENH
564 + this.moduleId
.getGuid().replaceAll("-", "_")
565 + ToolDefinitions
.LINE_SEPARATOR
566 + ToolDefinitions
.LINE_SEPARATOR
);
569 // Write EFI_SPECIFICATION_VERSION and EDK_RELEASE_VERSION
570 // to autogen.h file.
571 // Note: the specification version and release version should
572 // be get from module surface area instead of hard code.
574 fileBuffer
.append(CommonDefinition
.AUTOGENHBEGIN
);
575 String
[] specList
= SurfaceAreaQuery
.getExternSpecificaiton();
576 for (int i
= 0; i
< specList
.length
; i
++) {
577 fileBuffer
.append(CommonDefinition
.DEFINE
+ specList
[i
]
580 // fileBuffer.append(CommonDefinition.autoGenHLine1);
581 // fileBuffer.append(CommonDefinition.autoGenHLine2);
584 // Write consumed package's mdouleInfo related *.h file to autogen.h.
586 moduleType
= SurfaceAreaQuery
.getModuleType();
587 PackageIdentification
[] cosumedPkglist
= SurfaceAreaQuery
588 .getDependencePkg(this.arch
);
589 headerFileList
= depPkgToAutogenH(cosumedPkglist
, moduleType
);
590 item
= headerFileList
.iterator();
591 while (item
.hasNext()) {
592 fileBuffer
.append(item
.next().toString());
595 // Write library class's related *.h file to autogen.h
597 String
[] libClassList
= SurfaceAreaQuery
598 .getLibraryClasses(CommonDefinition
.ALWAYSCONSUMED
, this.arch
);
599 if (libClassList
!= null) {
600 libClassIncludeH
= LibraryClassToAutogenH(libClassList
);
601 item
= libClassIncludeH
.iterator();
602 while (item
.hasNext()) {
603 fileBuffer
.append(item
.next().toString());
607 libClassList
= SurfaceAreaQuery
608 .getLibraryClasses(CommonDefinition
.ALWAYSPRODUCED
, this.arch
);
609 if (libClassList
!= null) {
610 libClassIncludeH
= LibraryClassToAutogenH(libClassList
);
611 item
= libClassIncludeH
.iterator();
612 while (item
.hasNext()) {
613 fileBuffer
.append(item
.next().toString());
616 fileBuffer
.append(ToolDefinitions
.LINE_SEPARATOR
);
619 // If is TianoR8FlashMap, copy {Fv_DIR}/FlashMap.h to
620 // {DEST_DIR_DRBUG}/FlashMap.h
622 if (SurfaceAreaQuery
.isHaveTianoR8FlashMap()) {
623 fileBuffer
.append(CommonDefinition
.INCLUDE
);
624 fileBuffer
.append(" <");
625 fileBuffer
.append(CommonDefinition
.TIANOR8PLASHMAPH
+ ">\r\n");
626 copyFlashMapHToDebugDir();
630 // Write PCD information to library AutoGen.h.
632 if (this.myPcdAutogen
!= null) {
633 fileBuffer
.append("\r\n");
634 fileBuffer
.append(this.myPcdAutogen
.getHAutoGenString());
638 // Append the #endif at AutoGen.h
640 fileBuffer
.append("#endif\r\n");
643 // Save content of string buffer to AutoGen.h file.
645 if (!saveFile(outputPath
+ File
.separatorChar
+ "AutoGen.h", fileBuffer
)) {
646 throw new BuildException("Failed to generate AutoGen.h !!!");
653 This function generates AutoGen.h for library.
655 @throws BuildException
656 Failed to generate AutoGen.c.
658 void libGenAutogenC() throws BuildException
, PcdAutogenException
{
659 StringBuffer fileBuffer
= new StringBuffer(10240);
662 // Write Autogen.c header notation
664 fileBuffer
.append(CommonDefinition
.AUTOGENCNOTATION
);
666 fileBuffer
.append(ToolDefinitions
.LINE_SEPARATOR
);
667 fileBuffer
.append(ToolDefinitions
.LINE_SEPARATOR
);
672 this.myPcdAutogen
= new PCDAutoGenAction(moduleId
,
675 SurfaceAreaQuery
.getModulePcdEntryNameArray(),
678 this.myPcdAutogen
.execute();
679 } catch (Exception e
) {
680 throw new PcdAutogenException(e
.getMessage());
683 if (this.myPcdAutogen
!= null) {
684 fileBuffer
.append(ToolDefinitions
.LINE_SEPARATOR
);
685 fileBuffer
.append(this.myPcdAutogen
.getCAutoGenString());
688 if (!saveFile(outputPath
+ File
.separatorChar
+ "AutoGen.c", fileBuffer
)) {
689 throw new BuildException("Failed to generate AutoGen.c !!!");
694 LibraryClassToAutogenH
696 This function returns *.h files declared by library classes which are
697 consumed or produced by current build module or library.
700 List of library class which consumed or produce by current
701 build module or library.
702 @return includeStrList List of *.h file.
704 Set
<String
> LibraryClassToAutogenH(String
[] libClassList
)
705 throws AutoGenException
{
706 Set
<String
> includeStrList
= new LinkedHashSet
<String
>();
707 String includeName
[];
711 // Get include file from GlobalData's SPDTable according to
712 // library class name.
714 for (int i
= 0; i
< libClassList
.length
; i
++) {
715 includeName
= GlobalData
.getLibraryClassHeaderFiles(
716 SurfaceAreaQuery
.getDependencePkg(this.arch
),
718 if (includeName
== null) {
719 throw new AutoGenException("Can not find library class ["
720 + libClassList
[i
] + "] declaration in any SPD package. ");
722 for (int j
= 0; j
< includeName
.length
; j
++) {
723 String includeNameStr
= includeName
[j
];
724 if (includeNameStr
!= null) {
725 str
= CommonDefinition
.INCLUDE
+ " " + "<";
726 str
= str
+ includeNameStr
+ ">\r\n";
727 includeStrList
.add(str
);
728 includeNameStr
= null;
732 return includeStrList
;
738 This function add include file in AutoGen.h file.
740 @param packageNameList
741 List of module depended package.
746 List
<String
> depPkgToAutogenH(PackageIdentification
[] packageNameList
,
747 String moduleType
) throws AutoGenException
{
749 List
<String
> includeStrList
= new LinkedList
<String
>();
751 String includeStr
= "";
754 // Get include file from moduleInfo file
756 for (int i
= 0; i
< packageNameList
.length
; i
++) {
757 pkgHeader
= GlobalData
.getPackageHeaderFiles(packageNameList
[i
],
759 if (pkgHeader
== null) {
760 throw new AutoGenException("Can not find package ["
762 + "] declaration in any SPD package. ");
763 } else if (!pkgHeader
.equalsIgnoreCase("")) {
764 includeStr
= CommonDefinition
.INCLUDE
+ " <" + pkgHeader
766 includeStrList
.add(includeStr
);
770 return includeStrList
;
776 This function convert <ModuleEntryPoint> & <ModuleUnloadImage>
777 information in mas to AutoGen.c
779 @param entryPointList
782 String buffer fo AutoGen.c.
785 void EntryPointToAutoGen(String
[] entryPointList
, String
[] unloadImageList
, StringBuffer fileBuffer
)
786 throws BuildException
{
788 String typeStr
= SurfaceAreaQuery
.getModuleType();
789 int unloadImageCount
= 0;
790 int entryPointCount
= 0;
793 // The parameters and return value of entryPoint is difference
794 // for difference module type.
796 switch (CommonDefinition
.getModuleType(typeStr
)) {
798 case CommonDefinition
.ModuleTypePeiCore
:
799 if (entryPointList
== null ||entryPointList
.length
!= 1 ) {
800 throw new BuildException(
801 "Module type = 'PEI_CORE', can have only one module entry point!");
803 fileBuffer
.append("EFI_STATUS\r\n");
804 fileBuffer
.append("EFIAPI\r\n");
805 fileBuffer
.append(entryPointList
[0]);
806 fileBuffer
.append(" (\r\n");
808 .append(" IN EFI_PEI_STARTUP_DESCRIPTOR *PeiStartupDescriptor,\r\n");
810 .append(" IN VOID *OldCoreData\r\n");
811 fileBuffer
.append(" );\r\n\r\n");
813 fileBuffer
.append("EFI_STATUS\r\n");
814 fileBuffer
.append("EFIAPI\r\n");
815 fileBuffer
.append("ProcessModuleEntryPointList (\r\n");
817 .append(" IN EFI_PEI_STARTUP_DESCRIPTOR *PeiStartupDescriptor,\r\n");
819 .append(" IN VOID *OldCoreData\r\n");
820 fileBuffer
.append(" )\r\n\r\n");
821 fileBuffer
.append("{\r\n");
822 fileBuffer
.append(" return ");
823 fileBuffer
.append(entryPointList
[0]);
824 fileBuffer
.append(" (PeiStartupDescriptor, OldCoreData);\r\n");
825 fileBuffer
.append("}\r\n\r\n");
829 case CommonDefinition
.ModuleTypeDxeCore
:
830 fileBuffer
.append("const UINT32 _gUefiDriverRevision = 0;\r\n");
831 if (entryPointList
== null || entryPointList
.length
!= 1) {
832 throw new BuildException(
833 "Module type = 'DXE_CORE', can have only one module entry point!");
836 fileBuffer
.append("VOID\r\n");
837 fileBuffer
.append("EFIAPI\r\n");
838 fileBuffer
.append(entryPointList
[0]);
839 fileBuffer
.append(" (\n");
840 fileBuffer
.append(" IN VOID *HobStart\r\n");
841 fileBuffer
.append(" );\r\n\r\n");
843 fileBuffer
.append("VOID\r\n");
844 fileBuffer
.append("EFIAPI\r\n");
845 fileBuffer
.append("ProcessModuleEntryPointList (\r\n");
846 fileBuffer
.append(" IN VOID *HobStart\r\n");
847 fileBuffer
.append(" )\r\n\r\n");
848 fileBuffer
.append("{\r\n");
849 fileBuffer
.append(" ");
850 fileBuffer
.append(entryPointList
[0]);
851 fileBuffer
.append(" (HobStart);\r\n");
852 fileBuffer
.append("}\r\n\r\n");
856 case CommonDefinition
.ModuleTypePeim
:
859 .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT32 _gPeimRevision = 0;\r\n");
860 if (entryPointList
== null || entryPointList
.length
== 0) {
861 fileBuffer
.append("EFI_STATUS\r\n");
862 fileBuffer
.append("EFIAPI\r\n");
863 fileBuffer
.append("ProcessModuleEntryPointList (\r\n");
864 fileBuffer
.append(" IN EFI_FFS_FILE_HEADER *FfsHeader,\r\n");
865 fileBuffer
.append(" IN EFI_PEI_SERVICES **PeiServices\r\n");
866 fileBuffer
.append(" )\r\n\r\n");
867 fileBuffer
.append("{\r\n");
868 fileBuffer
.append(" return EFI_SUCCESS;\r\n");
869 fileBuffer
.append("}\r\n\r\n");
872 for (int i
= 0; i
< entryPointList
.length
; i
++) {
873 fileBuffer
.append("EFI_STATUS\r\n");
874 fileBuffer
.append("EFIAPI\r\n");
875 fileBuffer
.append(entryPointList
[i
]);
876 fileBuffer
.append(" (\r\n");
878 .append(" IN EFI_FFS_FILE_HEADER *FfsHeader,\r\n");
880 .append(" IN EFI_PEI_SERVICES **PeiServices\r\n");
881 fileBuffer
.append(" );\r\n");
886 fileBuffer
.append("EFI_STATUS\r\n");
887 fileBuffer
.append("EFIAPI\r\n");
888 fileBuffer
.append("ProcessModuleEntryPointList (\r\n");
889 fileBuffer
.append(" IN EFI_FFS_FILE_HEADER *FfsHeader,\r\n");
890 fileBuffer
.append(" IN EFI_PEI_SERVICES **PeiServices\r\n");
891 fileBuffer
.append(" )\r\n\r\n");
892 fileBuffer
.append("{\r\n");
893 if (entryPointCount
== 1) {
894 fileBuffer
.append(" return ");
895 fileBuffer
.append(entryPointList
[0]);
896 fileBuffer
.append(" (FfsHeader, PeiServices);\r\n");
898 fileBuffer
.append(" EFI_STATUS Status;\r\n");
899 fileBuffer
.append(" EFI_STATUS CombinedStatus;\r\n\r\n");
900 fileBuffer
.append(" CombinedStatus = EFI_LOAD_ERROR;\r\n\r\n");
901 for (int i
= 0; i
< entryPointList
.length
; i
++) {
902 if (!entryPointList
[i
].equals("")) {
903 fileBuffer
.append(" Status = ");
904 fileBuffer
.append(entryPointList
[i
]);
905 fileBuffer
.append(" (FfsHeader, PeiServices);\r\n");
907 .append(" if (!EFI_ERROR (Status) || EFI_ERROR (CombinedStatus)) {\r\n");
908 fileBuffer
.append(" CombinedStatus = Status;\r\n");
909 fileBuffer
.append(" }\r\n\r\n");
914 fileBuffer
.append(" return CombinedStatus;\r\n");
916 fileBuffer
.append("}\r\n\r\n");
919 case CommonDefinition
.ModuleTypeDxeSmmDriver
:
922 // If entryPoint is null, create an empty ProcessModuleEntryPointList
925 if (entryPointList
== null || entryPointList
.length
== 0) {
927 .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gDriverEntryPointCount = ");
928 fileBuffer
.append(Integer
.toString(entryPointCount
));
929 fileBuffer
.append(";\r\n");
930 fileBuffer
.append("EFI_STATUS\r\n");
931 fileBuffer
.append("EFIAPI\r\n");
932 fileBuffer
.append("ProcessModuleEntryPointList (\r\n");
933 fileBuffer
.append(" IN EFI_HANDLE ImageHandle,\r\n");
934 fileBuffer
.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");
935 fileBuffer
.append(" )\r\n\r\n");
936 fileBuffer
.append("{\r\n");
937 fileBuffer
.append(" return EFI_SUCCESS;\r\n");
938 fileBuffer
.append("}\r\n\r\n");
941 for (int i
= 0; i
< entryPointList
.length
; i
++) {
942 fileBuffer
.append("EFI_STATUS\r\n");
943 fileBuffer
.append("EFIAPI\r\n");
944 fileBuffer
.append(entryPointList
[i
]);
945 fileBuffer
.append(" (\r\n");
946 fileBuffer
.append(" IN EFI_HANDLE ImageHandle,\r\n");
947 fileBuffer
.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");
948 fileBuffer
.append(" );\r\n");
952 .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gDriverEntryPointCount = ");
953 fileBuffer
.append(Integer
.toString(entryPointCount
));
954 fileBuffer
.append(";\r\n");
956 .append("static BASE_LIBRARY_JUMP_BUFFER mJumpContext;\r\n");
958 .append("static EFI_STATUS mDriverEntryPointStatus = EFI_LOAD_ERROR;\r\n\r\n");
960 fileBuffer
.append("EFI_STATUS\r\n");
961 fileBuffer
.append("EFIAPI\r\n");
962 fileBuffer
.append("ProcessModuleEntryPointList (\r\n");
963 fileBuffer
.append(" IN EFI_HANDLE ImageHandle,\r\n");
964 fileBuffer
.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");
965 fileBuffer
.append(" )\r\n\r\n");
966 fileBuffer
.append("{\r\n");
969 for (int i
= 0; i
< entryPointList
.length
; i
++) {
971 .append(" if (SetJump (&mJumpContext) == 0) {\r\n");
972 fileBuffer
.append(" ExitDriver (");
973 fileBuffer
.append(entryPointList
[i
]);
974 fileBuffer
.append(" (ImageHandle, SystemTable));\r\n");
975 fileBuffer
.append(" ASSERT (FALSE);\r\n");
976 fileBuffer
.append(" }\r\n");
979 fileBuffer
.append(" return mDriverEntryPointStatus;\r\n");
980 fileBuffer
.append("}\r\n\r\n");
982 fileBuffer
.append("VOID\r\n");
983 fileBuffer
.append("EFIAPI\r\n");
984 fileBuffer
.append("ExitDriver (\r\n");
985 fileBuffer
.append(" IN EFI_STATUS Status\n");
986 fileBuffer
.append(" )\r\n\r\n");
987 fileBuffer
.append("{\r\n");
989 .append(" if (!EFI_ERROR (Status) || EFI_ERROR (mDriverEntryPointStatus)) {\r\n");
990 fileBuffer
.append(" mDriverEntryPointStatus = Status;\r\n");
991 fileBuffer
.append(" }\r\n");
992 fileBuffer
.append(" LongJump (&mJumpContext, (UINTN)-1);\r\n");
993 fileBuffer
.append(" ASSERT (FALSE);\r\n");
994 fileBuffer
.append("}\r\n\r\n");
1000 // Add "ModuleUnloadImage" for DxeSmmDriver module type;
1002 //entryPointList = SurfaceAreaQuery.getModuleUnloadImageArray();
1003 //entryPointList = CommonDefinition.remDupString(entryPointList);
1004 //entryPointCount = 0;
1006 unloadImageCount
= 0;
1007 if (unloadImageList
!= null) {
1008 for (int i
= 0; i
< unloadImageList
.length
; i
++) {
1009 fileBuffer
.append("EFI_STATUS\r\n");
1010 fileBuffer
.append("EFIAPI\r\n");
1011 fileBuffer
.append(unloadImageList
[i
]);
1012 fileBuffer
.append(" (\r\n");
1014 .append(" IN EFI_HANDLE ImageHandle\r\n");
1015 fileBuffer
.append(" );\r\n");
1021 .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gDriverUnloadImageCount = ");
1022 fileBuffer
.append(Integer
.toString(unloadImageCount
));
1023 fileBuffer
.append(";\r\n\r\n");
1025 fileBuffer
.append("EFI_STATUS\r\n");
1026 fileBuffer
.append("EFIAPI\r\n");
1027 fileBuffer
.append("ProcessModuleUnloadList (\r\n");
1028 fileBuffer
.append(" IN EFI_HANDLE ImageHandle\r\n");
1029 fileBuffer
.append(" )\r\n");
1030 fileBuffer
.append("{\r\n");
1032 if (unloadImageCount
== 0) {
1033 fileBuffer
.append(" return EFI_SUCCESS;\r\n");
1034 } else if (unloadImageCount
== 1) {
1035 fileBuffer
.append(" return ");
1036 fileBuffer
.append(unloadImageList
[0]);
1037 fileBuffer
.append("(ImageHandle);\r\n");
1039 fileBuffer
.append(" EFI_STATUS Status;\r\n\r\n");
1040 fileBuffer
.append(" Status = EFI_SUCCESS;\r\n\r\n");
1041 for (int i
= 0; i
< unloadImageList
.length
; i
++) {
1043 fileBuffer
.append(" Status = ");
1044 fileBuffer
.append(unloadImageList
[i
]);
1045 fileBuffer
.append("(ImageHandle);\r\n");
1047 fileBuffer
.append(" if (EFI_ERROR (Status)) {\r\n");
1048 fileBuffer
.append(" ");
1049 fileBuffer
.append(unloadImageList
[i
]);
1050 fileBuffer
.append("(ImageHandle);\r\n");
1051 fileBuffer
.append(" } else {\r\n");
1052 fileBuffer
.append(" Status = ");
1053 fileBuffer
.append(unloadImageList
[i
]);
1054 fileBuffer
.append("(ImageHandle);\r\n");
1055 fileBuffer
.append(" }\r\n");
1058 fileBuffer
.append(" return Status;\r\n");
1060 fileBuffer
.append("}\r\n\r\n");
1063 case CommonDefinition
.ModuleTypeDxeRuntimeDriver
:
1064 case CommonDefinition
.ModuleTypeDxeDriver
:
1065 case CommonDefinition
.ModuleTypeDxeSalDriver
:
1066 case CommonDefinition
.ModuleTypeUefiDriver
:
1067 case CommonDefinition
.ModuleTypeUefiApplication
:
1068 entryPointCount
= 0;
1069 fileBuffer
.append("const UINT32 _gUefiDriverRevision = 0;\r\n");
1071 // If entry point is null, create a empty ProcessModuleEntryPointList function.
1073 if (entryPointList
== null || entryPointList
.length
== 0) {
1075 .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gDriverEntryPointCount = 0;\r\n");
1076 fileBuffer
.append("EFI_STATUS\r\n");
1077 fileBuffer
.append("EFIAPI\r\n");
1078 fileBuffer
.append("ProcessModuleEntryPointList (\r\n");
1079 fileBuffer
.append(" IN EFI_HANDLE ImageHandle,\r\n");
1080 fileBuffer
.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");
1081 fileBuffer
.append(" )\r\n\r\n");
1082 fileBuffer
.append("{\r\n");
1083 fileBuffer
.append(" return EFI_SUCCESS;\r\n");
1084 fileBuffer
.append("}\r\n");
1087 for (int i
= 0; i
< entryPointList
.length
; i
++) {
1089 fileBuffer
.append("EFI_STATUS\r\n");
1090 fileBuffer
.append("EFIAPI\r\n");
1091 fileBuffer
.append(entryPointList
[i
]);
1092 fileBuffer
.append(" (\r\n");
1093 fileBuffer
.append(" IN EFI_HANDLE ImageHandle,\r\n");
1094 fileBuffer
.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");
1095 fileBuffer
.append(" );\r\n");
1100 .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gDriverEntryPointCount = ");
1101 fileBuffer
.append(Integer
.toString(entryPointCount
));
1102 fileBuffer
.append(";\r\n");
1103 if (entryPointCount
> 1) {
1105 .append("static BASE_LIBRARY_JUMP_BUFFER mJumpContext;\r\n");
1107 .append("static EFI_STATUS mDriverEntryPointStatus = EFI_LOAD_ERROR;\r\n");
1109 fileBuffer
.append("\n");
1111 fileBuffer
.append("EFI_STATUS\r\n");
1112 fileBuffer
.append("EFIAPI\r\n");
1113 fileBuffer
.append("ProcessModuleEntryPointList (\r\n");
1114 fileBuffer
.append(" IN EFI_HANDLE ImageHandle,\r\n");
1115 fileBuffer
.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");
1116 fileBuffer
.append(" )\r\n\r\n");
1117 fileBuffer
.append("{\r\n");
1119 if (entryPointCount
== 1) {
1120 fileBuffer
.append(" return (");
1121 fileBuffer
.append(entryPointList
[0]);
1122 fileBuffer
.append(" (ImageHandle, SystemTable));\r\n");
1124 for (int i
= 0; i
< entryPointList
.length
; i
++) {
1125 if (!entryPointList
[i
].equals("")) {
1127 .append(" if (SetJump (&mJumpContext) == 0) {\r\n");
1128 fileBuffer
.append(" ExitDriver (");
1129 fileBuffer
.append(entryPointList
[i
]);
1130 fileBuffer
.append(" (ImageHandle, SystemTable));\r\n");
1131 fileBuffer
.append(" ASSERT (FALSE);\r\n");
1132 fileBuffer
.append(" }\r\n");
1137 fileBuffer
.append(" return mDriverEntryPointStatus;\r\n");
1139 fileBuffer
.append("}\r\n\r\n");
1141 fileBuffer
.append("VOID\r\n");
1142 fileBuffer
.append("EFIAPI\r\n");
1143 fileBuffer
.append("ExitDriver (\r\n");
1144 fileBuffer
.append(" IN EFI_STATUS Status\r\n");
1145 fileBuffer
.append(" )\r\n\r\n");
1146 fileBuffer
.append("{\r\n");
1147 if (entryPointCount
<= 1) {
1148 fileBuffer
.append(" if (EFI_ERROR (Status)) {\r\n");
1150 .append(" ProcessLibraryDestructorList (gImageHandle, gST);\r\n");
1151 fileBuffer
.append(" }\r\n");
1153 .append(" gBS->Exit (gImageHandle, Status, 0, NULL);\r\n");
1156 .append(" if (!EFI_ERROR (Status) || EFI_ERROR (mDriverEntryPointStatus)) {\r\n");
1157 fileBuffer
.append(" mDriverEntryPointStatus = Status;\r\n");
1158 fileBuffer
.append(" }\r\n");
1159 fileBuffer
.append(" LongJump (&mJumpContext, (UINTN)-1);\r\n");
1160 fileBuffer
.append(" ASSERT (FALSE);\r\n");
1162 fileBuffer
.append("}\r\n\r\n");
1167 // Add ModuleUnloadImage for DxeDriver and UefiDriver module type.
1169 //entryPointList = SurfaceAreaQuery.getModuleUnloadImageArray();
1171 // Remover duplicate unload entry point.
1173 //entryPointList = CommonDefinition.remDupString(entryPointList);
1174 //entryPointCount = 0;
1175 unloadImageCount
= 0;
1176 if (unloadImageList
!= null) {
1177 for (int i
= 0; i
< unloadImageList
.length
; i
++) {
1178 fileBuffer
.append("EFI_STATUS\r\n");
1179 fileBuffer
.append("EFIAPI\r\n");
1180 fileBuffer
.append(unloadImageList
[i
]);
1181 fileBuffer
.append(" (\r\n");
1183 .append(" IN EFI_HANDLE ImageHandle\r\n");
1184 fileBuffer
.append(" );\r\n");
1190 .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gDriverUnloadImageCount = ");
1191 fileBuffer
.append(Integer
.toString(unloadImageCount
));
1192 fileBuffer
.append(";\r\n\r\n");
1194 fileBuffer
.append("EFI_STATUS\n");
1195 fileBuffer
.append("EFIAPI\r\n");
1196 fileBuffer
.append("ProcessModuleUnloadList (\r\n");
1197 fileBuffer
.append(" IN EFI_HANDLE ImageHandle\r\n");
1198 fileBuffer
.append(" )\r\n");
1199 fileBuffer
.append("{\r\n");
1201 if (unloadImageCount
== 0) {
1202 fileBuffer
.append(" return EFI_SUCCESS;\r\n");
1203 } else if (unloadImageCount
== 1) {
1204 fileBuffer
.append(" return ");
1205 fileBuffer
.append(unloadImageList
[0]);
1206 fileBuffer
.append("(ImageHandle);\r\n");
1208 fileBuffer
.append(" EFI_STATUS Status;\r\n\r\n");
1209 fileBuffer
.append(" Status = EFI_SUCCESS;\r\n\r\n");
1210 for (int i
= 0; i
< unloadImageList
.length
; i
++) {
1212 fileBuffer
.append(" Status = ");
1213 fileBuffer
.append(unloadImageList
[i
]);
1214 fileBuffer
.append("(ImageHandle);\r\n");
1216 fileBuffer
.append(" if (EFI_ERROR (Status)) {\r\n");
1217 fileBuffer
.append(" ");
1218 fileBuffer
.append(unloadImageList
[i
]);
1219 fileBuffer
.append("(ImageHandle);\r\n");
1220 fileBuffer
.append(" } else {\r\n");
1221 fileBuffer
.append(" Status = ");
1222 fileBuffer
.append(unloadImageList
[i
]);
1223 fileBuffer
.append("(ImageHandle);\r\n");
1224 fileBuffer
.append(" }\r\n");
1227 fileBuffer
.append(" return Status;\r\n");
1229 fileBuffer
.append("}\r\n\r\n");
1237 This function gets GUIDs from SPD file accrodeing to <PPIs> information
1238 and write those GUIDs to AutoGen.c.
1241 String Buffer for Autogen.c file.
1242 @throws BuildException
1243 Guid must set value!
1245 void PpiGuidToAutogenC(StringBuffer fileBuffer
) throws AutoGenException
{
1246 String
[] cNameGuid
= null;
1249 // Get the all PPI adn PPI Notify from MSA file,
1250 // then add those PPI ,and PPI Notify name to list.
1253 String
[] ppiList
= SurfaceAreaQuery
.getPpiArray(this.arch
);
1254 for (int i
= 0; i
< ppiList
.length
; i
++) {
1255 this.mPpiList
.add(ppiList
[i
]);
1258 String
[] ppiNotifyList
= SurfaceAreaQuery
.getPpiNotifyArray(this.arch
);
1259 for (int i
= 0; i
< ppiNotifyList
.length
; i
++) {
1260 this.mPpiList
.add(ppiNotifyList
[i
]);
1264 // Find CNAME and GUID from dependence SPD file and write to Autogen.c
1266 Iterator ppiIterator
= this.mPpiList
.iterator();
1267 String ppiKeyWord
= null;
1268 while (ppiIterator
.hasNext()) {
1269 ppiKeyWord
= ppiIterator
.next().toString();
1270 cNameGuid
= GlobalData
.getPpiGuid(this.mDepPkgList
, ppiKeyWord
);
1271 if (cNameGuid
!= null) {
1273 .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID ");
1274 fileBuffer
.append(cNameGuid
[0]);
1275 fileBuffer
.append(" = { ");
1276 fileBuffer
.append(CommonDefinition
.formatGuidName(cNameGuid
[1]));
1277 fileBuffer
.append(" } ;");
1280 // If can't find Ppi GUID declaration in every package
1282 throw new AutoGenException("Can not find Ppi GUID ["
1283 + ppiKeyWord
+ "] declaration in any SPD package!");
1289 ProtocolGuidToAutogenc
1291 This function gets GUIDs from SPD file accrodeing to <Protocol>
1292 information and write those GUIDs to AutoGen.c.
1295 String Buffer for Autogen.c file.
1296 @throws BuildException
1297 Protocol name must set.
1299 void ProtocolGuidToAutogenC(StringBuffer fileBuffer
) throws BuildException
{
1300 String
[] cNameGuid
= null;
1302 String
[] protocolList
= SurfaceAreaQuery
.getProtocolArray(this.arch
);
1305 // Add result to Autogen global list.
1307 for (int i
= 0; i
< protocolList
.length
; i
++) {
1308 this.mProtocolList
.add(protocolList
[i
]);
1311 String
[] protocolNotifyList
= SurfaceAreaQuery
1312 .getProtocolNotifyArray(this.arch
);
1314 for (int i
= 0; i
< protocolNotifyList
.length
; i
++) {
1315 this.mProtocolList
.add(protocolNotifyList
[i
]);
1319 // Get the NAME and GUID from dependence SPD and write to Autogen.c
1321 Iterator protocolIterator
= this.mProtocolList
.iterator();
1322 String protocolKeyWord
= null;
1325 while (protocolIterator
.hasNext()) {
1326 protocolKeyWord
= protocolIterator
.next().toString();
1327 cNameGuid
= GlobalData
.getProtocolGuid(this.mDepPkgList
, protocolKeyWord
);
1328 if (cNameGuid
!= null) {
1330 .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID ");
1331 fileBuffer
.append(cNameGuid
[0]);
1332 fileBuffer
.append(" = { ");
1333 fileBuffer
.append(CommonDefinition
.formatGuidName(cNameGuid
[1]));
1334 fileBuffer
.append(" } ;");
1337 // If can't find protocol GUID declaration in every package
1339 throw new BuildException("Can not find protocol Guid ["
1340 + protocolKeyWord
+ "] declaration in any SPD package!");
1348 This function gets GUIDs from SPD file accrodeing to <Guids> information
1349 and write those GUIDs to AutoGen.c.
1352 String Buffer for Autogen.c file.
1355 void GuidGuidToAutogenC(StringBuffer fileBuffer
) throws AutoGenException
{
1356 String
[] cNameGuid
= null;
1357 String guidKeyWord
= null;
1359 String
[] guidList
= SurfaceAreaQuery
.getGuidEntryArray(this.arch
);
1361 for (int i
= 0; i
< guidList
.length
; i
++) {
1362 this.mGuidList
.add(guidList
[i
]);
1366 Iterator guidIterator
= this.mGuidList
.iterator();
1367 while (guidIterator
.hasNext()) {
1368 guidKeyWord
= guidIterator
.next().toString();
1369 cNameGuid
= GlobalData
.getGuid(this.mDepPkgList
, guidKeyWord
);
1371 if (cNameGuid
!= null) {
1373 .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID ");
1374 fileBuffer
.append(cNameGuid
[0]);
1375 fileBuffer
.append(" = { ");
1376 fileBuffer
.append(CommonDefinition
.formatGuidName(cNameGuid
[1]));
1377 fileBuffer
.append("} ;");
1380 // If can't find GUID declaration in every package
1382 throw new AutoGenException("Can not find Guid [" + guidKeyWord
1383 + "] declaration in any SPD package. ");
1390 LibInstanceToAutogenC
1392 This function adds dependent library instance to autogen.c,which
1393 includeing library's constructor, destructor, and library dependent ppi,
1394 protocol, guid, pcd information.
1397 String buffer for AutoGen.c
1398 @throws BuildException
1400 void LibInstanceToAutogenC(StringBuffer fileBuffer
) throws BuildException
{
1402 String moduleType
= this.moduleId
.getModuleType();
1404 // Add library constructor to AutoGen.c
1406 LibConstructorToAutogenC(libConstructList
, moduleType
,
1407 fileBuffer
/* autogenC */);
1409 // Add library destructor to AutoGen.c
1411 LibDestructorToAutogenC(libDestructList
, moduleType
, fileBuffer
/* autogenC */);
1412 } catch (Exception e
) {
1413 throw new BuildException(e
.getMessage());
1418 LibConstructorToAutogenc
1420 This function writes library constructor list to AutoGen.c. The library
1421 constructor's parameter and return value depend on module type.
1423 @param libInstanceList
1424 List of library construct name.
1428 String buffer for AutoGen.c
1431 void LibConstructorToAutogenC(List
<String
> libInstanceList
,
1432 String moduleType
, StringBuffer fileBuffer
) throws Exception
{
1433 boolean isFirst
= true;
1436 // The library constructor's parameter and return value depend on
1439 for (int i
= 0; i
< libInstanceList
.size(); i
++) {
1440 switch (CommonDefinition
.getModuleType(moduleType
)) {
1441 case CommonDefinition
.ModuleTypeBase
:
1442 fileBuffer
.append("RETURN_STATUS\r\n");
1443 fileBuffer
.append("EFIAPI\r\n");
1444 fileBuffer
.append(libInstanceList
.get(i
));
1445 fileBuffer
.append(" (\r\n");
1446 fileBuffer
.append(" VOID\r\n");
1447 fileBuffer
.append(" );\r\n");
1450 case CommonDefinition
.ModuleTypePeiCore
:
1451 case CommonDefinition
.ModuleTypePeim
:
1452 fileBuffer
.append("EFI_STATUS\r\n");
1453 fileBuffer
.append("EFIAPI\r\n");
1454 fileBuffer
.append(libInstanceList
.get(i
));
1455 fileBuffer
.append(" (\r\n");
1457 .append(" IN EFI_FFS_FILE_HEADER *FfsHeader,\r\n");
1459 .append(" IN EFI_PEI_SERVICES **PeiServices\r\n");
1460 fileBuffer
.append(" );\r\n");
1463 case CommonDefinition
.ModuleTypeDxeCore
:
1464 case CommonDefinition
.ModuleTypeDxeDriver
:
1465 case CommonDefinition
.ModuleTypeDxeRuntimeDriver
:
1466 case CommonDefinition
.ModuleTypeDxeSmmDriver
:
1467 case CommonDefinition
.ModuleTypeDxeSalDriver
:
1468 case CommonDefinition
.ModuleTypeUefiDriver
:
1469 case CommonDefinition
.ModuleTypeUefiApplication
:
1470 fileBuffer
.append("EFI_STATUS\r\n");
1471 fileBuffer
.append("EFIAPI\r\n");
1472 fileBuffer
.append(libInstanceList
.get(i
));
1473 fileBuffer
.append(" (\r\n");
1474 fileBuffer
.append(" IN EFI_HANDLE ImageHandle,\r\n");
1475 fileBuffer
.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");
1476 fileBuffer
.append(" );\r\n");
1482 // Add ProcessLibraryConstructorList in AutoGen.c
1484 fileBuffer
.append("VOID\r\n");
1485 fileBuffer
.append("EFIAPI\r\n");
1486 fileBuffer
.append("ProcessLibraryConstructorList (\r\n");
1487 switch (CommonDefinition
.getModuleType(moduleType
)) {
1488 case CommonDefinition
.ModuleTypeBase
:
1489 fileBuffer
.append(" VOID\r\n");
1492 case CommonDefinition
.ModuleTypePeiCore
:
1493 case CommonDefinition
.ModuleTypePeim
:
1494 fileBuffer
.append(" IN EFI_FFS_FILE_HEADER *FfsHeader,\r\n");
1496 .append(" IN EFI_PEI_SERVICES **PeiServices\r\n");
1499 case CommonDefinition
.ModuleTypeDxeCore
:
1500 case CommonDefinition
.ModuleTypeDxeDriver
:
1501 case CommonDefinition
.ModuleTypeDxeRuntimeDriver
:
1502 case CommonDefinition
.ModuleTypeDxeSmmDriver
:
1503 case CommonDefinition
.ModuleTypeDxeSalDriver
:
1504 case CommonDefinition
.ModuleTypeUefiDriver
:
1505 case CommonDefinition
.ModuleTypeUefiApplication
:
1506 fileBuffer
.append(" IN EFI_HANDLE ImageHandle,\r\n");
1507 fileBuffer
.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");
1511 fileBuffer
.append(" )\r\n");
1512 fileBuffer
.append("{\r\n");
1514 // If no constructor function, return EFI_SUCCESS.
1516 //if (libInstanceList.size() == 0){
1517 // fileBuffer.append(" return EFI_SUCCESS;\r\n");
1519 for (int i
= 0; i
< libInstanceList
.size(); i
++) {
1521 fileBuffer
.append(" EFI_STATUS Status;\r\n");
1522 fileBuffer
.append(" Status = EFI_SUCCESS;\r\n");
1523 fileBuffer
.append("\r\n");
1526 switch (CommonDefinition
.getModuleType(moduleType
)) {
1527 case CommonDefinition
.ModuleTypeBase
:
1528 fileBuffer
.append(" Status = ");
1529 fileBuffer
.append(libInstanceList
.get(i
));
1530 fileBuffer
.append("();\r\n");
1531 fileBuffer
.append(" VOID\r\n");
1533 case CommonDefinition
.ModuleTypePeiCore
:
1534 case CommonDefinition
.ModuleTypePeim
:
1535 fileBuffer
.append(" Status = ");
1536 fileBuffer
.append(libInstanceList
.get(i
));
1537 fileBuffer
.append(" (FfsHeader, PeiServices);\r\n");
1539 case CommonDefinition
.ModuleTypeDxeCore
:
1540 case CommonDefinition
.ModuleTypeDxeDriver
:
1541 case CommonDefinition
.ModuleTypeDxeRuntimeDriver
:
1542 case CommonDefinition
.ModuleTypeDxeSmmDriver
:
1543 case CommonDefinition
.ModuleTypeDxeSalDriver
:
1544 case CommonDefinition
.ModuleTypeUefiDriver
:
1545 case CommonDefinition
.ModuleTypeUefiApplication
:
1546 fileBuffer
.append(" Status = ");
1547 fileBuffer
.append(libInstanceList
.get(i
));
1548 fileBuffer
.append(" (ImageHandle, SystemTable);\r\n");
1551 EdkLog
.log(EdkLog
.EDK_INFO
,"Autogen doesn't know how to deal with module type - " + moduleType
+ "!");
1553 fileBuffer
.append(" ASSERT_EFI_ERROR (Status);\r\n");
1555 fileBuffer
.append("}\r\n");
1559 LibDestructorToAutogenc
1561 This function writes library destructor list to AutoGen.c. The library
1562 destructor's parameter and return value depend on module type.
1564 @param libInstanceList
1565 List of library destructor name.
1569 String buffer for AutoGen.c
1572 void LibDestructorToAutogenC(List
<String
> libInstanceList
,
1573 String moduleType
, StringBuffer fileBuffer
) throws Exception
{
1574 boolean isFirst
= true;
1575 for (int i
= 0; i
< libInstanceList
.size(); i
++) {
1576 switch (CommonDefinition
.getModuleType(moduleType
)) {
1577 case CommonDefinition
.ModuleTypeBase
:
1578 fileBuffer
.append("RETURN_STATUS\r\n");
1579 fileBuffer
.append("EFIAPI\r\n");
1580 fileBuffer
.append(libInstanceList
.get(i
));
1581 fileBuffer
.append(" (\r\n");
1582 fileBuffer
.append(" VOID\r\n");
1583 fileBuffer
.append(" );\r\n");
1585 case CommonDefinition
.ModuleTypePeiCore
:
1586 case CommonDefinition
.ModuleTypePeim
:
1587 fileBuffer
.append("EFI_STATUS\r\n");
1588 fileBuffer
.append("EFIAPI\r\n");
1589 fileBuffer
.append(libInstanceList
.get(i
));
1590 fileBuffer
.append(" (\r\n");
1592 .append(" IN EFI_FFS_FILE_HEADER *FfsHeader,\r\n");
1594 .append(" IN EFI_PEI_SERVICES **PeiServices\r\n");
1595 fileBuffer
.append(" );\r\n");
1597 case CommonDefinition
.ModuleTypeDxeCore
:
1598 case CommonDefinition
.ModuleTypeDxeDriver
:
1599 case CommonDefinition
.ModuleTypeDxeRuntimeDriver
:
1600 case CommonDefinition
.ModuleTypeDxeSmmDriver
:
1601 case CommonDefinition
.ModuleTypeDxeSalDriver
:
1602 case CommonDefinition
.ModuleTypeUefiDriver
:
1603 case CommonDefinition
.ModuleTypeUefiApplication
:
1604 fileBuffer
.append("EFI_STATUS\r\n");
1605 fileBuffer
.append("EFIAPI\r\n");
1606 fileBuffer
.append(libInstanceList
.get(i
));
1607 fileBuffer
.append(" (\r\n");
1608 fileBuffer
.append(" IN EFI_HANDLE ImageHandle,\r\n");
1609 fileBuffer
.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");
1610 fileBuffer
.append(" );\r\n");
1616 // Write ProcessLibraryDestructor list to autogen.c
1618 switch (CommonDefinition
.getModuleType(moduleType
)) {
1619 case CommonDefinition
.ModuleTypeBase
:
1620 case CommonDefinition
.ModuleTypePeiCore
:
1621 case CommonDefinition
.ModuleTypePeim
:
1623 case CommonDefinition
.ModuleTypeDxeCore
:
1624 case CommonDefinition
.ModuleTypeDxeDriver
:
1625 case CommonDefinition
.ModuleTypeDxeRuntimeDriver
:
1626 case CommonDefinition
.ModuleTypeDxeSmmDriver
:
1627 case CommonDefinition
.ModuleTypeDxeSalDriver
:
1628 case CommonDefinition
.ModuleTypeUefiDriver
:
1629 case CommonDefinition
.ModuleTypeUefiApplication
:
1630 fileBuffer
.append("VOID\r\n");
1631 fileBuffer
.append("EFIAPI\r\n");
1632 fileBuffer
.append("ProcessLibraryDestructorList (\r\n");
1633 fileBuffer
.append(" IN EFI_HANDLE ImageHandle,\r\n");
1634 fileBuffer
.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");
1635 fileBuffer
.append(" )\r\n");
1636 fileBuffer
.append("{\r\n");
1638 // If no library destructor function, return EFI_SUCCESS.
1641 for (int i
= 0; i
< libInstanceList
.size(); i
++) {
1643 fileBuffer
.append(" EFI_STATUS Status;\r\n");
1644 fileBuffer
.append(" Status = EFI_SUCCESS;\r\n");
1645 fileBuffer
.append("\r\n");
1648 fileBuffer
.append(" Status = ");
1649 fileBuffer
.append(libInstanceList
.get(i
));
1650 fileBuffer
.append("(ImageHandle, SystemTable);\r\n");
1651 fileBuffer
.append(" ASSERT_EFI_ERROR (Status);\r\n");
1653 fileBuffer
.append("}\r\n");
1659 ExternsDriverBindingToAutoGenC
1661 This function is to write DRIVER_BINDING, COMPONENT_NAME,
1662 DRIVER_CONFIGURATION, DRIVER_DIAGNOSTIC in AutoGen.c.
1665 String buffer for AutoGen.c
1667 void ExternsDriverBindingToAutoGenC(StringBuffer fileBuffer
)
1668 throws BuildException
{
1671 // Check what <extern> contains. And the number of following elements
1672 // under <extern> should be same. 1. DRIVER_BINDING 2. COMPONENT_NAME
1673 // 3.DRIVER_CONFIGURATION 4. DRIVER_DIAGNOSTIC
1676 String
[] drvBindList
= SurfaceAreaQuery
.getDriverBindingArray();
1679 // If component name protocol,component configuration protocol,
1680 // component diagnostic protocol is not null or empty, check
1681 // if every one have the same number of the driver binding protocol.
1683 if (drvBindList
== null || drvBindList
.length
== 0) {
1687 String
[] compNamList
= SurfaceAreaQuery
.getComponentNameArray();
1688 String
[] compConfList
= SurfaceAreaQuery
.getDriverConfigArray();
1689 String
[] compDiagList
= SurfaceAreaQuery
.getDriverDiagArray();
1694 // Write driver binding protocol extern to autogen.c
1696 for (int i
= 0; i
< drvBindList
.length
; i
++) {
1697 fileBuffer
.append("extern EFI_DRIVER_BINDING_PROTOCOL ");
1698 fileBuffer
.append(drvBindList
[i
]);
1699 fileBuffer
.append(";\r\n");
1703 // Write component name protocol extern to autogen.c
1705 if (compNamList
!= null && compNamList
.length
!= 0) {
1706 if (drvBindList
.length
!= compNamList
.length
) {
1707 throw new BuildException(
1708 "Different number of Driver Binding and Component Name protocols!");
1712 for (int i
= 0; i
< compNamList
.length
; i
++) {
1713 fileBuffer
.append("extern EFI_COMPONENT_NAME_PROTOCOL ");
1714 fileBuffer
.append(compNamList
[i
]);
1715 fileBuffer
.append(";\r\n");
1720 // Write driver configration protocol extern to autogen.c
1722 if (compConfList
!= null && compConfList
.length
!= 0) {
1723 if (drvBindList
.length
!= compConfList
.length
) {
1724 throw new BuildException(
1725 "Different number of Driver Binding and Driver Configuration protocols!");
1729 for (int i
= 0; i
< compConfList
.length
; i
++) {
1730 fileBuffer
.append("extern EFI_DRIVER_CONFIGURATION_PROTOCOL ");
1731 fileBuffer
.append(compConfList
[i
]);
1732 fileBuffer
.append(";\r\n");
1737 // Write driver dignastic protocol extern to autogen.c
1739 if (compDiagList
!= null && compDiagList
.length
!= 0) {
1740 if (drvBindList
.length
!= compDiagList
.length
) {
1741 throw new BuildException(
1742 "Different number of Driver Binding and Driver Diagnosis protocols!");
1746 for (int i
= 0; i
< compDiagList
.length
; i
++) {
1747 fileBuffer
.append("extern EFI_DRIVER_DIAGNOSTICS_PROTOCOL ");
1748 fileBuffer
.append(compDiagList
[i
]);
1749 fileBuffer
.append(";\r\n");
1754 // Write driver module protocol bitmask.
1757 .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gDriverModelProtocolBitmask = ");
1758 fileBuffer
.append(Integer
.toString(BitMask
));
1759 fileBuffer
.append(";\r\n");
1762 // Write driver module protocol list entry
1765 .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINTN _gDriverModelProtocolListEntries = ");
1767 fileBuffer
.append(Integer
.toString(drvBindList
.length
));
1768 fileBuffer
.append(";\r\n");
1771 // Write drive module protocol list to autogen.c
1774 .append("GLOBAL_REMOVE_IF_UNREFERENCED const EFI_DRIVER_MODEL_PROTOCOL_LIST _gDriverModelProtocolList[] = {");
1775 for (int i
= 0; i
< drvBindList
.length
; i
++) {
1777 fileBuffer
.append(",");
1779 fileBuffer
.append("\r\n {\r\n");
1780 fileBuffer
.append(" &");
1781 fileBuffer
.append(drvBindList
[i
]);
1782 fileBuffer
.append(", \r\n");
1784 if (compNamList
!= null) {
1785 fileBuffer
.append(" &");
1786 fileBuffer
.append(compNamList
[i
]);
1787 fileBuffer
.append(", \r\n");
1789 fileBuffer
.append(" NULL, \r\n");
1792 if (compConfList
!= null) {
1793 fileBuffer
.append(" &");
1794 fileBuffer
.append(compConfList
[i
]);
1795 fileBuffer
.append(", \r\n");
1797 fileBuffer
.append(" NULL, \r\n");
1800 if (compDiagList
!= null) {
1801 fileBuffer
.append(" &");
1802 fileBuffer
.append(compDiagList
[i
]);
1803 fileBuffer
.append(", \r\n");
1805 fileBuffer
.append(" NULL, \r\n");
1807 fileBuffer
.append(" }");
1809 fileBuffer
.append("\r\n};\r\n");
1813 ExternCallBackToAutoGenC
1815 This function adds <SetVirtualAddressMapCallBack> and
1816 <ExitBootServicesCallBack> infomation to AutoGen.c
1819 String buffer for AutoGen.c
1820 @throws BuildException
1822 void ExternCallBackToAutoGenC(StringBuffer fileBuffer
)
1823 throws BuildException
{
1825 // Collect module's <SetVirtualAddressMapCallBack> and
1826 // <ExitBootServiceCallBack> and add to setVirtualAddList
1827 // exitBootServiceList.
1829 String
[] setVirtuals
= SurfaceAreaQuery
.getSetVirtualAddressMapCallBackArray();
1830 String
[] exitBoots
= SurfaceAreaQuery
.getExitBootServicesCallBackArray();
1831 if (setVirtuals
!= null) {
1832 for (int j
= 0; j
< setVirtuals
.length
; j
++) {
1833 this.setVirtalAddList
.add(setVirtuals
[j
]);
1836 if (exitBoots
!= null) {
1837 for (int k
= 0; k
< exitBoots
.length
; k
++) {
1838 this.exitBootServiceList
.add(exitBoots
[k
]);
1842 // Add c code in autogen.c which relate to <SetVirtualAddressMapCallBack>
1843 // and <ExitBootServicesCallBack>
1845 String moduleType
= this.moduleId
.getModuleType();
1846 switch (CommonDefinition
.getModuleType(moduleType
)) {
1847 case CommonDefinition
.ModuleTypeDxeDriver
:
1848 case CommonDefinition
.ModuleTypeDxeRuntimeDriver
:
1849 case CommonDefinition
.ModuleTypeDxeSalDriver
:
1850 case CommonDefinition
.ModuleTypeUefiDriver
:
1851 case CommonDefinition
.ModuleTypeUefiApplication
:
1853 // If moduleType is one of above, call setVirtualAddressToAutogenC,
1854 // and setExitBootServiceToAutogenC.
1856 setVirtualAddressToAutogenC(fileBuffer
);
1857 setExitBootServiceToAutogenC(fileBuffer
);
1865 copyFlashMapHToDebugDir
1867 This function is to copy the falshmap.h to debug directory and change
1868 its name to TianoR8FlashMap.h
1873 private void copyFlashMapHToDebugDir() throws AutoGenException
{
1875 File inFile
= new File(fvDir
+ File
.separatorChar
+ CommonDefinition
.FLASHMAPH
);
1876 int size
= (int)inFile
.length();
1877 byte[] buffer
= new byte[size
];
1878 File outFile
= new File (this.outputPath
+ File
.separatorChar
+ CommonDefinition
.TIANOR8PLASHMAPH
);
1880 // If TianoR8FlashMap.h existed and the flashMap.h don't change,
1883 if ((!outFile
.exists()) ||(inFile
.lastModified() - outFile
.lastModified()) >= 0) {
1885 if (inFile
.exists()) {
1886 FileInputStream fis
= new FileInputStream (inFile
);
1888 FileOutputStream fos
= new FileOutputStream(outFile
);
1893 throw new AutoGenException("The file, flashMap.h doesn't exist!");
1895 } catch (Exception e
) {
1896 throw new AutoGenException(e
.getMessage());
1902 This function first order the library instances, then collect
1903 library instance 's PPI, Protocol, GUID,
1904 SetVirtalAddressMapCallBack, ExitBootServiceCallBack, and
1905 Destructor, Constructor.
1910 private void collectLibInstanceInfo(){
1913 String libConstructName
= null;
1914 String libDestructName
= null;
1915 String
[] setVirtuals
= null;
1916 String
[] exitBoots
= null;
1918 ModuleIdentification
[] libraryIdList
= SurfaceAreaQuery
1919 .getLibraryInstance(this.arch
);
1921 if (libraryIdList
!= null) {
1923 // Reorder library instance sequence.
1925 AutogenLibOrder libOrder
= new AutogenLibOrder(libraryIdList
,
1927 List
<ModuleIdentification
> orderList
= libOrder
1928 .orderLibInstance();
1930 if (orderList
!= null) {
1932 // Process library instance one by one.
1934 for (int i
= 0; i
< orderList
.size(); i
++) {
1937 // Get library instance basename.
1939 ModuleIdentification libInstanceId
= orderList
.get(i
);
1945 Map
<String
, XmlObject
> libDoc
= GlobalData
.getDoc(libInstanceId
, this.arch
);
1946 SurfaceAreaQuery
.push(libDoc
);
1948 // Get <PPis>, <Protocols>, <Guids> list of this library
1951 String
[] ppiList
= SurfaceAreaQuery
.getPpiArray(this.arch
);
1952 String
[] ppiNotifyList
= SurfaceAreaQuery
1953 .getPpiNotifyArray(this.arch
);
1954 String
[] protocolList
= SurfaceAreaQuery
1955 .getProtocolArray(this.arch
);
1956 String
[] protocolNotifyList
= SurfaceAreaQuery
1957 .getProtocolNotifyArray(this.arch
);
1958 String
[] guidList
= SurfaceAreaQuery
1959 .getGuidEntryArray(this.arch
);
1960 PackageIdentification
[] pkgList
= SurfaceAreaQuery
.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
= SurfaceAreaQuery
1997 .getLibConstructorName();
1998 libDestructName
= SurfaceAreaQuery
1999 .getLibDestructorName();
2002 // Collect SetVirtualAddressMapCallBack and
2003 // ExitBootServiceCallBack.
2005 setVirtuals
= SurfaceAreaQuery
.getSetVirtualAddressMapCallBackArray();
2006 exitBoots
= SurfaceAreaQuery
.getExitBootServicesCallBackArray();
2007 if (setVirtuals
!= null) {
2008 for (int j
= 0; j
< setVirtuals
.length
; j
++) {
2009 this.setVirtalAddList
.add(setVirtuals
[j
]);
2012 if (exitBoots
!= null) {
2013 for (int k
= 0; k
< exitBoots
.length
; k
++) {
2014 this.exitBootServiceList
.add(exitBoots
[k
]);
2017 SurfaceAreaQuery
.pop();
2019 // Add dependent library instance constructor function.
2021 if (libConstructName
!= null) {
2022 this.libConstructList
.add(libConstructName
);
2025 // Add dependent library instance destructor fuction.
2027 if (libDestructName
!= null) {
2028 this.libDestructList
.add(libDestructName
);
2035 } catch (Exception e
) {
2036 System
.out
.println(e
.getMessage());
2037 System
.out
.println("Collect library instance failed!");
2040 private void setVirtualAddressToAutogenC(StringBuffer fileBuffer
){
2042 // Entry point lib for these module types needs to know the count
2046 .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED const UINTN _gDriverSetVirtualAddressMapEventCount = ");
2049 // If the list is not valid or has no entries set count to zero else
2050 // set count to the number of valid entries
2054 if (this.setVirtalAddList
!= null) {
2055 for (i
= 0; i
< this.setVirtalAddList
.size(); i
++) {
2056 if (this.setVirtalAddList
.get(i
).equalsIgnoreCase("")) {
2063 fileBuffer
.append(Integer
.toString(Count
));
2064 fileBuffer
.append(";\r\n\r\n");
2065 if (this.setVirtalAddList
== null || this.setVirtalAddList
.size() == 0) {
2067 // No data so make a NULL list
2070 .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED const EFI_EVENT_NOTIFY _gDriverSetVirtualAddressMapEvent[] = {\r\n");
2071 fileBuffer
.append(" NULL\r\n");
2072 fileBuffer
.append("};\r\n\r\n");
2075 // Write SetVirtualAddressMap function definition.
2077 for (i
= 0; i
< this.setVirtalAddList
.size(); i
++) {
2078 if (this.setVirtalAddList
.get(i
).equalsIgnoreCase("")) {
2081 fileBuffer
.append("VOID\r\n");
2082 fileBuffer
.append("EFIAPI\r\n");
2083 fileBuffer
.append(this.setVirtalAddList
.get(i
));
2084 fileBuffer
.append(" (\r\n");
2085 fileBuffer
.append(" IN EFI_EVENT Event,\r\n");
2086 fileBuffer
.append(" IN VOID *Context\r\n");
2087 fileBuffer
.append(" );\r\n\r\n");
2091 // Write SetVirtualAddressMap entry point array.
2094 .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED const EFI_EVENT_NOTIFY _gDriverSetVirtualAddressMapEvent[] = {");
2095 for (i
= 0; i
< this.setVirtalAddList
.size(); i
++) {
2096 if (this.setVirtalAddList
.get(i
).equalsIgnoreCase("")) {
2101 fileBuffer
.append("\r\n ");
2103 fileBuffer
.append(",\r\n ");
2106 fileBuffer
.append(this.setVirtalAddList
.get(i
));
2109 // add the NULL at the end of _gDriverSetVirtualAddressMapEvent list.
2111 fileBuffer
.append(",\r\n NULL");
2112 fileBuffer
.append("\r\n};\r\n\r\n");
2117 private void setExitBootServiceToAutogenC(StringBuffer fileBuffer
){
2119 // Entry point lib for these module types needs to know the count.
2122 .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED const UINTN _gDriverExitBootServicesEventCount = ");
2125 // If the list is not valid or has no entries set count to zero else
2126 // set count to the number of valid entries.
2130 if (this.exitBootServiceList
!= null) {
2131 for (i
= 0; i
< this.exitBootServiceList
.size(); i
++) {
2132 if (this.exitBootServiceList
.get(i
).equalsIgnoreCase("")) {
2138 fileBuffer
.append(Integer
.toString(Count
));
2139 fileBuffer
.append(";\r\n\r\n");
2141 if (this.exitBootServiceList
== null || this.exitBootServiceList
.size() == 0) {
2143 // No data so make a NULL list.
2146 .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED const EFI_EVENT_NOTIFY _gDriverExitBootServicesEvent[] = {\r\n");
2147 fileBuffer
.append(" NULL\r\n");
2148 fileBuffer
.append("};\r\n\r\n");
2151 // Write DriverExitBootServices function definition.
2153 for (i
= 0; i
< this.exitBootServiceList
.size(); i
++) {
2154 if (this.exitBootServiceList
.get(i
).equalsIgnoreCase("")) {
2158 fileBuffer
.append("VOID\r\n");
2159 fileBuffer
.append("EFIAPI\r\n");
2160 fileBuffer
.append(this.exitBootServiceList
.get(i
));
2161 fileBuffer
.append(" (\r\n");
2162 fileBuffer
.append(" IN EFI_EVENT Event,\r\n");
2163 fileBuffer
.append(" IN VOID *Context\r\n");
2164 fileBuffer
.append(" );\r\n\r\n");
2168 // Write DriverExitBootServices entry point array.
2171 .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED const EFI_EVENT_NOTIFY _gDriverExitBootServicesEvent[] = {");
2172 for (i
= 0; i
< this.exitBootServiceList
.size(); i
++) {
2173 if (this.exitBootServiceList
.get(i
).equalsIgnoreCase("")) {
2178 fileBuffer
.append("\r\n ");
2180 fileBuffer
.append(",\r\n ");
2182 fileBuffer
.append(this.exitBootServiceList
.get(i
));
2185 fileBuffer
.append(",\r\n NULL");
2186 fileBuffer
.append("\r\n};\r\n\r\n");