cpu-features.h 19 KB

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