[edk2] [Patch] BaseTools: GenFds get the Size info for FV image in the FD region

Yonghong Zhu posted 1 patch 7 years, 7 months ago
Failed in applying to current master (apply log)
BaseTools/Source/Python/GenFds/Fv.py     |  3 ++-
BaseTools/Source/Python/GenFds/GenFds.py | 19 +++++++++++++++++++
2 files changed, 21 insertions(+), 1 deletion(-)
[edk2] [Patch] BaseTools: GenFds get the Size info for FV image in the FD region
Posted by Yonghong Zhu 7 years, 7 months ago
When the FV size is specify in the FD region, Tool generate the FV file
may not use the correct size.

Fixes: https://bugzilla.tianocore.org/show_bug.cgi?id=387
Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
---
 BaseTools/Source/Python/GenFds/Fv.py     |  3 ++-
 BaseTools/Source/Python/GenFds/GenFds.py | 19 +++++++++++++++++++
 2 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/BaseTools/Source/Python/GenFds/Fv.py b/BaseTools/Source/Python/GenFds/Fv.py
index ab3f8b2..f6ccb59 100644
--- a/BaseTools/Source/Python/GenFds/Fv.py
+++ b/BaseTools/Source/Python/GenFds/Fv.py
@@ -1,9 +1,9 @@
 ## @file
 # process FV generation
 #
-#  Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.<BR>
+#  Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.<BR>
 #
 #  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
@@ -48,10 +48,11 @@ class FV (FvClassObject):
         self.InfFileName = None
         self.FvAddressFileName = None
         self.CapsuleName = None
         self.FvBaseAddress = None
         self.FvForceRebase = None
+        self.FvRegionInFD = None
         
     ## AddToBuffer()
     #
     #   Generate Fv and add it to the Buffer
     #
diff --git a/BaseTools/Source/Python/GenFds/GenFds.py b/BaseTools/Source/Python/GenFds/GenFds.py
index a8a68da..aa8c041 100644
--- a/BaseTools/Source/Python/GenFds/GenFds.py
+++ b/BaseTools/Source/Python/GenFds/GenFds.py
@@ -301,10 +301,29 @@ def main():
             CheckBuildOptionPcd()
 
         """Modify images from build output if the feature of loading driver at fixed address is on."""
         if GenFdsGlobalVariable.FixedLoadAddress:
             GenFds.PreprocessImage(BuildWorkSpace, GenFdsGlobalVariable.ActivePlatform)
+
+        # Record the FV Region info that may specific in the FD
+        if FdfParserObj.Profile.FvDict and FdfParserObj.Profile.FdDict:
+            for Fv in FdfParserObj.Profile.FvDict:
+                FvObj = FdfParserObj.Profile.FvDict[Fv]
+                for Fd in FdfParserObj.Profile.FdDict:
+                    FdObj = FdfParserObj.Profile.FdDict[Fd]
+                    for RegionObj in FdObj.RegionList:
+                        if RegionObj.RegionType != 'FV':
+                            continue
+                        for RegionData in RegionObj.RegionDataList:
+                            if FvObj.UiFvName.upper() == RegionData.upper():
+                                if FvObj.FvRegionInFD:
+                                    if FvObj.FvRegionInFD != RegionObj.Size:
+                                        EdkLogger.error("GenFds", FORMAT_INVALID, "The FV %s's region is specified in multiple FD with different value." %FvObj.UiFvName)
+                                else:
+                                    FvObj.FvRegionInFD = RegionObj.Size
+                                    RegionObj.BlockInfoOfRegion(FdObj.BlockSizeList, FvObj)
+
         """Call GenFds"""
         GenFds.GenFd('', FdfParserObj, BuildWorkSpace, ArchList)
 
         """Generate GUID cross reference file"""
         GenFds.GenerateGuidXRefFile(BuildWorkSpace, ArchList)
-- 
2.6.1.windows.1

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
Re: [edk2] [Patch] BaseTools: GenFds get the Size info for FV image in the FD region
Posted by Gao, Liming 7 years, 7 months ago
Reviewed-by: Liming Gao <liming.gao@intel.com>

