]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/Python/GenFds/FvImageSection.py
BaseTools: change the Division Operator
[mirror_edk2.git] / BaseTools / Source / Python / GenFds / FvImageSection.py
index 04556fc870998ce1422fcd0638ffc5ef77b7485b..535b86ab5ea902d5b8be51208957fd10b9529f52 100644 (file)
@@ -18,7 +18,7 @@
 from __future__ import absolute_import\r
 from . import Section\r
 from io import BytesIO\r
-from .Ffs import Ffs\r
+from .Ffs import SectionSuffix\r
 import subprocess\r
 from .GenFdsGlobalVariable import GenFdsGlobalVariable\r
 import Common.LongFilePathOs as os\r
@@ -71,12 +71,12 @@ 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
+                    FvAlignmentValue = 1 << (FvHeaderBuffer[0x2E] & 0x1F)\r
                     FvFileObj.close()\r
                 if FvAlignmentValue > MaxFvAlignment:\r
                     MaxFvAlignment = FvAlignmentValue\r
 \r
-                OutputFile = os.path.join(OutputPath, ModuleName + SUP_MODULE_SEC + Num + Ffs.SectionSuffix.get("FV_IMAGE"))\r
+                OutputFile = os.path.join(OutputPath, ModuleName + SUP_MODULE_SEC + Num + SectionSuffix.get("FV_IMAGE"))\r
                 GenFdsGlobalVariable.GenerateSection(OutputFile, [FvFileName], 'EFI_SECTION_FIRMWARE_VOLUME_IMAGE', IsMakefile=IsMakefile)\r
                 OutputFileList.append(OutputFile)\r
 \r
@@ -87,9 +87,9 @@ class FvImageSection(FvImageSectionClassObject):
                     if MaxFvAlignment >= 0x1000000:\r
                         self.Alignment = "16M"\r
                     else:\r
-                        self.Alignment = str(MaxFvAlignment / 0x100000) + "M"\r
+                        self.Alignment = str(MaxFvAlignment // 0x100000) + "M"\r
                 else:\r
-                    self.Alignment = str (MaxFvAlignment / 0x400) + "K"\r
+                    self.Alignment = str (MaxFvAlignment // 0x400) + "K"\r
             else:\r
                 # MaxFvAlignment is less than 1K\r
                 self.Alignment = str (MaxFvAlignment)\r
@@ -103,6 +103,8 @@ class FvImageSection(FvImageSectionClassObject):
             Fv = GenFdsGlobalVariable.FdfParser.Profile.FvDict.get(self.FvName)\r
             if Fv is not None:\r
                 self.Fv = Fv\r
+                if not self.FvAddr and self.Fv.BaseAddress:\r
+                    self.FvAddr = self.Fv.BaseAddress\r
                 FvFileName = Fv.AddToBuffer(Buffer, self.FvAddr, MacroDict = Dict, Flag=IsMakefile)\r
                 if Fv.FvAlignment is not None:\r
                     if self.Alignment is None:\r
@@ -127,9 +129,9 @@ class FvImageSection(FvImageSectionClassObject):
                                 if FvAlignmentValue >= 0x1000000:\r
                                     self.Alignment = "16M"\r
                                 else:\r
-                                    self.Alignment = str(FvAlignmentValue / 0x100000) + "M"\r
+                                    self.Alignment = str(FvAlignmentValue // 0x100000) + "M"\r
                             else:\r
-                                self.Alignment = str (FvAlignmentValue / 0x400) + "K"\r
+                                self.Alignment = str (FvAlignmentValue // 0x400) + "K"\r
                         else:\r
                             # FvAlignmentValue is less than 1K\r
                             self.Alignment = str (FvAlignmentValue)\r
@@ -146,7 +148,7 @@ class FvImageSection(FvImageSectionClassObject):
             #\r
             # Prepare the parameter of GenSection\r
             #\r
-            OutputFile = os.path.join(OutputPath, ModuleName + SUP_MODULE_SEC + SecNum + Ffs.SectionSuffix.get("FV_IMAGE"))\r
+            OutputFile = os.path.join(OutputPath, ModuleName + SUP_MODULE_SEC + SecNum + SectionSuffix.get("FV_IMAGE"))\r
             GenFdsGlobalVariable.GenerateSection(OutputFile, [FvFileName], 'EFI_SECTION_FIRMWARE_VOLUME_IMAGE', IsMakefile=IsMakefile)\r
             OutputFileList.append(OutputFile)\r
 \r