xref: /linux/drivers/firmware/efi/libstub/efistub.h (revision eeff7d634f4750306785be709ca444140c29b043)
1bd669475SArd Biesheuvel 
2bd669475SArd Biesheuvel #ifndef _DRIVERS_FIRMWARE_EFI_EFISTUB_H
3bd669475SArd Biesheuvel #define _DRIVERS_FIRMWARE_EFI_EFISTUB_H
4bd669475SArd Biesheuvel 
5bd669475SArd Biesheuvel /* error code which can't be mistaken for valid address */
6bd669475SArd Biesheuvel #define EFI_ERROR	(~0UL)
7bd669475SArd 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 
2760f38de7SArd Biesheuvel extern int __pure nokaslr(void);
28*eeff7d63SArd Biesheuvel extern int __pure is_quiet(void);
29*eeff7d63SArd Biesheuvel 
30*eeff7d63SArd Biesheuvel #define pr_efi(sys_table, msg)		do {				\
31*eeff7d63SArd Biesheuvel 	if (!is_quiet()) efi_printk(sys_table, "EFI stub: "msg);	\
32*eeff7d63SArd Biesheuvel } while (0)
33*eeff7d63SArd Biesheuvel 
34*eeff7d63SArd Biesheuvel #define pr_efi_err(sys_table, msg) efi_printk(sys_table, "EFI stub: ERROR: "msg)
3560f38de7SArd Biesheuvel 
36bd669475SArd Biesheuvel void efi_char16_printk(efi_system_table_t *, efi_char16_t *);
37bd669475SArd Biesheuvel 
38bd669475SArd Biesheuvel efi_status_t efi_open_volume(efi_system_table_t *sys_table_arg, void *__image,
39bd669475SArd Biesheuvel 			     void **__fh);
40bd669475SArd Biesheuvel 
41bd669475SArd Biesheuvel unsigned long get_dram_base(efi_system_table_t *sys_table_arg);
42bd669475SArd Biesheuvel 
43bd669475SArd Biesheuvel efi_status_t allocate_new_fdt_and_exit_boot(efi_system_table_t *sys_table,
44bd669475SArd Biesheuvel 					    void *handle,
45bd669475SArd Biesheuvel 					    unsigned long *new_fdt_addr,
46bd669475SArd Biesheuvel 					    unsigned long max_addr,
47bd669475SArd Biesheuvel 					    u64 initrd_addr, u64 initrd_size,
48bd669475SArd Biesheuvel 					    char *cmdline_ptr,
49bd669475SArd Biesheuvel 					    unsigned long fdt_addr,
50bd669475SArd Biesheuvel 					    unsigned long fdt_size);
51bd669475SArd Biesheuvel 
52a643375fSArd Biesheuvel void *get_fdt(efi_system_table_t *sys_table, unsigned long *fdt_size);
53bd669475SArd Biesheuvel 
54f3cdfd23SArd Biesheuvel void efi_get_virtmap(efi_memory_desc_t *memory_map, unsigned long map_size,
55f3cdfd23SArd Biesheuvel 		     unsigned long desc_size, efi_memory_desc_t *runtime_map,
56f3cdfd23SArd Biesheuvel 		     int *count);
57f3cdfd23SArd Biesheuvel 
58e4fbf476SArd Biesheuvel efi_status_t efi_get_random_bytes(efi_system_table_t *sys_table,
59e4fbf476SArd Biesheuvel 				  unsigned long size, u8 *out);
60e4fbf476SArd Biesheuvel 
612ddbfc81SArd Biesheuvel efi_status_t efi_random_alloc(efi_system_table_t *sys_table_arg,
622ddbfc81SArd Biesheuvel 			      unsigned long size, unsigned long align,
632ddbfc81SArd Biesheuvel 			      unsigned long *addr, unsigned long random_seed);
642ddbfc81SArd Biesheuvel 
65b9d6769bSArd Biesheuvel efi_status_t check_platform_features(efi_system_table_t *sys_table_arg);
66b9d6769bSArd Biesheuvel 
67568bc4e8SArd Biesheuvel efi_status_t efi_random_get_seed(efi_system_table_t *sys_table_arg);
68568bc4e8SArd Biesheuvel 
69bd669475SArd Biesheuvel #endif
70