L4Re Operating System Framework
Interface and Usage Documentation
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
event
Go to the documentation of this file.
1// vi:set ft=cpp: -*- Mode: C++ -*-
5/*
6 * (c) 2008-2009 Adam Lackorzynski <adam@os.inf.tu-dresden.de>,
7 * Alexander Warg <warg@os.inf.tu-dresden.de>
8 * economic rights: Technische Universität Dresden (Germany)
9 *
10 * License: see LICENSE.spdx (in this directory or the directories above)
11 */
12#pragma once
13
14#include <l4/re/cap_alloc>
15#include <l4/re/util/cap_alloc>
16#include <l4/re/util/unique_cap>
17#include <l4/re/env>
18#include <l4/re/rm>
19#include <l4/re/util/event_buffer>
20#include <l4/sys/factory>
21#include <l4/cxx/type_traits>
22
23namespace L4Re { namespace Util {
24
31template< typename PAYLOAD >
33{
34public:
38 enum Mode
39 {
42 };
43
58 template<typename IRQ_TYPE>
60 L4Re::Env const *env = L4Re::Env::env(),
62 {
64 if (!ev_ds.is_valid())
65 return -L4_ENOMEM;
66
67 int r;
68
69 Unique_del_cap<IRQ_TYPE> ev_irq(ca->alloc<IRQ_TYPE>());
70 if (!ev_irq.is_valid())
71 return -L4_ENOMEM;
72
73 if ((r = l4_error(env->factory()->create(ev_irq.get()))))
74 return r;
75
76 if ((r = l4_error(event->bind(0, ev_irq.get()))))
77 return r;
78
79 if ((r = event->get_buffer(ev_ds.get())))
80 return r;
81
82 long sz = ev_ds->size();
83 if (sz < 0)
84 return sz;
85
87
88 if ((r = env->rm()->attach(&buf, sz,
90 L4::Ipc::make_cap_rw(ev_ds.get()))))
91 return r;
92
93 _ev_buffer = L4Re::Event_buffer_t<PAYLOAD>(buf.get(), sz);
94 _ev_ds = cxx::move(ev_ds);
95 _ev_irq = cxx::move(ev_irq);
96 _buf = cxx::move(buf);
97
98 return 0;
99 }
100
113 L4Re::Env const *env = L4Re::Env::env(),
115 {
117 if (!ev_ds.is_valid())
118 return -L4_ENOMEM;
119
120 int r;
121
122 if ((r = event->get_buffer(ev_ds.get())))
123 return r;
124
125 long sz = ev_ds->size();
126 if (sz < 0)
127 return sz;
128
130
131 if ((r = env->rm()->attach(&buf, sz,
133 L4::Ipc::make_cap_rw(ev_ds.get()))))
134 return r;
135
136 _ev_buffer = L4Re::Event_buffer_t<PAYLOAD>(buf.get(), sz);
137 _ev_ds = cxx::move(ev_ds);
138 _buf = cxx::move(buf);
139
140 return 0;
141 }
142
148 L4Re::Event_buffer_t<PAYLOAD> &buffer() { return _ev_buffer; }
149
155 L4::Cap<L4::Triggerable> irq() const { return _ev_irq.get(); }
156
157private:
162};
163
164typedef Event_t<Default_event_payload> Event;
165
166}}
Abstract capability-allocator interface.
Capability allocator interface.
Definition cap_alloc:31
Interface for memory-like objects.
Definition dataspace:53
C++ interface of the initial environment that is provided to an L4 task.
Definition env:78
static Env const * env() noexcept
Returns the initial environment for the current task.
Definition env:95
Event buffer class.
Definition event:247
Event class.
Definition event:139
Unique region.
Definition rm:424
T get() const noexcept
Return the address.
Definition rm:497
Convenience wrapper for getting access to an event object.
Definition event:33
int init_poll(L4::Cap< L4Re::Event > event, L4Re::Env const *env=L4Re::Env::env(), L4Re::Cap_alloc *ca=&L4Re::Util::cap_alloc)
Initialise an event object in polling mode.
Definition event:112
L4::Cap< L4::Triggerable > irq() const
Get event IRQ.
Definition event:155
int init(L4::Cap< L4Re::Event > event, L4Re::Env const *env=L4Re::Env::env(), L4Re::Cap_alloc *ca=&L4Re::Util::cap_alloc)
Initialise an event object.
Definition event:59
Mode
Modes of operation.
Definition event:39
@ Mode_irq
Create an IRQ and attach, to get notifications.
Definition event:40
@ Mode_polling
Do not use an IRQ.
Definition event:41
L4Re::Event_buffer_t< PAYLOAD > & buffer()
Get event buffer.
Definition event:148
C++ interface for capabilities.
Definition capability.h:219
Environment interface.
Common factory related definitions.
@ L4_ENOMEM
No memory.
Definition err.h:39
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
_Cap_alloc & cap_alloc
Capability allocator.
L4::Detail::Unique_cap_impl< T, Smart_cap_auto< L4_FP_ALL_SPACES > > Unique_cap
Unique capability that implements automatic free and unmap of the capability selector.
Definition unique_cap:43
L4::Detail::Unique_cap_impl< T, Smart_cap_auto< L4_FP_DELETE_OBJ > > Unique_del_cap
Unique capability that implements automatic free and unmap+delete of the capability selector.
Definition unique_cap:86
L4Re C++ Interfaces.
Definition cmd_control:14
Cap< T > make_cap_rw(L4::Cap< T > cap) noexcept
Make an L4::Ipc::Cap<T> for the given capability with L4_CAP_FPAGE_RW rights.
Definition ipc_types:795
Region mapper interface.
@ RW
Readable and writable region.
Definition rm:139
@ Search_addr
Search for a suitable address range.
Definition rm:114
Capability allocator.
Unique_cap / Unique_del_cap.