]> git.ipfire.org Git - thirdparty/u-boot.git/blame - include/efi_loader.h
efi_loader: Add console interface
[thirdparty/u-boot.git] / include / efi_loader.h
CommitLineData
cb149c66
AG
1/*
2 * EFI application loader
3 *
4 * Copyright (c) 2016 Alexander Graf
5 *
6 * SPDX-License-Identifier: GPL-2.0+
7 */
8
bee91169 9#include <common.h>
cb149c66
AG
10#include <part_efi.h>
11#include <efi_api.h>
bee91169
AG
12
13/* No need for efi loader support in SPL */
14#if defined(CONFIG_EFI_LOADER) && !defined(CONFIG_SPL_BUILD)
15
cb149c66
AG
16#include <linux/list.h>
17
bee91169
AG
18/* #define DEBUG_EFI */
19
20#ifdef DEBUG_EFI
21#define EFI_ENTRY(format, ...) do { \
22 efi_restore_gd(); \
23 printf("EFI: Entry %s(" format ")\n", __func__, ##__VA_ARGS__); \
24 } while(0)
25#else
26#define EFI_ENTRY(format, ...) do { \
27 efi_restore_gd(); \
28 } while(0)
29#endif
30
31#define EFI_EXIT(ret) efi_exit_func(ret);
32
33extern struct efi_system_table systab;
34
c1311ad4
AG
35extern const struct efi_simple_text_output_protocol efi_con_out;
36extern const struct efi_simple_input_interface efi_con_in;
37extern const struct efi_console_control_protocol efi_console_control;
38
39extern const efi_guid_t efi_guid_console_control;
cb149c66
AG
40extern const efi_guid_t efi_guid_device_path;
41extern const efi_guid_t efi_guid_loaded_image;
42
bee91169
AG
43/*
44 * While UEFI objects can have callbacks, you can also call functions on
45 * protocols (classes) themselves. This struct maps a protocol GUID to its
46 * interface (usually a struct with callback functions).
47 */
48struct efi_class_map {
49 const efi_guid_t *guid;
50 const void *interface;
51};
52
53/*
54 * When the UEFI payload wants to open a protocol on an object to get its
55 * interface (usually a struct with callback functions), this struct maps the
56 * protocol GUID to the respective protocol handler open function for that
57 * object protocol combination.
58 */
59struct efi_handler {
60 const efi_guid_t *guid;
61 efi_status_t (EFIAPI *open)(void *handle,
62 efi_guid_t *protocol, void **protocol_interface,
63 void *agent_handle, void *controller_handle,
64 uint32_t attributes);
65};
66
67/*
68 * UEFI has a poor man's OO model where one "object" can be polymorphic and have
69 * multiple different protocols (classes) attached to it.
70 *
71 * This struct is the parent struct for all of our actual implementation objects
72 * that can include it to make themselves an EFI object
73 */
74struct efi_object {
75 /* Every UEFI object is part of a global object list */
76 struct list_head link;
77 /* We support up to 4 "protocols" an object can be accessed through */
78 struct efi_handler protocols[4];
79 /* The object spawner can either use this for data or as identifier */
80 void *handle;
81};
82
83/* This list contains all UEFI objects we know of */
84extern struct list_head efi_obj_list;
85
86/*
87 * Stub implementation for a protocol opener that just returns the handle as
88 * interface
89 */
cb149c66
AG
90efi_status_t efi_return_handle(void *handle,
91 efi_guid_t *protocol, void **protocol_interface,
92 void *agent_handle, void *controller_handle,
93 uint32_t attributes);
bee91169
AG
94/* Called from places to check whether a timer expired */
95void efi_timer_check(void);
96/* PE loader implementation */
cb149c66 97void *efi_load_pe(void *efi, struct efi_loaded_image *loaded_image_info);
bee91169
AG
98/* Called once to store the pristine gd pointer */
99void efi_save_gd(void);
100/* Called from EFI_ENTRY on callback entry to put gd into the gd register */
101void efi_restore_gd(void);
102/* Called from EFI_EXIT on callback exit to restore the gd register */
103efi_status_t efi_exit_func(efi_status_t ret);
104
105#else /* defined(EFI_LOADER) && !defined(CONFIG_SPL_BUILD) */
106
107/* No loader configured, stub out EFI_ENTRY */
108static inline void efi_restore_gd(void) { }
109
110#endif