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 <gaolim...@byosoft.com.cn> Cc: Michael D Kinney <michael.d.kin...@intel.com> Cc: Guomin Jiang <guomin.ji...@intel.com> Cc: Wei6 Xu <wei6...@intel.com> Signed-off-by: John Rahn <jr...@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 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#74306): https://edk2.groups.io/g/devel/message/74306 Mute This Topic: https://groups.io/mt/82247522/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-