0001
0002 #ifndef _ASM_POWERPC_MMU_8XX_H_
0003 #define _ASM_POWERPC_MMU_8XX_H_
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 #define SPRN_MI_CTR 784
0016 #define MI_GPM 0x80000000
0017 #define MI_PPM 0x40000000
0018 #define MI_CIDEF 0x20000000
0019 #define MI_RSV4I 0x08000000
0020 #define MI_PPCS 0x02000000
0021 #define MI_IDXMASK 0x00001f00
0022
0023
0024
0025
0026 #define SPRN_MI_AP 786
0027 #define MI_Ks 0x80000000
0028 #define MI_Kp 0x40000000
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045 #define MI_APG_INIT 0xde000000
0046
0047
0048
0049
0050
0051 #define SPRN_MI_EPN 787
0052 #define MI_EPNMASK 0xfffff000
0053 #define MI_EVALID 0x00000200
0054 #define MI_ASIDMASK 0x0000000f
0055
0056
0057
0058
0059
0060
0061 #define SPRN_MI_TWC 789
0062 #define MI_APG 0x000001e0
0063 #define MI_GUARDED 0x00000010
0064 #define MI_PSMASK 0x0000000c
0065 #define MI_PS8MEG 0x0000000c
0066 #define MI_PS512K 0x00000004
0067 #define MI_PS4K_16K 0x00000000
0068 #define MI_SVALID 0x00000001
0069
0070
0071
0072
0073
0074
0075 #define SPRN_MI_RPN 790
0076 #define MI_SPS16K 0x00000008
0077
0078
0079
0080
0081
0082
0083 #define MI_BOOTINIT 0x000001fd
0084
0085 #define SPRN_MD_CTR 792
0086 #define MD_GPM 0x80000000
0087 #define MD_PPM 0x40000000
0088 #define MD_CIDEF 0x20000000
0089 #define MD_WTDEF 0x10000000
0090 #define MD_RSV4I 0x08000000
0091 #define MD_TWAM 0x04000000
0092 #define MD_PPCS 0x02000000
0093 #define MD_IDXMASK 0x00001f00
0094
0095 #define SPRN_M_CASID 793
0096 #define MC_ASIDMASK 0x0000000f
0097
0098
0099
0100
0101
0102 #define SPRN_MD_AP 794
0103 #define MD_Ks 0x80000000
0104 #define MD_Kp 0x40000000
0105
0106
0107 #define MD_APG_INIT 0xdc000000
0108 #define MD_APG_KUAP 0xde000000
0109
0110
0111
0112
0113
0114 #define SPRN_MD_EPN 795
0115 #define MD_EPNMASK 0xfffff000
0116 #define MD_EVALID 0x00000200
0117 #define MD_ASIDMASK 0x0000000f
0118
0119
0120
0121
0122
0123
0124 #define SPRN_M_TWB 796
0125 #define M_L1TB 0xfffff000
0126 #define M_L1INDX 0x00000ffc
0127
0128
0129
0130
0131
0132
0133
0134 #define SPRN_MD_TWC 797
0135 #define MD_L2TB 0xfffff000
0136 #define MD_L2INDX 0xfffffe00
0137 #define MD_APG 0x000001e0
0138 #define MD_GUARDED 0x00000010
0139 #define MD_PSMASK 0x0000000c
0140 #define MD_PS8MEG 0x0000000c
0141 #define MD_PS512K 0x00000004
0142 #define MD_PS4K_16K 0x00000000
0143 #define MD_WT 0x00000002
0144 #define MD_SVALID 0x00000001
0145
0146
0147
0148
0149
0150
0151
0152 #define SPRN_MD_RPN 798
0153 #define MD_SPS16K 0x00000008
0154
0155
0156
0157
0158 #define SPRN_M_TW 799
0159
0160 #if defined(CONFIG_PPC_4K_PAGES)
0161 #define mmu_virtual_psize MMU_PAGE_4K
0162 #elif defined(CONFIG_PPC_16K_PAGES)
0163 #define mmu_virtual_psize MMU_PAGE_16K
0164 #define PTE_FRAG_NR 4
0165 #define PTE_FRAG_SIZE_SHIFT 12
0166 #define PTE_FRAG_SIZE (1UL << 12)
0167 #else
0168 #error "Unsupported PAGE_SIZE"
0169 #endif
0170
0171 #define mmu_linear_psize MMU_PAGE_8M
0172
0173 #define MODULES_VADDR (PAGE_OFFSET - SZ_256M)
0174 #define MODULES_END PAGE_OFFSET
0175
0176 #ifndef __ASSEMBLY__
0177
0178 #include <linux/mmdebug.h>
0179 #include <linux/sizes.h>
0180
0181 void mmu_pin_tlb(unsigned long top, bool readonly);
0182
0183 typedef struct {
0184 unsigned int id;
0185 unsigned int active;
0186 void __user *vdso;
0187 void *pte_frag;
0188 } mm_context_t;
0189
0190 #define PHYS_IMMR_BASE (mfspr(SPRN_IMMR) & 0xfff80000)
0191 #define VIRT_IMMR_BASE (__fix_to_virt(FIX_IMMR_BASE))
0192
0193
0194
0195
0196
0197
0198
0199 struct mmu_psize_def {
0200 unsigned int shift;
0201 unsigned int enc;
0202 unsigned int ind;
0203 unsigned int flags;
0204 #define MMU_PAGE_SIZE_DIRECT 0x1
0205 #define MMU_PAGE_SIZE_INDIRECT 0x2
0206 };
0207
0208 extern struct mmu_psize_def mmu_psize_defs[MMU_PAGE_COUNT];
0209
0210 static inline int shift_to_mmu_psize(unsigned int shift)
0211 {
0212 int psize;
0213
0214 for (psize = 0; psize < MMU_PAGE_COUNT; ++psize)
0215 if (mmu_psize_defs[psize].shift == shift)
0216 return psize;
0217 return -1;
0218 }
0219
0220 static inline unsigned int mmu_psize_to_shift(unsigned int mmu_psize)
0221 {
0222 if (mmu_psize_defs[mmu_psize].shift)
0223 return mmu_psize_defs[mmu_psize].shift;
0224 BUG();
0225 }
0226
0227 static inline bool arch_vmap_try_size(unsigned long addr, unsigned long end, u64 pfn,
0228 unsigned int max_page_shift, unsigned long size)
0229 {
0230 if (end - addr < size)
0231 return false;
0232
0233 if ((1UL << max_page_shift) < size)
0234 return false;
0235
0236 if (!IS_ALIGNED(addr, size))
0237 return false;
0238
0239 if (!IS_ALIGNED(PFN_PHYS(pfn), size))
0240 return false;
0241
0242 return true;
0243 }
0244
0245 static inline unsigned long arch_vmap_pte_range_map_size(unsigned long addr, unsigned long end,
0246 u64 pfn, unsigned int max_page_shift)
0247 {
0248 if (arch_vmap_try_size(addr, end, pfn, max_page_shift, SZ_512K))
0249 return SZ_512K;
0250 if (PAGE_SIZE == SZ_16K)
0251 return SZ_16K;
0252 if (arch_vmap_try_size(addr, end, pfn, max_page_shift, SZ_16K))
0253 return SZ_16K;
0254 return PAGE_SIZE;
0255 }
0256 #define arch_vmap_pte_range_map_size arch_vmap_pte_range_map_size
0257
0258 static inline int arch_vmap_pte_supported_shift(unsigned long size)
0259 {
0260 if (size >= SZ_512K)
0261 return 19;
0262 else if (size >= SZ_16K)
0263 return 14;
0264 else
0265 return PAGE_SHIFT;
0266 }
0267 #define arch_vmap_pte_supported_shift arch_vmap_pte_supported_shift
0268
0269
0270 extern s32 patch__itlbmiss_exit_1, patch__dtlbmiss_exit_1;
0271 extern s32 patch__itlbmiss_perf, patch__dtlbmiss_perf;
0272
0273 #endif
0274
0275 #endif