]>
git.proxmox.com Git - mirror_edk2.git/blob - BaseTools/Source/Python/GenFds/Vtf.py
2 # process VTF generation
4 # Copyright (c) 2007 - 2018, 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.
18 from __future__
import absolute_import
19 from .GenFdsGlobalVariable
import GenFdsGlobalVariable
20 import Common
.LongFilePathOs
as os
21 from Common
.LongFilePathSupport
import OpenLongFilePath
as open
22 from Common
.DataType
import TAB_LINE_BREAK
31 # @param self The object pointer
38 self
.ComponentStatementList
= []
44 # @param self The object pointer
45 # @param FdAddressDict dictionary contains FV name and its base address
46 # @retval Dict FV and corresponding VTF file name
48 def GenVtf(self
, FdAddressDict
) :
50 BaseAddArg
= self
.GetBaseAddressArg(FdAddressDict
)
51 OutputArg
, VtfRawDict
= self
.GenOutputArg()
56 '-f', self
.BsfInfName
,
59 GenFdsGlobalVariable
.CallExternalTool(Cmd
, "GenFv -Vtf Failed!")
60 GenFdsGlobalVariable
.SharpCounter
= 0
66 # Generate inf used to generate VTF
68 # @param self The object pointer
71 FvList
= self
.GetFvList()
72 self
.BsfInfName
= os
.path
.join(GenFdsGlobalVariable
.FvDir
, self
.UiName
+ '.inf')
73 BsfInf
= open(self
.BsfInfName
, 'w+')
75 BsfInf
.writelines ("[OPTIONS]" + TAB_LINE_BREAK
)
76 BsfInf
.writelines ("IA32_RST_BIN" + \
78 GenFdsGlobalVariable
.MacroExtend(GenFdsGlobalVariable
.ReplaceWorkspaceMacro(self
.ResetBin
)) + \
80 BsfInf
.writelines (TAB_LINE_BREAK
)
82 BsfInf
.writelines ("[COMPONENTS]" + TAB_LINE_BREAK
)
84 for ComponentObj
in self
.ComponentStatementList
:
85 BsfInf
.writelines ("COMP_NAME" + \
87 ComponentObj
.CompName
+ \
89 if ComponentObj
.CompLoc
.upper() == 'NONE':
90 BsfInf
.writelines ("COMP_LOC" + \
95 elif ComponentObj
.FilePos
:
96 BsfInf
.writelines ("COMP_LOC" + \
98 ComponentObj
.FilePos
+ \
101 Index
= FvList
.index(ComponentObj
.CompLoc
.upper())
103 BsfInf
.writelines ("COMP_LOC" + \
108 BsfInf
.writelines ("COMP_LOC" + \
113 BsfInf
.writelines ("COMP_TYPE" + \
115 ComponentObj
.CompType
+ \
117 BsfInf
.writelines ("COMP_VER" + \
119 ComponentObj
.CompVer
+ \
121 BsfInf
.writelines ("COMP_CS" + \
123 ComponentObj
.CompCs
+ \
126 BinPath
= ComponentObj
.CompBin
128 BinPath
= GenFdsGlobalVariable
.MacroExtend(GenFdsGlobalVariable
.ReplaceWorkspaceMacro(BinPath
))
129 BsfInf
.writelines ("COMP_BIN" + \
134 SymPath
= ComponentObj
.CompSym
136 SymPath
= GenFdsGlobalVariable
.MacroExtend(GenFdsGlobalVariable
.ReplaceWorkspaceMacro(SymPath
))
137 BsfInf
.writelines ("COMP_SYM" + \
141 BsfInf
.writelines ("COMP_SIZE" + \
143 ComponentObj
.CompSize
+ \
145 BsfInf
.writelines (TAB_LINE_BREAK
)
149 ## GenFvList() method
151 # Get FV list referenced by VTF components
153 # @param self The object pointer
157 for component
in self
.ComponentStatementList
:
158 if component
.CompLoc
.upper() != 'NONE' and not (component
.CompLoc
.upper() in FvList
):
159 FvList
.append(component
.CompLoc
.upper())
163 ## GetBaseAddressArg() method
165 # Get base address arguments for GenVtf
167 # @param self The object pointer
169 def GetBaseAddressArg(self
, FdAddressDict
):
170 FvList
= self
.GetFvList()
173 (BaseAddress
, Size
) = FdAddressDict
.get(i
)
175 '-r', '0x%x' % BaseAddress
,
180 ## GenOutputArg() method
182 # Get output arguments for GenVtf
184 # @param self The object pointer
186 def GenOutputArg(self
):
189 FvList
= self
.GetFvList()
194 OutputFileName
= 'Vtf%d.raw' % Index
195 OutputFileName
= os
.path
.join(GenFdsGlobalVariable
.FvDir
, OutputFileName
)
196 Arg
+= ('-o', OutputFileName
)
197 FvVtfDict
[FvObj
.upper()] = OutputFileName
199 return Arg
, FvVtfDict