From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.93; helo=mga11.intel.com; envelope-from=jaben.carsey@intel.com; receiver=edk2-devel@lists.01.org Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) (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 A40E12117B57F for ; Mon, 22 Oct 2018 08:14:05 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 22 Oct 2018 08:14:05 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,412,1534834800"; d="scan'208";a="97485963" Received: from fmsmsx103.amr.corp.intel.com ([10.18.124.201]) by fmsmga002.fm.intel.com with ESMTP; 22 Oct 2018 08:14:05 -0700 Received: from FMSMSX109.amr.corp.intel.com (10.18.116.9) by FMSMSX103.amr.corp.intel.com (10.18.124.201) with Microsoft SMTP Server (TLS) id 14.3.319.2; Mon, 22 Oct 2018 08:14:04 -0700 Received: from fmsmsx103.amr.corp.intel.com ([169.254.2.16]) by FMSMSX109.amr.corp.intel.com ([169.254.15.83]) with mapi id 14.03.0319.002; Mon, 22 Oct 2018 08:14:04 -0700 From: "Carsey, Jaben" To: "Feng, Bob C" , "Zhao, ZhiqiangX" , "edk2-devel@lists.01.org" CC: "Gao, Liming" Thread-Topic: [PATCH V2] BaseTool: Support different PCDs that refers to the same EFI variable. Thread-Index: AQHUaSuGEdOvYUfqnkaPAnQOQtKYZKUrYS7w Date: Mon, 22 Oct 2018 15:14:03 +0000 Message-ID: References: <20181018071211.49332-1-zhiqiangx.zhao@intel.com> <08650203BA1BD64D8AD9B6D5D74A85D15FFC3080@SHSMSX101.ccr.corp.intel.com> In-Reply-To: <08650203BA1BD64D8AD9B6D5D74A85D15FFC3080@SHSMSX101.ccr.corp.intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiZGFhMWQ2ZjEtMTg0Yi00OGZkLWFiNDYtMmJjZmMyY2YzZDAzIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoibzJsSjN2aFpMQVJQb1o3M2prZ0xEZEU5RFZHQ0xoV0IrYWN0bnNyQllzYkVEV2k1bjAyZGdSUERRelBuN29rcSJ9 x-ctpclassification: CTP_NT dlp-product: dlpe-windows dlp-version: 11.0.400.15 dlp-reaction: no-action x-originating-ip: [10.1.200.108] MIME-Version: 1.0 Subject: Re: [PATCH V2] BaseTool: Support different PCDs that refers to the same EFI variable. X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 22 Oct 2018 15:14:05 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable No effect on functionality, but sometimes first is spelled fisrt in below p= atch. =20 > -----Original Message----- > From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of > Feng, Bob C > Sent: Sunday, October 21, 2018 3:48 AM > To: Zhao, ZhiqiangX ; edk2-devel@lists.01.org > Cc: Gao, Liming > Subject: Re: [edk2] [PATCH V2] BaseTool: Support different PCDs that refe= rs > to the same EFI variable. >=20 > Reviewed-by: Bob Feng >=20 > -----Original Message----- > From: Zhao, ZhiqiangX > Sent: Thursday, October 18, 2018 3:12 PM > To: edk2-devel@lists.01.org > Cc: Zhao, ZhiqiangX ; Gao, Liming > ; Zhu, Yonghong ; Feng, > Bob C > Subject: [PATCH V2] BaseTool: Support different PCDs that refers to the > same EFI variable. >=20 > V2: > Make the code of patch both compatible for Python2 and Python3. >=20 > V1: > If different PCDs refer to the same EFI variable, then do EFI variable > combination, according to the VariableOffset of different PCDS. >=20 > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: ZhiqiangX Zhao > Cc: Liming Gao > Cc: Yonghong Zhu > Cc: Bob Feng > --- > BaseTools/Source/Python/AutoGen/GenVar.py | 97 ++++++++++------------ > --------- > 1 file changed, 30 insertions(+), 67 deletions(-) >=20 > diff --git a/BaseTools/Source/Python/AutoGen/GenVar.py > b/BaseTools/Source/Python/AutoGen/GenVar.py > index 036f00e2bb..98f88e2497 100644 > --- a/BaseTools/Source/Python/AutoGen/GenVar.py > +++ b/BaseTools/Source/Python/AutoGen/GenVar.py > @@ -56,51 +56,7 @@ class VariableMgr(object): > value_str +=3D ",".join(default_var_bin_strip) > value_str +=3D "}" > return value_str > - def Do_combine(self,sku_var_info_offset_list): > - newvalue =3D {} > - for item in sku_var_info_offset_list: > - data_type =3D item.data_type > - value_list =3D item.default_value.strip("{").strip("}").spli= t(",") > - if data_type in DataType.TAB_PCD_NUMERIC_TYPES: > - data_flag =3D > DataType.PACK_CODE_BY_SIZE[MAX_SIZE_TYPE[data_type]] > - data =3D value_list[0] > - value_list =3D [] > - for data_byte in pack(data_flag, int(data, 16) if > data.upper().startswith('0X') else int(data)): > - value_list.append(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 > - try: > - newvaluestr =3D "{" + > ",".join(VariableMgr.assemble_variable(newvalue)) +"}" > - except: > - EdkLogger.error("build", AUTOGEN_ERROR, "Variable offset con= flict in > PCDs: %s \n" % (" and ".join(item.pcdname for item in > sku_var_info_offset_list))) > - return newvaluestr > - def Do_Merge(self,sku_var_info_offset_list): > - StructrurePcds =3D sorted([item for item in sku_var_info_offset_= list if > item.StructurePcd], key =3D lambda x: x.PcdDscLine, reverse =3DTrue ) > - Base =3D StructrurePcds[0] > - BaseValue =3D Base.default_value.strip("{").strip("}").split(","= ) > - Override =3D [item for item in sku_var_info_offset_list if not > item.StructurePcd and item.PcdDscLine > Base.PcdDscLine] > - newvalue =3D {} > - for item in Override: > - data_type =3D item.data_type > - value_list =3D item.default_value.strip("{").strip("}").spli= t(",") > - if data_type in DataType.TAB_PCD_NUMERIC_TYPES: > - data_flag =3D > DataType.PACK_CODE_BY_SIZE[MAX_SIZE_TYPE[data_type]] > - data =3D value_list[0] > - value_list =3D [] > - for data_byte in pack(data_flag, int(data, 16) if > data.upper().startswith('0X') else int(data)): > - value_list.append(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,item.pcdname,item.PcdDscLine) > - for offset in newvalue: > - value_list,itemPcdname,itemPcdDscLine =3D newvalue[offset] > - if offset > len(BaseValue) or (offset + len(value_list) > > len(BaseValue)): > - EdkLogger.error("build", AUTOGEN_ERROR, "The EFI Variabl= e > referred by PCD %s in line %s exceeds variable size: %s\n" % > (itemPcdname,itemPcdDscLine,hex(len(BaseValue)))) > - for i in xrange(len(value_list)): > - BaseValue[offset + i] =3D value_list[i] > - newvaluestr =3D "{" + ",".join(BaseValue) +"}" > - return newvaluestr > - def NeedMerge(self,sku_var_info_offset_list): > - if [item for item in sku_var_info_offset_list if item.StructureP= cd]: > - return True > - return False > + > def combine_variable(self): > indexedvarinfo =3D collections.OrderedDict() > for item in self.VarInfo: > @@ -109,30 +65,37 @@ class VariableMgr(object): > 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 > - > + sku_var_info_offset_list.sort(key=3Dlambda x:x.PcdDscLine) > + FirstOffset =3D int(sku_var_info_offset_list[0].var_offset, = 16) if > sku_var_info_offset_list[0].var_offset.upper().startswith("0X") else > int(sku_var_info_offset_list[0].var_offset) > + fisrtvalue_list =3D > sku_var_info_offset_list[0].default_value.strip("{").strip("}").split(","= ) > + firstdata_type =3D sku_var_info_offset_list[0].data_type > + if firstdata_type in DataType.TAB_PCD_NUMERIC_TYPES: > + fisrtdata_flag =3D > DataType.PACK_CODE_BY_SIZE[MAX_SIZE_TYPE[firstdata_type]] > + fisrtdata =3D fisrtvalue_list[0] > + fisrtvalue_list =3D [] > + for data_byte in pack(fisrtdata_flag, int(fisrtdata, 16)= if > fisrtdata.upper().startswith('0X') else int(fisrtdata)): > + fisrtvalue_list.append(hex(unpack("B", data_byte)[0]= )) > + newvalue_list =3D ["0x00"] * FirstOffset + fisrtvalue_list > + > + for var_item in sku_var_info_offset_list[1:]: > + CurOffset =3D int(var_item.var_offset, 16) if > var_item.var_offset.upper().startswith("0X") else int(var_item.var_offset= ) > + CurvalueList =3D var_item.default_value.strip("{").strip= ("}").split(",") > + Curdata_type =3D var_item.data_type > + if Curdata_type in DataType.TAB_PCD_NUMERIC_TYPES: > + data_flag =3D > DataType.PACK_CODE_BY_SIZE[MAX_SIZE_TYPE[Curdata_type]] > + data =3D CurvalueList[0] > + CurvalueList =3D [] > + for data_byte in pack(data_flag, int(data, 16) if > data.upper().startswith('0X') else int(data)): > + CurvalueList.append(hex(unpack("B", data_byte)[0= ])) > + if CurOffset > len(newvalue_list): > + newvalue_list =3D newvalue_list + ["0x00"] * (CurOff= set - > len(newvalue_list)) + CurvalueList > + else: > + newvalue_list[CurOffset : CurOffset + > + len(CurvalueList)] =3D CurvalueList > + > + newvaluestr =3D "{" + ",".join(newvalue_list) +"}" > n =3D sku_var_info_offset_list[0] > - > - if self.NeedMerge(sku_var_info_offset_list): > - newvaluestr =3D self.Do_Merge(sku_var_info_offset_list) > - else: > - newvaluestr =3D self.Do_combine(sku_var_info_offset_list= ) > - > indexedvarinfo[key] =3D [var_info(n.pcdindex, n.pcdname, > n.defaultstoragename, n.skuname, n.var_name, n.var_guid, "0x00", > n.var_attribute, newvaluestr, newvaluestr, > DataType.TAB_VOID,n.PcdDscLine,n.StructurePcd)] > - self.VarInfo =3D [item[0] for item in indexedvarinfo.values()] > - > - @staticmethod > - def assemble_variable(valuedict): > - ordered_valuedict_keys =3D sorted(valuedict.keys()) > - var_value =3D [] > - for current_valuedict_key in ordered_valuedict_keys: > - if current_valuedict_key < len(var_value): > - raise > - for _ in xrange(current_valuedict_key - len(var_value)): > - var_value.append('0x00') > - var_value +=3D valuedict[current_valuedict_key] > - return var_value > + self.VarInfo =3D [item[0] for item in > + list(indexedvarinfo.values())] >=20 > def process_variable_data(self): >=20 > -- > 2.14.1.windows.1 >=20 > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel