public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [Patch] BaseTools: not report error for the optional items in the FmpTokens
@ 2017-01-04  5:14 Yonghong Zhu
  2017-01-04  5:32 ` Gao, Liming
  0 siblings, 1 reply; 2+ messages in thread
From: Yonghong Zhu @ 2017-01-04  5:14 UTC (permalink / raw)
  To: edk2-devel; +Cc: Liming Gao

<FmpTokens> in the FDF spec defined some optional items, eg: IMAGE_INDEX,
HARDWARE_INSTANCE. but current tool report error if no such item is exist
in the FDF file.

Fixes: https://bugzilla.tianocore.org/show_bug.cgi?id=293
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/CapsuleData.py |  8 ++++++--
 BaseTools/Source/Python/GenFds/FdfParser.py   | 13 +++++--------
 2 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/BaseTools/Source/Python/GenFds/CapsuleData.py b/BaseTools/Source/Python/GenFds/CapsuleData.py
index d7a6d54..24c210d 100644
--- a/BaseTools/Source/Python/GenFds/CapsuleData.py
+++ b/BaseTools/Source/Python/GenFds/CapsuleData.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
@@ -184,11 +184,15 @@ class CapsulePayload(CapsuleData):
         self.Certificate_Guid = None
         self.MonotonicCount = None
 
     def GenCapsuleSubItem(self, AuthData=[]):
         if not self.Version:
-            self.Version = 0x00000002
+            self.Version = '0x00000002'
+        if not self.ImageIndex:
+            self.ImageIndex = '0x1'
+        if not self.HardwareInstance:
+            self.HardwareInstance = '0x0'
         ImageFileSize = os.path.getsize(self.ImageFile)
         if AuthData:
             # the ImageFileSize need include the full authenticated info size. From first bytes of MonotonicCount to last bytes of certificate.
             # the 32 bit is the MonotonicCount, dwLength, wRevision, wCertificateType and CertType
             ImageFileSize += 32
diff --git a/BaseTools/Source/Python/GenFds/FdfParser.py b/BaseTools/Source/Python/GenFds/FdfParser.py
index 2900283..e1295f2 100644
--- a/BaseTools/Source/Python/GenFds/FdfParser.py
+++ b/BaseTools/Source/Python/GenFds/FdfParser.py
@@ -1,9 +1,9 @@
 ## @file
 # parse FDF file
 #
-#  Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.<BR>
+#  Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.<BR>
 #  Copyright (c) 2015, Hewlett Packard Enterprise Development, L.P.<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
@@ -3237,17 +3237,14 @@ class FdfParser:
         else:
             self.__UndoToken()
 
         if (FmpData.MonotonicCount and not FmpData.Certificate_Guid) or (not FmpData.MonotonicCount and FmpData.Certificate_Guid):
             EdkLogger.error("FdfParser", FORMAT_INVALID, "CERTIFICATE_GUID and MONOTONIC_COUNT must be work as a pair.")
-        # remove CERTIFICATE_GUID and MONOTONIC_COUNT from FmpKeyList, since these keys are optional
-        if 'CERTIFICATE_GUID' in FmpKeyList:
-            FmpKeyList.remove('CERTIFICATE_GUID')
-        if 'MONOTONIC_COUNT' in FmpKeyList:
-            FmpKeyList.remove('MONOTONIC_COUNT')
-        if FmpKeyList:
-            raise Warning("Missing keywords %s in FMP payload section." % ', '.join(FmpKeyList), self.FileName, self.CurrentLineNumber)
+
+        # Only the IMAGE_TYPE_ID is required item
+        if FmpKeyList and 'IMAGE_TYPE_ID' in FmpKeyList:
+            raise Warning("Missing keywords IMAGE_TYPE_ID in FMP payload section.", self.FileName, self.CurrentLineNumber)
         # get the Image file and Vendor code file
         self.__GetFMPCapsuleData(FmpData)
         if not FmpData.ImageFile:
             raise Warning("Missing image file in FMP payload section.", self.FileName, self.CurrentLineNumber)
         # check whether more than one Vendor code file
-- 
2.6.1.windows.1



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [Patch] BaseTools: not report error for the optional items in the FmpTokens
  2017-01-04  5:14 [Patch] BaseTools: not report error for the optional items in the FmpTokens Yonghong Zhu
@ 2017-01-04  5:32 ` Gao, Liming
  0 siblings, 0 replies; 2+ messages in thread
