]> git.ipfire.org Git - thirdparty/u-boot.git/blame_incremental - include/efi_loader.h
Merge tag 'efi-2025-07-rc6' of https://source.denx.de/u-boot/custodians/u-boot-efi
[thirdparty/u-boot.git] / include / efi_loader.h
... / ...
CommitLineData
1/* SPDX-License-Identifier: GPL-2.0+ */
2/*
3 * EFI application loader
4 *
5 * Copyright (c) 2016 Alexander Graf
6 */
7
8#ifndef _EFI_LOADER_H
9#define _EFI_LOADER_H 1
10
11#include <blk.h>
12#include <efi_device_path.h>
13#include <event.h>
14#include <log.h>
15#include <part_efi.h>
16#include <efi_api.h>
17#include <image.h>
18#include <pe.h>
19#include <setjmp.h>
20#include <linux/list.h>
21#include <linux/sizes.h>
22#include <linux/oid_registry.h>
23
24struct blk_desc;
25struct bootflow;
26
27#if CONFIG_IS_ENABLED(EFI_LOADER)
28
29/**
30 * __efi_runtime_data - declares a non-const variable for EFI runtime section
31 *
32 * This macro indicates that a variable is non-const and should go into the
33 * EFI runtime section, and thus still be available when the OS is running.
34 *
35 * Only use on variables not declared const.
36 *
37 * Example:
38 *
39 * ::
40 *
41 * static __efi_runtime_data my_computed_table[256];
42 */
43#define __efi_runtime_data __section(".data.efi_runtime")
44
45/**
46 * __efi_runtime_rodata - declares a read-only variable for EFI runtime section
47 *
48 * This macro indicates that a variable is read-only (const) and should go into
49 * the EFI runtime section, and thus still be available when the OS is running.
50 *
51 * Only use on variables also declared const.
52 *
53 * Example:
54 *
55 * ::
56 *
57 * static const __efi_runtime_rodata my_const_table[] = { 1, 2, 3 };
58 */
59#define __efi_runtime_rodata __section(".rodata.efi_runtime")
60
61/**
62 * __efi_runtime - declares a function for EFI runtime section
63 *
64 * This macro indicates that a function should go into the EFI runtime section,
65 * and thus still be available when the OS is running.
66 *
67 * Example:
68 *
69 * ::
70 *
71 * static __efi_runtime compute_my_table(void);
72 */
73#define __efi_runtime __section(".text.efi_runtime")
74
75/*
76 * Call this with mmio_ptr as the _pointer_ to a pointer to an MMIO region
77 * to make it available at runtime
78 */
79efi_status_t efi_add_runtime_mmio(void *mmio_ptr, u64 len);
80
81/*
82 * Special case handler for error/abort that just tries to dtrt to get
83 * back to u-boot world
84 */
85void efi_restore_gd(void);
86
87/* Called by networking code to memorize the dhcp ack package */
88void efi_net_set_dhcp_ack(void *pkt, int len);
89/* Print information about all loaded images */
90void efi_print_image_infos(void *pc);
91
92/* Hook at initialization */
93efi_status_t efi_launch_capsules(void);
94
95#else /* CONFIG_IS_ENABLED(EFI_LOADER) */
96
97/* Without CONFIG_EFI_LOADER we don't have a runtime section, stub it out */
98#define __efi_runtime_data
99#define __efi_runtime_rodata
100#define __efi_runtime
101static inline efi_status_t efi_add_runtime_mmio(void *mmio_ptr, u64 len)
102{
103 return EFI_SUCCESS;
104}
105
106/* No loader configured, stub out EFI_ENTRY */
107static inline void efi_restore_gd(void) { }
108static inline void efi_net_set_dhcp_ack(void *pkt, int len) { }
109static inline void efi_print_image_infos(void *pc) { }
110static inline efi_status_t efi_launch_capsules(void)
111{
112 return EFI_SUCCESS;
113}
114
115#endif /* CONFIG_IS_ENABLED(EFI_LOADER) */
116
117#if CONFIG_IS_ENABLED(EFI_BINARY_EXEC)
118/* Call this to unset the current device name */
119void efi_clear_bootdev(void);
120/* Call this to set the current device name */
121void efi_set_bootdev(const char *dev, const char *devnr, const char *path,
122 void *buffer, size_t buffer_size);
123#else
124static inline void efi_clear_bootdev(void) { }
125
126static inline void efi_set_bootdev(const char *dev, const char *devnr,
127 const char *path, void *buffer,
128 size_t buffer_size) { }
129#endif
130
131#if CONFIG_IS_ENABLED(NETDEVICES) && CONFIG_IS_ENABLED(EFI_LOADER)
132/* Call this to update the current device path of the efi net device */
133efi_status_t efi_net_new_dp(const char *dev, const char *server, struct udevice *udev);
134/* Call this to get the current device path of the efi net device */
135void efi_net_dp_from_dev(struct efi_device_path **dp, struct udevice *udev, bool cache_only);
136void efi_net_get_addr(struct efi_ipv4_address *ip,
137 struct efi_ipv4_address *mask,
138 struct efi_ipv4_address *gw,
139 struct udevice *dev);
140void efi_net_set_addr(struct efi_ipv4_address *ip,
141 struct efi_ipv4_address *mask,
142 struct efi_ipv4_address *gw,
143 struct udevice *dev);
144#if IS_ENABLED(CONFIG_EFI_HTTP_PROTOCOL)
145efi_status_t efi_net_do_request(u8 *url, enum efi_http_method method, void **buffer,
146 u32 *status_code, ulong *file_size, char *headers_buffer,
147 struct efi_service_binding_protocol *parent);
148#endif
149#define MAX_HTTP_HEADERS_SIZE SZ_64K
150#define MAX_HTTP_HEADERS 100
151#define MAX_HTTP_HEADER_NAME 128
152#define MAX_HTTP_HEADER_VALUE 512
153struct http_header {
154 uchar name[MAX_HTTP_HEADER_NAME];
155 uchar value[MAX_HTTP_HEADER_VALUE];
156};
157
158void efi_net_parse_headers(ulong *num_headers, struct http_header *headers);
159#else
160static inline void efi_net_dp_from_dev(struct efi_device_path **dp,
161 struct udevice *udev, bool cache_only) { }
162static inline void efi_net_get_addr(struct efi_ipv4_address *ip,
163 struct efi_ipv4_address *mask,
164 struct efi_ipv4_address *gw,
165 struct udevice *dev) { }
166static inline void efi_net_set_addr(struct efi_ipv4_address *ip,
167 struct efi_ipv4_address *mask,
168 struct efi_ipv4_address *gw,
169 struct udevice *dev) { }
170#endif
171
172/* Maximum number of configuration tables */
173#define EFI_MAX_CONFIGURATION_TABLES 16
174
175/* GUID used by the root node */
176#define U_BOOT_GUID \
177 EFI_GUID(0xe61d73b9, 0xa384, 0x4acc, \
178 0xae, 0xab, 0x82, 0xe8, 0x28, 0xf3, 0x62, 0x8b)
179/* GUID used as root for blkmap devices */
180#define U_BOOT_BLKMAP_DEV_GUID \
181 EFI_GUID(0x4cad859d, 0xd644, 0x42ff, \
182 0x87, 0x0b, 0xc0, 0x2e, 0xac, 0x05, 0x58, 0x63)
183/* GUID used as host device on sandbox */
184#define U_BOOT_HOST_DEV_GUID \
185 EFI_GUID(0xbbe4e671, 0x5773, 0x4ea1, \
186 0x9a, 0xab, 0x3a, 0x7d, 0xbf, 0x40, 0xc4, 0x82)
187/* GUID used as root for virtio devices */
188#define U_BOOT_VIRTIO_DEV_GUID \
189 EFI_GUID(0x63293792, 0xadf5, 0x9325, \
190 0xb9, 0x9f, 0x4e, 0x0e, 0x45, 0x5c, 0x1b, 0x1e)
191
192/* GUID for the auto generated boot menu entry */
193#define EFICONFIG_AUTO_GENERATED_ENTRY_GUID \
194 EFI_GUID(0x8108ac4e, 0x9f11, 0x4d59, \
195 0x85, 0x0e, 0xe2, 0x1a, 0x52, 0x2c, 0x59, 0xb2)
196#define U_BOOT_EFI_RT_VAR_FILE_GUID \
197 EFI_GUID(0xb2ac5fc9, 0x92b7, 0x4acd, \
198 0xae, 0xac, 0x11, 0xe8, 0x18, 0xc3, 0x13, 0x0c)
199
200/* Use internal device tree when starting UEFI application */
201#define EFI_FDT_USE_INTERNAL NULL
202
203/* Root node */
204extern efi_handle_t efi_root;
205
206/* Set to EFI_SUCCESS when initialized */
207extern efi_status_t efi_obj_list_initialized;
208
209/* Flag used by the selftest to avoid detaching devices in ExitBootServices() */
210extern bool efi_st_keep_devices;
211
212/* EFI system partition */
213extern struct efi_system_partition {
214 enum uclass_id uclass_id;
215 int devnum;
216 u8 part;
217} efi_system_partition;
218
219int __efi_entry_check(void);
220int __efi_exit_check(void);
221const char *__efi_nesting(void);
222const char *__efi_nesting_inc(void);
223const char *__efi_nesting_dec(void);
224
225/*
226 * Enter the u-boot world from UEFI:
227 */
228#define EFI_ENTRY(format, ...) do { \
229 assert(__efi_entry_check()); \
230 debug("%sEFI: Entry %s(" format ")\n", __efi_nesting_inc(), \
231 __func__, ##__VA_ARGS__); \
232 } while(0)
233
234/*
235 * Exit the u-boot world back to UEFI:
236 */
237#define EFI_EXIT(ret) ({ \
238 typeof(ret) _r = ret; \
239 debug("%sEFI: Exit: %s: %u\n", __efi_nesting_dec(), \
240 __func__, (u32)((uintptr_t) _r & ~EFI_ERROR_MASK)); \
241 assert(__efi_exit_check()); \
242 _r; \
243 })
244
245/*
246 * Call non-void UEFI function from u-boot and retrieve return value:
247 */
248#define EFI_CALL(exp) ({ \
249 debug("%sEFI: Call: %s\n", __efi_nesting_inc(), #exp); \
250 assert(__efi_exit_check()); \
251 typeof(exp) _r = exp; \
252 assert(__efi_entry_check()); \
253 debug("%sEFI: %lu returned by %s\n", __efi_nesting_dec(), \
254 (unsigned long)((uintptr_t)_r & ~EFI_ERROR_MASK), #exp); \
255 _r; \
256})
257
258/**
259 * define EFI_RETURN() - return from EFI_CALL in efi_start_image()
260 *
261 * @ret: status code
262 */
263#define EFI_RETURN(ret) ({ \
264 typeof(ret) _r = ret; \
265 assert(__efi_entry_check()); \
266 debug("%sEFI: %lu returned by started image", __efi_nesting_dec(), \
267 (unsigned long)((uintptr_t)_r & ~EFI_ERROR_MASK)); \
268})
269
270/*
271 * Call void UEFI function from u-boot:
272 */
273#define EFI_CALL_VOID(exp) do { \
274 debug("%sEFI: Call: %s\n", __efi_nesting_inc(), #exp); \
275 assert(__efi_exit_check()); \
276 exp; \
277 assert(__efi_entry_check()); \
278 debug("%sEFI: Return From: %s\n", __efi_nesting_dec(), #exp); \
279 } while(0)
280
281/*
282 * Write an indented message with EFI prefix
283 */
284#define EFI_PRINT(format, ...) ({ \
285 debug("%sEFI: " format, __efi_nesting(), \
286 ##__VA_ARGS__); \
287 })
288
289#ifdef CONFIG_SYS_CACHELINE_SIZE
290#define EFI_CACHELINE_SIZE CONFIG_SYS_CACHELINE_SIZE
291#else
292/* Just use the greatest cache flush alignment requirement I'm aware of */
293#define EFI_CACHELINE_SIZE 128
294#endif
295
296/* max bootmenu title size for volume selection */
297#define BOOTMENU_DEVICE_NAME_MAX 16
298
299/* Key identifying current memory map */
300extern efi_uintn_t efi_memory_map_key;
301
302extern struct efi_runtime_services efi_runtime_services;
303extern struct efi_system_table systab;
304
305extern struct efi_simple_text_output_protocol efi_con_out;
306extern struct efi_simple_text_input_protocol efi_con_in;
307extern struct efi_console_control_protocol efi_console_control;
308extern const struct efi_device_path_to_text_protocol efi_device_path_to_text;
309/* implementation of the EFI_DEVICE_PATH_UTILITIES_PROTOCOL */
310extern const struct efi_device_path_utilities_protocol
311 efi_device_path_utilities;
312/* current version of the EFI_UNICODE_COLLATION_PROTOCOL */
313extern const struct efi_unicode_collation_protocol
314 efi_unicode_collation_protocol2;
315extern const struct efi_hii_config_routing_protocol efi_hii_config_routing;
316extern const struct efi_hii_config_access_protocol efi_hii_config_access;
317extern const struct efi_hii_database_protocol efi_hii_database;
318extern const struct efi_hii_string_protocol efi_hii_string;
319
320uint16_t *efi_dp_str(struct efi_device_path *dp);
321
322/* GUID for the auto generated boot menu entry */
323extern const efi_guid_t efi_guid_bootmenu_auto_generated;
324
325/* GUID of the U-Boot root node */
326extern const efi_guid_t efi_u_boot_guid;
327#ifdef CONFIG_SANDBOX
328/* GUID of U-Boot host device on sandbox */
329extern const efi_guid_t efi_guid_host_dev;
330#endif
331/* GUID of the EFI_BLOCK_IO_PROTOCOL */
332extern const efi_guid_t efi_block_io_guid;
333/* GUID of the EFI_SIMPLE_NETWORK_PROTOCOL */
334extern const efi_guid_t efi_net_guid;
335extern const efi_guid_t efi_global_variable_guid;
336extern const efi_guid_t efi_guid_console_control;
337extern const efi_guid_t efi_guid_device_path;
338/* GUID of the EFI system partition */
339extern const efi_guid_t efi_system_partition_guid;
340/* GUID of the EFI_DRIVER_BINDING_PROTOCOL */
341extern const efi_guid_t efi_guid_driver_binding_protocol;
342/* event group ExitBootServices() invoked */
343extern const efi_guid_t efi_guid_event_group_exit_boot_services;
344/* event group SetVirtualAddressMap() invoked */
345extern const efi_guid_t efi_guid_event_group_virtual_address_change;
346/* event group memory map changed */
347extern const efi_guid_t efi_guid_event_group_memory_map_change;
348/* event group boot manager about to boot */
349extern const efi_guid_t efi_guid_event_group_ready_to_boot;
350/* event group ResetSystem() invoked (before ExitBootServices) */
351extern const efi_guid_t efi_guid_event_group_reset_system;
352/* event group return to efibootmgr */
353extern const efi_guid_t efi_guid_event_group_return_to_efibootmgr;
354/* GUID of the device tree table */
355extern const efi_guid_t efi_guid_fdt;
356extern const efi_guid_t efi_guid_loaded_image;
357extern const efi_guid_t efi_guid_loaded_image_device_path;
358extern const efi_guid_t efi_guid_device_path_to_text_protocol;
359extern const efi_guid_t efi_simple_file_system_protocol_guid;
360extern const efi_guid_t efi_file_info_guid;
361/* GUID for file system information */
362extern const efi_guid_t efi_file_system_info_guid;
363extern const efi_guid_t efi_guid_device_path_utilities_protocol;
364/* GUID of the deprecated Unicode collation protocol */
365extern const efi_guid_t efi_guid_unicode_collation_protocol;
366/* GUIDs of the Load File and Load File2 protocol */
367extern const efi_guid_t efi_guid_load_file_protocol;
368extern const efi_guid_t efi_guid_load_file2_protocol;
369/* GUID of the Unicode collation protocol */
370extern const efi_guid_t efi_guid_unicode_collation_protocol2;
371extern const efi_guid_t efi_guid_hii_config_routing_protocol;
372extern const efi_guid_t efi_guid_hii_config_access_protocol;
373extern const efi_guid_t efi_guid_hii_database_protocol;
374extern const efi_guid_t efi_guid_hii_string_protocol;
375/* GUIDs for authentication */
376extern const efi_guid_t efi_guid_image_security_database;
377extern const efi_guid_t efi_guid_sha256;
378extern const efi_guid_t efi_guid_cert_x509;
379extern const efi_guid_t efi_guid_cert_x509_sha256;
380extern const efi_guid_t efi_guid_cert_x509_sha384;
381extern const efi_guid_t efi_guid_cert_x509_sha512;
382extern const efi_guid_t efi_guid_cert_type_pkcs7;
383
384/* GUID of RNG protocol */
385extern const efi_guid_t efi_guid_rng_protocol;
386/* GUID of capsule update result */
387extern const efi_guid_t efi_guid_capsule_report;
388/* GUID of firmware management protocol */
389extern const efi_guid_t efi_guid_firmware_management_protocol;
390/* GUID for the ESRT */
391extern const efi_guid_t efi_esrt_guid;
392/* GUID of the SMBIOS table */
393extern const efi_guid_t smbios_guid;
394extern const efi_guid_t smbios3_guid;
395/*GUID of console */
396extern const efi_guid_t efi_guid_text_input_protocol;
397extern const efi_guid_t efi_guid_text_output_protocol;
398
399/**
400 * struct efi_open_protocol_info_item - open protocol info item
401 *
402 * When a protocol is opened a open protocol info entry is created.
403 * These are maintained in a list.
404 *
405 * @link: link to the list of open protocol info entries of a protocol
406 * @info: information about the opening of a protocol
407 */
408struct efi_open_protocol_info_item {
409 struct list_head link;
410 struct efi_open_protocol_info_entry info;
411};
412
413/**
414 * struct efi_handler - single protocol interface of a handle
415 *
416 * When the UEFI payload wants to open a protocol on an object to get its
417 * interface (usually a struct with callback functions), this struct maps the
418 * protocol GUID to the respective protocol interface
419 *
420 * @link: link to the list of protocols of a handle
421 * @guid: GUID of the protocol
422 * @protocol_interface: protocol interface
423 * @open_infos: link to the list of open protocol info items
424 */
425struct efi_handler {
426 struct list_head link;
427 const efi_guid_t guid;
428 void *protocol_interface;
429 struct list_head open_infos;
430};
431
432/**
433 * enum efi_object_type - type of EFI object
434 *
435 * In UnloadImage we must be able to identify if the handle relates to a
436 * started image.
437 */
438enum efi_object_type {
439 /** @EFI_OBJECT_TYPE_UNDEFINED: undefined image type */
440 EFI_OBJECT_TYPE_UNDEFINED = 0,
441 /** @EFI_OBJECT_TYPE_U_BOOT_FIRMWARE: U-Boot firmware */
442 EFI_OBJECT_TYPE_U_BOOT_FIRMWARE,
443 /** @EFI_OBJECT_TYPE_LOADED_IMAGE: loaded image (not started) */
444 EFI_OBJECT_TYPE_LOADED_IMAGE,
445 /** @EFI_OBJECT_TYPE_STARTED_IMAGE: started image */
446 EFI_OBJECT_TYPE_STARTED_IMAGE,
447};
448
449/**
450 * struct efi_object - dereferenced EFI handle
451 *
452 * @link: pointers to put the handle into a linked list
453 * @protocols: linked list with the protocol interfaces installed on this
454 * handle
455 * @type: image type if the handle relates to an image
456 * @dev: pointer to the DM device which is associated with this EFI handle
457 *
458 * UEFI offers a flexible and expandable object model. The objects in the UEFI
459 * API are devices, drivers, and loaded images. struct efi_object is our storage
460 * structure for these objects.
461 *
462 * When including this structure into a larger structure always put it first so
463 * that when deleting a handle the whole encompassing structure can be freed.
464 *
465 * A pointer to this structure is referred to as a handle. Typedef efi_handle_t
466 * has been created for such pointers.
467 */
468struct efi_object {
469 /* Every UEFI object is part of a global object list */
470 struct list_head link;
471 /* The list of protocols */
472 struct list_head protocols;
473 enum efi_object_type type;
474 struct udevice *dev;
475};
476
477enum efi_image_auth_status {
478 EFI_IMAGE_AUTH_FAILED = 0,
479 EFI_IMAGE_AUTH_PASSED,
480};
481
482/**
483 * struct efi_loaded_image_obj - handle of a loaded image
484 *
485 * @header: EFI object header
486 * @exit_status: exit status passed to Exit()
487 * @exit_data_size: exit data size passed to Exit()
488 * @exit_data: exit data passed to Exit()
489 * @exit_jmp: long jump buffer for returning from started image
490 * @entry: entry address of the relocated image
491 * @image_type: indicates if the image is an applicition or a driver
492 * @auth_status: indicates if the image is authenticated
493 */
494struct efi_loaded_image_obj {
495 struct efi_object header;
496 efi_status_t *exit_status;
497 efi_uintn_t *exit_data_size;
498 u16 **exit_data;
499 jmp_buf *exit_jmp;
500 EFIAPI efi_status_t (*entry)(efi_handle_t image_handle,
501 struct efi_system_table *st);
502 u16 image_type;
503 enum efi_image_auth_status auth_status;
504};
505
506/**
507 * struct efi_event
508 *
509 * @link: Link to list of all events
510 * @queue_link: Link to the list of queued events
511 * @type: Type of event, see efi_create_event
512 * @notify_tpl: Task priority level of notifications
513 * @notify_function: Function to call when the event is triggered
514 * @notify_context: Data to be passed to the notify function
515 * @group: Event group
516 * @trigger_time: Period of the timer
517 * @trigger_next: Next time to trigger the timer
518 * @trigger_type: Type of timer, see efi_set_timer
519 * @is_signaled: The event occurred. The event is in the signaled state.
520 */
521struct efi_event {
522 struct list_head link;
523 struct list_head queue_link;
524 uint32_t type;
525 efi_uintn_t notify_tpl;
526 void (EFIAPI *notify_function)(struct efi_event *event, void *context);
527 void *notify_context;
528 const efi_guid_t *group;
529 u64 trigger_next;
530 u64 trigger_time;
531 enum efi_timer_delay trigger_type;
532 bool is_signaled;
533};
534
535/* This list contains all UEFI objects we know of */
536extern struct list_head efi_obj_list;
537/* List of all events */
538extern struct list_head efi_events;
539
540/**
541 * struct efi_protocol_notification - handle for notified protocol
542 *
543 * When a protocol interface is installed for which an event was registered with
544 * the RegisterProtocolNotify() service this structure is used to hold the
545 * handle on which the protocol interface was installed.
546 *
547 * @link: link to list of all handles notified for this event
548 * @handle: handle on which the notified protocol interface was installed
549 */
550struct efi_protocol_notification {
551 struct list_head link;
552 efi_handle_t handle;
553};
554
555/**
556 * struct efi_register_notify_event - event registered by
557 * RegisterProtocolNotify()
558 *
559 * The address of this structure serves as registration value.
560 *
561 * @link: link to list of all registered events
562 * @event: registered event. The same event may registered for multiple
563 * GUIDs.
564 * @protocol: protocol for which the event is registered
565 * @handles: linked list of all handles on which the notified protocol was
566 * installed
567 */
568struct efi_register_notify_event {
569 struct list_head link;
570 struct efi_event *event;
571 efi_guid_t protocol;
572 struct list_head handles;
573};
574
575/* called at pre-initialization */
576int efi_init_early(void);
577/* Initialize efi execution environment */
578efi_status_t efi_init_obj_list(void);
579/* Append new boot option in BootOrder variable */
580efi_status_t efi_bootmgr_append_bootorder(u16 index);
581/* Get unused "Boot####" index */
582efi_status_t efi_bootmgr_get_unused_bootoption(u16 *buf,
583 efi_uintn_t buf_size, u32 *index);
584/* Generate the media device boot option */
585efi_status_t efi_bootmgr_update_media_device_boot_option(void);
586/* Delete selected boot option */
587efi_status_t efi_bootmgr_delete_boot_option(u16 boot_index);
588/* Invoke EFI boot manager */
589efi_status_t efi_bootmgr_run(void *fdt);
590/* search the boot option index in BootOrder */
591bool efi_search_bootorder(u16 *bootorder, efi_uintn_t num, u32 target, u32 *index);
592
593/**
594 * efi_setup_console_size() - update the mode table.
595 *
596 * By default the only mode available is 80x25. If the console has at least 50
597 * lines, enable mode 80x50. If we can query the console size and it is neither
598 * 80x25 nor 80x50, set it as an additional mode.
599 */
600void efi_setup_console_size(void);
601
602/**
603 * efi_console_set_ansi() - Set whether ANSI escape-characters should be emitted
604 *
605 * These characters mess up tests which use ut_assert_nextline(). Call this
606 * function to tell efi_loader not to emit these characters when starting up the
607 * terminal
608 *
609 * @allow_ansi: Allow emitting ANSI escape-characters
610 */
611void efi_console_set_ansi(bool allow_ansi);
612
613/* Set up load options from environment variable */
614efi_status_t efi_env_set_load_options(efi_handle_t handle, const char *env_var,
615 u16 **load_options);
616/* Get EFI configuration table */
617void *efi_get_configuration_table(const efi_guid_t *guid);
618/* Install device tree */
619efi_status_t efi_install_fdt(void *fdt);
620/* Install initrd */
621efi_status_t efi_install_initrd(void *initrd, size_t initd_sz);
622/* Execute loaded UEFI image */
623efi_status_t do_bootefi_exec(efi_handle_t handle, void *load_options);
624/* Run loaded UEFI image with given fdt */
625efi_status_t efi_binary_run(void *image, size_t size, void *fdt, void *initrd, size_t initrd_sz);
626
627/**
628 * efi_bootflow_run() - Run a bootflow containing an EFI application
629 *
630 * @bootflow: Bootflow to run
631 * Return: Status code, something went wrong
632 */
633efi_status_t efi_bootflow_run(struct bootflow *bootflow);
634
635/* Initialize variable services */
636efi_status_t efi_init_variables(void);
637/* Notify ExitBootServices() is called */
638void efi_variables_boot_exit_notify(void);
639efi_status_t efi_tcg2_notify_exit_boot_services_failed(void);
640/* Measure efi application invocation */
641efi_status_t efi_tcg2_measure_efi_app_invocation(struct efi_loaded_image_obj *handle);
642/* Measure efi application exit */
643efi_status_t efi_tcg2_measure_efi_app_exit(void);
644/* Measure DTB */
645efi_status_t efi_tcg2_measure_dtb(void *dtb);
646/* Called by bootefi to initialize root node */
647efi_status_t efi_root_node_register(void);
648/* Called by bootefi to initialize runtime */
649efi_status_t efi_initialize_system_table(void);
650/* efi_runtime_detach() - detach unimplemented runtime functions */
651void efi_runtime_detach(void);
652/* efi_convert_pointer() - convert pointer to virtual address */
653efi_status_t EFIAPI efi_convert_pointer(efi_uintn_t debug_disposition,
654 void **address);
655/* Carve out DT reserved memory ranges */
656void efi_carve_out_dt_rsv(void *fdt);
657/* Purge unused kaslr-seed */
658void efi_try_purge_rng_seed(void *fdt);
659/* Called by bootefi to make console interface available */
660efi_status_t efi_console_register(void);
661/* Called by efi_init_obj_list() to proble all block devices */
662efi_status_t efi_disks_register(void);
663/* Called by efi_init_obj_list() to install EFI_RNG_PROTOCOL */
664efi_status_t efi_rng_register(void);
665/* Called by efi_init_obj_list() to install EFI_TCG2_PROTOCOL */
666efi_status_t efi_tcg2_register(void);
667/* Called by efi_init_obj_list() to install RISCV_EFI_BOOT_PROTOCOL */
668efi_status_t efi_riscv_register(void);
669/* Called by efi_init_obj_list() to do initial measurement */
670efi_status_t efi_tcg2_do_initial_measurement(void);
671/* measure the pe-coff image, extend PCR and add Event Log */
672efi_status_t tcg2_measure_pe_image(void *efi, u64 efi_size,
673 struct efi_loaded_image_obj *handle,
674 struct efi_loaded_image *loaded_image_info);
675/* Create handles and protocols for the partitions of a block device */
676int efi_disk_create_partitions(efi_handle_t parent, struct blk_desc *desc,
677 const char *uclass_idname, int diskid,
678 const char *pdevname);
679/* Called by bootefi to make GOP (graphical) interface available */
680efi_status_t efi_gop_register(void);
681/* Called by bootefi to make the network interface available */
682efi_status_t efi_net_register(struct udevice *dev);
683efi_status_t efi_net_do_start(struct udevice *dev);
684/* Called by efi_net_register to make the ip4 config2 protocol available */
685efi_status_t efi_ipconfig_register(const efi_handle_t handle,
686 struct efi_ip4_config2_protocol *ip4config);
687/* Called by efi_net_register to make the http protocol available */
688efi_status_t efi_http_register(const efi_handle_t handle,
689 struct efi_service_binding_protocol *http_service_binding);
690/* Called by bootefi to make the watchdog available */
691efi_status_t efi_watchdog_register(void);
692efi_status_t efi_initrd_register(struct efi_device_path *dp_initrd);
693efi_status_t efi_initrd_deregister(void);
694/* Called by bootefi to make SMBIOS tables available */
695/**
696 * efi_acpi_register() - write out ACPI tables
697 *
698 * Called by bootefi to make ACPI tables available
699 *
700 * Return: 0 if OK, -ENOMEM if no memory is available for the tables
701 */
702efi_status_t efi_acpi_register(void);
703/**
704 * efi_smbios_register() - write out SMBIOS tables
705 *
706 * Called by bootefi to make SMBIOS tables available
707 *
708 * Return: 0 if OK, -ENOMEM if no memory is available for the tables
709 */
710efi_status_t efi_smbios_register(void);
711
712struct efi_simple_file_system_protocol *
713efi_fs_from_path(struct efi_device_path *fp);
714
715/* Called by efi_set_watchdog_timer to reset the timer */
716efi_status_t efi_set_watchdog(unsigned long timeout);
717
718/* Called from places to check whether a timer expired */
719void efi_timer_check(void);
720/* Check if a buffer contains a PE-COFF image */
721efi_status_t efi_check_pe(void *buffer, size_t size, void **nt_header);
722/* PE loader implementation */
723efi_status_t efi_load_pe(struct efi_loaded_image_obj *handle,
724 void *efi, size_t efi_size,
725 struct efi_loaded_image *loaded_image_info);
726/* Called once to store the pristine gd pointer */
727void efi_save_gd(void);
728/* Call this to relocate the runtime section to an address space */
729void efi_runtime_relocate(ulong offset, struct efi_mem_desc *map);
730/* Call this to get image parameters */
731void efi_get_image_parameters(void **img_addr, size_t *img_size);
732/* Add a new object to the object list. */
733void efi_add_handle(efi_handle_t obj);
734/* Create handle */
735efi_status_t efi_create_handle(efi_handle_t *handle);
736/* Delete handle */
737efi_status_t efi_delete_handle(efi_handle_t obj);
738/* Call this to validate a handle and find the EFI object for it */
739struct efi_object *efi_search_obj(const efi_handle_t handle);
740/* Locate device_path handle */
741efi_status_t EFIAPI efi_locate_device_path(const efi_guid_t *protocol,
742 struct efi_device_path **device_path,
743 efi_handle_t *device);
744/* Load image */
745efi_status_t EFIAPI efi_load_image(bool boot_policy,
746 efi_handle_t parent_image,
747 struct efi_device_path *file_path,
748 void *source_buffer,
749 efi_uintn_t source_size,
750 efi_handle_t *image_handle);
751/* Load image from path */
752efi_status_t efi_load_image_from_path(bool boot_policy,
753 struct efi_device_path *file_path,
754 void **buffer, efi_uintn_t *size);
755/* Start image */
756efi_status_t EFIAPI efi_start_image(efi_handle_t image_handle,
757 efi_uintn_t *exit_data_size,
758 u16 **exit_data);
759/* Unload image */
760efi_status_t EFIAPI efi_unload_image(efi_handle_t image_handle);
761/* Find a protocol on a handle */
762efi_status_t efi_search_protocol(const efi_handle_t handle,
763 const efi_guid_t *protocol_guid,
764 struct efi_handler **handler);
765/* Install new protocol on a handle */
766efi_status_t efi_add_protocol(const efi_handle_t handle,
767 const efi_guid_t *protocol,
768 void *protocol_interface);
769/* Uninstall new protocol on a handle */
770efi_status_t efi_uninstall_protocol
771 (efi_handle_t handle, const efi_guid_t *protocol,
772 void *protocol_interface, bool preserve);
773/* Reinstall a protocol on a handle */
774efi_status_t EFIAPI efi_reinstall_protocol_interface(
775 efi_handle_t handle,
776 const efi_guid_t *protocol,
777 void *old_interface, void *new_interface);
778/* Open protocol */
779efi_status_t efi_protocol_open(struct efi_handler *handler,
780 void **protocol_interface, void *agent_handle,
781 void *controller_handle, uint32_t attributes);
782
783/* Install multiple protocol interfaces */
784efi_status_t EFIAPI
785efi_install_multiple_protocol_interfaces(efi_handle_t *handle, ...);
786efi_status_t EFIAPI
787efi_uninstall_multiple_protocol_interfaces(efi_handle_t handle, ...);
788/* Connect and disconnect controller */
789efi_status_t EFIAPI efi_connect_controller(efi_handle_t controller_handle,
790 efi_handle_t *driver_image_handle,
791 struct efi_device_path *remain_device_path,
792 bool recursive);
793efi_status_t EFIAPI efi_disconnect_controller(
794 efi_handle_t controller_handle,
795 efi_handle_t driver_image_handle,
796 efi_handle_t child_handle);
797/* Get handles that support a given protocol */
798efi_status_t EFIAPI efi_locate_handle_buffer(
799 enum efi_locate_search_type search_type,
800 const efi_guid_t *protocol, void *search_key,
801 efi_uintn_t *no_handles, efi_handle_t **buffer);
802/* Close a previously opened protocol interface */
803efi_status_t efi_close_protocol(efi_handle_t handle, const efi_guid_t *protocol,
804 efi_handle_t agent_handle,
805 efi_handle_t controller_handle);
806/* Open a protocol interface */
807efi_status_t EFIAPI efi_handle_protocol(efi_handle_t handle,
808 const efi_guid_t *protocol,
809 void **protocol_interface);
810/* Call this to create an event */
811efi_status_t efi_create_event(uint32_t type, efi_uintn_t notify_tpl,
812 void (EFIAPI *notify_function) (
813 struct efi_event *event,
814 void *context),
815 void *notify_context, const efi_guid_t *group,
816 struct efi_event **event);
817/* Call this to close an event */
818efi_status_t EFIAPI efi_close_event(struct efi_event *event);
819/* Call this to set a timer */
820efi_status_t efi_set_timer(struct efi_event *event, enum efi_timer_delay type,
821 uint64_t trigger_time);
822/* Call this to signal an event */
823void efi_signal_event(struct efi_event *event);
824
825/* return true if the device is removable */
826bool efi_disk_is_removable(efi_handle_t handle);
827
828/**
829 * efi_create_simple_file_system() - create simple file system protocol
830 *
831 * Create a simple file system protocol for a partition.
832 *
833 * @desc: block device descriptor
834 * @part: partition number
835 * @dp: device path
836 * @fsp: simple file system protocol
837 * Return: status code
838 */
839efi_status_t
840efi_create_simple_file_system(struct blk_desc *desc, int part,
841 struct efi_device_path *dp,
842 struct efi_simple_file_system_protocol **fsp);
843
844/* open file from device-path: */
845struct efi_file_handle *efi_file_from_path(struct efi_device_path *fp);
846
847/* Registers a callback function for a notification event. */
848efi_status_t EFIAPI efi_register_protocol_notify(const efi_guid_t *protocol,
849 struct efi_event *event,
850 void **registration);
851efi_status_t efi_file_size(struct efi_file_handle *fh, efi_uintn_t *size);
852
853/* get a device path from a Boot#### option */
854struct efi_device_path *efi_get_dp_from_boot(const efi_guid_t *guid);
855
856/* get len, string (used in u-boot crypto from a guid */
857const char *guid_to_sha_str(const efi_guid_t *guid);
858int algo_to_len(const char *algo);
859
860int efi_link_dev(efi_handle_t handle, struct udevice *dev);
861int efi_unlink_dev(efi_handle_t handle);
862bool efi_varname_is_load_option(u16 *var_name16, int *index);
863efi_status_t efi_next_variable_name(efi_uintn_t *size, u16 **buf,
864 efi_guid_t *guid);
865
866/**
867 * efi_size_in_pages() - convert size in bytes to size in pages
868 *
869 * This macro returns the number of EFI memory pages required to hold 'size'
870 * bytes.
871 *
872 * @size: size in bytes
873 * Return: size in pages
874 */
875#define efi_size_in_pages(size) (((size) + EFI_PAGE_MASK) >> EFI_PAGE_SHIFT)
876/* Allocate boot service data pool memory */
877void *efi_alloc(size_t len);
878/* Allocate pages on the specified alignment */
879void *efi_alloc_aligned_pages(u64 len, int memory_type, size_t align);
880/* More specific EFI memory allocator, called by EFI payloads */
881efi_status_t efi_allocate_pages(enum efi_allocate_type type,
882 enum efi_memory_type memory_type,
883 efi_uintn_t pages, uint64_t *memory);
884/* EFI memory free function. */
885efi_status_t efi_free_pages(uint64_t memory, efi_uintn_t pages);
886/* EFI memory allocator for small allocations */
887efi_status_t efi_allocate_pool(enum efi_memory_type pool_type,
888 efi_uintn_t size, void **buffer);
889/* EFI pool memory free function. */
890efi_status_t efi_free_pool(void *buffer);
891/* Allocate and retrieve EFI memory map */
892efi_status_t efi_get_memory_map_alloc(efi_uintn_t *map_size,
893 struct efi_mem_desc **memory_map);
894/* Returns the EFI memory map */
895efi_status_t efi_get_memory_map(efi_uintn_t *memory_map_size,
896 struct efi_mem_desc *memory_map,
897 efi_uintn_t *map_key,
898 efi_uintn_t *descriptor_size,
899 uint32_t *descriptor_version);
900/* Adds a range into the EFI memory map */
901efi_status_t efi_add_memory_map(u64 start, u64 size, int memory_type);
902
903/**
904 * efi_update_memory_map() - update the memory map by adding/removing pages
905 *
906 * @start: start address, must be a multiple of
907 * EFI_PAGE_SIZE
908 * @pages: number of pages to add
909 * @memory_type: type of memory added
910 * @overlap_conventional: region may only overlap free(conventional)
911 * memory
912 * @remove: remove memory map
913 * Return: status code
914 */
915efi_status_t efi_update_memory_map(u64 start, u64 pages, int memory_type,
916 bool overlap_conventional, bool remove);
917
918/* Called by board init to initialize the EFI drivers */
919efi_status_t efi_driver_init(void);
920/* Called when a block device is added */
921int efi_disk_probe(void *ctx, struct event *event);
922/* Called when a block device is removed */
923int efi_disk_remove(void *ctx, struct event *event);
924/* Called by board init to initialize the EFI memory map */
925int efi_memory_init(void);
926/* Adds new or overrides configuration table entry to the system table */
927efi_status_t efi_install_configuration_table(const efi_guid_t *guid, void *table);
928/* Sets up a loaded image */
929efi_status_t efi_setup_loaded_image(struct efi_device_path *device_path,
930 struct efi_device_path *file_path,
931 struct efi_loaded_image_obj **handle_ptr,
932 struct efi_loaded_image **info_ptr);
933
934#ifdef CONFIG_EFI_LOADER_BOUNCE_BUFFER
935extern void *efi_bounce_buffer;
936#define EFI_LOADER_BOUNCE_BUFFER_SIZE (64 * 1024 * 1024)
937#endif
938
939#define EFI_DP_TYPE(_dp, _type, _subtype) \
940 (((_dp)->type == DEVICE_PATH_TYPE_##_type) && \
941 ((_dp)->sub_type == DEVICE_PATH_SUB_TYPE_##_subtype))
942
943/* Indicate supported runtime services */
944efi_status_t efi_init_runtime_supported(void);
945
946/* Update CRC32 in table header */
947void __efi_runtime efi_update_table_header_crc32(struct efi_table_hdr *table);
948
949/* Boards may provide the functions below to implement RTS functionality */
950
951void __efi_runtime EFIAPI efi_reset_system(
952 enum efi_reset_type reset_type,
953 efi_status_t reset_status,
954 unsigned long data_size, void *reset_data);
955
956/* Architecture specific initialization of the EFI subsystem */
957efi_status_t efi_reset_system_init(void);
958
959efi_status_t __efi_runtime EFIAPI efi_get_time(
960 struct efi_time *time,
961 struct efi_time_cap *capabilities);
962
963efi_status_t __efi_runtime EFIAPI efi_set_time(struct efi_time *time);
964
965/*
966 * Entry point for the tests of the EFI API.
967 * It is called by 'bootefi selftest'
968 */
969efi_status_t EFIAPI efi_selftest(efi_handle_t image_handle,
970 struct efi_system_table *systab);
971
972efi_status_t EFIAPI efi_get_variable(u16 *variable_name,
973 const efi_guid_t *vendor, u32 *attributes,
974 efi_uintn_t *data_size, void *data);
975efi_status_t EFIAPI efi_get_next_variable_name(efi_uintn_t *variable_name_size,
976 u16 *variable_name,
977 efi_guid_t *vendor);
978efi_status_t EFIAPI efi_set_variable(u16 *variable_name,
979 const efi_guid_t *vendor, u32 attributes,
980 efi_uintn_t data_size, const void *data);
981
982efi_status_t EFIAPI efi_query_variable_info(
983 u32 attributes, u64 *maximum_variable_storage_size,
984 u64 *remaining_variable_storage_size,
985 u64 *maximum_variable_size);
986
987void *efi_get_var(const u16 *name, const efi_guid_t *vendor, efi_uintn_t *size);
988
989/*
990 * See section 3.1.3 in the v2.7 UEFI spec for more details on
991 * the layout of EFI_LOAD_OPTION. In short it is:
992 *
993 * typedef struct _EFI_LOAD_OPTION {
994 * UINT32 Attributes;
995 * UINT16 FilePathListLength;
996 * // CHAR16 Description[]; <-- variable length, NULL terminated
997 * // EFI_DEVICE_PATH_PROTOCOL FilePathList[];
998 * <-- FilePathListLength bytes
999 * // UINT8 OptionalData[];
1000 * } EFI_LOAD_OPTION;
1001 */
1002struct efi_load_option {
1003 u32 attributes;
1004 u16 file_path_length;
1005 u16 *label;
1006 struct efi_device_path *file_path;
1007 const u8 *optional_data;
1008};
1009
1010struct efi_device_path *efi_dp_from_lo(struct efi_load_option *lo,
1011 const efi_guid_t *guid);
1012struct efi_device_path *efi_dp_concat(const struct efi_device_path *dp1,
1013 const struct efi_device_path *dp2,
1014 size_t split_end_node);
1015struct efi_device_path *search_gpt_dp_node(struct efi_device_path *device_path);
1016efi_status_t efi_deserialize_load_option(struct efi_load_option *lo, u8 *data,
1017 efi_uintn_t *size);
1018unsigned long efi_serialize_load_option(struct efi_load_option *lo, u8 **data);
1019efi_status_t efi_set_load_options(efi_handle_t handle,
1020 efi_uintn_t load_options_size,
1021 void *load_options);
1022efi_status_t efi_bootmgr_load(efi_handle_t *handle, void **load_options);
1023
1024/**
1025 * struct efi_image_regions - A list of memory regions
1026 *
1027 * @max: Maximum number of regions
1028 * @num: Number of regions
1029 * @reg: array of regions
1030 */
1031struct efi_image_regions {
1032 int max;
1033 int num;
1034 struct image_region reg[];
1035};
1036
1037/**
1038 * struct efi_sig_data - A decoded data of struct efi_signature_data
1039 *
1040 * This structure represents an internal form of signature in
1041 * signature database. A listed list may represent a signature list.
1042 *
1043 * @next: Pointer to next entry
1044 * @owner: Signature owner
1045 * @data: Pointer to signature data
1046 * @size: Size of signature data
1047 */
1048struct efi_sig_data {
1049 struct efi_sig_data *next;
1050 efi_guid_t owner;
1051 void *data;
1052 size_t size;
1053};
1054
1055/**
1056 * struct efi_signature_store - A decoded data of signature database
1057 *
1058 * This structure represents an internal form of signature database.
1059 *
1060 * @next: Pointer to next entry
1061 * @sig_type: Signature type
1062 * @sig_data_list: Pointer to signature list
1063 */
1064struct efi_signature_store {
1065 struct efi_signature_store *next;
1066 efi_guid_t sig_type;
1067 struct efi_sig_data *sig_data_list;
1068};
1069
1070struct x509_certificate;
1071struct pkcs7_message;
1072
1073/**
1074 * struct eficonfig_media_boot_option - boot option for (removable) media device
1075 *
1076 * This structure is used to enumerate possible boot option
1077 *
1078 * @lo: Serialized load option data
1079 * @size: Size of serialized load option data
1080 * @exist: Flag to indicate the load option already exists
1081 * in Non-volatile load option
1082 */
1083struct eficonfig_media_boot_option {
1084 void *lo;
1085 efi_uintn_t size;
1086 bool exist;
1087};
1088
1089bool efi_hash_regions(struct image_region *regs, int count,
1090 void **hash, const char *hash_algo, int *len);
1091bool efi_signature_lookup_digest(struct efi_image_regions *regs,
1092 struct efi_signature_store *db,
1093 bool dbx);
1094bool efi_signature_verify(struct efi_image_regions *regs,
1095 struct pkcs7_message *msg,
1096 struct efi_signature_store *db,
1097 struct efi_signature_store *dbx);
1098static inline bool efi_signature_verify_one(struct efi_image_regions *regs,
1099 struct pkcs7_message *msg,
1100 struct efi_signature_store *db)
1101{
1102 return efi_signature_verify(regs, msg, db, NULL);
1103}
1104bool efi_signature_check_signers(struct pkcs7_message *msg,
1105 struct efi_signature_store *dbx);
1106
1107efi_status_t efi_image_region_add(struct efi_image_regions *regs,
1108 const void *start, const void *end,
1109 int nocheck);
1110
1111void efi_sigstore_free(struct efi_signature_store *sigstore);
1112struct efi_signature_store *efi_build_signature_store(void *sig_list,
1113 efi_uintn_t size);
1114struct efi_signature_store *efi_sigstore_parse_sigdb(u16 *name);
1115
1116bool efi_secure_boot_enabled(void);
1117
1118bool efi_capsule_auth_enabled(void);
1119
1120void *efi_prepare_aligned_image(void *efi, u64 *efi_size);
1121
1122bool efi_image_parse(void *efi, size_t len, struct efi_image_regions **regp,
1123 WIN_CERTIFICATE **auth, size_t *auth_len);
1124
1125struct pkcs7_message *efi_parse_pkcs7_header(const void *buf,
1126 size_t buflen,
1127 u8 **tmpbuf);
1128
1129/* runtime implementation of memcpy() */
1130void efi_memcpy_runtime(void *dest, const void *src, size_t n);
1131
1132/* commonly used helper functions */
1133u16 *efi_create_indexed_name(u16 *buffer, size_t buffer_size, const char *name,
1134 unsigned int index);
1135efi_string_t efi_convert_string(const char *str);
1136
1137extern const struct efi_firmware_management_protocol efi_fmp_fit;
1138extern const struct efi_firmware_management_protocol efi_fmp_raw;
1139
1140/* Capsule update */
1141efi_status_t EFIAPI efi_update_capsule(
1142 struct efi_capsule_header **capsule_header_array,
1143 efi_uintn_t capsule_count,
1144 u64 scatter_gather_list);
1145efi_status_t EFIAPI efi_query_capsule_caps(
1146 struct efi_capsule_header **capsule_header_array,
1147 efi_uintn_t capsule_count,
1148 u64 *maximum_capsule_size,
1149 u32 *reset_type);
1150
1151efi_status_t efi_capsule_authenticate(const void *capsule,
1152 efi_uintn_t capsule_size,
1153 void **image, efi_uintn_t *image_size);
1154
1155#define EFI_CAPSULE_DIR u"\\EFI\\UpdateCapsule\\"
1156
1157/**
1158 * struct efi_fw_image - Information on firmware images updatable through
1159 * capsule update
1160 *
1161 * This structure gives information about the firmware images on the platform
1162 * which can be updated through the capsule update mechanism
1163 *
1164 * @image_type_id: Image GUID. Same value is to be used in the capsule
1165 * @fw_name: Name of the firmware image
1166 * @image_index: Image Index, same as value passed to SetImage FMP
1167 * function
1168 */
1169struct efi_fw_image {
1170 efi_guid_t image_type_id;
1171 u16 *fw_name;
1172 u8 image_index;
1173};
1174
1175/**
1176 * struct efi_capsule_update_info - Information needed for capsule updates
1177 *
1178 * This structure provides information needed for performing firmware
1179 * updates. The structure needs to be initialised per platform, for all
1180 * platforms which enable capsule updates
1181 *
1182 * @dfu_string: String used to populate dfu_alt_info
1183 * @num_images: The number of images array entries
1184 * @images: Pointer to an array of updatable images
1185 */
1186struct efi_capsule_update_info {
1187 const char *dfu_string;
1188 int num_images;
1189 struct efi_fw_image *images;
1190};
1191
1192extern struct efi_capsule_update_info update_info;
1193
1194/**
1195 * Install the ESRT system table.
1196 *
1197 * Return: status code
1198 */
1199efi_status_t efi_esrt_register(void);
1200
1201/**
1202 * efi_ecpt_register() - Install the ECPT system table.
1203 *
1204 * Return: status code
1205 */
1206efi_status_t efi_ecpt_register(void);
1207
1208/**
1209 * efi_esrt_populate() - Populates the ESRT entries from the FMP instances
1210 * present in the system.
1211 * If an ESRT already exists, the old ESRT is replaced in the system table.
1212 * The memory of the old ESRT is deallocated.
1213 *
1214 * Return:
1215 * - EFI_SUCCESS if the ESRT is correctly created
1216 * - error code otherwise.
1217 */
1218efi_status_t efi_esrt_populate(void);
1219efi_status_t efi_load_capsule_drivers(void);
1220
1221efi_status_t platform_get_eventlog(struct udevice *dev, u64 *addr, u32 *sz);
1222
1223efi_status_t efi_locate_handle_buffer_int(enum efi_locate_search_type search_type,
1224 const efi_guid_t *protocol, void *search_key,
1225 efi_uintn_t *no_handles, efi_handle_t **buffer);
1226
1227efi_status_t efi_open_volume_int(struct efi_simple_file_system_protocol *this,
1228 struct efi_file_handle **root);
1229efi_status_t efi_file_open_int(struct efi_file_handle *this,
1230 struct efi_file_handle **new_handle,
1231 u16 *file_name, u64 open_mode,
1232 u64 attributes);
1233efi_status_t efi_file_close_int(struct efi_file_handle *file);
1234efi_status_t efi_file_read_int(struct efi_file_handle *this,
1235 efi_uintn_t *buffer_size, void *buffer);
1236efi_status_t efi_file_setpos_int(struct efi_file_handle *file, u64 pos);
1237
1238typedef efi_status_t (*efi_console_filter_func)(struct efi_input_key *key);
1239efi_status_t efi_console_get_u16_string
1240 (struct efi_simple_text_input_protocol *cin,
1241 u16 *buf, efi_uintn_t count, efi_console_filter_func filer_func,
1242 int row, int col);
1243
1244efi_status_t efi_disk_get_device_name(const efi_handle_t handle, char *buf, int size);
1245
1246/**
1247 * efi_add_known_memory() - add memory types to the EFI memory map
1248 *
1249 * This function is to be used to add different memory types other
1250 * than EFI_CONVENTIONAL_MEMORY to the EFI memory map. The conventional
1251 * memory is handled by the LMB module and gets added to the memory
1252 * map through the LMB module.
1253 *
1254 * This function may be overridden for architectures specific purposes.
1255 */
1256void efi_add_known_memory(void);
1257
1258/**
1259 * efi_map_update_notify() - notify EFI of memory map changes
1260 *
1261 * @addr: start of memory area
1262 * @size: size of memory area
1263 * @op: type of change
1264 * Return: 0 if change could be processed
1265 */
1266#ifdef CONFIG_EFI_LOADER
1267int efi_map_update_notify(phys_addr_t addr, phys_size_t size,
1268 enum lmb_map_op op);
1269#else
1270#define efi_map_update_notify(addr, size, op) (0)
1271#endif
1272
1273/**
1274 * efi_load_option_dp_join() - join device-paths for load option
1275 *
1276 * @dp: in: binary device-path, out: joined device-path
1277 * @dp_size: size of joined device-path
1278 * @initrd_dp: initrd device-path or NULL
1279 * @fdt_dp: device-tree device-path or NULL
1280 * Return: status_code
1281 */
1282efi_status_t efi_load_option_dp_join(struct efi_device_path **dp,
1283 size_t *dp_size,
1284 struct efi_device_path *initrd_dp,
1285 struct efi_device_path *fdt_dp);
1286
1287int efi_get_distro_fdt_name(char *fname, int size, int seq);
1288
1289void efi_load_distro_fdt(efi_handle_t handle, void **fdt, efi_uintn_t *fdt_size);
1290
1291#endif /* _EFI_LOADER_H */