]>
git.proxmox.com Git - mirror_edk2.git/blob - BaseTools/Source/Python/GenFds/GenFds.py
4 # Copyright (c) 2007, Intel Corporation
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
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.
18 from optparse
import OptionParser
23 from Common
. BuildToolError
import *
24 from GenFdsGlobalVariable
import GenFdsGlobalVariable
25 from Workspace
. WorkspaceDatabase
import WorkspaceDatabase
26 from Workspace
. BuildClassObject
import PcdClassObject
27 from Workspace
. BuildClassObject
import ModuleBuildClassObject
28 import RuleComplexFile
29 from EfiSection
import EfiSection
31 import Common
. TargetTxtClassObject
as TargetTxtClassObject
32 import Common
. ToolDefClassObject
as ToolDefClassObject
33 import Common
. DataType
34 import Common
. GlobalData
as GlobalData
35 from Common
import EdkLogger
36 from Common
. String
import *
37 from Common
. Misc
import DirCache
, PathClass
39 ## Version and Copyright
41 __version__
= "%prog Version " + versionNumber
42 __copyright__
= "Copyright (c) 2007, Intel Corporation All rights reserved."
44 ## Tool entrance method
46 # This method mainly dispatch specific methods per the command line options.
47 # If no error found, return zero value so the caller of this tool can know
48 # if it's executed successfully or not.
50 # @retval 0 Tool was successful
51 # @retval 1 Tool failed
55 Options
= myOptionParser ()
62 EdkLogger
. Initialize ()
64 if Options
. verbose
!= None :
65 EdkLogger
. SetLevel ( EdkLogger
. VERBOSE
)
66 GenFdsGlobalVariable
. VerboseMode
= True
68 if Options
. FixedAddress
!= None :
69 GenFdsGlobalVariable
. FixedLoadAddress
= True
71 if Options
. quiet
!= None :
72 EdkLogger
. SetLevel ( EdkLogger
. QUIET
)
73 if Options
. debug
!= None :
74 EdkLogger
. SetLevel ( Options
. debug
+ 1 )
75 GenFdsGlobalVariable
. DebugLevel
= Options
. debug
77 EdkLogger
. SetLevel ( EdkLogger
. INFO
)
79 if ( Options
. Workspace
== None ):
80 EdkLogger
. error ( "GenFds" , BuildToolError
. OPTION_MISSING
, "WORKSPACE not defined" ,
81 ExtraData
= "Please use '-w' switch to pass it or set the WORKSPACE environment variable." )
82 elif not os
. path
. exists ( Options
. Workspace
):
83 EdkLogger
. error ( "GenFds" , BuildToolError
. PARAMETER_INVALID
, "WORKSPACE is invalid" ,
84 ExtraData
= "Please use '-w' switch to pass it or set the WORKSPACE environment variable." )
86 Workspace
= os
. path
. normcase ( Options
. Workspace
)
87 GenFdsGlobalVariable
. WorkSpaceDir
= Workspace
88 if 'EDK_SOURCE' in os
. environ
. keys ():
89 GenFdsGlobalVariable
. EdkSourceDir
= os
. path
. normcase ( os
. environ
[ 'EDK_SOURCE' ])
91 GenFdsGlobalVariable
. VerboseLogger ( "Using Workspace:" + Workspace
)
92 os
. chdir ( GenFdsGlobalVariable
. WorkSpaceDir
)
94 if ( Options
. filename
):
95 FdfFilename
= Options
. filename
96 FdfFilename
= GenFdsGlobalVariable
. ReplaceWorkspaceMacro ( FdfFilename
)
98 EdkLogger
. error ( "GenFds" , BuildToolError
. OPTION_MISSING
, "Missing FDF filename" )
100 if ( Options
. BuildTarget
):
101 GenFdsGlobalVariable
. TargetName
= Options
. BuildTarget
103 EdkLogger
. error ( "GenFds" , BuildToolError
. OPTION_MISSING
, "Missing build target" )
105 if ( Options
. ToolChain
):
106 GenFdsGlobalVariable
. ToolChainTag
= Options
. ToolChain
108 EdkLogger
. error ( "GenFds" , BuildToolError
. OPTION_MISSING
, "Missing tool chain tag" )
110 if FdfFilename
[ 0 : 2 ] == '..' :
111 FdfFilename
= os
. path
. realpath ( FdfFilename
)
112 if FdfFilename
[ 1 ] != ':' :
113 FdfFilename
= os
. path
. join ( GenFdsGlobalVariable
. WorkSpaceDir
, FdfFilename
)
115 if not os
. path
. exists ( FdfFilename
):
116 EdkLogger
. error ( "GenFds" , BuildToolError
. FILE_NOT_FOUND
, ExtraData
= FdfFilename
)
117 GenFdsGlobalVariable
. FdfFile
= FdfFilename
118 GenFdsGlobalVariable
. FdfFileTimeStamp
= os
. path
. getmtime ( FdfFilename
)
120 if ( Options
. activePlatform
):
121 ActivePlatform
= Options
. activePlatform
122 ActivePlatform
= GenFdsGlobalVariable
. ReplaceWorkspaceMacro ( ActivePlatform
)
124 if ActivePlatform
[ 0 : 2 ] == '..' :
125 ActivePlatform
= os
. path
. realpath ( ActivePlatform
)
127 if ActivePlatform
[ 1 ] != ':' :
128 ActivePlatform
= os
. path
. join ( GenFdsGlobalVariable
. WorkSpaceDir
, ActivePlatform
)
130 if not os
. path
. exists ( ActivePlatform
) :
131 EdkLogger
. error ( "GenFds" , BuildToolError
. FILE_NOT_FOUND
, "ActivePlatform doesn't exist!" )
133 if ActivePlatform
. find ( Workspace
) == - 1 :
134 EdkLogger
. error ( "GenFds" , BuildToolError
. FILE_NOT_FOUND
, "ActivePlatform doesn't exist in Workspace!" )
136 ActivePlatform
= ActivePlatform
. replace ( Workspace
, '' )
137 if len ( ActivePlatform
) > 0 :
138 if ActivePlatform
[ 0 ] == ' \\ ' or ActivePlatform
[ 0 ] == '/' :
139 ActivePlatform
= ActivePlatform
[ 1 :]
141 EdkLogger
. error ( "GenFds" , BuildToolError
. FILE_NOT_FOUND
, "ActivePlatform doesn't exist!" )
143 EdkLogger
. error ( "GenFds" , BuildToolError
. OPTION_MISSING
, "Missing active platform" )
145 GenFdsGlobalVariable
. ActivePlatform
= PathClass ( NormPath ( ActivePlatform
), Workspace
)
147 BuildConfigurationFile
= os
. path
. normpath ( os
. path
. join ( GenFdsGlobalVariable
. WorkSpaceDir
, "Conf/target.txt" ))
148 if os
. path
. isfile ( BuildConfigurationFile
) == True :
149 TargetTxtClassObject
. TargetTxtClassObject ( BuildConfigurationFile
)
151 EdkLogger
. error ( "GenFds" , BuildToolError
. FILE_NOT_FOUND
, ExtraData
= BuildConfigurationFile
)
154 for Pair
in Options
. Macros
:
156 List
= Pair
. split ( '=' )
158 FdfParser
. InputMacroDict
[ List
[ 0 ]. strip ()] = List
[ 1 ]. strip ()
159 if List
[ 0 ]. strip () == "EFI_SOURCE" :
160 GlobalData
. gEfiSource
= List
[ 1 ]. strip ()
161 elif List
[ 0 ]. strip () == "EDK_SOURCE" :
162 GlobalData
. gEdkSource
= List
[ 1 ]. strip ()
164 GlobalData
. gEdkGlobal
[ List
[ 0 ]. strip ()] = List
[ 1 ]. strip ()
166 FdfParser
. InputMacroDict
[ List
[ 0 ]. strip ()] = None
168 """call Workspace build create database"""
169 os
. environ
[ "WORKSPACE" ] = Workspace
170 BuildWorkSpace
= WorkspaceDatabase ( ':memory:' , GlobalData
. gGlobalDefines
)
171 BuildWorkSpace
. InitDatabase ()
174 # Get files real name in workspace dir
176 GlobalData
. gAllFiles
= DirCache ( Workspace
)
177 GlobalData
. gWorkspace
= Workspace
179 if ( Options
. archList
) :
180 ArchList
= Options
. archList
. split ( ',' )
182 # EdkLogger.error("GenFds", BuildToolError.OPTION_MISSING, "Missing build ARCH")
183 ArchList
= BuildWorkSpace
. BuildObject
[ GenFdsGlobalVariable
. ActivePlatform
, 'COMMON' ]. SupArchList
185 TargetArchList
= set ( BuildWorkSpace
. BuildObject
[ GenFdsGlobalVariable
. ActivePlatform
, 'COMMON' ]. SupArchList
) & set ( ArchList
)
186 if len ( TargetArchList
) == 0 :
187 EdkLogger
. error ( "GenFds" , GENFDS_ERROR
, "Target ARCH %s not in platform supported ARCH %s " % ( str ( ArchList
), str ( BuildWorkSpace
. BuildObject
[ GenFdsGlobalVariable
. ActivePlatform
, 'COMMON' ]. SupArchList
)))
189 for Arch
in ArchList
:
190 GenFdsGlobalVariable
. OutputDirFromDscDict
[ Arch
] = NormPath ( BuildWorkSpace
. BuildObject
[ GenFdsGlobalVariable
. ActivePlatform
, Arch
]. OutputDirectory
)
192 if ( Options
. outputDir
):
193 OutputDirFromCommandLine
= GenFdsGlobalVariable
. ReplaceWorkspaceMacro ( Options
. outputDir
)
194 for Arch
in ArchList
:
195 GenFdsGlobalVariable
. OutputDirDict
[ Arch
] = OutputDirFromCommandLine
197 for Arch
in ArchList
:
198 GenFdsGlobalVariable
. OutputDirDict
[ Arch
] = os
. path
. join ( GenFdsGlobalVariable
. OutputDirFromDscDict
[ Arch
], GenFdsGlobalVariable
. TargetName
+ '_' + GenFdsGlobalVariable
. ToolChainTag
)
200 for Key
in GenFdsGlobalVariable
. OutputDirDict
:
201 OutputDir
= GenFdsGlobalVariable
. OutputDirDict
[ Key
]
202 if OutputDir
[ 0 : 2 ] == '..' :
203 OutputDir
= os
. path
. realpath ( OutputDir
)
205 if OutputDir
[ 1 ] != ':' :
206 OutputDir
= os
. path
. join ( GenFdsGlobalVariable
. WorkSpaceDir
, OutputDir
)
208 if not os
. path
. exists ( OutputDir
):
209 EdkLogger
. error ( "GenFds" , BuildToolError
. FILE_NOT_FOUND
, ExtraData
= OutputDir
)
210 GenFdsGlobalVariable
. OutputDirDict
[ Key
] = OutputDir
212 """ Parse Fdf file, has to place after build Workspace as FDF may contain macros from DSC file """
213 FdfParserObj
= FdfParser
. FdfParser ( FdfFilename
)
214 FdfParserObj
. ParseFile ()
216 if FdfParserObj
. CycleReferenceCheck ():
217 EdkLogger
. error ( "GenFds" , BuildToolError
. FORMAT_NOT_SUPPORTED
, "Cycle Reference Detected in FDF file" )
219 if ( Options
. uiFdName
) :
220 if Options
. uiFdName
. upper () in FdfParserObj
. Profile
. FdDict
. keys ():
221 GenFds
. OnlyGenerateThisFd
= Options
. uiFdName
223 EdkLogger
. error ( "GenFds" , BuildToolError
. OPTION_VALUE_INVALID
,
224 "No such an FD in FDF file: %s " % Options
. uiFdName
)
226 if ( Options
. uiFvName
) :
227 if Options
. uiFvName
. upper () in FdfParserObj
. Profile
. FvDict
. keys ():
228 GenFds
. OnlyGenerateThisFv
= Options
. uiFvName
230 EdkLogger
. error ( "GenFds" , BuildToolError
. OPTION_VALUE_INVALID
,
231 "No such an FV in FDF file: %s " % Options
. uiFvName
)
233 """Modify images from build output if the feature of loading driver at fixed address is on."""
234 if GenFdsGlobalVariable
. FixedLoadAddress
:
235 GenFds
. PreprocessImage ( BuildWorkSpace
, GenFdsGlobalVariable
. ActivePlatform
)
237 GenFds
. GenFd ( '' , FdfParserObj
, BuildWorkSpace
, ArchList
)
239 """Display FV space info."""
240 GenFds
. DisplayFvSpaceInfo ( FdfParserObj
)
242 except FdfParser
. Warning , X
:
243 EdkLogger
. error ( X
. ToolName
, BuildToolError
. FORMAT_INVALID
, File
= X
. FileName
, Line
= X
. LineNumber
, ExtraData
= X
. Message
, RaiseError
= False )
244 ReturnCode
= BuildToolError
. FORMAT_INVALID
245 except FatalError
, X
:
246 if Options
. debug
!= None :
248 EdkLogger
. quiet ( traceback
. format_exc ())
249 ReturnCode
= X
. args
[ 0 ]
255 "Tools code failure" ,
256 ExtraData
= "Please submit bug report in www.TianoCore.org, attaching following call stack trace! \n " ,
259 EdkLogger
. quiet ( traceback
. format_exc ())
260 ReturnCode
= CODE_ERROR
264 def SingleCheckCallback ( option
, opt_str
, value
, parser
):
265 if option
not in gParamCheck
:
266 setattr ( parser
. values
, option
. dest
, value
)
267 gParamCheck
. append ( option
)
269 parser
. error ( "Option %s only allows one instance in command line!" % option
)
271 ## Parse command line options
273 # Using standard Python module optparse to parse command line option of this tool.
275 # @retval Opt A optparse.Values object containing the parsed options
276 # @retval Args Target of build command
278 def myOptionParser ():
279 usage
= "%prog [options] -f input_file -a arch_list -b build_target -p active_platform -t tool_chain_tag -D \" MacroName [= MacroValue] \" "
280 Parser
= OptionParser ( usage
= usage
, description
= __copyright__
, version
= "%prog " + str ( versionNumber
))
281 Parser
. add_option ( "-f" , "--file" , dest
= "filename" , type = "string" , help = "Name of FDF file to convert" , action
= "callback" , callback
= SingleCheckCallback
)
282 Parser
. add_option ( "-a" , "--arch" , dest
= "archList" , help = "comma separated list containing one or more of: IA32, X64, IPF, ARM or EBC which should be built, overrides target.txt?s TARGET_ARCH" )
283 Parser
. add_option ( "-q" , "--quiet" , action
= "store_true" , type = None , help = "Disable all messages except FATAL ERRORS." )
284 Parser
. add_option ( "-v" , "--verbose" , action
= "store_true" , type = None , help = "Turn on verbose output with informational messages printed." )
285 Parser
. add_option ( "-d" , "--debug" , action
= "store" , type = "int" , help = "Enable debug messages at specified level." )
286 Parser
. add_option ( "-p" , "--platform" , type = "string" , dest
= "activePlatform" , help = "Set the ACTIVE_PLATFORM, overrides target.txt ACTIVE_PLATFORM setting." ,
287 action
= "callback" , callback
= SingleCheckCallback
)
288 Parser
. add_option ( "-w" , "--workspace" , type = "string" , dest
= "Workspace" , default
= os
. environ
. get ( 'WORKSPACE' ), help = "Set the WORKSPACE" ,
289 action
= "callback" , callback
= SingleCheckCallback
)
290 Parser
. add_option ( "-o" , "--outputDir" , type = "string" , dest
= "outputDir" , help = "Name of Build Output directory" ,
291 action
= "callback" , callback
= SingleCheckCallback
)
292 Parser
. add_option ( "-r" , "--rom_image" , dest
= "uiFdName" , help = "Build the image using the [FD] section named by FdUiName." )
293 Parser
. add_option ( "-i" , "--FvImage" , dest
= "uiFvName" , help = "Buld the FV image using the [FV] section named by UiFvName" )
294 Parser
. add_option ( "-b" , "--buildtarget" , type = "choice" , choices
=[ 'DEBUG' , 'RELEASE' ], dest
= "BuildTarget" , help = "Build TARGET is one of list: DEBUG, RELEASE." ,
295 action
= "callback" , callback
= SingleCheckCallback
)
296 Parser
. add_option ( "-t" , "--tagname" , type = "string" , dest
= "ToolChain" , help = "Using the tools: TOOL_CHAIN_TAG name to build the platform." ,
297 action
= "callback" , callback
= SingleCheckCallback
)
298 Parser
. add_option ( "-D" , "--define" , action
= "append" , type = "string" , dest
= "Macros" , help = "Macro: \" Name [= Value] \" ." )
299 Parser
. add_option ( "-s" , "--specifyaddress" , dest
= "FixedAddress" , action
= "store_true" , type = None , help = "Specify driver load address." )
300 ( Options
, args
) = Parser
. parse_args ()
303 ## The class implementing the EDK2 flash image generation process
305 # This process includes:
306 # 1. Collect workspace information, includes platform and module information
307 # 2. Call methods of Fd class to generate FD
308 # 3. Call methods of Fv class to generate FV that not belong to FD
312 # FvName in FDF, FvBinFile name
314 OnlyGenerateThisFd
= None
315 OnlyGenerateThisFv
= None
319 # @param OutputDir Output directory
320 # @param FdfParser FDF contents parser
321 # @param Workspace The directory of workspace
322 # @param ArchList The Arch list of platform
324 def GenFd ( OutputDir
, FdfParser
, WorkSpace
, ArchList
):
325 GenFdsGlobalVariable
. SetDir ( '' , FdfParser
, WorkSpace
, ArchList
)
327 GenFdsGlobalVariable
. VerboseLogger ( " Gen Fd !" )
328 if GenFds
. OnlyGenerateThisFd
!= None and GenFds
. OnlyGenerateThisFd
. upper () in GenFdsGlobalVariable
. FdfParser
. Profile
. FdDict
. keys ():
329 FdObj
= GenFdsGlobalVariable
. FdfParser
. Profile
. FdDict
. get ( GenFds
. OnlyGenerateThisFd
. upper ())
331 FdObj
. GenFd ( GenFds
. FvBinDict
)
332 elif GenFds
. OnlyGenerateThisFv
== None :
333 for FdName
in GenFdsGlobalVariable
. FdfParser
. Profile
. FdDict
. keys ():
334 FdObj
= GenFdsGlobalVariable
. FdfParser
. Profile
. FdDict
[ FdName
]
335 FdObj
. GenFd ( GenFds
. FvBinDict
)
337 GenFdsGlobalVariable
. VerboseLogger ( " Gen FV ! " )
338 if GenFds
. OnlyGenerateThisFv
!= None and GenFds
. OnlyGenerateThisFv
. upper () in GenFdsGlobalVariable
. FdfParser
. Profile
. FvDict
. keys ():
339 FvObj
= GenFdsGlobalVariable
. FdfParser
. Profile
. FvDict
. get ( GenFds
. OnlyGenerateThisFv
. upper ())
341 Buffer
= StringIO
. StringIO ()
342 # Get FV base Address
343 FvObj
. AddToBuffer ( Buffer
, None , GenFds
. GetFvBlockSize ( FvObj
))
346 elif GenFds
. OnlyGenerateThisFd
== None :
347 for FvName
in GenFdsGlobalVariable
. FdfParser
. Profile
. FvDict
. keys ():
348 Buffer
= StringIO
. StringIO ( '' )
349 FvObj
= GenFdsGlobalVariable
. FdfParser
. Profile
. FvDict
[ FvName
]
350 # Get FV base Address
351 FvObj
. AddToBuffer ( Buffer
, None , GenFds
. GetFvBlockSize ( FvObj
))
354 if GenFds
. OnlyGenerateThisFv
== None and GenFds
. OnlyGenerateThisFd
== None :
355 GenFdsGlobalVariable
. VerboseLogger ( " Gen Capsule !" )
356 for CapsuleObj
in GenFdsGlobalVariable
. FdfParser
. Profile
. CapsuleList
:
357 CapsuleObj
. GenCapsule ()
359 if GenFdsGlobalVariable
. FdfParser
. Profile
. OptRomDict
!= {}:
360 GenFdsGlobalVariable
. VerboseLogger ( " Gen Option ROM !" )
361 for DriverName
in GenFdsGlobalVariable
. FdfParser
. Profile
. OptRomDict
. keys ():
362 OptRomObj
= GenFdsGlobalVariable
. FdfParser
. Profile
. OptRomDict
[ DriverName
]
363 OptRomObj
. AddToBuffer ( None )
367 # @param FvObj Whose block size to get
368 # @retval int Block size value
370 def GetFvBlockSize ( FvObj
):
371 DefaultBlockSize
= 0x10000
373 if GenFds
. OnlyGenerateThisFd
!= None and GenFds
. OnlyGenerateThisFd
. upper () in GenFdsGlobalVariable
. FdfParser
. Profile
. FdDict
. keys ():
374 FdObj
= GenFdsGlobalVariable
. FdfParser
. Profile
. FdDict
[ GenFds
. OnlyGenerateThisFd
. upper ()]
376 for ElementFd
in GenFdsGlobalVariable
. FdfParser
. Profile
. FdDict
. values ():
377 for ElementRegion
in ElementFd
. RegionList
:
378 if ElementRegion
. RegionType
== 'FV' :
379 for ElementRegionData
in ElementRegion
. RegionDataList
:
380 if ElementRegionData
!= None and ElementRegionData
. upper () == FvObj
. UiFvName
:
381 if FvObj
. BlockSizeList
!= []:
382 return FvObj
. BlockSizeList
[ 0 ][ 0 ]
384 return ElementRegion
. BlockSizeOfRegion ( ElementFd
. BlockSizeList
)
385 if FvObj
. BlockSizeList
!= []:
386 return FvObj
. BlockSizeList
[ 0 ][ 0 ]
387 return DefaultBlockSize
389 for ElementRegion
in FdObj
. RegionList
:
390 if ElementRegion
. RegionType
== 'FV' :
391 for ElementRegionData
in ElementRegion
. RegionDataList
:
392 if ElementRegionData
!= None and ElementRegionData
. upper () == FvObj
. UiFvName
:
393 if FvObj
. BlockSizeList
!= []:
394 return FvObj
. BlockSizeList
[ 0 ][ 0 ]
396 return ElementRegion
. BlockSizeOfRegion ( ElementFd
. BlockSizeList
)
397 return DefaultBlockSize
399 ## DisplayFvSpaceInfo()
401 # @param FvObj Whose block size to get
404 def DisplayFvSpaceInfo ( FdfParser
):
408 for FvName
in FdfParser
. Profile
. FvDict
:
409 if len ( FvName
) > MaxFvNameLength
:
410 MaxFvNameLength
= len ( FvName
)
411 FvSpaceInfoFileName
= os
. path
. join ( GenFdsGlobalVariable
. FvDir
, FvName
. upper () + '.Fv.map' )
412 if os
. path
. exists ( FvSpaceInfoFileName
):
413 FileLinesList
= linecache
. getlines ( FvSpaceInfoFileName
)
420 for Line
in FileLinesList
:
421 NameValue
= Line
. split ( '=' )
422 if len ( NameValue
) == 2 :
423 if NameValue
[ 0 ]. strip () == 'EFI_FV_TOTAL_SIZE' :
425 Total
= NameValue
[ 1 ]. strip ()
426 if NameValue
[ 0 ]. strip () == 'EFI_FV_TAKEN_SIZE' :
428 Used
= NameValue
[ 1 ]. strip ()
429 if NameValue
[ 0 ]. strip () == 'EFI_FV_SPACE_SIZE' :
431 Free
= NameValue
[ 1 ]. strip ()
433 if TotalFound
and UsedFound
and FreeFound
:
434 FvSpaceInfoList
. append (( FvName
, Total
, Used
, Free
))
436 GenFdsGlobalVariable
. InfLogger ( ' \n FV Space Information' )
437 for FvSpaceInfo
in FvSpaceInfoList
:
438 Name
= FvSpaceInfo
[ 0 ]
439 TotalSizeValue
= long ( FvSpaceInfo
[ 1 ], 0 )
440 UsedSizeValue
= long ( FvSpaceInfo
[ 2 ], 0 )
441 FreeSizeValue
= long ( FvSpaceInfo
[ 3 ], 0 )
442 GenFdsGlobalVariable
. InfLogger ( Name
+ ' ' + '[' + str (( UsedSizeValue
+ 0.0 )/ TotalSizeValue
)[ 0 : 4 ]. lstrip ( '0.' ) + ' %Fu ll] ' + str ( TotalSizeValue
) + ' total, ' + str ( UsedSizeValue
) + ' used, ' + str ( FreeSizeValue
) + ' free' )
446 # @param BuildDb Database from build meta data files
447 # @param DscFile modules from dsc file will be preprocessed
450 def PreprocessImage ( BuildDb
, DscFile
):
451 PcdDict
= BuildDb
. BuildObject
[ DscFile
, 'COMMON' ]. Pcds
454 PcdObj
= PcdDict
[ Key
]
455 if PcdObj
. TokenCName
== 'PcdBsBaseAddress' :
456 PcdValue
= PcdObj
. DefaultValue
462 Int64PcdValue
= long ( PcdValue
, 0 )
463 if Int64PcdValue
== 0 or Int64PcdValue
< - 1 :
467 if Int64PcdValue
> 0 :
468 TopAddress
= Int64PcdValue
470 ModuleDict
= BuildDb
. BuildObject
[ DscFile
, 'COMMON' ]. Modules
471 for Key
in ModuleDict
:
472 ModuleObj
= BuildDb
. BuildObject
[ Key
, 'COMMON' ]
473 print ModuleObj
. BaseName
+ ' ' + ModuleObj
. ModuleType
475 ##Define GenFd as static function
476 GenFd
= staticmethod ( GenFd
)
477 GetFvBlockSize
= staticmethod ( GetFvBlockSize
)
478 DisplayFvSpaceInfo
= staticmethod ( DisplayFvSpaceInfo
)
479 PreprocessImage
= staticmethod ( PreprocessImage
)
481 if __name__
== '__main__' :
483 ## 0-127 is a safe return range, and 1 is a standard default error
484 if r
< 0 or r
> 127 : r
= 1