3 #include "mem_layout.h"
6 class Mem_unit : public Mmu< Mem_layout::Cache_flush_area >
15 static void tlb_flush();
16 static void dtlb_flush(void *va);
17 static void tlb_flush(unsigned long asid);
18 static void tlb_flush(void *va, unsigned long asid);
20 static void kernel_tlb_flush();
23 //---------------------------------------------------------------------------
27 void Mem_unit::tlb_flush()
29 asm volatile("mcr p15, 0, %0, c8, c7, 0" // TLBIALL
30 : : "r" (0) : "memory");
34 void Mem_unit::dtlb_flush(void *va)
36 asm volatile("mcr p15, 0, %0, c8, c6, 1" // DTLBIMVA
37 : : "r" ((unsigned long)va & 0xfffff000) : "memory");
40 IMPLEMENT_DEFAULT inline NEEDS[Mem_unit::tlb_flush]
41 void Mem_unit::kernel_tlb_flush()
44 PUBLIC static inline ALWAYS_INLINE
46 Mem_unit::make_coherent_to_pou(void const *v)
49 //---------------------------------------------------------------------------
50 IMPLEMENTATION [arm && armv5]:
53 void Mem_unit::tlb_flush(void *va, unsigned long)
55 asm volatile("mcr p15, 0, %0, c8, c7, 1"
56 : : "r" ((unsigned long)va & 0xfffff000) : "memory");
60 void Mem_unit::tlb_flush(unsigned long)
62 asm volatile("mcr p15, 0, r0, c8, c7, 0" : : "r" (0) : "memory");
65 //---------------------------------------------------------------------------
66 IMPLEMENTATION [arm && (armv6 || armv7) && !hyp]:
69 void Mem_unit::tlb_flush(void *va, unsigned long asid)
71 if (asid == Asid_invalid)
75 asm volatile("mcr p15, 0, %0, c8, c7, 1" // TLBIMVA
76 : : "r" (((unsigned long)va & 0xfffff000) | asid) : "memory");
80 void Mem_unit::tlb_flush(unsigned long asid)
84 asm volatile("mcr p15, 0, %0, c8, c7, 2" // TLBIASID
85 : : "r" (asid) : "memory");
88 //---------------------------------------------------------------------------
89 IMPLEMENTATION [arm && (armv6 || armv7) && hyp]:
92 void Mem_unit::tlb_flush(void *va, unsigned long asid)
94 if (asid == Asid_invalid)
100 "mrrc p15, 6, %[tmp1], %[tmp2], c2 \n"
101 "mcrr p15, 6, %[tmp1], %[asid], c2 \n"
103 "mcr p15, 0, %[mva], c8, c7, 3 \n"
104 "mcrr p15, 6, %[tmp1], %[tmp2], c2 \n"
105 : [tmp1] "=&r" (t1), [tmp2] "=&r" (t2)
106 : [mva] "r" (((unsigned long)va & 0xfffff000)), [asid] "r" (asid << 16)
109 if (0) asm volatile ( "mcr p15, 4, r0, c8, c7, 4" );
113 void Mem_unit::tlb_flush(unsigned long asid)
119 "mrrc p15, 6, %[tmp1], %[tmp2], c2 \n"
120 "mcrr p15, 6, %[tmp1], %[asid], c2 \n"
122 "mcr p15, 0, %[tmp1], c8, c7, 0 \n"
123 "mcrr p15, 6, %[tmp1], %[tmp2], c2 \n"
124 : [tmp1] "=&r" (t1), [tmp2] "=&r" (t2)
125 : [asid] "r" (asid << 16)
128 if (0) asm volatile ( "mcr p15, 4, r0, c8, c7, 4" );
131 //---------------------------------------------------------------------------
132 IMPLEMENTATION [arm && hyp]:
134 IMPLEMENT_OVERRIDE inline
135 void Mem_unit::kernel_tlb_flush()
137 asm volatile("mcr p15, 4, r0, c8, c7, 0" : : "r" (0) : "memory");