sun3mmu.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. /*
  2. * Definitions for Sun3 custom MMU.
  3. */
  4. #ifndef __SUN3_MMU_H__
  5. #define __SUN3_MMU_H__
  6. #include <linux/types.h>
  7. #include <asm/movs.h>
  8. #include <asm/sun3-head.h>
  9. /* MMU characteristics. */
  10. #define SUN3_SEGMAPS_PER_CONTEXT 2048
  11. #define SUN3_PMEGS_NUM 256
  12. #define SUN3_CONTEXTS_NUM 8
  13. #define SUN3_PMEG_SIZE_BITS 17
  14. #define SUN3_PMEG_SIZE (1 << SUN3_PMEG_SIZE_BITS)
  15. #define SUN3_PMEG_MASK (SUN3_PMEG_SIZE - 1)
  16. #define SUN3_PTE_SIZE_BITS 13
  17. #define SUN3_PTE_SIZE (1 << SUN3_PTE_SIZE_BITS)
  18. #define SUN3_PTE_MASK (SUN3_PTE_SIZE - 1)
  19. #define SUN3_CONTROL_MASK (0x0FFFFFFC)
  20. #define SUN3_INVALID_PMEG 255
  21. #define SUN3_INVALID_CONTEXT 255
  22. #define AC_IDPROM 0x00000000 /* 34 ID PROM, R/O, byte, 32 bytes */
  23. #define AC_PAGEMAP 0x10000000 /* 3 Pagemap R/W, long */
  24. #define AC_SEGMAP 0x20000000 /* 3 Segment map, byte */
  25. #define AC_CONTEXT 0x30000000 /* 34c current mmu-context */
  26. #define AC_SENABLE 0x40000000 /* 34c system dvma/cache/reset enable reg*/
  27. #define AC_UDVMA_ENB 0x50000000 /* 34 Not used on Sun boards, byte */
  28. #define AC_BUS_ERROR 0x60000000 /* 34 Cleared on read, byte. */
  29. #define AC_SYNC_ERR 0x60000000 /* c fault type */
  30. #define AC_SYNC_VA 0x60000004 /* c fault virtual address */
  31. #define AC_ASYNC_ERR 0x60000008 /* c asynchronous fault type */
  32. #define AC_ASYNC_VA 0x6000000c /* c async fault virtual address */
  33. #define AC_LEDS 0x70000000 /* 34 Zero turns on LEDs, byte */
  34. #define AC_CACHETAGS 0x80000000 /* 34c direct access to the VAC tags */
  35. #define AC_CACHEDDATA 0x90000000 /* 3 c direct access to the VAC data */
  36. #define AC_UDVMA_MAP 0xD0000000 /* 4 Not used on Sun boards, byte */
  37. #define AC_VME_VECTOR 0xE0000000 /* 4 For non-Autovector VME, byte */
  38. #define AC_BOOT_SCC 0xF0000000 /* 34 bypass to access Zilog 8530. byte.*/
  39. #define SUN3_PAGE_CHG_MASK (SUN3_PAGE_PGNUM_MASK \
  40. | SUN3_PAGE_ACCESSED | SUN3_PAGE_MODIFIED)
  41. /* Bus access type within PTE. */
  42. #define SUN3_PAGE_TYPE_MASK (0x0c000000)
  43. #define SUN3_PAGE_TYPE_MEMORY (0x00000000)
  44. #define SUN3_PAGE_TYPE_IO (0x04000000)
  45. #define SUN3_PAGE_TYPE_VME16 (0x08000000)
  46. #define SUN3_PAGE_TYPE_VME32 (0x0c000000)
  47. /* Mask for page number within PTE. */
  48. #define SUN3_PAGE_PGNUM_MASK (0x0007FFFF)
  49. /* Bits within bus-error register. */
  50. #define SUN3_BUSERR_WATCHDOG (0x01)
  51. #define SUN3_BUSERR_unused (0x02)
  52. #define SUN3_BUSERR_FPAENERR (0x04)
  53. #define SUN3_BUSERR_FPABERR (0x08)
  54. #define SUN3_BUSERR_VMEBERR (0x10)
  55. #define SUN3_BUSERR_TIMEOUT (0x20)
  56. #define SUN3_BUSERR_PROTERR (0x40)
  57. #define SUN3_BUSERR_INVALID (0x80)
  58. #ifndef __ASSEMBLY__
  59. /* Read bus error status register (implicitly clearing it). */
  60. static inline unsigned char sun3_get_buserr(void)
  61. {
  62. unsigned char sfc, c;
  63. GET_SFC (sfc);
  64. SET_SFC (FC_CONTROL);
  65. GET_CONTROL_BYTE (AC_BUS_ERROR, c);
  66. SET_SFC (sfc);
  67. return c;
  68. }
  69. /* Read segmap from hardware MMU. */
  70. static inline unsigned long sun3_get_segmap(unsigned long addr)
  71. {
  72. register unsigned long entry;
  73. unsigned char c, sfc;
  74. GET_SFC (sfc);
  75. SET_SFC (FC_CONTROL);
  76. GET_CONTROL_BYTE (AC_SEGMAP | (addr & SUN3_CONTROL_MASK), c);
  77. SET_SFC (sfc);
  78. entry = c;
  79. return entry;
  80. }
  81. /* Write segmap to hardware MMU. */
  82. static inline void sun3_put_segmap(unsigned long addr, unsigned long entry)
  83. {
  84. unsigned char sfc;
  85. GET_DFC (sfc);
  86. SET_DFC (FC_CONTROL);
  87. SET_CONTROL_BYTE (AC_SEGMAP | (addr & SUN3_CONTROL_MASK), entry);
  88. SET_DFC (sfc);
  89. return;
  90. }
  91. /* Read PTE from hardware MMU. */
  92. static inline unsigned long sun3_get_pte(unsigned long addr)
  93. {
  94. register unsigned long entry;
  95. unsigned char sfc;
  96. GET_SFC (sfc);
  97. SET_SFC (FC_CONTROL);
  98. GET_CONTROL_WORD (AC_PAGEMAP | (addr & SUN3_CONTROL_MASK), entry);
  99. SET_SFC (sfc);
  100. return entry;
  101. }
  102. /* Write PTE to hardware MMU. */
  103. static inline void sun3_put_pte(unsigned long addr, unsigned long entry)
  104. {
  105. unsigned char sfc;
  106. GET_DFC (sfc);
  107. SET_DFC (FC_CONTROL);
  108. SET_CONTROL_WORD (AC_PAGEMAP | (addr & SUN3_CONTROL_MASK), entry);
  109. SET_DFC (sfc);
  110. return;
  111. }
  112. /* get current context */
  113. static inline unsigned char sun3_get_context(void)
  114. {
  115. unsigned char sfc, c;
  116. GET_SFC(sfc);
  117. SET_SFC(FC_CONTROL);
  118. GET_CONTROL_BYTE(AC_CONTEXT, c);
  119. SET_SFC(sfc);
  120. return c;
  121. }
  122. /* set alternate context */
  123. static inline void sun3_put_context(unsigned char c)
  124. {
  125. unsigned char dfc;
  126. GET_DFC(dfc);
  127. SET_DFC(FC_CONTROL);
  128. SET_CONTROL_BYTE(AC_CONTEXT, c);
  129. SET_DFC(dfc);
  130. return;
  131. }
  132. extern void __iomem *sun3_ioremap(unsigned long phys, unsigned long size,
  133. unsigned long type);
  134. extern int sun3_map_test(unsigned long addr, char *val);
  135. #endif /* !__ASSEMBLY__ */
  136. #endif /* !__SUN3_MMU_H__ */