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 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 */ 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 31 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 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 .popsection; 53 54 55 /* CPU feature dependent sections */ 56 #define BEGIN_FTR_SECTION_NESTED(label) START_FTR_SECTION(label) 57 #define BEGIN_FTR_SECTION START_FTR_SECTION(97) 58 59 #define END_FTR_SECTION_NESTED(msk, val, label) \ 60 FTR_SECTION_ELSE_NESTED(label) \ 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 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) 83 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 114 /* Firmware feature dependent sections */ 115 #define BEGIN_FW_FTR_SECTION_NESTED(label) START_FTR_SECTION(label) 116 #define BEGIN_FW_FTR_SECTION START_FTR_SECTION(97) 117 118 #define END_FW_FTR_SECTION_NESTED(msk, val, label) \ 119 FTR_SECTION_ELSE_NESTED(label) \ 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 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 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 159 #endif /* __ASSEMBLY__ */ 160 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: \ 168 .long label##1b-label##3b; \ 169 .popsection; 170 171 #endif /* __ASM_POWERPC_FEATURE_FIXUPS_H */ 172