[U-Boot] [PATCH] efi_loader: execute image's unload function
AKASHI Takahiro
takahiro.akashi at linaro.org
Thu Aug 9 06:50:20 UTC 2018
Currently, unload function in EFI_LOADED_IMAGE_PROTOCOL is never called
at UnloadImage Boot Service. This is not compliant to UEFI specification.
See chapter "9.1 EFI Loaded Image Protocol."
Signed-off-by: AKASHI Takahiro <takahiro.akashi at linaro.org>
---
include/efi_api.h | 4 +++-
lib/efi_loader/efi_boottime.c | 9 +++++++++
2 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/include/efi_api.h b/include/efi_api.h
index a4343ae98e2..b2806fba3b8 100644
--- a/include/efi_api.h
+++ b/include/efi_api.h
@@ -326,6 +326,8 @@ struct efi_system_table {
#define EFI_LOADED_IMAGE_PROTOCOL_REVISION 0x1000
+typedef efi_status_t (EFIAPI *efi_image_unload_t)(efi_handle_t *image_handle);
+
struct efi_loaded_image {
u32 revision;
void *parent_handle;
@@ -339,7 +341,7 @@ struct efi_loaded_image {
aligned_u64 image_size;
unsigned int image_code_type;
unsigned int image_data_type;
- unsigned long unload;
+ efi_image_unload_t unload;
/* Below are efi loader private fields */
#ifdef CONFIG_EFI_LOADER
diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c
index 80061e10ebc..d6fcf7e0049 100644
--- a/lib/efi_loader/efi_boottime.c
+++ b/lib/efi_loader/efi_boottime.c
@@ -1843,9 +1843,18 @@ static efi_status_t EFIAPI efi_exit(efi_handle_t image_handle,
*/
static efi_status_t EFIAPI efi_unload_image(efi_handle_t image_handle)
{
+ struct efi_loaded_image *info = image_handle;
struct efi_object *efiobj;
+ efi_status_t ret;
EFI_ENTRY("%p", image_handle);
+
+ if (info->unload) {
+ ret = info->unload(image_handle);
+ if (ret != EFI_SUCCESS)
+ return EFI_EXIT(ret);
+ }
+
efiobj = efi_search_obj(image_handle);
if (efiobj)
list_del(&efiobj->link);
--
2.18.0
More information about the U-Boot
mailing list