summaryrefslogtreecommitdiffstats
path: root/BaseTools/Source/Python/GenFds/Fv.py
diff options
context:
space:
mode:
authorCarsey, Jaben <jaben.carsey@intel.com>2018-10-24 01:29:19 +0800
committerYonghong Zhu <yonghong.zhu@intel.com>2018-10-25 20:14:49 +0800
commit9e47e6f90880e090cd81f585abd7a6c553fbce10 (patch)
treec280e390d282db4c41d64718b366c1c3e64dc9ba /BaseTools/Source/Python/GenFds/Fv.py
parent0019375fbc89e4d7cfebe29e288b74731bd9f456 (diff)
downloadedk2-9e47e6f90880e090cd81f585abd7a6c553fbce10.tar.gz
edk2-9e47e6f90880e090cd81f585abd7a6c553fbce10.tar.bz2
edk2-9e47e6f90880e090cd81f585abd7a6c553fbce10.zip
BaseTools/GenFds: cleanup GenFds
1) remove wildcard imports and use explicit imports 2) refactor to use shared variables from Common/DataType 3) rename to not shadow imports 4) don't assign a variable in a loop (just do final assignment) 5) remove spaces, parens, unused or commented out code, etc. 6) merge unnecessary parent classes into child 7) refactor to share DXE and PEI apriori GUIDs from one place this includes changes to Build and EOT files 8) for PEP8, dont use __ for custom methods. Cc: Yonghong Zhu <yonghong.zhu@intel.com> Cc: Liming Gao <liming.gao@intel.com> Cc: Bob C Feng <bob.c.feng@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jaben Carsey <jaben.carsey@intel.com> Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
Diffstat (limited to 'BaseTools/Source/Python/GenFds/Fv.py')
-rw-r--r--BaseTools/Source/Python/GenFds/Fv.py47
1 files changed, 27 insertions, 20 deletions
diff --git a/BaseTools/Source/Python/GenFds/Fv.py b/BaseTools/Source/Python/GenFds/Fv.py
index c66fc38327..30525bd11f 100644
--- a/BaseTools/Source/Python/GenFds/Fv.py
+++ b/BaseTools/Source/Python/GenFds/Fv.py
@@ -1,4 +1,3 @@
-from __future__ import absolute_import
## @file
# process FV generation
#
@@ -16,16 +15,13 @@ from __future__ import absolute_import
##
# Import Modules
#
+from __future__ import absolute_import
import Common.LongFilePathOs as os
import subprocess
from io import BytesIO
from struct import *
-
-from . import Ffs
-from . import AprioriSection
from . import FfsFileStatement
from .GenFdsGlobalVariable import GenFdsGlobalVariable
-from CommonDataClass.FdfClass import FvClassObject
from Common.Misc import SaveFileOnChange, PackGUID
from Common.LongFilePathSupport import CopyLongFilePath
from Common.LongFilePathSupport import OpenLongFilePath as open
@@ -36,13 +32,25 @@ FV_UI_EXT_ENTY_GUID = 'A67DF1FA-8DE8-4E98-AF09-4BDF2EFFBC7C'
## generate FV
#
#
-class FV (FvClassObject):
+class FV (object):
## The constructor
#
# @param self The object pointer
#
def __init__(self):
- FvClassObject.__init__(self)
+ self.UiFvName = None
+ self.CreateFileName = None
+ self.BlockSizeList = []
+ self.DefineVarDict = {}
+ self.SetVarDict = {}
+ self.FvAlignment = None
+ self.FvAttributeDict = {}
+ self.FvNameGuid = None
+ self.FvNameString = None
+ self.AprioriSectionList = []
+ self.FfsList = []
+ self.BsBaseAddress = None
+ self.RtBaseAddress = None
self.FvInfFile = None
self.FvAddressFile = None
self.BaseAddress = None
@@ -68,7 +76,7 @@ class FV (FvClassObject):
# @param MacroDict macro value pair
# @retval string Generated FV file path
#
- def AddToBuffer (self, Buffer, BaseAddress=None, BlockSize= None, BlockNum=None, ErasePloarity='1', VtfDict=None, MacroDict = {}, Flag=False) :
+ def AddToBuffer (self, Buffer, BaseAddress=None, BlockSize= None, BlockNum=None, ErasePloarity='1', VtfDict=None, MacroDict = {}, Flag=False):
if BaseAddress is None and self.UiFvName.upper() + 'fv' in GenFdsGlobalVariable.ImageBinDict:
return GenFdsGlobalVariable.ImageBinDict[self.UiFvName.upper() + 'fv']
@@ -96,7 +104,7 @@ class FV (FvClassObject):
if self.FvBaseAddress is not None:
BaseAddress = self.FvBaseAddress
if not Flag:
- self.__InitializeInf__(BaseAddress, BlockSize, BlockNum, ErasePloarity, VtfDict)
+ self._InitializeInf(BaseAddress, BlockSize, BlockNum, ErasePloarity, VtfDict)
#
# First Process the Apriori section
#
@@ -114,7 +122,7 @@ class FV (FvClassObject):
TAB_LINE_BREAK)
# Process Modules in FfsList
- for FfsFile in self.FfsList :
+ for FfsFile in self.FfsList:
if Flag:
if isinstance(FfsFile, FfsFileStatement.FileStatement):
continue
@@ -177,7 +185,7 @@ class FV (FvClassObject):
if FvChildAddr != []:
# Update Ffs again
- for FfsFile in self.FfsList :
+ for FfsFile in self.FfsList:
FileName = FfsFile.GenFfs(MacroDict, FvChildAddr, BaseAddress, IsMakefile=Flag, FvName=self.UiFvName)
if GenFdsGlobalVariable.LargeFileInFvFlags[-1]:
@@ -252,7 +260,7 @@ class FV (FvClassObject):
return True
return False
- ## __InitializeInf__()
+ ## _InitializeInf()
#
# Initilize the inf file to create FV
#
@@ -263,7 +271,7 @@ class FV (FvClassObject):
# @param ErasePolarity Flash erase polarity
# @param VtfDict VTF objects
#
- def __InitializeInf__ (self, BaseAddress = None, BlockSize= None, BlockNum = None, ErasePloarity='1', VtfDict=None) :
+ def _InitializeInf (self, BaseAddress = None, BlockSize= None, BlockNum = None, ErasePloarity='1', VtfDict=None):
#
# Create FV inf file
#
@@ -275,7 +283,7 @@ class FV (FvClassObject):
# Add [Options]
#
self.FvInfFile.writelines("[options]" + TAB_LINE_BREAK)
- if BaseAddress is not None :
+ if BaseAddress is not None:
self.FvInfFile.writelines("EFI_BASE_ADDRESS = " + \
BaseAddress + \
TAB_LINE_BREAK)
@@ -294,7 +302,7 @@ class FV (FvClassObject):
#set default block size is 1
self.FvInfFile.writelines("EFI_BLOCK_SIZE = 0x1" + TAB_LINE_BREAK)
- for BlockSize in self.BlockSizeList :
+ for BlockSize in self.BlockSizeList:
if BlockSize[0] is not None:
self.FvInfFile.writelines("EFI_BLOCK_SIZE = " + \
'0x%X' %BlockSize[0] + \
@@ -320,9 +328,9 @@ class FV (FvClassObject):
' %s' %ErasePloarity + \
TAB_LINE_BREAK)
if not (self.FvAttributeDict is None):
- for FvAttribute in self.FvAttributeDict.keys() :
+ for FvAttribute in self.FvAttributeDict.keys():
if FvAttribute == "FvUsedSizeEnable":
- if self.FvAttributeDict[FvAttribute].upper() in ('TRUE', '1') :
+ if self.FvAttributeDict[FvAttribute].upper() in ('TRUE', '1'):
self.UsedSizeEnable = True
continue
self.FvInfFile.writelines("EFI_" + \
@@ -365,8 +373,8 @@ class FV (FvClassObject):
Guid = FV_UI_EXT_ENTY_GUID.split('-')
#
# Layout:
- # EFI_FIRMWARE_VOLUME_EXT_ENTRY : size 4
- # GUID : size 16
+ # EFI_FIRMWARE_VOLUME_EXT_ENTRY: size 4
+ # GUID: size 16
# FV UI name
#
Buffer += (pack('HH', (FvUiLen + 16 + 4), 0x0002)
@@ -422,7 +430,6 @@ class FV (FvClassObject):
FvExtHeaderFileName + \
TAB_LINE_BREAK)
-
#
# Add [Files]
#