ross.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. /*
  2. * ross.h: Ross module specific definitions and defines.
  3. *
  4. * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
  5. */
  6. #ifndef _SPARC_ROSS_H
  7. #define _SPARC_ROSS_H
  8. #include <asm/asi.h>
  9. #include <asm/page.h>
  10. /* Ross made Hypersparcs have a %psr 'impl' field of '0001'. The 'vers'
  11. * field has '1111'.
  12. */
  13. /* The MMU control register fields on the HyperSparc.
  14. *
  15. * -----------------------------------------------------------------
  16. * |implvers| RSV |CWR|SE|WBE| MID |BM| C|CS|MR|CM|RSV|CE|RSV|NF|ME|
  17. * -----------------------------------------------------------------
  18. * 31 24 23-22 21 20 19 18-15 14 13 12 11 10 9 8 7-2 1 0
  19. *
  20. * Phew, lots of fields there ;-)
  21. *
  22. * CWR: Cache Wrapping Enabled, if one cache wrapping is on.
  23. * SE: Snoop Enable, turns on bus snooping for cache activity if one.
  24. * WBE: Write Buffer Enable, one turns it on.
  25. * MID: The ModuleID of the chip for MBus transactions.
  26. * BM: Boot-Mode. One indicates the MMU is in boot mode.
  27. * C: Indicates whether accesses are cachable while the MMU is
  28. * disabled.
  29. * CS: Cache Size -- 0 = 128k, 1 = 256k
  30. * MR: Memory Reflection, one indicates that the memory bus connected
  31. * to the MBus supports memory reflection.
  32. * CM: Cache Mode -- 0 = write-through, 1 = copy-back
  33. * CE: Cache Enable -- 0 = no caching, 1 = cache is on
  34. * NF: No Fault -- 0 = faults trap the CPU from supervisor mode
  35. * 1 = faults from supervisor mode do not generate traps
  36. * ME: MMU Enable -- 0 = MMU is off, 1 = MMU is on
  37. */
  38. #define HYPERSPARC_CWENABLE 0x00200000
  39. #define HYPERSPARC_SBENABLE 0x00100000
  40. #define HYPERSPARC_WBENABLE 0x00080000
  41. #define HYPERSPARC_MIDMASK 0x00078000
  42. #define HYPERSPARC_BMODE 0x00004000
  43. #define HYPERSPARC_ACENABLE 0x00002000
  44. #define HYPERSPARC_CSIZE 0x00001000
  45. #define HYPERSPARC_MRFLCT 0x00000800
  46. #define HYPERSPARC_CMODE 0x00000400
  47. #define HYPERSPARC_CENABLE 0x00000100
  48. #define HYPERSPARC_NFAULT 0x00000002
  49. #define HYPERSPARC_MENABLE 0x00000001
  50. /* The ICCR instruction cache register on the HyperSparc.
  51. *
  52. * -----------------------------------------------
  53. * | | FTD | ICE |
  54. * -----------------------------------------------
  55. * 31 1 0
  56. *
  57. * This register is accessed using the V8 'wrasr' and 'rdasr'
  58. * opcodes, since not all assemblers understand them and those
  59. * that do use different semantics I will just hard code the
  60. * instruction with a '.word' statement.
  61. *
  62. * FTD: If set to one flush instructions executed during an
  63. * instruction cache hit occurs, the corresponding line
  64. * for said cache-hit is invalidated. If FTD is zero,
  65. * an unimplemented 'flush' trap will occur when any
  66. * flush is executed by the processor.
  67. *
  68. * ICE: If set to one, the instruction cache is enabled. If
  69. * zero, the cache will not be used for instruction fetches.
  70. *
  71. * All other bits are read as zeros, and writes to them have no
  72. * effect.
  73. *
  74. * Wheee, not many assemblers understand the %iccr register nor
  75. * the generic asr r/w instructions.
  76. *
  77. * 1000 0011 0100 0111 1100 0000 0000 0000 ! rd %iccr, %g1
  78. *
  79. * 0x 8 3 4 7 c 0 0 0 ! 0x8347c000
  80. *
  81. * 1011 1111 1000 0000 0110 0000 0000 0000 ! wr %g1, 0x0, %iccr
  82. *
  83. * 0x b f 8 0 6 0 0 0 ! 0xbf806000
  84. *
  85. */
  86. #define HYPERSPARC_ICCR_FTD 0x00000002
  87. #define HYPERSPARC_ICCR_ICE 0x00000001
  88. #ifndef __ASSEMBLY__
  89. static inline unsigned int get_ross_icr(void)
  90. {
  91. unsigned int icreg;
  92. __asm__ __volatile__(".word 0x8347c000\n\t" /* rd %iccr, %g1 */
  93. "mov %%g1, %0\n\t"
  94. : "=r" (icreg)
  95. : /* no inputs */
  96. : "g1", "memory");
  97. return icreg;
  98. }
  99. static inline void put_ross_icr(unsigned int icreg)
  100. {
  101. __asm__ __volatile__("or %%g0, %0, %%g1\n\t"
  102. ".word 0xbf806000\n\t" /* wr %g1, 0x0, %iccr */
  103. "nop\n\t"
  104. "nop\n\t"
  105. "nop\n\t"
  106. : /* no outputs */
  107. : "r" (icreg)
  108. : "g1", "memory");
  109. return;
  110. }
  111. /* HyperSparc specific cache flushing. */
  112. /* This is for the on-chip instruction cache. */
  113. static inline void hyper_flush_whole_icache(void)
  114. {
  115. __asm__ __volatile__("sta %%g0, [%%g0] %0\n\t"
  116. : /* no outputs */
  117. : "i" (ASI_M_FLUSH_IWHOLE)
  118. : "memory");
  119. return;
  120. }
  121. extern int vac_cache_size;
  122. extern int vac_line_size;
  123. static inline void hyper_clear_all_tags(void)
  124. {
  125. unsigned long addr;
  126. for(addr = 0; addr < vac_cache_size; addr += vac_line_size)
  127. __asm__ __volatile__("sta %%g0, [%0] %1\n\t"
  128. : /* no outputs */
  129. : "r" (addr), "i" (ASI_M_DATAC_TAG)
  130. : "memory");
  131. }
  132. static inline void hyper_flush_unconditional_combined(void)
  133. {
  134. unsigned long addr;
  135. for (addr = 0; addr < vac_cache_size; addr += vac_line_size)
  136. __asm__ __volatile__("sta %%g0, [%0] %1\n\t"
  137. : /* no outputs */
  138. : "r" (addr), "i" (ASI_M_FLUSH_CTX)
  139. : "memory");
  140. }
  141. static inline void hyper_flush_cache_user(void)
  142. {
  143. unsigned long addr;
  144. for (addr = 0; addr < vac_cache_size; addr += vac_line_size)
  145. __asm__ __volatile__("sta %%g0, [%0] %1\n\t"
  146. : /* no outputs */
  147. : "r" (addr), "i" (ASI_M_FLUSH_USER)
  148. : "memory");
  149. }
  150. static inline void hyper_flush_cache_page(unsigned long page)
  151. {
  152. unsigned long end;
  153. page &= PAGE_MASK;
  154. end = page + PAGE_SIZE;
  155. while (page < end) {
  156. __asm__ __volatile__("sta %%g0, [%0] %1\n\t"
  157. : /* no outputs */
  158. : "r" (page), "i" (ASI_M_FLUSH_PAGE)
  159. : "memory");
  160. page += vac_line_size;
  161. }
  162. }
  163. #endif /* !(__ASSEMBLY__) */
  164. #endif /* !(_SPARC_ROSS_H) */