mipsregs.h 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706
  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. * FPU Status Register Values
  111. */
  112. /*
  113. * Status Register Values
  114. */
  115. #define FPU_CSR_FLUSH 0x01000000 /* flush denormalised results to 0 */
  116. #define FPU_CSR_COND 0x00800000 /* $fcc0 */
  117. #define FPU_CSR_COND0 0x00800000 /* $fcc0 */
  118. #define FPU_CSR_COND1 0x02000000 /* $fcc1 */
  119. #define FPU_CSR_COND2 0x04000000 /* $fcc2 */
  120. #define FPU_CSR_COND3 0x08000000 /* $fcc3 */
  121. #define FPU_CSR_COND4 0x10000000 /* $fcc4 */
  122. #define FPU_CSR_COND5 0x20000000 /* $fcc5 */
  123. #define FPU_CSR_COND6 0x40000000 /* $fcc6 */
  124. #define FPU_CSR_COND7 0x80000000 /* $fcc7 */
  125. /* FS/FO/FN */
  126. #define FPU_CSR_FS 0x01000000
  127. #define FPU_CSR_FO 0x00400000
  128. #define FPU_CSR_FN 0x00200000
  129. /*
  130. * Bits 18 - 20 of the FPU Status Register will be read as 0,
  131. * and should be written as zero.
  132. */
  133. #define FPU_CSR_RSVD 0x001c0000
  134. /*
  135. * X the exception cause indicator
  136. * E the exception enable
  137. * S the sticky/flag bit
  138. */
  139. #define FPU_CSR_ALL_X 0x0003f000
  140. #define FPU_CSR_UNI_X 0x00020000
  141. #define FPU_CSR_INV_X 0x00010000
  142. #define FPU_CSR_DIV_X 0x00008000
  143. #define FPU_CSR_OVF_X 0x00004000
  144. #define FPU_CSR_UDF_X 0x00002000
  145. #define FPU_CSR_INE_X 0x00001000
  146. #define FPU_CSR_ALL_E 0x00000f80
  147. #define FPU_CSR_INV_E 0x00000800
  148. #define FPU_CSR_DIV_E 0x00000400
  149. #define FPU_CSR_OVF_E 0x00000200
  150. #define FPU_CSR_UDF_E 0x00000100
  151. #define FPU_CSR_INE_E 0x00000080
  152. #define FPU_CSR_ALL_S 0x0000007c
  153. #define FPU_CSR_INV_S 0x00000040
  154. #define FPU_CSR_DIV_S 0x00000020
  155. #define FPU_CSR_OVF_S 0x00000010
  156. #define FPU_CSR_UDF_S 0x00000008
  157. #define FPU_CSR_INE_S 0x00000004
  158. /* Bits 0 and 1 of FPU Status Register specify the rounding mode */
  159. #define FPU_CSR_RM 0x00000003
  160. #define FPU_CSR_RN 0x0 /* nearest */
  161. #define FPU_CSR_RZ 0x1 /* towards zero */
  162. #define FPU_CSR_RU 0x2 /* towards +Infinity */
  163. #define FPU_CSR_RD 0x3 /* towards -Infinity */
  164. /*
  165. * R4x00 interrupt enable / cause bits
  166. */
  167. #define IE_SW0 (_ULCAST_(1) << 8)
  168. #define IE_SW1 (_ULCAST_(1) << 9)
  169. #define IE_IRQ0 (_ULCAST_(1) << 10)
  170. #define IE_IRQ1 (_ULCAST_(1) << 11)
  171. #define IE_IRQ2 (_ULCAST_(1) << 12)
  172. #define IE_IRQ3 (_ULCAST_(1) << 13)
  173. #define IE_IRQ4 (_ULCAST_(1) << 14)
  174. #define IE_IRQ5 (_ULCAST_(1) << 15)
  175. /*
  176. * R4x00 interrupt cause bits
  177. */
  178. #define C_SW0 (_ULCAST_(1) << 8)
  179. #define C_SW1 (_ULCAST_(1) << 9)
  180. #define C_IRQ0 (_ULCAST_(1) << 10)
  181. #define C_IRQ1 (_ULCAST_(1) << 11)
  182. #define C_IRQ2 (_ULCAST_(1) << 12)
  183. #define C_IRQ3 (_ULCAST_(1) << 13)
  184. #define C_IRQ4 (_ULCAST_(1) << 14)
  185. #define C_IRQ5 (_ULCAST_(1) << 15)
  186. /*
  187. * Bitfields in the R4xx0 cp0 status register
  188. */
  189. #define ST0_IE 0x00000001
  190. #define ST0_EXL 0x00000002
  191. #define ST0_ERL 0x00000004
  192. #define ST0_KSU 0x00000018
  193. # define KSU_USER 0x00000010
  194. # define KSU_SUPERVISOR 0x00000008
  195. # define KSU_KERNEL 0x00000000
  196. #define ST0_UX 0x00000020
  197. #define ST0_SX 0x00000040
  198. #define ST0_KX 0x00000080
  199. #define ST0_DE 0x00010000
  200. #define ST0_CE 0x00020000
  201. /*
  202. * Setting c0_status.co enables Hit_Writeback and Hit_Writeback_Invalidate
  203. * cacheops in userspace. This bit exists only on RM7000 and RM9000
  204. * processors.
  205. */
  206. #define ST0_CO 0x08000000
  207. /*
  208. * Bitfields in the R[23]000 cp0 status register.
  209. */
  210. #define ST0_IEC 0x00000001
  211. #define ST0_KUC 0x00000002
  212. #define ST0_IEP 0x00000004
  213. #define ST0_KUP 0x00000008
  214. #define ST0_IEO 0x00000010
  215. #define ST0_KUO 0x00000020
  216. /* bits 6 & 7 are reserved on R[23]000 */
  217. #define ST0_ISC 0x00010000
  218. #define ST0_SWC 0x00020000
  219. #define ST0_CM 0x00080000
  220. /*
  221. * Bits specific to the R4640/R4650
  222. */
  223. #define ST0_UM (_ULCAST_(1) << 4)
  224. #define ST0_IL (_ULCAST_(1) << 23)
  225. #define ST0_DL (_ULCAST_(1) << 24)
  226. /*
  227. * Enable the MIPS DSP ASE
  228. */
  229. #define ST0_MX 0x01000000
  230. /*
  231. * Bitfields in the TX39 family CP0 Configuration Register 3
  232. */
  233. #define TX39_CONF_ICS_SHIFT 19
  234. #define TX39_CONF_ICS_MASK 0x00380000
  235. #define TX39_CONF_ICS_1KB 0x00000000
  236. #define TX39_CONF_ICS_2KB 0x00080000
  237. #define TX39_CONF_ICS_4KB 0x00100000
  238. #define TX39_CONF_ICS_8KB 0x00180000
  239. #define TX39_CONF_ICS_16KB 0x00200000
  240. #define TX39_CONF_DCS_SHIFT 16
  241. #define TX39_CONF_DCS_MASK 0x00070000
  242. #define TX39_CONF_DCS_1KB 0x00000000
  243. #define TX39_CONF_DCS_2KB 0x00010000
  244. #define TX39_CONF_DCS_4KB 0x00020000
  245. #define TX39_CONF_DCS_8KB 0x00030000
  246. #define TX39_CONF_DCS_16KB 0x00040000
  247. #define TX39_CONF_CWFON 0x00004000
  248. #define TX39_CONF_WBON 0x00002000
  249. #define TX39_CONF_RF_SHIFT 10
  250. #define TX39_CONF_RF_MASK 0x00000c00
  251. #define TX39_CONF_DOZE 0x00000200
  252. #define TX39_CONF_HALT 0x00000100
  253. #define TX39_CONF_LOCK 0x00000080
  254. #define TX39_CONF_ICE 0x00000020
  255. #define TX39_CONF_DCE 0x00000010
  256. #define TX39_CONF_IRSIZE_SHIFT 2
  257. #define TX39_CONF_IRSIZE_MASK 0x0000000c
  258. #define TX39_CONF_DRSIZE_SHIFT 0
  259. #define TX39_CONF_DRSIZE_MASK 0x00000003
  260. /*
  261. * Status register bits available in all MIPS CPUs.
  262. */
  263. #define ST0_IM 0x0000ff00
  264. #define STATUSB_IP0 8
  265. #define STATUSF_IP0 (_ULCAST_(1) << 8)
  266. #define STATUSB_IP1 9
  267. #define STATUSF_IP1 (_ULCAST_(1) << 9)
  268. #define STATUSB_IP2 10
  269. #define STATUSF_IP2 (_ULCAST_(1) << 10)
  270. #define STATUSB_IP3 11
  271. #define STATUSF_IP3 (_ULCAST_(1) << 11)
  272. #define STATUSB_IP4 12
  273. #define STATUSF_IP4 (_ULCAST_(1) << 12)
  274. #define STATUSB_IP5 13
  275. #define STATUSF_IP5 (_ULCAST_(1) << 13)
  276. #define STATUSB_IP6 14
  277. #define STATUSF_IP6 (_ULCAST_(1) << 14)
  278. #define STATUSB_IP7 15
  279. #define STATUSF_IP7 (_ULCAST_(1) << 15)
  280. #define STATUSB_IP8 0
  281. #define STATUSF_IP8 (_ULCAST_(1) << 0)
  282. #define STATUSB_IP9 1
  283. #define STATUSF_IP9 (_ULCAST_(1) << 1)
  284. #define STATUSB_IP10 2
  285. #define STATUSF_IP10 (_ULCAST_(1) << 2)
  286. #define STATUSB_IP11 3
  287. #define STATUSF_IP11 (_ULCAST_(1) << 3)
  288. #define STATUSB_IP12 4
  289. #define STATUSF_IP12 (_ULCAST_(1) << 4)
  290. #define STATUSB_IP13 5
  291. #define STATUSF_IP13 (_ULCAST_(1) << 5)
  292. #define STATUSB_IP14 6
  293. #define STATUSF_IP14 (_ULCAST_(1) << 6)
  294. #define STATUSB_IP15 7
  295. #define STATUSF_IP15 (_ULCAST_(1) << 7)
  296. #define ST0_CH 0x00040000
  297. #define ST0_SR 0x00100000
  298. #define ST0_TS 0x00200000
  299. #define ST0_BEV 0x00400000
  300. #define ST0_RE 0x02000000
  301. #define ST0_FR 0x04000000
  302. #define ST0_CU 0xf0000000
  303. #define ST0_CU0 0x10000000
  304. #define ST0_CU1 0x20000000
  305. #define ST0_CU2 0x40000000
  306. #define ST0_CU3 0x80000000
  307. #define ST0_XX 0x80000000 /* MIPS IV naming */
  308. /*
  309. * Bitfields and bit numbers in the coprocessor 0 cause register.
  310. *
  311. * Refer to your MIPS R4xx0 manual, chapter 5 for explanation.
  312. */
  313. #define CAUSEB_EXCCODE 2
  314. #define CAUSEF_EXCCODE (_ULCAST_(31) << 2)
  315. #define CAUSEB_IP 8
  316. #define CAUSEF_IP (_ULCAST_(255) << 8)
  317. #define CAUSEB_IP0 8
  318. #define CAUSEF_IP0 (_ULCAST_(1) << 8)
  319. #define CAUSEB_IP1 9
  320. #define CAUSEF_IP1 (_ULCAST_(1) << 9)
  321. #define CAUSEB_IP2 10
  322. #define CAUSEF_IP2 (_ULCAST_(1) << 10)
  323. #define CAUSEB_IP3 11
  324. #define CAUSEF_IP3 (_ULCAST_(1) << 11)
  325. #define CAUSEB_IP4 12
  326. #define CAUSEF_IP4 (_ULCAST_(1) << 12)
  327. #define CAUSEB_IP5 13
  328. #define CAUSEF_IP5 (_ULCAST_(1) << 13)
  329. #define CAUSEB_IP6 14
  330. #define CAUSEF_IP6 (_ULCAST_(1) << 14)
  331. #define CAUSEB_IP7 15
  332. #define CAUSEF_IP7 (_ULCAST_(1) << 15)
  333. #define CAUSEB_IV 23
  334. #define CAUSEF_IV (_ULCAST_(1) << 23)
  335. #define CAUSEB_CE 28
  336. #define CAUSEF_CE (_ULCAST_(3) << 28)
  337. #define CAUSEB_BD 31
  338. #define CAUSEF_BD (_ULCAST_(1) << 31)
  339. /*
  340. * Bits in the coprocessor 0 config register.
  341. */
  342. /* Generic bits. */
  343. #define CONF_CM_CACHABLE_NO_WA 0
  344. #define CONF_CM_CACHABLE_WA 1
  345. #define CONF_CM_UNCACHED 2
  346. #define CONF_CM_CACHABLE_NONCOHERENT 3
  347. #define CONF_CM_CACHABLE_CE 4
  348. #define CONF_CM_CACHABLE_COW 5
  349. #define CONF_CM_CACHABLE_CUW 6
  350. #define CONF_CM_CACHABLE_ACCELERATED 7
  351. #define CONF_CM_CMASK 7
  352. #define CONF_BE (_ULCAST_(1) << 15)
  353. /* Bits common to various processors. */
  354. #define CONF_CU (_ULCAST_(1) << 3)
  355. #define CONF_DB (_ULCAST_(1) << 4)
  356. #define CONF_IB (_ULCAST_(1) << 5)
  357. #define CONF_DC (_ULCAST_(7) << 6)
  358. #define CONF_IC (_ULCAST_(7) << 9)
  359. #define CONF_EB (_ULCAST_(1) << 13)
  360. #define CONF_EM (_ULCAST_(1) << 14)
  361. #define CONF_SM (_ULCAST_(1) << 16)
  362. #define CONF_SC (_ULCAST_(1) << 17)
  363. #define CONF_EW (_ULCAST_(3) << 18)
  364. #define CONF_EP (_ULCAST_(15)<< 24)
  365. #define CONF_EC (_ULCAST_(7) << 28)
  366. #define CONF_CM (_ULCAST_(1) << 31)
  367. /* Bits specific to the R4xx0. */
  368. #define R4K_CONF_SW (_ULCAST_(1) << 20)
  369. #define R4K_CONF_SS (_ULCAST_(1) << 21)
  370. #define R4K_CONF_SB (_ULCAST_(3) << 22)
  371. /* Bits specific to the R5000. */
  372. #define R5K_CONF_SE (_ULCAST_(1) << 12)
  373. #define R5K_CONF_SS (_ULCAST_(3) << 20)
  374. /* Bits specific to the RM7000. */
  375. #define RM7K_CONF_SE (_ULCAST_(1) << 3)
  376. #define RM7K_CONF_TE (_ULCAST_(1) << 12)
  377. #define RM7K_CONF_CLK (_ULCAST_(1) << 16)
  378. #define RM7K_CONF_TC (_ULCAST_(1) << 17)
  379. #define RM7K_CONF_SI (_ULCAST_(3) << 20)
  380. #define RM7K_CONF_SC (_ULCAST_(1) << 31)
  381. /* Bits specific to the R10000. */
  382. #define R10K_CONF_DN (_ULCAST_(3) << 3)
  383. #define R10K_CONF_CT (_ULCAST_(1) << 5)
  384. #define R10K_CONF_PE (_ULCAST_(1) << 6)
  385. #define R10K_CONF_PM (_ULCAST_(3) << 7)
  386. #define R10K_CONF_EC (_ULCAST_(15)<< 9)
  387. #define R10K_CONF_SB (_ULCAST_(1) << 13)
  388. #define R10K_CONF_SK (_ULCAST_(1) << 14)
  389. #define R10K_CONF_SS (_ULCAST_(7) << 16)
  390. #define R10K_CONF_SC (_ULCAST_(7) << 19)
  391. #define R10K_CONF_DC (_ULCAST_(7) << 26)
  392. #define R10K_CONF_IC (_ULCAST_(7) << 29)
  393. /* Bits specific to the VR41xx. */
  394. #define VR41_CONF_CS (_ULCAST_(1) << 12)
  395. #define VR41_CONF_M16 (_ULCAST_(1) << 20)
  396. #define VR41_CONF_AD (_ULCAST_(1) << 23)
  397. /* Bits specific to the R30xx. */
  398. #define R30XX_CONF_FDM (_ULCAST_(1) << 19)
  399. #define R30XX_CONF_REV (_ULCAST_(1) << 22)
  400. #define R30XX_CONF_AC (_ULCAST_(1) << 23)
  401. #define R30XX_CONF_RF (_ULCAST_(1) << 24)
  402. #define R30XX_CONF_HALT (_ULCAST_(1) << 25)
  403. #define R30XX_CONF_FPINT (_ULCAST_(7) << 26)
  404. #define R30XX_CONF_DBR (_ULCAST_(1) << 29)
  405. #define R30XX_CONF_SB (_ULCAST_(1) << 30)
  406. #define R30XX_CONF_LOCK (_ULCAST_(1) << 31)
  407. /* Bits specific to the TX49. */
  408. #define TX49_CONF_DC (_ULCAST_(1) << 16)
  409. #define TX49_CONF_IC (_ULCAST_(1) << 17) /* conflict with CONF_SC */
  410. #define TX49_CONF_HALT (_ULCAST_(1) << 18)
  411. #define TX49_CONF_CWFON (_ULCAST_(1) << 27)
  412. /* Bits specific to the MIPS32/64 PRA. */
  413. #define MIPS_CONF_MT (_ULCAST_(7) << 7)
  414. #define MIPS_CONF_AR (_ULCAST_(7) << 10)
  415. #define MIPS_CONF_AT (_ULCAST_(3) << 13)
  416. #define MIPS_CONF_M (_ULCAST_(1) << 31)
  417. /*
  418. * Bits in the MIPS32/64 PRA coprocessor 0 config registers 1 and above.
  419. */
  420. #define MIPS_CONF1_FP (_ULCAST_(1) << 0)
  421. #define MIPS_CONF1_EP (_ULCAST_(1) << 1)
  422. #define MIPS_CONF1_CA (_ULCAST_(1) << 2)
  423. #define MIPS_CONF1_WR (_ULCAST_(1) << 3)
  424. #define MIPS_CONF1_PC (_ULCAST_(1) << 4)
  425. #define MIPS_CONF1_MD (_ULCAST_(1) << 5)
  426. #define MIPS_CONF1_C2 (_ULCAST_(1) << 6)
  427. #define MIPS_CONF1_DA (_ULCAST_(7) << 7)
  428. #define MIPS_CONF1_DL (_ULCAST_(7) << 10)
  429. #define MIPS_CONF1_DS (_ULCAST_(7) << 13)
  430. #define MIPS_CONF1_IA (_ULCAST_(7) << 16)
  431. #define MIPS_CONF1_IL (_ULCAST_(7) << 19)
  432. #define MIPS_CONF1_IS (_ULCAST_(7) << 22)
  433. #define MIPS_CONF1_TLBS (_ULCAST_(63)<< 25)
  434. #define MIPS_CONF2_SA (_ULCAST_(15)<< 0)
  435. #define MIPS_CONF2_SL (_ULCAST_(15)<< 4)
  436. #define MIPS_CONF2_SS (_ULCAST_(15)<< 8)
  437. #define MIPS_CONF2_SU (_ULCAST_(15)<< 12)
  438. #define MIPS_CONF2_TA (_ULCAST_(15)<< 16)
  439. #define MIPS_CONF2_TL (_ULCAST_(15)<< 20)
  440. #define MIPS_CONF2_TS (_ULCAST_(15)<< 24)
  441. #define MIPS_CONF2_TU (_ULCAST_(7) << 28)
  442. #define MIPS_CONF3_TL (_ULCAST_(1) << 0)
  443. #define MIPS_CONF3_SM (_ULCAST_(1) << 1)
  444. #define MIPS_CONF3_MT (_ULCAST_(1) << 2)
  445. #define MIPS_CONF3_SP (_ULCAST_(1) << 4)
  446. #define MIPS_CONF3_VINT (_ULCAST_(1) << 5)
  447. #define MIPS_CONF3_VEIC (_ULCAST_(1) << 6)
  448. #define MIPS_CONF3_LPA (_ULCAST_(1) << 7)
  449. #define MIPS_CONF3_DSP (_ULCAST_(1) << 10)
  450. /*
  451. * Bits in the MIPS32/64 coprocessor 1 (FPU) revision register.
  452. */
  453. #define MIPS_FPIR_S (_ULCAST_(1) << 16)
  454. #define MIPS_FPIR_D (_ULCAST_(1) << 17)
  455. #define MIPS_FPIR_PS (_ULCAST_(1) << 18)
  456. #define MIPS_FPIR_3D (_ULCAST_(1) << 19)
  457. #define MIPS_FPIR_W (_ULCAST_(1) << 20)
  458. #define MIPS_FPIR_L (_ULCAST_(1) << 21)
  459. #define MIPS_FPIR_F64 (_ULCAST_(1) << 22)
  460. /*
  461. * R10000 performance counter definitions.
  462. *
  463. * FIXME: The R10000 performance counter opens a nice way to implement CPU
  464. * time accounting with a precission of one cycle. I don't have
  465. * R10000 silicon but just a manual, so ...
  466. */
  467. /*
  468. * Events counted by counter #0
  469. */
  470. #define CE0_CYCLES 0
  471. #define CE0_INSN_ISSUED 1
  472. #define CE0_LPSC_ISSUED 2
  473. #define CE0_S_ISSUED 3
  474. #define CE0_SC_ISSUED 4
  475. #define CE0_SC_FAILED 5
  476. #define CE0_BRANCH_DECODED 6
  477. #define CE0_QW_WB_SECONDARY 7
  478. #define CE0_CORRECTED_ECC_ERRORS 8
  479. #define CE0_ICACHE_MISSES 9
  480. #define CE0_SCACHE_I_MISSES 10
  481. #define CE0_SCACHE_I_WAY_MISSPREDICTED 11
  482. #define CE0_EXT_INTERVENTIONS_REQ 12
  483. #define CE0_EXT_INVALIDATE_REQ 13
  484. #define CE0_VIRTUAL_COHERENCY_COND 14
  485. #define CE0_INSN_GRADUATED 15
  486. /*
  487. * Events counted by counter #1
  488. */
  489. #define CE1_CYCLES 0
  490. #define CE1_INSN_GRADUATED 1
  491. #define CE1_LPSC_GRADUATED 2
  492. #define CE1_S_GRADUATED 3
  493. #define CE1_SC_GRADUATED 4
  494. #define CE1_FP_INSN_GRADUATED 5
  495. #define CE1_QW_WB_PRIMARY 6
  496. #define CE1_TLB_REFILL 7
  497. #define CE1_BRANCH_MISSPREDICTED 8
  498. #define CE1_DCACHE_MISS 9
  499. #define CE1_SCACHE_D_MISSES 10
  500. #define CE1_SCACHE_D_WAY_MISSPREDICTED 11
  501. #define CE1_EXT_INTERVENTION_HITS 12
  502. #define CE1_EXT_INVALIDATE_REQ 13
  503. #define CE1_SP_HINT_TO_CEXCL_SC_BLOCKS 14
  504. #define CE1_SP_HINT_TO_SHARED_SC_BLOCKS 15
  505. /*
  506. * These flags define in which privilege mode the counters count events
  507. */
  508. #define CEB_USER 8 /* Count events in user mode, EXL = ERL = 0 */
  509. #define CEB_SUPERVISOR 4 /* Count events in supvervisor mode EXL = ERL = 0 */
  510. #define CEB_KERNEL 2 /* Count events in kernel mode EXL = ERL = 0 */
  511. #define CEB_EXL 1 /* Count events with EXL = 1, ERL = 0 */
  512. #ifndef __ASSEMBLY__
  513. /*
  514. * Macros to access the system control coprocessor
  515. */
  516. #define __read_32bit_c0_register(source, sel) \
  517. ({ int __res; \
  518. if (sel == 0) \
  519. __asm__ __volatile__( \
  520. "mfc0\t%0, " #source "\n\t" \
  521. : "=r" (__res)); \
  522. else \
  523. __asm__ __volatile__( \
  524. ".set\tmips32\n\t" \
  525. "mfc0\t%0, " #source ", " #sel "\n\t" \
  526. ".set\tmips0\n\t" \
  527. : "=r" (__res)); \
  528. __res; \
  529. })
  530. #define __write_32bit_c0_register(register, sel, value) \
  531. do { \
  532. if (sel == 0) \
  533. __asm__ __volatile__( \
  534. "mtc0\t%z0, " #register "\n\t" \
  535. : : "Jr" ((unsigned int)(value))); \
  536. else \
  537. __asm__ __volatile__( \
  538. ".set\tmips32\n\t" \
  539. "mtc0\t%z0, " #register ", " #sel "\n\t" \
  540. ".set\tmips0" \
  541. : : "Jr" ((unsigned int)(value))); \
  542. } while (0)
  543. #define read_c0_index() __read_32bit_c0_register($0, 0)
  544. #define write_c0_index(val) __write_32bit_c0_register($0, 0, val)
  545. #define read_c0_random() __read_32bit_c0_register($1, 0)
  546. #define write_c0_random(val) __write_32bit_c0_register($1, 0, val)
  547. #define read_c0_entrylo0() __read_32bit_c0_register($2, 0)
  548. #define write_c0_entrylo0(val) __write_32bit_c0_register($2, 0, val)
  549. #define read_c0_entrylo1() __read_32bit_c0_register($3, 0)
  550. #define write_c0_entrylo1(val) __write_32bit_c0_register($3, 0, val)
  551. #define read_c0_conf() __read_32bit_c0_register($3, 0)
  552. #define write_c0_conf(val) __write_32bit_c0_register($3, 0, val)
  553. #define read_c0_context() __read_32bit_c0_register($4, 0)
  554. #define write_c0_context(val) __write_32bit_c0_register($4, 0, val)
  555. #define read_c0_userlocal() __read_32bit_c0_register($4, 2)
  556. #define write_c0_userlocal(val) __write_32bit_c0_register($4, 2, val)
  557. #define read_c0_pagemask() __read_32bit_c0_register($5, 0)
  558. #define write_c0_pagemask(val) __write_32bit_c0_register($5, 0, val)
  559. #define read_c0_wired() __read_32bit_c0_register($6, 0)
  560. #define write_c0_wired(val) __write_32bit_c0_register($6, 0, val)
  561. #define read_c0_info() __read_32bit_c0_register($7, 0)
  562. #define read_c0_cache() __read_32bit_c0_register($7, 0) /* TX39xx */
  563. #define write_c0_cache(val) __write_32bit_c0_register($7, 0, val)
  564. #define read_c0_badvaddr() __read_32bit_c0_register($8, 0)
  565. #define write_c0_badvaddr(val) __write_32bit_c0_register($8, 0, val)
  566. #define read_c0_count() __read_32bit_c0_register($9, 0)
  567. #define write_c0_count(val) __write_32bit_c0_register($9, 0, val)
  568. #define read_c0_count2() __read_32bit_c0_register($9, 6) /* pnx8550 */
  569. #define write_c0_count2(val) __write_32bit_c0_register($9, 6, val)
  570. #define read_c0_count3() __read_32bit_c0_register($9, 7) /* pnx8550 */
  571. #define write_c0_count3(val) __write_32bit_c0_register($9, 7, val)
  572. #define read_c0_entryhi() __read_32bit_c0_register($10, 0)
  573. #define write_c0_entryhi(val) __write_32bit_c0_register($10, 0, val)
  574. #define read_c0_compare() __read_32bit_c0_register($11, 0)
  575. #define write_c0_compare(val) __write_32bit_c0_register($11, 0, val)
  576. #define read_c0_compare2() __read_32bit_c0_register($11, 6) /* pnx8550 */
  577. #define write_c0_compare2(val) __write_32bit_c0_register($11, 6, val)
  578. #define read_c0_compare3() __read_32bit_c0_register($11, 7) /* pnx8550 */
  579. #define write_c0_compare3(val) __write_32bit_c0_register($11, 7, val)
  580. #define read_c0_status() __read_32bit_c0_register($12, 0)
  581. #define write_c0_status(val) __write_32bit_c0_register($12, 0, val)
  582. #define read_c0_cause() __read_32bit_c0_register($13, 0)
  583. #define write_c0_cause(val) __write_32bit_c0_register($13, 0, val)
  584. #define read_c0_epc() __read_32bit_c0_register($14, 0)
  585. #define write_c0_epc(val) __write_32bit_c0_register($14, 0, val)
  586. #define read_c0_prid() __read_32bit_c0_register($15, 0)
  587. #define read_c0_ebase() __read_32bit_c0_register($15, 1)
  588. #define write_c0_ebase(val) __write_32bit_c0_register($15, 1, val)
  589. #define read_c0_config() __read_32bit_c0_register($16, 0)
  590. #define read_c0_config1() __read_32bit_c0_register($16, 1)
  591. #define read_c0_config2() __read_32bit_c0_register($16, 2)
  592. #define read_c0_config3() __read_32bit_c0_register($16, 3)
  593. #define write_c0_config(val) __write_32bit_c0_register($16, 0, val)
  594. #define write_c0_config1(val) __write_32bit_c0_register($16, 1, val)
  595. #define write_c0_config2(val) __write_32bit_c0_register($16, 2, val)
  596. #define write_c0_config3(val) __write_32bit_c0_register($16, 3, val)
  597. /*
  598. * Macros to access the floating point coprocessor control registers
  599. */
  600. #define read_32bit_cp1_register(source) \
  601. ({ int __res; \
  602. __asm__ __volatile__( \
  603. ".set\tpush\n\t" \
  604. ".set\treorder\n\t" \
  605. /* gas fails to assemble cfc1 for some archs (octeon).*/ \
  606. ".set\tmips1\n\t" \
  607. "cfc1\t%0,"STR(source)"\n\t" \
  608. ".set\tpop" \
  609. : "=r" (__res)); \
  610. __res;})
  611. #define write_32bit_cp1_register(register, value) \
  612. do { \
  613. __asm__ __volatile__( \
  614. "ctc1\t%z0, "STR(register)"\n\t" \
  615. : : "Jr" ((unsigned int)(value))); \
  616. } while (0)
  617. #define read_c1_status() read_32bit_cp1_register(CP1_STATUS)
  618. #define read_c1_revision() read_32bit_cp1_register(CP1_REVISION);
  619. #define write_c1_status(val) write_32bit_cp1_register(CP1_STATUS, val)
  620. #endif /* end of __ASSEMBLY__ */
  621. #endif /* end of __MIPSREGS_H__ */