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