1 /*
2  * (c) 2008-2009 Adam Lackorzynski <adam@os.inf.tu-dresden.de>,
3  *               Alexander Warg <warg@os.inf.tu-dresden.de>
4  *     economic rights: Technische Universität Dresden (Germany)
5  *
6  * This file is part of TUD:OS and distributed under the terms of the
7  * GNU General Public License 2.
8  * Please see the COPYING-GPL-2 file for details.
9  */
10 #ifndef SIGMA0_MEM_MAN_H__
11 #define SIGMA0_MEM_MAN_H__
12 
13 #include <l4/cxx/avl_set>
14 #include <l4/sys/types.h>
15 
16 #include "page_alloc.h"
17 #include "region.h"
18 #include "globals.h"
19 
20 
21 class Mem_man
22 {
23 private:
24   bool add(Region const &r);
25   bool alloc_from(Region const *r2, Region const &r);
26   bool morecore();
27 
28   static Mem_man _ram;
29 
30 public:
31   typedef cxx::Avl_set< Region, cxx::Lt_functor<Region>, Slab_alloc> Tree;
32 
33 private:
34   Tree _tree;
35 
36 public:
ram()37   static Mem_man *ram() { return &_ram; }
38 
39   unsigned long alloc(Region const &r);
40   bool alloc_get_rights(Region const &r, L4_fpage_rights *rights);
41   bool reserve(Region const &r);
42   bool add_free(Region const &r);
43   Region const *find(Region const &r, bool force = false) const;
44 
45   unsigned long alloc_first(unsigned long size, unsigned owner = sigma0_taskno);
46 
47   void dump();
48 };
49 
50 #endif
51 
52