]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/Python/GenFds/FvImageSection.py
BaseTools: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / BaseTools / Source / Python / GenFds / FvImageSection.py
index 535b86ab5ea902d5b8be51208957fd10b9529f52..2d38ff60969d020a92d556a152733a8d61b91c6f 100644 (file)
@@ -3,13 +3,7 @@
 #\r
 #  Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>\r
 #\r
-#  This program and the accompanying materials\r
-#  are licensed and made available under the terms and conditions of the BSD License\r
-#  which accompanies this distribution.  The full text of the license may be found at\r
-#  http://opensource.org/licenses/bsd-license.php\r
-#\r
-#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+#  SPDX-License-Identifier: BSD-2-Clause-Patent\r
 #\r
 \r
 ##\r
@@ -71,7 +65,10 @@ class FvImageSection(FvImageSectionClassObject):
                     # PI FvHeader is 0x48 byte\r
                     FvHeaderBuffer = FvFileObj.read(0x48)\r
                     # FV alignment position.\r
-                    FvAlignmentValue = 1 << (FvHeaderBuffer[0x2E] & 0x1F)\r
+                    if isinstance(FvHeaderBuffer[0x2E], str):\r
+                        FvAlignmentValue = 1 << (ord(FvHeaderBuffer[0x2E]) & 0x1F)\r
+                    else:\r
+                        FvAlignmentValue = 1 << (FvHeaderBuffer[0x2E] & 0x1F)\r
                     FvFileObj.close()\r
                 if FvAlignmentValue > MaxFvAlignment:\r
                     MaxFvAlignment = FvAlignmentValue\r
@@ -99,7 +96,7 @@ class FvImageSection(FvImageSectionClassObject):
         # Generate Fv\r
         #\r
         if self.FvName is not None:\r
-            Buffer = BytesIO('')\r
+            Buffer = BytesIO()\r
             Fv = GenFdsGlobalVariable.FdfParser.Profile.FvDict.get(self.FvName)\r
             if Fv is not None:\r
                 self.Fv = Fv\r
@@ -121,7 +118,10 @@ class FvImageSection(FvImageSectionClassObject):
                         # PI FvHeader is 0x48 byte\r
                         FvHeaderBuffer = FvFileObj.read(0x48)\r
                         # FV alignment position.\r
-                        FvAlignmentValue = 1 << (ord (FvHeaderBuffer[0x2E]) & 0x1F)\r
+                        if isinstance(FvHeaderBuffer[0x2E], str):\r
+                            FvAlignmentValue = 1 << (ord(FvHeaderBuffer[0x2E]) & 0x1F)\r
+                        else:\r
+                            FvAlignmentValue = 1 << (FvHeaderBuffer[0x2E] & 0x1F)\r
                         # FvAlignmentValue is larger than or equal to 1K\r
                         if FvAlignmentValue >= 0x400:\r
                             if FvAlignmentValue >= 0x100000:\r