cpu-features.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. /*
  2. * This file is subject to the terms and conditions of the GNU General Public
  3. * License. See the file "COPYING" in the main directory of this archive
  4. * for more details.
  5. *
  6. * Copyright (C) 2003, 2004 Ralf Baechle
  7. */
  8. #ifndef __ASM_CPU_FEATURES_H
  9. #define __ASM_CPU_FEATURES_H
  10. #include <linux/config.h>
  11. #include <asm/cpu.h>
  12. #include <asm/cpu-info.h>
  13. #include <cpu-feature-overrides.h>
  14. /*
  15. * SMP assumption: Options of CPU 0 are a superset of all processors.
  16. * This is true for all known MIPS systems.
  17. */
  18. #ifndef cpu_has_tlb
  19. #define cpu_has_tlb (cpu_data[0].options & MIPS_CPU_TLB)
  20. #endif
  21. #ifndef cpu_has_4kex
  22. #define cpu_has_4kex (cpu_data[0].options & MIPS_CPU_4KEX)
  23. #endif
  24. #ifndef cpu_has_4ktlb
  25. #define cpu_has_4ktlb (cpu_data[0].options & MIPS_CPU_4KTLB)
  26. #endif
  27. #ifndef cpu_has_fpu
  28. #define cpu_has_fpu (cpu_data[0].options & MIPS_CPU_FPU)
  29. #endif
  30. #ifndef cpu_has_32fpr
  31. #define cpu_has_32fpr (cpu_data[0].options & MIPS_CPU_32FPR)
  32. #endif
  33. #ifndef cpu_has_counter
  34. #define cpu_has_counter (cpu_data[0].options & MIPS_CPU_COUNTER)
  35. #endif
  36. #ifndef cpu_has_watch
  37. #define cpu_has_watch (cpu_data[0].options & MIPS_CPU_WATCH)
  38. #endif
  39. #ifndef cpu_has_mips16
  40. #define cpu_has_mips16 (cpu_data[0].options & MIPS_CPU_MIPS16)
  41. #endif
  42. #ifndef cpu_has_divec
  43. #define cpu_has_divec (cpu_data[0].options & MIPS_CPU_DIVEC)
  44. #endif
  45. #ifndef cpu_has_vce
  46. #define cpu_has_vce (cpu_data[0].options & MIPS_CPU_VCE)
  47. #endif
  48. #ifndef cpu_has_cache_cdex_p
  49. #define cpu_has_cache_cdex_p (cpu_data[0].options & MIPS_CPU_CACHE_CDEX_P)
  50. #endif
  51. #ifndef cpu_has_cache_cdex_s
  52. #define cpu_has_cache_cdex_s (cpu_data[0].options & MIPS_CPU_CACHE_CDEX_S)
  53. #endif
  54. #ifndef cpu_has_prefetch
  55. #define cpu_has_prefetch (cpu_data[0].options & MIPS_CPU_PREFETCH)
  56. #endif
  57. #ifndef cpu_has_mcheck
  58. #define cpu_has_mcheck (cpu_data[0].options & MIPS_CPU_MCHECK)
  59. #endif
  60. #ifndef cpu_has_ejtag
  61. #define cpu_has_ejtag (cpu_data[0].options & MIPS_CPU_EJTAG)
  62. #endif
  63. #ifndef cpu_has_llsc
  64. #define cpu_has_llsc (cpu_data[0].options & MIPS_CPU_LLSC)
  65. #endif
  66. #ifndef cpu_has_vtag_icache
  67. #define cpu_has_vtag_icache (cpu_data[0].icache.flags & MIPS_CACHE_VTAG)
  68. #endif
  69. #ifndef cpu_has_dc_aliases
  70. #define cpu_has_dc_aliases (cpu_data[0].dcache.flags & MIPS_CACHE_ALIASES)
  71. #endif
  72. #ifndef cpu_has_ic_fills_f_dc
  73. #define cpu_has_ic_fills_f_dc (cpu_data[0].icache.flags & MIPS_CACHE_IC_F_DC)
  74. #endif
  75. /*
  76. * I-Cache snoops remote store. This only matters on SMP. Some multiprocessors
  77. * such as the R10000 have I-Caches that snoop local stores; the embedded ones
  78. * don't. For maintaining I-cache coherency this means we need to flush the
  79. * D-cache all the way back to whever the I-cache does refills from, so the
  80. * I-cache has a chance to see the new data at all. Then we have to flush the
  81. * I-cache also.
  82. * Note we may have been rescheduled and may no longer be running on the CPU
  83. * that did the store so we can't optimize this into only doing the flush on
  84. * the local CPU.
  85. */
  86. #ifndef cpu_icache_snoops_remote_store
  87. #ifdef CONFIG_SMP
  88. #define cpu_icache_snoops_remote_store (cpu_data[0].icache.flags & MIPS_IC_SNOOPS_REMOTE)
  89. #else
  90. #define cpu_icache_snoops_remote_store 1
  91. #endif
  92. #endif
  93. /*
  94. * Certain CPUs may throw bizarre exceptions if not the whole cacheline
  95. * contains valid instructions. For these we ensure proper alignment of
  96. * signal trampolines and pad them to the size of a full cache lines with
  97. * nops. This is also used in structure definitions so can't be a test macro
  98. * like the others.
  99. */
  100. #ifndef PLAT_TRAMPOLINE_STUFF_LINE
  101. #define PLAT_TRAMPOLINE_STUFF_LINE 0UL
  102. #endif
  103. #ifdef CONFIG_MIPS32
  104. # ifndef cpu_has_nofpuex
  105. # define cpu_has_nofpuex (cpu_data[0].options & MIPS_CPU_NOFPUEX)
  106. # endif
  107. # ifndef cpu_has_64bits
  108. # define cpu_has_64bits (cpu_data[0].isa_level & MIPS_CPU_ISA_64BIT)
  109. # endif
  110. # ifndef cpu_has_64bit_zero_reg
  111. # define cpu_has_64bit_zero_reg (cpu_data[0].isa_level & MIPS_CPU_ISA_64BIT)
  112. # endif
  113. # ifndef cpu_has_64bit_gp_regs
  114. # define cpu_has_64bit_gp_regs 0
  115. # endif
  116. # ifndef cpu_has_64bit_addresses
  117. # define cpu_has_64bit_addresses 0
  118. # endif
  119. #endif
  120. #ifdef CONFIG_MIPS64
  121. # ifndef cpu_has_nofpuex
  122. # define cpu_has_nofpuex 0
  123. # endif
  124. # ifndef cpu_has_64bits
  125. # define cpu_has_64bits 1
  126. # endif
  127. # ifndef cpu_has_64bit_zero_reg
  128. # define cpu_has_64bit_zero_reg 1
  129. # endif
  130. # ifndef cpu_has_64bit_gp_regs
  131. # define cpu_has_64bit_gp_regs 1
  132. # endif
  133. # ifndef cpu_has_64bit_addresses
  134. # define cpu_has_64bit_addresses 1
  135. # endif
  136. #endif
  137. #ifndef cpu_has_subset_pcaches
  138. #define cpu_has_subset_pcaches (cpu_data[0].options & MIPS_CPU_SUBSET_CACHES)
  139. #endif
  140. #ifndef cpu_dcache_line_size
  141. #define cpu_dcache_line_size() current_cpu_data.dcache.linesz
  142. #endif
  143. #ifndef cpu_icache_line_size
  144. #define cpu_icache_line_size() current_cpu_data.icache.linesz
  145. #endif
  146. #ifndef cpu_scache_line_size
  147. #define cpu_scache_line_size() current_cpu_data.scache.linesz
  148. #endif
  149. #endif /* __ASM_CPU_FEATURES_H */