* [Patch] BaseTools: Fix the bug use same FMP_PAYLOAD in different capsule file
@ 2017-06-06 13:52 Yonghong Zhu
2017-06-07 2:50 ` Gao, Liming
2017-06-07 8:06 ` Gao, Liming
0 siblings, 2 replies; 3+ messages in thread
From: Yonghong Zhu @ 2017-06-06 13:52 UTC (permalink / raw)
To: edk2-devel; +Cc: Liming Gao
Fix the bug that use same FMP_PAYLOAD in different capsule file. Because
in previous FMP generation, the FMP already be generated, so we don't
need to regenerate again.
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/Capsule.py | 15 ++++++++++-----
BaseTools/Source/Python/GenFds/CapsuleData.py | 3 +++
2 files changed, 13 insertions(+), 5 deletions(-)
diff --git a/BaseTools/Source/Python/GenFds/Capsule.py b/BaseTools/Source/Python/GenFds/Capsule.py
index d025f0c..e03d789 100644
--- a/BaseTools/Source/Python/GenFds/Capsule.py
+++ b/BaseTools/Source/Python/GenFds/Capsule.py
@@ -1,9 +1,9 @@
## @file
# generate capsule
#
-# 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
@@ -139,10 +139,15 @@ class Capsule (CapsuleClassObject) :
PreSize += os.path.getsize(FileName)
File = open(FileName, 'rb')
Content.write(File.read())
File.close()
for fmp in self.FmpPayloadList:
+ if fmp.Existed:
+ FwMgrHdr.write(pack('=Q', PreSize))
+ PreSize += len(fmp.Buffer)
+ Content.write(fmp.Buffer)
+ continue
if fmp.ImageFile:
for Obj in fmp.ImageFile:
fmp.ImageFile = Obj.GenCapsuleSubItem()
if fmp.VendorCodeFile:
for Obj in fmp.VendorCodeFile:
@@ -167,16 +172,16 @@ class Capsule (CapsuleClassObject) :
dwLength = 4 + 2 + 2 + 16 + os.path.getsize(CapOutputTmp) - os.path.getsize(CapInputFile)
else:
dwLength = 4 + 2 + 2 + 16 + 16 + 256 + 256
fmp.ImageFile = CapOutputTmp
AuthData = [fmp.MonotonicCount, dwLength, WIN_CERT_REVISION, WIN_CERT_TYPE_EFI_GUID, fmp.Certificate_Guid]
- Buffer = fmp.GenCapsuleSubItem(AuthData)
+ fmp.Buffer = fmp.GenCapsuleSubItem(AuthData)
else:
- Buffer = fmp.GenCapsuleSubItem()
+ fmp.Buffer = fmp.GenCapsuleSubItem()
FwMgrHdr.write(pack('=Q', PreSize))
- PreSize += len(Buffer)
- Content.write(Buffer)
+ PreSize += len(fmp.Buffer)
+ Content.write(fmp.Buffer)
BodySize = len(FwMgrHdr.getvalue()) + len(Content.getvalue())
Header.write(pack('=I', HdrSize + BodySize))
#
# The real capsule header structure is 28 bytes
#
diff --git a/BaseTools/Source/Python/GenFds/CapsuleData.py b/BaseTools/Source/Python/GenFds/CapsuleData.py
index 24c210d..5b806d9 100644
--- a/BaseTools/Source/Python/GenFds/CapsuleData.py
+++ b/BaseTools/Source/Python/GenFds/CapsuleData.py
@@ -181,10 +181,12 @@ class CapsulePayload(CapsuleData):
self.HardwareInstance = None
self.ImageFile = []
self.VendorCodeFile = []
self.Certificate_Guid = None
self.MonotonicCount = None
+ self.Existed = False
+ self.Buffer = None
def GenCapsuleSubItem(self, AuthData=[]):
if not self.Version:
self.Version = '0x00000002'
if not self.ImageIndex:
@@ -237,6 +239,7 @@ class CapsulePayload(CapsuleData):
ImageFile.close()
if self.VendorCodeFile:
VendorFile = open(self.VendorCodeFile, 'rb')
Buffer += VendorFile.read()
VendorFile.close()
+ self.Existed = True
return Buffer
--
2.6.1.windows.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [Patch] BaseTools: Fix the bug use same FMP_PAYLOAD in different capsule file
2017-06-06 13:52 [Patch] BaseTools: Fix the bug use same FMP_PAYLOAD in different capsule file Yonghong Zhu
@ 2017-06-07 2:50 ` Gao, Liming
2017-06-07 8:06 ` Gao, Liming
1 sibling, 0 replies; 3+ messages in thread
From: Gao, Liming @ 2017-06-07 2:50 UTC (permalink / raw)
To: Zhu, Yonghong, edk2-devel@lists.01.org
Reviewed-by: Liming Gao <liming.gao@intel.com>
>-----Original Message-----
>From: Zhu, Yonghong
>Sent: Tuesday, June 06, 2017 9:52 PM
>To: edk2-devel@lists.01.org
>Cc: Gao, Liming <liming.gao@intel.com>
>Subject: [Patch] BaseTools: Fix the bug use same FMP_PAYLOAD in different
>capsule file
>
>Fix the bug that use same FMP_PAYLOAD in different capsule file. Because
>in previous FMP generation, the FMP already be generated, so we don't
>need to regenerate again.
>
>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/Capsule.py | 15 ++++++++++-----
> BaseTools/Source/Python/GenFds/CapsuleData.py | 3 +++
> 2 files changed, 13 insertions(+), 5 deletions(-)
>
>diff --git a/BaseTools/Source/Python/GenFds/Capsule.py
>b/BaseTools/Source/Python/GenFds/Capsule.py
>index d025f0c..e03d789 100644
>--- a/BaseTools/Source/Python/GenFds/Capsule.py
>+++ b/BaseTools/Source/Python/GenFds/Capsule.py
>@@ -1,9 +1,9 @@
> ## @file
> # generate capsule
> #
>-# 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
>@@ -139,10 +139,15 @@ class Capsule (CapsuleClassObject) :
> PreSize += os.path.getsize(FileName)
> File = open(FileName, 'rb')
> Content.write(File.read())
> File.close()
> for fmp in self.FmpPayloadList:
>+ if fmp.Existed:
>+ FwMgrHdr.write(pack('=Q', PreSize))
>+ PreSize += len(fmp.Buffer)
>+ Content.write(fmp.Buffer)
>+ continue
> if fmp.ImageFile:
> for Obj in fmp.ImageFile:
> fmp.ImageFile = Obj.GenCapsuleSubItem()
> if fmp.VendorCodeFile:
> for Obj in fmp.VendorCodeFile:
>@@ -167,16 +172,16 @@ class Capsule (CapsuleClassObject) :
> dwLength = 4 + 2 + 2 + 16 + os.path.getsize(CapOutputTmp) -
>os.path.getsize(CapInputFile)
> else:
> dwLength = 4 + 2 + 2 + 16 + 16 + 256 + 256
> fmp.ImageFile = CapOutputTmp
> AuthData = [fmp.MonotonicCount, dwLength, WIN_CERT_REVISION,
>WIN_CERT_TYPE_EFI_GUID, fmp.Certificate_Guid]
>- Buffer = fmp.GenCapsuleSubItem(AuthData)
>+ fmp.Buffer = fmp.GenCapsuleSubItem(AuthData)
> else:
>- Buffer = fmp.GenCapsuleSubItem()
>+ fmp.Buffer = fmp.GenCapsuleSubItem()
> FwMgrHdr.write(pack('=Q', PreSize))
>- PreSize += len(Buffer)
>- Content.write(Buffer)
>+ PreSize += len(fmp.Buffer)
>+ Content.write(fmp.Buffer)
> BodySize = len(FwMgrHdr.getvalue()) + len(Content.getvalue())
> Header.write(pack('=I', HdrSize + BodySize))
> #
> # The real capsule header structure is 28 bytes
> #
>diff --git a/BaseTools/Source/Python/GenFds/CapsuleData.py
>b/BaseTools/Source/Python/GenFds/CapsuleData.py
>index 24c210d..5b806d9 100644
>--- a/BaseTools/Source/Python/GenFds/CapsuleData.py
>+++ b/BaseTools/Source/Python/GenFds/CapsuleData.py
>@@ -181,10 +181,12 @@ class CapsulePayload(CapsuleData):
> self.HardwareInstance = None
> self.ImageFile = []
> self.VendorCodeFile = []
> self.Certificate_Guid = None
> self.MonotonicCount = None
>+ self.Existed = False
>+ self.Buffer = None
>
> def GenCapsuleSubItem(self, AuthData=[]):
> if not self.Version:
> self.Version = '0x00000002'
> if not self.ImageIndex:
>@@ -237,6 +239,7 @@ class CapsulePayload(CapsuleData):
> ImageFile.close()
> if self.VendorCodeFile:
> VendorFile = open(self.VendorCodeFile, 'rb')
> Buffer += VendorFile.read()
> VendorFile.close()
>+ self.Existed = True
> return Buffer
>--
>2.6.1.windows.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Patch] BaseTools: Fix the bug use same FMP_PAYLOAD in different capsule file
2017-06-06 13:52 [Patch] BaseTools: Fix the bug use same FMP_PAYLOAD in different capsule file Yonghong Zhu
2017-06-07 2:50 ` Gao, Liming
@ 2017-06-07 8:06 ` Gao, Liming
1 sibling, 0 replies; 3+ messages in thread
From: Gao, Liming @ 2017-06-07 8:06 UTC (permalink / raw)
To: Zhu, Yonghong, edk2-devel@lists.01.org
Reviewed-by: Liming Gao <liming.gao@intel.com>
>-----Original Message-----
>From: Zhu, Yonghong
>Sent: Tuesday, June 06, 2017 9:52 PM
>To: edk2-devel@lists.01.org
>Cc: Gao, Liming <liming.gao@intel.com>
>Subject: [Patch] BaseTools: Fix the bug use same FMP_PAYLOAD in different
>capsule file
>
>Fix the bug that use same FMP_PAYLOAD in different capsule file. Because
>in previous FMP generation, the FMP already be generated, so we don't
>need to regenerate again.
>
>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/Capsule.py | 15 ++++++++++-----
> BaseTools/Source/Python/GenFds/CapsuleData.py | 3 +++
> 2 files changed, 13 insertions(+), 5 deletions(-)
>
>diff --git a/BaseTools/Source/Python/GenFds/Capsule.py
>b/BaseTools/Source/Python/GenFds/Capsule.py
>index d025f0c..e03d789 100644
>--- a/BaseTools/Source/Python/GenFds/Capsule.py
>+++ b/BaseTools/Source/Python/GenFds/Capsule.py
>@@ -1,9 +1,9 @@
> ## @file
> # generate capsule
> #
>-# 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
>@@ -139,10 +139,15 @@ class Capsule (CapsuleClassObject) :
> PreSize += os.path.getsize(FileName)
> File = open(FileName, 'rb')
> Content.write(File.read())
> File.close()
> for fmp in self.FmpPayloadList:
>+ if fmp.Existed:
>+ FwMgrHdr.write(pack('=Q', PreSize))
>+ PreSize += len(fmp.Buffer)
>+ Content.write(fmp.Buffer)
>+ continue
> if fmp.ImageFile:
> for Obj in fmp.ImageFile:
> fmp.ImageFile = Obj.GenCapsuleSubItem()
> if fmp.VendorCodeFile:
> for Obj in fmp.VendorCodeFile:
>@@ -167,16 +172,16 @@ class Capsule (CapsuleClassObject) :
> dwLength = 4 + 2 + 2 + 16 + os.path.getsize(CapOutputTmp) -
>os.path.getsize(CapInputFile)
> else:
> dwLength = 4 + 2 + 2 + 16 + 16 + 256 + 256
> fmp.ImageFile = CapOutputTmp
> AuthData = [fmp.MonotonicCount, dwLength, WIN_CERT_REVISION,
>WIN_CERT_TYPE_EFI_GUID, fmp.Certificate_Guid]
>- Buffer = fmp.GenCapsuleSubItem(AuthData)
>+ fmp.Buffer = fmp.GenCapsuleSubItem(AuthData)
> else:
>- Buffer = fmp.GenCapsuleSubItem()
>+ fmp.Buffer = fmp.GenCapsuleSubItem()
> FwMgrHdr.write(pack('=Q', PreSize))
>- PreSize += len(Buffer)
>- Content.write(Buffer)
>+ PreSize += len(fmp.Buffer)
>+ Content.write(fmp.Buffer)
> BodySize = len(FwMgrHdr.getvalue()) + len(Content.getvalue())
> Header.write(pack('=I', HdrSize + BodySize))
> #
> # The real capsule header structure is 28 bytes
> #
>diff --git a/BaseTools/Source/Python/GenFds/CapsuleData.py
>b/BaseTools/Source/Python/GenFds/CapsuleData.py
>index 24c210d..5b806d9 100644
>--- a/BaseTools/Source/Python/GenFds/CapsuleData.py
>+++ b/BaseTools/Source/Python/GenFds/CapsuleData.py
>@@ -181,10 +181,12 @@ class CapsulePayload(CapsuleData):
> self.HardwareInstance = None
> self.ImageFile = []
> self.VendorCodeFile = []
> self.Certificate_Guid = None
> self.MonotonicCount = None
>+ self.Existed = False
>+ self.Buffer = None
>
> def GenCapsuleSubItem(self, AuthData=[]):
> if not self.Version:
> self.Version = '0x00000002'
> if not self.ImageIndex:
>@@ -237,6 +239,7 @@ class CapsulePayload(CapsuleData):
> ImageFile.close()
> if self.VendorCodeFile:
> VendorFile = open(self.VendorCodeFile, 'rb')
> Buffer += VendorFile.read()
> VendorFile.close()
>+ self.Existed = True
> return Buffer
>--
>2.6.1.windows.1
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-06-07 8:05 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-06-06 13:52 [Patch] BaseTools: Fix the bug use same FMP_PAYLOAD in different capsule file Yonghong Zhu
2017-06-07 2:50 ` Gao, Liming
2017-06-07 8:06 ` Gao, Liming
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox