public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Zhichao Gao <zhichao.gao@intel.com>
To: edk2-devel@lists.01.org
Cc: Liming Gao <liming.gao@intel.com>,
	Michael D Kinney <michael.d.kinney@intel.com>
Subject: [PATCH 2/2] FmpDevicePkg/FmpDxe: Change the default Image Type ID
Date: Fri, 22 Mar 2019 10:22:36 +0800	[thread overview]
Message-ID: <20190322022236.544-3-zhichao.gao@intel.com> (raw)
In-Reply-To: <20190322022236.544-1-zhichao.gao@intel.com>

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1638

Change the default Image Type id from gEfiCallerIdGuid to
PcdFmpDeviceImageDefaultTypeIdGuid. If the pcd is not
initialized as a valid GUID value, the driver will ASSERT
and fall back to gEfiCallerIdGuid.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Zhichao Gao <zhichao.gao@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
---
 FmpDevicePkg/FmpDxe/FmpDxe.c      | 26 ++++++++++++++++++--------
 FmpDevicePkg/FmpDxe/FmpDxe.inf    |  3 ++-
 FmpDevicePkg/FmpDxe/FmpDxeLib.inf |  3 ++-
 3 files changed, 22 insertions(+), 10 deletions(-)

diff --git a/FmpDevicePkg/FmpDxe/FmpDxe.c b/FmpDevicePkg/FmpDxe/FmpDxe.c
index 57eac5ac14..5dee59e378 100644
--- a/FmpDevicePkg/FmpDxe/FmpDxe.c
+++ b/FmpDevicePkg/FmpDxe/FmpDxe.c
@@ -4,7 +4,7 @@
   information provided through PCDs and libraries.
 
   Copyright (c) 2016, Microsoft Corporation. All rights reserved.<BR>
-  Copyright (c) 2018, Intel Corporation. All rights reserved.<BR>
+  Copyright (c) 2018 - 2019, Intel Corporation. All rights reserved.<BR>
 
   Redistribution and use in source and binary forms, with or without
   modification, are permitted provided that the following conditions are met:
