efi_loader: typedef struct efi_object *efi_handle_t
All our handles point to a struct efi_object. So let's define the
efi_handle_t accordingly. This helps us to discover coding errors much
more easily. This becomes evident by the corrections to the usage of
handles in this patch.
Rename variable image_handle to image_obj where applicable.
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: Alexander Graf <agraf@suse.de>
diff --git a/cmd/bootefi.c b/cmd/bootefi.c
index 4d68d80..faa00f7 100644
--- a/cmd/bootefi.c
+++ b/cmd/bootefi.c
@@ -345,7 +345,7 @@
efi_handle_t mem_handle = NULL;
struct efi_device_path *memdp = NULL;
efi_status_t ret;
- struct efi_loaded_image_obj *image_handle = NULL;
+ struct efi_loaded_image_obj *image_obj = NULL;
struct efi_loaded_image *loaded_image_info = NULL;
EFIAPI efi_status_t (*entry)(efi_handle_t image_handle,
@@ -376,7 +376,7 @@
assert(device_path && image_path);
}
- ret = efi_setup_loaded_image(device_path, image_path, &image_handle,
+ ret = efi_setup_loaded_image(device_path, image_path, &image_obj,
&loaded_image_info);
if (ret != EFI_SUCCESS)
goto exit;
@@ -384,7 +384,7 @@
/* Transfer environment variable bootargs as load options */
set_load_options(loaded_image_info, "bootargs");
/* Load the EFI payload */
- entry = efi_load_pe(image_handle, efi, loaded_image_info);
+ entry = efi_load_pe(image_obj, efi, loaded_image_info);
if (!entry) {
ret = EFI_LOAD_ERROR;
goto exit;
@@ -405,8 +405,8 @@
/* Call our payload! */
debug("%s:%d Jumping to 0x%lx\n", __func__, __LINE__, (long)entry);
- if (setjmp(&image_handle->exit_jmp)) {
- ret = image_handle->exit_status;
+ if (setjmp(&image_obj->exit_jmp)) {
+ ret = image_obj->exit_status;
goto exit;
}
@@ -418,7 +418,7 @@
/* Move into EL2 and keep running there */
armv8_switch_to_el2((ulong)entry,
- (ulong)image_handle,
+ (ulong)&image_obj->parent,
(ulong)&systab, 0, (ulong)efi_run_in_el2,
ES_TO_AARCH64);
@@ -435,7 +435,7 @@
secure_ram_addr(_do_nonsec_entry)(
efi_run_in_hyp,
(uintptr_t)entry,
- (uintptr_t)image_handle,
+ (uintptr_t)&image_obj->parent,
(uintptr_t)&systab);
/* Should never reach here, efi exits with longjmp */
@@ -443,12 +443,12 @@
}
#endif
- ret = efi_do_enter(image_handle, &systab, entry);
+ ret = efi_do_enter(&image_obj->parent, &systab, entry);
exit:
/* image has returned, loaded-image obj goes *poof*: */
- if (image_handle)
- efi_delete_handle(&image_handle->parent);
+ if (image_obj)
+ efi_delete_handle(&image_obj->parent);
if (mem_handle)
efi_delete_handle(mem_handle);
@@ -527,7 +527,7 @@
#endif
#ifdef CONFIG_CMD_BOOTEFI_SELFTEST
if (!strcmp(argv[1], "selftest")) {
- struct efi_loaded_image_obj *image_handle;
+ struct efi_loaded_image_obj *image_obj;
struct efi_loaded_image *loaded_image_info;
/* Construct a dummy device path. */
@@ -537,7 +537,7 @@
bootefi_image_path = efi_dp_from_file(NULL, 0, "\\selftest");
r = efi_setup_loaded_image(bootefi_device_path,
- bootefi_image_path, &image_handle,
+ bootefi_image_path, &image_obj,
&loaded_image_info);
if (r != EFI_SUCCESS)
return CMD_RET_FAILURE;
@@ -546,10 +546,10 @@
/* Transfer environment variable efi_selftest as load options */
set_load_options(loaded_image_info, "efi_selftest");
/* Execute the test */
- r = efi_selftest(image_handle, &systab);
+ r = efi_selftest(&image_obj->parent, &systab);
efi_restore_gd();
free(loaded_image_info->load_options);
- efi_delete_handle(&image_handle->parent);
+ efi_delete_handle(&image_obj->parent);
return r != EFI_SUCCESS;
} else
#endif