1.1 --- a/pkg/devices/keypad/src/letux400/keypad-letux400.cc Sun Jun 11 15:42:11 2023 +0200
1.2 +++ b/pkg/devices/keypad/src/letux400/keypad-letux400.cc Sun Jun 18 00:19:36 2023 +0200
1.3 @@ -2,7 +2,7 @@
1.4 * Export the keypad GPIOs on the Letux 400 as a data space accessible via the
1.5 * "keypad" capability.
1.6 *
1.7 - * Copyright (C) 2018 Paul Boddie <paul@boddie.org.uk>
1.8 + * Copyright (C) 2018, 2023 Paul Boddie <paul@boddie.org.uk>
1.9 *
1.10 * This program is free software; you can redistribute it and/or
1.11 * modify it under the terms of the GNU General Public License as
1.12 @@ -23,17 +23,19 @@
1.13 #include <l4/devices/gpio-jz4730.h>
1.14 #include <l4/devices/dataspace.h>
1.15 #include <l4/devices/memory.h>
1.16 -#include "keypad-server.h"
1.17 -#include "keypad-event-loop.h"
1.18
1.19 -#include <l4/re/dataspace>
1.20 -#include <l4/re/env>
1.21 -#include <l4/re/util/object_registry>
1.22 +#include <l4/re/c/dataspace.h>
1.23 +#include <l4/re/env.h>
1.24
1.25 #include <l4/sys/cache.h>
1.26
1.27 #include <stdint.h>
1.28
1.29 +#include "keypad-event-loop.h"
1.30 +#include "keypad-run.h"
1.31 +
1.32 +
1.33 +
1.34 enum Jz4730_keypad_gpio
1.35 {
1.36 Jz4730_keypad_gpio_inputs_count = 8,
1.37 @@ -128,24 +130,20 @@
1.38
1.39
1.40
1.41 -static L4Re::Util::Registry_server<> server;
1.42 -
1.43 -
1.44 -
1.45 /* Main program. */
1.46
1.47 int main(void)
1.48 {
1.49 + if (setup_memory())
1.50 + return 1;
1.51 +
1.52 /* Memory allocation capability for the keypad data. */
1.53
1.54 - L4::Cap<L4Re::Dataspace> mem;
1.55 l4_size_t mem_size = Jz4730_keypad_gpio_outputs_count * sizeof(uint32_t);
1.56 + l4re_ds_t mem = allocate_data(mem_size, &keymem);
1.57
1.58 - if (setup_memory()) return 1;
1.59 -
1.60 - mem = allocate_data(mem_size, &keymem);
1.61 -
1.62 - if (!mem.is_valid()) return 1;
1.63 + if (l4_is_invalid_cap(mem))
1.64 + return 1;
1.65
1.66 keypad = (uint32_t *) keymem;
1.67
1.68 @@ -159,13 +157,7 @@
1.69 loop.attach(scan_keypad);
1.70 loop.start();
1.71
1.72 - /* Initialise and register a server object. */
1.73 -
1.74 - Keypad_server server_obj(mem);
1.75 - server.registry()->register_obj(&server_obj, "keypad");
1.76 + /* Start a server using the common server functionality. */
1.77
1.78 - /* Enter the IPC server loop. */
1.79 -
1.80 - server.loop();
1.81 - return 0;
1.82 + return run(mem);
1.83 }