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
.util
.ArrayList
;
26 import java
.util
.HashSet
;
27 import java
.util
.Iterator
;
28 import java
.util
.LinkedHashSet
;
29 import java
.util
.LinkedList
;
30 import java
.util
.List
;
34 import org
.apache
.tools
.ant
.BuildException
;
35 import org
.apache
.xmlbeans
.XmlObject
;
36 import org
.tianocore
.GuidsDocument
;
37 import org
.tianocore
.LibraryClassDocument
.LibraryClass
;
38 import org
.tianocore
.PPIsDocument
;
39 import org
.tianocore
.ProtocolsDocument
;
40 import org
.tianocore
.build
.exception
.*;
41 import org
.tianocore
.build
.global
.GlobalData
;
42 import org
.tianocore
.build
.global
.Spd
;
43 import org
.tianocore
.build
.global
.SurfaceAreaQuery
;
44 import org
.tianocore
.build
.id
.ModuleIdentification
;
45 import org
.tianocore
.build
.id
.PackageIdentification
;
46 import org
.tianocore
.build
.pcd
.action
.PCDAutoGenAction
;
48 import org
.tianocore
.common
.logger
.EdkLog
;
51 * This class is to generate Autogen.h and Autogen.c according to module surface
52 * area or library surface area.
54 public class AutoGen
{
56 // / The output path of Autogen.h and Autogen.c
58 private String outputPath
;
60 /// The name of FV directory
64 // / The base name of module or library.
66 private ModuleIdentification moduleId
;
69 // / The build architecture
74 // / PcdAutogen instance which is used to manage how to generate the PCD
77 private PCDAutoGenAction myPcdAutogen
;
80 // / The protocl list which records in module or library surface area and
81 // / it's dependence on library instance surface area.
83 private Set
<String
> mProtocolList
= new HashSet
<String
>();
86 // / The Ppi list which recorded in module or library surface area and its
87 // / dependency on library instance surface area.
89 private Set
<String
> mPpiList
= new HashSet
<String
>();
92 // / The Guid list which recoreded in module or library surface area and it's
93 // / dependence on library instance surface area.
95 private Set
<String
> mGuidList
= new HashSet
<String
>();
98 // The dependence package list which recoreded in module or library surface
99 // area and it's dependence on library instance surface are.
101 private List
<PackageIdentification
> mDepPkgList
= new LinkedList
<PackageIdentification
>();
104 // For non library module, add its library instance's construct and destructor to
107 private List
<String
> libConstructList
= new ArrayList
<String
>();
108 private List
<String
> libDestructList
= new ArrayList
<String
>();
111 // List to store SetVirtalAddressMapCallBack, ExitBootServiceCallBack
113 private List
<String
> setVirtalAddList
= new ArrayList
<String
>();
114 private List
<String
> exitBootServiceList
= new ArrayList
<String
>();
120 * This function mainly initialize some member variable.
123 * Output path of AutoGen file.
127 * Target architecture.
129 public AutoGen(String fvDir
, String outputPath
, ModuleIdentification moduleId
, String arch
) {
130 this.outputPath
= outputPath
;
131 this.moduleId
= moduleId
;
140 * This function save the content in stringBuffer to file.
145 * The content of AutoGen file in buffer.
146 * @return "true" successful, "false" failed.
148 private boolean saveFile(String fileName
, StringBuffer fileBuffer
) {
150 File autoGenH
= new File(fileName
);
153 // if the file exists, compare their content
155 if (autoGenH
.exists()) {
156 FileReader fIn
= new FileReader(autoGenH
);
157 char[] oldFileBuffer
= new char[(int) autoGenH
.length()];
158 fIn
.read(oldFileBuffer
, 0, (int) autoGenH
.length());
162 // if we got the same file, don't re-generate it to prevent
163 // sources depending on it from re-building
165 if (fileBuffer
.toString().compareTo(new String(oldFileBuffer
)) == 0) {
169 FileWriter fOut
= new FileWriter(autoGenH
);
170 fOut
.write(fileBuffer
.toString());
172 } catch (Exception e
) {
179 * genAutogen function
181 * This function call libGenAutoGen or moduleGenAutogen function, which
182 * dependence on generate library autogen or module autogen.
184 * @throws BuildException
185 * Failed to creat AutoGen.c & AutoGen.h.
187 public void genAutogen() throws BuildException
{
190 // If outputPath do not exist, create it.
192 File path
= new File(outputPath
);
196 // Check current is library or not, then call the corresponding
199 if (this.moduleId
.isLibrary()) {
205 } catch (Exception e
) {
206 throw new BuildException(
207 "Failed to create AutoGen.c & AutoGen.h!\n"
213 * moduleGenAutogen function
215 * This function generates AutoGen.c & AutoGen.h for module.
217 * @throws BuildException
218 * Faile to create module AutoGen.c & AutoGen.h.
220 void moduleGenAutogen() throws BuildException
{
223 collectLibInstanceInfo();
226 } catch (Exception e
) {
227 throw new BuildException(
228 "Faile to create module AutoGen.c & AutoGen.h!\n"
234 * libGenAutogen function
236 * This function generates AutoGen.c & AutoGen.h for library.
238 * @throws BuildException
239 * Faile to create library AutoGen.c & AutoGen.h
241 void libGenAutogen() throws BuildException
{
245 } catch (Exception e
) {
246 throw new BuildException(
247 "Failed to create library AutoGen.c & AutoGen.h!\n"
255 * This function generates AutoGen.h for module.
257 * @throws BuildException
258 * Failed to generate AutoGen.h.
260 void moduleGenAutogenH() throws AutoGenException
{
262 Set
<String
> libClassIncludeH
;
264 // List<String> headerFileList;
265 List
<String
> headerFileList
;
267 StringBuffer fileBuffer
= new StringBuffer(8192);
270 // Write Autogen.h header notation
272 fileBuffer
.append(CommonDefinition
.autogenHNotation
);
275 // Add #ifndef ${BaseName}_AUTOGENH
276 // #def ${BseeName}_AUTOGENH
278 fileBuffer
.append("#ifndef " + "_AUTOGENH_" + this.moduleId
.getGuid().replaceAll("-", "_") +"\r\n");
279 fileBuffer
.append("#define " + "_AUTOGENH_" + this.moduleId
.getGuid().replaceAll("-", "_") +"\r\n\r\n");
282 // Write the specification version and release version at the begine
283 // of autogen.h file.
284 // Note: the specification version and release version should
285 // be got from module surface area instead of hard code by it's
288 moduleType
= SurfaceAreaQuery
.getModuleType();
291 // Add "extern int __make_me_compile_correctly;" at begin of
294 fileBuffer
.append(CommonDefinition
.autoGenHbegin
);
297 // Put EFI_SPECIFICATION_VERSION, and EDK_RELEASE_VERSION.
299 String
[] specList
= SurfaceAreaQuery
.getExternSpecificaiton();
300 for (int i
= 0; i
< specList
.length
; i
++) {
301 fileBuffer
.append(CommonDefinition
.marcDefineStr
+ specList
[i
]
305 // Write consumed package's mdouleInfo related .h file to autogen.h
307 // PackageIdentification[] consumedPkgIdList = SurfaceAreaQuery
308 // .getDependencePkg(this.arch);
309 PackageIdentification
[] consumedPkgIdList
= SurfaceAreaQuery
310 .getDependencePkg(this.arch
);
311 if (consumedPkgIdList
!= null) {
312 headerFileList
= depPkgToAutogenH(consumedPkgIdList
, moduleType
);
313 item
= headerFileList
.iterator();
314 while (item
.hasNext()) {
315 fileBuffer
.append(item
.next().toString());
320 // Write library class's related *.h file to autogen.h.
322 String
[] libClassList
= SurfaceAreaQuery
323 .getLibraryClasses(CommonDefinition
.AlwaysConsumed
,this.arch
);
324 if (libClassList
!= null) {
325 libClassIncludeH
= LibraryClassToAutogenH(libClassList
);
326 item
= libClassIncludeH
.iterator();
327 while (item
.hasNext()) {
328 fileBuffer
.append(item
.next().toString());
332 libClassList
= SurfaceAreaQuery
333 .getLibraryClasses(CommonDefinition
.AlwaysProduced
, this.arch
);
334 if (libClassList
!= null) {
335 libClassIncludeH
= LibraryClassToAutogenH(libClassList
);
336 item
= libClassIncludeH
.iterator();
337 while (item
.hasNext()) {
338 fileBuffer
.append(item
.next().toString());
341 fileBuffer
.append("\r\n");
344 // If is TianoR8FlashMap, copy {Fv_DIR}/FlashMap.h to
345 // {DEST_DIR_DRBUG}/FlashMap.h
347 if (SurfaceAreaQuery
.isHaveTianoR8FlashMap()) {
348 fileBuffer
.append(CommonDefinition
.include
);
349 fileBuffer
.append(" <");
350 fileBuffer
.append(CommonDefinition
.tianoR8FlashMapH
+ ">\r\n");
351 copyFlashMapHToDebugDir();
354 // Write PCD autogen information to AutoGen.h.
356 if (this.myPcdAutogen
!= null) {
357 fileBuffer
.append("\r\n");
358 fileBuffer
.append(this.myPcdAutogen
.OutputH());
362 // Append the #endif at AutoGen.h
364 fileBuffer
.append("#endif\r\n");
367 // Save string buffer content in AutoGen.h.
369 if (!saveFile(outputPath
+ File
.separatorChar
+ "AutoGen.h", fileBuffer
)) {
370 throw new BuildException("Failed to generate AutoGen.h !!!");
377 * This function generates AutoGen.c for module.
379 * @throws BuildException
380 * Failed to generate AutoGen.c.
382 void moduleGenAutogenC() throws AutoGenException
{
384 StringBuffer fileBuffer
= new StringBuffer(8192);
386 // Write Autogen.c header notation
388 fileBuffer
.append(CommonDefinition
.autogenCNotation
);
391 // Write #include <AutoGen.h> at beginning of AutoGen.c
393 fileBuffer
.append(CommonDefinition
.includeAutogenH
);
396 // Get the native MSA file infomation. Since before call autogen,
397 // the MSA native <Externs> information were overrided. So before
398 // process <Externs> it should be set the DOC as the Native MSA info.
400 Map
<String
, XmlObject
> doc
= GlobalData
.getNativeMsa(this.moduleId
);
401 SurfaceAreaQuery
.push(doc
);
404 // DriverBinding/ComponentName/DriverConfiguration/DriverDialog
408 ExternsDriverBindingToAutoGenC(fileBuffer
);
411 // Write DriverExitBootServicesEvent/DriverSetVirtualAddressMapEvent
414 ExternCallBackToAutoGenC(fileBuffer
);
417 // Write EntryPoint to autgoGen.c
419 String
[] entryPointList
= SurfaceAreaQuery
.getModuleEntryPointArray();
420 EntryPointToAutoGen(CommonDefinition
.remDupString(entryPointList
), fileBuffer
);
424 // Restore the DOC which include the FPD module info.
426 SurfaceAreaQuery
.pop();
429 // Write Guid to autogen.c
431 String guid
= CommonDefinition
.formatGuidName(SurfaceAreaQuery
435 .append("GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiCallerIdGuid = {");
437 throw new AutoGenException("Guid value must set!\n");
441 // Formate Guid as ANSI c form.Example:
442 // {0xd2b2b828, 0x826, 0x48a7,{0xb3, 0xdf, 0x98, 0x3c, 0x0, 0x60, 0x24,
446 fileBuffer
.append(guid
);
447 fileBuffer
.append("};\r\n");
450 // Generate library instance consumed protocol, guid, ppi, pcd list.
451 // Save those to this.protocolList, this.ppiList, this.pcdList,
452 // this.guidList. Write Consumed library constructor and desconstuct to
455 LibInstanceToAutogenC(fileBuffer
);
458 // Get module dependent Package identification.
460 PackageIdentification
[] packages
= SurfaceAreaQuery
.getDependencePkg(this.arch
);
461 for (int i
= 0; i
< packages
.length
; i
++){
462 if (!this.mDepPkgList
.contains(packages
[i
])){
463 this.mDepPkgList
.add(packages
[i
]);
469 // Write consumed ppi, guid, protocol to autogen.c
471 ProtocolGuidToAutogenC(fileBuffer
);
472 PpiGuidToAutogenC(fileBuffer
);
473 GuidGuidToAutogenC(fileBuffer
);
478 this.myPcdAutogen
= new PCDAutoGenAction(moduleId
, this.arch
, false, null);
480 this.myPcdAutogen
.execute();
481 } catch (Exception exp
) {
482 throw new PcdAutogenException (exp
.getMessage());
485 if (this.myPcdAutogen
!= null) {
486 fileBuffer
.append("\r\n");
487 fileBuffer
.append(this.myPcdAutogen
.OutputC());
490 if (!saveFile(outputPath
+ File
.separatorChar
+ "AutoGen.c", fileBuffer
)) {
491 throw new BuildException("Failed to generate AutoGen.c !!!");
499 * This function generates AutoGen.h for library.
501 * @throws BuildException
502 * Failed to generate AutoGen.c.
504 void libGenAutogenH() throws AutoGenException
{
506 Set
<String
> libClassIncludeH
;
508 List
<String
> headerFileList
;
510 StringBuffer fileBuffer
= new StringBuffer(10240);
513 // Write Autogen.h header notation
515 fileBuffer
.append(CommonDefinition
.autogenHNotation
);
518 // Add #ifndef ${BaseName}_AUTOGENH
519 // #def ${BseeName}_AUTOGENH
521 fileBuffer
.append("#ifndef " + "_AUTOGENH_" + this.moduleId
.getGuid().replaceAll("-", "_") + "\r\n");
522 fileBuffer
.append("#define " + "_AUTOGENH_" + this.moduleId
.getGuid().replaceAll("-", "_") + "\r\n\r\n");
525 // Write EFI_SPECIFICATION_VERSION and EDK_RELEASE_VERSION
526 // to autogen.h file.
527 // Note: the specification version and release version should
528 // be get from module surface area instead of hard code.
530 fileBuffer
.append(CommonDefinition
.autoGenHbegin
);
531 String
[] specList
= SurfaceAreaQuery
.getExternSpecificaiton();
532 for (int i
= 0; i
< specList
.length
; i
++) {
533 fileBuffer
.append(CommonDefinition
.marcDefineStr
+ specList
[i
]
536 // fileBuffer.append(CommonDefinition.autoGenHLine1);
537 // fileBuffer.append(CommonDefinition.autoGenHLine2);
540 // Write consumed package's mdouleInfo related *.h file to autogen.h.
542 moduleType
= SurfaceAreaQuery
.getModuleType();
543 PackageIdentification
[] cosumedPkglist
= SurfaceAreaQuery
544 .getDependencePkg(this.arch
);
545 headerFileList
= depPkgToAutogenH(cosumedPkglist
, moduleType
);
546 item
= headerFileList
.iterator();
547 while (item
.hasNext()) {
548 fileBuffer
.append(item
.next().toString());
551 // Write library class's related *.h file to autogen.h
553 String
[] libClassList
= SurfaceAreaQuery
554 .getLibraryClasses(CommonDefinition
.AlwaysConsumed
, this.arch
);
555 if (libClassList
!= null) {
556 libClassIncludeH
= LibraryClassToAutogenH(libClassList
);
557 item
= libClassIncludeH
.iterator();
558 while (item
.hasNext()) {
559 fileBuffer
.append(item
.next().toString());
563 libClassList
= SurfaceAreaQuery
564 .getLibraryClasses(CommonDefinition
.AlwaysProduced
, this.arch
);
565 if (libClassList
!= null) {
566 libClassIncludeH
= LibraryClassToAutogenH(libClassList
);
567 item
= libClassIncludeH
.iterator();
568 while (item
.hasNext()) {
569 fileBuffer
.append(item
.next().toString());
572 fileBuffer
.append("\r\n");
575 // If is TianoR8FlashMap, copy {Fv_DIR}/FlashMap.h to
576 // {DEST_DIR_DRBUG}/FlashMap.h
578 if (SurfaceAreaQuery
.isHaveTianoR8FlashMap()) {
579 fileBuffer
.append(CommonDefinition
.include
);
580 fileBuffer
.append(" <");
581 fileBuffer
.append(CommonDefinition
.tianoR8FlashMapH
+ ">\r\n");
582 copyFlashMapHToDebugDir();
586 // Write PCD information to library AutoGen.h.
588 if (this.myPcdAutogen
!= null) {
589 fileBuffer
.append("\r\n");
590 fileBuffer
.append(this.myPcdAutogen
.OutputH());
594 // Append the #endif at AutoGen.h
596 fileBuffer
.append("#endif\r\n");
599 // Save content of string buffer to AutoGen.h file.
601 if (!saveFile(outputPath
+ File
.separatorChar
+ "AutoGen.h", fileBuffer
)) {
602 throw new BuildException("Failed to generate AutoGen.h !!!");
609 * This function generates AutoGen.h for library.
611 * @throws BuildException
612 * Failed to generate AutoGen.c.
614 void libGenAutogenC() throws BuildException
, PcdAutogenException
{
615 StringBuffer fileBuffer
= new StringBuffer(10240);
618 // Write Autogen.c header notation
620 fileBuffer
.append(CommonDefinition
.autogenCNotation
);
622 fileBuffer
.append(CommonDefinition
.autoGenCLine1
);
623 fileBuffer
.append("\r\n");
628 this.myPcdAutogen
= new PCDAutoGenAction(this.moduleId
,
631 SurfaceAreaQuery
.getModulePcdEntryNameArray());
633 this.myPcdAutogen
.execute();
634 } catch (Exception e
) {
635 throw new PcdAutogenException(e
.getMessage());
638 if (this.myPcdAutogen
!= null) {
639 fileBuffer
.append("\r\n");
640 fileBuffer
.append(this.myPcdAutogen
.OutputC());
643 if (!saveFile(outputPath
+ File
.separatorChar
+ "AutoGen.c", fileBuffer
)) {
644 throw new BuildException("Failed to generate AutoGen.c !!!");
649 * LibraryClassToAutogenH
651 * This function returns *.h files declared by library classes which are
652 * consumed or produced by current build module or library.
654 * @param libClassList
655 * List of library class which consumed or produce by current
656 * build module or library.
657 * @return includeStrList List of *.h file.
659 Set
<String
> LibraryClassToAutogenH(String
[] libClassList
)
660 throws AutoGenException
{
661 Set
<String
> includStrList
= new LinkedHashSet
<String
>();
662 String includerName
[];
666 // Get include file from GlobalData's SPDTable according to
667 // library class name.
670 for (int i
= 0; i
< libClassList
.length
; i
++) {
671 includerName
= GlobalData
.getLibraryClassHeaderFiles(
672 SurfaceAreaQuery
.getDependencePkg(this.arch
),
674 if (includerName
== null) {
675 throw new AutoGenException("Can not find library class ["
676 + libClassList
[i
] + "] declaration in any SPD package. ");
678 for (int j
= 0; j
< includerName
.length
; j
++) {
679 String includeNameStr
= includerName
[j
];
680 if (includeNameStr
!= null) {
681 str
= CommonDefinition
.include
+ " " + "<";
682 str
= str
+ includeNameStr
+ ">\r\n";
683 includStrList
.add(str
);
684 includeNameStr
= null;
688 return includStrList
;
694 * This function add include file in AutoGen.h file.
696 * @param packageNameList
697 * List of module depended package.
702 List
<String
> depPkgToAutogenH(PackageIdentification
[] packageNameList
,
703 String moduleType
) throws AutoGenException
{
705 List
<String
> includeStrList
= new LinkedList
<String
>();
707 String includeStr
= "";
710 // Get include file from moduleInfo file
712 for (int i
= 0; i
< packageNameList
.length
; i
++) {
713 pkgHeader
= GlobalData
.getPackageHeaderFiles(packageNameList
[i
],
715 if (pkgHeader
== null) {
716 throw new AutoGenException("Can not find package ["
718 + "] declaration in any SPD package. ");
719 } else if (!pkgHeader
.equalsIgnoreCase("")) {
720 includeStr
= CommonDefinition
.include
+ " <" + pkgHeader
722 includeStrList
.add(includeStr
);
726 return includeStrList
;
730 * EntryPointToAutoGen
732 * This function convert <ModuleEntryPoint> & <ModuleUnloadImage>
733 * information in mas to AutoGen.c
735 * @param entryPointList
736 * List of entry point.
738 * String buffer fo AutoGen.c.
741 void EntryPointToAutoGen(String
[] entryPointList
, StringBuffer fileBuffer
)
742 throws BuildException
{
744 String typeStr
= SurfaceAreaQuery
.getModuleType();
747 // The parameters and return value of entryPoint is difference
748 // for difference module type.
750 switch (CommonDefinition
.getModuleType(typeStr
)) {
752 case CommonDefinition
.ModuleTypePeiCore
:
753 if (entryPointList
== null ||entryPointList
.length
!= 1 ) {
754 throw new BuildException(
755 "Module type = 'PEI_CORE', can have only one module entry point!");
757 fileBuffer
.append("EFI_STATUS\r\n");
758 fileBuffer
.append("EFIAPI\r\n");
759 fileBuffer
.append(entryPointList
[0]);
760 fileBuffer
.append(" (\r\n");
762 .append(" IN EFI_PEI_STARTUP_DESCRIPTOR *PeiStartupDescriptor,\r\n");
764 .append(" IN VOID *OldCoreData\r\n");
765 fileBuffer
.append(" );\r\n\r\n");
767 fileBuffer
.append("EFI_STATUS\r\n");
768 fileBuffer
.append("EFIAPI\r\n");
769 fileBuffer
.append("ProcessModuleEntryPointList (\r\n");
771 .append(" IN EFI_PEI_STARTUP_DESCRIPTOR *PeiStartupDescriptor,\r\n");
773 .append(" IN VOID *OldCoreData\r\n");
774 fileBuffer
.append(" )\r\n\r\n");
775 fileBuffer
.append("{\r\n");
776 fileBuffer
.append(" return ");
777 fileBuffer
.append(entryPointList
[0]);
778 fileBuffer
.append(" (PeiStartupDescriptor, OldCoreData);\r\n");
779 fileBuffer
.append("}\r\n\r\n");
783 case CommonDefinition
.ModuleTypeDxeCore
:
784 fileBuffer
.append("const UINT32 _gUefiDriverRevision = 0;\r\n");
785 if (entryPointList
== null || entryPointList
.length
!= 1) {
786 throw new BuildException(
787 "Module type = 'DXE_CORE', can have only one module entry point!");
790 fileBuffer
.append("VOID\r\n");
791 fileBuffer
.append("EFIAPI\r\n");
792 fileBuffer
.append(entryPointList
[0]);
793 fileBuffer
.append(" (\n");
794 fileBuffer
.append(" IN VOID *HobStart\r\n");
795 fileBuffer
.append(" );\r\n\r\n");
797 fileBuffer
.append("VOID\r\n");
798 fileBuffer
.append("EFIAPI\r\n");
799 fileBuffer
.append("ProcessModuleEntryPointList (\r\n");
800 fileBuffer
.append(" IN VOID *HobStart\r\n");
801 fileBuffer
.append(" )\r\n\r\n");
802 fileBuffer
.append("{\r\n");
803 fileBuffer
.append(" ");
804 fileBuffer
.append(entryPointList
[0]);
805 fileBuffer
.append(" (HobStart);\r\n");
806 fileBuffer
.append("}\r\n\r\n");
810 case CommonDefinition
.ModuleTypePeim
:
811 int entryPointCount
= 0;
813 .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT32 _gPeimRevision = 0;\r\n");
814 if (entryPointList
== null || entryPointList
.length
== 0) {
815 fileBuffer
.append("EFI_STATUS\r\n");
816 fileBuffer
.append("EFIAPI\r\n");
817 fileBuffer
.append("ProcessModuleEntryPointList (\r\n");
818 fileBuffer
.append(" IN EFI_FFS_FILE_HEADER *FfsHeader,\r\n");
819 fileBuffer
.append(" IN EFI_PEI_SERVICES **PeiServices\r\n");
820 fileBuffer
.append(" )\r\n\r\n");
821 fileBuffer
.append("{\r\n");
822 fileBuffer
.append(" return EFI_SUCCESS;\r\n");
823 fileBuffer
.append("}\r\n\r\n");
826 for (int i
= 0; i
< entryPointList
.length
; i
++) {
827 fileBuffer
.append("EFI_STATUS\r\n");
828 fileBuffer
.append("EFIAPI\r\n");
829 fileBuffer
.append(entryPointList
[i
]);
830 fileBuffer
.append(" (\r\n");
832 .append(" IN EFI_FFS_FILE_HEADER *FfsHeader,\r\n");
834 .append(" IN EFI_PEI_SERVICES **PeiServices\r\n");
835 fileBuffer
.append(" );\r\n");
840 fileBuffer
.append("EFI_STATUS\r\n");
841 fileBuffer
.append("EFIAPI\r\n");
842 fileBuffer
.append("ProcessModuleEntryPointList (\r\n");
843 fileBuffer
.append(" IN EFI_FFS_FILE_HEADER *FfsHeader,\r\n");
844 fileBuffer
.append(" IN EFI_PEI_SERVICES **PeiServices\r\n");
845 fileBuffer
.append(" )\r\n\r\n");
846 fileBuffer
.append("{\r\n");
847 if (entryPointCount
== 1) {
848 fileBuffer
.append(" return ");
849 fileBuffer
.append(entryPointList
[0]);
850 fileBuffer
.append(" (FfsHeader, PeiServices);\r\n");
852 fileBuffer
.append(" EFI_STATUS Status;\r\n");
853 fileBuffer
.append(" EFI_STATUS CombinedStatus;\r\n\r\n");
854 fileBuffer
.append(" CombinedStatus = EFI_LOAD_ERROR;\r\n\r\n");
855 for (int i
= 0; i
< entryPointList
.length
; i
++) {
856 if (!entryPointList
[i
].equals("")) {
857 fileBuffer
.append(" Status = ");
858 fileBuffer
.append(entryPointList
[i
]);
859 fileBuffer
.append(" (FfsHeader, PeiServices);\r\n");
861 .append(" if (!EFI_ERROR (Status) || EFI_ERROR (CombinedStatus)) {\r\n");
862 fileBuffer
.append(" CombinedStatus = Status;\r\n");
863 fileBuffer
.append(" }\r\n\r\n");
868 fileBuffer
.append(" return CombinedStatus;\r\n");
870 fileBuffer
.append("}\r\n\r\n");
873 case CommonDefinition
.ModuleTypeDxeSmmDriver
:
876 // If entryPoint is null, create an empty ProcessModuleEntryPointList
879 if (entryPointList
== null || entryPointList
.length
== 0){
881 .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gDriverEntryPointCount = ");
882 fileBuffer
.append(Integer
.toString(entryPointCount
));
883 fileBuffer
.append(";\r\n");
884 fileBuffer
.append("EFI_STATUS\r\n");
885 fileBuffer
.append("EFIAPI\r\n");
886 fileBuffer
.append("ProcessModuleEntryPointList (\r\n");
887 fileBuffer
.append(" IN EFI_HANDLE ImageHandle,\r\n");
888 fileBuffer
.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");
889 fileBuffer
.append(" )\r\n\r\n");
890 fileBuffer
.append("{\r\n");
891 fileBuffer
.append(" return EFI_SUCCESS;\r\n");
892 fileBuffer
.append("}\r\n\r\n");
895 for (int i
= 0; i
< entryPointList
.length
; i
++) {
896 fileBuffer
.append("EFI_STATUS\r\n");
897 fileBuffer
.append("EFIAPI\r\n");
898 fileBuffer
.append(entryPointList
[i
]);
899 fileBuffer
.append(" (\r\n");
900 fileBuffer
.append(" IN EFI_HANDLE ImageHandle,\r\n");
901 fileBuffer
.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");
902 fileBuffer
.append(" );\r\n");
906 .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gDriverEntryPointCount = ");
907 fileBuffer
.append(Integer
.toString(entryPointCount
));
908 fileBuffer
.append(";\r\n");
910 .append("static BASE_LIBRARY_JUMP_BUFFER mJumpContext;\r\n");
912 .append("static EFI_STATUS mDriverEntryPointStatus = EFI_LOAD_ERROR;\r\n\r\n");
914 fileBuffer
.append("EFI_STATUS\r\n");
915 fileBuffer
.append("EFIAPI\r\n");
916 fileBuffer
.append("ProcessModuleEntryPointList (\r\n");
917 fileBuffer
.append(" IN EFI_HANDLE ImageHandle,\r\n");
918 fileBuffer
.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");
919 fileBuffer
.append(" )\r\n\r\n");
920 fileBuffer
.append("{\r\n");
923 for (int i
= 0; i
< entryPointList
.length
; i
++) {
925 .append(" if (SetJump (&mJumpContext) == 0) {\r\n");
926 fileBuffer
.append(" ExitDriver (");
927 fileBuffer
.append(entryPointList
[i
]);
928 fileBuffer
.append(" (ImageHandle, SystemTable));\r\n");
929 fileBuffer
.append(" ASSERT (FALSE);\r\n");
930 fileBuffer
.append(" }\r\n");
933 fileBuffer
.append(" return mDriverEntryPointStatus;\r\n");
934 fileBuffer
.append("}\r\n\r\n");
936 fileBuffer
.append("VOID\r\n");
937 fileBuffer
.append("EFIAPI\r\n");
938 fileBuffer
.append("ExitDriver (\r\n");
939 fileBuffer
.append(" IN EFI_STATUS Status\n");
940 fileBuffer
.append(" )\r\n\r\n");
941 fileBuffer
.append("{\r\n");
943 .append(" if (!EFI_ERROR (Status) || EFI_ERROR (mDriverEntryPointStatus)) {\r\n");
944 fileBuffer
.append(" mDriverEntryPointStatus = Status;\r\n");
945 fileBuffer
.append(" }\r\n");
946 fileBuffer
.append(" LongJump (&mJumpContext, (UINTN)-1);\r\n");
947 fileBuffer
.append(" ASSERT (FALSE);\r\n");
948 fileBuffer
.append("}\r\n\r\n");
954 // Add "ModuleUnloadImage" for DxeSmmDriver module type;
956 entryPointList
= SurfaceAreaQuery
.getModuleUnloadImageArray();
957 entryPointList
= CommonDefinition
.remDupString(entryPointList
);
960 if (entryPointList
!= null) {
961 for (int i
= 0; i
< entryPointList
.length
; i
++) {
962 fileBuffer
.append("EFI_STATUS\r\n");
963 fileBuffer
.append("EFIAPI\r\n");
964 fileBuffer
.append(entryPointList
[i
]);
965 fileBuffer
.append(" (\r\n");
967 .append(" IN EFI_HANDLE ImageHandle\r\n");
968 fileBuffer
.append(" );\r\n");
974 .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gDriverUnloadImageCount = ");
975 fileBuffer
.append(Integer
.toString(entryPointCount
));
976 fileBuffer
.append(";\r\n\r\n");
978 fileBuffer
.append("EFI_STATUS\r\n");
979 fileBuffer
.append("EFIAPI\r\n");
980 fileBuffer
.append("ProcessModuleUnloadList (\r\n");
981 fileBuffer
.append(" IN EFI_HANDLE ImageHandle\r\n");
982 fileBuffer
.append(" )\r\n");
983 fileBuffer
.append("{\r\n");
985 if (entryPointCount
== 0) {
986 fileBuffer
.append(" return EFI_SUCCESS;\r\n");
987 } else if (entryPointCount
== 1) {
988 fileBuffer
.append(" return ");
989 fileBuffer
.append(entryPointList
[0]);
990 fileBuffer
.append("(ImageHandle);\r\n");
992 fileBuffer
.append(" EFI_STATUS Status;\r\n\r\n");
993 fileBuffer
.append(" Status = EFI_SUCCESS;\r\n\r\n");
994 for (int i
= 0; i
< entryPointList
.length
; i
++) {
996 fileBuffer
.append(" Status = ");
997 fileBuffer
.append(entryPointList
[i
]);
998 fileBuffer
.append("(ImageHandle);\r\n");
1000 fileBuffer
.append(" if (EFI_ERROR (Status)) {\r\n");
1001 fileBuffer
.append(" ");
1002 fileBuffer
.append(entryPointList
[i
]);
1003 fileBuffer
.append("(ImageHandle);\r\n");
1004 fileBuffer
.append(" } else {\r\n");
1005 fileBuffer
.append(" Status = ");
1006 fileBuffer
.append(entryPointList
[i
]);
1007 fileBuffer
.append("(ImageHandle);\r\n");
1008 fileBuffer
.append(" }\r\n");
1011 fileBuffer
.append(" return Status;\r\n");
1013 fileBuffer
.append("}\r\n\r\n");
1016 case CommonDefinition
.ModuleTypeDxeRuntimeDriver
:
1017 case CommonDefinition
.ModuleTypeDxeDriver
:
1018 case CommonDefinition
.ModuleTypeDxeSalDriver
:
1019 case CommonDefinition
.ModuleTypeUefiDriver
:
1020 case CommonDefinition
.ModuleTypeUefiApplication
:
1021 entryPointCount
= 0;
1022 fileBuffer
.append("const UINT32 _gUefiDriverRevision = 0;\r\n");
1024 // If entry point is null, create a empty ProcessModuleEntryPointList function.
1026 if (entryPointList
== null || entryPointList
.length
== 0){
1028 .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gDriverEntryPointCount = 0;\r\n");
1029 fileBuffer
.append("EFI_STATUS\r\n");
1030 fileBuffer
.append("EFIAPI\r\n");
1031 fileBuffer
.append("ProcessModuleEntryPointList (\r\n");
1032 fileBuffer
.append(" IN EFI_HANDLE ImageHandle,\r\n");
1033 fileBuffer
.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");
1034 fileBuffer
.append(" )\r\n\r\n");
1035 fileBuffer
.append("{\r\n");
1036 fileBuffer
.append(" return EFI_SUCCESS;\r\n");
1037 fileBuffer
.append("}\r\n");
1040 for (int i
= 0; i
< entryPointList
.length
; i
++) {
1042 fileBuffer
.append("EFI_STATUS\r\n");
1043 fileBuffer
.append("EFIAPI\r\n");
1044 fileBuffer
.append(entryPointList
[i
]);
1045 fileBuffer
.append(" (\r\n");
1046 fileBuffer
.append(" IN EFI_HANDLE ImageHandle,\r\n");
1047 fileBuffer
.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");
1048 fileBuffer
.append(" );\r\n");
1053 .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gDriverEntryPointCount = ");
1054 fileBuffer
.append(Integer
.toString(entryPointCount
));
1055 fileBuffer
.append(";\r\n");
1056 if (entryPointCount
> 1) {
1058 .append("static BASE_LIBRARY_JUMP_BUFFER mJumpContext;\r\n");
1060 .append("static EFI_STATUS mDriverEntryPointStatus = EFI_LOAD_ERROR;\r\n");
1062 fileBuffer
.append("\n");
1064 fileBuffer
.append("EFI_STATUS\r\n");
1065 fileBuffer
.append("EFIAPI\r\n");
1066 fileBuffer
.append("ProcessModuleEntryPointList (\r\n");
1067 fileBuffer
.append(" IN EFI_HANDLE ImageHandle,\r\n");
1068 fileBuffer
.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");
1069 fileBuffer
.append(" )\r\n\r\n");
1070 fileBuffer
.append("{\r\n");
1072 if (entryPointCount
== 1) {
1073 fileBuffer
.append(" return (");
1074 fileBuffer
.append(entryPointList
[0]);
1075 fileBuffer
.append(" (ImageHandle, SystemTable));\r\n");
1077 for (int i
= 0; i
< entryPointList
.length
; i
++) {
1078 if (!entryPointList
[i
].equals("")) {
1080 .append(" if (SetJump (&mJumpContext) == 0) {\r\n");
1081 fileBuffer
.append(" ExitDriver (");
1082 fileBuffer
.append(entryPointList
[i
]);
1083 fileBuffer
.append(" (ImageHandle, SystemTable));\r\n");
1084 fileBuffer
.append(" ASSERT (FALSE);\r\n");
1085 fileBuffer
.append(" }\r\n");
1090 fileBuffer
.append(" return mDriverEntryPointStatus;\r\n");
1092 fileBuffer
.append("}\r\n\r\n");
1094 fileBuffer
.append("VOID\r\n");
1095 fileBuffer
.append("EFIAPI\r\n");
1096 fileBuffer
.append("ExitDriver (\r\n");
1097 fileBuffer
.append(" IN EFI_STATUS Status\r\n");
1098 fileBuffer
.append(" )\r\n\r\n");
1099 fileBuffer
.append("{\r\n");
1100 if (entryPointCount
<= 1) {
1101 fileBuffer
.append(" if (EFI_ERROR (Status)) {\r\n");
1103 .append(" ProcessLibraryDestructorList (gImageHandle, gST);\r\n");
1104 fileBuffer
.append(" }\r\n");
1106 .append(" gBS->Exit (gImageHandle, Status, 0, NULL);\r\n");
1109 .append(" if (!EFI_ERROR (Status) || EFI_ERROR (mDriverEntryPointStatus)) {\r\n");
1110 fileBuffer
.append(" mDriverEntryPointStatus = Status;\r\n");
1111 fileBuffer
.append(" }\r\n");
1112 fileBuffer
.append(" LongJump (&mJumpContext, (UINTN)-1);\r\n");
1113 fileBuffer
.append(" ASSERT (FALSE);\r\n");
1115 fileBuffer
.append("}\r\n\r\n");
1120 // Add ModuleUnloadImage for DxeDriver and UefiDriver module type.
1122 entryPointList
= SurfaceAreaQuery
.getModuleUnloadImageArray();
1124 // Remover duplicate unload entry point.
1126 entryPointList
= CommonDefinition
.remDupString(entryPointList
);
1127 entryPointCount
= 0;
1128 if (entryPointList
!= null) {
1129 for (int i
= 0; i
< entryPointList
.length
; i
++) {
1130 fileBuffer
.append("EFI_STATUS\r\n");
1131 fileBuffer
.append("EFIAPI\r\n");
1132 fileBuffer
.append(entryPointList
[i
]);
1133 fileBuffer
.append(" (\r\n");
1135 .append(" IN EFI_HANDLE ImageHandle\r\n");
1136 fileBuffer
.append(" );\r\n");
1142 .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gDriverUnloadImageCount = ");
1143 fileBuffer
.append(Integer
.toString(entryPointCount
));
1144 fileBuffer
.append(";\r\n\r\n");
1146 fileBuffer
.append("EFI_STATUS\n");
1147 fileBuffer
.append("EFIAPI\r\n");
1148 fileBuffer
.append("ProcessModuleUnloadList (\r\n");
1149 fileBuffer
.append(" IN EFI_HANDLE ImageHandle\r\n");
1150 fileBuffer
.append(" )\r\n");
1151 fileBuffer
.append("{\r\n");
1153 if (entryPointCount
== 0) {
1154 fileBuffer
.append(" return EFI_SUCCESS;\r\n");
1155 } else if (entryPointCount
== 1) {
1156 fileBuffer
.append(" return ");
1157 fileBuffer
.append(entryPointList
[0]);
1158 fileBuffer
.append("(ImageHandle);\r\n");
1160 fileBuffer
.append(" EFI_STATUS Status;\r\n\r\n");
1161 fileBuffer
.append(" Status = EFI_SUCCESS;\r\n\r\n");
1162 for (int i
= 0; i
< entryPointList
.length
; i
++) {
1164 fileBuffer
.append(" Status = ");
1165 fileBuffer
.append(entryPointList
[i
]);
1166 fileBuffer
.append("(ImageHandle);\r\n");
1168 fileBuffer
.append(" if (EFI_ERROR (Status)) {\r\n");
1169 fileBuffer
.append(" ");
1170 fileBuffer
.append(entryPointList
[i
]);
1171 fileBuffer
.append("(ImageHandle);\r\n");
1172 fileBuffer
.append(" } else {\r\n");
1173 fileBuffer
.append(" Status = ");
1174 fileBuffer
.append(entryPointList
[i
]);
1175 fileBuffer
.append("(ImageHandle);\r\n");
1176 fileBuffer
.append(" }\r\n");
1179 fileBuffer
.append(" return Status;\r\n");
1181 fileBuffer
.append("}\r\n\r\n");
1189 * This function gets GUIDs from SPD file accrodeing to <PPIs> information
1190 * and write those GUIDs to AutoGen.c.
1193 * String Buffer for Autogen.c file.
1194 * @throws BuildException
1195 * Guid must set value!
1197 void PpiGuidToAutogenC(StringBuffer fileBuffer
) throws AutoGenException
{
1198 String
[] cNameGuid
= null;
1201 // Get the all PPI adn PPI Notify from MSA file,
1202 // then add those PPI ,and PPI Notify name to list.
1205 String
[] ppiList
= SurfaceAreaQuery
.getPpiArray(this.arch
);
1206 for (int i
= 0; i
< ppiList
.length
; i
++) {
1207 this.mPpiList
.add(ppiList
[i
]);
1210 String
[] ppiNotifyList
= SurfaceAreaQuery
.getPpiNotifyArray(this.arch
);
1211 for (int i
= 0; i
< ppiNotifyList
.length
; i
++) {
1212 this.mPpiList
.add(ppiNotifyList
[i
]);
1216 // Find CNAME and GUID from dependence SPD file and write to Autogen.c
1218 Iterator ppiIterator
= this.mPpiList
.iterator();
1219 String ppiKeyWord
= null;
1220 while (ppiIterator
.hasNext()) {
1221 ppiKeyWord
= ppiIterator
.next().toString();
1222 cNameGuid
= GlobalData
.getPpiGuid(this.mDepPkgList
, ppiKeyWord
);
1223 if (cNameGuid
!= null) {
1225 .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID ");
1226 fileBuffer
.append(cNameGuid
[0]);
1227 fileBuffer
.append(" = { ");
1228 fileBuffer
.append(CommonDefinition
.formatGuidName(cNameGuid
[1]));
1229 fileBuffer
.append(" } ;");
1232 // If can't find Ppi GUID declaration in every package
1234 throw new AutoGenException("Can not find Ppi GUID ["
1235 + ppiKeyWord
+ "] declaration in any SPD package!");
1241 * ProtocolGuidToAutogenc
1243 * This function gets GUIDs from SPD file accrodeing to <Protocol>
1244 * information and write those GUIDs to AutoGen.c.
1247 * String Buffer for Autogen.c file.
1248 * @throws BuildException
1249 * Protocol name must set.
1251 void ProtocolGuidToAutogenC(StringBuffer fileBuffer
) throws BuildException
{
1252 String
[] cNameGuid
= null;
1254 String
[] protocolList
= SurfaceAreaQuery
.getProtocolArray(this.arch
);
1257 // Add result to Autogen global list.
1259 for (int i
= 0; i
< protocolList
.length
; i
++) {
1260 this.mProtocolList
.add(protocolList
[i
]);
1263 String
[] protocolNotifyList
= SurfaceAreaQuery
1264 .getProtocolNotifyArray(this.arch
);
1266 for (int i
= 0; i
< protocolNotifyList
.length
; i
++) {
1267 this.mProtocolList
.add(protocolNotifyList
[i
]);
1271 // Get the NAME and GUID from dependence SPD and write to Autogen.c
1273 Iterator protocolIterator
= this.mProtocolList
.iterator();
1274 String protocolKeyWord
= null;
1277 while (protocolIterator
.hasNext()) {
1278 protocolKeyWord
= protocolIterator
.next().toString();
1279 cNameGuid
= GlobalData
.getProtocolGuid(this.mDepPkgList
, protocolKeyWord
);
1280 if (cNameGuid
!= null) {
1282 .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID ");
1283 fileBuffer
.append(cNameGuid
[0]);
1284 fileBuffer
.append(" = { ");
1285 fileBuffer
.append(CommonDefinition
.formatGuidName(cNameGuid
[1]));
1286 fileBuffer
.append(" } ;");
1289 // If can't find protocol GUID declaration in every package
1291 throw new BuildException("Can not find protocol Guid ["
1292 + protocolKeyWord
+ "] declaration in any SPD package!");
1298 * GuidGuidToAutogenc
1300 * This function gets GUIDs from SPD file accrodeing to <Guids> information
1301 * and write those GUIDs to AutoGen.c.
1304 * String Buffer for Autogen.c file.
1307 void GuidGuidToAutogenC(StringBuffer fileBuffer
) throws AutoGenException
{
1308 String
[] cNameGuid
= null;
1309 String guidKeyWord
= null;
1311 String
[] guidList
= SurfaceAreaQuery
.getGuidEntryArray(this.arch
);
1313 for (int i
= 0; i
< guidList
.length
; i
++) {
1314 this.mGuidList
.add(guidList
[i
]);
1318 Iterator guidIterator
= this.mGuidList
.iterator();
1319 while (guidIterator
.hasNext()) {
1320 guidKeyWord
= guidIterator
.next().toString();
1321 cNameGuid
= GlobalData
.getGuid(this.mDepPkgList
, guidKeyWord
);
1323 if (cNameGuid
!= null) {
1325 .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID ");
1326 fileBuffer
.append(cNameGuid
[0]);
1327 fileBuffer
.append(" = { ");
1328 fileBuffer
.append(CommonDefinition
.formatGuidName(cNameGuid
[1]));
1329 fileBuffer
.append("} ;");
1332 // If can't find GUID declaration in every package
1334 throw new AutoGenException("Can not find Guid [" + guidKeyWord
1335 + "] declaration in any SPD package. ");
1342 * LibInstanceToAutogenC
1344 * This function adds dependent library instance to autogen.c,which
1345 * includeing library's constructor, destructor, and library dependent ppi,
1346 * protocol, guid, pcd information.
1349 * String buffer for AutoGen.c
1350 * @throws BuildException
1352 void LibInstanceToAutogenC(StringBuffer fileBuffer
) throws BuildException
{
1354 String moduleType
= this.moduleId
.getModuleType();
1356 // Add library constructor to AutoGen.c
1358 LibConstructorToAutogenC(libConstructList
, moduleType
,
1359 fileBuffer
/* autogenC */);
1361 // Add library destructor to AutoGen.c
1363 LibDestructorToAutogenC(libDestructList
, moduleType
, fileBuffer
/* autogenC */);
1364 } catch (Exception e
) {
1365 throw new BuildException(e
.getMessage());
1370 * LibConstructorToAutogenc
1372 * This function writes library constructor list to AutoGen.c. The library
1373 * constructor's parameter and return value depend on module type.
1375 * @param libInstanceList
1376 * List of library construct name.
1380 * String buffer for AutoGen.c
1383 void LibConstructorToAutogenC(List
<String
> libInstanceList
,
1384 String moduleType
, StringBuffer fileBuffer
) throws Exception
{
1385 boolean isFirst
= true;
1388 // The library constructor's parameter and return value depend on
1391 for (int i
= 0; i
< libInstanceList
.size(); i
++) {
1392 switch (CommonDefinition
.getModuleType(moduleType
)) {
1393 case CommonDefinition
.ModuleTypeBase
:
1394 fileBuffer
.append("RETURN_STATUS\r\n");
1395 fileBuffer
.append("EFIAPI\r\n");
1396 fileBuffer
.append(libInstanceList
.get(i
));
1397 fileBuffer
.append(" (\r\n");
1398 fileBuffer
.append(" VOID\r\n");
1399 fileBuffer
.append(" );\r\n");
1402 case CommonDefinition
.ModuleTypePeiCore
:
1403 case CommonDefinition
.ModuleTypePeim
:
1404 fileBuffer
.append("EFI_STATUS\r\n");
1405 fileBuffer
.append("EFIAPI\r\n");
1406 fileBuffer
.append(libInstanceList
.get(i
));
1407 fileBuffer
.append(" (\r\n");
1409 .append(" IN EFI_FFS_FILE_HEADER *FfsHeader,\r\n");
1411 .append(" IN EFI_PEI_SERVICES **PeiServices\r\n");
1412 fileBuffer
.append(" );\r\n");
1415 case CommonDefinition
.ModuleTypeDxeCore
:
1416 case CommonDefinition
.ModuleTypeDxeDriver
:
1417 case CommonDefinition
.ModuleTypeDxeRuntimeDriver
:
1418 case CommonDefinition
.ModuleTypeDxeSmmDriver
:
1419 case CommonDefinition
.ModuleTypeDxeSalDriver
:
1420 case CommonDefinition
.ModuleTypeUefiDriver
:
1421 case CommonDefinition
.ModuleTypeUefiApplication
:
1422 fileBuffer
.append("EFI_STATUS\r\n");
1423 fileBuffer
.append("EFIAPI\r\n");
1424 fileBuffer
.append(libInstanceList
.get(i
));
1425 fileBuffer
.append(" (\r\n");
1426 fileBuffer
.append(" IN EFI_HANDLE ImageHandle,\r\n");
1427 fileBuffer
.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");
1428 fileBuffer
.append(" );\r\n");
1434 // Add ProcessLibraryConstructorList in AutoGen.c
1436 fileBuffer
.append("VOID\r\n");
1437 fileBuffer
.append("EFIAPI\r\n");
1438 fileBuffer
.append("ProcessLibraryConstructorList (\r\n");
1439 switch (CommonDefinition
.getModuleType(moduleType
)) {
1440 case CommonDefinition
.ModuleTypeBase
:
1441 fileBuffer
.append(" VOID\r\n");
1444 case CommonDefinition
.ModuleTypePeiCore
:
1445 case CommonDefinition
.ModuleTypePeim
:
1446 fileBuffer
.append(" IN EFI_FFS_FILE_HEADER *FfsHeader,\r\n");
1448 .append(" IN EFI_PEI_SERVICES **PeiServices\r\n");
1451 case CommonDefinition
.ModuleTypeDxeCore
:
1452 case CommonDefinition
.ModuleTypeDxeDriver
:
1453 case CommonDefinition
.ModuleTypeDxeRuntimeDriver
:
1454 case CommonDefinition
.ModuleTypeDxeSmmDriver
:
1455 case CommonDefinition
.ModuleTypeDxeSalDriver
:
1456 case CommonDefinition
.ModuleTypeUefiDriver
:
1457 case CommonDefinition
.ModuleTypeUefiApplication
:
1458 fileBuffer
.append(" IN EFI_HANDLE ImageHandle,\r\n");
1459 fileBuffer
.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");
1463 fileBuffer
.append(" )\r\n");
1464 fileBuffer
.append("{\r\n");
1466 // If no constructor function, return EFI_SUCCESS.
1468 //if (libInstanceList.size() == 0){
1469 // fileBuffer.append(" return EFI_SUCCESS;\r\n");
1471 for (int i
= 0; i
< libInstanceList
.size(); i
++) {
1473 fileBuffer
.append(" EFI_STATUS Status;\r\n");
1474 fileBuffer
.append(" Status = EFI_SUCCESS;\r\n");
1475 fileBuffer
.append("\r\n");
1478 switch (CommonDefinition
.getModuleType(moduleType
)) {
1479 case CommonDefinition
.ModuleTypeBase
:
1480 fileBuffer
.append(" Status = ");
1481 fileBuffer
.append(libInstanceList
.get(i
));
1482 fileBuffer
.append("();\r\n");
1483 fileBuffer
.append(" VOID\r\n");
1485 case CommonDefinition
.ModuleTypePeiCore
:
1486 case CommonDefinition
.ModuleTypePeim
:
1487 fileBuffer
.append(" Status = ");
1488 fileBuffer
.append(libInstanceList
.get(i
));
1489 fileBuffer
.append(" (FfsHeader, PeiServices);\r\n");
1491 case CommonDefinition
.ModuleTypeDxeCore
:
1492 case CommonDefinition
.ModuleTypeDxeDriver
:
1493 case CommonDefinition
.ModuleTypeDxeRuntimeDriver
:
1494 case CommonDefinition
.ModuleTypeDxeSmmDriver
:
1495 case CommonDefinition
.ModuleTypeDxeSalDriver
:
1496 case CommonDefinition
.ModuleTypeUefiDriver
:
1497 case CommonDefinition
.ModuleTypeUefiApplication
:
1498 fileBuffer
.append(" Status = ");
1499 fileBuffer
.append(libInstanceList
.get(i
));
1500 fileBuffer
.append(" (ImageHandle, SystemTable);\r\n");
1503 EdkLog
.log(EdkLog
.EDK_INFO
,"Autogen doesn't know how to deal with module type - " + moduleType
+ "!");
1505 fileBuffer
.append(" ASSERT_EFI_ERROR (Status);\r\n");
1507 fileBuffer
.append("}\r\n");
1511 * LibDestructorToAutogenc
1513 * This function writes library destructor list to AutoGen.c. The library
1514 * destructor's parameter and return value depend on module type.
1516 * @param libInstanceList
1517 * List of library destructor name.
1521 * String buffer for AutoGen.c
1524 void LibDestructorToAutogenC(List
<String
> libInstanceList
,
1525 String moduleType
, StringBuffer fileBuffer
) throws Exception
{
1526 boolean isFirst
= true;
1527 for (int i
= 0; i
< libInstanceList
.size(); i
++) {
1528 switch (CommonDefinition
.getModuleType(moduleType
)) {
1529 case CommonDefinition
.ModuleTypeBase
:
1530 fileBuffer
.append("RETURN_STATUS\r\n");
1531 fileBuffer
.append("EFIAPI\r\n");
1532 fileBuffer
.append(libInstanceList
.get(i
));
1533 fileBuffer
.append(" (\r\n");
1534 fileBuffer
.append(" VOID\r\n");
1535 fileBuffer
.append(" );\r\n");
1537 case CommonDefinition
.ModuleTypePeiCore
:
1538 case CommonDefinition
.ModuleTypePeim
:
1539 fileBuffer
.append("EFI_STATUS\r\n");
1540 fileBuffer
.append("EFIAPI\r\n");
1541 fileBuffer
.append(libInstanceList
.get(i
));
1542 fileBuffer
.append(" (\r\n");
1544 .append(" IN EFI_FFS_FILE_HEADER *FfsHeader,\r\n");
1546 .append(" IN EFI_PEI_SERVICES **PeiServices\r\n");
1547 fileBuffer
.append(" );\r\n");
1549 case CommonDefinition
.ModuleTypeDxeCore
:
1550 case CommonDefinition
.ModuleTypeDxeDriver
:
1551 case CommonDefinition
.ModuleTypeDxeRuntimeDriver
:
1552 case CommonDefinition
.ModuleTypeDxeSmmDriver
:
1553 case CommonDefinition
.ModuleTypeDxeSalDriver
:
1554 case CommonDefinition
.ModuleTypeUefiDriver
:
1555 case CommonDefinition
.ModuleTypeUefiApplication
:
1556 fileBuffer
.append("EFI_STATUS\r\n");
1557 fileBuffer
.append("EFIAPI\r\n");
1558 fileBuffer
.append(libInstanceList
.get(i
));
1559 fileBuffer
.append(" (\r\n");
1560 fileBuffer
.append(" IN EFI_HANDLE ImageHandle,\r\n");
1561 fileBuffer
.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");
1562 fileBuffer
.append(" );\r\n");
1568 // Write ProcessLibraryDestructor list to autogen.c
1570 switch (CommonDefinition
.getModuleType(moduleType
)) {
1571 case CommonDefinition
.ModuleTypeBase
:
1572 case CommonDefinition
.ModuleTypePeiCore
:
1573 case CommonDefinition
.ModuleTypePeim
:
1575 case CommonDefinition
.ModuleTypeDxeCore
:
1576 case CommonDefinition
.ModuleTypeDxeDriver
:
1577 case CommonDefinition
.ModuleTypeDxeRuntimeDriver
:
1578 case CommonDefinition
.ModuleTypeDxeSmmDriver
:
1579 case CommonDefinition
.ModuleTypeDxeSalDriver
:
1580 case CommonDefinition
.ModuleTypeUefiDriver
:
1581 case CommonDefinition
.ModuleTypeUefiApplication
:
1582 fileBuffer
.append("VOID\r\n");
1583 fileBuffer
.append("EFIAPI\r\n");
1584 fileBuffer
.append("ProcessLibraryDestructorList (\r\n");
1585 fileBuffer
.append(" IN EFI_HANDLE ImageHandle,\r\n");
1586 fileBuffer
.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");
1587 fileBuffer
.append(" )\r\n");
1588 fileBuffer
.append("{\r\n");
1590 // If no library destructor function, return EFI_SUCCESS.
1593 for (int i
= 0; i
< libInstanceList
.size(); i
++) {
1595 fileBuffer
.append(" EFI_STATUS Status;\r\n");
1596 fileBuffer
.append(" Status = EFI_SUCCESS;\r\n");
1597 fileBuffer
.append("\r\n");
1600 fileBuffer
.append(" Status = ");
1601 fileBuffer
.append(libInstanceList
.get(i
));
1602 fileBuffer
.append("(ImageHandle, SystemTable);\r\n");
1603 fileBuffer
.append(" ASSERT_EFI_ERROR (Status);\r\n");
1605 fileBuffer
.append("}\r\n");
1611 * ExternsDriverBindingToAutoGenC
1613 * This function is to write DRIVER_BINDING, COMPONENT_NAME,
1614 * DRIVER_CONFIGURATION, DRIVER_DIAGNOSTIC in AutoGen.c.
1617 * String buffer for AutoGen.c
1619 void ExternsDriverBindingToAutoGenC(StringBuffer fileBuffer
)
1620 throws BuildException
{
1623 // Check what <extern> contains. And the number of following elements
1624 // under <extern> should be same. 1. DRIVER_BINDING 2. COMPONENT_NAME
1625 // 3.DRIVER_CONFIGURATION 4. DRIVER_DIAGNOSTIC
1628 String
[] drvBindList
= SurfaceAreaQuery
.getDriverBindingArray();
1631 // If component name protocol,component configuration protocol,
1632 // component diagnostic protocol is not null or empty, check
1633 // if every one have the same number of the driver binding protocol.
1635 if (drvBindList
== null || drvBindList
.length
== 0) {
1639 String
[] compNamList
= SurfaceAreaQuery
.getComponentNameArray();
1640 String
[] compConfList
= SurfaceAreaQuery
.getDriverConfigArray();
1641 String
[] compDiagList
= SurfaceAreaQuery
.getDriverDiagArray();
1646 // Write driver binding protocol extern to autogen.c
1648 for (int i
= 0; i
< drvBindList
.length
; i
++) {
1649 fileBuffer
.append("extern EFI_DRIVER_BINDING_PROTOCOL ");
1650 fileBuffer
.append(drvBindList
[i
]);
1651 fileBuffer
.append(";\r\n");
1655 // Write component name protocol extern to autogen.c
1657 if (compNamList
!= null && compNamList
.length
!= 0) {
1658 if (drvBindList
.length
!= compNamList
.length
) {
1659 throw new BuildException(
1660 "Different number of Driver Binding and Component Name protocols!");
1664 for (int i
= 0; i
< compNamList
.length
; i
++) {
1665 fileBuffer
.append("extern EFI_COMPONENT_NAME_PROTOCOL ");
1666 fileBuffer
.append(compNamList
[i
]);
1667 fileBuffer
.append(";\r\n");
1672 // Write driver configration protocol extern to autogen.c
1674 if (compConfList
!= null && compConfList
.length
!= 0) {
1675 if (drvBindList
.length
!= compConfList
.length
) {
1676 throw new BuildException(
1677 "Different number of Driver Binding and Driver Configuration protocols!");
1681 for (int i
= 0; i
< compConfList
.length
; i
++) {
1682 fileBuffer
.append("extern EFI_DRIVER_CONFIGURATION_PROTOCOL ");
1683 fileBuffer
.append(compConfList
[i
]);
1684 fileBuffer
.append(";\r\n");
1689 // Write driver dignastic protocol extern to autogen.c
1691 if (compDiagList
!= null && compDiagList
.length
!= 0) {
1692 if (drvBindList
.length
!= compDiagList
.length
) {
1693 throw new BuildException(
1694 "Different number of Driver Binding and Driver Diagnosis protocols!");
1698 for (int i
= 0; i
< compDiagList
.length
; i
++) {
1699 fileBuffer
.append("extern EFI_DRIVER_DIAGNOSTICS_PROTOCOL ");
1700 fileBuffer
.append(compDiagList
[i
]);
1701 fileBuffer
.append(";\r\n");
1706 // Write driver module protocol bitmask.
1709 .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gDriverModelProtocolBitmask = ");
1710 fileBuffer
.append(Integer
.toString(BitMask
));
1711 fileBuffer
.append(";\r\n");
1714 // Write driver module protocol list entry
1717 .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINTN _gDriverModelProtocolListEntries = ");
1719 fileBuffer
.append(Integer
.toString(drvBindList
.length
));
1720 fileBuffer
.append(";\r\n");
1723 // Write drive module protocol list to autogen.c
1726 .append("GLOBAL_REMOVE_IF_UNREFERENCED const EFI_DRIVER_MODEL_PROTOCOL_LIST _gDriverModelProtocolList[] = {");
1727 for (int i
= 0; i
< drvBindList
.length
; i
++) {
1729 fileBuffer
.append(",");
1731 fileBuffer
.append("\r\n {\r\n");
1732 fileBuffer
.append(" &");
1733 fileBuffer
.append(drvBindList
[i
]);
1734 fileBuffer
.append(", \r\n");
1736 if (compNamList
!= null) {
1737 fileBuffer
.append(" &");
1738 fileBuffer
.append(compNamList
[i
]);
1739 fileBuffer
.append(", \r\n");
1741 fileBuffer
.append(" NULL, \r\n");
1744 if (compConfList
!= null) {
1745 fileBuffer
.append(" &");
1746 fileBuffer
.append(compConfList
[i
]);
1747 fileBuffer
.append(", \r\n");
1749 fileBuffer
.append(" NULL, \r\n");
1752 if (compDiagList
!= null) {
1753 fileBuffer
.append(" &");
1754 fileBuffer
.append(compDiagList
[i
]);
1755 fileBuffer
.append(", \r\n");
1757 fileBuffer
.append(" NULL, \r\n");
1759 fileBuffer
.append(" }");
1761 fileBuffer
.append("\r\n};\r\n");
1765 * ExternCallBackToAutoGenC
1767 * This function adds <SetVirtualAddressMapCallBack> and
1768 * <ExitBootServicesCallBack> infomation to AutoGen.c
1771 * String buffer for AutoGen.c
1772 * @throws BuildException
1774 void ExternCallBackToAutoGenC(StringBuffer fileBuffer
)
1775 throws BuildException
{
1777 // Collect module's <SetVirtualAddressMapCallBack> and
1778 // <ExitBootServiceCallBack> and add to setVirtualAddList
1779 // exitBootServiceList.
1781 String
[] setVirtuals
= SurfaceAreaQuery
.getSetVirtualAddressMapCallBackArray();
1782 String
[] exitBoots
= SurfaceAreaQuery
.getExitBootServicesCallBackArray();
1783 if (setVirtuals
!= null) {
1784 for (int j
= 0; j
< setVirtuals
.length
; j
++) {
1785 this.setVirtalAddList
.add(setVirtuals
[j
]);
1788 if (exitBoots
!= null) {
1789 for (int k
= 0; k
< exitBoots
.length
; k
++) {
1790 this.exitBootServiceList
.add(exitBoots
[k
]);
1794 // Add c code in autogen.c which relate to <SetVirtualAddressMapCallBack>
1795 // and <ExitBootServicesCallBack>
1797 String moduleType
= this.moduleId
.getModuleType();
1798 boolean UefiOrDxeModule
= false;
1801 switch (CommonDefinition
.getModuleType(moduleType
)) {
1802 case CommonDefinition
.ModuleTypeDxeDriver
:
1803 case CommonDefinition
.ModuleTypeDxeRuntimeDriver
:
1804 case CommonDefinition
.ModuleTypeDxeSalDriver
:
1805 case CommonDefinition
.ModuleTypeUefiDriver
:
1806 case CommonDefinition
.ModuleTypeUefiApplication
:
1808 // Entry point lib for these module types needs to know the count
1811 UefiOrDxeModule
= true;
1813 .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED const UINTN _gDriverSetVirtualAddressMapEventCount = ");
1816 // If the list is not valid or has no entries set count to zero else
1817 // set count to the number of valid entries
1820 if (this.setVirtalAddList
!= null) {
1821 for (i
= 0; i
< this.setVirtalAddList
.size(); i
++) {
1822 if (this.setVirtalAddList
.get(i
).equalsIgnoreCase("")) {
1829 fileBuffer
.append(Integer
.toString(Count
));
1830 fileBuffer
.append(";\r\n\r\n");
1836 if (this.setVirtalAddList
== null || this.setVirtalAddList
.size() == 0) {
1837 if (UefiOrDxeModule
) {
1839 // No data so make a NULL list
1842 .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED const EFI_EVENT_NOTIFY _gDriverSetVirtualAddressMapEvent[] = {\r\n");
1843 fileBuffer
.append(" NULL\r\n");
1844 fileBuffer
.append("};\r\n\r\n");
1848 // Write SetVirtualAddressMap function definition.
1850 for (i
= 0; i
< this.setVirtalAddList
.size(); i
++) {
1851 if (this.setVirtalAddList
.get(i
).equalsIgnoreCase("")) {
1854 fileBuffer
.append("VOID\r\n");
1855 fileBuffer
.append("EFIAPI\r\n");
1856 fileBuffer
.append(this.setVirtalAddList
.get(i
));
1857 fileBuffer
.append(" (\r\n");
1858 fileBuffer
.append(" IN EFI_EVENT Event,\r\n");
1859 fileBuffer
.append(" IN VOID *Context\r\n");
1860 fileBuffer
.append(" );\r\n\r\n");
1864 // Write SetVirtualAddressMap entry point array.
1867 .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED const EFI_EVENT_NOTIFY _gDriverSetVirtualAddressMapEvent[] = {");
1868 for (i
= 0; i
< this.setVirtalAddList
.size(); i
++) {
1869 if (this.setVirtalAddList
.get(i
).equalsIgnoreCase("")) {
1874 fileBuffer
.append("\r\n ");
1876 fileBuffer
.append(",\r\n ");
1879 fileBuffer
.append(this.setVirtalAddList
.get(i
));
1882 // If module is not DXE_DRIVER, DXE_RUNTIME_DIRVER, UEFI_DRIVER
1883 // UEFI_APPLICATION and DXE_SAL_DRIVER add the NULL at the end of
1884 // _gDriverSetVirtualAddressMapEvent list.
1886 if (!UefiOrDxeModule
) {
1887 fileBuffer
.append(",\r\n NULL");
1889 fileBuffer
.append("\r\n};\r\n\r\n");
1892 if (UefiOrDxeModule
) {
1894 // Entry point lib for these module types needs to know the count.
1897 .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED const UINTN _gDriverExitBootServicesEventCount = ");
1900 // If the list is not valid or has no entries set count to zero else
1901 // set count to the number of valid entries.
1904 if (this.exitBootServiceList
!= null) {
1905 for (i
= 0; i
< this.exitBootServiceList
.size(); i
++) {
1906 if (this.exitBootServiceList
.get(i
).equalsIgnoreCase("")) {
1912 fileBuffer
.append(Integer
.toString(Count
));
1913 fileBuffer
.append(";\r\n\r\n");
1916 if (this.exitBootServiceList
== null || this.exitBootServiceList
.size() == 0) {
1917 if (UefiOrDxeModule
) {
1919 // No data so make a NULL list.
1922 .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED const EFI_EVENT_NOTIFY _gDriverExitBootServicesEvent[] = {\r\n");
1923 fileBuffer
.append(" NULL\r\n");
1924 fileBuffer
.append("};\r\n\r\n");
1928 // Write DriverExitBootServices function definition.
1930 for (i
= 0; i
< this.exitBootServiceList
.size(); i
++) {
1931 if (this.exitBootServiceList
.get(i
).equalsIgnoreCase("")) {
1935 fileBuffer
.append("VOID\r\n");
1936 fileBuffer
.append("EFIAPI\r\n");
1937 fileBuffer
.append(this.exitBootServiceList
.get(i
));
1938 fileBuffer
.append(" (\r\n");
1939 fileBuffer
.append(" IN EFI_EVENT Event,\r\n");
1940 fileBuffer
.append(" IN VOID *Context\r\n");
1941 fileBuffer
.append(" );\r\n\r\n");
1945 // Write DriverExitBootServices entry point array.
1948 .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED const EFI_EVENT_NOTIFY _gDriverExitBootServicesEvent[] = {");
1949 for (i
= 0; i
< this.exitBootServiceList
.size(); i
++) {
1950 if (this.exitBootServiceList
.get(i
).equalsIgnoreCase("")) {
1955 fileBuffer
.append("\r\n ");
1957 fileBuffer
.append(",\r\n ");
1959 fileBuffer
.append(this.exitBootServiceList
.get(i
));
1961 if (!UefiOrDxeModule
) {
1962 fileBuffer
.append(",\r\n NULL");
1964 fileBuffer
.append("\r\n};\r\n\r\n");
1969 private void copyFlashMapHToDebugDir() throws AutoGenException
{
1971 File inFile
= new File(fvDir
+ File
.separatorChar
+ CommonDefinition
.flashMapH
);
1972 int size
= (int)inFile
.length();
1973 byte[] buffer
= new byte[size
];
1974 File outFile
= new File (this.outputPath
+ File
.separatorChar
+ CommonDefinition
.tianoR8FlashMapH
);
1976 // If TianoR8FlashMap.h existed and the flashMap.h don't change,
1979 if ((!outFile
.exists()) ||(inFile
.lastModified() - outFile
.lastModified()) >= 0) {
1981 if (inFile
.exists()) {
1982 FileInputStream fis
= new FileInputStream (inFile
);
1984 FileOutputStream fos
= new FileOutputStream(outFile
);
1989 throw new AutoGenException("The file, flashMap.h doesn't exist!");
1991 } catch (Exception e
){
1992 throw new AutoGenException(e
.getMessage());
1998 *This function first order the library instances, then collect
1999 *library instance 's PPI, Protocol, GUID,
2000 *SetVirtalAddressMapCallBack, ExitBootServiceCallBack, and
2001 *Destructor, Constructor.
2004 private void collectLibInstanceInfo(){
2007 String moduleType
= SurfaceAreaQuery
.getModuleType();
2008 String libConstructName
= null;
2009 String libDestructName
= null;
2010 String
[] setVirtuals
= null;
2011 String
[] exitBoots
= null;
2013 ModuleIdentification
[] libraryIdList
= SurfaceAreaQuery
2014 .getLibraryInstance(this.arch
);
2016 if (libraryIdList
!= null) {
2018 // Reorder library instance sequence.
2020 AutogenLibOrder libOrder
= new AutogenLibOrder(libraryIdList
,
2022 List
<ModuleIdentification
> orderList
= libOrder
2023 .orderLibInstance();
2025 if (orderList
!= null) {
2027 // Process library instance one by one.
2029 for (int i
= 0; i
< orderList
.size(); i
++) {
2032 // Get library instance basename.
2034 ModuleIdentification libInstanceId
= orderList
.get(i
);
2040 Map
<String
, XmlObject
> libDoc
= GlobalData
.getDoc(
2041 libInstanceId
, this.arch
);
2042 SurfaceAreaQuery
.push(libDoc
);
2044 // Get <PPis>, <Protocols>, <Guids> list of this library
2047 String
[] ppiList
= SurfaceAreaQuery
.getPpiArray(this.arch
);
2048 String
[] ppiNotifyList
= SurfaceAreaQuery
2049 .getPpiNotifyArray(this.arch
);
2050 String
[] protocolList
= SurfaceAreaQuery
2051 .getProtocolArray(this.arch
);
2052 String
[] protocolNotifyList
= SurfaceAreaQuery
2053 .getProtocolNotifyArray(this.arch
);
2054 String
[] guidList
= SurfaceAreaQuery
2055 .getGuidEntryArray(this.arch
);
2056 PackageIdentification
[] pkgList
= SurfaceAreaQuery
.getDependencePkg(this.arch
);
2059 // Add those ppi, protocol, guid in global ppi,
2063 for (index
= 0; index
< ppiList
.length
; index
++) {
2064 this.mPpiList
.add(ppiList
[index
]);
2067 for (index
= 0; index
< ppiNotifyList
.length
; index
++) {
2068 this.mPpiList
.add(ppiNotifyList
[index
]);
2071 for (index
= 0; index
< protocolList
.length
; index
++) {
2072 this.mProtocolList
.add(protocolList
[index
]);
2075 for (index
= 0; index
< protocolNotifyList
.length
; index
++) {
2076 this.mProtocolList
.add(protocolNotifyList
[index
]);
2079 for (index
= 0; index
< guidList
.length
; index
++) {
2080 this.mGuidList
.add(guidList
[index
]);
2082 for (index
= 0; index
< pkgList
.length
; index
++){
2083 if (!this.mDepPkgList
.contains(pkgList
[index
])){
2084 this.mDepPkgList
.add(pkgList
[index
]);
2089 // If not yet parse this library instance's constructor
2090 // element,parse it.
2092 libConstructName
= SurfaceAreaQuery
2093 .getLibConstructorName();
2094 libDestructName
= SurfaceAreaQuery
2095 .getLibDestructorName();
2098 // Collect SetVirtualAddressMapCallBack and
2099 // ExitBootServiceCallBack.
2101 setVirtuals
= SurfaceAreaQuery
.getSetVirtualAddressMapCallBackArray();
2102 exitBoots
= SurfaceAreaQuery
.getExitBootServicesCallBackArray();
2103 if (setVirtuals
!= null) {
2104 for (int j
= 0; j
< setVirtuals
.length
; j
++) {
2105 this.setVirtalAddList
.add(setVirtuals
[j
]);
2108 if (exitBoots
!= null) {
2109 for (int k
= 0; k
< exitBoots
.length
; k
++) {
2110 this.exitBootServiceList
.add(exitBoots
[k
]);
2113 SurfaceAreaQuery
.pop();
2115 // Add dependent library instance constructor function.
2117 if (libConstructName
!= null) {
2118 this.libConstructList
.add(libConstructName
);
2121 // Add dependent library instance destructor fuction.
2123 if (libDestructName
!= null) {
2124 this.libDestructList
.add(libDestructName
);
2131 }catch (Exception e
){
2132 System
.out
.println(e
.getMessage());
2133 System
.out
.println("Collect library instance failed!");