^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) #ifndef _DRIVERS_FIRMWARE_EFI_EFISTUB_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) #define _DRIVERS_FIRMWARE_EFI_EFISTUB_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) #include <linux/compiler.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) #include <linux/efi.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) #include <linux/kern_levels.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <linux/types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <asm/efi.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) * __init annotations should not be used in the EFI stub, since the code is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) * either included in the decompressor (x86, ARM) where they have no effect,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) * or the whole stub is __init annotated at the section level (arm64), by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) * renaming the sections, in which case the __init annotation will be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) * redundant, and will result in section names like .init.init.text, and our
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) * linker script does not expect that.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) #undef __init
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) * Allow the platform to override the allocation granularity: this allows
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) * systems that have the capability to run with a larger page size to deal
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) * with the allocations for initrd and fdt more efficiently.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) #ifndef EFI_ALLOC_ALIGN
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) #define EFI_ALLOC_ALIGN EFI_PAGE_SIZE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) extern bool efi_nochunk;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) extern bool efi_nokaslr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) extern bool efi_noinitrd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) extern int efi_loglevel;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) extern bool efi_novamap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) extern const efi_system_table_t *efi_system_table;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) efi_status_t __efiapi efi_pe_entry(efi_handle_t handle,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) efi_system_table_t *sys_table_arg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) #ifndef ARCH_HAS_EFISTUB_WRAPPERS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) #define efi_is_native() (true)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) #define efi_bs_call(func, ...) efi_system_table->boottime->func(__VA_ARGS__)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) #define efi_rt_call(func, ...) efi_system_table->runtime->func(__VA_ARGS__)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) #define efi_table_attr(inst, attr) (inst->attr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) #define efi_call_proto(inst, func, ...) inst->func(inst, ##__VA_ARGS__)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) #define efi_info(fmt, ...) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) efi_printk(KERN_INFO fmt, ##__VA_ARGS__)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) #define efi_warn(fmt, ...) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) efi_printk(KERN_WARNING "WARNING: " fmt, ##__VA_ARGS__)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) #define efi_err(fmt, ...) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) efi_printk(KERN_ERR "ERROR: " fmt, ##__VA_ARGS__)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) #define efi_debug(fmt, ...) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) efi_printk(KERN_DEBUG "DEBUG: " fmt, ##__VA_ARGS__)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) #define efi_printk_once(fmt, ...) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) ({ \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) static bool __print_once; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) bool __ret_print_once = !__print_once; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) if (!__print_once) { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) __print_once = true; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) efi_printk(fmt, ##__VA_ARGS__); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) } \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) __ret_print_once; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) })
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) #define efi_info_once(fmt, ...) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) efi_printk_once(KERN_INFO fmt, ##__VA_ARGS__)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) #define efi_warn_once(fmt, ...) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) efi_printk_once(KERN_WARNING "WARNING: " fmt, ##__VA_ARGS__)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) #define efi_err_once(fmt, ...) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) efi_printk_once(KERN_ERR "ERROR: " fmt, ##__VA_ARGS__)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) #define efi_debug_once(fmt, ...) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) efi_printk_once(KERN_DEBUG "DEBUG: " fmt, ##__VA_ARGS__)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) /* Helper macros for the usual case of using simple C variables: */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) #ifndef fdt_setprop_inplace_var
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) #define fdt_setprop_inplace_var(fdt, node_offset, name, var) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) fdt_setprop_inplace((fdt), (node_offset), (name), &(var), sizeof(var))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) #ifndef fdt_setprop_var
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) #define fdt_setprop_var(fdt, node_offset, name, var) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) fdt_setprop((fdt), (node_offset), (name), &(var), sizeof(var))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) #define get_efi_var(name, vendor, ...) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) efi_rt_call(get_variable, (efi_char16_t *)(name), \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) (efi_guid_t *)(vendor), __VA_ARGS__)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) #define set_efi_var(name, vendor, ...) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) efi_rt_call(set_variable, (efi_char16_t *)(name), \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) (efi_guid_t *)(vendor), __VA_ARGS__)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) #define efi_get_handle_at(array, idx) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) (efi_is_native() ? (array)[idx] \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) : (efi_handle_t)(unsigned long)((u32 *)(array))[idx])
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) #define efi_get_handle_num(size) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) ((size) / (efi_is_native() ? sizeof(efi_handle_t) : sizeof(u32)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) #define for_each_efi_handle(handle, array, size, i) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) for (i = 0; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) i < efi_get_handle_num(size) && \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) ((handle = efi_get_handle_at((array), i)) || true); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) static inline
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) void efi_set_u64_split(u64 data, u32 *lo, u32 *hi)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) *lo = lower_32_bits(data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) *hi = upper_32_bits(data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) * Allocation types for calls to boottime->allocate_pages.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) #define EFI_ALLOCATE_ANY_PAGES 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) #define EFI_ALLOCATE_MAX_ADDRESS 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) #define EFI_ALLOCATE_ADDRESS 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) #define EFI_MAX_ALLOCATE_TYPE 3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) * The type of search to perform when calling boottime->locate_handle
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) #define EFI_LOCATE_ALL_HANDLES 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) #define EFI_LOCATE_BY_REGISTER_NOTIFY 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) #define EFI_LOCATE_BY_PROTOCOL 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) * boottime->stall takes the time period in microseconds
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) #define EFI_USEC_PER_SEC 1000000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) * boottime->set_timer takes the time in 100ns units
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) #define EFI_100NSEC_PER_USEC ((u64)10)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) * An efi_boot_memmap is used by efi_get_memory_map() to return the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) * EFI memory map in a dynamically allocated buffer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) * The buffer allocated for the EFI memory map includes extra room for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) * a minimum of EFI_MMAP_NR_SLACK_SLOTS additional EFI memory descriptors.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) * This facilitates the reuse of the EFI memory map buffer when a second
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) * call to ExitBootServices() is needed because of intervening changes to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) * the EFI memory map. Other related structures, e.g. x86 e820ext, need
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) * to factor in this headroom requirement as well.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) #define EFI_MMAP_NR_SLACK_SLOTS 8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) struct efi_boot_memmap {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) efi_memory_desc_t **map;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) unsigned long *map_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) unsigned long *desc_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) u32 *desc_ver;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) unsigned long *key_ptr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) unsigned long *buff_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) typedef struct efi_generic_dev_path efi_device_path_protocol_t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) typedef void *efi_event_t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) /* Note that notifications won't work in mixed mode */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) typedef void (__efiapi *efi_event_notify_t)(efi_event_t, void *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) #define EFI_EVT_TIMER 0x80000000U
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) #define EFI_EVT_RUNTIME 0x40000000U
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) #define EFI_EVT_NOTIFY_WAIT 0x00000100U
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) #define EFI_EVT_NOTIFY_SIGNAL 0x00000200U
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) * efi_set_event_at() - add event to events array
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) * @events: array of UEFI events
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) * @ids: index where to put the event in the array
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) * @event: event to add to the aray
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) * boottime->wait_for_event() takes an array of events as input.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) * Provide a helper to set it up correctly for mixed mode.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) static inline
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) void efi_set_event_at(efi_event_t *events, size_t idx, efi_event_t event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) if (efi_is_native())
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) events[idx] = event;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) ((u32 *)events)[idx] = (u32)(unsigned long)event;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) #define EFI_TPL_APPLICATION 4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) #define EFI_TPL_CALLBACK 8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) #define EFI_TPL_NOTIFY 16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) #define EFI_TPL_HIGH_LEVEL 31
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) typedef enum {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) EfiTimerCancel,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) EfiTimerPeriodic,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) EfiTimerRelative
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) } EFI_TIMER_DELAY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) * EFI Boot Services table
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) union efi_boot_services {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) efi_table_hdr_t hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) void *raise_tpl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) void *restore_tpl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) efi_status_t (__efiapi *allocate_pages)(int, int, unsigned long,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) efi_physical_addr_t *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) efi_status_t (__efiapi *free_pages)(efi_physical_addr_t,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) unsigned long);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) efi_status_t (__efiapi *get_memory_map)(unsigned long *, void *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) unsigned long *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) unsigned long *, u32 *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) efi_status_t (__efiapi *allocate_pool)(int, unsigned long,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) void **);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) efi_status_t (__efiapi *free_pool)(void *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) efi_status_t (__efiapi *create_event)(u32, unsigned long,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) efi_event_notify_t, void *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) efi_event_t *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) efi_status_t (__efiapi *set_timer)(efi_event_t,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) EFI_TIMER_DELAY, u64);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) efi_status_t (__efiapi *wait_for_event)(unsigned long,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) efi_event_t *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) unsigned long *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) void *signal_event;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) efi_status_t (__efiapi *close_event)(efi_event_t);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) void *check_event;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) void *install_protocol_interface;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) void *reinstall_protocol_interface;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) void *uninstall_protocol_interface;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) efi_status_t (__efiapi *handle_protocol)(efi_handle_t,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) efi_guid_t *, void **);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) void *__reserved;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) void *register_protocol_notify;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) efi_status_t (__efiapi *locate_handle)(int, efi_guid_t *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) void *, unsigned long *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) efi_handle_t *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) efi_status_t (__efiapi *locate_device_path)(efi_guid_t *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) efi_device_path_protocol_t **,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) efi_handle_t *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) efi_status_t (__efiapi *install_configuration_table)(efi_guid_t *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) void *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) void *load_image;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) void *start_image;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) efi_status_t __noreturn (__efiapi *exit)(efi_handle_t,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) efi_status_t,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) unsigned long,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) efi_char16_t *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) void *unload_image;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) efi_status_t (__efiapi *exit_boot_services)(efi_handle_t,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) unsigned long);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) void *get_next_monotonic_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) efi_status_t (__efiapi *stall)(unsigned long);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) void *set_watchdog_timer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) void *connect_controller;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) efi_status_t (__efiapi *disconnect_controller)(efi_handle_t,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) efi_handle_t,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) efi_handle_t);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) void *open_protocol;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) void *close_protocol;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) void *open_protocol_information;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) void *protocols_per_handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) void *locate_handle_buffer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) efi_status_t (__efiapi *locate_protocol)(efi_guid_t *, void *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) void **);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) void *install_multiple_protocol_interfaces;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) void *uninstall_multiple_protocol_interfaces;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) void *calculate_crc32;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) void *copy_mem;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) void *set_mem;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) void *create_event_ex;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) efi_table_hdr_t hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) u32 raise_tpl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) u32 restore_tpl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) u32 allocate_pages;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) u32 free_pages;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) u32 get_memory_map;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) u32 allocate_pool;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) u32 free_pool;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) u32 create_event;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) u32 set_timer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) u32 wait_for_event;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) u32 signal_event;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) u32 close_event;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) u32 check_event;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) u32 install_protocol_interface;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) u32 reinstall_protocol_interface;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) u32 uninstall_protocol_interface;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) u32 handle_protocol;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) u32 __reserved;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) u32 register_protocol_notify;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) u32 locate_handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) u32 locate_device_path;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) u32 install_configuration_table;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) u32 load_image;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) u32 start_image;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) u32 exit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) u32 unload_image;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) u32 exit_boot_services;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) u32 get_next_monotonic_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) u32 stall;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) u32 set_watchdog_timer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) u32 connect_controller;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) u32 disconnect_controller;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) u32 open_protocol;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) u32 close_protocol;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) u32 open_protocol_information;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) u32 protocols_per_handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) u32 locate_handle_buffer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) u32 locate_protocol;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) u32 install_multiple_protocol_interfaces;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) u32 uninstall_multiple_protocol_interfaces;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) u32 calculate_crc32;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) u32 copy_mem;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) u32 set_mem;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) u32 create_event_ex;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) } mixed_mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) typedef union efi_uga_draw_protocol efi_uga_draw_protocol_t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) union efi_uga_draw_protocol {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) efi_status_t (__efiapi *get_mode)(efi_uga_draw_protocol_t *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) u32*, u32*, u32*, u32*);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) void *set_mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) void *blt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) u32 get_mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) u32 set_mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) u32 blt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) } mixed_mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) typedef struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) u16 scan_code;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) efi_char16_t unicode_char;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) } efi_input_key_t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) union efi_simple_text_input_protocol {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) void *reset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) efi_status_t (__efiapi *read_keystroke)(efi_simple_text_input_protocol_t *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) efi_input_key_t *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) efi_event_t wait_for_key;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) u32 reset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) u32 read_keystroke;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) u32 wait_for_key;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) } mixed_mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) efi_status_t efi_wait_for_key(unsigned long usec, efi_input_key_t *key);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) union efi_simple_text_output_protocol {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) void *reset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) efi_status_t (__efiapi *output_string)(efi_simple_text_output_protocol_t *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) efi_char16_t *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) void *test_string;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) u32 reset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) u32 output_string;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) u32 test_string;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) } mixed_mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) #define PIXEL_RGB_RESERVED_8BIT_PER_COLOR 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) #define PIXEL_BGR_RESERVED_8BIT_PER_COLOR 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) #define PIXEL_BIT_MASK 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) #define PIXEL_BLT_ONLY 3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) #define PIXEL_FORMAT_MAX 4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) typedef struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) u32 red_mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) u32 green_mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) u32 blue_mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) u32 reserved_mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) } efi_pixel_bitmask_t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) typedef struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) u32 version;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) u32 horizontal_resolution;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) u32 vertical_resolution;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) int pixel_format;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) efi_pixel_bitmask_t pixel_information;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) u32 pixels_per_scan_line;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) } efi_graphics_output_mode_info_t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) typedef union efi_graphics_output_protocol_mode efi_graphics_output_protocol_mode_t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) union efi_graphics_output_protocol_mode {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) u32 max_mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) u32 mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) efi_graphics_output_mode_info_t *info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) unsigned long size_of_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) efi_physical_addr_t frame_buffer_base;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) unsigned long frame_buffer_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) u32 max_mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) u32 mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) u32 info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) u32 size_of_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) u64 frame_buffer_base;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) u32 frame_buffer_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) } mixed_mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) typedef union efi_graphics_output_protocol efi_graphics_output_protocol_t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) union efi_graphics_output_protocol {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) efi_status_t (__efiapi *query_mode)(efi_graphics_output_protocol_t *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) u32, unsigned long *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) efi_graphics_output_mode_info_t **);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) efi_status_t (__efiapi *set_mode) (efi_graphics_output_protocol_t *, u32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) void *blt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) efi_graphics_output_protocol_mode_t *mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) u32 query_mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) u32 set_mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) u32 blt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) u32 mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) } mixed_mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) typedef union {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) u32 revision;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) efi_handle_t parent_handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) efi_system_table_t *system_table;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) efi_handle_t device_handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) void *file_path;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) void *reserved;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) u32 load_options_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) void *load_options;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) void *image_base;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) __aligned_u64 image_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) unsigned int image_code_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) unsigned int image_data_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) efi_status_t (__efiapi *unload)(efi_handle_t image_handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) u32 revision;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) u32 parent_handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) u32 system_table;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) u32 device_handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) u32 file_path;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) u32 reserved;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) u32 load_options_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) u32 load_options;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) u32 image_base;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) __aligned_u64 image_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) u32 image_code_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) u32 image_data_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) u32 unload;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) } mixed_mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) } efi_loaded_image_t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) typedef struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) u64 size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) u64 file_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) u64 phys_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) efi_time_t create_time;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) efi_time_t last_access_time;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) efi_time_t modification_time;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) __aligned_u64 attribute;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) efi_char16_t filename[];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) } efi_file_info_t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) typedef struct efi_file_protocol efi_file_protocol_t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) struct efi_file_protocol {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) u64 revision;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) efi_status_t (__efiapi *open) (efi_file_protocol_t *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) efi_file_protocol_t **,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) efi_char16_t *, u64, u64);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) efi_status_t (__efiapi *close) (efi_file_protocol_t *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498) efi_status_t (__efiapi *delete) (efi_file_protocol_t *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) efi_status_t (__efiapi *read) (efi_file_protocol_t *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) unsigned long *, void *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) efi_status_t (__efiapi *write) (efi_file_protocol_t *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) unsigned long, void *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) efi_status_t (__efiapi *get_position)(efi_file_protocol_t *, u64 *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504) efi_status_t (__efiapi *set_position)(efi_file_protocol_t *, u64);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505) efi_status_t (__efiapi *get_info) (efi_file_protocol_t *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506) efi_guid_t *, unsigned long *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507) void *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) efi_status_t (__efiapi *set_info) (efi_file_protocol_t *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509) efi_guid_t *, unsigned long,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) void *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) efi_status_t (__efiapi *flush) (efi_file_protocol_t *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514) typedef struct efi_simple_file_system_protocol efi_simple_file_system_protocol_t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516) struct efi_simple_file_system_protocol {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517) u64 revision;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518) int (__efiapi *open_volume)(efi_simple_file_system_protocol_t *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519) efi_file_protocol_t **);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522) #define EFI_FILE_MODE_READ 0x0000000000000001
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523) #define EFI_FILE_MODE_WRITE 0x0000000000000002
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524) #define EFI_FILE_MODE_CREATE 0x8000000000000000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526) typedef enum {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527) EfiPciIoWidthUint8,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528) EfiPciIoWidthUint16,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529) EfiPciIoWidthUint32,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530) EfiPciIoWidthUint64,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531) EfiPciIoWidthFifoUint8,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532) EfiPciIoWidthFifoUint16,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533) EfiPciIoWidthFifoUint32,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534) EfiPciIoWidthFifoUint64,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535) EfiPciIoWidthFillUint8,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 536) EfiPciIoWidthFillUint16,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 537) EfiPciIoWidthFillUint32,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 538) EfiPciIoWidthFillUint64,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 539) EfiPciIoWidthMaximum
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 540) } EFI_PCI_IO_PROTOCOL_WIDTH;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 541)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 542) typedef enum {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 543) EfiPciIoAttributeOperationGet,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 544) EfiPciIoAttributeOperationSet,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 545) EfiPciIoAttributeOperationEnable,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 546) EfiPciIoAttributeOperationDisable,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 547) EfiPciIoAttributeOperationSupported,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 548) EfiPciIoAttributeOperationMaximum
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 549) } EFI_PCI_IO_PROTOCOL_ATTRIBUTE_OPERATION;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 550)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 551) typedef struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 552) u32 read;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 553) u32 write;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 554) } efi_pci_io_protocol_access_32_t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 555)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 556) typedef union efi_pci_io_protocol efi_pci_io_protocol_t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 557)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 558) typedef
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 559) efi_status_t (__efiapi *efi_pci_io_protocol_cfg_t)(efi_pci_io_protocol_t *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 560) EFI_PCI_IO_PROTOCOL_WIDTH,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 561) u32 offset,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 562) unsigned long count,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 563) void *buffer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 564)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 565) typedef struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 566) void *read;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 567) void *write;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 568) } efi_pci_io_protocol_access_t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 569)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 570) typedef struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 571) efi_pci_io_protocol_cfg_t read;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 572) efi_pci_io_protocol_cfg_t write;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 573) } efi_pci_io_protocol_config_access_t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 574)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 575) union efi_pci_io_protocol {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 576) struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 577) void *poll_mem;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 578) void *poll_io;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 579) efi_pci_io_protocol_access_t mem;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 580) efi_pci_io_protocol_access_t io;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 581) efi_pci_io_protocol_config_access_t pci;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 582) void *copy_mem;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 583) void *map;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 584) void *unmap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 585) void *allocate_buffer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 586) void *free_buffer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 587) void *flush;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 588) efi_status_t (__efiapi *get_location)(efi_pci_io_protocol_t *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 589) unsigned long *segment_nr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 590) unsigned long *bus_nr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 591) unsigned long *device_nr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 592) unsigned long *func_nr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 593) void *attributes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 594) void *get_bar_attributes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 595) void *set_bar_attributes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 596) uint64_t romsize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 597) void *romimage;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 598) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 599) struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 600) u32 poll_mem;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 601) u32 poll_io;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 602) efi_pci_io_protocol_access_32_t mem;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 603) efi_pci_io_protocol_access_32_t io;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 604) efi_pci_io_protocol_access_32_t pci;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 605) u32 copy_mem;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 606) u32 map;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 607) u32 unmap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 608) u32 allocate_buffer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 609) u32 free_buffer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 610) u32 flush;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 611) u32 get_location;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 612) u32 attributes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 613) u32 get_bar_attributes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 614) u32 set_bar_attributes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 615) u64 romsize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 616) u32 romimage;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 617) } mixed_mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 618) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 619)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 620) #define EFI_PCI_IO_ATTRIBUTE_ISA_MOTHERBOARD_IO 0x0001
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 621) #define EFI_PCI_IO_ATTRIBUTE_ISA_IO 0x0002
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 622) #define EFI_PCI_IO_ATTRIBUTE_VGA_PALETTE_IO 0x0004
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 623) #define EFI_PCI_IO_ATTRIBUTE_VGA_MEMORY 0x0008
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 624) #define EFI_PCI_IO_ATTRIBUTE_VGA_IO 0x0010
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 625) #define EFI_PCI_IO_ATTRIBUTE_IDE_PRIMARY_IO 0x0020
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 626) #define EFI_PCI_IO_ATTRIBUTE_IDE_SECONDARY_IO 0x0040
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 627) #define EFI_PCI_IO_ATTRIBUTE_MEMORY_WRITE_COMBINE 0x0080
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 628) #define EFI_PCI_IO_ATTRIBUTE_IO 0x0100
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 629) #define EFI_PCI_IO_ATTRIBUTE_MEMORY 0x0200
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 630) #define EFI_PCI_IO_ATTRIBUTE_BUS_MASTER 0x0400
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 631) #define EFI_PCI_IO_ATTRIBUTE_MEMORY_CACHED 0x0800
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 632) #define EFI_PCI_IO_ATTRIBUTE_MEMORY_DISABLE 0x1000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 633) #define EFI_PCI_IO_ATTRIBUTE_EMBEDDED_DEVICE 0x2000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 634) #define EFI_PCI_IO_ATTRIBUTE_EMBEDDED_ROM 0x4000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 635) #define EFI_PCI_IO_ATTRIBUTE_DUAL_ADDRESS_CYCLE 0x8000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 636) #define EFI_PCI_IO_ATTRIBUTE_ISA_IO_16 0x10000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 637) #define EFI_PCI_IO_ATTRIBUTE_VGA_PALETTE_IO_16 0x20000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 638) #define EFI_PCI_IO_ATTRIBUTE_VGA_IO_16 0x40000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 639)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 640) struct efi_dev_path;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 641)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 642) typedef union apple_properties_protocol apple_properties_protocol_t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 643)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 644) union apple_properties_protocol {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 645) struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 646) unsigned long version;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 647) efi_status_t (__efiapi *get)(apple_properties_protocol_t *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 648) struct efi_dev_path *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 649) efi_char16_t *, void *, u32 *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 650) efi_status_t (__efiapi *set)(apple_properties_protocol_t *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 651) struct efi_dev_path *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 652) efi_char16_t *, void *, u32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 653) efi_status_t (__efiapi *del)(apple_properties_protocol_t *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 654) struct efi_dev_path *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 655) efi_char16_t *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 656) efi_status_t (__efiapi *get_all)(apple_properties_protocol_t *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 657) void *buffer, u32 *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 658) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 659) struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 660) u32 version;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 661) u32 get;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 662) u32 set;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 663) u32 del;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 664) u32 get_all;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 665) } mixed_mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 666) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 667)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 668) typedef u32 efi_tcg2_event_log_format;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 669)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 670) typedef union efi_tcg2_protocol efi_tcg2_protocol_t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 671)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 672) union efi_tcg2_protocol {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 673) struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 674) void *get_capability;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 675) efi_status_t (__efiapi *get_event_log)(efi_handle_t,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 676) efi_tcg2_event_log_format,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 677) efi_physical_addr_t *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 678) efi_physical_addr_t *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 679) efi_bool_t *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 680) void *hash_log_extend_event;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 681) void *submit_command;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 682) void *get_active_pcr_banks;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 683) void *set_active_pcr_banks;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 684) void *get_result_of_set_active_pcr_banks;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 685) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 686) struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 687) u32 get_capability;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 688) u32 get_event_log;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 689) u32 hash_log_extend_event;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 690) u32 submit_command;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 691) u32 get_active_pcr_banks;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 692) u32 set_active_pcr_banks;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 693) u32 get_result_of_set_active_pcr_banks;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 694) } mixed_mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 695) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 696)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 697) typedef union efi_load_file_protocol efi_load_file_protocol_t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 698) typedef union efi_load_file_protocol efi_load_file2_protocol_t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 699)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 700) union efi_load_file_protocol {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 701) struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 702) efi_status_t (__efiapi *load_file)(efi_load_file_protocol_t *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 703) efi_device_path_protocol_t *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 704) bool, unsigned long *, void *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 705) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 706) struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 707) u32 load_file;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 708) } mixed_mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 709) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 710)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 711) typedef struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 712) u32 attributes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 713) u16 file_path_list_length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 714) u8 variable_data[];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 715) // efi_char16_t description[];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 716) // efi_device_path_protocol_t file_path_list[];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 717) // u8 optional_data[];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 718) } __packed efi_load_option_t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 719)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 720) #define EFI_LOAD_OPTION_ACTIVE 0x0001U
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 721) #define EFI_LOAD_OPTION_FORCE_RECONNECT 0x0002U
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 722) #define EFI_LOAD_OPTION_HIDDEN 0x0008U
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 723) #define EFI_LOAD_OPTION_CATEGORY 0x1f00U
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 724) #define EFI_LOAD_OPTION_CATEGORY_BOOT 0x0000U
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 725) #define EFI_LOAD_OPTION_CATEGORY_APP 0x0100U
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 726)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 727) #define EFI_LOAD_OPTION_BOOT_MASK \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 728) (EFI_LOAD_OPTION_ACTIVE|EFI_LOAD_OPTION_HIDDEN|EFI_LOAD_OPTION_CATEGORY)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 729) #define EFI_LOAD_OPTION_MASK (EFI_LOAD_OPTION_FORCE_RECONNECT|EFI_LOAD_OPTION_BOOT_MASK)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 730)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 731) typedef struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 732) u32 attributes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 733) u16 file_path_list_length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 734) const efi_char16_t *description;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 735) const efi_device_path_protocol_t *file_path_list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 736) size_t optional_data_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 737) const void *optional_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 738) } efi_load_option_unpacked_t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 739)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 740) void efi_pci_disable_bridge_busmaster(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 741)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 742) typedef efi_status_t (*efi_exit_boot_map_processing)(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 743) struct efi_boot_memmap *map,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 744) void *priv);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 745)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 746) efi_status_t efi_exit_boot_services(void *handle,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 747) struct efi_boot_memmap *map,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 748) void *priv,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 749) efi_exit_boot_map_processing priv_func);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 750)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 751) efi_status_t allocate_new_fdt_and_exit_boot(void *handle,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 752) unsigned long *new_fdt_addr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 753) unsigned long max_addr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 754) u64 initrd_addr, u64 initrd_size,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 755) char *cmdline_ptr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 756) unsigned long fdt_addr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 757) unsigned long fdt_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 758)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 759) void *get_fdt(unsigned long *fdt_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 760)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 761) void efi_get_virtmap(efi_memory_desc_t *memory_map, unsigned long map_size,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 762) unsigned long desc_size, efi_memory_desc_t *runtime_map,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 763) int *count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 764)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 765) efi_status_t efi_get_random_bytes(unsigned long size, u8 *out);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 766)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 767) efi_status_t efi_random_alloc(unsigned long size, unsigned long align,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 768) unsigned long *addr, unsigned long random_seed);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 769)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 770) efi_status_t check_platform_features(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 771)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 772) void *get_efi_config_table(efi_guid_t guid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 773)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 774) /* NOTE: These functions do not print a trailing newline after the string */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 775) void efi_char16_puts(efi_char16_t *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 776) void efi_puts(const char *str);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 777)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 778) __printf(1, 2) int efi_printk(char const *fmt, ...);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 779)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 780) void efi_free(unsigned long size, unsigned long addr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 781)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 782) void efi_apply_loadoptions_quirk(const void **load_options, int *load_options_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 783)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 784) char *efi_convert_cmdline(efi_loaded_image_t *image, int *cmd_line_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 785)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 786) efi_status_t efi_get_memory_map(struct efi_boot_memmap *map);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 787)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 788) efi_status_t efi_allocate_pages(unsigned long size, unsigned long *addr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 789) unsigned long max);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 790)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 791) efi_status_t efi_allocate_pages_aligned(unsigned long size, unsigned long *addr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 792) unsigned long max, unsigned long align);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 793)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 794) efi_status_t efi_low_alloc_above(unsigned long size, unsigned long align,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 795) unsigned long *addr, unsigned long min);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 796)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 797) efi_status_t efi_relocate_kernel(unsigned long *image_addr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 798) unsigned long image_size,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 799) unsigned long alloc_size,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 800) unsigned long preferred_addr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 801) unsigned long alignment,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 802) unsigned long min_addr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 803)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 804) efi_status_t efi_parse_options(char const *cmdline);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 805)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 806) void efi_parse_option_graphics(char *option);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 807)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 808) efi_status_t efi_setup_gop(struct screen_info *si, efi_guid_t *proto,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 809) unsigned long size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 810)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 811) efi_status_t handle_cmdline_files(efi_loaded_image_t *image,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 812) const efi_char16_t *optstr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 813) int optstr_size,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 814) unsigned long soft_limit,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 815) unsigned long hard_limit,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 816) unsigned long *load_addr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 817) unsigned long *load_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 818)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 819)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 820) static inline efi_status_t efi_load_dtb(efi_loaded_image_t *image,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 821) unsigned long *load_addr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 822) unsigned long *load_size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 823) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 824) return handle_cmdline_files(image, L"dtb=", sizeof(L"dtb=") - 2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 825) ULONG_MAX, ULONG_MAX, load_addr, load_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 826) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 827)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 828) efi_status_t efi_load_initrd(efi_loaded_image_t *image,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 829) unsigned long *load_addr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 830) unsigned long *load_size,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 831) unsigned long soft_limit,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 832) unsigned long hard_limit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 833) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 834) * This function handles the architcture specific differences between arm and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 835) * arm64 regarding where the kernel image must be loaded and any memory that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 836) * must be reserved. On failure it is required to free all
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 837) * all allocations it has made.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 838) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 839) efi_status_t handle_kernel_image(unsigned long *image_addr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 840) unsigned long *image_size,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 841) unsigned long *reserve_addr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 842) unsigned long *reserve_size,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 843) efi_loaded_image_t *image);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 844)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 845) asmlinkage void __noreturn efi_enter_kernel(unsigned long entrypoint,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 846) unsigned long fdt_addr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 847) unsigned long fdt_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 848)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 849) void efi_handle_post_ebs_state(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 850)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 851) #endif