blob: 2fb5d5884e2331b7d6d299621bfb5c91fa701bf2 [file] [log] [blame]
H. Peter Anvin1965aae2008-10-22 22:26:29 -07001#ifndef _ASM_X86_EFI_H
2#define _ASM_X86_EFI_H
Huang, Ying5b836832008-01-30 13:31:19 +01003
4#ifdef CONFIG_X86_32
Huang, Yinge4297952008-01-30 13:31:19 +01005
Matt Flemingf7d7d012011-11-15 12:56:14 +00006#define EFI_LOADER_SIGNATURE "EL32"
7
Huang, Yinge4297952008-01-30 13:31:19 +01008extern unsigned long asmlinkage efi_call_phys(void *, ...);
9
10#define efi_call_phys0(f) efi_call_phys(f)
11#define efi_call_phys1(f, a1) efi_call_phys(f, a1)
12#define efi_call_phys2(f, a1, a2) efi_call_phys(f, a1, a2)
13#define efi_call_phys3(f, a1, a2, a3) efi_call_phys(f, a1, a2, a3)
14#define efi_call_phys4(f, a1, a2, a3, a4) \
15 efi_call_phys(f, a1, a2, a3, a4)
16#define efi_call_phys5(f, a1, a2, a3, a4, a5) \
17 efi_call_phys(f, a1, a2, a3, a4, a5)
18#define efi_call_phys6(f, a1, a2, a3, a4, a5, a6) \
19 efi_call_phys(f, a1, a2, a3, a4, a5, a6)
20/*
21 * Wrap all the virtual calls in a way that forces the parameters on the stack.
22 */
23
24#define efi_call_virt(f, args...) \
Joe Perches0c6f6ab2008-03-23 01:02:07 -070025 ((efi_##f##_t __attribute__((regparm(0)))*)efi.systab->runtime->f)(args)
Huang, Yinge4297952008-01-30 13:31:19 +010026
27#define efi_call_virt0(f) efi_call_virt(f)
28#define efi_call_virt1(f, a1) efi_call_virt(f, a1)
29#define efi_call_virt2(f, a1, a2) efi_call_virt(f, a1, a2)
30#define efi_call_virt3(f, a1, a2, a3) efi_call_virt(f, a1, a2, a3)
31#define efi_call_virt4(f, a1, a2, a3, a4) \
32 efi_call_virt(f, a1, a2, a3, a4)
33#define efi_call_virt5(f, a1, a2, a3, a4, a5) \
34 efi_call_virt(f, a1, a2, a3, a4, a5)
35#define efi_call_virt6(f, a1, a2, a3, a4, a5, a6) \
36 efi_call_virt(f, a1, a2, a3, a4, a5, a6)
Huang, Yinge4297952008-01-30 13:31:19 +010037
Matt Fleming3e8fa262012-10-19 13:25:46 +010038#define efi_ioremap(addr, size, type, attr) ioremap_cache(addr, size)
Keith Packarde1ad7832011-12-11 16:12:42 -080039
Huang, Ying5b836832008-01-30 13:31:19 +010040#else /* !CONFIG_X86_32 */
41
Matt Flemingf7d7d012011-11-15 12:56:14 +000042#define EFI_LOADER_SIGNATURE "EL64"
43
Huang, Ying5b836832008-01-30 13:31:19 +010044extern u64 efi_call0(void *fp);
45extern u64 efi_call1(void *fp, u64 arg1);
46extern u64 efi_call2(void *fp, u64 arg1, u64 arg2);
47extern u64 efi_call3(void *fp, u64 arg1, u64 arg2, u64 arg3);
48extern u64 efi_call4(void *fp, u64 arg1, u64 arg2, u64 arg3, u64 arg4);
49extern u64 efi_call5(void *fp, u64 arg1, u64 arg2, u64 arg3,
50 u64 arg4, u64 arg5);
51extern u64 efi_call6(void *fp, u64 arg1, u64 arg2, u64 arg3,
52 u64 arg4, u64 arg5, u64 arg6);
53
54#define efi_call_phys0(f) \
55 efi_call0((void *)(f))
56#define efi_call_phys1(f, a1) \
57 efi_call1((void *)(f), (u64)(a1))
58#define efi_call_phys2(f, a1, a2) \
59 efi_call2((void *)(f), (u64)(a1), (u64)(a2))
60#define efi_call_phys3(f, a1, a2, a3) \
61 efi_call3((void *)(f), (u64)(a1), (u64)(a2), (u64)(a3))
62#define efi_call_phys4(f, a1, a2, a3, a4) \
63 efi_call4((void *)(f), (u64)(a1), (u64)(a2), (u64)(a3), \
64 (u64)(a4))
65#define efi_call_phys5(f, a1, a2, a3, a4, a5) \
66 efi_call5((void *)(f), (u64)(a1), (u64)(a2), (u64)(a3), \
67 (u64)(a4), (u64)(a5))
68#define efi_call_phys6(f, a1, a2, a3, a4, a5, a6) \
69 efi_call6((void *)(f), (u64)(a1), (u64)(a2), (u64)(a3), \
70 (u64)(a4), (u64)(a5), (u64)(a6))
71
72#define efi_call_virt0(f) \
Linus Torvalds11520e52012-12-15 15:15:24 -080073 efi_call0((void *)(efi.systab->runtime->f))
Huang, Ying5b836832008-01-30 13:31:19 +010074#define efi_call_virt1(f, a1) \
Linus Torvalds11520e52012-12-15 15:15:24 -080075 efi_call1((void *)(efi.systab->runtime->f), (u64)(a1))
Huang, Ying5b836832008-01-30 13:31:19 +010076#define efi_call_virt2(f, a1, a2) \
Linus Torvalds11520e52012-12-15 15:15:24 -080077 efi_call2((void *)(efi.systab->runtime->f), (u64)(a1), (u64)(a2))
Huang, Ying5b836832008-01-30 13:31:19 +010078#define efi_call_virt3(f, a1, a2, a3) \
Linus Torvalds11520e52012-12-15 15:15:24 -080079 efi_call3((void *)(efi.systab->runtime->f), (u64)(a1), (u64)(a2), \
Huang, Ying5b836832008-01-30 13:31:19 +010080 (u64)(a3))
81#define efi_call_virt4(f, a1, a2, a3, a4) \
Linus Torvalds11520e52012-12-15 15:15:24 -080082 efi_call4((void *)(efi.systab->runtime->f), (u64)(a1), (u64)(a2), \
Huang, Ying5b836832008-01-30 13:31:19 +010083 (u64)(a3), (u64)(a4))
84#define efi_call_virt5(f, a1, a2, a3, a4, a5) \
Linus Torvalds11520e52012-12-15 15:15:24 -080085 efi_call5((void *)(efi.systab->runtime->f), (u64)(a1), (u64)(a2), \
Huang, Ying5b836832008-01-30 13:31:19 +010086 (u64)(a3), (u64)(a4), (u64)(a5))
87#define efi_call_virt6(f, a1, a2, a3, a4, a5, a6) \
Linus Torvalds11520e52012-12-15 15:15:24 -080088 efi_call6((void *)(efi.systab->runtime->f), (u64)(a1), (u64)(a2), \
Huang, Ying5b836832008-01-30 13:31:19 +010089 (u64)(a3), (u64)(a4), (u64)(a5), (u64)(a6))
90
Keith Packarde1ad7832011-12-11 16:12:42 -080091extern void __iomem *efi_ioremap(unsigned long addr, unsigned long size,
Matt Fleming3e8fa262012-10-19 13:25:46 +010092 u32 type, u64 attribute);
Keith Packarde1ad7832011-12-11 16:12:42 -080093
Huang, Ying5b836832008-01-30 13:31:19 +010094#endif /* CONFIG_X86_32 */
95
Jaswinder Singh Rajputcbafbc82008-12-29 20:36:40 +053096extern int add_efi_memmap;
Matt Fleming83e68182012-11-14 09:42:35 +000097extern unsigned long x86_efi_facility;
Matthew Garrett9cd2b072011-05-05 15:19:43 -040098extern void efi_set_executable(efi_memory_desc_t *md, bool executable);
Olof Johansson1adbfa32012-02-12 13:24:29 -080099extern int efi_memblock_x86_reserve_range(void);
Huang, Ying5b836832008-01-30 13:31:19 +0100100extern void efi_call_phys_prelog(void);
101extern void efi_call_phys_epilog(void);
Olof Johansson5189c2a2012-10-24 10:00:44 -0700102extern void efi_unmap_memmap(void);
Matt Fleming3e8fa262012-10-19 13:25:46 +0100103extern void efi_memory_uc(u64 addr, unsigned long size);
Huang, Ying5b836832008-01-30 13:31:19 +0100104
Matthew Garrettcc5a0802013-04-15 13:09:46 -0700105struct efi_var_bootdata {
106 struct setup_data data;
107 u64 store_size;
108 u64 remaining_size;
109 u64 max_var_size;
110};
111
Satoru Takeuchi6b59e362013-02-14 09:07:35 +0900112#ifdef CONFIG_EFI
113
114static inline bool efi_is_native(void)
115{
116 return IS_ENABLED(CONFIG_X86_64) == efi_enabled(EFI_64BIT);
117}
118
119#else
Russ Anderson7f594232008-10-03 11:59:15 -0500120/*
121 * IF EFI is not configured, have the EFI calls return -ENOSYS.
122 */
123#define efi_call0(_f) (-ENOSYS)
124#define efi_call1(_f, _a1) (-ENOSYS)
125#define efi_call2(_f, _a1, _a2) (-ENOSYS)
126#define efi_call3(_f, _a1, _a2, _a3) (-ENOSYS)
127#define efi_call4(_f, _a1, _a2, _a3, _a4) (-ENOSYS)
128#define efi_call5(_f, _a1, _a2, _a3, _a4, _a5) (-ENOSYS)
129#define efi_call6(_f, _a1, _a2, _a3, _a4, _a5, _a6) (-ENOSYS)
130#endif /* CONFIG_EFI */
131
H. Peter Anvin1965aae2008-10-22 22:26:29 -0700132#endif /* _ASM_X86_EFI_H */