1b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */ 2f4f75ad5SArd Biesheuvel 3f4f75ad5SArd Biesheuvel #ifndef _DRIVERS_FIRMWARE_EFI_EFISTUB_H 4f4f75ad5SArd Biesheuvel #define _DRIVERS_FIRMWARE_EFI_EFISTUB_H 5f4f75ad5SArd Biesheuvel 62c7d1e30SArvind Sankar #include <linux/compiler.h> 70b767353SArvind Sankar #include <linux/efi.h> 80b767353SArvind Sankar #include <linux/kernel.h> 923d5b73fSArvind Sankar #include <linux/kern_levels.h> 100b767353SArvind Sankar #include <linux/types.h> 110b767353SArvind Sankar #include <asm/efi.h> 120b767353SArvind Sankar 1307e83dbbSArd Biesheuvel /* 1407e83dbbSArd Biesheuvel * __init annotations should not be used in the EFI stub, since the code is 1507e83dbbSArd Biesheuvel * either included in the decompressor (x86, ARM) where they have no effect, 1607e83dbbSArd Biesheuvel * or the whole stub is __init annotated at the section level (arm64), by 1707e83dbbSArd Biesheuvel * renaming the sections, in which case the __init annotation will be 1807e83dbbSArd Biesheuvel * redundant, and will result in section names like .init.init.text, and our 1907e83dbbSArd Biesheuvel * linker script does not expect that. 2007e83dbbSArd Biesheuvel */ 2107e83dbbSArd Biesheuvel #undef __init 2207e83dbbSArd Biesheuvel 23a6a14469SArd Biesheuvel /* 24a6a14469SArd Biesheuvel * Allow the platform to override the allocation granularity: this allows 25a6a14469SArd Biesheuvel * systems that have the capability to run with a larger page size to deal 26a6a14469SArd Biesheuvel * with the allocations for initrd and fdt more efficiently. 27a6a14469SArd Biesheuvel */ 28a6a14469SArd Biesheuvel #ifndef EFI_ALLOC_ALIGN 29a6a14469SArd Biesheuvel #define EFI_ALLOC_ALIGN EFI_PAGE_SIZE 30a6a14469SArd Biesheuvel #endif 31a6a14469SArd Biesheuvel 32a37dac5cSArd Biesheuvel #ifndef EFI_ALLOC_LIMIT 33a37dac5cSArd Biesheuvel #define EFI_ALLOC_LIMIT ULONG_MAX 34a37dac5cSArd Biesheuvel #endif 35a37dac5cSArd Biesheuvel 36980771f6SArd Biesheuvel extern bool efi_nochunk; 37980771f6SArd Biesheuvel extern bool efi_nokaslr; 3823d5b73fSArvind Sankar extern int efi_loglevel; 39980771f6SArd Biesheuvel extern bool efi_novamap; 40eeff7d63SArd Biesheuvel 41ccc27ae7SArd Biesheuvel extern const efi_system_table_t *efi_system_table; 422fcdad2aSArd Biesheuvel 433ba75c13SBaskov Evgeniy typedef union efi_dxe_services_table efi_dxe_services_table_t; 443ba75c13SBaskov Evgeniy extern const efi_dxe_services_table_t *efi_dxe_table; 453ba75c13SBaskov Evgeniy 466e99d321SArd Biesheuvel efi_status_t __efiapi efi_pe_entry(efi_handle_t handle, 476e99d321SArd Biesheuvel efi_system_table_t *sys_table_arg); 486e99d321SArd Biesheuvel 49de8c5520SArvind Sankar #ifndef ARCH_HAS_EFISTUB_WRAPPERS 50de8c5520SArvind Sankar 5122090f84SArd Biesheuvel #define efi_is_native() (true) 52a61962d8SArd Biesheuvel #define efi_table_attr(inst, attr) (inst)->attr 53a61962d8SArd Biesheuvel #define efi_fn_call(inst, func, ...) (inst)->func(__VA_ARGS__) 54de8c5520SArvind Sankar 5522090f84SArd Biesheuvel #endif 5622090f84SArd Biesheuvel 57a61962d8SArd Biesheuvel #define efi_call_proto(inst, func, ...) ({ \ 58a61962d8SArd Biesheuvel __typeof__(inst) __inst = (inst); \ 59a61962d8SArd Biesheuvel efi_fn_call(__inst, func, __inst, ##__VA_ARGS__); \ 60a61962d8SArd Biesheuvel }) 61a61962d8SArd Biesheuvel #define efi_bs_call(func, ...) \ 62a61962d8SArd Biesheuvel efi_fn_call(efi_table_attr(efi_system_table, boottime), func, ##__VA_ARGS__) 63a61962d8SArd Biesheuvel #define efi_rt_call(func, ...) \ 64a61962d8SArd Biesheuvel efi_fn_call(efi_table_attr(efi_system_table, runtime), func, ##__VA_ARGS__) 65a61962d8SArd Biesheuvel #define efi_dxe_call(func, ...) \ 66a61962d8SArd Biesheuvel efi_fn_call(efi_dxe_table, func, ##__VA_ARGS__) 67a61962d8SArd Biesheuvel 6823d5b73fSArvind Sankar #define efi_info(fmt, ...) \ 6923d5b73fSArvind Sankar efi_printk(KERN_INFO fmt, ##__VA_ARGS__) 70c1df5e0cSArvind Sankar #define efi_warn(fmt, ...) \ 71c1df5e0cSArvind Sankar efi_printk(KERN_WARNING "WARNING: " fmt, ##__VA_ARGS__) 7223d5b73fSArvind Sankar #define efi_err(fmt, ...) \ 7323d5b73fSArvind Sankar efi_printk(KERN_ERR "ERROR: " fmt, ##__VA_ARGS__) 7423d5b73fSArvind Sankar #define efi_debug(fmt, ...) \ 7523d5b73fSArvind Sankar efi_printk(KERN_DEBUG "DEBUG: " fmt, ##__VA_ARGS__) 7660f38de7SArd Biesheuvel 77c1df5e0cSArvind Sankar #define efi_printk_once(fmt, ...) \ 78c1df5e0cSArvind Sankar ({ \ 79c1df5e0cSArvind Sankar static bool __print_once; \ 80c1df5e0cSArvind Sankar bool __ret_print_once = !__print_once; \ 81c1df5e0cSArvind Sankar \ 82c1df5e0cSArvind Sankar if (!__print_once) { \ 83c1df5e0cSArvind Sankar __print_once = true; \ 84c1df5e0cSArvind Sankar efi_printk(fmt, ##__VA_ARGS__); \ 85c1df5e0cSArvind Sankar } \ 86c1df5e0cSArvind Sankar __ret_print_once; \ 87c1df5e0cSArvind Sankar }) 88c1df5e0cSArvind Sankar 89c1df5e0cSArvind Sankar #define efi_info_once(fmt, ...) \ 90c1df5e0cSArvind Sankar efi_printk_once(KERN_INFO fmt, ##__VA_ARGS__) 91c1df5e0cSArvind Sankar #define efi_warn_once(fmt, ...) \ 92c1df5e0cSArvind Sankar efi_printk_once(KERN_WARNING "WARNING: " fmt, ##__VA_ARGS__) 93c1df5e0cSArvind Sankar #define efi_err_once(fmt, ...) \ 94c1df5e0cSArvind Sankar efi_printk_once(KERN_ERR "ERROR: " fmt, ##__VA_ARGS__) 95c1df5e0cSArvind Sankar #define efi_debug_once(fmt, ...) \ 96c1df5e0cSArvind Sankar efi_printk_once(KERN_DEBUG "DEBUG: " fmt, ##__VA_ARGS__) 97c1df5e0cSArvind Sankar 98ac9aff8eSIngo Molnar /* Helper macros for the usual case of using simple C variables: */ 99ac9aff8eSIngo Molnar #ifndef fdt_setprop_inplace_var 100ac9aff8eSIngo Molnar #define fdt_setprop_inplace_var(fdt, node_offset, name, var) \ 101ac9aff8eSIngo Molnar fdt_setprop_inplace((fdt), (node_offset), (name), &(var), sizeof(var)) 102ac9aff8eSIngo Molnar #endif 103ac9aff8eSIngo Molnar 104ac9aff8eSIngo Molnar #ifndef fdt_setprop_var 105ac9aff8eSIngo Molnar #define fdt_setprop_var(fdt, node_offset, name, var) \ 106ac9aff8eSIngo Molnar fdt_setprop((fdt), (node_offset), (name), &(var), sizeof(var)) 107ac9aff8eSIngo Molnar #endif 108ac9aff8eSIngo Molnar 109966291f6SArd Biesheuvel #define get_efi_var(name, vendor, ...) \ 110966291f6SArd Biesheuvel efi_rt_call(get_variable, (efi_char16_t *)(name), \ 111966291f6SArd Biesheuvel (efi_guid_t *)(vendor), __VA_ARGS__) 112966291f6SArd Biesheuvel 113966291f6SArd Biesheuvel #define set_efi_var(name, vendor, ...) \ 114966291f6SArd Biesheuvel efi_rt_call(set_variable, (efi_char16_t *)(name), \ 115966291f6SArd Biesheuvel (efi_guid_t *)(vendor), __VA_ARGS__) 116966291f6SArd Biesheuvel 1178166ec09SArd Biesheuvel #define efi_get_handle_at(array, idx) \ 1188166ec09SArd Biesheuvel (efi_is_native() ? (array)[idx] \ 1198166ec09SArd Biesheuvel : (efi_handle_t)(unsigned long)((u32 *)(array))[idx]) 1208166ec09SArd Biesheuvel 1218166ec09SArd Biesheuvel #define efi_get_handle_num(size) \ 1228166ec09SArd Biesheuvel ((size) / (efi_is_native() ? sizeof(efi_handle_t) : sizeof(u32))) 1238166ec09SArd Biesheuvel 1248166ec09SArd Biesheuvel #define for_each_efi_handle(handle, array, size, i) \ 1258166ec09SArd Biesheuvel for (i = 0; \ 1268166ec09SArd Biesheuvel i < efi_get_handle_num(size) && \ 1278166ec09SArd Biesheuvel ((handle = efi_get_handle_at((array), i)) || true); \ 1288166ec09SArd Biesheuvel i++) 1298166ec09SArd Biesheuvel 130eed4e019SArvind Sankar static inline 131eed4e019SArvind Sankar void efi_set_u64_split(u64 data, u32 *lo, u32 *hi) 132eed4e019SArvind Sankar { 133eed4e019SArvind Sankar *lo = lower_32_bits(data); 134eed4e019SArvind Sankar *hi = upper_32_bits(data); 135eed4e019SArvind Sankar } 136eed4e019SArvind Sankar 1378166ec09SArd Biesheuvel /* 1388166ec09SArd Biesheuvel * Allocation types for calls to boottime->allocate_pages. 1398166ec09SArd Biesheuvel */ 1408166ec09SArd Biesheuvel #define EFI_ALLOCATE_ANY_PAGES 0 1418166ec09SArd Biesheuvel #define EFI_ALLOCATE_MAX_ADDRESS 1 1428166ec09SArd Biesheuvel #define EFI_ALLOCATE_ADDRESS 2 1438166ec09SArd Biesheuvel #define EFI_MAX_ALLOCATE_TYPE 3 1448166ec09SArd Biesheuvel 1458166ec09SArd Biesheuvel /* 1468166ec09SArd Biesheuvel * The type of search to perform when calling boottime->locate_handle 1478166ec09SArd Biesheuvel */ 1488166ec09SArd Biesheuvel #define EFI_LOCATE_ALL_HANDLES 0 1498166ec09SArd Biesheuvel #define EFI_LOCATE_BY_REGISTER_NOTIFY 1 1508166ec09SArd Biesheuvel #define EFI_LOCATE_BY_PROTOCOL 2 1518166ec09SArd Biesheuvel 152fd626195SLenny Szubowicz /* 1539b47c527SArvind Sankar * boottime->stall takes the time period in microseconds 1549b47c527SArvind Sankar */ 1559b47c527SArvind Sankar #define EFI_USEC_PER_SEC 1000000 1569b47c527SArvind Sankar 1579b47c527SArvind Sankar /* 1589b47c527SArvind Sankar * boottime->set_timer takes the time in 100ns units 1599b47c527SArvind Sankar */ 1609b47c527SArvind Sankar #define EFI_100NSEC_PER_USEC ((u64)10) 1619b47c527SArvind Sankar 162d1343da3SIngo Molnar /* 163fd626195SLenny Szubowicz * An efi_boot_memmap is used by efi_get_memory_map() to return the 164fd626195SLenny Szubowicz * EFI memory map in a dynamically allocated buffer. 165fd626195SLenny Szubowicz * 166fd626195SLenny Szubowicz * The buffer allocated for the EFI memory map includes extra room for 167fd626195SLenny Szubowicz * a minimum of EFI_MMAP_NR_SLACK_SLOTS additional EFI memory descriptors. 168fd626195SLenny Szubowicz * This facilitates the reuse of the EFI memory map buffer when a second 169fd626195SLenny Szubowicz * call to ExitBootServices() is needed because of intervening changes to 170fd626195SLenny Szubowicz * the EFI memory map. Other related structures, e.g. x86 e820ext, need 171fd626195SLenny Szubowicz * to factor in this headroom requirement as well. 172fd626195SLenny Szubowicz */ 173fd626195SLenny Szubowicz #define EFI_MMAP_NR_SLACK_SLOTS 8 174fd626195SLenny Szubowicz 175abd26868SArd Biesheuvel typedef struct efi_generic_dev_path efi_device_path_protocol_t; 176abd26868SArd Biesheuvel 177c7007d9fSArd Biesheuvel union efi_device_path_to_text_protocol { 178c7007d9fSArd Biesheuvel struct { 179c7007d9fSArd Biesheuvel efi_char16_t *(__efiapi *convert_device_node_to_text)( 180c7007d9fSArd Biesheuvel const efi_device_path_protocol_t *, 181c7007d9fSArd Biesheuvel bool, bool); 182c7007d9fSArd Biesheuvel efi_char16_t *(__efiapi *convert_device_path_to_text)( 183c7007d9fSArd Biesheuvel const efi_device_path_protocol_t *, 184c7007d9fSArd Biesheuvel bool, bool); 185c7007d9fSArd Biesheuvel }; 186c7007d9fSArd Biesheuvel struct { 187c7007d9fSArd Biesheuvel u32 convert_device_node_to_text; 188c7007d9fSArd Biesheuvel u32 convert_device_path_to_text; 189c7007d9fSArd Biesheuvel } mixed_mode; 190c7007d9fSArd Biesheuvel }; 191c7007d9fSArd Biesheuvel 192c7007d9fSArd Biesheuvel typedef union efi_device_path_to_text_protocol efi_device_path_to_text_protocol_t; 193c7007d9fSArd Biesheuvel 19470912985SArd Biesheuvel union efi_device_path_from_text_protocol { 19570912985SArd Biesheuvel struct { 19670912985SArd Biesheuvel efi_device_path_protocol_t * 19770912985SArd Biesheuvel (__efiapi *convert_text_to_device_node)(const efi_char16_t *); 19870912985SArd Biesheuvel efi_device_path_protocol_t * 19970912985SArd Biesheuvel (__efiapi *convert_text_to_device_path)(const efi_char16_t *); 20070912985SArd Biesheuvel }; 20170912985SArd Biesheuvel struct { 20270912985SArd Biesheuvel u32 convert_text_to_device_node; 20370912985SArd Biesheuvel u32 convert_text_to_device_path; 20470912985SArd Biesheuvel } mixed_mode; 20570912985SArd Biesheuvel }; 20670912985SArd Biesheuvel 20770912985SArd Biesheuvel typedef union efi_device_path_from_text_protocol efi_device_path_from_text_protocol_t; 20870912985SArd Biesheuvel 2099b47c527SArvind Sankar typedef void *efi_event_t; 2109b47c527SArvind Sankar /* Note that notifications won't work in mixed mode */ 2119b47c527SArvind Sankar typedef void (__efiapi *efi_event_notify_t)(efi_event_t, void *); 2129b47c527SArvind Sankar 2139b47c527SArvind Sankar #define EFI_EVT_TIMER 0x80000000U 2149b47c527SArvind Sankar #define EFI_EVT_RUNTIME 0x40000000U 2159b47c527SArvind Sankar #define EFI_EVT_NOTIFY_WAIT 0x00000100U 2169b47c527SArvind Sankar #define EFI_EVT_NOTIFY_SIGNAL 0x00000200U 2179b47c527SArvind Sankar 2188c0a839cSHeinrich Schuchardt /** 2198c0a839cSHeinrich Schuchardt * efi_set_event_at() - add event to events array 2208c0a839cSHeinrich Schuchardt * 2218c0a839cSHeinrich Schuchardt * @events: array of UEFI events 2228c0a839cSHeinrich Schuchardt * @ids: index where to put the event in the array 2238c0a839cSHeinrich Schuchardt * @event: event to add to the aray 2248c0a839cSHeinrich Schuchardt * 2258c0a839cSHeinrich Schuchardt * boottime->wait_for_event() takes an array of events as input. 2269b47c527SArvind Sankar * Provide a helper to set it up correctly for mixed mode. 2279b47c527SArvind Sankar */ 2289b47c527SArvind Sankar static inline 2299b47c527SArvind Sankar void efi_set_event_at(efi_event_t *events, size_t idx, efi_event_t event) 2309b47c527SArvind Sankar { 2319b47c527SArvind Sankar if (efi_is_native()) 2329b47c527SArvind Sankar events[idx] = event; 2339b47c527SArvind Sankar else 2349b47c527SArvind Sankar ((u32 *)events)[idx] = (u32)(unsigned long)event; 2359b47c527SArvind Sankar } 2369b47c527SArvind Sankar 2379b47c527SArvind Sankar #define EFI_TPL_APPLICATION 4 2389b47c527SArvind Sankar #define EFI_TPL_CALLBACK 8 2399b47c527SArvind Sankar #define EFI_TPL_NOTIFY 16 2409b47c527SArvind Sankar #define EFI_TPL_HIGH_LEVEL 31 2419b47c527SArvind Sankar 2429b47c527SArvind Sankar typedef enum { 2439b47c527SArvind Sankar EfiTimerCancel, 2449b47c527SArvind Sankar EfiTimerPeriodic, 2459b47c527SArvind Sankar EfiTimerRelative 2469b47c527SArvind Sankar } EFI_TIMER_DELAY; 2479b47c527SArvind Sankar 2488166ec09SArd Biesheuvel /* 2498166ec09SArd Biesheuvel * EFI Boot Services table 2508166ec09SArd Biesheuvel */ 2518166ec09SArd Biesheuvel union efi_boot_services { 2528166ec09SArd Biesheuvel struct { 2538166ec09SArd Biesheuvel efi_table_hdr_t hdr; 2548166ec09SArd Biesheuvel void *raise_tpl; 2558166ec09SArd Biesheuvel void *restore_tpl; 2568166ec09SArd Biesheuvel efi_status_t (__efiapi *allocate_pages)(int, int, unsigned long, 2578166ec09SArd Biesheuvel efi_physical_addr_t *); 2588166ec09SArd Biesheuvel efi_status_t (__efiapi *free_pages)(efi_physical_addr_t, 2598166ec09SArd Biesheuvel unsigned long); 2608166ec09SArd Biesheuvel efi_status_t (__efiapi *get_memory_map)(unsigned long *, void *, 2618166ec09SArd Biesheuvel unsigned long *, 2628166ec09SArd Biesheuvel unsigned long *, u32 *); 2638166ec09SArd Biesheuvel efi_status_t (__efiapi *allocate_pool)(int, unsigned long, 2648166ec09SArd Biesheuvel void **); 2658166ec09SArd Biesheuvel efi_status_t (__efiapi *free_pool)(void *); 2669b47c527SArvind Sankar efi_status_t (__efiapi *create_event)(u32, unsigned long, 2679b47c527SArvind Sankar efi_event_notify_t, void *, 2689b47c527SArvind Sankar efi_event_t *); 2699b47c527SArvind Sankar efi_status_t (__efiapi *set_timer)(efi_event_t, 2709b47c527SArvind Sankar EFI_TIMER_DELAY, u64); 2719b47c527SArvind Sankar efi_status_t (__efiapi *wait_for_event)(unsigned long, 2729b47c527SArvind Sankar efi_event_t *, 2739b47c527SArvind Sankar unsigned long *); 2748166ec09SArd Biesheuvel void *signal_event; 2759b47c527SArvind Sankar efi_status_t (__efiapi *close_event)(efi_event_t); 2768166ec09SArd Biesheuvel void *check_event; 2778166ec09SArd Biesheuvel void *install_protocol_interface; 2788166ec09SArd Biesheuvel void *reinstall_protocol_interface; 2798166ec09SArd Biesheuvel void *uninstall_protocol_interface; 2808166ec09SArd Biesheuvel efi_status_t (__efiapi *handle_protocol)(efi_handle_t, 2818166ec09SArd Biesheuvel efi_guid_t *, void **); 2828166ec09SArd Biesheuvel void *__reserved; 2838166ec09SArd Biesheuvel void *register_protocol_notify; 2848166ec09SArd Biesheuvel efi_status_t (__efiapi *locate_handle)(int, efi_guid_t *, 2858166ec09SArd Biesheuvel void *, unsigned long *, 2868166ec09SArd Biesheuvel efi_handle_t *); 287abd26868SArd Biesheuvel efi_status_t (__efiapi *locate_device_path)(efi_guid_t *, 288abd26868SArd Biesheuvel efi_device_path_protocol_t **, 289abd26868SArd Biesheuvel efi_handle_t *); 2908166ec09SArd Biesheuvel efi_status_t (__efiapi *install_configuration_table)(efi_guid_t *, 2918166ec09SArd Biesheuvel void *); 292c7007d9fSArd Biesheuvel efi_status_t (__efiapi *load_image)(bool, efi_handle_t, 293c7007d9fSArd Biesheuvel efi_device_path_protocol_t *, 294c7007d9fSArd Biesheuvel void *, unsigned long, 295c7007d9fSArd Biesheuvel efi_handle_t *); 296c7007d9fSArd Biesheuvel efi_status_t (__efiapi *start_image)(efi_handle_t, unsigned long *, 297c7007d9fSArd Biesheuvel efi_char16_t **); 2983b8f44fcSArd Biesheuvel efi_status_t __noreturn (__efiapi *exit)(efi_handle_t, 2993b8f44fcSArd Biesheuvel efi_status_t, 3003b8f44fcSArd Biesheuvel unsigned long, 3013b8f44fcSArd Biesheuvel efi_char16_t *); 302c7007d9fSArd Biesheuvel efi_status_t (__efiapi *unload_image)(efi_handle_t); 3038166ec09SArd Biesheuvel efi_status_t (__efiapi *exit_boot_services)(efi_handle_t, 3048166ec09SArd Biesheuvel unsigned long); 3058166ec09SArd Biesheuvel void *get_next_monotonic_count; 3069b47c527SArvind Sankar efi_status_t (__efiapi *stall)(unsigned long); 3078166ec09SArd Biesheuvel void *set_watchdog_timer; 3088166ec09SArd Biesheuvel void *connect_controller; 3098166ec09SArd Biesheuvel efi_status_t (__efiapi *disconnect_controller)(efi_handle_t, 3108166ec09SArd Biesheuvel efi_handle_t, 3118166ec09SArd Biesheuvel efi_handle_t); 3128166ec09SArd Biesheuvel void *open_protocol; 3138166ec09SArd Biesheuvel void *close_protocol; 3148166ec09SArd Biesheuvel void *open_protocol_information; 3158166ec09SArd Biesheuvel void *protocols_per_handle; 3168166ec09SArd Biesheuvel void *locate_handle_buffer; 3178166ec09SArd Biesheuvel efi_status_t (__efiapi *locate_protocol)(efi_guid_t *, void *, 3188166ec09SArd Biesheuvel void **); 319c7007d9fSArd Biesheuvel efi_status_t (__efiapi *install_multiple_protocol_interfaces)(efi_handle_t *, ...); 320c7007d9fSArd Biesheuvel efi_status_t (__efiapi *uninstall_multiple_protocol_interfaces)(efi_handle_t, ...); 3218166ec09SArd Biesheuvel void *calculate_crc32; 322c82ceb44SArd Biesheuvel void (__efiapi *copy_mem)(void *, const void *, unsigned long); 323c82ceb44SArd Biesheuvel void (__efiapi *set_mem)(void *, unsigned long, unsigned char); 3248166ec09SArd Biesheuvel void *create_event_ex; 3258166ec09SArd Biesheuvel }; 3268166ec09SArd Biesheuvel struct { 3278166ec09SArd Biesheuvel efi_table_hdr_t hdr; 3288166ec09SArd Biesheuvel u32 raise_tpl; 3298166ec09SArd Biesheuvel u32 restore_tpl; 3308166ec09SArd Biesheuvel u32 allocate_pages; 3318166ec09SArd Biesheuvel u32 free_pages; 3328166ec09SArd Biesheuvel u32 get_memory_map; 3338166ec09SArd Biesheuvel u32 allocate_pool; 3348166ec09SArd Biesheuvel u32 free_pool; 3358166ec09SArd Biesheuvel u32 create_event; 3368166ec09SArd Biesheuvel u32 set_timer; 3378166ec09SArd Biesheuvel u32 wait_for_event; 3388166ec09SArd Biesheuvel u32 signal_event; 3398166ec09SArd Biesheuvel u32 close_event; 3408166ec09SArd Biesheuvel u32 check_event; 3418166ec09SArd Biesheuvel u32 install_protocol_interface; 3428166ec09SArd Biesheuvel u32 reinstall_protocol_interface; 3438166ec09SArd Biesheuvel u32 uninstall_protocol_interface; 3448166ec09SArd Biesheuvel u32 handle_protocol; 3458166ec09SArd Biesheuvel u32 __reserved; 3468166ec09SArd Biesheuvel u32 register_protocol_notify; 3478166ec09SArd Biesheuvel u32 locate_handle; 3488166ec09SArd Biesheuvel u32 locate_device_path; 3498166ec09SArd Biesheuvel u32 install_configuration_table; 3508166ec09SArd Biesheuvel u32 load_image; 3518166ec09SArd Biesheuvel u32 start_image; 3528166ec09SArd Biesheuvel u32 exit; 3538166ec09SArd Biesheuvel u32 unload_image; 3548166ec09SArd Biesheuvel u32 exit_boot_services; 3558166ec09SArd Biesheuvel u32 get_next_monotonic_count; 3568166ec09SArd Biesheuvel u32 stall; 3578166ec09SArd Biesheuvel u32 set_watchdog_timer; 3588166ec09SArd Biesheuvel u32 connect_controller; 3598166ec09SArd Biesheuvel u32 disconnect_controller; 3608166ec09SArd Biesheuvel u32 open_protocol; 3618166ec09SArd Biesheuvel u32 close_protocol; 3628166ec09SArd Biesheuvel u32 open_protocol_information; 3638166ec09SArd Biesheuvel u32 protocols_per_handle; 3648166ec09SArd Biesheuvel u32 locate_handle_buffer; 3658166ec09SArd Biesheuvel u32 locate_protocol; 3668166ec09SArd Biesheuvel u32 install_multiple_protocol_interfaces; 3678166ec09SArd Biesheuvel u32 uninstall_multiple_protocol_interfaces; 3688166ec09SArd Biesheuvel u32 calculate_crc32; 3698166ec09SArd Biesheuvel u32 copy_mem; 3708166ec09SArd Biesheuvel u32 set_mem; 3718166ec09SArd Biesheuvel u32 create_event_ex; 3728166ec09SArd Biesheuvel } mixed_mode; 3738166ec09SArd Biesheuvel }; 3748166ec09SArd Biesheuvel 3753ba75c13SBaskov Evgeniy typedef enum { 3763ba75c13SBaskov Evgeniy EfiGcdMemoryTypeNonExistent, 3773ba75c13SBaskov Evgeniy EfiGcdMemoryTypeReserved, 3783ba75c13SBaskov Evgeniy EfiGcdMemoryTypeSystemMemory, 3793ba75c13SBaskov Evgeniy EfiGcdMemoryTypeMemoryMappedIo, 3803ba75c13SBaskov Evgeniy EfiGcdMemoryTypePersistent, 3813ba75c13SBaskov Evgeniy EfiGcdMemoryTypeMoreReliable, 3823ba75c13SBaskov Evgeniy EfiGcdMemoryTypeMaximum 3833ba75c13SBaskov Evgeniy } efi_gcd_memory_type_t; 3843ba75c13SBaskov Evgeniy 3853ba75c13SBaskov Evgeniy typedef struct { 3863ba75c13SBaskov Evgeniy efi_physical_addr_t base_address; 3873ba75c13SBaskov Evgeniy u64 length; 3883ba75c13SBaskov Evgeniy u64 capabilities; 3893ba75c13SBaskov Evgeniy u64 attributes; 3903ba75c13SBaskov Evgeniy efi_gcd_memory_type_t gcd_memory_type; 3913ba75c13SBaskov Evgeniy void *image_handle; 3923ba75c13SBaskov Evgeniy void *device_handle; 3933ba75c13SBaskov Evgeniy } efi_gcd_memory_space_desc_t; 3943ba75c13SBaskov Evgeniy 3953ba75c13SBaskov Evgeniy /* 3963ba75c13SBaskov Evgeniy * EFI DXE Services table 3973ba75c13SBaskov Evgeniy */ 3983ba75c13SBaskov Evgeniy union efi_dxe_services_table { 3993ba75c13SBaskov Evgeniy struct { 4003ba75c13SBaskov Evgeniy efi_table_hdr_t hdr; 4013ba75c13SBaskov Evgeniy void *add_memory_space; 4023ba75c13SBaskov Evgeniy void *allocate_memory_space; 4033ba75c13SBaskov Evgeniy void *free_memory_space; 4043ba75c13SBaskov Evgeniy void *remove_memory_space; 4053ba75c13SBaskov Evgeniy efi_status_t (__efiapi *get_memory_space_descriptor)(efi_physical_addr_t, 4063ba75c13SBaskov Evgeniy efi_gcd_memory_space_desc_t *); 4073ba75c13SBaskov Evgeniy efi_status_t (__efiapi *set_memory_space_attributes)(efi_physical_addr_t, 4083ba75c13SBaskov Evgeniy u64, u64); 4093ba75c13SBaskov Evgeniy void *get_memory_space_map; 4103ba75c13SBaskov Evgeniy void *add_io_space; 4113ba75c13SBaskov Evgeniy void *allocate_io_space; 4123ba75c13SBaskov Evgeniy void *free_io_space; 4133ba75c13SBaskov Evgeniy void *remove_io_space; 4143ba75c13SBaskov Evgeniy void *get_io_space_descriptor; 4153ba75c13SBaskov Evgeniy void *get_io_space_map; 4163ba75c13SBaskov Evgeniy void *dispatch; 4173ba75c13SBaskov Evgeniy void *schedule; 4183ba75c13SBaskov Evgeniy void *trust; 4193ba75c13SBaskov Evgeniy void *process_firmware_volume; 4203ba75c13SBaskov Evgeniy void *set_memory_space_capabilities; 4213ba75c13SBaskov Evgeniy }; 4223ba75c13SBaskov Evgeniy struct { 4233ba75c13SBaskov Evgeniy efi_table_hdr_t hdr; 4243ba75c13SBaskov Evgeniy u32 add_memory_space; 4253ba75c13SBaskov Evgeniy u32 allocate_memory_space; 4263ba75c13SBaskov Evgeniy u32 free_memory_space; 4273ba75c13SBaskov Evgeniy u32 remove_memory_space; 4283ba75c13SBaskov Evgeniy u32 get_memory_space_descriptor; 4293ba75c13SBaskov Evgeniy u32 set_memory_space_attributes; 4303ba75c13SBaskov Evgeniy u32 get_memory_space_map; 4313ba75c13SBaskov Evgeniy u32 add_io_space; 4323ba75c13SBaskov Evgeniy u32 allocate_io_space; 4333ba75c13SBaskov Evgeniy u32 free_io_space; 4343ba75c13SBaskov Evgeniy u32 remove_io_space; 4353ba75c13SBaskov Evgeniy u32 get_io_space_descriptor; 4363ba75c13SBaskov Evgeniy u32 get_io_space_map; 4373ba75c13SBaskov Evgeniy u32 dispatch; 4383ba75c13SBaskov Evgeniy u32 schedule; 4393ba75c13SBaskov Evgeniy u32 trust; 4403ba75c13SBaskov Evgeniy u32 process_firmware_volume; 4413ba75c13SBaskov Evgeniy u32 set_memory_space_capabilities; 4423ba75c13SBaskov Evgeniy } mixed_mode; 4433ba75c13SBaskov Evgeniy }; 4443ba75c13SBaskov Evgeniy 44579729f26SEvgeniy Baskov typedef union efi_memory_attribute_protocol efi_memory_attribute_protocol_t; 44679729f26SEvgeniy Baskov 44779729f26SEvgeniy Baskov union efi_memory_attribute_protocol { 44879729f26SEvgeniy Baskov struct { 44979729f26SEvgeniy Baskov efi_status_t (__efiapi *get_memory_attributes)( 45079729f26SEvgeniy Baskov efi_memory_attribute_protocol_t *, efi_physical_addr_t, u64, u64 *); 45179729f26SEvgeniy Baskov 45279729f26SEvgeniy Baskov efi_status_t (__efiapi *set_memory_attributes)( 45379729f26SEvgeniy Baskov efi_memory_attribute_protocol_t *, efi_physical_addr_t, u64, u64); 45479729f26SEvgeniy Baskov 45579729f26SEvgeniy Baskov efi_status_t (__efiapi *clear_memory_attributes)( 45679729f26SEvgeniy Baskov efi_memory_attribute_protocol_t *, efi_physical_addr_t, u64, u64); 45779729f26SEvgeniy Baskov }; 45879729f26SEvgeniy Baskov struct { 45979729f26SEvgeniy Baskov u32 get_memory_attributes; 46079729f26SEvgeniy Baskov u32 set_memory_attributes; 46179729f26SEvgeniy Baskov u32 clear_memory_attributes; 46279729f26SEvgeniy Baskov } mixed_mode; 46379729f26SEvgeniy Baskov }; 46479729f26SEvgeniy Baskov 465c2d0b470SArd Biesheuvel typedef union efi_uga_draw_protocol efi_uga_draw_protocol_t; 466c2d0b470SArd Biesheuvel 467c2d0b470SArd Biesheuvel union efi_uga_draw_protocol { 468c2d0b470SArd Biesheuvel struct { 469c2d0b470SArd Biesheuvel efi_status_t (__efiapi *get_mode)(efi_uga_draw_protocol_t *, 470c2d0b470SArd Biesheuvel u32*, u32*, u32*, u32*); 471c2d0b470SArd Biesheuvel void *set_mode; 472c2d0b470SArd Biesheuvel void *blt; 473c2d0b470SArd Biesheuvel }; 474c2d0b470SArd Biesheuvel struct { 475c2d0b470SArd Biesheuvel u32 get_mode; 476c2d0b470SArd Biesheuvel u32 set_mode; 477c2d0b470SArd Biesheuvel u32 blt; 478c2d0b470SArd Biesheuvel } mixed_mode; 479c2d0b470SArd Biesheuvel }; 480c2d0b470SArd Biesheuvel 4819b47c527SArvind Sankar typedef struct { 4829b47c527SArvind Sankar u16 scan_code; 4839b47c527SArvind Sankar efi_char16_t unicode_char; 4849b47c527SArvind Sankar } efi_input_key_t; 4859b47c527SArvind Sankar 4869b47c527SArvind Sankar union efi_simple_text_input_protocol { 4879b47c527SArvind Sankar struct { 4889b47c527SArvind Sankar void *reset; 4899b47c527SArvind Sankar efi_status_t (__efiapi *read_keystroke)(efi_simple_text_input_protocol_t *, 4909b47c527SArvind Sankar efi_input_key_t *); 4919b47c527SArvind Sankar efi_event_t wait_for_key; 4929b47c527SArvind Sankar }; 4939b47c527SArvind Sankar struct { 4949b47c527SArvind Sankar u32 reset; 4959b47c527SArvind Sankar u32 read_keystroke; 4969b47c527SArvind Sankar u32 wait_for_key; 4979b47c527SArvind Sankar } mixed_mode; 4989b47c527SArvind Sankar }; 4999b47c527SArvind Sankar 50014c574f3SArvind Sankar efi_status_t efi_wait_for_key(unsigned long usec, efi_input_key_t *key); 50114c574f3SArvind Sankar 5028166ec09SArd Biesheuvel union efi_simple_text_output_protocol { 5038166ec09SArd Biesheuvel struct { 5048166ec09SArd Biesheuvel void *reset; 5058166ec09SArd Biesheuvel efi_status_t (__efiapi *output_string)(efi_simple_text_output_protocol_t *, 5068166ec09SArd Biesheuvel efi_char16_t *); 5078166ec09SArd Biesheuvel void *test_string; 5088166ec09SArd Biesheuvel }; 5098166ec09SArd Biesheuvel struct { 5108166ec09SArd Biesheuvel u32 reset; 5118166ec09SArd Biesheuvel u32 output_string; 5128166ec09SArd Biesheuvel u32 test_string; 5138166ec09SArd Biesheuvel } mixed_mode; 5148166ec09SArd Biesheuvel }; 5158166ec09SArd Biesheuvel 5168166ec09SArd Biesheuvel #define PIXEL_RGB_RESERVED_8BIT_PER_COLOR 0 5178166ec09SArd Biesheuvel #define PIXEL_BGR_RESERVED_8BIT_PER_COLOR 1 5188166ec09SArd Biesheuvel #define PIXEL_BIT_MASK 2 5198166ec09SArd Biesheuvel #define PIXEL_BLT_ONLY 3 5208166ec09SArd Biesheuvel #define PIXEL_FORMAT_MAX 4 5218166ec09SArd Biesheuvel 5228166ec09SArd Biesheuvel typedef struct { 5238166ec09SArd Biesheuvel u32 red_mask; 5248166ec09SArd Biesheuvel u32 green_mask; 5258166ec09SArd Biesheuvel u32 blue_mask; 5268166ec09SArd Biesheuvel u32 reserved_mask; 5278166ec09SArd Biesheuvel } efi_pixel_bitmask_t; 5288166ec09SArd Biesheuvel 5298166ec09SArd Biesheuvel typedef struct { 5308166ec09SArd Biesheuvel u32 version; 5318166ec09SArd Biesheuvel u32 horizontal_resolution; 5328166ec09SArd Biesheuvel u32 vertical_resolution; 5338166ec09SArd Biesheuvel int pixel_format; 5348166ec09SArd Biesheuvel efi_pixel_bitmask_t pixel_information; 5358166ec09SArd Biesheuvel u32 pixels_per_scan_line; 5368166ec09SArd Biesheuvel } efi_graphics_output_mode_info_t; 5378166ec09SArd Biesheuvel 5388166ec09SArd Biesheuvel typedef union efi_graphics_output_protocol_mode efi_graphics_output_protocol_mode_t; 5398166ec09SArd Biesheuvel 5408166ec09SArd Biesheuvel union efi_graphics_output_protocol_mode { 5418166ec09SArd Biesheuvel struct { 5428166ec09SArd Biesheuvel u32 max_mode; 5438166ec09SArd Biesheuvel u32 mode; 5448166ec09SArd Biesheuvel efi_graphics_output_mode_info_t *info; 5458166ec09SArd Biesheuvel unsigned long size_of_info; 5468166ec09SArd Biesheuvel efi_physical_addr_t frame_buffer_base; 5478166ec09SArd Biesheuvel unsigned long frame_buffer_size; 5488166ec09SArd Biesheuvel }; 5498166ec09SArd Biesheuvel struct { 5508166ec09SArd Biesheuvel u32 max_mode; 5518166ec09SArd Biesheuvel u32 mode; 5528166ec09SArd Biesheuvel u32 info; 5538166ec09SArd Biesheuvel u32 size_of_info; 5548166ec09SArd Biesheuvel u64 frame_buffer_base; 5558166ec09SArd Biesheuvel u32 frame_buffer_size; 5568166ec09SArd Biesheuvel } mixed_mode; 5578166ec09SArd Biesheuvel }; 5588166ec09SArd Biesheuvel 5598166ec09SArd Biesheuvel typedef union efi_graphics_output_protocol efi_graphics_output_protocol_t; 5608166ec09SArd Biesheuvel 5618166ec09SArd Biesheuvel union efi_graphics_output_protocol { 5628166ec09SArd Biesheuvel struct { 563b4b89a02SArvind Sankar efi_status_t (__efiapi *query_mode)(efi_graphics_output_protocol_t *, 564b4b89a02SArvind Sankar u32, unsigned long *, 565b4b89a02SArvind Sankar efi_graphics_output_mode_info_t **); 566b4b89a02SArvind Sankar efi_status_t (__efiapi *set_mode) (efi_graphics_output_protocol_t *, u32); 5678166ec09SArd Biesheuvel void *blt; 5688166ec09SArd Biesheuvel efi_graphics_output_protocol_mode_t *mode; 5698166ec09SArd Biesheuvel }; 5708166ec09SArd Biesheuvel struct { 5718166ec09SArd Biesheuvel u32 query_mode; 5728166ec09SArd Biesheuvel u32 set_mode; 5738166ec09SArd Biesheuvel u32 blt; 5748166ec09SArd Biesheuvel u32 mode; 5758166ec09SArd Biesheuvel } mixed_mode; 5768166ec09SArd Biesheuvel }; 5778166ec09SArd Biesheuvel 578f7b85b33SArd Biesheuvel typedef union { 579f7b85b33SArd Biesheuvel struct { 580a46a290aSArd Biesheuvel u32 revision; 581a46a290aSArd Biesheuvel efi_handle_t parent_handle; 582a46a290aSArd Biesheuvel efi_system_table_t *system_table; 583a46a290aSArd Biesheuvel efi_handle_t device_handle; 584a46a290aSArd Biesheuvel void *file_path; 585a46a290aSArd Biesheuvel void *reserved; 586a46a290aSArd Biesheuvel u32 load_options_size; 587a46a290aSArd Biesheuvel void *load_options; 588a46a290aSArd Biesheuvel void *image_base; 589a46a290aSArd Biesheuvel __aligned_u64 image_size; 590a46a290aSArd Biesheuvel unsigned int image_code_type; 591a46a290aSArd Biesheuvel unsigned int image_data_type; 592a46a290aSArd Biesheuvel efi_status_t (__efiapi *unload)(efi_handle_t image_handle); 593f7b85b33SArd Biesheuvel }; 594f7b85b33SArd Biesheuvel struct { 595f7b85b33SArd Biesheuvel u32 revision; 596f7b85b33SArd Biesheuvel u32 parent_handle; 597f7b85b33SArd Biesheuvel u32 system_table; 598f7b85b33SArd Biesheuvel u32 device_handle; 599f7b85b33SArd Biesheuvel u32 file_path; 600f7b85b33SArd Biesheuvel u32 reserved; 601f7b85b33SArd Biesheuvel u32 load_options_size; 602f7b85b33SArd Biesheuvel u32 load_options; 603f7b85b33SArd Biesheuvel u32 image_base; 604f7b85b33SArd Biesheuvel __aligned_u64 image_size; 605f7b85b33SArd Biesheuvel u32 image_code_type; 606f7b85b33SArd Biesheuvel u32 image_data_type; 607f7b85b33SArd Biesheuvel u32 unload; 608f7b85b33SArd Biesheuvel } mixed_mode; 609a46a290aSArd Biesheuvel } efi_loaded_image_t; 610a46a290aSArd Biesheuvel 611a46a290aSArd Biesheuvel typedef struct { 612a46a290aSArd Biesheuvel u64 size; 613a46a290aSArd Biesheuvel u64 file_size; 614a46a290aSArd Biesheuvel u64 phys_size; 615a46a290aSArd Biesheuvel efi_time_t create_time; 616a46a290aSArd Biesheuvel efi_time_t last_access_time; 617a46a290aSArd Biesheuvel efi_time_t modification_time; 618a46a290aSArd Biesheuvel __aligned_u64 attribute; 6199302c1bbSArd Biesheuvel efi_char16_t filename[]; 620a46a290aSArd Biesheuvel } efi_file_info_t; 621a46a290aSArd Biesheuvel 622f8a31244SArd Biesheuvel typedef union efi_file_protocol efi_file_protocol_t; 623a46a290aSArd Biesheuvel 624f8a31244SArd Biesheuvel union efi_file_protocol { 625f8a31244SArd Biesheuvel struct { 626a46a290aSArd Biesheuvel u64 revision; 627a46a290aSArd Biesheuvel efi_status_t (__efiapi *open) (efi_file_protocol_t *, 628a46a290aSArd Biesheuvel efi_file_protocol_t **, 629f8a31244SArd Biesheuvel efi_char16_t *, u64, 630f8a31244SArd Biesheuvel u64); 631a46a290aSArd Biesheuvel efi_status_t (__efiapi *close) (efi_file_protocol_t *); 632a46a290aSArd Biesheuvel efi_status_t (__efiapi *delete) (efi_file_protocol_t *); 633a46a290aSArd Biesheuvel efi_status_t (__efiapi *read) (efi_file_protocol_t *, 634f8a31244SArd Biesheuvel unsigned long *, 635f8a31244SArd Biesheuvel void *); 636a46a290aSArd Biesheuvel efi_status_t (__efiapi *write) (efi_file_protocol_t *, 637a46a290aSArd Biesheuvel unsigned long, void *); 638f8a31244SArd Biesheuvel efi_status_t (__efiapi *get_position)(efi_file_protocol_t *, 639f8a31244SArd Biesheuvel u64 *); 640f8a31244SArd Biesheuvel efi_status_t (__efiapi *set_position)(efi_file_protocol_t *, 641f8a31244SArd Biesheuvel u64); 642a46a290aSArd Biesheuvel efi_status_t (__efiapi *get_info) (efi_file_protocol_t *, 643f8a31244SArd Biesheuvel efi_guid_t *, 644f8a31244SArd Biesheuvel unsigned long *, 645a46a290aSArd Biesheuvel void *); 646a46a290aSArd Biesheuvel efi_status_t (__efiapi *set_info) (efi_file_protocol_t *, 647f8a31244SArd Biesheuvel efi_guid_t *, 648f8a31244SArd Biesheuvel unsigned long, 649a46a290aSArd Biesheuvel void *); 650a46a290aSArd Biesheuvel efi_status_t (__efiapi *flush) (efi_file_protocol_t *); 651a46a290aSArd Biesheuvel }; 652f8a31244SArd Biesheuvel struct { 653a46a290aSArd Biesheuvel u64 revision; 654f8a31244SArd Biesheuvel u32 open; 655f8a31244SArd Biesheuvel u32 close; 656f8a31244SArd Biesheuvel u32 delete; 657f8a31244SArd Biesheuvel u32 read; 658f8a31244SArd Biesheuvel u32 write; 659f8a31244SArd Biesheuvel u32 get_position; 660f8a31244SArd Biesheuvel u32 set_position; 661f8a31244SArd Biesheuvel u32 get_info; 662f8a31244SArd Biesheuvel u32 set_info; 663f8a31244SArd Biesheuvel u32 flush; 664f8a31244SArd Biesheuvel } mixed_mode; 665f8a31244SArd Biesheuvel }; 666f8a31244SArd Biesheuvel 667f8a31244SArd Biesheuvel typedef union efi_simple_file_system_protocol efi_simple_file_system_protocol_t; 668f8a31244SArd Biesheuvel 669f8a31244SArd Biesheuvel union efi_simple_file_system_protocol { 670f8a31244SArd Biesheuvel struct { 671f8a31244SArd Biesheuvel u64 revision; 672f8a31244SArd Biesheuvel efi_status_t (__efiapi *open_volume)(efi_simple_file_system_protocol_t *, 673a46a290aSArd Biesheuvel efi_file_protocol_t **); 674a46a290aSArd Biesheuvel }; 675f8a31244SArd Biesheuvel struct { 676f8a31244SArd Biesheuvel u64 revision; 677f8a31244SArd Biesheuvel u32 open_volume; 678f8a31244SArd Biesheuvel } mixed_mode; 679f8a31244SArd Biesheuvel }; 680a46a290aSArd Biesheuvel 681a46a290aSArd Biesheuvel #define EFI_FILE_MODE_READ 0x0000000000000001 682a46a290aSArd Biesheuvel #define EFI_FILE_MODE_WRITE 0x0000000000000002 683a46a290aSArd Biesheuvel #define EFI_FILE_MODE_CREATE 0x8000000000000000 684a46a290aSArd Biesheuvel 6858166ec09SArd Biesheuvel typedef enum { 6868166ec09SArd Biesheuvel EfiPciIoWidthUint8, 6878166ec09SArd Biesheuvel EfiPciIoWidthUint16, 6888166ec09SArd Biesheuvel EfiPciIoWidthUint32, 6898166ec09SArd Biesheuvel EfiPciIoWidthUint64, 6908166ec09SArd Biesheuvel EfiPciIoWidthFifoUint8, 6918166ec09SArd Biesheuvel EfiPciIoWidthFifoUint16, 6928166ec09SArd Biesheuvel EfiPciIoWidthFifoUint32, 6938166ec09SArd Biesheuvel EfiPciIoWidthFifoUint64, 6948166ec09SArd Biesheuvel EfiPciIoWidthFillUint8, 6958166ec09SArd Biesheuvel EfiPciIoWidthFillUint16, 6968166ec09SArd Biesheuvel EfiPciIoWidthFillUint32, 6978166ec09SArd Biesheuvel EfiPciIoWidthFillUint64, 6988166ec09SArd Biesheuvel EfiPciIoWidthMaximum 6998166ec09SArd Biesheuvel } EFI_PCI_IO_PROTOCOL_WIDTH; 7008166ec09SArd Biesheuvel 7018166ec09SArd Biesheuvel typedef enum { 7028166ec09SArd Biesheuvel EfiPciIoAttributeOperationGet, 7038166ec09SArd Biesheuvel EfiPciIoAttributeOperationSet, 7048166ec09SArd Biesheuvel EfiPciIoAttributeOperationEnable, 7058166ec09SArd Biesheuvel EfiPciIoAttributeOperationDisable, 7068166ec09SArd Biesheuvel EfiPciIoAttributeOperationSupported, 7078166ec09SArd Biesheuvel EfiPciIoAttributeOperationMaximum 7088166ec09SArd Biesheuvel } EFI_PCI_IO_PROTOCOL_ATTRIBUTE_OPERATION; 7098166ec09SArd Biesheuvel 7108166ec09SArd Biesheuvel typedef struct { 7118166ec09SArd Biesheuvel u32 read; 7128166ec09SArd Biesheuvel u32 write; 7138166ec09SArd Biesheuvel } efi_pci_io_protocol_access_32_t; 7148166ec09SArd Biesheuvel 7158166ec09SArd Biesheuvel typedef union efi_pci_io_protocol efi_pci_io_protocol_t; 7168166ec09SArd Biesheuvel 7178166ec09SArd Biesheuvel typedef 7188166ec09SArd Biesheuvel efi_status_t (__efiapi *efi_pci_io_protocol_cfg_t)(efi_pci_io_protocol_t *, 7198166ec09SArd Biesheuvel EFI_PCI_IO_PROTOCOL_WIDTH, 7208166ec09SArd Biesheuvel u32 offset, 7218166ec09SArd Biesheuvel unsigned long count, 7228166ec09SArd Biesheuvel void *buffer); 7238166ec09SArd Biesheuvel 7248166ec09SArd Biesheuvel typedef struct { 7258166ec09SArd Biesheuvel void *read; 7268166ec09SArd Biesheuvel void *write; 7278166ec09SArd Biesheuvel } efi_pci_io_protocol_access_t; 7288166ec09SArd Biesheuvel 7298166ec09SArd Biesheuvel typedef struct { 7308166ec09SArd Biesheuvel efi_pci_io_protocol_cfg_t read; 7318166ec09SArd Biesheuvel efi_pci_io_protocol_cfg_t write; 7328166ec09SArd Biesheuvel } efi_pci_io_protocol_config_access_t; 7338166ec09SArd Biesheuvel 7348166ec09SArd Biesheuvel union efi_pci_io_protocol { 7358166ec09SArd Biesheuvel struct { 7368166ec09SArd Biesheuvel void *poll_mem; 7378166ec09SArd Biesheuvel void *poll_io; 7388166ec09SArd Biesheuvel efi_pci_io_protocol_access_t mem; 7398166ec09SArd Biesheuvel efi_pci_io_protocol_access_t io; 7408166ec09SArd Biesheuvel efi_pci_io_protocol_config_access_t pci; 7418166ec09SArd Biesheuvel void *copy_mem; 7428166ec09SArd Biesheuvel void *map; 7438166ec09SArd Biesheuvel void *unmap; 7448166ec09SArd Biesheuvel void *allocate_buffer; 7458166ec09SArd Biesheuvel void *free_buffer; 7468166ec09SArd Biesheuvel void *flush; 7478166ec09SArd Biesheuvel efi_status_t (__efiapi *get_location)(efi_pci_io_protocol_t *, 7488166ec09SArd Biesheuvel unsigned long *segment_nr, 7498166ec09SArd Biesheuvel unsigned long *bus_nr, 7508166ec09SArd Biesheuvel unsigned long *device_nr, 7518166ec09SArd Biesheuvel unsigned long *func_nr); 7528166ec09SArd Biesheuvel void *attributes; 7538166ec09SArd Biesheuvel void *get_bar_attributes; 7548166ec09SArd Biesheuvel void *set_bar_attributes; 7558166ec09SArd Biesheuvel uint64_t romsize; 7568166ec09SArd Biesheuvel void *romimage; 7578166ec09SArd Biesheuvel }; 7588166ec09SArd Biesheuvel struct { 7598166ec09SArd Biesheuvel u32 poll_mem; 7608166ec09SArd Biesheuvel u32 poll_io; 7618166ec09SArd Biesheuvel efi_pci_io_protocol_access_32_t mem; 7628166ec09SArd Biesheuvel efi_pci_io_protocol_access_32_t io; 7638166ec09SArd Biesheuvel efi_pci_io_protocol_access_32_t pci; 7648166ec09SArd Biesheuvel u32 copy_mem; 7658166ec09SArd Biesheuvel u32 map; 7668166ec09SArd Biesheuvel u32 unmap; 7678166ec09SArd Biesheuvel u32 allocate_buffer; 7688166ec09SArd Biesheuvel u32 free_buffer; 7698166ec09SArd Biesheuvel u32 flush; 7708166ec09SArd Biesheuvel u32 get_location; 7718166ec09SArd Biesheuvel u32 attributes; 7728166ec09SArd Biesheuvel u32 get_bar_attributes; 7738166ec09SArd Biesheuvel u32 set_bar_attributes; 7748166ec09SArd Biesheuvel u64 romsize; 7758166ec09SArd Biesheuvel u32 romimage; 7768166ec09SArd Biesheuvel } mixed_mode; 7778166ec09SArd Biesheuvel }; 7788166ec09SArd Biesheuvel 7798166ec09SArd Biesheuvel #define EFI_PCI_IO_ATTRIBUTE_ISA_MOTHERBOARD_IO 0x0001 7808166ec09SArd Biesheuvel #define EFI_PCI_IO_ATTRIBUTE_ISA_IO 0x0002 7818166ec09SArd Biesheuvel #define EFI_PCI_IO_ATTRIBUTE_VGA_PALETTE_IO 0x0004 7828166ec09SArd Biesheuvel #define EFI_PCI_IO_ATTRIBUTE_VGA_MEMORY 0x0008 7838166ec09SArd Biesheuvel #define EFI_PCI_IO_ATTRIBUTE_VGA_IO 0x0010 7848166ec09SArd Biesheuvel #define EFI_PCI_IO_ATTRIBUTE_IDE_PRIMARY_IO 0x0020 7858166ec09SArd Biesheuvel #define EFI_PCI_IO_ATTRIBUTE_IDE_SECONDARY_IO 0x0040 7868166ec09SArd Biesheuvel #define EFI_PCI_IO_ATTRIBUTE_MEMORY_WRITE_COMBINE 0x0080 7878166ec09SArd Biesheuvel #define EFI_PCI_IO_ATTRIBUTE_IO 0x0100 7888166ec09SArd Biesheuvel #define EFI_PCI_IO_ATTRIBUTE_MEMORY 0x0200 7898166ec09SArd Biesheuvel #define EFI_PCI_IO_ATTRIBUTE_BUS_MASTER 0x0400 7908166ec09SArd Biesheuvel #define EFI_PCI_IO_ATTRIBUTE_MEMORY_CACHED 0x0800 7918166ec09SArd Biesheuvel #define EFI_PCI_IO_ATTRIBUTE_MEMORY_DISABLE 0x1000 7928166ec09SArd Biesheuvel #define EFI_PCI_IO_ATTRIBUTE_EMBEDDED_DEVICE 0x2000 7938166ec09SArd Biesheuvel #define EFI_PCI_IO_ATTRIBUTE_EMBEDDED_ROM 0x4000 7948166ec09SArd Biesheuvel #define EFI_PCI_IO_ATTRIBUTE_DUAL_ADDRESS_CYCLE 0x8000 7958166ec09SArd Biesheuvel #define EFI_PCI_IO_ATTRIBUTE_ISA_IO_16 0x10000 7968166ec09SArd Biesheuvel #define EFI_PCI_IO_ATTRIBUTE_VGA_PALETTE_IO_16 0x20000 7978166ec09SArd Biesheuvel #define EFI_PCI_IO_ATTRIBUTE_VGA_IO_16 0x40000 7988166ec09SArd Biesheuvel 7998166ec09SArd Biesheuvel struct efi_dev_path; 8008166ec09SArd Biesheuvel 8018166ec09SArd Biesheuvel typedef union apple_properties_protocol apple_properties_protocol_t; 8028166ec09SArd Biesheuvel 8038166ec09SArd Biesheuvel union apple_properties_protocol { 8048166ec09SArd Biesheuvel struct { 8058166ec09SArd Biesheuvel unsigned long version; 8068166ec09SArd Biesheuvel efi_status_t (__efiapi *get)(apple_properties_protocol_t *, 8078166ec09SArd Biesheuvel struct efi_dev_path *, 8088166ec09SArd Biesheuvel efi_char16_t *, void *, u32 *); 8098166ec09SArd Biesheuvel efi_status_t (__efiapi *set)(apple_properties_protocol_t *, 8108166ec09SArd Biesheuvel struct efi_dev_path *, 8118166ec09SArd Biesheuvel efi_char16_t *, void *, u32); 8128166ec09SArd Biesheuvel efi_status_t (__efiapi *del)(apple_properties_protocol_t *, 8138166ec09SArd Biesheuvel struct efi_dev_path *, 8148166ec09SArd Biesheuvel efi_char16_t *); 8158166ec09SArd Biesheuvel efi_status_t (__efiapi *get_all)(apple_properties_protocol_t *, 8168166ec09SArd Biesheuvel void *buffer, u32 *); 8178166ec09SArd Biesheuvel }; 8188166ec09SArd Biesheuvel struct { 8198166ec09SArd Biesheuvel u32 version; 8208166ec09SArd Biesheuvel u32 get; 8218166ec09SArd Biesheuvel u32 set; 8228166ec09SArd Biesheuvel u32 del; 8238166ec09SArd Biesheuvel u32 get_all; 8248166ec09SArd Biesheuvel } mixed_mode; 8258166ec09SArd Biesheuvel }; 8268166ec09SArd Biesheuvel 8278166ec09SArd Biesheuvel typedef u32 efi_tcg2_event_log_format; 8288166ec09SArd Biesheuvel 8294da87c51SArd Biesheuvel #define INITRD_EVENT_TAG_ID 0x8F3B22ECU 83071c7adc9SIlias Apalodimas #define LOAD_OPTIONS_EVENT_TAG_ID 0x8F3B22EDU 8314da87c51SArd Biesheuvel #define EV_EVENT_TAG 0x00000006U 8324da87c51SArd Biesheuvel #define EFI_TCG2_EVENT_HEADER_VERSION 0x1 8334da87c51SArd Biesheuvel 8344da87c51SArd Biesheuvel struct efi_tcg2_event { 8354da87c51SArd Biesheuvel u32 event_size; 8364da87c51SArd Biesheuvel struct { 8374da87c51SArd Biesheuvel u32 header_size; 8384da87c51SArd Biesheuvel u16 header_version; 8394da87c51SArd Biesheuvel u32 pcr_index; 8404da87c51SArd Biesheuvel u32 event_type; 8414da87c51SArd Biesheuvel } __packed event_header; 8424da87c51SArd Biesheuvel /* u8[] event follows here */ 8434da87c51SArd Biesheuvel } __packed; 8444da87c51SArd Biesheuvel 8454da87c51SArd Biesheuvel struct efi_tcg2_tagged_event { 8464da87c51SArd Biesheuvel u32 tagged_event_id; 8474da87c51SArd Biesheuvel u32 tagged_event_data_size; 8484da87c51SArd Biesheuvel /* u8 tagged event data follows here */ 8494da87c51SArd Biesheuvel } __packed; 8504da87c51SArd Biesheuvel 8514da87c51SArd Biesheuvel typedef struct efi_tcg2_event efi_tcg2_event_t; 8524da87c51SArd Biesheuvel typedef struct efi_tcg2_tagged_event efi_tcg2_tagged_event_t; 8538166ec09SArd Biesheuvel typedef union efi_tcg2_protocol efi_tcg2_protocol_t; 8548166ec09SArd Biesheuvel 8558166ec09SArd Biesheuvel union efi_tcg2_protocol { 8568166ec09SArd Biesheuvel struct { 8578166ec09SArd Biesheuvel void *get_capability; 858cdec91c0SArd Biesheuvel efi_status_t (__efiapi *get_event_log)(efi_tcg2_protocol_t *, 8598166ec09SArd Biesheuvel efi_tcg2_event_log_format, 8608166ec09SArd Biesheuvel efi_physical_addr_t *, 8618166ec09SArd Biesheuvel efi_physical_addr_t *, 8628166ec09SArd Biesheuvel efi_bool_t *); 8634da87c51SArd Biesheuvel efi_status_t (__efiapi *hash_log_extend_event)(efi_tcg2_protocol_t *, 8644da87c51SArd Biesheuvel u64, 8654da87c51SArd Biesheuvel efi_physical_addr_t, 8664da87c51SArd Biesheuvel u64, 8674da87c51SArd Biesheuvel const efi_tcg2_event_t *); 8688166ec09SArd Biesheuvel void *submit_command; 8698166ec09SArd Biesheuvel void *get_active_pcr_banks; 8708166ec09SArd Biesheuvel void *set_active_pcr_banks; 8718166ec09SArd Biesheuvel void *get_result_of_set_active_pcr_banks; 8728166ec09SArd Biesheuvel }; 8738166ec09SArd Biesheuvel struct { 8748166ec09SArd Biesheuvel u32 get_capability; 8758166ec09SArd Biesheuvel u32 get_event_log; 8768166ec09SArd Biesheuvel u32 hash_log_extend_event; 8778166ec09SArd Biesheuvel u32 submit_command; 8788166ec09SArd Biesheuvel u32 get_active_pcr_banks; 8798166ec09SArd Biesheuvel u32 set_active_pcr_banks; 8808166ec09SArd Biesheuvel u32 get_result_of_set_active_pcr_banks; 8818166ec09SArd Biesheuvel } mixed_mode; 8828166ec09SArd Biesheuvel }; 8838166ec09SArd Biesheuvel 8843f68e695SSunil V L struct riscv_efi_boot_protocol { 8853f68e695SSunil V L u64 revision; 8863f68e695SSunil V L 8873f68e695SSunil V L efi_status_t (__efiapi *get_boot_hartid)(struct riscv_efi_boot_protocol *, 8883f68e695SSunil V L unsigned long *boot_hartid); 8893f68e695SSunil V L }; 8903f68e695SSunil V L 8912931d526SArd Biesheuvel typedef union efi_load_file_protocol efi_load_file_protocol_t; 8922931d526SArd Biesheuvel typedef union efi_load_file_protocol efi_load_file2_protocol_t; 8932931d526SArd Biesheuvel 8942931d526SArd Biesheuvel union efi_load_file_protocol { 8952931d526SArd Biesheuvel struct { 8962931d526SArd Biesheuvel efi_status_t (__efiapi *load_file)(efi_load_file_protocol_t *, 8972931d526SArd Biesheuvel efi_device_path_protocol_t *, 8982931d526SArd Biesheuvel bool, unsigned long *, void *); 8992931d526SArd Biesheuvel }; 9002931d526SArd Biesheuvel struct { 9012931d526SArd Biesheuvel u32 load_file; 9022931d526SArd Biesheuvel } mixed_mode; 9032931d526SArd Biesheuvel }; 9042931d526SArd Biesheuvel 9054a568ce2SArvind Sankar typedef struct { 9064a568ce2SArvind Sankar u32 attributes; 9074a568ce2SArvind Sankar u16 file_path_list_length; 9084a568ce2SArvind Sankar u8 variable_data[]; 9094a568ce2SArvind Sankar // efi_char16_t description[]; 9104a568ce2SArvind Sankar // efi_device_path_protocol_t file_path_list[]; 9114a568ce2SArvind Sankar // u8 optional_data[]; 9124a568ce2SArvind Sankar } __packed efi_load_option_t; 9134a568ce2SArvind Sankar 9144a568ce2SArvind Sankar #define EFI_LOAD_OPTION_ACTIVE 0x0001U 9154a568ce2SArvind Sankar #define EFI_LOAD_OPTION_FORCE_RECONNECT 0x0002U 9164a568ce2SArvind Sankar #define EFI_LOAD_OPTION_HIDDEN 0x0008U 9174a568ce2SArvind Sankar #define EFI_LOAD_OPTION_CATEGORY 0x1f00U 9184a568ce2SArvind Sankar #define EFI_LOAD_OPTION_CATEGORY_BOOT 0x0000U 9194a568ce2SArvind Sankar #define EFI_LOAD_OPTION_CATEGORY_APP 0x0100U 9204a568ce2SArvind Sankar 9214a568ce2SArvind Sankar #define EFI_LOAD_OPTION_BOOT_MASK \ 9224a568ce2SArvind Sankar (EFI_LOAD_OPTION_ACTIVE|EFI_LOAD_OPTION_HIDDEN|EFI_LOAD_OPTION_CATEGORY) 9234a568ce2SArvind Sankar #define EFI_LOAD_OPTION_MASK (EFI_LOAD_OPTION_FORCE_RECONNECT|EFI_LOAD_OPTION_BOOT_MASK) 9244a568ce2SArvind Sankar 9254a568ce2SArvind Sankar typedef struct { 9264a568ce2SArvind Sankar u32 attributes; 9274a568ce2SArvind Sankar u16 file_path_list_length; 9284a568ce2SArvind Sankar const efi_char16_t *description; 9294a568ce2SArvind Sankar const efi_device_path_protocol_t *file_path_list; 930a241d94bSArd Biesheuvel u32 optional_data_size; 9314a568ce2SArvind Sankar const void *optional_data; 9324a568ce2SArvind Sankar } efi_load_option_unpacked_t; 9334a568ce2SArvind Sankar 9348166ec09SArd Biesheuvel void efi_pci_disable_bridge_busmaster(void); 9358166ec09SArd Biesheuvel 9368166ec09SArd Biesheuvel typedef efi_status_t (*efi_exit_boot_map_processing)( 9378166ec09SArd Biesheuvel struct efi_boot_memmap *map, 9388166ec09SArd Biesheuvel void *priv); 9398166ec09SArd Biesheuvel 940eab31265SArd Biesheuvel efi_status_t efi_exit_boot_services(void *handle, void *priv, 9418166ec09SArd Biesheuvel efi_exit_boot_map_processing priv_func); 9428166ec09SArd Biesheuvel 9434fc8e738SArd Biesheuvel efi_status_t efi_boot_kernel(void *handle, efi_loaded_image_t *image, 9444fc8e738SArd Biesheuvel unsigned long kernel_addr, char *cmdline_ptr); 9458166ec09SArd Biesheuvel 9468166ec09SArd Biesheuvel void *get_fdt(unsigned long *fdt_size); 9478166ec09SArd Biesheuvel 948f80d2604SArd Biesheuvel efi_status_t efi_alloc_virtmap(efi_memory_desc_t **virtmap, 949f80d2604SArd Biesheuvel unsigned long *desc_size, u32 *desc_ver); 9508166ec09SArd Biesheuvel void efi_get_virtmap(efi_memory_desc_t *memory_map, unsigned long map_size, 9518166ec09SArd Biesheuvel unsigned long desc_size, efi_memory_desc_t *runtime_map, 9528166ec09SArd Biesheuvel int *count); 9538166ec09SArd Biesheuvel 9548166ec09SArd Biesheuvel efi_status_t efi_get_random_bytes(unsigned long size, u8 *out); 9558166ec09SArd Biesheuvel 9568166ec09SArd Biesheuvel efi_status_t efi_random_alloc(unsigned long size, unsigned long align, 9579cf42bcaSArd Biesheuvel unsigned long *addr, unsigned long random_seed, 9589cf42bcaSArd Biesheuvel int memory_type); 9598166ec09SArd Biesheuvel 960196dff27SArd Biesheuvel efi_status_t efi_random_get_seed(void); 961196dff27SArd Biesheuvel 9628166ec09SArd Biesheuvel efi_status_t check_platform_features(void); 9638166ec09SArd Biesheuvel 9648166ec09SArd Biesheuvel void *get_efi_config_table(efi_guid_t guid); 9658166ec09SArd Biesheuvel 966cb8c90a0SArvind Sankar /* NOTE: These functions do not print a trailing newline after the string */ 967cb8c90a0SArvind Sankar void efi_char16_puts(efi_char16_t *); 968cb8c90a0SArvind Sankar void efi_puts(const char *str); 9698166ec09SArd Biesheuvel 9702c7d1e30SArvind Sankar __printf(1, 2) int efi_printk(char const *fmt, ...); 9718166ec09SArd Biesheuvel 9728166ec09SArd Biesheuvel void efi_free(unsigned long size, unsigned long addr); 9738166ec09SArd Biesheuvel 974a241d94bSArd Biesheuvel void efi_apply_loadoptions_quirk(const void **load_options, u32 *load_options_size); 9754a568ce2SArvind Sankar 97627cd5511SArd Biesheuvel char *efi_convert_cmdline(efi_loaded_image_t *image, int *cmd_line_len); 9778166ec09SArd Biesheuvel 978171539f5SArd Biesheuvel efi_status_t efi_get_memory_map(struct efi_boot_memmap **map, 979171539f5SArd Biesheuvel bool install_cfg_tbl); 9808166ec09SArd Biesheuvel 9818166ec09SArd Biesheuvel efi_status_t efi_allocate_pages(unsigned long size, unsigned long *addr, 9828166ec09SArd Biesheuvel unsigned long max); 9838166ec09SArd Biesheuvel 98443b1df0eSArd Biesheuvel efi_status_t efi_allocate_pages_aligned(unsigned long size, unsigned long *addr, 9859cf42bcaSArd Biesheuvel unsigned long max, unsigned long align, 9869cf42bcaSArd Biesheuvel int memory_type); 98743b1df0eSArd Biesheuvel 9881a895dbfSArd Biesheuvel efi_status_t efi_low_alloc_above(unsigned long size, unsigned long align, 9891a895dbfSArd Biesheuvel unsigned long *addr, unsigned long min); 9901a895dbfSArd Biesheuvel 9918166ec09SArd Biesheuvel efi_status_t efi_relocate_kernel(unsigned long *image_addr, 9928166ec09SArd Biesheuvel unsigned long image_size, 9938166ec09SArd Biesheuvel unsigned long alloc_size, 9948166ec09SArd Biesheuvel unsigned long preferred_addr, 9958166ec09SArd Biesheuvel unsigned long alignment, 9968166ec09SArd Biesheuvel unsigned long min_addr); 9978166ec09SArd Biesheuvel 9988166ec09SArd Biesheuvel efi_status_t efi_parse_options(char const *cmdline); 9998166ec09SArd Biesheuvel 1000fffb6804SArvind Sankar void efi_parse_option_graphics(char *option); 1001fffb6804SArvind Sankar 10028166ec09SArd Biesheuvel efi_status_t efi_setup_gop(struct screen_info *si, efi_guid_t *proto, 10038166ec09SArd Biesheuvel unsigned long size); 10048166ec09SArd Biesheuvel 1005cf6b8366SArd Biesheuvel efi_status_t handle_cmdline_files(efi_loaded_image_t *image, 1006cf6b8366SArd Biesheuvel const efi_char16_t *optstr, 1007cf6b8366SArd Biesheuvel int optstr_size, 1008cf6b8366SArd Biesheuvel unsigned long soft_limit, 1009cf6b8366SArd Biesheuvel unsigned long hard_limit, 10109302c1bbSArd Biesheuvel unsigned long *load_addr, 10119302c1bbSArd Biesheuvel unsigned long *load_size); 10129302c1bbSArd Biesheuvel 1013cf6b8366SArd Biesheuvel 1014cf6b8366SArd Biesheuvel static inline efi_status_t efi_load_dtb(efi_loaded_image_t *image, 1015cf6b8366SArd Biesheuvel unsigned long *load_addr, 1016cf6b8366SArd Biesheuvel unsigned long *load_size) 1017cf6b8366SArd Biesheuvel { 1018cf6b8366SArd Biesheuvel return handle_cmdline_files(image, L"dtb=", sizeof(L"dtb=") - 2, 1019cf6b8366SArd Biesheuvel ULONG_MAX, ULONG_MAX, load_addr, load_size); 1020cf6b8366SArd Biesheuvel } 1021cf6b8366SArd Biesheuvel 1022f61900fdSArvind Sankar efi_status_t efi_load_initrd(efi_loaded_image_t *image, 102331f5e546SArd Biesheuvel unsigned long soft_limit, 1024f4dc7fffSArd Biesheuvel unsigned long hard_limit, 1025f4dc7fffSArd Biesheuvel const struct linux_efi_initrd **out); 10263230d95cSAtish Patra /* 10273230d95cSAtish Patra * This function handles the architcture specific differences between arm and 10283230d95cSAtish Patra * arm64 regarding where the kernel image must be loaded and any memory that 10293230d95cSAtish Patra * must be reserved. On failure it is required to free all 10303230d95cSAtish Patra * all allocations it has made. 10313230d95cSAtish Patra */ 10323230d95cSAtish Patra efi_status_t handle_kernel_image(unsigned long *image_addr, 10333230d95cSAtish Patra unsigned long *image_size, 10343230d95cSAtish Patra unsigned long *reserve_addr, 10353230d95cSAtish Patra unsigned long *reserve_size, 1036416a9f84SArd Biesheuvel efi_loaded_image_t *image, 1037416a9f84SArd Biesheuvel efi_handle_t image_handle); 10383230d95cSAtish Patra 103942c8ea3dSArd Biesheuvel /* shared entrypoint between the normal stub and the zboot stub */ 104042c8ea3dSArd Biesheuvel efi_status_t efi_stub_common(efi_handle_t handle, 104142c8ea3dSArd Biesheuvel efi_loaded_image_t *image, 104242c8ea3dSArd Biesheuvel unsigned long image_addr, 104342c8ea3dSArd Biesheuvel char *cmdline_ptr); 104442c8ea3dSArd Biesheuvel 104542c8ea3dSArd Biesheuvel efi_status_t efi_handle_cmdline(efi_loaded_image_t *image, char **cmdline_ptr); 104642c8ea3dSArd Biesheuvel 10473230d95cSAtish Patra asmlinkage void __noreturn efi_enter_kernel(unsigned long entrypoint, 10483230d95cSAtish Patra unsigned long fdt_addr, 10493230d95cSAtish Patra unsigned long fdt_size); 1050ec93fc37SArd Biesheuvel 10512a55280aSArd Biesheuvel void efi_handle_post_ebs_state(void); 10522a55280aSArd Biesheuvel 1053e1ac4b24SChester Lin enum efi_secureboot_mode efi_get_secureboot(void); 1054e1ac4b24SChester Lin 10553820749dSArd Biesheuvel #ifdef CONFIG_RESET_ATTACK_MITIGATION 10563820749dSArd Biesheuvel void efi_enable_reset_attack_mitigation(void); 10573820749dSArd Biesheuvel #else 10583820749dSArd Biesheuvel static inline void 10593820749dSArd Biesheuvel efi_enable_reset_attack_mitigation(void) { } 10603820749dSArd Biesheuvel #endif 10613820749dSArd Biesheuvel 10623820749dSArd Biesheuvel void efi_retrieve_tpm2_eventlog(void); 10633820749dSArd Biesheuvel 1064732ea9dbSArd Biesheuvel struct screen_info *alloc_screen_info(void); 1065*fc3608aaSArd Biesheuvel struct screen_info *__alloc_screen_info(void); 1066732ea9dbSArd Biesheuvel void free_screen_info(struct screen_info *si); 1067732ea9dbSArd Biesheuvel 1068d9ffe524SArd Biesheuvel void efi_cache_sync_image(unsigned long image_base, 1069d9ffe524SArd Biesheuvel unsigned long alloc_size, 1070d9ffe524SArd Biesheuvel unsigned long code_size); 1071d9ffe524SArd Biesheuvel 1072550b33cfSArd Biesheuvel struct efi_smbios_record { 1073550b33cfSArd Biesheuvel u8 type; 1074550b33cfSArd Biesheuvel u8 length; 1075550b33cfSArd Biesheuvel u16 handle; 1076550b33cfSArd Biesheuvel }; 1077550b33cfSArd Biesheuvel 1078eb684408SArd Biesheuvel const struct efi_smbios_record *efi_get_smbios_record(u8 type); 1079eb684408SArd Biesheuvel 1080550b33cfSArd Biesheuvel struct efi_smbios_type1_record { 1081550b33cfSArd Biesheuvel struct efi_smbios_record header; 1082550b33cfSArd Biesheuvel 1083550b33cfSArd Biesheuvel u8 manufacturer; 1084550b33cfSArd Biesheuvel u8 product_name; 1085550b33cfSArd Biesheuvel u8 version; 1086550b33cfSArd Biesheuvel u8 serial_number; 1087550b33cfSArd Biesheuvel efi_guid_t uuid; 1088550b33cfSArd Biesheuvel u8 wakeup_type; 1089550b33cfSArd Biesheuvel u8 sku_number; 1090550b33cfSArd Biesheuvel u8 family; 1091550b33cfSArd Biesheuvel }; 1092550b33cfSArd Biesheuvel 1093eb684408SArd Biesheuvel struct efi_smbios_type4_record { 1094eb684408SArd Biesheuvel struct efi_smbios_record header; 1095eb684408SArd Biesheuvel 1096eb684408SArd Biesheuvel u8 socket; 1097eb684408SArd Biesheuvel u8 processor_type; 1098eb684408SArd Biesheuvel u8 processor_family; 1099eb684408SArd Biesheuvel u8 processor_manufacturer; 1100eb684408SArd Biesheuvel u8 processor_id[8]; 1101eb684408SArd Biesheuvel u8 processor_version; 1102eb684408SArd Biesheuvel u8 voltage; 1103eb684408SArd Biesheuvel u16 external_clock; 1104eb684408SArd Biesheuvel u16 max_speed; 1105eb684408SArd Biesheuvel u16 current_speed; 1106eb684408SArd Biesheuvel u8 status; 1107eb684408SArd Biesheuvel u8 processor_upgrade; 1108eb684408SArd Biesheuvel u16 l1_cache_handle; 1109eb684408SArd Biesheuvel u16 l2_cache_handle; 1110eb684408SArd Biesheuvel u16 l3_cache_handle; 1111eb684408SArd Biesheuvel u8 serial_number; 1112eb684408SArd Biesheuvel u8 asset_tag; 1113eb684408SArd Biesheuvel u8 part_number; 1114eb684408SArd Biesheuvel u8 core_count; 1115eb684408SArd Biesheuvel u8 enabled_core_count; 1116eb684408SArd Biesheuvel u8 thread_count; 1117eb684408SArd Biesheuvel u16 processor_characteristics; 1118eb684408SArd Biesheuvel u16 processor_family2; 1119eb684408SArd Biesheuvel u16 core_count2; 1120eb684408SArd Biesheuvel u16 enabled_core_count2; 1121eb684408SArd Biesheuvel u16 thread_count2; 1122eb684408SArd Biesheuvel u16 thread_enabled; 1123eb684408SArd Biesheuvel }; 1124eb684408SArd Biesheuvel 1125eb684408SArd Biesheuvel #define efi_get_smbios_string(__record, __type, __name) ({ \ 1126550b33cfSArd Biesheuvel int off = offsetof(struct efi_smbios_type ## __type ## _record, \ 1127550b33cfSArd Biesheuvel __name); \ 1128f59a7ec1SArd Biesheuvel __efi_get_smbios_string((__record), __type, off); \ 1129550b33cfSArd Biesheuvel }) 1130550b33cfSArd Biesheuvel 1131eb684408SArd Biesheuvel const u8 *__efi_get_smbios_string(const struct efi_smbios_record *record, 1132f59a7ec1SArd Biesheuvel u8 type, int offset); 1133550b33cfSArd Biesheuvel 1134ace013a5SArd Biesheuvel void efi_remap_image(unsigned long image_base, unsigned alloc_size, 1135ace013a5SArd Biesheuvel unsigned long code_size); 1136ace013a5SArd Biesheuvel 1137f4f75ad5SArd Biesheuvel #endif 1138