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 * License: see LICENSE.spdx (in this directory or the directories above)
14 */
15#pragma once
16
17#include <l4/sys/consts.h>
18#include <l4/sys/types.h>
19#include <l4/sys/kobject>
20#include <l4/sys/task.h>
21
22namespace L4
23{
24
25/* Forward declarations for our kernel object classes. */
26class Task;
27class Thread;
28class Factory;
29class Irq;
30class Log;
31class Vm;
32class Vcpu_context;
33class Kobject;
34
50#if __cplusplus >= 201103L
51# define L4_DISABLE_COPY(_class) \
52 public: \
53 _class(_class const &) = delete; \
54 _class operator = (_class const &) = delete; \
55 private:
56#else
57# define L4_DISABLE_COPY(_class) \
58 private: \
59 _class(_class const &); \
60 _class operator = (_class const &);
61#endif
62
63
64#define L4_KOBJECT_DISABLE_COPY(_class) \
65 protected: \
66 _class(); \
67 L4_DISABLE_COPY(_class)
68
69
70#define L4_KOBJECT(_class) L4_KOBJECT_DISABLE_COPY(_class)
71
72inline l4_msgtag_t
73Cap_base::validate(Cap<Task> task, l4_utcb_t *u) const noexcept
74{
75 return is_valid() ? l4_task_cap_valid_u(task.cap(), _c, u)
76 : l4_msgtag(0, 0, 0, 0);
77}
78
79inline l4_msgtag_t
80Cap_base::validate(l4_utcb_t *u) const noexcept
81{
82 return is_valid() ? l4_task_cap_valid_u(L4_BASE_TASK_CAP, _c, u)
83 : l4_msgtag(0, 0, 0, 0);
84}
85
86}; // namespace L4
87
88#include <l4/sys/meta>
89
90namespace L4 {
91
113template< typename T, typename F >
114inline
116{
117 if (!c.is_valid())
118 return Cap<T>::Invalid;
119
120 Cap<Meta> mc = cap_reinterpret_cast<Meta>(c);
121 Type_info const *m = kobject_typeid<T>();
122 if (m->proto() && l4_error(mc->supports(m->proto())) > 0)
123 return Cap<T>(c.cap());
124
125 // FIXME: use generic checker
126#if 0
127 if (l4_error(mc->supports(T::kobject_proto())) > 0)
128 return Cap<T>(c.cap());
129#endif
130
131 return Cap<T>::Invalid;
132}
133
134}
l4_msgtag_t validate(l4_utcb_t *u=l4_utcb()) const noexcept
Check whether a capability is present (refers to an object).
Definition capability:80
C++ interface for capabilities.
Definition capability.h:219
@ L4_BASE_TASK_CAP
Capability selector for the current task.
Definition consts.h:331
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:646
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:404
struct l4_utcb_t l4_utcb_t
Opaque type for the UTCB.
Definition utcb.h:56
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:115
Dynamic Type Information for L4Re Interfaces.
Definition __typeinfo.h:500
Message tag data structure.
Definition types.h:153
Meta interface for getting dynamic type information about objects behind capabilities.