arm.s 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /*
  2. * omap3530 machine assist, definitions
  3. * cortex-a8 processor
  4. *
  5. * loader uses R11 as scratch.
  6. */
  7. #include "mem.h"
  8. #include "arm.h"
  9. #undef B /* B is for 'botch' */
  10. #define KADDR(pa) (KZERO | ((pa) & ~KSEGM))
  11. #define PADDR(va) (PHYSDRAM | ((va) & ~KSEGM))
  12. #define L1X(va) (((((va))>>20) & 0x0fff)<<2)
  13. #define MACHADDR (L1-MACHSIZE)
  14. #define PTEDRAM (Dom0|L1AP(Krw)|Section|Cached|Buffered)
  15. #define PTEIO (Dom0|L1AP(Krw)|Section)
  16. #define DOUBLEMAPMBS 256 /* megabytes of low dram to double-map */
  17. /* steps on R0 */
  18. #define DELAY(label, mloops) \
  19. MOVW $((mloops)*1000000), R0; \
  20. label: \
  21. SUB.S $1, R0; \
  22. BNE label
  23. /* wave at the user; clobbers R0, R1 & R6; needs R12 (SB) set */
  24. #define PUTC(c) \
  25. BARRIERS; \
  26. MOVW $(c), R1; \
  27. MOVW $PHYSCONS, R6; \
  28. MOVW R1, (R6); \
  29. BARRIERS
  30. /*
  31. * new instructions
  32. */
  33. #define SMC WORD $0xe1600070 /* low 4-bits are call # (trustzone) */
  34. /* flush branch-target cache; zeroes R0 (cortex) */
  35. #define FLBTC \
  36. MOVW $0, R0; \
  37. MCR CpSC, 0, R0, C(CpCACHE), C(CpCACHEinvi), CpCACHEflushbtc
  38. /* flush one entry of the branch-target cache, va in R0 (cortex) */
  39. #define FLBTSE \
  40. MCR CpSC, 0, R0, C(CpCACHE), C(CpCACHEinvi), CpCACHEflushbtse
  41. /* arm v7 arch defines these */
  42. #define WFI WORD $0xe320f003 /* wait for interrupt */
  43. #define DMB WORD $0xf57ff05f /* data mem. barrier; last f = SY */
  44. #define DSB WORD $0xf57ff04f /* data synch. barrier; last f = SY */
  45. #define ISB WORD $0xf57ff06f /* instr. sync. barrier; last f = SY */
  46. #define NOOP WORD $0xe320f000
  47. #define CLZ(s, d) WORD $(0xe16f0f10 | (d) << 12 | (s)) /* count leading 0s */
  48. #define CPSIE WORD $0xf1080080 /* intr enable: zeroes I bit */
  49. #define CPSID WORD $0xf10c0080 /* intr disable: sets I bit */
  50. /* floating point */
  51. #define VMRS(fp, cpu) WORD $(0xeef00a10 | (fp)<<16 | (cpu)<<12) /* FP → arm */
  52. #define VMSR(cpu, fp) WORD $(0xeee00a10 | (fp)<<16 | (cpu)<<12) /* arm → FP */
  53. /*
  54. * a popular code sequence used to write a pte for va is:
  55. *
  56. * MOVW R(n), TTB[LnX(va)]
  57. * // clean the cache line
  58. * DSB
  59. * // invalidate tlb entry for va
  60. * FLBTC
  61. * DSB
  62. * PFF (now ISB)
  63. */
  64. /* zeroes R0 */
  65. #define BARRIERS FLBTC; DSB; ISB
  66. /*
  67. * invoked with PTE bits in R2, pa in R3, PTE pointed to by R4.
  68. * fill PTE pointed to by R4 and increment R4 past it.
  69. * increment R3 by a MB. clobbers R1.
  70. */
  71. #define FILLPTE() \
  72. ORR R3, R2, R1; /* pte bits in R2, pa in R3 */ \
  73. MOVW R1, (R4); \
  74. ADD $4, R4; /* bump PTE address */ \
  75. ADD $MiB, R3; /* bump pa */ \
  76. /* zero PTE pointed to by R4 and increment R4 past it. assumes R0 is 0. */
  77. #define ZEROPTE() \
  78. MOVW R0, (R4); \
  79. ADD $4, R4; /* bump PTE address */