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 Thread_group;
29class Factory;
30class Irq;
31class Log;
32class Vm;
33class Vcpu_context;
34class Kobject;
35
51#if __cplusplus >= 201103L
52# define L4_DISABLE_COPY(_class) \
53 public: \
54 _class(_class const &) = delete; \
55 _class operator = (_class const &) = delete; \
56 private:
57#else
58# define L4_DISABLE_COPY(_class) \
59 private: \
60 _class(_class const &); \
61 _class operator = (_class const &);
62#endif
63
64
65#define L4_KOBJECT_DISABLE_COPY(_class) \
66 protected: \
67 _class(); \
68 L4_DISABLE_COPY(_class)
69
70
71#define L4_KOBJECT(_class) L4_KOBJECT_DISABLE_COPY(_class)
72
73inline l4_msgtag_t
74Cap_base::validate(Cap<Task> task, l4_utcb_t *u) const noexcept
75{
76 return is_valid() ? l4_task_cap_valid_u(task.cap(), _c, u)
77 : l4_msgtag(0, 0, 0, 0);
78}
79
80inline l4_msgtag_t
81Cap_base::validate(l4_utcb_t *u) const noexcept
82{
83 return is_valid() ? l4_task_cap_valid_u(L4_BASE_TASK_CAP, _c, u)
84 : l4_msgtag(0, 0, 0, 0);
85}
86
87}; // namespace L4
88
89#include <l4/sys/meta>
90
91namespace L4 {
92
114template< typename T, typename F >
115inline
117{
118 if (!c.is_valid())
119 return Cap<T>::Invalid;
120
122 Type_info const *m = kobject_typeid<T>();
123 if (m->proto() && l4_error(mc->supports(m->proto())) > 0)
124 return Cap<T>(c.cap());
125
126 // FIXME: use generic checker
127#if 0
128 if (l4_error(mc->supports(T::kobject_proto())) > 0)
129 return Cap<T>(c.cap());
130#endif
131
132 return Cap<T>::Invalid;
133}
134
135}
l4_cap_idx_t _c
The C representation of a capability selector.
Definition capability.h:203
bool is_valid() const noexcept
Test whether the capability is a valid capability index (i.e., not L4_INVALID_CAP).
Definition capability.h:57
@ Invalid
Invalid capability selector.
Definition capability.h:42
l4_msgtag_t validate(l4_utcb_t *u=l4_utcb()) const noexcept
Check whether a capability is present (refers to an object).
Definition capability:81
C++ interface for capabilities.
Definition capability.h:224
C++ Factory interface, see Factory for the C interface.
Definition factory:39
C++ Irq interface, see IRQs for the C interface.
Definition irq:121
Base class for all kinds of kernel objects and remote objects, referenced by capabilities.
Definition kobject:37
C++ interface of the Task kernel object, see Task for the C interface.
Definition task:36
C++ L4 kernel thread group interface, see Thread groups for the C interface.
Definition thread_group:37
C++ L4 kernel thread interface, see Thread for the C interface.
Definition thread:55
Virtual machine host address space.
Definition __vm-arm.h:18
@ L4_BASE_TASK_CAP
Capability selector for the current task.
Definition consts.h:327
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
Type_info const * kobject_typeid() noexcept
Get the L4::Type_info for the L4Re interface given in T.
Definition __typeinfo.h:682
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:405
struct l4_utcb_t l4_utcb_t
Opaque type for the UTCB.
Definition utcb.h:56
Common constants.
Common task related definitions.
Common L4 ABI Data Types.
L4 low-level kernel interface.
Cap< T > cap_reinterpret_cast(Cap< F > const &c) noexcept
reinterpret_cast for capabilities.
Definition capability.h:447
Cap< T > cap_dynamic_cast(Cap< F > const &c) noexcept
dynamic_cast for capabilities.
Definition capability:116
Dynamic Type Information for L4Re Interfaces.
Definition __typeinfo.h:500
Message tag data structure.
Definition types.h:154
Meta interface for getting dynamic type information about objects behind capabilities.