arm.h 10 KB

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