arm.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311
  1. /*
  2. * arm-specific definitions for cortex-a8 and -a9
  3. * these are used in C and assembler
  4. *
  5. * `cortex' refers to the cortex-a8 or -a9.
  6. */
  7. #define NREGS 15 /* general-purpose regs, R0 through R14 */
  8. /*
  9. * Program Status Registers
  10. */
  11. #define PsrMusr 0x00000010 /* mode */
  12. #define PsrMfiq 0x00000011
  13. #define PsrMirq 0x00000012
  14. #define PsrMsvc 0x00000013 /* `protected mode for OS' */
  15. #define PsrMmon 0x00000016 /* `secure monitor' (trustzone hyper) */
  16. #define PsrMabt 0x00000017
  17. #define PsrMund 0x0000001B
  18. #define PsrMsys 0x0000001F /* `privileged user mode for OS' (trustzone) */
  19. #define PsrMask 0x0000001F
  20. #define PsrThumb 0x00000020 /* beware hammers */
  21. #define PsrDfiq 0x00000040 /* disable FIQ interrupts */
  22. #define PsrDirq 0x00000080 /* disable IRQ interrupts */
  23. #define PsrDasabt 0x00000100 /* disable asynch aborts */
  24. #define PsrBigend 0x00000200
  25. #define PsrJaz 0x01000000 /* java mode */
  26. #define PsrV 0x10000000 /* overflow */
  27. #define PsrC 0x20000000 /* carry/borrow/extend */
  28. #define PsrZ 0x40000000 /* zero */
  29. #define PsrN 0x80000000 /* negative/less than */
  30. #define PsrMbz (PsrJaz|PsrThumb|PsrBigend) /* these bits must be 0 */
  31. /*
  32. * MCR and MRC are anti-mnemonic.
  33. * MTCP coproc, opcode1, Rd, CRn, CRm[, opcode2] # arm -> coproc
  34. * MFCP coproc, opcode1, Rd, CRn, CRm[, opcode2] # coproc -> arm
  35. */
  36. #define MTCP MCR
  37. #define MFCP MRC
  38. /* instruction decoding */
  39. #define ISCPOP(op) ((op) == 0xE || ((op) & ~1) == 0xC)
  40. #define ISFPAOP(cp, op) ((cp) == CpOFPA && ISCPOP(op))
  41. #define ISVFPOP(cp, op) (((cp) == CpDFP || (cp) == CpFP) && ISCPOP(op))
  42. /*
  43. * Coprocessors
  44. * MCR coproc, opcode1, Rd, CRn, CRm[, opcode2] # arm -> coproc
  45. * MRC coproc, opcode1, Rd, CRn, CRm[, opcode2] # coproc -> arm
  46. */
  47. #define CpOFPA 1 /* ancient 7500 FPA */
  48. #define CpFP 10 /* float FP, VFP cfg. */
  49. #define CpDFP 11 /* double FP */
  50. #define CpSC 15 /* System Control */
  51. /*
  52. * Primary (CRn) CpSC registers.
  53. */
  54. #define CpID 0 /* ID and cache type */
  55. #define CpCONTROL 1 /* miscellaneous control */
  56. #define CpTTB 2 /* Translation Table Base(s) */
  57. #define CpDAC 3 /* Domain Access Control */
  58. #define CpFSR 5 /* Fault Status */
  59. #define CpFAR 6 /* Fault Address */
  60. #define CpCACHE 7 /* cache/write buffer control */
  61. #define CpTLB 8 /* TLB control */
  62. #define CpCLD 9 /* L2 Cache Lockdown, op1==1 */
  63. #define CpTLD 10 /* TLB Lockdown, with op2 */
  64. #define CpVECS 12 /* vector bases, op1==0, Crm==0, op2s (cortex) */
  65. #define CpPID 13 /* Process ID */
  66. #define CpDTLB 15 /* TLB, L1 cache stuff (cortex) */
  67. /*
  68. * CpTTB op1==0, Crm==0 opcode2 values.
  69. */
  70. #define CpTTB0 0 /* secure ttb */
  71. #define CpTTB1 1 /* non-secure ttb (v7) */
  72. #define CpTTBctl 2 /* v7 */
  73. /*
  74. * CpFSR op1==0, Crm==0 opcode 2 values.
  75. */
  76. #define CpDFSR 0 /* data fault status */
  77. #define CpIFSR 1 /* instruction fault status */
  78. /*
  79. * CpFAR op1==0, Crm==0 opcode 2 values.
  80. */
  81. #define CpDFAR 0 /* data fault address */
  82. #define CpIFAR 2 /* instruction fault address */
  83. /*
  84. * CpID Secondary (CRm) registers.
  85. */
  86. #define CpIDidct 0
  87. /*
  88. * CpID CpIDidct op1==0 opcode2 fields.
  89. */
  90. #define CpIDid 0 /* main ID */
  91. #define CpIDct 1 /* cache type */
  92. #define CpIDtlb 3 /* tlb type (cortex) */
  93. #define CpIDmpid 5 /* multiprocessor id (cortex) */
  94. /* CpIDid op1 values */
  95. #define CpIDcsize 1 /* cache size (cortex) */
  96. #define CpIDcssel 2 /* cache size select (cortex) */
  97. /*
  98. * CpID CpIDidct op1==CpIDcsize opcode2 fields.
  99. */
  100. #define CpIDcasize 0 /* cache size */
  101. #define CpIDclvlid 1 /* cache-level id */
  102. /*
  103. * CpCONTROL op2 codes, op1==0, Crm==0.
  104. */
  105. #define CpMainctl 0 /* sctlr */
  106. #define CpAuxctl 1
  107. #define CpCPaccess 2
  108. /*
  109. * CpCONTROL: op1==0, CRm==0, op2==CpMainctl.
  110. * main control register.
  111. * cortex/armv7 has more ops and CRm values.
  112. */
  113. #define CpCmmu 0x00000001 /* M: MMU enable */
  114. #define CpCalign 0x00000002 /* A: alignment fault enable */
  115. #define CpCdcache 0x00000004 /* C: data cache on */
  116. #define CpBigend (1<<7)
  117. #define CpCsw (1<<10) /* SW: SWP(B) enable (deprecated in v7) */
  118. #define CpCpredict 0x00000800 /* Z: branch prediction (armv7) */
  119. #define CpCicache 0x00001000 /* I: instruction cache on */
  120. #define CpChv 0x00002000 /* V: high vectors */
  121. #define CpCrr (1<<14) /* RR: round robin vs random cache replacement */
  122. #define CpCha (1<<17) /* HA: hw access flag enable */
  123. #define CpCdz (1<<19) /* DZ: divide by zero fault enable (not cortex-a9) */
  124. #define CpCfi (1<<21) /* FI: fast intrs */
  125. #define CpCve (1<<24) /* VE: intr vectors enable */
  126. #define CpCee (1<<25) /* EE: exception endianness: big */
  127. #define CpCnmfi (1<<27) /* NMFI: non-maskable fast intrs. (RO) */
  128. #define CpCtre (1<<28) /* TRE: TEX remap enable */
  129. #define CpCafe (1<<29) /* AFE: access flag (ttb) enable */
  130. #define CpCte (1<<30) /* TE: thumb exceptions */
  131. #define CpCsbz (1<<31 | CpCte | CpCafe | CpCtre | 1<<26 | CpCee | CpCve | \
  132. CpCfi | 3<<19 | CpCha | 1<<15 | 3<<8 | CpBigend) /* must be 0 (armv7) */
  133. #define CpCsbo (3<<22 | 1<<18 | 1<<16 | CpChv | CpCsw | 017<<3) /* must be 1 (armv7) */
  134. /*
  135. * CpCONTROL: op1==0, CRm==0, op2==CpAuxctl.
  136. * Auxiliary control register on cortex-a9.
  137. * these differ from even the cortex-a8 bits.
  138. */
  139. #define CpACparity (1<<9)
  140. #define CpACca1way (1<<8) /* cache in a single way */
  141. #define CpACcaexcl (1<<7) /* exclusive cache */
  142. #define CpACsmp (1<<6) /* SMP l1 caches coherence; needed for ldrex/strex */
  143. #define CpAClwr0line (1<<3) /* write full cache line of 0s; see Fullline0 */
  144. #define CpACl1pref (1<<2) /* l1 prefetch enable */
  145. #define CpACl2pref (1<<1) /* l2 prefetch enable */
  146. #define CpACmaintbcast (1<<0) /* broadcast cache & tlb maint. ops */
  147. /*
  148. * CpCONTROL Secondary (CRm) registers and opcode2 fields.
  149. */
  150. #define CpCONTROLscr 1
  151. #define CpSCRscr 0 /* secure configuration */
  152. /*
  153. * CpCACHE Secondary (CRm) registers and opcode2 fields. op1==0.
  154. * In ARM-speak, 'flush' means invalidate and 'clean' means writeback.
  155. */
  156. #define CpCACHEintr 0 /* interrupt (op2==4) */
  157. #define CpCACHEisi 1 /* inner-sharable I cache (v7) */
  158. #define CpCACHEpaddr 4 /* 0: phys. addr (cortex) */
  159. #define CpCACHEinvi 5 /* instruction, branch table */
  160. #define CpCACHEinvd 6 /* data or unified */
  161. // #define CpCACHEinvu 7 /* unified (not on cortex) */
  162. #define CpCACHEva2pa 8 /* va -> pa translation (cortex) */
  163. #define CpCACHEwb 10 /* writeback */
  164. #define CpCACHEinvdse 11 /* data or unified by mva */
  165. #define CpCACHEwbi 14 /* writeback+invalidate */
  166. #define CpCACHEall 0 /* entire (not for invd nor wb(i) on cortex) */
  167. #define CpCACHEse 1 /* single entry */
  168. #define CpCACHEsi 2 /* set/index (set/way) */
  169. #define CpCACHEtest 3 /* test loop */
  170. #define CpCACHEwait 4 /* wait (prefetch flush on cortex) */
  171. #define CpCACHEdmbarr 5 /* wb only (cortex) */
  172. #define CpCACHEflushbtc 6 /* flush branch-target cache (cortex) */
  173. #define CpCACHEflushbtse 7 /* ⋯ or just one entry in it (cortex) */
  174. /*
  175. * CpTLB Secondary (CRm) registers and opcode2 fields.
  176. */
  177. #define CpTLBinvi 5 /* instruction */
  178. #define CpTLBinvd 6 /* data */
  179. #define CpTLBinvu 7 /* unified */
  180. #define CpTLBinv 0 /* invalidate all */
  181. #define CpTLBinvse 1 /* invalidate single entry */
  182. #define CpTBLasid 2 /* by ASID (cortex) */
  183. /*
  184. * CpCLD Secondary (CRm) registers and opcode2 fields for op1==0. (cortex)
  185. */
  186. #define CpCLDena 12 /* enables */
  187. #define CpCLDcyc 13 /* cycle counter */
  188. #define CpCLDuser 14 /* user enable */
  189. #define CpCLDenapmnc 0
  190. #define CpCLDenacyc 1
  191. /*
  192. * CpCLD Secondary (CRm) registers and opcode2 fields for op1==1.
  193. */
  194. #define CpCLDl2 0 /* l2 cache */
  195. #define CpCLDl2aux 2 /* auxiliary control */
  196. /*
  197. * l2 cache aux. control
  198. */
  199. #define CpCl2ecc (1<<28) /* use ecc, not parity */
  200. #define CpCl2noldforw (1<<27) /* no ld forwarding */
  201. #define CpCl2nowrcomb (1<<25) /* no write combining */
  202. #define CpCl2nowralldel (1<<24) /* no write allocate delay */
  203. #define CpCl2nowrallcomb (1<<23) /* no write allocate combine */
  204. #define CpCl2nowralloc (1<<22) /* no write allocate */
  205. #define CpCl2eccparity (1<<21) /* enable ecc or parity */
  206. #define CpCl2inner (1<<16) /* inner cacheability */
  207. /* other bits are tag ram & data ram latencies */
  208. /*
  209. * CpTLD Secondary (CRm) registers and opcode2 fields.
  210. */
  211. #define CpTLDlock 0 /* TLB lockdown registers */
  212. #define CpTLDpreload 1 /* TLB preload */
  213. #define CpTLDi 0 /* TLB instr. lockdown reg. */
  214. #define CpTLDd 1 /* " data " " */
  215. /*
  216. * CpVECS Secondary (CRm) registers and opcode2 fields.
  217. */
  218. #define CpVECSbase 0
  219. #define CpVECSnorm 0 /* (non-)secure base addr */
  220. #define CpVECSmon 1 /* secure monitor base addr */
  221. /*
  222. * MMU page table entries.
  223. * memory must be cached, buffered, sharable and wralloc to participate in
  224. * automatic L1 cache coherency.
  225. */
  226. #define Mbz (0<<4) /* L1 page tables: must be 0 */
  227. #define Noexecsect (1<<4) /* L1 sections: no execute */
  228. #define Fault 0x00000000 /* L[12] pte: unmapped */
  229. #define Coarse (Mbz|1) /* L1: page table */
  230. #define Section (Mbz|2) /* L1 1MB */
  231. /*
  232. * next 2 bits (L1wralloc & L1sharable) and Buffered and Cached must be
  233. * set in l1 ptes for LDREX/STREX to work.
  234. */
  235. #define L1wralloc (1<<12) /* L1 TEX */
  236. #define L1sharable (1<<16)
  237. #define L1nonglobal (1<<17) /* tied to asid */
  238. #define Nonsecuresect (1<<19) /* L1 sections */
  239. #define Large 0x00000001 /* L2 64KB */
  240. #define Noexecsmall 1 /* L2: no execute */
  241. #define Small 0x00000002 /* L2 4KB */
  242. /*
  243. * next 4 bits (Buffered, Cached, L2wralloc & L2sharable) must be set in
  244. * l2 ptes for memory containing locks because LDREX/STREX require them.
  245. */
  246. #define Buffered 0x00000004 /* L[12]: 0 write-thru, 1 -back */
  247. #define Cached 0x00000008 /* L[12] */
  248. #define L2wralloc (1<<6) /* L2 TEX (small pages) */
  249. #define L2apro (1<<9) /* L2 AP: read only */
  250. #define L2sharable (1<<10)
  251. #define L2nonglobal (1<<11) /* tied to asid */
  252. #define Dom0 0
  253. /* attributes for memory containing locks */
  254. #define L1ptedramattrs (Cached | Buffered | L1wralloc | L1sharable)
  255. #define L2ptedramattrs (Cached | Buffered | L2wralloc | L2sharable)
  256. #define Noaccess 0 /* AP, DAC */
  257. #define Krw 1 /* AP */
  258. /* armv7 deprecates AP[2] == 1 & AP[1:0] == 2 (Uro), prefers 3 (new in v7) */
  259. #define Uro 2 /* AP */
  260. #define Urw 3 /* AP */
  261. #define Client 1 /* DAC */
  262. #define Manager 3 /* DAC */
  263. #define AP(n, v) F((v), ((n)*2)+4, 2)
  264. #define L1AP(ap) (AP(3, (ap)))
  265. #define L2AP(ap) (AP(0, (ap))) /* armv7 */
  266. #define DAC(n, v) F((v), (n)*2, 2)
  267. #define HVECTORS 0xffff0000