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