2 * EFI application loader
4 * Copyright (c) 2016 Alexander Graf
6 * SPDX-License-Identifier: GPL-2.0+
13 /* No need for efi loader support in SPL */
14 #if defined(CONFIG_EFI_LOADER) && !defined(CONFIG_SPL_BUILD)
16 #include <linux/list.h>
18 /* #define DEBUG_EFI */
21 #define EFI_ENTRY(format, ...) do { \
23 printf("EFI: Entry %s(" format ")\n", __func__, ##__VA_ARGS__); \
26 #define EFI_ENTRY(format, ...) do { \
31 #define EFI_EXIT(ret) efi_exit_func(ret);
33 extern struct efi_system_table systab;
35 extern const efi_guid_t efi_guid_device_path;
36 extern const efi_guid_t efi_guid_loaded_image;
39 * While UEFI objects can have callbacks, you can also call functions on
40 * protocols (classes) themselves. This struct maps a protocol GUID to its
41 * interface (usually a struct with callback functions).
43 struct efi_class_map {
44 const efi_guid_t *guid;
45 const void *interface;
49 * When the UEFI payload wants to open a protocol on an object to get its
50 * interface (usually a struct with callback functions), this struct maps the
51 * protocol GUID to the respective protocol handler open function for that
52 * object protocol combination.
55 const efi_guid_t *guid;
56 efi_status_t (EFIAPI *open)(void *handle,
57 efi_guid_t *protocol, void **protocol_interface,
58 void *agent_handle, void *controller_handle,
63 * UEFI has a poor man's OO model where one "object" can be polymorphic and have
64 * multiple different protocols (classes) attached to it.
66 * This struct is the parent struct for all of our actual implementation objects
67 * that can include it to make themselves an EFI object
70 /* Every UEFI object is part of a global object list */
71 struct list_head link;
72 /* We support up to 4 "protocols" an object can be accessed through */
73 struct efi_handler protocols[4];
74 /* The object spawner can either use this for data or as identifier */
78 /* This list contains all UEFI objects we know of */
79 extern struct list_head efi_obj_list;
82 * Stub implementation for a protocol opener that just returns the handle as
85 efi_status_t efi_return_handle(void *handle,
86 efi_guid_t *protocol, void **protocol_interface,
87 void *agent_handle, void *controller_handle,
89 /* Called from places to check whether a timer expired */
90 void efi_timer_check(void);
91 /* PE loader implementation */
92 void *efi_load_pe(void *efi, struct efi_loaded_image *loaded_image_info);
93 /* Called once to store the pristine gd pointer */
94 void efi_save_gd(void);
95 /* Called from EFI_ENTRY on callback entry to put gd into the gd register */
96 void efi_restore_gd(void);
97 /* Called from EFI_EXIT on callback exit to restore the gd register */
98 efi_status_t efi_exit_func(efi_status_t ret);
100 #else /* defined(EFI_LOADER) && !defined(CONFIG_SPL_BUILD) */
102 /* No loader configured, stub out EFI_ENTRY */
103 static inline void efi_restore_gd(void) { }