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)
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.
10 #include "dataspace_annon.h"
11 #include "page_alloc.h"
12 #include "slab_alloc.h"
14 #include <l4/cxx/exceptions>
18 typedef Moe::Q_alloc<Moe::Dataspace_annon, Slab_alloc> Allocator;
20 static Allocator *alloc()
26 void *Moe::Dataspace_annon::operator new (size_t, Quota *q)
28 return alloc()->alloc(q);
31 void Moe::Dataspace_annon::operator delete (void *m) throw()
32 { alloc()->free((Moe::Dataspace_annon*)m); }
35 Moe::Dataspace_annon::Dataspace_annon(unsigned long _size, bool w,
36 unsigned char page_shift)
37 : Moe::Dataspace_cont(0, 0, w), _page_shift(page_shift)
39 unsigned long r_size = (_size + page_size() - 1) & ~(page_size() -1);
40 Quota_guard g(quota(), r_size);
42 void *m = Single_page_alloc_base::_alloc(r_size, page_size());
49 Moe::Dataspace_annon::~Dataspace_annon()
54 unsigned long r_size = (size() + page_size() - 1) & ~(page_size() -1);
55 Single_page_alloc_base::_free(adr, r_size);
56 quota()->free(r_size);