L4Re – L4 Runtime Environment
kobject
1 // vi:set ft=cpp: -*- Mode: C++ -*-
2 /* \file
3  * Kobject C++ interface.
4  */
5 /*
6  * Copyright (C) 2015 Kernkonzept GmbH.
7  * Author(s): Alexander Warg <alexander.warg@kernkonzept.com>
8  *
9  * This file is distributed under the terms of the GNU General Public
10  * License, version 2. Please see the COPYING-GPL-2 file for details.
11  *
12  * As a special exception, you may use this file as part of a free software
13  * library without restriction. Specifically, if other files instantiate
14  * templates or use macros or inline functions from this file, or you compile
15  * this file and link it with other files to produce an executable, this
16  * file does not by itself cause the resulting executable to be covered by
17  * the GNU General Public License. This exception does not however
18  * invalidate any other reasons why the executable file might be covered by
19  * the GNU General Public License.
20  */
21 #pragma once
22 
23 #include "kernel_object.h"
24 #include "types.h"
25 #include "__typeinfo.h"
26 
27 namespace L4 {
28 
46 class L4_EXPORT Kobject
47 {
48 private:
49  Kobject();
50  Kobject(Kobject const &);
51  Kobject &operator = (Kobject const &);
52 
53  template<typename T> friend struct Kobject_typeid;
54 
55 protected:
56  typedef Typeid::Iface<L4_PROTO_META, Kobject> __Iface;
57  typedef Typeid::Iface_list<__Iface> __Iface_list;
58 
65  struct __Kobject_typeid
66  {
67  typedef Type_info::Demand_t<> Demand;
68  static Type_info const _m;
69  };
70 
79  l4_cap_idx_t cap() const noexcept { return _c(); }
80 
81 private:
82 
87  l4_cap_idx_t _c() const noexcept
88  { return reinterpret_cast<l4_cap_idx_t>(this) & L4_CAP_MASK; }
89 
90 public:
105  { return l4_kobject_dec_refcnt_u(cap(), diff, utcb); }
106 };
107 
108 template<typename Derived, long PROTO = L4::PROTO_ANY,
109  typename S_DEMAND = Type_info::Demand_t<> >
110 struct Kobject_0t : Kobject_t<Derived, L4::Kobject, PROTO, S_DEMAND> {};
111 
112 }
113 
Type information handling.
Base class for all kinds of kernel objects and remote objects, referenced by capabilities.
Definition: kobject:47
l4_cap_idx_t cap() const noexcept
Return capability selector.
Definition: kobject:79
l4_msgtag_t dec_refcnt(l4_mword_t diff, l4_utcb_t *utcb=l4_utcb())
Decrement the in kernel reference counter for the object.
Definition: kobject:104
signed long l4_mword_t
Signed machine word.
Definition: l4int.h:49
unsigned long l4_cap_idx_t
L4 Capability selector Type.
Definition: types.h:342
@ L4_CAP_MASK
Mask to get only the relevant bits of an l4_cap_idx_t.
Definition: consts.h:139
struct l4_utcb_t l4_utcb_t
Opaque type for the UTCB.
Definition: utcb.h:67
l4_utcb_t * l4_utcb(void) L4_NOTHROW L4_PURE
Get the UTCB address.
Definition: utcb.h:340
Kernel object system calls.
L4 low-level kernel interface.
@ PROTO_ANY
Default protocol used by Kobject_t and Kobject_x.
Definition: __typeinfo.h:58
Meta object for handling access to type information of Kobjects.
Definition: __typeinfo.h:621
Template type statically describing demand of receive buffers.
Definition: __typeinfo.h:564
Dynamic Type Information for L4Re Interfaces.
Definition: __typeinfo.h:510
Message tag data structure.
Definition: types.h:160