4 #include <cxx/dyn_cast>
8 class Kobject_mappable;
15 class Kobject_common : public cxx::Dyn_castable<Kobject_common>
18 Kobject_common() = default;
19 Kobject_common(Kobject_common const &) = delete;
20 Kobject_common &operator = (Kobject_common const &) = delete;
22 virtual bool is_local(Space *) const = 0;
23 virtual Mword obj_id() const = 0;
24 virtual void initiate_deletion(Kobject ***) = 0;
26 virtual Kobject_mappable *map_root() = 0;
27 virtual ~Kobject_common() = 0;
30 class Kobject_iface : public cxx::Dyn_castable<Kobject_iface, Kobject_common>
33 virtual void invoke(L4_obj_ref self, L4_fpage::Rights rights, Syscall_frame *, Utcb *) = 0;
35 typedef Kobject_iface *Factory_func(Ram_quota *q,
38 Utcb const *utcb, int *err);
39 enum { Max_factory_index = -L4_msg_tag::Max_factory_label };
40 static Factory_func *factory[Max_factory_index + 1];
47 IMPLEMENT inline Kobject_common::~Kobject_common() {}
49 Kobject_iface::Factory_func *Kobject_iface::factory[Max_factory_index + 1];
53 Kobject_iface::commit_result(Mword error,
54 unsigned words = 0, unsigned items = 0)
56 return L4_msg_tag(words, items, 0, error);
61 Kobject_iface::commit_error(Utcb const *utcb, L4_error const &e,
62 L4_msg_tag const &tag = L4_msg_tag(0, 0, 0, 0))
64 const_cast<Utcb*>(utcb)->error = e;
65 return L4_msg_tag(tag, L4_msg_tag::Error);
70 Kobject_iface::downgrade(unsigned long del_attribs)
71 { (void)del_attribs; return this; }
75 Kobject_iface::set_factory(long label, Factory_func *f)
77 if (label > 0 || -label > Max_factory_index)
78 panic("error: registering factory for invalid protocol/label: %ld\n",
82 panic("error: factory for protocol/label %ld already registered: %p\n",
83 label, factory[-label]);
90 Kobject_iface::manufacture(long label, Ram_quota *q,
92 L4_msg_tag tag, Utcb const *utcb, int *err)
94 *err = L4_err::ENodev;
95 if (EXPECT_FALSE(label > 0 || -label > Max_factory_index
99 return factory[-label](q, current_space, tag, utcb, err);
102 // ------------------------------------------------------------------------
103 IMPLEMENTATION [debug]:
105 PUBLIC virtual Kobject_dbg *Kobject_common::dbg_info() const = 0;