]> rtime.felk.cvut.cz Git - l4.git/blob - kernel/fiasco/src/kern/ia32/mem_unit-ia32.cpp
Some minor fixes.
[l4.git] / kernel / fiasco / src / kern / ia32 / mem_unit-ia32.cpp
1 INTERFACE[ia32 || amd64]:
2
3 #include "types.h"
4
5 class Mem_unit
6 {
7 };
8
9
10 IMPLEMENTATION[ia32 || amd64]:
11
12 PUBLIC static inline ALWAYS_INLINE
13 void
14 Mem_unit::make_coherent_to_pou(void const *)
15 {}
16
17 /** Flush the whole TLB.
18  */
19 PUBLIC static inline ALWAYS_INLINE
20 void
21 Mem_unit::tlb_flush()
22 {
23   Mword dummy;
24   __asm__ __volatile__ ("mov %%cr3,%0; mov %0,%%cr3 " : "=r"(dummy) : : "memory");
25 }
26
27
28 /** Flush TLB at virtual address.
29  */
30 PUBLIC static inline ALWAYS_INLINE
31 void
32 Mem_unit::tlb_flush(Address addr)
33 {
34   __asm__ __volatile__ ("invlpg %0" : : "m" (*(char*)addr) : "memory");
35 }
36
37 PUBLIC static inline ALWAYS_INLINE
38 void
39 Mem_unit::clean_dcache()
40 { asm volatile ("wbinvd"); }
41
42 PUBLIC static inline ALWAYS_INLINE
43 void
44 Mem_unit::clean_dcache(void const *addr)
45 { asm volatile ("clflush %0" : : "m" (*(char const *)addr)); }
46
47 PUBLIC static inline ALWAYS_INLINE
48 void
49 Mem_unit::clean_dcache(void const *start, void const *end)
50 {
51   enum { Cl_size = 64 };
52   if (((Address)end) - ((Address)start) >= 8192)
53     clean_dcache();
54   else
55     for (char const *s = (char const *)start; s < (char const *)end;
56          s += Cl_size)
57       clean_dcache(s);
58 }