Linux 4.13.16
[linux/fpc-iii.git] / arch / powerpc / include / asm / feature-fixups.h
blob2de2319b99e2c6a69991df5de988cc02c9abb3aa
1 #ifndef __ASM_POWERPC_FEATURE_FIXUPS_H
2 #define __ASM_POWERPC_FEATURE_FIXUPS_H
4 /*
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version
8 * 2 of the License, or (at your option) any later version.
9 */
12 * Feature section common macros
14 * Note that the entries now contain offsets between the table entry
15 * and the code rather than absolute code pointers in order to be
16 * useable with the vdso shared library. There is also an assumption
17 * that values will be negative, that is, the fixup table has to be
18 * located after the code it fixes up.
20 #if defined(CONFIG_PPC64) && !defined(__powerpc64__)
21 /* 64 bits kernel, 32 bits code (ie. vdso32) */
22 #define FTR_ENTRY_LONG .llong
23 #define FTR_ENTRY_OFFSET .long 0xffffffff; .long
24 #elif defined(CONFIG_PPC64)
25 #define FTR_ENTRY_LONG .llong
26 #define FTR_ENTRY_OFFSET .llong
27 #else
28 #define FTR_ENTRY_LONG .long
29 #define FTR_ENTRY_OFFSET .long
30 #endif
32 #define START_FTR_SECTION(label) label##1:
34 #define FTR_SECTION_ELSE_NESTED(label) \
35 label##2: \
36 .pushsection __ftr_alt_##label,"a"; \
37 .align 2; \
38 label##3:
40 #define MAKE_FTR_SECTION_ENTRY(msk, val, label, sect) \
41 label##4: \
42 .popsection; \
43 .pushsection sect,"a"; \
44 .align 3; \
45 label##5: \
46 FTR_ENTRY_LONG msk; \
47 FTR_ENTRY_LONG val; \
48 FTR_ENTRY_OFFSET label##1b-label##5b; \
49 FTR_ENTRY_OFFSET label##2b-label##5b; \
50 FTR_ENTRY_OFFSET label##3b-label##5b; \
51 FTR_ENTRY_OFFSET label##4b-label##5b; \
52 .ifgt (label##4b- label##3b)-(label##2b- label##1b); \
53 .error "Feature section else case larger than body"; \
54 .endif; \
55 .popsection;
58 /* CPU feature dependent sections */
59 #define BEGIN_FTR_SECTION_NESTED(label) START_FTR_SECTION(label)
60 #define BEGIN_FTR_SECTION START_FTR_SECTION(97)
62 #define END_FTR_SECTION_NESTED(msk, val, label) \
63 FTR_SECTION_ELSE_NESTED(label) \
64 MAKE_FTR_SECTION_ENTRY(msk, val, label, __ftr_fixup)
66 #define END_FTR_SECTION(msk, val) \
67 END_FTR_SECTION_NESTED(msk, val, 97)
69 #define END_FTR_SECTION_NESTED_IFSET(msk, label) \
70 END_FTR_SECTION_NESTED((msk), (msk), label)
72 #define END_FTR_SECTION_IFSET(msk) END_FTR_SECTION((msk), (msk))
73 #define END_FTR_SECTION_IFCLR(msk) END_FTR_SECTION((msk), 0)
75 /* CPU feature sections with alternatives, use BEGIN_FTR_SECTION to start */
76 #define FTR_SECTION_ELSE FTR_SECTION_ELSE_NESTED(97)
77 #define ALT_FTR_SECTION_END_NESTED(msk, val, label) \
78 MAKE_FTR_SECTION_ENTRY(msk, val, label, __ftr_fixup)
79 #define ALT_FTR_SECTION_END_NESTED_IFSET(msk, label) \
80 ALT_FTR_SECTION_END_NESTED(msk, msk, label)
81 #define ALT_FTR_SECTION_END_NESTED_IFCLR(msk, label) \
82 ALT_FTR_SECTION_END_NESTED(msk, 0, label)
83 #define ALT_FTR_SECTION_END(msk, val) \
84 ALT_FTR_SECTION_END_NESTED(msk, val, 97)
85 #define ALT_FTR_SECTION_END_IFSET(msk) \
86 ALT_FTR_SECTION_END_NESTED_IFSET(msk, 97)
87 #define ALT_FTR_SECTION_END_IFCLR(msk) \
88 ALT_FTR_SECTION_END_NESTED_IFCLR(msk, 97)
90 /* MMU feature dependent sections */
91 #define BEGIN_MMU_FTR_SECTION_NESTED(label) START_FTR_SECTION(label)
92 #define BEGIN_MMU_FTR_SECTION START_FTR_SECTION(97)
94 #define END_MMU_FTR_SECTION_NESTED(msk, val, label) \
95 FTR_SECTION_ELSE_NESTED(label) \
96 MAKE_FTR_SECTION_ENTRY(msk, val, label, __mmu_ftr_fixup)
98 #define END_MMU_FTR_SECTION(msk, val) \
99 END_MMU_FTR_SECTION_NESTED(msk, val, 97)
101 #define END_MMU_FTR_SECTION_IFSET(msk) END_MMU_FTR_SECTION((msk), (msk))
102 #define END_MMU_FTR_SECTION_IFCLR(msk) END_MMU_FTR_SECTION((msk), 0)
104 /* MMU feature sections with alternatives, use BEGIN_FTR_SECTION to start */
105 #define MMU_FTR_SECTION_ELSE_NESTED(label) FTR_SECTION_ELSE_NESTED(label)
106 #define MMU_FTR_SECTION_ELSE MMU_FTR_SECTION_ELSE_NESTED(97)
107 #define ALT_MMU_FTR_SECTION_END_NESTED(msk, val, label) \
108 MAKE_FTR_SECTION_ENTRY(msk, val, label, __mmu_ftr_fixup)
109 #define ALT_MMU_FTR_SECTION_END_NESTED_IFSET(msk, label) \
110 ALT_MMU_FTR_SECTION_END_NESTED(msk, msk, label)
111 #define ALT_MMU_FTR_SECTION_END_NESTED_IFCLR(msk, label) \
112 ALT_MMU_FTR_SECTION_END_NESTED(msk, 0, label)
113 #define ALT_MMU_FTR_SECTION_END(msk, val) \
114 ALT_MMU_FTR_SECTION_END_NESTED(msk, val, 97)
115 #define ALT_MMU_FTR_SECTION_END_IFSET(msk) \
116 ALT_MMU_FTR_SECTION_END_NESTED_IFSET(msk, 97)
117 #define ALT_MMU_FTR_SECTION_END_IFCLR(msk) \
118 ALT_MMU_FTR_SECTION_END_NESTED_IFCLR(msk, 97)
120 /* Firmware feature dependent sections */
121 #define BEGIN_FW_FTR_SECTION_NESTED(label) START_FTR_SECTION(label)
122 #define BEGIN_FW_FTR_SECTION START_FTR_SECTION(97)
124 #define END_FW_FTR_SECTION_NESTED(msk, val, label) \
125 FTR_SECTION_ELSE_NESTED(label) \
126 MAKE_FTR_SECTION_ENTRY(msk, val, label, __fw_ftr_fixup)
128 #define END_FW_FTR_SECTION(msk, val) \
129 END_FW_FTR_SECTION_NESTED(msk, val, 97)
131 #define END_FW_FTR_SECTION_IFSET(msk) END_FW_FTR_SECTION((msk), (msk))
132 #define END_FW_FTR_SECTION_IFCLR(msk) END_FW_FTR_SECTION((msk), 0)
134 /* Firmware feature sections with alternatives */
135 #define FW_FTR_SECTION_ELSE_NESTED(label) FTR_SECTION_ELSE_NESTED(label)
136 #define FW_FTR_SECTION_ELSE FTR_SECTION_ELSE_NESTED(97)
137 #define ALT_FW_FTR_SECTION_END_NESTED(msk, val, label) \
138 MAKE_FTR_SECTION_ENTRY(msk, val, label, __fw_ftr_fixup)
139 #define ALT_FW_FTR_SECTION_END_NESTED_IFSET(msk, label) \
140 ALT_FW_FTR_SECTION_END_NESTED(msk, msk, label)
141 #define ALT_FW_FTR_SECTION_END_NESTED_IFCLR(msk, label) \
142 ALT_FW_FTR_SECTION_END_NESTED(msk, 0, label)
143 #define ALT_FW_FTR_SECTION_END(msk, val) \
144 ALT_FW_FTR_SECTION_END_NESTED(msk, val, 97)
145 #define ALT_FW_FTR_SECTION_END_IFSET(msk) \
146 ALT_FW_FTR_SECTION_END_NESTED_IFSET(msk, 97)
147 #define ALT_FW_FTR_SECTION_END_IFCLR(msk) \
148 ALT_FW_FTR_SECTION_END_NESTED_IFCLR(msk, 97)
150 #ifndef __ASSEMBLY__
152 #define ASM_FTR_IF(section_if, section_else, msk, val) \
153 stringify_in_c(BEGIN_FTR_SECTION) \
154 section_if "; " \
155 stringify_in_c(FTR_SECTION_ELSE) \
156 section_else "; " \
157 stringify_in_c(ALT_FTR_SECTION_END((msk), (val)))
159 #define ASM_FTR_IFSET(section_if, section_else, msk) \
160 ASM_FTR_IF(section_if, section_else, (msk), (msk))
162 #define ASM_FTR_IFCLR(section_if, section_else, msk) \
163 ASM_FTR_IF(section_if, section_else, (msk), 0)
165 #define ASM_MMU_FTR_IF(section_if, section_else, msk, val) \
166 stringify_in_c(BEGIN_MMU_FTR_SECTION) \
167 section_if "; " \
168 stringify_in_c(MMU_FTR_SECTION_ELSE) \
169 section_else "; " \
170 stringify_in_c(ALT_MMU_FTR_SECTION_END((msk), (val)))
172 #define ASM_MMU_FTR_IFSET(section_if, section_else, msk) \
173 ASM_MMU_FTR_IF(section_if, section_else, (msk), (msk))
175 #define ASM_MMU_FTR_IFCLR(section_if, section_else, msk) \
176 ASM_MMU_FTR_IF(section_if, section_else, (msk), 0)
178 #endif /* __ASSEMBLY__ */
180 /* LWSYNC feature sections */
181 #define START_LWSYNC_SECTION(label) label##1:
182 #define MAKE_LWSYNC_SECTION_ENTRY(label, sect) \
183 label##2: \
184 .pushsection sect,"a"; \
185 .align 2; \
186 label##3: \
187 FTR_ENTRY_OFFSET label##1b-label##3b; \
188 .popsection;
190 #ifndef __ASSEMBLY__
191 void apply_feature_fixups(void);
192 void setup_feature_keys(void);
193 #endif
195 #endif /* __ASM_POWERPC_FEATURE_FIXUPS_H */