summaryrefslogtreecommitdiff
path: root/lib/efi_loader
diff options
context:
space:
mode:
authorHeinrich Schuchardt <xypron.glpk@gmx.de>2017-10-26 19:25:58 +0200
committerAlexander Graf <agraf@suse.de>2017-12-01 13:22:56 +0100
commit48b66230eef074c7335eab8c82b1f9c561b54794 (patch)
tree0463a9e49d33272cd83ad3164106e303d9bdd509 /lib/efi_loader
parent9172cd91fa58da48f31259c51536aa8778bd72da (diff)
downloadu-boot-48b66230eef074c7335eab8c82b1f9c561b54794.tar.gz
efi_loader: refactor efi_setup_loaded_image
Use helper functions to add protocols. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
Diffstat (limited to 'lib/efi_loader')
-rw-r--r--lib/efi_loader/efi_boottime.c39
1 files changed, 25 insertions, 14 deletions
diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c
index 9e8d8f486e..9b5512f086 100644
--- a/lib/efi_loader/efi_boottime.c
+++ b/lib/efi_loader/efi_boottime.c
@@ -1193,34 +1193,45 @@ void efi_setup_loaded_image(struct efi_loaded_image *info, struct efi_object *ob
struct efi_device_path *device_path,
struct efi_device_path *file_path)
{
+ efi_status_t ret;
+
obj->handle = info;
+ info->file_path = file_path;
+ if (device_path)
+ info->device_handle = efi_dp_find_obj(device_path, NULL);
+
+ list_add_tail(&obj->link, &efi_obj_list);
/*
* When asking for the device path interface, return
* bootefi_device_path
*/
- obj->protocols[0].guid = &efi_guid_device_path;
- obj->protocols[0].protocol_interface = device_path;
+ ret = efi_add_protocol(obj->handle, &efi_guid_device_path, device_path);
+ if (ret != EFI_SUCCESS)
+ goto failure;
/*
* When asking for the loaded_image interface, just
* return handle which points to loaded_image_info
*/
- obj->protocols[1].guid = &efi_guid_loaded_image;
- obj->protocols[1].protocol_interface = info;
-
- obj->protocols[2].guid = &efi_guid_console_control;
- obj->protocols[2].protocol_interface = (void *)&efi_console_control;
+ ret = efi_add_protocol(obj->handle, &efi_guid_loaded_image, info);
+ if (ret != EFI_SUCCESS)
+ goto failure;
- obj->protocols[3].guid = &efi_guid_device_path_to_text_protocol;
- obj->protocols[3].protocol_interface =
- (void *)&efi_device_path_to_text;
+ ret = efi_add_protocol(obj->handle, &efi_guid_console_control,
+ (void *)&efi_console_control);
+ if (ret != EFI_SUCCESS)
+ goto failure;
- info->file_path = file_path;
- if (device_path)
- info->device_handle = efi_dp_find_obj(device_path, NULL);
+ ret = efi_add_protocol(obj->handle,
+ &efi_guid_device_path_to_text_protocol,
+ (void *)&efi_device_path_to_text);
+ if (ret != EFI_SUCCESS)
+ goto failure;
- list_add_tail(&obj->link, &efi_obj_list);
+ return;
+failure:
+ printf("ERROR: Failure to install protocols for loaded image\n");
}
/*