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
;
47 import org
.tianocore
.logger
.EdkLog
;
50 * This class is to generate Autogen.h and Autogen.c according to module surface
51 * area or library surface area.
53 public class AutoGen
{
55 // / The output path of Autogen.h and Autogen.c
57 private String outputPath
;
59 /// The name of FV directory
63 // / The base name of module or library.
65 private ModuleIdentification moduleId
;
68 // / The build architecture
73 // / PcdAutogen instance which is used to manage how to generate the PCD
76 private PCDAutoGenAction myPcdAutogen
;
79 // / The protocl list which records in module or library surface area and
80 // / it's dependence on library instance surface area.
82 private Set
<String
> mProtocolList
= new HashSet
<String
>();
85 // / The Ppi list which recorded in module or library surface area and its
86 // / dependency on library instance surface area.
88 private Set
<String
> mPpiList
= new HashSet
<String
>();
91 // / The Guid list which recoreded in module or library surface area and it's
92 // / dependence on library instance surface area.
94 private Set
<String
> mGuidList
= new HashSet
<String
>();
97 // The dependence package list which recoreded in module or library surface
98 // area and it's dependence on library instance surface are.
100 private List
<PackageIdentification
> mDepPkgList
= new LinkedList
<PackageIdentification
>();
103 // For non library module, add its library instance's construct and destructor to
106 private List
<String
> libConstructList
= new ArrayList
<String
>();
107 private List
<String
> libDestructList
= new ArrayList
<String
>();
110 // List to store SetVirtalAddressMapCallBack, ExitBootServiceCallBack
112 private List
<String
> setVirtalAddList
= new ArrayList
<String
>();
113 private List
<String
> exitBootServiceList
= new ArrayList
<String
>();
119 * This function mainly initialize some member variable.
122 * Output path of AutoGen file.
126 * Target architecture.
128 public AutoGen(String fvDir
, String outputPath
, ModuleIdentification moduleId
, String arch
) {
129 this.outputPath
= outputPath
;
130 this.moduleId
= moduleId
;
139 * This function save the content in stringBuffer to file.
144 * The content of AutoGen file in buffer.
145 * @return "true" successful, "false" failed.
147 private boolean saveFile(String fileName
, StringBuffer fileBuffer
) {
149 File autoGenH
= new File(fileName
);
152 // if the file exists, compare their content
154 if (autoGenH
.exists()) {
155 FileReader fIn
= new FileReader(autoGenH
);
156 char[] oldFileBuffer
= new char[(int) autoGenH
.length()];
157 fIn
.read(oldFileBuffer
, 0, (int) autoGenH
.length());
161 // if we got the same file, don't re-generate it to prevent
162 // sources depending on it from re-building
164 if (fileBuffer
.toString().compareTo(new String(oldFileBuffer
)) == 0) {
168 FileWriter fOut
= new FileWriter(autoGenH
);
169 fOut
.write(fileBuffer
.toString());
171 } catch (Exception e
) {
178 * genAutogen function
180 * This function call libGenAutoGen or moduleGenAutogen function, which
181 * dependence on generate library autogen or module autogen.
183 * @throws BuildException
184 * Failed to creat AutoGen.c & AutoGen.h.
186 public void genAutogen() throws BuildException
{
189 // If outputPath do not exist, create it.
191 File path
= new File(outputPath
);
195 // Check current is library or not, then call the corresponding
198 if (this.moduleId
.isLibrary()) {
204 } catch (Exception e
) {
205 throw new BuildException(
206 "Failed to create AutoGen.c & AutoGen.h!\n"
212 * moduleGenAutogen function
214 * This function generates AutoGen.c & AutoGen.h for module.
216 * @throws BuildException
217 * Faile to create module AutoGen.c & AutoGen.h.
219 void moduleGenAutogen() throws BuildException
{
222 collectLibInstanceInfo();
225 } catch (Exception e
) {
226 throw new BuildException(
227 "Faile to create module AutoGen.c & AutoGen.h!\n"
233 * libGenAutogen function
235 * This function generates AutoGen.c & AutoGen.h for library.
237 * @throws BuildException
238 * Faile to create library AutoGen.c & AutoGen.h
240 void libGenAutogen() throws BuildException
{
244 } catch (Exception e
) {
245 throw new BuildException(
246 "Faile to create library AutoGen.c & AutoGen.h!\n"
254 * This function generates AutoGen.h for module.
256 * @throws BuildException
257 * Failed to generate AutoGen.h.
259 void moduleGenAutogenH() throws AutoGenException
{
261 Set
<String
> libClassIncludeH
;
263 // List<String> headerFileList;
264 List
<String
> headerFileList
;
266 StringBuffer fileBuffer
= new StringBuffer(8192);
269 // Write Autogen.h header notation
271 fileBuffer
.append(CommonDefinition
.autogenHNotation
);
274 // Add #ifndef ${BaseName}_AUTOGENH
275 // #def ${BseeName}_AUTOGENH
277 fileBuffer
.append("#ifndef " + "_AUTOGENH_" + this.moduleId
.getGuid().replaceAll("-", "_") +"\r\n");
278 fileBuffer
.append("#define " + "_AUTOGENH_" + this.moduleId
.getGuid().replaceAll("-", "_") +"\r\n\r\n");
281 // Write the specification version and release version at the begine
282 // of autogen.h file.
283 // Note: the specification version and release version should
284 // be got from module surface area instead of hard code by it's
287 moduleType
= SurfaceAreaQuery
.getModuleType();
290 // Add "extern int __make_me_compile_correctly;" at begin of
293 fileBuffer
.append(CommonDefinition
.autoGenHbegin
);
296 // Put EFI_SPECIFICATION_VERSION, and EDK_RELEASE_VERSION.
298 String
[] specList
= SurfaceAreaQuery
.getExternSpecificaiton();
299 for (int i
= 0; i
< specList
.length
; i
++) {
300 fileBuffer
.append(CommonDefinition
.marcDefineStr
+ specList
[i
]
304 // Write consumed package's mdouleInfo related .h file to autogen.h
306 // PackageIdentification[] consumedPkgIdList = SurfaceAreaQuery
307 // .getDependencePkg(this.arch);
308 PackageIdentification
[] consumedPkgIdList
= SurfaceAreaQuery
309 .getDependencePkg(this.arch
);
310 if (consumedPkgIdList
!= null) {
311 headerFileList
= depPkgToAutogenH(consumedPkgIdList
, moduleType
);
312 item
= headerFileList
.iterator();
313 while (item
.hasNext()) {
314 fileBuffer
.append(item
.next().toString());
319 // Write library class's related *.h file to autogen.h.
321 String
[] libClassList
= SurfaceAreaQuery
322 .getLibraryClasses(CommonDefinition
.AlwaysConsumed
,this.arch
);
323 if (libClassList
!= null) {
324 libClassIncludeH
= LibraryClassToAutogenH(libClassList
);
325 item
= libClassIncludeH
.iterator();
326 while (item
.hasNext()) {
327 fileBuffer
.append(item
.next().toString());
331 libClassList
= SurfaceAreaQuery
332 .getLibraryClasses(CommonDefinition
.AlwaysProduced
, this.arch
);
333 if (libClassList
!= null) {
334 libClassIncludeH
= LibraryClassToAutogenH(libClassList
);
335 item
= libClassIncludeH
.iterator();
336 while (item
.hasNext()) {
337 fileBuffer
.append(item
.next().toString());
340 fileBuffer
.append("\r\n");
343 // If is TianoR8FlashMap, copy {Fv_DIR}/FlashMap.h to
344 // {DEST_DIR_DRBUG}/FlashMap.h
346 if (SurfaceAreaQuery
.isHaveTianoR8FlashMap()) {
347 fileBuffer
.append(CommonDefinition
.include
);
348 fileBuffer
.append(" <");
349 fileBuffer
.append(CommonDefinition
.tianoR8FlashMapH
+ ">\r\n");
350 copyFlashMapHToDebugDir();
353 // Write PCD autogen information to AutoGen.h.
355 if (this.myPcdAutogen
!= null) {
356 fileBuffer
.append("\r\n");
357 fileBuffer
.append(this.myPcdAutogen
.OutputH());
361 // Append the #endif at AutoGen.h
363 fileBuffer
.append("#endif\r\n");
366 // Save string buffer content in AutoGen.h.
368 if (!saveFile(outputPath
+ File
.separatorChar
+ "AutoGen.h", fileBuffer
)) {
369 throw new BuildException("Failed to generate AutoGen.h !!!");
376 * This function generates AutoGen.c for module.
378 * @throws BuildException
379 * Failed to generate AutoGen.c.
381 void moduleGenAutogenC() throws AutoGenException
{
383 StringBuffer fileBuffer
= new StringBuffer(8192);
385 // Write Autogen.c header notation
387 fileBuffer
.append(CommonDefinition
.autogenCNotation
);
390 // Write #include <AutoGen.h> at beginning of AutoGen.c
392 fileBuffer
.append(CommonDefinition
.includeAutogenH
);
395 // Get the native MSA file infomation. Since before call autogen,
396 // the MSA native <Externs> information were overrided. So before
397 // process <Externs> it should be set the DOC as the Native MSA info.
399 Map
<String
, XmlObject
> doc
= GlobalData
.getNativeMsa(this.moduleId
);
400 SurfaceAreaQuery
.push(doc
);
403 // DriverBinding/ComponentName/DriverConfiguration/DriverDialog
407 ExternsDriverBindingToAutoGenC(fileBuffer
);
410 // Write DriverExitBootServicesEvent/DriverSetVirtualAddressMapEvent
413 ExternCallBackToAutoGenC(fileBuffer
);
416 // Write EntryPoint to autgoGen.c
418 String
[] entryPointList
= SurfaceAreaQuery
.getModuleEntryPointArray();
419 EntryPointToAutoGen(CommonDefinition
.remDupString(entryPointList
), fileBuffer
);
423 // Restore the DOC which include the FPD module info.
425 SurfaceAreaQuery
.pop();
428 // Write Guid to autogen.c
430 String guid
= CommonDefinition
.formatGuidName(SurfaceAreaQuery
434 .append("GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiCallerIdGuid = {");
436 throw new AutoGenException("Guid value must set!\n");
440 // Formate Guid as ANSI c form.Example:
441 // {0xd2b2b828, 0x826, 0x48a7,{0xb3, 0xdf, 0x98, 0x3c, 0x0, 0x60, 0x24,
445 fileBuffer
.append(guid
);
446 fileBuffer
.append("};\r\n");
449 // Generate library instance consumed protocol, guid, ppi, pcd list.
450 // Save those to this.protocolList, this.ppiList, this.pcdList,
451 // this.guidList. Write Consumed library constructor and desconstuct to
454 LibInstanceToAutogenC(fileBuffer
);
457 // Get module dependent Package identification.
459 PackageIdentification
[] packages
= SurfaceAreaQuery
.getDependencePkg(this.arch
);
460 for (int i
= 0; i
< packages
.length
; i
++){
461 if (!this.mDepPkgList
.contains(packages
[i
])){
462 this.mDepPkgList
.add(packages
[i
]);
468 // Write consumed ppi, guid, protocol to autogen.c
470 ProtocolGuidToAutogenC(fileBuffer
);
471 PpiGuidToAutogenC(fileBuffer
);
472 GuidGuidToAutogenC(fileBuffer
);
477 this.myPcdAutogen
= new PCDAutoGenAction(moduleId
, this.arch
, false, null);
479 this.myPcdAutogen
.execute();
480 } catch (Exception exp
) {
481 throw new PcdAutogenException (exp
.getMessage());
484 if (this.myPcdAutogen
!= null) {
485 fileBuffer
.append("\r\n");
486 fileBuffer
.append(this.myPcdAutogen
.OutputC());
489 if (!saveFile(outputPath
+ File
.separatorChar
+ "AutoGen.c", fileBuffer
)) {
490 throw new BuildException("Failed to generate AutoGen.c !!!");
498 * This function generates AutoGen.h for library.
500 * @throws BuildException
501 * Failed to generate AutoGen.c.
503 void libGenAutogenH() throws AutoGenException
{
505 Set
<String
> libClassIncludeH
;
507 List
<String
> headerFileList
;
509 StringBuffer fileBuffer
= new StringBuffer(10240);
512 // Write Autogen.h header notation
514 fileBuffer
.append(CommonDefinition
.autogenHNotation
);
517 // Add #ifndef ${BaseName}_AUTOGENH
518 // #def ${BseeName}_AUTOGENH
520 fileBuffer
.append("#ifndef " + "_AUTOGENH_" + this.moduleId
.getGuid().replaceAll("-", "_") + "\r\n");
521 fileBuffer
.append("#define " + "_AUTOGENH_" + this.moduleId
.getGuid().replaceAll("-", "_") + "\r\n\r\n");
524 // Write EFI_SPECIFICATION_VERSION and EDK_RELEASE_VERSION
525 // to autogen.h file.
526 // Note: the specification version and release version should
527 // be get from module surface area instead of hard code.
529 fileBuffer
.append(CommonDefinition
.autoGenHbegin
);
530 String
[] specList
= SurfaceAreaQuery
.getExternSpecificaiton();
531 for (int i
= 0; i
< specList
.length
; i
++) {
532 fileBuffer
.append(CommonDefinition
.marcDefineStr
+ specList
[i
]
535 // fileBuffer.append(CommonDefinition.autoGenHLine1);
536 // fileBuffer.append(CommonDefinition.autoGenHLine2);
539 // Write consumed package's mdouleInfo related *.h file to autogen.h.
541 moduleType
= SurfaceAreaQuery
.getModuleType();
542 PackageIdentification
[] cosumedPkglist
= SurfaceAreaQuery
543 .getDependencePkg(this.arch
);
544 headerFileList
= depPkgToAutogenH(cosumedPkglist
, moduleType
);
545 item
= headerFileList
.iterator();
546 while (item
.hasNext()) {
547 fileBuffer
.append(item
.next().toString());
550 // Write library class's related *.h file to autogen.h
552 String
[] libClassList
= SurfaceAreaQuery
553 .getLibraryClasses(CommonDefinition
.AlwaysConsumed
, this.arch
);
554 if (libClassList
!= null) {
555 libClassIncludeH
= LibraryClassToAutogenH(libClassList
);
556 item
= libClassIncludeH
.iterator();
557 while (item
.hasNext()) {
558 fileBuffer
.append(item
.next().toString());
562 libClassList
= SurfaceAreaQuery
563 .getLibraryClasses(CommonDefinition
.AlwaysProduced
, this.arch
);
564 if (libClassList
!= null) {
565 libClassIncludeH
= LibraryClassToAutogenH(libClassList
);
566 item
= libClassIncludeH
.iterator();
567 while (item
.hasNext()) {
568 fileBuffer
.append(item
.next().toString());
571 fileBuffer
.append("\r\n");
574 // If is TianoR8FlashMap, copy {Fv_DIR}/FlashMap.h to
575 // {DEST_DIR_DRBUG}/FlashMap.h
577 if (SurfaceAreaQuery
.isHaveTianoR8FlashMap()) {
578 fileBuffer
.append(CommonDefinition
.include
);
579 fileBuffer
.append(" <");
580 fileBuffer
.append(CommonDefinition
.tianoR8FlashMapH
+ ">\r\n");
581 copyFlashMapHToDebugDir();
585 // Write PCD information to library AutoGen.h.
587 if (this.myPcdAutogen
!= null) {
588 fileBuffer
.append("\r\n");
589 fileBuffer
.append(this.myPcdAutogen
.OutputH());
593 // Append the #endif at AutoGen.h
595 fileBuffer
.append("#endif\r\n");
598 // Save content of string buffer to AutoGen.h file.
600 if (!saveFile(outputPath
+ File
.separatorChar
+ "AutoGen.h", fileBuffer
)) {
601 throw new BuildException("Failed to generate AutoGen.h !!!");
608 * This function generates AutoGen.h for library.
610 * @throws BuildException
611 * Failed to generate AutoGen.c.
613 void libGenAutogenC() throws BuildException
, PcdAutogenException
{
614 StringBuffer fileBuffer
= new StringBuffer(10240);
617 // Write Autogen.c header notation
619 fileBuffer
.append(CommonDefinition
.autogenCNotation
);
621 fileBuffer
.append(CommonDefinition
.autoGenCLine1
);
622 fileBuffer
.append("\r\n");
627 this.myPcdAutogen
= new PCDAutoGenAction(this.moduleId
,
630 SurfaceAreaQuery
.getModulePcdEntryNameArray());
632 this.myPcdAutogen
.execute();
633 } catch (Exception e
) {
634 throw new PcdAutogenException(e
.getMessage());
637 if (this.myPcdAutogen
!= null) {
638 fileBuffer
.append("\r\n");
639 fileBuffer
.append(this.myPcdAutogen
.OutputC());
642 if (!saveFile(outputPath
+ File
.separatorChar
+ "AutoGen.c", fileBuffer
)) {
643 throw new BuildException("Failed to generate AutoGen.c !!!");
648 * LibraryClassToAutogenH
650 * This function returns *.h files declared by library classes which are
651 * consumed or produced by current build module or library.
653 * @param libClassList
654 * List of library class which consumed or produce by current
655 * build module or library.
656 * @return includeStrList List of *.h file.
658 Set
<String
> LibraryClassToAutogenH(String
[] libClassList
)
659 throws AutoGenException
{
660 Set
<String
> includStrList
= new LinkedHashSet
<String
>();
661 String includerName
[];
665 // Get include file from GlobalData's SPDTable according to
666 // library class name.
669 for (int i
= 0; i
< libClassList
.length
; i
++) {
670 includerName
= GlobalData
.getLibraryClassHeaderFiles(
671 SurfaceAreaQuery
.getDependencePkg(this.arch
),
673 if (includerName
== null) {
674 throw new AutoGenException("Can not find library class ["
675 + libClassList
[i
] + "] declaration in every packages. ");
677 for (int j
= 0; j
< includerName
.length
; j
++) {
678 String includeNameStr
= includerName
[j
];
679 if (includeNameStr
!= null) {
680 str
= CommonDefinition
.include
+ " " + "<";
681 str
= str
+ includeNameStr
+ ">\r\n";
682 includStrList
.add(str
);
683 includeNameStr
= null;
687 return includStrList
;
693 * This function add include file in AutoGen.h file.
695 * @param packageNameList
696 * List of module depended package.
701 List
<String
> depPkgToAutogenH(PackageIdentification
[] packageNameList
,
702 String moduleType
) throws AutoGenException
{
704 List
<String
> includeStrList
= new LinkedList
<String
>();
706 String includeStr
= "";
709 // Get include file from moduleInfo file
711 for (int i
= 0; i
< packageNameList
.length
; i
++) {
712 pkgHeader
= GlobalData
.getPackageHeaderFiles(packageNameList
[i
],
714 if (pkgHeader
== null) {
715 throw new AutoGenException("Can not find package ["
717 + "] declaration in every packages. ");
718 } else if (!pkgHeader
.equalsIgnoreCase("")) {
719 includeStr
= CommonDefinition
.include
+ " <" + pkgHeader
721 includeStrList
.add(includeStr
);
725 return includeStrList
;
729 * EntryPointToAutoGen
731 * This function convert <ModuleEntryPoint> & <ModuleUnloadImage>
732 * information in mas to AutoGen.c
734 * @param entryPointList
735 * List of entry point.
737 * String buffer fo AutoGen.c.
740 void EntryPointToAutoGen(String
[] entryPointList
, StringBuffer fileBuffer
)
741 throws BuildException
{
743 String typeStr
= SurfaceAreaQuery
.getModuleType();
746 // The parameters and return value of entryPoint is difference
747 // for difference module type.
749 switch (CommonDefinition
.getModuleType(typeStr
)) {
751 case CommonDefinition
.ModuleTypePeiCore
:
752 if (entryPointList
== null ||entryPointList
.length
!= 1 ) {
753 throw new BuildException(
754 "Module type = 'PEI_CORE', only have one module entry point!");
756 fileBuffer
.append("EFI_STATUS\r\n");
757 fileBuffer
.append("EFIAPI\r\n");
758 fileBuffer
.append(entryPointList
[0]);
759 fileBuffer
.append(" (\r\n");
761 .append(" IN EFI_PEI_STARTUP_DESCRIPTOR *PeiStartupDescriptor,\r\n");
763 .append(" IN VOID *OldCoreData\r\n");
764 fileBuffer
.append(" );\r\n\r\n");
766 fileBuffer
.append("EFI_STATUS\r\n");
767 fileBuffer
.append("EFIAPI\r\n");
768 fileBuffer
.append("ProcessModuleEntryPointList (\r\n");
770 .append(" IN EFI_PEI_STARTUP_DESCRIPTOR *PeiStartupDescriptor,\r\n");
772 .append(" IN VOID *OldCoreData\r\n");
773 fileBuffer
.append(" )\r\n\r\n");
774 fileBuffer
.append("{\r\n");
775 fileBuffer
.append(" return ");
776 fileBuffer
.append(entryPointList
[0]);
777 fileBuffer
.append(" (PeiStartupDescriptor, OldCoreData);\r\n");
778 fileBuffer
.append("}\r\n\r\n");
782 case CommonDefinition
.ModuleTypeDxeCore
:
783 fileBuffer
.append("const UINT32 _gUefiDriverRevision = 0;\r\n");
784 if (entryPointList
== null || entryPointList
.length
!= 1) {
785 throw new BuildException(
786 "Module type = 'DXE_CORE', only have one module entry point!");
789 fileBuffer
.append("VOID\r\n");
790 fileBuffer
.append("EFIAPI\r\n");
791 fileBuffer
.append(entryPointList
[0]);
792 fileBuffer
.append(" (\n");
793 fileBuffer
.append(" IN VOID *HobStart\r\n");
794 fileBuffer
.append(" );\r\n\r\n");
796 fileBuffer
.append("VOID\r\n");
797 fileBuffer
.append("EFIAPI\r\n");
798 fileBuffer
.append("ProcessModuleEntryPointList (\r\n");
799 fileBuffer
.append(" IN VOID *HobStart\r\n");
800 fileBuffer
.append(" )\r\n\r\n");
801 fileBuffer
.append("{\r\n");
802 fileBuffer
.append(" ");
803 fileBuffer
.append(entryPointList
[0]);
804 fileBuffer
.append(" (HobStart);\r\n");
805 fileBuffer
.append("}\r\n\r\n");
809 case CommonDefinition
.ModuleTypePeim
:
810 int entryPointCount
= 0;
812 .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT32 _gPeimRevision = 0;\r\n");
813 if (entryPointList
== null || entryPointList
.length
== 0) {
814 fileBuffer
.append("EFI_STATUS\r\n");
815 fileBuffer
.append("EFIAPI\r\n");
816 fileBuffer
.append("ProcessModuleEntryPointList (\r\n");
817 fileBuffer
.append(" IN EFI_FFS_FILE_HEADER *FfsHeader,\r\n");
818 fileBuffer
.append(" IN EFI_PEI_SERVICES **PeiServices\r\n");
819 fileBuffer
.append(" )\r\n\r\n");
820 fileBuffer
.append("{\r\n");
821 fileBuffer
.append(" return EFI_SUCCESS;\r\n");
822 fileBuffer
.append("}\r\n\r\n");
825 for (int i
= 0; i
< entryPointList
.length
; i
++) {
826 fileBuffer
.append("EFI_STATUS\r\n");
827 fileBuffer
.append("EFIAPI\r\n");
828 fileBuffer
.append(entryPointList
[i
]);
829 fileBuffer
.append(" (\r\n");
831 .append(" IN EFI_FFS_FILE_HEADER *FfsHeader,\r\n");
833 .append(" IN EFI_PEI_SERVICES **PeiServices\r\n");
834 fileBuffer
.append(" );\r\n");
839 fileBuffer
.append("EFI_STATUS\r\n");
840 fileBuffer
.append("EFIAPI\r\n");
841 fileBuffer
.append("ProcessModuleEntryPointList (\r\n");
842 fileBuffer
.append(" IN EFI_FFS_FILE_HEADER *FfsHeader,\r\n");
843 fileBuffer
.append(" IN EFI_PEI_SERVICES **PeiServices\r\n");
844 fileBuffer
.append(" )\r\n\r\n");
845 fileBuffer
.append("{\r\n");
846 if (entryPointCount
== 1) {
847 fileBuffer
.append(" return ");
848 fileBuffer
.append(entryPointList
[0]);
849 fileBuffer
.append(" (FfsHeader, PeiServices);\r\n");
851 fileBuffer
.append(" EFI_STATUS Status;\r\n");
852 fileBuffer
.append(" EFI_STATUS CombinedStatus;\r\n\r\n");
853 fileBuffer
.append(" CombinedStatus = EFI_LOAD_ERROR;\r\n\r\n");
854 for (int i
= 0; i
< entryPointList
.length
; i
++) {
855 if (!entryPointList
[i
].equals("")) {
856 fileBuffer
.append(" Status = ");
857 fileBuffer
.append(entryPointList
[i
]);
858 fileBuffer
.append(" (FfsHeader, PeiServices);\r\n");
860 .append(" if (!EFI_ERROR (Status) || EFI_ERROR (CombinedStatus)) {\r\n");
861 fileBuffer
.append(" CombinedStatus = Status;\r\n");
862 fileBuffer
.append(" }\r\n\r\n");
867 fileBuffer
.append(" return CombinedStatus;\r\n");
869 fileBuffer
.append("}\r\n\r\n");
872 case CommonDefinition
.ModuleTypeDxeSmmDriver
:
875 // If entryPoint is null, create an empty ProcessModuleEntryPointList
878 if (entryPointList
== null || entryPointList
.length
== 0){
880 .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gDriverEntryPointCount = ");
881 fileBuffer
.append(Integer
.toString(entryPointCount
));
882 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_HANDLE ImageHandle,\r\n");
887 fileBuffer
.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");
888 fileBuffer
.append(" )\r\n\r\n");
889 fileBuffer
.append("{\r\n");
890 fileBuffer
.append(" return EFI_SUCCESS;\r\n");
891 fileBuffer
.append("}\r\n\r\n");
894 for (int i
= 0; i
< entryPointList
.length
; i
++) {
895 fileBuffer
.append("EFI_STATUS\r\n");
896 fileBuffer
.append("EFIAPI\r\n");
897 fileBuffer
.append(entryPointList
[i
]);
898 fileBuffer
.append(" (\r\n");
899 fileBuffer
.append(" IN EFI_HANDLE ImageHandle,\r\n");
900 fileBuffer
.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");
901 fileBuffer
.append(" );\r\n");
905 .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gDriverEntryPointCount = ");
906 fileBuffer
.append(Integer
.toString(entryPointCount
));
907 fileBuffer
.append(";\r\n");
909 .append("static BASE_LIBRARY_JUMP_BUFFER mJumpContext;\r\n");
911 .append("static EFI_STATUS mDriverEntryPointStatus = EFI_LOAD_ERROR;\r\n\r\n");
913 fileBuffer
.append("EFI_STATUS\r\n");
914 fileBuffer
.append("EFIAPI\r\n");
915 fileBuffer
.append("ProcessModuleEntryPointList (\r\n");
916 fileBuffer
.append(" IN EFI_HANDLE ImageHandle,\r\n");
917 fileBuffer
.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");
918 fileBuffer
.append(" )\r\n\r\n");
919 fileBuffer
.append("{\r\n");
922 for (int i
= 0; i
< entryPointList
.length
; i
++) {
924 .append(" if (SetJump (&mJumpContext) == 0) {\r\n");
925 fileBuffer
.append(" ExitDriver (");
926 fileBuffer
.append(entryPointList
[i
]);
927 fileBuffer
.append(" (ImageHandle, SystemTable));\r\n");
928 fileBuffer
.append(" ASSERT (FALSE);\r\n");
929 fileBuffer
.append(" }\r\n");
932 fileBuffer
.append(" return mDriverEntryPointStatus;\r\n");
933 fileBuffer
.append("}\r\n\r\n");
935 fileBuffer
.append("VOID\r\n");
936 fileBuffer
.append("EFIAPI\r\n");
937 fileBuffer
.append("ExitDriver (\r\n");
938 fileBuffer
.append(" IN EFI_STATUS Status\n");
939 fileBuffer
.append(" )\r\n\r\n");
940 fileBuffer
.append("{\r\n");
942 .append(" if (!EFI_ERROR (Status) || EFI_ERROR (mDriverEntryPointStatus)) {\r\n");
943 fileBuffer
.append(" mDriverEntryPointStatus = Status;\r\n");
944 fileBuffer
.append(" }\r\n");
945 fileBuffer
.append(" LongJump (&mJumpContext, (UINTN)-1);\r\n");
946 fileBuffer
.append(" ASSERT (FALSE);\r\n");
947 fileBuffer
.append("}\r\n\r\n");
953 // Add "ModuleUnloadImage" for DxeSmmDriver module type;
955 entryPointList
= SurfaceAreaQuery
.getModuleUnloadImageArray();
956 entryPointList
= CommonDefinition
.remDupString(entryPointList
);
959 if (entryPointList
!= null) {
960 for (int i
= 0; i
< entryPointList
.length
; i
++) {
961 fileBuffer
.append("EFI_STATUS\r\n");
962 fileBuffer
.append("EFIAPI\r\n");
963 fileBuffer
.append(entryPointList
[i
]);
964 fileBuffer
.append(" (\r\n");
966 .append(" IN EFI_HANDLE ImageHandle\r\n");
967 fileBuffer
.append(" );\r\n");
973 .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gDriverUnloadImageCount = ");
974 fileBuffer
.append(Integer
.toString(entryPointCount
));
975 fileBuffer
.append(";\r\n\r\n");
977 fileBuffer
.append("EFI_STATUS\r\n");
978 fileBuffer
.append("EFIAPI\r\n");
979 fileBuffer
.append("ProcessModuleUnloadList (\r\n");
980 fileBuffer
.append(" IN EFI_HANDLE ImageHandle\r\n");
981 fileBuffer
.append(" )\r\n");
982 fileBuffer
.append("{\r\n");
984 if (entryPointCount
== 0) {
985 fileBuffer
.append(" return EFI_SUCCESS;\r\n");
986 } else if (entryPointCount
== 1) {
987 fileBuffer
.append(" return ");
988 fileBuffer
.append(entryPointList
[0]);
989 fileBuffer
.append("(ImageHandle);\r\n");
991 fileBuffer
.append(" EFI_STATUS Status;\r\n\r\n");
992 fileBuffer
.append(" Status = EFI_SUCCESS;\r\n\r\n");
993 for (int i
= 0; i
< entryPointList
.length
; i
++) {
995 fileBuffer
.append(" Status = ");
996 fileBuffer
.append(entryPointList
[i
]);
997 fileBuffer
.append("(ImageHandle);\r\n");
999 fileBuffer
.append(" if (EFI_ERROR (Status)) {\r\n");
1000 fileBuffer
.append(" ");
1001 fileBuffer
.append(entryPointList
[i
]);
1002 fileBuffer
.append("(ImageHandle);\r\n");
1003 fileBuffer
.append(" } else {\r\n");
1004 fileBuffer
.append(" Status = ");
1005 fileBuffer
.append(entryPointList
[i
]);
1006 fileBuffer
.append("(ImageHandle);\r\n");
1007 fileBuffer
.append(" }\r\n");
1010 fileBuffer
.append(" return Status;\r\n");
1012 fileBuffer
.append("}\r\n\r\n");
1015 case CommonDefinition
.ModuleTypeDxeRuntimeDriver
:
1016 case CommonDefinition
.ModuleTypeDxeDriver
:
1017 case CommonDefinition
.ModuleTypeDxeSalDriver
:
1018 case CommonDefinition
.ModuleTypeUefiDriver
:
1019 case CommonDefinition
.ModuleTypeUefiApplication
:
1020 entryPointCount
= 0;
1021 fileBuffer
.append("const UINT32 _gUefiDriverRevision = 0;\r\n");
1023 // If entry point is null, create a empty ProcessModuleEntryPointList function.
1025 if (entryPointList
== null || entryPointList
.length
== 0){
1027 .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gDriverEntryPointCount = 0;\r\n");
1028 fileBuffer
.append("EFI_STATUS\r\n");
1029 fileBuffer
.append("EFIAPI\r\n");
1030 fileBuffer
.append("ProcessModuleEntryPointList (\r\n");
1031 fileBuffer
.append(" IN EFI_HANDLE ImageHandle,\r\n");
1032 fileBuffer
.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");
1033 fileBuffer
.append(" )\r\n\r\n");
1034 fileBuffer
.append("{\r\n");
1035 fileBuffer
.append(" return EFI_SUCCESS;\r\n");
1036 fileBuffer
.append("}\r\n");
1039 for (int i
= 0; i
< entryPointList
.length
; i
++) {
1041 fileBuffer
.append("EFI_STATUS\r\n");
1042 fileBuffer
.append("EFIAPI\r\n");
1043 fileBuffer
.append(entryPointList
[i
]);
1044 fileBuffer
.append(" (\r\n");
1045 fileBuffer
.append(" IN EFI_HANDLE ImageHandle,\r\n");
1046 fileBuffer
.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");
1047 fileBuffer
.append(" );\r\n");
1052 .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gDriverEntryPointCount = ");
1053 fileBuffer
.append(Integer
.toString(entryPointCount
));
1054 fileBuffer
.append(";\r\n");
1055 if (entryPointCount
> 1) {
1057 .append("static BASE_LIBRARY_JUMP_BUFFER mJumpContext;\r\n");
1059 .append("static EFI_STATUS mDriverEntryPointStatus = EFI_LOAD_ERROR;\r\n");
1061 fileBuffer
.append("\n");
1063 fileBuffer
.append("EFI_STATUS\r\n");
1064 fileBuffer
.append("EFIAPI\r\n");
1065 fileBuffer
.append("ProcessModuleEntryPointList (\r\n");
1066 fileBuffer
.append(" IN EFI_HANDLE ImageHandle,\r\n");
1067 fileBuffer
.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");
1068 fileBuffer
.append(" )\r\n\r\n");
1069 fileBuffer
.append("{\r\n");
1071 if (entryPointCount
== 1) {
1072 fileBuffer
.append(" return (");
1073 fileBuffer
.append(entryPointList
[0]);
1074 fileBuffer
.append(" (ImageHandle, SystemTable));\r\n");
1076 for (int i
= 0; i
< entryPointList
.length
; i
++) {
1077 if (!entryPointList
[i
].equals("")) {
1079 .append(" if (SetJump (&mJumpContext) == 0) {\r\n");
1080 fileBuffer
.append(" ExitDriver (");
1081 fileBuffer
.append(entryPointList
[i
]);
1082 fileBuffer
.append(" (ImageHandle, SystemTable));\r\n");
1083 fileBuffer
.append(" ASSERT (FALSE);\r\n");
1084 fileBuffer
.append(" }\r\n");
1089 fileBuffer
.append(" return mDriverEntryPointStatus;\r\n");
1091 fileBuffer
.append("}\r\n\r\n");
1093 fileBuffer
.append("VOID\r\n");
1094 fileBuffer
.append("EFIAPI\r\n");
1095 fileBuffer
.append("ExitDriver (\r\n");
1096 fileBuffer
.append(" IN EFI_STATUS Status\r\n");
1097 fileBuffer
.append(" )\r\n\r\n");
1098 fileBuffer
.append("{\r\n");
1099 if (entryPointCount
<= 1) {
1100 fileBuffer
.append(" if (EFI_ERROR (Status)) {\r\n");
1102 .append(" ProcessLibraryDestructorList (gImageHandle, gST);\r\n");
1103 fileBuffer
.append(" }\r\n");
1105 .append(" gBS->Exit (gImageHandle, Status, 0, NULL);\r\n");
1108 .append(" if (!EFI_ERROR (Status) || EFI_ERROR (mDriverEntryPointStatus)) {\r\n");
1109 fileBuffer
.append(" mDriverEntryPointStatus = Status;\r\n");
1110 fileBuffer
.append(" }\r\n");
1111 fileBuffer
.append(" LongJump (&mJumpContext, (UINTN)-1);\r\n");
1112 fileBuffer
.append(" ASSERT (FALSE);\r\n");
1114 fileBuffer
.append("}\r\n\r\n");
1119 // Add ModuleUnloadImage for DxeDriver and UefiDriver module type.
1121 entryPointList
= SurfaceAreaQuery
.getModuleUnloadImageArray();
1123 // Remover duplicate unload entry point.
1125 entryPointList
= CommonDefinition
.remDupString(entryPointList
);
1126 entryPointCount
= 0;
1127 if (entryPointList
!= null) {
1128 for (int i
= 0; i
< entryPointList
.length
; i
++) {
1129 fileBuffer
.append("EFI_STATUS\r\n");
1130 fileBuffer
.append("EFIAPI\r\n");
1131 fileBuffer
.append(entryPointList
[i
]);
1132 fileBuffer
.append(" (\r\n");
1134 .append(" IN EFI_HANDLE ImageHandle\r\n");
1135 fileBuffer
.append(" );\r\n");
1141 .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gDriverUnloadImageCount = ");
1142 fileBuffer
.append(Integer
.toString(entryPointCount
));
1143 fileBuffer
.append(";\r\n\r\n");
1145 fileBuffer
.append("EFI_STATUS\n");
1146 fileBuffer
.append("EFIAPI\r\n");
1147 fileBuffer
.append("ProcessModuleUnloadList (\r\n");
1148 fileBuffer
.append(" IN EFI_HANDLE ImageHandle\r\n");
1149 fileBuffer
.append(" )\r\n");
1150 fileBuffer
.append("{\r\n");
1152 if (entryPointCount
== 0) {
1153 fileBuffer
.append(" return EFI_SUCCESS;\r\n");
1154 } else if (entryPointCount
== 1) {
1155 fileBuffer
.append(" return ");
1156 fileBuffer
.append(entryPointList
[0]);
1157 fileBuffer
.append("(ImageHandle);\r\n");
1159 fileBuffer
.append(" EFI_STATUS Status;\r\n\r\n");
1160 fileBuffer
.append(" Status = EFI_SUCCESS;\r\n\r\n");
1161 for (int i
= 0; i
< entryPointList
.length
; i
++) {
1163 fileBuffer
.append(" Status = ");
1164 fileBuffer
.append(entryPointList
[i
]);
1165 fileBuffer
.append("(ImageHandle);\r\n");
1167 fileBuffer
.append(" if (EFI_ERROR (Status)) {\r\n");
1168 fileBuffer
.append(" ");
1169 fileBuffer
.append(entryPointList
[i
]);
1170 fileBuffer
.append("(ImageHandle);\r\n");
1171 fileBuffer
.append(" } else {\r\n");
1172 fileBuffer
.append(" Status = ");
1173 fileBuffer
.append(entryPointList
[i
]);
1174 fileBuffer
.append("(ImageHandle);\r\n");
1175 fileBuffer
.append(" }\r\n");
1178 fileBuffer
.append(" return Status;\r\n");
1180 fileBuffer
.append("}\r\n\r\n");
1188 * This function gets GUIDs from SPD file accrodeing to <PPIs> information
1189 * and write those GUIDs to AutoGen.c.
1192 * String Buffer for Autogen.c file.
1193 * @throws BuildException
1194 * Guid must set value!
1196 void PpiGuidToAutogenC(StringBuffer fileBuffer
) throws AutoGenException
{
1197 String
[] cNameGuid
= null;
1200 // Get the all PPI adn PPI Notify from MSA file,
1201 // then add those PPI ,and PPI Notify name to list.
1204 String
[] ppiList
= SurfaceAreaQuery
.getPpiArray(this.arch
);
1205 for (int i
= 0; i
< ppiList
.length
; i
++) {
1206 this.mPpiList
.add(ppiList
[i
]);
1209 String
[] ppiNotifyList
= SurfaceAreaQuery
.getPpiNotifyArray(this.arch
);
1210 for (int i
= 0; i
< ppiNotifyList
.length
; i
++) {
1211 this.mPpiList
.add(ppiNotifyList
[i
]);
1215 // Find CNAME and GUID from dependence SPD file and write to Autogen.c
1217 Iterator ppiIterator
= this.mPpiList
.iterator();
1218 String ppiKeyWord
= null;
1219 while (ppiIterator
.hasNext()) {
1220 ppiKeyWord
= ppiIterator
.next().toString();
1221 cNameGuid
= GlobalData
.getPpiGuid(this.mDepPkgList
, ppiKeyWord
);
1222 if (cNameGuid
!= null) {
1224 .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID ");
1225 fileBuffer
.append(cNameGuid
[0]);
1226 fileBuffer
.append(" = { ");
1227 fileBuffer
.append(CommonDefinition
.formatGuidName(cNameGuid
[1]));
1228 fileBuffer
.append(" } ;");
1231 // If can't find Ppi GUID declaration in every package
1233 throw new AutoGenException("Can not find Ppi GUID ["
1234 + ppiKeyWord
+ "] declaration in every packages. ");
1240 * ProtocolGuidToAutogenc
1242 * This function gets GUIDs from SPD file accrodeing to <Protocol>
1243 * information and write those GUIDs to AutoGen.c.
1246 * String Buffer for Autogen.c file.
1247 * @throws BuildException
1248 * Protocol name must set.
1250 void ProtocolGuidToAutogenC(StringBuffer fileBuffer
) throws BuildException
{
1251 String
[] cNameGuid
= null;
1253 String
[] protocolList
= SurfaceAreaQuery
.getProtocolArray(this.arch
);
1256 // Add result to Autogen global list.
1258 for (int i
= 0; i
< protocolList
.length
; i
++) {
1259 this.mProtocolList
.add(protocolList
[i
]);
1262 String
[] protocolNotifyList
= SurfaceAreaQuery
1263 .getProtocolNotifyArray(this.arch
);
1265 for (int i
= 0; i
< protocolNotifyList
.length
; i
++) {
1266 this.mProtocolList
.add(protocolNotifyList
[i
]);
1270 // Get the NAME and GUID from dependence SPD and write to Autogen.c
1272 Iterator protocolIterator
= this.mProtocolList
.iterator();
1273 String protocolKeyWord
= null;
1276 while (protocolIterator
.hasNext()) {
1277 protocolKeyWord
= protocolIterator
.next().toString();
1278 cNameGuid
= GlobalData
.getProtocolGuid(this.mDepPkgList
, protocolKeyWord
);
1279 if (cNameGuid
!= null) {
1281 .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID ");
1282 fileBuffer
.append(cNameGuid
[0]);
1283 fileBuffer
.append(" = { ");
1284 fileBuffer
.append(CommonDefinition
.formatGuidName(cNameGuid
[1]));
1285 fileBuffer
.append(" } ;");
1288 // If can't find protocol GUID declaration in every package
1290 throw new BuildException("Can not find protocol Guid ["
1291 + protocolKeyWord
+ "] declaration in every packages. ");
1297 * GuidGuidToAutogenc
1299 * This function gets GUIDs from SPD file accrodeing to <Guids> information
1300 * and write those GUIDs to AutoGen.c.
1303 * String Buffer for Autogen.c file.
1306 void GuidGuidToAutogenC(StringBuffer fileBuffer
) throws AutoGenException
{
1307 String
[] cNameGuid
= null;
1308 String guidKeyWord
= null;
1310 String
[] guidList
= SurfaceAreaQuery
.getGuidEntryArray(this.arch
);
1312 for (int i
= 0; i
< guidList
.length
; i
++) {
1313 this.mGuidList
.add(guidList
[i
]);
1317 Iterator guidIterator
= this.mGuidList
.iterator();
1318 while (guidIterator
.hasNext()) {
1319 guidKeyWord
= guidIterator
.next().toString();
1320 cNameGuid
= GlobalData
.getGuid(this.mDepPkgList
, guidKeyWord
);
1322 if (cNameGuid
!= null) {
1324 .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID ");
1325 fileBuffer
.append(cNameGuid
[0]);
1326 fileBuffer
.append(" = { ");
1327 fileBuffer
.append(CommonDefinition
.formatGuidName(cNameGuid
[1]));
1328 fileBuffer
.append("} ;");
1331 // If can't find GUID declaration in every package
1333 throw new AutoGenException("Can not find Guid [" + guidKeyWord
1334 + "] declaration in every packages. ");
1341 * LibInstanceToAutogenC
1343 * This function adds dependent library instance to autogen.c,which
1344 * includeing library's constructor, destructor, and library dependent ppi,
1345 * protocol, guid, pcd information.
1348 * String buffer for AutoGen.c
1349 * @throws BuildException
1351 void LibInstanceToAutogenC(StringBuffer fileBuffer
) throws BuildException
{
1353 String moduleType
= this.moduleId
.getModuleType();
1355 // Add library constructor to AutoGen.c
1357 LibConstructorToAutogenC(libConstructList
, moduleType
,
1358 fileBuffer
/* autogenC */);
1360 // Add library destructor to AutoGen.c
1362 LibDestructorToAutogenC(libDestructList
, moduleType
, fileBuffer
/* autogenC */);
1363 } catch (Exception e
) {
1364 throw new BuildException(e
.getMessage());
1369 * LibConstructorToAutogenc
1371 * This function writes library constructor list to AutoGen.c. The library
1372 * constructor's parameter and return value depend on module type.
1374 * @param libInstanceList
1375 * List of library construct name.
1379 * String buffer for AutoGen.c
1382 void LibConstructorToAutogenC(List
<String
> libInstanceList
,
1383 String moduleType
, StringBuffer fileBuffer
) throws Exception
{
1384 boolean isFirst
= true;
1387 // The library constructor's parameter and return value depend on
1390 for (int i
= 0; i
< libInstanceList
.size(); i
++) {
1391 switch (CommonDefinition
.getModuleType(moduleType
)) {
1392 case CommonDefinition
.ModuleTypeBase
:
1393 fileBuffer
.append("RETURN_STATUS\r\n");
1394 fileBuffer
.append("EFIAPI\r\n");
1395 fileBuffer
.append(libInstanceList
.get(i
));
1396 fileBuffer
.append(" (\r\n");
1397 fileBuffer
.append(" VOID\r\n");
1398 fileBuffer
.append(" );\r\n");
1401 case CommonDefinition
.ModuleTypePeiCore
:
1402 case CommonDefinition
.ModuleTypePeim
:
1403 fileBuffer
.append("EFI_STATUS\r\n");
1404 fileBuffer
.append("EFIAPI\r\n");
1405 fileBuffer
.append(libInstanceList
.get(i
));
1406 fileBuffer
.append(" (\r\n");
1408 .append(" IN EFI_FFS_FILE_HEADER *FfsHeader,\r\n");
1410 .append(" IN EFI_PEI_SERVICES **PeiServices\r\n");
1411 fileBuffer
.append(" );\r\n");
1414 case CommonDefinition
.ModuleTypeDxeCore
:
1415 case CommonDefinition
.ModuleTypeDxeDriver
:
1416 case CommonDefinition
.ModuleTypeDxeRuntimeDriver
:
1417 case CommonDefinition
.ModuleTypeDxeSmmDriver
:
1418 case CommonDefinition
.ModuleTypeDxeSalDriver
:
1419 case CommonDefinition
.ModuleTypeUefiDriver
:
1420 case CommonDefinition
.ModuleTypeUefiApplication
:
1421 fileBuffer
.append("EFI_STATUS\r\n");
1422 fileBuffer
.append("EFIAPI\r\n");
1423 fileBuffer
.append(libInstanceList
.get(i
));
1424 fileBuffer
.append(" (\r\n");
1425 fileBuffer
.append(" IN EFI_HANDLE ImageHandle,\r\n");
1426 fileBuffer
.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");
1427 fileBuffer
.append(" );\r\n");
1433 // Add ProcessLibraryConstructorList in AutoGen.c
1435 fileBuffer
.append("VOID\r\n");
1436 fileBuffer
.append("EFIAPI\r\n");
1437 fileBuffer
.append("ProcessLibraryConstructorList (\r\n");
1438 switch (CommonDefinition
.getModuleType(moduleType
)) {
1439 case CommonDefinition
.ModuleTypeBase
:
1440 fileBuffer
.append(" VOID\r\n");
1443 case CommonDefinition
.ModuleTypePeiCore
:
1444 case CommonDefinition
.ModuleTypePeim
:
1445 fileBuffer
.append(" IN EFI_FFS_FILE_HEADER *FfsHeader,\r\n");
1447 .append(" IN EFI_PEI_SERVICES **PeiServices\r\n");
1450 case CommonDefinition
.ModuleTypeDxeCore
:
1451 case CommonDefinition
.ModuleTypeDxeDriver
:
1452 case CommonDefinition
.ModuleTypeDxeRuntimeDriver
:
1453 case CommonDefinition
.ModuleTypeDxeSmmDriver
:
1454 case CommonDefinition
.ModuleTypeDxeSalDriver
:
1455 case CommonDefinition
.ModuleTypeUefiDriver
:
1456 case CommonDefinition
.ModuleTypeUefiApplication
:
1457 fileBuffer
.append(" IN EFI_HANDLE ImageHandle,\r\n");
1458 fileBuffer
.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");
1462 fileBuffer
.append(" )\r\n");
1463 fileBuffer
.append("{\r\n");
1465 // If no constructor function, return EFI_SUCCESS.
1467 //if (libInstanceList.size() == 0){
1468 // fileBuffer.append(" return EFI_SUCCESS;\r\n");
1470 for (int i
= 0; i
< libInstanceList
.size(); i
++) {
1472 fileBuffer
.append(" EFI_STATUS Status;\r\n");
1473 fileBuffer
.append(" Status = EFI_SUCCESS;\r\n");
1474 fileBuffer
.append("\r\n");
1477 switch (CommonDefinition
.getModuleType(moduleType
)) {
1478 case CommonDefinition
.ModuleTypeBase
:
1479 fileBuffer
.append(" Status = ");
1480 fileBuffer
.append(libInstanceList
.get(i
));
1481 fileBuffer
.append("();\r\n");
1482 fileBuffer
.append(" VOID\r\n");
1484 case CommonDefinition
.ModuleTypePeiCore
:
1485 case CommonDefinition
.ModuleTypePeim
:
1486 fileBuffer
.append(" Status = ");
1487 fileBuffer
.append(libInstanceList
.get(i
));
1488 fileBuffer
.append(" (FfsHeader, PeiServices);\r\n");
1490 case CommonDefinition
.ModuleTypeDxeCore
:
1491 case CommonDefinition
.ModuleTypeDxeDriver
:
1492 case CommonDefinition
.ModuleTypeDxeRuntimeDriver
:
1493 case CommonDefinition
.ModuleTypeDxeSmmDriver
:
1494 case CommonDefinition
.ModuleTypeDxeSalDriver
:
1495 case CommonDefinition
.ModuleTypeUefiDriver
:
1496 case CommonDefinition
.ModuleTypeUefiApplication
:
1497 fileBuffer
.append(" Status = ");
1498 fileBuffer
.append(libInstanceList
.get(i
));
1499 fileBuffer
.append(" (ImageHandle, SystemTable);\r\n");
1502 EdkLog
.log(EdkLog
.EDK_INFO
,"Autogen don't know how to deal with module type -"+ moduleType
+ " !");
1504 fileBuffer
.append(" ASSERT_EFI_ERROR (Status);\r\n");
1506 fileBuffer
.append("}\r\n");
1510 * LibDestructorToAutogenc
1512 * This function writes library destructor list to AutoGen.c. The library
1513 * destructor's parameter and return value depend on module type.
1515 * @param libInstanceList
1516 * List of library destructor name.
1520 * String buffer for AutoGen.c
1523 void LibDestructorToAutogenC(List
<String
> libInstanceList
,
1524 String moduleType
, StringBuffer fileBuffer
) throws Exception
{
1525 boolean isFirst
= true;
1526 for (int i
= 0; i
< libInstanceList
.size(); i
++) {
1527 switch (CommonDefinition
.getModuleType(moduleType
)) {
1528 case CommonDefinition
.ModuleTypeBase
:
1529 fileBuffer
.append("RETURN_STATUS\r\n");
1530 fileBuffer
.append("EFIAPI\r\n");
1531 fileBuffer
.append(libInstanceList
.get(i
));
1532 fileBuffer
.append(" (\r\n");
1533 fileBuffer
.append(" VOID\r\n");
1534 fileBuffer
.append(" );\r\n");
1536 case CommonDefinition
.ModuleTypePeiCore
:
1537 case CommonDefinition
.ModuleTypePeim
:
1538 fileBuffer
.append("EFI_STATUS\r\n");
1539 fileBuffer
.append("EFIAPI\r\n");
1540 fileBuffer
.append(libInstanceList
.get(i
));
1541 fileBuffer
.append(" (\r\n");
1543 .append(" IN EFI_FFS_FILE_HEADER *FfsHeader,\r\n");
1545 .append(" IN EFI_PEI_SERVICES **PeiServices\r\n");
1546 fileBuffer
.append(" );\r\n");
1548 case CommonDefinition
.ModuleTypeDxeCore
:
1549 case CommonDefinition
.ModuleTypeDxeDriver
:
1550 case CommonDefinition
.ModuleTypeDxeRuntimeDriver
:
1551 case CommonDefinition
.ModuleTypeDxeSmmDriver
:
1552 case CommonDefinition
.ModuleTypeDxeSalDriver
:
1553 case CommonDefinition
.ModuleTypeUefiDriver
:
1554 case CommonDefinition
.ModuleTypeUefiApplication
:
1555 fileBuffer
.append("EFI_STATUS\r\n");
1556 fileBuffer
.append("EFIAPI\r\n");
1557 fileBuffer
.append(libInstanceList
.get(i
));
1558 fileBuffer
.append(" (\r\n");
1559 fileBuffer
.append(" IN EFI_HANDLE ImageHandle,\r\n");
1560 fileBuffer
.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");
1561 fileBuffer
.append(" );\r\n");
1567 // Write ProcessLibraryDestructor list to autogen.c
1569 switch (CommonDefinition
.getModuleType(moduleType
)) {
1570 case CommonDefinition
.ModuleTypeBase
:
1571 case CommonDefinition
.ModuleTypePeiCore
:
1572 case CommonDefinition
.ModuleTypePeim
:
1574 case CommonDefinition
.ModuleTypeDxeCore
:
1575 case CommonDefinition
.ModuleTypeDxeDriver
:
1576 case CommonDefinition
.ModuleTypeDxeRuntimeDriver
:
1577 case CommonDefinition
.ModuleTypeDxeSmmDriver
:
1578 case CommonDefinition
.ModuleTypeDxeSalDriver
:
1579 case CommonDefinition
.ModuleTypeUefiDriver
:
1580 case CommonDefinition
.ModuleTypeUefiApplication
:
1581 fileBuffer
.append("VOID\r\n");
1582 fileBuffer
.append("EFIAPI\r\n");
1583 fileBuffer
.append("ProcessLibraryDestructorList (\r\n");
1584 fileBuffer
.append(" IN EFI_HANDLE ImageHandle,\r\n");
1585 fileBuffer
.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");
1586 fileBuffer
.append(" )\r\n");
1587 fileBuffer
.append("{\r\n");
1589 // If no library destructor function, return EFI_SUCCESS.
1592 for (int i
= 0; i
< libInstanceList
.size(); i
++) {
1594 fileBuffer
.append(" EFI_STATUS Status;\r\n");
1595 fileBuffer
.append(" Status = EFI_SUCCESS;\r\n");
1596 fileBuffer
.append("\r\n");
1599 fileBuffer
.append(" Status = ");
1600 fileBuffer
.append(libInstanceList
.get(i
));
1601 fileBuffer
.append("(ImageHandle, SystemTable);\r\n");
1602 fileBuffer
.append(" ASSERT_EFI_ERROR (Status);\r\n");
1604 fileBuffer
.append("}\r\n");
1610 * ExternsDriverBindingToAutoGenC
1612 * This function is to write DRIVER_BINDING, COMPONENT_NAME,
1613 * DRIVER_CONFIGURATION, DRIVER_DIAGNOSTIC in AutoGen.c.
1616 * String buffer for AutoGen.c
1618 void ExternsDriverBindingToAutoGenC(StringBuffer fileBuffer
)
1619 throws BuildException
{
1622 // Check what <extern> contains. And the number of following elements
1623 // under <extern> should be same. 1. DRIVER_BINDING 2. COMPONENT_NAME
1624 // 3.DRIVER_CONFIGURATION 4. DRIVER_DIAGNOSTIC
1627 String
[] drvBindList
= SurfaceAreaQuery
.getDriverBindingArray();
1630 // If component name protocol,component configuration protocol,
1631 // component diagnostic protocol is not null or empty, check
1632 // if every one have the same number of the driver binding protocol.
1634 if (drvBindList
== null || drvBindList
.length
== 0) {
1638 String
[] compNamList
= SurfaceAreaQuery
.getComponentNameArray();
1639 String
[] compConfList
= SurfaceAreaQuery
.getDriverConfigArray();
1640 String
[] compDiagList
= SurfaceAreaQuery
.getDriverDiagArray();
1645 // Write driver binding protocol extern to autogen.c
1647 for (int i
= 0; i
< drvBindList
.length
; i
++) {
1648 fileBuffer
.append("extern EFI_DRIVER_BINDING_PROTOCOL ");
1649 fileBuffer
.append(drvBindList
[i
]);
1650 fileBuffer
.append(";\r\n");
1654 // Write component name protocol extern to autogen.c
1656 if (compNamList
!= null && compNamList
.length
!= 0) {
1657 if (drvBindList
.length
!= compNamList
.length
) {
1658 throw new BuildException(
1659 "Different number of Driver Binding and Component Name protocols!");
1663 for (int i
= 0; i
< compNamList
.length
; i
++) {
1664 fileBuffer
.append("extern EFI_COMPONENT_NAME_PROTOCOL ");
1665 fileBuffer
.append(compNamList
[i
]);
1666 fileBuffer
.append(";\r\n");
1671 // Write driver configration protocol extern to autogen.c
1673 if (compConfList
!= null && compConfList
.length
!= 0) {
1674 if (drvBindList
.length
!= compConfList
.length
) {
1675 throw new BuildException(
1676 "Different number of Driver Binding and Driver Configuration protocols!");
1680 for (int i
= 0; i
< compConfList
.length
; i
++) {
1681 fileBuffer
.append("extern EFI_DRIVER_CONFIGURATION_PROTOCOL ");
1682 fileBuffer
.append(compConfList
[i
]);
1683 fileBuffer
.append(";\r\n");
1688 // Write driver dignastic protocol extern to autogen.c
1690 if (compDiagList
!= null && compDiagList
.length
!= 0) {
1691 if (drvBindList
.length
!= compDiagList
.length
) {
1692 throw new BuildException(
1693 "Different number of Driver Binding and Driver Diagnosis protocols!");
1697 for (int i
= 0; i
< compDiagList
.length
; i
++) {
1698 fileBuffer
.append("extern EFI_DRIVER_DIAGNOSTICS_PROTOCOL ");
1699 fileBuffer
.append(compDiagList
[i
]);
1700 fileBuffer
.append(";\r\n");
1705 // Write driver module protocol bitmask.
1708 .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gDriverModelProtocolBitmask = ");
1709 fileBuffer
.append(Integer
.toString(BitMask
));
1710 fileBuffer
.append(";\r\n");
1713 // Write driver module protocol list entry
1716 .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINTN _gDriverModelProtocolListEntries = ");
1718 fileBuffer
.append(Integer
.toString(drvBindList
.length
));
1719 fileBuffer
.append(";\r\n");
1722 // Write drive module protocol list to autogen.c
1725 .append("GLOBAL_REMOVE_IF_UNREFERENCED const EFI_DRIVER_MODEL_PROTOCOL_LIST _gDriverModelProtocolList[] = {");
1726 for (int i
= 0; i
< drvBindList
.length
; i
++) {
1728 fileBuffer
.append(",");
1730 fileBuffer
.append("\r\n {\r\n");
1731 fileBuffer
.append(" &");
1732 fileBuffer
.append(drvBindList
[i
]);
1733 fileBuffer
.append(", \r\n");
1735 if (compNamList
!= null) {
1736 fileBuffer
.append(" &");
1737 fileBuffer
.append(compNamList
[i
]);
1738 fileBuffer
.append(", \r\n");
1740 fileBuffer
.append(" NULL, \r\n");
1743 if (compConfList
!= null) {
1744 fileBuffer
.append(" &");
1745 fileBuffer
.append(compConfList
[i
]);
1746 fileBuffer
.append(", \r\n");
1748 fileBuffer
.append(" NULL, \r\n");
1751 if (compDiagList
!= null) {
1752 fileBuffer
.append(" &");
1753 fileBuffer
.append(compDiagList
[i
]);
1754 fileBuffer
.append(", \r\n");
1756 fileBuffer
.append(" NULL, \r\n");
1758 fileBuffer
.append(" }");
1760 fileBuffer
.append("\r\n};\r\n");
1764 * ExternCallBackToAutoGenC
1766 * This function adds <SetVirtualAddressMapCallBack> and
1767 * <ExitBootServicesCallBack> infomation to AutoGen.c
1770 * String buffer for AutoGen.c
1771 * @throws BuildException
1773 void ExternCallBackToAutoGenC(StringBuffer fileBuffer
)
1774 throws BuildException
{
1776 // Collect module's <SetVirtualAddressMapCallBack> and
1777 // <ExitBootServiceCallBack> and add to setVirtualAddList
1778 // exitBootServiceList.
1780 String
[] setVirtuals
= SurfaceAreaQuery
.getSetVirtualAddressMapCallBackArray();
1781 String
[] exitBoots
= SurfaceAreaQuery
.getExitBootServicesCallBackArray();
1782 if (setVirtuals
!= null) {
1783 for (int j
= 0; j
< setVirtuals
.length
; j
++) {
1784 this.setVirtalAddList
.add(setVirtuals
[j
]);
1787 if (exitBoots
!= null) {
1788 for (int k
= 0; k
< exitBoots
.length
; k
++) {
1789 this.exitBootServiceList
.add(exitBoots
[k
]);
1793 // Add c code in autogen.c which relate to <SetVirtualAddressMapCallBack>
1794 // and <ExitBootServicesCallBack>
1796 String moduleType
= this.moduleId
.getModuleType();
1797 boolean UefiOrDxeModule
= false;
1800 switch (CommonDefinition
.getModuleType(moduleType
)) {
1801 case CommonDefinition
.ModuleTypeDxeDriver
:
1802 case CommonDefinition
.ModuleTypeDxeRuntimeDriver
:
1803 case CommonDefinition
.ModuleTypeDxeSalDriver
:
1804 case CommonDefinition
.ModuleTypeUefiDriver
:
1805 case CommonDefinition
.ModuleTypeUefiApplication
:
1807 // Entry point lib for these module types needs to know the count
1810 UefiOrDxeModule
= true;
1812 .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED const UINTN _gDriverSetVirtualAddressMapEventCount = ");
1815 // If the list is not valid or has no entries set count to zero else
1816 // set count to the number of valid entries
1819 if (this.setVirtalAddList
!= null) {
1820 for (i
= 0; i
< this.setVirtalAddList
.size(); i
++) {
1821 if (this.setVirtalAddList
.get(i
).equalsIgnoreCase("")) {
1828 fileBuffer
.append(Integer
.toString(Count
));
1829 fileBuffer
.append(";\r\n\r\n");
1835 if (this.setVirtalAddList
== null || this.setVirtalAddList
.size() == 0) {
1836 if (UefiOrDxeModule
) {
1838 // No data so make a NULL list
1841 .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED const EFI_EVENT_NOTIFY _gDriverSetVirtualAddressMapEvent[] = {\r\n");
1842 fileBuffer
.append(" NULL\r\n");
1843 fileBuffer
.append("};\r\n\r\n");
1847 // Write SetVirtualAddressMap function definition.
1849 for (i
= 0; i
< this.setVirtalAddList
.size(); i
++) {
1850 if (this.setVirtalAddList
.get(i
).equalsIgnoreCase("")) {
1853 fileBuffer
.append("VOID\r\n");
1854 fileBuffer
.append("EFIAPI\r\n");
1855 fileBuffer
.append(this.setVirtalAddList
.get(i
));
1856 fileBuffer
.append(" (\r\n");
1857 fileBuffer
.append(" IN EFI_EVENT Event,\r\n");
1858 fileBuffer
.append(" IN VOID *Context\r\n");
1859 fileBuffer
.append(" );\r\n\r\n");
1863 // Write SetVirtualAddressMap entry point array.
1866 .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED const EFI_EVENT_NOTIFY _gDriverSetVirtualAddressMapEvent[] = {");
1867 for (i
= 0; i
< this.setVirtalAddList
.size(); i
++) {
1868 if (this.setVirtalAddList
.get(i
).equalsIgnoreCase("")) {
1873 fileBuffer
.append("\r\n ");
1875 fileBuffer
.append(",\r\n ");
1878 fileBuffer
.append(this.setVirtalAddList
.get(i
));
1881 // If module is not DXE_DRIVER, DXE_RUNTIME_DIRVER, UEFI_DRIVER
1882 // UEFI_APPLICATION and DXE_SAL_DRIVER add the NULL at the end of
1883 // _gDriverSetVirtualAddressMapEvent list.
1885 if (!UefiOrDxeModule
) {
1886 fileBuffer
.append(",\r\n NULL");
1888 fileBuffer
.append("\r\n};\r\n\r\n");
1891 if (UefiOrDxeModule
) {
1893 // Entry point lib for these module types needs to know the count.
1896 .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED const UINTN _gDriverExitBootServicesEventCount = ");
1899 // If the list is not valid or has no entries set count to zero else
1900 // set count to the number of valid entries.
1903 if (this.exitBootServiceList
!= null) {
1904 for (i
= 0; i
< this.exitBootServiceList
.size(); i
++) {
1905 if (this.exitBootServiceList
.get(i
).equalsIgnoreCase("")) {
1911 fileBuffer
.append(Integer
.toString(Count
));
1912 fileBuffer
.append(";\r\n\r\n");
1915 if (this.exitBootServiceList
== null || this.exitBootServiceList
.size() == 0) {
1916 if (UefiOrDxeModule
) {
1918 // No data so make a NULL list.
1921 .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED const EFI_EVENT_NOTIFY _gDriverExitBootServicesEvent[] = {\r\n");
1922 fileBuffer
.append(" NULL\r\n");
1923 fileBuffer
.append("};\r\n\r\n");
1927 // Write DriverExitBootServices function definition.
1929 for (i
= 0; i
< this.exitBootServiceList
.size(); i
++) {
1930 if (this.exitBootServiceList
.get(i
).equalsIgnoreCase("")) {
1934 fileBuffer
.append("VOID\r\n");
1935 fileBuffer
.append("EFIAPI\r\n");
1936 fileBuffer
.append(this.exitBootServiceList
.get(i
));
1937 fileBuffer
.append(" (\r\n");
1938 fileBuffer
.append(" IN EFI_EVENT Event,\r\n");
1939 fileBuffer
.append(" IN VOID *Context\r\n");
1940 fileBuffer
.append(" );\r\n\r\n");
1944 // Write DriverExitBootServices entry point array.
1947 .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED const EFI_EVENT_NOTIFY _gDriverExitBootServicesEvent[] = {");
1948 for (i
= 0; i
< this.exitBootServiceList
.size(); i
++) {
1949 if (this.exitBootServiceList
.get(i
).equalsIgnoreCase("")) {
1954 fileBuffer
.append("\r\n ");
1956 fileBuffer
.append(",\r\n ");
1958 fileBuffer
.append(this.exitBootServiceList
.get(i
));
1960 if (!UefiOrDxeModule
) {
1961 fileBuffer
.append(",\r\n NULL");
1963 fileBuffer
.append("\r\n};\r\n\r\n");
1968 private void copyFlashMapHToDebugDir() throws AutoGenException
{
1970 File inFile
= new File(fvDir
+ File
.separatorChar
+ CommonDefinition
.flashMapH
);
1971 int size
= (int)inFile
.length();
1972 byte[] buffer
= new byte[size
];
1973 File outFile
= new File (this.outputPath
+ File
.separatorChar
+ CommonDefinition
.tianoR8FlashMapH
);
1975 // If TianoR8FlashMap.h existed and the flashMap.h don't change,
1978 if ((!outFile
.exists()) ||(inFile
.lastModified() - outFile
.lastModified()) >= 0) {
1980 if (inFile
.exists()) {
1981 FileInputStream fis
= new FileInputStream (inFile
);
1983 FileOutputStream fos
= new FileOutputStream(outFile
);
1988 throw new AutoGenException("The flashMap.h file don't exist!!");
1990 } catch (Exception e
){
1991 throw new AutoGenException(e
.getMessage());
1997 *This function first order the library instances, then collect
1998 *library instance 's PPI, Protocol, GUID,
1999 *SetVirtalAddressMapCallBack, ExitBootServiceCallBack, and
2000 *Destructor, Constructor.
2003 private void collectLibInstanceInfo(){
2006 String moduleType
= SurfaceAreaQuery
.getModuleType();
2007 String libConstructName
= null;
2008 String libDestructName
= null;
2009 String
[] setVirtuals
= null;
2010 String
[] exitBoots
= null;
2012 ModuleIdentification
[] libraryIdList
= SurfaceAreaQuery
2013 .getLibraryInstance(this.arch
);
2015 if (libraryIdList
!= null) {
2017 // Reorder library instance sequence.
2019 AutogenLibOrder libOrder
= new AutogenLibOrder(libraryIdList
,
2021 List
<ModuleIdentification
> orderList
= libOrder
2022 .orderLibInstance();
2024 if (orderList
!= null) {
2026 // Process library instance one by one.
2028 for (int i
= 0; i
< orderList
.size(); i
++) {
2031 // Get library instance basename.
2033 ModuleIdentification libInstanceId
= orderList
.get(i
);
2039 Map
<String
, XmlObject
> libDoc
= GlobalData
.getDoc(
2040 libInstanceId
, this.arch
);
2041 SurfaceAreaQuery
.push(libDoc
);
2043 // Get <PPis>, <Protocols>, <Guids> list of this library
2046 String
[] ppiList
= SurfaceAreaQuery
.getPpiArray(this.arch
);
2047 String
[] ppiNotifyList
= SurfaceAreaQuery
2048 .getPpiNotifyArray(this.arch
);
2049 String
[] protocolList
= SurfaceAreaQuery
2050 .getProtocolArray(this.arch
);
2051 String
[] protocolNotifyList
= SurfaceAreaQuery
2052 .getProtocolNotifyArray(this.arch
);
2053 String
[] guidList
= SurfaceAreaQuery
2054 .getGuidEntryArray(this.arch
);
2055 PackageIdentification
[] pkgList
= SurfaceAreaQuery
.getDependencePkg(this.arch
);
2058 // Add those ppi, protocol, guid in global ppi,
2062 for (index
= 0; index
< ppiList
.length
; index
++) {
2063 this.mPpiList
.add(ppiList
[index
]);
2066 for (index
= 0; index
< ppiNotifyList
.length
; index
++) {
2067 this.mPpiList
.add(ppiNotifyList
[index
]);
2070 for (index
= 0; index
< protocolList
.length
; index
++) {
2071 this.mProtocolList
.add(protocolList
[index
]);
2074 for (index
= 0; index
< protocolNotifyList
.length
; index
++) {
2075 this.mProtocolList
.add(protocolNotifyList
[index
]);
2078 for (index
= 0; index
< guidList
.length
; index
++) {
2079 this.mGuidList
.add(guidList
[index
]);
2081 for (index
= 0; index
< pkgList
.length
; index
++){
2082 if (!this.mDepPkgList
.contains(pkgList
[index
])){
2083 this.mDepPkgList
.add(pkgList
[index
]);
2088 // If not yet parse this library instance's constructor
2089 // element,parse it.
2091 libConstructName
= SurfaceAreaQuery
2092 .getLibConstructorName();
2093 libDestructName
= SurfaceAreaQuery
2094 .getLibDestructorName();
2097 // Collect SetVirtualAddressMapCallBack and
2098 // ExitBootServiceCallBack.
2100 setVirtuals
= SurfaceAreaQuery
.getSetVirtualAddressMapCallBackArray();
2101 exitBoots
= SurfaceAreaQuery
.getExitBootServicesCallBackArray();
2102 if (setVirtuals
!= null) {
2103 for (int j
= 0; j
< setVirtuals
.length
; j
++) {
2104 this.setVirtalAddList
.add(setVirtuals
[j
]);
2107 if (exitBoots
!= null) {
2108 for (int k
= 0; k
< exitBoots
.length
; k
++) {
2109 this.exitBootServiceList
.add(exitBoots
[k
]);
2112 SurfaceAreaQuery
.pop();
2114 // Add dependent library instance constructor function.
2116 if (libConstructName
!= null) {
2117 this.libConstructList
.add(libConstructName
);
2120 // Add dependent library instance destructor fuction.
2122 if (libDestructName
!= null) {
2123 this.libDestructList
.add(libDestructName
);
2130 }catch (Exception e
){
2131 System
.out
.println(e
.getMessage());
2132 System
.out
.println("Collect library instance failed!");