Landfall

Annotated pkg/devices/input/src/event_loop/input-event-loop.cc

153:929b5f0a63e4
16 months ago Paul Boddie Converted the remaining code to use libipc and generated IPC components. idl4re-libipc-libsystypes
paul@153 1
/*
paul@153 2
 * Input event loop functionality.
paul@153 3
 *
paul@153 4
 * Copyright (C) 2018 Paul Boddie <paul@boddie.org.uk>
paul@153 5
 *
paul@153 6
 * This program is free software; you can redistribute it and/or
paul@153 7
 * modify it under the terms of the GNU General Public License as
paul@153 8
 * published by the Free Software Foundation; either version 2 of
paul@153 9
 * the License, or (at your option) any later version.
paul@153 10
 *
paul@153 11
 * This program is distributed in the hope that it will be useful,
paul@153 12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
paul@153 13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
paul@153 14
 * GNU General Public License for more details.
paul@153 15
 *
paul@153 16
 * You should have received a copy of the GNU General Public License
paul@153 17
 * along with this program; if not, write to the Free Software
paul@153 18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor,
paul@153 19
 * Boston, MA  02110-1301, USA
paul@153 20
 */
paul@153 21
paul@153 22
#include "input-event-loop.h"
paul@153 23
paul@153 24
#include <l4/re/event>
paul@153 25
paul@153 26
/* Handler for incoming interrupts signalling the presence of events. */
paul@153 27
paul@153 28
void
paul@153 29
Input_event_loop::handle()
paul@153 30
{
paul@153 31
  Event_type *event;
paul@153 32
paul@153 33
  if (!l4_error(_irq->receive()))
paul@153 34
  {
paul@153 35
    while ((event = _event_buffer.next()))
paul@153 36
    {
paul@153 37
      _handler(*event);
paul@153 38
      event->free();
paul@153 39
    }
paul@153 40
  }
paul@153 41
}
paul@153 42
paul@153 43
/* Event loop initiation. */
paul@153 44
paul@153 45
void
paul@153 46
Input_event_loop::start(l4_umword_t label)
paul@153 47
{
paul@153 48
  Event_loop::start();
paul@153 49
paul@153 50
  _irq->bind_thread(Pthread::L4::cap(_pthread), label);
paul@153 51
}