Revision: 19651
http://sourceforge.net/p/edk2/code/19651
Author: yzhu52
Date: 2016-01-18 01:47:50 +0000 (Mon, 18 Jan 2016)
Log Message:
-----------
BaseTools: VPD Tool to allocate VPD region be aligned based on value type
Base on build spec update, ASCII strings(?\226?\128?\156string?\226?\128?\157),
will be byte aligned,
Unicode strings(L?\226?\128?\157string?\226?\128?\157) 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 <[email protected]>
Reviewed-by: Liming Gao <[email protected]>
Modified Paths:
--------------
trunk/edk2/BaseTools/Source/Python/BPDG/GenVpd.py
Modified: trunk/edk2/BaseTools/Source/Python/BPDG/GenVpd.py
===================================================================
--- trunk/edk2/BaseTools/Source/Python/BPDG/GenVpd.py 2016-01-18 01:46:25 UTC
(rev 19650)
+++ trunk/edk2/BaseTools/Source/Python/BPDG/GenVpd.py 2016-01-18 01:47:50 UTC
(rev 19651)
@@ -344,7 +344,7 @@
#
# Enhanced for support "|" character in the string.
#
- ValueList = ['', '', '', '','']
+ ValueList = ['', '', '', '','']
ValueRe = re.compile(r'\s*L?\".*\|.*\"\s*$')
PtrValue = ValueRe.findall(line)
@@ -359,7 +359,7 @@
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,16 +400,30 @@
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.
PackSize = None
try:
@@ -490,7 +504,7 @@
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 @@
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 @@
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 @@
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 @@
# 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 @@
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.
------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=267308311&iu=/4140
_______________________________________________
edk2-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-commits