mipsregs.h 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616
  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) 1994, 1995, 1996, 1997, 2000, 2001 by Ralf Baechle
  7. * Copyright (C) 2000 Silicon Graphics, Inc.
  8. * Modified for further R[236]000 support by Paul M. Antoine, 1996.
  9. * Kevin D. Kissell, kevink@mips.com and Carsten Langgaard, carstenl@mips.com
  10. * Copyright (C) 2000, 07 MIPS Technologies, Inc.
  11. * Copyright (C) 2003, 2004 Maciej W. Rozycki
  12. *
  13. * Change Logs:
  14. * Date Author Notes
  15. *
  16. */
  17. #ifndef __MIPSREGS_H__
  18. #define __MIPSREGS_H__
  19. /*
  20. * The following macros are especially useful for __asm__
  21. * inline assembler.
  22. */
  23. #ifndef __STR
  24. #define __STR(x) #x
  25. #endif
  26. #ifndef STR
  27. #define STR(x) __STR(x)
  28. #endif
  29. /*
  30. * Configure language
  31. */
  32. #ifdef __ASSEMBLY__
  33. #define _ULCAST_
  34. #else
  35. #define _ULCAST_ (unsigned long)
  36. #endif
  37. /*
  38. * Coprocessor 0 register names
  39. */
  40. #define CP0_INDEX $0
  41. #define CP0_RANDOM $1
  42. #define CP0_ENTRYLO0 $2
  43. #define CP0_ENTRYLO1 $3
  44. #define CP0_CONF $3
  45. #define CP0_CONTEXT $4
  46. #define CP0_PAGEMASK $5
  47. #define CP0_WIRED $6
  48. #define CP0_INFO $7
  49. #define CP0_BADVADDR $8
  50. #define CP0_COUNT $9
  51. #define CP0_ENTRYHI $10
  52. #define CP0_COMPARE $11
  53. #define CP0_STATUS $12
  54. #define CP0_CAUSE $13
  55. #define CP0_EPC $14
  56. #define CP0_PRID $15
  57. #define CP0_CONFIG $16
  58. #define CP0_LLADDR $17
  59. #define CP0_WATCHLO $18
  60. #define CP0_WATCHHI $19
  61. #define CP0_XCONTEXT $20
  62. #define CP0_FRAMEMASK $21
  63. #define CP0_DIAGNOSTIC $22
  64. #define CP0_DEBUG $23
  65. #define CP0_DEPC $24
  66. #define CP0_PERFORMANCE $25
  67. #define CP0_ECC $26
  68. #define CP0_CACHEERR $27
  69. #define CP0_TAGLO $28
  70. #define CP0_TAGHI $29
  71. #define CP0_ERROREPC $30
  72. #define CP0_DESAVE $31
  73. /*
  74. * R4640/R4650 cp0 register names. These registers are listed
  75. * here only for completeness; without MMU these CPUs are not useable
  76. * by Linux. A future ELKS port might take make Linux run on them
  77. * though ...
  78. */
  79. #define CP0_IBASE $0
  80. #define CP0_IBOUND $1
  81. #define CP0_DBASE $2
  82. #define CP0_DBOUND $3
  83. #define CP0_CALG $17
  84. #define CP0_IWATCH $18
  85. #define CP0_DWATCH $19
  86. /*
  87. * Coprocessor 0 Set 1 register names
  88. */
  89. #define CP0_S1_DERRADDR0 $26
  90. #define CP0_S1_DERRADDR1 $27
  91. #define CP0_S1_INTCONTROL $20
  92. /*
  93. * Coprocessor 0 Set 2 register names
  94. */
  95. #define CP0_S2_SRSCTL $12 /* MIPSR2 */
  96. /*
  97. * Coprocessor 0 Set 3 register names
  98. */
  99. #define CP0_S3_SRSMAP $12 /* MIPSR2 */
  100. /*
  101. * TX39 Series
  102. */
  103. #define CP0_TX39_CACHE $7
  104. /*
  105. * Coprocessor 1 (FPU) register names
  106. */
  107. #define CP1_REVISION $0
  108. #define CP1_STATUS $31
  109. /*
  110. * R4x00 interrupt enable / cause bits
  111. */
  112. #define IE_SW0 (_ULCAST_(1) << 8)
  113. #define IE_SW1 (_ULCAST_(1) << 9)
  114. #define IE_IRQ0 (_ULCAST_(1) << 10)
  115. #define IE_IRQ1 (_ULCAST_(1) << 11)
  116. #define IE_IRQ2 (_ULCAST_(1) << 12)
  117. #define IE_IRQ3 (_ULCAST_(1) << 13)
  118. #define IE_IRQ4 (_ULCAST_(1) << 14)
  119. #define IE_IRQ5 (_ULCAST_(1) << 15)
  120. /*
  121. * R4x00 interrupt cause bits
  122. */
  123. #define C_SW0 (_ULCAST_(1) << 8)
  124. #define C_SW1 (_ULCAST_(1) << 9)
  125. #define C_IRQ0 (_ULCAST_(1) << 10)
  126. #define C_IRQ1 (_ULCAST_(1) << 11)
  127. #define C_IRQ2 (_ULCAST_(1) << 12)
  128. #define C_IRQ3 (_ULCAST_(1) << 13)
  129. #define C_IRQ4 (_ULCAST_(1) << 14)
  130. #define C_IRQ5 (_ULCAST_(1) << 15)
  131. /*
  132. * Bitfields in the R4xx0 cp0 status register
  133. */
  134. #define ST0_IE 0x00000001
  135. #define ST0_EXL 0x00000002
  136. #define ST0_ERL 0x00000004
  137. #define ST0_KSU 0x00000018
  138. # define KSU_USER 0x00000010
  139. # define KSU_SUPERVISOR 0x00000008
  140. # define KSU_KERNEL 0x00000000
  141. #define ST0_UX 0x00000020
  142. #define ST0_SX 0x00000040
  143. #define ST0_KX 0x00000080
  144. #define ST0_DE 0x00010000
  145. #define ST0_CE 0x00020000
  146. /*
  147. * Setting c0_status.co enables Hit_Writeback and Hit_Writeback_Invalidate
  148. * cacheops in userspace. This bit exists only on RM7000 and RM9000
  149. * processors.
  150. */
  151. #define ST0_CO 0x08000000
  152. /*
  153. * Bitfields in the R[23]000 cp0 status register.
  154. */
  155. #define ST0_IEC 0x00000001
  156. #define ST0_KUC 0x00000002
  157. #define ST0_IEP 0x00000004
  158. #define ST0_KUP 0x00000008
  159. #define ST0_IEO 0x00000010
  160. #define ST0_KUO 0x00000020
  161. /* bits 6 & 7 are reserved on R[23]000 */
  162. #define ST0_ISC 0x00010000
  163. #define ST0_SWC 0x00020000
  164. #define ST0_CM 0x00080000
  165. /*
  166. * Bits specific to the R4640/R4650
  167. */
  168. #define ST0_UM (_ULCAST_(1) << 4)
  169. #define ST0_IL (_ULCAST_(1) << 23)
  170. #define ST0_DL (_ULCAST_(1) << 24)
  171. /*
  172. * Enable the MIPS DSP ASE
  173. */
  174. #define ST0_MX 0x01000000
  175. /*
  176. * Bitfields in the TX39 family CP0 Configuration Register 3
  177. */
  178. #define TX39_CONF_ICS_SHIFT 19
  179. #define TX39_CONF_ICS_MASK 0x00380000
  180. #define TX39_CONF_ICS_1KB 0x00000000
  181. #define TX39_CONF_ICS_2KB 0x00080000
  182. #define TX39_CONF_ICS_4KB 0x00100000
  183. #define TX39_CONF_ICS_8KB 0x00180000
  184. #define TX39_CONF_ICS_16KB 0x00200000
  185. #define TX39_CONF_DCS_SHIFT 16
  186. #define TX39_CONF_DCS_MASK 0x00070000
  187. #define TX39_CONF_DCS_1KB 0x00000000
  188. #define TX39_CONF_DCS_2KB 0x00010000
  189. #define TX39_CONF_DCS_4KB 0x00020000
  190. #define TX39_CONF_DCS_8KB 0x00030000
  191. #define TX39_CONF_DCS_16KB 0x00040000
  192. #define TX39_CONF_CWFON 0x00004000
  193. #define TX39_CONF_WBON 0x00002000
  194. #define TX39_CONF_RF_SHIFT 10
  195. #define TX39_CONF_RF_MASK 0x00000c00
  196. #define TX39_CONF_DOZE 0x00000200
  197. #define TX39_CONF_HALT 0x00000100
  198. #define TX39_CONF_LOCK 0x00000080
  199. #define TX39_CONF_ICE 0x00000020
  200. #define TX39_CONF_DCE 0x00000010
  201. #define TX39_CONF_IRSIZE_SHIFT 2
  202. #define TX39_CONF_IRSIZE_MASK 0x0000000c
  203. #define TX39_CONF_DRSIZE_SHIFT 0
  204. #define TX39_CONF_DRSIZE_MASK 0x00000003
  205. /*
  206. * Status register bits available in all MIPS CPUs.
  207. */
  208. #define ST0_IM 0x0000ff00
  209. #define STATUSB_IP0 8
  210. #define STATUSF_IP0 (_ULCAST_(1) << 8)
  211. #define STATUSB_IP1 9
  212. #define STATUSF_IP1 (_ULCAST_(1) << 9)
  213. #define STATUSB_IP2 10
  214. #define STATUSF_IP2 (_ULCAST_(1) << 10)
  215. #define STATUSB_IP3 11
  216. #define STATUSF_IP3 (_ULCAST_(1) << 11)
  217. #define STATUSB_IP4 12
  218. #define STATUSF_IP4 (_ULCAST_(1) << 12)
  219. #define STATUSB_IP5 13
  220. #define STATUSF_IP5 (_ULCAST_(1) << 13)
  221. #define STATUSB_IP6 14
  222. #define STATUSF_IP6 (_ULCAST_(1) << 14)
  223. #define STATUSB_IP7 15
  224. #define STATUSF_IP7 (_ULCAST_(1) << 15)
  225. #define STATUSB_IP8 0
  226. #define STATUSF_IP8 (_ULCAST_(1) << 0)
  227. #define STATUSB_IP9 1
  228. #define STATUSF_IP9 (_ULCAST_(1) << 1)
  229. #define STATUSB_IP10 2
  230. #define STATUSF_IP10 (_ULCAST_(1) << 2)
  231. #define STATUSB_IP11 3
  232. #define STATUSF_IP11 (_ULCAST_(1) << 3)
  233. #define STATUSB_IP12 4
  234. #define STATUSF_IP12 (_ULCAST_(1) << 4)
  235. #define STATUSB_IP13 5
  236. #define STATUSF_IP13 (_ULCAST_(1) << 5)
  237. #define STATUSB_IP14 6
  238. #define STATUSF_IP14 (_ULCAST_(1) << 6)
  239. #define STATUSB_IP15 7
  240. #define STATUSF_IP15 (_ULCAST_(1) << 7)
  241. #define ST0_CH 0x00040000
  242. #define ST0_SR 0x00100000
  243. #define ST0_TS 0x00200000
  244. #define ST0_BEV 0x00400000
  245. #define ST0_RE 0x02000000
  246. #define ST0_FR 0x04000000
  247. #define ST0_CU 0xf0000000
  248. #define ST0_CU0 0x10000000
  249. #define ST0_CU1 0x20000000
  250. #define ST0_CU2 0x40000000
  251. #define ST0_CU3 0x80000000
  252. #define ST0_XX 0x80000000 /* MIPS IV naming */
  253. /*
  254. * Bitfields and bit numbers in the coprocessor 0 cause register.
  255. *
  256. * Refer to your MIPS R4xx0 manual, chapter 5 for explanation.
  257. */
  258. #define CAUSEB_EXCCODE 2
  259. #define CAUSEF_EXCCODE (_ULCAST_(31) << 2)
  260. #define CAUSEB_IP 8
  261. #define CAUSEF_IP (_ULCAST_(255) << 8)
  262. #define CAUSEB_IP0 8
  263. #define CAUSEF_IP0 (_ULCAST_(1) << 8)
  264. #define CAUSEB_IP1 9
  265. #define CAUSEF_IP1 (_ULCAST_(1) << 9)
  266. #define CAUSEB_IP2 10
  267. #define CAUSEF_IP2 (_ULCAST_(1) << 10)
  268. #define CAUSEB_IP3 11
  269. #define CAUSEF_IP3 (_ULCAST_(1) << 11)
  270. #define CAUSEB_IP4 12
  271. #define CAUSEF_IP4 (_ULCAST_(1) << 12)
  272. #define CAUSEB_IP5 13
  273. #define CAUSEF_IP5 (_ULCAST_(1) << 13)
  274. #define CAUSEB_IP6 14
  275. #define CAUSEF_IP6 (_ULCAST_(1) << 14)
  276. #define CAUSEB_IP7 15
  277. #define CAUSEF_IP7 (_ULCAST_(1) << 15)
  278. #define CAUSEB_IV 23
  279. #define CAUSEF_IV (_ULCAST_(1) << 23)
  280. #define CAUSEB_CE 28
  281. #define CAUSEF_CE (_ULCAST_(3) << 28)
  282. #define CAUSEB_BD 31
  283. #define CAUSEF_BD (_ULCAST_(1) << 31)
  284. /*
  285. * Bits in the coprocessor 0 config register.
  286. */
  287. /* Generic bits. */
  288. #define CONF_CM_CACHABLE_NO_WA 0
  289. #define CONF_CM_CACHABLE_WA 1
  290. #define CONF_CM_UNCACHED 2
  291. #define CONF_CM_CACHABLE_NONCOHERENT 3
  292. #define CONF_CM_CACHABLE_CE 4
  293. #define CONF_CM_CACHABLE_COW 5
  294. #define CONF_CM_CACHABLE_CUW 6
  295. #define CONF_CM_CACHABLE_ACCELERATED 7
  296. #define CONF_CM_CMASK 7
  297. #define CONF_BE (_ULCAST_(1) << 15)
  298. /* Bits common to various processors. */
  299. #define CONF_CU (_ULCAST_(1) << 3)
  300. #define CONF_DB (_ULCAST_(1) << 4)
  301. #define CONF_IB (_ULCAST_(1) << 5)
  302. #define CONF_DC (_ULCAST_(7) << 6)
  303. #define CONF_IC (_ULCAST_(7) << 9)
  304. #define CONF_EB (_ULCAST_(1) << 13)
  305. #define CONF_EM (_ULCAST_(1) << 14)
  306. #define CONF_SM (_ULCAST_(1) << 16)
  307. #define CONF_SC (_ULCAST_(1) << 17)
  308. #define CONF_EW (_ULCAST_(3) << 18)
  309. #define CONF_EP (_ULCAST_(15)<< 24)
  310. #define CONF_EC (_ULCAST_(7) << 28)
  311. #define CONF_CM (_ULCAST_(1) << 31)
  312. /* Bits specific to the R4xx0. */
  313. #define R4K_CONF_SW (_ULCAST_(1) << 20)
  314. #define R4K_CONF_SS (_ULCAST_(1) << 21)
  315. #define R4K_CONF_SB (_ULCAST_(3) << 22)
  316. /* Bits specific to the R5000. */
  317. #define R5K_CONF_SE (_ULCAST_(1) << 12)
  318. #define R5K_CONF_SS (_ULCAST_(3) << 20)
  319. /* Bits specific to the RM7000. */
  320. #define RM7K_CONF_SE (_ULCAST_(1) << 3)
  321. #define RM7K_CONF_TE (_ULCAST_(1) << 12)
  322. #define RM7K_CONF_CLK (_ULCAST_(1) << 16)
  323. #define RM7K_CONF_TC (_ULCAST_(1) << 17)
  324. #define RM7K_CONF_SI (_ULCAST_(3) << 20)
  325. #define RM7K_CONF_SC (_ULCAST_(1) << 31)
  326. /* Bits specific to the R10000. */
  327. #define R10K_CONF_DN (_ULCAST_(3) << 3)
  328. #define R10K_CONF_CT (_ULCAST_(1) << 5)
  329. #define R10K_CONF_PE (_ULCAST_(1) << 6)
  330. #define R10K_CONF_PM (_ULCAST_(3) << 7)
  331. #define R10K_CONF_EC (_ULCAST_(15)<< 9)
  332. #define R10K_CONF_SB (_ULCAST_(1) << 13)
  333. #define R10K_CONF_SK (_ULCAST_(1) << 14)
  334. #define R10K_CONF_SS (_ULCAST_(7) << 16)
  335. #define R10K_CONF_SC (_ULCAST_(7) << 19)
  336. #define R10K_CONF_DC (_ULCAST_(7) << 26)
  337. #define R10K_CONF_IC (_ULCAST_(7) << 29)
  338. /* Bits specific to the VR41xx. */
  339. #define VR41_CONF_CS (_ULCAST_(1) << 12)
  340. #define VR41_CONF_M16 (_ULCAST_(1) << 20)
  341. #define VR41_CONF_AD (_ULCAST_(1) << 23)
  342. /* Bits specific to the R30xx. */
  343. #define R30XX_CONF_FDM (_ULCAST_(1) << 19)
  344. #define R30XX_CONF_REV (_ULCAST_(1) << 22)
  345. #define R30XX_CONF_AC (_ULCAST_(1) << 23)
  346. #define R30XX_CONF_RF (_ULCAST_(1) << 24)
  347. #define R30XX_CONF_HALT (_ULCAST_(1) << 25)
  348. #define R30XX_CONF_FPINT (_ULCAST_(7) << 26)
  349. #define R30XX_CONF_DBR (_ULCAST_(1) << 29)
  350. #define R30XX_CONF_SB (_ULCAST_(1) << 30)
  351. #define R30XX_CONF_LOCK (_ULCAST_(1) << 31)
  352. /* Bits specific to the TX49. */
  353. #define TX49_CONF_DC (_ULCAST_(1) << 16)
  354. #define TX49_CONF_IC (_ULCAST_(1) << 17) /* conflict with CONF_SC */
  355. #define TX49_CONF_HALT (_ULCAST_(1) << 18)
  356. #define TX49_CONF_CWFON (_ULCAST_(1) << 27)
  357. /* Bits specific to the MIPS32/64 PRA. */
  358. #define MIPS_CONF_MT (_ULCAST_(7) << 7)
  359. #define MIPS_CONF_AR (_ULCAST_(7) << 10)
  360. #define MIPS_CONF_AT (_ULCAST_(3) << 13)
  361. #define MIPS_CONF_M (_ULCAST_(1) << 31)
  362. /*
  363. * Bits in the MIPS32/64 PRA coprocessor 0 config registers 1 and above.
  364. */
  365. #define MIPS_CONF1_FP (_ULCAST_(1) << 0)
  366. #define MIPS_CONF1_EP (_ULCAST_(1) << 1)
  367. #define MIPS_CONF1_CA (_ULCAST_(1) << 2)
  368. #define MIPS_CONF1_WR (_ULCAST_(1) << 3)
  369. #define MIPS_CONF1_PC (_ULCAST_(1) << 4)
  370. #define MIPS_CONF1_MD (_ULCAST_(1) << 5)
  371. #define MIPS_CONF1_C2 (_ULCAST_(1) << 6)
  372. #define MIPS_CONF1_DA (_ULCAST_(7) << 7)
  373. #define MIPS_CONF1_DL (_ULCAST_(7) << 10)
  374. #define MIPS_CONF1_DS (_ULCAST_(7) << 13)
  375. #define MIPS_CONF1_IA (_ULCAST_(7) << 16)
  376. #define MIPS_CONF1_IL (_ULCAST_(7) << 19)
  377. #define MIPS_CONF1_IS (_ULCAST_(7) << 22)
  378. #define MIPS_CONF1_TLBS (_ULCAST_(63)<< 25)
  379. #define MIPS_CONF2_SA (_ULCAST_(15)<< 0)
  380. #define MIPS_CONF2_SL (_ULCAST_(15)<< 4)
  381. #define MIPS_CONF2_SS (_ULCAST_(15)<< 8)
  382. #define MIPS_CONF2_SU (_ULCAST_(15)<< 12)
  383. #define MIPS_CONF2_TA (_ULCAST_(15)<< 16)
  384. #define MIPS_CONF2_TL (_ULCAST_(15)<< 20)
  385. #define MIPS_CONF2_TS (_ULCAST_(15)<< 24)
  386. #define MIPS_CONF2_TU (_ULCAST_(7) << 28)
  387. #define MIPS_CONF3_TL (_ULCAST_(1) << 0)
  388. #define MIPS_CONF3_SM (_ULCAST_(1) << 1)
  389. #define MIPS_CONF3_MT (_ULCAST_(1) << 2)
  390. #define MIPS_CONF3_SP (_ULCAST_(1) << 4)
  391. #define MIPS_CONF3_VINT (_ULCAST_(1) << 5)
  392. #define MIPS_CONF3_VEIC (_ULCAST_(1) << 6)
  393. #define MIPS_CONF3_LPA (_ULCAST_(1) << 7)
  394. #define MIPS_CONF3_DSP (_ULCAST_(1) << 10)
  395. /*
  396. * Bits in the MIPS32/64 coprocessor 1 (FPU) revision register.
  397. */
  398. #define MIPS_FPIR_S (_ULCAST_(1) << 16)
  399. #define MIPS_FPIR_D (_ULCAST_(1) << 17)
  400. #define MIPS_FPIR_PS (_ULCAST_(1) << 18)
  401. #define MIPS_FPIR_3D (_ULCAST_(1) << 19)
  402. #define MIPS_FPIR_W (_ULCAST_(1) << 20)
  403. #define MIPS_FPIR_L (_ULCAST_(1) << 21)
  404. #define MIPS_FPIR_F64 (_ULCAST_(1) << 22)
  405. /*
  406. * R10000 performance counter definitions.
  407. *
  408. * FIXME: The R10000 performance counter opens a nice way to implement CPU
  409. * time accounting with a precission of one cycle. I don't have
  410. * R10000 silicon but just a manual, so ...
  411. */
  412. /*
  413. * Events counted by counter #0
  414. */
  415. #define CE0_CYCLES 0
  416. #define CE0_INSN_ISSUED 1
  417. #define CE0_LPSC_ISSUED 2
  418. #define CE0_S_ISSUED 3
  419. #define CE0_SC_ISSUED 4
  420. #define CE0_SC_FAILED 5
  421. #define CE0_BRANCH_DECODED 6
  422. #define CE0_QW_WB_SECONDARY 7
  423. #define CE0_CORRECTED_ECC_ERRORS 8
  424. #define CE0_ICACHE_MISSES 9
  425. #define CE0_SCACHE_I_MISSES 10
  426. #define CE0_SCACHE_I_WAY_MISSPREDICTED 11
  427. #define CE0_EXT_INTERVENTIONS_REQ 12
  428. #define CE0_EXT_INVALIDATE_REQ 13
  429. #define CE0_VIRTUAL_COHERENCY_COND 14
  430. #define CE0_INSN_GRADUATED 15
  431. /*
  432. * Events counted by counter #1
  433. */
  434. #define CE1_CYCLES 0
  435. #define CE1_INSN_GRADUATED 1
  436. #define CE1_LPSC_GRADUATED 2
  437. #define CE1_S_GRADUATED 3
  438. #define CE1_SC_GRADUATED 4
  439. #define CE1_FP_INSN_GRADUATED 5
  440. #define CE1_QW_WB_PRIMARY 6
  441. #define CE1_TLB_REFILL 7
  442. #define CE1_BRANCH_MISSPREDICTED 8
  443. #define CE1_DCACHE_MISS 9
  444. #define CE1_SCACHE_D_MISSES 10
  445. #define CE1_SCACHE_D_WAY_MISSPREDICTED 11
  446. #define CE1_EXT_INTERVENTION_HITS 12
  447. #define CE1_EXT_INVALIDATE_REQ 13
  448. #define CE1_SP_HINT_TO_CEXCL_SC_BLOCKS 14
  449. #define CE1_SP_HINT_TO_SHARED_SC_BLOCKS 15
  450. /*
  451. * These flags define in which privilege mode the counters count events
  452. */
  453. #define CEB_USER 8 /* Count events in user mode, EXL = ERL = 0 */
  454. #define CEB_SUPERVISOR 4 /* Count events in supvervisor mode EXL = ERL = 0 */
  455. #define CEB_KERNEL 2 /* Count events in kernel mode EXL = ERL = 0 */
  456. #define CEB_EXL 1 /* Count events with EXL = 1, ERL = 0 */
  457. #ifndef __ASSEMBLY__
  458. /*
  459. * Macros to access the system control coprocessor
  460. */
  461. #define __read_32bit_c0_register(source, sel) \
  462. ({ int __res; \
  463. if (sel == 0) \
  464. __asm__ __volatile__( \
  465. "mfc0\t%0, " #source "\n\t" \
  466. : "=r" (__res)); \
  467. else \
  468. __asm__ __volatile__( \
  469. ".set\tmips32\n\t" \
  470. "mfc0\t%0, " #source ", " #sel "\n\t" \
  471. ".set\tmips0\n\t" \
  472. : "=r" (__res)); \
  473. __res; \
  474. })
  475. #define __write_32bit_c0_register(register, sel, value) \
  476. do { \
  477. if (sel == 0) \
  478. __asm__ __volatile__( \
  479. "mtc0\t%z0, " #register "\n\t" \
  480. : : "Jr" ((unsigned int)(value))); \
  481. else \
  482. __asm__ __volatile__( \
  483. ".set\tmips32\n\t" \
  484. "mtc0\t%z0, " #register ", " #sel "\n\t" \
  485. ".set\tmips0" \
  486. : : "Jr" ((unsigned int)(value))); \
  487. } while (0)
  488. #define read_c0_index() __read_32bit_c0_register($0, 0)
  489. #define write_c0_index(val) __write_32bit_c0_register($0, 0, val)
  490. #define read_c0_random() __read_32bit_c0_register($1, 0)
  491. #define write_c0_random(val) __write_32bit_c0_register($1, 0, val)
  492. #define read_c0_entrylo0() __read_32bit_c0_register($2, 0)
  493. #define write_c0_entrylo0(val) __write_32bit_c0_register($2, 0, val)
  494. #define read_c0_entrylo1() __read_32bit_c0_register($3, 0)
  495. #define write_c0_entrylo1(val) __write_32bit_c0_register($3, 0, val)
  496. #define read_c0_conf() __read_32bit_c0_register($3, 0)
  497. #define write_c0_conf(val) __write_32bit_c0_register($3, 0, val)
  498. #define read_c0_context() __read_32bit_c0_register($4, 0)
  499. #define write_c0_context(val) __write_32bit_c0_register($4, 0, val)
  500. #define read_c0_userlocal() __read_32bit_c0_register($4, 2)
  501. #define write_c0_userlocal(val) __write_32bit_c0_register($4, 2, val)
  502. #define read_c0_pagemask() __read_32bit_c0_register($5, 0)
  503. #define write_c0_pagemask(val) __write_32bit_c0_register($5, 0, val)
  504. #define read_c0_wired() __read_32bit_c0_register($6, 0)
  505. #define write_c0_wired(val) __write_32bit_c0_register($6, 0, val)
  506. #define read_c0_info() __read_32bit_c0_register($7, 0)
  507. #define read_c0_cache() __read_32bit_c0_register($7, 0) /* TX39xx */
  508. #define write_c0_cache(val) __write_32bit_c0_register($7, 0, val)
  509. #define read_c0_badvaddr() __read_32bit_c0_register($8, 0)
  510. #define write_c0_badvaddr(val) __write_32bit_c0_register($8, 0, val)
  511. #define read_c0_count() __read_32bit_c0_register($9, 0)
  512. #define write_c0_count(val) __write_32bit_c0_register($9, 0, val)
  513. #define read_c0_count2() __read_32bit_c0_register($9, 6) /* pnx8550 */
  514. #define write_c0_count2(val) __write_32bit_c0_register($9, 6, val)
  515. #define read_c0_count3() __read_32bit_c0_register($9, 7) /* pnx8550 */
  516. #define write_c0_count3(val) __write_32bit_c0_register($9, 7, val)
  517. #define read_c0_entryhi() __read_32bit_c0_register($10, 0)
  518. #define write_c0_entryhi(val) __write_32bit_c0_register($10, 0, val)
  519. #define read_c0_compare() __read_32bit_c0_register($11, 0)
  520. #define write_c0_compare(val) __write_32bit_c0_register($11, 0, val)
  521. #define read_c0_compare2() __read_32bit_c0_register($11, 6) /* pnx8550 */
  522. #define write_c0_compare2(val) __write_32bit_c0_register($11, 6, val)
  523. #define read_c0_compare3() __read_32bit_c0_register($11, 7) /* pnx8550 */
  524. #define write_c0_compare3(val) __write_32bit_c0_register($11, 7, val)
  525. #define read_c0_status() __read_32bit_c0_register($12, 0)
  526. #define write_c0_status(val) __write_32bit_c0_register($12, 0, val)
  527. #define read_c0_cause() __read_32bit_c0_register($13, 0)
  528. #define write_c0_cause(val) __write_32bit_c0_register($13, 0, val)
  529. #define read_c0_epc() __read_32bit_c0_register($14, 0)
  530. #define write_c0_epc(val) __write_32bit_c0_register($14, 0, val)
  531. #define read_c0_prid() __read_32bit_c0_register($15, 0)
  532. #define read_c0_ebase() __read_32bit_c0_register($15, 1)
  533. #define write_c0_ebase(val) __write_32bit_c0_register($15, 1, val)
  534. #define read_c0_config() __read_32bit_c0_register($16, 0)
  535. #define read_c0_config1() __read_32bit_c0_register($16, 1)
  536. #define read_c0_config2() __read_32bit_c0_register($16, 2)
  537. #define read_c0_config3() __read_32bit_c0_register($16, 3)
  538. #define write_c0_config(val) __write_32bit_c0_register($16, 0, val)
  539. #define write_c0_config1(val) __write_32bit_c0_register($16, 1, val)
  540. #define write_c0_config2(val) __write_32bit_c0_register($16, 2, val)
  541. #define write_c0_config3(val) __write_32bit_c0_register($16, 3, val)
  542. #endif /* end of __ASSEMBLY__ */
  543. #endif /* end of __MIPSREGS_H__ */