>-----Original Message-----
>From: Zhu, Yonghong
>Sent: Wednesday, March 15, 2017 9:23 AM
>To: edk2-devel@lists.01.org
>Cc: Gao, Liming <liming.gao@intel.com>
>Subject: [Patch] BaseTools: GenFds get the Size info for FV image in the FD
>region
>
>When the FV size is specify in the FD region, Tool generate the FV file
>may not use the correct size.
>
>Fixes: https://bugzilla.tianocore.org/show_bug.cgi?id=387
>Cc: Liming Gao <liming.gao@intel.com>
>Contributed-under: TianoCore Contribution Agreement 1.0
>Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
>---
> BaseTools/Source/Python/GenFds/Fv.py     |  3 ++-
> BaseTools/Source/Python/GenFds/GenFds.py | 19 +++++++++++++++++++
> 2 files changed, 21 insertions(+), 1 deletion(-)
>
>diff --git a/BaseTools/Source/Python/GenFds/Fv.py
>b/BaseTools/Source/Python/GenFds/Fv.py
>index ab3f8b2..f6ccb59 100644
>--- a/BaseTools/Source/Python/GenFds/Fv.py
>+++ b/BaseTools/Source/Python/GenFds/Fv.py
>@@ -1,9 +1,9 @@
> ## @file
> # process FV generation
> #
>-#  Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.<BR>
>+#  Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.<BR>
> #
> #  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
>@@ -48,10 +48,11 @@ class FV (FvClassObject):
>         self.InfFileName = None
>         self.FvAddressFileName = None
>         self.CapsuleName = None
>         self.FvBaseAddress = None
>         self.FvForceRebase = None
>+        self.FvRegionInFD = None
>
>     ## AddToBuffer()
>     #
>     #   Generate Fv and add it to the Buffer
>     #
>diff --git a/BaseTools/Source/Python/GenFds/GenFds.py
>b/BaseTools/Source/Python/GenFds/GenFds.py
>index a8a68da..aa8c041 100644
>--- a/BaseTools/Source/Python/GenFds/GenFds.py
>+++ b/BaseTools/Source/Python/GenFds/GenFds.py
>@@ -301,10 +301,29 @@ def main():
>             CheckBuildOptionPcd()
>
>         """Modify images from build output if the feature of loading driver at
>fixed address is on."""
>         if GenFdsGlobalVariable.FixedLoadAddress:
>             GenFds.PreprocessImage(BuildWorkSpace,
>GenFdsGlobalVariable.ActivePlatform)
>+
>+        # Record the FV Region info that may specific in the FD
>+        if FdfParserObj.Profile.FvDict and FdfParserObj.Profile.FdDict:
>+            for Fv in FdfParserObj.Profile.FvDict:
>+                FvObj = FdfParserObj.Profile.FvDict[Fv]
>+                for Fd in FdfParserObj.Profile.FdDict:
>+                    FdObj = FdfParserObj.Profile.FdDict[Fd]
>+                    for RegionObj in FdObj.RegionList:
>+                        if RegionObj.RegionType != 'FV':
>+                            continue
>+                        for RegionData in RegionObj.RegionDataList:
>+                            if FvObj.UiFvName.upper() == RegionData.upper():
>+                                if FvObj.FvRegionInFD:
>+                                    if FvObj.FvRegionInFD != RegionObj.Size:
>+                                        EdkLogger.error("GenFds", FORMAT_INVALID, "The
>FV %s's region is specified in multiple FD with different
>value." %FvObj.UiFvName)
>+                                else:
>+                                    FvObj.FvRegionInFD = RegionObj.Size
>+                                    RegionObj.BlockInfoOfRegion(FdObj.BlockSizeList, FvObj)
>+
>         """Call GenFds"""
>         GenFds.GenFd('', FdfParserObj, BuildWorkSpace, ArchList)
>
>         """Generate GUID cross reference file"""
>         GenFds.GenerateGuidXRefFile(BuildWorkSpace, ArchList)
>--
>2.6.1.windows.1

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel