]> rtime.felk.cvut.cz Git - l4.git/blob - kernel/fiasco/src/kern/ia32/vm.cpp
update
[l4.git] / kernel / fiasco / src / kern / ia32 / vm.cpp
1 INTERFACE:
2
3 #include "task.h"
4
5 class Vm : public Task
6 {
7 public:
8   ~Vm() {}
9
10   int resume_vcpu(Context *, Vcpu_state *, bool) = 0;
11 };
12
13 template< typename VM >
14 struct Vm_allocator
15 {
16   static Kmem_slab_t<VM> a;
17 };
18
19 template<typename VM>
20 Kmem_slab_t<VM> Vm_allocator<VM>::a("Vm");
21
22 // ------------------------------------------------------------------------
23 IMPLEMENTATION:
24
25 #include "cpu.h"
26
27 class Mem_space_vm : public Mem_space
28 {
29 public:
30   Mem_space_vm(Ram_quota *q) : Mem_space(q, false) {}
31   virtual Page_number map_max_address() const
32   { return Page_number::create(1UL << (MWORD_BITS - Page_shift)); }
33 };
34
35 struct Vm_space_factory
36 {
37   /** Create a usual Mem_space object. */
38   template< typename A1 >
39   static void create(Mem_space *v, A1 a1)
40   { new (v) Mem_space_vm(a1); }
41
42   template< typename S >
43   static void create(S *v)
44   { new (v) S(); }
45 };
46
47
48 PUBLIC
49 Vm::Vm(Ram_quota *q) : Task(Vm_space_factory(), q)
50 {}
51
52 PUBLIC static
53 template< typename VM >
54 slab_cache_anon *
55 Vm::allocator()
56 { return &Vm_allocator<VM>::a; }
57
58
59 // ------------------------------------------------------------------------
60 IMPLEMENTATION [ia32]:
61
62 PROTECTED static inline
63 bool
64 Vm::is_64bit()
65 { return false; }
66
67 // ------------------------------------------------------------------------
68 IMPLEMENTATION [amd64]:
69
70 PROTECTED static inline
71 bool
72 Vm::is_64bit()
73 { return true; }