summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHeinrich Schuchardt <xypron.glpk@gmx.de>2017-11-26 14:05:20 +0100
committerAlexander Graf <agraf@suse.de>2017-12-01 13:39:20 +0100
commitbbf75dd9345d0b1a7ec7a50016547eb7c759b7af (patch)
tree1c58943c5178bafa056b821a3fe6c837acbf8129
parentc51e7df941c9d4a75d25505a9b0435f543edcf34 (diff)
downloadu-boot-bbf75dd9345d0b1a7ec7a50016547eb7c759b7af.tar.gz
u-boot-bbf75dd9345d0b1a7ec7a50016547eb7c759b7af.tar.xz
u-boot-bbf75dd9345d0b1a7ec7a50016547eb7c759b7af.zip
efi_loader: output load options in helloworld
We need to test if we pass a valid image handle when loading and EFI application. This cannot be done in efi_selftest as it is not loaded as an image. So let's enhance helloworld a bit. Reviewed-by: Simon Glass <sjg@chromium.org> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
-rw-r--r--lib/efi_loader/helloworld.c37
1 files changed, 35 insertions, 2 deletions
diff --git a/lib/efi_loader/helloworld.c b/lib/efi_loader/helloworld.c
index 77130a36dd..e59c24c788 100644
--- a/lib/efi_loader/helloworld.c
+++ b/lib/efi_loader/helloworld.c
@@ -5,19 +5,52 @@
* Written by Simon Glass <sjg@chromium.org>
*
* SPDX-License-Identifier: GPL-2.0+
+ *
+ * This program demonstrates calling a boottime service.
+ * It writes a greeting and the load options to the console.
*/
#include <common.h>
#include <efi_api.h>
+/*
+ * Entry point of the EFI application.
+ *
+ * @handle handle of the loaded image
+ * @systable system table
+ * @return status code
+ */
efi_status_t EFIAPI efi_main(efi_handle_t handle,
struct efi_system_table *systable)
{
struct efi_simple_text_output_protocol *con_out = systable->con_out;
struct efi_boot_services *boottime = systable->boottime;
+ struct efi_loaded_image *loaded_image;
+ const efi_guid_t loaded_image_guid = LOADED_IMAGE_GUID;
+ efi_status_t ret;
con_out->output_string(con_out, L"Hello, world!\n");
- boottime->exit(handle, 0, 0, NULL);
- return EFI_SUCCESS;
+ /* Get the loaded image protocol */
+ ret = boottime->handle_protocol(handle, &loaded_image_guid,
+ (void **)&loaded_image);
+ if (ret != EFI_SUCCESS) {
+ con_out->output_string(con_out,
+ L"Cannot open loaded image protocol\n");
+ goto out;
+ }
+ /* Output the load options */
+ con_out->output_string(con_out, L"Load options: ");
+ if (loaded_image->load_options_size && loaded_image->load_options)
+ con_out->output_string(con_out,
+ (u16 *)loaded_image->load_options);
+ else
+ con_out->output_string(con_out, L"<none>");
+ con_out->output_string(con_out, L"\n");
+
+out:
+ boottime->exit(handle, ret, 0, NULL);
+
+ /* We should never arrive here */
+ return ret;
}