mirror of https://github.com/acidanthera/audk.git
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.
|
||||
#
|
||||
ValueList = ['', '', '', '','']
|
||||
ValueList = ['', '', '', '','']
|
||||
|
||||
ValueRe = re.compile(r'\s*L?\".*\|.*\"\s*$')
|
||||
PtrValue = ValueRe.findall(line)
|
||||
|
@ -359,7 +359,7 @@ class GenVPD :
|
|||
ValueList[0:len(TokenList)] = TokenList
|
||||
|
||||
if ValueUpdateFlag:
|
||||
ValueList[4] = PtrValue[0]
|
||||
ValueList[4] = PtrValue[0]
|
||||
self.FileLinesList[count] = ValueList
|
||||
# Store the line number
|
||||
self.FileLinesList[count].append(str(count + 1))
|
||||
|
@ -400,14 +400,28 @@ class GenVPD :
|
|||
PCD.SkuId = PCD.SkuId.strip(' ')
|
||||
PCD.PcdOffset = PCD.PcdOffset.strip(' ')
|
||||
PCD.PcdSize = PCD.PcdSize.strip(' ')
|
||||
PCD.PcdValue = PCD.PcdValue.strip(' ')
|
||||
PCD.PcdValue = PCD.PcdValue.strip(' ')
|
||||
PCD.Lineno = PCD.Lineno.strip(' ')
|
||||
|
||||
|
||||
#
|
||||
# Store the original pcd value.
|
||||
# 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.
|
||||
|
@ -490,7 +504,7 @@ class GenVPD :
|
|||
for Pcd in self.PcdUnknownOffsetList :
|
||||
Pcd.PcdBinOffset = NowOffset
|
||||
Pcd.PcdOffset = str(hex(Pcd.PcdBinOffset))
|
||||
NowOffset += Pcd.PcdBinSize
|
||||
NowOffset += Pcd.PcdOccupySize
|
||||
|
||||
self.PcdFixedOffsetSizeList = self.PcdUnknownOffsetList
|
||||
return
|
||||
|
@ -514,14 +528,14 @@ class GenVPD :
|
|||
None)
|
||||
|
||||
# Overlapped
|
||||
if PcdNow.PcdBinOffset + PcdNow.PcdBinSize > PcdNext.PcdBinOffset :
|
||||
if PcdNow.PcdBinOffset + PcdNow.PcdOccupySize > 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" % \
|
||||
(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 :
|
||||
if PcdNow.PcdBinOffset + PcdNow.PcdOccupySize < 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" % \
|
||||
(PcdNow.PcdCName, PcdNow.Lineno, PcdNext.PcdCName, PcdNext.Lineno, PcdNext.FileName),
|
||||
|
@ -547,7 +561,7 @@ class GenVPD :
|
|||
countOfUnfixedList = 0
|
||||
while(countOfUnfixedList < lenOfUnfixedList) :
|
||||
eachUnfixedPcd = self.PcdUnknownOffsetList[countOfUnfixedList]
|
||||
needFixPcdSize = eachUnfixedPcd.PcdBinSize
|
||||
needFixPcdSize = eachUnfixedPcd.PcdOccupySize
|
||||
# Not been fixed
|
||||
if eachUnfixedPcd.PcdOffset == '*' :
|
||||
# The offset un-fixed pcd can write into this free space
|
||||
|
@ -572,7 +586,7 @@ class GenVPD :
|
|||
LastOffset += needFixPcdSize
|
||||
else :
|
||||
# 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
|
||||
break
|
||||
|
||||
|
@ -582,7 +596,7 @@ class GenVPD :
|
|||
|
||||
# No free space, smoothly connect with previous pcd.
|
||||
elif LastOffset == NowOffset :
|
||||
LastOffset = NowOffset + eachFixedPcd.PcdBinSize
|
||||
LastOffset = NowOffset + eachFixedPcd.PcdOccupySize
|
||||
FixOffsetSizeListCount += 1
|
||||
# Usually it will not enter into this thunk, if so, means it overlapped.
|
||||
else :
|
||||
|
@ -601,7 +615,7 @@ class GenVPD :
|
|||
LastPcd = self.PcdFixedOffsetSizeList[lenOfList-1]
|
||||
NeedFixPcd = self.PcdUnknownOffsetList[0]
|
||||
|
||||
NeedFixPcd.PcdBinOffset = LastPcd.PcdBinOffset + LastPcd.PcdBinSize
|
||||
NeedFixPcd.PcdBinOffset = LastPcd.PcdBinOffset + LastPcd.PcdOccupySize
|
||||
NeedFixPcd.PcdOffset = str(hex(NeedFixPcd.PcdBinOffset))
|
||||
|
||||
# Insert this pcd into fixed offset pcd list's tail.
|
||||
|
|
Loading…
Reference in New Issue