L4Re Operating System Framework – Interface and Usage Documentation
Loading...
Searching...
No Matches
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 * This file is part of TUD:OS and distributed under the terms of the
11 * GNU General Public License 2.
12 * Please see the COPYING-GPL-2 file for details.
13 *
14 * As a special exception, you may use this file as part of a free software
15 * library without restriction. Specifically, if other files instantiate
16 * templates or use macros or inline functions from this file, or you compile
17 * this file and link it with other files to produce an executable, this
18 * file does not by itself cause the resulting executable to be covered by
19 * the GNU General Public License. This exception does not however
20 * invalidate any other reasons why the executable file might be covered by
21 * the GNU General Public License.
22 */
23#pragma once
24
25#include <l4/re/cap_alloc>
26#include <l4/re/util/cap_alloc>
27#include <l4/re/util/unique_cap>
28#include <l4/re/env>
29#include <l4/re/rm>
30#include <l4/re/util/event_buffer>
31#include <l4/sys/factory>
32#include <l4/cxx/type_traits>
33
34namespace L4Re { namespace Util {
35
42template< typename PAYLOAD >
44{
45public:
49 enum Mode
50 {
53 };
54
69 template<typename IRQ_TYPE>
71 L4Re::Env const *env = L4Re::Env::env(),
73 {
75 if (!ev_ds.is_valid())
76 return -L4_ENOMEM;
77
78 int r;
79
80 Unique_del_cap<IRQ_TYPE> ev_irq(ca->alloc<IRQ_TYPE>());
81 if (!ev_irq.is_valid())
82 return -L4_ENOMEM;
83
84 if ((r = l4_error(env->factory()->create(ev_irq.get()))))
85 return r;
86
87 if ((r = l4_error(event->bind(0, ev_irq.get()))))
88 return r;
89
90 if ((r = event->get_buffer(ev_ds.get())))
91 return r;
92
93 long sz = ev_ds->size();
94 if (sz < 0)
95 return sz;
96
98
99 if ((r = env->rm()->attach(&buf, sz,
101 L4::Ipc::make_cap_rw(ev_ds.get()))))
102 return r;
103
104 _ev_buffer = L4Re::Event_buffer_t<PAYLOAD>(buf.get(), sz);
105 _ev_ds = cxx::move(ev_ds);
106 _ev_irq = cxx::move(ev_irq);
107 _buf = cxx::move(buf);
108
109 return 0;
110 }
111
124 L4Re::Env const *env = L4Re::Env::env(),
126 {
128 if (!ev_ds.is_valid())
129 return -L4_ENOMEM;
130
131 int r;
132
133 if ((r = event->get_buffer(ev_ds.get())))
134 return r;
135
136 long sz = ev_ds->size();
137 if (sz < 0)
138 return sz;
139
141
142 if ((r = env->rm()->attach(&buf, sz,
144 L4::Ipc::make_cap_rw(ev_ds.get()))))
145 return r;
146
147 _ev_buffer = L4Re::Event_buffer_t<PAYLOAD>(buf.get(), sz);
148 _ev_ds = cxx::move(ev_ds);
149 _buf = cxx::move(buf);
150
151 return 0;
152 }
153
159 L4Re::Event_buffer_t<PAYLOAD> &buffer() { return _ev_buffer; }
160
166 L4::Cap<L4::Triggerable> irq() const { return _ev_irq.get(); }
167
168private:
173};
174
175typedef Event_t<Default_event_payload> Event;
176
177}}
Abstract capability-allocator interface.
Capability allocator interface.
Definition cap_alloc:42
static L4Re::Cap_alloc * get_cap_alloc(CAP_ALLOC &ca)
Construct an instance of a capability allocator.
Definition cap_alloc:90
Interface for memory-like objects.
Definition dataspace:63
C++ interface of the initial environment that is provided to an L4 task.
Definition env:86
static Env const * env() noexcept
Returns the initial environment for the current task.
Definition env:103
Event buffer class.
Definition event:257
Event class.
Definition event:150
Unique region.
Definition rm:413
T get() const noexcept
Return the address.
Definition rm:486
Convenience wrapper for getting access to an event object.
Definition event:44
int init_poll(L4::Cap< L4Re::Event > event, L4Re::Env const *env=L4Re::Env::env(), L4Re::Cap_alloc *ca=L4Re::Cap_alloc::get_cap_alloc(L4Re::Util::cap_alloc))
Initialise an event object in polling mode.
Definition event:123
L4::Cap< L4::Triggerable > irq() const
Get event IRQ.
Definition event:166
int init(L4::Cap< L4Re::Event > event, L4Re::Env const *env=L4Re::Env::env(), L4Re::Cap_alloc *ca=L4Re::Cap_alloc::get_cap_alloc(L4Re::Util::cap_alloc))
Initialise an event object.
Definition event:70
Mode
Modes of operation.
Definition event:50
@ Mode_irq
Create an IRQ and attach, to get notifications.
Definition event:51
@ Mode_polling
Do not use an IRQ.
Definition event:52
L4Re::Event_buffer_t< PAYLOAD > & buffer()
Get event buffer.
Definition event:159
C++ interface for capabilities.
Definition capability.h:222
Environment interface.
Common factory related definitions.
@ L4_ENOMEM
No memory.
Definition err.h:50
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
_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:54
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:97
L4Re C++ Interfaces.
Definition cmd_control:15
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:638
Region mapper interface.
@ RW
Readable and writable region.
Definition rm:140
@ Search_addr
Search for a suitable address range.
Definition rm:118
Capability allocator.
Unique_cap / Unique_del_cap.