mipsregs.h 59 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011
  1. /*
  2. * Copyright (C) 1994, 1995, 1996, 1997, 2000, 2001 by Ralf Baechle
  3. * Copyright (C) 2000 Silicon Graphics, Inc.
  4. * Modified for further R[236]000 support by Paul M. Antoine, 1996.
  5. * Kevin D. Kissell, kevink@mips.com and Carsten Langgaard, carstenl@mips.com
  6. * Copyright (C) 2000, 07 MIPS Technologies, Inc.
  7. * Copyright (C) 2003, 2004 Maciej W. Rozycki
  8. *
  9. * SPDX-License-Identifier: GPL-2.0
  10. */
  11. #ifndef _ASM_MIPSREGS_H
  12. #define _ASM_MIPSREGS_H
  13. /*
  14. * The following macros are especially useful for __asm__
  15. * inline assembler.
  16. */
  17. #ifndef __STR
  18. #define __STR(x) #x
  19. #endif
  20. #ifndef STR
  21. #define STR(x) __STR(x)
  22. #endif
  23. /*
  24. * Configure language
  25. */
  26. #ifdef __ASSEMBLY__
  27. #define _ULCAST_
  28. #else
  29. #define _ULCAST_ (unsigned long)
  30. #endif
  31. /*
  32. * Coprocessor 0 register names
  33. */
  34. #define CP0_INDEX $0
  35. #define CP0_RANDOM $1
  36. #define CP0_ENTRYLO0 $2
  37. #define CP0_ENTRYLO1 $3
  38. #define CP0_CONF $3
  39. #define CP0_GLOBALNUMBER $3, 1
  40. #define CP0_CONTEXT $4
  41. #define CP0_PAGEMASK $5
  42. #define CP0_WIRED $6
  43. #define CP0_INFO $7
  44. #define CP0_HWRENA $7, 0
  45. #define CP0_BADVADDR $8
  46. #define CP0_BADINSTR $8, 1
  47. #define CP0_COUNT $9
  48. #define CP0_ENTRYHI $10
  49. #define CP0_COMPARE $11
  50. #define CP0_STATUS $12
  51. #define CP0_CAUSE $13
  52. #define CP0_EPC $14
  53. #define CP0_PRID $15
  54. #define CP0_EBASE $15, 1
  55. #define CP0_CMGCRBASE $15, 3
  56. #define CP0_CONFIG $16
  57. #define CP0_CONFIG3 $16, 3
  58. #define CP0_CONFIG5 $16, 5
  59. #define CP0_LLADDR $17
  60. #define CP0_WATCHLO $18
  61. #define CP0_WATCHHI $19
  62. #define CP0_XCONTEXT $20
  63. #define CP0_FRAMEMASK $21
  64. #define CP0_DIAGNOSTIC $22
  65. #define CP0_DEBUG $23
  66. #define CP0_DEPC $24
  67. #define CP0_PERFORMANCE $25
  68. #define CP0_ECC $26
  69. #define CP0_CACHEERR $27
  70. #define CP0_TAGLO $28
  71. #define CP0_TAGHI $29
  72. #define CP0_ERROREPC $30
  73. #define CP0_DESAVE $31
  74. /*
  75. * R4640/R4650 cp0 register names. These registers are listed
  76. * here only for completeness; without MMU these CPUs are not useable
  77. * by Linux. A future ELKS port might take make Linux run on them
  78. * though ...
  79. */
  80. #define CP0_IBASE $0
  81. #define CP0_IBOUND $1
  82. #define CP0_DBASE $2
  83. #define CP0_DBOUND $3
  84. #define CP0_CALG $17
  85. #define CP0_IWATCH $18
  86. #define CP0_DWATCH $19
  87. /*
  88. * Coprocessor 0 Set 1 register names
  89. */
  90. #define CP0_S1_DERRADDR0 $26
  91. #define CP0_S1_DERRADDR1 $27
  92. #define CP0_S1_INTCONTROL $20
  93. /*
  94. * Coprocessor 0 Set 2 register names
  95. */
  96. #define CP0_S2_SRSCTL $12 /* MIPSR2 */
  97. /*
  98. * Coprocessor 0 Set 3 register names
  99. */
  100. #define CP0_S3_SRSMAP $12 /* MIPSR2 */
  101. /*
  102. * TX39 Series
  103. */
  104. #define CP0_TX39_CACHE $7
  105. /* Generic EntryLo bit definitions */
  106. #define ENTRYLO_G (_ULCAST_(1) << 0)
  107. #define ENTRYLO_V (_ULCAST_(1) << 1)
  108. #define ENTRYLO_D (_ULCAST_(1) << 2)
  109. #define ENTRYLO_C_SHIFT 3
  110. #define ENTRYLO_C (_ULCAST_(7) << ENTRYLO_C_SHIFT)
  111. /* R3000 EntryLo bit definitions */
  112. #define R3K_ENTRYLO_G (_ULCAST_(1) << 8)
  113. #define R3K_ENTRYLO_V (_ULCAST_(1) << 9)
  114. #define R3K_ENTRYLO_D (_ULCAST_(1) << 10)
  115. #define R3K_ENTRYLO_N (_ULCAST_(1) << 11)
  116. /* MIPS32/64 EntryLo bit definitions */
  117. #define MIPS_ENTRYLO_PFN_SHIFT 6
  118. #define MIPS_ENTRYLO_XI (_ULCAST_(1) << (BITS_PER_LONG - 2))
  119. #define MIPS_ENTRYLO_RI (_ULCAST_(1) << (BITS_PER_LONG - 1))
  120. /*
  121. * Values for PageMask register
  122. */
  123. #ifdef CONFIG_CPU_VR41XX
  124. /* Why doesn't stupidity hurt ... */
  125. #define PM_1K 0x00000000
  126. #define PM_4K 0x00001800
  127. #define PM_16K 0x00007800
  128. #define PM_64K 0x0001f800
  129. #define PM_256K 0x0007f800
  130. #else
  131. #define PM_4K 0x00000000
  132. #define PM_8K 0x00002000
  133. #define PM_16K 0x00006000
  134. #define PM_32K 0x0000e000
  135. #define PM_64K 0x0001e000
  136. #define PM_128K 0x0003e000
  137. #define PM_256K 0x0007e000
  138. #define PM_512K 0x000fe000
  139. #define PM_1M 0x001fe000
  140. #define PM_2M 0x003fe000
  141. #define PM_4M 0x007fe000
  142. #define PM_8M 0x00ffe000
  143. #define PM_16M 0x01ffe000
  144. #define PM_32M 0x03ffe000
  145. #define PM_64M 0x07ffe000
  146. #define PM_256M 0x1fffe000
  147. #define PM_1G 0x7fffe000
  148. #endif
  149. /*
  150. * Values used for computation of new tlb entries
  151. */
  152. #define PL_4K 12
  153. #define PL_16K 14
  154. #define PL_64K 16
  155. #define PL_256K 18
  156. #define PL_1M 20
  157. #define PL_4M 22
  158. #define PL_16M 24
  159. #define PL_64M 26
  160. #define PL_256M 28
  161. /*
  162. * PageGrain bits
  163. */
  164. #define PG_RIE (_ULCAST_(1) << 31)
  165. #define PG_XIE (_ULCAST_(1) << 30)
  166. #define PG_ELPA (_ULCAST_(1) << 29)
  167. #define PG_ESP (_ULCAST_(1) << 28)
  168. #define PG_IEC (_ULCAST_(1) << 27)
  169. /* MIPS32/64 EntryHI bit definitions */
  170. #define MIPS_ENTRYHI_EHINV (_ULCAST_(1) << 10)
  171. /*
  172. * R4x00 interrupt enable / cause bits
  173. */
  174. #define IE_SW0 (_ULCAST_(1) << 8)
  175. #define IE_SW1 (_ULCAST_(1) << 9)
  176. #define IE_IRQ0 (_ULCAST_(1) << 10)
  177. #define IE_IRQ1 (_ULCAST_(1) << 11)
  178. #define IE_IRQ2 (_ULCAST_(1) << 12)
  179. #define IE_IRQ3 (_ULCAST_(1) << 13)
  180. #define IE_IRQ4 (_ULCAST_(1) << 14)
  181. #define IE_IRQ5 (_ULCAST_(1) << 15)
  182. /*
  183. * R4x00 interrupt cause bits
  184. */
  185. #define C_SW0 (_ULCAST_(1) << 8)
  186. #define C_SW1 (_ULCAST_(1) << 9)
  187. #define C_IRQ0 (_ULCAST_(1) << 10)
  188. #define C_IRQ1 (_ULCAST_(1) << 11)
  189. #define C_IRQ2 (_ULCAST_(1) << 12)
  190. #define C_IRQ3 (_ULCAST_(1) << 13)
  191. #define C_IRQ4 (_ULCAST_(1) << 14)
  192. #define C_IRQ5 (_ULCAST_(1) << 15)
  193. /*
  194. * Bitfields in the R4xx0 cp0 status register
  195. */
  196. #define ST0_IE 0x00000001
  197. #define ST0_EXL 0x00000002
  198. #define ST0_ERL 0x00000004
  199. #define ST0_KSU 0x00000018
  200. # define KSU_USER 0x00000010
  201. # define KSU_SUPERVISOR 0x00000008
  202. # define KSU_KERNEL 0x00000000
  203. #define ST0_UX 0x00000020
  204. #define ST0_SX 0x00000040
  205. #define ST0_KX 0x00000080
  206. #define ST0_DE 0x00010000
  207. #define ST0_CE 0x00020000
  208. /*
  209. * Setting c0_status.co enables Hit_Writeback and Hit_Writeback_Invalidate
  210. * cacheops in userspace. This bit exists only on RM7000 and RM9000
  211. * processors.
  212. */
  213. #define ST0_CO 0x08000000
  214. /*
  215. * Bitfields in the R[23]000 cp0 status register.
  216. */
  217. #define ST0_IEC 0x00000001
  218. #define ST0_KUC 0x00000002
  219. #define ST0_IEP 0x00000004
  220. #define ST0_KUP 0x00000008
  221. #define ST0_IEO 0x00000010
  222. #define ST0_KUO 0x00000020
  223. /* bits 6 & 7 are reserved on R[23]000 */
  224. #define ST0_ISC 0x00010000
  225. #define ST0_SWC 0x00020000
  226. #define ST0_CM 0x00080000
  227. /*
  228. * Bits specific to the R4640/R4650
  229. */
  230. #define ST0_UM (_ULCAST_(1) << 4)
  231. #define ST0_IL (_ULCAST_(1) << 23)
  232. #define ST0_DL (_ULCAST_(1) << 24)
  233. /*
  234. * Enable the MIPS MDMX and DSP ASEs
  235. */
  236. #define ST0_MX 0x01000000
  237. /*
  238. * Status register bits available in all MIPS CPUs.
  239. */
  240. #define ST0_IM 0x0000ff00
  241. #define STATUSB_IP0 8
  242. #define STATUSF_IP0 (_ULCAST_(1) << 8)
  243. #define STATUSB_IP1 9
  244. #define STATUSF_IP1 (_ULCAST_(1) << 9)
  245. #define STATUSB_IP2 10
  246. #define STATUSF_IP2 (_ULCAST_(1) << 10)
  247. #define STATUSB_IP3 11
  248. #define STATUSF_IP3 (_ULCAST_(1) << 11)
  249. #define STATUSB_IP4 12
  250. #define STATUSF_IP4 (_ULCAST_(1) << 12)
  251. #define STATUSB_IP5 13
  252. #define STATUSF_IP5 (_ULCAST_(1) << 13)
  253. #define STATUSB_IP6 14
  254. #define STATUSF_IP6 (_ULCAST_(1) << 14)
  255. #define STATUSB_IP7 15
  256. #define STATUSF_IP7 (_ULCAST_(1) << 15)
  257. #define STATUSB_IP8 0
  258. #define STATUSF_IP8 (_ULCAST_(1) << 0)
  259. #define STATUSB_IP9 1
  260. #define STATUSF_IP9 (_ULCAST_(1) << 1)
  261. #define STATUSB_IP10 2
  262. #define STATUSF_IP10 (_ULCAST_(1) << 2)
  263. #define STATUSB_IP11 3
  264. #define STATUSF_IP11 (_ULCAST_(1) << 3)
  265. #define STATUSB_IP12 4
  266. #define STATUSF_IP12 (_ULCAST_(1) << 4)
  267. #define STATUSB_IP13 5
  268. #define STATUSF_IP13 (_ULCAST_(1) << 5)
  269. #define STATUSB_IP14 6
  270. #define STATUSF_IP14 (_ULCAST_(1) << 6)
  271. #define STATUSB_IP15 7
  272. #define STATUSF_IP15 (_ULCAST_(1) << 7)
  273. #define ST0_IMPL (_ULCAST_(3) << 16)
  274. #define ST0_CH 0x00040000
  275. #define ST0_NMI 0x00080000
  276. #define ST0_SR 0x00100000
  277. #define ST0_TS 0x00200000
  278. #define ST0_BEV 0x00400000
  279. #define ST0_RE 0x02000000
  280. #define ST0_FR 0x04000000
  281. #define ST0_CU 0xf0000000
  282. #define ST0_CU0 0x10000000
  283. #define ST0_CU1 0x20000000
  284. #define ST0_CU2 0x40000000
  285. #define ST0_CU3 0x80000000
  286. #define ST0_XX 0x80000000 /* MIPS IV naming */
  287. /*
  288. * Bitfields and bit numbers in the coprocessor 0 IntCtl register. (MIPSR2)
  289. */
  290. #define INTCTLB_IPFDC 23
  291. #define INTCTLF_IPFDC (_ULCAST_(7) << INTCTLB_IPFDC)
  292. #define INTCTLB_IPPCI 26
  293. #define INTCTLF_IPPCI (_ULCAST_(7) << INTCTLB_IPPCI)
  294. #define INTCTLB_IPTI 29
  295. #define INTCTLF_IPTI (_ULCAST_(7) << INTCTLB_IPTI)
  296. /*
  297. * Bitfields and bit numbers in the coprocessor 0 cause register.
  298. *
  299. * Refer to your MIPS R4xx0 manual, chapter 5 for explanation.
  300. */
  301. #define CAUSEB_EXCCODE 2
  302. #define CAUSEF_EXCCODE (_ULCAST_(31) << 2)
  303. #define CAUSEB_IP 8
  304. #define CAUSEF_IP (_ULCAST_(255) << 8)
  305. #define CAUSEB_IP0 8
  306. #define CAUSEF_IP0 (_ULCAST_(1) << 8)
  307. #define CAUSEB_IP1 9
  308. #define CAUSEF_IP1 (_ULCAST_(1) << 9)
  309. #define CAUSEB_IP2 10
  310. #define CAUSEF_IP2 (_ULCAST_(1) << 10)
  311. #define CAUSEB_IP3 11
  312. #define CAUSEF_IP3 (_ULCAST_(1) << 11)
  313. #define CAUSEB_IP4 12
  314. #define CAUSEF_IP4 (_ULCAST_(1) << 12)
  315. #define CAUSEB_IP5 13
  316. #define CAUSEF_IP5 (_ULCAST_(1) << 13)
  317. #define CAUSEB_IP6 14
  318. #define CAUSEF_IP6 (_ULCAST_(1) << 14)
  319. #define CAUSEB_IP7 15
  320. #define CAUSEF_IP7 (_ULCAST_(1) << 15)
  321. #define CAUSEB_FDCI 21
  322. #define CAUSEF_FDCI (_ULCAST_(1) << 21)
  323. #define CAUSEB_IV 23
  324. #define CAUSEF_IV (_ULCAST_(1) << 23)
  325. #define CAUSEB_PCI 26
  326. #define CAUSEF_PCI (_ULCAST_(1) << 26)
  327. #define CAUSEB_CE 28
  328. #define CAUSEF_CE (_ULCAST_(3) << 28)
  329. #define CAUSEB_TI 30
  330. #define CAUSEF_TI (_ULCAST_(1) << 30)
  331. #define CAUSEB_BD 31
  332. #define CAUSEF_BD (_ULCAST_(1) << 31)
  333. /*
  334. * Bits in the coprocessor 0 EBase register.
  335. */
  336. #define EBASE_CPUNUM 0x3ff
  337. /*
  338. * Bits in the coprocessor 0 config register.
  339. */
  340. /* Generic bits. */
  341. #define CONF_CM_CACHABLE_NO_WA 0
  342. #define CONF_CM_CACHABLE_WA 1
  343. #define CONF_CM_UNCACHED 2
  344. #define CONF_CM_CACHABLE_NONCOHERENT 3
  345. #define CONF_CM_CACHABLE_CE 4
  346. #define CONF_CM_CACHABLE_COW 5
  347. #define CONF_CM_CACHABLE_CUW 6
  348. #define CONF_CM_CACHABLE_ACCELERATED 7
  349. #define CONF_CM_CMASK 7
  350. #define CONF_BE (_ULCAST_(1) << 15)
  351. /* Bits common to various processors. */
  352. #define CONF_CU (_ULCAST_(1) << 3)
  353. #define CONF_DB (_ULCAST_(1) << 4)
  354. #define CONF_IB (_ULCAST_(1) << 5)
  355. #define CONF_DC (_ULCAST_(7) << 6)
  356. #define CONF_IC (_ULCAST_(7) << 9)
  357. #define CONF_EB (_ULCAST_(1) << 13)
  358. #define CONF_EM (_ULCAST_(1) << 14)
  359. #define CONF_SM (_ULCAST_(1) << 16)
  360. #define CONF_SC (_ULCAST_(1) << 17)
  361. #define CONF_EW (_ULCAST_(3) << 18)
  362. #define CONF_EP (_ULCAST_(15) << 24)
  363. #define CONF_EC (_ULCAST_(7) << 28)
  364. #define CONF_CM (_ULCAST_(1) << 31)
  365. /* Bits specific to the R4xx0. */
  366. #define R4K_CONF_SW (_ULCAST_(1) << 20)
  367. #define R4K_CONF_SS (_ULCAST_(1) << 21)
  368. #define R4K_CONF_SB (_ULCAST_(3) << 22)
  369. /* Bits specific to the R5000. */
  370. #define R5K_CONF_SE (_ULCAST_(1) << 12)
  371. #define R5K_CONF_SS (_ULCAST_(3) << 20)
  372. /* Bits specific to the RM7000. */
  373. #define RM7K_CONF_SE (_ULCAST_(1) << 3)
  374. #define RM7K_CONF_TE (_ULCAST_(1) << 12)
  375. #define RM7K_CONF_CLK (_ULCAST_(1) << 16)
  376. #define RM7K_CONF_TC (_ULCAST_(1) << 17)
  377. #define RM7K_CONF_SI (_ULCAST_(3) << 20)
  378. #define RM7K_CONF_SC (_ULCAST_(1) << 31)
  379. /* Bits specific to the R10000. */
  380. #define R10K_CONF_DN (_ULCAST_(3) << 3)
  381. #define R10K_CONF_CT (_ULCAST_(1) << 5)
  382. #define R10K_CONF_PE (_ULCAST_(1) << 6)
  383. #define R10K_CONF_PM (_ULCAST_(3) << 7)
  384. #define R10K_CONF_EC (_ULCAST_(15) << 9)
  385. #define R10K_CONF_SB (_ULCAST_(1) << 13)
  386. #define R10K_CONF_SK (_ULCAST_(1) << 14)
  387. #define R10K_CONF_SS (_ULCAST_(7) << 16)
  388. #define R10K_CONF_SC (_ULCAST_(7) << 19)
  389. #define R10K_CONF_DC (_ULCAST_(7) << 26)
  390. #define R10K_CONF_IC (_ULCAST_(7) << 29)
  391. /* Bits specific to the VR41xx. */
  392. #define VR41_CONF_CS (_ULCAST_(1) << 12)
  393. #define VR41_CONF_P4K (_ULCAST_(1) << 13)
  394. #define VR41_CONF_BP (_ULCAST_(1) << 16)
  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_MT_TLB (_ULCAST_(1) << 7)
  415. #define MIPS_CONF_MT_FTLB (_ULCAST_(4) << 7)
  416. #define MIPS_CONF_AR (_ULCAST_(7) << 10)
  417. #define MIPS_CONF_AT (_ULCAST_(3) << 13)
  418. #define MIPS_CONF_IMPL (_ULCAST_(0x1ff) << 16)
  419. #define MIPS_CONF_M (_ULCAST_(1) << 31)
  420. /*
  421. * Bits in the MIPS32/64 PRA coprocessor 0 config registers 1 and above.
  422. */
  423. #define MIPS_CONF1_FP (_ULCAST_(1) << 0)
  424. #define MIPS_CONF1_EP (_ULCAST_(1) << 1)
  425. #define MIPS_CONF1_CA (_ULCAST_(1) << 2)
  426. #define MIPS_CONF1_WR (_ULCAST_(1) << 3)
  427. #define MIPS_CONF1_PC (_ULCAST_(1) << 4)
  428. #define MIPS_CONF1_MD (_ULCAST_(1) << 5)
  429. #define MIPS_CONF1_C2 (_ULCAST_(1) << 6)
  430. #define MIPS_CONF1_DA_SHF 7
  431. #define MIPS_CONF1_DA_SZ 3
  432. #define MIPS_CONF1_DA (_ULCAST_(7) << 7)
  433. #define MIPS_CONF1_DL_SHF 10
  434. #define MIPS_CONF1_DL_SZ 3
  435. #define MIPS_CONF1_DL (_ULCAST_(7) << 10)
  436. #define MIPS_CONF1_DS_SHF 13
  437. #define MIPS_CONF1_DS_SZ 3
  438. #define MIPS_CONF1_DS (_ULCAST_(7) << 13)
  439. #define MIPS_CONF1_IA_SHF 16
  440. #define MIPS_CONF1_IA_SZ 3
  441. #define MIPS_CONF1_IA (_ULCAST_(7) << 16)
  442. #define MIPS_CONF1_IL_SHF 19
  443. #define MIPS_CONF1_IL_SZ 3
  444. #define MIPS_CONF1_IL (_ULCAST_(7) << 19)
  445. #define MIPS_CONF1_IS_SHF 22
  446. #define MIPS_CONF1_IS_SZ 3
  447. #define MIPS_CONF1_IS (_ULCAST_(7) << 22)
  448. #define MIPS_CONF1_TLBS_SHIFT (25)
  449. #define MIPS_CONF1_TLBS_SIZE (6)
  450. #define MIPS_CONF1_TLBS (_ULCAST_(63) << MIPS_CONF1_TLBS_SHIFT)
  451. #define MIPS_CONF2_SA_SHF 0
  452. #define MIPS_CONF2_SA (_ULCAST_(15) << 0)
  453. #define MIPS_CONF2_SL_SHF 4
  454. #define MIPS_CONF2_SL (_ULCAST_(15) << 4)
  455. #define MIPS_CONF2_SS_SHF 8
  456. #define MIPS_CONF2_SS (_ULCAST_(15) << 8)
  457. #define MIPS_CONF2_L2B (_ULCAST_(1) << 12)
  458. #define MIPS_CONF2_SU (_ULCAST_(15) << 12)
  459. #define MIPS_CONF2_TA (_ULCAST_(15) << 16)
  460. #define MIPS_CONF2_TL (_ULCAST_(15) << 20)
  461. #define MIPS_CONF2_TS (_ULCAST_(15) << 24)
  462. #define MIPS_CONF2_TU (_ULCAST_(7) << 28)
  463. #define MIPS_CONF3_TL (_ULCAST_(1) << 0)
  464. #define MIPS_CONF3_SM (_ULCAST_(1) << 1)
  465. #define MIPS_CONF3_MT (_ULCAST_(1) << 2)
  466. #define MIPS_CONF3_CDMM (_ULCAST_(1) << 3)
  467. #define MIPS_CONF3_SP (_ULCAST_(1) << 4)
  468. #define MIPS_CONF3_VINT (_ULCAST_(1) << 5)
  469. #define MIPS_CONF3_VEIC (_ULCAST_(1) << 6)
  470. #define MIPS_CONF3_LPA (_ULCAST_(1) << 7)
  471. #define MIPS_CONF3_ITL (_ULCAST_(1) << 8)
  472. #define MIPS_CONF3_CTXTC (_ULCAST_(1) << 9)
  473. #define MIPS_CONF3_DSP (_ULCAST_(1) << 10)
  474. #define MIPS_CONF3_DSP2P (_ULCAST_(1) << 11)
  475. #define MIPS_CONF3_RXI (_ULCAST_(1) << 12)
  476. #define MIPS_CONF3_ULRI (_ULCAST_(1) << 13)
  477. #define MIPS_CONF3_ISA (_ULCAST_(3) << 14)
  478. #define MIPS_CONF3_ISA_OE (_ULCAST_(1) << 16)
  479. #define MIPS_CONF3_MCU (_ULCAST_(1) << 17)
  480. #define MIPS_CONF3_MMAR (_ULCAST_(7) << 18)
  481. #define MIPS_CONF3_IPLW (_ULCAST_(3) << 21)
  482. #define MIPS_CONF3_VZ (_ULCAST_(1) << 23)
  483. #define MIPS_CONF3_PW (_ULCAST_(1) << 24)
  484. #define MIPS_CONF3_SC (_ULCAST_(1) << 25)
  485. #define MIPS_CONF3_BI (_ULCAST_(1) << 26)
  486. #define MIPS_CONF3_BP (_ULCAST_(1) << 27)
  487. #define MIPS_CONF3_MSA (_ULCAST_(1) << 28)
  488. #define MIPS_CONF3_CMGCR (_ULCAST_(1) << 29)
  489. #define MIPS_CONF3_BPG (_ULCAST_(1) << 30)
  490. #define MIPS_CONF4_MMUSIZEEXT_SHIFT (0)
  491. #define MIPS_CONF4_MMUSIZEEXT (_ULCAST_(255) << 0)
  492. #define MIPS_CONF4_FTLBSETS_SHIFT (0)
  493. #define MIPS_CONF4_FTLBSETS (_ULCAST_(15) << MIPS_CONF4_FTLBSETS_SHIFT)
  494. #define MIPS_CONF4_FTLBWAYS_SHIFT (4)
  495. #define MIPS_CONF4_FTLBWAYS (_ULCAST_(15) << MIPS_CONF4_FTLBWAYS_SHIFT)
  496. #define MIPS_CONF4_FTLBPAGESIZE_SHIFT (8)
  497. /* bits 10:8 in FTLB-only configurations */
  498. #define MIPS_CONF4_FTLBPAGESIZE (_ULCAST_(7) << MIPS_CONF4_FTLBPAGESIZE_SHIFT)
  499. /* bits 12:8 in VTLB-FTLB only configurations */
  500. #define MIPS_CONF4_VFTLBPAGESIZE (_ULCAST_(31) << MIPS_CONF4_FTLBPAGESIZE_SHIFT)
  501. #define MIPS_CONF4_MMUEXTDEF (_ULCAST_(3) << 14)
  502. #define MIPS_CONF4_MMUEXTDEF_MMUSIZEEXT (_ULCAST_(1) << 14)
  503. #define MIPS_CONF4_MMUEXTDEF_FTLBSIZEEXT (_ULCAST_(2) << 14)
  504. #define MIPS_CONF4_MMUEXTDEF_VTLBSIZEEXT (_ULCAST_(3) << 14)
  505. #define MIPS_CONF4_KSCREXIST (_ULCAST_(255) << 16)
  506. #define MIPS_CONF4_VTLBSIZEEXT_SHIFT (24)
  507. #define MIPS_CONF4_VTLBSIZEEXT (_ULCAST_(15) << MIPS_CONF4_VTLBSIZEEXT_SHIFT)
  508. #define MIPS_CONF4_AE (_ULCAST_(1) << 28)
  509. #define MIPS_CONF4_IE (_ULCAST_(3) << 29)
  510. #define MIPS_CONF4_TLBINV (_ULCAST_(2) << 29)
  511. #define MIPS_CONF5_NF (_ULCAST_(1) << 0)
  512. #define MIPS_CONF5_UFR (_ULCAST_(1) << 2)
  513. #define MIPS_CONF5_MRP (_ULCAST_(1) << 3)
  514. #define MIPS_CONF5_LLB (_ULCAST_(1) << 4)
  515. #define MIPS_CONF5_MVH (_ULCAST_(1) << 5)
  516. #define MIPS_CONF5_VP (_ULCAST_(1) << 7)
  517. #define MIPS_CONF5_FRE (_ULCAST_(1) << 8)
  518. #define MIPS_CONF5_UFE (_ULCAST_(1) << 9)
  519. #define MIPS_CONF5_L2C (_ULCAST_(1) << 10)
  520. #define MIPS_CONF5_MSAEN (_ULCAST_(1) << 27)
  521. #define MIPS_CONF5_EVA (_ULCAST_(1) << 28)
  522. #define MIPS_CONF5_CV (_ULCAST_(1) << 29)
  523. #define MIPS_CONF5_K (_ULCAST_(1) << 30)
  524. #define MIPS_CONF6_SYND (_ULCAST_(1) << 13)
  525. /* proAptiv FTLB on/off bit */
  526. #define MIPS_CONF6_FTLBEN (_ULCAST_(1) << 15)
  527. /* FTLB probability bits */
  528. #define MIPS_CONF6_FTLBP_SHIFT (16)
  529. #define MIPS_CONF7_WII (_ULCAST_(1) << 31)
  530. #define MIPS_CONF7_RPS (_ULCAST_(1) << 2)
  531. #define MIPS_CONF7_IAR (_ULCAST_(1) << 10)
  532. #define MIPS_CONF7_AR (_ULCAST_(1) << 16)
  533. /* FTLB probability bits for R6 */
  534. #define MIPS_CONF7_FTLBP_SHIFT (18)
  535. /* MAAR bit definitions */
  536. #define MIPS_MAAR_ADDR ((BIT_ULL(BITS_PER_LONG - 12) - 1) << 12)
  537. #define MIPS_MAAR_ADDR_SHIFT 12
  538. #define MIPS_MAAR_S (_ULCAST_(1) << 1)
  539. #define MIPS_MAAR_V (_ULCAST_(1) << 0)
  540. /* CMGCRBase bit definitions */
  541. #define MIPS_CMGCRB_BASE 11
  542. #define MIPS_CMGCRF_BASE (~_ULCAST_((1 << MIPS_CMGCRB_BASE) - 1))
  543. /*
  544. * Bits in the MIPS32 Memory Segmentation registers.
  545. */
  546. #define MIPS_SEGCFG_PA_SHIFT 9
  547. #define MIPS_SEGCFG_PA (_ULCAST_(127) << MIPS_SEGCFG_PA_SHIFT)
  548. #define MIPS_SEGCFG_AM_SHIFT 4
  549. #define MIPS_SEGCFG_AM (_ULCAST_(7) << MIPS_SEGCFG_AM_SHIFT)
  550. #define MIPS_SEGCFG_EU_SHIFT 3
  551. #define MIPS_SEGCFG_EU (_ULCAST_(1) << MIPS_SEGCFG_EU_SHIFT)
  552. #define MIPS_SEGCFG_C_SHIFT 0
  553. #define MIPS_SEGCFG_C (_ULCAST_(7) << MIPS_SEGCFG_C_SHIFT)
  554. #define MIPS_SEGCFG_UUSK _ULCAST_(7)
  555. #define MIPS_SEGCFG_USK _ULCAST_(5)
  556. #define MIPS_SEGCFG_MUSUK _ULCAST_(4)
  557. #define MIPS_SEGCFG_MUSK _ULCAST_(3)
  558. #define MIPS_SEGCFG_MSK _ULCAST_(2)
  559. #define MIPS_SEGCFG_MK _ULCAST_(1)
  560. #define MIPS_SEGCFG_UK _ULCAST_(0)
  561. #define MIPS_PWFIELD_GDI_SHIFT 24
  562. #define MIPS_PWFIELD_GDI_MASK 0x3f000000
  563. #define MIPS_PWFIELD_UDI_SHIFT 18
  564. #define MIPS_PWFIELD_UDI_MASK 0x00fc0000
  565. #define MIPS_PWFIELD_MDI_SHIFT 12
  566. #define MIPS_PWFIELD_MDI_MASK 0x0003f000
  567. #define MIPS_PWFIELD_PTI_SHIFT 6
  568. #define MIPS_PWFIELD_PTI_MASK 0x00000fc0
  569. #define MIPS_PWFIELD_PTEI_SHIFT 0
  570. #define MIPS_PWFIELD_PTEI_MASK 0x0000003f
  571. #define MIPS_PWSIZE_GDW_SHIFT 24
  572. #define MIPS_PWSIZE_GDW_MASK 0x3f000000
  573. #define MIPS_PWSIZE_UDW_SHIFT 18
  574. #define MIPS_PWSIZE_UDW_MASK 0x00fc0000
  575. #define MIPS_PWSIZE_MDW_SHIFT 12
  576. #define MIPS_PWSIZE_MDW_MASK 0x0003f000
  577. #define MIPS_PWSIZE_PTW_SHIFT 6
  578. #define MIPS_PWSIZE_PTW_MASK 0x00000fc0
  579. #define MIPS_PWSIZE_PTEW_SHIFT 0
  580. #define MIPS_PWSIZE_PTEW_MASK 0x0000003f
  581. #define MIPS_PWCTL_PWEN_SHIFT 31
  582. #define MIPS_PWCTL_PWEN_MASK 0x80000000
  583. #define MIPS_PWCTL_DPH_SHIFT 7
  584. #define MIPS_PWCTL_DPH_MASK 0x00000080
  585. #define MIPS_PWCTL_HUGEPG_SHIFT 6
  586. #define MIPS_PWCTL_HUGEPG_MASK 0x00000060
  587. #define MIPS_PWCTL_PSN_SHIFT 0
  588. #define MIPS_PWCTL_PSN_MASK 0x0000003f
  589. /* CDMMBase register bit definitions */
  590. #define MIPS_CDMMBASE_SIZE_SHIFT 0
  591. #define MIPS_CDMMBASE_SIZE (_ULCAST_(511) << MIPS_CDMMBASE_SIZE_SHIFT)
  592. #define MIPS_CDMMBASE_CI (_ULCAST_(1) << 9)
  593. #define MIPS_CDMMBASE_EN (_ULCAST_(1) << 10)
  594. #define MIPS_CDMMBASE_ADDR_SHIFT 11
  595. #define MIPS_CDMMBASE_ADDR_START 15
  596. /*
  597. * Bitfields in the TX39 family CP0 Configuration Register 3
  598. */
  599. #define TX39_CONF_ICS_SHIFT 19
  600. #define TX39_CONF_ICS_MASK 0x00380000
  601. #define TX39_CONF_ICS_1KB 0x00000000
  602. #define TX39_CONF_ICS_2KB 0x00080000
  603. #define TX39_CONF_ICS_4KB 0x00100000
  604. #define TX39_CONF_ICS_8KB 0x00180000
  605. #define TX39_CONF_ICS_16KB 0x00200000
  606. #define TX39_CONF_DCS_SHIFT 16
  607. #define TX39_CONF_DCS_MASK 0x00070000
  608. #define TX39_CONF_DCS_1KB 0x00000000
  609. #define TX39_CONF_DCS_2KB 0x00010000
  610. #define TX39_CONF_DCS_4KB 0x00020000
  611. #define TX39_CONF_DCS_8KB 0x00030000
  612. #define TX39_CONF_DCS_16KB 0x00040000
  613. #define TX39_CONF_CWFON 0x00004000
  614. #define TX39_CONF_WBON 0x00002000
  615. #define TX39_CONF_RF_SHIFT 10
  616. #define TX39_CONF_RF_MASK 0x00000c00
  617. #define TX39_CONF_DOZE 0x00000200
  618. #define TX39_CONF_HALT 0x00000100
  619. #define TX39_CONF_LOCK 0x00000080
  620. #define TX39_CONF_ICE 0x00000020
  621. #define TX39_CONF_DCE 0x00000010
  622. #define TX39_CONF_IRSIZE_SHIFT 2
  623. #define TX39_CONF_IRSIZE_MASK 0x0000000c
  624. #define TX39_CONF_DRSIZE_SHIFT 0
  625. #define TX39_CONF_DRSIZE_MASK 0x00000003
  626. /*
  627. * Interesting Bits in the R10K CP0 Branch Diagnostic Register
  628. */
  629. /* Disable Branch Target Address Cache */
  630. #define R10K_DIAG_D_BTAC (_ULCAST_(1) << 27)
  631. /* Enable Branch Prediction Global History */
  632. #define R10K_DIAG_E_GHIST (_ULCAST_(1) << 26)
  633. /* Disable Branch Return Cache */
  634. #define R10K_DIAG_D_BRC (_ULCAST_(1) << 22)
  635. /*
  636. * Coprocessor 1 (FPU) register names
  637. */
  638. #define CP1_REVISION $0
  639. #define CP1_UFR $1
  640. #define CP1_UNFR $4
  641. #define CP1_FCCR $25
  642. #define CP1_FEXR $26
  643. #define CP1_FENR $28
  644. #define CP1_STATUS $31
  645. /*
  646. * Bits in the MIPS32/64 coprocessor 1 (FPU) revision register.
  647. */
  648. #define MIPS_FPIR_S (_ULCAST_(1) << 16)
  649. #define MIPS_FPIR_D (_ULCAST_(1) << 17)
  650. #define MIPS_FPIR_PS (_ULCAST_(1) << 18)
  651. #define MIPS_FPIR_3D (_ULCAST_(1) << 19)
  652. #define MIPS_FPIR_W (_ULCAST_(1) << 20)
  653. #define MIPS_FPIR_L (_ULCAST_(1) << 21)
  654. #define MIPS_FPIR_F64 (_ULCAST_(1) << 22)
  655. #define MIPS_FPIR_HAS2008 (_ULCAST_(1) << 23)
  656. #define MIPS_FPIR_UFRP (_ULCAST_(1) << 28)
  657. #define MIPS_FPIR_FREP (_ULCAST_(1) << 29)
  658. /*
  659. * Bits in the MIPS32/64 coprocessor 1 (FPU) condition codes register.
  660. */
  661. #define MIPS_FCCR_CONDX_S 0
  662. #define MIPS_FCCR_CONDX (_ULCAST_(255) << MIPS_FCCR_CONDX_S)
  663. #define MIPS_FCCR_COND0_S 0
  664. #define MIPS_FCCR_COND0 (_ULCAST_(1) << MIPS_FCCR_COND0_S)
  665. #define MIPS_FCCR_COND1_S 1
  666. #define MIPS_FCCR_COND1 (_ULCAST_(1) << MIPS_FCCR_COND1_S)
  667. #define MIPS_FCCR_COND2_S 2
  668. #define MIPS_FCCR_COND2 (_ULCAST_(1) << MIPS_FCCR_COND2_S)
  669. #define MIPS_FCCR_COND3_S 3
  670. #define MIPS_FCCR_COND3 (_ULCAST_(1) << MIPS_FCCR_COND3_S)
  671. #define MIPS_FCCR_COND4_S 4
  672. #define MIPS_FCCR_COND4 (_ULCAST_(1) << MIPS_FCCR_COND4_S)
  673. #define MIPS_FCCR_COND5_S 5
  674. #define MIPS_FCCR_COND5 (_ULCAST_(1) << MIPS_FCCR_COND5_S)
  675. #define MIPS_FCCR_COND6_S 6
  676. #define MIPS_FCCR_COND6 (_ULCAST_(1) << MIPS_FCCR_COND6_S)
  677. #define MIPS_FCCR_COND7_S 7
  678. #define MIPS_FCCR_COND7 (_ULCAST_(1) << MIPS_FCCR_COND7_S)
  679. /*
  680. * Bits in the MIPS32/64 coprocessor 1 (FPU) enables register.
  681. */
  682. #define MIPS_FENR_FS_S 2
  683. #define MIPS_FENR_FS (_ULCAST_(1) << MIPS_FENR_FS_S)
  684. /*
  685. * FPU Status Register Values
  686. */
  687. #define FPU_CSR_COND_S 23 /* $fcc0 */
  688. #define FPU_CSR_COND (_ULCAST_(1) << FPU_CSR_COND_S)
  689. #define FPU_CSR_FS_S 24 /* flush denormalised results to 0 */
  690. #define FPU_CSR_FS (_ULCAST_(1) << FPU_CSR_FS_S)
  691. #define FPU_CSR_CONDX_S 25 /* $fcc[7:1] */
  692. #define FPU_CSR_CONDX (_ULCAST_(127) << FPU_CSR_CONDX_S)
  693. #define FPU_CSR_COND1_S 25 /* $fcc1 */
  694. #define FPU_CSR_COND1 (_ULCAST_(1) << FPU_CSR_COND1_S)
  695. #define FPU_CSR_COND2_S 26 /* $fcc2 */
  696. #define FPU_CSR_COND2 (_ULCAST_(1) << FPU_CSR_COND2_S)
  697. #define FPU_CSR_COND3_S 27 /* $fcc3 */
  698. #define FPU_CSR_COND3 (_ULCAST_(1) << FPU_CSR_COND3_S)
  699. #define FPU_CSR_COND4_S 28 /* $fcc4 */
  700. #define FPU_CSR_COND4 (_ULCAST_(1) << FPU_CSR_COND4_S)
  701. #define FPU_CSR_COND5_S 29 /* $fcc5 */
  702. #define FPU_CSR_COND5 (_ULCAST_(1) << FPU_CSR_COND5_S)
  703. #define FPU_CSR_COND6_S 30 /* $fcc6 */
  704. #define FPU_CSR_COND6 (_ULCAST_(1) << FPU_CSR_COND6_S)
  705. #define FPU_CSR_COND7_S 31 /* $fcc7 */
  706. #define FPU_CSR_COND7 (_ULCAST_(1) << FPU_CSR_COND7_S)
  707. /*
  708. * Bits 22:20 of the FPU Status Register will be read as 0,
  709. * and should be written as zero.
  710. */
  711. #define FPU_CSR_RSVD (_ULCAST_(7) << 20)
  712. #define FPU_CSR_ABS2008 (_ULCAST_(1) << 19)
  713. #define FPU_CSR_NAN2008 (_ULCAST_(1) << 18)
  714. /*
  715. * X the exception cause indicator
  716. * E the exception enable
  717. * S the sticky/flag bit
  718. */
  719. #define FPU_CSR_ALL_X 0x0003f000
  720. #define FPU_CSR_UNI_X 0x00020000
  721. #define FPU_CSR_INV_X 0x00010000
  722. #define FPU_CSR_DIV_X 0x00008000
  723. #define FPU_CSR_OVF_X 0x00004000
  724. #define FPU_CSR_UDF_X 0x00002000
  725. #define FPU_CSR_INE_X 0x00001000
  726. #define FPU_CSR_ALL_E 0x00000f80
  727. #define FPU_CSR_INV_E 0x00000800
  728. #define FPU_CSR_DIV_E 0x00000400
  729. #define FPU_CSR_OVF_E 0x00000200
  730. #define FPU_CSR_UDF_E 0x00000100
  731. #define FPU_CSR_INE_E 0x00000080
  732. #define FPU_CSR_ALL_S 0x0000007c
  733. #define FPU_CSR_INV_S 0x00000040
  734. #define FPU_CSR_DIV_S 0x00000020
  735. #define FPU_CSR_OVF_S 0x00000010
  736. #define FPU_CSR_UDF_S 0x00000008
  737. #define FPU_CSR_INE_S 0x00000004
  738. /* Bits 0 and 1 of FPU Status Register specify the rounding mode */
  739. #define FPU_CSR_RM 0x00000003
  740. #define FPU_CSR_RN 0x0 /* nearest */
  741. #define FPU_CSR_RZ 0x1 /* towards zero */
  742. #define FPU_CSR_RU 0x2 /* towards +Infinity */
  743. #define FPU_CSR_RD 0x3 /* towards -Infinity */
  744. #ifndef __ASSEMBLY__
  745. /*
  746. * Macros for handling the ISA mode bit for MIPS16 and microMIPS.
  747. */
  748. #if defined(CONFIG_SYS_SUPPORTS_MIPS16) || \
  749. defined(CONFIG_SYS_SUPPORTS_MICROMIPS)
  750. #define get_isa16_mode(x) ((x) & 0x1)
  751. #define msk_isa16_mode(x) ((x) & ~0x1)
  752. #define set_isa16_mode(x) do { (x) |= 0x1; } while (0)
  753. #else
  754. #define get_isa16_mode(x) 0
  755. #define msk_isa16_mode(x) (x)
  756. #define set_isa16_mode(x) do { } while (0)
  757. #endif
  758. /*
  759. * microMIPS instructions can be 16-bit or 32-bit in length. This
  760. * returns a 1 if the instruction is 16-bit and a 0 if 32-bit.
  761. */
  762. static inline int mm_insn_16bit(u16 insn)
  763. {
  764. u16 opcode = (insn >> 10) & 0x7;
  765. return (opcode >= 1 && opcode <= 3) ? 1 : 0;
  766. }
  767. /*
  768. * TLB Invalidate Flush
  769. */
  770. static inline void tlbinvf(void)
  771. {
  772. __asm__ __volatile__(
  773. ".set push\n\t"
  774. ".set noreorder\n\t"
  775. ".word 0x42000004\n\t" /* tlbinvf */
  776. ".set pop");
  777. }
  778. /*
  779. * Functions to access the R10000 performance counters. These are basically
  780. * mfc0 and mtc0 instructions from and to coprocessor register with a 5-bit
  781. * performance counter number encoded into bits 1 ... 5 of the instruction.
  782. * Only performance counters 0 to 1 actually exist, so for a non-R10000 aware
  783. * disassembler these will look like an access to sel 0 or 1.
  784. */
  785. #define read_r10k_perf_cntr(counter) \
  786. ({ \
  787. unsigned int __res; \
  788. __asm__ __volatile__( \
  789. "mfpc\t%0, %1" \
  790. : "=r" (__res) \
  791. : "i" (counter)); \
  792. \
  793. __res; \
  794. })
  795. #define write_r10k_perf_cntr(counter,val) \
  796. do { \
  797. __asm__ __volatile__( \
  798. "mtpc\t%0, %1" \
  799. : \
  800. : "r" (val), "i" (counter)); \
  801. } while (0)
  802. #define read_r10k_perf_event(counter) \
  803. ({ \
  804. unsigned int __res; \
  805. __asm__ __volatile__( \
  806. "mfps\t%0, %1" \
  807. : "=r" (__res) \
  808. : "i" (counter)); \
  809. \
  810. __res; \
  811. })
  812. #define write_r10k_perf_cntl(counter,val) \
  813. do { \
  814. __asm__ __volatile__( \
  815. "mtps\t%0, %1" \
  816. : \
  817. : "r" (val), "i" (counter)); \
  818. } while (0)
  819. /*
  820. * Macros to access the system control coprocessor
  821. */
  822. #define __read_32bit_c0_register(source, sel) \
  823. ({ unsigned int __res; \
  824. if (sel == 0) \
  825. __asm__ __volatile__( \
  826. "mfc0\t%0, " #source "\n\t" \
  827. : "=r" (__res)); \
  828. else \
  829. __asm__ __volatile__( \
  830. ".set\tmips32\n\t" \
  831. "mfc0\t%0, " #source ", " #sel "\n\t" \
  832. ".set\tmips0\n\t" \
  833. : "=r" (__res)); \
  834. __res; \
  835. })
  836. #define __read_64bit_c0_register(source, sel) \
  837. ({ unsigned long long __res; \
  838. if (sizeof(unsigned long) == 4) \
  839. __res = __read_64bit_c0_split(source, sel); \
  840. else if (sel == 0) \
  841. __asm__ __volatile__( \
  842. ".set\tmips3\n\t" \
  843. "dmfc0\t%0, " #source "\n\t" \
  844. ".set\tmips0" \
  845. : "=r" (__res)); \
  846. else \
  847. __asm__ __volatile__( \
  848. ".set\tmips64\n\t" \
  849. "dmfc0\t%0, " #source ", " #sel "\n\t" \
  850. ".set\tmips0" \
  851. : "=r" (__res)); \
  852. __res; \
  853. })
  854. #define __write_32bit_c0_register(register, sel, value) \
  855. do { \
  856. if (sel == 0) \
  857. __asm__ __volatile__( \
  858. "mtc0\t%z0, " #register "\n\t" \
  859. : : "Jr" ((unsigned int)(value))); \
  860. else \
  861. __asm__ __volatile__( \
  862. ".set\tmips32\n\t" \
  863. "mtc0\t%z0, " #register ", " #sel "\n\t" \
  864. ".set\tmips0" \
  865. : : "Jr" ((unsigned int)(value))); \
  866. } while (0)
  867. #define __write_64bit_c0_register(register, sel, value) \
  868. do { \
  869. if (sizeof(unsigned long) == 4) \
  870. __write_64bit_c0_split(register, sel, value); \
  871. else if (sel == 0) \
  872. __asm__ __volatile__( \
  873. ".set\tmips3\n\t" \
  874. "dmtc0\t%z0, " #register "\n\t" \
  875. ".set\tmips0" \
  876. : : "Jr" (value)); \
  877. else \
  878. __asm__ __volatile__( \
  879. ".set\tmips64\n\t" \
  880. "dmtc0\t%z0, " #register ", " #sel "\n\t" \
  881. ".set\tmips0" \
  882. : : "Jr" (value)); \
  883. } while (0)
  884. #define __read_ulong_c0_register(reg, sel) \
  885. ((sizeof(unsigned long) == 4) ? \
  886. (unsigned long) __read_32bit_c0_register(reg, sel) : \
  887. (unsigned long) __read_64bit_c0_register(reg, sel))
  888. #define __write_ulong_c0_register(reg, sel, val) \
  889. do { \
  890. if (sizeof(unsigned long) == 4) \
  891. __write_32bit_c0_register(reg, sel, val); \
  892. else \
  893. __write_64bit_c0_register(reg, sel, val); \
  894. } while (0)
  895. /*
  896. * On RM7000/RM9000 these are uses to access cop0 set 1 registers
  897. */
  898. #define __read_32bit_c0_ctrl_register(source) \
  899. ({ unsigned int __res; \
  900. __asm__ __volatile__( \
  901. "cfc0\t%0, " #source "\n\t" \
  902. : "=r" (__res)); \
  903. __res; \
  904. })
  905. #define __write_32bit_c0_ctrl_register(register, value) \
  906. do { \
  907. __asm__ __volatile__( \
  908. "ctc0\t%z0, " #register "\n\t" \
  909. : : "Jr" ((unsigned int)(value))); \
  910. } while (0)
  911. /*
  912. * These versions are only needed for systems with more than 38 bits of
  913. * physical address space running the 32-bit kernel. That's none atm :-)
  914. */
  915. #define __read_64bit_c0_split(source, sel) \
  916. ({ \
  917. unsigned long long __val; \
  918. unsigned long __flags; \
  919. \
  920. local_irq_save(__flags); \
  921. if (sel == 0) \
  922. __asm__ __volatile__( \
  923. ".set\tmips64\n\t" \
  924. "dmfc0\t%M0, " #source "\n\t" \
  925. "dsll\t%L0, %M0, 32\n\t" \
  926. "dsra\t%M0, %M0, 32\n\t" \
  927. "dsra\t%L0, %L0, 32\n\t" \
  928. ".set\tmips0" \
  929. : "=r" (__val)); \
  930. else \
  931. __asm__ __volatile__( \
  932. ".set\tmips64\n\t" \
  933. "dmfc0\t%M0, " #source ", " #sel "\n\t" \
  934. "dsll\t%L0, %M0, 32\n\t" \
  935. "dsra\t%M0, %M0, 32\n\t" \
  936. "dsra\t%L0, %L0, 32\n\t" \
  937. ".set\tmips0" \
  938. : "=r" (__val)); \
  939. local_irq_restore(__flags); \
  940. \
  941. __val; \
  942. })
  943. #define __write_64bit_c0_split(source, sel, val) \
  944. do { \
  945. unsigned long __flags; \
  946. \
  947. local_irq_save(__flags); \
  948. if (sel == 0) \
  949. __asm__ __volatile__( \
  950. ".set\tmips64\n\t" \
  951. "dsll\t%L0, %L0, 32\n\t" \
  952. "dsrl\t%L0, %L0, 32\n\t" \
  953. "dsll\t%M0, %M0, 32\n\t" \
  954. "or\t%L0, %L0, %M0\n\t" \
  955. "dmtc0\t%L0, " #source "\n\t" \
  956. ".set\tmips0" \
  957. : : "r" (val)); \
  958. else \
  959. __asm__ __volatile__( \
  960. ".set\tmips64\n\t" \
  961. "dsll\t%L0, %L0, 32\n\t" \
  962. "dsrl\t%L0, %L0, 32\n\t" \
  963. "dsll\t%M0, %M0, 32\n\t" \
  964. "or\t%L0, %L0, %M0\n\t" \
  965. "dmtc0\t%L0, " #source ", " #sel "\n\t" \
  966. ".set\tmips0" \
  967. : : "r" (val)); \
  968. local_irq_restore(__flags); \
  969. } while (0)
  970. #define __readx_32bit_c0_register(source) \
  971. ({ \
  972. unsigned int __res; \
  973. \
  974. __asm__ __volatile__( \
  975. " .set push \n" \
  976. " .set noat \n" \
  977. " .set mips32r2 \n" \
  978. " .insn \n" \
  979. " # mfhc0 $1, %1 \n" \
  980. " .word (0x40410000 | ((%1 & 0x1f) << 11)) \n" \
  981. " move %0, $1 \n" \
  982. " .set pop \n" \
  983. : "=r" (__res) \
  984. : "i" (source)); \
  985. __res; \
  986. })
  987. #define __writex_32bit_c0_register(register, value) \
  988. ({ \
  989. __asm__ __volatile__( \
  990. " .set push \n" \
  991. " .set noat \n" \
  992. " .set mips32r2 \n" \
  993. " move $1, %0 \n" \
  994. " # mthc0 $1, %1 \n" \
  995. " .insn \n" \
  996. " .word (0x40c10000 | ((%1 & 0x1f) << 11)) \n" \
  997. " .set pop \n" \
  998. : \
  999. : "r" (value), "i" (register)); \
  1000. })
  1001. #define read_c0_index() __read_32bit_c0_register($0, 0)
  1002. #define write_c0_index(val) __write_32bit_c0_register($0, 0, val)
  1003. #define read_c0_random() __read_32bit_c0_register($1, 0)
  1004. #define write_c0_random(val) __write_32bit_c0_register($1, 0, val)
  1005. #define read_c0_entrylo0() __read_ulong_c0_register($2, 0)
  1006. #define write_c0_entrylo0(val) __write_ulong_c0_register($2, 0, val)
  1007. #define readx_c0_entrylo0() __readx_32bit_c0_register(2)
  1008. #define writex_c0_entrylo0(val) __writex_32bit_c0_register(2, val)
  1009. #define read_c0_entrylo1() __read_ulong_c0_register($3, 0)
  1010. #define write_c0_entrylo1(val) __write_ulong_c0_register($3, 0, val)
  1011. #define readx_c0_entrylo1() __readx_32bit_c0_register(3)
  1012. #define writex_c0_entrylo1(val) __writex_32bit_c0_register(3, val)
  1013. #define read_c0_conf() __read_32bit_c0_register($3, 0)
  1014. #define write_c0_conf(val) __write_32bit_c0_register($3, 0, val)
  1015. #define read_c0_context() __read_ulong_c0_register($4, 0)
  1016. #define write_c0_context(val) __write_ulong_c0_register($4, 0, val)
  1017. #define read_c0_userlocal() __read_ulong_c0_register($4, 2)
  1018. #define write_c0_userlocal(val) __write_ulong_c0_register($4, 2, val)
  1019. #define read_c0_pagemask() __read_32bit_c0_register($5, 0)
  1020. #define write_c0_pagemask(val) __write_32bit_c0_register($5, 0, val)
  1021. #define read_c0_pagegrain() __read_32bit_c0_register($5, 1)
  1022. #define write_c0_pagegrain(val) __write_32bit_c0_register($5, 1, val)
  1023. #define read_c0_wired() __read_32bit_c0_register($6, 0)
  1024. #define write_c0_wired(val) __write_32bit_c0_register($6, 0, val)
  1025. #define read_c0_info() __read_32bit_c0_register($7, 0)
  1026. #define read_c0_cache() __read_32bit_c0_register($7, 0) /* TX39xx */
  1027. #define write_c0_cache(val) __write_32bit_c0_register($7, 0, val)
  1028. #define read_c0_badvaddr() __read_ulong_c0_register($8, 0)
  1029. #define write_c0_badvaddr(val) __write_ulong_c0_register($8, 0, val)
  1030. #define read_c0_count() __read_32bit_c0_register($9, 0)
  1031. #define write_c0_count(val) __write_32bit_c0_register($9, 0, val)
  1032. #define read_c0_count2() __read_32bit_c0_register($9, 6) /* pnx8550 */
  1033. #define write_c0_count2(val) __write_32bit_c0_register($9, 6, val)
  1034. #define read_c0_count3() __read_32bit_c0_register($9, 7) /* pnx8550 */
  1035. #define write_c0_count3(val) __write_32bit_c0_register($9, 7, val)
  1036. #define read_c0_entryhi() __read_ulong_c0_register($10, 0)
  1037. #define write_c0_entryhi(val) __write_ulong_c0_register($10, 0, val)
  1038. #define read_c0_compare() __read_32bit_c0_register($11, 0)
  1039. #define write_c0_compare(val) __write_32bit_c0_register($11, 0, val)
  1040. #define read_c0_compare2() __read_32bit_c0_register($11, 6) /* pnx8550 */
  1041. #define write_c0_compare2(val) __write_32bit_c0_register($11, 6, val)
  1042. #define read_c0_compare3() __read_32bit_c0_register($11, 7) /* pnx8550 */
  1043. #define write_c0_compare3(val) __write_32bit_c0_register($11, 7, val)
  1044. #define read_c0_status() __read_32bit_c0_register($12, 0)
  1045. #define write_c0_status(val) __write_32bit_c0_register($12, 0, val)
  1046. #define read_c0_cause() __read_32bit_c0_register($13, 0)
  1047. #define write_c0_cause(val) __write_32bit_c0_register($13, 0, val)
  1048. #define read_c0_epc() __read_ulong_c0_register($14, 0)
  1049. #define write_c0_epc(val) __write_ulong_c0_register($14, 0, val)
  1050. #define read_c0_prid() __read_32bit_c0_register($15, 0)
  1051. #define read_c0_cmgcrbase() __read_ulong_c0_register($15, 3)
  1052. #define read_c0_config() __read_32bit_c0_register($16, 0)
  1053. #define read_c0_config1() __read_32bit_c0_register($16, 1)
  1054. #define read_c0_config2() __read_32bit_c0_register($16, 2)
  1055. #define read_c0_config3() __read_32bit_c0_register($16, 3)
  1056. #define read_c0_config4() __read_32bit_c0_register($16, 4)
  1057. #define read_c0_config5() __read_32bit_c0_register($16, 5)
  1058. #define read_c0_config6() __read_32bit_c0_register($16, 6)
  1059. #define read_c0_config7() __read_32bit_c0_register($16, 7)
  1060. #define write_c0_config(val) __write_32bit_c0_register($16, 0, val)
  1061. #define write_c0_config1(val) __write_32bit_c0_register($16, 1, val)
  1062. #define write_c0_config2(val) __write_32bit_c0_register($16, 2, val)
  1063. #define write_c0_config3(val) __write_32bit_c0_register($16, 3, val)
  1064. #define write_c0_config4(val) __write_32bit_c0_register($16, 4, val)
  1065. #define write_c0_config5(val) __write_32bit_c0_register($16, 5, val)
  1066. #define write_c0_config6(val) __write_32bit_c0_register($16, 6, val)
  1067. #define write_c0_config7(val) __write_32bit_c0_register($16, 7, val)
  1068. #define read_c0_lladdr() __read_ulong_c0_register($17, 0)
  1069. #define write_c0_lladdr(val) __write_ulong_c0_register($17, 0, val)
  1070. #define read_c0_maar() __read_ulong_c0_register($17, 1)
  1071. #define write_c0_maar(val) __write_ulong_c0_register($17, 1, val)
  1072. #define read_c0_maari() __read_32bit_c0_register($17, 2)
  1073. #define write_c0_maari(val) __write_32bit_c0_register($17, 2, val)
  1074. /*
  1075. * The WatchLo register. There may be up to 8 of them.
  1076. */
  1077. #define read_c0_watchlo0() __read_ulong_c0_register($18, 0)
  1078. #define read_c0_watchlo1() __read_ulong_c0_register($18, 1)
  1079. #define read_c0_watchlo2() __read_ulong_c0_register($18, 2)
  1080. #define read_c0_watchlo3() __read_ulong_c0_register($18, 3)
  1081. #define read_c0_watchlo4() __read_ulong_c0_register($18, 4)
  1082. #define read_c0_watchlo5() __read_ulong_c0_register($18, 5)
  1083. #define read_c0_watchlo6() __read_ulong_c0_register($18, 6)
  1084. #define read_c0_watchlo7() __read_ulong_c0_register($18, 7)
  1085. #define write_c0_watchlo0(val) __write_ulong_c0_register($18, 0, val)
  1086. #define write_c0_watchlo1(val) __write_ulong_c0_register($18, 1, val)
  1087. #define write_c0_watchlo2(val) __write_ulong_c0_register($18, 2, val)
  1088. #define write_c0_watchlo3(val) __write_ulong_c0_register($18, 3, val)
  1089. #define write_c0_watchlo4(val) __write_ulong_c0_register($18, 4, val)
  1090. #define write_c0_watchlo5(val) __write_ulong_c0_register($18, 5, val)
  1091. #define write_c0_watchlo6(val) __write_ulong_c0_register($18, 6, val)
  1092. #define write_c0_watchlo7(val) __write_ulong_c0_register($18, 7, val)
  1093. /*
  1094. * The WatchHi register. There may be up to 8 of them.
  1095. */
  1096. #define read_c0_watchhi0() __read_32bit_c0_register($19, 0)
  1097. #define read_c0_watchhi1() __read_32bit_c0_register($19, 1)
  1098. #define read_c0_watchhi2() __read_32bit_c0_register($19, 2)
  1099. #define read_c0_watchhi3() __read_32bit_c0_register($19, 3)
  1100. #define read_c0_watchhi4() __read_32bit_c0_register($19, 4)
  1101. #define read_c0_watchhi5() __read_32bit_c0_register($19, 5)
  1102. #define read_c0_watchhi6() __read_32bit_c0_register($19, 6)
  1103. #define read_c0_watchhi7() __read_32bit_c0_register($19, 7)
  1104. #define write_c0_watchhi0(val) __write_32bit_c0_register($19, 0, val)
  1105. #define write_c0_watchhi1(val) __write_32bit_c0_register($19, 1, val)
  1106. #define write_c0_watchhi2(val) __write_32bit_c0_register($19, 2, val)
  1107. #define write_c0_watchhi3(val) __write_32bit_c0_register($19, 3, val)
  1108. #define write_c0_watchhi4(val) __write_32bit_c0_register($19, 4, val)
  1109. #define write_c0_watchhi5(val) __write_32bit_c0_register($19, 5, val)
  1110. #define write_c0_watchhi6(val) __write_32bit_c0_register($19, 6, val)
  1111. #define write_c0_watchhi7(val) __write_32bit_c0_register($19, 7, val)
  1112. #define read_c0_xcontext() __read_ulong_c0_register($20, 0)
  1113. #define write_c0_xcontext(val) __write_ulong_c0_register($20, 0, val)
  1114. #define read_c0_intcontrol() __read_32bit_c0_ctrl_register($20)
  1115. #define write_c0_intcontrol(val) __write_32bit_c0_ctrl_register($20, val)
  1116. #define read_c0_framemask() __read_32bit_c0_register($21, 0)
  1117. #define write_c0_framemask(val) __write_32bit_c0_register($21, 0, val)
  1118. #define read_c0_diag() __read_32bit_c0_register($22, 0)
  1119. #define write_c0_diag(val) __write_32bit_c0_register($22, 0, val)
  1120. /* R10K CP0 Branch Diagnostic register is 64bits wide */
  1121. #define read_c0_r10k_diag() __read_64bit_c0_register($22, 0)
  1122. #define write_c0_r10k_diag(val) __write_64bit_c0_register($22, 0, val)
  1123. #define read_c0_diag1() __read_32bit_c0_register($22, 1)
  1124. #define write_c0_diag1(val) __write_32bit_c0_register($22, 1, val)
  1125. #define read_c0_diag2() __read_32bit_c0_register($22, 2)
  1126. #define write_c0_diag2(val) __write_32bit_c0_register($22, 2, val)
  1127. #define read_c0_diag3() __read_32bit_c0_register($22, 3)
  1128. #define write_c0_diag3(val) __write_32bit_c0_register($22, 3, val)
  1129. #define read_c0_diag4() __read_32bit_c0_register($22, 4)
  1130. #define write_c0_diag4(val) __write_32bit_c0_register($22, 4, val)
  1131. #define read_c0_diag5() __read_32bit_c0_register($22, 5)
  1132. #define write_c0_diag5(val) __write_32bit_c0_register($22, 5, val)
  1133. #define read_c0_debug() __read_32bit_c0_register($23, 0)
  1134. #define write_c0_debug(val) __write_32bit_c0_register($23, 0, val)
  1135. #define read_c0_depc() __read_ulong_c0_register($24, 0)
  1136. #define write_c0_depc(val) __write_ulong_c0_register($24, 0, val)
  1137. /*
  1138. * MIPS32 / MIPS64 performance counters
  1139. */
  1140. #define read_c0_perfctrl0() __read_32bit_c0_register($25, 0)
  1141. #define write_c0_perfctrl0(val) __write_32bit_c0_register($25, 0, val)
  1142. #define read_c0_perfcntr0() __read_32bit_c0_register($25, 1)
  1143. #define write_c0_perfcntr0(val) __write_32bit_c0_register($25, 1, val)
  1144. #define read_c0_perfcntr0_64() __read_64bit_c0_register($25, 1)
  1145. #define write_c0_perfcntr0_64(val) __write_64bit_c0_register($25, 1, val)
  1146. #define read_c0_perfctrl1() __read_32bit_c0_register($25, 2)
  1147. #define write_c0_perfctrl1(val) __write_32bit_c0_register($25, 2, val)
  1148. #define read_c0_perfcntr1() __read_32bit_c0_register($25, 3)
  1149. #define write_c0_perfcntr1(val) __write_32bit_c0_register($25, 3, val)
  1150. #define read_c0_perfcntr1_64() __read_64bit_c0_register($25, 3)
  1151. #define write_c0_perfcntr1_64(val) __write_64bit_c0_register($25, 3, val)
  1152. #define read_c0_perfctrl2() __read_32bit_c0_register($25, 4)
  1153. #define write_c0_perfctrl2(val) __write_32bit_c0_register($25, 4, val)
  1154. #define read_c0_perfcntr2() __read_32bit_c0_register($25, 5)
  1155. #define write_c0_perfcntr2(val) __write_32bit_c0_register($25, 5, val)
  1156. #define read_c0_perfcntr2_64() __read_64bit_c0_register($25, 5)
  1157. #define write_c0_perfcntr2_64(val) __write_64bit_c0_register($25, 5, val)
  1158. #define read_c0_perfctrl3() __read_32bit_c0_register($25, 6)
  1159. #define write_c0_perfctrl3(val) __write_32bit_c0_register($25, 6, val)
  1160. #define read_c0_perfcntr3() __read_32bit_c0_register($25, 7)
  1161. #define write_c0_perfcntr3(val) __write_32bit_c0_register($25, 7, val)
  1162. #define read_c0_perfcntr3_64() __read_64bit_c0_register($25, 7)
  1163. #define write_c0_perfcntr3_64(val) __write_64bit_c0_register($25, 7, val)
  1164. #define read_c0_ecc() __read_32bit_c0_register($26, 0)
  1165. #define write_c0_ecc(val) __write_32bit_c0_register($26, 0, val)
  1166. #define read_c0_derraddr0() __read_ulong_c0_register($26, 1)
  1167. #define write_c0_derraddr0(val) __write_ulong_c0_register($26, 1, val)
  1168. #define read_c0_cacheerr() __read_32bit_c0_register($27, 0)
  1169. #define read_c0_derraddr1() __read_ulong_c0_register($27, 1)
  1170. #define write_c0_derraddr1(val) __write_ulong_c0_register($27, 1, val)
  1171. #define read_c0_taglo() __read_32bit_c0_register($28, 0)
  1172. #define write_c0_taglo(val) __write_32bit_c0_register($28, 0, val)
  1173. #define read_c0_dtaglo() __read_32bit_c0_register($28, 2)
  1174. #define write_c0_dtaglo(val) __write_32bit_c0_register($28, 2, val)
  1175. #define read_c0_ddatalo() __read_32bit_c0_register($28, 3)
  1176. #define write_c0_ddatalo(val) __write_32bit_c0_register($28, 3, val)
  1177. #define read_c0_staglo() __read_32bit_c0_register($28, 4)
  1178. #define write_c0_staglo(val) __write_32bit_c0_register($28, 4, val)
  1179. #define read_c0_taghi() __read_32bit_c0_register($29, 0)
  1180. #define write_c0_taghi(val) __write_32bit_c0_register($29, 0, val)
  1181. #define read_c0_errorepc() __read_ulong_c0_register($30, 0)
  1182. #define write_c0_errorepc(val) __write_ulong_c0_register($30, 0, val)
  1183. /* MIPSR2 */
  1184. #define read_c0_hwrena() __read_32bit_c0_register($7, 0)
  1185. #define write_c0_hwrena(val) __write_32bit_c0_register($7, 0, val)
  1186. #define read_c0_intctl() __read_32bit_c0_register($12, 1)
  1187. #define write_c0_intctl(val) __write_32bit_c0_register($12, 1, val)
  1188. #define read_c0_srsctl() __read_32bit_c0_register($12, 2)
  1189. #define write_c0_srsctl(val) __write_32bit_c0_register($12, 2, val)
  1190. #define read_c0_srsmap() __read_32bit_c0_register($12, 3)
  1191. #define write_c0_srsmap(val) __write_32bit_c0_register($12, 3, val)
  1192. #define read_c0_ebase() __read_32bit_c0_register($15, 1)
  1193. #define write_c0_ebase(val) __write_32bit_c0_register($15, 1, val)
  1194. #define read_c0_cdmmbase() __read_ulong_c0_register($15, 2)
  1195. #define write_c0_cdmmbase(val) __write_ulong_c0_register($15, 2, val)
  1196. /* MIPSR3 */
  1197. #define read_c0_segctl0() __read_32bit_c0_register($5, 2)
  1198. #define write_c0_segctl0(val) __write_32bit_c0_register($5, 2, val)
  1199. #define read_c0_segctl1() __read_32bit_c0_register($5, 3)
  1200. #define write_c0_segctl1(val) __write_32bit_c0_register($5, 3, val)
  1201. #define read_c0_segctl2() __read_32bit_c0_register($5, 4)
  1202. #define write_c0_segctl2(val) __write_32bit_c0_register($5, 4, val)
  1203. /* Hardware Page Table Walker */
  1204. #define read_c0_pwbase() __read_ulong_c0_register($5, 5)
  1205. #define write_c0_pwbase(val) __write_ulong_c0_register($5, 5, val)
  1206. #define read_c0_pwfield() __read_ulong_c0_register($5, 6)
  1207. #define write_c0_pwfield(val) __write_ulong_c0_register($5, 6, val)
  1208. #define read_c0_pwsize() __read_ulong_c0_register($5, 7)
  1209. #define write_c0_pwsize(val) __write_ulong_c0_register($5, 7, val)
  1210. #define read_c0_pwctl() __read_32bit_c0_register($6, 6)
  1211. #define write_c0_pwctl(val) __write_32bit_c0_register($6, 6, val)
  1212. /* Cavium OCTEON (cnMIPS) */
  1213. #define read_c0_cvmcount() __read_ulong_c0_register($9, 6)
  1214. #define write_c0_cvmcount(val) __write_ulong_c0_register($9, 6, val)
  1215. #define read_c0_cvmctl() __read_64bit_c0_register($9, 7)
  1216. #define write_c0_cvmctl(val) __write_64bit_c0_register($9, 7, val)
  1217. #define read_c0_cvmmemctl() __read_64bit_c0_register($11, 7)
  1218. #define write_c0_cvmmemctl(val) __write_64bit_c0_register($11, 7, val)
  1219. /*
  1220. * The cacheerr registers are not standardized. On OCTEON, they are
  1221. * 64 bits wide.
  1222. */
  1223. #define read_octeon_c0_icacheerr() __read_64bit_c0_register($27, 0)
  1224. #define write_octeon_c0_icacheerr(val) __write_64bit_c0_register($27, 0, val)
  1225. #define read_octeon_c0_dcacheerr() __read_64bit_c0_register($27, 1)
  1226. #define write_octeon_c0_dcacheerr(val) __write_64bit_c0_register($27, 1, val)
  1227. /* BMIPS3300 */
  1228. #define read_c0_brcm_config_0() __read_32bit_c0_register($22, 0)
  1229. #define write_c0_brcm_config_0(val) __write_32bit_c0_register($22, 0, val)
  1230. #define read_c0_brcm_bus_pll() __read_32bit_c0_register($22, 4)
  1231. #define write_c0_brcm_bus_pll(val) __write_32bit_c0_register($22, 4, val)
  1232. #define read_c0_brcm_reset() __read_32bit_c0_register($22, 5)
  1233. #define write_c0_brcm_reset(val) __write_32bit_c0_register($22, 5, val)
  1234. /* BMIPS43xx */
  1235. #define read_c0_brcm_cmt_intr() __read_32bit_c0_register($22, 1)
  1236. #define write_c0_brcm_cmt_intr(val) __write_32bit_c0_register($22, 1, val)
  1237. #define read_c0_brcm_cmt_ctrl() __read_32bit_c0_register($22, 2)
  1238. #define write_c0_brcm_cmt_ctrl(val) __write_32bit_c0_register($22, 2, val)
  1239. #define read_c0_brcm_cmt_local() __read_32bit_c0_register($22, 3)
  1240. #define write_c0_brcm_cmt_local(val) __write_32bit_c0_register($22, 3, val)
  1241. #define read_c0_brcm_config_1() __read_32bit_c0_register($22, 5)
  1242. #define write_c0_brcm_config_1(val) __write_32bit_c0_register($22, 5, val)
  1243. #define read_c0_brcm_cbr() __read_32bit_c0_register($22, 6)
  1244. #define write_c0_brcm_cbr(val) __write_32bit_c0_register($22, 6, val)
  1245. /* BMIPS5000 */
  1246. #define read_c0_brcm_config() __read_32bit_c0_register($22, 0)
  1247. #define write_c0_brcm_config(val) __write_32bit_c0_register($22, 0, val)
  1248. #define read_c0_brcm_mode() __read_32bit_c0_register($22, 1)
  1249. #define write_c0_brcm_mode(val) __write_32bit_c0_register($22, 1, val)
  1250. #define read_c0_brcm_action() __read_32bit_c0_register($22, 2)
  1251. #define write_c0_brcm_action(val) __write_32bit_c0_register($22, 2, val)
  1252. #define read_c0_brcm_edsp() __read_32bit_c0_register($22, 3)
  1253. #define write_c0_brcm_edsp(val) __write_32bit_c0_register($22, 3, val)
  1254. #define read_c0_brcm_bootvec() __read_32bit_c0_register($22, 4)
  1255. #define write_c0_brcm_bootvec(val) __write_32bit_c0_register($22, 4, val)
  1256. #define read_c0_brcm_sleepcount() __read_32bit_c0_register($22, 7)
  1257. #define write_c0_brcm_sleepcount(val) __write_32bit_c0_register($22, 7, val)
  1258. /*
  1259. * Macros to access the floating point coprocessor control registers
  1260. */
  1261. #define _read_32bit_cp1_register(source, gas_hardfloat) \
  1262. ({ \
  1263. unsigned int __res; \
  1264. \
  1265. __asm__ __volatile__( \
  1266. " .set push \n" \
  1267. " .set reorder \n" \
  1268. " # gas fails to assemble cfc1 for some archs, \n" \
  1269. " # like Octeon. \n" \
  1270. " .set mips1 \n" \
  1271. " "STR(gas_hardfloat)" \n" \
  1272. " cfc1 %0,"STR(source)" \n" \
  1273. " .set pop \n" \
  1274. : "=r" (__res)); \
  1275. __res; \
  1276. })
  1277. #define _write_32bit_cp1_register(dest, val, gas_hardfloat) \
  1278. ({ \
  1279. __asm__ __volatile__( \
  1280. " .set push \n" \
  1281. " .set reorder \n" \
  1282. " "STR(gas_hardfloat)" \n" \
  1283. " ctc1 %0,"STR(dest)" \n" \
  1284. " .set pop \n" \
  1285. : : "r" (val)); \
  1286. })
  1287. #ifdef GAS_HAS_SET_HARDFLOAT
  1288. #define read_32bit_cp1_register(source) \
  1289. _read_32bit_cp1_register(source, .set hardfloat)
  1290. #define write_32bit_cp1_register(dest, val) \
  1291. _write_32bit_cp1_register(dest, val, .set hardfloat)
  1292. #else
  1293. #define read_32bit_cp1_register(source) \
  1294. _read_32bit_cp1_register(source, )
  1295. #define write_32bit_cp1_register(dest, val) \
  1296. _write_32bit_cp1_register(dest, val, )
  1297. #endif
  1298. #ifdef HAVE_AS_DSP
  1299. #define rddsp(mask) \
  1300. ({ \
  1301. unsigned int __dspctl; \
  1302. \
  1303. __asm__ __volatile__( \
  1304. " .set push \n" \
  1305. " .set dsp \n" \
  1306. " rddsp %0, %x1 \n" \
  1307. " .set pop \n" \
  1308. : "=r" (__dspctl) \
  1309. : "i" (mask)); \
  1310. __dspctl; \
  1311. })
  1312. #define wrdsp(val, mask) \
  1313. ({ \
  1314. __asm__ __volatile__( \
  1315. " .set push \n" \
  1316. " .set dsp \n" \
  1317. " wrdsp %0, %x1 \n" \
  1318. " .set pop \n" \
  1319. : \
  1320. : "r" (val), "i" (mask)); \
  1321. })
  1322. #define mflo0() \
  1323. ({ \
  1324. long mflo0; \
  1325. __asm__( \
  1326. " .set push \n" \
  1327. " .set dsp \n" \
  1328. " mflo %0, $ac0 \n" \
  1329. " .set pop \n" \
  1330. : "=r" (mflo0)); \
  1331. mflo0; \
  1332. })
  1333. #define mflo1() \
  1334. ({ \
  1335. long mflo1; \
  1336. __asm__( \
  1337. " .set push \n" \
  1338. " .set dsp \n" \
  1339. " mflo %0, $ac1 \n" \
  1340. " .set pop \n" \
  1341. : "=r" (mflo1)); \
  1342. mflo1; \
  1343. })
  1344. #define mflo2() \
  1345. ({ \
  1346. long mflo2; \
  1347. __asm__( \
  1348. " .set push \n" \
  1349. " .set dsp \n" \
  1350. " mflo %0, $ac2 \n" \
  1351. " .set pop \n" \
  1352. : "=r" (mflo2)); \
  1353. mflo2; \
  1354. })
  1355. #define mflo3() \
  1356. ({ \
  1357. long mflo3; \
  1358. __asm__( \
  1359. " .set push \n" \
  1360. " .set dsp \n" \
  1361. " mflo %0, $ac3 \n" \
  1362. " .set pop \n" \
  1363. : "=r" (mflo3)); \
  1364. mflo3; \
  1365. })
  1366. #define mfhi0() \
  1367. ({ \
  1368. long mfhi0; \
  1369. __asm__( \
  1370. " .set push \n" \
  1371. " .set dsp \n" \
  1372. " mfhi %0, $ac0 \n" \
  1373. " .set pop \n" \
  1374. : "=r" (mfhi0)); \
  1375. mfhi0; \
  1376. })
  1377. #define mfhi1() \
  1378. ({ \
  1379. long mfhi1; \
  1380. __asm__( \
  1381. " .set push \n" \
  1382. " .set dsp \n" \
  1383. " mfhi %0, $ac1 \n" \
  1384. " .set pop \n" \
  1385. : "=r" (mfhi1)); \
  1386. mfhi1; \
  1387. })
  1388. #define mfhi2() \
  1389. ({ \
  1390. long mfhi2; \
  1391. __asm__( \
  1392. " .set push \n" \
  1393. " .set dsp \n" \
  1394. " mfhi %0, $ac2 \n" \
  1395. " .set pop \n" \
  1396. : "=r" (mfhi2)); \
  1397. mfhi2; \
  1398. })
  1399. #define mfhi3() \
  1400. ({ \
  1401. long mfhi3; \
  1402. __asm__( \
  1403. " .set push \n" \
  1404. " .set dsp \n" \
  1405. " mfhi %0, $ac3 \n" \
  1406. " .set pop \n" \
  1407. : "=r" (mfhi3)); \
  1408. mfhi3; \
  1409. })
  1410. #define mtlo0(x) \
  1411. ({ \
  1412. __asm__( \
  1413. " .set push \n" \
  1414. " .set dsp \n" \
  1415. " mtlo %0, $ac0 \n" \
  1416. " .set pop \n" \
  1417. : \
  1418. : "r" (x)); \
  1419. })
  1420. #define mtlo1(x) \
  1421. ({ \
  1422. __asm__( \
  1423. " .set push \n" \
  1424. " .set dsp \n" \
  1425. " mtlo %0, $ac1 \n" \
  1426. " .set pop \n" \
  1427. : \
  1428. : "r" (x)); \
  1429. })
  1430. #define mtlo2(x) \
  1431. ({ \
  1432. __asm__( \
  1433. " .set push \n" \
  1434. " .set dsp \n" \
  1435. " mtlo %0, $ac2 \n" \
  1436. " .set pop \n" \
  1437. : \
  1438. : "r" (x)); \
  1439. })
  1440. #define mtlo3(x) \
  1441. ({ \
  1442. __asm__( \
  1443. " .set push \n" \
  1444. " .set dsp \n" \
  1445. " mtlo %0, $ac3 \n" \
  1446. " .set pop \n" \
  1447. : \
  1448. : "r" (x)); \
  1449. })
  1450. #define mthi0(x) \
  1451. ({ \
  1452. __asm__( \
  1453. " .set push \n" \
  1454. " .set dsp \n" \
  1455. " mthi %0, $ac0 \n" \
  1456. " .set pop \n" \
  1457. : \
  1458. : "r" (x)); \
  1459. })
  1460. #define mthi1(x) \
  1461. ({ \
  1462. __asm__( \
  1463. " .set push \n" \
  1464. " .set dsp \n" \
  1465. " mthi %0, $ac1 \n" \
  1466. " .set pop \n" \
  1467. : \
  1468. : "r" (x)); \
  1469. })
  1470. #define mthi2(x) \
  1471. ({ \
  1472. __asm__( \
  1473. " .set push \n" \
  1474. " .set dsp \n" \
  1475. " mthi %0, $ac2 \n" \
  1476. " .set pop \n" \
  1477. : \
  1478. : "r" (x)); \
  1479. })
  1480. #define mthi3(x) \
  1481. ({ \
  1482. __asm__( \
  1483. " .set push \n" \
  1484. " .set dsp \n" \
  1485. " mthi %0, $ac3 \n" \
  1486. " .set pop \n" \
  1487. : \
  1488. : "r" (x)); \
  1489. })
  1490. #else
  1491. #ifdef CONFIG_CPU_MICROMIPS
  1492. #define rddsp(mask) \
  1493. ({ \
  1494. unsigned int __res; \
  1495. \
  1496. __asm__ __volatile__( \
  1497. " .set push \n" \
  1498. " .set noat \n" \
  1499. " # rddsp $1, %x1 \n" \
  1500. " .hword ((0x0020067c | (%x1 << 14)) >> 16) \n" \
  1501. " .hword ((0x0020067c | (%x1 << 14)) & 0xffff) \n" \
  1502. " move %0, $1 \n" \
  1503. " .set pop \n" \
  1504. : "=r" (__res) \
  1505. : "i" (mask)); \
  1506. __res; \
  1507. })
  1508. #define wrdsp(val, mask) \
  1509. ({ \
  1510. __asm__ __volatile__( \
  1511. " .set push \n" \
  1512. " .set noat \n" \
  1513. " move $1, %0 \n" \
  1514. " # wrdsp $1, %x1 \n" \
  1515. " .hword ((0x0020167c | (%x1 << 14)) >> 16) \n" \
  1516. " .hword ((0x0020167c | (%x1 << 14)) & 0xffff) \n" \
  1517. " .set pop \n" \
  1518. : \
  1519. : "r" (val), "i" (mask)); \
  1520. })
  1521. #define _umips_dsp_mfxxx(ins) \
  1522. ({ \
  1523. unsigned long __treg; \
  1524. \
  1525. __asm__ __volatile__( \
  1526. " .set push \n" \
  1527. " .set noat \n" \
  1528. " .hword 0x0001 \n" \
  1529. " .hword %x1 \n" \
  1530. " move %0, $1 \n" \
  1531. " .set pop \n" \
  1532. : "=r" (__treg) \
  1533. : "i" (ins)); \
  1534. __treg; \
  1535. })
  1536. #define _umips_dsp_mtxxx(val, ins) \
  1537. ({ \
  1538. __asm__ __volatile__( \
  1539. " .set push \n" \
  1540. " .set noat \n" \
  1541. " move $1, %0 \n" \
  1542. " .hword 0x0001 \n" \
  1543. " .hword %x1 \n" \
  1544. " .set pop \n" \
  1545. : \
  1546. : "r" (val), "i" (ins)); \
  1547. })
  1548. #define _umips_dsp_mflo(reg) _umips_dsp_mfxxx((reg << 14) | 0x107c)
  1549. #define _umips_dsp_mfhi(reg) _umips_dsp_mfxxx((reg << 14) | 0x007c)
  1550. #define _umips_dsp_mtlo(val, reg) _umips_dsp_mtxxx(val, ((reg << 14) | 0x307c))
  1551. #define _umips_dsp_mthi(val, reg) _umips_dsp_mtxxx(val, ((reg << 14) | 0x207c))
  1552. #define mflo0() _umips_dsp_mflo(0)
  1553. #define mflo1() _umips_dsp_mflo(1)
  1554. #define mflo2() _umips_dsp_mflo(2)
  1555. #define mflo3() _umips_dsp_mflo(3)
  1556. #define mfhi0() _umips_dsp_mfhi(0)
  1557. #define mfhi1() _umips_dsp_mfhi(1)
  1558. #define mfhi2() _umips_dsp_mfhi(2)
  1559. #define mfhi3() _umips_dsp_mfhi(3)
  1560. #define mtlo0(x) _umips_dsp_mtlo(x, 0)
  1561. #define mtlo1(x) _umips_dsp_mtlo(x, 1)
  1562. #define mtlo2(x) _umips_dsp_mtlo(x, 2)
  1563. #define mtlo3(x) _umips_dsp_mtlo(x, 3)
  1564. #define mthi0(x) _umips_dsp_mthi(x, 0)
  1565. #define mthi1(x) _umips_dsp_mthi(x, 1)
  1566. #define mthi2(x) _umips_dsp_mthi(x, 2)
  1567. #define mthi3(x) _umips_dsp_mthi(x, 3)
  1568. #else /* !CONFIG_CPU_MICROMIPS */
  1569. #define rddsp(mask) \
  1570. ({ \
  1571. unsigned int __res; \
  1572. \
  1573. __asm__ __volatile__( \
  1574. " .set push \n" \
  1575. " .set noat \n" \
  1576. " # rddsp $1, %x1 \n" \
  1577. " .word 0x7c000cb8 | (%x1 << 16) \n" \
  1578. " move %0, $1 \n" \
  1579. " .set pop \n" \
  1580. : "=r" (__res) \
  1581. : "i" (mask)); \
  1582. __res; \
  1583. })
  1584. #define wrdsp(val, mask) \
  1585. ({ \
  1586. __asm__ __volatile__( \
  1587. " .set push \n" \
  1588. " .set noat \n" \
  1589. " move $1, %0 \n" \
  1590. " # wrdsp $1, %x1 \n" \
  1591. " .word 0x7c2004f8 | (%x1 << 11) \n" \
  1592. " .set pop \n" \
  1593. : \
  1594. : "r" (val), "i" (mask)); \
  1595. })
  1596. #define _dsp_mfxxx(ins) \
  1597. ({ \
  1598. unsigned long __treg; \
  1599. \
  1600. __asm__ __volatile__( \
  1601. " .set push \n" \
  1602. " .set noat \n" \
  1603. " .word (0x00000810 | %1) \n" \
  1604. " move %0, $1 \n" \
  1605. " .set pop \n" \
  1606. : "=r" (__treg) \
  1607. : "i" (ins)); \
  1608. __treg; \
  1609. })
  1610. #define _dsp_mtxxx(val, ins) \
  1611. ({ \
  1612. __asm__ __volatile__( \
  1613. " .set push \n" \
  1614. " .set noat \n" \
  1615. " move $1, %0 \n" \
  1616. " .word (0x00200011 | %1) \n" \
  1617. " .set pop \n" \
  1618. : \
  1619. : "r" (val), "i" (ins)); \
  1620. })
  1621. #define _dsp_mflo(reg) _dsp_mfxxx((reg << 21) | 0x0002)
  1622. #define _dsp_mfhi(reg) _dsp_mfxxx((reg << 21) | 0x0000)
  1623. #define _dsp_mtlo(val, reg) _dsp_mtxxx(val, ((reg << 11) | 0x0002))
  1624. #define _dsp_mthi(val, reg) _dsp_mtxxx(val, ((reg << 11) | 0x0000))
  1625. #define mflo0() _dsp_mflo(0)
  1626. #define mflo1() _dsp_mflo(1)
  1627. #define mflo2() _dsp_mflo(2)
  1628. #define mflo3() _dsp_mflo(3)
  1629. #define mfhi0() _dsp_mfhi(0)
  1630. #define mfhi1() _dsp_mfhi(1)
  1631. #define mfhi2() _dsp_mfhi(2)
  1632. #define mfhi3() _dsp_mfhi(3)
  1633. #define mtlo0(x) _dsp_mtlo(x, 0)
  1634. #define mtlo1(x) _dsp_mtlo(x, 1)
  1635. #define mtlo2(x) _dsp_mtlo(x, 2)
  1636. #define mtlo3(x) _dsp_mtlo(x, 3)
  1637. #define mthi0(x) _dsp_mthi(x, 0)
  1638. #define mthi1(x) _dsp_mthi(x, 1)
  1639. #define mthi2(x) _dsp_mthi(x, 2)
  1640. #define mthi3(x) _dsp_mthi(x, 3)
  1641. #endif /* CONFIG_CPU_MICROMIPS */
  1642. #endif
  1643. /*
  1644. * TLB operations.
  1645. *
  1646. * It is responsibility of the caller to take care of any TLB hazards.
  1647. */
  1648. static inline void tlb_probe(void)
  1649. {
  1650. __asm__ __volatile__(
  1651. ".set noreorder\n\t"
  1652. "tlbp\n\t"
  1653. ".set reorder");
  1654. }
  1655. static inline void tlb_read(void)
  1656. {
  1657. #if MIPS34K_MISSED_ITLB_WAR
  1658. int res = 0;
  1659. __asm__ __volatile__(
  1660. " .set push \n"
  1661. " .set noreorder \n"
  1662. " .set noat \n"
  1663. " .set mips32r2 \n"
  1664. " .word 0x41610001 # dvpe $1 \n"
  1665. " move %0, $1 \n"
  1666. " ehb \n"
  1667. " .set pop \n"
  1668. : "=r" (res));
  1669. instruction_hazard();
  1670. #endif
  1671. __asm__ __volatile__(
  1672. ".set noreorder\n\t"
  1673. "tlbr\n\t"
  1674. ".set reorder");
  1675. #if MIPS34K_MISSED_ITLB_WAR
  1676. if ((res & _ULCAST_(1)))
  1677. __asm__ __volatile__(
  1678. " .set push \n"
  1679. " .set noreorder \n"
  1680. " .set noat \n"
  1681. " .set mips32r2 \n"
  1682. " .word 0x41600021 # evpe \n"
  1683. " ehb \n"
  1684. " .set pop \n");
  1685. #endif
  1686. }
  1687. static inline void tlb_write_indexed(void)
  1688. {
  1689. __asm__ __volatile__(
  1690. ".set noreorder\n\t"
  1691. "tlbwi\n\t"
  1692. ".set reorder");
  1693. }
  1694. static inline void tlb_write_random(void)
  1695. {
  1696. __asm__ __volatile__(
  1697. ".set noreorder\n\t"
  1698. "tlbwr\n\t"
  1699. ".set reorder");
  1700. }
  1701. /*
  1702. * Manipulate bits in a c0 register.
  1703. */
  1704. #define __BUILD_SET_C0(name) \
  1705. static inline unsigned int \
  1706. set_c0_##name(unsigned int set) \
  1707. { \
  1708. unsigned int res, new; \
  1709. \
  1710. res = read_c0_##name(); \
  1711. new = res | set; \
  1712. write_c0_##name(new); \
  1713. \
  1714. return res; \
  1715. } \
  1716. \
  1717. static inline unsigned int \
  1718. clear_c0_##name(unsigned int clear) \
  1719. { \
  1720. unsigned int res, new; \
  1721. \
  1722. res = read_c0_##name(); \
  1723. new = res & ~clear; \
  1724. write_c0_##name(new); \
  1725. \
  1726. return res; \
  1727. } \
  1728. \
  1729. static inline unsigned int \
  1730. change_c0_##name(unsigned int change, unsigned int val) \
  1731. { \
  1732. unsigned int res, new; \
  1733. \
  1734. res = read_c0_##name(); \
  1735. new = res & ~change; \
  1736. new |= (val & change); \
  1737. write_c0_##name(new); \
  1738. \
  1739. return res; \
  1740. }
  1741. __BUILD_SET_C0(status)
  1742. __BUILD_SET_C0(cause)
  1743. __BUILD_SET_C0(config)
  1744. __BUILD_SET_C0(config5)
  1745. __BUILD_SET_C0(intcontrol)
  1746. __BUILD_SET_C0(intctl)
  1747. __BUILD_SET_C0(srsmap)
  1748. __BUILD_SET_C0(pagegrain)
  1749. __BUILD_SET_C0(brcm_config_0)
  1750. __BUILD_SET_C0(brcm_bus_pll)
  1751. __BUILD_SET_C0(brcm_reset)
  1752. __BUILD_SET_C0(brcm_cmt_intr)
  1753. __BUILD_SET_C0(brcm_cmt_ctrl)
  1754. __BUILD_SET_C0(brcm_config)
  1755. __BUILD_SET_C0(brcm_mode)
  1756. /*
  1757. * Return low 10 bits of ebase.
  1758. * Note that under KVM (MIPSVZ) this returns vcpu id.
  1759. */
  1760. static inline unsigned int get_ebase_cpunum(void)
  1761. {
  1762. return read_c0_ebase() & 0x3ff;
  1763. }
  1764. #endif /* !__ASSEMBLY__ */
  1765. #endif /* _ASM_MIPSREGS_H */