#include <l4/cxx/auto_ptr>
#include <l4/cxx/l4iostream>
-#include <l4/re/protocols>
-#include <l4/re/mem_alloc-sys.h>
-#include <l4/re/mem_alloc>
#include <l4/sys/factory>
#include <l4/re/util/meta>
virtual ~LLog() {}
};
+static L4::Ipc::Cap<void> new_cap(L4::Epiface *o)
+{
+ Gate_alloc::registry.register_obj(o);
+ return L4::Ipc::make_cap(o->obj_cap(), L4_CAP_FPAGE_RWSD);
+}
+
int
-Allocator::disp_factory(l4_umword_t, L4::Ipc::Iostream &ios)
+Allocator::op_create(L4::Factory::Rights, L4::Ipc::Cap<void> &res,
+ long type, L4::Ipc::Varg_list<> &&args)
{
- L4::Factory::Proto o;
- ios >> o;
- switch (o)
+ switch (type)
{
- case L4Re::Protocol::Namespace:
- ios << Gate_alloc::registry.register_obj(new Ldr::Name_space());
+ case L4Re::Namespace::Protocol:
+ res = new_cap(new Ldr::Name_space());
return L4_EOK;
- case L4Re::Protocol::Rm:
- ios << Gate_alloc::registry.register_obj(new Region_map());
+ case L4Re::Rm::Protocol:
+ res = new_cap(new Region_map());
return L4_EOK;
-
case L4_PROTO_LOG:
- {
- L4::Ipc::Istream_copy is(ios);
- L4::Ipc::Varg tag;
- is.get(&tag);
+ {
+ L4::Ipc::Varg tag = args.next();
- if (!tag.is_of<char const *>())
- return -L4_EINVAL;
+ if (!tag.is_of<char const *>())
+ return -L4_EINVAL;
- L4::Ipc::Varg col;
- is.get(&col);
+ L4::Ipc::Varg col = args.next();
- int color;
- if (col.is_of<char const *>())
- color = LLog::color_value(cxx::String(col.value<char const*>(),
- col.length()));
- else if(col.is_of_int()) // ignore sign
- color = col.value<long>();
- else
- color = 7;
+ int color;
+ if (col.is_of<char const *>())
+ color = LLog::color_value(cxx::String(col.value<char const*>(),
+ col.length()));
+ else if(col.is_of_int()) // ignore sign
+ color = col.value<long>();
+ else
+ color = 7;
- Ldr::Log *l = new LLog(tag.value<char const*>(), tag.length(), color);
+ Ldr::Log *l = new LLog(tag.value<char const*>(), tag.length(), color);
- ios << Gate_alloc::registry.register_obj(l);
- return L4_EOK;
- }
+ res = new_cap(l);
+ return L4_EOK;
+ }
case L4::Scheduler::Protocol:
- {
- if (!_sched_prio_limit)
- return -L4_ENODEV;
+ {
+ if (!_sched_prio_limit)
+ return -L4_ENODEV;
- L4::Ipc::Varg p_max, p_base, cpus;
- ios.get(&p_max);
- ios.get(&p_base);
- ios.get(&cpus);
+ L4::Ipc::Varg p_max = args.next(), p_base = args.next(), cpus = args.next();
- if (!p_max.is_of_int() || !p_base.is_of_int()) // ignore sign
- return -L4_EINVAL;
+ if (!p_max.is_of_int() || !p_base.is_of_int()) // ignore sign
+ return -L4_EINVAL;
- if (p_max.value<l4_mword_t>() > _sched_prio_limit
- || p_base.value<l4_mword_t>() > _sched_prio_limit)
- return -L4_ERANGE;
+ if (p_max.value<l4_mword_t>() > _sched_prio_limit
+ || p_base.value<l4_mword_t>() > _sched_prio_limit)
+ return -L4_ERANGE;
- if (p_max.value<l4_umword_t>() <= p_base.value<l4_umword_t>())
- return -L4_EINVAL;
+ if (p_max.value<l4_umword_t>() <= p_base.value<l4_umword_t>())
+ return -L4_EINVAL;
- l4_umword_t cpu_mask = ~0UL;
+ l4_umword_t cpu_mask = ~0UL;
- if (!cpus.is_of<void>() && cpus.is_of_int())
- cpu_mask = cpus.value<l4_umword_t>();
+ if (!cpus.is_of<void>() && cpus.is_of_int())
+ cpu_mask = cpus.value<l4_umword_t>();
- Sched_proxy *o = new Sched_proxy();
- o->set_prio(p_base.value<l4_mword_t>(), p_max.value<l4_mword_t>());
- o->restrict_cpus(cpu_mask);
+ Sched_proxy *o = new Sched_proxy();
+ o->set_prio(p_base.value<l4_mword_t>(), p_max.value<l4_mword_t>());
+ o->restrict_cpus(cpu_mask);
- ios << Gate_alloc::registry.register_obj(o);
- return L4_EOK;
- }
+ res = new_cap(o);
+ return L4_EOK;
+ }
default:
return -L4_ENODEV;
}
}
-int
-Allocator::dispatch(l4_umword_t obj, L4::Ipc::Iostream &ios)
-{
- l4_msgtag_t tag;
- ios >> tag;
- switch (tag.label())
- {
- case L4::Meta::Protocol:
- return L4Re::Util::handle_meta_request<L4::Factory>(ios);
- case L4::Factory::Protocol:
- return disp_factory(obj, ios);
-
- default:
- return -L4_EBADPROTO;
- }
-}
-
-
Allocator *
Allocator::root_allocator()
{