1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/conf/landfall-examples/mips-qi_lb60-input-event-client.cfg Thu May 17 22:49:35 2018 +0200 1.3 @@ -0,0 +1,155 @@ 1.4 +-- vim: ft=lua ts=2 et sw=2 1.5 + 1.6 +-- Start Mag to multiplex the framebuffer showing only a single program. 1.7 +-- This example shows the key values produced by the input event driver. 1.8 +-- The target platform is the Ben NanoNote. 1.9 + 1.10 +local L4 = require("L4"); 1.11 + 1.12 +local l = L4.default_loader; 1.13 + 1.14 +-- Define general access to peripherals. 1.15 + 1.16 +local io_buses = { 1.17 + cpm = l:new_channel(); 1.18 + gpio = l:new_channel(); 1.19 + lcd = l:new_channel(); 1.20 + }; 1.21 + 1.22 +l:start({ 1.23 + caps = { 1.24 + cpm = io_buses.cpm:svr(), 1.25 + gpio = io_buses.gpio:svr(), 1.26 + lcd = io_buses.lcd:svr(), 1.27 + 1.28 + icu = L4.Env.icu, 1.29 + sigma0 = L4.cast(L4.Proto.Factory, L4.Env.sigma0):create(L4.Proto.Sigma0), 1.30 + }, 1.31 + }, 1.32 + "rom/io rom/hw_devices.io rom/mips-qi_lb60-input-event-client.io"); 1.33 + 1.34 +-- Expose a SPI peripheral as a device. 1.35 + 1.36 +local spi = l:new_channel(); 1.37 + 1.38 +l:startv({ 1.39 + caps = { 1.40 + vbus = io_buses.gpio, 1.41 + spi = spi:svr(), 1.42 + }, 1.43 + }, 1.44 + "rom/dev_spi_jz4740", "C23", "C22", "C21"); -- specifying clock, data, enable pin details 1.45 + 1.46 +-- Expose a SPI backlight device for the Ben. 1.47 + 1.48 +local backlight = l:new_channel(); -- exposes backlight device 1.49 + 1.50 +l:start({ 1.51 + caps = { 1.52 + spi = spi, 1.53 + backlight = backlight:svr(), 1.54 + }, 1.55 + }, 1.56 + "rom/dev_backlight_spi_qi_lb60"); 1.57 + 1.58 +-- Expose a display device for the Ben. 1.59 + 1.60 +local display = l:new_channel(); -- exposes display device 1.61 + 1.62 +l:start({ 1.63 + caps = { 1.64 + backlight = backlight, 1.65 + display = display:svr(), 1.66 + vbus = io_buses.gpio, 1.67 + }, 1.68 + }, 1.69 + "rom/dev_display_qi_lb60"); 1.70 + 1.71 +-- Expose a panel definition for the Ben. 1.72 + 1.73 +local panel = l:new_channel(); -- exposes panel 1.74 + 1.75 +l:start({ 1.76 + caps = { 1.77 + panel = panel:svr(), 1.78 + }, 1.79 + }, 1.80 + "rom/dev_panel_qi_lb60"); 1.81 + 1.82 +-- Expose the CPM peripheral. 1.83 + 1.84 +local cpm = l:new_channel(); 1.85 + 1.86 +l:start({ 1.87 + caps = { 1.88 + vbus = io_buses.cpm, 1.89 + cpm = cpm:svr(), 1.90 + }, 1.91 + }, 1.92 + "rom/dev_cpm_jz4740"); 1.93 + 1.94 +-- Expose a framebuffer device. 1.95 + 1.96 +local fbdrv_fb = l:new_channel(); 1.97 + 1.98 +l:start({ 1.99 + caps = { 1.100 + vbus = io_buses.lcd, 1.101 + fb = fbdrv_fb:svr(), 1.102 + cpm = cpm, 1.103 + display = display, -- needed by LCD driver 1.104 + panel = panel, 1.105 + }, 1.106 + }, 1.107 + "rom/fb-drv"); 1.108 + 1.109 +-- Multiplex the framebuffer. 1.110 + 1.111 +local mag_caps = { 1.112 + mag = l:new_channel(), 1.113 + svc = l:new_channel(), 1.114 + }; 1.115 + 1.116 +l:start({ 1.117 + caps = { 1.118 + vbus = io_buses.gpio, -- needed by input driver 1.119 + fb = fbdrv_fb, 1.120 + mag = mag_caps.mag:svr(), 1.121 + svc = mag_caps.svc:svr(), 1.122 + }, 1.123 + }, 1.124 + "rom/mag"); 1.125 + 1.126 +-- Expose the keypad matrix. 1.127 + 1.128 +local keypad = l:new_channel(); 1.129 + 1.130 +l:start({ 1.131 + caps = { 1.132 + vbus = io_buses.gpio, 1.133 + keypad = keypad:svr(), 1.134 + }, 1.135 + }, 1.136 + "rom/dev_keypad_qi_lb60"); 1.137 + 1.138 +-- Expose the keypad events. 1.139 + 1.140 +local ev = l:new_channel(); 1.141 + 1.142 +l:start({ 1.143 + caps = { 1.144 + keypad = keypad, 1.145 + ev = ev:svr(), 1.146 + }, 1.147 + }, 1.148 + "rom/dev_input_keypad_qi_lb60"); 1.149 + 1.150 +-- Show key event values. 1.151 + 1.152 +l:startv({ 1.153 + caps = { 1.154 + fb = mag_caps.svc:create(L4.Proto.Goos, "g=320x230+0+0", "barheight=10"), 1.155 + ev = ev, 1.156 + }, 1.157 + }, 1.158 + "rom/ex_input_event_client", "chars");
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 2.2 +++ b/conf/landfall-examples/mips-qi_lb60-input-event-client.io Thu May 17 22:49:35 2018 +0200 2.3 @@ -0,0 +1,20 @@ 2.4 +-- vim: ft=lua ts=2 et sw=2 2.5 + 2.6 +-- Configuration file for Io. 2.7 + 2.8 +local hw = Io.system_bus() 2.9 + 2.10 +Io.add_vbus("cpm", Io.Vi.System_bus 2.11 +{ 2.12 + CPM = wrap(hw:match("jz4740-cpm")); 2.13 +}) 2.14 + 2.15 +Io.add_vbus("gpio", Io.Vi.System_bus 2.16 +{ 2.17 + GPIO = wrap(hw:match("jz4740-gpio")); 2.18 +}) 2.19 + 2.20 +Io.add_vbus("lcd", Io.Vi.System_bus 2.21 +{ 2.22 + LCD = wrap(hw:match("jz4740-lcd")); 2.23 +})
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 3.2 +++ b/conf/landfall-examples/mips-qi_lb60-input-event-client.list Thu May 17 22:49:35 2018 +0200 3.3 @@ -0,0 +1,23 @@ 3.4 + 3.5 +modaddr 0x1100000 3.6 + 3.7 +entry mips-qi_lb60-input-event-client-example 3.8 +bootstrap bootstrap -serial 3.9 +kernel fiasco -serial_esc 3.10 +roottask moe rom/mips-qi_lb60-input-event-client.cfg 3.11 +module mips-qi_lb60-input-event-client.cfg 3.12 +module mips-qi_lb60-input-event-client.io 3.13 +module plat-qi_lb60/hw_devices.io 3.14 +module l4re 3.15 +module io 3.16 +module ned 3.17 +module fb-drv 3.18 +module mag 3.19 +module dev_spi_jz4740 3.20 +module dev_backlight_spi_qi_lb60 3.21 +module dev_display_qi_lb60 3.22 +module dev_panel_qi_lb60 3.23 +module dev_cpm_jz4740 3.24 +module dev_keypad_qi_lb60 3.25 +module dev_input_keypad_qi_lb60 3.26 +module ex_input_event_client
4.1 --- a/pkg/devices/Control Mon May 14 19:16:59 2018 +0200 4.2 +++ b/pkg/devices/Control Thu May 17 22:49:35 2018 +0200 4.3 @@ -11,6 +11,7 @@ 4.4 provides: libdevice-fb-client libdevice-fb-ops 4.5 provides: libdevice-fb-lcd libdevice-fb-server 4.6 provides: libdevice-input-keypad 4.7 +provides: libdevice-input-event-client libdevice-input-event-ops 4.8 provides: devices-keypad-letux400 devices-keypad-qi_lb60 4.9 provides: libdevice-keypad-client libdevice-keypad-ops 4.10 provides: libdevice-keypad-server
5.1 --- a/pkg/devices/input/include/Makefile Mon May 14 19:16:59 2018 +0200 5.2 +++ b/pkg/devices/input/include/Makefile Thu May 17 22:49:35 2018 +0200 5.3 @@ -1,6 +1,6 @@ 5.4 PKGDIR = ../.. 5.5 L4DIR ?= $(PKGDIR)/../.. 5.6 5.7 -PC_FILENAME := libdevice-input-ops 5.8 +PC_FILENAME := libdevice-input-event-ops 5.9 5.10 include $(L4DIR)/mk/include.mk
6.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 6.2 +++ b/pkg/devices/input/include/input-event-client.h Thu May 17 22:49:35 2018 +0200 6.3 @@ -0,0 +1,39 @@ 6.4 +/* 6.5 + * Input event client to access input event servers. 6.6 + * 6.7 + * (c) 2018 Paul Boddie <paul@boddie.org.uk> 6.8 + * 6.9 + * This program is free software; you can redistribute it and/or 6.10 + * modify it under the terms of the GNU General Public License as 6.11 + * published by the Free Software Foundation; either version 2 of 6.12 + * the License, or (at your option) any later version. 6.13 + * 6.14 + * This program is distributed in the hope that it will be useful, 6.15 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 6.16 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 6.17 + * GNU General Public License for more details. 6.18 + * 6.19 + * You should have received a copy of the GNU General Public License 6.20 + * along with this program; if not, write to the Free Software 6.21 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, 6.22 + * Boston, MA 02110-1301, USA 6.23 + */ 6.24 + 6.25 +#pragma once 6.26 + 6.27 +#ifdef __cplusplus 6.28 + 6.29 +#include <l4/re/dataspace> 6.30 +#include <l4/re/env> 6.31 +#include <l4/sys/icu> 6.32 + 6.33 +class Input_event_interface : public L4::Kobject_t<Input_event_interface, L4::Kobject> 6.34 +{ 6.35 + L4_KOBJECT(Input_event_interface) 6.36 + 6.37 +public: 6.38 + int get_buffer(L4::Cap<L4Re::Dataspace> mem) throw(); 6.39 + int bind(unsigned irqnum, L4::Cap<L4::Irq> irq) throw(); 6.40 +}; 6.41 + 6.42 +#endif
7.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 7.2 +++ b/pkg/devices/input/include/input-event-loop.h Thu May 17 22:49:35 2018 +0200 7.3 @@ -0,0 +1,88 @@ 7.4 +/* 7.5 + * Input event loop functionality. 7.6 + * 7.7 + * (c) 2018 Paul Boddie <paul@boddie.org.uk> 7.8 + * 7.9 + * This program is free software; you can redistribute it and/or 7.10 + * modify it under the terms of the GNU General Public License as 7.11 + * published by the Free Software Foundation; either version 2 of 7.12 + * the License, or (at your option) any later version. 7.13 + * 7.14 + * This program is distributed in the hope that it will be useful, 7.15 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 7.16 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 7.17 + * GNU General Public License for more details. 7.18 + * 7.19 + * You should have received a copy of the GNU General Public License 7.20 + * along with this program; if not, write to the Free Software 7.21 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, 7.22 + * Boston, MA 02110-1301, USA 7.23 + */ 7.24 + 7.25 +#pragma once 7.26 + 7.27 +#ifdef __cplusplus 7.28 + 7.29 +#include <l4/re/event> 7.30 +#include <l4/sys/capability> 7.31 +#include <l4/sys/icu> 7.32 + 7.33 +#include <pthread.h> 7.34 +#include <pthread-l4.h> 7.35 + 7.36 +/* POSIX-thread-compatible handler function type. */ 7.37 + 7.38 +typedef void (*Event_handler)(L4Re::Event_buffer::Event &, void *); 7.39 + 7.40 +/* Input event loop abstraction. */ 7.41 + 7.42 +class Input_event_loop 7.43 +{ 7.44 + /* Notification interrupt capability. */ 7.45 + 7.46 + L4::Cap<L4::Irq> _irq; 7.47 + 7.48 + /* External handler function. */ 7.49 + 7.50 + Event_handler _handler; 7.51 + 7.52 + /* Private data for the handler. */ 7.53 + 7.54 + void *_priv; 7.55 + 7.56 + /* Event buffer and notification interrupt capability. */ 7.57 + 7.58 + L4Re::Event_buffer _event_buffer; 7.59 + 7.60 + /* Thread properties. */ 7.61 + 7.62 + int _priority; 7.63 + pthread_t _pthread; 7.64 + 7.65 +public: 7.66 + /* Initialise the event loop with a notification interrupt, thread priority, 7.67 + event handler function and private data, and an event buffer. */ 7.68 + 7.69 + explicit Input_event_loop(L4::Cap<L4::Irq> irq, 7.70 + Event_handler handler, void *priv, 7.71 + L4Re::Event_buffer event_buffer, 7.72 + int priority=0x20) 7.73 + : _irq(irq), _handler(handler), _priv(priv), _event_buffer(event_buffer), 7.74 + _priority(priority) 7.75 + { 7.76 + } 7.77 + 7.78 + /* Static main loop function for event-handling thread. */ 7.79 + 7.80 + static void *event_loop(void *data); 7.81 + 7.82 + /* Event handler method. */ 7.83 + 7.84 + void handle(); 7.85 + 7.86 + /* Initiation function. */ 7.87 + 7.88 + void start(); 7.89 +}; 7.90 + 7.91 +#endif
8.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 8.2 +++ b/pkg/devices/input/include/input-event-ops.h Thu May 17 22:49:35 2018 +0200 8.3 @@ -0,0 +1,24 @@ 8.4 +/* 8.5 + * Input event server operations. 8.6 + * 8.7 + * (c) 2018 Paul Boddie <paul@boddie.org.uk> 8.8 + * 8.9 + * This program is free software; you can redistribute it and/or 8.10 + * modify it under the terms of the GNU General Public License as 8.11 + * published by the Free Software Foundation; either version 2 of 8.12 + * the License, or (at your option) any later version. 8.13 + * 8.14 + * This program is distributed in the hope that it will be useful, 8.15 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 8.16 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 8.17 + * GNU General Public License for more details. 8.18 + * 8.19 + * You should have received a copy of the GNU General Public License 8.20 + * along with this program; if not, write to the Free Software 8.21 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, 8.22 + * Boston, MA 02110-1301, USA 8.23 + */ 8.24 + 8.25 +#pragma once 8.26 + 8.27 +enum { Input_event_op_get_buffer, Input_event_op_bind };
9.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 9.2 +++ b/pkg/devices/input/include/input-event-server.h Thu May 17 22:49:35 2018 +0200 9.3 @@ -0,0 +1,61 @@ 9.4 +/* 9.5 + * Common input event server functionality. 9.6 + * 9.7 + * (c) 2018 Paul Boddie <paul@boddie.org.uk> 9.8 + * 9.9 + * This program is free software; you can redistribute it and/or 9.10 + * modify it under the terms of the GNU General Public License as 9.11 + * published by the Free Software Foundation; either version 2 of 9.12 + * the License, or (at your option) any later version. 9.13 + * 9.14 + * This program is distributed in the hope that it will be useful, 9.15 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 9.16 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9.17 + * GNU General Public License for more details. 9.18 + * 9.19 + * You should have received a copy of the GNU General Public License 9.20 + * along with this program; if not, write to the Free Software 9.21 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, 9.22 + * Boston, MA 02110-1301, USA 9.23 + */ 9.24 + 9.25 +#pragma once 9.26 + 9.27 +#ifdef __cplusplus 9.28 + 9.29 +#include <l4/cxx/ipc_server> 9.30 +#include <l4/re/dataspace> 9.31 +#include <l4/re/env> 9.32 +#include <l4/re/event> 9.33 +#include <l4/sys/icu> 9.34 +#include <l4/sys/types.h> 9.35 + 9.36 +/* Server object to provide input event source access. */ 9.37 + 9.38 +class Input_event_server : public L4::Server_object_t<L4::Kobject> 9.39 +{ 9.40 +private: 9.41 + L4::Cap<L4Re::Dataspace> _mem; 9.42 + L4::Cap<L4::Irq> _irq; 9.43 + L4Re::Event_buffer _events; 9.44 + 9.45 +public: 9.46 + /* Initialise the server with a capability referencing the exported memory 9.47 + and an event buffer through which events will be communicated. */ 9.48 + 9.49 + explicit Input_event_server(L4::Cap<L4Re::Dataspace> mem, L4::Cap<L4::Irq> irq, 9.50 + L4Re::Event_buffer events) 9.51 + : _mem(mem), _irq(irq), _events(events) 9.52 + { 9.53 + } 9.54 + 9.55 + int dispatch(l4_umword_t obj, L4::Ipc::Iostream &ios); 9.56 + 9.57 + /* Event sending methods. */ 9.58 + 9.59 + void send_event(int type, int code, int value); 9.60 +}; 9.61 + 9.62 +#endif 9.63 + 9.64 +int run(void);
10.1 --- a/pkg/devices/input/src/Makefile Mon May 14 19:16:59 2018 +0200 10.2 +++ b/pkg/devices/input/src/Makefile Thu May 17 22:49:35 2018 +0200 10.3 @@ -1,6 +1,10 @@ 10.4 PKGDIR ?= ../.. 10.5 L4DIR ?= $(PKGDIR)/../.. 10.6 10.7 -TARGET := keypad 10.8 +TARGET := client keypad letux400 qi_lb60 server 10.9 10.10 include $(L4DIR)/mk/subdir.mk 10.11 + 10.12 +letux400: server 10.13 +qi_lb60: server 10.14 +server: keypad
11.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 11.2 +++ b/pkg/devices/input/src/client/Makefile Thu May 17 22:49:35 2018 +0200 11.3 @@ -0,0 +1,13 @@ 11.4 +PKGDIR ?= ../../.. 11.5 +L4DIR ?= $(PKGDIR)/../.. 11.6 + 11.7 +TARGET = libdevice_input_event_client.o.a 11.8 +PC_FILENAME := libdevice-input-event-client 11.9 + 11.10 +SRC_CC := input-event-client.cc input-event-loop.cc 11.11 + 11.12 +PRIVATE_INCDIR += $(PKGDIR)/input/include 11.13 + 11.14 +REQUIRES_LIBS := l4re_c l4re_c-util 11.15 + 11.16 +include $(L4DIR)/mk/lib.mk
12.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 12.2 +++ b/pkg/devices/input/src/client/input-event-client.cc Thu May 17 22:49:35 2018 +0200 12.3 @@ -0,0 +1,52 @@ 12.4 +/* 12.5 + * Input event client to access input event servers. 12.6 + * 12.7 + * (c) 2018 Paul Boddie <paul@boddie.org.uk> 12.8 + * 12.9 + * This program is free software; you can redistribute it and/or 12.10 + * modify it under the terms of the GNU General Public License as 12.11 + * published by the Free Software Foundation; either version 2 of 12.12 + * the License, or (at your option) any later version. 12.13 + * 12.14 + * This program is distributed in the hope that it will be useful, 12.15 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 12.16 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12.17 + * GNU General Public License for more details. 12.18 + * 12.19 + * You should have received a copy of the GNU General Public License 12.20 + * along with this program; if not, write to the Free Software 12.21 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, 12.22 + * Boston, MA 02110-1301, USA 12.23 + */ 12.24 + 12.25 +#include <l4/cxx/ipc_stream> 12.26 +#include <l4/re/env> 12.27 + 12.28 +#include "input-event-client.h" 12.29 +#include "input-event-ops.h" 12.30 + 12.31 +int 12.32 +Input_event_interface::get_buffer(L4::Cap<L4Re::Dataspace> mem) throw() 12.33 +{ 12.34 + L4::Ipc::Iostream s(l4_utcb()); 12.35 + 12.36 + /* Send a "receive item" for requesting a capability. */ 12.37 + 12.38 + s << L4::Ipc::Small_buf(mem); 12.39 + 12.40 + return l4_error(s.call(cap(), Input_event_op_get_buffer)); 12.41 +} 12.42 + 12.43 +int 12.44 +Input_event_interface::bind(unsigned irqnum, L4::Cap<L4::Irq> irq) throw() 12.45 +{ 12.46 + L4::Ipc::Iostream s(l4_utcb()); 12.47 + 12.48 + s << irqnum; 12.49 + 12.50 + /* Send a "receive item" for requesting a capability. */ 12.51 + 12.52 + s << L4::Ipc::Small_buf(irq); 12.53 + 12.54 + return l4_error(s.call(cap(), Input_event_op_bind)); 12.55 +}
13.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 13.2 +++ b/pkg/devices/input/src/client/input-event-loop.cc Thu May 17 22:49:35 2018 +0200 13.3 @@ -0,0 +1,81 @@ 13.4 +/* 13.5 + * Input event loop functionality. 13.6 + * 13.7 + * (c) 2018 Paul Boddie <paul@boddie.org.uk> 13.8 + * 13.9 + * This program is free software; you can redistribute it and/or 13.10 + * modify it under the terms of the GNU General Public License as 13.11 + * published by the Free Software Foundation; either version 2 of 13.12 + * the License, or (at your option) any later version. 13.13 + * 13.14 + * This program is distributed in the hope that it will be useful, 13.15 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 13.16 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13.17 + * GNU General Public License for more details. 13.18 + * 13.19 + * You should have received a copy of the GNU General Public License 13.20 + * along with this program; if not, write to the Free Software 13.21 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, 13.22 + * Boston, MA 02110-1301, USA 13.23 + */ 13.24 + 13.25 +#include <l4/devices/input-event-loop.h> 13.26 + 13.27 +#include <pthread.h> 13.28 +#include <pthread-l4.h> 13.29 + 13.30 +#include <l4/re/event> 13.31 + 13.32 +/* Main loop for event threads. */ 13.33 + 13.34 +void * 13.35 +Input_event_loop::event_loop(void *data) 13.36 +{ 13.37 + Input_event_loop *self = reinterpret_cast<Input_event_loop *>(data); 13.38 + 13.39 + while (1) self->handle(); 13.40 + 13.41 + return 0; 13.42 +} 13.43 + 13.44 +/* Handler for incoming interrupts signalling the presence of events. */ 13.45 + 13.46 +void 13.47 +Input_event_loop::handle() 13.48 +{ 13.49 + L4Re::Event_buffer::Event *event; 13.50 + 13.51 + if (!l4_error(_irq->receive())) 13.52 + { 13.53 + while ((event = _event_buffer.next())) 13.54 + { 13.55 + _handler(*event, _priv); 13.56 + event->free(); 13.57 + } 13.58 + } 13.59 +} 13.60 + 13.61 +/* Event loop initiation. */ 13.62 + 13.63 +void 13.64 +Input_event_loop::start() 13.65 +{ 13.66 + pthread_attr_t thread_attr; 13.67 + struct sched_param sp; 13.68 + 13.69 + /* Thread initialisation boilerplate. */ 13.70 + 13.71 + if (pthread_attr_init(&thread_attr)) 13.72 + return; 13.73 + 13.74 + sp.sched_priority = _priority; 13.75 + pthread_attr_setschedparam(&thread_attr, &sp); 13.76 + pthread_attr_setschedpolicy(&thread_attr, SCHED_L4); 13.77 + pthread_attr_setinheritsched(&thread_attr, PTHREAD_EXPLICIT_SCHED); 13.78 + 13.79 + /* Provide this instance as the private data. */ 13.80 + 13.81 + pthread_create(&_pthread, &thread_attr, event_loop, this); 13.82 + 13.83 + _irq->bind_thread(Pthread::L4::cap(_pthread), 0xDEAD); 13.84 +}
14.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 14.2 +++ b/pkg/devices/input/src/letux400/Makefile Thu May 17 22:49:35 2018 +0200 14.3 @@ -0,0 +1,13 @@ 14.4 +PKGDIR ?= ../../.. 14.5 +L4DIR ?= $(PKGDIR)/../.. 14.6 + 14.7 +TARGET = dev_input_keypad_letux400 14.8 +PC_FILENAME := devices-input-keypad-letux400 14.9 + 14.10 +SRC_CC := input-keypad-letux400.cc 14.11 + 14.12 +PRIVATE_INCDIR += $(PKGDIR)/input/include 14.13 + 14.14 +REQUIRES_LIBS := l4re_c l4re_c-util libdevice-input-keypad-server libdrivers-keypad-letux400 14.15 + 14.16 +include $(L4DIR)/mk/prog.mk
15.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 15.2 +++ b/pkg/devices/input/src/letux400/input-keypad-letux400.cc Thu May 17 22:49:35 2018 +0200 15.3 @@ -0,0 +1,29 @@ 15.4 +/* 15.5 + * Export the keypad for the Letux 400 via the "ev" capability. 15.6 + * 15.7 + * (c) 2018 Paul Boddie <paul@boddie.org.uk> 15.8 + * 15.9 + * This program is free software; you can redistribute it and/or 15.10 + * modify it under the terms of the GNU General Public License as 15.11 + * published by the Free Software Foundation; either version 2 of 15.12 + * the License, or (at your option) any later version. 15.13 + * 15.14 + * This program is distributed in the hope that it will be useful, 15.15 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 15.16 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15.17 + * GNU General Public License for more details. 15.18 + * 15.19 + * You should have received a copy of the GNU General Public License 15.20 + * along with this program; if not, write to the Free Software 15.21 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, 15.22 + * Boston, MA 02110-1301, USA 15.23 + */ 15.24 + 15.25 +#include "input-event-server.h" 15.26 + 15.27 +/* Main program. */ 15.28 + 15.29 +int main() 15.30 +{ 15.31 + return run(); 15.32 +}
16.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 16.2 +++ b/pkg/devices/input/src/qi_lb60/Makefile Thu May 17 22:49:35 2018 +0200 16.3 @@ -0,0 +1,13 @@ 16.4 +PKGDIR ?= ../../.. 16.5 +L4DIR ?= $(PKGDIR)/../.. 16.6 + 16.7 +TARGET = dev_input_keypad_qi_lb60 16.8 +PC_FILENAME := devices-input-keypad-qi_lb60 16.9 + 16.10 +SRC_CC := input-keypad-qi_lb60.cc 16.11 + 16.12 +PRIVATE_INCDIR += $(PKGDIR)/input/include 16.13 + 16.14 +REQUIRES_LIBS := l4re_c l4re_c-util libdevice-input-keypad-server libdrivers-keypad-qi_lb60 16.15 + 16.16 +include $(L4DIR)/mk/prog.mk
17.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 17.2 +++ b/pkg/devices/input/src/qi_lb60/input-keypad-qi_lb60.cc Thu May 17 22:49:35 2018 +0200 17.3 @@ -0,0 +1,29 @@ 17.4 +/* 17.5 + * Export the keypad for the Ben NanoNote via the "ev" capability. 17.6 + * 17.7 + * (c) 2018 Paul Boddie <paul@boddie.org.uk> 17.8 + * 17.9 + * This program is free software; you can redistribute it and/or 17.10 + * modify it under the terms of the GNU General Public License as 17.11 + * published by the Free Software Foundation; either version 2 of 17.12 + * the License, or (at your option) any later version. 17.13 + * 17.14 + * This program is distributed in the hope that it will be useful, 17.15 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 17.16 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17.17 + * GNU General Public License for more details. 17.18 + * 17.19 + * You should have received a copy of the GNU General Public License 17.20 + * along with this program; if not, write to the Free Software 17.21 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17.22 + * Boston, MA 02110-1301, USA 17.23 + */ 17.24 + 17.25 +#include "input-event-server.h" 17.26 + 17.27 +/* Main program. */ 17.28 + 17.29 +int main() 17.30 +{ 17.31 + return run(); 17.32 +}
18.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 18.2 +++ b/pkg/devices/input/src/server/Makefile Thu May 17 22:49:35 2018 +0200 18.3 @@ -0,0 +1,13 @@ 18.4 +PKGDIR ?= ../../.. 18.5 +L4DIR ?= $(PKGDIR)/../.. 18.6 + 18.7 +TARGET = libdevice_input_keypad_server.o.a 18.8 +PC_FILENAME := libdevice-input-keypad-server 18.9 + 18.10 +SRC_CC := input-keypad-server.cc 18.11 + 18.12 +PRIVATE_INCDIR += $(PKGDIR)/input/include 18.13 + 18.14 +REQUIRES_LIBS := l4re_c l4re_c-util libdevice-input-keypad libdevice-util 18.15 + 18.16 +include $(L4DIR)/mk/lib.mk
19.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 19.2 +++ b/pkg/devices/input/src/server/input-keypad-server.cc Thu May 17 22:49:35 2018 +0200 19.3 @@ -0,0 +1,146 @@ 19.4 +/* 19.5 + * Provide access to keypad events on the configured device. 19.6 + * 19.7 + * (c) 2018 Paul Boddie <paul@boddie.org.uk> 19.8 + * 19.9 + * This program is free software; you can redistribute it and/or 19.10 + * modify it under the terms of the GNU General Public License as 19.11 + * published by the Free Software Foundation; either version 2 of 19.12 + * the License, or (at your option) any later version. 19.13 + * 19.14 + * This program is distributed in the hope that it will be useful, 19.15 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 19.16 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19.17 + * GNU General Public License for more details. 19.18 + * 19.19 + * You should have received a copy of the GNU General Public License 19.20 + * along with this program; if not, write to the Free Software 19.21 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, 19.22 + * Boston, MA 02110-1301, USA 19.23 + */ 19.24 + 19.25 +#include <l4/devices/dataspace.h> 19.26 +#include "input-event-client.h" 19.27 +#include "input-event-server.h" 19.28 +#include "input-event-ops.h" 19.29 +#include "input-keypad-client.h" 19.30 + 19.31 +#include <l4/cxx/ipc_stream> 19.32 +#include <l4/re/dataspace> 19.33 +#include <l4/re/env> 19.34 +#include <l4/re/event> 19.35 +#include <l4/re/util/cap_alloc> 19.36 +#include <l4/re/util/object_registry> 19.37 +#include <l4/sys/capability> 19.38 +#include <l4/sys/icu> 19.39 +#include <l4/sys/kip.h> 19.40 +#include <l4/sys/types.h> 19.41 +#include <l4/util/util.h> 19.42 + 19.43 +/* Handle invocations. */ 19.44 + 19.45 +int 19.46 +Input_event_server::dispatch(l4_umword_t obj, L4::Ipc::Iostream &ios) 19.47 +{ 19.48 + l4_msgtag_t tag; 19.49 + 19.50 + (void) obj; 19.51 + ios >> tag; 19.52 + 19.53 + switch (tag.label()) 19.54 + { 19.55 + case L4::Meta::Protocol: 19.56 + return L4::Util::handle_meta_request<Input_event_interface>(ios); 19.57 + 19.58 + /* Reset the buffer state and return the buffer memory capability. */ 19.59 + 19.60 + case Input_event_op_get_buffer: 19.61 + _events.reset(); 19.62 + ios << _mem; 19.63 + return L4_EOK; 19.64 + 19.65 + /* Just return the interrupt capability. */ 19.66 + 19.67 + case Input_event_op_bind: 19.68 + ios << _irq; 19.69 + return L4_EOK; 19.70 + 19.71 + default: 19.72 + return -L4_EBADPROTO; 19.73 + } 19.74 +} 19.75 + 19.76 + 19.77 + 19.78 +/* Event sending methods. */ 19.79 + 19.80 +void 19.81 +Input_event_server::send_event(int type, int code, int value) 19.82 +{ 19.83 + L4Re::Event_buffer::Event event; 19.84 + 19.85 + event.time = l4_kip_clock(l4re_kip()); 19.86 + event.payload.stream_id = 0; 19.87 + event.payload.type = type; 19.88 + event.payload.code = code; 19.89 + event.payload.value = value; 19.90 + 19.91 + /* Queue the event and trigger the interrupt. */ 19.92 + 19.93 + _events.put(event); 19.94 + _irq->trigger(); 19.95 +} 19.96 + 19.97 + 19.98 + 19.99 +static void handler(Input_event event, void *priv) 19.100 +{ 19.101 + Input_event_server *server = (Input_event_server *) priv; 19.102 + 19.103 + server->send_event(event.type, event.code, event.value); 19.104 +} 19.105 + 19.106 + 19.107 + 19.108 +static L4Re::Util::Registry_server<> server; 19.109 + 19.110 + 19.111 + 19.112 +int run(void) 19.113 +{ 19.114 + Keypad *keypad = Keypad::get_keypad(); 19.115 + Input_keypad_client client(keypad); 19.116 + void *buffer; 19.117 + 19.118 + // Memory allocation capability for the event data. 19.119 + 19.120 + L4::Cap<L4Re::Dataspace> mem = allocate_data(L4_PAGESIZE, &buffer); 19.121 + if (!mem.is_valid()) return 1; 19.122 + 19.123 + /* Obtain a capability for the interrupt. */ 19.124 + 19.125 + L4::Cap<L4::Irq> irq = L4Re::Util::cap_alloc.alloc<L4::Irq>(); 19.126 + if (!irq.is_valid()) return 1; 19.127 + 19.128 + /* Create an interrupt object. */ 19.129 + 19.130 + if (l4_error(L4Re::Env::env()->factory()->create(irq))) return 1; 19.131 + 19.132 + // Event buffer for the data. 19.133 + 19.134 + L4Re::Event_buffer events(buffer, L4_PAGESIZE); 19.135 + 19.136 + // Initialise and register a server object. 19.137 + 19.138 + Input_event_server server_obj(mem, irq, events); 19.139 + server.registry()->register_obj(&server_obj, "ev"); 19.140 + 19.141 + // Attach the event handler and wait for events. 19.142 + 19.143 + client.attach(handler, (void *) &server_obj); 19.144 + 19.145 + // Enter the IPC server loop. 19.146 + 19.147 + server.loop(); 19.148 + return 0; 19.149 +}
20.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 20.2 +++ b/pkg/landfall-examples/input_event_client/Makefile Thu May 17 22:49:35 2018 +0200 20.3 @@ -0,0 +1,9 @@ 20.4 +PKGDIR ?= .. 20.5 +L4DIR ?= $(PKGDIR)/../.. 20.6 + 20.7 +TARGET = ex_input_event_client 20.8 +SRC_CC = input_event_client.cc 20.9 +SRC_DATA = unifont.tff 20.10 +REQUIRES_LIBS = libio l4re_c-util mag-gfx libevent libdevice-input-event-client 20.11 + 20.12 +include $(L4DIR)/mk/prog.mk
21.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 21.2 +++ b/pkg/landfall-examples/input_event_client/input_event_client.cc Thu May 17 22:49:35 2018 +0200 21.3 @@ -0,0 +1,303 @@ 21.4 +/* 21.5 + * Access an input device via a capability. 21.6 + * 21.7 + * (c) 2018 Paul Boddie <paul@boddie.org.uk> 21.8 + * 21.9 + * This program is free software; you can redistribute it and/or 21.10 + * modify it under the terms of the GNU General Public License as 21.11 + * published by the Free Software Foundation; either version 2 of 21.12 + * the License, or (at your option) any later version. 21.13 + * 21.14 + * This program is distributed in the hope that it will be useful, 21.15 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 21.16 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21.17 + * GNU General Public License for more details. 21.18 + * 21.19 + * You should have received a copy of the GNU General Public License 21.20 + * along with this program; if not, write to the Free Software 21.21 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, 21.22 + * Boston, MA 02110-1301, USA 21.23 + * 21.24 + * 21.25 + * Font definitions and licence (see unifont.tff for bitmap data derived from 21.26 + * GNU Unifont's unifont.hex file): 21.27 + * 21.28 + * Copyright (C) 1998-2003 Roman Czyborra (http://czyborra.com/) 21.29 + * 21.30 + * All glyphs are released under the GNU General Public License 21.31 + * (GPL) version 2 or (at your option) a later version, with the 21.32 + * GNU font embedding exception: 21.33 + * 21.34 + * ** GPL v2.0 license with font embedding exception: 21.35 + * 21.36 + * As a special exception, if you create a document which 21.37 + * uses this font, and embed this font or unaltered portions 21.38 + * of this font into the document, this font does not by 21.39 + * itself cause the resulting document to be covered by 21.40 + * the GNU General Public License. This exception does not 21.41 + * however invalidate any other reasons why the document 21.42 + * might be covered by the GNU General Public License. 21.43 + * If you modify this font, you may extend this exception 21.44 + * to your version of the font, but you are not obligated 21.45 + * to do so. If you do not wish to do so, delete this 21.46 + * exception statement from your version. 21.47 + */ 21.48 + 21.49 +#include <l4/devices/input-event-client.h> 21.50 +#include <l4/devices/input-event-loop.h> 21.51 + 21.52 +#include <pthread.h> 21.53 +#include <pthread-l4.h> 21.54 + 21.55 +#include <l4/re/c/util/video/goos_fb.h> 21.56 +#include <l4/re/c/video/view.h> 21.57 +#include <l4/re/env> 21.58 +#include <l4/re/event> 21.59 +#include <l4/re/event_enums.h> 21.60 +#include <l4/re/util/cap_alloc> 21.61 +#include <l4/util/util.h> 21.62 + 21.63 +#include <l4/mag-gfx/canvas> 21.64 +#include <l4/mag-gfx/font> 21.65 +#include <l4/mag-gfx/geometry> 21.66 +#include <l4/mag-gfx/gfx_colors> 21.67 +#include <l4/mag-gfx/mem_factory> 21.68 + 21.69 +#include <stdint.h> 21.70 +#include <string.h> 21.71 + 21.72 +/* Video abstractions. */ 21.73 + 21.74 +static l4re_util_video_goos_fb_t gfb; 21.75 +static l4re_video_view_info_t view_info; 21.76 +static void *fb = 0; 21.77 + 21.78 +/* Bundled font data. */ 21.79 + 21.80 +extern char const _binary_unifont_tff_start[]; 21.81 + 21.82 +/* Screen abstractions. */ 21.83 + 21.84 +using namespace Mag_gfx; 21.85 + 21.86 +static Font *_font = 0; 21.87 +static Canvas *_screen = 0; 21.88 + 21.89 + 21.90 + 21.91 +/* Factories for certain pixel formats. */ 21.92 + 21.93 +static Mem::Factory<Rgb16> _rgb16; 21.94 +static Mem::Factory<Rgb32> _rgb32; 21.95 + 21.96 + 21.97 + 21.98 +/* Key to character conversion function. */ 21.99 + 21.100 +static const char *keys_to_strings[] = { 21.101 + 21.102 + 0, "Escape", "1", "2", "3", "4", "5", "6", "7", "8", 21.103 + 21.104 + "9", "0", "-", "=", "Backspace", "Tab", "Q", "W", "E", "R", 21.105 + 21.106 + "T", "Y", "U", "I", "O", "P", "[", "]", "Enter", "Left Ctrl", 21.107 + 21.108 + "A", "S", "D", "F", "G", "H", "J", "K", "L", ";", 21.109 + 21.110 + "'", "`", "Left Shift", "\\", "Z", "X", "C", "V", "B", "N", 21.111 + 21.112 + "M", ",", ".", "/", "Right Shift", "Keypad *", "Left Alt", "Space", 21.113 + "Caps Lock", "F1", 21.114 + 21.115 + "F2", "F3", "F4", "F5", "F6", "F7", "F8", "F9", "F10", "Num Lock", 21.116 + 21.117 + "Scroll Lock", "Keypad 7", "Keypad 8", "Keypad 9", "Keypad -", "Keypad 4", 21.118 + "Keypad 5", "Keypad 6", "Keypad +", "Keypad 1", 21.119 + 21.120 + "Keypad 2", "Keypad 3", "Keypad 0", "Keypad .", 0, 0, "#102", "F11", "F12", 0, 21.121 + 21.122 + 0, 0, 0, 0, 0, 0, "Keypad Enter", "Right Ctrl", "Keypad /", "SysRq", 21.123 + 21.124 + "Right Alt", "Line Feed", "Home", "Up", "Page Up", "Left", "Right", "End", 21.125 + "Down", "Page Down", 21.126 + 21.127 + "Insert", "Delete", "Macro", "Mute", "Volume Down", "Volume Up", "Power", 21.128 + "Keypad =", "Keypad +-", "Pause", 21.129 +}; 21.130 + 21.131 +static const char null_string[] = "Unknown"; 21.132 + 21.133 +const int keys_to_strings_length = 120; 21.134 + 21.135 +static const char *key_to_string(int key) 21.136 +{ 21.137 + return key < keys_to_strings_length ? keys_to_strings[key] : 0; 21.138 +} 21.139 + 21.140 + 21.141 + 21.142 +/* Show the keypad event status on the display. */ 21.143 + 21.144 +static uint8_t row = 0; 21.145 +static uint32_t text_x = 0, text_y = 0, next_y = 0; 21.146 + 21.147 +static void handler(L4Re::Event_buffer::Event &event, void *priv) 21.148 +{ 21.149 + uint32_t colsize = view_info.width / 10, 21.150 + rowsize = view_info.height / 20; 21.151 + uint8_t column; 21.152 + uint16_t mask; 21.153 + 21.154 + /* Convert the key code into a bit pattern. */ 21.155 + 21.156 + if (!priv) 21.157 + { 21.158 + for (column = 0, mask = (1 << 9); column < 10; column++, mask >>= 1) 21.159 + _screen->draw_box(Rect(Point(column * colsize, row * rowsize), Area(colsize, rowsize)), 21.160 + event.payload.code & mask ? event.payload.value ? Rgb32::Color(0, 255, 0) : Rgb32::Color(255, 0, 0) 21.161 + : Rgb32::Color(0, 0, 0)); 21.162 + 21.163 + /* Advance to the next row, wrapping around. */ 21.164 + 21.165 + row = (row + 1) % 20; 21.166 + } 21.167 + 21.168 + /* Or produce a string. */ 21.169 + 21.170 + else if (event.payload.value) 21.171 + { 21.172 + const char *s = ((const char *(*)(int)) priv)(event.payload.code); 21.173 + Rgba32::Color col; 21.174 + 21.175 + if (!s) 21.176 + { 21.177 + s = null_string; 21.178 + col = Rgba32::Color(255, 0, 0, Rgba32::Color::Amax); 21.179 + } 21.180 + else 21.181 + col = Rgba32::Color(255, 255, 255, Rgba32::Color::Amax); 21.182 + 21.183 + Area box = _font->str_sz(s, strlen(s)); 21.184 + 21.185 + /* Test for enough space horizontally. */ 21.186 + 21.187 + if (text_x + box.w() > view_info.width) 21.188 + { 21.189 + text_x = 0; 21.190 + text_y = next_y; 21.191 + next_y = text_y + box.h(); 21.192 + } 21.193 + 21.194 + /* Expand the line height, if appropriate. */ 21.195 + 21.196 + else if (text_y + box.h() > next_y) 21.197 + next_y += box.h(); 21.198 + 21.199 + /* Test for enough space vertically. */ 21.200 + 21.201 + if (next_y > view_info.height) 21.202 + { 21.203 + text_x = 0; 21.204 + text_y = 0; 21.205 + next_y = box.h(); 21.206 + } 21.207 + 21.208 + Point p(text_x, text_y); 21.209 + 21.210 + _screen->draw_box(Rect(p, box), Rgb32::Color(0, 0, 0)); 21.211 + _screen->draw_string(p, _font, col, s, strlen(s)); 21.212 + 21.213 + /* Move to the next position. */ 21.214 + 21.215 + text_x += box.w(); 21.216 + } 21.217 + 21.218 + /* Refresh the display. */ 21.219 + 21.220 + l4re_util_video_goos_fb_refresh(&gfb, 0, 0, view_info.width, view_info.height); 21.221 +} 21.222 + 21.223 + 21.224 + 21.225 +/* Event buffer memory. */ 21.226 + 21.227 +static void *evmem = 0; 21.228 + 21.229 + 21.230 + 21.231 +/* Arguments: [ chars ] */ 21.232 + 21.233 +int main(int argc, char *argv[]) 21.234 +{ 21.235 + if (l4re_util_video_goos_fb_setup_name(&gfb, "fb")) 21.236 + return 1; 21.237 + 21.238 + if (l4re_util_video_goos_fb_view_info(&gfb, &view_info)) 21.239 + return 1; 21.240 + 21.241 + if (!(fb = l4re_util_video_goos_fb_attach_buffer(&gfb))) 21.242 + return 1; 21.243 + 21.244 + /* Obtain a canvas for the framebuffer. */ 21.245 + 21.246 + Factory *factory; 21.247 + 21.248 + if (view_info.pixel_info.bytes_per_pixel == 2) 21.249 + factory = &_rgb16; 21.250 + else 21.251 + factory = &_rgb32; 21.252 + 21.253 + Canvas *screen = factory->create_canvas((void *) ((unsigned long) fb + view_info.buffer_offset), 21.254 + Area(view_info.width, view_info.height), 21.255 + view_info.bytes_per_line); 21.256 + 21.257 + Font font(&_binary_unifont_tff_start[0]); 21.258 + 21.259 + _screen = screen; 21.260 + _font = &font; 21.261 + 21.262 + /* Obtain a reference to the event source. */ 21.263 + 21.264 + L4::Cap<Input_event_interface> event_server = L4Re::Env::env()->get_cap<Input_event_interface>("ev"); 21.265 + if (!event_server.is_valid()) return 1; 21.266 + 21.267 + /* Obtain a capability for the event buffer. */ 21.268 + 21.269 + L4::Cap<L4Re::Dataspace> mem = L4Re::Util::cap_alloc.alloc<L4Re::Dataspace>(); 21.270 + if (!mem.is_valid()) return 1; 21.271 + 21.272 + if (event_server->get_buffer(mem)) return 1; 21.273 + 21.274 + /* Attach the event buffer to this task. */ 21.275 + 21.276 + if (L4Re::Env::env()->rm()->attach(&evmem, mem->size(), L4Re::Rm::Search_addr, 21.277 + L4::Ipc::make_cap_rw(mem))) 21.278 + return 1; 21.279 + 21.280 + L4Re::Event_buffer event_buffer = L4Re::Event_buffer(evmem, mem->size()); 21.281 + 21.282 + /* Obtain an interrupt capability. */ 21.283 + 21.284 + L4::Cap<L4::Irq> irq = L4Re::Util::cap_alloc.alloc<L4::Irq>(); 21.285 + if (!irq.is_valid()) return 1; 21.286 + 21.287 + /* Bind the interrupt to the event capability. */ 21.288 + 21.289 + if (event_server->bind(0, irq)) return 1; 21.290 + 21.291 + /* Private data for the handler function. */ 21.292 + 21.293 + void *priv = 0; 21.294 + 21.295 + if ((argc > 1) && (!strcmp(argv[1], "chars"))) 21.296 + priv = (void *) key_to_string; 21.297 + 21.298 + /* Create an event handler and wait for events. */ 21.299 + 21.300 + Input_event_loop loop(irq, handler, priv, event_buffer); 21.301 + 21.302 + loop.start(); 21.303 + l4_sleep_forever(); 21.304 + 21.305 + return 0; 21.306 +}
22.1 Binary file pkg/landfall-examples/input_event_client/unifont.tff has changed