// vi:ft=cpp: /** * \file */ /* * (c) 2008-2009 Adam Lackorzynski , * Alexander Warg * economic rights: Technische Universität Dresden (Germany) * * This file is part of TUD:OS and distributed under the terms of the * GNU General Public License 2. * Please see the COPYING-GPL-2 file for details. * * As a special exception, you may use this file as part of a free software * library without restriction. Specifically, if other files instantiate * templates or use macros or inline functions from this file, or you compile * this file and link it with other files to produce an executable, this * file does not by itself cause the resulting executable to be covered by * the GNU General Public License. This exception does not however * invalidate any other reasons why the executable file might be covered by * the GNU General Public License. */ #pragma once #include #include #include #include #include namespace L4Re { namespace Util { /** * \brief Convenience wrapper for getting access to an event object. * * After calling init() the class supplies the event-buffer and the * associated IRQ object. */ class Event { public: /** * \brief Modes of operation. */ enum Mode { Mode_irq, ///< Create an IRQ and attach, to get notifications. Mode_polling, ///< Do not use an IRQ. }; /** * \brief Initialise an event object. * * \param event Capability to event. * \param env Optional: Pointer to L4Re-Environment * \param ca Optional: Pointer to capability allocator. * \return 0 on success, error code on error */ int init(L4::Cap event, Mode mode = Mode_irq, L4Re::Env const *env = L4Re::Env::env(), L4Re::Cap_alloc *ca = L4Re::Cap_alloc::get_cap_alloc(L4Re::Util::cap_alloc)); /** * \brief Get event buffer. * \return Event buffer object. */ L4Re::Event_buffer &buffer() { return _ev_buffer; } /** * \brief Get event IRQ. * \return Event IRQ. */ L4::Cap irq() const { return _ev_irq.get(); } private: Auto_cap::Cap _ev_ds; Auto_del_cap::Cap _ev_irq; L4Re::Event_buffer _ev_buffer; Rm::Auto_region _buf; }; }}