BaseTools: VPD Tool to allocate VPD region be aligned based on value type
Base on build spec update, ASCII strings(“string”), will be byte aligned, Unicode strings(L”string”) will be two-byte aligned, Byte arrays, {0x00, 0x01} will be 8-byte aligned. This patch is going to update VPD Tool to allocate VOID* PCDs to an offset value that is aligned based in syntax of the PCD value. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@19651 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
5a13737abf
commit
22061fab23
@ -344,7 +344,7 @@ class GenVPD :
|
|||||||
#
|
#
|
||||||
# Enhanced for support "|" character in the string.
|
# Enhanced for support "|" character in the string.
|
||||||
#
|
#
|
||||||
ValueList = ['', '', '', '','']
|
ValueList = ['', '', '', '','']
|
||||||
|
|
||||||
ValueRe = re.compile(r'\s*L?\".*\|.*\"\s*$')
|
ValueRe = re.compile(r'\s*L?\".*\|.*\"\s*$')
|
||||||
PtrValue = ValueRe.findall(line)
|
PtrValue = ValueRe.findall(line)
|
||||||
@ -359,7 +359,7 @@ class GenVPD :
|
|||||||
ValueList[0:len(TokenList)] = TokenList
|
ValueList[0:len(TokenList)] = TokenList
|
||||||
|
|
||||||
if ValueUpdateFlag:
|
if ValueUpdateFlag:
|
||||||
ValueList[4] = PtrValue[0]
|
ValueList[4] = PtrValue[0]
|
||||||
self.FileLinesList[count] = ValueList
|
self.FileLinesList[count] = ValueList
|
||||||
# Store the line number
|
# Store the line number
|
||||||
self.FileLinesList[count].append(str(count + 1))
|
self.FileLinesList[count].append(str(count + 1))
|
||||||
@ -400,14 +400,28 @@ class GenVPD :
|
|||||||
PCD.SkuId = PCD.SkuId.strip(' ')
|
PCD.SkuId = PCD.SkuId.strip(' ')
|
||||||
PCD.PcdOffset = PCD.PcdOffset.strip(' ')
|
PCD.PcdOffset = PCD.PcdOffset.strip(' ')
|
||||||
PCD.PcdSize = PCD.PcdSize.strip(' ')
|
PCD.PcdSize = PCD.PcdSize.strip(' ')
|
||||||
PCD.PcdValue = PCD.PcdValue.strip(' ')
|
PCD.PcdValue = PCD.PcdValue.strip(' ')
|
||||||
PCD.Lineno = PCD.Lineno.strip(' ')
|
PCD.Lineno = PCD.Lineno.strip(' ')
|
||||||
|
|
||||||
#
|
#
|
||||||
# Store the original pcd value.
|
# Store the original pcd value.
|
||||||
# This information will be useful while generate the output map file.
|
# This information will be useful while generate the output map file.
|
||||||
#
|
#
|
||||||
PCD.PcdUnpackValue = str(PCD.PcdValue)
|
PCD.PcdUnpackValue = str(PCD.PcdValue)
|
||||||
|
|
||||||
|
#
|
||||||
|
# If value is Unicode string (e.g. L""), then use 2-byte alignment
|
||||||
|
# If value is byte array (e.g. {}), then use 8-byte alignment
|
||||||
|
#
|
||||||
|
PCD.PcdOccupySize = int(PCD.PcdSize)
|
||||||
|
if PCD.PcdUnpackValue.startswith("{"):
|
||||||
|
Alignment = 8
|
||||||
|
elif PCD.PcdUnpackValue.startswith("L"):
|
||||||
|
Alignment = 2
|
||||||
|
else:
|
||||||
|
Alignment = 1
|
||||||
|
if PCD.PcdOccupySize % Alignment != 0:
|
||||||
|
PCD.PcdOccupySize = (PCD.PcdOccupySize / Alignment + 1) * Alignment
|
||||||
|
|
||||||
#
|
#
|
||||||
# Translate PCD size string to an integer value.
|
# Translate PCD size string to an integer value.
|
||||||
@ -490,7 +504,7 @@ class GenVPD :
|
|||||||
for Pcd in self.PcdUnknownOffsetList :
|
for Pcd in self.PcdUnknownOffsetList :
|
||||||
Pcd.PcdBinOffset = NowOffset
|
Pcd.PcdBinOffset = NowOffset
|
||||||
Pcd.PcdOffset = str(hex(Pcd.PcdBinOffset))
|
Pcd.PcdOffset = str(hex(Pcd.PcdBinOffset))
|
||||||
NowOffset += Pcd.PcdBinSize
|
NowOffset += Pcd.PcdOccupySize
|
||||||
|
|
||||||
self.PcdFixedOffsetSizeList = self.PcdUnknownOffsetList
|
self.PcdFixedOffsetSizeList = self.PcdUnknownOffsetList
|
||||||
return
|
return
|
||||||
@ -514,14 +528,14 @@ class GenVPD :
|
|||||||
None)
|
None)
|
||||||
|
|
||||||
# Overlapped
|
# Overlapped
|
||||||
if PcdNow.PcdBinOffset + PcdNow.PcdBinSize > PcdNext.PcdBinOffset :
|
if PcdNow.PcdBinOffset + PcdNow.PcdOccupySize > PcdNext.PcdBinOffset :
|
||||||
EdkLogger.error("BPDG", BuildToolError.ATTRIBUTE_GET_FAILURE,
|
EdkLogger.error("BPDG", BuildToolError.ATTRIBUTE_GET_FAILURE,
|
||||||
"The offset of %s at line: %s is overlapped with %s at line: %s in file %s" % \
|
"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),
|
(PcdNow.PcdCName, PcdNow.Lineno, PcdNext.PcdCName, PcdNext.Lineno, PcdNext.FileName),
|
||||||
None)
|
None)
|
||||||
|
|
||||||
# Has free space, raise a warning message
|
# Has free space, raise a warning message
|
||||||
if PcdNow.PcdBinOffset + PcdNow.PcdBinSize < PcdNext.PcdBinOffset :
|
if PcdNow.PcdBinOffset + PcdNow.PcdOccupySize < PcdNext.PcdBinOffset :
|
||||||
EdkLogger.warn("BPDG", BuildToolError.ATTRIBUTE_GET_FAILURE,
|
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" % \
|
"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),
|
(PcdNow.PcdCName, PcdNow.Lineno, PcdNext.PcdCName, PcdNext.Lineno, PcdNext.FileName),
|
||||||
@ -547,7 +561,7 @@ class GenVPD :
|
|||||||
countOfUnfixedList = 0
|
countOfUnfixedList = 0
|
||||||
while(countOfUnfixedList < lenOfUnfixedList) :
|
while(countOfUnfixedList < lenOfUnfixedList) :
|
||||||
eachUnfixedPcd = self.PcdUnknownOffsetList[countOfUnfixedList]
|
eachUnfixedPcd = self.PcdUnknownOffsetList[countOfUnfixedList]
|
||||||
needFixPcdSize = eachUnfixedPcd.PcdBinSize
|
needFixPcdSize = eachUnfixedPcd.PcdOccupySize
|
||||||
# Not been fixed
|
# Not been fixed
|
||||||
if eachUnfixedPcd.PcdOffset == '*' :
|
if eachUnfixedPcd.PcdOffset == '*' :
|
||||||
# The offset un-fixed pcd can write into this free space
|
# The offset un-fixed pcd can write into this free space
|
||||||
@ -572,7 +586,7 @@ class GenVPD :
|
|||||||
LastOffset += needFixPcdSize
|
LastOffset += needFixPcdSize
|
||||||
else :
|
else :
|
||||||
# It can not insert into those two pcds, need to check still has other space can store it.
|
# It can not insert into those two pcds, need to check still has other space can store it.
|
||||||
LastOffset = NowOffset + self.PcdFixedOffsetSizeList[FixOffsetSizeListCount].PcdBinSize
|
LastOffset = NowOffset + self.PcdFixedOffsetSizeList[FixOffsetSizeListCount].PcdOccupySize
|
||||||
FixOffsetSizeListCount += 1
|
FixOffsetSizeListCount += 1
|
||||||
break
|
break
|
||||||
|
|
||||||
@ -582,7 +596,7 @@ class GenVPD :
|
|||||||
|
|
||||||
# No free space, smoothly connect with previous pcd.
|
# No free space, smoothly connect with previous pcd.
|
||||||
elif LastOffset == NowOffset :
|
elif LastOffset == NowOffset :
|
||||||
LastOffset = NowOffset + eachFixedPcd.PcdBinSize
|
LastOffset = NowOffset + eachFixedPcd.PcdOccupySize
|
||||||
FixOffsetSizeListCount += 1
|
FixOffsetSizeListCount += 1
|
||||||
# Usually it will not enter into this thunk, if so, means it overlapped.
|
# Usually it will not enter into this thunk, if so, means it overlapped.
|
||||||
else :
|
else :
|
||||||
@ -601,7 +615,7 @@ class GenVPD :
|
|||||||
LastPcd = self.PcdFixedOffsetSizeList[lenOfList-1]
|
LastPcd = self.PcdFixedOffsetSizeList[lenOfList-1]
|
||||||
NeedFixPcd = self.PcdUnknownOffsetList[0]
|
NeedFixPcd = self.PcdUnknownOffsetList[0]
|
||||||
|
|
||||||
NeedFixPcd.PcdBinOffset = LastPcd.PcdBinOffset + LastPcd.PcdBinSize
|
NeedFixPcd.PcdBinOffset = LastPcd.PcdBinOffset + LastPcd.PcdOccupySize
|
||||||
NeedFixPcd.PcdOffset = str(hex(NeedFixPcd.PcdBinOffset))
|
NeedFixPcd.PcdOffset = str(hex(NeedFixPcd.PcdBinOffset))
|
||||||
|
|
||||||
# Insert this pcd into fixed offset pcd list's tail.
|
# Insert this pcd into fixed offset pcd list's tail.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user