]>
git.proxmox.com Git - mirror_edk2.git/blob - BaseTools/Source/Python/GenFds/Vtf.py
2 # process VTF generation
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 GenFdsGlobalVariable
import GenFdsGlobalVariable
20 from CommonDataClass
.FdfClass
import VtfClassObject
26 class Vtf (VtfClassObject
):
30 # @param self The object pointer
33 VtfClassObject
.__init
__(self
)
39 # @param self The object pointer
40 # @param FdAddressDict dictionary contains FV name and its base address
41 # @retval Dict FV and corresponding VTF file name
43 def GenVtf(self
, FdAddressDict
) :
45 OutputFile
= os
.path
.join(GenFdsGlobalVariable
.FvDir
, self
.UiName
+ '.Vtf')
46 BaseAddArg
= self
.GetBaseAddressArg(FdAddressDict
)
47 OutputArg
, VtfRawDict
= self
.GenOutputArg()
52 '-f', self
.BsfInfName
,
55 GenFdsGlobalVariable
.CallExternalTool(Cmd
, "GenFv -Vtf Failed!")
56 GenFdsGlobalVariable
.SharpCounter
= 0
62 # Generate inf used to generate VTF
64 # @param self The object pointer
67 FvList
= self
.GetFvList()
68 self
.BsfInfName
= os
.path
.join(GenFdsGlobalVariable
.FvDir
, self
.UiName
+ '.inf')
69 BsfInf
= open (self
.BsfInfName
, 'w+')
70 BsfInf
.writelines ("[COMPONENTS]" + T_CHAR_LF
)
72 for ComponentObj
in self
.ComponentStatementList
:
73 BsfInf
.writelines ("COMP_NAME" + \
75 ComponentObj
.CompName
+ \
77 if ComponentObj
.CompLoc
.upper() == 'NONE':
78 BsfInf
.writelines ("COMP_LOC" + \
83 elif ComponentObj
.FilePos
!= None:
84 BsfInf
.writelines ("COMP_LOC" + \
86 ComponentObj
.FilePos
+ \
89 Index
= FvList
.index(ComponentObj
.CompLoc
.upper())
91 BsfInf
.writelines ("COMP_LOC" + \
96 BsfInf
.writelines ("COMP_LOC" + \
101 BsfInf
.writelines ("COMP_TYPE" + \
103 ComponentObj
.CompType
+ \
105 BsfInf
.writelines ("COMP_VER" + \
107 ComponentObj
.CompVer
+ \
109 BsfInf
.writelines ("COMP_CS" + \
111 ComponentObj
.CompCs
+ \
114 BinPath
= ComponentObj
.CompBin
116 BinPath
= GenFdsGlobalVariable
.MacroExtend(GenFdsGlobalVariable
.ReplaceWorkspaceMacro(BinPath
))
117 BsfInf
.writelines ("COMP_BIN" + \
122 SymPath
= ComponentObj
.CompSym
124 SymPath
= GenFdsGlobalVariable
.MacroExtend(GenFdsGlobalVariable
.ReplaceWorkspaceMacro(SymPath
))
125 BsfInf
.writelines ("COMP_SYM" + \
129 BsfInf
.writelines ("COMP_SIZE" + \
131 ComponentObj
.CompSize
+ \
133 BsfInf
.writelines (T_CHAR_LF
)
137 ## GenFvList() method
139 # Get FV list referenced by VTF components
141 # @param self The object pointer
145 for component
in self
.ComponentStatementList
:
146 if component
.CompLoc
.upper() != 'NONE' and not (component
.CompLoc
.upper() in FvList
):
147 FvList
.append(component
.CompLoc
.upper())
151 ## GetBaseAddressArg() method
153 # Get base address arguments for GenVtf
155 # @param self The object pointer
157 def GetBaseAddressArg(self
, FdAddressDict
):
158 FvList
= self
.GetFvList()
161 (BaseAddress
, Size
) = FdAddressDict
.get(i
)
163 '-r', '0x%x' % BaseAddress
,
168 ## GenOutputArg() method
170 # Get output arguments for GenVtf
172 # @param self The object pointer
174 def GenOutputArg(self
):
177 FvList
= self
.GetFvList()
182 OutputFileName
= 'Vtf%d.raw' % Index
183 OutputFileName
= os
.path
.join(GenFdsGlobalVariable
.FvDir
, OutputFileName
)
184 Arg
+= ('-o', OutputFileName
)
185 FvVtfDict
[FvObj
.upper()] = OutputFileName
187 return Arg
, FvVtfDict