]> rtime.felk.cvut.cz Git - l4.git/blob - kernel/fiasco/src/kern/arm/mem_unit.cpp
update
[l4.git] / kernel / fiasco / src / kern / arm / mem_unit.cpp
1 INTERFACE [arm]:
2
3 #include "kmem.h"
4 #include "mmu.h"
5
6 class Mem_unit : public Mmu< Kmem::Cache_flush_area >
7 {
8 public:
9   static void tlb_flush();
10   static void dtlb_flush( void* va );
11   static void dtlb_flush();
12   static void tlb_flush(unsigned long asid);
13   static void dtlb_flush(unsigned long asid);
14 };
15
16 //---------------------------------------------------------------------------
17 IMPLEMENTATION [arm]:
18
19 IMPLEMENT inline
20 void Mem_unit::tlb_flush()
21 {
22   asm volatile (
23       "mcr p15, 0, %0, c8, c7, 0x00 \n"
24       :
25       : "r" (0)
26       : "memory" ); // TLB flush
27 }
28
29
30 IMPLEMENT inline
31 void Mem_unit::dtlb_flush( void* va )
32 {
33   asm volatile (
34       "mcr p15, 0, %0, c8, c6, 0x01 \n"
35       :
36       : "r"((unsigned long)va & 0xfffff000)
37       : "memory" ); // TLB flush
38 }
39
40 IMPLEMENT inline
41 void Mem_unit::dtlb_flush()
42 {
43   asm volatile (
44       "mcr p15, 0, %0, c8, c6, 0x0 \n"
45       :
46       : "r"(0)
47       : "memory" ); // TLB flush
48 }
49
50 //---------------------------------------------------------------------------
51 IMPLEMENTATION [arm && armv5]:
52
53 PUBLIC static inline
54 void Mem_unit::tlb_flush( void* va, unsigned long)
55 {
56   asm volatile (
57       "mcr p15, 0, %0, c8, c7, 0x01 \n"
58       :
59       : "r"((unsigned long)va & 0xfffff000)
60       : "memory" ); // TLB flush
61 }
62
63
64 IMPLEMENT inline
65 void Mem_unit::tlb_flush(unsigned long)
66 {
67   asm volatile (
68       "mcr p15, 0, r0, c8, c7, 0x00 \n"
69       :
70       :
71       : "memory" ); // TLB flush
72 }
73
74 IMPLEMENT inline
75 void Mem_unit::dtlb_flush(unsigned long)
76 {
77   asm volatile (
78       "mcr p15, 0, %0, c8, c6, 0x0 \n"
79       :
80       : "r"(0)
81       : "memory" ); // TLB flush
82 }
83
84
85 //---------------------------------------------------------------------------
86 IMPLEMENTATION [arm && (armv6 || armv7)]:
87
88 PUBLIC static inline
89 void Mem_unit::tlb_flush(void *va, unsigned long asid)
90 {
91   if (asid == ~0UL)
92     return;
93   btc_flush();
94   asm volatile (
95       "mcr p15, 0, %1, c7, c10, 4   \n" // drain write buffer
96       "mcr p15, 0, %0, c8, c7, 1    \n" // flush both TLB entry
97       :
98       : "r"(((unsigned long)va & 0xfffff000) | (asid & 0xff)),
99         "r" (0)
100       : "memory" );
101 }
102
103 IMPLEMENT inline
104 void Mem_unit::tlb_flush(unsigned long asid)
105 {
106   btc_flush();
107   asm volatile (
108       "mcr p15, 0, %1, c7, c10, 4   \n" // drain write buffer
109       "mcr p15, 0, %0, c8, c7, 2    \n" // flush both TLB with asid
110       :
111       : "r"(asid),
112         "r" (0)
113       : "memory" );
114 }
115
116 IMPLEMENT inline
117 void Mem_unit::dtlb_flush(unsigned long asid)
118 {
119   asm volatile (
120       "mcr p15, 0, r0, c7, c10, 4   \n" // drain write buffer
121       "mcr p15, 0, %0, c8, c6, 2    \n" // flush data TLB with asid
122       :
123       : "r"(asid)
124       : "memory" );
125 }
126