]> git.proxmox.com Git - mirror_edk2.git/blob - BaseTools/Source/Python/GenFds/FfsInfStatement.py
Fix build break caused by adding DebugAgentLib to the DXE Core.
[mirror_edk2.git] / BaseTools / Source / Python / GenFds / FfsInfStatement.py
1 ## @file
2 # process FFS generation from INF statement
3 #
4 # Copyright (c) 2007, Intel Corporation
5 #
6 # All rights reserved. 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
10 #
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.
13 #
14
15 ##
16 # Import Modules
17 #
18 import Rule
19 import os
20 import shutil
21 from GenFdsGlobalVariable import GenFdsGlobalVariable
22 import Ffs
23 import subprocess
24 import sys
25 import Section
26 import RuleSimpleFile
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
35 ## generate FFS from INF
36 #
37 #
38 class FfsInfStatement(FfsInfStatementClassObject):
39 ## The constructor
40 #
41 # @param self The object pointer
42 #
43 def __init__(self):
44 FfsInfStatementClassObject.__init__(self)
45 self.TargetOverrideList = []
46 self.ShadowFromInfFile = None
47 self.KeepRelocFromRule = None
48 self.InDsc = True
49 self.OptRomDefs = {}
50 self.PiSpecVersion = 0
51
52 ## __InfParse() method
53 #
54 # Parse inf file to get module information
55 #
56 # @param self The object pointer
57 # @param Dict dictionary contains macro and value pair
58 #
59 def __InfParse__(self, Dict = {}):
60
61 GenFdsGlobalVariable.VerboseLogger( " Begine parsing INf file : %s" %self.InfFileName)
62
63 self.InfFileName = self.InfFileName.replace('$(WORKSPACE)', '')
64 if self.InfFileName[0] == '\\' or self.InfFileName[0] == '/' :
65 self.InfFileName = self.InfFileName[1:]
66
67 if self.InfFileName.find('$') == -1:
68 InfPath = NormPath(self.InfFileName)
69 if not os.path.exists(InfPath):
70 InfPath = GenFdsGlobalVariable.ReplaceWorkspaceMacro(InfPath)
71 if not os.path.exists(InfPath):
72 EdkLogger.error("GenFds", GENFDS_ERROR, "Non-existant Module %s !" % (self.InfFileName))
73
74 self.CurrentArch = self.GetCurrentArch()
75 #
76 # Get the InfClass object
77 #
78
79 PathClassObj = PathClass(self.InfFileName, GenFdsGlobalVariable.WorkSpaceDir)
80 ErrorCode, ErrorInfo = PathClassObj.Validate()
81 if ErrorCode != 0:
82 EdkLogger.error("GenFds", ErrorCode, ExtraData=ErrorInfo)
83
84 if self.CurrentArch != None:
85
86 Inf = GenFdsGlobalVariable.WorkSpace.BuildObject[PathClassObj, self.CurrentArch]
87 #
88 # Set Ffs BaseName, MdouleGuid, ModuleType, Version, OutputPath
89 #
90 self.BaseName = Inf.BaseName
91 self.ModuleGuid = Inf.Guid
92 self.ModuleType = Inf.ModuleType
93 if Inf.Specification != None and 'PI_SPECIFICATION_VERSION' in Inf.Specification:
94 self.PiSpecVersion = Inf.Specification['PI_SPECIFICATION_VERSION']
95 if Inf.AutoGenVersion < 0x00010005:
96 self.ModuleType = Inf.ComponentType
97 self.VersionString = Inf.Version
98 self.BinFileList = Inf.Binaries
99 self.SourceFileList = Inf.Sources
100 if self.KeepReloc == None and Inf.Shadow:
101 self.ShadowFromInfFile = Inf.Shadow
102
103 else:
104 Inf = GenFdsGlobalVariable.WorkSpace.BuildObject[PathClassObj, 'COMMON']
105 self.BaseName = Inf.BaseName
106 self.ModuleGuid = Inf.Guid
107 self.ModuleType = Inf.ModuleType
108 if Inf.Specification != None and 'PI_SPECIFICATION_VERSION' in Inf.Specification:
109 self.PiSpecVersion = Inf.Specification['PI_SPECIFICATION_VERSION']
110 self.VersionString = Inf.Version
111 self.BinFileList = Inf.Binaries
112 self.SourceFileList = Inf.Sources
113 if self.BinFileList == []:
114 EdkLogger.error("GenFds", GENFDS_ERROR,
115 "INF %s specified in FDF could not be found in build ARCH %s!" \
116 % (self.InfFileName, GenFdsGlobalVariable.ArchList))
117
118 if len(self.SourceFileList) != 0 and not self.InDsc:
119 EdkLogger.warn("GenFds", GENFDS_ERROR, "Module %s NOT found in DSC file; Is it really a binary module?" % (self.InfFileName))
120
121 if self.ModuleType == 'SMM_CORE' and self.PiSpecVersion < 0x0001000A:
122 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)
123
124 if Inf._Defs != None and len(Inf._Defs) > 0:
125 self.OptRomDefs.update(Inf._Defs)
126
127 GenFdsGlobalVariable.VerboseLogger( "BaseName : %s" %self.BaseName)
128 GenFdsGlobalVariable.VerboseLogger("ModuleGuid : %s" %self.ModuleGuid)
129 GenFdsGlobalVariable.VerboseLogger("ModuleType : %s" %self.ModuleType)
130 GenFdsGlobalVariable.VerboseLogger("VersionString : %s" %self.VersionString)
131 GenFdsGlobalVariable.VerboseLogger("InfFileName :%s" %self.InfFileName)
132
133 #
134 # Set OutputPath = ${WorkSpace}\Build\Fv\Ffs\${ModuleGuid}+ ${MdouleName}\
135 #
136
137 self.OutputPath = os.path.join(GenFdsGlobalVariable.FfsDir, \
138 self.ModuleGuid + self.BaseName)
139 if not os.path.exists(self.OutputPath) :
140 os.makedirs(self.OutputPath)
141
142 self.EfiOutputPath = self.__GetEFIOutPutPath__()
143 GenFdsGlobalVariable.VerboseLogger( "ModuelEFIPath: " + self.EfiOutputPath)
144
145 ## GenFfs() method
146 #
147 # Generate FFS
148 #
149 # @param self The object pointer
150 # @param Dict dictionary contains macro and value pair
151 # @retval string Generated FFS file name
152 #
153 def GenFfs(self, Dict = {}):
154 #
155 # Parse Inf file get Module related information
156 #
157
158 self.__InfParse__(Dict)
159 #
160 # Get the rule of how to generate Ffs file
161 #
162 Rule = self.__GetRule__()
163 GenFdsGlobalVariable.VerboseLogger( "Packing binaries from inf file : %s" %self.InfFileName)
164 #
165 # Convert Fv File Type for PI1.1 SMM driver.
166 #
167 if self.ModuleType == 'DXE_SMM_DRIVER' and self.PiSpecVersion >= 0x0001000A:
168 if Rule.FvFileType == 'DRIVER':
169 Rule.FvFileType = 'SMM'
170 #
171 # Framework SMM Driver has no SMM FV file type
172 #
173 if self.ModuleType == 'DXE_SMM_DRIVER' and self.PiSpecVersion < 0x0001000A:
174 if Rule.FvFileType == 'SMM' or Rule.FvFileType == 'SMM_CORE':
175 EdkLogger.error("GenFds", FORMAT_NOT_SUPPORTED, "Framework SMM module doesn't support SMM or SMM_CORE FV file type", File=self.InfFileName)
176 #
177 # For the rule only has simpleFile
178 #
179 if isinstance (Rule, RuleSimpleFile.RuleSimpleFile) :
180 SectionOutputList = self.__GenSimpleFileSection__(Rule)
181 FfsOutput = self.__GenSimpleFileFfs__(Rule, SectionOutputList)
182 return FfsOutput
183 #
184 # For Rule has ComplexFile
185 #
186 elif isinstance(Rule, RuleComplexFile.RuleComplexFile):
187 InputSectList, InputSectAlignments = self.__GenComplexFileSection__(Rule)
188 FfsOutput = self.__GenComplexFileFfs__(Rule, InputSectList, InputSectAlignments)
189
190 return FfsOutput
191
192 ## __ExtendMacro__() method
193 #
194 # Replace macro with its value
195 #
196 # @param self The object pointer
197 # @param String The string to be replaced
198 # @retval string Macro replaced string
199 #
200 def __ExtendMacro__ (self, String):
201 MacroDict = {
202 '$(INF_OUTPUT)' : self.EfiOutputPath,
203 '$(MODULE_NAME)' : self.BaseName,
204 '$(BUILD_NUMBER)': self.BuildNum,
205 '$(INF_VERSION)' : self.VersionString,
206 '$(NAMED_GUID)' : self.ModuleGuid
207 }
208 String = GenFdsGlobalVariable.MacroExtend(String, MacroDict)
209 return String
210
211 ## __GetRule__() method
212 #
213 # Get correct rule for generating FFS for this INF
214 #
215 # @param self The object pointer
216 # @retval Rule Rule object
217 #
218 def __GetRule__ (self) :
219 CurrentArchList = []
220 if self.CurrentArch == None:
221 CurrentArchList = ['common']
222 else:
223 CurrentArchList.append(self.CurrentArch)
224
225 for CurrentArch in CurrentArchList:
226 RuleName = 'RULE' + \
227 '.' + \
228 CurrentArch.upper() + \
229 '.' + \
230 self.ModuleType.upper()
231 if self.Rule != None:
232 RuleName = RuleName + \
233 '.' + \
234 self.Rule.upper()
235
236 Rule = GenFdsGlobalVariable.FdfParser.Profile.RuleDict.get(RuleName)
237 if Rule != None:
238 GenFdsGlobalVariable.VerboseLogger ("Want To Find Rule Name is : " + RuleName)
239 return Rule
240
241 RuleName = 'RULE' + \
242 '.' + \
243 'COMMON' + \
244 '.' + \
245 self.ModuleType.upper()
246
247 if self.Rule != None:
248 RuleName = RuleName + \
249 '.' + \
250 self.Rule.upper()
251
252 GenFdsGlobalVariable.VerboseLogger ('Trying to apply common rule %s for INF %s' % (RuleName, self.InfFileName))
253
254 Rule = GenFdsGlobalVariable.FdfParser.Profile.RuleDict.get(RuleName)
255 if Rule != None:
256 GenFdsGlobalVariable.VerboseLogger ("Want To Find Rule Name is : " + RuleName)
257 return Rule
258
259 if Rule == None :
260 EdkLogger.error("GenFds", GENFDS_ERROR, 'Don\'t Find common rule %s for INF %s' \
261 % (RuleName, self.InfFileName))
262
263 ## __GetPlatformArchList__() method
264 #
265 # Get Arch list this INF built under
266 #
267 # @param self The object pointer
268 # @retval list Arch list
269 #
270 def __GetPlatformArchList__(self):
271
272 InfFileKey = os.path.normpath(os.path.join(GenFdsGlobalVariable.WorkSpaceDir, self.InfFileName))
273 DscArchList = []
274 PlatformDataBase = GenFdsGlobalVariable.WorkSpace.BuildObject[GenFdsGlobalVariable.ActivePlatform, 'IA32']
275 if PlatformDataBase != None:
276 if InfFileKey in PlatformDataBase.Modules:
277 DscArchList.append ('IA32')
278
279 PlatformDataBase = GenFdsGlobalVariable.WorkSpace.BuildObject[GenFdsGlobalVariable.ActivePlatform, 'X64']
280 if PlatformDataBase != None:
281 if InfFileKey in PlatformDataBase.Modules:
282 DscArchList.append ('X64')
283
284 PlatformDataBase = GenFdsGlobalVariable.WorkSpace.BuildObject[GenFdsGlobalVariable.ActivePlatform, 'IPF']
285 if PlatformDataBase != None:
286 if InfFileKey in (PlatformDataBase.Modules):
287 DscArchList.append ('IPF')
288
289 PlatformDataBase = GenFdsGlobalVariable.WorkSpace.BuildObject[GenFdsGlobalVariable.ActivePlatform, 'ARM']
290 if PlatformDataBase != None:
291 if InfFileKey in (PlatformDataBase.Modules):
292 DscArchList.append ('ARM')
293
294 PlatformDataBase = GenFdsGlobalVariable.WorkSpace.BuildObject[GenFdsGlobalVariable.ActivePlatform, 'EBC']
295 if PlatformDataBase != None:
296 if InfFileKey in (PlatformDataBase.Modules):
297 DscArchList.append ('EBC')
298
299 return DscArchList
300
301 ## GetCurrentArch() method
302 #
303 # Get Arch list of the module from this INF is to be placed into flash
304 #
305 # @param self The object pointer
306 # @retval list Arch list
307 #
308 def GetCurrentArch(self) :
309
310 TargetArchList = GenFdsGlobalVariable.ArchList
311
312 PlatformArchList = self.__GetPlatformArchList__()
313
314 CurArchList = TargetArchList
315 if PlatformArchList != []:
316 CurArchList = list(set (TargetArchList) & set (PlatformArchList))
317 GenFdsGlobalVariable.VerboseLogger ("Valid target architecture(s) is : " + " ".join(CurArchList))
318
319 ArchList = []
320 if self.KeyStringList != []:
321 for Key in self.KeyStringList:
322 Key = GenFdsGlobalVariable.MacroExtend(Key)
323 Target, Tag, Arch = Key.split('_')
324 if Arch in CurArchList:
325 ArchList.append(Arch)
326 if Target not in self.TargetOverrideList:
327 self.TargetOverrideList.append(Target)
328 else:
329 ArchList = CurArchList
330
331 UseArchList = TargetArchList
332 if self.UseArch != None:
333 UseArchList = []
334 UseArchList.append(self.UseArch)
335 ArchList = list(set (UseArchList) & set (ArchList))
336
337 self.InfFileName = NormPath(self.InfFileName)
338 if len(PlatformArchList) == 0:
339 self.InDsc = False
340 PathClassObj = PathClass(self.InfFileName, GenFdsGlobalVariable.WorkSpaceDir)
341 ErrorCode, ErrorInfo = PathClassObj.Validate()
342 if ErrorCode != 0:
343 EdkLogger.error("GenFds", ErrorCode, ExtraData=ErrorInfo)
344 if len(ArchList) == 1:
345 Arch = ArchList[0]
346 return Arch
347 elif len(ArchList) > 1:
348 if len(PlatformArchList) == 0:
349 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))
350 else:
351 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))
352 else:
353 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." \
354 % (self.InfFileName, str(PlatformArchList), GenFdsGlobalVariable.ActivePlatform, str(set (UseArchList) & set (TargetArchList))))
355
356 ## __GetEFIOutPutPath__() method
357 #
358 # Get the output path for generated files
359 #
360 # @param self The object pointer
361 # @retval string Path that output files from this INF go to
362 #
363 def __GetEFIOutPutPath__(self):
364 Arch = ''
365 OutputPath = ''
366 (ModulePath, FileName) = os.path.split(self.InfFileName)
367 Index = FileName.find('.')
368 FileName = FileName[0:Index]
369 Arch = "NoneArch"
370 if self.CurrentArch != None:
371 Arch = self.CurrentArch
372
373 OutputPath = os.path.join(GenFdsGlobalVariable.OutputDirDict[Arch],
374 Arch ,
375 ModulePath,
376 FileName,
377 'OUTPUT'
378 )
379 OutputPath = os.path.realpath(OutputPath)
380 return OutputPath
381
382 ## __GenSimpleFileSection__() method
383 #
384 # Generate section by specified file name or a list of files with file extension
385 #
386 # @param self The object pointer
387 # @param Rule The rule object used to generate section
388 # @retval string File name of the generated section file
389 #
390 def __GenSimpleFileSection__(self, Rule):
391 #
392 # Prepare the parameter of GenSection
393 #
394 FileList = []
395 OutputFileList = []
396 if Rule.FileName != None:
397 GenSecInputFile = self.__ExtendMacro__(Rule.FileName)
398 else:
399 FileList, IsSect = Section.Section.GetFileList(self, '', Rule.FileExtension)
400
401 Index = 1
402 SectionType = Rule.SectionType
403 #
404 # Convert Fv Section Type for PI1.1 SMM driver.
405 #
406 if self.ModuleType == 'DXE_SMM_DRIVER' and self.PiSpecVersion >= 0x0001000A:
407 if SectionType == 'DXE_DEPEX':
408 SectionType = 'SMM_DEPEX'
409 #
410 # Framework SMM Driver has no SMM_DEPEX section type
411 #
412 if self.ModuleType == 'DXE_SMM_DRIVER' and self.PiSpecVersion < 0x0001000A:
413 if SectionType == 'SMM_DEPEX':
414 EdkLogger.error("GenFds", FORMAT_NOT_SUPPORTED, "Framework SMM module doesn't support SMM_DEPEX section type", File=self.InfFileName)
415 NoStrip = True
416 if self.ModuleType in ('SEC', 'PEI_CORE', 'PEIM'):
417 if self.KeepReloc != None:
418 NoStrip = self.KeepReloc
419 elif Rule.KeepReloc != None:
420 NoStrip = Rule.KeepReloc
421 elif self.ShadowFromInfFile != None:
422 NoStrip = self.ShadowFromInfFile
423
424 if FileList != [] :
425 for File in FileList:
426
427 SecNum = '%d' %Index
428 GenSecOutputFile= self.__ExtendMacro__(Rule.NameGuid) + \
429 Ffs.Ffs.SectionSuffix[SectionType] + 'SEC' + SecNum
430 Index = Index + 1
431 OutputFile = os.path.join(self.OutputPath, GenSecOutputFile)
432
433 if not NoStrip:
434 FileBeforeStrip = os.path.join(self.OutputPath, ModuleName + '.reloc')
435 if not os.path.exists(FileBeforeStrip) or \
436 (os.path.getmtime(File) > os.path.getmtime(FileBeforeStrip)):
437 shutil.copyfile(File, FileBeforeStrip)
438 StrippedFile = os.path.join(self.OutputPath, ModuleName + '.stipped')
439 GenFdsGlobalVariable.GenerateFirmwareImage(
440 StrippedFile,
441 [GenFdsGlobalVariable.MacroExtend(File, Dict, self.CurrentArch)],
442 Strip=True
443 )
444 File = StrippedFile
445
446 if SectionType == 'TE':
447 TeFile = os.path.join( self.OutputPath, self.ModuleGuid + 'Te.raw')
448 GenFdsGlobalVariable.GenerateFirmwareImage(
449 TeFile,
450 [GenFdsGlobalVariable.MacroExtend(File, Dict, self.CurrentArch)],
451 Type='te'
452 )
453 File = TeFile
454
455 GenFdsGlobalVariable.GenerateSection(OutputFile, [File], Section.Section.SectionType[SectionType])
456 OutputFileList.append(OutputFile)
457 else:
458 SecNum = '%d' %Index
459 GenSecOutputFile= self.__ExtendMacro__(Rule.NameGuid) + \
460 Ffs.Ffs.SectionSuffix[SectionType] + 'SEC' + SecNum
461 OutputFile = os.path.join(self.OutputPath, GenSecOutputFile)
462
463 if not NoStrip:
464 FileBeforeStrip = os.path.join(self.OutputPath, ModuleName + '.reloc')
465 if not os.path.exists(FileBeforeStrip) or \
466 (os.path.getmtime(GenSecInputFile) > os.path.getmtime(FileBeforeStrip)):
467 shutil.copyfile(GenSecInputFile, FileBeforeStrip)
468 StrippedFile = os.path.join(self.OutputPath, ModuleName + '.stipped')
469 GenFdsGlobalVariable.GenerateFirmwareImage(
470 StrippedFile,
471 [GenFdsGlobalVariable.MacroExtend(GenSecInputFile, Dict, self.CurrentArch)],
472 Strip=True
473 )
474 GenSecInputFile = StrippedFile
475
476 if SectionType == 'TE':
477 TeFile = os.path.join( self.OutputPath, self.ModuleGuid + 'Te.raw')
478 GenFdsGlobalVariable.GenerateFirmwareImage(
479 TeFile,
480 [GenFdsGlobalVariable.MacroExtend(File, Dict, self.CurrentArch)],
481 Type='te'
482 )
483 GenSecInputFile = TeFile
484
485 GenFdsGlobalVariable.GenerateSection(OutputFile, [GenSecInputFile], Section.Section.SectionType[SectionType])
486 OutputFileList.append(OutputFile)
487
488 return OutputFileList
489
490 ## __GenSimpleFileFfs__() method
491 #
492 # Generate FFS
493 #
494 # @param self The object pointer
495 # @param Rule The rule object used to generate section
496 # @param InputFileList The output file list from GenSection
497 # @retval string Generated FFS file name
498 #
499 def __GenSimpleFileFfs__(self, Rule, InputFileList):
500 FfsOutput = self.OutputPath + \
501 os.sep + \
502 self.__ExtendMacro__(Rule.NameGuid) + \
503 '.ffs'
504
505 GenFdsGlobalVariable.VerboseLogger(self.__ExtendMacro__(Rule.NameGuid))
506 InputSection = []
507 SectionAlignments = []
508 for InputFile in InputFileList:
509 InputSection.append(InputFile)
510 SectionAlignments.append(Rule.Alignment)
511
512 if Rule.NameGuid != None and Rule.NameGuid.startswith('PCD('):
513 PcdValue = GenFdsGlobalVariable.GetPcdValue(Rule.NameGuid)
514 if len(PcdValue) == 0:
515 EdkLogger.error("GenFds", GENFDS_ERROR, '%s NOT defined.' \
516 % (Rule.NameGuid))
517 if PcdValue.startswith('{'):
518 PcdValue = GuidStructureByteArrayToGuidString(PcdValue)
519 RegistryGuidStr = PcdValue
520 if len(RegistryGuidStr) == 0:
521 EdkLogger.error("GenFds", GENFDS_ERROR, 'GUID value for %s in wrong format.' \
522 % (Rule.NameGuid))
523 self.ModuleGuid = RegistryGuidStr
524
525 GenFdsGlobalVariable.GenerateFfs(FfsOutput, InputSection,
526 Ffs.Ffs.FdfFvFileTypeToFileType[Rule.FvFileType],
527 self.ModuleGuid, Fixed=Rule.Fixed,
528 CheckSum=Rule.CheckSum, Align=Rule.Alignment,
529 SectionAlign=SectionAlignments
530 )
531 return FfsOutput
532
533 ## __GenComplexFileSection__() method
534 #
535 # Generate section by sections in Rule
536 #
537 # @param self The object pointer
538 # @param Rule The rule object used to generate section
539 # @retval string File name of the generated section file
540 #
541 def __GenComplexFileSection__(self, Rule):
542 if self.ModuleType in ('SEC', 'PEI_CORE', 'PEIM'):
543 if Rule.KeepReloc != None:
544 self.KeepRelocFromRule = Rule.KeepReloc
545 SectFiles = []
546 SectAlignments = []
547 Index = 1
548 for Sect in Rule.SectionList:
549 SecIndex = '%d' %Index
550 SectList = []
551 #
552 # Convert Fv Section Type for PI1.1 SMM driver.
553 #
554 if self.ModuleType == 'DXE_SMM_DRIVER' and self.PiSpecVersion >= 0x0001000A:
555 if Sect.SectionType == 'DXE_DEPEX':
556 Sect.SectionType = 'SMM_DEPEX'
557 #
558 # Framework SMM Driver has no SMM_DEPEX section type
559 #
560 if self.ModuleType == 'DXE_SMM_DRIVER' and self.PiSpecVersion < 0x0001000A:
561 if Sect.SectionType == 'SMM_DEPEX':
562 EdkLogger.error("GenFds", FORMAT_NOT_SUPPORTED, "Framework SMM module doesn't support SMM_DEPEX section type", File=self.InfFileName)
563 if Rule.KeyStringList != []:
564 SectList, Align = Sect.GenSection(self.OutputPath , self.ModuleGuid, SecIndex, Rule.KeyStringList, self)
565 else :
566 SectList, Align = Sect.GenSection(self.OutputPath , self.ModuleGuid, SecIndex, self.KeyStringList, self)
567 for SecName in SectList :
568 SectFiles.append(SecName)
569 SectAlignments.append(Align)
570 Index = Index + 1
571 return SectFiles, SectAlignments
572
573 ## __GenComplexFileFfs__() method
574 #
575 # Generate FFS
576 #
577 # @param self The object pointer
578 # @param Rule The rule object used to generate section
579 # @param InputFileList The output file list from GenSection
580 # @retval string Generated FFS file name
581 #
582 def __GenComplexFileFfs__(self, Rule, InputFile, Alignments):
583
584 if Rule.NameGuid != None and Rule.NameGuid.startswith('PCD('):
585 PcdValue = GenFdsGlobalVariable.GetPcdValue(Rule.NameGuid)
586 if len(PcdValue) == 0:
587 EdkLogger.error("GenFds", GENFDS_ERROR, '%s NOT defined.' \
588 % (Rule.NameGuid))
589 if PcdValue.startswith('{'):
590 PcdValue = GuidStructureByteArrayToGuidString(PcdValue)
591 RegistryGuidStr = PcdValue
592 if len(RegistryGuidStr) == 0:
593 EdkLogger.error("GenFds", GENFDS_ERROR, 'GUID value for %s in wrong format.' \
594 % (Rule.NameGuid))
595 self.ModuleGuid = RegistryGuidStr
596
597 FfsOutput = os.path.join( self.OutputPath, self.ModuleGuid + '.ffs')
598 GenFdsGlobalVariable.GenerateFfs(FfsOutput, InputFile,
599 Ffs.Ffs.FdfFvFileTypeToFileType[Rule.FvFileType],
600 self.ModuleGuid, Fixed=Rule.Fixed,
601 CheckSum=Rule.CheckSum, Align=Rule.Alignment,
602 SectionAlign=Alignments
603 )
604 return FfsOutput
605
606 ## __GetGenFfsCmdParameter__() method
607 #
608 # Create parameter string for GenFfs
609 #
610 # @param self The object pointer
611 # @param Rule The rule object used to generate section
612 # @retval tuple (FileType, Fixed, CheckSum, Alignment)
613 #
614 def __GetGenFfsCmdParameter__(self, Rule):
615 result = tuple()
616 result += ('-t', Ffs.Ffs.FdfFvFileTypeToFileType[Rule.FvFileType])
617 if Rule.Fixed != False:
618 result += ('-x',)
619 if Rule.CheckSum != False:
620 result += ('-s',)
621
622 if Rule.Alignment != None and Rule.Alignment != '':
623 result += ('-a', Rule.Alignment)
624
625 return result