public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "John Rahn" <jrahn@nvidia.com>
To: <devel@edk2.groups.io>
Cc: Liming Gao <gaoliming@byosoft.com.cn>,
	Michael D Kinney <michael.d.kinney@intel.com>,
	Guomin Jiang <guomin.jiang@intel.com>,
	Wei6 Xu <wei6.xu@intel.com>
Subject: [PATCH v1 1/1] FmpDevicePkg: FmpDeviceLib interface change for Driver Unload support
Date: Tue, 20 Apr 2021 14:35:57 -0700	[thread overview]
Message-ID: <20210420213557.9498-2-jrahn@nvidia.com> (raw)
In-Reply-To: <20210420213557.9498-1-jrahn@nvidia.com>

   https://bugzilla.tianocore.org/show_bug.cgi?id=3342
     FmpDeviceLib interface for Driver Unload is missing
   Add FmpDeviceLibUnloadImage function declaration and NULL sample.
   Add FmpDxeUnloadImage function.
   Replace UNLOAD_IMAGE function in FmpDxe sample with FmpDxeUnloadImage.

Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Guomin Jiang <guomin.jiang@intel.com>
Cc: Wei6 Xu <wei6.xu@intel.com>
Signed-off-by: John Rahn <jrahn@nvidia.com>
---
 FmpDevicePkg/FmpDxe/FmpDxe.inf                       |  2 +-
 FmpDevicePkg/Include/Library/FmpDeviceLib.h          | 21 +++++++++++++++++
 FmpDevicePkg/FmpDxe/FmpDxe.c                         | 21 +++++++++++++++++
 FmpDevicePkg/Library/FmpDeviceLibNull/FmpDeviceLib.c | 24 ++++++++++++++++++++
 4 files changed, 67 insertions(+), 1 deletion(-)

diff --git a/FmpDevicePkg/FmpDxe/FmpDxe.inf b/FmpDevicePkg/FmpDxe/FmpDxe.inf
index eeb904a09148..2de9e3e4f2ad 100644
--- a/FmpDevicePkg/FmpDxe/FmpDxe.inf
+++ b/FmpDevicePkg/FmpDxe/FmpDxe.inf
@@ -17,7 +17,7 @@ [Defines]
   MODULE_TYPE                    = DXE_DRIVER
   VERSION_STRING                 = 1.0
   ENTRY_POINT                    = FmpDxeEntryPoint
-  UNLOAD_IMAGE                   = UninstallFmpInstance
+  UNLOAD_IMAGE                   = BZ3342FmpDxeUnloadImage
 
 #
 # The following information is for reference only and not required by the build tools.
diff --git a/FmpDevicePkg/Include/Library/FmpDeviceLib.h b/FmpDevicePkg/Include/Library/FmpDeviceLib.h
index 6abd99fa1f47..d9da5b940886 100644
--- a/FmpDevicePkg/Include/Library/FmpDeviceLib.h
+++ b/FmpDevicePkg/Include/Library/FmpDeviceLib.h
@@ -104,6 +104,27 @@ RegisterFmpUninstaller (
   IN FMP_DEVICE_LIB_REGISTER_FMP_UNINSTALLER  FmpUninstaller
   );
 
