+ def CollectVariables(self, DynamicPcdSet):\r
+\r
+ VpdRegionSize = 0\r
+ VpdRegionBase = 0\r
+ if self.Workspace.FdfFile:\r
+ FdDict = self.Workspace.FdfProfile.FdDict[GlobalData.gFdfParser.CurrentFdName]\r
+ for FdRegion in FdDict.RegionList:\r
+ for item in FdRegion.RegionDataList:\r
+ if self.Platform.VpdToolGuid.strip() and self.Platform.VpdToolGuid in item:\r
+ VpdRegionSize = FdRegion.Size\r
+ VpdRegionBase = FdRegion.Offset\r
+ break\r
+\r
+\r
+ VariableInfo = VariableMgr(self.DscBuildDataObj._GetDefaultStores(),self.DscBuildDataObj._GetSkuIds())\r
+ VariableInfo.SetVpdRegionMaxSize(VpdRegionSize)\r
+ VariableInfo.SetVpdRegionOffset(VpdRegionBase)\r
+ Index = 0\r
+ for Pcd in DynamicPcdSet:\r
+ pcdname = ".".join((Pcd.TokenSpaceGuidCName,Pcd.TokenCName))\r
+ for SkuName in Pcd.SkuInfoList:\r
+ Sku = Pcd.SkuInfoList[SkuName]\r
+ SkuId = Sku.SkuId\r
+ if SkuId == None or SkuId == '':\r
+ continue\r
+ if len(Sku.VariableName) > 0:\r
+ VariableGuidStructure = Sku.VariableGuidValue\r
+ VariableGuid = GuidStructureStringToGuidString(VariableGuidStructure)\r
+ if Pcd.Phase == "DXE":\r
+ for StorageName in Sku.DefaultStoreDict:\r
+ VariableInfo.append_variable(var_info(Index,pcdname,StorageName,SkuName, StringToArray(Sku.VariableName),VariableGuid, Sku.VariableAttribute , Sku.HiiDefaultValue,Sku.DefaultStoreDict[StorageName],Pcd.DatumType))\r
+ Index += 1\r
+ return VariableInfo\r
+\r
+ def UpdateNVStoreMaxSize(self,OrgVpdFile):\r
+ VpdMapFilePath = os.path.join(self.BuildDir, "FV", "%s.map" % self.Platform.VpdToolGuid)\r
+# VpdFile = VpdInfoFile.VpdInfoFile()\r
+ PcdNvStoreDfBuffer = [item for item in self._DynamicPcdList if item.TokenCName == "PcdNvStoreDefaultValueBuffer" and item.TokenSpaceGuidCName == "gEfiMdeModulePkgTokenSpaceGuid"]\r
+\r
+ if PcdNvStoreDfBuffer:\r
+ if os.path.exists(VpdMapFilePath):\r
+ OrgVpdFile.Read(VpdMapFilePath)\r
+ PcdItems = OrgVpdFile.GetOffset(PcdNvStoreDfBuffer[0])\r
+ NvStoreOffset = PcdItems[0].strip() if PcdItems else 0\r
+ else:\r
+ EdkLogger.error("build", FILE_READ_FAILURE, "Can not find VPD map file %s to fix up VPD offset." % VpdMapFilePath)\r
+\r
+ NvStoreOffset = int(NvStoreOffset,16) if NvStoreOffset.upper().startswith("0X") else int(NvStoreOffset)\r
+ maxsize = self.VariableInfo.VpdRegionSize - NvStoreOffset\r
+ var_data = self.VariableInfo.PatchNVStoreDefaultMaxSize(maxsize)\r
+ default_skuobj = PcdNvStoreDfBuffer[0].SkuInfoList.get("DEFAULT")\r
+\r
+ if var_data and default_skuobj:\r
+ default_skuobj.DefaultValue = var_data\r
+ PcdNvStoreDfBuffer[0].DefaultValue = var_data\r
+ PcdNvStoreDfBuffer[0].SkuInfoList.clear()\r
+ PcdNvStoreDfBuffer[0].SkuInfoList['DEFAULT'] = default_skuobj\r
+ PcdNvStoreDfBuffer[0].MaxDatumSize = str(len(default_skuobj.DefaultValue.split(",")))\r
+\r
+ return OrgVpdFile\r
+\r