xref: /openbmc/linux/arch/x86/include/asm/efi.h (revision 1965aae3c98397aad957412413c07e97b1bd4e64)
1*1965aae3SH. Peter Anvin #ifndef _ASM_X86_EFI_H
2*1965aae3SH. 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 
36bb898558SAl Viro #define efi_ioremap(addr, size)			ioremap_cache(addr, size)
37bb898558SAl Viro 
38bb898558SAl Viro #else /* !CONFIG_X86_32 */
39bb898558SAl Viro 
40bb898558SAl Viro #define MAX_EFI_IO_PAGES	100
41bb898558SAl Viro 
42bb898558SAl Viro extern u64 efi_call0(void *fp);
43bb898558SAl Viro extern u64 efi_call1(void *fp, u64 arg1);
44bb898558SAl Viro extern u64 efi_call2(void *fp, u64 arg1, u64 arg2);
45bb898558SAl Viro extern u64 efi_call3(void *fp, u64 arg1, u64 arg2, u64 arg3);
46bb898558SAl Viro extern u64 efi_call4(void *fp, u64 arg1, u64 arg2, u64 arg3, u64 arg4);
47bb898558SAl Viro extern u64 efi_call5(void *fp, u64 arg1, u64 arg2, u64 arg3,
48bb898558SAl Viro 		     u64 arg4, u64 arg5);
49bb898558SAl Viro extern u64 efi_call6(void *fp, u64 arg1, u64 arg2, u64 arg3,
50bb898558SAl Viro 		     u64 arg4, u64 arg5, u64 arg6);
51bb898558SAl Viro 
52bb898558SAl Viro #define efi_call_phys0(f)			\
53bb898558SAl Viro 	efi_call0((void *)(f))
54bb898558SAl Viro #define efi_call_phys1(f, a1)			\
55bb898558SAl Viro 	efi_call1((void *)(f), (u64)(a1))
56bb898558SAl Viro #define efi_call_phys2(f, a1, a2)			\
57bb898558SAl Viro 	efi_call2((void *)(f), (u64)(a1), (u64)(a2))
58bb898558SAl Viro #define efi_call_phys3(f, a1, a2, a3)				\
59bb898558SAl Viro 	efi_call3((void *)(f), (u64)(a1), (u64)(a2), (u64)(a3))
60bb898558SAl Viro #define efi_call_phys4(f, a1, a2, a3, a4)				\
61bb898558SAl Viro 	efi_call4((void *)(f), (u64)(a1), (u64)(a2), (u64)(a3),		\
62bb898558SAl Viro 		  (u64)(a4))
63bb898558SAl Viro #define efi_call_phys5(f, a1, a2, a3, a4, a5)				\
64bb898558SAl Viro 	efi_call5((void *)(f), (u64)(a1), (u64)(a2), (u64)(a3),		\
65bb898558SAl Viro 		  (u64)(a4), (u64)(a5))
66bb898558SAl Viro #define efi_call_phys6(f, a1, a2, a3, a4, a5, a6)			\
67bb898558SAl Viro 	efi_call6((void *)(f), (u64)(a1), (u64)(a2), (u64)(a3),		\
68bb898558SAl Viro 		  (u64)(a4), (u64)(a5), (u64)(a6))
69bb898558SAl Viro 
70bb898558SAl Viro #define efi_call_virt0(f)				\
71bb898558SAl Viro 	efi_call0((void *)(efi.systab->runtime->f))
72bb898558SAl Viro #define efi_call_virt1(f, a1)					\
73bb898558SAl Viro 	efi_call1((void *)(efi.systab->runtime->f), (u64)(a1))
74bb898558SAl Viro #define efi_call_virt2(f, a1, a2)					\
75bb898558SAl Viro 	efi_call2((void *)(efi.systab->runtime->f), (u64)(a1), (u64)(a2))
76bb898558SAl Viro #define efi_call_virt3(f, a1, a2, a3)					\
77bb898558SAl Viro 	efi_call3((void *)(efi.systab->runtime->f), (u64)(a1), (u64)(a2), \
78bb898558SAl Viro 		  (u64)(a3))
79bb898558SAl Viro #define efi_call_virt4(f, a1, a2, a3, a4)				\
80bb898558SAl Viro 	efi_call4((void *)(efi.systab->runtime->f), (u64)(a1), (u64)(a2), \
81bb898558SAl Viro 		  (u64)(a3), (u64)(a4))
82bb898558SAl Viro #define efi_call_virt5(f, a1, a2, a3, a4, a5)				\
83bb898558SAl Viro 	efi_call5((void *)(efi.systab->runtime->f), (u64)(a1), (u64)(a2), \
84bb898558SAl Viro 		  (u64)(a3), (u64)(a4), (u64)(a5))
85bb898558SAl Viro #define efi_call_virt6(f, a1, a2, a3, a4, a5, a6)			\
86bb898558SAl Viro 	efi_call6((void *)(efi.systab->runtime->f), (u64)(a1), (u64)(a2), \
87bb898558SAl Viro 		  (u64)(a3), (u64)(a4), (u64)(a5), (u64)(a6))
88bb898558SAl Viro 
89bb898558SAl Viro extern void __iomem *efi_ioremap(unsigned long addr, unsigned long size);
90bb898558SAl Viro 
91bb898558SAl Viro #endif /* CONFIG_X86_32 */
92bb898558SAl Viro 
93bb898558SAl Viro extern void efi_reserve_early(void);
94bb898558SAl Viro extern void efi_call_phys_prelog(void);
95bb898558SAl Viro extern void efi_call_phys_epilog(void);
96bb898558SAl Viro 
97bb898558SAl Viro #ifndef CONFIG_EFI
98bb898558SAl Viro /*
99bb898558SAl Viro  * IF EFI is not configured, have the EFI calls return -ENOSYS.
100bb898558SAl Viro  */
101bb898558SAl Viro #define efi_call0(_f)					(-ENOSYS)
102bb898558SAl Viro #define efi_call1(_f, _a1)				(-ENOSYS)
103bb898558SAl Viro #define efi_call2(_f, _a1, _a2)				(-ENOSYS)
104bb898558SAl Viro #define efi_call3(_f, _a1, _a2, _a3)			(-ENOSYS)
105bb898558SAl Viro #define efi_call4(_f, _a1, _a2, _a3, _a4)		(-ENOSYS)
106bb898558SAl Viro #define efi_call5(_f, _a1, _a2, _a3, _a4, _a5)		(-ENOSYS)
107bb898558SAl Viro #define efi_call6(_f, _a1, _a2, _a3, _a4, _a5, _a6)	(-ENOSYS)
108bb898558SAl Viro #endif /* CONFIG_EFI */
109bb898558SAl Viro 
110*1965aae3SH. Peter Anvin #endif /* _ASM_X86_EFI_H */
111