feature-fixups.h 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. #ifndef __ASM_POWERPC_FEATURE_FIXUPS_H
  2. #define __ASM_POWERPC_FEATURE_FIXUPS_H
  3. /*
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License
  6. * as published by the Free Software Foundation; either version
  7. * 2 of the License, or (at your option) any later version.
  8. */
  9. /*
  10. * Feature section common macros
  11. *
  12. * Note that the entries now contain offsets between the table entry
  13. * and the code rather than absolute code pointers in order to be
  14. * useable with the vdso shared library. There is also an assumption
  15. * that values will be negative, that is, the fixup table has to be
  16. * located after the code it fixes up.
  17. */
  18. #if defined(CONFIG_PPC64) && !defined(__powerpc64__)
  19. /* 64 bits kernel, 32 bits code (ie. vdso32) */
  20. #define FTR_ENTRY_LONG .llong
  21. #define FTR_ENTRY_OFFSET .long 0xffffffff; .long
  22. #elif defined(CONFIG_PPC64)
  23. #define FTR_ENTRY_LONG .llong
  24. #define FTR_ENTRY_OFFSET .llong
  25. #else
  26. #define FTR_ENTRY_LONG .long
  27. #define FTR_ENTRY_OFFSET .long
  28. #endif
  29. #define START_FTR_SECTION(label) label##1:
  30. #define FTR_SECTION_ELSE_NESTED(label) \
  31. label##2: \
  32. .pushsection __ftr_alt_##label,"a"; \
  33. .align 2; \
  34. label##3:
  35. #define MAKE_FTR_SECTION_ENTRY(msk, val, label, sect) \
  36. label##4: \
  37. .popsection; \
  38. .pushsection sect,"a"; \
  39. .align 3; \
  40. label##5: \
  41. FTR_ENTRY_LONG msk; \
  42. FTR_ENTRY_LONG val; \
  43. FTR_ENTRY_OFFSET label##1b-label##5b; \
  44. FTR_ENTRY_OFFSET label##2b-label##5b; \
  45. FTR_ENTRY_OFFSET label##3b-label##5b; \
  46. FTR_ENTRY_OFFSET label##4b-label##5b; \
  47. .ifgt (label##4b- label##3b)-(label##2b- label##1b); \
  48. .error "Feature section else case larger than body"; \
  49. .endif; \
  50. .popsection;
  51. /* CPU feature dependent sections */
  52. #define BEGIN_FTR_SECTION_NESTED(label) START_FTR_SECTION(label)
  53. #define BEGIN_FTR_SECTION START_FTR_SECTION(97)
  54. #define END_FTR_SECTION_NESTED(msk, val, label) \
  55. FTR_SECTION_ELSE_NESTED(label) \
  56. MAKE_FTR_SECTION_ENTRY(msk, val, label, __ftr_fixup)
  57. #define END_FTR_SECTION(msk, val) \
  58. END_FTR_SECTION_NESTED(msk, val, 97)
  59. #define END_FTR_SECTION_IFSET(msk) END_FTR_SECTION((msk), (msk))
  60. #define END_FTR_SECTION_IFCLR(msk) END_FTR_SECTION((msk), 0)
  61. /* CPU feature sections with alternatives, use BEGIN_FTR_SECTION to start */
  62. #define FTR_SECTION_ELSE FTR_SECTION_ELSE_NESTED(97)
  63. #define ALT_FTR_SECTION_END_NESTED(msk, val, label) \
  64. MAKE_FTR_SECTION_ENTRY(msk, val, label, __ftr_fixup)
  65. #define ALT_FTR_SECTION_END_NESTED_IFSET(msk, label) \
  66. ALT_FTR_SECTION_END_NESTED(msk, msk, label)
  67. #define ALT_FTR_SECTION_END_NESTED_IFCLR(msk, label) \
  68. ALT_FTR_SECTION_END_NESTED(msk, 0, label)
  69. #define ALT_FTR_SECTION_END(msk, val) \
  70. ALT_FTR_SECTION_END_NESTED(msk, val, 97)
  71. #define ALT_FTR_SECTION_END_IFSET(msk) \
  72. ALT_FTR_SECTION_END_NESTED_IFSET(msk, 97)
  73. #define ALT_FTR_SECTION_END_IFCLR(msk) \
  74. ALT_FTR_SECTION_END_NESTED_IFCLR(msk, 97)
  75. /* MMU feature dependent sections */
  76. #define BEGIN_MMU_FTR_SECTION_NESTED(label) START_FTR_SECTION(label)
  77. #define BEGIN_MMU_FTR_SECTION START_FTR_SECTION(97)
  78. #define END_MMU_FTR_SECTION_NESTED(msk, val, label) \
  79. FTR_SECTION_ELSE_NESTED(label) \
  80. MAKE_FTR_SECTION_ENTRY(msk, val, label, __mmu_ftr_fixup)
  81. #define END_MMU_FTR_SECTION(msk, val) \
  82. END_MMU_FTR_SECTION_NESTED(msk, val, 97)
  83. #define END_MMU_FTR_SECTION_IFSET(msk) END_MMU_FTR_SECTION((msk), (msk))
  84. #define END_MMU_FTR_SECTION_IFCLR(msk) END_MMU_FTR_SECTION((msk), 0)
  85. /* MMU feature sections with alternatives, use BEGIN_FTR_SECTION to start */
  86. #define MMU_FTR_SECTION_ELSE_NESTED(label) FTR_SECTION_ELSE_NESTED(label)
  87. #define MMU_FTR_SECTION_ELSE MMU_FTR_SECTION_ELSE_NESTED(97)
  88. #define ALT_MMU_FTR_SECTION_END_NESTED(msk, val, label) \
  89. MAKE_FTR_SECTION_ENTRY(msk, val, label, __mmu_ftr_fixup)
  90. #define ALT_MMU_FTR_SECTION_END_NESTED_IFSET(msk, label) \
  91. ALT_MMU_FTR_SECTION_END_NESTED(msk, msk, label)
  92. #define ALT_MMU_FTR_SECTION_END_NESTED_IFCLR(msk, label) \
  93. ALT_MMU_FTR_SECTION_END_NESTED(msk, 0, label)
  94. #define ALT_MMU_FTR_SECTION_END(msk, val) \
  95. ALT_MMU_FTR_SECTION_END_NESTED(msk, val, 97)
  96. #define ALT_MMU_FTR_SECTION_END_IFSET(msk) \
  97. ALT_MMU_FTR_SECTION_END_NESTED_IFSET(msk, 97)
  98. #define ALT_MMU_FTR_SECTION_END_IFCLR(msk) \
  99. ALT_MMU_FTR_SECTION_END_NESTED_IFCLR(msk, 97)
  100. /* Firmware feature dependent sections */
  101. #define BEGIN_FW_FTR_SECTION_NESTED(label) START_FTR_SECTION(label)
  102. #define BEGIN_FW_FTR_SECTION START_FTR_SECTION(97)
  103. #define END_FW_FTR_SECTION_NESTED(msk, val, label) \
  104. FTR_SECTION_ELSE_NESTED(label) \
  105. MAKE_FTR_SECTION_ENTRY(msk, val, label, __fw_ftr_fixup)
  106. #define END_FW_FTR_SECTION(msk, val) \
  107. END_FW_FTR_SECTION_NESTED(msk, val, 97)
  108. #define END_FW_FTR_SECTION_IFSET(msk) END_FW_FTR_SECTION((msk), (msk))
  109. #define END_FW_FTR_SECTION_IFCLR(msk) END_FW_FTR_SECTION((msk), 0)
  110. /* Firmware feature sections with alternatives */
  111. #define FW_FTR_SECTION_ELSE_NESTED(label) FTR_SECTION_ELSE_NESTED(label)
  112. #define FW_FTR_SECTION_ELSE FTR_SECTION_ELSE_NESTED(97)
  113. #define ALT_FW_FTR_SECTION_END_NESTED(msk, val, label) \
  114. MAKE_FTR_SECTION_ENTRY(msk, val, label, __fw_ftr_fixup)
  115. #define ALT_FW_FTR_SECTION_END_NESTED_IFSET(msk, label) \
  116. ALT_FW_FTR_SECTION_END_NESTED(msk, msk, label)
  117. #define ALT_FW_FTR_SECTION_END_NESTED_IFCLR(msk, label) \
  118. ALT_FW_FTR_SECTION_END_NESTED(msk, 0, label)
  119. #define ALT_FW_FTR_SECTION_END(msk, val) \
  120. ALT_FW_FTR_SECTION_END_NESTED(msk, val, 97)
  121. #define ALT_FW_FTR_SECTION_END_IFSET(msk) \
  122. ALT_FW_FTR_SECTION_END_NESTED_IFSET(msk, 97)
  123. #define ALT_FW_FTR_SECTION_END_IFCLR(msk) \
  124. ALT_FW_FTR_SECTION_END_NESTED_IFCLR(msk, 97)
  125. #ifndef __ASSEMBLY__
  126. #define ASM_FTR_IF(section_if, section_else, msk, val) \
  127. stringify_in_c(BEGIN_FTR_SECTION) \
  128. section_if "; " \
  129. stringify_in_c(FTR_SECTION_ELSE) \
  130. section_else "; " \
  131. stringify_in_c(ALT_FTR_SECTION_END((msk), (val)))
  132. #define ASM_FTR_IFSET(section_if, section_else, msk) \
  133. ASM_FTR_IF(section_if, section_else, (msk), (msk))
  134. #define ASM_FTR_IFCLR(section_if, section_else, msk) \
  135. ASM_FTR_IF(section_if, section_else, (msk), 0)
  136. #define ASM_MMU_FTR_IF(section_if, section_else, msk, val) \
  137. stringify_in_c(BEGIN_MMU_FTR_SECTION) \
  138. section_if "; " \
  139. stringify_in_c(MMU_FTR_SECTION_ELSE) \
  140. section_else "; " \
  141. stringify_in_c(ALT_MMU_FTR_SECTION_END((msk), (val)))
  142. #define ASM_MMU_FTR_IFSET(section_if, section_else, msk) \
  143. ASM_MMU_FTR_IF(section_if, section_else, (msk), (msk))
  144. #define ASM_MMU_FTR_IFCLR(section_if, section_else, msk) \
  145. ASM_MMU_FTR_IF(section_if, section_else, (msk), 0)
  146. #endif /* __ASSEMBLY__ */
  147. /* LWSYNC feature sections */
  148. #define START_LWSYNC_SECTION(label) label##1:
  149. #define MAKE_LWSYNC_SECTION_ENTRY(label, sect) \
  150. label##2: \
  151. .pushsection sect,"a"; \
  152. .align 2; \
  153. label##3: \
  154. FTR_ENTRY_OFFSET label##1b-label##3b; \
  155. .popsection;
  156. #define RFI_FLUSH_FIXUP_SECTION \
  157. 951: \
  158. .pushsection __rfi_flush_fixup,"a"; \
  159. .align 2; \
  160. 952: \
  161. FTR_ENTRY_OFFSET 951b-952b; \
  162. .popsection;
  163. #ifndef __ASSEMBLY__
  164. extern long __start___rfi_flush_fixup, __stop___rfi_flush_fixup;
  165. #endif
  166. #endif /* __ASM_POWERPC_FEATURE_FIXUPS_H */