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)
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.
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.
25 #include <l4/re/cap_alloc>
26 #include <l4/re/util/cap_alloc>
29 #include <l4/re/util/event_buffer>
31 namespace L4Re { namespace Util {
34 * \brief Convenience wrapper for getting access to an event object.
36 * After calling init() the class supplies the event-buffer and the
37 * associated IRQ object.
43 * \brief Modes of operation.
47 Mode_irq, ///< Create an IRQ and attach, to get notifications.
48 Mode_polling, ///< Do not use an IRQ.
52 * \brief Initialise an event object.
54 * \param event Capability to event.
55 * \param env Optional: Pointer to L4Re-Environment
56 * \param ca Optional: Pointer to capability allocator.
57 * \return 0 on success, error code on error
59 int init(L4::Cap<L4Re::Event> event, Mode mode = Mode_irq,
60 L4Re::Env const *env = L4Re::Env::env(),
61 L4Re::Cap_alloc *ca = L4Re::Cap_alloc::get_cap_alloc(L4Re::Util::cap_alloc));
64 * \brief Get event buffer.
65 * \return Event buffer object.
67 L4Re::Event_buffer &buffer() { return _ev_buffer; }
70 * \brief Get event IRQ.
73 L4::Cap<L4::Irq> irq() const { return _ev_irq.get(); }
76 Auto_cap<L4Re::Dataspace>::Cap _ev_ds;
77 Auto_del_cap<L4::Irq>::Cap _ev_irq;
78 L4Re::Event_buffer _ev_buffer;
79 Rm::Auto_region<void*> _buf;