1.1 --- a/pkg/devices/input/src/keypad/input-keypad-client.cc Sat Jun 10 23:59:44 2023 +0200
1.2 +++ b/pkg/devices/input/src/keypad/input-keypad-client.cc Sun Jun 11 15:42:11 2023 +0200
1.3 @@ -24,72 +24,76 @@
1.4 #include <pthread.h>
1.5 #include <pthread-l4.h>
1.6
1.7 -#include <l4/re/dataspace>
1.8 -#include <l4/re/env>
1.9 -#include <l4/re/rm>
1.10 -#include <l4/re/util/cap_alloc>
1.11 +#include <l4/re/env.h>
1.12
1.13 #include <l4/re/event_enums.h>
1.14 #include <l4/sys/thread.h>
1.15 #include <l4/util/util.h>
1.16
1.17 +#include <ipc/cap_alloc.h>
1.18 +#include <ipc/mem_ipc.h>
1.19 +
1.20 #include <stdlib.h>
1.21
1.22 +#include "keypad_interface.h"
1.23 +
1.24 +
1.25 +
1.26 /* Obtain a capability for the keypad data. */
1.27
1.28 -void
1.29 -Input_keypad_client::init_memory()
1.30 +void Input_keypad_client::init_memory()
1.31 {
1.32 - _mem = L4Re::Util::cap_alloc.alloc<L4Re::Dataspace>();
1.33 + _mem = ipc_cap_alloc();
1.34 }
1.35
1.36 /* Obtain a reference to the keypad. */
1.37
1.38 -void
1.39 -Input_keypad_client::init_keypad()
1.40 +void Input_keypad_client::init_keypad()
1.41 {
1.42 - _keypad_server = L4Re::Env::env()->get_cap<Keypad_device_interface>("keypad");
1.43 + _keypad_cap = l4re_env_get_cap("keypad");
1.44 }
1.45
1.46 /* Access the keypad server memory. */
1.47
1.48 -void
1.49 -Input_keypad_client::init_keypad_data()
1.50 +void Input_keypad_client::init_keypad_data()
1.51 {
1.52 - if (!_mem.is_valid())
1.53 + if (l4_is_invalid_cap(_mem))
1.54 return;
1.55
1.56 - if (!_keypad_server.is_valid())
1.57 + if (l4_is_invalid_cap(_keypad_server))
1.58 return;
1.59
1.60 /* Obtain a reference to the keypad data. */
1.61
1.62 - if (_keypad_server->get_keypad_data(_mem))
1.63 + client_Keypad keypad(_keypad_cap);
1.64 +
1.65 + if (keypad.get_keypad_data(_mem))
1.66 return;
1.67
1.68 /* Attach the keypad data to a region in this task. */
1.69
1.70 - if (L4Re::Env::env()->rm()->attach(&_keymem, _mem->size(),
1.71 - L4Re::Rm::F::Search_addr |
1.72 - L4Re::Rm::F::R,
1.73 - L4::Ipc::make_cap_rw(_mem)))
1.74 + unsigned long size;
1.75 +
1.76 + if (ipc_dataspace_size(_mem, &size))
1.77 + return;
1.78 +
1.79 + if (ipc_attach_dataspace(_mem, size, &_keymem))
1.80 return;
1.81
1.82 /* Allocate memory for a copy of the keypad data. */
1.83
1.84 - _keymem_previous = malloc(_mem->size());
1.85 + _keymem_previous = malloc(size);
1.86 }
1.87
1.88 /* Release capabilities and the memory for a copy of the keypad data. */
1.89
1.90 -void
1.91 -Input_keypad_client::release_keypad_data()
1.92 +void Input_keypad_client::release_keypad_data()
1.93 {
1.94 - if (_mem.is_valid())
1.95 - L4Re::Util::cap_alloc.free(_mem);
1.96 + if (l4_is_valid_cap(_mem))
1.97 + ipc_cap_free(_mem);
1.98
1.99 - if (_keypad_server.is_valid())
1.100 - L4Re::Util::cap_alloc.free(_keypad_server);
1.101 + if (l4_is_valid_cap(_keypad_cap))
1.102 + ipc_cap_free(_keypad_cap);
1.103
1.104 if (_keymem_previous && (_keymem_previous != NULL))
1.105 free(_keymem_previous);
1.106 @@ -97,8 +101,7 @@
1.107
1.108 /* Scan the keypad, compare old and new states, and generate key events. */
1.109
1.110 -void
1.111 -Input_keypad_client::scan_keypad()
1.112 +void Input_keypad_client::scan_keypad()
1.113 {
1.114 uint32_t *keymem = (uint32_t *) _keymem;
1.115 uint32_t *keymem_previous = (uint32_t *) _keymem_previous;
1.116 @@ -147,8 +150,7 @@
1.117
1.118 /* Perform keypad scanning in a separate thread. */
1.119
1.120 -void *
1.121 -Input_keypad_client::scan_mainloop(void *data)
1.122 +void *Input_keypad_client::scan_mainloop(void *data)
1.123 {
1.124 /* Since this is a static method, obtain instance details from the data. */
1.125
1.126 @@ -165,8 +167,7 @@
1.127
1.128 /* Thread initialisation for the keypad scanning activity. */
1.129
1.130 -void
1.131 -Input_keypad_client::attach(Input_handler handler, void *priv)
1.132 +void Input_keypad_client::attach(Input_handler handler, void *priv)
1.133 {
1.134 pthread_attr_t thread_attr;
1.135 struct sched_param sp;