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.115; helo=mga14.intel.com; envelope-from=yonghong.zhu@intel.com; receiver=edk2-devel@lists.01.org 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 2DDA021122E54 for ; Thu, 6 Sep 2018 17:43:49 -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 fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 06 Sep 2018 17:43:48 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.53,340,1531810800"; d="scan'208";a="83759192" Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203]) by fmsmga002.fm.intel.com with ESMTP; 06 Sep 2018 17:43:49 -0700 Received: from fmsmsx101.amr.corp.intel.com (10.18.124.199) by FMSMSX105.amr.corp.intel.com (10.18.124.203) with Microsoft SMTP Server (TLS) id 14.3.319.2; Thu, 6 Sep 2018 17:43:49 -0700 Received: from shsmsx104.ccr.corp.intel.com (10.239.4.70) by fmsmsx101.amr.corp.intel.com (10.18.124.199) with Microsoft SMTP Server (TLS) id 14.3.319.2; Thu, 6 Sep 2018 17:43:48 -0700 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.240]) by SHSMSX104.ccr.corp.intel.com ([169.254.5.143]) with mapi id 14.03.0319.002; Fri, 7 Sep 2018 08:43:44 +0800 From: "Zhu, Yonghong" To: "Carsey, Jaben" , "edk2-devel@lists.01.org" CC: "Gao, Liming" , "Feng, Bob C" , "Zhu, Yonghong" Thread-Topic: [PATCH v1 1/1] BaseTools: refactor to remove duplicate functions Thread-Index: AQHURWKIskJ8b3jd7ku8SN4GOOmGTKTj/LCQ Date: Fri, 7 Sep 2018 00:43:44 +0000 Message-ID: References: <88960c0e4eadbb9434eb56800a20ec83bbd355a9.1536184227.git.jaben.carsey@intel.com> In-Reply-To: <88960c0e4eadbb9434eb56800a20ec83bbd355a9.1536184227.git.jaben.carsey@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 v1 1/1] BaseTools: refactor to remove duplicate functions 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: Fri, 07 Sep 2018 00:43:50 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Yonghong Zhu =20 Best Regards, Zhu Yonghong -----Original Message----- From: Carsey, Jaben=20 Sent: Thursday, September 06, 2018 5:51 AM To: edk2-devel@lists.01.org Cc: Zhu, Yonghong ; Gao, Liming ; Feng, Bob C Subject: [PATCH v1 1/1] BaseTools: refactor to remove duplicate functions Update GenFdsGlobalVariable GetAlignment to support G. replace use of local function in Region with updated shared function. Cc: Yonghong Zhu Cc: Liming Gao Cc: Bob C Feng Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jaben Carsey --- BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py | 11 +++++----- BaseTools/Source/Python/GenFds/Region.py | 21 +-------------= ------ 2 files changed, 7 insertions(+), 25 deletions(-) diff --git a/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py b/BaseT= ools/Source/Python/GenFds/GenFdsGlobalVariable.py index eb106b574420..77873d36b98a 100644 --- a/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py +++ b/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py @@ -512,14 +512,15 @@ class GenFdsGlobalVariable: =20 @staticmethod def GetAlignment (AlignString): - if AlignString is None: + if not AlignString: return 0 - if AlignString in ("1K", "2K", "4K", "8K", "16K", "32K", "64K", "1= 28K", "256K", "512K"): + if AlignString.endswith('K'): return int (AlignString.rstrip('K')) * 1024 - elif AlignString in ("1M", "2M", "4M", "8M", "16M"): + if AlignString.endswith('M'): return int (AlignString.rstrip('M')) * 1024 * 1024 - else: - return int (AlignString) + if AlignString.endswith('G'): + return int (AlignString.rstrip('G')) * 1024 * 1024 * 1024 + return int (AlignString) =20 @staticmethod def GenerateFfs(Output, Input, Type, Guid, Fixed=3DFalse, CheckSum=3DF= alse, Align=3DNone, diff --git a/BaseTools/Source/Python/GenFds/Region.py b= /BaseTools/Source/Python/GenFds/Region.py index 7f94b3d66b55..5242b74c9e70 100644 --- a/BaseTools/Source/Python/GenFds/Region.py +++ b/BaseTools/Source/Python/GenFds/Region.py @@ -124,7 +124,7 @@ class Region(RegionClassObject): # self.BlockInfoOfRegion(BlockSizeList, FvObj) self.FvAddress =3D self.FvAddress + FvOffset - FvAlignValue =3D self.GetFvAlignValue(FvObj.FvAlig= nment) + FvAlignValue =3D=20 + GenFdsGlobalVariable.GetAlignment(FvObj.FvAlignment) if self.FvAddress % FvAlignValue !=3D 0: EdkLogger.error("GenFds", GENFDS_ERROR, "FV (%s) is NOT %s Aligned!" %= (FvObj.UiFvName, FvObj.FvAlignment)) @@ -277,25 +277,6 @@ class Region(Reg= ionClassObject): GenFdsGlobalVariable.InfLogger(' Region Name =3D None') self.PadBuffer(Buffer, ErasePolarity, Size) =20 - def GetFvAlignValue(self, Str): - AlignValue =3D 1 - Granu =3D 1 - Str =3D Str.strip().upper() - if Str.endswith('K'): - Granu =3D 1024 - Str =3D Str[:-1] - elif Str.endswith('M'): - Granu =3D 1024 * 1024 - Str =3D Str[:-1] - elif Str.endswith('G'): - Granu =3D 1024 * 1024 * 1024 - Str =3D Str[:-1] - else: - pass - - AlignValue =3D int(Str) * Granu - return AlignValue - ## BlockSizeOfRegion() # # @param BlockSizeList List of block information -- 2.16.2.windows.1