]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/moe/server/src/alloc.h
update
[l4.git] / l4 / pkg / moe / server / src / alloc.h
1 /*
2  * (c) 2008-2009 Alexander Warg <warg@os.inf.tu-dresden.de>
3  *     economic rights: Technische Universität Dresden (Germany)
4  *
5  * This file is part of TUD:OS and distributed under the terms of the
6  * GNU General Public License 2.
7  * Please see the COPYING-GPL-2 file for details.
8  */
9 #pragma once
10
11 #include <l4/cxx/ipc_server>
12 #include "quota.h"
13 #include "server_obj.h"
14
15 #include <l4/cxx/list>
16
17 namespace Moe {
18 class Dataspace;
19 }
20
21 class Allocator : public Moe::Server_object, public Moe::Q_object
22 {
23 private:
24   cxx::List_item _head;
25   Moe::Quota _quota;
26   long _sched_prio_limit;
27   l4_umword_t _sched_cpu_mask;
28
29 public:
30   explicit Allocator(size_t limit, unsigned prio_limit = 0)
31   : _quota(limit), _sched_prio_limit(prio_limit), _sched_cpu_mask(~0UL)
32   {}
33
34   Moe::Quota *quota() { return &_quota; }
35
36   Moe::Dataspace *alloc(unsigned long size, unsigned long flags = 0,
37                         unsigned long align = 0);
38
39   virtual ~Allocator();
40
41   int dispatch(l4_umword_t obj, L4::Ipc::Iostream &ios);
42   int disp_factory(l4_umword_t, L4::Ipc::Iostream &ios);
43
44   void *operator new (size_t size, Moe::Quota *q, size_t limit);
45   void operator delete (void *m) throw();
46
47   L4::Server_object *open(int argc, cxx::String const *argv);
48   static Allocator *root_allocator();
49
50 };