blob: e59c24c7881b5b8466f32ec8dfd116b73aadcce7 [file] [log] [blame]
Simon Glassfac4ced2016-11-07 08:47:08 -07001/*
2 * EFI hello world
3 *
4 * Copyright (c) 2016 Google, Inc
5 * Written by Simon Glass <sjg@chromium.org>
6 *
7 * SPDX-License-Identifier: GPL-2.0+
Heinrich Schuchardt08645802017-11-26 14:05:20 +01008 *
9 * This program demonstrates calling a boottime service.
10 * It writes a greeting and the load options to the console.
Simon Glassfac4ced2016-11-07 08:47:08 -070011 */
12
13#include <common.h>
Simon Glassfac4ced2016-11-07 08:47:08 -070014#include <efi_api.h>
15
Heinrich Schuchardt08645802017-11-26 14:05:20 +010016/*
17 * Entry point of the EFI application.
18 *
19 * @handle handle of the loaded image
20 * @systable system table
21 * @return status code
22 */
Simon Glassfac4ced2016-11-07 08:47:08 -070023efi_status_t EFIAPI efi_main(efi_handle_t handle,
24 struct efi_system_table *systable)
25{
26 struct efi_simple_text_output_protocol *con_out = systable->con_out;
27 struct efi_boot_services *boottime = systable->boottime;
Heinrich Schuchardt08645802017-11-26 14:05:20 +010028 struct efi_loaded_image *loaded_image;
29 const efi_guid_t loaded_image_guid = LOADED_IMAGE_GUID;
30 efi_status_t ret;
Simon Glassfac4ced2016-11-07 08:47:08 -070031
32 con_out->output_string(con_out, L"Hello, world!\n");
Heinrich Schuchardt08645802017-11-26 14:05:20 +010033
34 /* Get the loaded image protocol */
35 ret = boottime->handle_protocol(handle, &loaded_image_guid,
36 (void **)&loaded_image);
37 if (ret != EFI_SUCCESS) {
38 con_out->output_string(con_out,
39 L"Cannot open loaded image protocol\n");
40 goto out;
41 }
42 /* Output the load options */
43 con_out->output_string(con_out, L"Load options: ");
44 if (loaded_image->load_options_size && loaded_image->load_options)
45 con_out->output_string(con_out,
46 (u16 *)loaded_image->load_options);
47 else
48 con_out->output_string(con_out, L"<none>");
49 con_out->output_string(con_out, L"\n");
50
51out:
52 boottime->exit(handle, ret, 0, NULL);
Simon Glassfac4ced2016-11-07 08:47:08 -070053
Heinrich Schuchardt08645802017-11-26 14:05:20 +010054 /* We should never arrive here */
55 return ret;
Simon Glassfac4ced2016-11-07 08:47:08 -070056}