1f4f75ad5SArd Biesheuvel 2f4f75ad5SArd Biesheuvel #ifndef _DRIVERS_FIRMWARE_EFI_EFISTUB_H 3f4f75ad5SArd Biesheuvel #define _DRIVERS_FIRMWARE_EFI_EFISTUB_H 4f4f75ad5SArd Biesheuvel 5f4f75ad5SArd Biesheuvel /* error code which can't be mistaken for valid address */ 6f4f75ad5SArd Biesheuvel #define EFI_ERROR (~0UL) 7f4f75ad5SArd Biesheuvel 807e83dbbSArd Biesheuvel /* 907e83dbbSArd Biesheuvel * __init annotations should not be used in the EFI stub, since the code is 1007e83dbbSArd Biesheuvel * either included in the decompressor (x86, ARM) where they have no effect, 1107e83dbbSArd Biesheuvel * or the whole stub is __init annotated at the section level (arm64), by 1207e83dbbSArd Biesheuvel * renaming the sections, in which case the __init annotation will be 1307e83dbbSArd Biesheuvel * redundant, and will result in section names like .init.init.text, and our 1407e83dbbSArd Biesheuvel * linker script does not expect that. 1507e83dbbSArd Biesheuvel */ 1607e83dbbSArd Biesheuvel #undef __init 1707e83dbbSArd Biesheuvel 18a6a14469SArd Biesheuvel /* 19a6a14469SArd Biesheuvel * Allow the platform to override the allocation granularity: this allows 20a6a14469SArd Biesheuvel * systems that have the capability to run with a larger page size to deal 21a6a14469SArd Biesheuvel * with the allocations for initrd and fdt more efficiently. 22a6a14469SArd Biesheuvel */ 23a6a14469SArd Biesheuvel #ifndef EFI_ALLOC_ALIGN 24a6a14469SArd Biesheuvel #define EFI_ALLOC_ALIGN EFI_PAGE_SIZE 25a6a14469SArd Biesheuvel #endif 26a6a14469SArd Biesheuvel 27f4f75ad5SArd Biesheuvel void efi_char16_printk(efi_system_table_t *, efi_char16_t *); 28f4f75ad5SArd Biesheuvel 29f4f75ad5SArd Biesheuvel efi_status_t efi_open_volume(efi_system_table_t *sys_table_arg, void *__image, 30f4f75ad5SArd Biesheuvel void **__fh); 31f4f75ad5SArd Biesheuvel 32f4f75ad5SArd Biesheuvel efi_status_t efi_file_size(efi_system_table_t *sys_table_arg, void *__fh, 33f4f75ad5SArd Biesheuvel efi_char16_t *filename_16, void **handle, 34f4f75ad5SArd Biesheuvel u64 *file_sz); 35f4f75ad5SArd Biesheuvel 36f4f75ad5SArd Biesheuvel efi_status_t efi_file_read(void *handle, unsigned long *size, void *addr); 37f4f75ad5SArd Biesheuvel 38f4f75ad5SArd Biesheuvel efi_status_t efi_file_close(void *handle); 39f4f75ad5SArd Biesheuvel 40f4f75ad5SArd Biesheuvel unsigned long get_dram_base(efi_system_table_t *sys_table_arg); 41f4f75ad5SArd Biesheuvel 42f4f75ad5SArd Biesheuvel efi_status_t update_fdt(efi_system_table_t *sys_table, void *orig_fdt, 43f4f75ad5SArd Biesheuvel unsigned long orig_fdt_size, 44f4f75ad5SArd Biesheuvel void *fdt, int new_fdt_size, char *cmdline_ptr, 45f4f75ad5SArd Biesheuvel u64 initrd_addr, u64 initrd_size, 46f4f75ad5SArd Biesheuvel efi_memory_desc_t *memory_map, 47f4f75ad5SArd Biesheuvel unsigned long map_size, unsigned long desc_size, 48f4f75ad5SArd Biesheuvel u32 desc_ver); 49f4f75ad5SArd Biesheuvel 50f4f75ad5SArd Biesheuvel efi_status_t allocate_new_fdt_and_exit_boot(efi_system_table_t *sys_table, 51f4f75ad5SArd Biesheuvel void *handle, 52f4f75ad5SArd Biesheuvel unsigned long *new_fdt_addr, 53f4f75ad5SArd Biesheuvel unsigned long max_addr, 54f4f75ad5SArd Biesheuvel u64 initrd_addr, u64 initrd_size, 55f4f75ad5SArd Biesheuvel char *cmdline_ptr, 56f4f75ad5SArd Biesheuvel unsigned long fdt_addr, 57f4f75ad5SArd Biesheuvel unsigned long fdt_size); 58f4f75ad5SArd Biesheuvel 59a643375fSArd Biesheuvel void *get_fdt(efi_system_table_t *sys_table, unsigned long *fdt_size); 60f4f75ad5SArd Biesheuvel 61f3cdfd23SArd Biesheuvel void efi_get_virtmap(efi_memory_desc_t *memory_map, unsigned long map_size, 62f3cdfd23SArd Biesheuvel unsigned long desc_size, efi_memory_desc_t *runtime_map, 63f3cdfd23SArd Biesheuvel int *count); 64f3cdfd23SArd Biesheuvel 65e4fbf476SArd Biesheuvel efi_status_t efi_get_random_bytes(efi_system_table_t *sys_table, 66e4fbf476SArd Biesheuvel unsigned long size, u8 *out); 67e4fbf476SArd Biesheuvel 682ddbfc81SArd Biesheuvel efi_status_t efi_random_alloc(efi_system_table_t *sys_table_arg, 692ddbfc81SArd Biesheuvel unsigned long size, unsigned long align, 702ddbfc81SArd Biesheuvel unsigned long *addr, unsigned long random_seed); 712ddbfc81SArd Biesheuvel 72b9d6769bSArd Biesheuvel efi_status_t check_platform_features(efi_system_table_t *sys_table_arg); 73b9d6769bSArd Biesheuvel 74f4f75ad5SArd Biesheuvel #endif 75