blob: 96a7d067fbb260ce03f0d03a8163a3d755d4c08a [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 Ellermanc5157e52008-06-24 11:32:39 +100040#define MAKE_FTR_SECTION_ENTRY(msk, val, label, sect) \
Michael Ellermanfac23fe2008-06-24 11:32:54 +100041label##4: \
42 .popsection; \
43 .pushsection sect,"a"; \
Michael Ellermanc5157e52008-06-24 11:32:39 +100044 .align 3; \
Michael Ellermanfac23fe2008-06-24 11:32:54 +100045label##5: \
Michael Ellermanc1137c32008-06-24 11:32:48 +100046 FTR_ENTRY_LONG msk; \
47 FTR_ENTRY_LONG val; \
Michael Ellermanfac23fe2008-06-24 11:32:54 +100048 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 .popsection;
Michael Ellermanc5157e52008-06-24 11:32:39 +100053
54
55/* CPU feature dependent sections */
Michael Ellermanfac23fe2008-06-24 11:32:54 +100056#define BEGIN_FTR_SECTION_NESTED(label) START_FTR_SECTION(label)
57#define BEGIN_FTR_SECTION START_FTR_SECTION(97)
Michael Ellermanc5157e52008-06-24 11:32:39 +100058
Michael Ellermanfac23fe2008-06-24 11:32:54 +100059#define END_FTR_SECTION_NESTED(msk, val, label) \
60 FTR_SECTION_ELSE_NESTED(label) \
Michael Ellermanc5157e52008-06-24 11:32:39 +100061 MAKE_FTR_SECTION_ENTRY(msk, val, label, __ftr_fixup)
62
63#define END_FTR_SECTION(msk, val) \
64 END_FTR_SECTION_NESTED(msk, val, 97)
65
66#define END_FTR_SECTION_IFSET(msk) END_FTR_SECTION((msk), (msk))
67#define END_FTR_SECTION_IFCLR(msk) END_FTR_SECTION((msk), 0)
68
Michael Ellermanfac23fe2008-06-24 11:32:54 +100069/* CPU feature sections with alternatives, use BEGIN_FTR_SECTION to start */
70#define FTR_SECTION_ELSE FTR_SECTION_ELSE_NESTED(97)
71#define ALT_FTR_SECTION_END_NESTED(msk, val, label) \
72 MAKE_FTR_SECTION_ENTRY(msk, val, label, __ftr_fixup)
73#define ALT_FTR_SECTION_END_NESTED_IFSET(msk, label) \
74 ALT_FTR_SECTION_END_NESTED(msk, msk, label)
75#define ALT_FTR_SECTION_END_NESTED_IFCLR(msk, label) \
76 ALT_FTR_SECTION_END_NESTED(msk, 0, label)
77#define ALT_FTR_SECTION_END(msk, val) \
78 ALT_FTR_SECTION_END_NESTED(msk, val, 97)
79#define ALT_FTR_SECTION_END_IFSET(msk) \
80 ALT_FTR_SECTION_END_NESTED_IFSET(msk, 97)
81#define ALT_FTR_SECTION_END_IFCLR(msk) \
82 ALT_FTR_SECTION_END_NESTED_IFCLR(msk, 97)
Michael Ellermanc5157e52008-06-24 11:32:39 +100083
Benjamin Herrenschmidt7c03d652008-12-18 19:13:32 +000084/* MMU feature dependent sections */
85#define BEGIN_MMU_FTR_SECTION_NESTED(label) START_FTR_SECTION(label)
86#define BEGIN_MMU_FTR_SECTION START_FTR_SECTION(97)
87
88#define END_MMU_FTR_SECTION_NESTED(msk, val, label) \
89 FTR_SECTION_ELSE_NESTED(label) \
90 MAKE_FTR_SECTION_ENTRY(msk, val, label, __mmu_ftr_fixup)
91
92#define END_MMU_FTR_SECTION(msk, val) \
93 END_MMU_FTR_SECTION_NESTED(msk, val, 97)
94
95#define END_MMU_FTR_SECTION_IFSET(msk) END_MMU_FTR_SECTION((msk), (msk))
96#define END_MMU_FTR_SECTION_IFCLR(msk) END_MMU_FTR_SECTION((msk), 0)
97
98/* MMU feature sections with alternatives, use BEGIN_FTR_SECTION to start */
99#define MMU_FTR_SECTION_ELSE_NESTED(label) FTR_SECTION_ELSE_NESTED(label)
100#define MMU_FTR_SECTION_ELSE MMU_FTR_SECTION_ELSE_NESTED(97)
101#define ALT_MMU_FTR_SECTION_END_NESTED(msk, val, label) \
102 MAKE_FTR_SECTION_ENTRY(msk, val, label, __mmu_ftr_fixup)
103#define ALT_MMU_FTR_SECTION_END_NESTED_IFSET(msk, label) \
104 ALT_MMU_FTR_SECTION_END_NESTED(msk, msk, label)
105#define ALT_MMU_FTR_SECTION_END_NESTED_IFCLR(msk, label) \
106 ALT_MMU_FTR_SECTION_END_NESTED(msk, 0, label)
107#define ALT_MMU_FTR_SECTION_END(msk, val) \
108 ALT_MMU_FTR_SECTION_END_NESTED(msk, val, 97)
109#define ALT_MMU_FTR_SECTION_END_IFSET(msk) \
110 ALT_MMU_FTR_SECTION_END_NESTED_IFSET(msk, 97)
111#define ALT_MMU_FTR_SECTION_END_IFCLR(msk) \
112 ALT_MMU_FTR_SECTION_END_NESTED_IFCLR(msk, 97)
113
Michael Ellermanc5157e52008-06-24 11:32:39 +1000114/* Firmware feature dependent sections */
Michael Ellermanfac23fe2008-06-24 11:32:54 +1000115#define BEGIN_FW_FTR_SECTION_NESTED(label) START_FTR_SECTION(label)
116#define BEGIN_FW_FTR_SECTION START_FTR_SECTION(97)
Michael Ellermanc5157e52008-06-24 11:32:39 +1000117
Michael Ellermanfac23fe2008-06-24 11:32:54 +1000118#define END_FW_FTR_SECTION_NESTED(msk, val, label) \
119 FTR_SECTION_ELSE_NESTED(label) \
Michael Ellermanc5157e52008-06-24 11:32:39 +1000120 MAKE_FTR_SECTION_ENTRY(msk, val, label, __fw_ftr_fixup)
121
122#define END_FW_FTR_SECTION(msk, val) \
123 END_FW_FTR_SECTION_NESTED(msk, val, 97)
124
125#define END_FW_FTR_SECTION_IFSET(msk) END_FW_FTR_SECTION((msk), (msk))
126#define END_FW_FTR_SECTION_IFCLR(msk) END_FW_FTR_SECTION((msk), 0)
127
Michael Ellermanfac23fe2008-06-24 11:32:54 +1000128/* Firmware feature sections with alternatives */
129#define FW_FTR_SECTION_ELSE_NESTED(label) FTR_SECTION_ELSE_NESTED(label)
130#define FW_FTR_SECTION_ELSE FTR_SECTION_ELSE_NESTED(97)
131#define ALT_FW_FTR_SECTION_END_NESTED(msk, val, label) \
132 MAKE_FTR_SECTION_ENTRY(msk, val, label, __fw_ftr_fixup)
133#define ALT_FW_FTR_SECTION_END_NESTED_IFSET(msk, label) \
134 ALT_FW_FTR_SECTION_END_NESTED(msk, msk, label)
135#define ALT_FW_FTR_SECTION_END_NESTED_IFCLR(msk, label) \
136 ALT_FW_FTR_SECTION_END_NESTED(msk, 0, label)
137#define ALT_FW_FTR_SECTION_END(msk, val) \
138 ALT_FW_FTR_SECTION_END_NESTED(msk, val, 97)
139#define ALT_FW_FTR_SECTION_END_IFSET(msk) \
140 ALT_FW_FTR_SECTION_END_NESTED_IFSET(msk, 97)
141#define ALT_FW_FTR_SECTION_END_IFCLR(msk) \
142 ALT_FW_FTR_SECTION_END_NESTED_IFCLR(msk, 97)
143
Milton Milleraf20aeb2009-04-29 20:58:01 +0000144#ifndef __ASSEMBLY__
145
146#define ASM_MMU_FTR_IF(section_if, section_else, msk, val) \
147 stringify_in_c(BEGIN_MMU_FTR_SECTION) \
148 section_if "; " \
149 stringify_in_c(MMU_FTR_SECTION_ELSE) \
150 section_else "; " \
151 stringify_in_c(ALT_MMU_FTR_SECTION_END((msk), (val)))
152
153#define ASM_MMU_FTR_IFSET(section_if, section_else, msk) \
154 ASM_MMU_FTR_IF(section_if, section_else, (msk), (msk))
155
156#define ASM_MMU_FTR_IFCLR(section_if, section_else, msk) \
157 ASM_MMU_FTR_IF(section_if, section_else, (msk), 0)
158
Michael Ellermanc5157e52008-06-24 11:32:39 +1000159#endif /* __ASSEMBLY__ */
160
Kumar Gala2d1b2022008-07-02 01:16:40 +1000161/* LWSYNC feature sections */
162#define START_LWSYNC_SECTION(label) label##1:
163#define MAKE_LWSYNC_SECTION_ENTRY(label, sect) \
164label##2: \
165 .pushsection sect,"a"; \
166 .align 2; \
167label##3: \
Benjamin Herrenschmidt3d98ffb2010-02-26 18:29:17 +1100168 FTR_ENTRY_OFFSET label##1b-label##3b; \
Kumar Gala2d1b2022008-07-02 01:16:40 +1000169 .popsection;
170
Michael Ellermanc5157e52008-06-24 11:32:39 +1000171#endif /* __ASM_POWERPC_FEATURE_FIXUPS_H */