cpu-features.h 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627
  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. * Copyright (C) 2004 Maciej W. Rozycki
  8. */
  9. #ifndef __ASM_CPU_FEATURES_H
  10. #define __ASM_CPU_FEATURES_H
  11. #include <asm/cpu.h>
  12. #include <asm/cpu-info.h>
  13. #include <asm/isa-rev.h>
  14. #include <cpu-feature-overrides.h>
  15. /*
  16. * SMP assumption: Options of CPU 0 are a superset of all processors.
  17. * This is true for all known MIPS systems.
  18. */
  19. #ifndef cpu_has_tlb
  20. #define cpu_has_tlb (cpu_data[0].options & MIPS_CPU_TLB)
  21. #endif
  22. #ifndef cpu_has_ftlb
  23. #define cpu_has_ftlb (cpu_data[0].options & MIPS_CPU_FTLB)
  24. #endif
  25. #ifndef cpu_has_tlbinv
  26. #define cpu_has_tlbinv (cpu_data[0].options & MIPS_CPU_TLBINV)
  27. #endif
  28. #ifndef cpu_has_segments
  29. #define cpu_has_segments (cpu_data[0].options & MIPS_CPU_SEGMENTS)
  30. #endif
  31. #ifndef cpu_has_eva
  32. #define cpu_has_eva (cpu_data[0].options & MIPS_CPU_EVA)
  33. #endif
  34. #ifndef cpu_has_htw
  35. #define cpu_has_htw (cpu_data[0].options & MIPS_CPU_HTW)
  36. #endif
  37. #ifndef cpu_has_ldpte
  38. #define cpu_has_ldpte (cpu_data[0].options & MIPS_CPU_LDPTE)
  39. #endif
  40. #ifndef cpu_has_rixiex
  41. #define cpu_has_rixiex (cpu_data[0].options & MIPS_CPU_RIXIEX)
  42. #endif
  43. #ifndef cpu_has_maar
  44. #define cpu_has_maar (cpu_data[0].options & MIPS_CPU_MAAR)
  45. #endif
  46. #ifndef cpu_has_rw_llb
  47. #define cpu_has_rw_llb (cpu_data[0].options & MIPS_CPU_RW_LLB)
  48. #endif
  49. /*
  50. * For the moment we don't consider R6000 and R8000 so we can assume that
  51. * anything that doesn't support R4000-style exceptions and interrupts is
  52. * R3000-like. Users should still treat these two macro definitions as
  53. * opaque.
  54. */
  55. #ifndef cpu_has_3kex
  56. #define cpu_has_3kex (!cpu_has_4kex)
  57. #endif
  58. #ifndef cpu_has_4kex
  59. #define cpu_has_4kex (cpu_data[0].options & MIPS_CPU_4KEX)
  60. #endif
  61. #ifndef cpu_has_3k_cache
  62. #define cpu_has_3k_cache (cpu_data[0].options & MIPS_CPU_3K_CACHE)
  63. #endif
  64. #define cpu_has_6k_cache 0
  65. #define cpu_has_8k_cache 0
  66. #ifndef cpu_has_4k_cache
  67. #define cpu_has_4k_cache (cpu_data[0].options & MIPS_CPU_4K_CACHE)
  68. #endif
  69. #ifndef cpu_has_tx39_cache
  70. #define cpu_has_tx39_cache (cpu_data[0].options & MIPS_CPU_TX39_CACHE)
  71. #endif
  72. #ifndef cpu_has_octeon_cache
  73. #define cpu_has_octeon_cache 0
  74. #endif
  75. /* Don't override `cpu_has_fpu' to 1 or the "nofpu" option won't work. */
  76. #ifndef cpu_has_fpu
  77. #define cpu_has_fpu (current_cpu_data.options & MIPS_CPU_FPU)
  78. #define raw_cpu_has_fpu (raw_current_cpu_data.options & MIPS_CPU_FPU)
  79. #else
  80. #define raw_cpu_has_fpu cpu_has_fpu
  81. #endif
  82. #ifndef cpu_has_32fpr
  83. #define cpu_has_32fpr (cpu_data[0].options & MIPS_CPU_32FPR)
  84. #endif
  85. #ifndef cpu_has_counter
  86. #define cpu_has_counter (cpu_data[0].options & MIPS_CPU_COUNTER)
  87. #endif
  88. #ifndef cpu_has_watch
  89. #define cpu_has_watch (cpu_data[0].options & MIPS_CPU_WATCH)
  90. #endif
  91. #ifndef cpu_has_divec
  92. #define cpu_has_divec (cpu_data[0].options & MIPS_CPU_DIVEC)
  93. #endif
  94. #ifndef cpu_has_vce
  95. #define cpu_has_vce (cpu_data[0].options & MIPS_CPU_VCE)
  96. #endif
  97. #ifndef cpu_has_cache_cdex_p
  98. #define cpu_has_cache_cdex_p (cpu_data[0].options & MIPS_CPU_CACHE_CDEX_P)
  99. #endif
  100. #ifndef cpu_has_cache_cdex_s
  101. #define cpu_has_cache_cdex_s (cpu_data[0].options & MIPS_CPU_CACHE_CDEX_S)
  102. #endif
  103. #ifndef cpu_has_prefetch
  104. #define cpu_has_prefetch (cpu_data[0].options & MIPS_CPU_PREFETCH)
  105. #endif
  106. #ifndef cpu_has_mcheck
  107. #define cpu_has_mcheck (cpu_data[0].options & MIPS_CPU_MCHECK)
  108. #endif
  109. #ifndef cpu_has_ejtag
  110. #define cpu_has_ejtag (cpu_data[0].options & MIPS_CPU_EJTAG)
  111. #endif
  112. #ifndef cpu_has_llsc
  113. #define cpu_has_llsc (cpu_data[0].options & MIPS_CPU_LLSC)
  114. #endif
  115. #ifndef cpu_has_bp_ghist
  116. #define cpu_has_bp_ghist (cpu_data[0].options & MIPS_CPU_BP_GHIST)
  117. #endif
  118. #ifndef kernel_uses_llsc
  119. #define kernel_uses_llsc cpu_has_llsc
  120. #endif
  121. #ifndef cpu_has_guestctl0ext
  122. #define cpu_has_guestctl0ext (cpu_data[0].options & MIPS_CPU_GUESTCTL0EXT)
  123. #endif
  124. #ifndef cpu_has_guestctl1
  125. #define cpu_has_guestctl1 (cpu_data[0].options & MIPS_CPU_GUESTCTL1)
  126. #endif
  127. #ifndef cpu_has_guestctl2
  128. #define cpu_has_guestctl2 (cpu_data[0].options & MIPS_CPU_GUESTCTL2)
  129. #endif
  130. #ifndef cpu_has_guestid
  131. #define cpu_has_guestid (cpu_data[0].options & MIPS_CPU_GUESTID)
  132. #endif
  133. #ifndef cpu_has_drg
  134. #define cpu_has_drg (cpu_data[0].options & MIPS_CPU_DRG)
  135. #endif
  136. #ifndef cpu_has_mips16
  137. #define cpu_has_mips16 (cpu_data[0].ases & MIPS_ASE_MIPS16)
  138. #endif
  139. #ifndef cpu_has_mips16e2
  140. #define cpu_has_mips16e2 (cpu_data[0].ases & MIPS_ASE_MIPS16E2)
  141. #endif
  142. #ifndef cpu_has_mdmx
  143. #define cpu_has_mdmx (cpu_data[0].ases & MIPS_ASE_MDMX)
  144. #endif
  145. #ifndef cpu_has_mips3d
  146. #define cpu_has_mips3d (cpu_data[0].ases & MIPS_ASE_MIPS3D)
  147. #endif
  148. #ifndef cpu_has_smartmips
  149. #define cpu_has_smartmips (cpu_data[0].ases & MIPS_ASE_SMARTMIPS)
  150. #endif
  151. #ifndef cpu_has_rixi
  152. #define cpu_has_rixi (cpu_data[0].options & MIPS_CPU_RIXI)
  153. #endif
  154. #ifndef cpu_has_mmips
  155. # ifdef CONFIG_SYS_SUPPORTS_MICROMIPS
  156. # define cpu_has_mmips (cpu_data[0].options & MIPS_CPU_MICROMIPS)
  157. # else
  158. # define cpu_has_mmips 0
  159. # endif
  160. #endif
  161. #ifndef cpu_has_lpa
  162. #define cpu_has_lpa (cpu_data[0].options & MIPS_CPU_LPA)
  163. #endif
  164. #ifndef cpu_has_mvh
  165. #define cpu_has_mvh (cpu_data[0].options & MIPS_CPU_MVH)
  166. #endif
  167. #ifndef cpu_has_xpa
  168. #define cpu_has_xpa (cpu_has_lpa && cpu_has_mvh)
  169. #endif
  170. #ifndef cpu_has_vtag_icache
  171. #define cpu_has_vtag_icache (cpu_data[0].icache.flags & MIPS_CACHE_VTAG)
  172. #endif
  173. #ifndef cpu_has_dc_aliases
  174. #define cpu_has_dc_aliases (cpu_data[0].dcache.flags & MIPS_CACHE_ALIASES)
  175. #endif
  176. #ifndef cpu_has_ic_fills_f_dc
  177. #define cpu_has_ic_fills_f_dc (cpu_data[0].icache.flags & MIPS_CACHE_IC_F_DC)
  178. #endif
  179. #ifndef cpu_has_pindexed_dcache
  180. #define cpu_has_pindexed_dcache (cpu_data[0].dcache.flags & MIPS_CACHE_PINDEX)
  181. #endif
  182. #ifndef cpu_has_local_ebase
  183. #define cpu_has_local_ebase 1
  184. #endif
  185. /*
  186. * I-Cache snoops remote store. This only matters on SMP. Some multiprocessors
  187. * such as the R10000 have I-Caches that snoop local stores; the embedded ones
  188. * don't. For maintaining I-cache coherency this means we need to flush the
  189. * D-cache all the way back to whever the I-cache does refills from, so the
  190. * I-cache has a chance to see the new data at all. Then we have to flush the
  191. * I-cache also.
  192. * Note we may have been rescheduled and may no longer be running on the CPU
  193. * that did the store so we can't optimize this into only doing the flush on
  194. * the local CPU.
  195. */
  196. #ifndef cpu_icache_snoops_remote_store
  197. #ifdef CONFIG_SMP
  198. #define cpu_icache_snoops_remote_store (cpu_data[0].icache.flags & MIPS_IC_SNOOPS_REMOTE)
  199. #else
  200. #define cpu_icache_snoops_remote_store 1
  201. #endif
  202. #endif
  203. /* __builtin_constant_p(cpu_has_mips_r) && cpu_has_mips_r */
  204. #if !((defined(cpu_has_mips32r1) && cpu_has_mips32r1) || \
  205. (defined(cpu_has_mips32r2) && cpu_has_mips32r2) || \
  206. (defined(cpu_has_mips32r6) && cpu_has_mips32r6) || \
  207. (defined(cpu_has_mips64r1) && cpu_has_mips64r1) || \
  208. (defined(cpu_has_mips64r2) && cpu_has_mips64r2) || \
  209. (defined(cpu_has_mips64r6) && cpu_has_mips64r6))
  210. #define CPU_NO_EFFICIENT_FFS 1
  211. #endif
  212. #ifndef cpu_has_mips_1
  213. # define cpu_has_mips_1 (!cpu_has_mips_r6)
  214. #endif
  215. #ifndef cpu_has_mips_2
  216. # define cpu_has_mips_2 (cpu_data[0].isa_level & MIPS_CPU_ISA_II)
  217. #endif
  218. #ifndef cpu_has_mips_3
  219. # define cpu_has_mips_3 (cpu_data[0].isa_level & MIPS_CPU_ISA_III)
  220. #endif
  221. #ifndef cpu_has_mips_4
  222. # define cpu_has_mips_4 (cpu_data[0].isa_level & MIPS_CPU_ISA_IV)
  223. #endif
  224. #ifndef cpu_has_mips_5
  225. # define cpu_has_mips_5 (cpu_data[0].isa_level & MIPS_CPU_ISA_V)
  226. #endif
  227. #ifndef cpu_has_mips32r1
  228. # define cpu_has_mips32r1 (cpu_data[0].isa_level & MIPS_CPU_ISA_M32R1)
  229. #endif
  230. #ifndef cpu_has_mips32r2
  231. # define cpu_has_mips32r2 (cpu_data[0].isa_level & MIPS_CPU_ISA_M32R2)
  232. #endif
  233. #ifndef cpu_has_mips32r6
  234. # define cpu_has_mips32r6 (cpu_data[0].isa_level & MIPS_CPU_ISA_M32R6)
  235. #endif
  236. #ifndef cpu_has_mips64r1
  237. # define cpu_has_mips64r1 (cpu_data[0].isa_level & MIPS_CPU_ISA_M64R1)
  238. #endif
  239. #ifndef cpu_has_mips64r2
  240. # define cpu_has_mips64r2 (cpu_data[0].isa_level & MIPS_CPU_ISA_M64R2)
  241. #endif
  242. #ifndef cpu_has_mips64r6
  243. # define cpu_has_mips64r6 (cpu_data[0].isa_level & MIPS_CPU_ISA_M64R6)
  244. #endif
  245. /*
  246. * Shortcuts ...
  247. */
  248. #define cpu_has_mips_2_3_4_5 (cpu_has_mips_2 | cpu_has_mips_3_4_5)
  249. #define cpu_has_mips_3_4_5 (cpu_has_mips_3 | cpu_has_mips_4_5)
  250. #define cpu_has_mips_4_5 (cpu_has_mips_4 | cpu_has_mips_5)
  251. #define cpu_has_mips_2_3_4_5_r (cpu_has_mips_2 | cpu_has_mips_3_4_5_r)
  252. #define cpu_has_mips_3_4_5_r (cpu_has_mips_3 | cpu_has_mips_4_5_r)
  253. #define cpu_has_mips_4_5_r (cpu_has_mips_4 | cpu_has_mips_5_r)
  254. #define cpu_has_mips_5_r (cpu_has_mips_5 | cpu_has_mips_r)
  255. #define cpu_has_mips_3_4_5_64_r2_r6 \
  256. (cpu_has_mips_3 | cpu_has_mips_4_5_64_r2_r6)
  257. #define cpu_has_mips_4_5_64_r2_r6 \
  258. (cpu_has_mips_4_5 | cpu_has_mips64r1 | \
  259. cpu_has_mips_r2 | cpu_has_mips_r6)
  260. #define cpu_has_mips32 (cpu_has_mips32r1 | cpu_has_mips32r2 | cpu_has_mips32r6)
  261. #define cpu_has_mips64 (cpu_has_mips64r1 | cpu_has_mips64r2 | cpu_has_mips64r6)
  262. #define cpu_has_mips_r1 (cpu_has_mips32r1 | cpu_has_mips64r1)
  263. #define cpu_has_mips_r2 (cpu_has_mips32r2 | cpu_has_mips64r2)
  264. #define cpu_has_mips_r6 (cpu_has_mips32r6 | cpu_has_mips64r6)
  265. #define cpu_has_mips_r (cpu_has_mips32r1 | cpu_has_mips32r2 | \
  266. cpu_has_mips32r6 | cpu_has_mips64r1 | \
  267. cpu_has_mips64r2 | cpu_has_mips64r6)
  268. /* MIPSR2 and MIPSR6 have a lot of similarities */
  269. #define cpu_has_mips_r2_r6 (cpu_has_mips_r2 | cpu_has_mips_r6)
  270. /*
  271. * cpu_has_mips_r2_exec_hazard - return if IHB is required on current processor
  272. *
  273. * Returns non-zero value if the current processor implementation requires
  274. * an IHB instruction to deal with an instruction hazard as per MIPS R2
  275. * architecture specification, zero otherwise.
  276. */
  277. #ifndef cpu_has_mips_r2_exec_hazard
  278. #define cpu_has_mips_r2_exec_hazard \
  279. ({ \
  280. int __res; \
  281. \
  282. switch (current_cpu_type()) { \
  283. case CPU_M14KC: \
  284. case CPU_74K: \
  285. case CPU_1074K: \
  286. case CPU_PROAPTIV: \
  287. case CPU_P5600: \
  288. case CPU_M5150: \
  289. case CPU_QEMU_GENERIC: \
  290. case CPU_CAVIUM_OCTEON: \
  291. case CPU_CAVIUM_OCTEON_PLUS: \
  292. case CPU_CAVIUM_OCTEON2: \
  293. case CPU_CAVIUM_OCTEON3: \
  294. __res = 0; \
  295. break; \
  296. \
  297. default: \
  298. __res = 1; \
  299. } \
  300. \
  301. __res; \
  302. })
  303. #endif
  304. /*
  305. * MIPS32, MIPS64, VR5500, IDT32332, IDT32334 and maybe a few other
  306. * pre-MIPS32/MIPS64 processors have CLO, CLZ. The IDT RC64574 is 64-bit and
  307. * has CLO and CLZ but not DCLO nor DCLZ. For 64-bit kernels
  308. * cpu_has_clo_clz also indicates the availability of DCLO and DCLZ.
  309. */
  310. #ifndef cpu_has_clo_clz
  311. #define cpu_has_clo_clz cpu_has_mips_r
  312. #endif
  313. /*
  314. * MIPS32 R2, MIPS64 R2, Loongson 3A and Octeon have WSBH.
  315. * MIPS64 R2, Loongson 3A and Octeon have WSBH, DSBH and DSHD.
  316. * This indicates the availability of WSBH and in case of 64 bit CPUs also
  317. * DSBH and DSHD.
  318. */
  319. #ifndef cpu_has_wsbh
  320. #define cpu_has_wsbh cpu_has_mips_r2
  321. #endif
  322. #ifndef cpu_has_dsp
  323. #define cpu_has_dsp (cpu_data[0].ases & MIPS_ASE_DSP)
  324. #endif
  325. #ifndef cpu_has_dsp2
  326. #define cpu_has_dsp2 (cpu_data[0].ases & MIPS_ASE_DSP2P)
  327. #endif
  328. #ifndef cpu_has_dsp3
  329. #define cpu_has_dsp3 (cpu_data[0].ases & MIPS_ASE_DSP3)
  330. #endif
  331. #ifndef cpu_has_mipsmt
  332. #define cpu_has_mipsmt (cpu_data[0].ases & MIPS_ASE_MIPSMT)
  333. #endif
  334. #ifndef cpu_has_vp
  335. #define cpu_has_vp (cpu_data[0].options & MIPS_CPU_VP)
  336. #endif
  337. #ifndef cpu_has_userlocal
  338. #define cpu_has_userlocal (cpu_data[0].options & MIPS_CPU_ULRI)
  339. #endif
  340. #ifdef CONFIG_32BIT
  341. # ifndef cpu_has_nofpuex
  342. # define cpu_has_nofpuex (cpu_data[0].options & MIPS_CPU_NOFPUEX)
  343. # endif
  344. # ifndef cpu_has_64bits
  345. # define cpu_has_64bits (cpu_data[0].isa_level & MIPS_CPU_ISA_64BIT)
  346. # endif
  347. # ifndef cpu_has_64bit_zero_reg
  348. # define cpu_has_64bit_zero_reg (cpu_data[0].isa_level & MIPS_CPU_ISA_64BIT)
  349. # endif
  350. # ifndef cpu_has_64bit_gp_regs
  351. # define cpu_has_64bit_gp_regs 0
  352. # endif
  353. # ifndef cpu_has_64bit_addresses
  354. # define cpu_has_64bit_addresses 0
  355. # endif
  356. # ifndef cpu_vmbits
  357. # define cpu_vmbits 31
  358. # endif
  359. #endif
  360. #ifdef CONFIG_64BIT
  361. # ifndef cpu_has_nofpuex
  362. # define cpu_has_nofpuex 0
  363. # endif
  364. # ifndef cpu_has_64bits
  365. # define cpu_has_64bits 1
  366. # endif
  367. # ifndef cpu_has_64bit_zero_reg
  368. # define cpu_has_64bit_zero_reg 1
  369. # endif
  370. # ifndef cpu_has_64bit_gp_regs
  371. # define cpu_has_64bit_gp_regs 1
  372. # endif
  373. # ifndef cpu_has_64bit_addresses
  374. # define cpu_has_64bit_addresses 1
  375. # endif
  376. # ifndef cpu_vmbits
  377. # define cpu_vmbits cpu_data[0].vmbits
  378. # define __NEED_VMBITS_PROBE
  379. # endif
  380. #endif
  381. #if defined(CONFIG_CPU_MIPSR2_IRQ_VI) && !defined(cpu_has_vint)
  382. # define cpu_has_vint (cpu_data[0].options & MIPS_CPU_VINT)
  383. #elif !defined(cpu_has_vint)
  384. # define cpu_has_vint 0
  385. #endif
  386. #if defined(CONFIG_CPU_MIPSR2_IRQ_EI) && !defined(cpu_has_veic)
  387. # define cpu_has_veic (cpu_data[0].options & MIPS_CPU_VEIC)
  388. #elif !defined(cpu_has_veic)
  389. # define cpu_has_veic 0
  390. #endif
  391. #ifndef cpu_has_inclusive_pcaches
  392. #define cpu_has_inclusive_pcaches (cpu_data[0].options & MIPS_CPU_INCLUSIVE_CACHES)
  393. #endif
  394. #ifndef cpu_dcache_line_size
  395. #define cpu_dcache_line_size() cpu_data[0].dcache.linesz
  396. #endif
  397. #ifndef cpu_icache_line_size
  398. #define cpu_icache_line_size() cpu_data[0].icache.linesz
  399. #endif
  400. #ifndef cpu_scache_line_size
  401. #define cpu_scache_line_size() cpu_data[0].scache.linesz
  402. #endif
  403. #ifndef cpu_tcache_line_size
  404. #define cpu_tcache_line_size() cpu_data[0].tcache.linesz
  405. #endif
  406. #ifndef cpu_hwrena_impl_bits
  407. #define cpu_hwrena_impl_bits 0
  408. #endif
  409. #ifndef cpu_has_perf_cntr_intr_bit
  410. #define cpu_has_perf_cntr_intr_bit (cpu_data[0].options & MIPS_CPU_PCI)
  411. #endif
  412. #ifndef cpu_has_vz
  413. #define cpu_has_vz (cpu_data[0].ases & MIPS_ASE_VZ)
  414. #endif
  415. #if defined(CONFIG_CPU_HAS_MSA) && !defined(cpu_has_msa)
  416. # define cpu_has_msa (cpu_data[0].ases & MIPS_ASE_MSA)
  417. #elif !defined(cpu_has_msa)
  418. # define cpu_has_msa 0
  419. #endif
  420. #ifndef cpu_has_ufr
  421. # define cpu_has_ufr (cpu_data[0].options & MIPS_CPU_UFR)
  422. #endif
  423. #ifndef cpu_has_fre
  424. # define cpu_has_fre (cpu_data[0].options & MIPS_CPU_FRE)
  425. #endif
  426. #ifndef cpu_has_cdmm
  427. # define cpu_has_cdmm (cpu_data[0].options & MIPS_CPU_CDMM)
  428. #endif
  429. #ifndef cpu_has_small_pages
  430. # define cpu_has_small_pages (cpu_data[0].options & MIPS_CPU_SP)
  431. #endif
  432. #ifndef cpu_has_nan_legacy
  433. #define cpu_has_nan_legacy (cpu_data[0].options & MIPS_CPU_NAN_LEGACY)
  434. #endif
  435. #ifndef cpu_has_nan_2008
  436. #define cpu_has_nan_2008 (cpu_data[0].options & MIPS_CPU_NAN_2008)
  437. #endif
  438. #ifndef cpu_has_ebase_wg
  439. # define cpu_has_ebase_wg (cpu_data[0].options & MIPS_CPU_EBASE_WG)
  440. #endif
  441. #ifndef cpu_has_badinstr
  442. # define cpu_has_badinstr (cpu_data[0].options & MIPS_CPU_BADINSTR)
  443. #endif
  444. #ifndef cpu_has_badinstrp
  445. # define cpu_has_badinstrp (cpu_data[0].options & MIPS_CPU_BADINSTRP)
  446. #endif
  447. #ifndef cpu_has_contextconfig
  448. # define cpu_has_contextconfig (cpu_data[0].options & MIPS_CPU_CTXTC)
  449. #endif
  450. #ifndef cpu_has_perf
  451. # define cpu_has_perf (cpu_data[0].options & MIPS_CPU_PERF)
  452. #endif
  453. #if defined(CONFIG_SMP) && (MIPS_ISA_REV >= 6)
  454. /*
  455. * Some systems share FTLB RAMs between threads within a core (siblings in
  456. * kernel parlance). This means that FTLB entries may become invalid at almost
  457. * any point when an entry is evicted due to a sibling thread writing an entry
  458. * to the shared FTLB RAM.
  459. *
  460. * This is only relevant to SMP systems, and the only systems that exhibit this
  461. * property implement MIPSr6 or higher so we constrain support for this to
  462. * kernels that will run on such systems.
  463. */
  464. # ifndef cpu_has_shared_ftlb_ram
  465. # define cpu_has_shared_ftlb_ram \
  466. (current_cpu_data.options & MIPS_CPU_SHARED_FTLB_RAM)
  467. # endif
  468. /*
  469. * Some systems take this a step further & share FTLB entries between siblings.
  470. * This is implemented as TLB writes happening as usual, but if an entry
  471. * written by a sibling exists in the shared FTLB for a translation which would
  472. * otherwise cause a TLB refill exception then the CPU will use the entry
  473. * written by its sibling rather than triggering a refill & writing a matching
  474. * TLB entry for itself.
  475. *
  476. * This is naturally only valid if a TLB entry is known to be suitable for use
  477. * on all siblings in a CPU, and so it only takes effect when MMIDs are in use
  478. * rather than ASIDs or when a TLB entry is marked global.
  479. */
  480. # ifndef cpu_has_shared_ftlb_entries
  481. # define cpu_has_shared_ftlb_entries \
  482. (current_cpu_data.options & MIPS_CPU_SHARED_FTLB_ENTRIES)
  483. # endif
  484. #endif /* SMP && MIPS_ISA_REV >= 6 */
  485. #ifndef cpu_has_shared_ftlb_ram
  486. # define cpu_has_shared_ftlb_ram 0
  487. #endif
  488. #ifndef cpu_has_shared_ftlb_entries
  489. # define cpu_has_shared_ftlb_entries 0
  490. #endif
  491. /*
  492. * Guest capabilities
  493. */
  494. #ifndef cpu_guest_has_conf1
  495. #define cpu_guest_has_conf1 (cpu_data[0].guest.conf & (1 << 1))
  496. #endif
  497. #ifndef cpu_guest_has_conf2
  498. #define cpu_guest_has_conf2 (cpu_data[0].guest.conf & (1 << 2))
  499. #endif
  500. #ifndef cpu_guest_has_conf3
  501. #define cpu_guest_has_conf3 (cpu_data[0].guest.conf & (1 << 3))
  502. #endif
  503. #ifndef cpu_guest_has_conf4
  504. #define cpu_guest_has_conf4 (cpu_data[0].guest.conf & (1 << 4))
  505. #endif
  506. #ifndef cpu_guest_has_conf5
  507. #define cpu_guest_has_conf5 (cpu_data[0].guest.conf & (1 << 5))
  508. #endif
  509. #ifndef cpu_guest_has_conf6
  510. #define cpu_guest_has_conf6 (cpu_data[0].guest.conf & (1 << 6))
  511. #endif
  512. #ifndef cpu_guest_has_conf7
  513. #define cpu_guest_has_conf7 (cpu_data[0].guest.conf & (1 << 7))
  514. #endif
  515. #ifndef cpu_guest_has_fpu
  516. #define cpu_guest_has_fpu (cpu_data[0].guest.options & MIPS_CPU_FPU)
  517. #endif
  518. #ifndef cpu_guest_has_watch
  519. #define cpu_guest_has_watch (cpu_data[0].guest.options & MIPS_CPU_WATCH)
  520. #endif
  521. #ifndef cpu_guest_has_contextconfig
  522. #define cpu_guest_has_contextconfig (cpu_data[0].guest.options & MIPS_CPU_CTXTC)
  523. #endif
  524. #ifndef cpu_guest_has_segments
  525. #define cpu_guest_has_segments (cpu_data[0].guest.options & MIPS_CPU_SEGMENTS)
  526. #endif
  527. #ifndef cpu_guest_has_badinstr
  528. #define cpu_guest_has_badinstr (cpu_data[0].guest.options & MIPS_CPU_BADINSTR)
  529. #endif
  530. #ifndef cpu_guest_has_badinstrp
  531. #define cpu_guest_has_badinstrp (cpu_data[0].guest.options & MIPS_CPU_BADINSTRP)
  532. #endif
  533. #ifndef cpu_guest_has_htw
  534. #define cpu_guest_has_htw (cpu_data[0].guest.options & MIPS_CPU_HTW)
  535. #endif
  536. #ifndef cpu_guest_has_mvh
  537. #define cpu_guest_has_mvh (cpu_data[0].guest.options & MIPS_CPU_MVH)
  538. #endif
  539. #ifndef cpu_guest_has_msa
  540. #define cpu_guest_has_msa (cpu_data[0].guest.ases & MIPS_ASE_MSA)
  541. #endif
  542. #ifndef cpu_guest_has_kscr
  543. #define cpu_guest_has_kscr(n) (cpu_data[0].guest.kscratch_mask & (1u << (n)))
  544. #endif
  545. #ifndef cpu_guest_has_rw_llb
  546. #define cpu_guest_has_rw_llb (cpu_has_mips_r6 || (cpu_data[0].guest.options & MIPS_CPU_RW_LLB))
  547. #endif
  548. #ifndef cpu_guest_has_perf
  549. #define cpu_guest_has_perf (cpu_data[0].guest.options & MIPS_CPU_PERF)
  550. #endif
  551. #ifndef cpu_guest_has_maar
  552. #define cpu_guest_has_maar (cpu_data[0].guest.options & MIPS_CPU_MAAR)
  553. #endif
  554. #ifndef cpu_guest_has_userlocal
  555. #define cpu_guest_has_userlocal (cpu_data[0].guest.options & MIPS_CPU_ULRI)
  556. #endif
  557. /*
  558. * Guest dynamic capabilities
  559. */
  560. #ifndef cpu_guest_has_dyn_fpu
  561. #define cpu_guest_has_dyn_fpu (cpu_data[0].guest.options_dyn & MIPS_CPU_FPU)
  562. #endif
  563. #ifndef cpu_guest_has_dyn_watch
  564. #define cpu_guest_has_dyn_watch (cpu_data[0].guest.options_dyn & MIPS_CPU_WATCH)
  565. #endif
  566. #ifndef cpu_guest_has_dyn_contextconfig
  567. #define cpu_guest_has_dyn_contextconfig (cpu_data[0].guest.options_dyn & MIPS_CPU_CTXTC)
  568. #endif
  569. #ifndef cpu_guest_has_dyn_perf
  570. #define cpu_guest_has_dyn_perf (cpu_data[0].guest.options_dyn & MIPS_CPU_PERF)
  571. #endif
  572. #ifndef cpu_guest_has_dyn_msa
  573. #define cpu_guest_has_dyn_msa (cpu_data[0].guest.ases_dyn & MIPS_ASE_MSA)
  574. #endif
  575. #ifndef cpu_guest_has_dyn_maar
  576. #define cpu_guest_has_dyn_maar (cpu_data[0].guest.options_dyn & MIPS_CPU_MAAR)
  577. #endif
  578. #endif /* __ASM_CPU_FEATURES_H */