0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef _ASM_ARC_MMU_ARCV2_H
0010 #define _ASM_ARC_MMU_ARCV2_H
0011
0012
0013
0014
0015 #define ARC_REG_MMU_BCR 0x06f
0016
0017 #ifdef CONFIG_ARC_MMU_V3
0018 #define ARC_REG_TLBPD0 0x405
0019 #define ARC_REG_TLBPD1 0x406
0020 #define ARC_REG_TLBPD1HI 0
0021 #define ARC_REG_TLBINDEX 0x407
0022 #define ARC_REG_TLBCOMMAND 0x408
0023 #define ARC_REG_PID 0x409
0024 #define ARC_REG_SCRATCH_DATA0 0x418
0025 #else
0026 #define ARC_REG_TLBPD0 0x460
0027 #define ARC_REG_TLBPD1 0x461
0028 #define ARC_REG_TLBPD1HI 0x463
0029 #define ARC_REG_TLBINDEX 0x464
0030 #define ARC_REG_TLBCOMMAND 0x465
0031 #define ARC_REG_PID 0x468
0032 #define ARC_REG_SCRATCH_DATA0 0x46c
0033 #endif
0034
0035
0036 #define __TLB_ENABLE (1 << 31)
0037 #define __PROG_ENABLE (1 << 30)
0038 #define MMU_ENABLE (__TLB_ENABLE | __PROG_ENABLE)
0039
0040
0041 #define TLB_LKUP_ERR 0x80000000
0042
0043 #ifdef CONFIG_ARC_MMU_V3
0044 #define TLB_DUP_ERR (TLB_LKUP_ERR | 0x00000001)
0045 #else
0046 #define TLB_DUP_ERR (TLB_LKUP_ERR | 0x40000000)
0047 #endif
0048
0049
0050
0051
0052 #define TLBWrite 0x1
0053 #define TLBRead 0x2
0054 #define TLBGetIndex 0x3
0055 #define TLBProbe 0x4
0056 #define TLBWriteNI 0x5
0057 #define TLBIVUTLB 0x6
0058
0059 #ifdef CONFIG_ARC_MMU_V4
0060 #define TLBInsertEntry 0x7
0061 #define TLBDeleteEntry 0x8
0062 #endif
0063
0064
0065 #define PTE_BITS_IN_PD0 (_PAGE_GLOBAL | _PAGE_PRESENT | _PAGE_HW_SZ)
0066 #define PTE_BITS_RWX (_PAGE_EXECUTE | _PAGE_WRITE | _PAGE_READ)
0067
0068 #define PTE_BITS_NON_RWX_IN_PD1 (PAGE_MASK_PHYS | _PAGE_CACHEABLE)
0069
0070 #ifndef __ASSEMBLY__
0071
0072 struct mm_struct;
0073 extern int pae40_exist_but_not_enab(void);
0074
0075 static inline int is_pae40_enabled(void)
0076 {
0077 return IS_ENABLED(CONFIG_ARC_HAS_PAE40);
0078 }
0079
0080 static inline void mmu_setup_asid(struct mm_struct *mm, unsigned long asid)
0081 {
0082 write_aux_reg(ARC_REG_PID, asid | MMU_ENABLE);
0083 }
0084
0085 static inline void mmu_setup_pgd(struct mm_struct *mm, void *pgd)
0086 {
0087
0088 #ifdef CONFIG_ISA_ARCV2
0089 write_aux_reg(ARC_REG_SCRATCH_DATA0, (unsigned int)pgd);
0090 #endif
0091 }
0092
0093 #else
0094
0095 .macro ARC_MMU_REENABLE reg
0096 lr \reg, [ARC_REG_PID]
0097 or \reg, \reg, MMU_ENABLE
0098 sr \reg, [ARC_REG_PID]
0099 .endm
0100
0101 #endif
0102
0103 #endif