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
>();
104 * This function mainly initialize some member variable.
107 * Output path of AutoGen file.
111 * Target architecture.
113 public AutoGen(String fvDir
, String outputPath
, ModuleIdentification moduleId
, String arch
) {
114 this.outputPath
= outputPath
;
115 this.moduleId
= moduleId
;
124 * This function save the content in stringBuffer to file.
129 * The content of AutoGen file in buffer.
130 * @return "true" successful, "false" failed.
132 private boolean saveFile(String fileName
, StringBuffer fileBuffer
) {
134 File autoGenH
= new File(fileName
);
137 // if the file exists, compare their content
139 if (autoGenH
.exists()) {
140 FileReader fIn
= new FileReader(autoGenH
);
141 char[] oldFileBuffer
= new char[(int) autoGenH
.length()];
142 fIn
.read(oldFileBuffer
, 0, (int) autoGenH
.length());
146 // if we got the same file, don't re-generate it to prevent
147 // sources depending on it from re-building
149 if (fileBuffer
.toString().compareTo(new String(oldFileBuffer
)) == 0) {
153 FileWriter fOut
= new FileWriter(autoGenH
);
154 fOut
.write(fileBuffer
.toString());
156 } catch (Exception e
) {
163 * genAutogen function
165 * This function call libGenAutoGen or moduleGenAutogen function, which
166 * dependence on generate library autogen or module autogen.
168 * @throws BuildException
169 * Failed to creat AutoGen.c & AutoGen.h.
171 public void genAutogen() throws BuildException
{
174 // If outputPath do not exist, create it.
176 File path
= new File(outputPath
);
180 // Check current is library or not, then call the corresponding
183 if (this.moduleId
.isLibrary()) {
189 } catch (Exception e
) {
190 throw new BuildException(
191 "Failed to create AutoGen.c & AutoGen.h!\n"
197 * moduleGenAutogen function
199 * This function generates AutoGen.c & AutoGen.h for module.
201 * @throws BuildException
202 * Faile to create module AutoGen.c & AutoGen.h.
204 void moduleGenAutogen() throws BuildException
{
209 } catch (Exception e
) {
210 throw new BuildException(
211 "Faile to create module AutoGen.c & AutoGen.h!\n"
217 * libGenAutogen function
219 * This function generates AutoGen.c & AutoGen.h for library.
221 * @throws BuildException
222 * Faile to create library AutoGen.c & AutoGen.h
224 void libGenAutogen() throws BuildException
{
228 } catch (Exception e
) {
229 throw new BuildException(
230 "Faile to create library AutoGen.c & AutoGen.h!\n"
238 * This function generates AutoGen.h for module.
240 * @throws BuildException
241 * Failed to generate AutoGen.h.
243 void moduleGenAutogenH() throws AutoGenException
{
245 Set
<String
> libClassIncludeH
;
247 // List<String> headerFileList;
248 List
<String
> headerFileList
;
250 StringBuffer fileBuffer
= new StringBuffer(8192);
253 // Write Autogen.h header notation
255 fileBuffer
.append(CommonDefinition
.autogenHNotation
);
258 // Add #ifndef ${BaseName}_AUTOGENH
259 // #def ${BseeName}_AUTOGENH
261 fileBuffer
.append("#ifndef " + "_AUTOGENH_" + this.moduleId
.getGuid().replaceAll("-", "_") +"\r\n");
262 fileBuffer
.append("#define " + "_AUTOGENH_" + this.moduleId
.getGuid().replaceAll("-", "_") +"\r\n\r\n");
265 // Write the specification version and release version at the begine
266 // of autogen.h file.
267 // Note: the specification version and release version should
268 // be got from module surface area instead of hard code by it's
271 moduleType
= SurfaceAreaQuery
.getModuleType();
274 // Add "extern int __make_me_compile_correctly;" at begin of
277 fileBuffer
.append(CommonDefinition
.autoGenHbegin
);
280 // Put EFI_SPECIFICATION_VERSION, and EDK_RELEASE_VERSION.
282 String
[] specList
= SurfaceAreaQuery
.getExternSpecificaiton();
283 for (int i
= 0; i
< specList
.length
; i
++) {
284 fileBuffer
.append(CommonDefinition
.marcDefineStr
+ specList
[i
]
288 // Write consumed package's mdouleInfo related .h file to autogen.h
290 // PackageIdentification[] consumedPkgIdList = SurfaceAreaQuery
291 // .getDependencePkg(this.arch);
292 PackageIdentification
[] consumedPkgIdList
= SurfaceAreaQuery
293 .getDependencePkg(this.arch
);
294 if (consumedPkgIdList
!= null) {
295 headerFileList
= depPkgToAutogenH(consumedPkgIdList
, moduleType
);
296 item
= headerFileList
.iterator();
297 while (item
.hasNext()) {
298 fileBuffer
.append(item
.next().toString());
303 // Write library class's related *.h file to autogen.h.
305 String
[] libClassList
= SurfaceAreaQuery
306 .getLibraryClasses(CommonDefinition
.AlwaysConsumed
,this.arch
);
307 if (libClassList
!= null) {
308 libClassIncludeH
= LibraryClassToAutogenH(libClassList
);
309 item
= libClassIncludeH
.iterator();
310 while (item
.hasNext()) {
311 fileBuffer
.append(item
.next().toString());
315 libClassList
= SurfaceAreaQuery
316 .getLibraryClasses(CommonDefinition
.AlwaysProduced
, this.arch
);
317 if (libClassList
!= null) {
318 libClassIncludeH
= LibraryClassToAutogenH(libClassList
);
319 item
= libClassIncludeH
.iterator();
320 while (item
.hasNext()) {
321 fileBuffer
.append(item
.next().toString());
324 fileBuffer
.append("\r\n");
327 // If is TianoR8FlashMap, copy {Fv_DIR}/FlashMap.h to
328 // {DEST_DIR_DRBUG}/FlashMap.h
330 if (SurfaceAreaQuery
.isHaveTianoR8FlashMap()) {
331 fileBuffer
.append(CommonDefinition
.include
);
332 fileBuffer
.append(" <");
333 fileBuffer
.append(CommonDefinition
.tianoR8FlashMapH
+ ">\r\n");
334 copyFlashMapHToDebugDir();
337 // Write PCD autogen information to AutoGen.h.
339 if (this.myPcdAutogen
!= null) {
340 fileBuffer
.append("\r\n");
341 fileBuffer
.append(this.myPcdAutogen
.OutputH());
345 // Append the #endif at AutoGen.h
347 fileBuffer
.append("#endif\r\n");
350 // Save string buffer content in AutoGen.h.
352 if (!saveFile(outputPath
+ File
.separatorChar
+ "AutoGen.h", fileBuffer
)) {
353 throw new BuildException("Failed to generate AutoGen.h !!!");
360 * This function generates AutoGen.c for module.
362 * @throws BuildException
363 * Failed to generate AutoGen.c.
365 void moduleGenAutogenC() throws AutoGenException
{
367 StringBuffer fileBuffer
= new StringBuffer(8192);
369 // Write Autogen.c header notation
371 fileBuffer
.append(CommonDefinition
.autogenCNotation
);
374 // Write #include <AutoGen.h> at beginning of AutoGen.c
376 fileBuffer
.append(CommonDefinition
.includeAutogenH
);
379 // Get the native MSA file infomation. Since before call autogen,
380 // the MSA native <Externs> information were overrided. So before
381 // process <Externs> it should be set the DOC as the Native MSA info.
383 Map
<String
, XmlObject
> doc
= GlobalData
.getNativeMsa(this.moduleId
);
384 SurfaceAreaQuery
.push(doc
);
387 // DriverBinding/ComponentName/DriverConfiguration/DriverDialog
391 ExternsDriverBindingToAutoGenC(fileBuffer
);
394 // Write DriverExitBootServicesEvent/DriverSetVirtualAddressMapEvent
397 ExternCallBackToAutoGenC(fileBuffer
);
400 // Write EntryPoint to autgoGen.c
402 String
[] entryPointList
= SurfaceAreaQuery
.getModuleEntryPointArray();
403 EntryPointToAutoGen(CommonDefinition
.remDupString(entryPointList
), fileBuffer
);
407 // Restore the DOC which include the FPD module info.
409 SurfaceAreaQuery
.pop();
412 // Write Guid to autogen.c
414 String guid
= CommonDefinition
.formatGuidName(SurfaceAreaQuery
418 .append("GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiCallerIdGuid = {");
420 throw new AutoGenException("Guid value must set!\n");
424 // Formate Guid as ANSI c form.Example:
425 // {0xd2b2b828, 0x826, 0x48a7,{0xb3, 0xdf, 0x98, 0x3c, 0x0, 0x60, 0x24,
429 fileBuffer
.append(guid
);
430 fileBuffer
.append("};\r\n");
433 // Generate library instance consumed protocol, guid, ppi, pcd list.
434 // Save those to this.protocolList, this.ppiList, this.pcdList,
435 // this.guidList. Write Consumed library constructor and desconstuct to
438 LibInstanceToAutogenC(fileBuffer
);
441 // Get module dependent Package identification.
443 PackageIdentification
[] packages
= SurfaceAreaQuery
.getDependencePkg(this.arch
);
444 for (int i
= 0; i
< packages
.length
; i
++){
445 if (!this.mDepPkgList
.contains(packages
[i
])){
446 this.mDepPkgList
.add(packages
[i
]);
452 // Write consumed ppi, guid, protocol to autogen.c
454 ProtocolGuidToAutogenC(fileBuffer
);
455 PpiGuidToAutogenC(fileBuffer
);
456 GuidGuidToAutogenC(fileBuffer
);
461 this.myPcdAutogen
= new PCDAutoGenAction(moduleId
, this.arch
, false, null);
463 this.myPcdAutogen
.execute();
464 } catch (Exception exp
) {
465 throw new PcdAutogenException (exp
.getMessage());
468 if (this.myPcdAutogen
!= null) {
469 fileBuffer
.append("\r\n");
470 fileBuffer
.append(this.myPcdAutogen
.OutputC());
473 if (!saveFile(outputPath
+ File
.separatorChar
+ "AutoGen.c", fileBuffer
)) {
474 throw new BuildException("Failed to generate AutoGen.c !!!");
482 * This function generates AutoGen.h for library.
484 * @throws BuildException
485 * Failed to generate AutoGen.c.
487 void libGenAutogenH() throws AutoGenException
{
489 Set
<String
> libClassIncludeH
;
491 List
<String
> headerFileList
;
493 StringBuffer fileBuffer
= new StringBuffer(10240);
496 // Write Autogen.h header notation
498 fileBuffer
.append(CommonDefinition
.autogenHNotation
);
501 // Add #ifndef ${BaseName}_AUTOGENH
502 // #def ${BseeName}_AUTOGENH
504 fileBuffer
.append("#ifndef " + "_AUTOGENH_" + this.moduleId
.getGuid().replaceAll("-", "_") + "\r\n");
505 fileBuffer
.append("#define " + "_AUTOGENH_" + this.moduleId
.getGuid().replaceAll("-", "_") + "\r\n\r\n");
508 // Write EFI_SPECIFICATION_VERSION and EDK_RELEASE_VERSION
509 // to autogen.h file.
510 // Note: the specification version and release version should
511 // be get from module surface area instead of hard code.
513 fileBuffer
.append(CommonDefinition
.autoGenHbegin
);
514 String
[] specList
= SurfaceAreaQuery
.getExternSpecificaiton();
515 for (int i
= 0; i
< specList
.length
; i
++) {
516 fileBuffer
.append(CommonDefinition
.marcDefineStr
+ specList
[i
]
519 // fileBuffer.append(CommonDefinition.autoGenHLine1);
520 // fileBuffer.append(CommonDefinition.autoGenHLine2);
523 // Write consumed package's mdouleInfo related *.h file to autogen.h.
525 moduleType
= SurfaceAreaQuery
.getModuleType();
526 PackageIdentification
[] cosumedPkglist
= SurfaceAreaQuery
527 .getDependencePkg(this.arch
);
528 headerFileList
= depPkgToAutogenH(cosumedPkglist
, moduleType
);
529 item
= headerFileList
.iterator();
530 while (item
.hasNext()) {
531 fileBuffer
.append(item
.next().toString());
534 // Write library class's related *.h file to autogen.h
536 String
[] libClassList
= SurfaceAreaQuery
537 .getLibraryClasses(CommonDefinition
.AlwaysConsumed
, this.arch
);
538 if (libClassList
!= null) {
539 libClassIncludeH
= LibraryClassToAutogenH(libClassList
);
540 item
= libClassIncludeH
.iterator();
541 while (item
.hasNext()) {
542 fileBuffer
.append(item
.next().toString());
546 libClassList
= SurfaceAreaQuery
547 .getLibraryClasses(CommonDefinition
.AlwaysProduced
, this.arch
);
548 if (libClassList
!= null) {
549 libClassIncludeH
= LibraryClassToAutogenH(libClassList
);
550 item
= libClassIncludeH
.iterator();
551 while (item
.hasNext()) {
552 fileBuffer
.append(item
.next().toString());
555 fileBuffer
.append("\r\n");
558 // If is TianoR8FlashMap, copy {Fv_DIR}/FlashMap.h to
559 // {DEST_DIR_DRBUG}/FlashMap.h
561 if (SurfaceAreaQuery
.isHaveTianoR8FlashMap()) {
562 fileBuffer
.append(CommonDefinition
.include
);
563 fileBuffer
.append(" <");
564 fileBuffer
.append(CommonDefinition
.tianoR8FlashMapH
+ ">\r\n");
565 copyFlashMapHToDebugDir();
569 // Write PCD information to library AutoGen.h.
571 if (this.myPcdAutogen
!= null) {
572 fileBuffer
.append("\r\n");
573 fileBuffer
.append(this.myPcdAutogen
.OutputH());
577 // Append the #endif at AutoGen.h
579 fileBuffer
.append("#endif\r\n");
582 // Save content of string buffer to AutoGen.h file.
584 if (!saveFile(outputPath
+ File
.separatorChar
+ "AutoGen.h", fileBuffer
)) {
585 throw new BuildException("Failed to generate AutoGen.h !!!");
592 * This function generates AutoGen.h for library.
594 * @throws BuildException
595 * Failed to generate AutoGen.c.
597 void libGenAutogenC() throws BuildException
, PcdAutogenException
{
598 StringBuffer fileBuffer
= new StringBuffer(10240);
601 // Write Autogen.c header notation
603 fileBuffer
.append(CommonDefinition
.autogenCNotation
);
605 fileBuffer
.append(CommonDefinition
.autoGenCLine1
);
606 fileBuffer
.append("\r\n");
611 this.myPcdAutogen
= new PCDAutoGenAction(this.moduleId
,
614 SurfaceAreaQuery
.getModulePcdEntryNameArray());
616 this.myPcdAutogen
.execute();
617 } catch (Exception e
) {
618 throw new PcdAutogenException(e
.getMessage());
621 if (this.myPcdAutogen
!= null) {
622 fileBuffer
.append("\r\n");
623 fileBuffer
.append(this.myPcdAutogen
.OutputC());
626 if (!saveFile(outputPath
+ File
.separatorChar
+ "AutoGen.c", fileBuffer
)) {
627 throw new BuildException("Failed to generate AutoGen.c !!!");
632 * LibraryClassToAutogenH
634 * This function returns *.h files declared by library classes which are
635 * consumed or produced by current build module or library.
637 * @param libClassList
638 * List of library class which consumed or produce by current
639 * build module or library.
640 * @return includeStrList List of *.h file.
642 Set
<String
> LibraryClassToAutogenH(String
[] libClassList
)
643 throws AutoGenException
{
644 Set
<String
> includStrList
= new LinkedHashSet
<String
>();
645 String includerName
[];
649 // Get include file from GlobalData's SPDTable according to
650 // library class name.
653 for (int i
= 0; i
< libClassList
.length
; i
++) {
654 includerName
= GlobalData
.getLibraryClassHeaderFiles(
655 SurfaceAreaQuery
.getDependencePkg(this.arch
),
657 if (includerName
== null) {
658 throw new AutoGenException("Can not find library class ["
659 + libClassList
[i
] + "] declaration in every packages. ");
661 for (int j
= 0; j
< includerName
.length
; j
++) {
662 String includeNameStr
= includerName
[j
];
663 if (includeNameStr
!= null) {
664 str
= CommonDefinition
.include
+ " " + "<";
665 str
= str
+ includeNameStr
+ ">\r\n";
666 includStrList
.add(str
);
667 includeNameStr
= null;
671 return includStrList
;
677 * This function add include file in AutoGen.h file.
679 * @param packageNameList
680 * List of module depended package.
685 List
<String
> depPkgToAutogenH(PackageIdentification
[] packageNameList
,
686 String moduleType
) throws AutoGenException
{
688 List
<String
> includeStrList
= new LinkedList
<String
>();
690 String includeStr
= "";
693 // Get include file from moduleInfo file
695 for (int i
= 0; i
< packageNameList
.length
; i
++) {
696 pkgHeader
= GlobalData
.getPackageHeaderFiles(packageNameList
[i
],
698 if (pkgHeader
== null) {
699 throw new AutoGenException("Can not find package ["
701 + "] declaration in every packages. ");
702 } else if (!pkgHeader
.equalsIgnoreCase("")) {
703 includeStr
= CommonDefinition
.include
+ " <" + pkgHeader
705 includeStrList
.add(includeStr
);
709 return includeStrList
;
713 * EntryPointToAutoGen
715 * This function convert <ModuleEntryPoint> & <ModuleUnloadImage>
716 * information in mas to AutoGen.c
718 * @param entryPointList
719 * List of entry point.
721 * String buffer fo AutoGen.c.
724 void EntryPointToAutoGen(String
[] entryPointList
, StringBuffer fileBuffer
)
725 throws BuildException
{
727 String typeStr
= SurfaceAreaQuery
.getModuleType();
730 // The parameters and return value of entryPoint is difference
731 // for difference module type.
733 switch (CommonDefinition
.getModuleType(typeStr
)) {
735 case CommonDefinition
.ModuleTypePeiCore
:
736 if (entryPointList
== null ||entryPointList
.length
!= 1 ) {
737 throw new BuildException(
738 "Module type = 'PEI_CORE', only have one module entry point!");
740 fileBuffer
.append("EFI_STATUS\r\n");
741 fileBuffer
.append("EFIAPI\r\n");
742 fileBuffer
.append(entryPointList
[0]);
743 fileBuffer
.append(" (\r\n");
745 .append(" IN EFI_PEI_STARTUP_DESCRIPTOR *PeiStartupDescriptor,\r\n");
747 .append(" IN VOID *OldCoreData\r\n");
748 fileBuffer
.append(" );\r\n\r\n");
750 fileBuffer
.append("EFI_STATUS\r\n");
751 fileBuffer
.append("EFIAPI\r\n");
752 fileBuffer
.append("ProcessModuleEntryPointList (\r\n");
754 .append(" IN EFI_PEI_STARTUP_DESCRIPTOR *PeiStartupDescriptor,\r\n");
756 .append(" IN VOID *OldCoreData\r\n");
757 fileBuffer
.append(" )\r\n\r\n");
758 fileBuffer
.append("{\r\n");
759 fileBuffer
.append(" return ");
760 fileBuffer
.append(entryPointList
[0]);
761 fileBuffer
.append(" (PeiStartupDescriptor, OldCoreData);\r\n");
762 fileBuffer
.append("}\r\n\r\n");
766 case CommonDefinition
.ModuleTypeDxeCore
:
767 fileBuffer
.append("const UINT32 _gUefiDriverRevision = 0;\r\n");
768 if (entryPointList
== null || entryPointList
.length
!= 1) {
769 throw new BuildException(
770 "Module type = 'DXE_CORE', only have one module entry point!");
773 fileBuffer
.append("VOID\r\n");
774 fileBuffer
.append("EFIAPI\r\n");
775 fileBuffer
.append(entryPointList
[0]);
776 fileBuffer
.append(" (\n");
777 fileBuffer
.append(" IN VOID *HobStart\r\n");
778 fileBuffer
.append(" );\r\n\r\n");
780 fileBuffer
.append("VOID\r\n");
781 fileBuffer
.append("EFIAPI\r\n");
782 fileBuffer
.append("ProcessModuleEntryPointList (\r\n");
783 fileBuffer
.append(" IN VOID *HobStart\r\n");
784 fileBuffer
.append(" )\r\n\r\n");
785 fileBuffer
.append("{\r\n");
786 fileBuffer
.append(" ");
787 fileBuffer
.append(entryPointList
[0]);
788 fileBuffer
.append(" (HobStart);\r\n");
789 fileBuffer
.append("}\r\n\r\n");
793 case CommonDefinition
.ModuleTypePeim
:
794 int entryPointCount
= 0;
796 .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT32 _gPeimRevision = 0;\r\n");
797 if (entryPointList
== null || entryPointList
.length
== 0) {
798 fileBuffer
.append("EFI_STATUS\r\n");
799 fileBuffer
.append("EFIAPI\r\n");
800 fileBuffer
.append("ProcessModuleEntryPointList (\r\n");
801 fileBuffer
.append(" IN EFI_FFS_FILE_HEADER *FfsHeader,\r\n");
802 fileBuffer
.append(" IN EFI_PEI_SERVICES **PeiServices\r\n");
803 fileBuffer
.append(" )\r\n\r\n");
804 fileBuffer
.append("{\r\n");
805 fileBuffer
.append(" return EFI_SUCCESS;\r\n");
806 fileBuffer
.append("}\r\n\r\n");
809 for (int i
= 0; i
< entryPointList
.length
; i
++) {
810 fileBuffer
.append("EFI_STATUS\r\n");
811 fileBuffer
.append("EFIAPI\r\n");
812 fileBuffer
.append(entryPointList
[i
]);
813 fileBuffer
.append(" (\r\n");
815 .append(" IN EFI_FFS_FILE_HEADER *FfsHeader,\r\n");
817 .append(" IN EFI_PEI_SERVICES **PeiServices\r\n");
818 fileBuffer
.append(" );\r\n");
823 fileBuffer
.append("EFI_STATUS\r\n");
824 fileBuffer
.append("EFIAPI\r\n");
825 fileBuffer
.append("ProcessModuleEntryPointList (\r\n");
826 fileBuffer
.append(" IN EFI_FFS_FILE_HEADER *FfsHeader,\r\n");
827 fileBuffer
.append(" IN EFI_PEI_SERVICES **PeiServices\r\n");
828 fileBuffer
.append(" )\r\n\r\n");
829 fileBuffer
.append("{\r\n");
830 if (entryPointCount
== 1) {
831 fileBuffer
.append(" return ");
832 fileBuffer
.append(entryPointList
[0]);
833 fileBuffer
.append(" (FfsHeader, PeiServices);\r\n");
835 fileBuffer
.append(" EFI_STATUS Status;\r\n");
836 fileBuffer
.append(" EFI_STATUS CombinedStatus;\r\n\r\n");
837 fileBuffer
.append(" CombinedStatus = EFI_LOAD_ERROR;\r\n\r\n");
838 for (int i
= 0; i
< entryPointList
.length
; i
++) {
839 if (!entryPointList
[i
].equals("")) {
840 fileBuffer
.append(" Status = ");
841 fileBuffer
.append(entryPointList
[i
]);
842 fileBuffer
.append(" (FfsHeader, PeiServices);\r\n");
844 .append(" if (!EFI_ERROR (Status) || EFI_ERROR (CombinedStatus)) {\r\n");
845 fileBuffer
.append(" CombinedStatus = Status;\r\n");
846 fileBuffer
.append(" }\r\n\r\n");
851 fileBuffer
.append(" return CombinedStatus;\r\n");
853 fileBuffer
.append("}\r\n\r\n");
856 case CommonDefinition
.ModuleTypeDxeSmmDriver
:
859 // If entryPoint is null, create an empty ProcessModuleEntryPointList
862 if (entryPointList
== null || entryPointList
.length
== 0){
864 .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gDriverEntryPointCount = ");
865 fileBuffer
.append(Integer
.toString(entryPointCount
));
866 fileBuffer
.append(";\r\n");
867 fileBuffer
.append("EFI_STATUS\r\n");
868 fileBuffer
.append("EFIAPI\r\n");
869 fileBuffer
.append("ProcessModuleEntryPointList (\r\n");
870 fileBuffer
.append(" IN EFI_HANDLE ImageHandle,\r\n");
871 fileBuffer
.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");
872 fileBuffer
.append(" )\r\n\r\n");
873 fileBuffer
.append("{\r\n");
874 fileBuffer
.append(" return EFI_SUCCESS;\r\n");
875 fileBuffer
.append("}\r\n\r\n");
878 for (int i
= 0; i
< entryPointList
.length
; i
++) {
879 fileBuffer
.append("EFI_STATUS\r\n");
880 fileBuffer
.append("EFIAPI\r\n");
881 fileBuffer
.append(entryPointList
[i
]);
882 fileBuffer
.append(" (\r\n");
883 fileBuffer
.append(" IN EFI_HANDLE ImageHandle,\r\n");
884 fileBuffer
.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");
885 fileBuffer
.append(" );\r\n");
889 .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gDriverEntryPointCount = ");
890 fileBuffer
.append(Integer
.toString(entryPointCount
));
891 fileBuffer
.append(";\r\n");
893 .append("static BASE_LIBRARY_JUMP_BUFFER mJumpContext;\r\n");
895 .append("static EFI_STATUS mDriverEntryPointStatus = EFI_LOAD_ERROR;\r\n\r\n");
897 fileBuffer
.append("EFI_STATUS\r\n");
898 fileBuffer
.append("EFIAPI\r\n");
899 fileBuffer
.append("ProcessModuleEntryPointList (\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\r\n");
903 fileBuffer
.append("{\r\n");
906 for (int i
= 0; i
< entryPointList
.length
; i
++) {
908 .append(" if (SetJump (&mJumpContext) == 0) {\r\n");
909 fileBuffer
.append(" ExitDriver (");
910 fileBuffer
.append(entryPointList
[i
]);
911 fileBuffer
.append(" (ImageHandle, SystemTable));\r\n");
912 fileBuffer
.append(" ASSERT (FALSE);\r\n");
913 fileBuffer
.append(" }\r\n");
916 fileBuffer
.append(" return mDriverEntryPointStatus;\r\n");
917 fileBuffer
.append("}\r\n\r\n");
919 fileBuffer
.append("VOID\r\n");
920 fileBuffer
.append("EFIAPI\r\n");
921 fileBuffer
.append("ExitDriver (\r\n");
922 fileBuffer
.append(" IN EFI_STATUS Status\n");
923 fileBuffer
.append(" )\r\n\r\n");
924 fileBuffer
.append("{\r\n");
926 .append(" if (!EFI_ERROR (Status) || EFI_ERROR (mDriverEntryPointStatus)) {\r\n");
927 fileBuffer
.append(" mDriverEntryPointStatus = Status;\r\n");
928 fileBuffer
.append(" }\r\n");
929 fileBuffer
.append(" LongJump (&mJumpContext, (UINTN)-1);\r\n");
930 fileBuffer
.append(" ASSERT (FALSE);\r\n");
931 fileBuffer
.append("}\r\n\r\n");
937 // Add "ModuleUnloadImage" for DxeSmmDriver module type;
939 entryPointList
= SurfaceAreaQuery
.getModuleUnloadImageArray();
940 entryPointList
= CommonDefinition
.remDupString(entryPointList
);
943 if (entryPointList
!= null) {
944 for (int i
= 0; i
< entryPointList
.length
; i
++) {
945 fileBuffer
.append("EFI_STATUS\r\n");
946 fileBuffer
.append("EFIAPI\r\n");
947 fileBuffer
.append(entryPointList
[i
]);
948 fileBuffer
.append(" (\r\n");
950 .append(" IN EFI_HANDLE ImageHandle\r\n");
951 fileBuffer
.append(" );\r\n");
957 .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gDriverUnloadImageCount = ");
958 fileBuffer
.append(Integer
.toString(entryPointCount
));
959 fileBuffer
.append(";\r\n\r\n");
961 fileBuffer
.append("EFI_STATUS\r\n");
962 fileBuffer
.append("EFIAPI\r\n");
963 fileBuffer
.append("ProcessModuleUnloadList (\r\n");
964 fileBuffer
.append(" IN EFI_HANDLE ImageHandle\r\n");
965 fileBuffer
.append(" )\r\n");
966 fileBuffer
.append("{\r\n");
968 if (entryPointCount
== 0) {
969 fileBuffer
.append(" return EFI_SUCCESS;\r\n");
970 } else if (entryPointCount
== 1) {
971 fileBuffer
.append(" return ");
972 fileBuffer
.append(entryPointList
[0]);
973 fileBuffer
.append("(ImageHandle);\r\n");
975 fileBuffer
.append(" EFI_STATUS Status;\r\n\r\n");
976 fileBuffer
.append(" Status = EFI_SUCCESS;\r\n\r\n");
977 for (int i
= 0; i
< entryPointList
.length
; i
++) {
979 fileBuffer
.append(" Status = ");
980 fileBuffer
.append(entryPointList
[i
]);
981 fileBuffer
.append("(ImageHandle);\r\n");
983 fileBuffer
.append(" if (EFI_ERROR (Status)) {\r\n");
984 fileBuffer
.append(" ");
985 fileBuffer
.append(entryPointList
[i
]);
986 fileBuffer
.append("(ImageHandle);\r\n");
987 fileBuffer
.append(" } else {\r\n");
988 fileBuffer
.append(" Status = ");
989 fileBuffer
.append(entryPointList
[i
]);
990 fileBuffer
.append("(ImageHandle);\r\n");
991 fileBuffer
.append(" }\r\n");
994 fileBuffer
.append(" return Status;\r\n");
996 fileBuffer
.append("}\r\n\r\n");
999 case CommonDefinition
.ModuleTypeDxeRuntimeDriver
:
1000 case CommonDefinition
.ModuleTypeDxeDriver
:
1001 case CommonDefinition
.ModuleTypeDxeSalDriver
:
1002 case CommonDefinition
.ModuleTypeUefiDriver
:
1003 case CommonDefinition
.ModuleTypeUefiApplication
:
1004 entryPointCount
= 0;
1005 fileBuffer
.append("const UINT32 _gUefiDriverRevision = 0;\r\n");
1007 // If entry point is null, create a empty ProcessModuleEntryPointList function.
1009 if (entryPointList
== null || entryPointList
.length
== 0){
1011 .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gDriverEntryPointCount = 0;\r\n");
1012 fileBuffer
.append("EFI_STATUS\r\n");
1013 fileBuffer
.append("EFIAPI\r\n");
1014 fileBuffer
.append("ProcessModuleEntryPointList (\r\n");
1015 fileBuffer
.append(" IN EFI_HANDLE ImageHandle,\r\n");
1016 fileBuffer
.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");
1017 fileBuffer
.append(" )\r\n\r\n");
1018 fileBuffer
.append("{\r\n");
1019 fileBuffer
.append(" return EFI_SUCCESS;\r\n");
1020 fileBuffer
.append("}\r\n");
1023 for (int i
= 0; i
< entryPointList
.length
; i
++) {
1025 fileBuffer
.append("EFI_STATUS\r\n");
1026 fileBuffer
.append("EFIAPI\r\n");
1027 fileBuffer
.append(entryPointList
[i
]);
1028 fileBuffer
.append(" (\r\n");
1029 fileBuffer
.append(" IN EFI_HANDLE ImageHandle,\r\n");
1030 fileBuffer
.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");
1031 fileBuffer
.append(" );\r\n");
1036 .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gDriverEntryPointCount = ");
1037 fileBuffer
.append(Integer
.toString(entryPointCount
));
1038 fileBuffer
.append(";\r\n");
1039 if (entryPointCount
> 1) {
1041 .append("static BASE_LIBRARY_JUMP_BUFFER mJumpContext;\r\n");
1043 .append("static EFI_STATUS mDriverEntryPointStatus = EFI_LOAD_ERROR;\r\n");
1045 fileBuffer
.append("\n");
1047 fileBuffer
.append("EFI_STATUS\r\n");
1048 fileBuffer
.append("EFIAPI\r\n");
1049 fileBuffer
.append("ProcessModuleEntryPointList (\r\n");
1050 fileBuffer
.append(" IN EFI_HANDLE ImageHandle,\r\n");
1051 fileBuffer
.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");
1052 fileBuffer
.append(" )\r\n\r\n");
1053 fileBuffer
.append("{\r\n");
1055 if (entryPointCount
== 1) {
1056 fileBuffer
.append(" return (");
1057 fileBuffer
.append(entryPointList
[0]);
1058 fileBuffer
.append(" (ImageHandle, SystemTable));\r\n");
1060 for (int i
= 0; i
< entryPointList
.length
; i
++) {
1061 if (!entryPointList
[i
].equals("")) {
1063 .append(" if (SetJump (&mJumpContext) == 0) {\r\n");
1064 fileBuffer
.append(" ExitDriver (");
1065 fileBuffer
.append(entryPointList
[i
]);
1066 fileBuffer
.append(" (ImageHandle, SystemTable));\r\n");
1067 fileBuffer
.append(" ASSERT (FALSE);\r\n");
1068 fileBuffer
.append(" }\r\n");
1073 fileBuffer
.append(" return mDriverEntryPointStatus;\r\n");
1075 fileBuffer
.append("}\r\n\r\n");
1077 fileBuffer
.append("VOID\n");
1078 fileBuffer
.append("EFIAPI\n");
1079 fileBuffer
.append("ExitDriver (\r\n");
1080 fileBuffer
.append(" IN EFI_STATUS Status\n");
1081 fileBuffer
.append(" )\r\n\r\n");
1082 fileBuffer
.append("{\r\n");
1083 if (entryPointCount
<= 1) {
1084 fileBuffer
.append(" if (EFI_ERROR (Status)) {\r\n");
1086 .append(" ProcessLibraryDestructorList (gImageHandle, gST);\r\n");
1087 fileBuffer
.append(" }\r\n");
1089 .append(" gBS->Exit (gImageHandle, Status, 0, NULL);\r\n");
1092 .append(" if (!EFI_ERROR (Status) || EFI_ERROR (mDriverEntryPointStatus)) {\r\n");
1093 fileBuffer
.append(" mDriverEntryPointStatus = Status;\r\n");
1094 fileBuffer
.append(" }\r\n");
1095 fileBuffer
.append(" LongJump (&mJumpContext, (UINTN)-1);\r\n");
1096 fileBuffer
.append(" ASSERT (FALSE);\r\n");
1098 fileBuffer
.append("}\r\n\r\n");
1103 // Add ModuleUnloadImage for DxeDriver and UefiDriver module type.
1105 entryPointList
= SurfaceAreaQuery
.getModuleUnloadImageArray();
1107 // Remover duplicate unload entry point.
1109 entryPointList
= CommonDefinition
.remDupString(entryPointList
);
1110 entryPointCount
= 0;
1111 if (entryPointList
!= null) {
1112 for (int i
= 0; i
< entryPointList
.length
; i
++) {
1113 fileBuffer
.append("EFI_STATUS\r\n");
1114 fileBuffer
.append("EFIAPI\r\n");
1115 fileBuffer
.append(entryPointList
[i
]);
1116 fileBuffer
.append(" (\r\n");
1118 .append(" IN EFI_HANDLE ImageHandle\r\n");
1119 fileBuffer
.append(" );\r\n");
1125 .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gDriverUnloadImageCount = ");
1126 fileBuffer
.append(Integer
.toString(entryPointCount
));
1127 fileBuffer
.append(";\r\n\r\n");
1129 fileBuffer
.append("EFI_STATUS\n");
1130 fileBuffer
.append("EFIAPI\r\n");
1131 fileBuffer
.append("ProcessModuleUnloadList (\r\n");
1132 fileBuffer
.append(" IN EFI_HANDLE ImageHandle\r\n");
1133 fileBuffer
.append(" )\r\n");
1134 fileBuffer
.append("{\r\n");
1136 if (entryPointCount
== 0) {
1137 fileBuffer
.append(" return EFI_SUCCESS;\r\n");
1138 } else if (entryPointCount
== 1) {
1139 fileBuffer
.append(" return ");
1140 fileBuffer
.append(entryPointList
[0]);
1141 fileBuffer
.append("(ImageHandle);\r\n");
1143 fileBuffer
.append(" EFI_STATUS Status;\r\n\r\n");
1144 fileBuffer
.append(" Status = EFI_SUCCESS;\r\n\r\n");
1145 for (int i
= 0; i
< entryPointList
.length
; i
++) {
1147 fileBuffer
.append(" Status = ");
1148 fileBuffer
.append(entryPointList
[i
]);
1149 fileBuffer
.append("(ImageHandle);\r\n");
1151 fileBuffer
.append(" if (EFI_ERROR (Status)) {\r\n");
1152 fileBuffer
.append(" ");
1153 fileBuffer
.append(entryPointList
[i
]);
1154 fileBuffer
.append("(ImageHandle);\r\n");
1155 fileBuffer
.append(" } else {\r\n");
1156 fileBuffer
.append(" Status = ");
1157 fileBuffer
.append(entryPointList
[i
]);
1158 fileBuffer
.append("(ImageHandle);\r\n");
1159 fileBuffer
.append(" }\r\n");
1162 fileBuffer
.append(" return Status;\r\n");
1164 fileBuffer
.append("}\r\n\r\n");
1172 * This function gets GUIDs from SPD file accrodeing to <PPIs> information
1173 * and write those GUIDs to AutoGen.c.
1176 * String Buffer for Autogen.c file.
1177 * @throws BuildException
1178 * Guid must set value!
1180 void PpiGuidToAutogenC(StringBuffer fileBuffer
) throws AutoGenException
{
1181 String
[] cNameGuid
= null;
1184 // Get the all PPI adn PPI Notify from MSA file,
1185 // then add those PPI ,and PPI Notify name to list.
1188 String
[] ppiList
= SurfaceAreaQuery
.getPpiArray(this.arch
);
1189 for (int i
= 0; i
< ppiList
.length
; i
++) {
1190 this.mPpiList
.add(ppiList
[i
]);
1193 String
[] ppiNotifyList
= SurfaceAreaQuery
.getPpiNotifyArray(this.arch
);
1194 for (int i
= 0; i
< ppiNotifyList
.length
; i
++) {
1195 this.mPpiList
.add(ppiNotifyList
[i
]);
1199 // Find CNAME and GUID from dependence SPD file and write to Autogen.c
1201 Iterator ppiIterator
= this.mPpiList
.iterator();
1202 String ppiKeyWord
= null;
1203 while (ppiIterator
.hasNext()) {
1204 ppiKeyWord
= ppiIterator
.next().toString();
1205 cNameGuid
= GlobalData
.getPpiGuid(this.mDepPkgList
, ppiKeyWord
);
1206 if (cNameGuid
!= null) {
1208 .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID ");
1209 fileBuffer
.append(cNameGuid
[0]);
1210 fileBuffer
.append(" = { ");
1211 fileBuffer
.append(CommonDefinition
.formatGuidName(cNameGuid
[1]));
1212 fileBuffer
.append(" } ;");
1215 // If can't find Ppi GUID declaration in every package
1217 throw new AutoGenException("Can not find Ppi GUID ["
1218 + ppiKeyWord
+ "] declaration in every packages. ");
1224 * ProtocolGuidToAutogenc
1226 * This function gets GUIDs from SPD file accrodeing to <Protocol>
1227 * information and write those GUIDs to AutoGen.c.
1230 * String Buffer for Autogen.c file.
1231 * @throws BuildException
1232 * Protocol name must set.
1234 void ProtocolGuidToAutogenC(StringBuffer fileBuffer
) throws BuildException
{
1235 String
[] cNameGuid
= null;
1237 String
[] protocolList
= SurfaceAreaQuery
.getProtocolArray(this.arch
);
1240 // Add result to Autogen global list.
1242 for (int i
= 0; i
< protocolList
.length
; i
++) {
1243 this.mProtocolList
.add(protocolList
[i
]);
1246 String
[] protocolNotifyList
= SurfaceAreaQuery
1247 .getProtocolNotifyArray(this.arch
);
1249 for (int i
= 0; i
< protocolNotifyList
.length
; i
++) {
1250 this.mProtocolList
.add(protocolNotifyList
[i
]);
1254 // Get the NAME and GUID from dependence SPD and write to Autogen.c
1256 Iterator protocolIterator
= this.mProtocolList
.iterator();
1257 String protocolKeyWord
= null;
1260 while (protocolIterator
.hasNext()) {
1261 protocolKeyWord
= protocolIterator
.next().toString();
1262 cNameGuid
= GlobalData
.getProtocolGuid(this.mDepPkgList
, protocolKeyWord
);
1263 if (cNameGuid
!= null) {
1265 .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID ");
1266 fileBuffer
.append(cNameGuid
[0]);
1267 fileBuffer
.append(" = { ");
1268 fileBuffer
.append(CommonDefinition
.formatGuidName(cNameGuid
[1]));
1269 fileBuffer
.append(" } ;");
1272 // If can't find protocol GUID declaration in every package
1274 throw new BuildException("Can not find protocol Guid ["
1275 + protocolKeyWord
+ "] declaration in every packages. ");
1281 * GuidGuidToAutogenc
1283 * This function gets GUIDs from SPD file accrodeing to <Guids> information
1284 * and write those GUIDs to AutoGen.c.
1287 * String Buffer for Autogen.c file.
1290 void GuidGuidToAutogenC(StringBuffer fileBuffer
) throws AutoGenException
{
1291 String
[] cNameGuid
= null;
1292 String guidKeyWord
= null;
1294 String
[] guidList
= SurfaceAreaQuery
.getGuidEntryArray(this.arch
);
1296 for (int i
= 0; i
< guidList
.length
; i
++) {
1297 this.mGuidList
.add(guidList
[i
]);
1301 Iterator guidIterator
= this.mGuidList
.iterator();
1302 while (guidIterator
.hasNext()) {
1303 guidKeyWord
= guidIterator
.next().toString();
1304 cNameGuid
= GlobalData
.getGuid(this.mDepPkgList
, guidKeyWord
);
1306 if (cNameGuid
!= null) {
1308 .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID ");
1309 fileBuffer
.append(cNameGuid
[0]);
1310 fileBuffer
.append(" = { ");
1311 fileBuffer
.append(CommonDefinition
.formatGuidName(cNameGuid
[1]));
1312 fileBuffer
.append("} ;");
1315 // If can't find GUID declaration in every package
1317 throw new AutoGenException("Can not find Guid [" + guidKeyWord
1318 + "] declaration in every packages. ");
1325 * LibInstanceToAutogenC
1327 * This function adds dependent library instance to autogen.c,which
1328 * includeing library's constructor, destructor, and library dependent ppi,
1329 * protocol, guid, pcd information.
1332 * String buffer for AutoGen.c
1333 * @throws BuildException
1335 void LibInstanceToAutogenC(StringBuffer fileBuffer
) throws BuildException
{
1338 String moduleType
= SurfaceAreaQuery
.getModuleType();
1339 List
<String
> libConstructList
= new ArrayList
<String
>();
1340 List
<String
> libDestructList
= new ArrayList
<String
>();
1342 String libConstructName
= null;
1343 String libDestructName
= null;
1344 ModuleIdentification
[] libraryIdList
= SurfaceAreaQuery
1345 .getLibraryInstance(this.arch
);
1348 if (libraryIdList
!= null) {
1350 // Reorder library instance sequence.
1352 AutogenLibOrder libOrder
= new AutogenLibOrder(libraryIdList
,
1354 List
<ModuleIdentification
> orderList
= libOrder
1355 .orderLibInstance();
1357 if (orderList
!= null) {
1359 // Process library instance one by one.
1361 for (int i
= 0; i
< orderList
.size(); i
++) {
1364 // Get library instance basename.
1366 ModuleIdentification libInstanceId
= orderList
.get(i
);
1372 Map
<String
, XmlObject
> libDoc
= GlobalData
.getDoc(
1373 libInstanceId
, this.arch
);
1374 SurfaceAreaQuery
.push(libDoc
);
1377 // Get <PPis>, <Protocols>, <Guids> list of this library
1380 String
[] ppiList
= SurfaceAreaQuery
.getPpiArray(this.arch
);
1381 String
[] ppiNotifyList
= SurfaceAreaQuery
1382 .getPpiNotifyArray(this.arch
);
1383 String
[] protocolList
= SurfaceAreaQuery
1384 .getProtocolArray(this.arch
);
1385 String
[] protocolNotifyList
= SurfaceAreaQuery
1386 .getProtocolNotifyArray(this.arch
);
1387 String
[] guidList
= SurfaceAreaQuery
1388 .getGuidEntryArray(this.arch
);
1389 PackageIdentification
[] pkgList
= SurfaceAreaQuery
.getDependencePkg(this.arch
);
1392 // Add those ppi, protocol, guid in global ppi,
1396 for (index
= 0; index
< ppiList
.length
; index
++) {
1397 this.mPpiList
.add(ppiList
[index
]);
1400 for (index
= 0; index
< ppiNotifyList
.length
; index
++) {
1401 this.mPpiList
.add(ppiNotifyList
[index
]);
1404 for (index
= 0; index
< protocolList
.length
; index
++) {
1405 this.mProtocolList
.add(protocolList
[index
]);
1408 for (index
= 0; index
< protocolNotifyList
.length
; index
++) {
1409 this.mProtocolList
.add(protocolNotifyList
[index
]);
1412 for (index
= 0; index
< guidList
.length
; index
++) {
1413 this.mGuidList
.add(guidList
[index
]);
1415 for (index
= 0; index
< pkgList
.length
; index
++){
1416 if (!this.mDepPkgList
.contains(pkgList
[index
])){
1417 this.mDepPkgList
.add(pkgList
[index
]);
1422 // If not yet parse this library instance's constructor
1423 // element,parse it.
1425 libConstructName
= SurfaceAreaQuery
1426 .getLibConstructorName();
1427 libDestructName
= SurfaceAreaQuery
1428 .getLibDestructorName();
1430 SurfaceAreaQuery
.pop();
1432 // Add dependent library instance constructor function.
1434 if (libConstructName
!= null) {
1435 libConstructList
.add(libConstructName
);
1438 // Add dependent library instance destructor fuction.
1440 if (libDestructName
!= null) {
1441 libDestructList
.add(libDestructName
);
1448 // Add library constructor to AutoGen.c
1450 LibConstructorToAutogenC(libConstructList
, moduleType
,
1451 fileBuffer
/* autogenC */);
1453 // Add library destructor to AutoGen.c
1455 LibDestructorToAutogenC(libDestructList
, moduleType
, fileBuffer
/* autogenC */);
1458 } catch (Exception e
) {
1459 throw new BuildException(e
.getMessage());
1464 * LibConstructorToAutogenc
1466 * This function writes library constructor list to AutoGen.c. The library
1467 * constructor's parameter and return value depend on module type.
1469 * @param libInstanceList
1470 * List of library construct name.
1474 * String buffer for AutoGen.c
1477 void LibConstructorToAutogenC(List
<String
> libInstanceList
,
1478 String moduleType
, StringBuffer fileBuffer
) throws Exception
{
1479 boolean isFirst
= true;
1482 // The library constructor's parameter and return value depend on
1485 for (int i
= 0; i
< libInstanceList
.size(); i
++) {
1486 switch (CommonDefinition
.getModuleType(moduleType
)) {
1487 case CommonDefinition
.ModuleTypeBase
:
1488 fileBuffer
.append("RETURN_STATUS\r\n");
1489 fileBuffer
.append("EFIAPI\r\n");
1490 fileBuffer
.append(libInstanceList
.get(i
));
1491 fileBuffer
.append(" (\r\n");
1492 fileBuffer
.append(" VOID\r\n");
1493 fileBuffer
.append(" );\r\n");
1496 case CommonDefinition
.ModuleTypePeiCore
:
1497 case CommonDefinition
.ModuleTypePeim
:
1498 fileBuffer
.append("EFI_STATUS\r\n");
1499 fileBuffer
.append("EFIAPI\r\n");
1500 fileBuffer
.append(libInstanceList
.get(i
));
1501 fileBuffer
.append(" (\r\n");
1503 .append(" IN EFI_FFS_FILE_HEADER *FfsHeader,\r\n");
1505 .append(" IN EFI_PEI_SERVICES **PeiServices\r\n");
1506 fileBuffer
.append(" );\r\n");
1509 case CommonDefinition
.ModuleTypeDxeCore
:
1510 case CommonDefinition
.ModuleTypeDxeDriver
:
1511 case CommonDefinition
.ModuleTypeDxeRuntimeDriver
:
1512 case CommonDefinition
.ModuleTypeDxeSmmDriver
:
1513 case CommonDefinition
.ModuleTypeDxeSalDriver
:
1514 case CommonDefinition
.ModuleTypeUefiDriver
:
1515 case CommonDefinition
.ModuleTypeUefiApplication
:
1516 fileBuffer
.append("EFI_STATUS\r\n");
1517 fileBuffer
.append("EFIAPI\r\n");
1518 fileBuffer
.append(libInstanceList
.get(i
));
1519 fileBuffer
.append(" (\r\n");
1520 fileBuffer
.append(" IN EFI_HANDLE ImageHandle,\r\n");
1521 fileBuffer
.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");
1522 fileBuffer
.append(" );\r\n");
1528 // Add ProcessLibraryConstructorList in AutoGen.c
1530 fileBuffer
.append("VOID\r\n");
1531 fileBuffer
.append("EFIAPI\r\n");
1532 fileBuffer
.append("ProcessLibraryConstructorList (\r\n");
1533 switch (CommonDefinition
.getModuleType(moduleType
)) {
1534 case CommonDefinition
.ModuleTypeBase
:
1535 fileBuffer
.append(" VOID\r\n");
1538 case CommonDefinition
.ModuleTypePeiCore
:
1539 case CommonDefinition
.ModuleTypePeim
:
1540 fileBuffer
.append(" IN EFI_FFS_FILE_HEADER *FfsHeader,\r\n");
1542 .append(" IN EFI_PEI_SERVICES **PeiServices\r\n");
1545 case CommonDefinition
.ModuleTypeDxeCore
:
1546 case CommonDefinition
.ModuleTypeDxeDriver
:
1547 case CommonDefinition
.ModuleTypeDxeRuntimeDriver
:
1548 case CommonDefinition
.ModuleTypeDxeSmmDriver
:
1549 case CommonDefinition
.ModuleTypeDxeSalDriver
:
1550 case CommonDefinition
.ModuleTypeUefiDriver
:
1551 case CommonDefinition
.ModuleTypeUefiApplication
:
1552 fileBuffer
.append(" IN EFI_HANDLE ImageHandle,\r\n");
1553 fileBuffer
.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");
1557 fileBuffer
.append(" )\r\n");
1558 fileBuffer
.append("{\r\n");
1560 // If no constructor function, return EFI_SUCCESS.
1562 //if (libInstanceList.size() == 0){
1563 // fileBuffer.append(" return EFI_SUCCESS;\r\n");
1565 for (int i
= 0; i
< libInstanceList
.size(); i
++) {
1567 fileBuffer
.append(" EFI_STATUS Status;\r\n");
1568 fileBuffer
.append(" Status = EFI_SUCCESS;\r\n");
1569 fileBuffer
.append("\r\n");
1572 switch (CommonDefinition
.getModuleType(moduleType
)) {
1573 case CommonDefinition
.ModuleTypeBase
:
1574 fileBuffer
.append(" Status = ");
1575 fileBuffer
.append(libInstanceList
.get(i
));
1576 fileBuffer
.append("();\r\n");
1577 fileBuffer
.append(" VOID\r\n");
1579 case CommonDefinition
.ModuleTypePeiCore
:
1580 case CommonDefinition
.ModuleTypePeim
:
1581 fileBuffer
.append(" Status = ");
1582 fileBuffer
.append(libInstanceList
.get(i
));
1583 fileBuffer
.append(" (FfsHeader, PeiServices);\r\n");
1585 case CommonDefinition
.ModuleTypeDxeCore
:
1586 case CommonDefinition
.ModuleTypeDxeDriver
:
1587 case CommonDefinition
.ModuleTypeDxeRuntimeDriver
:
1588 case CommonDefinition
.ModuleTypeDxeSmmDriver
:
1589 case CommonDefinition
.ModuleTypeDxeSalDriver
:
1590 case CommonDefinition
.ModuleTypeUefiDriver
:
1591 case CommonDefinition
.ModuleTypeUefiApplication
:
1592 fileBuffer
.append(" Status = ");
1593 fileBuffer
.append(libInstanceList
.get(i
));
1594 fileBuffer
.append(" (ImageHandle, SystemTable);\r\n");
1597 EdkLog
.log(EdkLog
.EDK_INFO
,"Autogen don't know how to deal with module type -"+ moduleType
+ " !");
1599 fileBuffer
.append(" ASSERT_EFI_ERROR (Status);\r\n");
1601 fileBuffer
.append("}\r\n");
1605 * LibDestructorToAutogenc
1607 * This function writes library destructor list to AutoGen.c. The library
1608 * destructor's parameter and return value depend on module type.
1610 * @param libInstanceList
1611 * List of library destructor name.
1615 * String buffer for AutoGen.c
1618 void LibDestructorToAutogenC(List
<String
> libInstanceList
,
1619 String moduleType
, StringBuffer fileBuffer
) throws Exception
{
1620 boolean isFirst
= true;
1621 for (int i
= 0; i
< libInstanceList
.size(); i
++) {
1622 switch (CommonDefinition
.getModuleType(moduleType
)) {
1623 case CommonDefinition
.ModuleTypeBase
:
1624 fileBuffer
.append("RETURN_STATUS\r\n");
1625 fileBuffer
.append("EFIAPI\r\n");
1626 fileBuffer
.append(libInstanceList
.get(i
));
1627 fileBuffer
.append(" (\r\n");
1628 fileBuffer
.append(" VOID\r\n");
1629 fileBuffer
.append(" );\r\n");
1631 case CommonDefinition
.ModuleTypePeiCore
:
1632 case CommonDefinition
.ModuleTypePeim
:
1633 fileBuffer
.append("EFI_STATUS\r\n");
1634 fileBuffer
.append("EFIAPI\r\n");
1635 fileBuffer
.append(libInstanceList
.get(i
));
1636 fileBuffer
.append(" (\r\n");
1638 .append(" IN EFI_FFS_FILE_HEADER *FfsHeader,\r\n");
1640 .append(" IN EFI_PEI_SERVICES **PeiServices\r\n");
1641 fileBuffer
.append(" );\r\n");
1643 case CommonDefinition
.ModuleTypeDxeCore
:
1644 case CommonDefinition
.ModuleTypeDxeDriver
:
1645 case CommonDefinition
.ModuleTypeDxeRuntimeDriver
:
1646 case CommonDefinition
.ModuleTypeDxeSmmDriver
:
1647 case CommonDefinition
.ModuleTypeDxeSalDriver
:
1648 case CommonDefinition
.ModuleTypeUefiDriver
:
1649 case CommonDefinition
.ModuleTypeUefiApplication
:
1650 fileBuffer
.append("EFI_STATUS\r\n");
1651 fileBuffer
.append("EFIAPI\r\n");
1652 fileBuffer
.append(libInstanceList
.get(i
));
1653 fileBuffer
.append(" (\r\n");
1654 fileBuffer
.append(" IN EFI_HANDLE ImageHandle,\r\n");
1655 fileBuffer
.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");
1656 fileBuffer
.append(" );\r\n");
1662 // Write ProcessLibraryDestructor list to autogen.c
1664 switch (CommonDefinition
.getModuleType(moduleType
)) {
1665 case CommonDefinition
.ModuleTypeBase
:
1666 case CommonDefinition
.ModuleTypePeiCore
:
1667 case CommonDefinition
.ModuleTypePeim
:
1669 case CommonDefinition
.ModuleTypeDxeCore
:
1670 case CommonDefinition
.ModuleTypeDxeDriver
:
1671 case CommonDefinition
.ModuleTypeDxeRuntimeDriver
:
1672 case CommonDefinition
.ModuleTypeDxeSmmDriver
:
1673 case CommonDefinition
.ModuleTypeDxeSalDriver
:
1674 case CommonDefinition
.ModuleTypeUefiDriver
:
1675 case CommonDefinition
.ModuleTypeUefiApplication
:
1676 fileBuffer
.append("VOID\r\n");
1677 fileBuffer
.append("EFIAPI\r\n");
1678 fileBuffer
.append("ProcessLibraryDestructorList (\r\n");
1679 fileBuffer
.append(" IN EFI_HANDLE ImageHandle,\r\n");
1680 fileBuffer
.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");
1681 fileBuffer
.append(" )\r\n");
1682 fileBuffer
.append("{\r\n");
1684 // If no library destructor function, return EFI_SUCCESS.
1687 for (int i
= 0; i
< libInstanceList
.size(); i
++) {
1689 fileBuffer
.append(" EFI_STATUS Status;\r\n");
1690 fileBuffer
.append(" Status = EFI_SUCCESS;\r\n");
1691 fileBuffer
.append("\r\n");
1694 fileBuffer
.append(" Status = ");
1695 fileBuffer
.append(libInstanceList
.get(i
));
1696 fileBuffer
.append("(ImageHandle, SystemTable);\r\n");
1697 fileBuffer
.append(" ASSERT_EFI_ERROR (Status);\r\n");
1699 fileBuffer
.append("}\r\n");
1705 * ExternsDriverBindingToAutoGenC
1707 * This function is to write DRIVER_BINDING, COMPONENT_NAME,
1708 * DRIVER_CONFIGURATION, DRIVER_DIAGNOSTIC in AutoGen.c.
1711 * String buffer for AutoGen.c
1713 void ExternsDriverBindingToAutoGenC(StringBuffer fileBuffer
)
1714 throws BuildException
{
1717 // Check what <extern> contains. And the number of following elements
1718 // under <extern> should be same. 1. DRIVER_BINDING 2. COMPONENT_NAME
1719 // 3.DRIVER_CONFIGURATION 4. DRIVER_DIAGNOSTIC
1722 String
[] drvBindList
= SurfaceAreaQuery
.getDriverBindingArray();
1725 // If component name protocol,component configuration protocol,
1726 // component diagnostic protocol is not null or empty, check
1727 // if every one have the same number of the driver binding protocol.
1729 if (drvBindList
== null || drvBindList
.length
== 0) {
1733 String
[] compNamList
= SurfaceAreaQuery
.getComponentNameArray();
1734 String
[] compConfList
= SurfaceAreaQuery
.getDriverConfigArray();
1735 String
[] compDiagList
= SurfaceAreaQuery
.getDriverDiagArray();
1740 // Write driver binding protocol extern to autogen.c
1742 for (int i
= 0; i
< drvBindList
.length
; i
++) {
1743 fileBuffer
.append("extern EFI_DRIVER_BINDING_PROTOCOL ");
1744 fileBuffer
.append(drvBindList
[i
]);
1745 fileBuffer
.append(";\r\n");
1749 // Write component name protocol extern to autogen.c
1751 if (compNamList
!= null && compNamList
.length
!= 0) {
1752 if (drvBindList
.length
!= compNamList
.length
) {
1753 throw new BuildException(
1754 "Different number of Driver Binding and Component Name protocols!");
1758 for (int i
= 0; i
< compNamList
.length
; i
++) {
1759 fileBuffer
.append("extern EFI_COMPONENT_NAME_PROTOCOL ");
1760 fileBuffer
.append(compNamList
[i
]);
1761 fileBuffer
.append(";\r\n");
1766 // Write driver configration protocol extern to autogen.c
1768 if (compConfList
!= null && compConfList
.length
!= 0) {
1769 if (drvBindList
.length
!= compConfList
.length
) {
1770 throw new BuildException(
1771 "Different number of Driver Binding and Driver Configuration protocols!");
1775 for (int i
= 0; i
< compConfList
.length
; i
++) {
1776 fileBuffer
.append("extern EFI_DRIVER_CONFIGURATION_PROTOCOL ");
1777 fileBuffer
.append(compConfList
[i
]);
1778 fileBuffer
.append(";\r\n");
1783 // Write driver dignastic protocol extern to autogen.c
1785 if (compDiagList
!= null && compDiagList
.length
!= 0) {
1786 if (drvBindList
.length
!= compDiagList
.length
) {
1787 throw new BuildException(
1788 "Different number of Driver Binding and Driver Diagnosis protocols!");
1792 for (int i
= 0; i
< compDiagList
.length
; i
++) {
1793 fileBuffer
.append("extern EFI_DRIVER_DIAGNOSTICS_PROTOCOL ");
1794 fileBuffer
.append(compDiagList
[i
]);
1795 fileBuffer
.append(";\r\n");
1800 // Write driver module protocol bitmask.
1803 .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gDriverModelProtocolBitmask = ");
1804 fileBuffer
.append(Integer
.toString(BitMask
));
1805 fileBuffer
.append(";\r\n");
1808 // Write driver module protocol list entry
1811 .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINTN _gDriverModelProtocolListEntries = ");
1813 fileBuffer
.append(Integer
.toString(drvBindList
.length
));
1814 fileBuffer
.append(";\r\n");
1817 // Write drive module protocol list to autogen.c
1820 .append("GLOBAL_REMOVE_IF_UNREFERENCED const EFI_DRIVER_MODEL_PROTOCOL_LIST _gDriverModelProtocolList[] = {");
1821 for (int i
= 0; i
< drvBindList
.length
; i
++) {
1823 fileBuffer
.append(",");
1825 fileBuffer
.append("\r\n {\r\n");
1826 fileBuffer
.append(" &");
1827 fileBuffer
.append(drvBindList
[i
]);
1828 fileBuffer
.append(", \r\n");
1830 if (compNamList
!= null) {
1831 fileBuffer
.append(" &");
1832 fileBuffer
.append(compNamList
[i
]);
1833 fileBuffer
.append(", \r\n");
1835 fileBuffer
.append(" NULL, \r\n");
1838 if (compConfList
!= null) {
1839 fileBuffer
.append(" &");
1840 fileBuffer
.append(compConfList
[i
]);
1841 fileBuffer
.append(", \r\n");
1843 fileBuffer
.append(" NULL, \r\n");
1846 if (compDiagList
!= null) {
1847 fileBuffer
.append(" &");
1848 fileBuffer
.append(compDiagList
[i
]);
1849 fileBuffer
.append(", \r\n");
1851 fileBuffer
.append(" NULL, \r\n");
1853 fileBuffer
.append(" }");
1855 fileBuffer
.append("\r\n};\r\n");
1859 * ExternCallBackToAutoGenC
1861 * This function adds <SetVirtualAddressMapCallBack> and
1862 * <ExitBootServicesCallBack> infomation to AutoGen.c
1865 * String buffer for AutoGen.c
1866 * @throws BuildException
1868 void ExternCallBackToAutoGenC(StringBuffer fileBuffer
)
1869 throws BuildException
{
1870 String
[] setVirtualList
= SurfaceAreaQuery
1871 .getSetVirtualAddressMapCallBackArray();
1872 String
[] exitBootList
= SurfaceAreaQuery
1873 .getExitBootServicesCallBackArray();
1874 String moduleType
= SurfaceAreaQuery
.getModuleType();
1875 boolean UefiOrDxeModule
= false;
1879 switch (CommonDefinition
.getModuleType(moduleType
)) {
1880 case CommonDefinition
.ModuleTypeDxeDriver
:
1881 case CommonDefinition
.ModuleTypeDxeRuntimeDriver
:
1882 case CommonDefinition
.ModuleTypeDxeSalDriver
:
1883 case CommonDefinition
.ModuleTypeUefiDriver
:
1884 case CommonDefinition
.ModuleTypeUefiApplication
:
1886 // Entry point lib for these module types needs to know the count
1889 UefiOrDxeModule
= true;
1891 .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED const UINTN _gDriverSetVirtualAddressMapEventCount = ");
1894 // If the list is not valid or has no entries set count to zero else
1895 // set count to the number of valid entries
1898 if (setVirtualList
!= null) {
1899 for (i
= 0; i
< setVirtualList
.length
; i
++) {
1900 if (setVirtualList
[i
].equalsIgnoreCase("")) {
1907 fileBuffer
.append(Integer
.toString(Count
));
1908 fileBuffer
.append(";\r\n\r\n");
1914 if (setVirtualList
== null) {
1915 if (UefiOrDxeModule
) {
1917 // No data so make a NULL list
1920 .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED const EFI_EVENT_NOTIFY _gDriverSetVirtualAddressMapEvent[] = {\r\n");
1921 fileBuffer
.append(" NULL\r\n");
1922 fileBuffer
.append("};\r\n\r\n");
1926 // Write SetVirtualAddressMap function definition.
1928 for (i
= 0; i
< setVirtualList
.length
; i
++) {
1929 if (setVirtualList
[i
].equalsIgnoreCase("")) {
1932 fileBuffer
.append("VOID\r\n");
1933 fileBuffer
.append("EFIAPI\r\n");
1934 fileBuffer
.append(setVirtualList
[i
]);
1935 fileBuffer
.append(" (\r\n");
1936 fileBuffer
.append(" IN EFI_EVENT Event,\r\n");
1937 fileBuffer
.append(" IN VOID *Context\r\n");
1938 fileBuffer
.append(" );\r\n\r\n");
1942 // Write SetVirtualAddressMap entry point array.
1945 .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED const EFI_EVENT_NOTIFY _gDriverSetVirtualAddressMapEvent[] = {");
1946 for (i
= 0; i
< setVirtualList
.length
; i
++) {
1947 if (setVirtualList
[i
].equalsIgnoreCase("")) {
1952 fileBuffer
.append("\r\n ");
1954 fileBuffer
.append(",\r\n ");
1957 fileBuffer
.append(setVirtualList
[i
]);
1960 // If module is not DXE_DRIVER, DXE_RUNTIME_DIRVER, UEFI_DRIVER
1961 // UEFI_APPLICATION and DXE_SAL_DRIVER add the NULL at the end of
1962 // _gDriverSetVirtualAddressMapEvent list.
1964 if (!UefiOrDxeModule
) {
1965 fileBuffer
.append(",\r\n NULL");
1967 fileBuffer
.append("\r\n};\r\n\r\n");
1970 if (UefiOrDxeModule
) {
1972 // Entry point lib for these module types needs to know the count.
1975 .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED const UINTN _gDriverExitBootServicesEventCount = ");
1978 // If the list is not valid or has no entries set count to zero else
1979 // set count to the number of valid entries.
1982 if (exitBootList
!= null) {
1983 for (i
= 0; i
< exitBootList
.length
; i
++) {
1984 if (exitBootList
[i
].equalsIgnoreCase("")) {
1990 fileBuffer
.append(Integer
.toString(Count
));
1991 fileBuffer
.append(";\r\n\r\n");
1994 if (exitBootList
== null) {
1995 if (UefiOrDxeModule
) {
1997 // No data so make a NULL list.
2000 .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED const EFI_EVENT_NOTIFY _gDriverExitBootServicesEvent[] = {\r\n");
2001 fileBuffer
.append(" NULL\r\n");
2002 fileBuffer
.append("};\r\n\r\n");
2006 // Write DriverExitBootServices function definition.
2008 for (i
= 0; i
< exitBootList
.length
; i
++) {
2009 if (exitBootList
[i
].equalsIgnoreCase("")) {
2013 fileBuffer
.append("VOID\r\n");
2014 fileBuffer
.append("EFIAPI\r\n");
2015 fileBuffer
.append(exitBootList
[i
]);
2016 fileBuffer
.append(" (\r\n");
2017 fileBuffer
.append(" IN EFI_EVENT Event,\r\n");
2018 fileBuffer
.append(" IN VOID *Context\r\n");
2019 fileBuffer
.append(" );\r\n\r\n");
2023 // Write DriverExitBootServices entry point array.
2026 .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED const EFI_EVENT_NOTIFY _gDriverExitBootServicesEvent[] = {");
2027 for (i
= 0; i
< exitBootList
.length
; i
++) {
2028 if (exitBootList
[i
].equalsIgnoreCase("")) {
2033 fileBuffer
.append("\r\n ");
2035 fileBuffer
.append(",\r\n ");
2037 fileBuffer
.append(exitBootList
[i
]);
2039 if (!UefiOrDxeModule
) {
2040 fileBuffer
.append(",\r\n NULL");
2042 fileBuffer
.append("\r\n};\r\n\r\n");
2047 private void copyFlashMapHToDebugDir() throws AutoGenException
{
2049 File inFile
= new File(fvDir
+ File
.separatorChar
+ CommonDefinition
.flashMapH
);
2050 int size
= (int)inFile
.length();
2051 byte[] buffer
= new byte[size
];
2052 File outFile
= new File (this.outputPath
+ File
.separatorChar
+ CommonDefinition
.tianoR8FlashMapH
);
2054 // If TianoR8FlashMap.h existed and the flashMap.h don't change,
2057 if ((!outFile
.exists()) ||(inFile
.lastModified() - outFile
.lastModified()) >= 0) {
2059 if (inFile
.exists()) {
2060 FileInputStream fis
= new FileInputStream (inFile
);
2062 FileOutputStream fos
= new FileOutputStream(outFile
);
2067 throw new AutoGenException("The flashMap.h file don't exist!!");
2069 } catch (Exception e
){
2070 throw new AutoGenException(e
.getMessage());