Commit | Line | Data |
---|---|---|
1965aae3 PA |
1 | #ifndef _ASM_X86_EFI_H |
2 | #define _ASM_X86_EFI_H | |
5b83683f | 3 | |
d2f7cbe7 BP |
4 | /* |
5 | * We map the EFI regions needed for runtime services non-contiguously, | |
6 | * with preserved alignment on virtual addresses starting from -4G down | |
7 | * for a total max space of 64G. This way, we provide for stable runtime | |
8 | * services addresses across kernels so that a kexec'd kernel can still | |
9 | * use them. | |
10 | * | |
11 | * This is the main reason why we're doing stable VA mappings for RT | |
12 | * services. | |
13 | * | |
14 | * This flag is used in conjuction with a chicken bit called | |
15 | * "efi=old_map" which can be used as a fallback to the old runtime | |
16 | * services mapping method in case there's some b0rkage with a | |
17 | * particular EFI implementation (haha, it is hard to hold up the | |
18 | * sarcasm here...). | |
19 | */ | |
20 | #define EFI_OLD_MEMMAP EFI_ARCH_1 | |
21 | ||
5b83683f | 22 | #ifdef CONFIG_X86_32 |
e429795c | 23 | |
f7d7d01b MF |
24 | #define EFI_LOADER_SIGNATURE "EL32" |
25 | ||
e429795c HY |
26 | extern unsigned long asmlinkage efi_call_phys(void *, ...); |
27 | ||
28 | #define efi_call_phys0(f) efi_call_phys(f) | |
29 | #define efi_call_phys1(f, a1) efi_call_phys(f, a1) | |
30 | #define efi_call_phys2(f, a1, a2) efi_call_phys(f, a1, a2) | |
31 | #define efi_call_phys3(f, a1, a2, a3) efi_call_phys(f, a1, a2, a3) | |
32 | #define efi_call_phys4(f, a1, a2, a3, a4) \ | |
33 | efi_call_phys(f, a1, a2, a3, a4) | |
34 | #define efi_call_phys5(f, a1, a2, a3, a4, a5) \ | |
35 | efi_call_phys(f, a1, a2, a3, a4, a5) | |
36 | #define efi_call_phys6(f, a1, a2, a3, a4, a5, a6) \ | |
37 | efi_call_phys(f, a1, a2, a3, a4, a5, a6) | |
38 | /* | |
39 | * Wrap all the virtual calls in a way that forces the parameters on the stack. | |
40 | */ | |
41 | ||
42 | #define efi_call_virt(f, args...) \ | |
0c6f6abf | 43 | ((efi_##f##_t __attribute__((regparm(0)))*)efi.systab->runtime->f)(args) |
e429795c HY |
44 | |
45 | #define efi_call_virt0(f) efi_call_virt(f) | |
46 | #define efi_call_virt1(f, a1) efi_call_virt(f, a1) | |
47 | #define efi_call_virt2(f, a1, a2) efi_call_virt(f, a1, a2) | |
48 | #define efi_call_virt3(f, a1, a2, a3) efi_call_virt(f, a1, a2, a3) | |
49 | #define efi_call_virt4(f, a1, a2, a3, a4) \ | |
50 | efi_call_virt(f, a1, a2, a3, a4) | |
51 | #define efi_call_virt5(f, a1, a2, a3, a4, a5) \ | |
52 | efi_call_virt(f, a1, a2, a3, a4, a5) | |
53 | #define efi_call_virt6(f, a1, a2, a3, a4, a5, a6) \ | |
54 | efi_call_virt(f, a1, a2, a3, a4, a5, a6) | |
e429795c | 55 | |
3e8fa263 | 56 | #define efi_ioremap(addr, size, type, attr) ioremap_cache(addr, size) |
e1ad783b | 57 | |
5b83683f HY |
58 | #else /* !CONFIG_X86_32 */ |
59 | ||
f7d7d01b MF |
60 | #define EFI_LOADER_SIGNATURE "EL64" |
61 | ||
5b83683f HY |
62 | extern u64 efi_call0(void *fp); |
63 | extern u64 efi_call1(void *fp, u64 arg1); | |
64 | extern u64 efi_call2(void *fp, u64 arg1, u64 arg2); | |
65 | extern u64 efi_call3(void *fp, u64 arg1, u64 arg2, u64 arg3); | |
66 | extern u64 efi_call4(void *fp, u64 arg1, u64 arg2, u64 arg3, u64 arg4); | |
67 | extern u64 efi_call5(void *fp, u64 arg1, u64 arg2, u64 arg3, | |
68 | u64 arg4, u64 arg5); | |
69 | extern u64 efi_call6(void *fp, u64 arg1, u64 arg2, u64 arg3, | |
70 | u64 arg4, u64 arg5, u64 arg6); | |
71 | ||
72 | #define efi_call_phys0(f) \ | |
43ab0476 | 73 | efi_call0((f)) |
5b83683f | 74 | #define efi_call_phys1(f, a1) \ |
43ab0476 | 75 | efi_call1((f), (u64)(a1)) |
5b83683f | 76 | #define efi_call_phys2(f, a1, a2) \ |
43ab0476 | 77 | efi_call2((f), (u64)(a1), (u64)(a2)) |
5b83683f | 78 | #define efi_call_phys3(f, a1, a2, a3) \ |
43ab0476 | 79 | efi_call3((f), (u64)(a1), (u64)(a2), (u64)(a3)) |
5b83683f | 80 | #define efi_call_phys4(f, a1, a2, a3, a4) \ |
43ab0476 | 81 | efi_call4((f), (u64)(a1), (u64)(a2), (u64)(a3), \ |
5b83683f HY |
82 | (u64)(a4)) |
83 | #define efi_call_phys5(f, a1, a2, a3, a4, a5) \ | |
43ab0476 | 84 | efi_call5((f), (u64)(a1), (u64)(a2), (u64)(a3), \ |
5b83683f HY |
85 | (u64)(a4), (u64)(a5)) |
86 | #define efi_call_phys6(f, a1, a2, a3, a4, a5, a6) \ | |
43ab0476 | 87 | efi_call6((f), (u64)(a1), (u64)(a2), (u64)(a3), \ |
5b83683f HY |
88 | (u64)(a4), (u64)(a5), (u64)(a6)) |
89 | ||
d2f7cbe7 BP |
90 | #define _efi_call_virtX(x, f, ...) \ |
91 | ({ \ | |
92 | efi_status_t __s; \ | |
93 | \ | |
94 | efi_sync_low_kernel_mappings(); \ | |
95 | preempt_disable(); \ | |
96 | __s = efi_call##x((void *)efi.systab->runtime->f, __VA_ARGS__); \ | |
97 | preempt_enable(); \ | |
98 | __s; \ | |
99 | }) | |
100 | ||
5b83683f | 101 | #define efi_call_virt0(f) \ |
d2f7cbe7 BP |
102 | _efi_call_virtX(0, f) |
103 | #define efi_call_virt1(f, a1) \ | |
104 | _efi_call_virtX(1, f, (u64)(a1)) | |
105 | #define efi_call_virt2(f, a1, a2) \ | |
106 | _efi_call_virtX(2, f, (u64)(a1), (u64)(a2)) | |
107 | #define efi_call_virt3(f, a1, a2, a3) \ | |
108 | _efi_call_virtX(3, f, (u64)(a1), (u64)(a2), (u64)(a3)) | |
109 | #define efi_call_virt4(f, a1, a2, a3, a4) \ | |
110 | _efi_call_virtX(4, f, (u64)(a1), (u64)(a2), (u64)(a3), (u64)(a4)) | |
111 | #define efi_call_virt5(f, a1, a2, a3, a4, a5) \ | |
112 | _efi_call_virtX(5, f, (u64)(a1), (u64)(a2), (u64)(a3), (u64)(a4), (u64)(a5)) | |
113 | #define efi_call_virt6(f, a1, a2, a3, a4, a5, a6) \ | |
114 | _efi_call_virtX(6, f, (u64)(a1), (u64)(a2), (u64)(a3), (u64)(a4), (u64)(a5), (u64)(a6)) | |
5b83683f | 115 | |
e1ad783b | 116 | extern void __iomem *efi_ioremap(unsigned long addr, unsigned long size, |
3e8fa263 | 117 | u32 type, u64 attribute); |
e1ad783b | 118 | |
5b83683f HY |
119 | #endif /* CONFIG_X86_32 */ |
120 | ||
cbafbc82 | 121 | extern int add_efi_memmap; |
83e68189 | 122 | extern unsigned long x86_efi_facility; |
d2f7cbe7 | 123 | extern struct efi_scratch efi_scratch; |
9cd2b07c | 124 | extern void efi_set_executable(efi_memory_desc_t *md, bool executable); |
1adbfa35 | 125 | extern int efi_memblock_x86_reserve_range(void); |
5b83683f HY |
126 | extern void efi_call_phys_prelog(void); |
127 | extern void efi_call_phys_epilog(void); | |
5189c2a7 | 128 | extern void efi_unmap_memmap(void); |
3e8fa263 | 129 | extern void efi_memory_uc(u64 addr, unsigned long size); |
d2f7cbe7 | 130 | extern void __init efi_map_region(efi_memory_desc_t *md); |
3b266496 | 131 | extern void __init efi_map_region_fixed(efi_memory_desc_t *md); |
d2f7cbe7 BP |
132 | extern void efi_sync_low_kernel_mappings(void); |
133 | extern void efi_setup_page_tables(void); | |
134 | extern void __init old_map_region(efi_memory_desc_t *md); | |
c55d016f BP |
135 | extern void __init runtime_code_page_mkexec(void); |
136 | extern void __init efi_runtime_mkexec(void); | |
5b83683f | 137 | |
1fec0533 DY |
138 | struct efi_setup_data { |
139 | u64 fw_vendor; | |
140 | u64 runtime; | |
141 | u64 tables; | |
142 | u64 smbios; | |
143 | u64 reserved[8]; | |
144 | }; | |
145 | ||
146 | extern u64 efi_setup; | |
1fec0533 | 147 | |
6b59e366 ST |
148 | #ifdef CONFIG_EFI |
149 | ||
150 | static inline bool efi_is_native(void) | |
151 | { | |
152 | return IS_ENABLED(CONFIG_X86_64) == efi_enabled(EFI_64BIT); | |
153 | } | |
154 | ||
72548e83 | 155 | extern struct console early_efi_console; |
5c12af0c | 156 | extern void parse_efi_setup(u64 phys_addr, u32 data_len); |
6b59e366 | 157 | #else |
7f594232 RA |
158 | /* |
159 | * IF EFI is not configured, have the EFI calls return -ENOSYS. | |
160 | */ | |
161 | #define efi_call0(_f) (-ENOSYS) | |
162 | #define efi_call1(_f, _a1) (-ENOSYS) | |
163 | #define efi_call2(_f, _a1, _a2) (-ENOSYS) | |
164 | #define efi_call3(_f, _a1, _a2, _a3) (-ENOSYS) | |
165 | #define efi_call4(_f, _a1, _a2, _a3, _a4) (-ENOSYS) | |
166 | #define efi_call5(_f, _a1, _a2, _a3, _a4, _a5) (-ENOSYS) | |
167 | #define efi_call6(_f, _a1, _a2, _a3, _a4, _a5, _a6) (-ENOSYS) | |
5c12af0c | 168 | static inline void parse_efi_setup(u64 phys_addr, u32 data_len) {} |
7f594232 RA |
169 | #endif /* CONFIG_EFI */ |
170 | ||
1965aae3 | 171 | #endif /* _ASM_X86_EFI_H */ |