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
>();
119 private SurfaceAreaQuery saq
= null;
124 This function mainly initialize some member variable.
127 Absolute path of FV directory.
129 Output path of AutoGen file.
131 Module identification.
135 public AutoGen(String fvDir
, String outputPath
, ModuleIdentification moduleId
, String arch
, SurfaceAreaQuery saq
) {
136 this.outputPath
= outputPath
;
137 this.moduleId
= moduleId
;
146 This function save the content in stringBuffer to file.
151 The content of AutoGen file in buffer.
156 private boolean saveFile(String fileName
, StringBuffer fileBuffer
) {
158 File autoGenH
= new File(fileName
);
161 // if the file exists, compare their content
163 if (autoGenH
.exists()) {
164 char[] oldFileBuffer
= new char[(int) autoGenH
.length()];
166 FileReader fIn
= new FileReader(autoGenH
);
167 fIn
.read(oldFileBuffer
, 0, (int) autoGenH
.length());
169 } catch (IOException e
) {
170 EdkLog
.log(EdkLog
.EDK_INFO
, this.moduleId
.getName()
173 + " is exist, but can't be open!!");
178 // if we got the same file, don't re-generate it to prevent
179 // sources depending on it from re-building
181 if (fileBuffer
.toString().compareTo(new String(oldFileBuffer
)) == 0) {
187 FileWriter fOut
= new FileWriter(autoGenH
);
188 fOut
.write(fileBuffer
.toString());
191 } catch (IOException e
) {
192 EdkLog
.log(EdkLog
.EDK_INFO
, this.moduleId
.getName()
195 + " can't be create!!");
204 This function call libGenAutoGen or moduleGenAutogen function, which
205 dependence on generate library autogen or module autogen.
207 @throws BuildException
208 Failed to creat AutoGen.c & AutoGen.h.
210 public void genAutogen() throws BuildException
{
213 // If outputPath do not exist, create it.
215 File path
= new File(outputPath
);
219 // Check current is library or not, then call the corresponding
222 if (this.moduleId
.isLibrary()) {
228 } catch (Exception e
) {
229 throw new BuildException(
230 "Failed to create AutoGen.c & AutoGen.h!\n"
236 moduleGenAutogen function
238 This function generates AutoGen.c & AutoGen.h for module.
240 @throws BuildException
241 Faile to create module AutoGen.c & AutoGen.h.
243 void moduleGenAutogen() throws BuildException
{
246 collectLibInstanceInfo();
249 } catch (Exception e
) {
250 throw new BuildException(
251 "Faile to create module AutoGen.c & AutoGen.h!\n"
257 libGenAutogen function
259 This function generates AutoGen.c & AutoGen.h for library.
261 @throws BuildException
262 Faile to create library AutoGen.c & AutoGen.h
264 void libGenAutogen() throws BuildException
{
268 } catch (Exception e
) {
269 throw new BuildException(
270 "Failed to create library AutoGen.c & AutoGen.h!\n"
278 This function generates AutoGen.h for module.
280 @throws BuildException
281 Failed to generate AutoGen.h.
283 void moduleGenAutogenH() throws AutoGenException
{
285 Set
<String
> libClassIncludeH
;
287 // List<String> headerFileList;
288 List
<String
> headerFileList
;
290 StringBuffer fileBuffer
= new StringBuffer(8192);
293 // Write Autogen.h header notation
295 fileBuffer
.append(CommonDefinition
.AUTOGENHNOTATION
);
298 // Add #ifndef ${BaseName}_AUTOGENH
299 // #def ${BseeName}_AUTOGENH
301 fileBuffer
.append(CommonDefinition
.IFNDEF
302 + CommonDefinition
.AUTOGENH
303 + this.moduleId
.getGuid().replaceAll("-", "_")
304 + ToolDefinitions
.LINE_SEPARATOR
);
305 fileBuffer
.append(CommonDefinition
.DEFINE
306 + CommonDefinition
.AUTOGENH
307 + this.moduleId
.getGuid().replaceAll("-", "_")
308 + ToolDefinitions
.LINE_SEPARATOR
309 + ToolDefinitions
.LINE_SEPARATOR
);
312 // Write the specification version and release version at the begine
313 // of autogen.h file.
314 // Note: the specification version and release version should
315 // be got from module surface area instead of hard code by it's
318 moduleType
= saq
.getModuleType();
321 // Add "extern int __make_me_compile_correctly;" at begin of
324 fileBuffer
.append(CommonDefinition
.AUTOGENHBEGIN
);
327 // Put EFI_SPECIFICATION_VERSION, and EDK_RELEASE_VERSION.
329 String
[] specList
= saq
.getExternSpecificaiton();
330 for (int i
= 0; i
< specList
.length
; i
++) {
331 fileBuffer
.append(CommonDefinition
.DEFINE
+ specList
[i
]
335 // Write consumed package's mdouleInfo related .h file to autogen.h
337 // PackageIdentification[] consumedPkgIdList = SurfaceAreaQuery
338 // .getDependencePkg(this.arch);
339 PackageIdentification
[] consumedPkgIdList
= saq
.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
= saq
.getLibraryClasses(CommonDefinition
.ALWAYSCONSUMED
,this.arch
);
352 if (libClassList
!= null) {
353 libClassIncludeH
= LibraryClassToAutogenH(libClassList
);
354 item
= libClassIncludeH
.iterator();
355 while (item
.hasNext()) {
356 fileBuffer
.append(item
.next().toString());
360 libClassList
= saq
.getLibraryClasses(CommonDefinition
.ALWAYSPRODUCED
, this.arch
);
361 if (libClassList
!= null) {
362 libClassIncludeH
= LibraryClassToAutogenH(libClassList
);
363 item
= libClassIncludeH
.iterator();
364 while (item
.hasNext()) {
365 fileBuffer
.append(item
.next().toString());
368 fileBuffer
.append("\r\n");
371 // If is TianoR8FlashMap, copy {Fv_DIR}/FlashMap.h to
372 // {DEST_DIR_DRBUG}/FlashMap.h
374 if (saq
.isHaveTianoR8FlashMap()) {
375 fileBuffer
.append(CommonDefinition
.INCLUDE
);
376 fileBuffer
.append(" <");
377 fileBuffer
.append(CommonDefinition
.TIANOR8PLASHMAPH
+ ">\r\n");
378 copyFlashMapHToDebugDir();
381 // Write PCD autogen information to AutoGen.h.
383 if (this.myPcdAutogen
!= null) {
384 fileBuffer
.append("\r\n");
385 fileBuffer
.append(this.myPcdAutogen
.getHAutoGenString());
389 // Append the #endif at AutoGen.h
391 fileBuffer
.append("#endif\r\n");
394 // Save string buffer content in AutoGen.h.
396 if (!saveFile(outputPath
+ File
.separatorChar
+ "AutoGen.h", fileBuffer
)) {
397 throw new BuildException("Failed to generate AutoGen.h !!!");
404 This function generates AutoGen.c for module.
406 @throws BuildException
407 Failed to generate AutoGen.c.
409 void moduleGenAutogenC() throws AutoGenException
{
411 StringBuffer fileBuffer
= new StringBuffer(8192);
413 // Write Autogen.c header notation
415 fileBuffer
.append(CommonDefinition
.AUTOGENCNOTATION
);
418 // Write #include <AutoGen.h> at beginning of AutoGen.c
420 fileBuffer
.append(CommonDefinition
.INCLUDEAUTOGENH
);
423 // Get the native MSA file infomation. Since before call autogen,
424 // the MSA native <Externs> information were overrided. So before
425 // process <Externs> it should be set the DOC as the Native MSA info.
427 Map
<String
, XmlObject
> doc
= GlobalData
.getNativeMsa(this.moduleId
);
431 // DriverBinding/ComponentName/DriverConfiguration/DriverDialog
435 ExternsDriverBindingToAutoGenC(fileBuffer
);
438 // Write DriverExitBootServicesEvent/DriverSetVirtualAddressMapEvent
441 ExternCallBackToAutoGenC(fileBuffer
);
444 // Write EntryPoint to autgoGen.c
446 String
[] entryPointList
= saq
.getModuleEntryPointArray();
447 String
[] unloadImageList
= saq
.getModuleUnloadImageArray();
448 EntryPointToAutoGen(CommonDefinition
.remDupString(entryPointList
),
449 CommonDefinition
.remDupString(unloadImageList
),
452 pcdDriverType
= saq
.getPcdDriverType();
455 // Restore the DOC which include the FPD module info.
460 // Write Guid to autogen.c
462 String guid
= CommonDefinition
.formatGuidName(saq
.getModuleGuid());
465 .append("GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiCallerIdGuid = {");
467 throw new AutoGenException("Guid value must set!\n");
471 // Formate Guid as ANSI c form.Example:
472 // {0xd2b2b828, 0x826, 0x48a7,{0xb3, 0xdf, 0x98, 0x3c, 0x0, 0x60, 0x24,
476 fileBuffer
.append(guid
);
477 fileBuffer
.append("};\r\n");
480 // Generate library instance consumed protocol, guid, ppi, pcd list.
481 // Save those to this.protocolList, this.ppiList, this.pcdList,
482 // this.guidList. Write Consumed library constructor and desconstuct to
485 LibInstanceToAutogenC(fileBuffer
);
488 // Get module dependent Package identification.
490 PackageIdentification
[] packages
= saq
.getDependencePkg(this.arch
);
491 for (int i
= 0; i
< packages
.length
; i
++) {
492 if (!this.mDepPkgList
.contains(packages
[i
])) {
493 this.mDepPkgList
.add(packages
[i
]);
499 // Write consumed ppi, guid, protocol to autogen.c
501 ProtocolGuidToAutogenC(fileBuffer
);
502 PpiGuidToAutogenC(fileBuffer
);
503 GuidGuidToAutogenC(fileBuffer
);
508 this.myPcdAutogen
= new PCDAutoGenAction(moduleId
,
514 this.myPcdAutogen
.execute();
515 } catch (Exception exp
) {
516 throw new PcdAutogenException (exp
.getMessage());
519 if (this.myPcdAutogen
!= null) {
520 fileBuffer
.append("\r\n");
521 fileBuffer
.append(this.myPcdAutogen
.getCAutoGenString());
524 if (!saveFile(outputPath
+ File
.separatorChar
+ "AutoGen.c", fileBuffer
)) {
525 throw new BuildException("Failed to generate AutoGen.c !!!");
533 This function generates AutoGen.h for library.
535 @throws BuildException
536 Failed to generate AutoGen.c.
538 void libGenAutogenH() throws AutoGenException
{
540 Set
<String
> libClassIncludeH
;
542 List
<String
> headerFileList
;
544 StringBuffer fileBuffer
= new StringBuffer(10240);
547 // Write Autogen.h header notation
549 fileBuffer
.append(CommonDefinition
.AUTOGENHNOTATION
);
552 // Add #ifndef ${BaseName}_AUTOGENH
553 // #def ${BseeName}_AUTOGENH
555 fileBuffer
.append(CommonDefinition
.IFNDEF
556 + CommonDefinition
.AUTOGENH
557 + this.moduleId
.getGuid().replaceAll("-", "_")
558 + ToolDefinitions
.LINE_SEPARATOR
);
559 fileBuffer
.append(CommonDefinition
.DEFINE
560 + CommonDefinition
.AUTOGENH
561 + this.moduleId
.getGuid().replaceAll("-", "_")
562 + ToolDefinitions
.LINE_SEPARATOR
563 + ToolDefinitions
.LINE_SEPARATOR
);
566 // Write EFI_SPECIFICATION_VERSION and EDK_RELEASE_VERSION
567 // to autogen.h file.
568 // Note: the specification version and release version should
569 // be get from module surface area instead of hard code.
571 fileBuffer
.append(CommonDefinition
.AUTOGENHBEGIN
);
572 String
[] specList
= saq
.getExternSpecificaiton();
573 for (int i
= 0; i
< specList
.length
; i
++) {
574 fileBuffer
.append(CommonDefinition
.DEFINE
+ specList
[i
]
577 // fileBuffer.append(CommonDefinition.autoGenHLine1);
578 // fileBuffer.append(CommonDefinition.autoGenHLine2);
581 // Write consumed package's mdouleInfo related *.h file to autogen.h.
583 moduleType
= saq
.getModuleType();
584 PackageIdentification
[] cosumedPkglist
= saq
585 .getDependencePkg(this.arch
);
586 headerFileList
= depPkgToAutogenH(cosumedPkglist
, moduleType
);
587 item
= headerFileList
.iterator();
588 while (item
.hasNext()) {
589 fileBuffer
.append(item
.next().toString());
592 // Write library class's related *.h file to autogen.h
594 String
[] libClassList
= saq
595 .getLibraryClasses(CommonDefinition
.ALWAYSCONSUMED
, this.arch
);
596 if (libClassList
!= null) {
597 libClassIncludeH
= LibraryClassToAutogenH(libClassList
);
598 item
= libClassIncludeH
.iterator();
599 while (item
.hasNext()) {
600 fileBuffer
.append(item
.next().toString());
605 .getLibraryClasses(CommonDefinition
.ALWAYSPRODUCED
, this.arch
);
606 if (libClassList
!= null) {
607 libClassIncludeH
= LibraryClassToAutogenH(libClassList
);
608 item
= libClassIncludeH
.iterator();
609 while (item
.hasNext()) {
610 fileBuffer
.append(item
.next().toString());
613 fileBuffer
.append(ToolDefinitions
.LINE_SEPARATOR
);
616 // If is TianoR8FlashMap, copy {Fv_DIR}/FlashMap.h to
617 // {DEST_DIR_DRBUG}/FlashMap.h
619 if (saq
.isHaveTianoR8FlashMap()) {
620 fileBuffer
.append(CommonDefinition
.INCLUDE
);
621 fileBuffer
.append(" <");
622 fileBuffer
.append(CommonDefinition
.TIANOR8PLASHMAPH
+ ">\r\n");
623 copyFlashMapHToDebugDir();
627 // Write PCD information to library AutoGen.h.
629 if (this.myPcdAutogen
!= null) {
630 fileBuffer
.append("\r\n");
631 fileBuffer
.append(this.myPcdAutogen
.getHAutoGenString());
635 // Append the #endif at AutoGen.h
637 fileBuffer
.append("#endif\r\n");
640 // Save content of string buffer to AutoGen.h file.
642 if (!saveFile(outputPath
+ File
.separatorChar
+ "AutoGen.h", fileBuffer
)) {
643 throw new BuildException("Failed to generate AutoGen.h !!!");
650 This function generates AutoGen.h for library.
652 @throws BuildException
653 Failed to generate AutoGen.c.
655 void libGenAutogenC() throws BuildException
, PcdAutogenException
{
656 StringBuffer fileBuffer
= new StringBuffer(10240);
659 // Write Autogen.c header notation
661 fileBuffer
.append(CommonDefinition
.AUTOGENCNOTATION
);
663 fileBuffer
.append(ToolDefinitions
.LINE_SEPARATOR
);
664 fileBuffer
.append(ToolDefinitions
.LINE_SEPARATOR
);
669 this.myPcdAutogen
= new PCDAutoGenAction(moduleId
,
672 saq
.getModulePcdEntryNameArray(),
675 this.myPcdAutogen
.execute();
676 } catch (Exception e
) {
677 throw new PcdAutogenException(e
.getMessage());
680 if (this.myPcdAutogen
!= null) {
681 fileBuffer
.append(ToolDefinitions
.LINE_SEPARATOR
);
682 fileBuffer
.append(this.myPcdAutogen
.getCAutoGenString());
685 if (!saveFile(outputPath
+ File
.separatorChar
+ "AutoGen.c", fileBuffer
)) {
686 throw new BuildException("Failed to generate AutoGen.c !!!");
691 LibraryClassToAutogenH
693 This function returns *.h files declared by library classes which are
694 consumed or produced by current build module or library.
697 List of library class which consumed or produce by current
698 build module or library.
699 @return includeStrList List of *.h file.
701 Set
<String
> LibraryClassToAutogenH(String
[] libClassList
)
702 throws AutoGenException
{
703 Set
<String
> includeStrList
= new LinkedHashSet
<String
>();
704 String includeName
[];
708 // Get include file from GlobalData's SPDTable according to
709 // library class name.
711 for (int i
= 0; i
< libClassList
.length
; i
++) {
712 includeName
= GlobalData
.getLibraryClassHeaderFiles(
713 saq
.getDependencePkg(this.arch
),
715 if (includeName
== null) {
716 throw new AutoGenException("Can not find library class ["
717 + libClassList
[i
] + "] declaration in any SPD package. ");
719 for (int j
= 0; j
< includeName
.length
; j
++) {
720 String includeNameStr
= includeName
[j
];
721 if (includeNameStr
!= null) {
722 str
= CommonDefinition
.INCLUDE
+ " " + "<";
723 str
= str
+ includeNameStr
+ ">\r\n";
724 includeStrList
.add(str
);
725 includeNameStr
= null;
729 return includeStrList
;
735 This function add include file in AutoGen.h file.
737 @param packageNameList
738 List of module depended package.
743 List
<String
> depPkgToAutogenH(PackageIdentification
[] packageNameList
,
744 String moduleType
) throws AutoGenException
{
746 List
<String
> includeStrList
= new LinkedList
<String
>();
748 String includeStr
= "";
751 // Get include file from moduleInfo file
753 for (int i
= 0; i
< packageNameList
.length
; i
++) {
754 pkgHeader
= GlobalData
.getPackageHeaderFiles(packageNameList
[i
],
756 if (pkgHeader
== null) {
757 throw new AutoGenException("Can not find package ["
759 + "] declaration in any SPD package. ");
760 } else if (!pkgHeader
.equalsIgnoreCase("")) {
761 includeStr
= CommonDefinition
.INCLUDE
+ " <" + pkgHeader
763 includeStrList
.add(includeStr
);
767 return includeStrList
;
773 This function convert <ModuleEntryPoint> & <ModuleUnloadImage>
774 information in mas to AutoGen.c
776 @param entryPointList
779 String buffer fo AutoGen.c.
782 void EntryPointToAutoGen(String
[] entryPointList
, String
[] unloadImageList
, StringBuffer fileBuffer
)
783 throws BuildException
{
785 String typeStr
= saq
.getModuleType();
786 int unloadImageCount
= 0;
787 int entryPointCount
= 0;
790 // The parameters and return value of entryPoint is difference
791 // for difference module type.
793 switch (CommonDefinition
.getModuleType(typeStr
)) {
795 case CommonDefinition
.ModuleTypePeiCore
:
796 if (entryPointList
== null ||entryPointList
.length
!= 1 ) {
797 throw new BuildException(
798 "Module type = 'PEI_CORE', can have only one module entry point!");
800 fileBuffer
.append("EFI_STATUS\r\n");
801 fileBuffer
.append("EFIAPI\r\n");
802 fileBuffer
.append(entryPointList
[0]);
803 fileBuffer
.append(" (\r\n");
805 .append(" IN EFI_PEI_STARTUP_DESCRIPTOR *PeiStartupDescriptor,\r\n");
807 .append(" IN VOID *OldCoreData\r\n");
808 fileBuffer
.append(" );\r\n\r\n");
810 fileBuffer
.append("EFI_STATUS\r\n");
811 fileBuffer
.append("EFIAPI\r\n");
812 fileBuffer
.append("ProcessModuleEntryPointList (\r\n");
814 .append(" IN EFI_PEI_STARTUP_DESCRIPTOR *PeiStartupDescriptor,\r\n");
816 .append(" IN VOID *OldCoreData\r\n");
817 fileBuffer
.append(" )\r\n\r\n");
818 fileBuffer
.append("{\r\n");
819 fileBuffer
.append(" return ");
820 fileBuffer
.append(entryPointList
[0]);
821 fileBuffer
.append(" (PeiStartupDescriptor, OldCoreData);\r\n");
822 fileBuffer
.append("}\r\n\r\n");
826 case CommonDefinition
.ModuleTypeDxeCore
:
827 fileBuffer
.append("const UINT32 _gUefiDriverRevision = 0;\r\n");
828 if (entryPointList
== null || entryPointList
.length
!= 1) {
829 throw new BuildException(
830 "Module type = 'DXE_CORE', can have only one module entry point!");
833 fileBuffer
.append("VOID\r\n");
834 fileBuffer
.append("EFIAPI\r\n");
835 fileBuffer
.append(entryPointList
[0]);
836 fileBuffer
.append(" (\n");
837 fileBuffer
.append(" IN VOID *HobStart\r\n");
838 fileBuffer
.append(" );\r\n\r\n");
840 fileBuffer
.append("VOID\r\n");
841 fileBuffer
.append("EFIAPI\r\n");
842 fileBuffer
.append("ProcessModuleEntryPointList (\r\n");
843 fileBuffer
.append(" IN VOID *HobStart\r\n");
844 fileBuffer
.append(" )\r\n\r\n");
845 fileBuffer
.append("{\r\n");
846 fileBuffer
.append(" ");
847 fileBuffer
.append(entryPointList
[0]);
848 fileBuffer
.append(" (HobStart);\r\n");
849 fileBuffer
.append("}\r\n\r\n");
853 case CommonDefinition
.ModuleTypePeim
:
856 .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT32 _gPeimRevision = 0;\r\n");
857 if (entryPointList
== null || entryPointList
.length
== 0) {
858 fileBuffer
.append("EFI_STATUS\r\n");
859 fileBuffer
.append("EFIAPI\r\n");
860 fileBuffer
.append("ProcessModuleEntryPointList (\r\n");
861 fileBuffer
.append(" IN EFI_FFS_FILE_HEADER *FfsHeader,\r\n");
862 fileBuffer
.append(" IN EFI_PEI_SERVICES **PeiServices\r\n");
863 fileBuffer
.append(" )\r\n\r\n");
864 fileBuffer
.append("{\r\n");
865 fileBuffer
.append(" return EFI_SUCCESS;\r\n");
866 fileBuffer
.append("}\r\n\r\n");
869 for (int i
= 0; i
< entryPointList
.length
; i
++) {
870 fileBuffer
.append("EFI_STATUS\r\n");
871 fileBuffer
.append("EFIAPI\r\n");
872 fileBuffer
.append(entryPointList
[i
]);
873 fileBuffer
.append(" (\r\n");
875 .append(" IN EFI_FFS_FILE_HEADER *FfsHeader,\r\n");
877 .append(" IN EFI_PEI_SERVICES **PeiServices\r\n");
878 fileBuffer
.append(" );\r\n");
883 fileBuffer
.append("EFI_STATUS\r\n");
884 fileBuffer
.append("EFIAPI\r\n");
885 fileBuffer
.append("ProcessModuleEntryPointList (\r\n");
886 fileBuffer
.append(" IN EFI_FFS_FILE_HEADER *FfsHeader,\r\n");
887 fileBuffer
.append(" IN EFI_PEI_SERVICES **PeiServices\r\n");
888 fileBuffer
.append(" )\r\n\r\n");
889 fileBuffer
.append("{\r\n");
890 if (entryPointCount
== 1) {
891 fileBuffer
.append(" return ");
892 fileBuffer
.append(entryPointList
[0]);
893 fileBuffer
.append(" (FfsHeader, PeiServices);\r\n");
895 fileBuffer
.append(" EFI_STATUS Status;\r\n");
896 fileBuffer
.append(" EFI_STATUS CombinedStatus;\r\n\r\n");
897 fileBuffer
.append(" CombinedStatus = EFI_LOAD_ERROR;\r\n\r\n");
898 for (int i
= 0; i
< entryPointList
.length
; i
++) {
899 if (!entryPointList
[i
].equals("")) {
900 fileBuffer
.append(" Status = ");
901 fileBuffer
.append(entryPointList
[i
]);
902 fileBuffer
.append(" (FfsHeader, PeiServices);\r\n");
904 .append(" if (!EFI_ERROR (Status) || EFI_ERROR (CombinedStatus)) {\r\n");
905 fileBuffer
.append(" CombinedStatus = Status;\r\n");
906 fileBuffer
.append(" }\r\n\r\n");
911 fileBuffer
.append(" return CombinedStatus;\r\n");
913 fileBuffer
.append("}\r\n\r\n");
916 case CommonDefinition
.ModuleTypeDxeSmmDriver
:
919 // If entryPoint is null, create an empty ProcessModuleEntryPointList
922 if (entryPointList
== null || entryPointList
.length
== 0) {
924 .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gDriverEntryPointCount = ");
925 fileBuffer
.append(Integer
.toString(entryPointCount
));
926 fileBuffer
.append(";\r\n");
927 fileBuffer
.append("EFI_STATUS\r\n");
928 fileBuffer
.append("EFIAPI\r\n");
929 fileBuffer
.append("ProcessModuleEntryPointList (\r\n");
930 fileBuffer
.append(" IN EFI_HANDLE ImageHandle,\r\n");
931 fileBuffer
.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");
932 fileBuffer
.append(" )\r\n\r\n");
933 fileBuffer
.append("{\r\n");
934 fileBuffer
.append(" return EFI_SUCCESS;\r\n");
935 fileBuffer
.append("}\r\n\r\n");
938 for (int i
= 0; i
< entryPointList
.length
; i
++) {
939 fileBuffer
.append("EFI_STATUS\r\n");
940 fileBuffer
.append("EFIAPI\r\n");
941 fileBuffer
.append(entryPointList
[i
]);
942 fileBuffer
.append(" (\r\n");
943 fileBuffer
.append(" IN EFI_HANDLE ImageHandle,\r\n");
944 fileBuffer
.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");
945 fileBuffer
.append(" );\r\n");
949 .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gDriverEntryPointCount = ");
950 fileBuffer
.append(Integer
.toString(entryPointCount
));
951 fileBuffer
.append(";\r\n");
953 .append("static BASE_LIBRARY_JUMP_BUFFER mJumpContext;\r\n");
955 .append("static EFI_STATUS mDriverEntryPointStatus = EFI_LOAD_ERROR;\r\n\r\n");
957 fileBuffer
.append("EFI_STATUS\r\n");
958 fileBuffer
.append("EFIAPI\r\n");
959 fileBuffer
.append("ProcessModuleEntryPointList (\r\n");
960 fileBuffer
.append(" IN EFI_HANDLE ImageHandle,\r\n");
961 fileBuffer
.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");
962 fileBuffer
.append(" )\r\n\r\n");
963 fileBuffer
.append("{\r\n");
966 for (int i
= 0; i
< entryPointList
.length
; i
++) {
968 .append(" if (SetJump (&mJumpContext) == 0) {\r\n");
969 fileBuffer
.append(" ExitDriver (");
970 fileBuffer
.append(entryPointList
[i
]);
971 fileBuffer
.append(" (ImageHandle, SystemTable));\r\n");
972 fileBuffer
.append(" ASSERT (FALSE);\r\n");
973 fileBuffer
.append(" }\r\n");
976 fileBuffer
.append(" return mDriverEntryPointStatus;\r\n");
977 fileBuffer
.append("}\r\n\r\n");
979 fileBuffer
.append("VOID\r\n");
980 fileBuffer
.append("EFIAPI\r\n");
981 fileBuffer
.append("ExitDriver (\r\n");
982 fileBuffer
.append(" IN EFI_STATUS Status\n");
983 fileBuffer
.append(" )\r\n\r\n");
984 fileBuffer
.append("{\r\n");
986 .append(" if (!EFI_ERROR (Status) || EFI_ERROR (mDriverEntryPointStatus)) {\r\n");
987 fileBuffer
.append(" mDriverEntryPointStatus = Status;\r\n");
988 fileBuffer
.append(" }\r\n");
989 fileBuffer
.append(" LongJump (&mJumpContext, (UINTN)-1);\r\n");
990 fileBuffer
.append(" ASSERT (FALSE);\r\n");
991 fileBuffer
.append("}\r\n\r\n");
997 // Add "ModuleUnloadImage" for DxeSmmDriver module type;
999 //entryPointList = SurfaceAreaQuery.getModuleUnloadImageArray();
1000 //entryPointList = CommonDefinition.remDupString(entryPointList);
1001 //entryPointCount = 0;
1003 unloadImageCount
= 0;
1004 if (unloadImageList
!= null) {
1005 for (int i
= 0; i
< unloadImageList
.length
; i
++) {
1006 fileBuffer
.append("EFI_STATUS\r\n");
1007 fileBuffer
.append("EFIAPI\r\n");
1008 fileBuffer
.append(unloadImageList
[i
]);
1009 fileBuffer
.append(" (\r\n");
1011 .append(" IN EFI_HANDLE ImageHandle\r\n");
1012 fileBuffer
.append(" );\r\n");
1018 .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gDriverUnloadImageCount = ");
1019 fileBuffer
.append(Integer
.toString(unloadImageCount
));
1020 fileBuffer
.append(";\r\n\r\n");
1022 fileBuffer
.append("EFI_STATUS\r\n");
1023 fileBuffer
.append("EFIAPI\r\n");
1024 fileBuffer
.append("ProcessModuleUnloadList (\r\n");
1025 fileBuffer
.append(" IN EFI_HANDLE ImageHandle\r\n");
1026 fileBuffer
.append(" )\r\n");
1027 fileBuffer
.append("{\r\n");
1029 if (unloadImageCount
== 0) {
1030 fileBuffer
.append(" return EFI_SUCCESS;\r\n");
1031 } else if (unloadImageCount
== 1) {
1032 fileBuffer
.append(" return ");
1033 fileBuffer
.append(unloadImageList
[0]);
1034 fileBuffer
.append("(ImageHandle);\r\n");
1036 fileBuffer
.append(" EFI_STATUS Status;\r\n\r\n");
1037 fileBuffer
.append(" Status = EFI_SUCCESS;\r\n\r\n");
1038 for (int i
= 0; i
< unloadImageList
.length
; i
++) {
1040 fileBuffer
.append(" Status = ");
1041 fileBuffer
.append(unloadImageList
[i
]);
1042 fileBuffer
.append("(ImageHandle);\r\n");
1044 fileBuffer
.append(" if (EFI_ERROR (Status)) {\r\n");
1045 fileBuffer
.append(" ");
1046 fileBuffer
.append(unloadImageList
[i
]);
1047 fileBuffer
.append("(ImageHandle);\r\n");
1048 fileBuffer
.append(" } else {\r\n");
1049 fileBuffer
.append(" Status = ");
1050 fileBuffer
.append(unloadImageList
[i
]);
1051 fileBuffer
.append("(ImageHandle);\r\n");
1052 fileBuffer
.append(" }\r\n");
1055 fileBuffer
.append(" return Status;\r\n");
1057 fileBuffer
.append("}\r\n\r\n");
1060 case CommonDefinition
.ModuleTypeDxeRuntimeDriver
:
1061 case CommonDefinition
.ModuleTypeDxeDriver
:
1062 case CommonDefinition
.ModuleTypeDxeSalDriver
:
1063 case CommonDefinition
.ModuleTypeUefiDriver
:
1064 case CommonDefinition
.ModuleTypeUefiApplication
:
1065 entryPointCount
= 0;
1066 fileBuffer
.append("const UINT32 _gUefiDriverRevision = 0;\r\n");
1068 // If entry point is null, create a empty ProcessModuleEntryPointList function.
1070 if (entryPointList
== null || entryPointList
.length
== 0) {
1072 .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gDriverEntryPointCount = 0;\r\n");
1073 fileBuffer
.append("EFI_STATUS\r\n");
1074 fileBuffer
.append("EFIAPI\r\n");
1075 fileBuffer
.append("ProcessModuleEntryPointList (\r\n");
1076 fileBuffer
.append(" IN EFI_HANDLE ImageHandle,\r\n");
1077 fileBuffer
.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");
1078 fileBuffer
.append(" )\r\n\r\n");
1079 fileBuffer
.append("{\r\n");
1080 fileBuffer
.append(" return EFI_SUCCESS;\r\n");
1081 fileBuffer
.append("}\r\n");
1084 for (int i
= 0; i
< entryPointList
.length
; i
++) {
1086 fileBuffer
.append("EFI_STATUS\r\n");
1087 fileBuffer
.append("EFIAPI\r\n");
1088 fileBuffer
.append(entryPointList
[i
]);
1089 fileBuffer
.append(" (\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");
1097 .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gDriverEntryPointCount = ");
1098 fileBuffer
.append(Integer
.toString(entryPointCount
));
1099 fileBuffer
.append(";\r\n");
1100 if (entryPointCount
> 1) {
1102 .append("static BASE_LIBRARY_JUMP_BUFFER mJumpContext;\r\n");
1104 .append("static EFI_STATUS mDriverEntryPointStatus = EFI_LOAD_ERROR;\r\n");
1106 fileBuffer
.append("\n");
1108 fileBuffer
.append("EFI_STATUS\r\n");
1109 fileBuffer
.append("EFIAPI\r\n");
1110 fileBuffer
.append("ProcessModuleEntryPointList (\r\n");
1111 fileBuffer
.append(" IN EFI_HANDLE ImageHandle,\r\n");
1112 fileBuffer
.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");
1113 fileBuffer
.append(" )\r\n\r\n");
1114 fileBuffer
.append("{\r\n");
1116 if (entryPointCount
== 1) {
1117 fileBuffer
.append(" return (");
1118 fileBuffer
.append(entryPointList
[0]);
1119 fileBuffer
.append(" (ImageHandle, SystemTable));\r\n");
1121 for (int i
= 0; i
< entryPointList
.length
; i
++) {
1122 if (!entryPointList
[i
].equals("")) {
1124 .append(" if (SetJump (&mJumpContext) == 0) {\r\n");
1125 fileBuffer
.append(" ExitDriver (");
1126 fileBuffer
.append(entryPointList
[i
]);
1127 fileBuffer
.append(" (ImageHandle, SystemTable));\r\n");
1128 fileBuffer
.append(" ASSERT (FALSE);\r\n");
1129 fileBuffer
.append(" }\r\n");
1134 fileBuffer
.append(" return mDriverEntryPointStatus;\r\n");
1136 fileBuffer
.append("}\r\n\r\n");
1138 fileBuffer
.append("VOID\r\n");
1139 fileBuffer
.append("EFIAPI\r\n");
1140 fileBuffer
.append("ExitDriver (\r\n");
1141 fileBuffer
.append(" IN EFI_STATUS Status\r\n");
1142 fileBuffer
.append(" )\r\n\r\n");
1143 fileBuffer
.append("{\r\n");
1144 if (entryPointCount
<= 1) {
1145 fileBuffer
.append(" if (EFI_ERROR (Status)) {\r\n");
1147 .append(" ProcessLibraryDestructorList (gImageHandle, gST);\r\n");
1148 fileBuffer
.append(" }\r\n");
1150 .append(" gBS->Exit (gImageHandle, Status, 0, NULL);\r\n");
1153 .append(" if (!EFI_ERROR (Status) || EFI_ERROR (mDriverEntryPointStatus)) {\r\n");
1154 fileBuffer
.append(" mDriverEntryPointStatus = Status;\r\n");
1155 fileBuffer
.append(" }\r\n");
1156 fileBuffer
.append(" LongJump (&mJumpContext, (UINTN)-1);\r\n");
1157 fileBuffer
.append(" ASSERT (FALSE);\r\n");
1159 fileBuffer
.append("}\r\n\r\n");
1164 // Add ModuleUnloadImage for DxeDriver and UefiDriver module type.
1166 //entryPointList = SurfaceAreaQuery.getModuleUnloadImageArray();
1168 // Remover duplicate unload entry point.
1170 //entryPointList = CommonDefinition.remDupString(entryPointList);
1171 //entryPointCount = 0;
1172 unloadImageCount
= 0;
1173 if (unloadImageList
!= null) {
1174 for (int i
= 0; i
< unloadImageList
.length
; i
++) {
1175 fileBuffer
.append("EFI_STATUS\r\n");
1176 fileBuffer
.append("EFIAPI\r\n");
1177 fileBuffer
.append(unloadImageList
[i
]);
1178 fileBuffer
.append(" (\r\n");
1180 .append(" IN EFI_HANDLE ImageHandle\r\n");
1181 fileBuffer
.append(" );\r\n");
1187 .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gDriverUnloadImageCount = ");
1188 fileBuffer
.append(Integer
.toString(unloadImageCount
));
1189 fileBuffer
.append(";\r\n\r\n");
1191 fileBuffer
.append("EFI_STATUS\n");
1192 fileBuffer
.append("EFIAPI\r\n");
1193 fileBuffer
.append("ProcessModuleUnloadList (\r\n");
1194 fileBuffer
.append(" IN EFI_HANDLE ImageHandle\r\n");
1195 fileBuffer
.append(" )\r\n");
1196 fileBuffer
.append("{\r\n");
1198 if (unloadImageCount
== 0) {
1199 fileBuffer
.append(" return EFI_SUCCESS;\r\n");
1200 } else if (unloadImageCount
== 1) {
1201 fileBuffer
.append(" return ");
1202 fileBuffer
.append(unloadImageList
[0]);
1203 fileBuffer
.append("(ImageHandle);\r\n");
1205 fileBuffer
.append(" EFI_STATUS Status;\r\n\r\n");
1206 fileBuffer
.append(" Status = EFI_SUCCESS;\r\n\r\n");
1207 for (int i
= 0; i
< unloadImageList
.length
; i
++) {
1209 fileBuffer
.append(" Status = ");
1210 fileBuffer
.append(unloadImageList
[i
]);
1211 fileBuffer
.append("(ImageHandle);\r\n");
1213 fileBuffer
.append(" if (EFI_ERROR (Status)) {\r\n");
1214 fileBuffer
.append(" ");
1215 fileBuffer
.append(unloadImageList
[i
]);
1216 fileBuffer
.append("(ImageHandle);\r\n");
1217 fileBuffer
.append(" } else {\r\n");
1218 fileBuffer
.append(" Status = ");
1219 fileBuffer
.append(unloadImageList
[i
]);
1220 fileBuffer
.append("(ImageHandle);\r\n");
1221 fileBuffer
.append(" }\r\n");
1224 fileBuffer
.append(" return Status;\r\n");
1226 fileBuffer
.append("}\r\n\r\n");
1234 This function gets GUIDs from SPD file accrodeing to <PPIs> information
1235 and write those GUIDs to AutoGen.c.
1238 String Buffer for Autogen.c file.
1239 @throws BuildException
1240 Guid must set value!
1242 void PpiGuidToAutogenC(StringBuffer fileBuffer
) throws AutoGenException
{
1243 String
[] cNameGuid
= null;
1246 // Get the all PPI adn PPI Notify from MSA file,
1247 // then add those PPI ,and PPI Notify name to list.
1250 String
[] ppiList
= saq
.getPpiArray(this.arch
);
1251 for (int i
= 0; i
< ppiList
.length
; i
++) {
1252 this.mPpiList
.add(ppiList
[i
]);
1255 String
[] ppiNotifyList
= saq
.getPpiNotifyArray(this.arch
);
1256 for (int i
= 0; i
< ppiNotifyList
.length
; i
++) {
1257 this.mPpiList
.add(ppiNotifyList
[i
]);
1261 // Find CNAME and GUID from dependence SPD file and write to Autogen.c
1263 Iterator ppiIterator
= this.mPpiList
.iterator();
1264 String ppiKeyWord
= null;
1265 while (ppiIterator
.hasNext()) {
1266 ppiKeyWord
= ppiIterator
.next().toString();
1267 cNameGuid
= GlobalData
.getPpiGuid(this.mDepPkgList
, ppiKeyWord
);
1268 if (cNameGuid
!= null) {
1270 .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID ");
1271 fileBuffer
.append(cNameGuid
[0]);
1272 fileBuffer
.append(" = { ");
1273 fileBuffer
.append(CommonDefinition
.formatGuidName(cNameGuid
[1]));
1274 fileBuffer
.append(" } ;");
1277 // If can't find Ppi GUID declaration in every package
1279 throw new AutoGenException("Can not find Ppi GUID ["
1280 + ppiKeyWord
+ "] declaration in any SPD package!");
1286 ProtocolGuidToAutogenc
1288 This function gets GUIDs from SPD file accrodeing to <Protocol>
1289 information and write those GUIDs to AutoGen.c.
1292 String Buffer for Autogen.c file.
1293 @throws BuildException
1294 Protocol name must set.
1296 void ProtocolGuidToAutogenC(StringBuffer fileBuffer
) throws BuildException
{
1297 String
[] cNameGuid
= null;
1299 String
[] protocolList
= saq
.getProtocolArray(this.arch
);
1302 // Add result to Autogen global list.
1304 for (int i
= 0; i
< protocolList
.length
; i
++) {
1305 this.mProtocolList
.add(protocolList
[i
]);
1308 String
[] protocolNotifyList
= saq
1309 .getProtocolNotifyArray(this.arch
);
1311 for (int i
= 0; i
< protocolNotifyList
.length
; i
++) {
1312 this.mProtocolList
.add(protocolNotifyList
[i
]);
1316 // Get the NAME and GUID from dependence SPD and write to Autogen.c
1318 Iterator protocolIterator
= this.mProtocolList
.iterator();
1319 String protocolKeyWord
= null;
1322 while (protocolIterator
.hasNext()) {
1323 protocolKeyWord
= protocolIterator
.next().toString();
1324 cNameGuid
= GlobalData
.getProtocolGuid(this.mDepPkgList
, protocolKeyWord
);
1325 if (cNameGuid
!= null) {
1327 .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID ");
1328 fileBuffer
.append(cNameGuid
[0]);
1329 fileBuffer
.append(" = { ");
1330 fileBuffer
.append(CommonDefinition
.formatGuidName(cNameGuid
[1]));
1331 fileBuffer
.append(" } ;");
1334 // If can't find protocol GUID declaration in every package
1336 throw new BuildException("Can not find protocol Guid ["
1337 + protocolKeyWord
+ "] declaration in any SPD package!");
1345 This function gets GUIDs from SPD file accrodeing to <Guids> information
1346 and write those GUIDs to AutoGen.c.
1349 String Buffer for Autogen.c file.
1352 void GuidGuidToAutogenC(StringBuffer fileBuffer
) throws AutoGenException
{
1353 String
[] cNameGuid
= null;
1354 String guidKeyWord
= null;
1356 String
[] guidList
= saq
.getGuidEntryArray(this.arch
);
1358 for (int i
= 0; i
< guidList
.length
; i
++) {
1359 this.mGuidList
.add(guidList
[i
]);
1363 Iterator guidIterator
= this.mGuidList
.iterator();
1364 while (guidIterator
.hasNext()) {
1365 guidKeyWord
= guidIterator
.next().toString();
1366 cNameGuid
= GlobalData
.getGuid(this.mDepPkgList
, guidKeyWord
);
1368 if (cNameGuid
!= null) {
1370 .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID ");
1371 fileBuffer
.append(cNameGuid
[0]);
1372 fileBuffer
.append(" = { ");
1373 fileBuffer
.append(CommonDefinition
.formatGuidName(cNameGuid
[1]));
1374 fileBuffer
.append("} ;");
1377 // If can't find GUID declaration in every package
1379 throw new AutoGenException("Can not find Guid [" + guidKeyWord
1380 + "] declaration in any SPD package. ");
1387 LibInstanceToAutogenC
1389 This function adds dependent library instance to autogen.c,which
1390 includeing library's constructor, destructor, and library dependent ppi,
1391 protocol, guid, pcd information.
1394 String buffer for AutoGen.c
1395 @throws BuildException
1397 void LibInstanceToAutogenC(StringBuffer fileBuffer
) throws BuildException
{
1399 String moduleType
= this.moduleId
.getModuleType();
1401 // Add library constructor to AutoGen.c
1403 LibConstructorToAutogenC(libConstructList
, moduleType
,
1404 fileBuffer
/* autogenC */);
1406 // Add library destructor to AutoGen.c
1408 LibDestructorToAutogenC(libDestructList
, moduleType
, fileBuffer
/* autogenC */);
1409 } catch (Exception e
) {
1410 throw new BuildException(e
.getMessage());
1415 LibConstructorToAutogenc
1417 This function writes library constructor list to AutoGen.c. The library
1418 constructor's parameter and return value depend on module type.
1420 @param libInstanceList
1421 List of library construct name.
1425 String buffer for AutoGen.c
1428 void LibConstructorToAutogenC(List
<String
> libInstanceList
,
1429 String moduleType
, StringBuffer fileBuffer
) throws Exception
{
1430 boolean isFirst
= true;
1433 // The library constructor's parameter and return value depend on
1436 for (int i
= 0; i
< libInstanceList
.size(); i
++) {
1437 switch (CommonDefinition
.getModuleType(moduleType
)) {
1438 case CommonDefinition
.ModuleTypeBase
:
1439 fileBuffer
.append("RETURN_STATUS\r\n");
1440 fileBuffer
.append("EFIAPI\r\n");
1441 fileBuffer
.append(libInstanceList
.get(i
));
1442 fileBuffer
.append(" (\r\n");
1443 fileBuffer
.append(" VOID\r\n");
1444 fileBuffer
.append(" );\r\n");
1447 case CommonDefinition
.ModuleTypePeiCore
:
1448 case CommonDefinition
.ModuleTypePeim
:
1449 fileBuffer
.append("EFI_STATUS\r\n");
1450 fileBuffer
.append("EFIAPI\r\n");
1451 fileBuffer
.append(libInstanceList
.get(i
));
1452 fileBuffer
.append(" (\r\n");
1454 .append(" IN EFI_FFS_FILE_HEADER *FfsHeader,\r\n");
1456 .append(" IN EFI_PEI_SERVICES **PeiServices\r\n");
1457 fileBuffer
.append(" );\r\n");
1460 case CommonDefinition
.ModuleTypeDxeCore
:
1461 case CommonDefinition
.ModuleTypeDxeDriver
:
1462 case CommonDefinition
.ModuleTypeDxeRuntimeDriver
:
1463 case CommonDefinition
.ModuleTypeDxeSmmDriver
:
1464 case CommonDefinition
.ModuleTypeDxeSalDriver
:
1465 case CommonDefinition
.ModuleTypeUefiDriver
:
1466 case CommonDefinition
.ModuleTypeUefiApplication
:
1467 fileBuffer
.append("EFI_STATUS\r\n");
1468 fileBuffer
.append("EFIAPI\r\n");
1469 fileBuffer
.append(libInstanceList
.get(i
));
1470 fileBuffer
.append(" (\r\n");
1471 fileBuffer
.append(" IN EFI_HANDLE ImageHandle,\r\n");
1472 fileBuffer
.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");
1473 fileBuffer
.append(" );\r\n");
1479 // Add ProcessLibraryConstructorList in AutoGen.c
1481 fileBuffer
.append("VOID\r\n");
1482 fileBuffer
.append("EFIAPI\r\n");
1483 fileBuffer
.append("ProcessLibraryConstructorList (\r\n");
1484 switch (CommonDefinition
.getModuleType(moduleType
)) {
1485 case CommonDefinition
.ModuleTypeBase
:
1486 fileBuffer
.append(" VOID\r\n");
1489 case CommonDefinition
.ModuleTypePeiCore
:
1490 case CommonDefinition
.ModuleTypePeim
:
1491 fileBuffer
.append(" IN EFI_FFS_FILE_HEADER *FfsHeader,\r\n");
1493 .append(" IN EFI_PEI_SERVICES **PeiServices\r\n");
1496 case CommonDefinition
.ModuleTypeDxeCore
:
1497 case CommonDefinition
.ModuleTypeDxeDriver
:
1498 case CommonDefinition
.ModuleTypeDxeRuntimeDriver
:
1499 case CommonDefinition
.ModuleTypeDxeSmmDriver
:
1500 case CommonDefinition
.ModuleTypeDxeSalDriver
:
1501 case CommonDefinition
.ModuleTypeUefiDriver
:
1502 case CommonDefinition
.ModuleTypeUefiApplication
:
1503 fileBuffer
.append(" IN EFI_HANDLE ImageHandle,\r\n");
1504 fileBuffer
.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");
1508 fileBuffer
.append(" )\r\n");
1509 fileBuffer
.append("{\r\n");
1511 // If no constructor function, return EFI_SUCCESS.
1513 //if (libInstanceList.size() == 0){
1514 // fileBuffer.append(" return EFI_SUCCESS;\r\n");
1516 for (int i
= 0; i
< libInstanceList
.size(); i
++) {
1518 fileBuffer
.append(" EFI_STATUS Status;\r\n");
1519 fileBuffer
.append(" Status = EFI_SUCCESS;\r\n");
1520 fileBuffer
.append("\r\n");
1523 switch (CommonDefinition
.getModuleType(moduleType
)) {
1524 case CommonDefinition
.ModuleTypeBase
:
1525 fileBuffer
.append(" Status = ");
1526 fileBuffer
.append(libInstanceList
.get(i
));
1527 fileBuffer
.append("();\r\n");
1528 fileBuffer
.append(" VOID\r\n");
1530 case CommonDefinition
.ModuleTypePeiCore
:
1531 case CommonDefinition
.ModuleTypePeim
:
1532 fileBuffer
.append(" Status = ");
1533 fileBuffer
.append(libInstanceList
.get(i
));
1534 fileBuffer
.append(" (FfsHeader, PeiServices);\r\n");
1536 case CommonDefinition
.ModuleTypeDxeCore
:
1537 case CommonDefinition
.ModuleTypeDxeDriver
:
1538 case CommonDefinition
.ModuleTypeDxeRuntimeDriver
:
1539 case CommonDefinition
.ModuleTypeDxeSmmDriver
:
1540 case CommonDefinition
.ModuleTypeDxeSalDriver
:
1541 case CommonDefinition
.ModuleTypeUefiDriver
:
1542 case CommonDefinition
.ModuleTypeUefiApplication
:
1543 fileBuffer
.append(" Status = ");
1544 fileBuffer
.append(libInstanceList
.get(i
));
1545 fileBuffer
.append(" (ImageHandle, SystemTable);\r\n");
1548 EdkLog
.log(EdkLog
.EDK_INFO
,"Autogen doesn't know how to deal with module type - " + moduleType
+ "!");
1550 fileBuffer
.append(" ASSERT_EFI_ERROR (Status);\r\n");
1552 fileBuffer
.append("}\r\n");
1556 LibDestructorToAutogenc
1558 This function writes library destructor list to AutoGen.c. The library
1559 destructor's parameter and return value depend on module type.
1561 @param libInstanceList
1562 List of library destructor name.
1566 String buffer for AutoGen.c
1569 void LibDestructorToAutogenC(List
<String
> libInstanceList
,
1570 String moduleType
, StringBuffer fileBuffer
) throws Exception
{
1571 boolean isFirst
= true;
1572 for (int i
= 0; i
< libInstanceList
.size(); i
++) {
1573 switch (CommonDefinition
.getModuleType(moduleType
)) {
1574 case CommonDefinition
.ModuleTypeBase
:
1575 fileBuffer
.append("RETURN_STATUS\r\n");
1576 fileBuffer
.append("EFIAPI\r\n");
1577 fileBuffer
.append(libInstanceList
.get(i
));
1578 fileBuffer
.append(" (\r\n");
1579 fileBuffer
.append(" VOID\r\n");
1580 fileBuffer
.append(" );\r\n");
1582 case CommonDefinition
.ModuleTypePeiCore
:
1583 case CommonDefinition
.ModuleTypePeim
:
1584 fileBuffer
.append("EFI_STATUS\r\n");
1585 fileBuffer
.append("EFIAPI\r\n");
1586 fileBuffer
.append(libInstanceList
.get(i
));
1587 fileBuffer
.append(" (\r\n");
1589 .append(" IN EFI_FFS_FILE_HEADER *FfsHeader,\r\n");
1591 .append(" IN EFI_PEI_SERVICES **PeiServices\r\n");
1592 fileBuffer
.append(" );\r\n");
1594 case CommonDefinition
.ModuleTypeDxeCore
:
1595 case CommonDefinition
.ModuleTypeDxeDriver
:
1596 case CommonDefinition
.ModuleTypeDxeRuntimeDriver
:
1597 case CommonDefinition
.ModuleTypeDxeSmmDriver
:
1598 case CommonDefinition
.ModuleTypeDxeSalDriver
:
1599 case CommonDefinition
.ModuleTypeUefiDriver
:
1600 case CommonDefinition
.ModuleTypeUefiApplication
:
1601 fileBuffer
.append("EFI_STATUS\r\n");
1602 fileBuffer
.append("EFIAPI\r\n");
1603 fileBuffer
.append(libInstanceList
.get(i
));
1604 fileBuffer
.append(" (\r\n");
1605 fileBuffer
.append(" IN EFI_HANDLE ImageHandle,\r\n");
1606 fileBuffer
.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");
1607 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 fileBuffer
.append(" Status = ");
1646 fileBuffer
.append(libInstanceList
.get(i
));
1647 fileBuffer
.append("(ImageHandle, SystemTable);\r\n");
1648 fileBuffer
.append(" ASSERT_EFI_ERROR (Status);\r\n");
1650 fileBuffer
.append("}\r\n");
1656 ExternsDriverBindingToAutoGenC
1658 This function is to write DRIVER_BINDING, COMPONENT_NAME,
1659 DRIVER_CONFIGURATION, DRIVER_DIAGNOSTIC in AutoGen.c.
1662 String buffer for AutoGen.c
1664 void ExternsDriverBindingToAutoGenC(StringBuffer fileBuffer
)
1665 throws BuildException
{
1668 // Check what <extern> contains. And the number of following elements
1669 // under <extern> should be same. 1. DRIVER_BINDING 2. COMPONENT_NAME
1670 // 3.DRIVER_CONFIGURATION 4. DRIVER_DIAGNOSTIC
1673 String
[] drvBindList
= saq
.getDriverBindingArray();
1676 // If component name protocol,component configuration protocol,
1677 // component diagnostic protocol is not null or empty, check
1678 // if every one have the same number of the driver binding protocol.
1680 if (drvBindList
== null || drvBindList
.length
== 0) {
1684 String
[] compNamList
= saq
.getComponentNameArray();
1685 String
[] compConfList
= saq
.getDriverConfigArray();
1686 String
[] compDiagList
= saq
.getDriverDiagArray();
1691 // Write driver binding protocol extern to autogen.c
1693 for (int i
= 0; i
< drvBindList
.length
; i
++) {
1694 fileBuffer
.append("extern EFI_DRIVER_BINDING_PROTOCOL ");
1695 fileBuffer
.append(drvBindList
[i
]);
1696 fileBuffer
.append(";\r\n");
1700 // Write component name protocol extern to autogen.c
1702 if (compNamList
!= null && compNamList
.length
!= 0) {
1703 if (drvBindList
.length
!= compNamList
.length
) {
1704 throw new BuildException(
1705 "Different number of Driver Binding and Component Name protocols!");
1709 for (int i
= 0; i
< compNamList
.length
; i
++) {
1710 fileBuffer
.append("extern EFI_COMPONENT_NAME_PROTOCOL ");
1711 fileBuffer
.append(compNamList
[i
]);
1712 fileBuffer
.append(";\r\n");
1717 // Write driver configration protocol extern to autogen.c
1719 if (compConfList
!= null && compConfList
.length
!= 0) {
1720 if (drvBindList
.length
!= compConfList
.length
) {
1721 throw new BuildException(
1722 "Different number of Driver Binding and Driver Configuration protocols!");
1726 for (int i
= 0; i
< compConfList
.length
; i
++) {
1727 fileBuffer
.append("extern EFI_DRIVER_CONFIGURATION_PROTOCOL ");
1728 fileBuffer
.append(compConfList
[i
]);
1729 fileBuffer
.append(";\r\n");
1734 // Write driver dignastic protocol extern to autogen.c
1736 if (compDiagList
!= null && compDiagList
.length
!= 0) {
1737 if (drvBindList
.length
!= compDiagList
.length
) {
1738 throw new BuildException(
1739 "Different number of Driver Binding and Driver Diagnosis protocols!");
1743 for (int i
= 0; i
< compDiagList
.length
; i
++) {
1744 fileBuffer
.append("extern EFI_DRIVER_DIAGNOSTICS_PROTOCOL ");
1745 fileBuffer
.append(compDiagList
[i
]);
1746 fileBuffer
.append(";\r\n");
1751 // Write driver module protocol bitmask.
1754 .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gDriverModelProtocolBitmask = ");
1755 fileBuffer
.append(Integer
.toString(BitMask
));
1756 fileBuffer
.append(";\r\n");
1759 // Write driver module protocol list entry
1762 .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINTN _gDriverModelProtocolListEntries = ");
1764 fileBuffer
.append(Integer
.toString(drvBindList
.length
));
1765 fileBuffer
.append(";\r\n");
1768 // Write drive module protocol list to autogen.c
1771 .append("GLOBAL_REMOVE_IF_UNREFERENCED const EFI_DRIVER_MODEL_PROTOCOL_LIST _gDriverModelProtocolList[] = {");
1772 for (int i
= 0; i
< drvBindList
.length
; i
++) {
1774 fileBuffer
.append(",");
1776 fileBuffer
.append("\r\n {\r\n");
1777 fileBuffer
.append(" &");
1778 fileBuffer
.append(drvBindList
[i
]);
1779 fileBuffer
.append(", \r\n");
1781 if (compNamList
!= null) {
1782 fileBuffer
.append(" &");
1783 fileBuffer
.append(compNamList
[i
]);
1784 fileBuffer
.append(", \r\n");
1786 fileBuffer
.append(" NULL, \r\n");
1789 if (compConfList
!= null) {
1790 fileBuffer
.append(" &");
1791 fileBuffer
.append(compConfList
[i
]);
1792 fileBuffer
.append(", \r\n");
1794 fileBuffer
.append(" NULL, \r\n");
1797 if (compDiagList
!= null) {
1798 fileBuffer
.append(" &");
1799 fileBuffer
.append(compDiagList
[i
]);
1800 fileBuffer
.append(", \r\n");
1802 fileBuffer
.append(" NULL, \r\n");
1804 fileBuffer
.append(" }");
1806 fileBuffer
.append("\r\n};\r\n");
1810 ExternCallBackToAutoGenC
1812 This function adds <SetVirtualAddressMapCallBack> and
1813 <ExitBootServicesCallBack> infomation to AutoGen.c
1816 String buffer for AutoGen.c
1817 @throws BuildException
1819 void ExternCallBackToAutoGenC(StringBuffer fileBuffer
)
1820 throws BuildException
{
1822 // Collect module's <SetVirtualAddressMapCallBack> and
1823 // <ExitBootServiceCallBack> and add to setVirtualAddList
1824 // exitBootServiceList.
1826 String
[] setVirtuals
= saq
.getSetVirtualAddressMapCallBackArray();
1827 String
[] exitBoots
= saq
.getExitBootServicesCallBackArray();
1828 if (setVirtuals
!= null) {
1829 for (int j
= 0; j
< setVirtuals
.length
; j
++) {
1830 this.setVirtalAddList
.add(setVirtuals
[j
]);
1833 if (exitBoots
!= null) {
1834 for (int k
= 0; k
< exitBoots
.length
; k
++) {
1835 this.exitBootServiceList
.add(exitBoots
[k
]);
1839 // Add c code in autogen.c which relate to <SetVirtualAddressMapCallBack>
1840 // and <ExitBootServicesCallBack>
1842 String moduleType
= this.moduleId
.getModuleType();
1843 switch (CommonDefinition
.getModuleType(moduleType
)) {
1844 case CommonDefinition
.ModuleTypeDxeDriver
:
1845 case CommonDefinition
.ModuleTypeDxeRuntimeDriver
:
1846 case CommonDefinition
.ModuleTypeDxeSalDriver
:
1847 case CommonDefinition
.ModuleTypeUefiDriver
:
1848 case CommonDefinition
.ModuleTypeUefiApplication
:
1850 // If moduleType is one of above, call setVirtualAddressToAutogenC,
1851 // and setExitBootServiceToAutogenC.
1853 setVirtualAddressToAutogenC(fileBuffer
);
1854 setExitBootServiceToAutogenC(fileBuffer
);
1862 copyFlashMapHToDebugDir
1864 This function is to copy the falshmap.h to debug directory and change
1865 its name to TianoR8FlashMap.h
1870 private void copyFlashMapHToDebugDir() throws AutoGenException
{
1872 File inFile
= new File(fvDir
+ File
.separatorChar
+ CommonDefinition
.FLASHMAPH
);
1873 int size
= (int)inFile
.length();
1874 byte[] buffer
= new byte[size
];
1875 File outFile
= new File (this.outputPath
+ File
.separatorChar
+ CommonDefinition
.TIANOR8PLASHMAPH
);
1877 // If TianoR8FlashMap.h existed and the flashMap.h don't change,
1880 if ((!outFile
.exists()) ||(inFile
.lastModified() - outFile
.lastModified()) >= 0) {
1882 if (inFile
.exists()) {
1883 FileInputStream fis
= new FileInputStream (inFile
);
1885 FileOutputStream fos
= new FileOutputStream(outFile
);
1890 throw new AutoGenException("The file, flashMap.h doesn't exist!");
1892 } catch (Exception e
) {
1893 throw new AutoGenException(e
.getMessage());
1899 This function first order the library instances, then collect
1900 library instance 's PPI, Protocol, GUID,
1901 SetVirtalAddressMapCallBack, ExitBootServiceCallBack, and
1902 Destructor, Constructor.
1907 private void collectLibInstanceInfo(){
1910 String libConstructName
= null;
1911 String libDestructName
= null;
1912 String
[] setVirtuals
= null;
1913 String
[] exitBoots
= null;
1915 ModuleIdentification
[] libraryIdList
= saq
.getLibraryInstance(this.arch
);
1917 if (libraryIdList
!= null) {
1919 // Reorder library instance sequence.
1921 AutogenLibOrder libOrder
= new AutogenLibOrder(libraryIdList
,
1923 List
<ModuleIdentification
> orderList
= libOrder
1924 .orderLibInstance();
1926 if (orderList
!= null) {
1928 // Process library instance one by one.
1930 for (int i
= 0; i
< orderList
.size(); i
++) {
1933 // Get library instance basename.
1935 ModuleIdentification libInstanceId
= orderList
.get(i
);
1941 Map
<String
, XmlObject
> libDoc
= GlobalData
.getDoc(libInstanceId
, this.arch
);
1944 // Get <PPis>, <Protocols>, <Guids> list of this library
1947 String
[] ppiList
= saq
.getPpiArray(this.arch
);
1948 String
[] ppiNotifyList
= saq
.getPpiNotifyArray(this.arch
);
1949 String
[] protocolList
= saq
.getProtocolArray(this.arch
);
1950 String
[] protocolNotifyList
= saq
.getProtocolNotifyArray(this.arch
);
1951 String
[] guidList
= saq
.getGuidEntryArray(this.arch
);
1952 PackageIdentification
[] pkgList
= saq
.getDependencePkg(this.arch
);
1955 // Add those ppi, protocol, guid in global ppi,
1959 for (index
= 0; index
< ppiList
.length
; index
++) {
1960 this.mPpiList
.add(ppiList
[index
]);
1963 for (index
= 0; index
< ppiNotifyList
.length
; index
++) {
1964 this.mPpiList
.add(ppiNotifyList
[index
]);
1967 for (index
= 0; index
< protocolList
.length
; index
++) {
1968 this.mProtocolList
.add(protocolList
[index
]);
1971 for (index
= 0; index
< protocolNotifyList
.length
; index
++) {
1972 this.mProtocolList
.add(protocolNotifyList
[index
]);
1975 for (index
= 0; index
< guidList
.length
; index
++) {
1976 this.mGuidList
.add(guidList
[index
]);
1978 for (index
= 0; index
< pkgList
.length
; index
++) {
1979 if (!this.mDepPkgList
.contains(pkgList
[index
])) {
1980 this.mDepPkgList
.add(pkgList
[index
]);
1985 // If not yet parse this library instance's constructor
1986 // element,parse it.
1988 libConstructName
= saq
.getLibConstructorName();
1989 libDestructName
= saq
.getLibDestructorName();
1992 // Collect SetVirtualAddressMapCallBack and
1993 // ExitBootServiceCallBack.
1995 setVirtuals
= saq
.getSetVirtualAddressMapCallBackArray();
1996 exitBoots
= saq
.getExitBootServicesCallBackArray();
1997 if (setVirtuals
!= null) {
1998 for (int j
= 0; j
< setVirtuals
.length
; j
++) {
1999 this.setVirtalAddList
.add(setVirtuals
[j
]);
2002 if (exitBoots
!= null) {
2003 for (int k
= 0; k
< exitBoots
.length
; k
++) {
2004 this.exitBootServiceList
.add(exitBoots
[k
]);
2009 // Add dependent library instance constructor function.
2011 if (libConstructName
!= null) {
2012 this.libConstructList
.add(libConstructName
);
2015 // Add dependent library instance destructor fuction.
2017 if (libDestructName
!= null) {
2018 this.libDestructList
.add(libDestructName
);
2025 } catch (Exception e
) {
2026 System
.out
.println(e
.getMessage());
2027 System
.out
.println("Collect library instance failed!");
2030 private void setVirtualAddressToAutogenC(StringBuffer fileBuffer
){
2032 // Entry point lib for these module types needs to know the count
2036 .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED const UINTN _gDriverSetVirtualAddressMapEventCount = ");
2039 // If the list is not valid or has no entries set count to zero else
2040 // set count to the number of valid entries
2044 if (this.setVirtalAddList
!= null) {
2045 for (i
= 0; i
< this.setVirtalAddList
.size(); i
++) {
2046 if (this.setVirtalAddList
.get(i
).equalsIgnoreCase("")) {
2053 fileBuffer
.append(Integer
.toString(Count
));
2054 fileBuffer
.append(";\r\n\r\n");
2055 if (this.setVirtalAddList
== null || this.setVirtalAddList
.size() == 0) {
2057 // No data so make a NULL list
2060 .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED const EFI_EVENT_NOTIFY _gDriverSetVirtualAddressMapEvent[] = {\r\n");
2061 fileBuffer
.append(" NULL\r\n");
2062 fileBuffer
.append("};\r\n\r\n");
2065 // Write SetVirtualAddressMap function definition.
2067 for (i
= 0; i
< this.setVirtalAddList
.size(); i
++) {
2068 if (this.setVirtalAddList
.get(i
).equalsIgnoreCase("")) {
2071 fileBuffer
.append("VOID\r\n");
2072 fileBuffer
.append("EFIAPI\r\n");
2073 fileBuffer
.append(this.setVirtalAddList
.get(i
));
2074 fileBuffer
.append(" (\r\n");
2075 fileBuffer
.append(" IN EFI_EVENT Event,\r\n");
2076 fileBuffer
.append(" IN VOID *Context\r\n");
2077 fileBuffer
.append(" );\r\n\r\n");
2081 // Write SetVirtualAddressMap entry point array.
2084 .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED const EFI_EVENT_NOTIFY _gDriverSetVirtualAddressMapEvent[] = {");
2085 for (i
= 0; i
< this.setVirtalAddList
.size(); i
++) {
2086 if (this.setVirtalAddList
.get(i
).equalsIgnoreCase("")) {
2091 fileBuffer
.append("\r\n ");
2093 fileBuffer
.append(",\r\n ");
2096 fileBuffer
.append(this.setVirtalAddList
.get(i
));
2099 // add the NULL at the end of _gDriverSetVirtualAddressMapEvent list.
2101 fileBuffer
.append(",\r\n NULL");
2102 fileBuffer
.append("\r\n};\r\n\r\n");
2107 private void setExitBootServiceToAutogenC(StringBuffer fileBuffer
){
2109 // Entry point lib for these module types needs to know the count.
2112 .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED const UINTN _gDriverExitBootServicesEventCount = ");
2115 // If the list is not valid or has no entries set count to zero else
2116 // set count to the number of valid entries.
2120 if (this.exitBootServiceList
!= null) {
2121 for (i
= 0; i
< this.exitBootServiceList
.size(); i
++) {
2122 if (this.exitBootServiceList
.get(i
).equalsIgnoreCase("")) {
2128 fileBuffer
.append(Integer
.toString(Count
));
2129 fileBuffer
.append(";\r\n\r\n");
2131 if (this.exitBootServiceList
== null || this.exitBootServiceList
.size() == 0) {
2133 // No data so make a NULL list.
2136 .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED const EFI_EVENT_NOTIFY _gDriverExitBootServicesEvent[] = {\r\n");
2137 fileBuffer
.append(" NULL\r\n");
2138 fileBuffer
.append("};\r\n\r\n");
2141 // Write DriverExitBootServices function definition.
2143 for (i
= 0; i
< this.exitBootServiceList
.size(); i
++) {
2144 if (this.exitBootServiceList
.get(i
).equalsIgnoreCase("")) {
2148 fileBuffer
.append("VOID\r\n");
2149 fileBuffer
.append("EFIAPI\r\n");
2150 fileBuffer
.append(this.exitBootServiceList
.get(i
));
2151 fileBuffer
.append(" (\r\n");
2152 fileBuffer
.append(" IN EFI_EVENT Event,\r\n");
2153 fileBuffer
.append(" IN VOID *Context\r\n");
2154 fileBuffer
.append(" );\r\n\r\n");
2158 // Write DriverExitBootServices entry point array.
2161 .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED const EFI_EVENT_NOTIFY _gDriverExitBootServicesEvent[] = {");
2162 for (i
= 0; i
< this.exitBootServiceList
.size(); i
++) {
2163 if (this.exitBootServiceList
.get(i
).equalsIgnoreCase("")) {
2168 fileBuffer
.append("\r\n ");
2170 fileBuffer
.append(",\r\n ");
2172 fileBuffer
.append(this.exitBootServiceList
.get(i
));
2175 fileBuffer
.append(",\r\n NULL");
2176 fileBuffer
.append("\r\n};\r\n\r\n");