From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.24; helo=mga09.intel.com; envelope-from=liming.gao@intel.com; receiver=edk2-devel@lists.01.org Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) (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 173D8223648BD for ; Wed, 31 Jan 2018 00:54:05 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 31 Jan 2018 00:59:40 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,439,1511856000"; d="scan'208";a="23610345" Received: from fmsmsx108.amr.corp.intel.com ([10.18.124.206]) by orsmga003.jf.intel.com with ESMTP; 31 Jan 2018 00:59:40 -0800 Received: from FMSMSX109.amr.corp.intel.com (10.18.116.9) by FMSMSX108.amr.corp.intel.com (10.18.124.206) with Microsoft SMTP Server (TLS) id 14.3.319.2; Wed, 31 Jan 2018 00:59:40 -0800 Received: from shsmsx101.ccr.corp.intel.com (10.239.4.153) by fmsmsx109.amr.corp.intel.com (10.18.116.9) with Microsoft SMTP Server (TLS) id 14.3.319.2; Wed, 31 Jan 2018 00:59:39 -0800 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.127]) by SHSMSX101.ccr.corp.intel.com ([169.254.1.192]) with mapi id 14.03.0319.002; Wed, 31 Jan 2018 16:59:34 +0800 From: "Gao, Liming" To: "Zhu, Yonghong" , "edk2-devel@lists.01.org" Thread-Topic: [edk2] [Patch] BaseTools: Fix the bug to align VPD PCD based on value type Thread-Index: AQHTmZeOqYfwE17nX0Cv9DEAr1ye8qONsG7g Date: Wed, 31 Jan 2018 08:59:34 +0000 Message-ID: <4A89E2EF3DFEDB4C8BFDE51014F606A14E1B9E12@SHSMSX104.ccr.corp.intel.com> References: <1517295390-10280-1-git-send-email-yonghong.zhu@intel.com> In-Reply-To: <1517295390-10280-1-git-send-email-yonghong.zhu@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [Patch] BaseTools: Fix the bug to align VPD PCD based on value type 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: , X-List-Received-Date: Wed, 31 Jan 2018 08:54:05 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Liming Gao >-----Original Message----- >From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of >Yonghong Zhu >Sent: Tuesday, January 30, 2018 2:57 PM >To: edk2-devel@lists.01.org >Subject: [edk2] [Patch] BaseTools: Fix the bug to align VPD PCD based on >value type > >Spec required for VOID* VPD Pcd, Ascii string use byte alignment, byte >array use 8-byte alignment, unicode string use 2-byte alignment. >while when the VPD pcd offset use *, the offset generated in the .map >file not follow this rule. > >Contributed-under: TianoCore Contribution Agreement 1.1 >Signed-off-by: Yonghong Zhu >--- > BaseTools/Source/Python/BPDG/GenVpd.py | 14 ++++++++++++-- > 1 file changed, 12 insertions(+), 2 deletions(-) > >diff --git a/BaseTools/Source/Python/BPDG/GenVpd.py >b/BaseTools/Source/Python/BPDG/GenVpd.py >index 9861e7d..ec4da23 100644 >--- a/BaseTools/Source/Python/BPDG/GenVpd.py >+++ b/BaseTools/Source/Python/BPDG/GenVpd.py >@@ -1,10 +1,10 @@ > ## @file > # This file include GenVpd class for fix the Vpd type PCD offset, and Pc= dEntry >for describe > # and process each entry of vpd type PCD. > # >-# Copyright (c) 2010 - 2016, Intel Corporation. All rights reserved.
>+# Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.
> # > # This program and the accompanying materials > # are licensed and made available under the terms and conditions of the = BSD >License > # which accompanies this distribution. The full text of the license may= be >found at > # http://opensource.org/licenses/bsd-license.php >@@ -33,21 +33,22 @@ _FORMAT_CHAR =3D {1: 'B', > # > # This class contain method to format and pack pcd's value. > # > class PcdEntry: > def __init__(self, PcdCName, SkuId,PcdOffset, PcdSize, PcdValue, >Lineno=3DNone, FileName=3DNone, PcdUnpackValue=3DNone, >- PcdBinOffset=3DNone, PcdBinSize=3DNone): >+ PcdBinOffset=3DNone, PcdBinSize=3DNone, Alignment=3DNone= ): > self.PcdCName =3D PcdCName.strip() > self.SkuId =3D SkuId.strip() > self.PcdOffset =3D PcdOffset.strip() > self.PcdSize =3D PcdSize.strip() > self.PcdValue =3D PcdValue.strip() > self.Lineno =3D Lineno.strip() > self.FileName =3D FileName.strip() > self.PcdUnpackValue =3D PcdUnpackValue > self.PcdBinOffset =3D PcdBinOffset > self.PcdBinSize =3D PcdBinSize >+ self.Alignment =3D Alignment > > if self.PcdValue =3D=3D '' : > EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID, > "Invalid PCD format(Name: %s File: %s line: %= s) , no Value >specified!" % (self.PcdCName, self.FileName, self.Lineno)) > >@@ -432,20 +433,22 @@ class GenVPD : > elif PCD.PcdUnpackValue.startswith("L"): > Alignment =3D 2 > else: > Alignment =3D 1 > >+ PCD.Alignment =3D Alignment > if PCD.PcdOffset !=3D '*': > if PCD.PcdOccupySize % Alignment !=3D 0: > if PCD.PcdUnpackValue.startswith("{"): > EdkLogger.warn("BPDG", "The offset value of P= CD %s is not 8- >byte aligned!" %(PCD.PcdCName), File=3Dself.InputFileName) > else: > EdkLogger.error("BPDG", BuildToolError.FORMAT= _INVALID, >'The offset value of PCD %s should be %s-byte aligned.' % (PCD.PcdCName, >Alignment)) > else: > if PCD.PcdOccupySize % Alignment !=3D 0: > PCD.PcdOccupySize =3D (PCD.PcdOccupySize / Alignm= ent + 1) * >Alignment > >+ PackSize =3D PCD.PcdOccupySize > if PCD._IsBoolean(PCD.PcdValue, PCD.PcdSize): > PCD._PackBooleanValue(PCD.PcdValue) > self.FileLinesList[count] =3D PCD > count +=3D 1 > continue >@@ -516,10 +519,12 @@ class GenVPD : > # > if (len(self.PcdFixedOffsetSizeList) =3D=3D 0) and >(len(self.PcdUnknownOffsetList) !=3D 0) : > # The offset start from 0 > NowOffset =3D 0 > for Pcd in self.PcdUnknownOffsetList : >+ if NowOffset % Pcd.Alignment !=3D 0: >+ NowOffset =3D (NowOffset/ Pcd.Alignment + 1) * Pcd.Al= ignment > Pcd.PcdBinOffset =3D NowOffset > Pcd.PcdOffset =3D str(hex(Pcd.PcdBinOffset)) > NowOffset +=3D Pcd.PcdOccupySize > > self.PcdFixedOffsetSizeList =3D self.PcdUnknownOffsetList >@@ -578,10 +583,12 @@ class GenVPD : > while(countOfUnfixedList < lenOfUnfixedList) : > eachUnfixedPcd =3D >self.PcdUnknownOffsetList[countOfUnfixedList] > needFixPcdSize =3D eachUnfixedPcd.PcdOccupyS= ize > # Not been fixed > if eachUnfixedPcd.PcdOffset =3D=3D '*' : >+ if LastOffset % eachUnfixedPcd.Alignment !=3D= 0: >+ LastOffset =3D (LastOffset / eachUnfixedP= cd.Alignment + 1) * >eachUnfixedPcd.Alignment > # The offset un-fixed pcd can write into this= free space > if needFixPcdSize <=3D (NowOffset - LastOffse= t) : > # Change the offset value of un-fixed pcd > eachUnfixedPcd.PcdOffset =3D str(hex(L= astOffset)) > eachUnfixedPcd.PcdBinOffset =3D LastOffse= t >@@ -630,10 +637,13 @@ class GenVPD : > # The last pcd instance > LastPcd =3D self.PcdFixedOffsetSizeList[lenOfList-1] > NeedFixPcd =3D self.PcdUnknownOffsetList[0] > > NeedFixPcd.PcdBinOffset =3D LastPcd.PcdBinOffset + >LastPcd.PcdOccupySize >+ if NeedFixPcd.PcdBinOffset % NeedFixPcd.Alignment !=3D 0: >+ NeedFixPcd.PcdBinOffset =3D (NeedFixPcd.PcdBinOffset / >NeedFixPcd.Alignment + 1) * NeedFixPcd.Alignment >+ > NeedFixPcd.PcdOffset =3D str(hex(NeedFixPcd.PcdBinOffset)) > > # Insert this pcd into fixed offset pcd list's tail. > self.PcdFixedOffsetSizeList.insert(lenOfList, NeedFixPcd) > # Delete the item's offset that has been fixed and added into= fixed >offset list >-- >2.6.1.windows.1 > >_______________________________________________ >edk2-devel mailing list >edk2-devel@lists.01.org >https://lists.01.org/mailman/listinfo/edk2-devel