From nobody Fri Nov 1 12:22:49 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 15166739409027.623976362494773; Mon, 22 Jan 2018 18:19:00 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id F342F2233378A; Mon, 22 Jan 2018 18:13:32 -0800 (PST) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 81E5822333787 for ; Mon, 22 Jan 2018 18:13:31 -0800 (PST) Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 22 Jan 2018 18:18:57 -0800 Received: from shwdeopenpsi105.ccr.corp.intel.com ([10.239.9.129]) by fmsmga005.fm.intel.com with ESMTP; 22 Jan 2018 18:18:56 -0800 X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.115; helo=mga14.intel.com; envelope-from=bob.c.feng@intel.com; receiver=edk2-devel@lists.01.org X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,398,1511856000"; d="scan'208";a="197787656" From: BobCF To: edk2-devel@lists.01.org Date: Tue, 23 Jan 2018 10:18:53 +0800 Message-Id: <20180123021853.12684-1-bob.c.feng@intel.com> X-Mailer: git-send-email 2.14.3.windows.1 Subject: [edk2] [Patch] BaseTool: Combine the HiiPcd value if they link to same Variable X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Liming Gao MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Bob Feng Cc: Liming Gao Reviewed-by: Liming Gao --- BaseTools/Source/Python/AutoGen/AutoGen.py | 2 +- BaseTools/Source/Python/AutoGen/GenVar.py | 36 ++++++++++++++++++++++++++= ++-- 2 files changed, 35 insertions(+), 3 deletions(-) diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py b/BaseTools/Source/= Python/AutoGen/AutoGen.py index 0f7454f55a..604d38a4d6 100644 --- a/BaseTools/Source/Python/AutoGen/AutoGen.py +++ b/BaseTools/Source/Python/AutoGen/AutoGen.py @@ -1404,11 +1404,11 @@ class PlatformAutoGen(AutoGen): continue if len(Sku.VariableName) > 0: VariableGuidStructure =3D Sku.VariableGuidValue VariableGuid =3D GuidStructureStringToGuidString(Varia= bleGuidStructure) for StorageName in Sku.DefaultStoreDict: - VariableInfo.append_variable(var_info(Index,pcdnam= e,StorageName,SkuName, StringToArray(Sku.VariableName),VariableGuid, Sku.Va= riableAttribute , Sku.HiiDefaultValue,Sku.DefaultStoreDict[StorageName],Pcd= .DatumType)) + VariableInfo.append_variable(var_info(Index,pcdnam= e,StorageName,SkuName, StringToArray(Sku.VariableName),VariableGuid, Sku.Va= riableOffset, Sku.VariableAttribute , Sku.HiiDefaultValue,Sku.DefaultStoreD= ict[StorageName],Pcd.DatumType)) Index +=3D 1 return VariableInfo =20 def UpdateNVStoreMaxSize(self,OrgVpdFile): if self.VariableInfo: diff --git a/BaseTools/Source/Python/AutoGen/GenVar.py b/BaseTools/Source/P= ython/AutoGen/GenVar.py index 65d0bea36c..1389d7ff62 100644 --- a/BaseTools/Source/Python/AutoGen/GenVar.py +++ b/BaseTools/Source/Python/AutoGen/GenVar.py @@ -19,11 +19,11 @@ import collections import copy from Common.VariableAttributes import VariableAttributes from Common.Misc import * import collections =20 -var_info =3D collections.namedtuple("uefi_var", "pcdindex,pcdname,defaults= toragename,skuname,var_name, var_guid, var_attribute,pcd_default_value, def= ault_value, data_type") +var_info =3D collections.namedtuple("uefi_var", "pcdindex,pcdname,defaults= toragename,skuname,var_name, var_guid, var_offset,var_attribute,pcd_default= _value, default_value, data_type") NvStorageHeaderSize =3D 28 VariableHeaderSize =3D 32 =20 def StringArrayToList(StringArray): StringArray =3D StringArray[1:-1] @@ -74,11 +74,42 @@ class VariableMgr(object): value_str =3D "{" default_var_bin_strip =3D [ data.strip("""'""") for data in defaul= t_var_bin] value_str +=3D ",".join(default_var_bin_strip) value_str +=3D "}" return value_str - + def combine_variable(self): + indexedvarinfo =3D collections.OrderedDict() + for item in self.VarInfo: + if (item.skuname,item.defaultstoragename, item.var_name,item.v= ar_guid) not in indexedvarinfo: + indexedvarinfo[(item.skuname,item.defaultstoragename, item= .var_name,item.var_guid) ] =3D [] + indexedvarinfo[(item.skuname,item.defaultstoragename, item.var= _name,item.var_guid)].append(item) + for key in indexedvarinfo: + sku_var_info_offset_list =3D indexedvarinfo[key] + if len(sku_var_info_offset_list) =3D=3D 1: + continue + newvalue =3D {} + for item in sku_var_info_offset_list: + data_type =3D item.data_type + value_list =3D item.default_value.strip("{").strip("}").sp= lit(",") + if data_type in ["BOOLEAN","UINT8","UINT16","UINT32","UINT= 64"]: + if data_type =3D=3D ["BOOLEAN","UINT8"]: + data_flag =3D "=3DB" + elif data_type =3D=3D "UINT16": + data_flag =3D "=3DH" + elif data_type =3D=3D "UINT32": + data_flag =3D "=3DL" + elif data_type =3D=3D "UINT64": + data_flag =3D "=3DQ" + data =3D value_list[0] + value_list =3D [] + for data_byte in pack(data_flag,int(data,16) if data.u= pper().startswith('0X') else int(data)): + value_list +=3D [hex(unpack("B",data_byte)[0])] + newvalue[int(item.var_offset,16) if item.var_offset.upper(= ).startswith("0X") else int(item.var_offset)] =3D value_list + newvaluestr =3D "{" + ",".join(reduce(lambda x,y: x+y, [newval= ue[k] for k in sorted(newvalue.keys())] )) +"}" + n =3D sku_var_info_offset_list[0] + indexedvarinfo[key] =3D [var_info(n.pcdindex,n.pcdname,n.defa= ultstoragename,n.skuname,n.var_name, n.var_guid, "0x00",n.var_attribute,new= valuestr , newvaluestr , "VOID*")] + self.VarInfo =3D [item[0] for item in indexedvarinfo.values()] def process_variable_data(self): =20 var_data =3D dict() =20 indexedvarinfo =3D collections.OrderedDict() @@ -132,10 +163,11 @@ class VariableMgr(object): var_data[(skuid,defaultstoragename)] =3D collections.O= rderedDict() var_data[(skuid,defaultstoragename)][index] =3D (data_delt= a,sku_var_info[(skuid,defaultstoragename)]) return var_data =20 def new_process_varinfo(self): + self.combine_variable() =20 var_data =3D self.process_variable_data() =20 if not var_data: return [] --=20 2.14.3.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel