
On 11/14/2018 07:50 AM, Simon Glass wrote:
There is still duplicated code in efi_loader for tests and normal operation.
Add a new bootefi_run_prepare() function which holds common code used to set up U-Boot to run EFI code. Make use of this from the existing bootefi_test_prepare() function, as well as do_bootefi_exec().
Also shorten a few variable names.
Signed-off-by: Simon Glass sjg@chromium.org
Changes in v13: None Changes in v12: None Changes in v11: None Changes in v9: None Changes in v7: None Changes in v5:
- Drop call to efi_init_obj_list() which is now done in do_bootefi()
- Introduce load_options_path to specifyc U-Boot env var for load_options_path
Changes in v4:
- Rebase to master
Changes in v3:
Add patch to create a function to set up for running EFI code
cmd/bootefi.c | 85 +++++++++++++++++++++++++++++---------------------- 1 file changed, 48 insertions(+), 37 deletions(-)
diff --git a/cmd/bootefi.c b/cmd/bootefi.c index 91e6046cf5f..492052d827a 100644 --- a/cmd/bootefi.c +++ b/cmd/bootefi.c @@ -325,6 +325,30 @@ static efi_status_t efi_install_fdt(ulong fdt_addr) return ret; }
+static efi_status_t bootefi_run_prepare(const char *load_options_path,
struct efi_device_path *device_path,
struct efi_device_path *image_path,
struct efi_loaded_image **imagep,
struct efi_loaded_image_obj **objp)
+{
- efi_status_t ret;
- ret = efi_setup_loaded_image(device_path, image_path, objp, imagep);
- if (ret != EFI_SUCCESS)
return ret;
- /*
* gd lives in a fixed register which may get clobbered while we execute
* the payload. So save it here and restore it on every callback entry
*/
- efi_save_gd();
- /* Transfer environment variable as load options */
- set_load_options(*imagep, load_options_path);
- return 0;
+}
- /**
- do_bootefi_exec() - execute EFI binary
@@ -343,8 +367,8 @@ static efi_status_t do_bootefi_exec(void *efi, efi_handle_t mem_handle = NULL; struct efi_device_path *memdp = NULL; efi_status_t ret;
- struct efi_loaded_image_obj *image_obj = NULL;
- struct efi_loaded_image *loaded_image_info = NULL;
- struct efi_loaded_image_obj *obj = NULL;
- struct efi_loaded_image *image_prot = NULL;
Same here.
Alex