xref: /openbmc/linux/arch/arm64/include/asm/efi.h (revision a2cce7a9)
1 #ifndef _ASM_EFI_H
2 #define _ASM_EFI_H
3 
4 #include <asm/io.h>
5 #include <asm/neon.h>
6 
7 #ifdef CONFIG_EFI
8 extern void efi_init(void);
9 #else
10 #define efi_init()
11 #endif
12 
13 #define efi_call_virt(f, ...)						\
14 ({									\
15 	efi_##f##_t *__f;						\
16 	efi_status_t __s;						\
17 									\
18 	kernel_neon_begin();						\
19 	efi_virtmap_load();						\
20 	__f = efi.systab->runtime->f;					\
21 	__s = __f(__VA_ARGS__);						\
22 	efi_virtmap_unload();						\
23 	kernel_neon_end();						\
24 	__s;								\
25 })
26 
27 #define __efi_call_virt(f, ...)						\
28 ({									\
29 	efi_##f##_t *__f;						\
30 									\
31 	kernel_neon_begin();						\
32 	efi_virtmap_load();						\
33 	__f = efi.systab->runtime->f;					\
34 	__f(__VA_ARGS__);						\
35 	efi_virtmap_unload();						\
36 	kernel_neon_end();						\
37 })
38 
39 /* arch specific definitions used by the stub code */
40 
41 /*
42  * AArch64 requires the DTB to be 8-byte aligned in the first 512MiB from
43  * start of kernel and may not cross a 2MiB boundary. We set alignment to
44  * 2MiB so we know it won't cross a 2MiB boundary.
45  */
46 #define EFI_FDT_ALIGN	SZ_2M   /* used by allocate_new_fdt_and_exit_boot() */
47 #define MAX_FDT_OFFSET	SZ_512M
48 
49 #define efi_call_early(f, ...) sys_table_arg->boottime->f(__VA_ARGS__)
50 
51 #define EFI_ALLOC_ALIGN		SZ_64K
52 
53 /*
54  * On ARM systems, virtually remapped UEFI runtime services are set up in two
55  * distinct stages:
56  * - The stub retrieves the final version of the memory map from UEFI, populates
57  *   the virt_addr fields and calls the SetVirtualAddressMap() [SVAM] runtime
58  *   service to communicate the new mapping to the firmware (Note that the new
59  *   mapping is not live at this time)
60  * - During an early initcall(), the EFI system table is permanently remapped
61  *   and the virtual remapping of the UEFI Runtime Services regions is loaded
62  *   into a private set of page tables. If this all succeeds, the Runtime
63  *   Services are enabled and the EFI_RUNTIME_SERVICES bit set.
64  */
65 
66 void efi_virtmap_load(void);
67 void efi_virtmap_unload(void);
68 
69 #endif /* _ASM_EFI_H */
70