blob: 804ca7e46791cb6cefb4c98bca47ac6854763c66 [file] [log] [blame]
Simon Glass8a4ee052024-11-07 14:31:41 -07001// SPDX-License-Identifier: GPL-2.0-or-later
2/*
3 * EFI test application
4 *
5 * Copyright 2024 Google LLC
6 * Written by Simon Glass <sjg@chromium.org>
7 *
8 * This test program is used to test the invocation of an EFI application.
9 * It writes a few messages to the console and then exits boot services
10 */
11
12#include <efi_api.h>
13
14static const efi_guid_t loaded_image_guid = EFI_LOADED_IMAGE_PROTOCOL_GUID;
15
16static struct efi_system_table *systable;
17static struct efi_boot_services *boottime;
18static struct efi_simple_text_output_protocol *con_out;
19
20/**
21 * efi_main() - entry point of the EFI application.
22 *
23 * @handle: handle of the loaded image
24 * @systab: system table
25 * Return: status code
26 */
27efi_status_t EFIAPI efi_main(efi_handle_t handle,
28 struct efi_system_table *systab)
29{
30 struct efi_loaded_image *loaded_image;
31 efi_status_t ret;
32
33 systable = systab;
34 boottime = systable->boottime;
35 con_out = systable->con_out;
36
37 /* Get the loaded image protocol */
38 ret = boottime->open_protocol(handle, &loaded_image_guid,
39 (void **)&loaded_image, NULL, NULL,
40 EFI_OPEN_PROTOCOL_GET_PROTOCOL);
41 if (ret != EFI_SUCCESS) {
42 con_out->output_string
43 (con_out, u"Cannot open loaded image protocol\r\n");
44 goto out;
45 }
46
47 /* UEFI requires CR LF */
48 con_out->output_string(con_out, u"U-Boot test app for EFI_LOADER\r\n");
49
50out:
51 con_out->output_string(con_out, u"Exiting test app\n");
52 ret = boottime->exit(handle, ret, 0, NULL);
53
54 /* We should never arrive here */
55 return ret;
56}