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
);
459 // Call pcd autogen. PCDAutoGenAction tool only need module name and
460 // isPcdEmulatedDriver as parameter. Library inherits PCD and module's
461 // PCD information has been collected in FPDParser task by
463 // Note : when PCD image tool ready,
464 // isPCDEmulatedDriver parameter will be removed.
467 // this.myPcdAutogen = new PCDAutoGenAction(moduleId.getName(),
468 // moduleId.getGuid(), moduleId.getPackage().getName(), moduleId.getPackage().getGuid(),this.arch,moduleId.getVersion(),false, null);
469 this.myPcdAutogen
= new PCDAutoGenAction(moduleId
.getName(),null,null,null, this.arch
,null,false, null);
470 this.myPcdAutogen
.execute();
471 } catch (Exception e
) {
472 throw new BuildException("PCD Autogen failed:" + e
.getMessage());
475 if (this.myPcdAutogen
!= null) {
476 fileBuffer
.append("\r\n");
477 fileBuffer
.append(this.myPcdAutogen
.OutputC());
480 if (!saveFile(outputPath
+ File
.separatorChar
+ "AutoGen.c", fileBuffer
)) {
481 throw new BuildException("Failed to generate AutoGen.c !!!");
489 * This function generates AutoGen.h for library.
491 * @throws BuildException
492 * Failed to generate AutoGen.c.
494 void libGenAutogenH() throws AutoGenException
{
496 Set
<String
> libClassIncludeH
;
498 List
<String
> headerFileList
;
500 StringBuffer fileBuffer
= new StringBuffer(10240);
503 // Write Autogen.h header notation
505 fileBuffer
.append(CommonDefinition
.autogenHNotation
);
508 // Add #ifndef ${BaseName}_AUTOGENH
509 // #def ${BseeName}_AUTOGENH
511 fileBuffer
.append("#ifndef " + "_AUTOGENH_" + this.moduleId
.getGuid().replaceAll("-", "_") + "\r\n");
512 fileBuffer
.append("#define " + "_AUTOGENH_" + this.moduleId
.getGuid().replaceAll("-", "_") + "\r\n\r\n");
515 // Write EFI_SPECIFICATION_VERSION and EDK_RELEASE_VERSION
516 // to autogen.h file.
517 // Note: the specification version and release version should
518 // be get from module surface area instead of hard code.
520 fileBuffer
.append(CommonDefinition
.autoGenHbegin
);
521 String
[] specList
= SurfaceAreaQuery
.getExternSpecificaiton();
522 for (int i
= 0; i
< specList
.length
; i
++) {
523 fileBuffer
.append(CommonDefinition
.marcDefineStr
+ specList
[i
]
526 // fileBuffer.append(CommonDefinition.autoGenHLine1);
527 // fileBuffer.append(CommonDefinition.autoGenHLine2);
530 // Write consumed package's mdouleInfo related *.h file to autogen.h.
532 moduleType
= SurfaceAreaQuery
.getModuleType();
533 PackageIdentification
[] cosumedPkglist
= SurfaceAreaQuery
534 .getDependencePkg(this.arch
);
535 headerFileList
= depPkgToAutogenH(cosumedPkglist
, moduleType
);
536 item
= headerFileList
.iterator();
537 while (item
.hasNext()) {
538 fileBuffer
.append(item
.next().toString());
541 // Write library class's related *.h file to autogen.h
543 String
[] libClassList
= SurfaceAreaQuery
544 .getLibraryClasses(CommonDefinition
.AlwaysConsumed
, this.arch
);
545 if (libClassList
!= null) {
546 libClassIncludeH
= LibraryClassToAutogenH(libClassList
);
547 item
= libClassIncludeH
.iterator();
548 while (item
.hasNext()) {
549 fileBuffer
.append(item
.next().toString());
553 libClassList
= SurfaceAreaQuery
554 .getLibraryClasses(CommonDefinition
.AlwaysProduced
, this.arch
);
555 if (libClassList
!= null) {
556 libClassIncludeH
= LibraryClassToAutogenH(libClassList
);
557 item
= libClassIncludeH
.iterator();
558 while (item
.hasNext()) {
559 fileBuffer
.append(item
.next().toString());
562 fileBuffer
.append("\r\n");
565 // If is TianoR8FlashMap, copy {Fv_DIR}/FlashMap.h to
566 // {DEST_DIR_DRBUG}/FlashMap.h
568 if (SurfaceAreaQuery
.isHaveTianoR8FlashMap()) {
569 fileBuffer
.append(CommonDefinition
.include
);
570 fileBuffer
.append(" <");
571 fileBuffer
.append(CommonDefinition
.tianoR8FlashMapH
+ ">\r\n");
572 copyFlashMapHToDebugDir();
576 // Write PCD information to library AutoGen.h.
578 if (this.myPcdAutogen
!= null) {
579 fileBuffer
.append("\r\n");
580 fileBuffer
.append(this.myPcdAutogen
.OutputH());
584 // Append the #endif at AutoGen.h
586 fileBuffer
.append("#endif\r\n");
589 // Save content of string buffer to AutoGen.h file.
591 if (!saveFile(outputPath
+ File
.separatorChar
+ "AutoGen.h", fileBuffer
)) {
592 throw new BuildException("Failed to generate AutoGen.h !!!");
599 * This function generates AutoGen.h for library.
601 * @throws BuildException
602 * Failed to generate AutoGen.c.
604 void libGenAutogenC() throws BuildException
{
605 StringBuffer fileBuffer
= new StringBuffer(10240);
608 // Write Autogen.c header notation
610 fileBuffer
.append(CommonDefinition
.autogenCNotation
);
612 fileBuffer
.append(CommonDefinition
.autoGenCLine1
);
613 fileBuffer
.append("\r\n");
616 // Call pcd autogen. PCDAutoGenAction tool only need module name and
617 // isPcdEmulatedDriver as parameter. Library inherit PCD and module's
618 // PCD information has been collected in FPDParser task by
620 // Note : when PCD image tool ready,
621 // isPCDEmulatedDriver parameter will be removed.
624 // this.myPcdAutogen = new PCDAutoGenAction(this.moduleId.getName(),
625 // this.moduleId.getGuid(),moduleId.getPackage().getName(),moduleId.getPackage().getGuid(), this.arch, moduleId.getVersion(),true, SurfaceAreaQuery.getModulePcdEntryNameArray());
626 this.myPcdAutogen
= new PCDAutoGenAction(this.moduleId
.getName(),
633 SurfaceAreaQuery
.getModulePcdEntryNameArray());
635 this.myPcdAutogen
.execute();
636 } catch (Exception e
) {
637 throw new BuildException(e
.getMessage());
640 if (this.myPcdAutogen
!= null) {
641 fileBuffer
.append("\r\n");
642 fileBuffer
.append(this.myPcdAutogen
.OutputC());
645 if (!saveFile(outputPath
+ File
.separatorChar
+ "AutoGen.c", fileBuffer
)) {
646 throw new BuildException("Failed to generate AutoGen.c !!!");
651 * LibraryClassToAutogenH
653 * This function returns *.h files declared by library classes which are
654 * consumed or produced by current build module or library.
656 * @param libClassList
657 * List of library class which consumed or produce by current
658 * build module or library.
659 * @return includeStrList List of *.h file.
661 Set
<String
> LibraryClassToAutogenH(String
[] libClassList
)
662 throws AutoGenException
{
663 Set
<String
> includStrList
= new LinkedHashSet
<String
>();
664 String includerName
[];
668 // Get include file from GlobalData's SPDTable according to
669 // library class name.
672 for (int i
= 0; i
< libClassList
.length
; i
++) {
673 includerName
= GlobalData
.getLibraryClassHeaderFiles(
674 SurfaceAreaQuery
.getDependencePkg(this.arch
),
676 if (includerName
== null) {
677 throw new AutoGenException("Can not find library class ["
678 + libClassList
[i
] + "] declaration in every packages. ");
680 for (int j
= 0; j
< includerName
.length
; j
++) {
681 String includeNameStr
= includerName
[j
];
682 if (includeNameStr
!= null) {
683 str
= CommonDefinition
.include
+ " " + "<";
684 str
= str
+ includeNameStr
+ ">\r\n";
685 includStrList
.add(str
);
686 includeNameStr
= null;
690 return includStrList
;
696 * This function add include file in AutoGen.h file.
698 * @param packageNameList
699 * List of module depended package.
704 List
<String
> depPkgToAutogenH(PackageIdentification
[] packageNameList
,
705 String moduleType
) throws AutoGenException
{
707 List
<String
> includeStrList
= new LinkedList
<String
>();
709 String includeStr
= "";
712 // Get include file from moduleInfo file
714 for (int i
= 0; i
< packageNameList
.length
; i
++) {
715 pkgHeader
= GlobalData
.getPackageHeaderFiles(packageNameList
[i
],
717 if (pkgHeader
== null) {
718 throw new AutoGenException("Can not find package ["
720 + "] declaration in every packages. ");
721 } else if (!pkgHeader
.equalsIgnoreCase("")) {
722 includeStr
= CommonDefinition
.include
+ " <" + pkgHeader
724 includeStrList
.add(includeStr
);
728 return includeStrList
;
732 * EntryPointToAutoGen
734 * This function convert <ModuleEntryPoint> & <ModuleUnloadImage>
735 * information in mas to AutoGen.c
737 * @param entryPointList
738 * List of entry point.
740 * String buffer fo AutoGen.c.
743 void EntryPointToAutoGen(String
[] entryPointList
, StringBuffer fileBuffer
)
744 throws BuildException
{
746 String typeStr
= SurfaceAreaQuery
.getModuleType();
749 // The parameters and return value of entryPoint is difference
750 // for difference module type.
752 switch (CommonDefinition
.getModuleType(typeStr
)) {
754 case CommonDefinition
.ModuleTypePeiCore
:
755 if (entryPointList
== null ||entryPointList
.length
!= 1 ) {
756 throw new BuildException(
757 "Module type = 'PEI_CORE', only have one module entry point!");
759 fileBuffer
.append("EFI_STATUS\r\n");
760 fileBuffer
.append("EFIAPI\r\n");
761 fileBuffer
.append(entryPointList
[0]);
762 fileBuffer
.append(" (\r\n");
764 .append(" IN EFI_PEI_STARTUP_DESCRIPTOR *PeiStartupDescriptor,\r\n");
766 .append(" IN VOID *OldCoreData\r\n");
767 fileBuffer
.append(" );\r\n\r\n");
769 fileBuffer
.append("EFI_STATUS\r\n");
770 fileBuffer
.append("EFIAPI\r\n");
771 fileBuffer
.append("ProcessModuleEntryPointList (\r\n");
773 .append(" IN EFI_PEI_STARTUP_DESCRIPTOR *PeiStartupDescriptor,\r\n");
775 .append(" IN VOID *OldCoreData\r\n");
776 fileBuffer
.append(" )\r\n\r\n");
777 fileBuffer
.append("{\r\n");
778 fileBuffer
.append(" return ");
779 fileBuffer
.append(entryPointList
[0]);
780 fileBuffer
.append(" (PeiStartupDescriptor, OldCoreData);\r\n");
781 fileBuffer
.append("}\r\n\r\n");
785 case CommonDefinition
.ModuleTypeDxeCore
:
786 fileBuffer
.append("const UINT32 _gUefiDriverRevision = 0;\r\n");
787 if (entryPointList
== null || entryPointList
.length
!= 1) {
788 throw new BuildException(
789 "Module type = 'DXE_CORE', only have one module entry point!");
792 fileBuffer
.append("VOID\r\n");
793 fileBuffer
.append("EFIAPI\r\n");
794 fileBuffer
.append(entryPointList
[0]);
795 fileBuffer
.append(" (\n");
796 fileBuffer
.append(" IN VOID *HobStart\r\n");
797 fileBuffer
.append(" );\r\n\r\n");
799 fileBuffer
.append("VOID\r\n");
800 fileBuffer
.append("EFIAPI\r\n");
801 fileBuffer
.append("ProcessModuleEntryPointList (\r\n");
802 fileBuffer
.append(" IN VOID *HobStart\r\n");
803 fileBuffer
.append(" )\r\n\r\n");
804 fileBuffer
.append("{\r\n");
805 fileBuffer
.append(" ");
806 fileBuffer
.append(entryPointList
[0]);
807 fileBuffer
.append(" (HobStart);\r\n");
808 fileBuffer
.append("}\r\n\r\n");
812 case CommonDefinition
.ModuleTypePeim
:
813 int entryPointCount
= 0;
815 .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT32 _gPeimRevision = 0;\r\n");
816 if (entryPointList
== null || entryPointList
.length
== 0) {
817 fileBuffer
.append("EFI_STATUS\r\n");
818 fileBuffer
.append("EFIAPI\r\n");
819 fileBuffer
.append("ProcessModuleEntryPointList (\r\n");
820 fileBuffer
.append(" IN EFI_FFS_FILE_HEADER *FfsHeader,\r\n");
821 fileBuffer
.append(" IN EFI_PEI_SERVICES **PeiServices\r\n");
822 fileBuffer
.append(" )\r\n\r\n");
823 fileBuffer
.append("{\r\n");
824 fileBuffer
.append(" return EFI_SUCCESS;\r\n");
825 fileBuffer
.append("}\r\n\r\n");
828 for (int i
= 0; i
< entryPointList
.length
; i
++) {
829 fileBuffer
.append("EFI_STATUS\r\n");
830 fileBuffer
.append("EFIAPI\r\n");
831 fileBuffer
.append(entryPointList
[i
]);
832 fileBuffer
.append(" (\r\n");
834 .append(" IN EFI_FFS_FILE_HEADER *FfsHeader,\r\n");
836 .append(" IN EFI_PEI_SERVICES **PeiServices\r\n");
837 fileBuffer
.append(" );\r\n");
842 fileBuffer
.append("EFI_STATUS\r\n");
843 fileBuffer
.append("EFIAPI\r\n");
844 fileBuffer
.append("ProcessModuleEntryPointList (\r\n");
845 fileBuffer
.append(" IN EFI_FFS_FILE_HEADER *FfsHeader,\r\n");
846 fileBuffer
.append(" IN EFI_PEI_SERVICES **PeiServices\r\n");
847 fileBuffer
.append(" )\r\n\r\n");
848 fileBuffer
.append("{\r\n");
849 if (entryPointCount
== 1) {
850 fileBuffer
.append(" return ");
851 fileBuffer
.append(entryPointList
[0]);
852 fileBuffer
.append(" (FfsHeader, PeiServices);\r\n");
854 fileBuffer
.append(" EFI_STATUS Status;\r\n");
855 fileBuffer
.append(" EFI_STATUS CombinedStatus;\r\n\r\n");
856 fileBuffer
.append(" CombinedStatus = EFI_LOAD_ERROR;\r\n\r\n");
857 for (int i
= 0; i
< entryPointList
.length
; i
++) {
858 if (!entryPointList
[i
].equals("")) {
859 fileBuffer
.append(" Status = ");
860 fileBuffer
.append(entryPointList
[i
]);
861 fileBuffer
.append(" (FfsHeader, PeiServices);\r\n");
863 .append(" if (!EFI_ERROR (Status) || EFI_ERROR (CombinedStatus)) {\r\n");
864 fileBuffer
.append(" CombinedStatus = Status;\r\n");
865 fileBuffer
.append(" }\r\n\r\n");
870 fileBuffer
.append(" return CombinedStatus;\r\n");
872 fileBuffer
.append("}\r\n\r\n");
875 case CommonDefinition
.ModuleTypeDxeSmmDriver
:
878 // If entryPoint is null, create an empty ProcessModuleEntryPointList
881 if (entryPointList
== null || entryPointList
.length
== 0){
883 .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gDriverEntryPointCount = ");
884 fileBuffer
.append(Integer
.toString(entryPointCount
));
885 fileBuffer
.append(";\r\n");
886 fileBuffer
.append("EFI_STATUS\r\n");
887 fileBuffer
.append("EFIAPI\r\n");
888 fileBuffer
.append("ProcessModuleEntryPointList (\r\n");
889 fileBuffer
.append(" IN EFI_HANDLE ImageHandle,\r\n");
890 fileBuffer
.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");
891 fileBuffer
.append(" )\r\n\r\n");
892 fileBuffer
.append("{\r\n");
893 fileBuffer
.append(" return EFI_SUCCESS;\r\n");
894 fileBuffer
.append("}\r\n\r\n");
897 for (int i
= 0; i
< entryPointList
.length
; i
++) {
898 fileBuffer
.append("EFI_STATUS\r\n");
899 fileBuffer
.append("EFIAPI\r\n");
900 fileBuffer
.append(entryPointList
[i
]);
901 fileBuffer
.append(" (\r\n");
902 fileBuffer
.append(" IN EFI_HANDLE ImageHandle,\r\n");
903 fileBuffer
.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");
904 fileBuffer
.append(" );\r\n");
908 .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gDriverEntryPointCount = ");
909 fileBuffer
.append(Integer
.toString(entryPointCount
));
910 fileBuffer
.append(";\r\n");
912 .append("static BASE_LIBRARY_JUMP_BUFFER mJumpContext;\r\n");
914 .append("static EFI_STATUS mDriverEntryPointStatus = EFI_LOAD_ERROR;\r\n\r\n");
916 fileBuffer
.append("EFI_STATUS\r\n");
917 fileBuffer
.append("EFIAPI\r\n");
918 fileBuffer
.append("ProcessModuleEntryPointList (\r\n");
919 fileBuffer
.append(" IN EFI_HANDLE ImageHandle,\r\n");
920 fileBuffer
.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");
921 fileBuffer
.append(" )\r\n\r\n");
922 fileBuffer
.append("{\r\n");
925 for (int i
= 0; i
< entryPointList
.length
; i
++) {
927 .append(" if (SetJump (&mJumpContext) == 0) {\r\n");
928 fileBuffer
.append(" ExitDriver (");
929 fileBuffer
.append(entryPointList
[i
]);
930 fileBuffer
.append(" (ImageHandle, SystemTable));\r\n");
931 fileBuffer
.append(" ASSERT (FALSE);\r\n");
932 fileBuffer
.append(" }\r\n");
935 fileBuffer
.append(" return mDriverEntryPointStatus;\r\n");
936 fileBuffer
.append("}\r\n\r\n");
938 fileBuffer
.append("VOID\r\n");
939 fileBuffer
.append("EFIAPI\r\n");
940 fileBuffer
.append("ExitDriver (\r\n");
941 fileBuffer
.append(" IN EFI_STATUS Status\n");
942 fileBuffer
.append(" )\r\n\r\n");
943 fileBuffer
.append("{\r\n");
945 .append(" if (!EFI_ERROR (Status) || EFI_ERROR (mDriverEntryPointStatus)) {\r\n");
946 fileBuffer
.append(" mDriverEntryPointStatus = Status;\r\n");
947 fileBuffer
.append(" }\r\n");
948 fileBuffer
.append(" LongJump (&mJumpContext, (UINTN)-1);\r\n");
949 fileBuffer
.append(" ASSERT (FALSE);\r\n");
950 fileBuffer
.append("}\r\n\r\n");
956 // Add "ModuleUnloadImage" for DxeSmmDriver module type;
958 entryPointList
= SurfaceAreaQuery
.getModuleUnloadImageArray();
959 entryPointList
= CommonDefinition
.remDupString(entryPointList
);
962 if (entryPointList
!= null) {
963 for (int i
= 0; i
< entryPointList
.length
; i
++) {
964 fileBuffer
.append("EFI_STATUS\r\n");
965 fileBuffer
.append("EFIAPI\r\n");
966 fileBuffer
.append(entryPointList
[i
]);
967 fileBuffer
.append(" (\r\n");
969 .append(" IN EFI_HANDLE ImageHandle\r\n");
970 fileBuffer
.append(" );\r\n");
976 .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gDriverUnloadImageCount = ");
977 fileBuffer
.append(Integer
.toString(entryPointCount
));
978 fileBuffer
.append(";\r\n\r\n");
980 fileBuffer
.append("EFI_STATUS\r\n");
981 fileBuffer
.append("EFIAPI\r\n");
982 fileBuffer
.append("ProcessModuleUnloadList (\r\n");
983 fileBuffer
.append(" IN EFI_HANDLE ImageHandle\r\n");
984 fileBuffer
.append(" )\r\n");
985 fileBuffer
.append("{\r\n");
987 if (entryPointCount
== 0) {
988 fileBuffer
.append(" return EFI_SUCCESS;\r\n");
989 } else if (entryPointCount
== 1) {
990 fileBuffer
.append(" return ");
991 fileBuffer
.append(entryPointList
[0]);
992 fileBuffer
.append("(ImageHandle);\r\n");
994 fileBuffer
.append(" EFI_STATUS Status;\r\n\r\n");
995 fileBuffer
.append(" Status = EFI_SUCCESS;\r\n\r\n");
996 for (int i
= 0; i
< entryPointList
.length
; i
++) {
998 fileBuffer
.append(" Status = ");
999 fileBuffer
.append(entryPointList
[i
]);
1000 fileBuffer
.append("(ImageHandle);\r\n");
1002 fileBuffer
.append(" if (EFI_ERROR (Status)) {\r\n");
1003 fileBuffer
.append(" ");
1004 fileBuffer
.append(entryPointList
[i
]);
1005 fileBuffer
.append("(ImageHandle);\r\n");
1006 fileBuffer
.append(" } else {\r\n");
1007 fileBuffer
.append(" Status = ");
1008 fileBuffer
.append(entryPointList
[i
]);
1009 fileBuffer
.append("(ImageHandle);\r\n");
1010 fileBuffer
.append(" }\r\n");
1013 fileBuffer
.append(" return Status;\r\n");
1015 fileBuffer
.append("}\r\n\r\n");
1018 case CommonDefinition
.ModuleTypeDxeRuntimeDriver
:
1019 case CommonDefinition
.ModuleTypeDxeDriver
:
1020 case CommonDefinition
.ModuleTypeDxeSalDriver
:
1021 case CommonDefinition
.ModuleTypeUefiDriver
:
1022 case CommonDefinition
.ModuleTypeUefiApplication
:
1023 entryPointCount
= 0;
1024 fileBuffer
.append("const UINT32 _gUefiDriverRevision = 0;\r\n");
1026 // If entry point is null, create a empty ProcessModuleEntryPointList function.
1028 if (entryPointList
== null || entryPointList
.length
== 0){
1030 .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gDriverEntryPointCount = 0;\r\n");
1031 fileBuffer
.append("EFI_STATUS\r\n");
1032 fileBuffer
.append("EFIAPI\r\n");
1033 fileBuffer
.append("ProcessModuleEntryPointList (\r\n");
1034 fileBuffer
.append(" IN EFI_HANDLE ImageHandle,\r\n");
1035 fileBuffer
.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");
1036 fileBuffer
.append(" )\r\n\r\n");
1037 fileBuffer
.append("{\r\n");
1038 fileBuffer
.append(" return EFI_SUCCESS;\r\n");
1039 fileBuffer
.append("}\r\n");
1042 for (int i
= 0; i
< entryPointList
.length
; i
++) {
1044 fileBuffer
.append("EFI_STATUS\r\n");
1045 fileBuffer
.append("EFIAPI\r\n");
1046 fileBuffer
.append(entryPointList
[i
]);
1047 fileBuffer
.append(" (\r\n");
1048 fileBuffer
.append(" IN EFI_HANDLE ImageHandle,\r\n");
1049 fileBuffer
.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");
1050 fileBuffer
.append(" );\r\n");
1055 .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gDriverEntryPointCount = ");
1056 fileBuffer
.append(Integer
.toString(entryPointCount
));
1057 fileBuffer
.append(";\r\n");
1058 if (entryPointCount
> 1) {
1060 .append("static BASE_LIBRARY_JUMP_BUFFER mJumpContext;\r\n");
1062 .append("static EFI_STATUS mDriverEntryPointStatus = EFI_LOAD_ERROR;\r\n");
1064 fileBuffer
.append("\n");
1066 fileBuffer
.append("EFI_STATUS\r\n");
1067 fileBuffer
.append("EFIAPI\r\n");
1068 fileBuffer
.append("ProcessModuleEntryPointList (\r\n");
1069 fileBuffer
.append(" IN EFI_HANDLE ImageHandle,\r\n");
1070 fileBuffer
.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");
1071 fileBuffer
.append(" )\r\n\r\n");
1072 fileBuffer
.append("{\r\n");
1074 if (entryPointCount
== 1) {
1075 fileBuffer
.append(" return (");
1076 fileBuffer
.append(entryPointList
[0]);
1077 fileBuffer
.append(" (ImageHandle, SystemTable));\r\n");
1079 for (int i
= 0; i
< entryPointList
.length
; i
++) {
1080 if (!entryPointList
[i
].equals("")) {
1082 .append(" if (SetJump (&mJumpContext) == 0) {\r\n");
1083 fileBuffer
.append(" ExitDriver (");
1084 fileBuffer
.append(entryPointList
[i
]);
1085 fileBuffer
.append(" (ImageHandle, SystemTable));\r\n");
1086 fileBuffer
.append(" ASSERT (FALSE);\r\n");
1087 fileBuffer
.append(" }\r\n");
1092 fileBuffer
.append(" return mDriverEntryPointStatus;\r\n");
1094 fileBuffer
.append("}\r\n\r\n");
1096 fileBuffer
.append("VOID\n");
1097 fileBuffer
.append("EFIAPI\n");
1098 fileBuffer
.append("ExitDriver (\r\n");
1099 fileBuffer
.append(" IN EFI_STATUS Status\n");
1100 fileBuffer
.append(" )\r\n\r\n");
1101 fileBuffer
.append("{\r\n");
1102 if (entryPointCount
<= 1) {
1103 fileBuffer
.append(" if (EFI_ERROR (Status)) {\r\n");
1105 .append(" ProcessLibraryDestructorList (gImageHandle, gST);\r\n");
1106 fileBuffer
.append(" }\r\n");
1108 .append(" gBS->Exit (gImageHandle, Status, 0, NULL);\r\n");
1111 .append(" if (!EFI_ERROR (Status) || EFI_ERROR (mDriverEntryPointStatus)) {\r\n");
1112 fileBuffer
.append(" mDriverEntryPointStatus = Status;\r\n");
1113 fileBuffer
.append(" }\r\n");
1114 fileBuffer
.append(" LongJump (&mJumpContext, (UINTN)-1);\r\n");
1115 fileBuffer
.append(" ASSERT (FALSE);\r\n");
1117 fileBuffer
.append("}\r\n\r\n");
1122 // Add ModuleUnloadImage for DxeDriver and UefiDriver module type.
1124 entryPointList
= SurfaceAreaQuery
.getModuleUnloadImageArray();
1126 // Remover duplicate unload entry point.
1128 entryPointList
= CommonDefinition
.remDupString(entryPointList
);
1129 entryPointCount
= 0;
1130 if (entryPointList
!= null) {
1131 for (int i
= 0; i
< entryPointList
.length
; i
++) {
1132 fileBuffer
.append("EFI_STATUS\r\n");
1133 fileBuffer
.append("EFIAPI\r\n");
1134 fileBuffer
.append(entryPointList
[i
]);
1135 fileBuffer
.append(" (\r\n");
1137 .append(" IN EFI_HANDLE ImageHandle\r\n");
1138 fileBuffer
.append(" );\r\n");
1144 .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gDriverUnloadImageCount = ");
1145 fileBuffer
.append(Integer
.toString(entryPointCount
));
1146 fileBuffer
.append(";\r\n\r\n");
1148 fileBuffer
.append("EFI_STATUS\n");
1149 fileBuffer
.append("EFIAPI\r\n");
1150 fileBuffer
.append("ProcessModuleUnloadList (\r\n");
1151 fileBuffer
.append(" IN EFI_HANDLE ImageHandle\r\n");
1152 fileBuffer
.append(" )\r\n");
1153 fileBuffer
.append("{\r\n");
1155 if (entryPointCount
== 0) {
1156 fileBuffer
.append(" return EFI_SUCCESS;\r\n");
1157 } else if (entryPointCount
== 1) {
1158 fileBuffer
.append(" return ");
1159 fileBuffer
.append(entryPointList
[0]);
1160 fileBuffer
.append("(ImageHandle);\r\n");
1162 fileBuffer
.append(" EFI_STATUS Status;\r\n\r\n");
1163 fileBuffer
.append(" Status = EFI_SUCCESS;\r\n\r\n");
1164 for (int i
= 0; i
< entryPointList
.length
; i
++) {
1166 fileBuffer
.append(" Status = ");
1167 fileBuffer
.append(entryPointList
[i
]);
1168 fileBuffer
.append("(ImageHandle);\r\n");
1170 fileBuffer
.append(" if (EFI_ERROR (Status)) {\r\n");
1171 fileBuffer
.append(" ");
1172 fileBuffer
.append(entryPointList
[i
]);
1173 fileBuffer
.append("(ImageHandle);\r\n");
1174 fileBuffer
.append(" } else {\r\n");
1175 fileBuffer
.append(" Status = ");
1176 fileBuffer
.append(entryPointList
[i
]);
1177 fileBuffer
.append("(ImageHandle);\r\n");
1178 fileBuffer
.append(" }\r\n");
1181 fileBuffer
.append(" return Status;\r\n");
1183 fileBuffer
.append("}\r\n\r\n");
1191 * This function gets GUIDs from SPD file accrodeing to <PPIs> information
1192 * and write those GUIDs to AutoGen.c.
1195 * String Buffer for Autogen.c file.
1196 * @throws BuildException
1197 * Guid must set value!
1199 void PpiGuidToAutogenC(StringBuffer fileBuffer
) throws AutoGenException
{
1200 String
[] cNameGuid
= null;
1203 // Get the all PPI adn PPI Notify from MSA file,
1204 // then add those PPI ,and PPI Notify name to list.
1207 String
[] ppiList
= SurfaceAreaQuery
.getPpiArray(this.arch
);
1208 for (int i
= 0; i
< ppiList
.length
; i
++) {
1209 this.mPpiList
.add(ppiList
[i
]);
1212 String
[] ppiNotifyList
= SurfaceAreaQuery
.getPpiNotifyArray(this.arch
);
1213 for (int i
= 0; i
< ppiNotifyList
.length
; i
++) {
1214 this.mPpiList
.add(ppiNotifyList
[i
]);
1218 // Find CNAME and GUID from dependence SPD file and write to Autogen.c
1220 Iterator ppiIterator
= this.mPpiList
.iterator();
1221 String ppiKeyWord
= null;
1222 while (ppiIterator
.hasNext()) {
1223 ppiKeyWord
= ppiIterator
.next().toString();
1224 cNameGuid
= GlobalData
.getPpiGuid(this.mDepPkgList
, ppiKeyWord
);
1225 if (cNameGuid
!= null) {
1227 .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID ");
1228 fileBuffer
.append(cNameGuid
[0]);
1229 fileBuffer
.append(" = { ");
1230 fileBuffer
.append(CommonDefinition
.formatGuidName(cNameGuid
[1]));
1231 fileBuffer
.append(" } ;");
1234 // If can't find Ppi GUID declaration in every package
1236 throw new AutoGenException("Can not find Ppi GUID ["
1237 + ppiKeyWord
+ "] declaration in every packages. ");
1243 * ProtocolGuidToAutogenc
1245 * This function gets GUIDs from SPD file accrodeing to <Protocol>
1246 * information and write those GUIDs to AutoGen.c.
1249 * String Buffer for Autogen.c file.
1250 * @throws BuildException
1251 * Protocol name must set.
1253 void ProtocolGuidToAutogenC(StringBuffer fileBuffer
) throws BuildException
{
1254 String
[] cNameGuid
= null;
1256 String
[] protocolList
= SurfaceAreaQuery
.getProtocolArray(this.arch
);
1259 // Add result to Autogen global list.
1261 for (int i
= 0; i
< protocolList
.length
; i
++) {
1262 this.mProtocolList
.add(protocolList
[i
]);
1265 String
[] protocolNotifyList
= SurfaceAreaQuery
1266 .getProtocolNotifyArray(this.arch
);
1268 for (int i
= 0; i
< protocolNotifyList
.length
; i
++) {
1269 this.mProtocolList
.add(protocolNotifyList
[i
]);
1273 // Get the NAME and GUID from dependence SPD and write to Autogen.c
1275 Iterator protocolIterator
= this.mProtocolList
.iterator();
1276 String protocolKeyWord
= null;
1279 while (protocolIterator
.hasNext()) {
1280 protocolKeyWord
= protocolIterator
.next().toString();
1281 cNameGuid
= GlobalData
.getProtocolGuid(this.mDepPkgList
, protocolKeyWord
);
1282 if (cNameGuid
!= null) {
1284 .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID ");
1285 fileBuffer
.append(cNameGuid
[0]);
1286 fileBuffer
.append(" = { ");
1287 fileBuffer
.append(CommonDefinition
.formatGuidName(cNameGuid
[1]));
1288 fileBuffer
.append(" } ;");
1291 // If can't find protocol GUID declaration in every package
1293 throw new BuildException("Can not find protocol Guid ["
1294 + protocolKeyWord
+ "] declaration in every packages. ");
1300 * GuidGuidToAutogenc
1302 * This function gets GUIDs from SPD file accrodeing to <Guids> information
1303 * and write those GUIDs to AutoGen.c.
1306 * String Buffer for Autogen.c file.
1309 void GuidGuidToAutogenC(StringBuffer fileBuffer
) throws AutoGenException
{
1310 String
[] cNameGuid
= null;
1311 String guidKeyWord
= null;
1313 String
[] guidList
= SurfaceAreaQuery
.getGuidEntryArray(this.arch
);
1315 for (int i
= 0; i
< guidList
.length
; i
++) {
1316 this.mGuidList
.add(guidList
[i
]);
1320 Iterator guidIterator
= this.mGuidList
.iterator();
1321 while (guidIterator
.hasNext()) {
1322 guidKeyWord
= guidIterator
.next().toString();
1323 cNameGuid
= GlobalData
.getGuid(this.mDepPkgList
, guidKeyWord
);
1325 if (cNameGuid
!= null) {
1327 .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID ");
1328 fileBuffer
.append(cNameGuid
[0]);
1329 fileBuffer
.append(" = { ");
1330 fileBuffer
.append(CommonDefinition
.formatGuidName(cNameGuid
[1]));
1331 fileBuffer
.append("} ;");
1334 // If can't find GUID declaration in every package
1336 throw new AutoGenException("Can not find Guid [" + guidKeyWord
1337 + "] declaration in every packages. ");
1344 * LibInstanceToAutogenC
1346 * This function adds dependent library instance to autogen.c,which
1347 * includeing library's constructor, destructor, and library dependent ppi,
1348 * protocol, guid, pcd information.
1351 * String buffer for AutoGen.c
1352 * @throws BuildException
1354 void LibInstanceToAutogenC(StringBuffer fileBuffer
) throws BuildException
{
1357 String moduleType
= SurfaceAreaQuery
.getModuleType();
1358 List
<String
> libConstructList
= new ArrayList
<String
>();
1359 List
<String
> libDestructList
= new ArrayList
<String
>();
1361 String libConstructName
= null;
1362 String libDestructName
= null;
1363 ModuleIdentification
[] libraryIdList
= SurfaceAreaQuery
1364 .getLibraryInstance(this.arch
);
1367 if (libraryIdList
!= null) {
1369 // Reorder library instance sequence.
1371 AutogenLibOrder libOrder
= new AutogenLibOrder(libraryIdList
,
1373 List
<ModuleIdentification
> orderList
= libOrder
1374 .orderLibInstance();
1376 if (orderList
!= null) {
1378 // Process library instance one by one.
1380 for (int i
= 0; i
< orderList
.size(); i
++) {
1383 // Get library instance basename.
1385 ModuleIdentification libInstanceId
= orderList
.get(i
);
1391 Map
<String
, XmlObject
> libDoc
= GlobalData
.getDoc(
1392 libInstanceId
, this.arch
);
1393 SurfaceAreaQuery
.push(libDoc
);
1396 // Get <PPis>, <Protocols>, <Guids> list of this library
1399 String
[] ppiList
= SurfaceAreaQuery
.getPpiArray(this.arch
);
1400 String
[] ppiNotifyList
= SurfaceAreaQuery
1401 .getPpiNotifyArray(this.arch
);
1402 String
[] protocolList
= SurfaceAreaQuery
1403 .getProtocolArray(this.arch
);
1404 String
[] protocolNotifyList
= SurfaceAreaQuery
1405 .getProtocolNotifyArray(this.arch
);
1406 String
[] guidList
= SurfaceAreaQuery
1407 .getGuidEntryArray(this.arch
);
1408 PackageIdentification
[] pkgList
= SurfaceAreaQuery
.getDependencePkg(this.arch
);
1411 // Add those ppi, protocol, guid in global ppi,
1415 for (index
= 0; index
< ppiList
.length
; index
++) {
1416 this.mPpiList
.add(ppiList
[index
]);
1419 for (index
= 0; index
< ppiNotifyList
.length
; index
++) {
1420 this.mPpiList
.add(ppiNotifyList
[index
]);
1423 for (index
= 0; index
< protocolList
.length
; index
++) {
1424 this.mProtocolList
.add(protocolList
[index
]);
1427 for (index
= 0; index
< protocolNotifyList
.length
; index
++) {
1428 this.mProtocolList
.add(protocolNotifyList
[index
]);
1431 for (index
= 0; index
< guidList
.length
; index
++) {
1432 this.mGuidList
.add(guidList
[index
]);
1434 for (index
= 0; index
< pkgList
.length
; index
++){
1435 if (!this.mDepPkgList
.contains(pkgList
[index
])){
1436 this.mDepPkgList
.add(pkgList
[index
]);
1441 // If not yet parse this library instance's constructor
1442 // element,parse it.
1444 libConstructName
= SurfaceAreaQuery
1445 .getLibConstructorName();
1446 libDestructName
= SurfaceAreaQuery
1447 .getLibDestructorName();
1449 SurfaceAreaQuery
.pop();
1451 // Add dependent library instance constructor function.
1453 if (libConstructName
!= null) {
1454 libConstructList
.add(libConstructName
);
1457 // Add dependent library instance destructor fuction.
1459 if (libDestructName
!= null) {
1460 libDestructList
.add(libDestructName
);
1467 // Add library constructor to AutoGen.c
1469 LibConstructorToAutogenC(libConstructList
, moduleType
,
1470 fileBuffer
/* autogenC */);
1472 // Add library destructor to AutoGen.c
1474 LibDestructorToAutogenC(libDestructList
, moduleType
, fileBuffer
/* autogenC */);
1477 } catch (Exception e
) {
1478 throw new BuildException(e
.getMessage());
1483 * LibConstructorToAutogenc
1485 * This function writes library constructor list to AutoGen.c. The library
1486 * constructor's parameter and return value depend on module type.
1488 * @param libInstanceList
1489 * List of library construct name.
1493 * String buffer for AutoGen.c
1496 void LibConstructorToAutogenC(List
<String
> libInstanceList
,
1497 String moduleType
, StringBuffer fileBuffer
) throws Exception
{
1498 boolean isFirst
= true;
1501 // The library constructor's parameter and return value depend on
1504 for (int i
= 0; i
< libInstanceList
.size(); i
++) {
1505 switch (CommonDefinition
.getModuleType(moduleType
)) {
1506 case CommonDefinition
.ModuleTypeBase
:
1507 fileBuffer
.append("RETURN_STATUS\r\n");
1508 fileBuffer
.append(libInstanceList
.get(i
));
1509 fileBuffer
.append(" (\r\n");
1510 fileBuffer
.append(" VOID\r\n");
1511 fileBuffer
.append(" );\r\n");
1514 case CommonDefinition
.ModuleTypePeiCore
:
1515 case CommonDefinition
.ModuleTypePeim
:
1516 fileBuffer
.append("EFI_STATUS\r\n");
1517 fileBuffer
.append(libInstanceList
.get(i
));
1518 fileBuffer
.append(" (\r\n");
1520 .append(" IN EFI_FFS_FILE_HEADER *FfsHeader,\r\n");
1522 .append(" IN EFI_PEI_SERVICES **PeiServices\r\n");
1523 fileBuffer
.append(" );\r\n");
1526 case CommonDefinition
.ModuleTypeDxeCore
:
1527 case CommonDefinition
.ModuleTypeDxeDriver
:
1528 case CommonDefinition
.ModuleTypeDxeRuntimeDriver
:
1529 case CommonDefinition
.ModuleTypeDxeSmmDriver
:
1530 case CommonDefinition
.ModuleTypeDxeSalDriver
:
1531 case CommonDefinition
.ModuleTypeUefiDriver
:
1532 case CommonDefinition
.ModuleTypeUefiApplication
:
1533 fileBuffer
.append("EFI_STATUS\r\n");
1534 fileBuffer
.append(libInstanceList
.get(i
));
1535 fileBuffer
.append(" (\r\n");
1536 fileBuffer
.append(" IN EFI_HANDLE ImageHandle,\r\n");
1537 fileBuffer
.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");
1538 fileBuffer
.append(" );\r\n");
1544 // Add ProcessLibraryConstructorList in AutoGen.c
1546 fileBuffer
.append("VOID\r\n");
1547 fileBuffer
.append("ProcessLibraryConstructorList (\r\n");
1548 switch (CommonDefinition
.getModuleType(moduleType
)) {
1549 case CommonDefinition
.ModuleTypeBase
:
1550 fileBuffer
.append(" VOID\r\n");
1553 case CommonDefinition
.ModuleTypePeiCore
:
1554 case CommonDefinition
.ModuleTypePeim
:
1555 fileBuffer
.append(" IN EFI_FFS_FILE_HEADER *FfsHeader,\r\n");
1557 .append(" IN EFI_PEI_SERVICES **PeiServices\r\n");
1560 case CommonDefinition
.ModuleTypeDxeCore
:
1561 case CommonDefinition
.ModuleTypeDxeDriver
:
1562 case CommonDefinition
.ModuleTypeDxeRuntimeDriver
:
1563 case CommonDefinition
.ModuleTypeDxeSmmDriver
:
1564 case CommonDefinition
.ModuleTypeDxeSalDriver
:
1565 case CommonDefinition
.ModuleTypeUefiDriver
:
1566 case CommonDefinition
.ModuleTypeUefiApplication
:
1567 fileBuffer
.append(" IN EFI_HANDLE ImageHandle,\r\n");
1568 fileBuffer
.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");
1572 fileBuffer
.append(" )\r\n");
1573 fileBuffer
.append("{\r\n");
1575 // If no constructor function, return EFI_SUCCESS.
1577 //if (libInstanceList.size() == 0){
1578 // fileBuffer.append(" return EFI_SUCCESS;\r\n");
1580 for (int i
= 0; i
< libInstanceList
.size(); i
++) {
1582 fileBuffer
.append(" EFI_STATUS Status;\r\n");
1583 fileBuffer
.append(" Status = EFI_SUCCESS;\r\n");
1584 fileBuffer
.append("\r\n");
1587 switch (CommonDefinition
.getModuleType(moduleType
)) {
1588 case CommonDefinition
.ModuleTypeBase
:
1589 fileBuffer
.append(" Status = ");
1590 fileBuffer
.append(libInstanceList
.get(i
));
1591 fileBuffer
.append("();\r\n");
1592 fileBuffer
.append(" VOID\r\n");
1594 case CommonDefinition
.ModuleTypePeiCore
:
1595 case CommonDefinition
.ModuleTypePeim
:
1596 fileBuffer
.append(" Status = ");
1597 fileBuffer
.append(libInstanceList
.get(i
));
1598 fileBuffer
.append(" (FfsHeader, PeiServices);\r\n");
1600 case CommonDefinition
.ModuleTypeDxeCore
:
1601 case CommonDefinition
.ModuleTypeDxeDriver
:
1602 case CommonDefinition
.ModuleTypeDxeRuntimeDriver
:
1603 case CommonDefinition
.ModuleTypeDxeSmmDriver
:
1604 case CommonDefinition
.ModuleTypeDxeSalDriver
:
1605 case CommonDefinition
.ModuleTypeUefiDriver
:
1606 case CommonDefinition
.ModuleTypeUefiApplication
:
1607 fileBuffer
.append(" Status = ");
1608 fileBuffer
.append(libInstanceList
.get(i
));
1609 fileBuffer
.append(" (ImageHandle, SystemTable);\r\n");
1612 EdkLog
.log(EdkLog
.EDK_INFO
,"Autogen don't know how to deal with module type -"+ moduleType
+ " !");
1614 fileBuffer
.append(" ASSERT_EFI_ERROR (Status);\r\n");
1616 fileBuffer
.append("}\r\n");
1620 * LibDestructorToAutogenc
1622 * This function writes library destructor list to AutoGen.c. The library
1623 * destructor's parameter and return value depend on module type.
1625 * @param libInstanceList
1626 * List of library destructor name.
1630 * String buffer for AutoGen.c
1633 void LibDestructorToAutogenC(List
<String
> libInstanceList
,
1634 String moduleType
, StringBuffer fileBuffer
) throws Exception
{
1635 boolean isFirst
= true;
1636 for (int i
= 0; i
< libInstanceList
.size(); i
++) {
1637 switch (CommonDefinition
.getModuleType(moduleType
)) {
1638 case CommonDefinition
.ModuleTypeBase
:
1639 fileBuffer
.append("RETURN_STATUS\n");
1640 fileBuffer
.append(libInstanceList
.get(i
));
1641 fileBuffer
.append(" (\r\n");
1642 fileBuffer
.append(" VOID\r\n");
1643 fileBuffer
.append(" );\r\n");
1645 case CommonDefinition
.ModuleTypePeiCore
:
1646 case CommonDefinition
.ModuleTypePeim
:
1647 fileBuffer
.append("EFI_STATUS\r\n");
1648 fileBuffer
.append(libInstanceList
.get(i
));
1649 fileBuffer
.append(" (\r\n");
1651 .append(" IN EFI_FFS_FILE_HEADER *FfsHeader,\r\n");
1653 .append(" IN EFI_PEI_SERVICES **PeiServices\r\n");
1654 fileBuffer
.append(" );\r\n");
1656 case CommonDefinition
.ModuleTypeDxeCore
:
1657 case CommonDefinition
.ModuleTypeDxeDriver
:
1658 case CommonDefinition
.ModuleTypeDxeRuntimeDriver
:
1659 case CommonDefinition
.ModuleTypeDxeSmmDriver
:
1660 case CommonDefinition
.ModuleTypeDxeSalDriver
:
1661 case CommonDefinition
.ModuleTypeUefiDriver
:
1662 case CommonDefinition
.ModuleTypeUefiApplication
:
1663 fileBuffer
.append("EFI_STATUS\r\n");
1664 fileBuffer
.append(libInstanceList
.get(i
));
1665 fileBuffer
.append(" (\r\n");
1666 fileBuffer
.append(" IN EFI_HANDLE ImageHandle,\r\n");
1667 fileBuffer
.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");
1668 fileBuffer
.append(" );\r\n");
1674 // Write ProcessLibraryDestructor list to autogen.c
1676 switch (CommonDefinition
.getModuleType(moduleType
)) {
1677 case CommonDefinition
.ModuleTypeBase
:
1678 case CommonDefinition
.ModuleTypePeiCore
:
1679 case CommonDefinition
.ModuleTypePeim
:
1681 case CommonDefinition
.ModuleTypeDxeCore
:
1682 case CommonDefinition
.ModuleTypeDxeDriver
:
1683 case CommonDefinition
.ModuleTypeDxeRuntimeDriver
:
1684 case CommonDefinition
.ModuleTypeDxeSmmDriver
:
1685 case CommonDefinition
.ModuleTypeDxeSalDriver
:
1686 case CommonDefinition
.ModuleTypeUefiDriver
:
1687 case CommonDefinition
.ModuleTypeUefiApplication
:
1688 fileBuffer
.append("VOID\r\n");
1689 fileBuffer
.append("ProcessLibraryDestructorList (\r\n");
1690 fileBuffer
.append(" IN EFI_HANDLE ImageHandle,\r\n");
1691 fileBuffer
.append(" IN EFI_SYSTEM_TABLE *SystemTable\r\n");
1692 fileBuffer
.append(" )\r\n");
1693 fileBuffer
.append("{\r\n");
1695 // If no library destructor function, return EFI_SUCCESS.
1698 for (int i
= 0; i
< libInstanceList
.size(); i
++) {
1700 fileBuffer
.append(" EFI_STATUS Status;\r\n");
1701 fileBuffer
.append(" Status = EFI_SUCCESS;\r\n");
1702 fileBuffer
.append("\r\n");
1705 fileBuffer
.append(" Status = ");
1706 fileBuffer
.append(libInstanceList
.get(i
));
1707 fileBuffer
.append("(ImageHandle, SystemTable);\r\n");
1708 fileBuffer
.append(" ASSERT_EFI_ERROR (Status);\r\n");
1710 fileBuffer
.append("}\r\n");
1716 * ExternsDriverBindingToAutoGenC
1718 * This function is to write DRIVER_BINDING, COMPONENT_NAME,
1719 * DRIVER_CONFIGURATION, DRIVER_DIAGNOSTIC in AutoGen.c.
1722 * String buffer for AutoGen.c
1724 void ExternsDriverBindingToAutoGenC(StringBuffer fileBuffer
)
1725 throws BuildException
{
1728 // Check what <extern> contains. And the number of following elements
1729 // under <extern> should be same. 1. DRIVER_BINDING 2. COMPONENT_NAME
1730 // 3.DRIVER_CONFIGURATION 4. DRIVER_DIAGNOSTIC
1733 String
[] drvBindList
= SurfaceAreaQuery
.getDriverBindingArray();
1736 // If component name protocol,component configuration protocol,
1737 // component diagnostic protocol is not null or empty, check
1738 // if every one have the same number of the driver binding protocol.
1740 if (drvBindList
== null || drvBindList
.length
== 0) {
1744 String
[] compNamList
= SurfaceAreaQuery
.getComponentNameArray();
1745 String
[] compConfList
= SurfaceAreaQuery
.getDriverConfigArray();
1746 String
[] compDiagList
= SurfaceAreaQuery
.getDriverDiagArray();
1751 // Write driver binding protocol extern to autogen.c
1753 for (int i
= 0; i
< drvBindList
.length
; i
++) {
1754 fileBuffer
.append("extern EFI_DRIVER_BINDING_PROTOCOL ");
1755 fileBuffer
.append(drvBindList
[i
]);
1756 fileBuffer
.append(";\r\n");
1760 // Write component name protocol extern to autogen.c
1762 if (compNamList
!= null && compNamList
.length
!= 0) {
1763 if (drvBindList
.length
!= compNamList
.length
) {
1764 throw new BuildException(
1765 "Different number of Driver Binding and Component Name protocols!");
1769 for (int i
= 0; i
< compNamList
.length
; i
++) {
1770 fileBuffer
.append("extern EFI_COMPONENT_NAME_PROTOCOL ");
1771 fileBuffer
.append(compNamList
[i
]);
1772 fileBuffer
.append(";\r\n");
1777 // Write driver configration protocol extern to autogen.c
1779 if (compConfList
!= null && compConfList
.length
!= 0) {
1780 if (drvBindList
.length
!= compConfList
.length
) {
1781 throw new BuildException(
1782 "Different number of Driver Binding and Driver Configuration protocols!");
1786 for (int i
= 0; i
< compConfList
.length
; i
++) {
1787 fileBuffer
.append("extern EFI_DRIVER_CONFIGURATION_PROTOCOL ");
1788 fileBuffer
.append(compConfList
[i
]);
1789 fileBuffer
.append(";\r\n");
1794 // Write driver dignastic protocol extern to autogen.c
1796 if (compDiagList
!= null && compDiagList
.length
!= 0) {
1797 if (drvBindList
.length
!= compDiagList
.length
) {
1798 throw new BuildException(
1799 "Different number of Driver Binding and Driver Diagnosis protocols!");
1803 for (int i
= 0; i
< compDiagList
.length
; i
++) {
1804 fileBuffer
.append("extern EFI_DRIVER_DIAGNOSTICS_PROTOCOL ");
1805 fileBuffer
.append(compDiagList
[i
]);
1806 fileBuffer
.append(";\r\n");
1811 // Write driver module protocol bitmask.
1814 .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gDriverModelProtocolBitmask = ");
1815 fileBuffer
.append(Integer
.toString(BitMask
));
1816 fileBuffer
.append(";\r\n");
1819 // Write driver module protocol list entry
1822 .append("GLOBAL_REMOVE_IF_UNREFERENCED const UINTN _gDriverModelProtocolListEntries = ");
1824 fileBuffer
.append(Integer
.toString(drvBindList
.length
));
1825 fileBuffer
.append(";\r\n");
1828 // Write drive module protocol list to autogen.c
1831 .append("GLOBAL_REMOVE_IF_UNREFERENCED const EFI_DRIVER_MODEL_PROTOCOL_LIST _gDriverModelProtocolList[] = {");
1832 for (int i
= 0; i
< drvBindList
.length
; i
++) {
1834 fileBuffer
.append(",");
1836 fileBuffer
.append("\r\n {\r\n");
1837 fileBuffer
.append(" &");
1838 fileBuffer
.append(drvBindList
[i
]);
1839 fileBuffer
.append(", \r\n");
1841 if (compNamList
!= null) {
1842 fileBuffer
.append(" &");
1843 fileBuffer
.append(compNamList
[i
]);
1844 fileBuffer
.append(", \r\n");
1846 fileBuffer
.append(" NULL, \r\n");
1849 if (compConfList
!= null) {
1850 fileBuffer
.append(" &");
1851 fileBuffer
.append(compConfList
[i
]);
1852 fileBuffer
.append(", \r\n");
1854 fileBuffer
.append(" NULL, \r\n");
1857 if (compDiagList
!= null) {
1858 fileBuffer
.append(" &");
1859 fileBuffer
.append(compDiagList
[i
]);
1860 fileBuffer
.append(", \r\n");
1862 fileBuffer
.append(" NULL, \r\n");
1864 fileBuffer
.append(" }");
1866 fileBuffer
.append("\r\n};\r\n");
1870 * ExternCallBackToAutoGenC
1872 * This function adds <SetVirtualAddressMapCallBack> and
1873 * <ExitBootServicesCallBack> infomation to AutoGen.c
1876 * String buffer for AutoGen.c
1877 * @throws BuildException
1879 void ExternCallBackToAutoGenC(StringBuffer fileBuffer
)
1880 throws BuildException
{
1881 String
[] setVirtualList
= SurfaceAreaQuery
1882 .getSetVirtualAddressMapCallBackArray();
1883 String
[] exitBootList
= SurfaceAreaQuery
1884 .getExitBootServicesCallBackArray();
1885 String moduleType
= SurfaceAreaQuery
.getModuleType();
1886 boolean UefiOrDxeModule
= false;
1890 switch (CommonDefinition
.getModuleType(moduleType
)) {
1891 case CommonDefinition
.ModuleTypeDxeDriver
:
1892 case CommonDefinition
.ModuleTypeDxeRuntimeDriver
:
1893 case CommonDefinition
.ModuleTypeDxeSalDriver
:
1894 case CommonDefinition
.ModuleTypeUefiDriver
:
1895 case CommonDefinition
.ModuleTypeUefiApplication
:
1897 // Entry point lib for these module types needs to know the count
1900 UefiOrDxeModule
= true;
1902 .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED const UINTN _gDriverSetVirtualAddressMapEventCount = ");
1905 // If the list is not valid or has no entries set count to zero else
1906 // set count to the number of valid entries
1909 if (setVirtualList
!= null) {
1910 for (i
= 0; i
< setVirtualList
.length
; i
++) {
1911 if (setVirtualList
[i
].equalsIgnoreCase("")) {
1918 fileBuffer
.append(Integer
.toString(Count
));
1919 fileBuffer
.append(";\r\n\r\n");
1925 if (setVirtualList
== null) {
1926 if (UefiOrDxeModule
) {
1928 // No data so make a NULL list
1931 .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED const EFI_EVENT_NOTIFY _gDriverSetVirtualAddressMapEvent[] = {\r\n");
1932 fileBuffer
.append(" NULL\r\n");
1933 fileBuffer
.append("};\r\n\r\n");
1937 // Write SetVirtualAddressMap function definition.
1939 for (i
= 0; i
< setVirtualList
.length
; i
++) {
1940 if (setVirtualList
[i
].equalsIgnoreCase("")) {
1943 fileBuffer
.append("VOID\r\n");
1944 fileBuffer
.append("EFIAPI\r\n");
1945 fileBuffer
.append(setVirtualList
[i
]);
1946 fileBuffer
.append(" (\r\n");
1947 fileBuffer
.append(" IN EFI_EVENT Event,\r\n");
1948 fileBuffer
.append(" IN VOID *Context\r\n");
1949 fileBuffer
.append(" );\r\n\r\n");
1953 // Write SetVirtualAddressMap entry point array.
1956 .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED const EFI_EVENT_NOTIFY _gDriverSetVirtualAddressMapEvent[] = {");
1957 for (i
= 0; i
< setVirtualList
.length
; i
++) {
1958 if (setVirtualList
[i
].equalsIgnoreCase("")) {
1963 fileBuffer
.append("\r\n ");
1965 fileBuffer
.append(",\r\n ");
1968 fileBuffer
.append(setVirtualList
[i
]);
1971 // If module is not DXE_DRIVER, DXE_RUNTIME_DIRVER, UEFI_DRIVER
1972 // UEFI_APPLICATION and DXE_SAL_DRIVER add the NULL at the end of
1973 // _gDriverSetVirtualAddressMapEvent list.
1975 if (!UefiOrDxeModule
) {
1976 fileBuffer
.append(",\r\n NULL");
1978 fileBuffer
.append("\r\n};\r\n\r\n");
1981 if (UefiOrDxeModule
) {
1983 // Entry point lib for these module types needs to know the count.
1986 .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED const UINTN _gDriverExitBootServicesEventCount = ");
1989 // If the list is not valid or has no entries set count to zero else
1990 // set count to the number of valid entries.
1993 if (exitBootList
!= null) {
1994 for (i
= 0; i
< exitBootList
.length
; i
++) {
1995 if (exitBootList
[i
].equalsIgnoreCase("")) {
2001 fileBuffer
.append(Integer
.toString(Count
));
2002 fileBuffer
.append(";\r\n\r\n");
2005 if (exitBootList
== null) {
2006 if (UefiOrDxeModule
) {
2008 // No data so make a NULL list.
2011 .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED const EFI_EVENT_NOTIFY _gDriverExitBootServicesEvent[] = {\r\n");
2012 fileBuffer
.append(" NULL\r\n");
2013 fileBuffer
.append("};\r\n\r\n");
2017 // Write DriverExitBootServices function definition.
2019 for (i
= 0; i
< exitBootList
.length
; i
++) {
2020 if (exitBootList
[i
].equalsIgnoreCase("")) {
2024 fileBuffer
.append("VOID\r\n");
2025 fileBuffer
.append("EFIAPI\r\n");
2026 fileBuffer
.append(exitBootList
[i
]);
2027 fileBuffer
.append(" (\r\n");
2028 fileBuffer
.append(" IN EFI_EVENT Event,\r\n");
2029 fileBuffer
.append(" IN VOID *Context\r\n");
2030 fileBuffer
.append(" );\r\n\r\n");
2034 // Write DriverExitBootServices entry point array.
2037 .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED const EFI_EVENT_NOTIFY _gDriverExitBootServicesEvent[] = {");
2038 for (i
= 0; i
< exitBootList
.length
; i
++) {
2039 if (exitBootList
[i
].equalsIgnoreCase("")) {
2044 fileBuffer
.append("\r\n ");
2046 fileBuffer
.append(",\r\n ");
2048 fileBuffer
.append(exitBootList
[i
]);
2050 if (!UefiOrDxeModule
) {
2051 fileBuffer
.append(",\r\n NULL");
2053 fileBuffer
.append("\r\n};\r\n\r\n");
2058 private void copyFlashMapHToDebugDir() throws AutoGenException
{
2060 File inFile
= new File(fvDir
+ File
.separatorChar
+ CommonDefinition
.flashMapH
);
2061 int size
= (int)inFile
.length();
2062 byte[] buffer
= new byte[size
];
2063 File outFile
= new File (this.outputPath
+ File
.separatorChar
+ CommonDefinition
.tianoR8FlashMapH
);
2065 // If TianoR8FlashMap.h existed and the flashMap.h don't change,
2068 if ((!outFile
.exists()) ||(inFile
.lastModified() - outFile
.lastModified()) >= 0) {
2070 if (inFile
.exists()) {
2071 FileInputStream fis
= new FileInputStream (inFile
);
2073 FileOutputStream fos
= new FileOutputStream(outFile
);
2078 throw new AutoGenException("The flashMap.h file don't exist!!");
2080 } catch (Exception e
){
2081 throw new AutoGenException(e
.getMessage());