cpu-features.h 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570
  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_mdmx
  139. #define cpu_has_mdmx (cpu_data[0].ases & MIPS_ASE_MDMX)
  140. #endif
  141. #ifndef cpu_has_mips3d
  142. #define cpu_has_mips3d (cpu_data[0].ases & MIPS_ASE_MIPS3D)
  143. #endif
  144. #ifndef cpu_has_smartmips
  145. #define cpu_has_smartmips (cpu_data[0].ases & MIPS_ASE_SMARTMIPS)
  146. #endif
  147. #ifndef cpu_has_rixi
  148. #define cpu_has_rixi (cpu_data[0].options & MIPS_CPU_RIXI)
  149. #endif
  150. #ifndef cpu_has_mmips
  151. # ifdef CONFIG_SYS_SUPPORTS_MICROMIPS
  152. # define cpu_has_mmips (cpu_data[0].options & MIPS_CPU_MICROMIPS)
  153. # else
  154. # define cpu_has_mmips 0
  155. # endif
  156. #endif
  157. #ifndef cpu_has_lpa
  158. #define cpu_has_lpa (cpu_data[0].options & MIPS_CPU_LPA)
  159. #endif
  160. #ifndef cpu_has_mvh
  161. #define cpu_has_mvh (cpu_data[0].options & MIPS_CPU_MVH)
  162. #endif
  163. #ifndef cpu_has_xpa
  164. #define cpu_has_xpa (cpu_has_lpa && cpu_has_mvh)
  165. #endif
  166. #ifndef cpu_has_vtag_icache
  167. #define cpu_has_vtag_icache (cpu_data[0].icache.flags & MIPS_CACHE_VTAG)
  168. #endif
  169. #ifndef cpu_has_dc_aliases
  170. #define cpu_has_dc_aliases (cpu_data[0].dcache.flags & MIPS_CACHE_ALIASES)
  171. #endif
  172. #ifndef cpu_has_ic_fills_f_dc
  173. #define cpu_has_ic_fills_f_dc (cpu_data[0].icache.flags & MIPS_CACHE_IC_F_DC)
  174. #endif
  175. #ifndef cpu_has_pindexed_dcache
  176. #define cpu_has_pindexed_dcache (cpu_data[0].dcache.flags & MIPS_CACHE_PINDEX)
  177. #endif
  178. #ifndef cpu_has_local_ebase
  179. #define cpu_has_local_ebase 1
  180. #endif
  181. /*
  182. * I-Cache snoops remote store. This only matters on SMP. Some multiprocessors
  183. * such as the R10000 have I-Caches that snoop local stores; the embedded ones
  184. * don't. For maintaining I-cache coherency this means we need to flush the
  185. * D-cache all the way back to whever the I-cache does refills from, so the
  186. * I-cache has a chance to see the new data at all. Then we have to flush the
  187. * I-cache also.
  188. * Note we may have been rescheduled and may no longer be running on the CPU
  189. * that did the store so we can't optimize this into only doing the flush on
  190. * the local CPU.
  191. */
  192. #ifndef cpu_icache_snoops_remote_store
  193. #ifdef CONFIG_SMP
  194. #define cpu_icache_snoops_remote_store (cpu_data[0].icache.flags & MIPS_IC_SNOOPS_REMOTE)
  195. #else
  196. #define cpu_icache_snoops_remote_store 1
  197. #endif
  198. #endif
  199. /* __builtin_constant_p(cpu_has_mips_r) && cpu_has_mips_r */
  200. #if !((defined(cpu_has_mips32r1) && cpu_has_mips32r1) || \
  201. (defined(cpu_has_mips32r2) && cpu_has_mips32r2) || \
  202. (defined(cpu_has_mips32r6) && cpu_has_mips32r6) || \
  203. (defined(cpu_has_mips64r1) && cpu_has_mips64r1) || \
  204. (defined(cpu_has_mips64r2) && cpu_has_mips64r2) || \
  205. (defined(cpu_has_mips64r6) && cpu_has_mips64r6))
  206. #define CPU_NO_EFFICIENT_FFS 1
  207. #endif
  208. #ifndef cpu_has_mips_1
  209. # define cpu_has_mips_1 (!cpu_has_mips_r6)
  210. #endif
  211. #ifndef cpu_has_mips_2
  212. # define cpu_has_mips_2 (cpu_data[0].isa_level & MIPS_CPU_ISA_II)
  213. #endif
  214. #ifndef cpu_has_mips_3
  215. # define cpu_has_mips_3 (cpu_data[0].isa_level & MIPS_CPU_ISA_III)
  216. #endif
  217. #ifndef cpu_has_mips_4
  218. # define cpu_has_mips_4 (cpu_data[0].isa_level & MIPS_CPU_ISA_IV)
  219. #endif
  220. #ifndef cpu_has_mips_5
  221. # define cpu_has_mips_5 (cpu_data[0].isa_level & MIPS_CPU_ISA_V)
  222. #endif
  223. #ifndef cpu_has_mips32r1
  224. # define cpu_has_mips32r1 (cpu_data[0].isa_level & MIPS_CPU_ISA_M32R1)
  225. #endif
  226. #ifndef cpu_has_mips32r2
  227. # define cpu_has_mips32r2 (cpu_data[0].isa_level & MIPS_CPU_ISA_M32R2)
  228. #endif
  229. #ifndef cpu_has_mips32r6
  230. # define cpu_has_mips32r6 (cpu_data[0].isa_level & MIPS_CPU_ISA_M32R6)
  231. #endif
  232. #ifndef cpu_has_mips64r1
  233. # define cpu_has_mips64r1 (cpu_data[0].isa_level & MIPS_CPU_ISA_M64R1)
  234. #endif
  235. #ifndef cpu_has_mips64r2
  236. # define cpu_has_mips64r2 (cpu_data[0].isa_level & MIPS_CPU_ISA_M64R2)
  237. #endif
  238. #ifndef cpu_has_mips64r6
  239. # define cpu_has_mips64r6 (cpu_data[0].isa_level & MIPS_CPU_ISA_M64R6)
  240. #endif
  241. /*
  242. * Shortcuts ...
  243. */
  244. #define cpu_has_mips_2_3_4_5 (cpu_has_mips_2 | cpu_has_mips_3_4_5)
  245. #define cpu_has_mips_3_4_5 (cpu_has_mips_3 | cpu_has_mips_4_5)
  246. #define cpu_has_mips_4_5 (cpu_has_mips_4 | cpu_has_mips_5)
  247. #define cpu_has_mips_2_3_4_5_r (cpu_has_mips_2 | cpu_has_mips_3_4_5_r)
  248. #define cpu_has_mips_3_4_5_r (cpu_has_mips_3 | cpu_has_mips_4_5_r)
  249. #define cpu_has_mips_4_5_r (cpu_has_mips_4 | cpu_has_mips_5_r)
  250. #define cpu_has_mips_5_r (cpu_has_mips_5 | cpu_has_mips_r)
  251. #define cpu_has_mips_3_4_5_64_r2_r6 \
  252. (cpu_has_mips_3 | cpu_has_mips_4_5_64_r2_r6)
  253. #define cpu_has_mips_4_5_64_r2_r6 \
  254. (cpu_has_mips_4_5 | cpu_has_mips64r1 | \
  255. cpu_has_mips_r2 | cpu_has_mips_r6)
  256. #define cpu_has_mips32 (cpu_has_mips32r1 | cpu_has_mips32r2 | cpu_has_mips32r6)
  257. #define cpu_has_mips64 (cpu_has_mips64r1 | cpu_has_mips64r2 | cpu_has_mips64r6)
  258. #define cpu_has_mips_r1 (cpu_has_mips32r1 | cpu_has_mips64r1)
  259. #define cpu_has_mips_r2 (cpu_has_mips32r2 | cpu_has_mips64r2)
  260. #define cpu_has_mips_r6 (cpu_has_mips32r6 | cpu_has_mips64r6)
  261. #define cpu_has_mips_r (cpu_has_mips32r1 | cpu_has_mips32r2 | \
  262. cpu_has_mips32r6 | cpu_has_mips64r1 | \
  263. cpu_has_mips64r2 | cpu_has_mips64r6)
  264. /* MIPSR2 and MIPSR6 have a lot of similarities */
  265. #define cpu_has_mips_r2_r6 (cpu_has_mips_r2 | cpu_has_mips_r6)
  266. /*
  267. * cpu_has_mips_r2_exec_hazard - return if IHB is required on current processor
  268. *
  269. * Returns non-zero value if the current processor implementation requires
  270. * an IHB instruction to deal with an instruction hazard as per MIPS R2
  271. * architecture specification, zero otherwise.
  272. */
  273. #ifndef cpu_has_mips_r2_exec_hazard
  274. #define cpu_has_mips_r2_exec_hazard \
  275. ({ \
  276. int __res; \
  277. \
  278. switch (current_cpu_type()) { \
  279. case CPU_M14KC: \
  280. case CPU_74K: \
  281. case CPU_1074K: \
  282. case CPU_PROAPTIV: \
  283. case CPU_P5600: \
  284. case CPU_M5150: \
  285. case CPU_QEMU_GENERIC: \
  286. case CPU_CAVIUM_OCTEON: \
  287. case CPU_CAVIUM_OCTEON_PLUS: \
  288. case CPU_CAVIUM_OCTEON2: \
  289. case CPU_CAVIUM_OCTEON3: \
  290. __res = 0; \
  291. break; \
  292. \
  293. default: \
  294. __res = 1; \
  295. } \
  296. \
  297. __res; \
  298. })
  299. #endif
  300. /*
  301. * MIPS32, MIPS64, VR5500, IDT32332, IDT32334 and maybe a few other
  302. * pre-MIPS32/MIPS64 processors have CLO, CLZ. The IDT RC64574 is 64-bit and
  303. * has CLO and CLZ but not DCLO nor DCLZ. For 64-bit kernels
  304. * cpu_has_clo_clz also indicates the availability of DCLO and DCLZ.
  305. */
  306. #ifndef cpu_has_clo_clz
  307. #define cpu_has_clo_clz cpu_has_mips_r
  308. #endif
  309. /*
  310. * MIPS32 R2, MIPS64 R2, Loongson 3A and Octeon have WSBH.
  311. * MIPS64 R2, Loongson 3A and Octeon have WSBH, DSBH and DSHD.
  312. * This indicates the availability of WSBH and in case of 64 bit CPUs also
  313. * DSBH and DSHD.
  314. */
  315. #ifndef cpu_has_wsbh
  316. #define cpu_has_wsbh cpu_has_mips_r2
  317. #endif
  318. #ifndef cpu_has_dsp
  319. #define cpu_has_dsp (cpu_data[0].ases & MIPS_ASE_DSP)
  320. #endif
  321. #ifndef cpu_has_dsp2
  322. #define cpu_has_dsp2 (cpu_data[0].ases & MIPS_ASE_DSP2P)
  323. #endif
  324. #ifndef cpu_has_dsp3
  325. #define cpu_has_dsp3 (cpu_data[0].ases & MIPS_ASE_DSP3)
  326. #endif
  327. #ifndef cpu_has_mipsmt
  328. #define cpu_has_mipsmt (cpu_data[0].ases & MIPS_ASE_MIPSMT)
  329. #endif
  330. #ifndef cpu_has_vp
  331. #define cpu_has_vp (cpu_data[0].options & MIPS_CPU_VP)
  332. #endif
  333. #ifndef cpu_has_userlocal
  334. #define cpu_has_userlocal (cpu_data[0].options & MIPS_CPU_ULRI)
  335. #endif
  336. #ifdef CONFIG_32BIT
  337. # ifndef cpu_has_nofpuex
  338. # define cpu_has_nofpuex (cpu_data[0].options & MIPS_CPU_NOFPUEX)
  339. # endif
  340. # ifndef cpu_has_64bits
  341. # define cpu_has_64bits (cpu_data[0].isa_level & MIPS_CPU_ISA_64BIT)
  342. # endif
  343. # ifndef cpu_has_64bit_zero_reg
  344. # define cpu_has_64bit_zero_reg (cpu_data[0].isa_level & MIPS_CPU_ISA_64BIT)
  345. # endif
  346. # ifndef cpu_has_64bit_gp_regs
  347. # define cpu_has_64bit_gp_regs 0
  348. # endif
  349. # ifndef cpu_has_64bit_addresses
  350. # define cpu_has_64bit_addresses 0
  351. # endif
  352. # ifndef cpu_vmbits
  353. # define cpu_vmbits 31
  354. # endif
  355. #endif
  356. #ifdef CONFIG_64BIT
  357. # ifndef cpu_has_nofpuex
  358. # define cpu_has_nofpuex 0
  359. # endif
  360. # ifndef cpu_has_64bits
  361. # define cpu_has_64bits 1
  362. # endif
  363. # ifndef cpu_has_64bit_zero_reg
  364. # define cpu_has_64bit_zero_reg 1
  365. # endif
  366. # ifndef cpu_has_64bit_gp_regs
  367. # define cpu_has_64bit_gp_regs 1
  368. # endif
  369. # ifndef cpu_has_64bit_addresses
  370. # define cpu_has_64bit_addresses 1
  371. # endif
  372. # ifndef cpu_vmbits
  373. # define cpu_vmbits cpu_data[0].vmbits
  374. # define __NEED_VMBITS_PROBE
  375. # endif
  376. #endif
  377. #if defined(CONFIG_CPU_MIPSR2_IRQ_VI) && !defined(cpu_has_vint)
  378. # define cpu_has_vint (cpu_data[0].options & MIPS_CPU_VINT)
  379. #elif !defined(cpu_has_vint)
  380. # define cpu_has_vint 0
  381. #endif
  382. #if defined(CONFIG_CPU_MIPSR2_IRQ_EI) && !defined(cpu_has_veic)
  383. # define cpu_has_veic (cpu_data[0].options & MIPS_CPU_VEIC)
  384. #elif !defined(cpu_has_veic)
  385. # define cpu_has_veic 0
  386. #endif
  387. #ifndef cpu_has_inclusive_pcaches
  388. #define cpu_has_inclusive_pcaches (cpu_data[0].options & MIPS_CPU_INCLUSIVE_CACHES)
  389. #endif
  390. #ifndef cpu_dcache_line_size
  391. #define cpu_dcache_line_size() cpu_data[0].dcache.linesz
  392. #endif
  393. #ifndef cpu_icache_line_size
  394. #define cpu_icache_line_size() cpu_data[0].icache.linesz
  395. #endif
  396. #ifndef cpu_scache_line_size
  397. #define cpu_scache_line_size() cpu_data[0].scache.linesz
  398. #endif
  399. #ifndef cpu_hwrena_impl_bits
  400. #define cpu_hwrena_impl_bits 0
  401. #endif
  402. #ifndef cpu_has_perf_cntr_intr_bit
  403. #define cpu_has_perf_cntr_intr_bit (cpu_data[0].options & MIPS_CPU_PCI)
  404. #endif
  405. #ifndef cpu_has_vz
  406. #define cpu_has_vz (cpu_data[0].ases & MIPS_ASE_VZ)
  407. #endif
  408. #if defined(CONFIG_CPU_HAS_MSA) && !defined(cpu_has_msa)
  409. # define cpu_has_msa (cpu_data[0].ases & MIPS_ASE_MSA)
  410. #elif !defined(cpu_has_msa)
  411. # define cpu_has_msa 0
  412. #endif
  413. #ifndef cpu_has_fre
  414. # define cpu_has_fre (cpu_data[0].options & MIPS_CPU_FRE)
  415. #endif
  416. #ifndef cpu_has_cdmm
  417. # define cpu_has_cdmm (cpu_data[0].options & MIPS_CPU_CDMM)
  418. #endif
  419. #ifndef cpu_has_small_pages
  420. # define cpu_has_small_pages (cpu_data[0].options & MIPS_CPU_SP)
  421. #endif
  422. #ifndef cpu_has_nan_legacy
  423. #define cpu_has_nan_legacy (cpu_data[0].options & MIPS_CPU_NAN_LEGACY)
  424. #endif
  425. #ifndef cpu_has_nan_2008
  426. #define cpu_has_nan_2008 (cpu_data[0].options & MIPS_CPU_NAN_2008)
  427. #endif
  428. #ifndef cpu_has_ebase_wg
  429. # define cpu_has_ebase_wg (cpu_data[0].options & MIPS_CPU_EBASE_WG)
  430. #endif
  431. #ifndef cpu_has_badinstr
  432. # define cpu_has_badinstr (cpu_data[0].options & MIPS_CPU_BADINSTR)
  433. #endif
  434. #ifndef cpu_has_badinstrp
  435. # define cpu_has_badinstrp (cpu_data[0].options & MIPS_CPU_BADINSTRP)
  436. #endif
  437. #ifndef cpu_has_contextconfig
  438. # define cpu_has_contextconfig (cpu_data[0].options & MIPS_CPU_CTXTC)
  439. #endif
  440. #ifndef cpu_has_perf
  441. # define cpu_has_perf (cpu_data[0].options & MIPS_CPU_PERF)
  442. #endif
  443. /*
  444. * Guest capabilities
  445. */
  446. #ifndef cpu_guest_has_conf1
  447. #define cpu_guest_has_conf1 (cpu_data[0].guest.conf & (1 << 1))
  448. #endif
  449. #ifndef cpu_guest_has_conf2
  450. #define cpu_guest_has_conf2 (cpu_data[0].guest.conf & (1 << 2))
  451. #endif
  452. #ifndef cpu_guest_has_conf3
  453. #define cpu_guest_has_conf3 (cpu_data[0].guest.conf & (1 << 3))
  454. #endif
  455. #ifndef cpu_guest_has_conf4
  456. #define cpu_guest_has_conf4 (cpu_data[0].guest.conf & (1 << 4))
  457. #endif
  458. #ifndef cpu_guest_has_conf5
  459. #define cpu_guest_has_conf5 (cpu_data[0].guest.conf & (1 << 5))
  460. #endif
  461. #ifndef cpu_guest_has_conf6
  462. #define cpu_guest_has_conf6 (cpu_data[0].guest.conf & (1 << 6))
  463. #endif
  464. #ifndef cpu_guest_has_conf7
  465. #define cpu_guest_has_conf7 (cpu_data[0].guest.conf & (1 << 7))
  466. #endif
  467. #ifndef cpu_guest_has_fpu
  468. #define cpu_guest_has_fpu (cpu_data[0].guest.options & MIPS_CPU_FPU)
  469. #endif
  470. #ifndef cpu_guest_has_watch
  471. #define cpu_guest_has_watch (cpu_data[0].guest.options & MIPS_CPU_WATCH)
  472. #endif
  473. #ifndef cpu_guest_has_contextconfig
  474. #define cpu_guest_has_contextconfig (cpu_data[0].guest.options & MIPS_CPU_CTXTC)
  475. #endif
  476. #ifndef cpu_guest_has_segments
  477. #define cpu_guest_has_segments (cpu_data[0].guest.options & MIPS_CPU_SEGMENTS)
  478. #endif
  479. #ifndef cpu_guest_has_badinstr
  480. #define cpu_guest_has_badinstr (cpu_data[0].guest.options & MIPS_CPU_BADINSTR)
  481. #endif
  482. #ifndef cpu_guest_has_badinstrp
  483. #define cpu_guest_has_badinstrp (cpu_data[0].guest.options & MIPS_CPU_BADINSTRP)
  484. #endif
  485. #ifndef cpu_guest_has_htw
  486. #define cpu_guest_has_htw (cpu_data[0].guest.options & MIPS_CPU_HTW)
  487. #endif
  488. #ifndef cpu_guest_has_msa
  489. #define cpu_guest_has_msa (cpu_data[0].guest.ases & MIPS_ASE_MSA)
  490. #endif
  491. #ifndef cpu_guest_has_kscr
  492. #define cpu_guest_has_kscr(n) (cpu_data[0].guest.kscratch_mask & (1u << (n)))
  493. #endif
  494. #ifndef cpu_guest_has_rw_llb
  495. #define cpu_guest_has_rw_llb (cpu_has_mips_r6 || (cpu_data[0].guest.options & MIPS_CPU_RW_LLB))
  496. #endif
  497. #ifndef cpu_guest_has_perf
  498. #define cpu_guest_has_perf (cpu_data[0].guest.options & MIPS_CPU_PERF)
  499. #endif
  500. #ifndef cpu_guest_has_maar
  501. #define cpu_guest_has_maar (cpu_data[0].guest.options & MIPS_CPU_MAAR)
  502. #endif
  503. /*
  504. * Guest dynamic capabilities
  505. */
  506. #ifndef cpu_guest_has_dyn_fpu
  507. #define cpu_guest_has_dyn_fpu (cpu_data[0].guest.options_dyn & MIPS_CPU_FPU)
  508. #endif
  509. #ifndef cpu_guest_has_dyn_watch
  510. #define cpu_guest_has_dyn_watch (cpu_data[0].guest.options_dyn & MIPS_CPU_WATCH)
  511. #endif
  512. #ifndef cpu_guest_has_dyn_contextconfig
  513. #define cpu_guest_has_dyn_contextconfig (cpu_data[0].guest.options_dyn & MIPS_CPU_CTXTC)
  514. #endif
  515. #ifndef cpu_guest_has_dyn_perf
  516. #define cpu_guest_has_dyn_perf (cpu_data[0].guest.options_dyn & MIPS_CPU_PERF)
  517. #endif
  518. #ifndef cpu_guest_has_dyn_msa
  519. #define cpu_guest_has_dyn_msa (cpu_data[0].guest.ases_dyn & MIPS_ASE_MSA)
  520. #endif
  521. #ifndef cpu_guest_has_dyn_maar
  522. #define cpu_guest_has_dyn_maar (cpu_data[0].guest.options_dyn & MIPS_CPU_MAAR)
  523. #endif
  524. #endif /* __ASM_CPU_FEATURES_H */