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
.LinkedList
;
29 import java
.util
.List
;
33 import org
.apache
.tools
.ant
.BuildException
;
34 import org
.apache
.xmlbeans
.XmlObject
;
35 import org
.tianocore
.GuidsDocument
;
36 import org
.tianocore
.LibraryClassDocument
.LibraryClass
;
37 import org
.tianocore
.PPIsDocument
;
38 import org
.tianocore
.ProtocolsDocument
;
39 import org
.tianocore
.build
.exception
.*;
40 import org
.tianocore
.build
.global
.GlobalData
;
41 import org
.tianocore
.build
.global
.Spd
;
42 import org
.tianocore
.build
.global
.SurfaceAreaQuery
;
43 import org
.tianocore
.build
.id
.ModuleIdentification
;
44 import org
.tianocore
.build
.id
.PackageIdentification
;
45 import org
.tianocore
.build
.pcd
.action
.PCDAutoGenAction
;
46 import org
.tianocore
.logger
.EdkLog
;
49 * This class is to generate Autogen.h and Autogen.c according to module surface
50 * area or library surface area.
52 public class AutoGen
{
54 // / The output path of Autogen.h and Autogen.c
56 private String outputPath
;
58 /// The name of FV directory
62 // / The base name of module or library.
64 private ModuleIdentification moduleId
;
67 // / The build architecture
72 // / PcdAutogen instance which is used to manage how to generate the PCD
75 private PCDAutoGenAction myPcdAutogen
;
78 // / The protocl list which records in module or library surface area and
79 // / it's dependence on library instance surface area.
81 private Set
<String
> mProtocolList
= new HashSet
<String
>();
84 // / The Ppi list which recorded in module or library surface area and its
85 // / dependency on library instance surface area.
87 private Set
<String
> mPpiList
= new HashSet
<String
>();
90 // / The Guid list which recoreded in module or library surface area and it's
91 // / dependence on library instance surface area.
93 private Set
<String
> mGuidList
= new HashSet
<String
>();
96 // The dependence package list which recoreded in module or library surface
97 // area and it's dependence on library instance surface are.
99 private List
<PackageIdentification
> mDepPkgList
= new LinkedList
<PackageIdentification
>();
103 * This function mainly initialize some member variable.
106 * Output path of AutoGen file.
110 * Target architecture.
112 public AutoGen(String fvDir
, String outputPath
, ModuleIdentification moduleId
, String arch
) {
113 this.outputPath
= outputPath
;
114 this.moduleId
= moduleId
;
123 * This function save the content in stringBuffer to file.
128 * The content of AutoGen file in buffer.
129 * @return "true" successful, "false" failed.
131 private boolean saveFile(String fileName
, StringBuffer fileBuffer
) {
133 File autoGenH
= new File(fileName
);
136 // if the file exists, compare their content
138 if (autoGenH
.exists()) {
139 FileReader fIn
= new FileReader(autoGenH
);
140 char[] oldFileBuffer
= new char[(int) autoGenH
.length()];
141 fIn
.read(oldFileBuffer
, 0, (int) autoGenH
.length());
145 // if we got the same file, don't re-generate it to prevent
146 // sources depending on it from re-building
148 if (fileBuffer
.toString().compareTo(new String(oldFileBuffer
)) == 0) {
152 FileWriter fOut
= new FileWriter(autoGenH
);
153 fOut
.write(fileBuffer
.toString());
155 } catch (Exception e
) {
162 * genAutogen function
164 * This function call libGenAutoGen or moduleGenAutogen function, which
165 * dependence on generate library autogen or module autogen.
167 * @throws BuildException
168 * Failed to creat AutoGen.c & AutoGen.h.
170 public void genAutogen() throws BuildException
{
173 // If outputPath do not exist, create it.
175 File path
= new File(outputPath
);
179 // Check current is library or not, then call the corresponding
182 if (this.moduleId
.isLibrary()) {
188 } catch (Exception e
) {
189 throw new BuildException(
190 "Failed to create AutoGen.c & AutoGen.h!\n"
196 * moduleGenAutogen function
198 * This function generates AutoGen.c & AutoGen.h for module.
200 * @throws BuildException
201 * Faile to create module AutoGen.c & AutoGen.h.
203 void moduleGenAutogen() throws BuildException
{
208 } catch (Exception e
) {
209 throw new BuildException(
210 "Faile to create module AutoGen.c & AutoGen.h!\n"
216 * libGenAutogen function
218 * This function generates AutoGen.c & AutoGen.h for library.
220 * @throws BuildException
221 * Faile to create library AutoGen.c & AutoGen.h
223 void libGenAutogen() throws BuildException
{
227 } catch (Exception e
) {
228 throw new BuildException(
229 "Faile to create library AutoGen.c & AutoGen.h!\n"
237 * This function generates AutoGen.h for module.
239 * @throws BuildException
240 * Failed to generate AutoGen.h.
242 void moduleGenAutogenH() throws AutoGenException
{
244 Set
<String
> libClassIncludeH
;
246 // List<String> headerFileList;
247 List
<String
> headerFileList
;
249 StringBuffer fileBuffer
= new StringBuffer(8192);
252 // Write Autogen.h header notation
254 fileBuffer
.append(CommonDefinition
.autogenHNotation
);
257 // Add #ifndef ${BaseName}_AUTOGENH
258 // #def ${BseeName}_AUTOGENH
260 fileBuffer
.append("#ifndef " + "_AUTOGENH_" + this.moduleId
.getGuid().replaceAll("-", "_") +"\r\n");
261 fileBuffer
.append("#define " + "_AUTOGENH_" + this.moduleId
.getGuid().replaceAll("-", "_") +"\r\n\r\n");
264 // Write the specification version and release version at the begine
265 // of autogen.h file.
266 // Note: the specification version and release version should
267 // be got from module surface area instead of hard code by it's
270 moduleType
= SurfaceAreaQuery
.getModuleType();
273 // Add "extern int __make_me_compile_correctly;" at begin of
276 fileBuffer
.append(CommonDefinition
.autoGenHbegin
);
279 // Put EFI_SPECIFICATION_VERSION, and EDK_RELEASE_VERSION.
281 String
[] specList
= SurfaceAreaQuery
.getExternSpecificaiton();
282 for (int i
= 0; i
< specList
.length
; i
++) {
283 fileBuffer
.append(CommonDefinition
.marcDefineStr
+ specList
[i
]
287 // Write consumed package's mdouleInfo related .h file to autogen.h
289 // PackageIdentification[] consumedPkgIdList = SurfaceAreaQuery
290 // .getDependencePkg(this.arch);
291 PackageIdentification
[] consumedPkgIdList
= SurfaceAreaQuery
292 .getDependencePkg(this.arch
);
293 if (consumedPkgIdList
!= null) {
294 headerFileList
= depPkgToAutogenH(consumedPkgIdList
, moduleType
);
295 item
= headerFileList
.iterator();
296 while (item
.hasNext()) {
297 fileBuffer
.append(item
.next().toString());
302 // Write library class's related *.h file to autogen.h.
304 String
[] libClassList
= SurfaceAreaQuery
305 .getLibraryClasses(CommonDefinition
.AlwaysConsumed
,this.arch
);
306 if (libClassList
!= null) {
307 libClassIncludeH
= LibraryClassToAutogenH(libClassList
);
308 item
= libClassIncludeH
.iterator();
309 while (item
.hasNext()) {
310 fileBuffer
.append(item
.next().toString());
314 libClassList
= SurfaceAreaQuery
315 .getLibraryClasses(CommonDefinition
.AlwaysProduced
, this.arch
);
316 if (libClassList
!= null) {
317 libClassIncludeH
= LibraryClassToAutogenH(libClassList
);
318 item
= libClassIncludeH
.iterator();
319 while (item
.hasNext()) {
320 fileBuffer
.append(item
.next().toString());
323 fileBuffer
.append("\r\n");
326 // If is TianoR8FlashMap, copy {Fv_DIR}/FlashMap.h to
327 // {DEST_DIR_DRBUG}/FlashMap.h
329 if (SurfaceAreaQuery
.isHaveTianoR8FlashMap()) {
330 fileBuffer
.append(CommonDefinition
.include
);
331 fileBuffer
.append(" <");
332 fileBuffer
.append(CommonDefinition
.tianoR8FlashMapH
+ ">\r\n");
333 copyFlashMapHToDebugDir();
336 // Write PCD autogen information to AutoGen.h.
338 if (this.myPcdAutogen
!= null) {
339 fileBuffer
.append("\r\n");
340 fileBuffer
.append(this.myPcdAutogen
.OutputH());
344 // Append the #endif at AutoGen.h
346 fileBuffer
.append("#endif\r\n");
349 // Save string buffer content in AutoGen.h.
351 if (!saveFile(outputPath
+ File
.separatorChar
+ "AutoGen.h", fileBuffer
)) {
352 throw new BuildException("Failed to generate AutoGen.h !!!");
359 * This function generates AutoGen.c for module.
361 * @throws BuildException
362 * Failed to generate AutoGen.c.
364 void moduleGenAutogenC() throws AutoGenException
{
366 StringBuffer fileBuffer
= new StringBuffer(8192);
368 // Write Autogen.c header notation
370 fileBuffer
.append(CommonDefinition
.autogenCNotation
);
373 // Write #include <AutoGen.h> at beginning of AutoGen.c
375 fileBuffer
.append(CommonDefinition
.includeAutogenH
);
378 // Get the native MSA file infomation. Since before call autogen,
379 // the MSA native <Externs> information were overrided. So before
380 // process <Externs> it should be set the DOC as the Native MSA info.
382 Map
<String
, XmlObject
> doc
= GlobalData
.getNativeMsa(this.moduleId
);
383 SurfaceAreaQuery
.push(doc
);
386 // DriverBinding/ComponentName/DriverConfiguration/DriverDialog
390 ExternsDriverBindingToAutoGenC(fileBuffer
);
393 // Write DriverExitBootServicesEvent/DriverSetVirtualAddressMapEvent
396 ExternCallBackToAutoGenC(fileBuffer
);
399 // Write EntryPoint to autgoGen.c
401 String
[] entryPointList
= SurfaceAreaQuery
.getModuleEntryPointArray();
402 EntryPointToAutoGen(CommonDefinition
.remDupString(entryPointList
), fileBuffer
);
406 // Restore the DOC which include the FPD module info.
408 SurfaceAreaQuery
.pop();
411 // Write Guid to autogen.c
413 String guid
= CommonDefinition
.formatGuidName(SurfaceAreaQuery
417 .append("GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiCallerIdGuid = {");
419 throw new AutoGenException("Guid value must set!\n");
423 // Formate Guid as ANSI c form.Example:
424 // {0xd2b2b828, 0x826, 0x48a7,{0xb3, 0xdf, 0x98, 0x3c, 0x0, 0x60, 0x24,
428 fileBuffer
.append(guid
);
429 fileBuffer
.append("};\r\n");
432 // Generate library instance consumed protocol, guid, ppi, pcd list.
433 // Save those to this.protocolList, this.ppiList, this.pcdList,
434 // this.guidList. Write Consumed library constructor and desconstuct to
437 LibInstanceToAutogenC(fileBuffer
);
440 // Get module dependent Package identification.
442 PackageIdentification
[] packages
= SurfaceAreaQuery
.getDependencePkg(this.arch
);
443 for (int i
= 0; i
< packages
.length
; i
++){
444 if (!this.mDepPkgList
.contains(packages
[i
])){
445 this.mDepPkgList
.add(packages
[i
]);
451 // Write consumed ppi, guid, protocol to autogen.c
453 ProtocolGuidToAutogenC(fileBuffer
);
454 PpiGuidToAutogenC(fileBuffer
);
455 GuidGuidToAutogenC(fileBuffer
);
458 // Call pcd autogen. PCDAutoGenAction tool only need module name and
459 // isPcdEmulatedDriver as parameter. Library inherits PCD and module's
460 // PCD information has been collected in FPDParser task by
462 // Note : when PCD image tool ready,
463 // isPCDEmulatedDriver parameter will be removed.
466 // this.myPcdAutogen = new PCDAutoGenAction(moduleId.getName(),
467 // moduleId.getGuid(), moduleId.getPackage().getName(), moduleId.getPackage().getGuid(),this.arch,moduleId.getVersion(),false, null);
468 this.myPcdAutogen
= new PCDAutoGenAction(moduleId
.getName(),null,null,null, this.arch
,null,false, null);
469 this.myPcdAutogen
.execute();
470 } catch (Exception e
) {
471 throw new BuildException("PCD Autogen failed:" + e
.getMessage());
474 if (this.myPcdAutogen
!= null) {
475 fileBuffer
.append("\r\n");
476 fileBuffer
.append(this.myPcdAutogen
.OutputC());
479 if (!saveFile(outputPath
+ File
.separatorChar
+ "AutoGen.c", fileBuffer
)) {
480 throw new BuildException("Failed to generate AutoGen.c !!!");
488 * This function generates AutoGen.h for library.
490 * @throws BuildException
491 * Failed to generate AutoGen.c.
493 void libGenAutogenH() throws AutoGenException
{
495 Set
<String
> libClassIncludeH
;
497 List
<String
> headerFileList
;
499 StringBuffer fileBuffer
= new StringBuffer(10240);
502 // Write Autogen.h header notation
504 fileBuffer
.append(CommonDefinition
.autogenHNotation
);
507 // Add #ifndef ${BaseName}_AUTOGENH
508 // #def ${BseeName}_AUTOGENH
510 fileBuffer
.append("#ifndef " + "_AUTOGENH_" + this.moduleId
.getGuid().replaceAll("-", "_") + "\r\n");
511 fileBuffer
.append("#define " + "_AUTOGENH_" + this.moduleId
.getGuid().replaceAll("-", "_") + "\r\n\r\n");
514 // Write EFI_SPECIFICATION_VERSION and EDK_RELEASE_VERSION
515 // to autogen.h file.
516 // Note: the specification version and release version should
517 // be get from module surface area instead of hard code.
519 fileBuffer
.append(CommonDefinition
.autoGenHbegin
);
520 String
[] specList
= SurfaceAreaQuery
.getExternSpecificaiton();
521 for (int i
= 0; i
< specList
.length
; i
++) {
522 fileBuffer
.append(CommonDefinition
.marcDefineStr
+ specList
[i
]
525 // fileBuffer.append(CommonDefinition.autoGenHLine1);
526 // fileBuffer.append(CommonDefinition.autoGenHLine2);
529 // Write consumed package's mdouleInfo related *.h file to autogen.h.
531 moduleType
= SurfaceAreaQuery
.getModuleType();
532 PackageIdentification
[] cosumedPkglist
= SurfaceAreaQuery
533 .getDependencePkg(this.arch
);
534 headerFileList
= depPkgToAutogenH(cosumedPkglist
, moduleType
);
535 item
= headerFileList
.iterator();
536 while (item
.hasNext()) {
537 fileBuffer
.append(item
.next().toString());
540 // Write library class's related *.h file to autogen.h
542 String
[] libClassList
= SurfaceAreaQuery
543 .getLibraryClasses(CommonDefinition
.AlwaysConsumed
, this.arch
);
544 if (libClassList
!= null) {
545 libClassIncludeH
= LibraryClassToAutogenH(libClassList
);
546 item
= libClassIncludeH
.iterator();
547 while (item
.hasNext()) {
548 fileBuffer
.append(item
.next().toString());
552 libClassList
= SurfaceAreaQuery
553 .getLibraryClasses(CommonDefinition
.AlwaysProduced
, this.arch
);
554 if (libClassList
!= null) {
555 libClassIncludeH
= LibraryClassToAutogenH(libClassList
);
556 item
= libClassIncludeH
.iterator();
557 while (item
.hasNext()) {
558 fileBuffer
.append(item
.next().toString());
561 fileBuffer
.append("\r\n");
564 // If is TianoR8FlashMap, copy {Fv_DIR}/FlashMap.h to
565 // {DEST_DIR_DRBUG}/FlashMap.h
567 if (SurfaceAreaQuery
.isHaveTianoR8FlashMap()) {
568 fileBuffer
.append(CommonDefinition
.include
);
569 fileBuffer
.append(" <");
570 fileBuffer
.append(CommonDefinition
.tianoR8FlashMapH
+ ">\r\n");
571 copyFlashMapHToDebugDir();
575 // Write PCD information to library AutoGen.h.
577 if (this.myPcdAutogen
!= null) {
578 fileBuffer
.append("\r\n");
579 fileBuffer
.append(this.myPcdAutogen
.OutputH());
583 // Append the #endif at AutoGen.h
585 fileBuffer
.append("#endif\r\n");
588 // Save content of string buffer to AutoGen.h file.
590 if (!saveFile(outputPath
+ File
.separatorChar
+ "AutoGen.h", fileBuffer
)) {
591 throw new BuildException("Failed to generate AutoGen.h !!!");
598 * This function generates AutoGen.h for library.
600 * @throws BuildException
601 * Failed to generate AutoGen.c.
603 void libGenAutogenC() throws BuildException
{
604 StringBuffer fileBuffer
= new StringBuffer(10240);
607 // Write Autogen.c header notation
609 fileBuffer
.append(CommonDefinition
.autogenCNotation
);
611 fileBuffer
.append(CommonDefinition
.autoGenCLine1
);
612 fileBuffer
.append("\r\n");
615 // Call pcd autogen. PCDAutoGenAction tool only need module name and
616 // isPcdEmulatedDriver as parameter. Library inherit PCD and module's
617 // PCD information has been collected in FPDParser task by
619 // Note : when PCD image tool ready,
620 // isPCDEmulatedDriver parameter will be removed.
623 // this.myPcdAutogen = new PCDAutoGenAction(this.moduleId.getName(),
624 // this.moduleId.getGuid(),moduleId.getPackage().getName(),moduleId.getPackage().getGuid(), this.arch, moduleId.getVersion(),true, SurfaceAreaQuery.getModulePcdEntryNameArray());
625 this.myPcdAutogen
= new PCDAutoGenAction(this.moduleId
.getName(),
632 SurfaceAreaQuery
.getModulePcdEntryNameArray());
634 this.myPcdAutogen
.execute();
635 } catch (Exception e
) {
636 throw new BuildException(e
.getMessage());
639 if (this.myPcdAutogen
!= null) {
640 fileBuffer
.append("\r\n");
641 fileBuffer
.append(this.myPcdAutogen
.OutputC());
644 if (!saveFile(outputPath
+ File
.separatorChar
+ "AutoGen.c", fileBuffer
)) {
645 throw new BuildException("Failed to generate AutoGen.c !!!");
650 * LibraryClassToAutogenH
652 * This function returns *.h files declared by library classes which are
653 * consumed or produced by current build module or library.
655 * @param libClassList
656 * List of library class which consumed or produce by current
657 * build module or library.
658 * @return includeStrList List of *.h file.
660 Set
<String
> LibraryClassToAutogenH(String
[] libClassList
)
661 throws AutoGenException
{
662 Set
<String
> includStrList
= new HashSet
<String
>();
663 String includerName
[];
667 // Get include file from GlobalData's SPDTable according to
668 // library class name.
671 for (int i
= 0; i
< libClassList
.length
; i
++) {
672 includerName
= GlobalData
.getLibraryClassHeaderFiles(
673 SurfaceAreaQuery
.getDependencePkg(this.arch
),
675 if (includerName
== null) {
676 throw new AutoGenException("Can not find library class ["
677 + libClassList
[i
] + "] declaration in every packages. ");
679 for (int j
= 0; j
< includerName
.length
; j
++) {
680 String includeNameStr
= includerName
[j
];
681 if (includeNameStr
!= null) {
682 str
= CommonDefinition
.include
+ " " + "<";
683 str
= str
+ includeNameStr
+ ">\r\n";
684 includStrList
.add(str
);
685 includeNameStr
= null;
689 return includStrList
;
695 * This function add include file in AutoGen.h file.
697 * @param packageNameList
698 * List of module depended package.
703 List
<String
> depPkgToAutogenH(PackageIdentification
[] packageNameList
,
704 String moduleType
) throws AutoGenException
{
706 List
<String
> includeStrList
= new LinkedList
<String
>();
708 String includeStr
= "";
711 // Get include file from moduleInfo file
713 for (int i
= 0; i
< packageNameList
.length
; i
++) {
714 pkgHeader
= GlobalData
.getPackageHeaderFiles(packageNameList
[i
],
716 if (pkgHeader
== null) {
717 throw new AutoGenException("Can not find package ["
719 + "] declaration in every packages. ");
720 } else if (!pkgHeader
.equalsIgnoreCase("")) {
721 includeStr
= CommonDefinition
.include
+ " <" + pkgHeader
723 includeStrList
.add(includeStr
);
727 return includeStrList
;
731 * EntryPointToAutoGen
733 * This function convert <ModuleEntryPoint> & <ModuleUnloadImage>
734 * information in mas to AutoGen.c
736 * @param entryPointList
737 * List of entry point.
739 * String buffer fo AutoGen.c.
742 void EntryPointToAutoGen(String
[] entryPointList
, StringBuffer fileBuffer
)
743 throws BuildException
{
745 String typeStr
= SurfaceAreaQuery
.getModuleType();
748 // The parameters and return value of entryPoint is difference
749 // for difference module type.
751 switch (CommonDefinition
.getModuleType(typeStr
)) {
753 case CommonDefinition
.ModuleTypePeiCore
:
754 if (entryPointList
== null ||entryPointList
.length
!= 1 ) {
755 throw new BuildException(
756 "Module type = 'PEI_CORE', only have one module entry point!");
758 fileBuffer
.append("EFI_STATUS\r\n");
759 fileBuffer
.append("EFIAPI\r\n");
760 fileBuffer
.append(entryPointList
[0]);
761 fileBuffer
.append(" (\r\n");
763 .append(" IN EFI_PEI_STARTUP_DESCRIPTOR *PeiStartupDescriptor,\r\n");
765 .append(" IN VOID *OldCoreData\r\n");
766 fileBuffer
.append(" );\r\n\r\n");
768 fileBuffer
.append("EFI_STATUS\r\n");
769 fileBuffer
.append("EFIAPI\r\n");
770 fileBuffer
.append("ProcessModuleEntryPointList (\r\n");
772 .append(" IN EFI_PEI_STARTUP_DESCRIPTOR *PeiStartupDescriptor,\r\n");
774 .append(" IN VOID *OldCoreData\r\n");
775 fileBuffer
.append(" )\r\n\r\n");
776 fileBuffer
.append("{\r\n");
777 fileBuffer
.append(" return ");
778 fileBuffer
.append(entryPointList
[0]);
779 fileBuffer
.append(" (PeiStartupDescriptor, OldCoreData);\r\n");
780 fileBuffer
.append("}\r\n\r\n");
784 case CommonDefinition
.ModuleTypeDxeCore
:
785 fileBuffer
.append("const UINT32 _gUefiDriverRevision = 0;\r\n");
786 if (entryPointList
== null || entryPointList
.length
!= 1) {
787 throw new BuildException(
788 "Module type = 'DXE_CORE', only have one module entry point!");
791 fileBuffer
.append("VOID\r\n");
792 fileBuffer
.append("EFIAPI\r\n");
793 fileBuffer
.append(entryPointList
[0]);
794 fileBuffer
.append(" (\n");
795 fileBuffer
.append(" IN VOID *HobStart\r\n");
796 fileBuffer
.append(" );\r\n\r\n");
798 fileBuffer
.append("VOID\r\n");
799 fileBuffer
.append("EFIAPI\r\n");
800 fileBuffer
.append("ProcessModuleEntryPointList (\r\n");
801 fileBuffer
.append(" IN VOID *HobStart\r\n");
802 fileBuffer
.append(" )\r\n\r\n");
803 fileBuffer
.append("{\r\n");
804 fileBuffer
.append(" ");
805 fileBuffer
.append(entryPointList
[0]);
806 fileBuffer
.append(" (HobStart);\r\n");
807 fileBuffer
.append("}\r\n\r\n");
811 case CommonDefinition
.ModuleTypePeim
:
812 int entryPointCount
= 0;
814 .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT32 _gPeimRevision = 0;\r\n");
815 if (entryPointList
== null || entryPointList
.length
== 0) {
816 fileBuffer
.append("EFI_STATUS\r\n");
817 fileBuffer
.append("EFIAPI\r\n");
818 fileBuffer
.append("ProcessModuleEntryPointList (\r\n");
819 fileBuffer
.append(" IN EFI_FFS_FILE_HEADER *FfsHeader,\r\n");
820 fileBuffer
.append(" IN EFI_PEI_SERVICES **PeiServices\r\n");
821 fileBuffer
.append(" )\r\n\r\n");
822 fileBuffer
.append("{\r\n");
823 fileBuffer
.append(" return EFI_SUCCESS;\r\n");
824 fileBuffer
.append("}\r\n\r\n");
827 for (int i
= 0; i
< entryPointList
.length
; i
++) {
828 fileBuffer
.append("EFI_STATUS\r\n");
829 fileBuffer
.append("EFIAPI\r\n");
830 fileBuffer
.append(entryPointList
[i
]);
831 fileBuffer
.append(" (\r\n");
833 .append(" IN EFI_FFS_FILE_HEADER *FfsHeader,\r\n");
835 .append(" IN EFI_PEI_SERVICES **PeiServices\r\n");
836 fileBuffer
.append(" );\r\n");
841 fileBuffer
.append("EFI_STATUS\r\n");
842 fileBuffer
.append("EFIAPI\r\n");
843 fileBuffer
.append("ProcessModuleEntryPointList (\r\n");
844 fileBuffer
.append(" IN EFI_FFS_FILE_HEADER *FfsHeader,\r\n");
845 fileBuffer
.append(" IN EFI_PEI_SERVICES **PeiServices\r\n");
846 fileBuffer
.append(" )\r\n\r\n");
847 fileBuffer
.append("{\r\n");
848 if (entryPointCount
== 1) {
849 fileBuffer
.append(" return ");
850 fileBuffer
.append(entryPointList
[0]);
851 fileBuffer
.append(" (FfsHeader, PeiServices);\r\n");
853 fileBuffer
.append(" EFI_STATUS Status;\r\n");
854 fileBuffer
.append(" EFI_STATUS CombinedStatus;\r\n\r\n");
855 fileBuffer
.append(" CombinedStatus = EFI_LOAD_ERROR;\r\n\r\n");
856 for (int i
= 0; i
< entryPointList
.length
; i
++) {
857 if (!entryPointList
[i
].equals("")) {
858 fileBuffer
.append(" Status = ");
859 fileBuffer
.append(entryPointList
[i
]);
860 fileBuffer
.append(" (FfsHeader, PeiServices);\r\n");
862 .append(" if (!EFI_ERROR (Status) || EFI_ERROR (CombinedStatus)) {\r\n");
863 fileBuffer
.append(" CombinedStatus = Status;\r\n");
864 fileBuffer
.append(" }\r\n\r\n");
869 fileBuffer
.append(" return CombinedStatus;\r\n");
871 fileBuffer
.append("}\r\n\r\n");
874 case CommonDefinition
.ModuleTypeDxeSmmDriver
:
877 // If entryPoint is null, create an empty ProcessModuleEntryPointList
880 if (entryPointList
== null || entryPointList
.length
== 0){
882 .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gDriverEntryPointCount = ");
883 fileBuffer
.append(Integer
.toString(entryPointCount
));
884 fileBuffer
.append(";\r\n");
885 fileBuffer
.append("EFI_STATUS\r\n");
886 fileBuffer
.append("EFIAPI\r\n");
887 fileBuffer
.append("ProcessModuleEntryPointList (\r\n");
888 fileBuffer
.append(" IN EFI_HANDLE ImageHandle,\r\n");
889 fileBuffer
.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");
890 fileBuffer
.append(" )\r\n\r\n");
891 fileBuffer
.append("{\r\n");
892 fileBuffer
.append(" return EFI_SUCCESS;\r\n");
893 fileBuffer
.append("}\r\n\r\n");
896 for (int i
= 0; i
< entryPointList
.length
; i
++) {
897 fileBuffer
.append("EFI_STATUS\r\n");
898 fileBuffer
.append("EFIAPI\r\n");
899 fileBuffer
.append(entryPointList
[i
]);
900 fileBuffer
.append(" (\r\n");
901 fileBuffer
.append(" IN EFI_HANDLE ImageHandle,\r\n");
902 fileBuffer
.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");
903 fileBuffer
.append(" );\r\n");
907 .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gDriverEntryPointCount = ");
908 fileBuffer
.append(Integer
.toString(entryPointCount
));
909 fileBuffer
.append(";\r\n");
911 .append("static BASE_LIBRARY_JUMP_BUFFER mJumpContext;\r\n");
913 .append("static EFI_STATUS mDriverEntryPointStatus = EFI_LOAD_ERROR;\r\n\r\n");
915 fileBuffer
.append("EFI_STATUS\r\n");
916 fileBuffer
.append("EFIAPI\r\n");
917 fileBuffer
.append("ProcessModuleEntryPointList (\r\n");
918 fileBuffer
.append(" IN EFI_HANDLE ImageHandle,\r\n");
919 fileBuffer
.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");
920 fileBuffer
.append(" )\r\n\r\n");
921 fileBuffer
.append("{\r\n");
924 for (int i
= 0; i
< entryPointList
.length
; i
++) {
926 .append(" if (SetJump (&mJumpContext) == 0) {\r\n");
927 fileBuffer
.append(" ExitDriver (");
928 fileBuffer
.append(entryPointList
[i
]);
929 fileBuffer
.append(" (ImageHandle, SystemTable));\r\n");
930 fileBuffer
.append(" ASSERT (FALSE);\r\n");
931 fileBuffer
.append(" }\r\n");
934 fileBuffer
.append(" return mDriverEntryPointStatus;\r\n");
935 fileBuffer
.append("}\r\n\r\n");
937 fileBuffer
.append("VOID\r\n");
938 fileBuffer
.append("EFIAPI\r\n");
939 fileBuffer
.append("ExitDriver (\r\n");
940 fileBuffer
.append(" IN EFI_STATUS Status\n");
941 fileBuffer
.append(" )\r\n\r\n");
942 fileBuffer
.append("{\r\n");
944 .append(" if (!EFI_ERROR (Status) || EFI_ERROR (mDriverEntryPointStatus)) {\r\n");
945 fileBuffer
.append(" mDriverEntryPointStatus = Status;\r\n");
946 fileBuffer
.append(" }\r\n");
947 fileBuffer
.append(" LongJump (&mJumpContext, (UINTN)-1);\r\n");
948 fileBuffer
.append(" ASSERT (FALSE);\r\n");
949 fileBuffer
.append("}\r\n\r\n");
955 // Add "ModuleUnloadImage" for DxeSmmDriver module type;
957 entryPointList
= SurfaceAreaQuery
.getModuleUnloadImageArray();
958 entryPointList
= CommonDefinition
.remDupString(entryPointList
);
961 if (entryPointList
!= null) {
962 for (int i
= 0; i
< entryPointList
.length
; i
++) {
963 fileBuffer
.append("EFI_STATUS\r\n");
964 fileBuffer
.append("EFIAPI\r\n");
965 fileBuffer
.append(entryPointList
[i
]);
966 fileBuffer
.append(" (\r\n");
968 .append(" IN EFI_HANDLE ImageHandle\r\n");
969 fileBuffer
.append(" );\r\n");
975 .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gDriverUnloadImageCount = ");
976 fileBuffer
.append(Integer
.toString(entryPointCount
));
977 fileBuffer
.append(";\r\n\r\n");
979 fileBuffer
.append("EFI_STATUS\r\n");
980 fileBuffer
.append("EFIAPI\r\n");
981 fileBuffer
.append("ProcessModuleUnloadList (\r\n");
982 fileBuffer
.append(" IN EFI_HANDLE ImageHandle\r\n");
983 fileBuffer
.append(" )\r\n");
984 fileBuffer
.append("{\r\n");
986 if (entryPointCount
== 0) {
987 fileBuffer
.append(" return EFI_SUCCESS;\r\n");
988 } else if (entryPointCount
== 1) {
989 fileBuffer
.append(" return ");
990 fileBuffer
.append(entryPointList
[0]);
991 fileBuffer
.append("(ImageHandle);\r\n");
993 fileBuffer
.append(" EFI_STATUS Status;\r\n\r\n");
994 fileBuffer
.append(" Status = EFI_SUCCESS;\r\n\r\n");
995 for (int i
= 0; i
< entryPointList
.length
; i
++) {
997 fileBuffer
.append(" Status = ");
998 fileBuffer
.append(entryPointList
[i
]);
999 fileBuffer
.append("(ImageHandle);\r\n");
1001 fileBuffer
.append(" if (EFI_ERROR (Status)) {\r\n");
1002 fileBuffer
.append(" ");
1003 fileBuffer
.append(entryPointList
[i
]);
1004 fileBuffer
.append("(ImageHandle);\r\n");
1005 fileBuffer
.append(" } else {\r\n");
1006 fileBuffer
.append(" Status = ");
1007 fileBuffer
.append(entryPointList
[i
]);
1008 fileBuffer
.append("(ImageHandle);\r\n");
1009 fileBuffer
.append(" }\r\n");
1012 fileBuffer
.append(" return Status;\r\n");
1014 fileBuffer
.append("}\r\n\r\n");
1017 case CommonDefinition
.ModuleTypeDxeRuntimeDriver
:
1018 case CommonDefinition
.ModuleTypeDxeDriver
:
1019 case CommonDefinition
.ModuleTypeDxeSalDriver
:
1020 case CommonDefinition
.ModuleTypeUefiDriver
:
1021 case CommonDefinition
.ModuleTypeUefiApplication
:
1022 entryPointCount
= 0;
1023 fileBuffer
.append("const UINT32 _gUefiDriverRevision = 0;\r\n");
1025 // If entry point is null, create a empty ProcessModuleEntryPointList function.
1027 if (entryPointList
== null || entryPointList
.length
== 0){
1029 .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gDriverEntryPointCount = 0;\r\n");
1030 fileBuffer
.append("EFI_STATUS\r\n");
1031 fileBuffer
.append("EFIAPI\r\n");
1032 fileBuffer
.append("ProcessModuleEntryPointList (\r\n");
1033 fileBuffer
.append(" IN EFI_HANDLE ImageHandle,\r\n");
1034 fileBuffer
.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");
1035 fileBuffer
.append(" )\r\n\r\n");
1036 fileBuffer
.append("{\r\n");
1037 fileBuffer
.append(" return EFI_SUCCESS;\r\n");
1038 fileBuffer
.append("}\r\n");
1041 for (int i
= 0; i
< entryPointList
.length
; i
++) {
1043 fileBuffer
.append("EFI_STATUS\r\n");
1044 fileBuffer
.append("EFIAPI\r\n");
1045 fileBuffer
.append(entryPointList
[i
]);
1046 fileBuffer
.append(" (\r\n");
1047 fileBuffer
.append(" IN EFI_HANDLE ImageHandle,\r\n");
1048 fileBuffer
.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");
1049 fileBuffer
.append(" );\r\n");
1054 .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gDriverEntryPointCount = ");
1055 fileBuffer
.append(Integer
.toString(entryPointCount
));
1056 fileBuffer
.append(";\r\n");
1057 if (entryPointCount
> 1) {
1059 .append("static BASE_LIBRARY_JUMP_BUFFER mJumpContext;\r\n");
1061 .append("static EFI_STATUS mDriverEntryPointStatus = EFI_LOAD_ERROR;\r\n");
1063 fileBuffer
.append("\n");
1065 fileBuffer
.append("EFI_STATUS\r\n");
1066 fileBuffer
.append("EFIAPI\r\n");
1067 fileBuffer
.append("ProcessModuleEntryPointList (\r\n");
1068 fileBuffer
.append(" IN EFI_HANDLE ImageHandle,\r\n");
1069 fileBuffer
.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");
1070 fileBuffer
.append(" )\r\n\r\n");
1071 fileBuffer
.append("{\r\n");
1073 if (entryPointCount
== 1) {
1074 fileBuffer
.append(" return (");
1075 fileBuffer
.append(entryPointList
[0]);
1076 fileBuffer
.append(" (ImageHandle, SystemTable));\r\n");
1078 for (int i
= 0; i
< entryPointList
.length
; i
++) {
1079 if (!entryPointList
[i
].equals("")) {
1081 .append(" if (SetJump (&mJumpContext) == 0) {\r\n");
1082 fileBuffer
.append(" ExitDriver (");
1083 fileBuffer
.append(entryPointList
[i
]);
1084 fileBuffer
.append(" (ImageHandle, SystemTable));\r\n");
1085 fileBuffer
.append(" ASSERT (FALSE);\r\n");
1086 fileBuffer
.append(" }\r\n");
1091 fileBuffer
.append(" return mDriverEntryPointStatus;\r\n");
1093 fileBuffer
.append("}\r\n\r\n");
1095 fileBuffer
.append("VOID\n");
1096 fileBuffer
.append("EFIAPI\n");
1097 fileBuffer
.append("ExitDriver (\r\n");
1098 fileBuffer
.append(" IN EFI_STATUS Status\n");
1099 fileBuffer
.append(" )\r\n\r\n");
1100 fileBuffer
.append("{\r\n");
1101 if (entryPointCount
<= 1) {
1102 fileBuffer
.append(" if (EFI_ERROR (Status)) {\r\n");
1104 .append(" ProcessLibraryDestructorList (gImageHandle, gST);\r\n");
1105 fileBuffer
.append(" }\r\n");
1107 .append(" gBS->Exit (gImageHandle, Status, 0, NULL);\r\n");
1110 .append(" if (!EFI_ERROR (Status) || EFI_ERROR (mDriverEntryPointStatus)) {\r\n");
1111 fileBuffer
.append(" mDriverEntryPointStatus = Status;\r\n");
1112 fileBuffer
.append(" }\r\n");
1113 fileBuffer
.append(" LongJump (&mJumpContext, (UINTN)-1);\r\n");
1114 fileBuffer
.append(" ASSERT (FALSE);\r\n");
1116 fileBuffer
.append("}\r\n\r\n");
1121 // Add ModuleUnloadImage for DxeDriver and UefiDriver module type.
1123 entryPointList
= SurfaceAreaQuery
.getModuleUnloadImageArray();
1125 // Remover duplicate unload entry point.
1127 entryPointList
= CommonDefinition
.remDupString(entryPointList
);
1128 entryPointCount
= 0;
1129 if (entryPointList
!= null) {
1130 for (int i
= 0; i
< entryPointList
.length
; i
++) {
1131 fileBuffer
.append("EFI_STATUS\r\n");
1132 fileBuffer
.append("EFIAPI\r\n");
1133 fileBuffer
.append(entryPointList
[i
]);
1134 fileBuffer
.append(" (\r\n");
1136 .append(" IN EFI_HANDLE ImageHandle\r\n");
1137 fileBuffer
.append(" );\r\n");
1143 .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gDriverUnloadImageCount = ");
1144 fileBuffer
.append(Integer
.toString(entryPointCount
));
1145 fileBuffer
.append(";\r\n\r\n");
1147 fileBuffer
.append("EFI_STATUS\n");
1148 fileBuffer
.append("EFIAPI\r\n");
1149 fileBuffer
.append("ProcessModuleUnloadList (\r\n");
1150 fileBuffer
.append(" IN EFI_HANDLE ImageHandle\r\n");
1151 fileBuffer
.append(" )\r\n");
1152 fileBuffer
.append("{\r\n");
1154 if (entryPointCount
== 0) {
1155 fileBuffer
.append(" return EFI_SUCCESS;\r\n");
1156 } else if (entryPointCount
== 1) {
1157 fileBuffer
.append(" return ");
1158 fileBuffer
.append(entryPointList
[0]);
1159 fileBuffer
.append("(ImageHandle);\r\n");
1161 fileBuffer
.append(" EFI_STATUS Status;\r\n\r\n");
1162 fileBuffer
.append(" Status = EFI_SUCCESS;\r\n\r\n");
1163 for (int i
= 0; i
< entryPointList
.length
; i
++) {
1165 fileBuffer
.append(" Status = ");
1166 fileBuffer
.append(entryPointList
[i
]);
1167 fileBuffer
.append("(ImageHandle);\r\n");
1169 fileBuffer
.append(" if (EFI_ERROR (Status)) {\r\n");
1170 fileBuffer
.append(" ");
1171 fileBuffer
.append(entryPointList
[i
]);
1172 fileBuffer
.append("(ImageHandle);\r\n");
1173 fileBuffer
.append(" } else {\r\n");
1174 fileBuffer
.append(" Status = ");
1175 fileBuffer
.append(entryPointList
[i
]);
1176 fileBuffer
.append("(ImageHandle);\r\n");
1177 fileBuffer
.append(" }\r\n");
1180 fileBuffer
.append(" return Status;\r\n");
1182 fileBuffer
.append("}\r\n\r\n");
1190 * This function gets GUIDs from SPD file accrodeing to <PPIs> information
1191 * and write those GUIDs to AutoGen.c.
1194 * String Buffer for Autogen.c file.
1195 * @throws BuildException
1196 * Guid must set value!
1198 void PpiGuidToAutogenC(StringBuffer fileBuffer
) throws AutoGenException
{
1199 String
[] cNameGuid
= null;
1202 // Get the all PPI adn PPI Notify from MSA file,
1203 // then add those PPI ,and PPI Notify name to list.
1206 String
[] ppiList
= SurfaceAreaQuery
.getPpiArray(this.arch
);
1207 for (int i
= 0; i
< ppiList
.length
; i
++) {
1208 this.mPpiList
.add(ppiList
[i
]);
1211 String
[] ppiNotifyList
= SurfaceAreaQuery
.getPpiNotifyArray(this.arch
);
1212 for (int i
= 0; i
< ppiNotifyList
.length
; i
++) {
1213 this.mPpiList
.add(ppiNotifyList
[i
]);
1217 // Find CNAME and GUID from dependence SPD file and write to Autogen.c
1219 Iterator ppiIterator
= this.mPpiList
.iterator();
1220 String ppiKeyWord
= null;
1221 while (ppiIterator
.hasNext()) {
1222 ppiKeyWord
= ppiIterator
.next().toString();
1223 cNameGuid
= GlobalData
.getPpiGuid(this.mDepPkgList
, ppiKeyWord
);
1224 if (cNameGuid
!= null) {
1226 .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID ");
1227 fileBuffer
.append(cNameGuid
[0]);
1228 fileBuffer
.append(" = { ");
1229 fileBuffer
.append(CommonDefinition
.formatGuidName(cNameGuid
[1]));
1230 fileBuffer
.append(" } ;");
1233 // If can't find Ppi GUID declaration in every package
1235 throw new AutoGenException("Can not find Ppi GUID ["
1236 + ppiKeyWord
+ "] declaration in every packages. ");
1242 * ProtocolGuidToAutogenc
1244 * This function gets GUIDs from SPD file accrodeing to <Protocol>
1245 * information and write those GUIDs to AutoGen.c.
1248 * String Buffer for Autogen.c file.
1249 * @throws BuildException
1250 * Protocol name must set.
1252 void ProtocolGuidToAutogenC(StringBuffer fileBuffer
) throws BuildException
{
1253 String
[] cNameGuid
= null;
1255 String
[] protocolList
= SurfaceAreaQuery
.getProtocolArray(this.arch
);
1258 // Add result to Autogen global list.
1260 for (int i
= 0; i
< protocolList
.length
; i
++) {
1261 this.mProtocolList
.add(protocolList
[i
]);
1264 String
[] protocolNotifyList
= SurfaceAreaQuery
1265 .getProtocolNotifyArray(this.arch
);
1267 for (int i
= 0; i
< protocolNotifyList
.length
; i
++) {
1268 this.mProtocolList
.add(protocolNotifyList
[i
]);
1272 // Get the NAME and GUID from dependence SPD and write to Autogen.c
1274 Iterator protocolIterator
= this.mProtocolList
.iterator();
1275 String protocolKeyWord
= null;
1278 while (protocolIterator
.hasNext()) {
1279 protocolKeyWord
= protocolIterator
.next().toString();
1280 cNameGuid
= GlobalData
.getProtocolGuid(this.mDepPkgList
, protocolKeyWord
);
1281 if (cNameGuid
!= null) {
1283 .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID ");
1284 fileBuffer
.append(cNameGuid
[0]);
1285 fileBuffer
.append(" = { ");
1286 fileBuffer
.append(CommonDefinition
.formatGuidName(cNameGuid
[1]));
1287 fileBuffer
.append(" } ;");
1290 // If can't find protocol GUID declaration in every package
1292 throw new BuildException("Can not find protocol Guid ["
1293 + protocolKeyWord
+ "] declaration in every packages. ");
1299 * GuidGuidToAutogenc
1301 * This function gets GUIDs from SPD file accrodeing to <Guids> information
1302 * and write those GUIDs to AutoGen.c.
1305 * String Buffer for Autogen.c file.
1308 void GuidGuidToAutogenC(StringBuffer fileBuffer
) throws AutoGenException
{
1309 String
[] cNameGuid
= null;
1310 String guidKeyWord
= null;
1312 String
[] guidList
= SurfaceAreaQuery
.getGuidEntryArray(this.arch
);
1314 for (int i
= 0; i
< guidList
.length
; i
++) {
1315 this.mGuidList
.add(guidList
[i
]);
1319 Iterator guidIterator
= this.mGuidList
.iterator();
1320 while (guidIterator
.hasNext()) {
1321 guidKeyWord
= guidIterator
.next().toString();
1322 cNameGuid
= GlobalData
.getGuid(this.mDepPkgList
, guidKeyWord
);
1324 if (cNameGuid
!= null) {
1326 .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID ");
1327 fileBuffer
.append(cNameGuid
[0]);
1328 fileBuffer
.append(" = { ");
1329 fileBuffer
.append(CommonDefinition
.formatGuidName(cNameGuid
[1]));
1330 fileBuffer
.append("} ;");
1333 // If can't find GUID declaration in every package
1335 throw new AutoGenException("Can not find Guid [" + guidKeyWord
1336 + "] declaration in every packages. ");
1343 * LibInstanceToAutogenC
1345 * This function adds dependent library instance to autogen.c,which
1346 * includeing library's constructor, destructor, and library dependent ppi,
1347 * protocol, guid, pcd information.
1350 * String buffer for AutoGen.c
1351 * @throws BuildException
1353 void LibInstanceToAutogenC(StringBuffer fileBuffer
) throws BuildException
{
1356 String moduleType
= SurfaceAreaQuery
.getModuleType();
1357 List
<String
> libConstructList
= new ArrayList
<String
>();
1358 List
<String
> libDestructList
= new ArrayList
<String
>();
1360 String libConstructName
= null;
1361 String libDestructName
= null;
1362 ModuleIdentification
[] libraryIdList
= SurfaceAreaQuery
1363 .getLibraryInstance(this.arch
);
1366 if (libraryIdList
!= null) {
1368 // Reorder library instance sequence.
1370 AutogenLibOrder libOrder
= new AutogenLibOrder(libraryIdList
,
1372 List
<ModuleIdentification
> orderList
= libOrder
1373 .orderLibInstance();
1375 if (orderList
!= null) {
1377 // Process library instance one by one.
1379 for (int i
= 0; i
< orderList
.size(); i
++) {
1382 // Get library instance basename.
1384 ModuleIdentification libInstanceId
= orderList
.get(i
);
1390 Map
<String
, XmlObject
> libDoc
= GlobalData
.getDoc(
1391 libInstanceId
, this.arch
);
1392 SurfaceAreaQuery
.push(libDoc
);
1395 // Get <PPis>, <Protocols>, <Guids> list of this library
1398 String
[] ppiList
= SurfaceAreaQuery
.getPpiArray(this.arch
);
1399 String
[] ppiNotifyList
= SurfaceAreaQuery
1400 .getPpiNotifyArray(this.arch
);
1401 String
[] protocolList
= SurfaceAreaQuery
1402 .getProtocolArray(this.arch
);
1403 String
[] protocolNotifyList
= SurfaceAreaQuery
1404 .getProtocolNotifyArray(this.arch
);
1405 String
[] guidList
= SurfaceAreaQuery
1406 .getGuidEntryArray(this.arch
);
1407 PackageIdentification
[] pkgList
= SurfaceAreaQuery
.getDependencePkg(this.arch
);
1410 // Add those ppi, protocol, guid in global ppi,
1414 for (index
= 0; index
< ppiList
.length
; index
++) {
1415 this.mPpiList
.add(ppiList
[index
]);
1418 for (index
= 0; index
< ppiNotifyList
.length
; index
++) {
1419 this.mPpiList
.add(ppiNotifyList
[index
]);
1422 for (index
= 0; index
< protocolList
.length
; index
++) {
1423 this.mProtocolList
.add(protocolList
[index
]);
1426 for (index
= 0; index
< protocolNotifyList
.length
; index
++) {
1427 this.mProtocolList
.add(protocolNotifyList
[index
]);
1430 for (index
= 0; index
< guidList
.length
; index
++) {
1431 this.mGuidList
.add(guidList
[index
]);
1433 for (index
= 0; index
< pkgList
.length
; index
++){
1434 if (!this.mDepPkgList
.contains(pkgList
[index
])){
1435 this.mDepPkgList
.add(pkgList
[index
]);
1440 // If not yet parse this library instance's constructor
1441 // element,parse it.
1443 libConstructName
= SurfaceAreaQuery
1444 .getLibConstructorName();
1445 libDestructName
= SurfaceAreaQuery
1446 .getLibDestructorName();
1448 SurfaceAreaQuery
.pop();
1450 // Add dependent library instance constructor function.
1452 if (libConstructName
!= null) {
1453 libConstructList
.add(libConstructName
);
1456 // Add dependent library instance destructor fuction.
1458 if (libDestructName
!= null) {
1459 libDestructList
.add(libDestructName
);
1466 // Add library constructor to AutoGen.c
1468 LibConstructorToAutogenC(libConstructList
, moduleType
,
1469 fileBuffer
/* autogenC */);
1471 // Add library destructor to AutoGen.c
1473 LibDestructorToAutogenC(libDestructList
, moduleType
, fileBuffer
/* autogenC */);
1476 } catch (Exception e
) {
1477 throw new BuildException(e
.getMessage());
1482 * LibConstructorToAutogenc
1484 * This function writes library constructor list to AutoGen.c. The library
1485 * constructor's parameter and return value depend on module type.
1487 * @param libInstanceList
1488 * List of library construct name.
1492 * String buffer for AutoGen.c
1495 void LibConstructorToAutogenC(List
<String
> libInstanceList
,
1496 String moduleType
, StringBuffer fileBuffer
) throws Exception
{
1497 boolean isFirst
= true;
1500 // The library constructor's parameter and return value depend on
1503 for (int i
= 0; i
< libInstanceList
.size(); i
++) {
1504 switch (CommonDefinition
.getModuleType(moduleType
)) {
1505 case CommonDefinition
.ModuleTypeBase
:
1506 fileBuffer
.append("RETURN_STATUS\r\n");
1507 fileBuffer
.append(libInstanceList
.get(i
));
1508 fileBuffer
.append(" (\r\n");
1509 fileBuffer
.append(" VOID\r\n");
1510 fileBuffer
.append(" );\r\n");
1513 case CommonDefinition
.ModuleTypePeiCore
:
1514 case CommonDefinition
.ModuleTypePeim
:
1515 fileBuffer
.append("EFI_STATUS\r\n");
1516 fileBuffer
.append(libInstanceList
.get(i
));
1517 fileBuffer
.append(" (\r\n");
1519 .append(" IN EFI_FFS_FILE_HEADER *FfsHeader,\r\n");
1521 .append(" IN EFI_PEI_SERVICES **PeiServices\r\n");
1522 fileBuffer
.append(" );\r\n");
1525 case CommonDefinition
.ModuleTypeDxeCore
:
1526 case CommonDefinition
.ModuleTypeDxeDriver
:
1527 case CommonDefinition
.ModuleTypeDxeRuntimeDriver
:
1528 case CommonDefinition
.ModuleTypeDxeSmmDriver
:
1529 case CommonDefinition
.ModuleTypeDxeSalDriver
:
1530 case CommonDefinition
.ModuleTypeUefiDriver
:
1531 case CommonDefinition
.ModuleTypeUefiApplication
:
1532 fileBuffer
.append("EFI_STATUS\r\n");
1533 fileBuffer
.append(libInstanceList
.get(i
));
1534 fileBuffer
.append(" (\r\n");
1535 fileBuffer
.append(" IN EFI_HANDLE ImageHandle,\r\n");
1536 fileBuffer
.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");
1537 fileBuffer
.append(" );\r\n");
1543 // Add ProcessLibraryConstructorList in AutoGen.c
1545 fileBuffer
.append("VOID\r\n");
1546 fileBuffer
.append("ProcessLibraryConstructorList (\r\n");
1547 switch (CommonDefinition
.getModuleType(moduleType
)) {
1548 case CommonDefinition
.ModuleTypeBase
:
1549 fileBuffer
.append(" VOID\r\n");
1552 case CommonDefinition
.ModuleTypePeiCore
:
1553 case CommonDefinition
.ModuleTypePeim
:
1554 fileBuffer
.append(" IN EFI_FFS_FILE_HEADER *FfsHeader,\r\n");
1556 .append(" IN EFI_PEI_SERVICES **PeiServices\r\n");
1559 case CommonDefinition
.ModuleTypeDxeCore
:
1560 case CommonDefinition
.ModuleTypeDxeDriver
:
1561 case CommonDefinition
.ModuleTypeDxeRuntimeDriver
:
1562 case CommonDefinition
.ModuleTypeDxeSmmDriver
:
1563 case CommonDefinition
.ModuleTypeDxeSalDriver
:
1564 case CommonDefinition
.ModuleTypeUefiDriver
:
1565 case CommonDefinition
.ModuleTypeUefiApplication
:
1566 fileBuffer
.append(" IN EFI_HANDLE ImageHandle,\r\n");
1567 fileBuffer
.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");
1571 fileBuffer
.append(" )\r\n");
1572 fileBuffer
.append("{\r\n");
1574 // If no constructor function, return EFI_SUCCESS.
1576 //if (libInstanceList.size() == 0){
1577 // fileBuffer.append(" return EFI_SUCCESS;\r\n");
1579 for (int i
= 0; i
< libInstanceList
.size(); i
++) {
1581 fileBuffer
.append(" EFI_STATUS Status;\r\n");
1582 fileBuffer
.append(" Status = EFI_SUCCESS;\r\n");
1583 fileBuffer
.append("\r\n");
1586 switch (CommonDefinition
.getModuleType(moduleType
)) {
1587 case CommonDefinition
.ModuleTypeBase
:
1588 fileBuffer
.append(" Status = ");
1589 fileBuffer
.append(libInstanceList
.get(i
));
1590 fileBuffer
.append("();\r\n");
1591 fileBuffer
.append(" VOID\r\n");
1593 case CommonDefinition
.ModuleTypePeiCore
:
1594 case CommonDefinition
.ModuleTypePeim
:
1595 fileBuffer
.append(" Status = ");
1596 fileBuffer
.append(libInstanceList
.get(i
));
1597 fileBuffer
.append(" (FfsHeader, PeiServices);\r\n");
1599 case CommonDefinition
.ModuleTypeDxeCore
:
1600 case CommonDefinition
.ModuleTypeDxeDriver
:
1601 case CommonDefinition
.ModuleTypeDxeRuntimeDriver
:
1602 case CommonDefinition
.ModuleTypeDxeSmmDriver
:
1603 case CommonDefinition
.ModuleTypeDxeSalDriver
:
1604 case CommonDefinition
.ModuleTypeUefiDriver
:
1605 case CommonDefinition
.ModuleTypeUefiApplication
:
1606 fileBuffer
.append(" Status = ");
1607 fileBuffer
.append(libInstanceList
.get(i
));
1608 fileBuffer
.append(" (ImageHandle, SystemTable);\r\n");
1611 EdkLog
.log(EdkLog
.EDK_INFO
,"Autogen don't know how to deal with module type -"+ moduleType
+ " !");
1613 fileBuffer
.append(" ASSERT_EFI_ERROR (Status);\r\n");
1615 fileBuffer
.append("}\r\n");
1619 * LibDestructorToAutogenc
1621 * This function writes library destructor list to AutoGen.c. The library
1622 * destructor's parameter and return value depend on module type.
1624 * @param libInstanceList
1625 * List of library destructor name.
1629 * String buffer for AutoGen.c
1632 void LibDestructorToAutogenC(List
<String
> libInstanceList
,
1633 String moduleType
, StringBuffer fileBuffer
) throws Exception
{
1634 boolean isFirst
= true;
1635 for (int i
= 0; i
< libInstanceList
.size(); i
++) {
1636 switch (CommonDefinition
.getModuleType(moduleType
)) {
1637 case CommonDefinition
.ModuleTypeBase
:
1638 fileBuffer
.append("RETURN_STATUS\n");
1639 fileBuffer
.append(libInstanceList
.get(i
));
1640 fileBuffer
.append(" (\r\n");
1641 fileBuffer
.append(" VOID\r\n");
1642 fileBuffer
.append(" );\r\n");
1644 case CommonDefinition
.ModuleTypePeiCore
:
1645 case CommonDefinition
.ModuleTypePeim
:
1646 fileBuffer
.append("EFI_STATUS\r\n");
1647 fileBuffer
.append(libInstanceList
.get(i
));
1648 fileBuffer
.append(" (\r\n");
1650 .append(" IN EFI_FFS_FILE_HEADER *FfsHeader,\r\n");
1652 .append(" IN EFI_PEI_SERVICES **PeiServices\r\n");
1653 fileBuffer
.append(" );\r\n");
1655 case CommonDefinition
.ModuleTypeDxeCore
:
1656 case CommonDefinition
.ModuleTypeDxeDriver
:
1657 case CommonDefinition
.ModuleTypeDxeRuntimeDriver
:
1658 case CommonDefinition
.ModuleTypeDxeSmmDriver
:
1659 case CommonDefinition
.ModuleTypeDxeSalDriver
:
1660 case CommonDefinition
.ModuleTypeUefiDriver
:
1661 case CommonDefinition
.ModuleTypeUefiApplication
:
1662 fileBuffer
.append("EFI_STATUS\r\n");
1663 fileBuffer
.append(libInstanceList
.get(i
));
1664 fileBuffer
.append(" (\r\n");
1665 fileBuffer
.append(" IN EFI_HANDLE ImageHandle,\r\n");
1666 fileBuffer
.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");
1667 fileBuffer
.append(" );\r\n");
1673 // Write ProcessLibraryDestructor list to autogen.c
1675 switch (CommonDefinition
.getModuleType(moduleType
)) {
1676 case CommonDefinition
.ModuleTypeBase
:
1677 case CommonDefinition
.ModuleTypePeiCore
:
1678 case CommonDefinition
.ModuleTypePeim
:
1680 case CommonDefinition
.ModuleTypeDxeCore
:
1681 case CommonDefinition
.ModuleTypeDxeDriver
:
1682 case CommonDefinition
.ModuleTypeDxeRuntimeDriver
:
1683 case CommonDefinition
.ModuleTypeDxeSmmDriver
:
1684 case CommonDefinition
.ModuleTypeDxeSalDriver
:
1685 case CommonDefinition
.ModuleTypeUefiDriver
:
1686 case CommonDefinition
.ModuleTypeUefiApplication
:
1687 fileBuffer
.append("VOID\r\n");
1688 fileBuffer
.append("ProcessLibraryDestructorList (\r\n");
1689 fileBuffer
.append(" IN EFI_HANDLE ImageHandle,\r\n");
1690 fileBuffer
.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");
1691 fileBuffer
.append(" )\r\n");
1692 fileBuffer
.append("{\r\n");
1694 // If no library destructor function, return EFI_SUCCESS.
1697 for (int i
= 0; i
< libInstanceList
.size(); i
++) {
1699 fileBuffer
.append(" EFI_STATUS Status;\r\n");
1700 fileBuffer
.append(" Status = EFI_SUCCESS;\r\n");
1701 fileBuffer
.append("\r\n");
1704 fileBuffer
.append(" Status = ");
1705 fileBuffer
.append(libInstanceList
.get(i
));
1706 fileBuffer
.append("(ImageHandle, SystemTable);\r\n");
1707 fileBuffer
.append(" ASSERT_EFI_ERROR (Status);\r\n");
1709 fileBuffer
.append("}\r\n");
1715 * ExternsDriverBindingToAutoGenC
1717 * This function is to write DRIVER_BINDING, COMPONENT_NAME,
1718 * DRIVER_CONFIGURATION, DRIVER_DIAGNOSTIC in AutoGen.c.
1721 * String buffer for AutoGen.c
1723 void ExternsDriverBindingToAutoGenC(StringBuffer fileBuffer
)
1724 throws BuildException
{
1727 // Check what <extern> contains. And the number of following elements
1728 // under <extern> should be same. 1. DRIVER_BINDING 2. COMPONENT_NAME
1729 // 3.DRIVER_CONFIGURATION 4. DRIVER_DIAGNOSTIC
1732 String
[] drvBindList
= SurfaceAreaQuery
.getDriverBindingArray();
1735 // If component name protocol,component configuration protocol,
1736 // component diagnostic protocol is not null or empty, check
1737 // if every one have the same number of the driver binding protocol.
1739 if (drvBindList
== null || drvBindList
.length
== 0) {
1743 String
[] compNamList
= SurfaceAreaQuery
.getComponentNameArray();
1744 String
[] compConfList
= SurfaceAreaQuery
.getDriverConfigArray();
1745 String
[] compDiagList
= SurfaceAreaQuery
.getDriverDiagArray();
1750 // Write driver binding protocol extern to autogen.c
1752 for (int i
= 0; i
< drvBindList
.length
; i
++) {
1753 fileBuffer
.append("extern EFI_DRIVER_BINDING_PROTOCOL ");
1754 fileBuffer
.append(drvBindList
[i
]);
1755 fileBuffer
.append(";\r\n");
1759 // Write component name protocol extern to autogen.c
1761 if (compNamList
!= null && compNamList
.length
!= 0) {
1762 if (drvBindList
.length
!= compNamList
.length
) {
1763 throw new BuildException(
1764 "Different number of Driver Binding and Component Name protocols!");
1768 for (int i
= 0; i
< compNamList
.length
; i
++) {
1769 fileBuffer
.append("extern EFI_COMPONENT_NAME_PROTOCOL ");
1770 fileBuffer
.append(compNamList
[i
]);
1771 fileBuffer
.append(";\r\n");
1776 // Write driver configration protocol extern to autogen.c
1778 if (compConfList
!= null && compConfList
.length
!= 0) {
1779 if (drvBindList
.length
!= compConfList
.length
) {
1780 throw new BuildException(
1781 "Different number of Driver Binding and Driver Configuration protocols!");
1785 for (int i
= 0; i
< compConfList
.length
; i
++) {
1786 fileBuffer
.append("extern EFI_DRIVER_CONFIGURATION_PROTOCOL ");
1787 fileBuffer
.append(compConfList
[i
]);
1788 fileBuffer
.append(";\r\n");
1793 // Write driver dignastic protocol extern to autogen.c
1795 if (compDiagList
!= null && compDiagList
.length
!= 0) {
1796 if (drvBindList
.length
!= compDiagList
.length
) {
1797 throw new BuildException(
1798 "Different number of Driver Binding and Driver Diagnosis protocols!");
1802 for (int i
= 0; i
< compDiagList
.length
; i
++) {
1803 fileBuffer
.append("extern EFI_DRIVER_DIAGNOSTICS_PROTOCOL ");
1804 fileBuffer
.append(compDiagList
[i
]);
1805 fileBuffer
.append(";\r\n");
1810 // Write driver module protocol bitmask.
1813 .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gDriverModelProtocolBitmask = ");
1814 fileBuffer
.append(Integer
.toString(BitMask
));
1815 fileBuffer
.append(";\r\n");
1818 // Write driver module protocol list entry
1821 .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINTN _gDriverModelProtocolListEntries = ");
1823 fileBuffer
.append(Integer
.toString(drvBindList
.length
));
1824 fileBuffer
.append(";\r\n");
1827 // Write drive module protocol list to autogen.c
1830 .append("GLOBAL_REMOVE_IF_UNREFERENCED const EFI_DRIVER_MODEL_PROTOCOL_LIST _gDriverModelProtocolList[] = {");
1831 for (int i
= 0; i
< drvBindList
.length
; i
++) {
1833 fileBuffer
.append(",");
1835 fileBuffer
.append("\r\n {\r\n");
1836 fileBuffer
.append(" &");
1837 fileBuffer
.append(drvBindList
[i
]);
1838 fileBuffer
.append(", \r\n");
1840 if (compNamList
!= null) {
1841 fileBuffer
.append(" &");
1842 fileBuffer
.append(compNamList
[i
]);
1843 fileBuffer
.append(", \r\n");
1845 fileBuffer
.append(" NULL, \r\n");
1848 if (compConfList
!= null) {
1849 fileBuffer
.append(" &");
1850 fileBuffer
.append(compConfList
[i
]);
1851 fileBuffer
.append(", \r\n");
1853 fileBuffer
.append(" NULL, \r\n");
1856 if (compDiagList
!= null) {
1857 fileBuffer
.append(" &");
1858 fileBuffer
.append(compDiagList
[i
]);
1859 fileBuffer
.append(", \r\n");
1861 fileBuffer
.append(" NULL, \r\n");
1863 fileBuffer
.append(" }");
1865 fileBuffer
.append("\r\n};\r\n");
1869 * ExternCallBackToAutoGenC
1871 * This function adds <SetVirtualAddressMapCallBack> and
1872 * <ExitBootServicesCallBack> infomation to AutoGen.c
1875 * String buffer for AutoGen.c
1876 * @throws BuildException
1878 void ExternCallBackToAutoGenC(StringBuffer fileBuffer
)
1879 throws BuildException
{
1880 String
[] setVirtualList
= SurfaceAreaQuery
1881 .getSetVirtualAddressMapCallBackArray();
1882 String
[] exitBootList
= SurfaceAreaQuery
1883 .getExitBootServicesCallBackArray();
1884 String moduleType
= SurfaceAreaQuery
.getModuleType();
1885 boolean UefiOrDxeModule
= false;
1889 switch (CommonDefinition
.getModuleType(moduleType
)) {
1890 case CommonDefinition
.ModuleTypeDxeDriver
:
1891 case CommonDefinition
.ModuleTypeDxeRuntimeDriver
:
1892 case CommonDefinition
.ModuleTypeDxeSalDriver
:
1893 case CommonDefinition
.ModuleTypeUefiDriver
:
1894 case CommonDefinition
.ModuleTypeUefiApplication
:
1896 // Entry point lib for these module types needs to know the count
1899 UefiOrDxeModule
= true;
1901 .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED const UINTN _gDriverSetVirtualAddressMapEventCount = ");
1904 // If the list is not valid or has no entries set count to zero else
1905 // set count to the number of valid entries
1908 if (setVirtualList
!= null) {
1909 for (i
= 0; i
< setVirtualList
.length
; i
++) {
1910 if (setVirtualList
[i
].equalsIgnoreCase("")) {
1917 fileBuffer
.append(Integer
.toString(Count
));
1918 fileBuffer
.append(";\r\n\r\n");
1924 if (setVirtualList
== null) {
1925 if (UefiOrDxeModule
) {
1927 // No data so make a NULL list
1930 .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED const EFI_EVENT_NOTIFY _gDriverSetVirtualAddressMapEvent[] = {\r\n");
1931 fileBuffer
.append(" NULL\r\n");
1932 fileBuffer
.append("};\r\n\r\n");
1936 // Write SetVirtualAddressMap function definition.
1938 for (i
= 0; i
< setVirtualList
.length
; i
++) {
1939 if (setVirtualList
[i
].equalsIgnoreCase("")) {
1942 fileBuffer
.append("VOID\r\n");
1943 fileBuffer
.append("EFIAPI\r\n");
1944 fileBuffer
.append(setVirtualList
[i
]);
1945 fileBuffer
.append(" (\r\n");
1946 fileBuffer
.append(" IN EFI_EVENT Event,\r\n");
1947 fileBuffer
.append(" IN VOID *Context\r\n");
1948 fileBuffer
.append(" );\r\n\r\n");
1952 // Write SetVirtualAddressMap entry point array.
1955 .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED const EFI_EVENT_NOTIFY _gDriverSetVirtualAddressMapEvent[] = {");
1956 for (i
= 0; i
< setVirtualList
.length
; i
++) {
1957 if (setVirtualList
[i
].equalsIgnoreCase("")) {
1962 fileBuffer
.append("\r\n ");
1964 fileBuffer
.append(",\r\n ");
1967 fileBuffer
.append(setVirtualList
[i
]);
1970 // If module is not DXE_DRIVER, DXE_RUNTIME_DIRVER, UEFI_DRIVER
1971 // UEFI_APPLICATION and DXE_SAL_DRIVER add the NULL at the end of
1972 // _gDriverSetVirtualAddressMapEvent list.
1974 if (!UefiOrDxeModule
) {
1975 fileBuffer
.append(",\r\n NULL");
1977 fileBuffer
.append("\r\n};\r\n\r\n");
1980 if (UefiOrDxeModule
) {
1982 // Entry point lib for these module types needs to know the count.
1985 .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED const UINTN _gDriverExitBootServicesEventCount = ");
1988 // If the list is not valid or has no entries set count to zero else
1989 // set count to the number of valid entries.
1992 if (exitBootList
!= null) {
1993 if (setVirtualList
!= null) {
1994 for (i
= 0; i
< exitBootList
.length
; i
++) {
1995 if (exitBootList
[i
].equalsIgnoreCase("")) {
2002 fileBuffer
.append(Integer
.toString(Count
));
2003 fileBuffer
.append(";\r\n\r\n");
2006 if (exitBootList
== null) {
2007 if (UefiOrDxeModule
) {
2009 // No data so make a NULL list.
2012 .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED const EFI_EVENT_NOTIFY _gDriverExitBootServicesEvent[] = {\r\n");
2013 fileBuffer
.append(" NULL\r\n");
2014 fileBuffer
.append("};\r\n\r\n");
2018 // Write DriverExitBootServices function definition.
2020 for (i
= 0; i
< exitBootList
.length
; i
++) {
2021 if (exitBootList
[i
].equalsIgnoreCase("")) {
2025 fileBuffer
.append("VOID\r\n");
2026 fileBuffer
.append("EFIAPI\r\n");
2027 fileBuffer
.append(exitBootList
[i
]);
2028 fileBuffer
.append(" (\r\n");
2029 fileBuffer
.append(" IN EFI_EVENT Event,\r\n");
2030 fileBuffer
.append(" IN VOID *Context\r\n");
2031 fileBuffer
.append(" );\r\n\r\n");
2035 // Write DriverExitBootServices entry point array.
2038 .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED const EFI_EVENT_NOTIFY _gDriverExitBootServicesEvent[] = {");
2039 for (i
= 0; i
< exitBootList
.length
; i
++) {
2040 if (exitBootList
[i
].equalsIgnoreCase("")) {
2045 fileBuffer
.append("\r\n ");
2047 fileBuffer
.append(",\r\n ");
2049 fileBuffer
.append(exitBootList
[i
]);
2051 if (!UefiOrDxeModule
) {
2052 fileBuffer
.append(",\r\n NULL");
2054 fileBuffer
.append("\r\n};\r\n\r\n");
2059 private void copyFlashMapHToDebugDir() throws AutoGenException
{
2061 File inFile
= new File(fvDir
+ File
.separatorChar
+ CommonDefinition
.flashMapH
);
2062 int size
= (int)inFile
.length();
2063 byte[] buffer
= new byte[size
];
2064 File outFile
= new File (this.outputPath
+ File
.separatorChar
+ CommonDefinition
.tianoR8FlashMapH
);
2066 if (inFile
.exists()) {
2067 FileInputStream fis
= new FileInputStream (inFile
);
2069 FileOutputStream fos
= new FileOutputStream(outFile
);
2074 throw new AutoGenException("The flashMap.h file don't exist!!");
2076 } catch (Exception e
){
2077 throw new AutoGenException(e
.getMessage());