Michael Ellerman | c5157e5 | 2008-06-24 11:32:39 +1000 | [diff] [blame] | 1 | #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 Ellerman | c5157e5 | 2008-06-24 11:32:39 +1000 | [diff] [blame] | 11 | /* |
| 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 Ellerman | c1137c3 | 2008-06-24 11:32:48 +1000 | [diff] [blame] | 20 | #if defined(CONFIG_PPC64) && !defined(__powerpc64__) |
Michael Ellerman | c5157e5 | 2008-06-24 11:32:39 +1000 | [diff] [blame] | 21 | /* 64 bits kernel, 32 bits code (ie. vdso32) */ |
Michael Ellerman | c1137c3 | 2008-06-24 11:32:48 +1000 | [diff] [blame] | 22 | #define FTR_ENTRY_LONG .llong |
| 23 | #define FTR_ENTRY_OFFSET .long 0xffffffff; .long |
Milton Miller | af20aeb | 2009-04-29 20:58:01 +0000 | [diff] [blame] | 24 | #elif defined(CONFIG_PPC64) |
| 25 | #define FTR_ENTRY_LONG .llong |
| 26 | #define FTR_ENTRY_OFFSET .llong |
Michael Ellerman | c1137c3 | 2008-06-24 11:32:48 +1000 | [diff] [blame] | 27 | #else |
Milton Miller | af20aeb | 2009-04-29 20:58:01 +0000 | [diff] [blame] | 28 | #define FTR_ENTRY_LONG .long |
| 29 | #define FTR_ENTRY_OFFSET .long |
Michael Ellerman | c1137c3 | 2008-06-24 11:32:48 +1000 | [diff] [blame] | 30 | #endif |
| 31 | |
Michael Ellerman | fac23fe | 2008-06-24 11:32:54 +1000 | [diff] [blame] | 32 | #define START_FTR_SECTION(label) label##1: |
| 33 | |
| 34 | #define FTR_SECTION_ELSE_NESTED(label) \ |
| 35 | label##2: \ |
| 36 | .pushsection __ftr_alt_##label,"a"; \ |
| 37 | .align 2; \ |
| 38 | label##3: |
| 39 | |
Michael Ellerman | c033728 | 2010-11-07 18:22:29 +0000 | [diff] [blame] | 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; \ |
Benjamin Herrenschmidt | b3e6b5d | 2011-04-05 14:27:11 +1000 | [diff] [blame] | 52 | .ifgt (label##4b- label##3b)-(label##2b- label##1b); \ |
Michael Ellerman | c033728 | 2010-11-07 18:22:29 +0000 | [diff] [blame] | 53 | .error "Feature section else case larger than body"; \ |
| 54 | .endif; \ |
Michael Ellerman | fac23fe | 2008-06-24 11:32:54 +1000 | [diff] [blame] | 55 | .popsection; |
Michael Ellerman | c5157e5 | 2008-06-24 11:32:39 +1000 | [diff] [blame] | 56 | |
| 57 | |
| 58 | /* CPU feature dependent sections */ |
Michael Ellerman | fac23fe | 2008-06-24 11:32:54 +1000 | [diff] [blame] | 59 | #define BEGIN_FTR_SECTION_NESTED(label) START_FTR_SECTION(label) |
| 60 | #define BEGIN_FTR_SECTION START_FTR_SECTION(97) |
Michael Ellerman | c5157e5 | 2008-06-24 11:32:39 +1000 | [diff] [blame] | 61 | |
Michael Ellerman | fac23fe | 2008-06-24 11:32:54 +1000 | [diff] [blame] | 62 | #define END_FTR_SECTION_NESTED(msk, val, label) \ |
| 63 | FTR_SECTION_ELSE_NESTED(label) \ |
Michael Ellerman | c5157e5 | 2008-06-24 11:32:39 +1000 | [diff] [blame] | 64 | 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 Ellerman | fac23fe | 2008-06-24 11:32:54 +1000 | [diff] [blame] | 72 | /* 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 Ellerman | c5157e5 | 2008-06-24 11:32:39 +1000 | [diff] [blame] | 86 | |
Benjamin Herrenschmidt | 7c03d65 | 2008-12-18 19:13:32 +0000 | [diff] [blame] | 87 | /* 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 Ellerman | c5157e5 | 2008-06-24 11:32:39 +1000 | [diff] [blame] | 117 | /* Firmware feature dependent sections */ |
Michael Ellerman | fac23fe | 2008-06-24 11:32:54 +1000 | [diff] [blame] | 118 | #define BEGIN_FW_FTR_SECTION_NESTED(label) START_FTR_SECTION(label) |
| 119 | #define BEGIN_FW_FTR_SECTION START_FTR_SECTION(97) |
Michael Ellerman | c5157e5 | 2008-06-24 11:32:39 +1000 | [diff] [blame] | 120 | |
Michael Ellerman | fac23fe | 2008-06-24 11:32:54 +1000 | [diff] [blame] | 121 | #define END_FW_FTR_SECTION_NESTED(msk, val, label) \ |
| 122 | FTR_SECTION_ELSE_NESTED(label) \ |
Michael Ellerman | c5157e5 | 2008-06-24 11:32:39 +1000 | [diff] [blame] | 123 | 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 Ellerman | fac23fe | 2008-06-24 11:32:54 +1000 | [diff] [blame] | 131 | /* 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 Miller | af20aeb | 2009-04-29 20:58:01 +0000 | [diff] [blame] | 147 | #ifndef __ASSEMBLY__ |
| 148 | |
Michael Neuling | a32e252 | 2011-04-06 18:23:29 +0000 | [diff] [blame] | 149 | #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 Miller | af20aeb | 2009-04-29 20:58:01 +0000 | [diff] [blame] | 162 | #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 Ellerman | c5157e5 | 2008-06-24 11:32:39 +1000 | [diff] [blame] | 175 | #endif /* __ASSEMBLY__ */ |
| 176 | |
Kumar Gala | 2d1b202 | 2008-07-02 01:16:40 +1000 | [diff] [blame] | 177 | /* LWSYNC feature sections */ |
| 178 | #define START_LWSYNC_SECTION(label) label##1: |
| 179 | #define MAKE_LWSYNC_SECTION_ENTRY(label, sect) \ |
| 180 | label##2: \ |
| 181 | .pushsection sect,"a"; \ |
| 182 | .align 2; \ |
| 183 | label##3: \ |
Benjamin Herrenschmidt | 3d98ffb | 2010-02-26 18:29:17 +1100 | [diff] [blame] | 184 | FTR_ENTRY_OFFSET label##1b-label##3b; \ |
Kumar Gala | 2d1b202 | 2008-07-02 01:16:40 +1000 | [diff] [blame] | 185 | .popsection; |
| 186 | |
Michael Ellerman | c5157e5 | 2008-06-24 11:32:39 +1000 | [diff] [blame] | 187 | #endif /* __ASM_POWERPC_FEATURE_FIXUPS_H */ |