Blame view
include/efi_loader.h
25 KB
f739fcd83
|
1 |
/* SPDX-License-Identifier: GPL-2.0+ */ |
cb149c663
|
2 3 4 5 |
/* * EFI application loader * * Copyright (c) 2016 Alexander Graf |
cb149c663
|
6 |
*/ |
cd9e18dee
|
7 8 |
#ifndef _EFI_LOADER_H #define _EFI_LOADER_H 1 |
bee91169f
|
9 |
#include <common.h> |
cb149c663
|
10 11 |
#include <part_efi.h> #include <efi_api.h> |
bee91169f
|
12 |
|
fdeb6f7dc
|
13 14 15 16 |
static inline int guidcmp(const void *g1, const void *g2) { return memcmp(g1, g2, sizeof(efi_guid_t)); } |
61e42d946
|
17 18 19 20 |
static inline void *guidcpy(void *dst, const void *src) { return memcpy(dst, src, sizeof(efi_guid_t)); } |
bee91169f
|
21 |
/* No need for efi loader support in SPL */ |
9b5e6396b
|
22 |
#if CONFIG_IS_ENABLED(EFI_LOADER) |
bee91169f
|
23 |
|
cb149c663
|
24 |
#include <linux/list.h> |
4182a129e
|
25 26 |
/* Maximum number of configuration tables */ #define EFI_MAX_CONFIGURATION_TABLES 16 |
4e6b5d650
|
27 28 29 30 |
/* GUID used by the root node */ #define U_BOOT_GUID \ EFI_GUID(0xe61d73b9, 0xa384, 0x4acc, \ 0xae, 0xab, 0x82, 0xe8, 0x28, 0xf3, 0x62, 0x8b) |
23ad52fff
|
31 32 33 34 |
/* GUID used as host device on sandbox */ #define U_BOOT_HOST_DEV_GUID \ EFI_GUID(0xbbe4e671, 0x5773, 0x4ea1, \ 0x9a, 0xab, 0x3a, 0x7d, 0xbf, 0x40, 0xc4, 0x82) |
4e6b5d650
|
35 |
|
7a597259d
|
36 |
/* Use internal device tree when starting UEFI application */ |
f64f22325
|
37 |
#define EFI_FDT_USE_INTERNAL NULL |
7a597259d
|
38 |
|
a2a4bc3b0
|
39 40 |
/* Root node */ extern efi_handle_t efi_root; |
c160d2f5e
|
41 42 |
int __efi_entry_check(void); int __efi_exit_check(void); |
ae0bd3a98
|
43 |
const char *__efi_nesting(void); |
af65db85b
|
44 45 |
const char *__efi_nesting_inc(void); const char *__efi_nesting_dec(void); |
c160d2f5e
|
46 |
|
a095aadff
|
47 48 49 |
/* * Enter the u-boot world from UEFI: */ |
bee91169f
|
50 |
#define EFI_ENTRY(format, ...) do { \ |
c160d2f5e
|
51 |
assert(__efi_entry_check()); \ |
af65db85b
|
52 53 54 |
debug("%sEFI: Entry %s(" format ") ", __efi_nesting_inc(), \ __func__, ##__VA_ARGS__); \ |
bee91169f
|
55 |
} while(0) |
bee91169f
|
56 |
|
a095aadff
|
57 58 59 |
/* * Exit the u-boot world back to UEFI: */ |
804b1d737
|
60 |
#define EFI_EXIT(ret) ({ \ |
c81883dfc
|
61 |
typeof(ret) _r = ret; \ |
af65db85b
|
62 63 |
debug("%sEFI: Exit: %s: %u ", __efi_nesting_dec(), \ |
c81883dfc
|
64 |
__func__, (u32)((uintptr_t) _r & ~EFI_ERROR_MASK)); \ |
c160d2f5e
|
65 66 |
assert(__efi_exit_check()); \ _r; \ |
804b1d737
|
67 |
}) |
bee91169f
|
68 |
|
a095aadff
|
69 |
/* |
ea630ce9e
|
70 |
* Call non-void UEFI function from u-boot and retrieve return value: |
a095aadff
|
71 |
*/ |
ea630ce9e
|
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
#define EFI_CALL(exp) ({ \ debug("%sEFI: Call: %s ", __efi_nesting_inc(), #exp); \ assert(__efi_exit_check()); \ typeof(exp) _r = exp; \ assert(__efi_entry_check()); \ debug("%sEFI: %lu returned by %s ", __efi_nesting_dec(), \ (unsigned long)((uintptr_t)_r & ~EFI_ERROR_MASK), #exp); \ _r; \ }) /* * Call void UEFI function from u-boot: */ #define EFI_CALL_VOID(exp) do { \ |
af65db85b
|
88 89 |
debug("%sEFI: Call: %s ", __efi_nesting_inc(), #exp); \ |
c160d2f5e
|
90 |
assert(__efi_exit_check()); \ |
a095aadff
|
91 |
exp; \ |
c160d2f5e
|
92 |
assert(__efi_entry_check()); \ |
af65db85b
|
93 94 |
debug("%sEFI: Return From: %s ", __efi_nesting_dec(), #exp); \ |
a095aadff
|
95 |
} while(0) |
ae0bd3a98
|
96 |
/* |
d55041443
|
97 |
* Write an indented message with EFI prefix |
ae0bd3a98
|
98 |
*/ |
d55041443
|
99 100 101 |
#define EFI_PRINT(format, ...) ({ \ debug("%sEFI: " format, __efi_nesting(), \ ##__VA_ARGS__); \ |
ae0bd3a98
|
102 |
}) |
89aea4364
|
103 104 105 106 107 108 |
#ifdef CONFIG_SYS_CACHELINE_SIZE #define EFI_CACHELINE_SIZE CONFIG_SYS_CACHELINE_SIZE #else /* Just use the greatest cache flush alignment requirement I'm aware of */ #define EFI_CACHELINE_SIZE 128 #endif |
1fcb7ea28
|
109 110 |
/* Key identifying current memory map */ extern efi_uintn_t efi_memory_map_key; |
50149ea37
|
111 |
extern struct efi_runtime_services efi_runtime_services; |
bee91169f
|
112 |
extern struct efi_system_table systab; |
ebb4dd5bc
|
113 |
extern struct efi_simple_text_output_protocol efi_con_out; |
3e603ec75
|
114 |
extern struct efi_simple_text_input_protocol efi_con_in; |
ebb4dd5bc
|
115 |
extern struct efi_console_control_protocol efi_console_control; |
cc5b70812
|
116 |
extern const struct efi_device_path_to_text_protocol efi_device_path_to_text; |
e70f8dfa2
|
117 118 119 |
/* implementation of the EFI_DEVICE_PATH_UTILITIES_PROTOCOL */ extern const struct efi_device_path_utilities_protocol efi_device_path_utilities; |
b1b782d30
|
120 121 122 123 |
/* deprecated version of the EFI_UNICODE_COLLATION_PROTOCOL */ extern const struct efi_unicode_collation_protocol efi_unicode_collation_protocol; /* current version of the EFI_UNICODE_COLLATION_PROTOCOL */ |
0bc4b0da7
|
124 |
extern const struct efi_unicode_collation_protocol |
95ab38167
|
125 |
efi_unicode_collation_protocol2; |
cb728e51a
|
126 127 |
extern const struct efi_hii_config_routing_protocol efi_hii_config_routing; extern const struct efi_hii_config_access_protocol efi_hii_config_access; |
c9bfb2229
|
128 129 |
extern const struct efi_hii_database_protocol efi_hii_database; extern const struct efi_hii_string_protocol efi_hii_string; |
33c37d978
|
130 |
extern const struct efi_rng_protocol efi_rng_protocol; |
c1311ad4e
|
131 |
|
adae4313c
|
132 |
uint16_t *efi_dp_str(struct efi_device_path *dp); |
4e6b5d650
|
133 134 |
/* GUID of the U-Boot root node */ extern const efi_guid_t efi_u_boot_guid; |
23ad52fff
|
135 136 137 138 |
#ifdef CONFIG_SANDBOX /* GUID of U-Boot host device on sandbox */ extern const efi_guid_t efi_guid_host_dev; #endif |
b3dd14b6b
|
139 140 |
/* GUID of the EFI_BLOCK_IO_PROTOCOL */ extern const efi_guid_t efi_block_io_guid; |
9975fe96b
|
141 |
extern const efi_guid_t efi_global_variable_guid; |
c1311ad4e
|
142 |
extern const efi_guid_t efi_guid_console_control; |
cb149c663
|
143 |
extern const efi_guid_t efi_guid_device_path; |
f0959dbee
|
144 145 |
/* GUID of the EFI_DRIVER_BINDING_PROTOCOL */ extern const efi_guid_t efi_guid_driver_binding_protocol; |
a3a28f5f0
|
146 147 148 149 150 151 152 153 154 155 |
/* event group ExitBootServices() invoked */ extern const efi_guid_t efi_guid_event_group_exit_boot_services; /* event group SetVirtualAddressMap() invoked */ extern const efi_guid_t efi_guid_event_group_virtual_address_change; /* event group memory map changed */ extern const efi_guid_t efi_guid_event_group_memory_map_change; /* event group boot manager about to boot */ extern const efi_guid_t efi_guid_event_group_ready_to_boot; /* event group ResetSystem() invoked (before ExitBootServices) */ extern const efi_guid_t efi_guid_event_group_reset_system; |
bc4f9133e
|
156 157 |
/* GUID of the device tree table */ extern const efi_guid_t efi_guid_fdt; |
cb149c663
|
158 |
extern const efi_guid_t efi_guid_loaded_image; |
bc8fc3285
|
159 |
extern const efi_guid_t efi_guid_loaded_image_device_path; |
cc5b70812
|
160 |
extern const efi_guid_t efi_guid_device_path_to_text_protocol; |
2a92080d8
|
161 162 |
extern const efi_guid_t efi_simple_file_system_protocol_guid; extern const efi_guid_t efi_file_info_guid; |
9e6835e6b
|
163 164 |
/* GUID for file system information */ extern const efi_guid_t efi_file_system_info_guid; |
e70f8dfa2
|
165 |
extern const efi_guid_t efi_guid_device_path_utilities_protocol; |
b1b782d30
|
166 167 |
/* GUID of the deprecated Unicode collation protocol */ extern const efi_guid_t efi_guid_unicode_collation_protocol; |
0bc4b0da7
|
168 |
/* GUID of the Unicode collation protocol */ |
95ab38167
|
169 |
extern const efi_guid_t efi_guid_unicode_collation_protocol2; |
cb728e51a
|
170 171 |
extern const efi_guid_t efi_guid_hii_config_routing_protocol; extern const efi_guid_t efi_guid_hii_config_access_protocol; |
c9bfb2229
|
172 173 |
extern const efi_guid_t efi_guid_hii_database_protocol; extern const efi_guid_t efi_guid_hii_string_protocol; |
cb149c663
|
174 |
|
33c37d978
|
175 176 |
/* GUID of RNG protocol */ extern const efi_guid_t efi_guid_rng_protocol; |
50149ea37
|
177 178 |
extern unsigned int __efi_runtime_start, __efi_runtime_stop; extern unsigned int __efi_runtime_rel_start, __efi_runtime_rel_stop; |
1f1075c6e
|
179 180 181 |
/** * struct efi_open_protocol_info_item - open protocol info item * |
fe1599daf
|
182 183 |
* When a protocol is opened a open protocol info entry is created. * These are maintained in a list. |
1f1075c6e
|
184 185 186 |
* * @link: link to the list of open protocol info entries of a protocol * @info: information about the opening of a protocol |
fe1599daf
|
187 188 |
*/ struct efi_open_protocol_info_item { |
fe1599daf
|
189 190 191 |
struct list_head link; struct efi_open_protocol_info_entry info; }; |
1f1075c6e
|
192 193 194 |
/** * struct efi_handler - single protocol interface of a handle * |
bee91169f
|
195 196 |
* When the UEFI payload wants to open a protocol on an object to get its * interface (usually a struct with callback functions), this struct maps the |
fe1599daf
|
197 |
* protocol GUID to the respective protocol interface |
1f1075c6e
|
198 199 200 201 202 |
* * @link: link to the list of protocols of a handle * @guid: GUID of the protocol * @protocol_interface: protocol interface * @open_infos link to the list of open protocol info items |
fe1599daf
|
203 |
*/ |
bee91169f
|
204 |
struct efi_handler { |
69fb6b1af
|
205 |
struct list_head link; |
bee91169f
|
206 |
const efi_guid_t *guid; |
b5349f742
|
207 |
void *protocol_interface; |
fe1599daf
|
208 |
struct list_head open_infos; |
bee91169f
|
209 |
}; |
fae0118e7
|
210 |
/** |
cd73aba65
|
211 212 213 214 215 216 217 |
* enum efi_object_type - type of EFI object * * In UnloadImage we must be able to identify if the handle relates to a * started image. */ enum efi_object_type { EFI_OBJECT_TYPE_UNDEFINED = 0, |
84a918e8c
|
218 |
EFI_OBJECT_TYPE_U_BOOT_FIRMWARE, |
cd73aba65
|
219 220 221 222 223 |
EFI_OBJECT_TYPE_LOADED_IMAGE, EFI_OBJECT_TYPE_STARTED_IMAGE, }; /** |
fae0118e7
|
224 225 226 227 228 229 230 231 232 233 234 235 |
* struct efi_object - dereferenced EFI handle * * @link: pointers to put the handle into a linked list * @protocols: linked list with the protocol interfaces installed on this * handle * * UEFI offers a flexible and expandable object model. The objects in the UEFI * API are devices, drivers, and loaded images. struct efi_object is our storage * structure for these objects. * * When including this structure into a larger structure always put it first so * that when deleting a handle the whole encompassing structure can be freed. |
bee91169f
|
236 |
* |
fae0118e7
|
237 238 |
* A pointer to this structure is referred to as a handle. Typedef efi_handle_t * has been created for such pointers. |
bee91169f
|
239 240 241 242 |
*/ struct efi_object { /* Every UEFI object is part of a global object list */ struct list_head link; |
69fb6b1af
|
243 244 |
/* The list of protocols */ struct list_head protocols; |
cd73aba65
|
245 |
enum efi_object_type type; |
bee91169f
|
246 |
}; |
c68415922
|
247 |
/** |
c982874e9
|
248 |
* struct efi_loaded_image_obj - handle of a loaded image |
d39646a38
|
249 250 |
* * @header: EFI object header |
556d8dc93
|
251 252 253 |
* @exit_status: exit status passed to Exit() * @exit_data_size: exit data size passed to Exit() * @exit_data: exit data passed to Exit() |
d39646a38
|
254 255 |
* @exit_jmp: long jump buffer for returning form started image * @entry: entry address of the relocated image |
c982874e9
|
256 257 |
*/ struct efi_loaded_image_obj { |
d39646a38
|
258 |
struct efi_object header; |
c982874e9
|
259 |
efi_status_t exit_status; |
556d8dc93
|
260 261 |
efi_uintn_t *exit_data_size; u16 **exit_data; |
c982874e9
|
262 263 264 |
struct jmp_buf_data exit_jmp; EFIAPI efi_status_t (*entry)(efi_handle_t image_handle, struct efi_system_table *st); |
126a43f15
|
265 |
u16 image_type; |
c982874e9
|
266 267 268 |
}; /** |
c68415922
|
269 270 |
* struct efi_event * |
43bce4426
|
271 |
* @link: Link to list of all events |
7a69e97ba
|
272 |
* @queue_link: Link to the list of queued events |
c68415922
|
273 274 |
* @type: Type of event, see efi_create_event * @notify_tpl: Task priority level of notifications |
c68415922
|
275 276 |
* @nofify_function: Function to call when the event is triggered * @notify_context: Data to be passed to the notify function |
b095f3c85
|
277 |
* @group: Event group |
43bce4426
|
278 279 |
* @trigger_time: Period of the timer * @trigger_next: Next time to trigger the timer |
c68415922
|
280 |
* @trigger_type: Type of timer, see efi_set_timer |
43bce4426
|
281 |
* @is_signaled: The event occurred. The event is in the signaled state. |
c68415922
|
282 283 |
*/ struct efi_event { |
43bce4426
|
284 |
struct list_head link; |
7a69e97ba
|
285 |
struct list_head queue_link; |
b521d29eb
|
286 |
uint32_t type; |
152cade32
|
287 |
efi_uintn_t notify_tpl; |
c68415922
|
288 289 |
void (EFIAPI *notify_function)(struct efi_event *event, void *context); void *notify_context; |
b095f3c85
|
290 |
const efi_guid_t *group; |
c68415922
|
291 292 |
u64 trigger_next; u64 trigger_time; |
b521d29eb
|
293 |
enum efi_timer_delay trigger_type; |
e190e8972
|
294 |
bool is_signaled; |
c68415922
|
295 |
}; |
bee91169f
|
296 297 |
/* This list contains all UEFI objects we know of */ extern struct list_head efi_obj_list; |
b095f3c85
|
298 299 |
/* List of all events */ extern struct list_head efi_events; |
bee91169f
|
300 |
|
ab15d4149
|
301 |
/** |
f09cea36c
|
302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 |
* struct efi_protocol_notification - handle for notified protocol * * When a protocol interface is installed for which an event was registered with * the RegisterProtocolNotify() service this structure is used to hold the * handle on which the protocol interface was installed. * * @link: link to list of all handles notified for this event * @handle: handle on which the notified protocol interface was installed */ struct efi_protocol_notification { struct list_head link; efi_handle_t handle; }; /** |
ab15d4149
|
317 318 319 320 |
* efi_register_notify_event - event registered by RegisterProtocolNotify() * * The address of this structure serves as registration value. * |
f09cea36c
|
321 322 323 324 325 326 |
* @link: link to list of all registered events * @event: registered event. The same event may registered for multiple * GUIDs. * @protocol: protocol for which the event is registered * @handles: linked list of all handles on which the notified protocol was * installed |
ab15d4149
|
327 328 329 330 331 |
*/ struct efi_register_notify_event { struct list_head link; struct efi_event *event; efi_guid_t protocol; |
f09cea36c
|
332 |
struct list_head handles; |
ab15d4149
|
333 334 335 336 |
}; /* List of all events registered by RegisterProtocolNotify() */ extern struct list_head efi_register_notify_events; |
056b45bc5
|
337 338 |
/* Initialize efi execution environment */ efi_status_t efi_init_obj_list(void); |
f64f22325
|
339 340 |
/* Install device tree */ efi_status_t efi_install_fdt(void *fdt); |
f9ceb6ac1
|
341 342 |
/* Run loaded UEFI image */ efi_status_t efi_run_image(void *source_buffer, efi_uintn_t source_size); |
88192098d
|
343 344 |
/* Initialize variable services */ efi_status_t efi_init_variables(void); |
29018abb0
|
345 346 |
/* Notify ExitBootServices() is called */ void efi_variables_boot_exit_notify(void); |
4e6b5d650
|
347 348 |
/* Called by bootefi to initialize root node */ efi_status_t efi_root_node_register(void); |
640adadf8
|
349 350 |
/* Called by bootefi to initialize runtime */ efi_status_t efi_initialize_system_table(void); |
7f95104d9
|
351 352 |
/* efi_runtime_detach() - detach unimplemented runtime functions */ void efi_runtime_detach(void); |
91be9a77b
|
353 |
/* Called by bootefi to make console interface available */ |
6f566c231
|
354 |
efi_status_t efi_console_register(void); |
2a22d05d3
|
355 |
/* Called by bootefi to make all disk storage accessible as EFI objects */ |
df9cf561b
|
356 |
efi_status_t efi_disk_register(void); |
64e4db0f1
|
357 358 359 360 |
/* Create handles and protocols for the partitions of a block device */ int efi_disk_create_partitions(efi_handle_t parent, struct blk_desc *desc, const char *if_typename, int diskid, const char *pdevname); |
be8d32419
|
361 |
/* Called by bootefi to make GOP (graphical) interface available */ |
80ea9b099
|
362 |
efi_status_t efi_gop_register(void); |
0efe1bcf5
|
363 |
/* Called by bootefi to make the network interface available */ |
075d425d6
|
364 |
efi_status_t efi_net_register(void); |
b3d609004
|
365 |
/* Called by bootefi to make the watchdog available */ |
d7b181d57
|
366 |
efi_status_t efi_watchdog_register(void); |
ec80b4735
|
367 |
efi_status_t efi_initrd_register(void); |
e663b350f
|
368 |
/* Called by bootefi to make SMBIOS tables available */ |
0864c565a
|
369 |
/** |
86df34d42
|
370 371 372 373 374 375 376 377 |
* efi_acpi_register() - write out ACPI tables * * Called by bootefi to make ACPI tables available * * @return 0 if OK, -ENOMEM if no memory is available for the tables */ efi_status_t efi_acpi_register(void); /** |
0864c565a
|
378 379 380 381 382 383 |
* efi_smbios_register() - write out SMBIOS tables * * Called by bootefi to make SMBIOS tables available * * @return 0 if OK, -ENOMEM if no memory is available for the tables */ |
7657152bd
|
384 |
efi_status_t efi_smbios_register(void); |
0efe1bcf5
|
385 |
|
2a92080d8
|
386 387 |
struct efi_simple_file_system_protocol * efi_fs_from_path(struct efi_device_path *fp); |
0efe1bcf5
|
388 389 |
/* Called by networking code to memorize the dhcp ack package */ void efi_net_set_dhcp_ack(void *pkt, int len); |
b3d609004
|
390 391 |
/* Called by efi_set_watchdog_timer to reset the timer */ efi_status_t efi_set_watchdog(unsigned long timeout); |
0efe1bcf5
|
392 |
|
bee91169f
|
393 394 395 |
/* Called from places to check whether a timer expired */ void efi_timer_check(void); /* PE loader implementation */ |
8f7e2b298
|
396 397 |
efi_status_t efi_load_pe(struct efi_loaded_image_obj *handle, void *efi, struct efi_loaded_image *loaded_image_info); |
bee91169f
|
398 399 |
/* Called once to store the pristine gd pointer */ void efi_save_gd(void); |
c160d2f5e
|
400 401 |
/* Special case handler for error/abort that just tries to dtrt to get * back to u-boot world */ |
bee91169f
|
402 |
void efi_restore_gd(void); |
50149ea37
|
403 404 |
/* Call this to relocate the runtime section to an address space */ void efi_runtime_relocate(ulong offset, struct efi_mem_desc *map); |
0f4060ebc
|
405 |
/* Call this to set the current device name */ |
c07ad7c03
|
406 |
void efi_set_bootdev(const char *dev, const char *devnr, const char *path); |
44549d62c
|
407 |
/* Add a new object to the object list. */ |
fae0118e7
|
408 |
void efi_add_handle(efi_handle_t obj); |
2edab5e2e
|
409 |
/* Create handle */ |
2074f7006
|
410 |
efi_status_t efi_create_handle(efi_handle_t *handle); |
678e03a00
|
411 |
/* Delete handle */ |
fae0118e7
|
412 |
void efi_delete_handle(efi_handle_t obj); |
1b68153af
|
413 |
/* Call this to validate a handle and find the EFI object for it */ |
2074f7006
|
414 |
struct efi_object *efi_search_obj(const efi_handle_t handle); |
d7e0b0109
|
415 416 417 418 419 420 421 |
/* Load image */ efi_status_t EFIAPI efi_load_image(bool boot_policy, efi_handle_t parent_image, struct efi_device_path *file_path, void *source_buffer, efi_uintn_t source_size, efi_handle_t *image_handle); |
f69d63fae
|
422 423 424 425 |
/* Start image */ efi_status_t EFIAPI efi_start_image(efi_handle_t image_handle, efi_uintn_t *exit_data_size, u16 **exit_data); |
d7e0b0109
|
426 427 |
/* Unload image */ efi_status_t EFIAPI efi_unload_image(efi_handle_t image_handle); |
3f79a2b53
|
428 |
/* Find a protocol on a handle */ |
2074f7006
|
429 |
efi_status_t efi_search_protocol(const efi_handle_t handle, |
3f79a2b53
|
430 431 432 |
const efi_guid_t *protocol_guid, struct efi_handler **handler); /* Install new protocol on a handle */ |
2074f7006
|
433 434 |
efi_status_t efi_add_protocol(const efi_handle_t handle, const efi_guid_t *protocol, |
3f79a2b53
|
435 436 |
void *protocol_interface); /* Delete protocol from a handle */ |
2074f7006
|
437 438 |
efi_status_t efi_remove_protocol(const efi_handle_t handle, const efi_guid_t *protocol, |
3f79a2b53
|
439 440 |
void *protocol_interface); /* Delete all protocols from a handle */ |
2074f7006
|
441 |
efi_status_t efi_remove_all_protocols(const efi_handle_t handle); |
7657ae12f
|
442 443 444 |
/* Install multiple protocol interfaces */ efi_status_t EFIAPI efi_install_multiple_protocol_interfaces (efi_handle_t *handle, ...); |
b51ec6397
|
445 446 447 448 449 450 451 452 453 454 455 456 457 458 |
/* Get handles that support a given protocol */ efi_status_t EFIAPI efi_locate_handle_buffer( enum efi_locate_search_type search_type, const efi_guid_t *protocol, void *search_key, efi_uintn_t *no_handles, efi_handle_t **buffer); /* Close an previously opened protocol interface */ efi_status_t EFIAPI efi_close_protocol(efi_handle_t handle, const efi_guid_t *protocol, efi_handle_t agent_handle, efi_handle_t controller_handle); /* Open a protocol interface */ efi_status_t EFIAPI efi_handle_protocol(efi_handle_t handle, const efi_guid_t *protocol, void **protocol_interface); |
49deb455e
|
459 |
/* Call this to create an event */ |
152cade32
|
460 |
efi_status_t efi_create_event(uint32_t type, efi_uintn_t notify_tpl, |
49deb455e
|
461 462 463 |
void (EFIAPI *notify_function) ( struct efi_event *event, void *context), |
b095f3c85
|
464 465 |
void *notify_context, efi_guid_t *group, struct efi_event **event); |
bfc724625
|
466 |
/* Call this to set a timer */ |
b521d29eb
|
467 |
efi_status_t efi_set_timer(struct efi_event *event, enum efi_timer_delay type, |
bfc724625
|
468 |
uint64_t trigger_time); |
91be9a77b
|
469 |
/* Call this to signal an event */ |
7eaa900e5
|
470 |
void efi_signal_event(struct efi_event *event); |
50149ea37
|
471 |
|
2a92080d8
|
472 473 474 475 476 477 |
/* open file system: */ struct efi_simple_file_system_protocol *efi_simple_file_system( struct blk_desc *desc, int part, struct efi_device_path *dp); /* open file from device-path: */ struct efi_file_handle *efi_file_from_path(struct efi_device_path *fp); |
c3772ca1e
|
478 479 480 481 482 483 484 485 486 487 |
/** * efi_size_in_pages() - convert size in bytes to size in pages * * This macro returns the number of EFI memory pages required to hold 'size' * bytes. * * @size: size in bytes * Return: size in pages */ #define efi_size_in_pages(size) ((size + EFI_PAGE_MASK) >> EFI_PAGE_SHIFT) |
5d00995c3
|
488 489 490 |
/* Generic EFI memory allocator, call this to get memory */ void *efi_alloc(uint64_t len, int memory_type); /* More specific EFI memory allocator, called by EFI payloads */ |
f5a2a9389
|
491 |
efi_status_t efi_allocate_pages(int type, int memory_type, efi_uintn_t pages, |
5d00995c3
|
492 |
uint64_t *memory); |
b61d857b2
|
493 |
/* EFI memory free function. */ |
f5a2a9389
|
494 |
efi_status_t efi_free_pages(uint64_t memory, efi_uintn_t pages); |
ead1274b7
|
495 |
/* EFI memory allocator for small allocations */ |
f5a2a9389
|
496 |
efi_status_t efi_allocate_pool(int pool_type, efi_uintn_t size, |
ead1274b7
|
497 |
void **buffer); |
42417bc84
|
498 499 |
/* EFI pool memory free function. */ efi_status_t efi_free_pool(void *buffer); |
5d00995c3
|
500 |
/* Returns the EFI memory map */ |
f5a2a9389
|
501 |
efi_status_t efi_get_memory_map(efi_uintn_t *memory_map_size, |
5d00995c3
|
502 |
struct efi_mem_desc *memory_map, |
f5a2a9389
|
503 504 |
efi_uintn_t *map_key, efi_uintn_t *descriptor_size, |
5d00995c3
|
505 506 |
uint32_t *descriptor_version); /* Adds a range into the EFI memory map */ |
b225c92fd
|
507 508 |
efi_status_t efi_add_memory_map(uint64_t start, uint64_t pages, int memory_type, bool overlap_only_ram); |
b5b9eff26
|
509 510 511 |
/* Adds a conventional range into the EFI memory map */ efi_status_t efi_add_conventional_memory_map(u64 ram_start, u64 ram_end, u64 ram_top); |
05ef48a24
|
512 |
/* Called by board init to initialize the EFI drivers */ |
038782a27
|
513 |
efi_status_t efi_driver_init(void); |
5d00995c3
|
514 515 |
/* Called by board init to initialize the EFI memory map */ int efi_memory_init(void); |
488bf12d8
|
516 517 |
/* Adds new or overrides configuration table entry to the system table */ efi_status_t efi_install_configuration_table(const efi_guid_t *guid, void *table); |
56d928885
|
518 |
/* Sets up a loaded image */ |
c982874e9
|
519 520 521 522 |
efi_status_t efi_setup_loaded_image(struct efi_device_path *device_path, struct efi_device_path *file_path, struct efi_loaded_image_obj **handle_ptr, struct efi_loaded_image **info_ptr); |
c9a63f44b
|
523 524 |
/* Print information about all loaded images */ void efi_print_image_infos(void *pc); |
5d00995c3
|
525 |
|
51735ae0e
|
526 527 528 529 |
#ifdef CONFIG_EFI_LOADER_BOUNCE_BUFFER extern void *efi_bounce_buffer; #define EFI_LOADER_BOUNCE_BUFFER_SIZE (64 * 1024 * 1024) #endif |
b66c60dde
|
530 531 |
struct efi_device_path *efi_dp_next(const struct efi_device_path *dp); |
ff401d3f8
|
532 533 |
int efi_dp_match(const struct efi_device_path *a, const struct efi_device_path *b); |
b66c60dde
|
534 535 |
struct efi_object *efi_dp_find_obj(struct efi_device_path *dp, struct efi_device_path **rem); |
f6dd3f359
|
536 537 538 539 |
/* get size of the first device path instance excluding end node */ efi_uintn_t efi_dp_instance_size(const struct efi_device_path *dp); /* size of multi-instance device path excluding end node */ efi_uintn_t efi_dp_size(const struct efi_device_path *dp); |
b66c60dde
|
540 541 542 543 544 |
struct efi_device_path *efi_dp_dup(const struct efi_device_path *dp); struct efi_device_path *efi_dp_append(const struct efi_device_path *dp1, const struct efi_device_path *dp2); struct efi_device_path *efi_dp_append_node(const struct efi_device_path *dp, const struct efi_device_path *node); |
211314c10
|
545 546 547 548 |
/* Create a device path node of given type, sub-type, length */ struct efi_device_path *efi_dp_create_device_node(const u8 type, const u8 sub_type, const u16 length); |
3acef5da4
|
549 550 551 552 553 554 555 556 557 |
/* Append device path instance */ struct efi_device_path *efi_dp_append_instance( const struct efi_device_path *dp, const struct efi_device_path *dpi); /* Get next device path instance */ struct efi_device_path *efi_dp_get_next_instance(struct efi_device_path **dp, efi_uintn_t *size); /* Check if a device path contains muliple instances */ bool efi_dp_is_multi_instance(const struct efi_device_path *dp); |
b66c60dde
|
558 |
|
b66c60dde
|
559 |
struct efi_device_path *efi_dp_from_part(struct blk_desc *desc, int part); |
98d48bdf4
|
560 561 |
/* Create a device node for a block device partition. */ struct efi_device_path *efi_dp_part_node(struct blk_desc *desc, int part); |
b66c60dde
|
562 563 564 |
struct efi_device_path *efi_dp_from_file(struct blk_desc *desc, int part, const char *path); struct efi_device_path *efi_dp_from_eth(void); |
bf19273e8
|
565 566 567 |
struct efi_device_path *efi_dp_from_mem(uint32_t mem_type, uint64_t start_address, uint64_t end_address); |
65436f91c
|
568 569 570 |
/* Determine the last device path node that is not the end node. */ const struct efi_device_path *efi_dp_last_node( const struct efi_device_path *dp); |
04298686a
|
571 572 573 |
efi_status_t efi_dp_split_file_path(struct efi_device_path *full_path, struct efi_device_path **device_path, struct efi_device_path **file_path); |
f1589ffb3
|
574 575 576 577 |
efi_status_t efi_dp_from_name(const char *dev, const char *devnr, const char *path, struct efi_device_path **device, struct efi_device_path **file); |
b66c60dde
|
578 579 580 581 |
#define EFI_DP_TYPE(_dp, _type, _subtype) \ (((_dp)->type == DEVICE_PATH_TYPE_##_type) && \ ((_dp)->sub_type == DEVICE_PATH_SUB_TYPE_##_subtype)) |
50149ea37
|
582 583 584 585 |
/* * Use these to indicate that your code / data should go into the EFI runtime * section and thus still be available when the OS is running */ |
7e21fbca2
|
586 587 |
#define __efi_runtime_data __attribute__ ((section (".data.efi_runtime"))) #define __efi_runtime __attribute__ ((section (".text.efi_runtime"))) |
bee91169f
|
588 |
|
e771b4b39
|
589 590 |
/* Indicate supported runtime services */ efi_status_t efi_init_runtime_supported(void); |
a39f39cdd
|
591 592 |
/* Update CRC32 in table header */ void __efi_runtime efi_update_table_header_crc32(struct efi_table_hdr *table); |
80a4800ee
|
593 594 |
/* Call this with mmio_ptr as the _pointer_ to a pointer to an MMIO region * to make it available at runtime */ |
22c793e6a
|
595 |
efi_status_t efi_add_runtime_mmio(void *mmio_ptr, u64 len); |
80a4800ee
|
596 597 |
/* Boards may provide the functions below to implement RTS functionality */ |
3c63db9ca
|
598 |
void __efi_runtime EFIAPI efi_reset_system( |
80a4800ee
|
599 600 601 |
enum efi_reset_type reset_type, efi_status_t reset_status, unsigned long data_size, void *reset_data); |
22c793e6a
|
602 603 604 |
/* Architecture specific initialization of the EFI subsystem */ efi_status_t efi_reset_system_init(void); |
80a4800ee
|
605 |
|
3c63db9ca
|
606 |
efi_status_t __efi_runtime EFIAPI efi_get_time( |
80a4800ee
|
607 608 |
struct efi_time *time, struct efi_time_cap *capabilities); |
80a4800ee
|
609 |
|
656f17106
|
610 |
efi_status_t __efi_runtime EFIAPI efi_set_time(struct efi_time *time); |
623b3a579
|
611 612 613 614 615 616 617 618 |
#ifdef CONFIG_CMD_BOOTEFI_SELFTEST /* * Entry point for the tests of the EFI API. * It is called by 'bootefi selftest' */ efi_status_t EFIAPI efi_selftest(efi_handle_t image_handle, struct efi_system_table *systab); #endif |
0bda81bfd
|
619 620 621 |
efi_status_t EFIAPI efi_get_variable(u16 *variable_name, const efi_guid_t *vendor, u32 *attributes, efi_uintn_t *data_size, void *data); |
45c66f9cd
|
622 623 |
efi_status_t EFIAPI efi_get_next_variable_name(efi_uintn_t *variable_name_size, u16 *variable_name, |
7a4e717b9
|
624 |
efi_guid_t *vendor); |
0bda81bfd
|
625 626 |
efi_status_t EFIAPI efi_set_variable(u16 *variable_name, const efi_guid_t *vendor, u32 attributes, |
452257a34
|
627 |
efi_uintn_t data_size, const void *data); |
ad644e7c1
|
628 |
|
ce43528d6
|
629 630 631 632 |
efi_status_t EFIAPI efi_query_variable_info( u32 attributes, u64 *maximum_variable_storage_size, u64 *remaining_variable_storage_size, u64 *maximum_variable_size); |
1a82b3413
|
633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 |
/* * See section 3.1.3 in the v2.7 UEFI spec for more details on * the layout of EFI_LOAD_OPTION. In short it is: * * typedef struct _EFI_LOAD_OPTION { * UINT32 Attributes; * UINT16 FilePathListLength; * // CHAR16 Description[]; <-- variable length, NULL terminated * // EFI_DEVICE_PATH_PROTOCOL FilePathList[]; * <-- FilePathListLength bytes * // UINT8 OptionalData[]; * } EFI_LOAD_OPTION; */ struct efi_load_option { u32 attributes; u16 file_path_length; u16 *label; struct efi_device_path *file_path; |
39a1ff8ce
|
651 |
const u8 *optional_data; |
1a82b3413
|
652 653 654 655 |
}; void efi_deserialize_load_option(struct efi_load_option *lo, u8 *data); unsigned long efi_serialize_load_option(struct efi_load_option *lo, u8 **data); |
6b95b38c4
|
656 |
efi_status_t efi_bootmgr_load(efi_handle_t *handle); |
9975fe96b
|
657 |
|
9b5e6396b
|
658 |
#else /* CONFIG_IS_ENABLED(EFI_LOADER) */ |
bee91169f
|
659 |
|
50149ea37
|
660 |
/* Without CONFIG_EFI_LOADER we don't have a runtime section, stub it out */ |
3c63db9ca
|
661 662 |
#define __efi_runtime_data #define __efi_runtime |
22c793e6a
|
663 664 665 666 |
static inline efi_status_t efi_add_runtime_mmio(void *mmio_ptr, u64 len) { return EFI_SUCCESS; } |
50149ea37
|
667 |
|
bee91169f
|
668 669 |
/* No loader configured, stub out EFI_ENTRY */ static inline void efi_restore_gd(void) { } |
c07ad7c03
|
670 671 |
static inline void efi_set_bootdev(const char *dev, const char *devnr, const char *path) { } |
0efe1bcf5
|
672 |
static inline void efi_net_set_dhcp_ack(void *pkt, int len) { } |
c9a63f44b
|
673 |
static inline void efi_print_image_infos(void *pc) { } |
bee91169f
|
674 |
|
9b5e6396b
|
675 |
#endif /* CONFIG_IS_ENABLED(EFI_LOADER) */ |
cd9e18dee
|
676 677 |
#endif /* _EFI_LOADER_H */ |