arm.s 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*
  2. * sheevaplug machine assist, definitions
  3. * arm926ej-s processor at 1.2GHz
  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 PADDR(a) ((a) & ~KZERO)
  11. #define KADDR(a) (KZERO|(a))
  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. /* wave at the user; clobbers R1 & R7; needs R12 (SB) set */
  17. #define PUTC(c) \
  18. ISB; \
  19. MOVW $PHYSCONS, R7; \
  20. MOVW $(c), R1; \
  21. MOVW R1, (R7); \
  22. ISB
  23. /* new instructions */
  24. #define CLZ(s, d) WORD $(0xe16f0f10 | (d) << 12 | (s)) /* count leading 0s */
  25. #define DMB \
  26. MCR CpSC, 0, R0, C(CpCACHE), C(CpCACHEwb), CpCACHEdmbarr
  27. /*
  28. * data synchronisation barrier (formerly drain write buffer).
  29. * waits for cache flushes, eviction buffer drain, tlb flushes,
  30. * branch-prediction flushes, writes to memory; the lot.
  31. * on sheeva, also flushes L2 eviction buffer.
  32. * zeroes R0.
  33. */
  34. #define DSB \
  35. MOVW $0, R0; \
  36. MCR CpSC, 0, R0, C(CpCACHE), C(CpCACHEwb), CpCACHEwait
  37. /*
  38. * prefetch flush; zeroes R0.
  39. * arm926ej-s manual says we need to sync with l2 cache in isb,
  40. * and uncached load is the easiest way. doesn't seem to matter.
  41. */
  42. #define ISB \
  43. MOVW $0, R0; \
  44. MCR CpSC, 0, R0, C(CpCACHE), C(CpCACHEinvi), CpCACHEwait
  45. // MOVW (R0), R0; MOVW $0, R0
  46. /* zeroes R0 */
  47. #define BARRIERS ISB; DSB
  48. /*
  49. * invoked with PTE bits in R2, pa in R3, PTE pointed to by R4.
  50. * fill PTE pointed to by R4 and increment R4 past it.
  51. * increment R3 by a MB. clobbers R1.
  52. */
  53. #define FILLPTE() \
  54. ORR R3, R2, R1; /* pte bits in R2, pa in R3 */ \
  55. MOVW R1, (R4); \
  56. ADD $4, R4; /* bump PTE address */ \
  57. ADD $MiB, R3; /* bump pa */ \
  58. /* zero PTE pointed to by R4 and increment R4 past it. assumes R0 is 0. */
  59. #define ZEROPTE() \
  60. MOVW R0, (R4); \
  61. ADD $4, R4; /* bump PTE address */