fd13815fe85c9d9d45a6c79b7c93d9e68f9ebff0
[pandora-kernel.git] / arch / x86 / include / asm / efi.h
1 #ifndef _ASM_X86_EFI_H
2 #define _ASM_X86_EFI_H
3
4 #ifdef CONFIG_X86_32
5
6 #define EFI_LOADER_SIGNATURE    "EL32"
7
8 extern 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...) \
25         ((efi_##f##_t __attribute__((regparm(0)))*)efi.systab->runtime->f)(args)
26
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)
37
38 #define efi_ioremap(addr, size, type, attr)     ioremap_cache(addr, size)
39
40 #else /* !CONFIG_X86_32 */
41
42 #define EFI_LOADER_SIGNATURE    "EL64"
43
44 extern u64 efi_call0(void *fp);
45 extern u64 efi_call1(void *fp, u64 arg1);
46 extern u64 efi_call2(void *fp, u64 arg1, u64 arg2);
47 extern u64 efi_call3(void *fp, u64 arg1, u64 arg2, u64 arg3);
48 extern u64 efi_call4(void *fp, u64 arg1, u64 arg2, u64 arg3, u64 arg4);
49 extern u64 efi_call5(void *fp, u64 arg1, u64 arg2, u64 arg3,
50                      u64 arg4, u64 arg5);
51 extern 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 extern unsigned long efi_call_virt_prelog(void);
73 extern void efi_call_virt_epilog(unsigned long);
74
75 #define efi_callx(x, func, ...)                                 \
76         ({                                                      \
77                 efi_status_t __status;                          \
78                 unsigned long __pgd;                            \
79                                                                 \
80                 __pgd = efi_call_virt_prelog();                 \
81                 __status = efi_call##x(func, __VA_ARGS__);      \
82                 efi_call_virt_epilog(__pgd);                    \
83                 __status;                                       \
84         })
85
86 #define efi_call_virt0(f)                               \
87         efi_callx(0, (void *)(efi.systab->runtime->f))
88 #define efi_call_virt1(f, a1)                                   \
89         efi_callx(1, (void *)(efi.systab->runtime->f), (u64)(a1))
90 #define efi_call_virt2(f, a1, a2)                                       \
91         efi_callx(2, (void *)(efi.systab->runtime->f), (u64)(a1), (u64)(a2))
92 #define efi_call_virt3(f, a1, a2, a3)                                   \
93         efi_callx(3, (void *)(efi.systab->runtime->f), (u64)(a1), (u64)(a2), \
94                   (u64)(a3))
95 #define efi_call_virt4(f, a1, a2, a3, a4)                               \
96         efi_callx(4, (void *)(efi.systab->runtime->f), (u64)(a1), (u64)(a2), \
97                   (u64)(a3), (u64)(a4))
98 #define efi_call_virt5(f, a1, a2, a3, a4, a5)                           \
99         efi_callx(5, (void *)(efi.systab->runtime->f), (u64)(a1), (u64)(a2), \
100                   (u64)(a3), (u64)(a4), (u64)(a5))
101 #define efi_call_virt6(f, a1, a2, a3, a4, a5, a6)                       \
102         efi_callx(6, (void *)(efi.systab->runtime->f), (u64)(a1), (u64)(a2), \
103                   (u64)(a3), (u64)(a4), (u64)(a5), (u64)(a6))
104
105 extern void __iomem *efi_ioremap(unsigned long addr, unsigned long size,
106                                  u32 type, u64 attribute);
107
108 #endif /* CONFIG_X86_32 */
109
110 extern int add_efi_memmap;
111 extern void efi_set_executable(efi_memory_desc_t *md, bool executable);
112 extern int efi_memblock_x86_reserve_range(void);
113 extern void efi_call_phys_prelog(void);
114 extern void efi_call_phys_epilog(void);
115 extern void efi_unmap_memmap(void);
116 extern void efi_memory_uc(u64 addr, unsigned long size);
117
118 #ifndef CONFIG_EFI
119 /*
120  * IF EFI is not configured, have the EFI calls return -ENOSYS.
121  */
122 #define efi_call0(_f)                                   (-ENOSYS)
123 #define efi_call1(_f, _a1)                              (-ENOSYS)
124 #define efi_call2(_f, _a1, _a2)                         (-ENOSYS)
125 #define efi_call3(_f, _a1, _a2, _a3)                    (-ENOSYS)
126 #define efi_call4(_f, _a1, _a2, _a3, _a4)               (-ENOSYS)
127 #define efi_call5(_f, _a1, _a2, _a3, _a4, _a5)          (-ENOSYS)
128 #define efi_call6(_f, _a1, _a2, _a3, _a4, _a5, _a6)     (-ENOSYS)
129 #endif /* CONFIG_EFI */
130
131 #endif /* _ASM_X86_EFI_H */