]> rtime.felk.cvut.cz Git - l4.git/blob - kernel/fiasco/src/kern/globals.cpp
Update
[l4.git] / kernel / fiasco / src / kern / globals.cpp
1 INTERFACE:
2
3 #include <cassert>
4
5 #include "panic.h"
6 #include "per_cpu_data.h"
7 #include "types.h"
8
9 class Timeout;
10
11 extern Per_cpu<Timeout *> timeslice_timeout;
12
13 /* the check macro is like assert(), but it evaluates its argument
14    even if NDEBUG is defined */
15 #ifndef check
16 #ifdef NDEBUG
17 # define check(expression) ((void)(expression))
18 #else /* ! NDEBUG */
19 # define check(expression) assert(expression)
20 #endif /* NDEBUG */
21 #endif /* check */
22
23 class Kobject_iface;
24
25 class Initial_kobjects
26 {
27 public:
28   enum Initial_cap
29   {
30     Task      = 1,
31     Factory   = 2,
32     Thread    = 3,
33     Pager     = 4,
34     Log       = 5,
35     Icu       = 6,
36     Scheduler = 7,
37     Iommu     = 8,
38
39     First_alloc_cap = Log,
40     Num_alloc       = 5,
41     End_alloc_cap   = First_alloc_cap + Num_alloc,
42   };
43
44   static Cap_index first() { return Cap_index(First_alloc_cap); }
45   static Cap_index end() { return Cap_index(End_alloc_cap); }
46
47   void register_obj(Kobject_iface *o, Initial_cap cap)
48   {
49     assert (cap >= First_alloc_cap);
50     assert (cap < End_alloc_cap);
51
52     int c = cap - First_alloc_cap;
53
54     assert (!_v[c]);
55
56     _v[c] = o;
57   }
58
59   Kobject_iface *obj(Cap_index cap) const
60   {
61     assert (cap >= first());
62     assert (cap < end());
63
64     return _v[cxx::int_value<Cap_diff>(cap - first())];
65   }
66
67 private:
68   Kobject_iface *_v[Num_alloc];
69 };
70
71
72 extern Initial_kobjects initial_kobjects;
73
74
75 //---------------------------------------------------------------------------
76 IMPLEMENTATION:
77
78 Initial_kobjects initial_kobjects;
79
80