From: Gao, Liming @ 2017-01-04  5:32 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: Wednesday, January 04, 2017 1:15 PM
>To: edk2-devel@lists.01.org
>Cc: Gao, Liming <liming.gao@intel.com>
>Subject: [Patch] BaseTools: not report error for the optional items in the
>FmpTokens
>
><FmpTokens> in the FDF spec defined some optional items, eg:
>IMAGE_INDEX,
>HARDWARE_INSTANCE. but current tool report error if no such item is exist
>in the FDF file.
>
>Fixes: https://bugzilla.tianocore.org/show_bug.cgi?id=293
>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/CapsuleData.py |  8 ++++++--
> BaseTools/Source/Python/GenFds/FdfParser.py   | 13 +++++--------
> 2 files changed, 11 insertions(+), 10 deletions(-)
>
>diff --git a/BaseTools/Source/Python/GenFds/CapsuleData.py
>b/BaseTools/Source/Python/GenFds/CapsuleData.py
>index d7a6d54..24c210d 100644
>--- a/BaseTools/Source/Python/GenFds/CapsuleData.py
>+++ b/BaseTools/Source/Python/GenFds/CapsuleData.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
>@@ -184,11 +184,15 @@ class CapsulePayload(CapsuleData):
>         self.Certificate_Guid = None
>         self.MonotonicCount = None
>
>     def GenCapsuleSubItem(self, AuthData=[]):
>         if not self.Version:
>-            self.Version = 0x00000002
>+            self.Version = '0x00000002'
>+        if not self.ImageIndex:
>+            self.ImageIndex = '0x1'
>+        if not self.HardwareInstance:
>+            self.HardwareInstance = '0x0'
>         ImageFileSize = os.path.getsize(self.ImageFile)
>         if AuthData:
>             # the ImageFileSize need include the full authenticated info size. From
>first bytes of MonotonicCount to last bytes of certificate.
>             # the 32 bit is the MonotonicCount, dwLength, wRevision,
>wCertificateType and CertType
>             ImageFileSize += 32
>diff --git a/BaseTools/Source/Python/GenFds/FdfParser.py
>b/BaseTools/Source/Python/GenFds/FdfParser.py
>index 2900283..e1295f2 100644
>--- a/BaseTools/Source/Python/GenFds/FdfParser.py
>+++ b/BaseTools/Source/Python/GenFds/FdfParser.py
>@@ -1,9 +1,9 @@
> ## @file
> # parse FDF file
> #
>-#  Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.<BR>
>+#  Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.<BR>
> #  Copyright (c) 2015, Hewlett Packard Enterprise Development, L.P.<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
>@@ -3237,17 +3237,14 @@ class FdfParser:
>         else:
>             self.__UndoToken()
>
>         if (FmpData.MonotonicCount and not FmpData.Certificate_Guid) or (not
>FmpData.MonotonicCount and FmpData.Certificate_Guid):
>             EdkLogger.error("FdfParser", FORMAT_INVALID, "CERTIFICATE_GUID
>and MONOTONIC_COUNT must be work as a pair.")
>-        # remove CERTIFICATE_GUID and MONOTONIC_COUNT from
>FmpKeyList, since these keys are optional
>-        if 'CERTIFICATE_GUID' in FmpKeyList:
>-            FmpKeyList.remove('CERTIFICATE_GUID')
>-        if 'MONOTONIC_COUNT' in FmpKeyList:
>-            FmpKeyList.remove('MONOTONIC_COUNT')
>-        if FmpKeyList:
>-            raise Warning("Missing keywords %s in FMP payload section." % ',
>'.join(FmpKeyList), self.FileName, self.CurrentLineNumber)
>+
>+        # Only the IMAGE_TYPE_ID is required item
>+        if FmpKeyList and 'IMAGE_TYPE_ID' in FmpKeyList:
>+            raise Warning("Missing keywords IMAGE_TYPE_ID in FMP payload
>section.", self.FileName, self.CurrentLineNumber)
>         # get the Image file and Vendor code file
>         self.__GetFMPCapsuleData(FmpData)
>         if not FmpData.ImageFile:
>             raise Warning("Missing image file in FMP payload section.",
>self.FileName, self.CurrentLineNumber)
>         # check whether more than one Vendor code file
>--
>2.6.1.windows.1



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-01-04  5:32 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-01-04  5:14 [Patch] BaseTools: not report error for the optional items in the FmpTokens Yonghong Zhu
2017-01-04  5:32 ` Gao, Liming

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox