mipsregs.h 39 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370
  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. #ifndef _ASM_MIPSREGS_H
  14. #define _ASM_MIPSREGS_H
  15. #if 0
  16. #include <linux/linkage.h>
  17. #endif
  18. /*
  19. * The following macros are especially useful for __asm__
  20. * inline assembler.
  21. */
  22. #ifndef __STR
  23. #define __STR(x) #x
  24. #endif
  25. #ifndef STR
  26. #define STR(x) __STR(x)
  27. #endif
  28. /*
  29. * Configure language
  30. */
  31. #ifdef __ASSEMBLY__
  32. #define _ULCAST_
  33. #else
  34. #define _ULCAST_ (unsigned long)
  35. #endif
  36. /*
  37. * Coprocessor 0 register names
  38. */
  39. #define CP0_INDEX $0
  40. #define CP0_RANDOM $1
  41. #define CP0_ENTRYLO0 $2
  42. #define CP0_ENTRYLO1 $3
  43. #define CP0_CONF $3
  44. #define CP0_CONTEXT $4
  45. #define CP0_PAGEMASK $5
  46. #define CP0_WIRED $6
  47. #define CP0_INFO $7
  48. #define CP0_BADVADDR $8
  49. #define CP0_COUNT $9
  50. #define CP0_ENTRYHI $10
  51. #define CP0_COMPARE $11
  52. #define CP0_STATUS $12
  53. #define CP0_CAUSE $13
  54. #define CP0_EPC $14
  55. #define CP0_PRID $15
  56. #define CP0_CONFIG $16
  57. #define CP0_LLADDR $17
  58. #define CP0_WATCHLO $18
  59. #define CP0_WATCHHI $19
  60. #define CP0_XCONTEXT $20
  61. #define CP0_FRAMEMASK $21
  62. #define CP0_DIAGNOSTIC $22
  63. #define CP0_DEBUG $23
  64. #define CP0_DEPC $24
  65. #define CP0_PERFORMANCE $25
  66. #define CP0_ECC $26
  67. #define CP0_CACHEERR $27
  68. #define CP0_TAGLO $28
  69. #define CP0_TAGHI $29
  70. #define CP0_ERROREPC $30
  71. #define CP0_DESAVE $31
  72. /*
  73. * R4640/R4650 cp0 register names. These registers are listed
  74. * here only for completeness; without MMU these CPUs are not useable
  75. * by Linux. A future ELKS port might take make Linux run on them
  76. * though ...
  77. */
  78. #define CP0_IBASE $0
  79. #define CP0_IBOUND $1
  80. #define CP0_DBASE $2
  81. #define CP0_DBOUND $3
  82. #define CP0_CALG $17
  83. #define CP0_IWATCH $18
  84. #define CP0_DWATCH $19
  85. /*
  86. * Coprocessor 0 Set 1 register names
  87. */
  88. #define CP0_S1_DERRADDR0 $26
  89. #define CP0_S1_DERRADDR1 $27
  90. #define CP0_S1_INTCONTROL $20
  91. /*
  92. * Coprocessor 0 Set 2 register names
  93. */
  94. #define CP0_S2_SRSCTL $12 /* MIPSR2 */
  95. /*
  96. * Coprocessor 0 Set 3 register names
  97. */
  98. #define CP0_S3_SRSMAP $12 /* MIPSR2 */
  99. /*
  100. * TX39 Series
  101. */
  102. #define CP0_TX39_CACHE $7
  103. /*
  104. * Coprocessor 1 (FPU) register names
  105. */
  106. #define CP1_REVISION $0
  107. #define CP1_STATUS $31
  108. /*
  109. * FPU Status Register Values
  110. */
  111. /*
  112. * Status Register Values
  113. */
  114. #define FPU_CSR_FLUSH 0x01000000 /* flush denormalised results to 0 */
  115. #define FPU_CSR_COND 0x00800000 /* $fcc0 */
  116. #define FPU_CSR_COND0 0x00800000 /* $fcc0 */
  117. #define FPU_CSR_COND1 0x02000000 /* $fcc1 */
  118. #define FPU_CSR_COND2 0x04000000 /* $fcc2 */
  119. #define FPU_CSR_COND3 0x08000000 /* $fcc3 */
  120. #define FPU_CSR_COND4 0x10000000 /* $fcc4 */
  121. #define FPU_CSR_COND5 0x20000000 /* $fcc5 */
  122. #define FPU_CSR_COND6 0x40000000 /* $fcc6 */
  123. #define FPU_CSR_COND7 0x80000000 /* $fcc7 */
  124. /*
  125. * X the exception cause indicator
  126. * E the exception enable
  127. * S the sticky/flag bit
  128. */
  129. #define FPU_CSR_ALL_X 0x0003f000
  130. #define FPU_CSR_UNI_X 0x00020000
  131. #define FPU_CSR_INV_X 0x00010000
  132. #define FPU_CSR_DIV_X 0x00008000
  133. #define FPU_CSR_OVF_X 0x00004000
  134. #define FPU_CSR_UDF_X 0x00002000
  135. #define FPU_CSR_INE_X 0x00001000
  136. #define FPU_CSR_ALL_E 0x00000f80
  137. #define FPU_CSR_INV_E 0x00000800
  138. #define FPU_CSR_DIV_E 0x00000400
  139. #define FPU_CSR_OVF_E 0x00000200
  140. #define FPU_CSR_UDF_E 0x00000100
  141. #define FPU_CSR_INE_E 0x00000080
  142. #define FPU_CSR_ALL_S 0x0000007c
  143. #define FPU_CSR_INV_S 0x00000040
  144. #define FPU_CSR_DIV_S 0x00000020
  145. #define FPU_CSR_OVF_S 0x00000010
  146. #define FPU_CSR_UDF_S 0x00000008
  147. #define FPU_CSR_INE_S 0x00000004
  148. /* rounding mode */
  149. #define FPU_CSR_RN 0x0 /* nearest */
  150. #define FPU_CSR_RZ 0x1 /* towards zero */
  151. #define FPU_CSR_RU 0x2 /* towards +Infinity */
  152. #define FPU_CSR_RD 0x3 /* towards -Infinity */
  153. /*
  154. * Values for PageMask register
  155. */
  156. #ifdef CONFIG_CPU_VR41XX
  157. /* Why doesn't stupidity hurt ... */
  158. #define PM_1K 0x00000000
  159. #define PM_4K 0x00001800
  160. #define PM_16K 0x00007800
  161. #define PM_64K 0x0001f800
  162. #define PM_256K 0x0007f800
  163. #else
  164. #define PM_4K 0x00000000
  165. #define PM_16K 0x00006000
  166. #define PM_64K 0x0001e000
  167. #define PM_256K 0x0007e000
  168. #define PM_1M 0x001fe000
  169. #define PM_4M 0x007fe000
  170. #define PM_16M 0x01ffe000
  171. #define PM_64M 0x07ffe000
  172. #define PM_256M 0x1fffe000
  173. #endif
  174. /*
  175. * Values used for computation of new tlb entries
  176. */
  177. #define PL_4K 12
  178. #define PL_16K 14
  179. #define PL_64K 16
  180. #define PL_256K 18
  181. #define PL_1M 20
  182. #define PL_4M 22
  183. #define PL_16M 24
  184. #define PL_64M 26
  185. #define PL_256M 28
  186. /*
  187. * R4x00 interrupt enable / cause bits
  188. */
  189. #define IE_SW0 (_ULCAST_(1) << 8)
  190. #define IE_SW1 (_ULCAST_(1) << 9)
  191. #define IE_IRQ0 (_ULCAST_(1) << 10)
  192. #define IE_IRQ1 (_ULCAST_(1) << 11)
  193. #define IE_IRQ2 (_ULCAST_(1) << 12)
  194. #define IE_IRQ3 (_ULCAST_(1) << 13)
  195. #define IE_IRQ4 (_ULCAST_(1) << 14)
  196. #define IE_IRQ5 (_ULCAST_(1) << 15)
  197. /*
  198. * R4x00 interrupt cause bits
  199. */
  200. #define C_SW0 (_ULCAST_(1) << 8)
  201. #define C_SW1 (_ULCAST_(1) << 9)
  202. #define C_IRQ0 (_ULCAST_(1) << 10)
  203. #define C_IRQ1 (_ULCAST_(1) << 11)
  204. #define C_IRQ2 (_ULCAST_(1) << 12)
  205. #define C_IRQ3 (_ULCAST_(1) << 13)
  206. #define C_IRQ4 (_ULCAST_(1) << 14)
  207. #define C_IRQ5 (_ULCAST_(1) << 15)
  208. /*
  209. * Bitfields in the R4xx0 cp0 status register
  210. */
  211. #define ST0_IE 0x00000001
  212. #define ST0_EXL 0x00000002
  213. #define ST0_ERL 0x00000004
  214. #define ST0_KSU 0x00000018
  215. # define KSU_USER 0x00000010
  216. # define KSU_SUPERVISOR 0x00000008
  217. # define KSU_KERNEL 0x00000000
  218. #define ST0_UX 0x00000020
  219. #define ST0_SX 0x00000040
  220. #define ST0_KX 0x00000080
  221. #define ST0_DE 0x00010000
  222. #define ST0_CE 0x00020000
  223. /*
  224. * Setting c0_status.co enables Hit_Writeback and Hit_Writeback_Invalidate
  225. * cacheops in userspace. This bit exists only on RM7000 and RM9000
  226. * processors.
  227. */
  228. #define ST0_CO 0x08000000
  229. /*
  230. * Bitfields in the R[23]000 cp0 status register.
  231. */
  232. #define ST0_IEC 0x00000001
  233. #define ST0_KUC 0x00000002
  234. #define ST0_IEP 0x00000004
  235. #define ST0_KUP 0x00000008
  236. #define ST0_IEO 0x00000010
  237. #define ST0_KUO 0x00000020
  238. /* bits 6 & 7 are reserved on R[23]000 */
  239. #define ST0_ISC 0x00010000
  240. #define ST0_SWC 0x00020000
  241. #define ST0_CM 0x00080000
  242. /*
  243. * Bits specific to the R4640/R4650
  244. */
  245. #define ST0_UM (_ULCAST_(1) << 4)
  246. #define ST0_IL (_ULCAST_(1) << 23)
  247. #define ST0_DL (_ULCAST_(1) << 24)
  248. /*
  249. * Enable the MIPS MDMX and DSP ASEs
  250. */
  251. #define ST0_MX 0x01000000
  252. /*
  253. * Bitfields in the TX39 family CP0 Configuration Register 3
  254. */
  255. #define TX39_CONF_ICS_SHIFT 19
  256. #define TX39_CONF_ICS_MASK 0x00380000
  257. #define TX39_CONF_ICS_1KB 0x00000000
  258. #define TX39_CONF_ICS_2KB 0x00080000
  259. #define TX39_CONF_ICS_4KB 0x00100000
  260. #define TX39_CONF_ICS_8KB 0x00180000
  261. #define TX39_CONF_ICS_16KB 0x00200000
  262. #define TX39_CONF_DCS_SHIFT 16
  263. #define TX39_CONF_DCS_MASK 0x00070000
  264. #define TX39_CONF_DCS_1KB 0x00000000
  265. #define TX39_CONF_DCS_2KB 0x00010000
  266. #define TX39_CONF_DCS_4KB 0x00020000
  267. #define TX39_CONF_DCS_8KB 0x00030000
  268. #define TX39_CONF_DCS_16KB 0x00040000
  269. #define TX39_CONF_CWFON 0x00004000
  270. #define TX39_CONF_WBON 0x00002000
  271. #define TX39_CONF_RF_SHIFT 10
  272. #define TX39_CONF_RF_MASK 0x00000c00
  273. #define TX39_CONF_DOZE 0x00000200
  274. #define TX39_CONF_HALT 0x00000100
  275. #define TX39_CONF_LOCK 0x00000080
  276. #define TX39_CONF_ICE 0x00000020
  277. #define TX39_CONF_DCE 0x00000010
  278. #define TX39_CONF_IRSIZE_SHIFT 2
  279. #define TX39_CONF_IRSIZE_MASK 0x0000000c
  280. #define TX39_CONF_DRSIZE_SHIFT 0
  281. #define TX39_CONF_DRSIZE_MASK 0x00000003
  282. /*
  283. * Status register bits available in all MIPS CPUs.
  284. */
  285. #define ST0_IM 0x0000ff00
  286. #define STATUSB_IP0 8
  287. #define STATUSF_IP0 (_ULCAST_(1) << 8)
  288. #define STATUSB_IP1 9
  289. #define STATUSF_IP1 (_ULCAST_(1) << 9)
  290. #define STATUSB_IP2 10
  291. #define STATUSF_IP2 (_ULCAST_(1) << 10)
  292. #define STATUSB_IP3 11
  293. #define STATUSF_IP3 (_ULCAST_(1) << 11)
  294. #define STATUSB_IP4 12
  295. #define STATUSF_IP4 (_ULCAST_(1) << 12)
  296. #define STATUSB_IP5 13
  297. #define STATUSF_IP5 (_ULCAST_(1) << 13)
  298. #define STATUSB_IP6 14
  299. #define STATUSF_IP6 (_ULCAST_(1) << 14)
  300. #define STATUSB_IP7 15
  301. #define STATUSF_IP7 (_ULCAST_(1) << 15)
  302. #define STATUSB_IP8 0
  303. #define STATUSF_IP8 (_ULCAST_(1) << 0)
  304. #define STATUSB_IP9 1
  305. #define STATUSF_IP9 (_ULCAST_(1) << 1)
  306. #define STATUSB_IP10 2
  307. #define STATUSF_IP10 (_ULCAST_(1) << 2)
  308. #define STATUSB_IP11 3
  309. #define STATUSF_IP11 (_ULCAST_(1) << 3)
  310. #define STATUSB_IP12 4
  311. #define STATUSF_IP12 (_ULCAST_(1) << 4)
  312. #define STATUSB_IP13 5
  313. #define STATUSF_IP13 (_ULCAST_(1) << 5)
  314. #define STATUSB_IP14 6
  315. #define STATUSF_IP14 (_ULCAST_(1) << 6)
  316. #define STATUSB_IP15 7
  317. #define STATUSF_IP15 (_ULCAST_(1) << 7)
  318. #define ST0_CH 0x00040000
  319. #define ST0_SR 0x00100000
  320. #define ST0_TS 0x00200000
  321. #define ST0_BEV 0x00400000
  322. #define ST0_RE 0x02000000
  323. #define ST0_FR 0x04000000
  324. #define ST0_CU 0xf0000000
  325. #define ST0_CU0 0x10000000
  326. #define ST0_CU1 0x20000000
  327. #define ST0_CU2 0x40000000
  328. #define ST0_CU3 0x80000000
  329. #define ST0_XX 0x80000000 /* MIPS IV naming */
  330. /*
  331. * Bitfields and bit numbers in the coprocessor 0 cause register.
  332. *
  333. * Refer to your MIPS R4xx0 manual, chapter 5 for explanation.
  334. */
  335. #define CAUSEB_EXCCODE 2
  336. #define CAUSEF_EXCCODE (_ULCAST_(31) << 2)
  337. #define CAUSEB_IP 8
  338. #define CAUSEF_IP (_ULCAST_(255) << 8)
  339. #define CAUSEB_IP0 8
  340. #define CAUSEF_IP0 (_ULCAST_(1) << 8)
  341. #define CAUSEB_IP1 9
  342. #define CAUSEF_IP1 (_ULCAST_(1) << 9)
  343. #define CAUSEB_IP2 10
  344. #define CAUSEF_IP2 (_ULCAST_(1) << 10)
  345. #define CAUSEB_IP3 11
  346. #define CAUSEF_IP3 (_ULCAST_(1) << 11)
  347. #define CAUSEB_IP4 12
  348. #define CAUSEF_IP4 (_ULCAST_(1) << 12)
  349. #define CAUSEB_IP5 13
  350. #define CAUSEF_IP5 (_ULCAST_(1) << 13)
  351. #define CAUSEB_IP6 14
  352. #define CAUSEF_IP6 (_ULCAST_(1) << 14)
  353. #define CAUSEB_IP7 15
  354. #define CAUSEF_IP7 (_ULCAST_(1) << 15)
  355. #define CAUSEB_IV 23
  356. #define CAUSEF_IV (_ULCAST_(1) << 23)
  357. #define CAUSEB_CE 28
  358. #define CAUSEF_CE (_ULCAST_(3) << 28)
  359. #define CAUSEB_BD 31
  360. #define CAUSEF_BD (_ULCAST_(1) << 31)
  361. /*
  362. * Bits in the coprocessor 0 config register.
  363. */
  364. /* Generic bits. */
  365. #define CONF_CM_CACHABLE_NO_WA 0
  366. #define CONF_CM_CACHABLE_WA 1
  367. #define CONF_CM_UNCACHED 2
  368. #define CONF_CM_CACHABLE_NONCOHERENT 3
  369. #define CONF_CM_CACHABLE_CE 4
  370. #define CONF_CM_CACHABLE_COW 5
  371. #define CONF_CM_CACHABLE_CUW 6
  372. #define CONF_CM_CACHABLE_ACCELERATED 7
  373. #define CONF_CM_CMASK 7
  374. #define CONF_BE (_ULCAST_(1) << 15)
  375. /* Bits common to various processors. */
  376. #define CONF_CU (_ULCAST_(1) << 3)
  377. #define CONF_DB (_ULCAST_(1) << 4)
  378. #define CONF_IB (_ULCAST_(1) << 5)
  379. #define CONF_DC (_ULCAST_(7) << 6)
  380. #define CONF_IC (_ULCAST_(7) << 9)
  381. #define CONF_EB (_ULCAST_(1) << 13)
  382. #define CONF_EM (_ULCAST_(1) << 14)
  383. #define CONF_SM (_ULCAST_(1) << 16)
  384. #define CONF_SC (_ULCAST_(1) << 17)
  385. #define CONF_EW (_ULCAST_(3) << 18)
  386. #define CONF_EP (_ULCAST_(15)<< 24)
  387. #define CONF_EC (_ULCAST_(7) << 28)
  388. #define CONF_CM (_ULCAST_(1) << 31)
  389. /* Bits specific to the R4xx0. */
  390. #define R4K_CONF_SW (_ULCAST_(1) << 20)
  391. #define R4K_CONF_SS (_ULCAST_(1) << 21)
  392. #define R4K_CONF_SB (_ULCAST_(3) << 22)
  393. /* Bits specific to the R5000. */
  394. #define R5K_CONF_SE (_ULCAST_(1) << 12)
  395. #define R5K_CONF_SS (_ULCAST_(3) << 20)
  396. /* Bits specific to the RM7000. */
  397. #define RM7K_CONF_SE (_ULCAST_(1) << 3)
  398. #define RM7K_CONF_TE (_ULCAST_(1) << 12)
  399. #define RM7K_CONF_CLK (_ULCAST_(1) << 16)
  400. #define RM7K_CONF_TC (_ULCAST_(1) << 17)
  401. #define RM7K_CONF_SI (_ULCAST_(3) << 20)
  402. #define RM7K_CONF_SC (_ULCAST_(1) << 31)
  403. /* Bits specific to the R10000. */
  404. #define R10K_CONF_DN (_ULCAST_(3) << 3)
  405. #define R10K_CONF_CT (_ULCAST_(1) << 5)
  406. #define R10K_CONF_PE (_ULCAST_(1) << 6)
  407. #define R10K_CONF_PM (_ULCAST_(3) << 7)
  408. #define R10K_CONF_EC (_ULCAST_(15)<< 9)
  409. #define R10K_CONF_SB (_ULCAST_(1) << 13)
  410. #define R10K_CONF_SK (_ULCAST_(1) << 14)
  411. #define R10K_CONF_SS (_ULCAST_(7) << 16)
  412. #define R10K_CONF_SC (_ULCAST_(7) << 19)
  413. #define R10K_CONF_DC (_ULCAST_(7) << 26)
  414. #define R10K_CONF_IC (_ULCAST_(7) << 29)
  415. /* Bits specific to the VR41xx. */
  416. #define VR41_CONF_CS (_ULCAST_(1) << 12)
  417. #define VR41_CONF_P4K (_ULCAST_(1) << 13)
  418. #define VR41_CONF_BP (_ULCAST_(1) << 16)
  419. #define VR41_CONF_M16 (_ULCAST_(1) << 20)
  420. #define VR41_CONF_AD (_ULCAST_(1) << 23)
  421. /* Bits specific to the R30xx. */
  422. #define R30XX_CONF_FDM (_ULCAST_(1) << 19)
  423. #define R30XX_CONF_REV (_ULCAST_(1) << 22)
  424. #define R30XX_CONF_AC (_ULCAST_(1) << 23)
  425. #define R30XX_CONF_RF (_ULCAST_(1) << 24)
  426. #define R30XX_CONF_HALT (_ULCAST_(1) << 25)
  427. #define R30XX_CONF_FPINT (_ULCAST_(7) << 26)
  428. #define R30XX_CONF_DBR (_ULCAST_(1) << 29)
  429. #define R30XX_CONF_SB (_ULCAST_(1) << 30)
  430. #define R30XX_CONF_LOCK (_ULCAST_(1) << 31)
  431. /* Bits specific to the TX49. */
  432. #define TX49_CONF_DC (_ULCAST_(1) << 16)
  433. #define TX49_CONF_IC (_ULCAST_(1) << 17) /* conflict with CONF_SC */
  434. #define TX49_CONF_HALT (_ULCAST_(1) << 18)
  435. #define TX49_CONF_CWFON (_ULCAST_(1) << 27)
  436. /* Bits specific to the MIPS32/64 PRA. */
  437. #define MIPS_CONF_MT (_ULCAST_(7) << 7)
  438. #define MIPS_CONF_AR (_ULCAST_(7) << 10)
  439. #define MIPS_CONF_AT (_ULCAST_(3) << 13)
  440. #define MIPS_CONF_M (_ULCAST_(1) << 31)
  441. /*
  442. * Bits in the MIPS32/64 PRA coprocessor 0 config registers 1 and above.
  443. */
  444. #define MIPS_CONF1_FP (_ULCAST_(1) << 0)
  445. #define MIPS_CONF1_EP (_ULCAST_(1) << 1)
  446. #define MIPS_CONF1_CA (_ULCAST_(1) << 2)
  447. #define MIPS_CONF1_WR (_ULCAST_(1) << 3)
  448. #define MIPS_CONF1_PC (_ULCAST_(1) << 4)
  449. #define MIPS_CONF1_MD (_ULCAST_(1) << 5)
  450. #define MIPS_CONF1_C2 (_ULCAST_(1) << 6)
  451. #define MIPS_CONF1_DA_SHIFT 7
  452. #define MIPS_CONF1_DA (_ULCAST_(7) << 7)
  453. #define MIPS_CONF1_DL_SHIFT 10
  454. #define MIPS_CONF1_DL (_ULCAST_(7) << 10)
  455. #define MIPS_CONF1_DS_SHIFT 13
  456. #define MIPS_CONF1_DS (_ULCAST_(7) << 13)
  457. #define MIPS_CONF1_IA_SHIFT 16
  458. #define MIPS_CONF1_IA (_ULCAST_(7) << 16)
  459. #define MIPS_CONF1_IL_SHIFT 19
  460. #define MIPS_CONF1_IL (_ULCAST_(7) << 19)
  461. #define MIPS_CONF1_IS_SHIFT 22
  462. #define MIPS_CONF1_IS (_ULCAST_(7) << 22)
  463. #define MIPS_CONF1_TLBS (_ULCAST_(63)<< 25)
  464. #define MIPS_CONF2_SA (_ULCAST_(15)<< 0)
  465. #define MIPS_CONF2_SL (_ULCAST_(15)<< 4)
  466. #define MIPS_CONF2_SS (_ULCAST_(15)<< 8)
  467. #define MIPS_CONF2_SU (_ULCAST_(15)<< 12)
  468. #define MIPS_CONF2_TA (_ULCAST_(15)<< 16)
  469. #define MIPS_CONF2_TL (_ULCAST_(15)<< 20)
  470. #define MIPS_CONF2_TS (_ULCAST_(15)<< 24)
  471. #define MIPS_CONF2_TU (_ULCAST_(7) << 28)
  472. #define MIPS_CONF3_TL (_ULCAST_(1) << 0)
  473. #define MIPS_CONF3_SM (_ULCAST_(1) << 1)
  474. #define MIPS_CONF3_MT (_ULCAST_(1) << 2)
  475. #define MIPS_CONF3_SP (_ULCAST_(1) << 4)
  476. #define MIPS_CONF3_VINT (_ULCAST_(1) << 5)
  477. #define MIPS_CONF3_VEIC (_ULCAST_(1) << 6)
  478. #define MIPS_CONF3_LPA (_ULCAST_(1) << 7)
  479. #define MIPS_CONF3_DSP (_ULCAST_(1) << 10)
  480. #define MIPS_CONF3_ULRI (_ULCAST_(1) << 13)
  481. #define MIPS_CONF7_WII (_ULCAST_(1) << 31)
  482. #define MIPS_CONF7_RPS (_ULCAST_(1) << 2)
  483. /*
  484. * Bits in the MIPS32/64 coprocessor 1 (FPU) revision register.
  485. */
  486. #define MIPS_FPIR_S (_ULCAST_(1) << 16)
  487. #define MIPS_FPIR_D (_ULCAST_(1) << 17)
  488. #define MIPS_FPIR_PS (_ULCAST_(1) << 18)
  489. #define MIPS_FPIR_3D (_ULCAST_(1) << 19)
  490. #define MIPS_FPIR_W (_ULCAST_(1) << 20)
  491. #define MIPS_FPIR_L (_ULCAST_(1) << 21)
  492. #define MIPS_FPIR_F64 (_ULCAST_(1) << 22)
  493. #ifndef __ASSEMBLY__
  494. /*
  495. * Functions to access the R10000 performance counters. These are basically
  496. * mfc0 and mtc0 instructions from and to coprocessor register with a 5-bit
  497. * performance counter number encoded into bits 1 ... 5 of the instruction.
  498. * Only performance counters 0 to 1 actually exist, so for a non-R10000 aware
  499. * disassembler these will look like an access to sel 0 or 1.
  500. */
  501. #define read_r10k_perf_cntr(counter) \
  502. ({ \
  503. unsigned int __res; \
  504. __asm__ __volatile__( \
  505. "mfpc\t%0, %1" \
  506. : "=r" (__res) \
  507. : "i" (counter)); \
  508. \
  509. __res; \
  510. })
  511. #define write_r10k_perf_cntr(counter,val) \
  512. do { \
  513. __asm__ __volatile__( \
  514. "mtpc\t%0, %1" \
  515. : \
  516. : "r" (val), "i" (counter)); \
  517. } while (0)
  518. #define read_r10k_perf_event(counter) \
  519. ({ \
  520. unsigned int __res; \
  521. __asm__ __volatile__( \
  522. "mfps\t%0, %1" \
  523. : "=r" (__res) \
  524. : "i" (counter)); \
  525. \
  526. __res; \
  527. })
  528. #define write_r10k_perf_cntl(counter,val) \
  529. do { \
  530. __asm__ __volatile__( \
  531. "mtps\t%0, %1" \
  532. : \
  533. : "r" (val), "i" (counter)); \
  534. } while (0)
  535. /*
  536. * Macros to access the system control coprocessor
  537. */
  538. #define __read_32bit_c0_register(source, sel) \
  539. ({ int __res; \
  540. if (sel == 0) \
  541. __asm__ __volatile__( \
  542. "mfc0\t%0, " #source "\n\t" \
  543. : "=r" (__res)); \
  544. else \
  545. __asm__ __volatile__( \
  546. ".set\tmips32\n\t" \
  547. "mfc0\t%0, " #source ", " #sel "\n\t" \
  548. ".set\tmips0\n\t" \
  549. : "=r" (__res)); \
  550. __res; \
  551. })
  552. #define __read_64bit_c0_register(source, sel) \
  553. ({ unsigned long long __res; \
  554. if (sizeof(unsigned long) == 4) \
  555. __res = __read_64bit_c0_split(source, sel); \
  556. else if (sel == 0) \
  557. __asm__ __volatile__( \
  558. ".set\tmips3\n\t" \
  559. "dmfc0\t%0, " #source "\n\t" \
  560. ".set\tmips0" \
  561. : "=r" (__res)); \
  562. else \
  563. __asm__ __volatile__( \
  564. ".set\tmips64\n\t" \
  565. "dmfc0\t%0, " #source ", " #sel "\n\t" \
  566. ".set\tmips0" \
  567. : "=r" (__res)); \
  568. __res; \
  569. })
  570. #define __write_32bit_c0_register(register, sel, value) \
  571. do { \
  572. if (sel == 0) \
  573. __asm__ __volatile__( \
  574. "mtc0\t%z0, " #register "\n\t" \
  575. : : "Jr" ((unsigned int)(value))); \
  576. else \
  577. __asm__ __volatile__( \
  578. ".set\tmips32\n\t" \
  579. "mtc0\t%z0, " #register ", " #sel "\n\t" \
  580. ".set\tmips0" \
  581. : : "Jr" ((unsigned int)(value))); \
  582. } while (0)
  583. #define __write_64bit_c0_register(register, sel, value) \
  584. do { \
  585. if (sizeof(unsigned long) == 4) \
  586. __write_64bit_c0_split(register, sel, value); \
  587. else if (sel == 0) \
  588. __asm__ __volatile__( \
  589. ".set\tmips3\n\t" \
  590. "dmtc0\t%z0, " #register "\n\t" \
  591. ".set\tmips0" \
  592. : : "Jr" (value)); \
  593. else \
  594. __asm__ __volatile__( \
  595. ".set\tmips64\n\t" \
  596. "dmtc0\t%z0, " #register ", " #sel "\n\t" \
  597. ".set\tmips0" \
  598. : : "Jr" (value)); \
  599. } while (0)
  600. #define __read_ulong_c0_register(reg, sel) \
  601. ((sizeof(unsigned long) == 4) ? \
  602. (unsigned long) __read_32bit_c0_register(reg, sel) : \
  603. (unsigned long) __read_64bit_c0_register(reg, sel))
  604. #define __write_ulong_c0_register(reg, sel, val) \
  605. do { \
  606. if (sizeof(unsigned long) == 4) \
  607. __write_32bit_c0_register(reg, sel, val); \
  608. else \
  609. __write_64bit_c0_register(reg, sel, val); \
  610. } while (0)
  611. /*
  612. * On RM7000/RM9000 these are uses to access cop0 set 1 registers
  613. */
  614. #define __read_32bit_c0_ctrl_register(source) \
  615. ({ int __res; \
  616. __asm__ __volatile__( \
  617. "cfc0\t%0, " #source "\n\t" \
  618. : "=r" (__res)); \
  619. __res; \
  620. })
  621. #define __write_32bit_c0_ctrl_register(register, value) \
  622. do { \
  623. __asm__ __volatile__( \
  624. "ctc0\t%z0, " #register "\n\t" \
  625. : : "Jr" ((unsigned int)(value))); \
  626. } while (0)
  627. /*
  628. * These versions are only needed for systems with more than 38 bits of
  629. * physical address space running the 32-bit kernel. That's none atm :-)
  630. */
  631. #define __read_64bit_c0_split(source, sel) \
  632. ({ \
  633. unsigned long long __val; \
  634. unsigned long __flags; \
  635. \
  636. local_irq_save(__flags); \
  637. if (sel == 0) \
  638. __asm__ __volatile__( \
  639. ".set\tmips64\n\t" \
  640. "dmfc0\t%M0, " #source "\n\t" \
  641. "dsll\t%L0, %M0, 32\n\t" \
  642. "dsrl\t%M0, %M0, 32\n\t" \
  643. "dsrl\t%L0, %L0, 32\n\t" \
  644. ".set\tmips0" \
  645. : "=r" (__val)); \
  646. else \
  647. __asm__ __volatile__( \
  648. ".set\tmips64\n\t" \
  649. "dmfc0\t%M0, " #source ", " #sel "\n\t" \
  650. "dsll\t%L0, %M0, 32\n\t" \
  651. "dsrl\t%M0, %M0, 32\n\t" \
  652. "dsrl\t%L0, %L0, 32\n\t" \
  653. ".set\tmips0" \
  654. : "=r" (__val)); \
  655. local_irq_restore(__flags); \
  656. \
  657. __val; \
  658. })
  659. #define __write_64bit_c0_split(source, sel, val) \
  660. do { \
  661. unsigned long __flags; \
  662. \
  663. local_irq_save(__flags); \
  664. if (sel == 0) \
  665. __asm__ __volatile__( \
  666. ".set\tmips64\n\t" \
  667. "dsll\t%L0, %L0, 32\n\t" \
  668. "dsrl\t%L0, %L0, 32\n\t" \
  669. "dsll\t%M0, %M0, 32\n\t" \
  670. "or\t%L0, %L0, %M0\n\t" \
  671. "dmtc0\t%L0, " #source "\n\t" \
  672. ".set\tmips0" \
  673. : : "r" (val)); \
  674. else \
  675. __asm__ __volatile__( \
  676. ".set\tmips64\n\t" \
  677. "dsll\t%L0, %L0, 32\n\t" \
  678. "dsrl\t%L0, %L0, 32\n\t" \
  679. "dsll\t%M0, %M0, 32\n\t" \
  680. "or\t%L0, %L0, %M0\n\t" \
  681. "dmtc0\t%L0, " #source ", " #sel "\n\t" \
  682. ".set\tmips0" \
  683. : : "r" (val)); \
  684. local_irq_restore(__flags); \
  685. } while (0)
  686. #define read_c0_index() __read_32bit_c0_register($0, 0)
  687. #define write_c0_index(val) __write_32bit_c0_register($0, 0, val)
  688. #define read_c0_entrylo0() __read_ulong_c0_register($2, 0)
  689. #define write_c0_entrylo0(val) __write_ulong_c0_register($2, 0, val)
  690. #define read_c0_entrylo1() __read_ulong_c0_register($3, 0)
  691. #define write_c0_entrylo1(val) __write_ulong_c0_register($3, 0, val)
  692. #define read_c0_conf() __read_32bit_c0_register($3, 0)
  693. #define write_c0_conf(val) __write_32bit_c0_register($3, 0, val)
  694. #define read_c0_context() __read_ulong_c0_register($4, 0)
  695. #define write_c0_context(val) __write_ulong_c0_register($4, 0, val)
  696. #define read_c0_userlocal() __read_ulong_c0_register($4, 2)
  697. #define write_c0_userlocal(val) __write_ulong_c0_register($4, 2, val)
  698. #define read_c0_pagemask() __read_32bit_c0_register($5, 0)
  699. #define write_c0_pagemask(val) __write_32bit_c0_register($5, 0, val)
  700. #define read_c0_wired() __read_32bit_c0_register($6, 0)
  701. #define write_c0_wired(val) __write_32bit_c0_register($6, 0, val)
  702. #define read_c0_info() __read_32bit_c0_register($7, 0)
  703. #define read_c0_cache() __read_32bit_c0_register($7, 0) /* TX39xx */
  704. #define write_c0_cache(val) __write_32bit_c0_register($7, 0, val)
  705. #define read_c0_badvaddr() __read_ulong_c0_register($8, 0)
  706. #define write_c0_badvaddr(val) __write_ulong_c0_register($8, 0, val)
  707. #define read_c0_count() __read_32bit_c0_register($9, 0)
  708. #define write_c0_count(val) __write_32bit_c0_register($9, 0, val)
  709. #define read_c0_count2() __read_32bit_c0_register($9, 6) /* pnx8550 */
  710. #define write_c0_count2(val) __write_32bit_c0_register($9, 6, val)
  711. #define read_c0_count3() __read_32bit_c0_register($9, 7) /* pnx8550 */
  712. #define write_c0_count3(val) __write_32bit_c0_register($9, 7, val)
  713. #define read_c0_entryhi() __read_ulong_c0_register($10, 0)
  714. #define write_c0_entryhi(val) __write_ulong_c0_register($10, 0, val)
  715. #define read_c0_compare() __read_32bit_c0_register($11, 0)
  716. #define write_c0_compare(val) __write_32bit_c0_register($11, 0, val)
  717. #define read_c0_compare2() __read_32bit_c0_register($11, 6) /* pnx8550 */
  718. #define write_c0_compare2(val) __write_32bit_c0_register($11, 6, val)
  719. #define read_c0_compare3() __read_32bit_c0_register($11, 7) /* pnx8550 */
  720. #define write_c0_compare3(val) __write_32bit_c0_register($11, 7, val)
  721. #define read_c0_status() __read_32bit_c0_register($12, 0)
  722. #ifdef CONFIG_MIPS_MT_SMTC
  723. #define write_c0_status(val) \
  724. do { \
  725. __write_32bit_c0_register($12, 0, val); \
  726. __ehb(); \
  727. } while (0)
  728. #else
  729. /*
  730. * Legacy non-SMTC code, which may be hazardous
  731. * but which might not support EHB
  732. */
  733. #define write_c0_status(val) __write_32bit_c0_register($12, 0, val)
  734. #endif /* CONFIG_MIPS_MT_SMTC */
  735. #define read_c0_cause() __read_32bit_c0_register($13, 0)
  736. #define write_c0_cause(val) __write_32bit_c0_register($13, 0, val)
  737. #define read_c0_epc() __read_ulong_c0_register($14, 0)
  738. #define write_c0_epc(val) __write_ulong_c0_register($14, 0, val)
  739. #define read_c0_prid() __read_32bit_c0_register($15, 0)
  740. #define read_c0_config() __read_32bit_c0_register($16, 0)
  741. #define read_c0_config1() __read_32bit_c0_register($16, 1)
  742. #define read_c0_config2() __read_32bit_c0_register($16, 2)
  743. #define read_c0_config3() __read_32bit_c0_register($16, 3)
  744. #define read_c0_config4() __read_32bit_c0_register($16, 4)
  745. #define read_c0_config5() __read_32bit_c0_register($16, 5)
  746. #define read_c0_config6() __read_32bit_c0_register($16, 6)
  747. #define read_c0_config7() __read_32bit_c0_register($16, 7)
  748. #define write_c0_config(val) __write_32bit_c0_register($16, 0, val)
  749. #define write_c0_config1(val) __write_32bit_c0_register($16, 1, val)
  750. #define write_c0_config2(val) __write_32bit_c0_register($16, 2, val)
  751. #define write_c0_config3(val) __write_32bit_c0_register($16, 3, val)
  752. #define write_c0_config4(val) __write_32bit_c0_register($16, 4, val)
  753. #define write_c0_config5(val) __write_32bit_c0_register($16, 5, val)
  754. #define write_c0_config6(val) __write_32bit_c0_register($16, 6, val)
  755. #define write_c0_config7(val) __write_32bit_c0_register($16, 7, val)
  756. /*
  757. * The WatchLo register. There may be upto 8 of them.
  758. */
  759. #define read_c0_watchlo0() __read_ulong_c0_register($18, 0)
  760. #define read_c0_watchlo1() __read_ulong_c0_register($18, 1)
  761. #define read_c0_watchlo2() __read_ulong_c0_register($18, 2)
  762. #define read_c0_watchlo3() __read_ulong_c0_register($18, 3)
  763. #define read_c0_watchlo4() __read_ulong_c0_register($18, 4)
  764. #define read_c0_watchlo5() __read_ulong_c0_register($18, 5)
  765. #define read_c0_watchlo6() __read_ulong_c0_register($18, 6)
  766. #define read_c0_watchlo7() __read_ulong_c0_register($18, 7)
  767. #define write_c0_watchlo0(val) __write_ulong_c0_register($18, 0, val)
  768. #define write_c0_watchlo1(val) __write_ulong_c0_register($18, 1, val)
  769. #define write_c0_watchlo2(val) __write_ulong_c0_register($18, 2, val)
  770. #define write_c0_watchlo3(val) __write_ulong_c0_register($18, 3, val)
  771. #define write_c0_watchlo4(val) __write_ulong_c0_register($18, 4, val)
  772. #define write_c0_watchlo5(val) __write_ulong_c0_register($18, 5, val)
  773. #define write_c0_watchlo6(val) __write_ulong_c0_register($18, 6, val)
  774. #define write_c0_watchlo7(val) __write_ulong_c0_register($18, 7, val)
  775. /*
  776. * The WatchHi register. There may be upto 8 of them.
  777. */
  778. #define read_c0_watchhi0() __read_32bit_c0_register($19, 0)
  779. #define read_c0_watchhi1() __read_32bit_c0_register($19, 1)
  780. #define read_c0_watchhi2() __read_32bit_c0_register($19, 2)
  781. #define read_c0_watchhi3() __read_32bit_c0_register($19, 3)
  782. #define read_c0_watchhi4() __read_32bit_c0_register($19, 4)
  783. #define read_c0_watchhi5() __read_32bit_c0_register($19, 5)
  784. #define read_c0_watchhi6() __read_32bit_c0_register($19, 6)
  785. #define read_c0_watchhi7() __read_32bit_c0_register($19, 7)
  786. #define write_c0_watchhi0(val) __write_32bit_c0_register($19, 0, val)
  787. #define write_c0_watchhi1(val) __write_32bit_c0_register($19, 1, val)
  788. #define write_c0_watchhi2(val) __write_32bit_c0_register($19, 2, val)
  789. #define write_c0_watchhi3(val) __write_32bit_c0_register($19, 3, val)
  790. #define write_c0_watchhi4(val) __write_32bit_c0_register($19, 4, val)
  791. #define write_c0_watchhi5(val) __write_32bit_c0_register($19, 5, val)
  792. #define write_c0_watchhi6(val) __write_32bit_c0_register($19, 6, val)
  793. #define write_c0_watchhi7(val) __write_32bit_c0_register($19, 7, val)
  794. #define read_c0_xcontext() __read_ulong_c0_register($20, 0)
  795. #define write_c0_xcontext(val) __write_ulong_c0_register($20, 0, val)
  796. #define read_c0_intcontrol() __read_32bit_c0_ctrl_register($20)
  797. #define write_c0_intcontrol(val) __write_32bit_c0_ctrl_register($20, val)
  798. #define read_c0_framemask() __read_32bit_c0_register($21, 0)
  799. #define write_c0_framemask(val) __write_32bit_c0_register($21, 0, val)
  800. /* RM9000 PerfControl performance counter control register */
  801. #define read_c0_perfcontrol() __read_32bit_c0_register($22, 0)
  802. #define write_c0_perfcontrol(val) __write_32bit_c0_register($22, 0, val)
  803. #define read_c0_diag() __read_32bit_c0_register($22, 0)
  804. #define write_c0_diag(val) __write_32bit_c0_register($22, 0, val)
  805. #define read_c0_diag1() __read_32bit_c0_register($22, 1)
  806. #define write_c0_diag1(val) __write_32bit_c0_register($22, 1, val)
  807. #define read_c0_diag2() __read_32bit_c0_register($22, 2)
  808. #define write_c0_diag2(val) __write_32bit_c0_register($22, 2, val)
  809. #define read_c0_diag3() __read_32bit_c0_register($22, 3)
  810. #define write_c0_diag3(val) __write_32bit_c0_register($22, 3, val)
  811. #define read_c0_diag4() __read_32bit_c0_register($22, 4)
  812. #define write_c0_diag4(val) __write_32bit_c0_register($22, 4, val)
  813. #define read_c0_diag5() __read_32bit_c0_register($22, 5)
  814. #define write_c0_diag5(val) __write_32bit_c0_register($22, 5, val)
  815. #define read_c0_debug() __read_32bit_c0_register($23, 0)
  816. #define write_c0_debug(val) __write_32bit_c0_register($23, 0, val)
  817. #define read_c0_depc() __read_ulong_c0_register($24, 0)
  818. #define write_c0_depc(val) __write_ulong_c0_register($24, 0, val)
  819. /*
  820. * MIPS32 / MIPS64 performance counters
  821. */
  822. #define read_c0_perfctrl0() __read_32bit_c0_register($25, 0)
  823. #define write_c0_perfctrl0(val) __write_32bit_c0_register($25, 0, val)
  824. #define read_c0_perfcntr0() __read_32bit_c0_register($25, 1)
  825. #define write_c0_perfcntr0(val) __write_32bit_c0_register($25, 1, val)
  826. #define read_c0_perfctrl1() __read_32bit_c0_register($25, 2)
  827. #define write_c0_perfctrl1(val) __write_32bit_c0_register($25, 2, val)
  828. #define read_c0_perfcntr1() __read_32bit_c0_register($25, 3)
  829. #define write_c0_perfcntr1(val) __write_32bit_c0_register($25, 3, val)
  830. #define read_c0_perfctrl2() __read_32bit_c0_register($25, 4)
  831. #define write_c0_perfctrl2(val) __write_32bit_c0_register($25, 4, val)
  832. #define read_c0_perfcntr2() __read_32bit_c0_register($25, 5)
  833. #define write_c0_perfcntr2(val) __write_32bit_c0_register($25, 5, val)
  834. #define read_c0_perfctrl3() __read_32bit_c0_register($25, 6)
  835. #define write_c0_perfctrl3(val) __write_32bit_c0_register($25, 6, val)
  836. #define read_c0_perfcntr3() __read_32bit_c0_register($25, 7)
  837. #define write_c0_perfcntr3(val) __write_32bit_c0_register($25, 7, val)
  838. /* RM9000 PerfCount performance counter register */
  839. #define read_c0_perfcount() __read_64bit_c0_register($25, 0)
  840. #define write_c0_perfcount(val) __write_64bit_c0_register($25, 0, val)
  841. #define read_c0_ecc() __read_32bit_c0_register($26, 0)
  842. #define write_c0_ecc(val) __write_32bit_c0_register($26, 0, val)
  843. #define read_c0_derraddr0() __read_ulong_c0_register($26, 1)
  844. #define write_c0_derraddr0(val) __write_ulong_c0_register($26, 1, val)
  845. #define read_c0_cacheerr() __read_32bit_c0_register($27, 0)
  846. #define read_c0_derraddr1() __read_ulong_c0_register($27, 1)
  847. #define write_c0_derraddr1(val) __write_ulong_c0_register($27, 1, val)
  848. #define read_c0_taglo() __read_32bit_c0_register($28, 0)
  849. #define write_c0_taglo(val) __write_32bit_c0_register($28, 0, val)
  850. #define read_c0_dtaglo() __read_32bit_c0_register($28, 2)
  851. #define write_c0_dtaglo(val) __write_32bit_c0_register($28, 2, val)
  852. #define read_c0_taghi() __read_32bit_c0_register($29, 0)
  853. #define write_c0_taghi(val) __write_32bit_c0_register($29, 0, val)
  854. #define read_c0_errorepc() __read_ulong_c0_register($30, 0)
  855. #define write_c0_errorepc(val) __write_ulong_c0_register($30, 0, val)
  856. /* MIPSR2 */
  857. #define read_c0_hwrena() __read_32bit_c0_register($7, 0)
  858. #define write_c0_hwrena(val) __write_32bit_c0_register($7, 0, val)
  859. #define read_c0_intctl() __read_32bit_c0_register($12, 1)
  860. #define write_c0_intctl(val) __write_32bit_c0_register($12, 1, val)
  861. #define read_c0_srsctl() __read_32bit_c0_register($12, 2)
  862. #define write_c0_srsctl(val) __write_32bit_c0_register($12, 2, val)
  863. #define read_c0_srsmap() __read_32bit_c0_register($12, 3)
  864. #define write_c0_srsmap(val) __write_32bit_c0_register($12, 3, val)
  865. #define read_c0_ebase() __read_32bit_c0_register($15, 1)
  866. #define write_c0_ebase(val) __write_32bit_c0_register($15, 1, val)
  867. /*
  868. * Macros to access the floating point coprocessor control registers
  869. */
  870. #define read_32bit_cp1_register(source) \
  871. ({ int __res; \
  872. __asm__ __volatile__( \
  873. ".set\tpush\n\t" \
  874. ".set\treorder\n\t" \
  875. "cfc1\t%0,"STR(source)"\n\t" \
  876. ".set\tpop" \
  877. : "=r" (__res)); \
  878. __res;})
  879. #define rddsp(mask) \
  880. ({ \
  881. unsigned int __res; \
  882. \
  883. __asm__ __volatile__( \
  884. " .set push \n" \
  885. " .set noat \n" \
  886. " # rddsp $1, %x1 \n" \
  887. " .word 0x7c000cb8 | (%x1 << 16) \n" \
  888. " move %0, $1 \n" \
  889. " .set pop \n" \
  890. : "=r" (__res) \
  891. : "i" (mask)); \
  892. __res; \
  893. })
  894. #define wrdsp(val, mask) \
  895. do { \
  896. __asm__ __volatile__( \
  897. " .set push \n" \
  898. " .set noat \n" \
  899. " move $1, %0 \n" \
  900. " # wrdsp $1, %x1 \n" \
  901. " .word 0x7c2004f8 | (%x1 << 11) \n" \
  902. " .set pop \n" \
  903. : \
  904. : "r" (val), "i" (mask)); \
  905. } while (0)
  906. #define mfhi0() \
  907. ({ \
  908. unsigned long __treg; \
  909. \
  910. __asm__ __volatile__( \
  911. " .set push \n" \
  912. " .set noat \n" \
  913. " # mfhi %0, $ac0 \n" \
  914. " .word 0x00000810 \n" \
  915. " move %0, $1 \n" \
  916. " .set pop \n" \
  917. : "=r" (__treg)); \
  918. __treg; \
  919. })
  920. #define mfhi1() \
  921. ({ \
  922. unsigned long __treg; \
  923. \
  924. __asm__ __volatile__( \
  925. " .set push \n" \
  926. " .set noat \n" \
  927. " # mfhi %0, $ac1 \n" \
  928. " .word 0x00200810 \n" \
  929. " move %0, $1 \n" \
  930. " .set pop \n" \
  931. : "=r" (__treg)); \
  932. __treg; \
  933. })
  934. #define mfhi2() \
  935. ({ \
  936. unsigned long __treg; \
  937. \
  938. __asm__ __volatile__( \
  939. " .set push \n" \
  940. " .set noat \n" \
  941. " # mfhi %0, $ac2 \n" \
  942. " .word 0x00400810 \n" \
  943. " move %0, $1 \n" \
  944. " .set pop \n" \
  945. : "=r" (__treg)); \
  946. __treg; \
  947. })
  948. #define mfhi3() \
  949. ({ \
  950. unsigned long __treg; \
  951. \
  952. __asm__ __volatile__( \
  953. " .set push \n" \
  954. " .set noat \n" \
  955. " # mfhi %0, $ac3 \n" \
  956. " .word 0x00600810 \n" \
  957. " move %0, $1 \n" \
  958. " .set pop \n" \
  959. : "=r" (__treg)); \
  960. __treg; \
  961. })
  962. #define mflo0() \
  963. ({ \
  964. unsigned long __treg; \
  965. \
  966. __asm__ __volatile__( \
  967. " .set push \n" \
  968. " .set noat \n" \
  969. " # mflo %0, $ac0 \n" \
  970. " .word 0x00000812 \n" \
  971. " move %0, $1 \n" \
  972. " .set pop \n" \
  973. : "=r" (__treg)); \
  974. __treg; \
  975. })
  976. #define mflo1() \
  977. ({ \
  978. unsigned long __treg; \
  979. \
  980. __asm__ __volatile__( \
  981. " .set push \n" \
  982. " .set noat \n" \
  983. " # mflo %0, $ac1 \n" \
  984. " .word 0x00200812 \n" \
  985. " move %0, $1 \n" \
  986. " .set pop \n" \
  987. : "=r" (__treg)); \
  988. __treg; \
  989. })
  990. #define mflo2() \
  991. ({ \
  992. unsigned long __treg; \
  993. \
  994. __asm__ __volatile__( \
  995. " .set push \n" \
  996. " .set noat \n" \
  997. " # mflo %0, $ac2 \n" \
  998. " .word 0x00400812 \n" \
  999. " move %0, $1 \n" \
  1000. " .set pop \n" \
  1001. : "=r" (__treg)); \
  1002. __treg; \
  1003. })
  1004. #define mflo3() \
  1005. ({ \
  1006. unsigned long __treg; \
  1007. \
  1008. __asm__ __volatile__( \
  1009. " .set push \n" \
  1010. " .set noat \n" \
  1011. " # mflo %0, $ac3 \n" \
  1012. " .word 0x00600812 \n" \
  1013. " move %0, $1 \n" \
  1014. " .set pop \n" \
  1015. : "=r" (__treg)); \
  1016. __treg; \
  1017. })
  1018. #define mthi0(x) \
  1019. do { \
  1020. __asm__ __volatile__( \
  1021. " .set push \n" \
  1022. " .set noat \n" \
  1023. " move $1, %0 \n" \
  1024. " # mthi $1, $ac0 \n" \
  1025. " .word 0x00200011 \n" \
  1026. " .set pop \n" \
  1027. : \
  1028. : "r" (x)); \
  1029. } while (0)
  1030. #define mthi1(x) \
  1031. do { \
  1032. __asm__ __volatile__( \
  1033. " .set push \n" \
  1034. " .set noat \n" \
  1035. " move $1, %0 \n" \
  1036. " # mthi $1, $ac1 \n" \
  1037. " .word 0x00200811 \n" \
  1038. " .set pop \n" \
  1039. : \
  1040. : "r" (x)); \
  1041. } while (0)
  1042. #define mthi2(x) \
  1043. do { \
  1044. __asm__ __volatile__( \
  1045. " .set push \n" \
  1046. " .set noat \n" \
  1047. " move $1, %0 \n" \
  1048. " # mthi $1, $ac2 \n" \
  1049. " .word 0x00201011 \n" \
  1050. " .set pop \n" \
  1051. : \
  1052. : "r" (x)); \
  1053. } while (0)
  1054. #define mthi3(x) \
  1055. do { \
  1056. __asm__ __volatile__( \
  1057. " .set push \n" \
  1058. " .set noat \n" \
  1059. " move $1, %0 \n" \
  1060. " # mthi $1, $ac3 \n" \
  1061. " .word 0x00201811 \n" \
  1062. " .set pop \n" \
  1063. : \
  1064. : "r" (x)); \
  1065. } while (0)
  1066. #define mtlo0(x) \
  1067. do { \
  1068. __asm__ __volatile__( \
  1069. " .set push \n" \
  1070. " .set noat \n" \
  1071. " move $1, %0 \n" \
  1072. " # mtlo $1, $ac0 \n" \
  1073. " .word 0x00200013 \n" \
  1074. " .set pop \n" \
  1075. : \
  1076. : "r" (x)); \
  1077. } while (0)
  1078. #define mtlo1(x) \
  1079. do { \
  1080. __asm__ __volatile__( \
  1081. " .set push \n" \
  1082. " .set noat \n" \
  1083. " move $1, %0 \n" \
  1084. " # mtlo $1, $ac1 \n" \
  1085. " .word 0x00200813 \n" \
  1086. " .set pop \n" \
  1087. : \
  1088. : "r" (x)); \
  1089. } while (0)
  1090. #define mtlo2(x) \
  1091. do { \
  1092. __asm__ __volatile__( \
  1093. " .set push \n" \
  1094. " .set noat \n" \
  1095. " move $1, %0 \n" \
  1096. " # mtlo $1, $ac2 \n" \
  1097. " .word 0x00201013 \n" \
  1098. " .set pop \n" \
  1099. : \
  1100. : "r" (x)); \
  1101. } while (0)
  1102. #define mtlo3(x) \
  1103. do { \
  1104. __asm__ __volatile__( \
  1105. " .set push \n" \
  1106. " .set noat \n" \
  1107. " move $1, %0 \n" \
  1108. " # mtlo $1, $ac3 \n" \
  1109. " .word 0x00201813 \n" \
  1110. " .set pop \n" \
  1111. : \
  1112. : "r" (x)); \
  1113. } while (0)
  1114. /*
  1115. * TLB operations.
  1116. *
  1117. * It is responsibility of the caller to take care of any TLB hazards.
  1118. */
  1119. static inline void tlb_probe(void)
  1120. {
  1121. __asm__ __volatile__(
  1122. ".set noreorder\n\t"
  1123. "tlbp\n\t"
  1124. ".set reorder");
  1125. }
  1126. static inline void tlb_read(void)
  1127. {
  1128. #if MIPS34K_MISSED_ITLB_WAR
  1129. int res = 0;
  1130. __asm__ __volatile__(
  1131. " .set push \n"
  1132. " .set noreorder \n"
  1133. " .set noat \n"
  1134. " .set mips32r2 \n"
  1135. " .word 0x41610001 # dvpe $1 \n"
  1136. " move %0, $1 \n"
  1137. " ehb \n"
  1138. " .set pop \n"
  1139. : "=r" (res));
  1140. instruction_hazard();
  1141. #endif
  1142. __asm__ __volatile__(
  1143. ".set noreorder\n\t"
  1144. "tlbr\n\t"
  1145. ".set reorder");
  1146. #if MIPS34K_MISSED_ITLB_WAR
  1147. if ((res & _ULCAST_(1)))
  1148. __asm__ __volatile__(
  1149. " .set push \n"
  1150. " .set noreorder \n"
  1151. " .set noat \n"
  1152. " .set mips32r2 \n"
  1153. " .word 0x41600021 # evpe \n"
  1154. " ehb \n"
  1155. " .set pop \n");
  1156. #endif
  1157. }
  1158. static inline void tlb_write_indexed(void)
  1159. {
  1160. __asm__ __volatile__(
  1161. ".set noreorder\n\t"
  1162. "tlbwi\n\t"
  1163. ".set reorder");
  1164. }
  1165. static inline void tlb_write_random(void)
  1166. {
  1167. __asm__ __volatile__(
  1168. ".set noreorder\n\t"
  1169. "tlbwr\n\t"
  1170. ".set reorder");
  1171. }
  1172. /*
  1173. * Manipulate bits in a c0 register.
  1174. */
  1175. #define __BUILD_SET_C0(name) \
  1176. static inline unsigned int \
  1177. set_c0_##name(unsigned int set) \
  1178. { \
  1179. unsigned int res; \
  1180. \
  1181. res = read_c0_##name(); \
  1182. res |= set; \
  1183. write_c0_##name(res); \
  1184. \
  1185. return res; \
  1186. } \
  1187. \
  1188. static inline unsigned int \
  1189. clear_c0_##name(unsigned int clear) \
  1190. { \
  1191. unsigned int res; \
  1192. \
  1193. res = read_c0_##name(); \
  1194. res &= ~clear; \
  1195. write_c0_##name(res); \
  1196. \
  1197. return res; \
  1198. } \
  1199. \
  1200. static inline unsigned int \
  1201. change_c0_##name(unsigned int change, unsigned int new) \
  1202. { \
  1203. unsigned int res; \
  1204. \
  1205. res = read_c0_##name(); \
  1206. res &= ~change; \
  1207. res |= (new & change); \
  1208. write_c0_##name(res); \
  1209. \
  1210. return res; \
  1211. }
  1212. __BUILD_SET_C0(status)
  1213. __BUILD_SET_C0(cause)
  1214. __BUILD_SET_C0(config)
  1215. __BUILD_SET_C0(intcontrol)
  1216. __BUILD_SET_C0(intctl)
  1217. __BUILD_SET_C0(srsmap)
  1218. #endif /* !__ASSEMBLY__ */
  1219. #endif /* _ASM_MIPSREGS_H */