public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Zhu, Yonghong" <yonghong.zhu@intel.com>
To: "Carsey, Jaben" <jaben.carsey@intel.com>,
	"edk2-devel@lists.01.org" <edk2-devel@lists.01.org>
Cc: "Gao, Liming" <liming.gao@intel.com>,
	"Feng, Bob C" <bob.c.feng@intel.com>,
	"Zhu, Yonghong" <yonghong.zhu@intel.com>
Subject: Re: [PATCH v1 1/1] BaseTools: refactor to remove duplicate functions
Date: Fri, 7 Sep 2018 00:43:44 +0000	[thread overview]
Message-ID: <B9726D6DCCFB8B4CA276A9169B02216D520F5442@SHSMSX103.ccr.corp.intel.com> (raw)
In-Reply-To: <88960c0e4eadbb9434eb56800a20ec83bbd355a9.1536184227.git.jaben.carsey@intel.com>

Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com> 

Best Regards,
Zhu Yonghong


-----Original Message-----
From: Carsey, Jaben 
Sent: Thursday, September 06, 2018 5:51 AM
To: edk2-devel@lists.01.org
Cc: Zhu, Yonghong <yonghong.zhu@intel.com>; Gao, Liming <liming.gao@intel.com>; Feng, Bob C <bob.c.feng@intel.com>
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 <yonghong.zhu@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Bob C Feng <bob.c.feng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jaben Carsey <jaben.carsey@intel.com>
---
 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/BaseTools/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:
 
     @staticmethod
     def GetAlignment (AlignString):
-        if AlignString is None:
+        if not AlignString:
             return 0
-        if AlignString in ("1K", "2K", "4K", "8K", "16K", "32K", "64K", "128K", "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)
 
     @staticmethod
     def GenerateFfs(Output, Input, Type, Guid, Fixed=False, CheckSum=False, Align=None, 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 = self.FvAddress + FvOffset
-                        FvAlignValue = self.GetFvAlignValue(FvObj.FvAlignment)
+                        FvAlignValue = 
+ GenFdsGlobalVariable.GetAlignment(FvObj.FvAlignment)
                         if self.FvAddress % FvAlignValue != 0:
                             EdkLogger.error("GenFds", GENFDS_ERROR,
                                             "FV (%s) is NOT %s Aligned!" % (FvObj.UiFvName, FvObj.FvAlignment)) @@ -277,25 +277,6 @@ class Region(RegionClassObject):
             GenFdsGlobalVariable.InfLogger('   Region Name = None')
             self.PadBuffer(Buffer, ErasePolarity, Size)
 
-    def GetFvAlignValue(self, Str):
-        AlignValue = 1
-        Granu = 1
-        Str = Str.strip().upper()
-        if Str.endswith('K'):
-            Granu = 1024
-            Str = Str[:-1]
-        elif Str.endswith('M'):
-            Granu = 1024 * 1024
-            Str = Str[:-1]
-        elif Str.endswith('G'):
-            Granu = 1024 * 1024 * 1024
-            Str = Str[:-1]
-        else:
-            pass
-
-        AlignValue = int(Str) * Granu
-        return AlignValue
-
     ## BlockSizeOfRegion()
     #
     #   @param  BlockSizeList        List of block information
--
2.16.2.windows.1



      reply	other threads:[~2018-09-07  0:43 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <cover.1536184227.git.jaben.carsey@intel.com>
2018-09-05 21:50 ` [PATCH v1 1/1] BaseTools: refactor to remove duplicate functions Jaben Carsey
2018-09-07  0:43   ` Zhu, Yonghong [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=B9726D6DCCFB8B4CA276A9169B02216D520F5442@SHSMSX103.ccr.corp.intel.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox