2 # process FFS generation from INF statement
4 # Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
6 # This program and the accompanying materials
7 # are licensed and made available under the terms and conditions of the BSD License
8 # which accompanies this distribution. The full text of the license may be found at
9 # http://opensource.org/licenses/bsd-license.php
11 # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
21 from GenFdsGlobalVariable
import GenFdsGlobalVariable
27 import RuleComplexFile
28 from CommonDataClass
.FdfClass
import FfsInfStatementClassObject
29 from Common
.String
import *
30 from Common
.Misc
import PathClass
31 from Common
.Misc
import GuidStructureByteArrayToGuidString
32 from Common
import EdkLogger
33 from Common
.BuildToolError
import *
34 from GuidSection
import GuidSection
35 from FvImageSection
import FvImageSection
36 from Common
.Misc
import PeImageClass
38 ## generate FFS from INF
41 class FfsInfStatement(FfsInfStatementClassObject
):
44 # @param self The object pointer
47 FfsInfStatementClassObject
.__init
__(self
)
48 self
.TargetOverrideList
= []
49 self
.ShadowFromInfFile
= None
50 self
.KeepRelocFromRule
= None
53 self
.PiSpecVersion
= 0
55 ## __InfParse() method
57 # Parse inf file to get module information
59 # @param self The object pointer
60 # @param Dict dictionary contains macro and value pair
62 def __InfParse__(self
, Dict
= {}):
64 GenFdsGlobalVariable
.VerboseLogger( " Begine parsing INf file : %s" %self
.InfFileName
)
66 self
.InfFileName
= self
.InfFileName
.replace('$(WORKSPACE)', '')
67 if self
.InfFileName
[0] == '\\' or self
.InfFileName
[0] == '/' :
68 self
.InfFileName
= self
.InfFileName
[1:]
70 if self
.InfFileName
.find('$') == -1:
71 InfPath
= NormPath(self
.InfFileName
)
72 if not os
.path
.exists(InfPath
):
73 InfPath
= GenFdsGlobalVariable
.ReplaceWorkspaceMacro(InfPath
)
74 if not os
.path
.exists(InfPath
):
75 EdkLogger
.error("GenFds", GENFDS_ERROR
, "Non-existant Module %s !" % (self
.InfFileName
))
77 self
.CurrentArch
= self
.GetCurrentArch()
79 # Get the InfClass object
82 PathClassObj
= PathClass(self
.InfFileName
, GenFdsGlobalVariable
.WorkSpaceDir
)
83 ErrorCode
, ErrorInfo
= PathClassObj
.Validate(".inf")
85 EdkLogger
.error("GenFds", ErrorCode
, ExtraData
=ErrorInfo
)
87 if self
.CurrentArch
!= None:
89 Inf
= GenFdsGlobalVariable
.WorkSpace
.BuildObject
[PathClassObj
, self
.CurrentArch
]
91 # Set Ffs BaseName, MdouleGuid, ModuleType, Version, OutputPath
93 self
.BaseName
= Inf
.BaseName
94 self
.ModuleGuid
= Inf
.Guid
95 self
.ModuleType
= Inf
.ModuleType
96 if Inf
.Specification
!= None and 'PI_SPECIFICATION_VERSION' in Inf
.Specification
:
97 self
.PiSpecVersion
= Inf
.Specification
['PI_SPECIFICATION_VERSION']
98 if Inf
.AutoGenVersion
< 0x00010005:
99 self
.ModuleType
= Inf
.ComponentType
100 self
.VersionString
= Inf
.Version
101 self
.BinFileList
= Inf
.Binaries
102 self
.SourceFileList
= Inf
.Sources
103 if self
.KeepReloc
== None and Inf
.Shadow
:
104 self
.ShadowFromInfFile
= Inf
.Shadow
107 Inf
= GenFdsGlobalVariable
.WorkSpace
.BuildObject
[PathClassObj
, 'COMMON']
108 self
.BaseName
= Inf
.BaseName
109 self
.ModuleGuid
= Inf
.Guid
110 self
.ModuleType
= Inf
.ModuleType
111 if Inf
.Specification
!= None and 'PI_SPECIFICATION_VERSION' in Inf
.Specification
:
112 self
.PiSpecVersion
= Inf
.Specification
['PI_SPECIFICATION_VERSION']
113 self
.VersionString
= Inf
.Version
114 self
.BinFileList
= Inf
.Binaries
115 self
.SourceFileList
= Inf
.Sources
116 if self
.BinFileList
== []:
117 EdkLogger
.error("GenFds", GENFDS_ERROR
,
118 "INF %s specified in FDF could not be found in build ARCH %s!" \
119 % (self
.InfFileName
, GenFdsGlobalVariable
.ArchList
))
121 if len(self
.SourceFileList
) != 0 and not self
.InDsc
:
122 EdkLogger
.warn("GenFds", GENFDS_ERROR
, "Module %s NOT found in DSC file; Is it really a binary module?" % (self
.InfFileName
))
124 if self
.ModuleType
== 'SMM_CORE' and self
.PiSpecVersion
< 0x0001000A:
125 EdkLogger
.error("GenFds", FORMAT_NOT_SUPPORTED
, "SMM_CORE module type can't be used in the module with PI_SPECIFICATION_VERSION less than 0x0001000A", File
=self
.InfFileName
)
127 if Inf
._Defs
!= None and len(Inf
._Defs
) > 0:
128 self
.OptRomDefs
.update(Inf
._Defs
)
130 GenFdsGlobalVariable
.VerboseLogger( "BaseName : %s" %self
.BaseName
)
131 GenFdsGlobalVariable
.VerboseLogger("ModuleGuid : %s" %self
.ModuleGuid
)
132 GenFdsGlobalVariable
.VerboseLogger("ModuleType : %s" %self
.ModuleType
)
133 GenFdsGlobalVariable
.VerboseLogger("VersionString : %s" %self
.VersionString
)
134 GenFdsGlobalVariable
.VerboseLogger("InfFileName :%s" %self
.InfFileName
)
137 # Set OutputPath = ${WorkSpace}\Build\Fv\Ffs\${ModuleGuid}+ ${MdouleName}\
140 self
.OutputPath
= os
.path
.join(GenFdsGlobalVariable
.FfsDir
, \
141 self
.ModuleGuid
+ self
.BaseName
)
142 if not os
.path
.exists(self
.OutputPath
) :
143 os
.makedirs(self
.OutputPath
)
145 self
.EfiOutputPath
= self
.__GetEFIOutPutPath
__()
146 GenFdsGlobalVariable
.VerboseLogger( "ModuelEFIPath: " + self
.EfiOutputPath
)
152 # @param self The object pointer
153 # @param Dict dictionary contains macro and value pair
154 # @param FvChildAddr Array of the inside FvImage base address
155 # @param FvParentAddr Parent Fv base address
156 # @retval string Generated FFS file name
158 def GenFfs(self
, Dict
= {}, FvChildAddr
= [], FvParentAddr
=None):
160 # Parse Inf file get Module related information
163 self
.__InfParse
__(Dict
)
166 # Allow binary type module not specify override rule in FDF file.
168 if len(self
.BinFileList
) >0 and not self
.InDsc
:
169 if self
.Rule
== None or self
.Rule
== "":
173 # Get the rule of how to generate Ffs file
175 Rule
= self
.__GetRule
__()
176 GenFdsGlobalVariable
.VerboseLogger( "Packing binaries from inf file : %s" %self
.InfFileName
)
178 # Convert Fv File Type for PI1.1 SMM driver.
180 if self
.ModuleType
== 'DXE_SMM_DRIVER' and self
.PiSpecVersion
>= 0x0001000A:
181 if Rule
.FvFileType
== 'DRIVER':
182 Rule
.FvFileType
= 'SMM'
184 # Framework SMM Driver has no SMM FV file type
186 if self
.ModuleType
== 'DXE_SMM_DRIVER' and self
.PiSpecVersion
< 0x0001000A:
187 if Rule
.FvFileType
== 'SMM' or Rule
.FvFileType
== 'SMM_CORE':
188 EdkLogger
.error("GenFds", FORMAT_NOT_SUPPORTED
, "Framework SMM module doesn't support SMM or SMM_CORE FV file type", File
=self
.InfFileName
)
190 # For the rule only has simpleFile
192 if isinstance (Rule
, RuleSimpleFile
.RuleSimpleFile
) :
193 SectionOutputList
= self
.__GenSimpleFileSection
__(Rule
)
194 FfsOutput
= self
.__GenSimpleFileFfs
__(Rule
, SectionOutputList
)
197 # For Rule has ComplexFile
199 elif isinstance(Rule
, RuleComplexFile
.RuleComplexFile
):
200 InputSectList
, InputSectAlignments
= self
.__GenComplexFileSection
__(Rule
, FvChildAddr
, FvParentAddr
)
201 FfsOutput
= self
.__GenComplexFileFfs
__(Rule
, InputSectList
, InputSectAlignments
)
205 ## __ExtendMacro__() method
207 # Replace macro with its value
209 # @param self The object pointer
210 # @param String The string to be replaced
211 # @retval string Macro replaced string
213 def __ExtendMacro__ (self
, String
):
215 '$(INF_OUTPUT)' : self
.EfiOutputPath
,
216 '$(MODULE_NAME)' : self
.BaseName
,
217 '$(BUILD_NUMBER)': self
.BuildNum
,
218 '$(INF_VERSION)' : self
.VersionString
,
219 '$(NAMED_GUID)' : self
.ModuleGuid
221 String
= GenFdsGlobalVariable
.MacroExtend(String
, MacroDict
)
224 ## __GetRule__() method
226 # Get correct rule for generating FFS for this INF
228 # @param self The object pointer
229 # @retval Rule Rule object
231 def __GetRule__ (self
) :
233 if self
.CurrentArch
== None:
234 CurrentArchList
= ['common']
236 CurrentArchList
.append(self
.CurrentArch
)
238 for CurrentArch
in CurrentArchList
:
239 RuleName
= 'RULE' + \
241 CurrentArch
.upper() + \
243 self
.ModuleType
.upper()
244 if self
.Rule
!= None:
245 RuleName
= RuleName
+ \
249 Rule
= GenFdsGlobalVariable
.FdfParser
.Profile
.RuleDict
.get(RuleName
)
251 GenFdsGlobalVariable
.VerboseLogger ("Want To Find Rule Name is : " + RuleName
)
254 RuleName
= 'RULE' + \
258 self
.ModuleType
.upper()
260 if self
.Rule
!= None:
261 RuleName
= RuleName
+ \
265 GenFdsGlobalVariable
.VerboseLogger ('Trying to apply common rule %s for INF %s' % (RuleName
, self
.InfFileName
))
267 Rule
= GenFdsGlobalVariable
.FdfParser
.Profile
.RuleDict
.get(RuleName
)
269 GenFdsGlobalVariable
.VerboseLogger ("Want To Find Rule Name is : " + RuleName
)
273 EdkLogger
.error("GenFds", GENFDS_ERROR
, 'Don\'t Find common rule %s for INF %s' \
274 % (RuleName
, self
.InfFileName
))
276 ## __GetPlatformArchList__() method
278 # Get Arch list this INF built under
280 # @param self The object pointer
281 # @retval list Arch list
283 def __GetPlatformArchList__(self
):
285 InfFileKey
= os
.path
.normpath(os
.path
.join(GenFdsGlobalVariable
.WorkSpaceDir
, self
.InfFileName
))
287 PlatformDataBase
= GenFdsGlobalVariable
.WorkSpace
.BuildObject
[GenFdsGlobalVariable
.ActivePlatform
, 'IA32']
288 if PlatformDataBase
!= None:
289 if InfFileKey
in PlatformDataBase
.Modules
:
290 DscArchList
.append ('IA32')
292 PlatformDataBase
= GenFdsGlobalVariable
.WorkSpace
.BuildObject
[GenFdsGlobalVariable
.ActivePlatform
, 'X64']
293 if PlatformDataBase
!= None:
294 if InfFileKey
in PlatformDataBase
.Modules
:
295 DscArchList
.append ('X64')
297 PlatformDataBase
= GenFdsGlobalVariable
.WorkSpace
.BuildObject
[GenFdsGlobalVariable
.ActivePlatform
, 'IPF']
298 if PlatformDataBase
!= None:
299 if InfFileKey
in (PlatformDataBase
.Modules
):
300 DscArchList
.append ('IPF')
302 PlatformDataBase
= GenFdsGlobalVariable
.WorkSpace
.BuildObject
[GenFdsGlobalVariable
.ActivePlatform
, 'ARM']
303 if PlatformDataBase
!= None:
304 if InfFileKey
in (PlatformDataBase
.Modules
):
305 DscArchList
.append ('ARM')
307 PlatformDataBase
= GenFdsGlobalVariable
.WorkSpace
.BuildObject
[GenFdsGlobalVariable
.ActivePlatform
, 'EBC']
308 if PlatformDataBase
!= None:
309 if InfFileKey
in (PlatformDataBase
.Modules
):
310 DscArchList
.append ('EBC')
314 ## GetCurrentArch() method
316 # Get Arch list of the module from this INF is to be placed into flash
318 # @param self The object pointer
319 # @retval list Arch list
321 def GetCurrentArch(self
) :
323 TargetArchList
= GenFdsGlobalVariable
.ArchList
325 PlatformArchList
= self
.__GetPlatformArchList
__()
327 CurArchList
= TargetArchList
328 if PlatformArchList
!= []:
329 CurArchList
= list(set (TargetArchList
) & set (PlatformArchList
))
330 GenFdsGlobalVariable
.VerboseLogger ("Valid target architecture(s) is : " + " ".join(CurArchList
))
333 if self
.KeyStringList
!= []:
334 for Key
in self
.KeyStringList
:
335 Key
= GenFdsGlobalVariable
.MacroExtend(Key
)
336 Target
, Tag
, Arch
= Key
.split('_')
337 if Arch
in CurArchList
:
338 ArchList
.append(Arch
)
339 if Target
not in self
.TargetOverrideList
:
340 self
.TargetOverrideList
.append(Target
)
342 ArchList
= CurArchList
344 UseArchList
= TargetArchList
345 if self
.UseArch
!= None:
347 UseArchList
.append(self
.UseArch
)
348 ArchList
= list(set (UseArchList
) & set (ArchList
))
350 self
.InfFileName
= NormPath(self
.InfFileName
)
351 if len(PlatformArchList
) == 0:
353 PathClassObj
= PathClass(self
.InfFileName
, GenFdsGlobalVariable
.WorkSpaceDir
)
354 ErrorCode
, ErrorInfo
= PathClassObj
.Validate(".inf")
356 EdkLogger
.error("GenFds", ErrorCode
, ExtraData
=ErrorInfo
)
357 if len(ArchList
) == 1:
360 elif len(ArchList
) > 1:
361 if len(PlatformArchList
) == 0:
362 EdkLogger
.error("GenFds", GENFDS_ERROR
, "GenFds command line option has multiple ARCHs %s. Not able to determine which ARCH is valid for Module %s !" % (str(ArchList
), self
.InfFileName
))
364 EdkLogger
.error("GenFds", GENFDS_ERROR
, "Module built under multiple ARCHs %s. Not able to determine which output to put into flash for Module %s !" % (str(ArchList
), self
.InfFileName
))
366 EdkLogger
.error("GenFds", GENFDS_ERROR
, "Module %s appears under ARCH %s in platform %s, but current deduced ARCH is %s, so NO build output could be put into flash." \
367 % (self
.InfFileName
, str(PlatformArchList
), GenFdsGlobalVariable
.ActivePlatform
, str(set (UseArchList
) & set (TargetArchList
))))
369 ## __GetEFIOutPutPath__() method
371 # Get the output path for generated files
373 # @param self The object pointer
374 # @retval string Path that output files from this INF go to
376 def __GetEFIOutPutPath__(self
):
379 (ModulePath
, FileName
) = os
.path
.split(self
.InfFileName
)
380 Index
= FileName
.find('.')
381 FileName
= FileName
[0:Index
]
383 if self
.CurrentArch
!= None:
384 Arch
= self
.CurrentArch
386 OutputPath
= os
.path
.join(GenFdsGlobalVariable
.OutputDirDict
[Arch
],
392 OutputPath
= os
.path
.realpath(OutputPath
)
395 ## __GenSimpleFileSection__() method
397 # Generate section by specified file name or a list of files with file extension
399 # @param self The object pointer
400 # @param Rule The rule object used to generate section
401 # @retval string File name of the generated section file
403 def __GenSimpleFileSection__(self
, Rule
):
405 # Prepare the parameter of GenSection
409 GenSecInputFile
= None
410 if Rule
.FileName
!= None:
411 GenSecInputFile
= self
.__ExtendMacro
__(Rule
.FileName
)
412 if os
.path
.isabs(GenSecInputFile
):
413 GenSecInputFile
= os
.path
.normpath(GenSecInputFile
)
415 GenSecInputFile
= os
.path
.normpath(os
.path
.join(self
.EfiOutputPath
, GenSecInputFile
))
417 FileList
, IsSect
= Section
.Section
.GetFileList(self
, '', Rule
.FileExtension
)
420 SectionType
= Rule
.SectionType
422 # Convert Fv Section Type for PI1.1 SMM driver.
424 if self
.ModuleType
== 'DXE_SMM_DRIVER' and self
.PiSpecVersion
>= 0x0001000A:
425 if SectionType
== 'DXE_DEPEX':
426 SectionType
= 'SMM_DEPEX'
428 # Framework SMM Driver has no SMM_DEPEX section type
430 if self
.ModuleType
== 'DXE_SMM_DRIVER' and self
.PiSpecVersion
< 0x0001000A:
431 if SectionType
== 'SMM_DEPEX':
432 EdkLogger
.error("GenFds", FORMAT_NOT_SUPPORTED
, "Framework SMM module doesn't support SMM_DEPEX section type", File
=self
.InfFileName
)
434 if self
.ModuleType
in ('SEC', 'PEI_CORE', 'PEIM'):
435 if self
.KeepReloc
!= None:
436 NoStrip
= self
.KeepReloc
437 elif Rule
.KeepReloc
!= None:
438 NoStrip
= Rule
.KeepReloc
439 elif self
.ShadowFromInfFile
!= None:
440 NoStrip
= self
.ShadowFromInfFile
443 for File
in FileList
:
446 GenSecOutputFile
= self
.__ExtendMacro
__(Rule
.NameGuid
) + \
447 Ffs
.Ffs
.SectionSuffix
[SectionType
] + 'SEC' + SecNum
449 OutputFile
= os
.path
.join(self
.OutputPath
, GenSecOutputFile
)
450 File
= GenFdsGlobalVariable
.MacroExtend(File
, Dict
, self
.CurrentArch
)
452 #Get PE Section alignment when align is set to AUTO
453 if self
.Alignment
== 'Auto' and (SectionType
== 'PE32' or SectionType
== 'TE'):
454 ImageObj
= PeImageClass (File
)
455 if ImageObj
.SectionAlignment
< 0x400:
456 self
.Alignment
= str (ImageObj
.SectionAlignment
)
458 self
.Alignment
= str (ImageObj
.SectionAlignment
/ 0x400) + 'K'
461 FileBeforeStrip
= os
.path
.join(self
.OutputPath
, ModuleName
+ '.reloc')
462 if not os
.path
.exists(FileBeforeStrip
) or \
463 (os
.path
.getmtime(File
) > os
.path
.getmtime(FileBeforeStrip
)):
464 shutil
.copyfile(File
, FileBeforeStrip
)
465 StrippedFile
= os
.path
.join(self
.OutputPath
, ModuleName
+ '.stipped')
466 GenFdsGlobalVariable
.GenerateFirmwareImage(
473 if SectionType
== 'TE':
474 TeFile
= os
.path
.join( self
.OutputPath
, self
.ModuleGuid
+ 'Te.raw')
475 GenFdsGlobalVariable
.GenerateFirmwareImage(
482 GenFdsGlobalVariable
.GenerateSection(OutputFile
, [File
], Section
.Section
.SectionType
[SectionType
])
483 OutputFileList
.append(OutputFile
)
486 GenSecOutputFile
= self
.__ExtendMacro
__(Rule
.NameGuid
) + \
487 Ffs
.Ffs
.SectionSuffix
[SectionType
] + 'SEC' + SecNum
488 OutputFile
= os
.path
.join(self
.OutputPath
, GenSecOutputFile
)
489 GenSecInputFile
= GenFdsGlobalVariable
.MacroExtend(GenSecInputFile
, Dict
, self
.CurrentArch
)
491 #Get PE Section alignment when align is set to AUTO
492 if self
.Alignment
== 'Auto' and (SectionType
== 'PE32' or SectionType
== 'TE'):
493 ImageObj
= PeImageClass (GenSecInputFile
)
494 if ImageObj
.SectionAlignment
< 0x400:
495 self
.Alignment
= str (ImageObj
.SectionAlignment
)
497 self
.Alignment
= str (ImageObj
.SectionAlignment
/ 0x400) + 'K'
500 FileBeforeStrip
= os
.path
.join(self
.OutputPath
, ModuleName
+ '.reloc')
501 if not os
.path
.exists(FileBeforeStrip
) or \
502 (os
.path
.getmtime(GenSecInputFile
) > os
.path
.getmtime(FileBeforeStrip
)):
503 shutil
.copyfile(GenSecInputFile
, FileBeforeStrip
)
504 StrippedFile
= os
.path
.join(self
.OutputPath
, ModuleName
+ '.stipped')
505 GenFdsGlobalVariable
.GenerateFirmwareImage(
510 GenSecInputFile
= StrippedFile
512 if SectionType
== 'TE':
513 TeFile
= os
.path
.join( self
.OutputPath
, self
.ModuleGuid
+ 'Te.raw')
514 GenFdsGlobalVariable
.GenerateFirmwareImage(
519 GenSecInputFile
= TeFile
521 GenFdsGlobalVariable
.GenerateSection(OutputFile
, [GenSecInputFile
], Section
.Section
.SectionType
[SectionType
])
522 OutputFileList
.append(OutputFile
)
524 return OutputFileList
526 ## __GenSimpleFileFfs__() method
530 # @param self The object pointer
531 # @param Rule The rule object used to generate section
532 # @param InputFileList The output file list from GenSection
533 # @retval string Generated FFS file name
535 def __GenSimpleFileFfs__(self
, Rule
, InputFileList
):
536 FfsOutput
= self
.OutputPath
+ \
538 self
.__ExtendMacro
__(Rule
.NameGuid
) + \
541 GenFdsGlobalVariable
.VerboseLogger(self
.__ExtendMacro
__(Rule
.NameGuid
))
543 SectionAlignments
= []
544 for InputFile
in InputFileList
:
545 InputSection
.append(InputFile
)
546 SectionAlignments
.append(Rule
.SectAlignment
)
548 if Rule
.NameGuid
!= None and Rule
.NameGuid
.startswith('PCD('):
549 PcdValue
= GenFdsGlobalVariable
.GetPcdValue(Rule
.NameGuid
)
550 if len(PcdValue
) == 0:
551 EdkLogger
.error("GenFds", GENFDS_ERROR
, '%s NOT defined.' \
553 if PcdValue
.startswith('{'):
554 PcdValue
= GuidStructureByteArrayToGuidString(PcdValue
)
555 RegistryGuidStr
= PcdValue
556 if len(RegistryGuidStr
) == 0:
557 EdkLogger
.error("GenFds", GENFDS_ERROR
, 'GUID value for %s in wrong format.' \
559 self
.ModuleGuid
= RegistryGuidStr
561 GenFdsGlobalVariable
.GenerateFfs(FfsOutput
, InputSection
,
562 Ffs
.Ffs
.FdfFvFileTypeToFileType
[Rule
.FvFileType
],
563 self
.ModuleGuid
, Fixed
=Rule
.Fixed
,
564 CheckSum
=Rule
.CheckSum
, Align
=Rule
.Alignment
,
565 SectionAlign
=SectionAlignments
569 ## __GenComplexFileSection__() method
571 # Generate section by sections in Rule
573 # @param self The object pointer
574 # @param Rule The rule object used to generate section
575 # @param FvChildAddr Array of the inside FvImage base address
576 # @param FvParentAddr Parent Fv base address
577 # @retval string File name of the generated section file
579 def __GenComplexFileSection__(self
, Rule
, FvChildAddr
, FvParentAddr
):
580 if self
.ModuleType
in ('SEC', 'PEI_CORE', 'PEIM'):
581 if Rule
.KeepReloc
!= None:
582 self
.KeepRelocFromRule
= Rule
.KeepReloc
586 for Sect
in Rule
.SectionList
:
587 SecIndex
= '%d' %Index
590 # Convert Fv Section Type for PI1.1 SMM driver.
592 if self
.ModuleType
== 'DXE_SMM_DRIVER' and self
.PiSpecVersion
>= 0x0001000A:
593 if Sect
.SectionType
== 'DXE_DEPEX':
594 Sect
.SectionType
= 'SMM_DEPEX'
596 # Framework SMM Driver has no SMM_DEPEX section type
598 if self
.ModuleType
== 'DXE_SMM_DRIVER' and self
.PiSpecVersion
< 0x0001000A:
599 if Sect
.SectionType
== 'SMM_DEPEX':
600 EdkLogger
.error("GenFds", FORMAT_NOT_SUPPORTED
, "Framework SMM module doesn't support SMM_DEPEX section type", File
=self
.InfFileName
)
602 # process the inside FvImage from FvSection or GuidSection
604 if FvChildAddr
!= []:
605 if isinstance(Sect
, FvImageSection
):
606 Sect
.FvAddr
= FvChildAddr
.pop(0)
607 elif isinstance(Sect
, GuidSection
):
608 Sect
.FvAddr
= FvChildAddr
609 if FvParentAddr
!= None and isinstance(Sect
, GuidSection
):
610 Sect
.FvParentAddr
= FvParentAddr
612 if Rule
.KeyStringList
!= []:
613 SectList
, Align
= Sect
.GenSection(self
.OutputPath
, self
.ModuleGuid
, SecIndex
, Rule
.KeyStringList
, self
)
615 SectList
, Align
= Sect
.GenSection(self
.OutputPath
, self
.ModuleGuid
, SecIndex
, self
.KeyStringList
, self
)
616 for SecName
in SectList
:
617 SectFiles
.append(SecName
)
618 SectAlignments
.append(Align
)
620 return SectFiles
, SectAlignments
622 ## __GenComplexFileFfs__() method
626 # @param self The object pointer
627 # @param Rule The rule object used to generate section
628 # @param InputFileList The output file list from GenSection
629 # @retval string Generated FFS file name
631 def __GenComplexFileFfs__(self
, Rule
, InputFile
, Alignments
):
633 if Rule
.NameGuid
!= None and Rule
.NameGuid
.startswith('PCD('):
634 PcdValue
= GenFdsGlobalVariable
.GetPcdValue(Rule
.NameGuid
)
635 if len(PcdValue
) == 0:
636 EdkLogger
.error("GenFds", GENFDS_ERROR
, '%s NOT defined.' \
638 if PcdValue
.startswith('{'):
639 PcdValue
= GuidStructureByteArrayToGuidString(PcdValue
)
640 RegistryGuidStr
= PcdValue
641 if len(RegistryGuidStr
) == 0:
642 EdkLogger
.error("GenFds", GENFDS_ERROR
, 'GUID value for %s in wrong format.' \
644 self
.ModuleGuid
= RegistryGuidStr
646 FfsOutput
= os
.path
.join( self
.OutputPath
, self
.ModuleGuid
+ '.ffs')
647 GenFdsGlobalVariable
.GenerateFfs(FfsOutput
, InputFile
,
648 Ffs
.Ffs
.FdfFvFileTypeToFileType
[Rule
.FvFileType
],
649 self
.ModuleGuid
, Fixed
=Rule
.Fixed
,
650 CheckSum
=Rule
.CheckSum
, Align
=Rule
.Alignment
,
651 SectionAlign
=Alignments
655 ## __GetGenFfsCmdParameter__() method
657 # Create parameter string for GenFfs
659 # @param self The object pointer
660 # @param Rule The rule object used to generate section
661 # @retval tuple (FileType, Fixed, CheckSum, Alignment)
663 def __GetGenFfsCmdParameter__(self
, Rule
):
665 result
+= ('-t', Ffs
.Ffs
.FdfFvFileTypeToFileType
[Rule
.FvFileType
])
666 if Rule
.Fixed
!= False:
668 if Rule
.CheckSum
!= False:
671 if Rule
.Alignment
!= None and Rule
.Alignment
!= '':
672 result
+= ('-a', Rule
.Alignment
)