@@ -152,7 +152,10 @@ FmpDxeProgress (
 /**
   Returns a pointer to the ImageTypeId GUID value.  An attempt is made to get
   the GUID value from the FmpDeviceLib. If the FmpDeviceLib does not provide
-  a GUID value, then gEfiCallerIdGuid is returned.
+  a GUID value, then PcdFmpDeviceImageDefaultTypeIdGuid is returned.
+
+  If the PcdFmpDeviceImageDefaultTypeIdGuid is not initialize as a EFI_GUID,
+  then ASSERT().
 
   @return  The ImageTypeId GUID
 
@@ -167,16 +170,23 @@ GetImageTypeIdGuid (
 
   FmpDeviceLibGuid = NULL;
   Status = FmpDeviceGetImageTypeIdGuidPtr (&FmpDeviceLibGuid);
-  if (EFI_ERROR (Status)) {
+
+  if (EFI_ERROR(Status) || FmpDeviceLibGuid == NULL) {
     if (Status != EFI_UNSUPPORTED) {
       DEBUG ((DEBUG_ERROR, "FmpDxe: FmpDeviceLib GetImageTypeIdGuidPtr() returned invalid error %r\n", Status));
     }
-    return &gEfiCallerIdGuid;
-  }
-  if (FmpDeviceLibGuid == NULL) {
-    DEBUG ((DEBUG_ERROR, "FmpDxe: FmpDeviceLib GetImageTypeIdGuidPtr() returned invalid GUID\n"));
-    return &gEfiCallerIdGuid;
+    if (FmpDeviceLibGuid == NULL) {
+      DEBUG ((DEBUG_ERROR, "FmpDxe: FmpDeviceLib GetImageTypeIdGuidPtr() returned invalid GUID\n"));
+    }
+    if (PcdGetSize (PcdFmpDeviceImageDefaultTypeIdGuid) == sizeof (EFI_GUID)) {
+      FmpDeviceLibGuid = (EFI_GUID *)PcdGetPtr (PcdFmpDeviceImageDefaultTypeIdGuid);
+    } else {
+      DEBUG ((DEBUG_ERROR, "FmpDxe %s: FmpDeviceLib did not return a GUID and PcdFmpDeviceImageDefaultTypeIdGuid is undefined\n", mImageIdName));
+      ASSERT (FALSE);
+      FmpDeviceLibGuid = &gEfiCallerIdGuid;
+    }
   }
+
   return FmpDeviceLibGuid;
 }
 
diff --git a/FmpDevicePkg/FmpDxe/FmpDxe.inf b/FmpDevicePkg/FmpDxe/FmpDxe.inf
index 228e53658a..52807ca2cb 100644
--- a/FmpDevicePkg/FmpDxe/FmpDxe.inf
+++ b/FmpDevicePkg/FmpDxe/FmpDxe.inf
@@ -4,7 +4,7 @@
 #  information provided through PCDs and libraries.
 #
 #  Copyright (c) 2016, Microsoft Corporation. All rights reserved.<BR>
-#  Copyright (c) 2018, Intel Corporation. All rights reserved.<BR>
+#  Copyright (c) 2018 - 2019, Intel Corporation. All rights reserved.<BR>
 #
 #  Redistribution and use in source and binary forms, with or without
 #  modification, are permitted provided that the following conditions are met:
@@ -84,6 +84,7 @@
   gFmpDevicePkgTokenSpaceGuid.PcdFmpDevicePkcs7CertBufferXdr               ## CONSUMES
   gFmpDevicePkgTokenSpaceGuid.PcdFmpDeviceTestKeySha256Digest              ## CONSUMES
   gEfiMdeModulePkgTokenSpaceGuid.PcdTestKeyUsed                            ## SOMETIMES_PRODUCES
+  gFmpDevicePkgTokenSpaceGuid.PcdFmpDeviceImageDefaultTypeIdGuid           ## SOMETIMES_CONSUMES
 
 [Depex]
   gEfiVariableWriteArchProtocolGuid AND gEdkiiVariableLockProtocolGuid
diff --git a/FmpDevicePkg/FmpDxe/FmpDxeLib.inf b/FmpDevicePkg/FmpDxe/FmpDxeLib.inf
index 5484531155..57189a77d1 100644
--- a/FmpDevicePkg/FmpDxe/FmpDxeLib.inf
+++ b/FmpDevicePkg/FmpDxe/FmpDxeLib.inf
@@ -4,7 +4,7 @@
 #  information provided through PCDs and libraries.
 #
 #  Copyright (c) 2016, Microsoft Corporation. All rights reserved.<BR>
-#  Copyright (c) 2018, Intel Corporation. All rights reserved.<BR>
+#  Copyright (c) 2018 - 2019, Intel Corporation. All rights reserved.<BR>
 #
 #  Redistribution and use in source and binary forms, with or without
 #  modification, are permitted provided that the following conditions are met:
@@ -84,6 +84,7 @@
   gFmpDevicePkgTokenSpaceGuid.PcdFmpDevicePkcs7CertBufferXdr               ## CONSUMES
   gFmpDevicePkgTokenSpaceGuid.PcdFmpDeviceTestKeySha256Digest              ## CONSUMES
   gEfiMdeModulePkgTokenSpaceGuid.PcdTestKeyUsed                            ## SOMETIMES_PRODUCES
+  gFmpDevicePkgTokenSpaceGuid.PcdFmpDeviceImageDefaultTypeIdGuid           ## SOMETIMES_CONSUMES
 
 [Depex]
   gEfiVariableWriteArchProtocolGuid AND gEdkiiVariableLockProtocolGuid
-- 
2.16.2.windows.1



      parent reply	other threads:[~2019-03-22  2:22 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-22  2:22 [PATCH 0/2] FmpDevicePkg/FmpDxe: Change the default Image Type ID Zhichao Gao
2019-03-22  2:22 ` [PATCH 1/2] FmpDevicePkg/FmpDevucePkg.dec: Add a pcd Zhichao Gao
2019-03-22  2:22 ` Zhichao Gao [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190322022236.544-3-zhichao.gao@intel.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox