diff options
author | Liming Gao <liming.gao@intel.com> | 2017-12-22 20:23:21 +0800 |
---|---|---|
committer | Liming Gao <liming.gao@intel.com> | 2017-12-25 11:05:51 +0800 |
commit | 0b6c5954e1d9a17e01eee7d5ef840a5b4790e2e8 (patch) | |
tree | fdf9727a45a08ae8d6e59022975d33665581fca8 /BaseTools | |
parent | b23957242c01ae776af86f91ebb35827422dec60 (diff) | |
download | edk2-0b6c5954e1d9a17e01eee7d5ef840a5b4790e2e8.tar.gz edk2-0b6c5954e1d9a17e01eee7d5ef840a5b4790e2e8.tar.bz2 edk2-0b6c5954e1d9a17e01eee7d5ef840a5b4790e2e8.zip |
BaseTools: Generate correct VPD PCD value to store the default setting
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Feng Bob C <bob.c.feng@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
Diffstat (limited to 'BaseTools')
-rw-r--r-- | BaseTools/Source/Python/AutoGen/AutoGen.py | 68 | ||||
-rw-r--r-- | BaseTools/Source/Python/BPDG/GenVpd.py | 8 |
2 files changed, 42 insertions, 34 deletions
diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py b/BaseTools/Source/Python/AutoGen/AutoGen.py index 28e575d219..67de17320b 100644 --- a/BaseTools/Source/Python/AutoGen/AutoGen.py +++ b/BaseTools/Source/Python/AutoGen/AutoGen.py @@ -1393,29 +1393,29 @@ class PlatformAutoGen(AutoGen): return VariableInfo
def UpdateNVStoreMaxSize(self,OrgVpdFile):
- VpdMapFilePath = os.path.join(self.BuildDir, "FV", "%s.map" % self.Platform.VpdToolGuid)
-# VpdFile = VpdInfoFile.VpdInfoFile()
- PcdNvStoreDfBuffer = [item for item in self._DynamicPcdList if item.TokenCName == "PcdNvStoreDefaultValueBuffer" and item.TokenSpaceGuidCName == "gEfiMdeModulePkgTokenSpaceGuid"]
-
- if PcdNvStoreDfBuffer:
- if os.path.exists(VpdMapFilePath):
- OrgVpdFile.Read(VpdMapFilePath)
- PcdItems = OrgVpdFile.GetOffset(PcdNvStoreDfBuffer[0])
- NvStoreOffset = PcdItems[0].strip() if PcdItems else 0
- else:
- EdkLogger.error("build", FILE_READ_FAILURE, "Can not find VPD map file %s to fix up VPD offset." % VpdMapFilePath)
+ if self.VariableInfo:
+ VpdMapFilePath = os.path.join(self.BuildDir, "FV", "%s.map" % self.Platform.VpdToolGuid)
+ PcdNvStoreDfBuffer = [item for item in self._DynamicPcdList if item.TokenCName == "PcdNvStoreDefaultValueBuffer" and item.TokenSpaceGuidCName == "gEfiMdeModulePkgTokenSpaceGuid"]
+
+ if PcdNvStoreDfBuffer:
+ if os.path.exists(VpdMapFilePath):
+ OrgVpdFile.Read(VpdMapFilePath)
+ PcdItems = OrgVpdFile.GetOffset(PcdNvStoreDfBuffer[0])
+ NvStoreOffset = PcdItems[0].strip() if PcdItems else '0'
+ else:
+ EdkLogger.error("build", FILE_READ_FAILURE, "Can not find VPD map file %s to fix up VPD offset." % VpdMapFilePath)
- NvStoreOffset = int(NvStoreOffset,16) if NvStoreOffset.upper().startswith("0X") else int(NvStoreOffset)
- maxsize = self.VariableInfo.VpdRegionSize - NvStoreOffset
- var_data = self.VariableInfo.PatchNVStoreDefaultMaxSize(maxsize)
- default_skuobj = PcdNvStoreDfBuffer[0].SkuInfoList.get("DEFAULT")
+ NvStoreOffset = int(NvStoreOffset,16) if NvStoreOffset.upper().startswith("0X") else int(NvStoreOffset)
+ default_skuobj = PcdNvStoreDfBuffer[0].SkuInfoList.get("DEFAULT")
+ maxsize = self.VariableInfo.VpdRegionSize - NvStoreOffset if self.VariableInfo.VpdRegionSize else len(default_skuobj.DefaultValue.split(","))
+ var_data = self.VariableInfo.PatchNVStoreDefaultMaxSize(maxsize)
- if var_data and default_skuobj:
- default_skuobj.DefaultValue = var_data
- PcdNvStoreDfBuffer[0].DefaultValue = var_data
- PcdNvStoreDfBuffer[0].SkuInfoList.clear()
- PcdNvStoreDfBuffer[0].SkuInfoList['DEFAULT'] = default_skuobj
- PcdNvStoreDfBuffer[0].MaxDatumSize = str(len(default_skuobj.DefaultValue.split(",")))
+ if var_data and default_skuobj:
+ default_skuobj.DefaultValue = var_data
+ PcdNvStoreDfBuffer[0].DefaultValue = var_data
+ PcdNvStoreDfBuffer[0].SkuInfoList.clear()
+ PcdNvStoreDfBuffer[0].SkuInfoList['DEFAULT'] = default_skuobj
+ PcdNvStoreDfBuffer[0].MaxDatumSize = str(len(default_skuobj.DefaultValue.split(",")))
return OrgVpdFile
@@ -1613,9 +1613,9 @@ class PlatformAutoGen(AutoGen): #
# The reason of sorting is make sure the unicode string is in double-byte alignment in string table.
#
- UnicodePcdArray = []
- HiiPcdArray = []
- OtherPcdArray = []
+ UnicodePcdArray = set()
+ HiiPcdArray = set()
+ OtherPcdArray = set()
VpdPcdDict = {}
VpdFile = VpdInfoFile.VpdInfoFile()
NeedProcessVpdMapFile = False
@@ -1775,12 +1775,12 @@ class PlatformAutoGen(AutoGen): if not NeedProcessVpdMapFile and Sku.VpdOffset == "*":
NeedProcessVpdMapFile = True
if DscPcdEntry.DatumType == 'VOID*' and PcdValue.startswith("L"):
- UnicodePcdArray.append(DscPcdEntry)
+ UnicodePcdArray.add(DscPcdEntry)
elif len(Sku.VariableName) > 0:
- HiiPcdArray.append(DscPcdEntry)
+ HiiPcdArray.add(DscPcdEntry)
else:
- OtherPcdArray.append(DscPcdEntry)
-
+ OtherPcdArray.add(DscPcdEntry)
+
# if the offset of a VPD is *, then it need to be fixed up by third party tool.
VpdSkuMap[DscPcd] = SkuValueMap
if (self.Platform.FlashDefinition == None or self.Platform.FlashDefinition == '') and \
@@ -1826,16 +1826,16 @@ class PlatformAutoGen(AutoGen): PcdValue = Sku.DefaultValue
if Pcd.DatumType == 'VOID*' and PcdValue.startswith("L"):
# if found PCD which datum value is unicode string the insert to left size of UnicodeIndex
- UnicodePcdArray.append(Pcd)
+ UnicodePcdArray.add(Pcd)
elif len(Sku.VariableName) > 0:
# if found HII type PCD then insert to right of UnicodeIndex
- HiiPcdArray.append(Pcd)
+ HiiPcdArray.add(Pcd)
else:
- OtherPcdArray.append(Pcd)
+ OtherPcdArray.add(Pcd)
del self._DynamicPcdList[:]
- self._DynamicPcdList.extend(UnicodePcdArray)
- self._DynamicPcdList.extend(HiiPcdArray)
- self._DynamicPcdList.extend(OtherPcdArray)
+ self._DynamicPcdList.extend(list(UnicodePcdArray))
+ self._DynamicPcdList.extend(list(HiiPcdArray))
+ self._DynamicPcdList.extend(list(OtherPcdArray))
allskuset = [(SkuName,Sku.SkuId) for pcd in self._DynamicPcdList for (SkuName,Sku) in pcd.SkuInfoList.items()]
for pcd in self._DynamicPcdList:
if len(pcd.SkuInfoList) == 1:
diff --git a/BaseTools/Source/Python/BPDG/GenVpd.py b/BaseTools/Source/Python/BPDG/GenVpd.py index 4ff464756f..9861e7da68 100644 --- a/BaseTools/Source/Python/BPDG/GenVpd.py +++ b/BaseTools/Source/Python/BPDG/GenVpd.py @@ -503,6 +503,14 @@ class GenVPD : #
self.PcdUnknownOffsetList.sort(lambda x, y: cmp(x.PcdBinSize, y.PcdBinSize))
+ index =0
+ for pcd in self.PcdUnknownOffsetList:
+ index += 1
+ if pcd.PcdCName == ".".join(("gEfiMdeModulePkgTokenSpaceGuid","PcdNvStoreDefaultValueBuffer")):
+ if index != len(self.PcdUnknownOffsetList):
+ for i in range(len(self.PcdUnknownOffsetList) - index):
+ self.PcdUnknownOffsetList[index+i -1 ] , self.PcdUnknownOffsetList[index+i] = self.PcdUnknownOffsetList[index+i] , self.PcdUnknownOffsetList[index+i -1]
+
#
# Process all Offset value are "*"
#
|