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 | c5157e5 | 2008-06-24 11:32:39 +1000 | [diff] [blame] | 40 | #define MAKE_FTR_SECTION_ENTRY(msk, val, label, sect) \ |
Michael Ellerman | fac23fe | 2008-06-24 11:32:54 +1000 | [diff] [blame] | 41 | label##4: \ |
| 42 | .popsection; \ |
| 43 | .pushsection sect,"a"; \ |
Michael Ellerman | c5157e5 | 2008-06-24 11:32:39 +1000 | [diff] [blame] | 44 | .align 3; \ |
Michael Ellerman | fac23fe | 2008-06-24 11:32:54 +1000 | [diff] [blame] | 45 | label##5: \ |
Michael Ellerman | c1137c3 | 2008-06-24 11:32:48 +1000 | [diff] [blame] | 46 | FTR_ENTRY_LONG msk; \ |
| 47 | FTR_ENTRY_LONG val; \ |
Michael Ellerman | fac23fe | 2008-06-24 11:32:54 +1000 | [diff] [blame] | 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 | .popsection; |
Michael Ellerman | c5157e5 | 2008-06-24 11:32:39 +1000 | [diff] [blame] | 53 | |
| 54 | |
| 55 | /* CPU feature dependent sections */ |
Michael Ellerman | fac23fe | 2008-06-24 11:32:54 +1000 | [diff] [blame] | 56 | #define BEGIN_FTR_SECTION_NESTED(label) START_FTR_SECTION(label) |
| 57 | #define BEGIN_FTR_SECTION START_FTR_SECTION(97) |
Michael Ellerman | c5157e5 | 2008-06-24 11:32:39 +1000 | [diff] [blame] | 58 | |
Michael Ellerman | fac23fe | 2008-06-24 11:32:54 +1000 | [diff] [blame] | 59 | #define END_FTR_SECTION_NESTED(msk, val, label) \ |
| 60 | FTR_SECTION_ELSE_NESTED(label) \ |
Michael Ellerman | c5157e5 | 2008-06-24 11:32:39 +1000 | [diff] [blame] | 61 | 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 Ellerman | fac23fe | 2008-06-24 11:32:54 +1000 | [diff] [blame] | 69 | /* 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 Ellerman | c5157e5 | 2008-06-24 11:32:39 +1000 | [diff] [blame] | 83 | |
Benjamin Herrenschmidt | 7c03d65 | 2008-12-18 19:13:32 +0000 | [diff] [blame] | 84 | /* 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 Ellerman | c5157e5 | 2008-06-24 11:32:39 +1000 | [diff] [blame] | 114 | /* Firmware feature dependent sections */ |
Michael Ellerman | fac23fe | 2008-06-24 11:32:54 +1000 | [diff] [blame] | 115 | #define BEGIN_FW_FTR_SECTION_NESTED(label) START_FTR_SECTION(label) |
| 116 | #define BEGIN_FW_FTR_SECTION START_FTR_SECTION(97) |
Michael Ellerman | c5157e5 | 2008-06-24 11:32:39 +1000 | [diff] [blame] | 117 | |
Michael Ellerman | fac23fe | 2008-06-24 11:32:54 +1000 | [diff] [blame] | 118 | #define END_FW_FTR_SECTION_NESTED(msk, val, label) \ |
| 119 | FTR_SECTION_ELSE_NESTED(label) \ |
Michael Ellerman | c5157e5 | 2008-06-24 11:32:39 +1000 | [diff] [blame] | 120 | 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 Ellerman | fac23fe | 2008-06-24 11:32:54 +1000 | [diff] [blame] | 128 | /* 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 Miller | af20aeb | 2009-04-29 20:58:01 +0000 | [diff] [blame] | 144 | #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 Ellerman | c5157e5 | 2008-06-24 11:32:39 +1000 | [diff] [blame] | 159 | #endif /* __ASSEMBLY__ */ |
| 160 | |
Kumar Gala | 2d1b202 | 2008-07-02 01:16:40 +1000 | [diff] [blame] | 161 | /* LWSYNC feature sections */ |
| 162 | #define START_LWSYNC_SECTION(label) label##1: |
| 163 | #define MAKE_LWSYNC_SECTION_ENTRY(label, sect) \ |
| 164 | label##2: \ |
| 165 | .pushsection sect,"a"; \ |
| 166 | .align 2; \ |
| 167 | label##3: \ |
Benjamin Herrenschmidt | 3d98ffb | 2010-02-26 18:29:17 +1100 | [diff] [blame] | 168 | FTR_ENTRY_OFFSET label##1b-label##3b; \ |
Kumar Gala | 2d1b202 | 2008-07-02 01:16:40 +1000 | [diff] [blame] | 169 | .popsection; |
| 170 | |
Michael Ellerman | c5157e5 | 2008-06-24 11:32:39 +1000 | [diff] [blame] | 171 | #endif /* __ASM_POWERPC_FEATURE_FIXUPS_H */ |