1.1 --- a/pkg/devices/input/src/server/input-keypad-server.cc Wed May 23 23:57:09 2018 +0200
1.2 +++ b/pkg/devices/input/src/server/input-keypad-server.cc Thu May 24 23:49:57 2018 +0200
1.3 @@ -29,6 +29,7 @@
1.4 #include <l4/re/dataspace>
1.5 #include <l4/re/env>
1.6 #include <l4/re/event>
1.7 +#include <l4/re/util/br_manager>
1.8 #include <l4/re/util/cap_alloc>
1.9 #include <l4/re/util/object_registry>
1.10 #include <l4/sys/capability>
1.11 @@ -37,6 +38,25 @@
1.12 #include <l4/sys/types.h>
1.13 #include <l4/util/util.h>
1.14
1.15 +/* Extract a fpage from the message buffers. Provide a Snd_fpage reference for
1.16 + modification. */
1.17 +
1.18 +static
1.19 +void get_fpage(L4::Ipc::Iostream &ios, L4::Ipc::Snd_item &fpage)
1.20 +{
1.21 + l4_msgtag_t tag = ios.tag();
1.22 +
1.23 + if (!tag.items())
1.24 + return;
1.25 +
1.26 + /* Extract the fpage details directly since the stream operator doesn't seem
1.27 + to work. */
1.28 +
1.29 + l4_msg_regs_t *m = l4_utcb_mr_u(l4_utcb());
1.30 + l4_umword_t b = m->mr[tag.words()], d = m->mr[tag.words() + 1];
1.31 + fpage = L4::Ipc::Snd_item(b, d);
1.32 +}
1.33 +
1.34 /* Handle invocations. */
1.35
1.36 int
1.37 @@ -44,6 +64,8 @@
1.38 {
1.39 l4_msgtag_t tag;
1.40 l4_umword_t op;
1.41 + unsigned irqnum;
1.42 + L4::Ipc::Snd_fpage fpage;
1.43
1.44 (void) obj;
1.45 ios >> tag;
1.46 @@ -65,7 +87,7 @@
1.47 return L4_EOK;
1.48
1.49 default:
1.50 - return -L4_ENOSYS;
1.51 + return -L4_EINVAL;
1.52 }
1.53
1.54 case L4_PROTO_IRQ:
1.55 @@ -75,11 +97,17 @@
1.56 /* Just return the interrupt capability. */
1.57
1.58 case Input_event_op_bind:
1.59 - ios << _irq;
1.60 - return L4_EOK;
1.61 + ios >> irqnum;
1.62 + get_fpage(ios, fpage);
1.63 +
1.64 + if (!fpage.cap_received())
1.65 + return -L4_EINVAL;
1.66 +
1.67 + _irq = server_iface()->rcv_cap<L4::Irq>(0);
1.68 + return server_iface()->realloc_rcv_cap(0);
1.69
1.70 default:
1.71 - return -L4_ENOSYS;
1.72 + return -L4_EINVAL;
1.73 }
1.74
1.75 default:
1.76 @@ -119,7 +147,7 @@
1.77
1.78
1.79
1.80 -static L4Re::Util::Registry_server<> server;
1.81 +static L4Re::Util::Registry_server<L4Re::Util::Br_manager_hooks> server;
1.82
1.83
1.84
1.85 @@ -139,17 +167,13 @@
1.86 L4::Cap<L4::Irq> irq = L4Re::Util::cap_alloc.alloc<L4::Irq>();
1.87 if (!irq.is_valid()) return 1;
1.88
1.89 - /* Create an interrupt object. */
1.90 -
1.91 - if (l4_error(L4Re::Env::env()->factory()->create(irq))) return 1;
1.92 -
1.93 // Event buffer for the data.
1.94
1.95 L4Re::Event_buffer events(buffer, L4_PAGESIZE);
1.96
1.97 // Initialise and register a server object.
1.98
1.99 - Input_event_server server_obj(mem, irq, events);
1.100 + Input_event_server server_obj(mem, events);
1.101 server.registry()->register_obj(&server_obj, "ev");
1.102
1.103 // Attach the event handler and wait for events.