sysreg.h 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  1. /*
  2. * AVR32 System Registers
  3. *
  4. * Copyright (C) 2004-2006 Atmel Corporation
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2 as
  8. * published by the Free Software Foundation.
  9. */
  10. #ifndef __ASM_AVR32_SYSREG_H
  11. #define __ASM_AVR32_SYSREG_H
  12. /* sysreg register offsets */
  13. #define SYSREG_SR 0x0000
  14. #define SYSREG_EVBA 0x0004
  15. #define SYSREG_ACBA 0x0008
  16. #define SYSREG_CPUCR 0x000c
  17. #define SYSREG_ECR 0x0010
  18. #define SYSREG_RSR_SUP 0x0014
  19. #define SYSREG_RSR_INT0 0x0018
  20. #define SYSREG_RSR_INT1 0x001c
  21. #define SYSREG_RSR_INT2 0x0020
  22. #define SYSREG_RSR_INT3 0x0024
  23. #define SYSREG_RSR_EX 0x0028
  24. #define SYSREG_RSR_NMI 0x002c
  25. #define SYSREG_RSR_DBG 0x0030
  26. #define SYSREG_RAR_SUP 0x0034
  27. #define SYSREG_RAR_INT0 0x0038
  28. #define SYSREG_RAR_INT1 0x003c
  29. #define SYSREG_RAR_INT2 0x0040
  30. #define SYSREG_RAR_INT3 0x0044
  31. #define SYSREG_RAR_EX 0x0048
  32. #define SYSREG_RAR_NMI 0x004c
  33. #define SYSREG_RAR_DBG 0x0050
  34. #define SYSREG_JECR 0x0054
  35. #define SYSREG_JOSP 0x0058
  36. #define SYSREG_JAVA_LV0 0x005c
  37. #define SYSREG_JAVA_LV1 0x0060
  38. #define SYSREG_JAVA_LV2 0x0064
  39. #define SYSREG_JAVA_LV3 0x0068
  40. #define SYSREG_JAVA_LV4 0x006c
  41. #define SYSREG_JAVA_LV5 0x0070
  42. #define SYSREG_JAVA_LV6 0x0074
  43. #define SYSREG_JAVA_LV7 0x0078
  44. #define SYSREG_JTBA 0x007c
  45. #define SYSREG_JBCR 0x0080
  46. #define SYSREG_CONFIG0 0x0100
  47. #define SYSREG_CONFIG1 0x0104
  48. #define SYSREG_COUNT 0x0108
  49. #define SYSREG_COMPARE 0x010c
  50. #define SYSREG_TLBEHI 0x0110
  51. #define SYSREG_TLBELO 0x0114
  52. #define SYSREG_PTBR 0x0118
  53. #define SYSREG_TLBEAR 0x011c
  54. #define SYSREG_MMUCR 0x0120
  55. #define SYSREG_TLBARLO 0x0124
  56. #define SYSREG_TLBARHI 0x0128
  57. #define SYSREG_PCCNT 0x012c
  58. #define SYSREG_PCNT0 0x0130
  59. #define SYSREG_PCNT1 0x0134
  60. #define SYSREG_PCCR 0x0138
  61. #define SYSREG_BEAR 0x013c
  62. #define SYSREG_SABAL 0x0300
  63. #define SYSREG_SABAH 0x0304
  64. #define SYSREG_SABD 0x0308
  65. /* Bitfields in SR */
  66. #define SYSREG_SR_C_OFFSET 0
  67. #define SYSREG_SR_C_SIZE 1
  68. #define SYSREG_Z_OFFSET 1
  69. #define SYSREG_Z_SIZE 1
  70. #define SYSREG_SR_N_OFFSET 2
  71. #define SYSREG_SR_N_SIZE 1
  72. #define SYSREG_SR_V_OFFSET 3
  73. #define SYSREG_SR_V_SIZE 1
  74. #define SYSREG_Q_OFFSET 4
  75. #define SYSREG_Q_SIZE 1
  76. #define SYSREG_L_OFFSET 5
  77. #define SYSREG_L_SIZE 1
  78. #define SYSREG_T_OFFSET 14
  79. #define SYSREG_T_SIZE 1
  80. #define SYSREG_SR_R_OFFSET 15
  81. #define SYSREG_SR_R_SIZE 1
  82. #define SYSREG_GM_OFFSET 16
  83. #define SYSREG_GM_SIZE 1
  84. #define SYSREG_I0M_OFFSET 17
  85. #define SYSREG_I0M_SIZE 1
  86. #define SYSREG_I1M_OFFSET 18
  87. #define SYSREG_I1M_SIZE 1
  88. #define SYSREG_I2M_OFFSET 19
  89. #define SYSREG_I2M_SIZE 1
  90. #define SYSREG_I3M_OFFSET 20
  91. #define SYSREG_I3M_SIZE 1
  92. #define SYSREG_EM_OFFSET 21
  93. #define SYSREG_EM_SIZE 1
  94. #define SYSREG_MODE_OFFSET 22
  95. #define SYSREG_MODE_SIZE 3
  96. #define SYSREG_M0_OFFSET 22
  97. #define SYSREG_M0_SIZE 1
  98. #define SYSREG_M1_OFFSET 23
  99. #define SYSREG_M1_SIZE 1
  100. #define SYSREG_M2_OFFSET 24
  101. #define SYSREG_M2_SIZE 1
  102. #define SYSREG_SR_D_OFFSET 26
  103. #define SYSREG_SR_D_SIZE 1
  104. #define SYSREG_DM_OFFSET 27
  105. #define SYSREG_DM_SIZE 1
  106. #define SYSREG_SR_J_OFFSET 28
  107. #define SYSREG_SR_J_SIZE 1
  108. #define SYSREG_H_OFFSET 29
  109. #define SYSREG_H_SIZE 1
  110. /* Bitfields in CPUCR */
  111. #define SYSREG_BI_OFFSET 0
  112. #define SYSREG_BI_SIZE 1
  113. #define SYSREG_BE_OFFSET 1
  114. #define SYSREG_BE_SIZE 1
  115. #define SYSREG_FE_OFFSET 2
  116. #define SYSREG_FE_SIZE 1
  117. #define SYSREG_RE_OFFSET 3
  118. #define SYSREG_RE_SIZE 1
  119. #define SYSREG_IBE_OFFSET 4
  120. #define SYSREG_IBE_SIZE 1
  121. #define SYSREG_IEE_OFFSET 5
  122. #define SYSREG_IEE_SIZE 1
  123. /* Bitfields in CONFIG0 */
  124. #define SYSREG_CONFIG0_R_OFFSET 0
  125. #define SYSREG_CONFIG0_R_SIZE 1
  126. #define SYSREG_CONFIG0_D_OFFSET 1
  127. #define SYSREG_CONFIG0_D_SIZE 1
  128. #define SYSREG_CONFIG0_S_OFFSET 2
  129. #define SYSREG_CONFIG0_S_SIZE 1
  130. #define SYSREG_CONFIG0_O_OFFSET 3
  131. #define SYSREG_CONFIG0_O_SIZE 1
  132. #define SYSREG_CONFIG0_P_OFFSET 4
  133. #define SYSREG_CONFIG0_P_SIZE 1
  134. #define SYSREG_CONFIG0_J_OFFSET 5
  135. #define SYSREG_CONFIG0_J_SIZE 1
  136. #define SYSREG_CONFIG0_F_OFFSET 6
  137. #define SYSREG_CONFIG0_F_SIZE 1
  138. #define SYSREG_MMUT_OFFSET 7
  139. #define SYSREG_MMUT_SIZE 3
  140. #define SYSREG_AR_OFFSET 10
  141. #define SYSREG_AR_SIZE 3
  142. #define SYSREG_AT_OFFSET 13
  143. #define SYSREG_AT_SIZE 3
  144. #define SYSREG_PROCESSORREVISION_OFFSET 16
  145. #define SYSREG_PROCESSORREVISION_SIZE 8
  146. #define SYSREG_PROCESSORID_OFFSET 24
  147. #define SYSREG_PROCESSORID_SIZE 8
  148. /* Bitfields in CONFIG1 */
  149. #define SYSREG_DASS_OFFSET 0
  150. #define SYSREG_DASS_SIZE 3
  151. #define SYSREG_DLSZ_OFFSET 3
  152. #define SYSREG_DLSZ_SIZE 3
  153. #define SYSREG_DSET_OFFSET 6
  154. #define SYSREG_DSET_SIZE 4
  155. #define SYSREG_IASS_OFFSET 10
  156. #define SYSREG_IASS_SIZE 3
  157. #define SYSREG_ILSZ_OFFSET 13
  158. #define SYSREG_ILSZ_SIZE 3
  159. #define SYSREG_ISET_OFFSET 16
  160. #define SYSREG_ISET_SIZE 4
  161. #define SYSREG_DMMUSZ_OFFSET 20
  162. #define SYSREG_DMMUSZ_SIZE 6
  163. #define SYSREG_IMMUSZ_OFFSET 26
  164. #define SYSREG_IMMUSZ_SIZE 6
  165. /* Bitfields in TLBEHI */
  166. #define SYSREG_ASID_OFFSET 0
  167. #define SYSREG_ASID_SIZE 8
  168. #define SYSREG_TLBEHI_I_OFFSET 8
  169. #define SYSREG_TLBEHI_I_SIZE 1
  170. #define SYSREG_TLBEHI_V_OFFSET 9
  171. #define SYSREG_TLBEHI_V_SIZE 1
  172. #define SYSREG_VPN_OFFSET 10
  173. #define SYSREG_VPN_SIZE 22
  174. /* Bitfields in TLBELO */
  175. #define SYSREG_W_OFFSET 0
  176. #define SYSREG_W_SIZE 1
  177. #define SYSREG_TLBELO_D_OFFSET 1
  178. #define SYSREG_TLBELO_D_SIZE 1
  179. #define SYSREG_SZ_OFFSET 2
  180. #define SYSREG_SZ_SIZE 2
  181. #define SYSREG_AP_OFFSET 4
  182. #define SYSREG_AP_SIZE 3
  183. #define SYSREG_B_OFFSET 7
  184. #define SYSREG_B_SIZE 1
  185. #define SYSREG_G_OFFSET 8
  186. #define SYSREG_G_SIZE 1
  187. #define SYSREG_TLBELO_C_OFFSET 9
  188. #define SYSREG_TLBELO_C_SIZE 1
  189. #define SYSREG_PFN_OFFSET 10
  190. #define SYSREG_PFN_SIZE 22
  191. /* Bitfields in MMUCR */
  192. #define SYSREG_E_OFFSET 0
  193. #define SYSREG_E_SIZE 1
  194. #define SYSREG_M_OFFSET 1
  195. #define SYSREG_M_SIZE 1
  196. #define SYSREG_MMUCR_I_OFFSET 2
  197. #define SYSREG_MMUCR_I_SIZE 1
  198. #define SYSREG_MMUCR_N_OFFSET 3
  199. #define SYSREG_MMUCR_N_SIZE 1
  200. #define SYSREG_MMUCR_S_OFFSET 4
  201. #define SYSREG_MMUCR_S_SIZE 1
  202. #define SYSREG_DLA_OFFSET 8
  203. #define SYSREG_DLA_SIZE 6
  204. #define SYSREG_DRP_OFFSET 14
  205. #define SYSREG_DRP_SIZE 6
  206. #define SYSREG_ILA_OFFSET 20
  207. #define SYSREG_ILA_SIZE 6
  208. #define SYSREG_IRP_OFFSET 26
  209. #define SYSREG_IRP_SIZE 6
  210. /* Bitfields in PCCR */
  211. #define SYSREG_PCCR_E_OFFSET 0
  212. #define SYSREG_PCCR_E_SIZE 1
  213. #define SYSREG_PCCR_R_OFFSET 1
  214. #define SYSREG_PCCR_R_SIZE 1
  215. #define SYSREG_PCCR_C_OFFSET 2
  216. #define SYSREG_PCCR_C_SIZE 1
  217. #define SYSREG_PCCR_S_OFFSET 3
  218. #define SYSREG_PCCR_S_SIZE 1
  219. #define SYSREG_IEC_OFFSET 4
  220. #define SYSREG_IEC_SIZE 1
  221. #define SYSREG_IE0_OFFSET 5
  222. #define SYSREG_IE0_SIZE 1
  223. #define SYSREG_IE1_OFFSET 6
  224. #define SYSREG_IE1_SIZE 1
  225. #define SYSREG_FC_OFFSET 8
  226. #define SYSREG_FC_SIZE 1
  227. #define SYSREG_F0_OFFSET 9
  228. #define SYSREG_F0_SIZE 1
  229. #define SYSREG_F1_OFFSET 10
  230. #define SYSREG_F1_SIZE 1
  231. #define SYSREG_CONF0_OFFSET 12
  232. #define SYSREG_CONF0_SIZE 6
  233. #define SYSREG_CONF1_OFFSET 18
  234. #define SYSREG_CONF1_SIZE 6
  235. /* Constants for ECR */
  236. #define ECR_UNRECOVERABLE 0
  237. #define ECR_TLB_MULTIPLE 1
  238. #define ECR_BUS_ERROR_WRITE 2
  239. #define ECR_BUS_ERROR_READ 3
  240. #define ECR_NMI 4
  241. #define ECR_ADDR_ALIGN_X 5
  242. #define ECR_PROTECTION_X 6
  243. #define ECR_DEBUG 7
  244. #define ECR_ILLEGAL_OPCODE 8
  245. #define ECR_UNIMPL_INSTRUCTION 9
  246. #define ECR_PRIVILEGE_VIOLATION 10
  247. #define ECR_FPE 11
  248. #define ECR_COPROC_ABSENT 12
  249. #define ECR_ADDR_ALIGN_R 13
  250. #define ECR_ADDR_ALIGN_W 14
  251. #define ECR_PROTECTION_R 15
  252. #define ECR_PROTECTION_W 16
  253. #define ECR_DTLB_MODIFIED 17
  254. #define ECR_TLB_MISS_X 20
  255. #define ECR_TLB_MISS_R 24
  256. #define ECR_TLB_MISS_W 28
  257. /* Bit manipulation macros */
  258. #define SYSREG_BIT(name) \
  259. (1 << SYSREG_##name##_OFFSET)
  260. #define SYSREG_BF(name,value) \
  261. (((value) & ((1 << SYSREG_##name##_SIZE) - 1)) \
  262. << SYSREG_##name##_OFFSET)
  263. #define SYSREG_BFEXT(name,value)\
  264. (((value) >> SYSREG_##name##_OFFSET) \
  265. & ((1 << SYSREG_##name##_SIZE) - 1))
  266. #define SYSREG_BFINS(name,value,old) \
  267. (((old) & ~(((1 << SYSREG_##name##_SIZE) - 1) \
  268. << SYSREG_##name##_OFFSET)) \
  269. | SYSREG_BF(name,value))
  270. /* Register access macros */
  271. #ifdef __CHECKER__
  272. extern unsigned long __builtin_mfsr(unsigned long reg);
  273. extern void __builtin_mtsr(unsigned long reg, unsigned long value);
  274. #endif
  275. #define sysreg_read(reg) __builtin_mfsr(SYSREG_##reg)
  276. #define sysreg_write(reg, value) __builtin_mtsr(SYSREG_##reg, value)
  277. #endif /* __ASM_AVR32_SYSREG_H */