BaseTools: Fix VPD data optimization issue
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>
This commit is contained in:
@ -1401,7 +1401,7 @@ class PlatformAutoGen(AutoGen):
|
|||||||
if os.path.exists(VpdMapFilePath):
|
if os.path.exists(VpdMapFilePath):
|
||||||
OrgVpdFile.Read(VpdMapFilePath)
|
OrgVpdFile.Read(VpdMapFilePath)
|
||||||
PcdItems = OrgVpdFile.GetOffset(PcdNvStoreDfBuffer[0])
|
PcdItems = OrgVpdFile.GetOffset(PcdNvStoreDfBuffer[0])
|
||||||
NvStoreOffset = PcdItems[0].strip() if PcdItems else '0'
|
NvStoreOffset = PcdItems.values()[0].strip() if PcdItems else '0'
|
||||||
else:
|
else:
|
||||||
EdkLogger.error("build", FILE_READ_FAILURE, "Can not find VPD map file %s to fix up VPD offset." % VpdMapFilePath)
|
EdkLogger.error("build", FILE_READ_FAILURE, "Can not find VPD map file %s to fix up VPD offset." % VpdMapFilePath)
|
||||||
|
|
||||||
@ -1665,6 +1665,14 @@ class PlatformAutoGen(AutoGen):
|
|||||||
PcdKey in VpdPcdDict:
|
PcdKey in VpdPcdDict:
|
||||||
Pcd = VpdPcdDict[PcdKey]
|
Pcd = VpdPcdDict[PcdKey]
|
||||||
SkuValueMap = {}
|
SkuValueMap = {}
|
||||||
|
DefaultSku = Pcd.SkuInfoList.get('DEFAULT')
|
||||||
|
if DefaultSku:
|
||||||
|
PcdValue = DefaultSku.DefaultValue
|
||||||
|
if PcdValue not in SkuValueMap:
|
||||||
|
SkuValueMap[PcdValue] = []
|
||||||
|
VpdFile.Add(Pcd, 'DEFAULT',DefaultSku.VpdOffset)
|
||||||
|
SkuValueMap[PcdValue].append(DefaultSku)
|
||||||
|
|
||||||
for (SkuName,Sku) in Pcd.SkuInfoList.items():
|
for (SkuName,Sku) in Pcd.SkuInfoList.items():
|
||||||
Sku.VpdOffset = Sku.VpdOffset.strip()
|
Sku.VpdOffset = Sku.VpdOffset.strip()
|
||||||
PcdValue = Sku.DefaultValue
|
PcdValue = Sku.DefaultValue
|
||||||
@ -1691,7 +1699,7 @@ class PlatformAutoGen(AutoGen):
|
|||||||
EdkLogger.error("build", FORMAT_INVALID, 'The offset value of PCD %s.%s should be %s-byte aligned.' % (Pcd.TokenSpaceGuidCName, Pcd.TokenCName, Alignment))
|
EdkLogger.error("build", FORMAT_INVALID, 'The offset value of PCD %s.%s should be %s-byte aligned.' % (Pcd.TokenSpaceGuidCName, Pcd.TokenCName, Alignment))
|
||||||
if PcdValue not in SkuValueMap:
|
if PcdValue not in SkuValueMap:
|
||||||
SkuValueMap[PcdValue] = []
|
SkuValueMap[PcdValue] = []
|
||||||
VpdFile.Add(Pcd, Sku.VpdOffset)
|
VpdFile.Add(Pcd, SkuName,Sku.VpdOffset)
|
||||||
SkuValueMap[PcdValue].append(Sku)
|
SkuValueMap[PcdValue].append(Sku)
|
||||||
# if the offset of a VPD is *, then it need to be fixed up by third party tool.
|
# if the offset of a VPD is *, then it need to be fixed up by third party tool.
|
||||||
if not NeedProcessVpdMapFile and Sku.VpdOffset == "*":
|
if not NeedProcessVpdMapFile and Sku.VpdOffset == "*":
|
||||||
@ -1720,6 +1728,13 @@ class PlatformAutoGen(AutoGen):
|
|||||||
if not FoundFlag :
|
if not FoundFlag :
|
||||||
# just pick the a value to determine whether is unicode string type
|
# just pick the a value to determine whether is unicode string type
|
||||||
SkuValueMap = {}
|
SkuValueMap = {}
|
||||||
|
DefaultSku = DscPcdEntry.SkuInfoList.get('DEFAULT')
|
||||||
|
if DefaultSku:
|
||||||
|
PcdValue = DefaultSku.DefaultValue
|
||||||
|
if PcdValue not in SkuValueMap:
|
||||||
|
SkuValueMap[PcdValue] = []
|
||||||
|
VpdFile.Add(DscPcdEntry, 'DEFAULT',Sku.VpdOffset)
|
||||||
|
SkuValueMap[PcdValue].append(Sku)
|
||||||
for (SkuName,Sku) in DscPcdEntry.SkuInfoList.items():
|
for (SkuName,Sku) in DscPcdEntry.SkuInfoList.items():
|
||||||
Sku.VpdOffset = Sku.VpdOffset.strip()
|
Sku.VpdOffset = Sku.VpdOffset.strip()
|
||||||
|
|
||||||
@ -1770,7 +1785,7 @@ class PlatformAutoGen(AutoGen):
|
|||||||
EdkLogger.error("build", FORMAT_INVALID, 'The offset value of PCD %s.%s should be %s-byte aligned.' % (DscPcdEntry.TokenSpaceGuidCName, DscPcdEntry.TokenCName, Alignment))
|
EdkLogger.error("build", FORMAT_INVALID, 'The offset value of PCD %s.%s should be %s-byte aligned.' % (DscPcdEntry.TokenSpaceGuidCName, DscPcdEntry.TokenCName, Alignment))
|
||||||
if PcdValue not in SkuValueMap:
|
if PcdValue not in SkuValueMap:
|
||||||
SkuValueMap[PcdValue] = []
|
SkuValueMap[PcdValue] = []
|
||||||
VpdFile.Add(DscPcdEntry, Sku.VpdOffset)
|
VpdFile.Add(DscPcdEntry, SkuName,Sku.VpdOffset)
|
||||||
SkuValueMap[PcdValue].append(Sku)
|
SkuValueMap[PcdValue].append(Sku)
|
||||||
if not NeedProcessVpdMapFile and Sku.VpdOffset == "*":
|
if not NeedProcessVpdMapFile and Sku.VpdOffset == "*":
|
||||||
NeedProcessVpdMapFile = True
|
NeedProcessVpdMapFile = True
|
||||||
|
@ -88,7 +88,7 @@ class VpdInfoFile:
|
|||||||
#
|
#
|
||||||
# @param offset integer value for VPD's offset in specific SKU.
|
# @param offset integer value for VPD's offset in specific SKU.
|
||||||
#
|
#
|
||||||
def Add(self, Vpd, Offset):
|
def Add(self, Vpd, skuname,Offset):
|
||||||
if (Vpd == None):
|
if (Vpd == None):
|
||||||
EdkLogger.error("VpdInfoFile", BuildToolError.ATTRIBUTE_UNKNOWN_ERROR, "Invalid VPD PCD entry.")
|
EdkLogger.error("VpdInfoFile", BuildToolError.ATTRIBUTE_UNKNOWN_ERROR, "Invalid VPD PCD entry.")
|
||||||
|
|
||||||
@ -111,12 +111,9 @@ class VpdInfoFile:
|
|||||||
#
|
#
|
||||||
# If there is no Vpd instance in dict, that imply this offset for a given SKU is a new one
|
# If there is no Vpd instance in dict, that imply this offset for a given SKU is a new one
|
||||||
#
|
#
|
||||||
self._VpdArray[Vpd] = [Offset]
|
self._VpdArray[Vpd] = {}
|
||||||
else:
|
|
||||||
#
|
self._VpdArray[Vpd].update({skuname:Offset})
|
||||||
# If there is an offset for a specific SKU in dict, then append this offset for other sku to array.
|
|
||||||
#
|
|
||||||
self._VpdArray[Vpd].append(Offset)
|
|
||||||
|
|
||||||
|
|
||||||
## Generate VPD PCD information into a text file
|
## Generate VPD PCD information into a text file
|
||||||
@ -138,12 +135,12 @@ class VpdInfoFile:
|
|||||||
for PcdItem in GlobalData.MixedPcd:
|
for PcdItem in GlobalData.MixedPcd:
|
||||||
if (Pcd.TokenCName, Pcd.TokenSpaceGuidCName) in GlobalData.MixedPcd[PcdItem]:
|
if (Pcd.TokenCName, Pcd.TokenSpaceGuidCName) in GlobalData.MixedPcd[PcdItem]:
|
||||||
PcdTokenCName = PcdItem[0]
|
PcdTokenCName = PcdItem[0]
|
||||||
for Offset in self._VpdArray[Pcd]:
|
for skuname in self._VpdArray[Pcd]:
|
||||||
PcdValue = str(Pcd.SkuInfoList[Pcd.SkuInfoList.keys()[i]].DefaultValue).strip()
|
PcdValue = str(Pcd.SkuInfoList[skuname].DefaultValue).strip()
|
||||||
if PcdValue == "" :
|
if PcdValue == "" :
|
||||||
PcdValue = Pcd.DefaultValue
|
PcdValue = Pcd.DefaultValue
|
||||||
|
|
||||||
Content += "%s.%s|%s|%s|%s|%s \n" % (Pcd.TokenSpaceGuidCName, PcdTokenCName, str(Pcd.SkuInfoList.keys()[i]),str(Offset).strip(), str(Pcd.MaxDatumSize).strip(),PcdValue)
|
Content += "%s.%s|%s|%s|%s|%s \n" % (Pcd.TokenSpaceGuidCName, PcdTokenCName, skuname,str(self._VpdArray[Pcd][skuname]).strip(), str(Pcd.MaxDatumSize).strip(),PcdValue)
|
||||||
i += 1
|
i += 1
|
||||||
|
|
||||||
return SaveFileOnChange(FilePath, Content, False)
|
return SaveFileOnChange(FilePath, Content, False)
|
||||||
@ -190,10 +187,10 @@ class VpdInfoFile:
|
|||||||
VpdObjectTokenCName = PcdItem[0]
|
VpdObjectTokenCName = PcdItem[0]
|
||||||
for sku in VpdObject.SkuInfoList.keys():
|
for sku in VpdObject.SkuInfoList.keys():
|
||||||
if VpdObject.TokenSpaceGuidCName == TokenSpaceName and VpdObjectTokenCName == PcdTokenName.strip() and sku == SkuId:
|
if VpdObject.TokenSpaceGuidCName == TokenSpaceName and VpdObjectTokenCName == PcdTokenName.strip() and sku == SkuId:
|
||||||
if self._VpdArray[VpdObject][VpdObject.SkuInfoList.keys().index(sku)] == "*":
|
if self._VpdArray[VpdObject][sku] == "*":
|
||||||
if Offset == "*":
|
if Offset == "*":
|
||||||
EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID, "The offset of %s has not been fixed up by third-party BPDG tool." % PcdName)
|
EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID, "The offset of %s has not been fixed up by third-party BPDG tool." % PcdName)
|
||||||
self._VpdArray[VpdObject][VpdObject.SkuInfoList.keys().index(sku)] = Offset
|
self._VpdArray[VpdObject][sku] = Offset
|
||||||
Found = True
|
Found = True
|
||||||
if not Found:
|
if not Found:
|
||||||
EdkLogger.error("BPDG", BuildToolError.PARSER_ERROR, "Can not find PCD defined in VPD guid file.")
|
EdkLogger.error("BPDG", BuildToolError.PARSER_ERROR, "Can not find PCD defined in VPD guid file.")
|
||||||
|
@ -1653,6 +1653,7 @@ class DscBuildData(PlatformBuildClassObject):
|
|||||||
Pcds = {}
|
Pcds = {}
|
||||||
DefaultStoreObj = DefaultStore(self._GetDefaultStores())
|
DefaultStoreObj = DefaultStore(self._GetDefaultStores())
|
||||||
SkuIds = set([(skuid,skuobj.SkuId) for pcdobj in PcdSet.values() for skuid,skuobj in pcdobj.SkuInfoList.items()])
|
SkuIds = set([(skuid,skuobj.SkuId) for pcdobj in PcdSet.values() for skuid,skuobj in pcdobj.SkuInfoList.items()])
|
||||||
|
SkuIds = self.SkuIdMgr.AvailableSkuIdSet
|
||||||
DefaultStores = set([storename for pcdobj in PcdSet.values() for skuobj in pcdobj.SkuInfoList.values() for storename in skuobj.DefaultStoreDict.keys()])
|
DefaultStores = set([storename for pcdobj in PcdSet.values() for skuobj in pcdobj.SkuInfoList.values() for storename in skuobj.DefaultStoreDict.keys()])
|
||||||
for PcdCName, TokenSpaceGuid in PcdSet:
|
for PcdCName, TokenSpaceGuid in PcdSet:
|
||||||
PcdObj = PcdSet[(PcdCName, TokenSpaceGuid)]
|
PcdObj = PcdSet[(PcdCName, TokenSpaceGuid)]
|
||||||
@ -1673,7 +1674,7 @@ class DscBuildData(PlatformBuildClassObject):
|
|||||||
if defaultstorename not in skuobj.DefaultStoreDict:
|
if defaultstorename not in skuobj.DefaultStoreDict:
|
||||||
skuobj.DefaultStoreDict[defaultstorename] = copy.deepcopy(skuobj.DefaultStoreDict[mindefaultstorename])
|
skuobj.DefaultStoreDict[defaultstorename] = copy.deepcopy(skuobj.DefaultStoreDict[mindefaultstorename])
|
||||||
skuobj.HiiDefaultValue = skuobj.DefaultStoreDict[mindefaultstorename]
|
skuobj.HiiDefaultValue = skuobj.DefaultStoreDict[mindefaultstorename]
|
||||||
for skuname,skuid in SkuIds:
|
for skuname,skuid in SkuIds.items():
|
||||||
if skuname not in PcdObj.SkuInfoList:
|
if skuname not in PcdObj.SkuInfoList:
|
||||||
nextskuid = self.SkuIdMgr.GetNextSkuId(skuname)
|
nextskuid = self.SkuIdMgr.GetNextSkuId(skuname)
|
||||||
while nextskuid not in PcdObj.SkuInfoList:
|
while nextskuid not in PcdObj.SkuInfoList:
|
||||||
|
Reference in New Issue
Block a user