cpu-features.h 20 KB

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