/* * (c) 2008-2009 Alexander Warg * economic rights: Technische Universität Dresden (Germany) * * This file is part of TUD:OS and distributed under the terms of the * GNU General Public License 2. * Please see the COPYING-GPL-2 file for details. */ #pragma once #include #include #include "quota.h" #include "server_obj.h" #include #ifndef NDEBUG #include typedef L4Re::Debug_obj_t Allocator_iface; #else typedef L4::Factory Allocator_iface; #endif namespace Moe { class Dataspace; } class Allocator : public L4::Epiface_t { private: Moe::Q_alloc _qalloc; long _sched_prio_limit; public: explicit Allocator(size_t limit, unsigned prio_limit = 0) : _qalloc(limit), _sched_prio_limit(prio_limit) {} template T *make_obj(ARGS &&...args) { T *o = qalloc()->make_obj(cxx::forward(args)...); Obj_list::insert_after(o, Obj_list::iter(this)); return o; } Moe::Q_alloc *qalloc() { return &_qalloc; } Moe::Dataspace *alloc(long size, unsigned long flags = 0, unsigned long align = 0); /// Return the quota allocator that contains this factory. Moe::Q_alloc *parent_qalloc() { return dynamic_cast(Moe::Malloc_container::from_ptr(this)); } virtual ~Allocator(); int op_create(L4::Factory::Rights rights, L4::Ipc::Cap &, long, L4::Ipc::Varg_list<> &&args); #ifndef NDEBUG long op_debug(L4Re::Debug_obj::Rights, unsigned long function); #endif static Allocator *root_allocator(); };