xref: /openbmc/linux/arch/x86/include/asm/efi.h (revision e1ad783b12ec8b69da83479c5d21a0d8180bc519)
11965aae3SH. Peter Anvin #ifndef _ASM_X86_EFI_H
21965aae3SH. Peter Anvin #define _ASM_X86_EFI_H
3bb898558SAl Viro 
4bb898558SAl Viro #ifdef CONFIG_X86_32
5bb898558SAl Viro 
6bb898558SAl Viro extern unsigned long asmlinkage efi_call_phys(void *, ...);
7bb898558SAl Viro 
8bb898558SAl Viro #define efi_call_phys0(f)		efi_call_phys(f)
9bb898558SAl Viro #define efi_call_phys1(f, a1)		efi_call_phys(f, a1)
10bb898558SAl Viro #define efi_call_phys2(f, a1, a2)	efi_call_phys(f, a1, a2)
11bb898558SAl Viro #define efi_call_phys3(f, a1, a2, a3)	efi_call_phys(f, a1, a2, a3)
12bb898558SAl Viro #define efi_call_phys4(f, a1, a2, a3, a4)	\
13bb898558SAl Viro 	efi_call_phys(f, a1, a2, a3, a4)
14bb898558SAl Viro #define efi_call_phys5(f, a1, a2, a3, a4, a5)	\
15bb898558SAl Viro 	efi_call_phys(f, a1, a2, a3, a4, a5)
16bb898558SAl Viro #define efi_call_phys6(f, a1, a2, a3, a4, a5, a6)	\
17bb898558SAl Viro 	efi_call_phys(f, a1, a2, a3, a4, a5, a6)
18bb898558SAl Viro /*
19bb898558SAl Viro  * Wrap all the virtual calls in a way that forces the parameters on the stack.
20bb898558SAl Viro  */
21bb898558SAl Viro 
22bb898558SAl Viro #define efi_call_virt(f, args...) \
23bb898558SAl Viro 	((efi_##f##_t __attribute__((regparm(0)))*)efi.systab->runtime->f)(args)
24bb898558SAl Viro 
25bb898558SAl Viro #define efi_call_virt0(f)		efi_call_virt(f)
26bb898558SAl Viro #define efi_call_virt1(f, a1)		efi_call_virt(f, a1)
27bb898558SAl Viro #define efi_call_virt2(f, a1, a2)	efi_call_virt(f, a1, a2)
28bb898558SAl Viro #define efi_call_virt3(f, a1, a2, a3)	efi_call_virt(f, a1, a2, a3)
29bb898558SAl Viro #define efi_call_virt4(f, a1, a2, a3, a4)	\
30bb898558SAl Viro 	efi_call_virt(f, a1, a2, a3, a4)
31bb898558SAl Viro #define efi_call_virt5(f, a1, a2, a3, a4, a5)	\
32bb898558SAl Viro 	efi_call_virt(f, a1, a2, a3, a4, a5)
33bb898558SAl Viro #define efi_call_virt6(f, a1, a2, a3, a4, a5, a6)	\
34bb898558SAl Viro 	efi_call_virt(f, a1, a2, a3, a4, a5, a6)
35bb898558SAl Viro 
36*e1ad783bSKeith Packard #define efi_ioremap(addr, size, type)		ioremap_cache(addr, size)
37*e1ad783bSKeith Packard 
38bb898558SAl Viro #else /* !CONFIG_X86_32 */
39bb898558SAl Viro 
40bb898558SAl Viro extern u64 efi_call0(void *fp);
41bb898558SAl Viro extern u64 efi_call1(void *fp, u64 arg1);
42bb898558SAl Viro extern u64 efi_call2(void *fp, u64 arg1, u64 arg2);
43bb898558SAl Viro extern u64 efi_call3(void *fp, u64 arg1, u64 arg2, u64 arg3);
44bb898558SAl Viro extern u64 efi_call4(void *fp, u64 arg1, u64 arg2, u64 arg3, u64 arg4);
45bb898558SAl Viro extern u64 efi_call5(void *fp, u64 arg1, u64 arg2, u64 arg3,
46bb898558SAl Viro 		     u64 arg4, u64 arg5);
47bb898558SAl Viro extern u64 efi_call6(void *fp, u64 arg1, u64 arg2, u64 arg3,
48bb898558SAl Viro 		     u64 arg4, u64 arg5, u64 arg6);
49bb898558SAl Viro 
50bb898558SAl Viro #define efi_call_phys0(f)			\
51bb898558SAl Viro 	efi_call0((void *)(f))
52bb898558SAl Viro #define efi_call_phys1(f, a1)			\
53bb898558SAl Viro 	efi_call1((void *)(f), (u64)(a1))
54bb898558SAl Viro #define efi_call_phys2(f, a1, a2)			\
55bb898558SAl Viro 	efi_call2((void *)(f), (u64)(a1), (u64)(a2))
56bb898558SAl Viro #define efi_call_phys3(f, a1, a2, a3)				\
57bb898558SAl Viro 	efi_call3((void *)(f), (u64)(a1), (u64)(a2), (u64)(a3))
58bb898558SAl Viro #define efi_call_phys4(f, a1, a2, a3, a4)				\
59bb898558SAl Viro 	efi_call4((void *)(f), (u64)(a1), (u64)(a2), (u64)(a3),		\
60bb898558SAl Viro 		  (u64)(a4))
61bb898558SAl Viro #define efi_call_phys5(f, a1, a2, a3, a4, a5)				\
62bb898558SAl Viro 	efi_call5((void *)(f), (u64)(a1), (u64)(a2), (u64)(a3),		\
63bb898558SAl Viro 		  (u64)(a4), (u64)(a5))
64bb898558SAl Viro #define efi_call_phys6(f, a1, a2, a3, a4, a5, a6)			\
65bb898558SAl Viro 	efi_call6((void *)(f), (u64)(a1), (u64)(a2), (u64)(a3),		\
66bb898558SAl Viro 		  (u64)(a4), (u64)(a5), (u64)(a6))
67bb898558SAl Viro 
68bb898558SAl Viro #define efi_call_virt0(f)				\
69bb898558SAl Viro 	efi_call0((void *)(efi.systab->runtime->f))
70bb898558SAl Viro #define efi_call_virt1(f, a1)					\
71bb898558SAl Viro 	efi_call1((void *)(efi.systab->runtime->f), (u64)(a1))
72bb898558SAl Viro #define efi_call_virt2(f, a1, a2)					\
73bb898558SAl Viro 	efi_call2((void *)(efi.systab->runtime->f), (u64)(a1), (u64)(a2))
74bb898558SAl Viro #define efi_call_virt3(f, a1, a2, a3)					\
75bb898558SAl Viro 	efi_call3((void *)(efi.systab->runtime->f), (u64)(a1), (u64)(a2), \
76bb898558SAl Viro 		  (u64)(a3))
77bb898558SAl Viro #define efi_call_virt4(f, a1, a2, a3, a4)				\
78bb898558SAl Viro 	efi_call4((void *)(efi.systab->runtime->f), (u64)(a1), (u64)(a2), \
79bb898558SAl Viro 		  (u64)(a3), (u64)(a4))
80bb898558SAl Viro #define efi_call_virt5(f, a1, a2, a3, a4, a5)				\
81bb898558SAl Viro 	efi_call5((void *)(efi.systab->runtime->f), (u64)(a1), (u64)(a2), \
82bb898558SAl Viro 		  (u64)(a3), (u64)(a4), (u64)(a5))
83bb898558SAl Viro #define efi_call_virt6(f, a1, a2, a3, a4, a5, a6)			\
84bb898558SAl Viro 	efi_call6((void *)(efi.systab->runtime->f), (u64)(a1), (u64)(a2), \
85bb898558SAl Viro 		  (u64)(a3), (u64)(a4), (u64)(a5), (u64)(a6))
86bb898558SAl Viro 
87*e1ad783bSKeith Packard extern void __iomem *efi_ioremap(unsigned long addr, unsigned long size,
88*e1ad783bSKeith Packard 				 u32 type);
89*e1ad783bSKeith Packard 
90bb898558SAl Viro #endif /* CONFIG_X86_32 */
91bb898558SAl Viro 
92cbafbc82SJaswinder Singh Rajput extern int add_efi_memmap;
939cd2b07cSMatthew Garrett extern void efi_set_executable(efi_memory_desc_t *md, bool executable);
94a9ce6bc1SYinghai Lu extern void efi_memblock_x86_reserve_range(void);
95bb898558SAl Viro extern void efi_call_phys_prelog(void);
96bb898558SAl Viro extern void efi_call_phys_epilog(void);
97bb898558SAl Viro 
98bb898558SAl Viro #ifndef CONFIG_EFI
99bb898558SAl Viro /*
100bb898558SAl Viro  * IF EFI is not configured, have the EFI calls return -ENOSYS.
101bb898558SAl Viro  */
102bb898558SAl Viro #define efi_call0(_f)					(-ENOSYS)
103bb898558SAl Viro #define efi_call1(_f, _a1)				(-ENOSYS)
104bb898558SAl Viro #define efi_call2(_f, _a1, _a2)				(-ENOSYS)
105bb898558SAl Viro #define efi_call3(_f, _a1, _a2, _a3)			(-ENOSYS)
106bb898558SAl Viro #define efi_call4(_f, _a1, _a2, _a3, _a4)		(-ENOSYS)
107bb898558SAl Viro #define efi_call5(_f, _a1, _a2, _a3, _a4, _a5)		(-ENOSYS)
108bb898558SAl Viro #define efi_call6(_f, _a1, _a2, _a3, _a4, _a5, _a6)	(-ENOSYS)
109bb898558SAl Viro #endif /* CONFIG_EFI */
110bb898558SAl Viro 
1111965aae3SH. Peter Anvin #endif /* _ASM_X86_EFI_H */
112