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