1.1 --- a/pkg/devices/input/include/input-event-client.h Wed May 23 23:57:09 2018 +0200
1.2 +++ b/pkg/devices/input/include/input-event-client.h Thu May 24 23:49:57 2018 +0200
1.3 @@ -25,15 +25,19 @@
1.4
1.5 #include <l4/re/dataspace>
1.6 #include <l4/re/env>
1.7 +#include <l4/re/event>
1.8 +#include <l4/sys/capability>
1.9 #include <l4/sys/icu>
1.10 +#include <l4/sys/types.h>
1.11
1.12 -class Input_event_interface : public L4::Kobject_t<Input_event_interface, L4::Kobject>
1.13 +class Input_event_interface : public L4::Kobject_t<Input_event_interface,
1.14 + L4::Kobject,
1.15 + /* PROTO_ANY */ 0,
1.16 + /* accepts one cap */ L4::Type_info::Demand_t<1> >
1.17 {
1.18 - L4_KOBJECT(Input_event_interface)
1.19 -
1.20 public:
1.21 + int bind(unsigned irqnum, L4::Cap<L4::Irq> irq) throw();
1.22 int get_buffer(L4::Cap<L4Re::Dataspace> mem) throw();
1.23 - int bind(unsigned irqnum, L4::Cap<L4::Irq> irq) throw();
1.24 };
1.25
1.26 #endif
2.1 --- a/pkg/devices/input/include/input-event-server.h Wed May 23 23:57:09 2018 +0200
2.2 +++ b/pkg/devices/input/include/input-event-server.h Thu May 24 23:49:57 2018 +0200
2.3 @@ -23,6 +23,8 @@
2.4
2.5 #ifdef __cplusplus
2.6
2.7 +#include "input-event-client.h"
2.8 +
2.9 #include <l4/cxx/ipc_server>
2.10 #include <l4/re/dataspace>
2.11 #include <l4/re/env>
2.12 @@ -32,7 +34,7 @@
2.13
2.14 /* Server object to provide input event source access. */
2.15
2.16 -class Input_event_server : public L4::Server_object_t<L4::Kobject>
2.17 +class Input_event_server : public L4::Server_object_t<Input_event_interface>
2.18 {
2.19 private:
2.20 L4::Cap<L4Re::Dataspace> _mem;
2.21 @@ -43,9 +45,9 @@
2.22 /* Initialise the server with a capability referencing the exported memory
2.23 and an event buffer through which events will be communicated. */
2.24
2.25 - explicit Input_event_server(L4::Cap<L4Re::Dataspace> mem, L4::Cap<L4::Irq> irq,
2.26 + explicit Input_event_server(L4::Cap<L4Re::Dataspace> mem,
2.27 L4Re::Event_buffer events)
2.28 - : _mem(mem), _irq(irq), _events(events)
2.29 + : _mem(mem), _events(events)
2.30 {
2.31 }
2.32
3.1 --- a/pkg/devices/input/src/client/input-event-client.cc Wed May 23 23:57:09 2018 +0200
3.2 +++ b/pkg/devices/input/src/client/input-event-client.cc Thu May 24 23:49:57 2018 +0200
3.3 @@ -1,5 +1,6 @@
3.4 /*
3.5 - * Input event client to access input event servers.
3.6 + * Input event client to access input event servers. This is a more narrow
3.7 + * alternative to the L4Re::Event interface.
3.8 *
3.9 * (c) 2018 Paul Boddie <paul@boddie.org.uk>
3.10 *
3.11 @@ -46,10 +47,7 @@
3.12
3.13 s << Input_event_op_bind;
3.14 s << irqnum;
3.15 -
3.16 - /* Send a "receive item" for requesting a capability. */
3.17 -
3.18 - s << L4::Ipc::Small_buf(irq);
3.19 + s << irq;
3.20
3.21 return l4_error(s.call(cap(), Input_event_proto_icu));
3.22 }
4.1 --- a/pkg/devices/input/src/server/input-keypad-server.cc Wed May 23 23:57:09 2018 +0200
4.2 +++ b/pkg/devices/input/src/server/input-keypad-server.cc Thu May 24 23:49:57 2018 +0200
4.3 @@ -29,6 +29,7 @@
4.4 #include <l4/re/dataspace>
4.5 #include <l4/re/env>
4.6 #include <l4/re/event>
4.7 +#include <l4/re/util/br_manager>
4.8 #include <l4/re/util/cap_alloc>
4.9 #include <l4/re/util/object_registry>
4.10 #include <l4/sys/capability>
4.11 @@ -37,6 +38,25 @@
4.12 #include <l4/sys/types.h>
4.13 #include <l4/util/util.h>
4.14
4.15 +/* Extract a fpage from the message buffers. Provide a Snd_fpage reference for
4.16 + modification. */
4.17 +
4.18 +static
4.19 +void get_fpage(L4::Ipc::Iostream &ios, L4::Ipc::Snd_item &fpage)
4.20 +{
4.21 + l4_msgtag_t tag = ios.tag();
4.22 +
4.23 + if (!tag.items())
4.24 + return;
4.25 +
4.26 + /* Extract the fpage details directly since the stream operator doesn't seem
4.27 + to work. */
4.28 +
4.29 + l4_msg_regs_t *m = l4_utcb_mr_u(l4_utcb());
4.30 + l4_umword_t b = m->mr[tag.words()], d = m->mr[tag.words() + 1];
4.31 + fpage = L4::Ipc::Snd_item(b, d);
4.32 +}
4.33 +
4.34 /* Handle invocations. */
4.35
4.36 int
4.37 @@ -44,6 +64,8 @@
4.38 {
4.39 l4_msgtag_t tag;
4.40 l4_umword_t op;
4.41 + unsigned irqnum;
4.42 + L4::Ipc::Snd_fpage fpage;
4.43
4.44 (void) obj;
4.45 ios >> tag;
4.46 @@ -65,7 +87,7 @@
4.47 return L4_EOK;
4.48
4.49 default:
4.50 - return -L4_ENOSYS;
4.51 + return -L4_EINVAL;
4.52 }
4.53
4.54 case L4_PROTO_IRQ:
4.55 @@ -75,11 +97,17 @@
4.56 /* Just return the interrupt capability. */
4.57
4.58 case Input_event_op_bind:
4.59 - ios << _irq;
4.60 - return L4_EOK;
4.61 + ios >> irqnum;
4.62 + get_fpage(ios, fpage);
4.63 +
4.64 + if (!fpage.cap_received())
4.65 + return -L4_EINVAL;
4.66 +
4.67 + _irq = server_iface()->rcv_cap<L4::Irq>(0);
4.68 + return server_iface()->realloc_rcv_cap(0);
4.69
4.70 default:
4.71 - return -L4_ENOSYS;
4.72 + return -L4_EINVAL;
4.73 }
4.74
4.75 default:
4.76 @@ -119,7 +147,7 @@
4.77
4.78
4.79
4.80 -static L4Re::Util::Registry_server<> server;
4.81 +static L4Re::Util::Registry_server<L4Re::Util::Br_manager_hooks> server;
4.82
4.83
4.84
4.85 @@ -139,17 +167,13 @@
4.86 L4::Cap<L4::Irq> irq = L4Re::Util::cap_alloc.alloc<L4::Irq>();
4.87 if (!irq.is_valid()) return 1;
4.88
4.89 - /* Create an interrupt object. */
4.90 -
4.91 - if (l4_error(L4Re::Env::env()->factory()->create(irq))) return 1;
4.92 -
4.93 // Event buffer for the data.
4.94
4.95 L4Re::Event_buffer events(buffer, L4_PAGESIZE);
4.96
4.97 // Initialise and register a server object.
4.98
4.99 - Input_event_server server_obj(mem, irq, events);
4.100 + Input_event_server server_obj(mem, events);
4.101 server.registry()->register_obj(&server_obj, "ev");
4.102
4.103 // Attach the event handler and wait for events.
5.1 --- a/pkg/landfall-examples/input_event_client/Makefile Wed May 23 23:57:09 2018 +0200
5.2 +++ b/pkg/landfall-examples/input_event_client/Makefile Thu May 24 23:49:57 2018 +0200
5.3 @@ -4,6 +4,6 @@
5.4 TARGET = ex_input_event_client
5.5 SRC_CC = input_event_client.cc
5.6 SRC_DATA = unifont.tff
5.7 -REQUIRES_LIBS = libio l4re_c-util mag-gfx libevent libdevice-input-event-client
5.8 +REQUIRES_LIBS = l4re_c-util mag-gfx libdevice-input-event-client
5.9
5.10 include $(L4DIR)/mk/prog.mk
6.1 --- a/pkg/landfall-examples/input_event_client/input_event_client.cc Wed May 23 23:57:09 2018 +0200
6.2 +++ b/pkg/landfall-examples/input_event_client/input_event_client.cc Thu May 24 23:49:57 2018 +0200
6.3 @@ -43,7 +43,6 @@
6.4 * exception statement from your version.
6.5 */
6.6
6.7 -#include <l4/devices/input-event-client.h>
6.8 #include <l4/devices/input-event-loop.h>
6.9
6.10 #include <pthread.h>
6.11 @@ -56,6 +55,7 @@
6.12 #include <l4/re/event>
6.13 #include <l4/re/event_enums.h>
6.14 #include <l4/re/util/cap_alloc>
6.15 +#include <l4/sys/icu.h>
6.16 #include <l4/util/util.h>
6.17
6.18 #include <l4/mag-gfx/canvas>
6.19 @@ -260,9 +260,10 @@
6.20 _screen = screen;
6.21 _font = &font;
6.22
6.23 - /* Obtain a reference to the event source. */
6.24 + /* Obtain a reference to the event source. It should also be possible to use
6.25 + the Input_event_interface for the core operations. */
6.26
6.27 - L4::Cap<Input_event_interface> event_server = L4Re::Env::env()->get_cap<Input_event_interface>("ev");
6.28 + L4::Cap<L4Re::Event> event_server = L4Re::Env::env()->get_cap<L4Re::Event>("ev");
6.29 if (!event_server.is_valid()) return 1;
6.30
6.31 /* Obtain a capability for the event buffer. */
6.32 @@ -286,9 +287,13 @@
6.33 L4::Cap<L4::Irq> irq = L4Re::Util::cap_alloc.alloc<L4::Irq>();
6.34 if (!irq.is_valid()) return 1;
6.35
6.36 + /* Create an interrupt object. */
6.37 +
6.38 + if (l4_error(L4Re::Env::env()->factory()->create(irq))) return 1;
6.39 +
6.40 /* Bind the interrupt to the event capability. */
6.41
6.42 - if (event_server->bind(0, irq)) return 1;
6.43 + if (l4_error(event_server->bind(0, irq))) return 1;
6.44
6.45 /* Create an event handler. */
6.46