blob: 9a67a38bf7b94a3b443dc0b1428bf64b40b544aa [file] [log] [blame]
Michael Ellermanc5157e52008-06-24 11:32:39 +10001#ifndef __ASM_POWERPC_FEATURE_FIXUPS_H
2#define __ASM_POWERPC_FEATURE_FIXUPS_H
3
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 */
10
Michael Ellermanc5157e52008-06-24 11:32:39 +100011/*
12 * Feature section common macros
13 *
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.
19 */
Michael Ellermanc1137c32008-06-24 11:32:48 +100020#if defined(CONFIG_PPC64) && !defined(__powerpc64__)
Michael Ellermanc5157e52008-06-24 11:32:39 +100021/* 64 bits kernel, 32 bits code (ie. vdso32) */
Michael Ellermanc1137c32008-06-24 11:32:48 +100022#define FTR_ENTRY_LONG .llong
23#define FTR_ENTRY_OFFSET .long 0xffffffff; .long
Milton Milleraf20aeb2009-04-29 20:58:01 +000024#elif defined(CONFIG_PPC64)
25#define FTR_ENTRY_LONG .llong
26#define FTR_ENTRY_OFFSET .llong
Michael Ellermanc1137c32008-06-24 11:32:48 +100027#else
Milton Milleraf20aeb2009-04-29 20:58:01 +000028#define FTR_ENTRY_LONG .long
29#define FTR_ENTRY_OFFSET .long
Michael Ellermanc1137c32008-06-24 11:32:48 +100030#endif
31
Michael Ellermanfac23fe2008-06-24 11:32:54 +100032#define START_FTR_SECTION(label) label##1:
33
34#define FTR_SECTION_ELSE_NESTED(label) \
35label##2: \
36 .pushsection __ftr_alt_##label,"a"; \
37 .align 2; \
38label##3:
39
Michael Ellermanc0337282010-11-07 18:22:29 +000040#define MAKE_FTR_SECTION_ENTRY(msk, val, label, sect) \
41label##4: \
42 .popsection; \
43 .pushsection sect,"a"; \
44 .align 3; \
45label##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; \
Benjamin Herrenschmidtb3e6b5d2011-04-05 14:27:11 +100052 .ifgt (label##4b- label##3b)-(label##2b- label##1b); \
Michael Ellermanc0337282010-11-07 18:22:29 +000053 .error "Feature section else case larger than body"; \
54 .endif; \
Michael Ellermanfac23fe2008-06-24 11:32:54 +100055 .popsection;
Michael Ellermanc5157e52008-06-24 11:32:39 +100056
57
58/* CPU feature dependent sections */
Michael Ellermanfac23fe2008-06-24 11:32:54 +100059#define BEGIN_FTR_SECTION_NESTED(label) START_FTR_SECTION(label)
60#define BEGIN_FTR_SECTION START_FTR_SECTION(97)
Michael Ellermanc5157e52008-06-24 11:32:39 +100061
Michael Ellermanfac23fe2008-06-24 11:32:54 +100062#define END_FTR_SECTION_NESTED(msk, val, label) \
63 FTR_SECTION_ELSE_NESTED(label) \
Michael Ellermanc5157e52008-06-24 11:32:39 +100064 MAKE_FTR_SECTION_ENTRY(msk, val, label, __ftr_fixup)
65
66#define END_FTR_SECTION(msk, val) \
67 END_FTR_SECTION_NESTED(msk, val, 97)
68
69#define END_FTR_SECTION_IFSET(msk) END_FTR_SECTION((msk), (msk))
70#define END_FTR_SECTION_IFCLR(msk) END_FTR_SECTION((msk), 0)
71
Michael Ellermanfac23fe2008-06-24 11:32:54 +100072/* CPU feature sections with alternatives, use BEGIN_FTR_SECTION to start */
73#define FTR_SECTION_ELSE FTR_SECTION_ELSE_NESTED(97)
74#define ALT_FTR_SECTION_END_NESTED(msk, val, label) \
75 MAKE_FTR_SECTION_ENTRY(msk, val, label, __ftr_fixup)
76#define ALT_FTR_SECTION_END_NESTED_IFSET(msk, label) \
77 ALT_FTR_SECTION_END_NESTED(msk, msk, label)
78#define ALT_FTR_SECTION_END_NESTED_IFCLR(msk, label) \
79 ALT_FTR_SECTION_END_NESTED(msk, 0, label)
80#define ALT_FTR_SECTION_END(msk, val) \
81 ALT_FTR_SECTION_END_NESTED(msk, val, 97)
82#define ALT_FTR_SECTION_END_IFSET(msk) \
83 ALT_FTR_SECTION_END_NESTED_IFSET(msk, 97)
84#define ALT_FTR_SECTION_END_IFCLR(msk) \
85 ALT_FTR_SECTION_END_NESTED_IFCLR(msk, 97)
Michael Ellermanc5157e52008-06-24 11:32:39 +100086
Benjamin Herrenschmidt7c03d652008-12-18 19:13:32 +000087/* MMU feature dependent sections */
88#define BEGIN_MMU_FTR_SECTION_NESTED(label) START_FTR_SECTION(label)
89#define BEGIN_MMU_FTR_SECTION START_FTR_SECTION(97)
90
91#define END_MMU_FTR_SECTION_NESTED(msk, val, label) \
92 FTR_SECTION_ELSE_NESTED(label) \
93 MAKE_FTR_SECTION_ENTRY(msk, val, label, __mmu_ftr_fixup)
94
95#define END_MMU_FTR_SECTION(msk, val) \
96 END_MMU_FTR_SECTION_NESTED(msk, val, 97)
97
98#define END_MMU_FTR_SECTION_IFSET(msk) END_MMU_FTR_SECTION((msk), (msk))
99#define END_MMU_FTR_SECTION_IFCLR(msk) END_MMU_FTR_SECTION((msk), 0)
100
101/* MMU feature sections with alternatives, use BEGIN_FTR_SECTION to start */
102#define MMU_FTR_SECTION_ELSE_NESTED(label) FTR_SECTION_ELSE_NESTED(label)
103#define MMU_FTR_SECTION_ELSE MMU_FTR_SECTION_ELSE_NESTED(97)
104#define ALT_MMU_FTR_SECTION_END_NESTED(msk, val, label) \
105 MAKE_FTR_SECTION_ENTRY(msk, val, label, __mmu_ftr_fixup)
106#define ALT_MMU_FTR_SECTION_END_NESTED_IFSET(msk, label) \
107 ALT_MMU_FTR_SECTION_END_NESTED(msk, msk, label)
108#define ALT_MMU_FTR_SECTION_END_NESTED_IFCLR(msk, label) \
109 ALT_MMU_FTR_SECTION_END_NESTED(msk, 0, label)
110#define ALT_MMU_FTR_SECTION_END(msk, val) \
111 ALT_MMU_FTR_SECTION_END_NESTED(msk, val, 97)
112#define ALT_MMU_FTR_SECTION_END_IFSET(msk) \
113 ALT_MMU_FTR_SECTION_END_NESTED_IFSET(msk, 97)
114#define ALT_MMU_FTR_SECTION_END_IFCLR(msk) \
115 ALT_MMU_FTR_SECTION_END_NESTED_IFCLR(msk, 97)
116
Michael Ellermanc5157e52008-06-24 11:32:39 +1000117/* Firmware feature dependent sections */
Michael Ellermanfac23fe2008-06-24 11:32:54 +1000118#define BEGIN_FW_FTR_SECTION_NESTED(label) START_FTR_SECTION(label)
119#define BEGIN_FW_FTR_SECTION START_FTR_SECTION(97)
Michael Ellermanc5157e52008-06-24 11:32:39 +1000120
Michael Ellermanfac23fe2008-06-24 11:32:54 +1000121#define END_FW_FTR_SECTION_NESTED(msk, val, label) \
122 FTR_SECTION_ELSE_NESTED(label) \
Michael Ellermanc5157e52008-06-24 11:32:39 +1000123 MAKE_FTR_SECTION_ENTRY(msk, val, label, __fw_ftr_fixup)
124
125#define END_FW_FTR_SECTION(msk, val) \
126 END_FW_FTR_SECTION_NESTED(msk, val, 97)
127
128#define END_FW_FTR_SECTION_IFSET(msk) END_FW_FTR_SECTION((msk), (msk))
129#define END_FW_FTR_SECTION_IFCLR(msk) END_FW_FTR_SECTION((msk), 0)
130
Michael Ellermanfac23fe2008-06-24 11:32:54 +1000131/* Firmware feature sections with alternatives */
132#define FW_FTR_SECTION_ELSE_NESTED(label) FTR_SECTION_ELSE_NESTED(label)
133#define FW_FTR_SECTION_ELSE FTR_SECTION_ELSE_NESTED(97)
134#define ALT_FW_FTR_SECTION_END_NESTED(msk, val, label) \
135 MAKE_FTR_SECTION_ENTRY(msk, val, label, __fw_ftr_fixup)
136#define ALT_FW_FTR_SECTION_END_NESTED_IFSET(msk, label) \
137 ALT_FW_FTR_SECTION_END_NESTED(msk, msk, label)
138#define ALT_FW_FTR_SECTION_END_NESTED_IFCLR(msk, label) \
139 ALT_FW_FTR_SECTION_END_NESTED(msk, 0, label)
140#define ALT_FW_FTR_SECTION_END(msk, val) \
141 ALT_FW_FTR_SECTION_END_NESTED(msk, val, 97)
142#define ALT_FW_FTR_SECTION_END_IFSET(msk) \
143 ALT_FW_FTR_SECTION_END_NESTED_IFSET(msk, 97)
144#define ALT_FW_FTR_SECTION_END_IFCLR(msk) \
145 ALT_FW_FTR_SECTION_END_NESTED_IFCLR(msk, 97)
146
Milton Milleraf20aeb2009-04-29 20:58:01 +0000147#ifndef __ASSEMBLY__
148
Michael Neulinga32e2522011-04-06 18:23:29 +0000149#define ASM_FTR_IF(section_if, section_else, msk, val) \
150 stringify_in_c(BEGIN_FTR_SECTION) \
151 section_if "; " \
152 stringify_in_c(FTR_SECTION_ELSE) \
153 section_else "; " \
154 stringify_in_c(ALT_FTR_SECTION_END((msk), (val)))
155
156#define ASM_FTR_IFSET(section_if, section_else, msk) \
157 ASM_FTR_IF(section_if, section_else, (msk), (msk))
158
159#define ASM_FTR_IFCLR(section_if, section_else, msk) \
160 ASM_FTR_IF(section_if, section_else, (msk), 0)
161
Milton Milleraf20aeb2009-04-29 20:58:01 +0000162#define ASM_MMU_FTR_IF(section_if, section_else, msk, val) \
163 stringify_in_c(BEGIN_MMU_FTR_SECTION) \
164 section_if "; " \
165 stringify_in_c(MMU_FTR_SECTION_ELSE) \
166 section_else "; " \
167 stringify_in_c(ALT_MMU_FTR_SECTION_END((msk), (val)))
168
169#define ASM_MMU_FTR_IFSET(section_if, section_else, msk) \
170 ASM_MMU_FTR_IF(section_if, section_else, (msk), (msk))
171
172#define ASM_MMU_FTR_IFCLR(section_if, section_else, msk) \
173 ASM_MMU_FTR_IF(section_if, section_else, (msk), 0)
174
Michael Ellermanc5157e52008-06-24 11:32:39 +1000175#endif /* __ASSEMBLY__ */
176
Kumar Gala2d1b2022008-07-02 01:16:40 +1000177/* LWSYNC feature sections */
178#define START_LWSYNC_SECTION(label) label##1:
179#define MAKE_LWSYNC_SECTION_ENTRY(label, sect) \
180label##2: \
181 .pushsection sect,"a"; \
182 .align 2; \
183label##3: \
Benjamin Herrenschmidt3d98ffb2010-02-26 18:29:17 +1100184 FTR_ENTRY_OFFSET label##1b-label##3b; \
Kumar Gala2d1b2022008-07-02 01:16:40 +1000185 .popsection;
186
Michael Ellermanc5157e52008-06-24 11:32:39 +1000187#endif /* __ASM_POWERPC_FEATURE_FIXUPS_H */