L4Re Operating System Framework – Interface and Usage Documentation
Loading...
Searching...
No Matches
capability
Go to the documentation of this file.
1// vim:set ft=cpp: -*- Mode: C++ -*-
9/*
10 * (c) 2008-2009,2015 Author(s)
11 * economic rights: Technische Universität Dresden (Germany)
12 *
13 * This file is part of TUD:OS and distributed under the terms of the
14 * GNU General Public License 2.
15 * Please see the COPYING-GPL-2 file for details.
16 *
17 * As a special exception, you may use this file as part of a free software
18 * library without restriction. Specifically, if other files instantiate
19 * templates or use macros or inline functions from this file, or you compile
20 * this file and link it with other files to produce an executable, this
21 * file does not by itself cause the resulting executable to be covered by
22 * the GNU General Public License. This exception does not however
23 * invalidate any other reasons why the executable file might be covered by
24 * the GNU General Public License.
25 */
26#pragma once
27
28#include <l4/sys/consts.h>
29#include <l4/sys/types.h>
30#include <l4/sys/kobject>
31#include <l4/sys/task.h>
32
33namespace L4
34{
35
36/* Forward declarations for our kernel object classes. */
37class Task;
38class Thread;
39class Factory;
40class Irq;
41class Log;
42class Vm;
43class Kobject;
44
60#if __cplusplus >= 201103L
61# define L4_DISABLE_COPY(_class) \
62 public: \
63 _class(_class const &) = delete; \
64 _class operator = (_class const &) = delete; \
65 private:
66#else
67# define L4_DISABLE_COPY(_class) \
68 private: \
69 _class(_class const &); \
70 _class operator = (_class const &);
71#endif
72
73
74#define L4_KOBJECT_DISABLE_COPY(_class) \
75 protected: \
76 _class(); \
77 L4_DISABLE_COPY(_class)
78
79
80#define L4_KOBJECT(_class) L4_KOBJECT_DISABLE_COPY(_class)
81
82inline l4_msgtag_t
83Cap_base::validate(Cap<Task> task, l4_utcb_t *u) const noexcept
84{
85 return is_valid() ? l4_task_cap_valid_u(task.cap(), _c, u)
86 : l4_msgtag(0, 0, 0, 0);
87}
88
89inline l4_msgtag_t
90Cap_base::validate(l4_utcb_t *u) const noexcept
91{
92 return is_valid() ? l4_task_cap_valid_u(L4_BASE_TASK_CAP, _c, u)
93 : l4_msgtag(0, 0, 0, 0);
94}
95
96}; // namespace L4
97
98#include <l4/sys/meta>
99
100namespace L4 {
101
123template< typename T, typename F >
124inline
126{
127 if (!c.is_valid())
128 return Cap<T>::Invalid;
129
130 Cap<Meta> mc = cap_reinterpret_cast<Meta>(c);
131 Type_info const *m = kobject_typeid<T>();
132 if (m->proto() && l4_error(mc->supports(m->proto())) > 0)
133 return Cap<T>(c.cap());
134
135 // FIXME: use generic checker
136#if 0
137 if (l4_error(mc->supports(T::kobject_proto())) > 0)
138 return Cap<T>(c.cap());
139#endif
140
141 return Cap<T>::Invalid;
142}
143
144}
l4_msgtag_t validate(l4_utcb_t *u=l4_utcb()) const noexcept
Check whether a capability is present (refers to an object).
Definition capability:90
C++ interface for capabilities.
Definition capability.h:222
@ L4_BASE_TASK_CAP
Capability selector for the current task.
Definition consts.h:316
long l4_error(l4_msgtag_t tag) L4_NOTHROW
Get IPC error code if any or message tag label otherwise for an IPC call.
Definition ipc.h:636
l4_msgtag_t l4_msgtag(long label, unsigned words, unsigned items, unsigned flags) L4_NOTHROW
Create a message tag from the specified values.
Definition types.h:427
struct l4_utcb_t l4_utcb_t
Opaque type for the UTCB.
Definition utcb.h:67
Common L4 ABI Data Types.
L4 low-level kernel interface.
Cap< T > cap_dynamic_cast(Cap< F > const &c) noexcept
dynamic_cast for capabilities.
Definition capability:125
Dynamic Type Information for L4Re Interfaces.
Definition __typeinfo.h:510
Message tag data structure.
Definition types.h:163
Meta interface for getting dynamic type information about objects behind capabilities.