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 Vcpu_context;
44class Kobject;
45
61#if __cplusplus >= 201103L
62# define L4_DISABLE_COPY(_class) \
63 public: \
64 _class(_class const &) = delete; \
65 _class operator = (_class const &) = delete; \
66 private:
67#else
68# define L4_DISABLE_COPY(_class) \
69 private: \
70 _class(_class const &); \
71 _class operator = (_class const &);
72#endif
73
74
75#define L4_KOBJECT_DISABLE_COPY(_class) \
76 protected: \
77 _class(); \
78 L4_DISABLE_COPY(_class)
79
80
81#define L4_KOBJECT(_class) L4_KOBJECT_DISABLE_COPY(_class)
82
83inline l4_msgtag_t
84Cap_base::validate(Cap<Task> task, l4_utcb_t *u) const noexcept
85{
86 return is_valid() ? l4_task_cap_valid_u(task.cap(), _c, u)
87 : l4_msgtag(0, 0, 0, 0);
88}
89
90inline l4_msgtag_t
91Cap_base::validate(l4_utcb_t *u) const noexcept
92{
93 return is_valid() ? l4_task_cap_valid_u(L4_BASE_TASK_CAP, _c, u)
94 : l4_msgtag(0, 0, 0, 0);
95}
96
97}; // namespace L4
98
99#include <l4/sys/meta>
100
101namespace L4 {
102
124template< typename T, typename F >
125inline
127{
128 if (!c.is_valid())
129 return Cap<T>::Invalid;
130
131 Cap<Meta> mc = cap_reinterpret_cast<Meta>(c);
132 Type_info const *m = kobject_typeid<T>();
133 if (m->proto() && l4_error(mc->supports(m->proto())) > 0)
134 return Cap<T>(c.cap());
135
136 // FIXME: use generic checker
137#if 0
138 if (l4_error(mc->supports(T::kobject_proto())) > 0)
139 return Cap<T>(c.cap());
140#endif
141
142 return Cap<T>::Invalid;
143}
144
145}
l4_msgtag_t validate(l4_utcb_t *u=l4_utcb()) const noexcept
Check whether a capability is present (refers to an object).
Definition capability:91
C++ interface for capabilities.
Definition capability.h:219
@ 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:657
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:428
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.
Definition io_regblock.h:19
Cap< T > cap_dynamic_cast(Cap< F > const &c) noexcept
dynamic_cast for capabilities.
Definition capability:126
Dynamic Type Information for L4Re Interfaces.
Definition __typeinfo.h:511
Message tag data structure.
Definition types.h:164
Meta interface for getting dynamic type information about objects behind capabilities.