]> rtime.felk.cvut.cz Git - l4.git/blob - kernel/fiasco/src/drivers/mmu.cpp
update
[l4.git] / kernel / fiasco / src / drivers / mmu.cpp
1 INTERFACE:
2
3 #include "types.h"
4
5 template< unsigned long Flush_area = 0, bool Ram = false >
6 class Mmu
7 {
8 public:
9   /* start address is include, end address is exclusive
10    * (end = start + size) */
11   static void clean_vdcache();
12   static void clean_vdcache(void const *start, void const *end);
13   static void flush_vcache();
14   static void flush_vcache(void const *start, void const *end);
15   static void flush_vdcache();
16   static void flush_vdcache(void const *start, void const *end);
17   static void inv_vdcache(void const *start, void const *end);
18
19   /**
20    * Clean the entire dcache.
21    */
22   static void clean_dcache();
23
24
25   /**
26    * Clean given D cache region.
27    */
28   static void clean_dcache(void const *va);
29
30   /**
31    * Clean given D cache region.
32    */
33   static void clean_dcache(void const *start, void const *end);
34   /**
35    * Clean and invalidate the entire cache.
36    * D and I cache is cleaned and invalidated and the write buffer is
37    * drained.
38    */
39   static void flush_cache();
40
41
42   /**
43    * Clean and invalidate the given cache region.
44    * D and I cache are affected.
45    */
46   static void flush_cache(void const *start, void const *end);
47
48   /**
49    * Clean and invalidate the entire D cache.
50    */
51   static void flush_dcache();
52
53   /**
54    * Clean and invalidate the given D cache region.
55    */
56   static void flush_dcache(void const *start, void const *end);
57
58   /**
59    * Invalidate the given D cache region.
60    */
61   static void inv_dcache(void const *start, void const *end);
62
63   /**
64    * Switch page table and do the necessary things. 
65    */
66   static void switch_pdbr(Address base);
67   
68  // static void write_back_data_cache(bool ram = false);
69  // static void write_back_data_cache(void *a);
70 };
71
72 //---------------------------------------------------------------------------
73 IMPLEMENTATION [!arm || arm_nocache]:
74
75 IMPLEMENT inline
76 template< unsigned long Flush_area, bool Ram >
77 void Mmu<Flush_area, Ram>::flush_cache()
78 {}
79
80 IMPLEMENT inline
81 template< unsigned long Flush_area, bool Ram >
82 void Mmu<Flush_area, Ram>::flush_cache(void const *, void const *)
83 {}
84
85 IMPLEMENT inline
86 template< unsigned long Flush_area, bool Ram >
87 void Mmu<Flush_area, Ram>::clean_dcache()
88 {}
89
90 IMPLEMENT inline
91 template< unsigned long Flush_area, bool Ram >
92 void Mmu<Flush_area, Ram>::clean_dcache(void const *, void const *)
93 {}
94
95 IMPLEMENT inline
96 template< unsigned long Flush_area, bool Ram >
97 void Mmu<Flush_area, Ram>::flush_dcache()
98 {}
99
100 IMPLEMENT inline
101 template< unsigned long Flush_area, bool Ram >
102 void Mmu<Flush_area, Ram>::flush_dcache(void const *, void const *)
103 {}
104
105 IMPLEMENT inline
106 template< unsigned long Flush_area, bool Ram >
107 void Mmu<Flush_area, Ram>::inv_dcache(void const *, void const *)
108 {}
109
110 //---------------------------------------------------------------------------
111 IMPLEMENTATION[!vcache]:
112
113 IMPLEMENT inline
114 template< unsigned long Flush_area, bool Ram >
115 void Mmu<Flush_area, Ram>::flush_vcache(void const *, void const *)
116 {}
117
118 IMPLEMENT
119 template< unsigned long Flush_area , bool Ram >
120 void Mmu<Flush_area, Ram>::clean_vdcache(void const *, void const *)
121 {}
122
123 IMPLEMENT
124 template< unsigned long Flush_area, bool Ram >
125 void Mmu<Flush_area, Ram>::flush_vdcache(void const *, void const *)
126 {}
127
128 IMPLEMENT
129 template< unsigned long Flush_area, bool Ram >
130 void Mmu<Flush_area, Ram>::inv_vdcache(void const *, void const *)
131 {}
132
133 IMPLEMENT
134 template< unsigned long Flush_area, bool Ram >
135 void Mmu<Flush_area, Ram>::flush_vcache()
136 {}
137
138 IMPLEMENT
139 template< unsigned long Flush_area, bool Ram >
140 void Mmu<Flush_area, Ram>::clean_vdcache()
141 {}
142
143 IMPLEMENT
144 template< unsigned long Flush_area, bool Ram >
145 void Mmu<Flush_area, Ram>::flush_vdcache()
146 {}
147
148
149 //---------------------------------------------------------------------------
150 IMPLEMENTATION[vcache]:
151
152 IMPLEMENT inline
153 template< unsigned long Flush_area, bool Ram >
154 void Mmu<Flush_area, Ram>::flush_vcache(void const *start, 
155                                        void const *end)
156 { flush_cache(start, end); }
157
158 IMPLEMENT
159 template< unsigned long Flush_area , bool Ram >
160 void Mmu<Flush_area, Ram>::clean_vdcache(void const *start, void const *end)
161 { clean_dcache(start, end); }
162
163 IMPLEMENT
164 template< unsigned long Flush_area, bool Ram >
165 void Mmu<Flush_area, Ram>::flush_vdcache(void const *start, void const *end)
166 { flush_dcache(start, end); }
167
168 IMPLEMENT
169 template< unsigned long Flush_area, bool Ram >
170 void Mmu<Flush_area, Ram>::inv_vdcache(void const *start, void const *end)
171 { inv_dcache(start, end); }
172
173 IMPLEMENT
174 template< unsigned long Flush_area, bool Ram >
175 void Mmu<Flush_area, Ram>::flush_vcache()
176 { flush_cache(); }
177
178 IMPLEMENT
179 template< unsigned long Flush_area, bool Ram >
180 void Mmu<Flush_area, Ram>::clean_vdcache()
181 { clean_dcache(); }
182
183 IMPLEMENT
184 template< unsigned long Flush_area, bool Ram >
185 void Mmu<Flush_area, Ram>::flush_vdcache()
186 { flush_dcache(); }