1 /* SPDX-License-Identifier: GPL-2.0 */
3 #ifndef _DRIVERS_FIRMWARE_EFI_EFISTUB_H
4 #define _DRIVERS_FIRMWARE_EFI_EFISTUB_H
6 #include <linux/compiler.h>
8 #include <linux/kernel.h>
9 #include <linux/kern_levels.h>
10 #include <linux/types.h>
14 * __init annotations should not be used in the EFI stub, since the code is
15 * either included in the decompressor (x86, ARM) where they have no effect,
16 * or the whole stub is __init annotated at the section level (arm64), by
17 * renaming the sections, in which case the __init annotation will be
18 * redundant, and will result in section names like .init.init.text, and our
19 * linker script does not expect that.
24 * Allow the platform to override the allocation granularity: this allows
25 * systems that have the capability to run with a larger page size to deal
26 * with the allocations for initrd and fdt more efficiently.
28 #ifndef EFI_ALLOC_ALIGN
29 #define EFI_ALLOC_ALIGN EFI_PAGE_SIZE
32 extern bool efi_nochunk;
33 extern bool efi_nokaslr;
34 extern int efi_loglevel;
35 extern bool efi_novamap;
37 extern const efi_system_table_t *efi_system_table;
39 typedef union efi_dxe_services_table efi_dxe_services_table_t;
40 extern const efi_dxe_services_table_t *efi_dxe_table;
42 efi_status_t __efiapi efi_pe_entry(efi_handle_t handle,
43 efi_system_table_t *sys_table_arg);
45 #ifndef ARCH_HAS_EFISTUB_WRAPPERS
47 #define efi_is_native() (true)
48 #define efi_bs_call(func, ...) efi_system_table->boottime->func(__VA_ARGS__)
49 #define efi_rt_call(func, ...) efi_system_table->runtime->func(__VA_ARGS__)
50 #define efi_dxe_call(func, ...) efi_dxe_table->func(__VA_ARGS__)
51 #define efi_table_attr(inst, attr) (inst->attr)
52 #define efi_call_proto(inst, func, ...) inst->func(inst, ##__VA_ARGS__)
56 #define efi_info(fmt, ...) \
57 efi_printk(KERN_INFO fmt, ##__VA_ARGS__)
58 #define efi_warn(fmt, ...) \
59 efi_printk(KERN_WARNING "WARNING: " fmt, ##__VA_ARGS__)
60 #define efi_err(fmt, ...) \
61 efi_printk(KERN_ERR "ERROR: " fmt, ##__VA_ARGS__)
62 #define efi_debug(fmt, ...) \
63 efi_printk(KERN_DEBUG "DEBUG: " fmt, ##__VA_ARGS__)
65 #define efi_printk_once(fmt, ...) \
67 static bool __print_once; \
68 bool __ret_print_once = !__print_once; \
70 if (!__print_once) { \
71 __print_once = true; \
72 efi_printk(fmt, ##__VA_ARGS__); \
77 #define efi_info_once(fmt, ...) \
78 efi_printk_once(KERN_INFO fmt, ##__VA_ARGS__)
79 #define efi_warn_once(fmt, ...) \
80 efi_printk_once(KERN_WARNING "WARNING: " fmt, ##__VA_ARGS__)
81 #define efi_err_once(fmt, ...) \
82 efi_printk_once(KERN_ERR "ERROR: " fmt, ##__VA_ARGS__)
83 #define efi_debug_once(fmt, ...) \
84 efi_printk_once(KERN_DEBUG "DEBUG: " fmt, ##__VA_ARGS__)
86 /* Helper macros for the usual case of using simple C variables: */
87 #ifndef fdt_setprop_inplace_var
88 #define fdt_setprop_inplace_var(fdt, node_offset, name, var) \
89 fdt_setprop_inplace((fdt), (node_offset), (name), &(var), sizeof(var))
92 #ifndef fdt_setprop_var
93 #define fdt_setprop_var(fdt, node_offset, name, var) \
94 fdt_setprop((fdt), (node_offset), (name), &(var), sizeof(var))
97 #define get_efi_var(name, vendor, ...) \
98 efi_rt_call(get_variable, (efi_char16_t *)(name), \
99 (efi_guid_t *)(vendor), __VA_ARGS__)
101 #define set_efi_var(name, vendor, ...) \
102 efi_rt_call(set_variable, (efi_char16_t *)(name), \
103 (efi_guid_t *)(vendor), __VA_ARGS__)
105 #define efi_get_handle_at(array, idx) \
106 (efi_is_native() ? (array)[idx] \
107 : (efi_handle_t)(unsigned long)((u32 *)(array))[idx])
109 #define efi_get_handle_num(size) \
110 ((size) / (efi_is_native() ? sizeof(efi_handle_t) : sizeof(u32)))
112 #define for_each_efi_handle(handle, array, size, i) \
114 i < efi_get_handle_num(size) && \
115 ((handle = efi_get_handle_at((array), i)) || true); \
119 void efi_set_u64_split(u64 data, u32 *lo, u32 *hi)
121 *lo = lower_32_bits(data);
122 *hi = upper_32_bits(data);
126 * Allocation types for calls to boottime->allocate_pages.
128 #define EFI_ALLOCATE_ANY_PAGES 0
129 #define EFI_ALLOCATE_MAX_ADDRESS 1
130 #define EFI_ALLOCATE_ADDRESS 2
131 #define EFI_MAX_ALLOCATE_TYPE 3
134 * The type of search to perform when calling boottime->locate_handle
136 #define EFI_LOCATE_ALL_HANDLES 0
137 #define EFI_LOCATE_BY_REGISTER_NOTIFY 1
138 #define EFI_LOCATE_BY_PROTOCOL 2
141 * boottime->stall takes the time period in microseconds
143 #define EFI_USEC_PER_SEC 1000000
146 * boottime->set_timer takes the time in 100ns units
148 #define EFI_100NSEC_PER_USEC ((u64)10)
151 * An efi_boot_memmap is used by efi_get_memory_map() to return the
152 * EFI memory map in a dynamically allocated buffer.
154 * The buffer allocated for the EFI memory map includes extra room for
155 * a minimum of EFI_MMAP_NR_SLACK_SLOTS additional EFI memory descriptors.
156 * This facilitates the reuse of the EFI memory map buffer when a second
157 * call to ExitBootServices() is needed because of intervening changes to
158 * the EFI memory map. Other related structures, e.g. x86 e820ext, need
159 * to factor in this headroom requirement as well.
161 #define EFI_MMAP_NR_SLACK_SLOTS 8
163 struct efi_boot_memmap {
164 efi_memory_desc_t **map;
165 unsigned long *map_size;
166 unsigned long *desc_size;
168 unsigned long *key_ptr;
169 unsigned long *buff_size;
172 typedef struct efi_generic_dev_path efi_device_path_protocol_t;
174 typedef void *efi_event_t;
175 /* Note that notifications won't work in mixed mode */
176 typedef void (__efiapi *efi_event_notify_t)(efi_event_t, void *);
178 #define EFI_EVT_TIMER 0x80000000U
179 #define EFI_EVT_RUNTIME 0x40000000U
180 #define EFI_EVT_NOTIFY_WAIT 0x00000100U
181 #define EFI_EVT_NOTIFY_SIGNAL 0x00000200U
184 * efi_set_event_at() - add event to events array
186 * @events: array of UEFI events
187 * @ids: index where to put the event in the array
188 * @event: event to add to the aray
190 * boottime->wait_for_event() takes an array of events as input.
191 * Provide a helper to set it up correctly for mixed mode.
194 void efi_set_event_at(efi_event_t *events, size_t idx, efi_event_t event)
199 ((u32 *)events)[idx] = (u32)(unsigned long)event;
202 #define EFI_TPL_APPLICATION 4
203 #define EFI_TPL_CALLBACK 8
204 #define EFI_TPL_NOTIFY 16
205 #define EFI_TPL_HIGH_LEVEL 31
214 * EFI Boot Services table
216 union efi_boot_services {
221 efi_status_t (__efiapi *allocate_pages)(int, int, unsigned long,
222 efi_physical_addr_t *);
223 efi_status_t (__efiapi *free_pages)(efi_physical_addr_t,
225 efi_status_t (__efiapi *get_memory_map)(unsigned long *, void *,
227 unsigned long *, u32 *);
228 efi_status_t (__efiapi *allocate_pool)(int, unsigned long,
230 efi_status_t (__efiapi *free_pool)(void *);
231 efi_status_t (__efiapi *create_event)(u32, unsigned long,
232 efi_event_notify_t, void *,
234 efi_status_t (__efiapi *set_timer)(efi_event_t,
235 EFI_TIMER_DELAY, u64);
236 efi_status_t (__efiapi *wait_for_event)(unsigned long,
240 efi_status_t (__efiapi *close_event)(efi_event_t);
242 void *install_protocol_interface;
243 void *reinstall_protocol_interface;
244 void *uninstall_protocol_interface;
245 efi_status_t (__efiapi *handle_protocol)(efi_handle_t,
246 efi_guid_t *, void **);
248 void *register_protocol_notify;
249 efi_status_t (__efiapi *locate_handle)(int, efi_guid_t *,
250 void *, unsigned long *,
252 efi_status_t (__efiapi *locate_device_path)(efi_guid_t *,
253 efi_device_path_protocol_t **,
255 efi_status_t (__efiapi *install_configuration_table)(efi_guid_t *,
259 efi_status_t __noreturn (__efiapi *exit)(efi_handle_t,
264 efi_status_t (__efiapi *exit_boot_services)(efi_handle_t,
266 void *get_next_monotonic_count;
267 efi_status_t (__efiapi *stall)(unsigned long);
268 void *set_watchdog_timer;
269 void *connect_controller;
270 efi_status_t (__efiapi *disconnect_controller)(efi_handle_t,
274 void *close_protocol;
275 void *open_protocol_information;
276 void *protocols_per_handle;
277 void *locate_handle_buffer;
278 efi_status_t (__efiapi *locate_protocol)(efi_guid_t *, void *,
280 void *install_multiple_protocol_interfaces;
281 void *uninstall_multiple_protocol_interfaces;
282 void *calculate_crc32;
285 void *create_event_ex;
302 u32 install_protocol_interface;
303 u32 reinstall_protocol_interface;
304 u32 uninstall_protocol_interface;
307 u32 register_protocol_notify;
309 u32 locate_device_path;
310 u32 install_configuration_table;
315 u32 exit_boot_services;
316 u32 get_next_monotonic_count;
318 u32 set_watchdog_timer;
319 u32 connect_controller;
320 u32 disconnect_controller;
323 u32 open_protocol_information;
324 u32 protocols_per_handle;
325 u32 locate_handle_buffer;
327 u32 install_multiple_protocol_interfaces;
328 u32 uninstall_multiple_protocol_interfaces;
337 EfiGcdMemoryTypeNonExistent,
338 EfiGcdMemoryTypeReserved,
339 EfiGcdMemoryTypeSystemMemory,
340 EfiGcdMemoryTypeMemoryMappedIo,
341 EfiGcdMemoryTypePersistent,
342 EfiGcdMemoryTypeMoreReliable,
343 EfiGcdMemoryTypeMaximum
344 } efi_gcd_memory_type_t;
347 efi_physical_addr_t base_address;
351 efi_gcd_memory_type_t gcd_memory_type;
354 } efi_gcd_memory_space_desc_t;
357 * EFI DXE Services table
359 union efi_dxe_services_table {
362 void *add_memory_space;
363 void *allocate_memory_space;
364 void *free_memory_space;
365 void *remove_memory_space;
366 efi_status_t (__efiapi *get_memory_space_descriptor)(efi_physical_addr_t,
367 efi_gcd_memory_space_desc_t *);
368 efi_status_t (__efiapi *set_memory_space_attributes)(efi_physical_addr_t,
370 void *get_memory_space_map;
372 void *allocate_io_space;
374 void *remove_io_space;
375 void *get_io_space_descriptor;
376 void *get_io_space_map;
380 void *process_firmware_volume;
381 void *set_memory_space_capabilities;
385 u32 add_memory_space;
386 u32 allocate_memory_space;
387 u32 free_memory_space;
388 u32 remove_memory_space;
389 u32 get_memory_space_descriptor;
390 u32 set_memory_space_attributes;
391 u32 get_memory_space_map;
393 u32 allocate_io_space;
396 u32 get_io_space_descriptor;
397 u32 get_io_space_map;
401 u32 process_firmware_volume;
402 u32 set_memory_space_capabilities;
406 typedef union efi_uga_draw_protocol efi_uga_draw_protocol_t;
408 union efi_uga_draw_protocol {
410 efi_status_t (__efiapi *get_mode)(efi_uga_draw_protocol_t *,
411 u32*, u32*, u32*, u32*);
424 efi_char16_t unicode_char;
427 union efi_simple_text_input_protocol {
430 efi_status_t (__efiapi *read_keystroke)(efi_simple_text_input_protocol_t *,
432 efi_event_t wait_for_key;
441 efi_status_t efi_wait_for_key(unsigned long usec, efi_input_key_t *key);
443 union efi_simple_text_output_protocol {
446 efi_status_t (__efiapi *output_string)(efi_simple_text_output_protocol_t *,
457 #define PIXEL_RGB_RESERVED_8BIT_PER_COLOR 0
458 #define PIXEL_BGR_RESERVED_8BIT_PER_COLOR 1
459 #define PIXEL_BIT_MASK 2
460 #define PIXEL_BLT_ONLY 3
461 #define PIXEL_FORMAT_MAX 4
468 } efi_pixel_bitmask_t;
472 u32 horizontal_resolution;
473 u32 vertical_resolution;
475 efi_pixel_bitmask_t pixel_information;
476 u32 pixels_per_scan_line;
477 } efi_graphics_output_mode_info_t;
479 typedef union efi_graphics_output_protocol_mode efi_graphics_output_protocol_mode_t;
481 union efi_graphics_output_protocol_mode {
485 efi_graphics_output_mode_info_t *info;
486 unsigned long size_of_info;
487 efi_physical_addr_t frame_buffer_base;
488 unsigned long frame_buffer_size;
495 u64 frame_buffer_base;
496 u32 frame_buffer_size;
500 typedef union efi_graphics_output_protocol efi_graphics_output_protocol_t;
502 union efi_graphics_output_protocol {
504 efi_status_t (__efiapi *query_mode)(efi_graphics_output_protocol_t *,
505 u32, unsigned long *,
506 efi_graphics_output_mode_info_t **);
507 efi_status_t (__efiapi *set_mode) (efi_graphics_output_protocol_t *, u32);
509 efi_graphics_output_protocol_mode_t *mode;
522 efi_handle_t parent_handle;
523 efi_system_table_t *system_table;
524 efi_handle_t device_handle;
527 u32 load_options_size;
530 __aligned_u64 image_size;
531 unsigned int image_code_type;
532 unsigned int image_data_type;
533 efi_status_t (__efiapi *unload)(efi_handle_t image_handle);
542 u32 load_options_size;
545 __aligned_u64 image_size;
550 } efi_loaded_image_t;
556 efi_time_t create_time;
557 efi_time_t last_access_time;
558 efi_time_t modification_time;
559 __aligned_u64 attribute;
560 efi_char16_t filename[];
563 typedef struct efi_file_protocol efi_file_protocol_t;
565 struct efi_file_protocol {
567 efi_status_t (__efiapi *open) (efi_file_protocol_t *,
568 efi_file_protocol_t **,
569 efi_char16_t *, u64, u64);
570 efi_status_t (__efiapi *close) (efi_file_protocol_t *);
571 efi_status_t (__efiapi *delete) (efi_file_protocol_t *);
572 efi_status_t (__efiapi *read) (efi_file_protocol_t *,
573 unsigned long *, void *);
574 efi_status_t (__efiapi *write) (efi_file_protocol_t *,
575 unsigned long, void *);
576 efi_status_t (__efiapi *get_position)(efi_file_protocol_t *, u64 *);
577 efi_status_t (__efiapi *set_position)(efi_file_protocol_t *, u64);
578 efi_status_t (__efiapi *get_info) (efi_file_protocol_t *,
579 efi_guid_t *, unsigned long *,
581 efi_status_t (__efiapi *set_info) (efi_file_protocol_t *,
582 efi_guid_t *, unsigned long,
584 efi_status_t (__efiapi *flush) (efi_file_protocol_t *);
587 typedef struct efi_simple_file_system_protocol efi_simple_file_system_protocol_t;
589 struct efi_simple_file_system_protocol {
591 int (__efiapi *open_volume)(efi_simple_file_system_protocol_t *,
592 efi_file_protocol_t **);
595 #define EFI_FILE_MODE_READ 0x0000000000000001
596 #define EFI_FILE_MODE_WRITE 0x0000000000000002
597 #define EFI_FILE_MODE_CREATE 0x8000000000000000
604 EfiPciIoWidthFifoUint8,
605 EfiPciIoWidthFifoUint16,
606 EfiPciIoWidthFifoUint32,
607 EfiPciIoWidthFifoUint64,
608 EfiPciIoWidthFillUint8,
609 EfiPciIoWidthFillUint16,
610 EfiPciIoWidthFillUint32,
611 EfiPciIoWidthFillUint64,
613 } EFI_PCI_IO_PROTOCOL_WIDTH;
616 EfiPciIoAttributeOperationGet,
617 EfiPciIoAttributeOperationSet,
618 EfiPciIoAttributeOperationEnable,
619 EfiPciIoAttributeOperationDisable,
620 EfiPciIoAttributeOperationSupported,
621 EfiPciIoAttributeOperationMaximum
622 } EFI_PCI_IO_PROTOCOL_ATTRIBUTE_OPERATION;
627 } efi_pci_io_protocol_access_32_t;
629 typedef union efi_pci_io_protocol efi_pci_io_protocol_t;
632 efi_status_t (__efiapi *efi_pci_io_protocol_cfg_t)(efi_pci_io_protocol_t *,
633 EFI_PCI_IO_PROTOCOL_WIDTH,
641 } efi_pci_io_protocol_access_t;
644 efi_pci_io_protocol_cfg_t read;
645 efi_pci_io_protocol_cfg_t write;
646 } efi_pci_io_protocol_config_access_t;
648 union efi_pci_io_protocol {
652 efi_pci_io_protocol_access_t mem;
653 efi_pci_io_protocol_access_t io;
654 efi_pci_io_protocol_config_access_t pci;
658 void *allocate_buffer;
661 efi_status_t (__efiapi *get_location)(efi_pci_io_protocol_t *,
662 unsigned long *segment_nr,
663 unsigned long *bus_nr,
664 unsigned long *device_nr,
665 unsigned long *func_nr);
667 void *get_bar_attributes;
668 void *set_bar_attributes;
675 efi_pci_io_protocol_access_32_t mem;
676 efi_pci_io_protocol_access_32_t io;
677 efi_pci_io_protocol_access_32_t pci;
686 u32 get_bar_attributes;
687 u32 set_bar_attributes;
693 #define EFI_PCI_IO_ATTRIBUTE_ISA_MOTHERBOARD_IO 0x0001
694 #define EFI_PCI_IO_ATTRIBUTE_ISA_IO 0x0002
695 #define EFI_PCI_IO_ATTRIBUTE_VGA_PALETTE_IO 0x0004
696 #define EFI_PCI_IO_ATTRIBUTE_VGA_MEMORY 0x0008
697 #define EFI_PCI_IO_ATTRIBUTE_VGA_IO 0x0010
698 #define EFI_PCI_IO_ATTRIBUTE_IDE_PRIMARY_IO 0x0020
699 #define EFI_PCI_IO_ATTRIBUTE_IDE_SECONDARY_IO 0x0040
700 #define EFI_PCI_IO_ATTRIBUTE_MEMORY_WRITE_COMBINE 0x0080
701 #define EFI_PCI_IO_ATTRIBUTE_IO 0x0100
702 #define EFI_PCI_IO_ATTRIBUTE_MEMORY 0x0200
703 #define EFI_PCI_IO_ATTRIBUTE_BUS_MASTER 0x0400
704 #define EFI_PCI_IO_ATTRIBUTE_MEMORY_CACHED 0x0800
705 #define EFI_PCI_IO_ATTRIBUTE_MEMORY_DISABLE 0x1000
706 #define EFI_PCI_IO_ATTRIBUTE_EMBEDDED_DEVICE 0x2000
707 #define EFI_PCI_IO_ATTRIBUTE_EMBEDDED_ROM 0x4000
708 #define EFI_PCI_IO_ATTRIBUTE_DUAL_ADDRESS_CYCLE 0x8000
709 #define EFI_PCI_IO_ATTRIBUTE_ISA_IO_16 0x10000
710 #define EFI_PCI_IO_ATTRIBUTE_VGA_PALETTE_IO_16 0x20000
711 #define EFI_PCI_IO_ATTRIBUTE_VGA_IO_16 0x40000
715 typedef union apple_properties_protocol apple_properties_protocol_t;
717 union apple_properties_protocol {
719 unsigned long version;
720 efi_status_t (__efiapi *get)(apple_properties_protocol_t *,
721 struct efi_dev_path *,
722 efi_char16_t *, void *, u32 *);
723 efi_status_t (__efiapi *set)(apple_properties_protocol_t *,
724 struct efi_dev_path *,
725 efi_char16_t *, void *, u32);
726 efi_status_t (__efiapi *del)(apple_properties_protocol_t *,
727 struct efi_dev_path *,
729 efi_status_t (__efiapi *get_all)(apple_properties_protocol_t *,
730 void *buffer, u32 *);
741 typedef u32 efi_tcg2_event_log_format;
743 #define INITRD_EVENT_TAG_ID 0x8F3B22ECU
744 #define EV_EVENT_TAG 0x00000006U
745 #define EFI_TCG2_EVENT_HEADER_VERSION 0x1
747 struct efi_tcg2_event {
754 } __packed event_header;
755 /* u8[] event follows here */
758 struct efi_tcg2_tagged_event {
760 u32 tagged_event_data_size;
761 /* u8 tagged event data follows here */
764 typedef struct efi_tcg2_event efi_tcg2_event_t;
765 typedef struct efi_tcg2_tagged_event efi_tcg2_tagged_event_t;
766 typedef union efi_tcg2_protocol efi_tcg2_protocol_t;
768 union efi_tcg2_protocol {
770 void *get_capability;
771 efi_status_t (__efiapi *get_event_log)(efi_tcg2_protocol_t *,
772 efi_tcg2_event_log_format,
773 efi_physical_addr_t *,
774 efi_physical_addr_t *,
776 efi_status_t (__efiapi *hash_log_extend_event)(efi_tcg2_protocol_t *,
780 const efi_tcg2_event_t *);
781 void *submit_command;
782 void *get_active_pcr_banks;
783 void *set_active_pcr_banks;
784 void *get_result_of_set_active_pcr_banks;
789 u32 hash_log_extend_event;
791 u32 get_active_pcr_banks;
792 u32 set_active_pcr_banks;
793 u32 get_result_of_set_active_pcr_banks;
797 struct riscv_efi_boot_protocol {
800 efi_status_t (__efiapi *get_boot_hartid)(struct riscv_efi_boot_protocol *,
801 unsigned long *boot_hartid);
804 typedef union efi_load_file_protocol efi_load_file_protocol_t;
805 typedef union efi_load_file_protocol efi_load_file2_protocol_t;
807 union efi_load_file_protocol {
809 efi_status_t (__efiapi *load_file)(efi_load_file_protocol_t *,
810 efi_device_path_protocol_t *,
811 bool, unsigned long *, void *);
820 u16 file_path_list_length;
822 // efi_char16_t description[];
823 // efi_device_path_protocol_t file_path_list[];
824 // u8 optional_data[];
825 } __packed efi_load_option_t;
827 #define EFI_LOAD_OPTION_ACTIVE 0x0001U
828 #define EFI_LOAD_OPTION_FORCE_RECONNECT 0x0002U
829 #define EFI_LOAD_OPTION_HIDDEN 0x0008U
830 #define EFI_LOAD_OPTION_CATEGORY 0x1f00U
831 #define EFI_LOAD_OPTION_CATEGORY_BOOT 0x0000U
832 #define EFI_LOAD_OPTION_CATEGORY_APP 0x0100U
834 #define EFI_LOAD_OPTION_BOOT_MASK \
835 (EFI_LOAD_OPTION_ACTIVE|EFI_LOAD_OPTION_HIDDEN|EFI_LOAD_OPTION_CATEGORY)
836 #define EFI_LOAD_OPTION_MASK (EFI_LOAD_OPTION_FORCE_RECONNECT|EFI_LOAD_OPTION_BOOT_MASK)
840 u16 file_path_list_length;
841 const efi_char16_t *description;
842 const efi_device_path_protocol_t *file_path_list;
843 size_t optional_data_size;
844 const void *optional_data;
845 } efi_load_option_unpacked_t;
847 void efi_pci_disable_bridge_busmaster(void);
849 typedef efi_status_t (*efi_exit_boot_map_processing)(
850 struct efi_boot_memmap *map,
853 efi_status_t efi_exit_boot_services(void *handle,
854 struct efi_boot_memmap *map,
856 efi_exit_boot_map_processing priv_func);
858 efi_status_t allocate_new_fdt_and_exit_boot(void *handle,
859 unsigned long *new_fdt_addr,
860 u64 initrd_addr, u64 initrd_size,
862 unsigned long fdt_addr,
863 unsigned long fdt_size);
865 void *get_fdt(unsigned long *fdt_size);
867 void efi_get_virtmap(efi_memory_desc_t *memory_map, unsigned long map_size,
868 unsigned long desc_size, efi_memory_desc_t *runtime_map,
871 efi_status_t efi_get_random_bytes(unsigned long size, u8 *out);
873 efi_status_t efi_random_alloc(unsigned long size, unsigned long align,
874 unsigned long *addr, unsigned long random_seed);
876 efi_status_t check_platform_features(void);
878 void *get_efi_config_table(efi_guid_t guid);
880 /* NOTE: These functions do not print a trailing newline after the string */
881 void efi_char16_puts(efi_char16_t *);
882 void efi_puts(const char *str);
884 __printf(1, 2) int efi_printk(char const *fmt, ...);
886 void efi_free(unsigned long size, unsigned long addr);
888 void efi_apply_loadoptions_quirk(const void **load_options, int *load_options_size);
890 char *efi_convert_cmdline(efi_loaded_image_t *image, int *cmd_line_len);
892 efi_status_t efi_get_memory_map(struct efi_boot_memmap *map);
894 efi_status_t efi_allocate_pages(unsigned long size, unsigned long *addr,
897 efi_status_t efi_allocate_pages_aligned(unsigned long size, unsigned long *addr,
898 unsigned long max, unsigned long align);
900 efi_status_t efi_low_alloc_above(unsigned long size, unsigned long align,
901 unsigned long *addr, unsigned long min);
903 efi_status_t efi_relocate_kernel(unsigned long *image_addr,
904 unsigned long image_size,
905 unsigned long alloc_size,
906 unsigned long preferred_addr,
907 unsigned long alignment,
908 unsigned long min_addr);
910 efi_status_t efi_parse_options(char const *cmdline);
912 void efi_parse_option_graphics(char *option);
914 efi_status_t efi_setup_gop(struct screen_info *si, efi_guid_t *proto,
917 efi_status_t handle_cmdline_files(efi_loaded_image_t *image,
918 const efi_char16_t *optstr,
920 unsigned long soft_limit,
921 unsigned long hard_limit,
922 unsigned long *load_addr,
923 unsigned long *load_size);
926 static inline efi_status_t efi_load_dtb(efi_loaded_image_t *image,
927 unsigned long *load_addr,
928 unsigned long *load_size)
930 return handle_cmdline_files(image, L"dtb=", sizeof(L"dtb=") - 2,
931 ULONG_MAX, ULONG_MAX, load_addr, load_size);
934 efi_status_t efi_load_initrd(efi_loaded_image_t *image,
935 unsigned long *load_addr,
936 unsigned long *load_size,
937 unsigned long soft_limit,
938 unsigned long hard_limit);
940 * This function handles the architcture specific differences between arm and
941 * arm64 regarding where the kernel image must be loaded and any memory that
942 * must be reserved. On failure it is required to free all
943 * all allocations it has made.
945 efi_status_t handle_kernel_image(unsigned long *image_addr,
946 unsigned long *image_size,
947 unsigned long *reserve_addr,
948 unsigned long *reserve_size,
949 efi_loaded_image_t *image,
950 efi_handle_t image_handle);
952 asmlinkage void __noreturn efi_enter_kernel(unsigned long entrypoint,
953 unsigned long fdt_addr,
954 unsigned long fdt_size);
956 void efi_handle_post_ebs_state(void);
958 enum efi_secureboot_mode efi_get_secureboot(void);
960 #ifdef CONFIG_RESET_ATTACK_MITIGATION
961 void efi_enable_reset_attack_mitigation(void);
964 efi_enable_reset_attack_mitigation(void) { }
967 void efi_retrieve_tpm2_eventlog(void);