+/**
+  Function that unloads a Firmware Management Device Library based driver instance when
+  the FmpDeviceLib supports the driver binding model.
+  If the FmpDeviceLib does not support the UEFI driver model, the FmpDeviceLib Unload Image
+  should return EFI_UNSUPPORTED.
+
+  @param[in]  ImageHandle  The driver handle managing the Firmware Management Protocol instance to unload.
+
+  @retval EFI_SUCCESS               Driver image was removed successfully.
+  @retval EFI_UNSUPPORTED           The device is not managed by a driver that follows
+                                    the UEFI Driver Model.
+  @retval EFI_INVALID_PARAMETER     ImageHandle is NULL.
+  @retval EFI_INVALID_PARAMETER     ImageHandle does not match driver image handle.
+  @retval other                     Driver image was not removed.
+**/
+EFI_STATUS
+EFIAPI
+BZ3342FmpDeviceLibUnloadImage (
+  IN EFI_HANDLE  ImageHandle
+  );
+
 /**
   Set the device context for the FmpDeviceLib services when the device is
   managed by a driver that follows the UEFI Driver Model.  If the device is not
diff --git a/FmpDevicePkg/FmpDxe/FmpDxe.c b/FmpDevicePkg/FmpDxe/FmpDxe.c
index 6b0675ea38f8..6680a381b8fe 100644
--- a/FmpDevicePkg/FmpDxe/FmpDxe.c
+++ b/FmpDevicePkg/FmpDxe/FmpDxe.c
@@ -1813,6 +1813,27 @@ UninstallFmpInstance (
   return EFI_SUCCESS;
 }
 
+/**
+  Unloads the application and its installed protocol.
+
+  @param ImageHandle       Handle that identifies the image to be unloaded.
+
+  @retval EFI_SUCCESS      The image has been unloaded.
+
+**/
+EFI_STATUS
+EFIAPI
+BZ3342FmpDxeUnloadImage (
+  IN EFI_HANDLE       ImageHandle
+  )
+{
+  if (mFmpSingleInstance) {
+    return UninstallFmpInstance (ImageHandle);
+  } else {
+    return BZ3342FmpDeviceLibUnloadImage (ImageHandle);
+  }
+}
+
 /**
   Unloads the application and its installed protocol.
 
diff --git a/FmpDevicePkg/Library/FmpDeviceLibNull/FmpDeviceLib.c b/FmpDevicePkg/Library/FmpDeviceLibNull/FmpDeviceLib.c
index f4f57b29bdb1..4d2cbc64b7c6 100644
--- a/FmpDevicePkg/Library/FmpDeviceLibNull/FmpDeviceLib.c
+++ b/FmpDevicePkg/Library/FmpDeviceLibNull/FmpDeviceLib.c
@@ -41,6 +41,30 @@ RegisterFmpInstaller (
   return EFI_UNSUPPORTED;
 }
 
+/**
+  Function that unloads a Firmware Management Device Library based driver instance when
+  the FmpDeviceLib supports the driver binding model.
+  If the FmpDeviceLib does not support the UEFI driver model, the FmpDeviceLib Unload Image
+  should return EFI_UNSUPPORTED.
+
+  @param[in]  ImageHandle  The driver handle managing the Firmware Management Protocol instance to unload.
+
+  @retval EFI_SUCCESS               Driver image was removed successfully.
+  @retval EFI_UNSUPPORTED           The device is not managed by a driver that follows
+                                      the UEFI Driver Model.
+  @retval EFI_INVALID_PARAMETER     ImageHandle is NULL.
+  @retval EFI_INVALID_PARAMETER     ImageHandle does not match driver image handle.
+  @retval other                     Driver image was not removed.
+**/
+EFI_STATUS
+EFIAPI
+BZ3342FmpDeviceLibUnloadImage (
+  IN EFI_HANDLE  ImageHandle
+  )
+{
+  return EFI_UNSUPPORTED;
+}
+
 /**
   Provide a function to uninstall the Firmware Management Protocol instance from a
   device handle when the device is managed by a driver that follows the UEFI
-- 
2.17.1


  reply	other threads:[~2021-04-20 21:36 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-20 21:35 [PATCH v1 0/1] FmpDevicePkg: FmpDeviceLib interface change for Driver Unload support jrahn
2021-04-20 21:35 ` John Rahn [this message]
2021-04-20 22:37   ` [PATCH v1 1/1] " Michael D Kinney
2021-04-20 23:24     ` John Rahn
     [not found]     ` <1677B48878591BF9.1355@groups.io>
2021-05-24 20:01       ` [edk2-devel] " John Rahn
2022-07-22 10:02         ` gordontcp

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=20210420213557.9498-2-jrahn@nvidia.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