Landfall

Annotated pkg/devices/input/include/input-event-loop.h

153:929b5f0a63e4
16 months ago Paul Boddie Converted the remaining code to use libipc and generated IPC components. idl4re-libipc-libsystypes
paul@3 1
/*
paul@3 2
 * Input event loop functionality.
paul@3 3
 *
paul@31 4
 * Copyright (C) 2018 Paul Boddie <paul@boddie.org.uk>
paul@3 5
 *
paul@3 6
 * This program is free software; you can redistribute it and/or
paul@3 7
 * modify it under the terms of the GNU General Public License as
paul@3 8
 * published by the Free Software Foundation; either version 2 of
paul@3 9
 * the License, or (at your option) any later version.
paul@3 10
 *
paul@3 11
 * This program is distributed in the hope that it will be useful,
paul@3 12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
paul@3 13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
paul@3 14
 * GNU General Public License for more details.
paul@3 15
 *
paul@3 16
 * You should have received a copy of the GNU General Public License
paul@3 17
 * along with this program; if not, write to the Free Software
paul@3 18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor,
paul@3 19
 * Boston, MA  02110-1301, USA
paul@3 20
 */
paul@3 21
paul@3 22
#pragma once
paul@3 23
paul@3 24
#ifdef __cplusplus
paul@3 25
paul@9 26
#include <l4/devices/event-loop.h>
paul@9 27
paul@3 28
#include <l4/re/event>
paul@3 29
#include <l4/sys/capability>
paul@3 30
#include <l4/sys/icu>
paul@3 31
paul@3 32
/* Input event loop abstraction. */
paul@3 33
paul@10 34
class Input_event_loop : public Event_handler_loop<L4Re::Event_buffer::Event>
paul@3 35
{
paul@3 36
  /* Event buffer and notification interrupt capability. */
paul@3 37
paul@3 38
  L4Re::Event_buffer _event_buffer;
paul@3 39
paul@9 40
  /* Notification interrupt capability. */
paul@3 41
paul@9 42
  L4::Cap<L4::Irq> _irq;
paul@3 43
paul@3 44
public:
paul@10 45
  /* Initialise the event loop with an event buffer, a notification interrupt,
paul@10 46
     and a thread priority. */
paul@3 47
paul@10 48
  explicit Input_event_loop(L4Re::Event_buffer event_buffer,
paul@9 49
                            L4::Cap<L4::Irq> irq,
paul@3 50
                            int priority=0x20)
paul@10 51
  : Event_handler_loop(priority), _event_buffer(event_buffer), _irq(irq)
paul@3 52
  {
paul@3 53
  }
paul@3 54
paul@153 55
  explicit Input_event_loop(L4Re::Event_buffer event_buffer,
paul@153 56
                            l4_cap_idx_t irq,
paul@153 57
                            int priority=0x20)
paul@153 58
  : Event_handler_loop(priority), _event_buffer(event_buffer), _irq(L4::Cap<L4::Irq>(irq))
paul@153 59
  {
paul@153 60
  }
paul@153 61
paul@10 62
  /* Event handler method, dispatching to the provided handler. */
paul@3 63
paul@9 64
  virtual void handle();
paul@3 65
paul@10 66
  /* Start the loop, dispatching to the handle method. */
paul@3 67
paul@9 68
  virtual void start(l4_umword_t label=0xDF00);
paul@3 69
};
paul@3 70
paul@3 71
#endif