]>
git.proxmox.com Git - mirror_edk2.git/blob - BaseTools/Source/Python/GenFds/Vtf.py
2 # process VTF generation
4 # Copyright (c) 2007 - 2014, 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 GenFdsGlobalVariable
import GenFdsGlobalVariable
19 import Common
.LongFilePathOs
as os
20 from CommonDataClass
.FdfClass
import VtfClassObject
21 from Common
.LongFilePathSupport
import OpenLongFilePath
as open
27 class Vtf (VtfClassObject
):
31 # @param self The object pointer
34 VtfClassObject
.__init
__(self
)
40 # @param self The object pointer
41 # @param FdAddressDict dictionary contains FV name and its base address
42 # @retval Dict FV and corresponding VTF file name
44 def GenVtf(self
, FdAddressDict
) :
46 OutputFile
= os
.path
.join(GenFdsGlobalVariable
.FvDir
, self
.UiName
+ '.Vtf')
47 BaseAddArg
= self
.GetBaseAddressArg(FdAddressDict
)
48 OutputArg
, VtfRawDict
= self
.GenOutputArg()
53 '-f', self
.BsfInfName
,
56 GenFdsGlobalVariable
.CallExternalTool(Cmd
, "GenFv -Vtf Failed!")
57 GenFdsGlobalVariable
.SharpCounter
= 0
63 # Generate inf used to generate VTF
65 # @param self The object pointer
68 FvList
= self
.GetFvList()
69 self
.BsfInfName
= os
.path
.join(GenFdsGlobalVariable
.FvDir
, self
.UiName
+ '.inf')
70 BsfInf
= open (self
.BsfInfName
, 'w+')
71 if self
.ResetBin
!= None:
72 BsfInf
.writelines ("[OPTIONS]" + T_CHAR_LF
)
73 BsfInf
.writelines ("IA32_RST_BIN" + \
75 GenFdsGlobalVariable
.MacroExtend(GenFdsGlobalVariable
.ReplaceWorkspaceMacro(self
.ResetBin
)) + \
77 BsfInf
.writelines (T_CHAR_LF
)
79 BsfInf
.writelines ("[COMPONENTS]" + T_CHAR_LF
)
81 for ComponentObj
in self
.ComponentStatementList
:
82 BsfInf
.writelines ("COMP_NAME" + \
84 ComponentObj
.CompName
+ \
86 if ComponentObj
.CompLoc
.upper() == 'NONE':
87 BsfInf
.writelines ("COMP_LOC" + \
92 elif ComponentObj
.FilePos
!= None:
93 BsfInf
.writelines ("COMP_LOC" + \
95 ComponentObj
.FilePos
+ \
98 Index
= FvList
.index(ComponentObj
.CompLoc
.upper())
100 BsfInf
.writelines ("COMP_LOC" + \
105 BsfInf
.writelines ("COMP_LOC" + \
110 BsfInf
.writelines ("COMP_TYPE" + \
112 ComponentObj
.CompType
+ \
114 BsfInf
.writelines ("COMP_VER" + \
116 ComponentObj
.CompVer
+ \
118 BsfInf
.writelines ("COMP_CS" + \
120 ComponentObj
.CompCs
+ \
123 BinPath
= ComponentObj
.CompBin
125 BinPath
= GenFdsGlobalVariable
.MacroExtend(GenFdsGlobalVariable
.ReplaceWorkspaceMacro(BinPath
))
126 BsfInf
.writelines ("COMP_BIN" + \
131 SymPath
= ComponentObj
.CompSym
133 SymPath
= GenFdsGlobalVariable
.MacroExtend(GenFdsGlobalVariable
.ReplaceWorkspaceMacro(SymPath
))
134 BsfInf
.writelines ("COMP_SYM" + \
138 BsfInf
.writelines ("COMP_SIZE" + \
140 ComponentObj
.CompSize
+ \
142 BsfInf
.writelines (T_CHAR_LF
)
146 ## GenFvList() method
148 # Get FV list referenced by VTF components
150 # @param self The object pointer
154 for component
in self
.ComponentStatementList
:
155 if component
.CompLoc
.upper() != 'NONE' and not (component
.CompLoc
.upper() in FvList
):
156 FvList
.append(component
.CompLoc
.upper())
160 ## GetBaseAddressArg() method
162 # Get base address arguments for GenVtf
164 # @param self The object pointer
166 def GetBaseAddressArg(self
, FdAddressDict
):
167 FvList
= self
.GetFvList()
170 (BaseAddress
, Size
) = FdAddressDict
.get(i
)
172 '-r', '0x%x' % BaseAddress
,
177 ## GenOutputArg() method
179 # Get output arguments for GenVtf
181 # @param self The object pointer
183 def GenOutputArg(self
):
186 FvList
= self
.GetFvList()
191 OutputFileName
= 'Vtf%d.raw' % Index
192 OutputFileName
= os
.path
.join(GenFdsGlobalVariable
.FvDir
, OutputFileName
)
193 Arg
+= ('-o', OutputFileName
)
194 FvVtfDict
[FvObj
.upper()] = OutputFileName
196 return Arg
, FvVtfDict