summaryrefslogtreecommitdiff
path: root/BaseTools/Source/Python/BPDG/GenVpd.py
diff options
context:
space:
mode:
Diffstat (limited to 'BaseTools/Source/Python/BPDG/GenVpd.py')
-rw-r--r--BaseTools/Source/Python/BPDG/GenVpd.py298
1 files changed, 149 insertions, 149 deletions
diff --git a/BaseTools/Source/Python/BPDG/GenVpd.py b/BaseTools/Source/Python/BPDG/GenVpd.py
index 76d30fa6ff..d1da99fe5f 100644
--- a/BaseTools/Source/Python/BPDG/GenVpd.py
+++ b/BaseTools/Source/Python/BPDG/GenVpd.py
@@ -48,19 +48,19 @@ class PcdEntry:
self.PcdBinSize = PcdBinSize
if self.PcdValue == '' :
- EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID,
- "Invalid PCD format(Name: %s File: %s line: %s) , no Value specified!" %(self.PcdCName, self.FileName, self.Lineno))
-
+ EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID,
+ "Invalid PCD format(Name: %s File: %s line: %s) , no Value specified!" % (self.PcdCName, self.FileName, self.Lineno))
+
if self.PcdOffset == '' :
- EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID,
- "Invalid PCD format(Name: %s File: %s Line: %s) , no Offset specified!" %(self.PcdCName, self.FileName, self.Lineno))
-
+ EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID,
+ "Invalid PCD format(Name: %s File: %s Line: %s) , no Offset specified!" % (self.PcdCName, self.FileName, self.Lineno))
+
if self.PcdSize == '' :
- EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID,
- "Invalid PCD format(Name: %s File: %s Line: %s), no PcdSize specified!" %(self.PcdCName, self.FileName, self.Lineno))
-
+ EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID,
+ "Invalid PCD format(Name: %s File: %s Line: %s), no PcdSize specified!" % (self.PcdCName, self.FileName, self.Lineno))
+
self._GenOffsetValue ()
-
+
## Analyze the string value to judge the PCD's datum type euqal to Boolean or not.
#
# @param ValueString PCD's value
@@ -74,10 +74,10 @@ class PcdEntry:
if ValueString.upper() in ["TRUE", "FALSE"]:
return True
elif ValueString in ["0", "1", "0x0", "0x1", "0x00", "0x01"]:
- return True
-
+ return True
+
return False
-
+
## Convert the PCD's value from string to integer.
#
# This function will try to convert the Offset value form string to integer
@@ -91,9 +91,9 @@ class PcdEntry:
try:
self.PcdBinOffset = int(self.PcdOffset, 16)
except:
- EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID,
- "Invalid offset value %s for PCD %s (File: %s Line: %s)" % (self.PcdOffset, self.PcdCName, self.FileName, self.Lineno))
-
+ EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID,
+ "Invalid offset value %s for PCD %s (File: %s Line: %s)" % (self.PcdOffset, self.PcdCName, self.FileName, self.Lineno))
+
## Pack Boolean type VPD PCD's value form string to binary type.
#
# @param ValueString The boolean type string for pack.
@@ -101,18 +101,18 @@ class PcdEntry:
#
def _PackBooleanValue(self, ValueString):
if ValueString.upper() == "TRUE" or ValueString in ["1", "0x1", "0x01"]:
- try:
- self.PcdValue = pack(_FORMAT_CHAR[1], 1)
+ try:
+ self.PcdValue = pack(_FORMAT_CHAR[1], 1)
except:
- EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID,
- "Invalid size or value for PCD %s to pack(File: %s Line: %s)." % (self.PcdCName, self.FileName, self.Lineno))
+ EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID,
+ "Invalid size or value for PCD %s to pack(File: %s Line: %s)." % (self.PcdCName, self.FileName, self.Lineno))
else:
try:
- self.PcdValue = pack(_FORMAT_CHAR[1], 0)
+ self.PcdValue = pack(_FORMAT_CHAR[1], 0)
except:
- EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID,
- "Invalid size or value for PCD %s to pack(File: %s Line: %s)." % (self.PcdCName, self.FileName, self.Lineno))
-
+ EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID,
+ "Invalid size or value for PCD %s to pack(File: %s Line: %s)." % (self.PcdCName, self.FileName, self.Lineno))
+
## Pack Integer type VPD PCD's value form string to binary type.
#
# @param ValueString The Integer type string for pack.
@@ -120,46 +120,46 @@ class PcdEntry:
#
def _PackIntValue(self, IntValue, Size):
if Size not in _FORMAT_CHAR.keys():
- EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID,
- "Invalid size %d for PCD %s in integer datum size(File: %s Line: %s)." % (Size, self.PcdCName, self.FileName, self.Lineno))
-
- if Size == 1:
+ EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID,
+ "Invalid size %d for PCD %s in integer datum size(File: %s Line: %s)." % (Size, self.PcdCName, self.FileName, self.Lineno))
+
+ if Size == 1:
if IntValue < 0:
- EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID,
+ EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID,
"PCD can't be set to negative value %d for PCD %s in UINT8 datum type(File: %s Line: %s)." % (IntValue, self.PcdCName, self.FileName, self.Lineno))
elif IntValue >= 0x100:
- EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID,
- "Too large PCD value %d for datum type UINT8 for PCD %s(File: %s Line: %s)." % (IntValue, self.PcdCName, self.FileName, self.Lineno))
+ EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID,
+ "Too large PCD value %d for datum type UINT8 for PCD %s(File: %s Line: %s)." % (IntValue, self.PcdCName, self.FileName, self.Lineno))
elif Size == 2:
if IntValue < 0:
- EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID,
+ EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID,
"PCD can't be set to negative value %d for PCD %s in UINT16 datum type(File: %s Line: %s)." % (IntValue, self.PcdCName, self.FileName, self.Lineno))
elif IntValue >= 0x10000:
- EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID,
- "Too large PCD value %d for datum type UINT16 for PCD %s(File: %s Line: %s)." % (IntValue, self.PcdCName, self.FileName, self.Lineno))
+ EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID,
+ "Too large PCD value %d for datum type UINT16 for PCD %s(File: %s Line: %s)." % (IntValue, self.PcdCName, self.FileName, self.Lineno))
elif Size == 4:
if IntValue < 0:
- EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID,
+ EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID,
"PCD can't be set to negative value %d for PCD %s in UINT32 datum type(File: %s Line: %s)." % (IntValue, self.PcdCName, self.FileName, self.Lineno))
elif IntValue >= 0x100000000:
- EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID,
+ EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID,
"Too large PCD value %d for datum type UINT32 for PCD %s(File: %s Line: %s)." % (IntValue, self.PcdCName, self.FileName, self.Lineno))
elif Size == 8:
if IntValue < 0:
- EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID,
+ EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID,
"PCD can't be set to negative value %d for PCD %s in UINT32 datum type(File: %s Line: %s)." % (IntValue, self.PcdCName, self.FileName, self.Lineno))
elif IntValue >= 0x10000000000000000:
- EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID,
+ EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID,
"Too large PCD value %d for datum type UINT32 for PCD %s(File: %s Line: %s)." % (IntValue, self.PcdCName, self.FileName, self.Lineno))
else:
- EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID,
- "Invalid size %d for PCD %s in integer datum size(File: %s Line: %s)." % (Size, self.PcdCName, self.FileName, self.Lineno))
-
+ EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID,
+ "Invalid size %d for PCD %s in integer datum size(File: %s Line: %s)." % (Size, self.PcdCName, self.FileName, self.Lineno))
+
try:
- self.PcdValue = pack(_FORMAT_CHAR[Size], IntValue)
+ self.PcdValue = pack(_FORMAT_CHAR[Size], IntValue)
except:
- EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID,
- "Invalid size or value for PCD %s to pack(File: %s Line: %s)." % (self.PcdCName, self.FileName, self.Lineno))
+ EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID,
+ "Invalid size or value for PCD %s to pack(File: %s Line: %s)." % (self.PcdCName, self.FileName, self.Lineno))
## Pack VOID* type VPD PCD's value form string to binary type.
#
@@ -178,53 +178,53 @@ class PcdEntry:
elif ValueString.startswith('"') and ValueString.endswith('"'):
self._PackString(ValueString, Size)
else:
- EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID,
- "Invalid VOID* type PCD %s value %s (File: %s Line: %s)" % (self.PcdCName, ValueString, self.FileName, self.Lineno))
-
+ EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID,
+ "Invalid VOID* type PCD %s value %s (File: %s Line: %s)" % (self.PcdCName, ValueString, self.FileName, self.Lineno))
+
## Pack an Ascii PCD value.
#
# An Ascii string for a PCD should be in format as "".
#
def _PackString(self, ValueString, Size):
if (Size < 0):
- EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID,
+ EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID,
"Invalid parameter Size %s of PCD %s!(File: %s Line: %s)" % (self.PcdBinSize, self.PcdCName, self.FileName, self.Lineno))
if (ValueString == ""):
- EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID, "Invalid parameter ValueString %s of PCD %s!(File: %s Line: %s)" % (self.PcdUnpackValue, self.PcdCName, self.FileName, self.Lineno))
+ EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID, "Invalid parameter ValueString %s of PCD %s!(File: %s Line: %s)" % (self.PcdUnpackValue, self.PcdCName, self.FileName, self.Lineno))
if (len(ValueString) < 2):
EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID, "For PCD: %s ,ASCII string %s at least contains two!(File: %s Line: %s)" % (self.PcdCName, self.PcdUnpackValue, self.FileName, self.Lineno))
-
+
ValueString = ValueString[1:-1]
if len(ValueString) + 1 > Size:
- EdkLogger.error("BPDG", BuildToolError.RESOURCE_OVERFLOW,
+ EdkLogger.error("BPDG", BuildToolError.RESOURCE_OVERFLOW,
"PCD value string %s is exceed to size %d(File: %s Line: %s)" % (ValueString, Size, self.FileName, self.Lineno))
try:
- self.PcdValue= pack('%ds' % Size, ValueString)
+ self.PcdValue = pack('%ds' % Size, ValueString)
except:
- EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID,
- "Invalid size or value for PCD %s to pack(File: %s Line: %s)." % (self.PcdCName, self.FileName, self.Lineno))
-
+ EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID,
+ "Invalid size or value for PCD %s to pack(File: %s Line: %s)." % (self.PcdCName, self.FileName, self.Lineno))
+
## Pack a byte-array PCD value.
#
# A byte-array for a PCD should be in format as {0x01, 0x02, ...}.
#
def _PackByteArray(self, ValueString, Size):
- if (Size < 0):
+ if (Size < 0):
EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID, "Invalid parameter Size %s of PCD %s!(File: %s Line: %s)" % (self.PcdBinSize, self.PcdCName, self.FileName, self.Lineno))
if (ValueString == ""):
- EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID, "Invalid parameter ValueString %s of PCD %s!(File: %s Line: %s)" % (self.PcdUnpackValue, self.PcdCName, self.FileName, self.Lineno))
-
+ EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID, "Invalid parameter ValueString %s of PCD %s!(File: %s Line: %s)" % (self.PcdUnpackValue, self.PcdCName, self.FileName, self.Lineno))
+
ValueString = ValueString.strip()
ValueString = ValueString.lstrip('{').strip('}')
ValueList = ValueString.split(',')
ValueList = [item.strip() for item in ValueList]
-
+
if len(ValueList) > Size:
- EdkLogger.error("BPDG", BuildToolError.RESOURCE_OVERFLOW,
+ EdkLogger.error("BPDG", BuildToolError.RESOURCE_OVERFLOW,
"The byte array %s is too large for size %d(File: %s Line: %s)" % (ValueString, Size, self.FileName, self.Lineno))
-
+
ReturnArray = array.array('B')
-
+
for Index in xrange(len(ValueList)):
Value = None
if ValueList[Index].lower().startswith('0x'):
@@ -232,7 +232,7 @@ class PcdEntry:
try:
Value = int(ValueList[Index], 16)
except:
- EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID,
+ EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID,
"The value item %s in byte array %s is an invalid HEX value.(File: %s Line: %s)" % \
(ValueList[Index], ValueString, self.FileName, self.Lineno))
else:
@@ -243,52 +243,52 @@ class PcdEntry:
EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID,
"The value item %s in byte array %s is an invalid DECIMAL value.(File: %s Line: %s)" % \
(ValueList[Index], ValueString, self.FileName, self.Lineno))
-
+
if Value > 255:
- EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID,
- "The value item %s in byte array %s do not in range 0 ~ 0xFF(File: %s Line: %s)" %\
+ EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID,
+ "The value item %s in byte array %s do not in range 0 ~ 0xFF(File: %s Line: %s)" % \
(ValueList[Index], ValueString, self.FileName, self.Lineno))
-
+
ReturnArray.append(Value)
-
+
for Index in xrange(len(ValueList), Size):
ReturnArray.append(0)
-
- self.PcdValue = ReturnArray.tolist()
+
+ self.PcdValue = ReturnArray.tolist()
## Pack a unicode PCD value into byte array.
#
# A unicode string for a PCD should be in format as L"".
#
def _PackUnicode(self, UnicodeString, Size):
- if (Size < 0):
- EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID, "Invalid parameter Size %s of PCD %s!(File: %s Line: %s)" %\
+ if (Size < 0):
+ EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID, "Invalid parameter Size %s of PCD %s!(File: %s Line: %s)" % \
(self.PcdBinSize, self.PcdCName, self.FileName, self.Lineno))
if (len(UnicodeString) < 3):
- EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID, "For PCD: %s ,ASCII string %s at least contains two!(File: %s Line: %s)" %\
+ EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID, "For PCD: %s ,ASCII string %s at least contains two!(File: %s Line: %s)" % \
(self.PcdCName, self.PcdUnpackValue, self.FileName, self.Lineno))
-
+
UnicodeString = UnicodeString[2:-1]
-
+
if (len(UnicodeString) + 1) * 2 > Size:
EdkLogger.error("BPDG", BuildToolError.RESOURCE_OVERFLOW,
"The size of unicode string %s is too larger for size %s(File: %s Line: %s)" % \
(UnicodeString, Size, self.FileName, self.Lineno))
-
+
ReturnArray = array.array('B')
for Value in UnicodeString:
try:
ReturnArray.append(ord(Value))
ReturnArray.append(0)
except:
- EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID,
+ EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID,
"Invalid unicode character %s in unicode string %s(File: %s Line: %s)" % \
(Value, UnicodeString, self.FileName, self.Lineno))
-
+
for Index in xrange(len(UnicodeString) * 2, Size):
ReturnArray.append(0)
-
- self.PcdValue = ReturnArray.tolist()
+
+ self.PcdValue = ReturnArray.tolist()
@@ -300,7 +300,7 @@ class PcdEntry:
# 3. Fixed offset if needed;
# 4. Generate output file, including guided.map and guided.bin file;
#
-class GenVPD :
+class GenVPD :
## Constructor of DscBuildData
#
# Initialize object of GenVPD
@@ -322,47 +322,47 @@ class GenVPD :
try:
self.FileLinesList = fInputfile.readlines()
except:
- EdkLogger.error("BPDG", BuildToolError.FILE_READ_FAILURE, "File read failed for %s" %InputFileName,None)
+ EdkLogger.error("BPDG", BuildToolError.FILE_READ_FAILURE, "File read failed for %s" % InputFileName, None)
finally:
fInputfile.close()
except:
- EdkLogger.error("BPDG", BuildToolError.FILE_OPEN_FAILURE, "File open failed for %s" %InputFileName,None)
-
+ EdkLogger.error("BPDG", BuildToolError.FILE_OPEN_FAILURE, "File open failed for %s" % InputFileName, None)
+
##
# Parser the input file which is generated by the build tool. Convert the value of each pcd's
# from string to it's real format. Also remove the useless line in the input file.
#
def ParserInputFile (self):
- count = 0
+ count = 0
for line in self.FileLinesList:
# Strip "\r\n" generated by readlines ().
line = line.strip()
line = line.rstrip(os.linesep)
-
+
# Skip the comment line
if (not line.startswith("#")) and len(line) > 1 :
#
# Enhanced for support "|" character in the string.
#
ValueList = ['', '', '', '','']
-
- ValueRe = re.compile(r'\s*L?\".*\|.*\"\s*$')
+
+ ValueRe = re.compile(r'\s*L?\".*\|.*\"\s*$')
PtrValue = ValueRe.findall(line)
-
+
ValueUpdateFlag = False
-
+
if len(PtrValue) >= 1:
line = re.sub(ValueRe, '', line)
- ValueUpdateFlag = True
-
+ ValueUpdateFlag = True
+
TokenList = line.split('|')
ValueList[0:len(TokenList)] = TokenList
-
+
if ValueUpdateFlag:
ValueList[4] = PtrValue[0]
self.FileLinesList[count] = ValueList
# Store the line number
- self.FileLinesList[count].append(str(count+1))
+ self.FileLinesList[count].append(str(count + 1))
elif len(line) <= 1 :
# Set the blank line to "None"
self.FileLinesList[count] = None
@@ -370,9 +370,9 @@ class GenVPD :
# Set the comment line to "None"
self.FileLinesList[count] = None
count += 1
-
+
# The line count contain usage information
- count = 0
+ count = 0
# Delete useless lines
while (True) :
try :
@@ -381,18 +381,18 @@ class GenVPD :
else :
count += 1
except :
- break
+ break
#
# After remove the useless line, if there are no data remain in the file line list,
# Report warning messages to user's.
#
if len(self.FileLinesList) == 0 :
- EdkLogger.warn('BPDG', BuildToolError.RESOURCE_NOT_AVAILABLE,
+ EdkLogger.warn('BPDG', BuildToolError.RESOURCE_NOT_AVAILABLE,
"There are no VPD type pcds defined in DSC file, Please check it.")
-
+
# Process the pcds one by one base on the pcd's value and size
count = 0
- for line in self.FileLinesList:
+ for line in self.FileLinesList:
if line != None :
PCD = PcdEntry(line[0], line[1], line[2], line[3], line[4],line[5], self.InputFileName)
# Strip the space char
@@ -421,7 +421,7 @@ class GenVPD :
PCD.PcdBinSize = PackSize
except:
EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID, "Invalid PCD size value %s at file: %s line: %s" % (PCD.PcdSize, self.InputFileName, PCD.Lineno))
-
+
if PCD._IsBoolean(PCD.PcdValue, PCD.PcdSize):
PCD._PackBooleanValue(PCD.PcdValue)
self.FileLinesList[count] = PCD
@@ -431,7 +431,7 @@ class GenVPD :
# Try to translate value to an integer firstly.
#
IsInteger = True
- PackValue = None
+ PackValue = None
try:
PackValue = int(PCD.PcdValue)
except:
@@ -439,23 +439,23 @@ class GenVPD :
PackValue = int(PCD.PcdValue, 16)
except:
IsInteger = False
-
+
if IsInteger:
PCD._PackIntValue(PackValue, PackSize)
else:
PCD._PackPtrValue(PCD.PcdValue, PackSize)
-
+
self.FileLinesList[count] = PCD
count += 1
else :
continue
-
+
##
# This function used to create a clean list only contain useful information and reorganized to make it
# easy to be sorted
#
def FormatFileLine (self) :
-
+
for eachPcd in self.FileLinesList :
if eachPcd.PcdOffset != '*' :
# Use pcd's Offset value as key, and pcd's Value as value
@@ -463,43 +463,43 @@ class GenVPD :
else :
# Use pcd's CName as key, and pcd's Size as value
self.PcdUnknownOffsetList.append(eachPcd)
-
-
+
+
##
# This function is use to fix the offset value which the not specified in the map file.
# Usually it use the star (meaning any offset) character in the offset field
#
- def FixVpdOffset (self):
+ def FixVpdOffset (self):
# At first, the offset should start at 0
# Sort fixed offset list in order to find out where has free spaces for the pcd's offset
# value is "*" to insert into.
-
- self.PcdFixedOffsetSizeList.sort(lambda x,y: cmp(x.PcdBinOffset, y.PcdBinOffset))
-
+
+ self.PcdFixedOffsetSizeList.sort(lambda x, y: cmp(x.PcdBinOffset, y.PcdBinOffset))
+
#
# Sort the un-fixed pcd's offset by it's size.
#
- self.PcdUnknownOffsetList.sort(lambda x,y: cmp(x.PcdBinSize, y.PcdBinSize))
-
+ self.PcdUnknownOffsetList.sort(lambda x, y: cmp(x.PcdBinSize, y.PcdBinSize))
+
#
# Process all Offset value are "*"
#
if (len(self.PcdFixedOffsetSizeList) == 0) and (len(self.PcdUnknownOffsetList) != 0) :
# The offset start from 0
NowOffset = 0
- for Pcd in self.PcdUnknownOffsetList :
+ for Pcd in self.PcdUnknownOffsetList :
Pcd.PcdBinOffset = NowOffset
Pcd.PcdOffset = str(hex(Pcd.PcdBinOffset))
NowOffset += Pcd.PcdBinSize
self.PcdFixedOffsetSizeList = self.PcdUnknownOffsetList
return
-
+
# Check the offset of VPD type pcd's offset start from 0.
- if self.PcdFixedOffsetSizeList[0].PcdBinOffset != 0 :
+ if self.PcdFixedOffsetSizeList[0].PcdBinOffset != 0 :
EdkLogger.warn("BPDG", "The offset of VPD type pcd should start with 0, please check it.",
- None)
-
+ None)
+
# Judge whether the offset in fixed pcd offset list is overlapped or not.
lenOfList = len(self.PcdFixedOffsetSizeList)
count = 0
@@ -508,22 +508,22 @@ class GenVPD :
PcdNext = self.PcdFixedOffsetSizeList[count+1]
# Two pcd's offset is same
if PcdNow.PcdBinOffset == PcdNext.PcdBinOffset :
- EdkLogger.error("BPDG", BuildToolError.ATTRIBUTE_GET_FAILURE,
- "The offset of %s at line: %s is same with %s at line: %s in file %s" %\
+ EdkLogger.error("BPDG", BuildToolError.ATTRIBUTE_GET_FAILURE,
+ "The offset of %s at line: %s is same with %s at line: %s in file %s" % \
(PcdNow.PcdCName, PcdNow.Lineno, PcdNext.PcdCName, PcdNext.Lineno, PcdNext.FileName),
None)
-
+
# Overlapped
if PcdNow.PcdBinOffset + PcdNow.PcdBinSize > PcdNext.PcdBinOffset :
- EdkLogger.error("BPDG", BuildToolError.ATTRIBUTE_GET_FAILURE,
- "The offset of %s at line: %s is overlapped with %s at line: %s in file %s" %\
+ EdkLogger.error("BPDG", BuildToolError.ATTRIBUTE_GET_FAILURE,
+ "The offset of %s at line: %s is overlapped with %s at line: %s in file %s" % \
(PcdNow.PcdCName, PcdNow.Lineno, PcdNext.PcdCName, PcdNext.Lineno, PcdNext.FileName),
None)
-
+
# Has free space, raise a warning message
if PcdNow.PcdBinOffset + PcdNow.PcdBinSize < PcdNext.PcdBinOffset :
- EdkLogger.warn("BPDG", BuildToolError.ATTRIBUTE_GET_FAILURE,
- "The offsets have free space of between %s at line: %s and %s at line: %s in file %s" %\
+ EdkLogger.warn("BPDG", BuildToolError.ATTRIBUTE_GET_FAILURE,
+ "The offsets have free space of between %s at line: %s and %s at line: %s in file %s" % \
(PcdNow.PcdCName, PcdNow.Lineno, PcdNext.PcdCName, PcdNext.Lineno, PcdNext.FileName),
None)
count += 1
@@ -545,7 +545,7 @@ class GenVPD :
if LastOffset < NowOffset :
if lenOfUnfixedList != 0 :
countOfUnfixedList = 0
- while(countOfUnfixedList < lenOfUnfixedList) :
+ while(countOfUnfixedList < lenOfUnfixedList) :
eachUnfixedPcd = self.PcdUnknownOffsetList[countOfUnfixedList]
needFixPcdSize = eachUnfixedPcd.PcdBinSize
# Not been fixed
@@ -586,8 +586,8 @@ class GenVPD :
FixOffsetSizeListCount += 1
# Usually it will not enter into this thunk, if so, means it overlapped.
else :
- EdkLogger.error("BPDG", BuildToolError.ATTRIBUTE_NOT_AVAILABLE,
- "The offset value definition has overlapped at pcd: %s, it's offset is: %s, in file: %s line: %s" %\
+ EdkLogger.error("BPDG", BuildToolError.ATTRIBUTE_NOT_AVAILABLE,
+ "The offset value definition has overlapped at pcd: %s, it's offset is: %s, in file: %s line: %s" % \
(eachFixedPcd.PcdCName, eachFixedPcd.PcdOffset, eachFixedPcd.InputFileName, eachFixedPcd.Lineno),
None)
FixOffsetSizeListCount += 1
@@ -618,46 +618,46 @@ class GenVPD :
#Open an VPD file to process
try:
- fVpdFile = open (BinFileName, "wb", 0)
+ fVpdFile = open(BinFileName, "wb", 0)
except:
# Open failed
- EdkLogger.error("BPDG", BuildToolError.FILE_OPEN_FAILURE, "File open failed for %s" %self.VpdFileName,None)
-
+ EdkLogger.error("BPDG", BuildToolError.FILE_OPEN_FAILURE, "File open failed for %s" % self.VpdFileName, None)
+
try :
- fMapFile = open (MapFileName, "w", 0)
+ fMapFile = open(MapFileName, "w", 0)
except:
# Open failed
- EdkLogger.error("BPDG", BuildToolError.FILE_OPEN_FAILURE, "File open failed for %s" %self.MapFileName,None)
-
+ EdkLogger.error("BPDG", BuildToolError.FILE_OPEN_FAILURE, "File open failed for %s" % self.MapFileName, None)
+
# Use a instance of StringIO to cache data
- fStringIO = StringIO.StringIO('')
-
+ fStringIO = StringIO.StringIO('')
+
# Write the header of map file.
try :
fMapFile.write (st.MAP_FILE_COMMENT_TEMPLATE + "\n")
except:
- EdkLogger.error("BPDG", BuildToolError.FILE_WRITE_FAILURE, "Write data to file %s failed, please check whether the file been locked or using by other applications." %self.MapFileName,None)
-
+ EdkLogger.error("BPDG", BuildToolError.FILE_WRITE_FAILURE, "Write data to file %s failed, please check whether the file been locked or using by other applications." % self.MapFileName, None)
+
for eachPcd in self.PcdFixedOffsetSizeList :
# write map file
try :
fMapFile.write("%s | %s | %s | %s | %s \n" % (eachPcd.PcdCName, eachPcd.SkuId,eachPcd.PcdOffset, eachPcd.PcdSize,eachPcd.PcdUnpackValue))
except:
- EdkLogger.error("BPDG", BuildToolError.FILE_WRITE_FAILURE, "Write data to file %s failed, please check whether the file been locked or using by other applications." %self.MapFileName,None)
-
+ EdkLogger.error("BPDG", BuildToolError.FILE_WRITE_FAILURE, "Write data to file %s failed, please check whether the file been locked or using by other applications." % self.MapFileName, None)
+
# Write Vpd binary file
- fStringIO.seek (eachPcd.PcdBinOffset)
+ fStringIO.seek (eachPcd.PcdBinOffset)
if isinstance(eachPcd.PcdValue, list):
ValueList = [chr(Item) for Item in eachPcd.PcdValue]
- fStringIO.write(''.join(ValueList))
- else:
+ fStringIO.write(''.join(ValueList))
+ else:
fStringIO.write (eachPcd.PcdValue)
-
- try :
+
+ try :
fVpdFile.write (fStringIO.getvalue())
except:
- EdkLogger.error("BPDG", BuildToolError.FILE_WRITE_FAILURE, "Write data to file %s failed, please check whether the file been locked or using by other applications." %self.VpdFileName,None)
-
+ EdkLogger.error("BPDG", BuildToolError.FILE_WRITE_FAILURE, "Write data to file %s failed, please check whether the file been locked or using by other applications." % self.VpdFileName, None)
+
fStringIO.close ()
fVpdFile.close ()
fMapFile.close ()