]> rtime.felk.cvut.cz Git - l4.git/blob - kernel/fiasco/src/kern/fpu.cpp
09629f02f039033bbccf58ea1fcebbb550edf2ca
[l4.git] / kernel / fiasco / src / kern / fpu.cpp
1 /*
2  * Fiasco
3  * Floating point unit code
4  */
5
6 INTERFACE:
7
8 #include "initcalls.h"
9 #include "per_cpu_data.h"
10 #include "types.h"
11
12 class slab_cache_anon;
13 class Context;
14 class Fpu_state;
15 struct Trap_state;
16
17
18 class Fpu
19 {
20 public:
21
22   static Context *owner(unsigned cpu);
23   static void set_owner(unsigned cpu, Context *owner);
24   static bool is_owner(unsigned cpu, Context *owner);
25
26   // all the following methods are arch dependent
27   static void init(unsigned cpu) FIASCO_INIT_CPU;
28   static unsigned state_size();
29   static unsigned state_align();
30   static void init_state(Fpu_state *);
31   static void restore_state(Fpu_state *);
32   static void save_state(Fpu_state *);
33   static void disable();
34   static void enable();
35
36 private:
37
38   static Per_cpu<Context *>_owner;
39 };
40
41 IMPLEMENTATION:
42
43 #include "fpu_state.h"
44
45 Per_cpu<Context *> DEFINE_PER_CPU Fpu::_owner;
46
47 IMPLEMENT inline
48 Context * Fpu::owner(unsigned cpu)
49 {
50   return _owner.cpu(cpu);
51 }
52
53 IMPLEMENT inline
54 void Fpu::set_owner(unsigned cpu, Context *owner)
55 {
56   _owner.cpu(cpu) = owner;
57 }
58
59 IMPLEMENT inline
60 bool Fpu::is_owner(unsigned cpu, Context *owner)
61 {
62   return _owner.cpu(cpu) == owner;
63 }
64
65 //---------------------------------------------------------------------------
66 IMPLEMENTATION [!fpu]:
67
68 IMPLEMENT inline
69 void Fpu::init_state(Fpu_state *)
70 {}
71
72 IMPLEMENT inline
73 unsigned Fpu::state_size()
74 { return 0; }
75
76 IMPLEMENT inline
77 unsigned Fpu::state_align()
78 { return 0; }
79
80 IMPLEMENT
81 void Fpu::init(unsigned)
82 {}
83
84 IMPLEMENT inline
85 void Fpu::save_state(Fpu_state *)
86 {}
87
88 IMPLEMENT inline
89 void Fpu::restore_state(Fpu_state *)
90 {}
91
92 IMPLEMENT inline
93 void Fpu::disable()
94 {}
95
96 IMPLEMENT inline
97 void Fpu::enable()
98 {}