# HG changeset patch # User Paul Boddie # Date 1527198597 -7200 # Node ID c9cbc0cafa8017865c2568fe55e8e28c416761dd # Parent 05788bc55c390e0fced8652ca1ea864073875e4d Permit the binding of client-created interrupt objects to input event servers. Support L4Re::Event interface usage by input event clients. diff -r 05788bc55c39 -r c9cbc0cafa80 pkg/devices/input/include/input-event-client.h --- a/pkg/devices/input/include/input-event-client.h Wed May 23 23:57:09 2018 +0200 +++ b/pkg/devices/input/include/input-event-client.h Thu May 24 23:49:57 2018 +0200 @@ -25,15 +25,19 @@ #include #include +#include +#include #include +#include -class Input_event_interface : public L4::Kobject_t +class Input_event_interface : public L4::Kobject_t > { - L4_KOBJECT(Input_event_interface) - public: + int bind(unsigned irqnum, L4::Cap irq) throw(); int get_buffer(L4::Cap mem) throw(); - int bind(unsigned irqnum, L4::Cap irq) throw(); }; #endif diff -r 05788bc55c39 -r c9cbc0cafa80 pkg/devices/input/include/input-event-server.h --- a/pkg/devices/input/include/input-event-server.h Wed May 23 23:57:09 2018 +0200 +++ b/pkg/devices/input/include/input-event-server.h Thu May 24 23:49:57 2018 +0200 @@ -23,6 +23,8 @@ #ifdef __cplusplus +#include "input-event-client.h" + #include #include #include @@ -32,7 +34,7 @@ /* Server object to provide input event source access. */ -class Input_event_server : public L4::Server_object_t +class Input_event_server : public L4::Server_object_t { private: L4::Cap _mem; @@ -43,9 +45,9 @@ /* Initialise the server with a capability referencing the exported memory and an event buffer through which events will be communicated. */ - explicit Input_event_server(L4::Cap mem, L4::Cap irq, + explicit Input_event_server(L4::Cap mem, L4Re::Event_buffer events) - : _mem(mem), _irq(irq), _events(events) + : _mem(mem), _events(events) { } diff -r 05788bc55c39 -r c9cbc0cafa80 pkg/devices/input/src/client/input-event-client.cc --- a/pkg/devices/input/src/client/input-event-client.cc Wed May 23 23:57:09 2018 +0200 +++ b/pkg/devices/input/src/client/input-event-client.cc Thu May 24 23:49:57 2018 +0200 @@ -1,5 +1,6 @@ /* - * Input event client to access input event servers. + * Input event client to access input event servers. This is a more narrow + * alternative to the L4Re::Event interface. * * (c) 2018 Paul Boddie * @@ -46,10 +47,7 @@ s << Input_event_op_bind; s << irqnum; - - /* Send a "receive item" for requesting a capability. */ - - s << L4::Ipc::Small_buf(irq); + s << irq; return l4_error(s.call(cap(), Input_event_proto_icu)); } diff -r 05788bc55c39 -r c9cbc0cafa80 pkg/devices/input/src/server/input-keypad-server.cc --- a/pkg/devices/input/src/server/input-keypad-server.cc Wed May 23 23:57:09 2018 +0200 +++ b/pkg/devices/input/src/server/input-keypad-server.cc Thu May 24 23:49:57 2018 +0200 @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -37,6 +38,25 @@ #include #include +/* Extract a fpage from the message buffers. Provide a Snd_fpage reference for + modification. */ + +static +void get_fpage(L4::Ipc::Iostream &ios, L4::Ipc::Snd_item &fpage) +{ + l4_msgtag_t tag = ios.tag(); + + if (!tag.items()) + return; + + /* Extract the fpage details directly since the stream operator doesn't seem + to work. */ + + l4_msg_regs_t *m = l4_utcb_mr_u(l4_utcb()); + l4_umword_t b = m->mr[tag.words()], d = m->mr[tag.words() + 1]; + fpage = L4::Ipc::Snd_item(b, d); +} + /* Handle invocations. */ int @@ -44,6 +64,8 @@ { l4_msgtag_t tag; l4_umword_t op; + unsigned irqnum; + L4::Ipc::Snd_fpage fpage; (void) obj; ios >> tag; @@ -65,7 +87,7 @@ return L4_EOK; default: - return -L4_ENOSYS; + return -L4_EINVAL; } case L4_PROTO_IRQ: @@ -75,11 +97,17 @@ /* Just return the interrupt capability. */ case Input_event_op_bind: - ios << _irq; - return L4_EOK; + ios >> irqnum; + get_fpage(ios, fpage); + + if (!fpage.cap_received()) + return -L4_EINVAL; + + _irq = server_iface()->rcv_cap(0); + return server_iface()->realloc_rcv_cap(0); default: - return -L4_ENOSYS; + return -L4_EINVAL; } default: @@ -119,7 +147,7 @@ -static L4Re::Util::Registry_server<> server; +static L4Re::Util::Registry_server server; @@ -139,17 +167,13 @@ L4::Cap irq = L4Re::Util::cap_alloc.alloc(); if (!irq.is_valid()) return 1; - /* Create an interrupt object. */ - - if (l4_error(L4Re::Env::env()->factory()->create(irq))) return 1; - // Event buffer for the data. L4Re::Event_buffer events(buffer, L4_PAGESIZE); // Initialise and register a server object. - Input_event_server server_obj(mem, irq, events); + Input_event_server server_obj(mem, events); server.registry()->register_obj(&server_obj, "ev"); // Attach the event handler and wait for events. diff -r 05788bc55c39 -r c9cbc0cafa80 pkg/landfall-examples/input_event_client/Makefile --- a/pkg/landfall-examples/input_event_client/Makefile Wed May 23 23:57:09 2018 +0200 +++ b/pkg/landfall-examples/input_event_client/Makefile Thu May 24 23:49:57 2018 +0200 @@ -4,6 +4,6 @@ TARGET = ex_input_event_client SRC_CC = input_event_client.cc SRC_DATA = unifont.tff -REQUIRES_LIBS = libio l4re_c-util mag-gfx libevent libdevice-input-event-client +REQUIRES_LIBS = l4re_c-util mag-gfx libdevice-input-event-client include $(L4DIR)/mk/prog.mk diff -r 05788bc55c39 -r c9cbc0cafa80 pkg/landfall-examples/input_event_client/input_event_client.cc --- a/pkg/landfall-examples/input_event_client/input_event_client.cc Wed May 23 23:57:09 2018 +0200 +++ b/pkg/landfall-examples/input_event_client/input_event_client.cc Thu May 24 23:49:57 2018 +0200 @@ -43,7 +43,6 @@ * exception statement from your version. */ -#include #include #include @@ -56,6 +55,7 @@ #include #include #include +#include #include #include @@ -260,9 +260,10 @@ _screen = screen; _font = &font; - /* Obtain a reference to the event source. */ + /* Obtain a reference to the event source. It should also be possible to use + the Input_event_interface for the core operations. */ - L4::Cap event_server = L4Re::Env::env()->get_cap("ev"); + L4::Cap event_server = L4Re::Env::env()->get_cap("ev"); if (!event_server.is_valid()) return 1; /* Obtain a capability for the event buffer. */ @@ -286,9 +287,13 @@ L4::Cap irq = L4Re::Util::cap_alloc.alloc(); if (!irq.is_valid()) return 1; + /* Create an interrupt object. */ + + if (l4_error(L4Re::Env::env()->factory()->create(irq))) return 1; + /* Bind the interrupt to the event capability. */ - if (event_server->bind(0, irq)) return 1; + if (l4_error(event_server->bind(0, irq))) return 1; /* Create an event handler. */