# HG changeset patch # User Paul Boddie # Date 1687040376 -7200 # Node ID 929b5f0a63e4b12c4f64e1548b6c10f2e288a938 # Parent c9a29e1ba843b5df69e4f29ec0f8f97a94496e64 Converted the remaining code to use libipc and generated IPC components. diff -r c9a29e1ba843 -r 929b5f0a63e4 pkg/devices/Control --- a/pkg/devices/Control Sun Jun 11 15:42:11 2023 +0200 +++ b/pkg/devices/Control Sun Jun 18 00:19:36 2023 +0200 @@ -13,16 +13,10 @@ provides: devices-keypad-qi_lb60 provides: devices-pwm-jz4730 provides: devices-spi-jz4740 -provides: libdevice-display-ops -provides: libdevice-fb-client provides: libdevice-fb-lcd -provides: libdevice-fb-ops provides: libdevice-fb-server -provides: libdevice-input-event-client -provides: libdevice-input-event-ops +provides: libdevice-input-event-loop provides: libdevice-input-keypad -provides: libdevice-keypad-client -provides: libdevice-keypad-ops provides: libdevice-keypad-server provides: libdevice-lcd provides: libdevice-lcd-jz4740 @@ -45,5 +39,5 @@ provides: libdrivers-panel-loader provides: libdrivers-panel-qi_lb60 provides: libdrivers-pwm -requires: libc libc_be_l4re libdl l4re_c libio +requires: libc libc_be_l4re libdl l4re_c libio libipc Maintainer: paul@boddie.org.uk diff -r c9a29e1ba843 -r 929b5f0a63e4 pkg/devices/Makefile --- a/pkg/devices/Makefile Sun Jun 11 15:42:11 2023 +0200 +++ b/pkg/devices/Makefile Sun Jun 18 00:19:36 2023 +0200 @@ -12,9 +12,9 @@ backlight: pwm spi include cpm: lib util -display: backlight cpm lib util include +display: backlight cpm lib util fb: lcd lib util -input: keypad lib +input: keypad lib util keypad: lib util lcd: display lib util lib: include util diff -r c9a29e1ba843 -r 929b5f0a63e4 pkg/devices/fb/include/Makefile --- a/pkg/devices/fb/include/Makefile Sun Jun 11 15:42:11 2023 +0200 +++ b/pkg/devices/fb/include/Makefile Sun Jun 18 00:19:36 2023 +0200 @@ -1,6 +1,4 @@ PKGDIR = ../.. L4DIR ?= $(PKGDIR)/../.. -PC_FILENAME := libdevice-fb-ops - include $(L4DIR)/mk/include.mk diff -r c9a29e1ba843 -r 929b5f0a63e4 pkg/devices/fb/include/fb-lcd-run.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/pkg/devices/fb/include/fb-lcd-run.h Sun Jun 18 00:19:36 2023 +0200 @@ -0,0 +1,24 @@ +/* + * LCD framebuffer server functionality. + * + * Copyright (C) 2018, 2023 Paul Boddie + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA + */ + +#pragma once + +int fb_lcd_run(void); diff -r c9a29e1ba843 -r 929b5f0a63e4 pkg/devices/fb/include/fb-lcd.h --- a/pkg/devices/fb/include/fb-lcd.h Sun Jun 11 15:42:11 2023 +0200 +++ b/pkg/devices/fb/include/fb-lcd.h Sun Jun 18 00:19:36 2023 +0200 @@ -23,11 +23,10 @@ #ifdef __cplusplus +#include #include #include -#include "fb-server.h" - class Framebuffer_lcd_server : public Framebuffer_server { Lcd_device *_device; @@ -46,7 +45,3 @@ }; #endif - -/* Common initiation method. */ - -int run(void); diff -r c9a29e1ba843 -r 929b5f0a63e4 pkg/devices/fb/include/fb-run.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/pkg/devices/fb/include/fb-run.h Sun Jun 18 00:19:36 2023 +0200 @@ -0,0 +1,28 @@ +/* + * LCD framebuffer server functionality. + * + * Copyright (C) 2018, 2023 Paul Boddie + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA + */ + +#pragma once + +#include + +/* Common initiation method. */ + +int run(Framebuffer *obj); diff -r c9a29e1ba843 -r 929b5f0a63e4 pkg/devices/fb/include/fb-server.h --- a/pkg/devices/fb/include/fb-server.h Sun Jun 11 15:42:11 2023 +0200 +++ b/pkg/devices/fb/include/fb-server.h Sun Jun 18 00:19:36 2023 +0200 @@ -23,11 +23,10 @@ #ifdef __cplusplus +#include #include #include -#include "framebuffer_interface.h" - /* Server object to provide framebuffer data access. */ class Framebuffer_server : public Framebuffer diff -r c9a29e1ba843 -r 929b5f0a63e4 pkg/devices/fb/src/jz4740/fb-jz4740.cc --- a/pkg/devices/fb/src/jz4740/fb-jz4740.cc Sun Jun 11 15:42:11 2023 +0200 +++ b/pkg/devices/fb/src/jz4740/fb-jz4740.cc Sun Jun 18 00:19:36 2023 +0200 @@ -1,7 +1,7 @@ /* * Export the framebuffer for the Ben NanoNote via the "fb" capability. * - * Copyright (C) 2018 Paul Boddie + * Copyright (C) 2018, 2023 Paul Boddie * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -19,11 +19,11 @@ * Boston, MA 02110-1301, USA */ -#include "fb-lcd.h" +#include "fb-lcd-run.h" /* Main program. */ int main() { - return run(); + return fb_lcd_run(); } diff -r c9a29e1ba843 -r 929b5f0a63e4 pkg/devices/fb/src/lcd/Makefile --- a/pkg/devices/fb/src/lcd/Makefile Sun Jun 11 15:42:11 2023 +0200 +++ b/pkg/devices/fb/src/lcd/Makefile Sun Jun 18 00:19:36 2023 +0200 @@ -4,7 +4,7 @@ TARGET = libdevice_fb_lcd.o.a PC_FILENAME = libdevice-fb-lcd -SRC_CC = fb-lcd.cc +SRC_CC = fb-lcd.cc fb-lcd-run.cc REQUIRES_LIBS = l4re_c l4re_c-util libdevice-fb-server libdevice-lcd diff -r c9a29e1ba843 -r 929b5f0a63e4 pkg/devices/fb/src/lcd/fb-lcd-run.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/pkg/devices/fb/src/lcd/fb-lcd-run.cc Sun Jun 18 00:19:36 2023 +0200 @@ -0,0 +1,50 @@ +/* + * Export the framebuffer as a data space accessible via the "fb" capability. + * + * Copyright (C) 2018, 2023 Paul Boddie + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA + */ + +#include "fb-lcd.h" +#include "fb-lcd-run.h" +#include "fb-run.h" + + + +int fb_lcd_run() +{ + /* Obtain the LCD device. */ + + Lcd_device *lcd_device = Lcd_device::get_device(); + + /* Memory allocation capability for the framebuffer data. */ + + l4re_ds_t mem = lcd_device->get_framebuffer_cap(); + + if (l4_is_invalid_cap(mem)) + return 1; + + /* Enable the LCD device. */ + + lcd_device->enable(); + + /* Initialise and register a server object. */ + + Framebuffer_lcd_server obj(mem, lcd_device); + + return run(&obj); +} diff -r c9a29e1ba843 -r 929b5f0a63e4 pkg/devices/fb/src/lcd/fb-lcd.cc --- a/pkg/devices/fb/src/lcd/fb-lcd.cc Sun Jun 11 15:42:11 2023 +0200 +++ b/pkg/devices/fb/src/lcd/fb-lcd.cc Sun Jun 18 00:19:36 2023 +0200 @@ -1,5 +1,5 @@ /* - * Export the framebuffer as a data space accessible via the "fb" capability. + * Common LCD framebuffer server functionality. * * Copyright (C) 2018, 2023 Paul Boddie * @@ -19,12 +19,7 @@ * Boston, MA 02110-1301, USA */ -#include - -#include - #include "fb-lcd.h" -#include "framebuffer_server.h" @@ -39,36 +34,3 @@ { _device->get_view_info(view_info); } - - - -// Main program. - -int run() -{ - /* Obtain the LCD device. */ - - Lcd_device *lcd_device = Lcd_device::get_device(); - - /* Memory allocation capability for the framebuffer data. */ - - l4re_ds_t mem = lcd_device->get_framebuffer_cap(); - - if (l4_is_invalid_cap(mem)) - return 1; - - /* Enable the LCD device. */ - - lcd_device->enable(); - - /* Initialise and register a server object. */ - - Framebuffer_lcd_server obj(mem, lcd_device); - - /* Bind and start the IPC server loop. */ - - if (ipc_server_loop_for(Framebuffer, &obj, "fb")) - return 1; - - return 0; -} diff -r c9a29e1ba843 -r 929b5f0a63e4 pkg/devices/fb/src/server/Makefile --- a/pkg/devices/fb/src/server/Makefile Sun Jun 11 15:42:11 2023 +0200 +++ b/pkg/devices/fb/src/server/Makefile Sun Jun 18 00:19:36 2023 +0200 @@ -4,10 +4,34 @@ TARGET = libdevice_fb_server.o.a PC_FILENAME = libdevice-fb-server -SRC_CC = fb-server.cc +# Locations for interface input and generated output. + +IDL_DIR = $(PKGDIR)/idl +IDL_MK_DIR = $(L4DIR)/idl4re/mk +IDL_BUILD_DIR = . +IDL_EXPORT_DIR = $(OBJ_BASE)/include/l4/devices/fb + +include $(IDL_MK_DIR)/idl.mk + +# Individual interfaces. + +SERVER_INTERFACES_CC = framebuffer -PRIVATE_INCDIR = $(PKGDIR)/fb/include +# Generated and plain source files. + +SERVER_INTERFACES_SRC_CC = $(call interfaces_to_server_cc,$(SERVER_INTERFACES_CC)) + +PLAIN_SRC_CC = fb-run.cc fb-server.cc -REQUIRES_LIBS = l4re_c l4re_c-util +# Normal definitions. + +SRC_CC = $(SERVER_INTERFACES_SRC_CC) $(PLAIN_SRC_CC) + +REQUIRES_LIBS = l4re_c l4re_c-util libipc + +PRIVATE_INCDIR = $(PKGDIR)/fb/include $(IDL_BUILD_DIR) $(IDL_EXPORT_DIR) include $(L4DIR)/mk/lib.mk +include $(IDL_MK_DIR)/interface_rules.mk + +$(PLAIN_SRC_CC): $(SERVER_INTERFACES_SRC_CC) diff -r c9a29e1ba843 -r 929b5f0a63e4 pkg/devices/fb/src/server/fb-run.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/pkg/devices/fb/src/server/fb-run.cc Sun Jun 18 00:19:36 2023 +0200 @@ -0,0 +1,38 @@ +/* + * Export the framebuffer as a data space accessible via the "fb" capability. + * + * Copyright (C) 2018, 2023 Paul Boddie + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA + */ + +#include "fb-run.h" + +#include + +#include "framebuffer_server.h" + + + +int run(Framebuffer *obj) +{ + /* Bind and start the IPC server loop. */ + + if (ipc_server_loop_for(Framebuffer, obj, "fb")) + return 1; + + return 0; +} diff -r c9a29e1ba843 -r 929b5f0a63e4 pkg/devices/idl/event.idl --- a/pkg/devices/idl/event.idl Sun Jun 11 15:42:11 2023 +0200 +++ b/pkg/devices/idl/event.idl Sun Jun 18 00:19:36 2023 +0200 @@ -1,9 +1,10 @@ -#include +#include -/* An event interface. */ +/* An event interface. + See: pkg/l4re-core/l4re/include/event */ [protocol(L4RE_PROTO_EVENT)] interface Event { - void get_buffer(out cap mem); + [opcode(0)] void get_buffer(out cap mem); }; diff -r c9a29e1ba843 -r 929b5f0a63e4 pkg/devices/idl/input.idl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/pkg/devices/idl/input.idl Sun Jun 18 00:19:36 2023 +0200 @@ -0,0 +1,6 @@ +import "event.idl"; +import "icu.idl"; + +/* An input interface supporting events and IRQ binding. */ + +interface Input composes Event, ICU; diff -r c9a29e1ba843 -r 929b5f0a63e4 pkg/devices/idl/pwm.idl --- a/pkg/devices/idl/pwm.idl Sun Jun 11 15:42:11 2023 +0200 +++ b/pkg/devices/idl/pwm.idl Sun Jun 18 00:19:36 2023 +0200 @@ -1,8 +1,6 @@ #include #include -/* A PWM interface. PWM devices may also support the Activation interface. */ - [protocol(LANDFALL_PWM)] interface PWM { diff -r c9a29e1ba843 -r 929b5f0a63e4 pkg/devices/idl/pwm_object.idl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/pkg/devices/idl/pwm_object.idl Sun Jun 18 00:19:36 2023 +0200 @@ -0,0 +1,4 @@ +import "activation.idl"; +import "pwm.idl"; + +interface PWMObject composes Activation, PWM; diff -r c9a29e1ba843 -r 929b5f0a63e4 pkg/devices/include/protocols.h --- a/pkg/devices/include/protocols.h Sun Jun 11 15:42:11 2023 +0200 +++ b/pkg/devices/include/protocols.h Sun Jun 18 00:19:36 2023 +0200 @@ -25,6 +25,7 @@ #define LANDFALL_BACKLIGHT 0x1f02 #define LANDFALL_CPM 0x1f03 #define LANDFALL_FRAMEBUFFER 0x1f04 +#define LANDFALL_KEYPAD 0x1f05 #define LANDFALL_PWM 0x1f10 #define LANDFALL_SPI 0x1f13 diff -r c9a29e1ba843 -r 929b5f0a63e4 pkg/devices/input/include/Makefile --- a/pkg/devices/input/include/Makefile Sun Jun 11 15:42:11 2023 +0200 +++ b/pkg/devices/input/include/Makefile Sun Jun 18 00:19:36 2023 +0200 @@ -1,6 +1,4 @@ PKGDIR = ../.. L4DIR ?= $(PKGDIR)/../.. -PC_FILENAME := libdevice-input-event-ops - include $(L4DIR)/mk/include.mk diff -r c9a29e1ba843 -r 929b5f0a63e4 pkg/devices/input/include/input-event-client.h --- a/pkg/devices/input/include/input-event-client.h Sun Jun 11 15:42:11 2023 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,43 +0,0 @@ -/* - * Input event client to access input event servers. - * - * Copyright (C) 2018 Paul Boddie - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA - */ - -#pragma once - -#ifdef __cplusplus - -#include -#include -#include -#include -#include -#include - -class Input_event_interface : public L4::Kobject_t > -{ -public: - int bind(unsigned irqnum, L4::Cap irq) throw(); - int get_buffer(L4::Cap mem) throw(); -}; - -#endif diff -r c9a29e1ba843 -r 929b5f0a63e4 pkg/devices/input/include/input-event-loop.h --- a/pkg/devices/input/include/input-event-loop.h Sun Jun 11 15:42:11 2023 +0200 +++ b/pkg/devices/input/include/input-event-loop.h Sun Jun 18 00:19:36 2023 +0200 @@ -52,6 +52,13 @@ { } + explicit Input_event_loop(L4Re::Event_buffer event_buffer, + l4_cap_idx_t irq, + int priority=0x20) + : Event_handler_loop(priority), _event_buffer(event_buffer), _irq(L4::Cap(irq)) + { + } + /* Event handler method, dispatching to the provided handler. */ virtual void handle(); diff -r c9a29e1ba843 -r 929b5f0a63e4 pkg/devices/input/include/input-event-ops.h --- a/pkg/devices/input/include/input-event-ops.h Sun Jun 11 15:42:11 2023 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,49 +0,0 @@ -/* - * Input event server operations. - * - * Copyright (C) 2018 Paul Boddie - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA - */ - -#pragma once - -#include -#include - -enum Input_event_protocols -{ - Input_event_proto_event = L4RE_PROTO_EVENT, - Input_event_proto_icu = L4_PROTO_IRQ, -}; - -enum Input_event_operations -{ - /* Event protocol operations. - NOTE: These definitions should employ the values defined elsewhere. */ - - Input_event_op_get_buffer = 0, - Input_event_op_get_num_streams = 1, - Input_event_op_get_stream_info = 2, - Input_event_op_get_stream_info_for_id = 3, - Input_event_op_get_axis_info = 4, - Input_event_op_get_stream_state_for_id = 5, - - /* IRQ protocol operations. - See: pkg/l4re-core/l4sys/include/icu.h */ - - Input_event_op_bind = L4_ICU_OP_BIND, -}; diff -r c9a29e1ba843 -r 929b5f0a63e4 pkg/devices/input/include/input-event-server.h --- a/pkg/devices/input/include/input-event-server.h Sun Jun 11 15:42:11 2023 +0200 +++ b/pkg/devices/input/include/input-event-server.h Sun Jun 18 00:19:36 2023 +0200 @@ -23,35 +23,38 @@ #ifdef __cplusplus -#include "input-event-client.h" +#include +#include +#include -#include -#include -#include -#include -#include -#include +#include "input_interface.h" + + /* Server object to provide input event source access. */ -class Input_event_server : public L4::Server_object_t +class Input_event_server : public Input { private: - L4::Cap _mem; - L4::Cap _irq; + l4re_ds_t _mem; + l4_cap_idx_t _irq; L4Re::Event_buffer _events; public: /* 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, + explicit Input_event_server(l4re_ds_t mem, L4Re::Event_buffer events) : _mem(mem), _events(events) { } - int dispatch(l4_umword_t obj, L4::Ipc::Iostream &ios); + /* Input event interface operations. */ + + virtual long get_buffer(l4re_ds_t *mem); + + virtual long bind(unsigned int irqnum, l4_cap_idx_t irq); /* Event sending methods. */ diff -r c9a29e1ba843 -r 929b5f0a63e4 pkg/devices/input/include/input-keypad-client.h --- a/pkg/devices/input/include/input-keypad-client.h Sun Jun 11 15:42:11 2023 +0200 +++ b/pkg/devices/input/include/input-keypad-client.h Sun Jun 18 00:19:36 2023 +0200 @@ -22,11 +22,11 @@ #pragma once #include -#include #include #include +#include #include #include @@ -48,9 +48,6 @@ #ifdef __cplusplus -#include -#include - /* Client object to provide input event access. */ class Input_keypad_client @@ -62,7 +59,7 @@ /* Keypad layout details. */ - Keypad *_keypad; + Keypad_generic *_keypad; /* Keypad memory. */ @@ -90,7 +87,7 @@ void scan_keypad(); public: - explicit Input_keypad_client(Keypad *keypad) : _keypad(keypad) + explicit Input_keypad_client(Keypad_generic *keypad) : _keypad(keypad) { init_memory(); init_keypad(); diff -r c9a29e1ba843 -r 929b5f0a63e4 pkg/devices/input/src/Makefile --- a/pkg/devices/input/src/Makefile Sun Jun 11 15:42:11 2023 +0200 +++ b/pkg/devices/input/src/Makefile Sun Jun 18 00:19:36 2023 +0200 @@ -1,8 +1,9 @@ PKGDIR ?= ../.. L4DIR ?= $(PKGDIR)/../.. -TARGET := client keypad server +TARGET := event_loop keypad server include $(L4DIR)/mk/subdir.mk +keypad: event_loop server: keypad diff -r c9a29e1ba843 -r 929b5f0a63e4 pkg/devices/input/src/client/Makefile --- a/pkg/devices/input/src/client/Makefile Sun Jun 11 15:42:11 2023 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,13 +0,0 @@ -PKGDIR ?= ../../.. -L4DIR ?= $(PKGDIR)/../.. - -TARGET = libdevice_input_event_client.o.a -PC_FILENAME := libdevice-input-event-client - -SRC_CC := input-event-client.cc input-event-loop.cc - -PRIVATE_INCDIR += $(PKGDIR)/input/include - -REQUIRES_LIBS := l4re_c l4re_c-util libdrivers-keypad-headers libdevice-util - -include $(L4DIR)/mk/lib.mk diff -r c9a29e1ba843 -r 929b5f0a63e4 pkg/devices/input/src/client/input-event-client.cc --- a/pkg/devices/input/src/client/input-event-client.cc Sun Jun 11 15:42:11 2023 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,53 +0,0 @@ -/* - * Input event client to access input event servers. This is a more narrow - * alternative to the L4Re::Event interface. - * - * Copyright (C) 2018 Paul Boddie - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA - */ - -#include -#include - -#include "input-event-client.h" -#include "input-event-ops.h" - -int -Input_event_interface::get_buffer(L4::Cap mem) throw() -{ - L4::Ipc::Iostream s(l4_utcb()); - - s << Input_event_op_get_buffer; - - /* Send a "receive item" for requesting a capability. */ - - s << L4::Ipc::Small_buf(mem); - - return l4_error(s.call(cap(), Input_event_proto_event)); -} - -int -Input_event_interface::bind(unsigned irqnum, L4::Cap irq) throw() -{ - L4::Ipc::Iostream s(l4_utcb()); - - s << Input_event_op_bind; - s << irqnum; - s << irq; - - return l4_error(s.call(cap(), Input_event_proto_icu)); -} diff -r c9a29e1ba843 -r 929b5f0a63e4 pkg/devices/input/src/client/input-event-loop.cc --- a/pkg/devices/input/src/client/input-event-loop.cc Sun Jun 11 15:42:11 2023 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,51 +0,0 @@ -/* - * Input event loop functionality. - * - * Copyright (C) 2018 Paul Boddie - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA - */ - -#include "input-event-loop.h" - -#include - -/* Handler for incoming interrupts signalling the presence of events. */ - -void -Input_event_loop::handle() -{ - Event_type *event; - - if (!l4_error(_irq->receive())) - { - while ((event = _event_buffer.next())) - { - _handler(*event); - event->free(); - } - } -} - -/* Event loop initiation. */ - -void -Input_event_loop::start(l4_umword_t label) -{ - Event_loop::start(); - - _irq->bind_thread(Pthread::L4::cap(_pthread), label); -} diff -r c9a29e1ba843 -r 929b5f0a63e4 pkg/devices/input/src/event_loop/Makefile --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/pkg/devices/input/src/event_loop/Makefile Sun Jun 18 00:19:36 2023 +0200 @@ -0,0 +1,13 @@ +PKGDIR ?= ../../.. +L4DIR ?= $(PKGDIR)/../.. + +TARGET = libdevice_input_event_loop.o.a +PC_FILENAME = libdevice-input-event-loop + +SRC_CC = input-event-loop.cc + +PRIVATE_INCDIR = $(PKGDIR)/input/include + +REQUIRES_LIBS = l4re_c l4re_c-util libdrivers-keypad-headers libdevice-util + +include $(L4DIR)/mk/lib.mk diff -r c9a29e1ba843 -r 929b5f0a63e4 pkg/devices/input/src/event_loop/input-event-loop.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/pkg/devices/input/src/event_loop/input-event-loop.cc Sun Jun 18 00:19:36 2023 +0200 @@ -0,0 +1,51 @@ +/* + * Input event loop functionality. + * + * Copyright (C) 2018 Paul Boddie + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA + */ + +#include "input-event-loop.h" + +#include + +/* Handler for incoming interrupts signalling the presence of events. */ + +void +Input_event_loop::handle() +{ + Event_type *event; + + if (!l4_error(_irq->receive())) + { + while ((event = _event_buffer.next())) + { + _handler(*event); + event->free(); + } + } +} + +/* Event loop initiation. */ + +void +Input_event_loop::start(l4_umword_t label) +{ + Event_loop::start(); + + _irq->bind_thread(Pthread::L4::cap(_pthread), label); +} diff -r c9a29e1ba843 -r 929b5f0a63e4 pkg/devices/input/src/keypad/Makefile --- a/pkg/devices/input/src/keypad/Makefile Sun Jun 11 15:42:11 2023 +0200 +++ b/pkg/devices/input/src/keypad/Makefile Sun Jun 18 00:19:36 2023 +0200 @@ -4,10 +4,34 @@ TARGET = libinput_keypad.o.a PC_FILENAME = libdevice-input-keypad -SRC_CC = input-keypad-client.cc +# Locations for interface input and generated output. + +IDL_DIR = $(PKGDIR)/idl +IDL_MK_DIR = $(L4DIR)/idl4re/mk +IDL_BUILD_DIR = . +IDL_EXPORT_DIR = . + +include $(IDL_MK_DIR)/idl.mk + +# Individual interfaces. + +CLIENT_INTERFACES_CC = keypad -PRIVATE_INCDIR = $(PKGDIR)/input/include +# Generated and plain source files. + +CLIENT_INTERFACES_SRC_CC = $(call interfaces_to_client_cc,$(CLIENT_INTERFACES_CC)) + +PLAIN_SRC_CC = input-keypad-client.cc -REQUIRES_LIBS = l4re_c l4re_c-util libdrivers-keypad-headers libdevice-keypad-client +# Normal definitions. + +SRC_CC = $(CLIENT_INTERFACES_SRC_CC) $(PLAIN_SRC_CC) + +PRIVATE_INCDIR = $(PKGDIR)/input/include $(IDL_BUILD_DIR) $(IDL_EXPORT_DIR) + +REQUIRES_LIBS = l4re_c l4re_c-util libdrivers-keypad-headers libdevice-input-event-loop libipc include $(L4DIR)/mk/lib.mk +include $(IDL_MK_DIR)/interface_rules.mk + +$(PLAIN_SRC_CC): $(CLIENT_INTERFACES_SRC_CC) diff -r c9a29e1ba843 -r 929b5f0a63e4 pkg/devices/input/src/keypad/input-keypad-client.cc --- a/pkg/devices/input/src/keypad/input-keypad-client.cc Sun Jun 11 15:42:11 2023 +0200 +++ b/pkg/devices/input/src/keypad/input-keypad-client.cc Sun Jun 18 00:19:36 2023 +0200 @@ -35,7 +35,7 @@ #include -#include "keypad_interface.h" +#include "keypad_client.h" @@ -57,17 +57,11 @@ void Input_keypad_client::init_keypad_data() { - if (l4_is_invalid_cap(_mem)) - return; - - if (l4_is_invalid_cap(_keypad_server)) - return; - /* Obtain a reference to the keypad data. */ client_Keypad keypad(_keypad_cap); - if (keypad.get_keypad_data(_mem)) + if (keypad.get_keypad_data(&_mem)) return; /* Attach the keypad data to a region in this task. */ diff -r c9a29e1ba843 -r 929b5f0a63e4 pkg/devices/input/src/server/Makefile --- a/pkg/devices/input/src/server/Makefile Sun Jun 11 15:42:11 2023 +0200 +++ b/pkg/devices/input/src/server/Makefile Sun Jun 18 00:19:36 2023 +0200 @@ -2,12 +2,36 @@ L4DIR ?= $(PKGDIR)/../.. TARGET = dev_input_keypad -PC_FILENAME := devices-input-keypad-server +PC_FILENAME = devices-input-keypad-server + +# Locations for interface input and generated output. -SRC_CC := input-keypad-server.cc +IDL_DIR = $(PKGDIR)/idl +IDL_MK_DIR = $(L4DIR)/idl4re/mk +IDL_BUILD_DIR = . +IDL_EXPORT_DIR = . + +include $(IDL_MK_DIR)/idl.mk + +# Individual interfaces. -PRIVATE_INCDIR += $(PKGDIR)/input/include +SERVER_INTERFACES_CC = input + +# Generated and plain source files. + +SERVER_INTERFACES_SRC_CC = $(call interfaces_to_server_cc,$(SERVER_INTERFACES_CC)) + +PLAIN_SRC_CC = input-event-server.cc input-keypad-server.cc -REQUIRES_LIBS := l4re_c l4re_c-util libdevice-input-keypad libdrivers-keypad-loader libdevice-util +# Normal definitions. + +SRC_CC = $(SERVER_INTERFACES_SRC_CC) $(PLAIN_SRC_CC) + +PRIVATE_INCDIR = $(PKGDIR)/input/include $(IDL_BUILD_DIR) $(IDL_EXPORT_DIR) + +REQUIRES_LIBS = l4re_c l4re_c-util libdevice-input-keypad libdrivers-keypad-loader libdevice-util libipc include $(L4DIR)/mk/prog.mk +include $(IDL_MK_DIR)/interface_rules.mk + +$(PLAIN_SRC_CC): $(SERVER_INTERFACES_SRC_CC) diff -r c9a29e1ba843 -r 929b5f0a63e4 pkg/devices/input/src/server/input-event-server.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/pkg/devices/input/src/server/input-event-server.cc Sun Jun 18 00:19:36 2023 +0200 @@ -0,0 +1,67 @@ +/* + * Provide access to keypad events on the configured device. + * + * Copyright (C) 2018, 2023 Paul Boddie + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA + */ + +#include "input-event-server.h" + +#include +#include +#include + + + +/* Reset the buffer state and return the buffer memory capability. */ + +long Input_event_server::get_buffer(l4re_ds_t *mem) +{ + _events.reset(); + *mem = _mem; + return L4_EOK; +} + +/* Obtain the interrupt capability. */ + +long Input_event_server::bind(unsigned int irqnum, l4_cap_idx_t irq) +{ + (void) irqnum; + + _irq = irq; + return L4_EOK; +} + + + +/* Event sending methods. */ + +void Input_event_server::send_event(int type, int code, int value) +{ + L4Re::Event_buffer::Event event; + + event.time = l4_kip_clock(l4re_kip()); + event.payload.stream_id = 0; + event.payload.type = type; + event.payload.code = code; + event.payload.value = value; + + /* Queue the event and trigger the interrupt. */ + + _events.put(event); + l4_irq_trigger(_irq); +} diff -r c9a29e1ba843 -r 929b5f0a63e4 pkg/devices/input/src/server/input-keypad-server.cc --- a/pkg/devices/input/src/server/input-keypad-server.cc Sun Jun 11 15:42:11 2023 +0200 +++ b/pkg/devices/input/src/server/input-keypad-server.cc Sun Jun 18 00:19:36 2023 +0200 @@ -1,7 +1,7 @@ /* * Provide access to keypad events on the configured device. * - * Copyright (C) 2018 Paul Boddie + * Copyright (C) 2018, 2023 Paul Boddie * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -21,123 +21,16 @@ #include #include -#include "input-event-client.h" + #include "input-event-server.h" -#include "input-event-ops.h" #include "input-keypad-client.h" -#include -#include -#include #include -#include -#include -#include -#include -#include -#include -#include -#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 -Input_event_server::dispatch(l4_umword_t obj, L4::Ipc::Iostream &ios) -{ - l4_msgtag_t tag; - l4_umword_t op; - unsigned irqnum; - L4::Ipc::Snd_fpage fpage; - - (void) obj; - ios >> tag; - - switch (tag.label()) - { - case L4::Meta::Protocol: - return L4::Util::handle_meta_request(ios); - case L4RE_PROTO_EVENT: - ios >> op; - switch (op) - { - /* Reset the buffer state and return the buffer memory capability. */ - - case Input_event_op_get_buffer: - _events.reset(); - ios << _mem; - return L4_EOK; - - default: - return -L4_EINVAL; - } - - case L4_PROTO_IRQ: - ios >> op; - switch (op) - { - /* Just obtain the interrupt capability. */ - - case Input_event_op_bind: - ios >> irqnum; - get_fpage(ios, fpage); - - if (!fpage.cap_received()) - return -L4_EINVAL; +#include +#include - _irq = server_iface()->rcv_cap(0); - return server_iface()->realloc_rcv_cap(0); - - default: - return -L4_EINVAL; - } - - default: - return -L4_EBADPROTO; - } -} - - - -/* Event sending methods. */ - -void -Input_event_server::send_event(int type, int code, int value) -{ - L4Re::Event_buffer::Event event; - - event.time = l4_kip_clock(l4re_kip()); - event.payload.stream_id = 0; - event.payload.type = type; - event.payload.code = code; - event.payload.value = value; - - /* Queue the event and trigger the interrupt. */ - - _events.put(event); - _irq->trigger(); -} +#include "input_server.h" @@ -150,43 +43,44 @@ -static L4Re::Util::Registry_server server; - - - int main(void) { - // Load the keypad details from the configured library. + /* Load the keypad details from the configured library. */ - Keypad *keypad = load_keypad(); + Keypad_generic *keypad = load_keypad(); Input_keypad_client client(keypad); void *buffer; - // Memory allocation capability for the event data. + /* Memory allocation capability for the event data. */ - L4::Cap mem = allocate_data(L4_PAGESIZE, &buffer); - if (!mem.is_valid()) return 1; + l4re_ds_t mem = allocate_data(L4_PAGESIZE, &buffer); + + if (l4_is_invalid_cap(mem)) + return 1; /* Obtain a capability for the interrupt. */ - L4::Cap irq = L4Re::Util::cap_alloc.alloc(); - if (!irq.is_valid()) return 1; + l4_cap_idx_t irq = ipc_cap_alloc(); - // Event buffer for the data. + if (l4_is_invalid_cap(irq)) + return 1; + + /* Event buffer for the data. */ L4Re::Event_buffer events(buffer, L4_PAGESIZE); - // Initialise and register a server object. + /* Initialise and register a server object. */ - Input_event_server server_obj(mem, events); - server.registry()->register_obj(&server_obj, "ev"); + Input_event_server obj(mem, events); + + /* Attach the event handler and wait for events. */ - // Attach the event handler and wait for events. + client.attach(handler, (void *) &obj); - client.attach(handler, (void *) &server_obj); + /* Bind and start the IPC server loop. */ - // Enter the IPC server loop. + if (ipc_server_loop_for(Input, &obj, "ev")) + return 1; - server.loop(); return 0; } diff -r c9a29e1ba843 -r 929b5f0a63e4 pkg/devices/keypad/include/Makefile --- a/pkg/devices/keypad/include/Makefile Sun Jun 11 15:42:11 2023 +0200 +++ b/pkg/devices/keypad/include/Makefile Sun Jun 18 00:19:36 2023 +0200 @@ -1,6 +1,4 @@ PKGDIR = ../.. L4DIR ?= $(PKGDIR)/../.. -PC_FILENAME := libdevice-keypad-ops - include $(L4DIR)/mk/include.mk diff -r c9a29e1ba843 -r 929b5f0a63e4 pkg/devices/keypad/include/keypad-client.h --- a/pkg/devices/keypad/include/keypad-client.h Sun Jun 11 15:42:11 2023 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,38 +0,0 @@ -/* - * Keypad client to access keypad servers. - * - * Copyright (C) 2018 Paul Boddie - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA - */ - -#pragma once - -#ifdef __cplusplus - -#include -#include -#include "keypad-ops.h" - -class Keypad_device_interface : public L4::Kobject_t -{ - L4_KOBJECT(Keypad_device_interface) - -public: - int get_keypad_data(L4::Cap mem) throw(); -}; - -#endif diff -r c9a29e1ba843 -r 929b5f0a63e4 pkg/devices/keypad/include/keypad-ops.h --- a/pkg/devices/keypad/include/keypad-ops.h Sun Jun 11 15:42:11 2023 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,24 +0,0 @@ -/* - * Keypad server operations. - * - * Copyright (C) 2018 Paul Boddie - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA - */ - -#pragma once - -enum { Keypad_op_get_keypad_data }; diff -r c9a29e1ba843 -r 929b5f0a63e4 pkg/devices/keypad/include/keypad-run.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/pkg/devices/keypad/include/keypad-run.h Sun Jun 18 00:19:36 2023 +0200 @@ -0,0 +1,26 @@ +/* + * Common keypad server functionality. + * + * Copyright (C) 2023 Paul Boddie + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA + */ + +#pragma once + +#include + +long run(l4re_ds_t mem); diff -r c9a29e1ba843 -r 929b5f0a63e4 pkg/devices/keypad/include/keypad-server.h --- a/pkg/devices/keypad/include/keypad-server.h Sun Jun 11 15:42:11 2023 +0200 +++ b/pkg/devices/keypad/include/keypad-server.h Sun Jun 18 00:19:36 2023 +0200 @@ -23,7 +23,7 @@ #include -#include +#include "keypad_interface.h" diff -r c9a29e1ba843 -r 929b5f0a63e4 pkg/devices/keypad/src/Makefile --- a/pkg/devices/keypad/src/Makefile Sun Jun 11 15:42:11 2023 +0200 +++ b/pkg/devices/keypad/src/Makefile Sun Jun 18 00:19:36 2023 +0200 @@ -1,7 +1,7 @@ PKGDIR ?= ../.. L4DIR ?= $(PKGDIR)/../.. -TARGET := client letux400 qi_lb60 server +TARGET := letux400 qi_lb60 server include $(L4DIR)/mk/subdir.mk diff -r c9a29e1ba843 -r 929b5f0a63e4 pkg/devices/keypad/src/client/Makefile --- a/pkg/devices/keypad/src/client/Makefile Sun Jun 11 15:42:11 2023 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,13 +0,0 @@ -PKGDIR ?= ../../.. -L4DIR ?= $(PKGDIR)/../.. - -TARGET = libdevice_keypad_client.o.a -PC_FILENAME := libdevice-keypad-client - -SRC_CC := keypad-client.cc - -PRIVATE_INCDIR += $(PKGDIR)/keypad/include - -REQUIRES_LIBS := l4re_c l4re_c-util - -include $(L4DIR)/mk/lib.mk diff -r c9a29e1ba843 -r 929b5f0a63e4 pkg/devices/keypad/src/client/keypad-client.cc --- a/pkg/devices/keypad/src/client/keypad-client.cc Sun Jun 11 15:42:11 2023 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,37 +0,0 @@ -/* - * Keypad client to access keypad servers. - * - * Copyright (C) 2018 Paul Boddie - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA - */ - -#include -#include - -#include "keypad-client.h" - -int -Keypad_device_interface::get_keypad_data(L4::Cap mem) throw() -{ - L4::Ipc::Iostream s(l4_utcb()); - - /* Send a "receive item" for requesting a capability. */ - - s << L4::Ipc::Small_buf(mem); - - return l4_error(s.call(cap(), Keypad_op_get_keypad_data)); -} diff -r c9a29e1ba843 -r 929b5f0a63e4 pkg/devices/keypad/src/letux400/Makefile --- a/pkg/devices/keypad/src/letux400/Makefile Sun Jun 11 15:42:11 2023 +0200 +++ b/pkg/devices/keypad/src/letux400/Makefile Sun Jun 18 00:19:36 2023 +0200 @@ -2,12 +2,12 @@ L4DIR ?= $(PKGDIR)/../.. TARGET = dev_keypad_letux400 -PC_FILENAME := devices-keypad-letux400 +PC_FILENAME = devices-keypad-letux400 -SRC_CC := keypad-letux400.cc +SRC_CC = keypad-letux400.cc -PRIVATE_INCDIR += $(PKGDIR)/keypad/include +PRIVATE_INCDIR = $(PKGDIR)/keypad/include -REQUIRES_LIBS := l4re_c l4re_c-util libdrivers-gpio libdevice-util libdevice-keypad-server +REQUIRES_LIBS = l4re_c l4re_c-util libdrivers-gpio libdevice-util libdevice-keypad-server include $(L4DIR)/mk/prog.mk diff -r c9a29e1ba843 -r 929b5f0a63e4 pkg/devices/keypad/src/letux400/keypad-letux400.cc --- a/pkg/devices/keypad/src/letux400/keypad-letux400.cc Sun Jun 11 15:42:11 2023 +0200 +++ b/pkg/devices/keypad/src/letux400/keypad-letux400.cc Sun Jun 18 00:19:36 2023 +0200 @@ -2,7 +2,7 @@ * Export the keypad GPIOs on the Letux 400 as a data space accessible via the * "keypad" capability. * - * Copyright (C) 2018 Paul Boddie + * Copyright (C) 2018, 2023 Paul Boddie * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -23,17 +23,19 @@ #include #include #include -#include "keypad-server.h" -#include "keypad-event-loop.h" -#include -#include -#include +#include +#include #include #include +#include "keypad-event-loop.h" +#include "keypad-run.h" + + + enum Jz4730_keypad_gpio { Jz4730_keypad_gpio_inputs_count = 8, @@ -128,24 +130,20 @@ -static L4Re::Util::Registry_server<> server; - - - /* Main program. */ int main(void) { + if (setup_memory()) + return 1; + /* Memory allocation capability for the keypad data. */ - L4::Cap mem; l4_size_t mem_size = Jz4730_keypad_gpio_outputs_count * sizeof(uint32_t); + l4re_ds_t mem = allocate_data(mem_size, &keymem); - if (setup_memory()) return 1; - - mem = allocate_data(mem_size, &keymem); - - if (!mem.is_valid()) return 1; + if (l4_is_invalid_cap(mem)) + return 1; keypad = (uint32_t *) keymem; @@ -159,13 +157,7 @@ loop.attach(scan_keypad); loop.start(); - /* Initialise and register a server object. */ - - Keypad_server server_obj(mem); - server.registry()->register_obj(&server_obj, "keypad"); + /* Start a server using the common server functionality. */ - /* Enter the IPC server loop. */ - - server.loop(); - return 0; + return run(mem); } diff -r c9a29e1ba843 -r 929b5f0a63e4 pkg/devices/keypad/src/qi_lb60/Makefile --- a/pkg/devices/keypad/src/qi_lb60/Makefile Sun Jun 11 15:42:11 2023 +0200 +++ b/pkg/devices/keypad/src/qi_lb60/Makefile Sun Jun 18 00:19:36 2023 +0200 @@ -2,12 +2,12 @@ L4DIR ?= $(PKGDIR)/../.. TARGET = dev_keypad_qi_lb60 -PC_FILENAME := devices-keypad-qi_lb60 +PC_FILENAME = devices-keypad-qi_lb60 -SRC_CC := keypad-qi_lb60.cc +SRC_CC = keypad-qi_lb60.cc -PRIVATE_INCDIR += $(PKGDIR)/keypad/include +PRIVATE_INCDIR = $(PKGDIR)/keypad/include -REQUIRES_LIBS := l4re_c l4re_c-util libdrivers-gpio libdevice-util libdevice-keypad-server +REQUIRES_LIBS = l4re_c l4re_c-util libdrivers-gpio libdevice-util libdevice-keypad-server include $(L4DIR)/mk/prog.mk diff -r c9a29e1ba843 -r 929b5f0a63e4 pkg/devices/keypad/src/qi_lb60/keypad-qi_lb60.cc --- a/pkg/devices/keypad/src/qi_lb60/keypad-qi_lb60.cc Sun Jun 11 15:42:11 2023 +0200 +++ b/pkg/devices/keypad/src/qi_lb60/keypad-qi_lb60.cc Sun Jun 18 00:19:36 2023 +0200 @@ -2,7 +2,7 @@ * Export the keypad GPIOs on the Ben NanoNote as a data space accessible via * the "keypad" capability. * - * Copyright (C) 2018 Paul Boddie + * Copyright (C) 2018, 2023 Paul Boddie * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -23,17 +23,17 @@ #include #include #include -#include "keypad-server.h" -#include "keypad-event-loop.h" - -#include -#include -#include - +#include +#include #include #include +#include "keypad-event-loop.h" +#include "keypad-run.h" + + + enum Jz4740_keypad_gpio { Jz4740_keypad_gpio_inputs_count = 8, @@ -128,24 +128,20 @@ -static L4Re::Util::Registry_server<> server; - - - /* Main program. */ int main(void) { + if (setup_memory()) + return 1; + /* Memory allocation capability for the keypad data. */ - L4::Cap mem; l4_size_t mem_size = Jz4740_keypad_gpio_outputs_count * sizeof(uint32_t); + l4re_ds_t mem = allocate_data(mem_size, &keymem); - if (setup_memory()) return 1; - - mem = allocate_data(mem_size, &keymem); - - if (!mem.is_valid()) return 1; + if (l4_is_invalid_cap(mem)) + return 1; keypad = (uint32_t *) keymem; @@ -159,13 +155,7 @@ loop.attach(scan_keypad); loop.start(); - /* Initialise and register a server object. */ - - Keypad_server server_obj(mem); - server.registry()->register_obj(&server_obj, "keypad"); + /* Start a server using the common server functionality. */ - /* Enter the IPC server loop. */ - - server.loop(); - return 0; + return run(mem); } diff -r c9a29e1ba843 -r 929b5f0a63e4 pkg/devices/keypad/src/server/Makefile --- a/pkg/devices/keypad/src/server/Makefile Sun Jun 11 15:42:11 2023 +0200 +++ b/pkg/devices/keypad/src/server/Makefile Sun Jun 18 00:19:36 2023 +0200 @@ -2,12 +2,36 @@ L4DIR ?= $(PKGDIR)/../.. TARGET = libdevice_keypad_server.o.a -PC_FILENAME := libdevice-keypad-server +PC_FILENAME = libdevice-keypad-server + +# Locations for interface input and generated output. -SRC_CC := keypad-server.cc +IDL_DIR = $(PKGDIR)/idl +IDL_MK_DIR = $(L4DIR)/idl4re/mk +IDL_BUILD_DIR = . +IDL_EXPORT_DIR = . + +include $(IDL_MK_DIR)/idl.mk + +# Individual interfaces. -PRIVATE_INCDIR += $(PKGDIR)/keypad/include +SERVER_INTERFACES_CC = keypad + +# Generated and plain source files. + +SERVER_INTERFACES_SRC_CC = $(call interfaces_to_server_cc,$(SERVER_INTERFACES_CC)) + +PLAIN_SRC_CC = keypad-run.cc keypad-server.cc -REQUIRES_LIBS := l4re_c l4re_c-util +# Normal definitions. + +SRC_CC = $(SERVER_INTERFACES_SRC_CC) $(PLAIN_SRC_CC) + +REQUIRES_LIBS = l4re_c l4re_c-util libipc + +PRIVATE_INCDIR = $(PKGDIR)/keypad/include $(IDL_BUILD_DIR) $(IDL_EXPORT_DIR) include $(L4DIR)/mk/lib.mk +include $(IDL_MK_DIR)/interface_rules.mk + +$(PLAIN_SRC_CC): $(SERVER_INTERFACES_SRC_CC) diff -r c9a29e1ba843 -r 929b5f0a63e4 pkg/devices/keypad/src/server/keypad-run.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/pkg/devices/keypad/src/server/keypad-run.cc Sun Jun 18 00:19:36 2023 +0200 @@ -0,0 +1,49 @@ +/* + * Common keypad server functionality. + * + * Copyright (C) 2023 Paul Boddie + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA + */ + +/* Common server functionality. */ + +#include "keypad-server.h" + +/* Server infrastructure. */ + +#include +#include "keypad_server.h" + +#include "keypad-run.h" + + + +/* Main program. */ + +long run(l4re_ds_t mem) +{ + /* Initialise and register a server object. */ + + Keypad_server obj(mem); + + /* Bind and start the IPC server loop. */ + + if (ipc_server_loop_for(Keypad, &obj, "keypad")) + return 1; + + return 0; +} diff -r c9a29e1ba843 -r 929b5f0a63e4 pkg/devices/lcd/include/lcd-ci20.h --- a/pkg/devices/lcd/include/lcd-ci20.h Sun Jun 11 15:42:11 2023 +0200 +++ b/pkg/devices/lcd/include/lcd-ci20.h Sun Jun 18 00:19:36 2023 +0200 @@ -1,7 +1,7 @@ /* * LCD device support for the MIPS Creator CI20. * - * Copyright (C) 2018, 2020 Paul Boddie + * Copyright (C) 2018, 2020, 2023 Paul Boddie * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -21,7 +21,7 @@ #pragma once -#include "lcd-jz4740-device.h" +#include #ifdef __cplusplus diff -r c9a29e1ba843 -r 929b5f0a63e4 pkg/devices/lcd/include/lcd-device.h --- a/pkg/devices/lcd/include/lcd-device.h Sun Jun 11 15:42:11 2023 +0200 +++ b/pkg/devices/lcd/include/lcd-device.h Sun Jun 18 00:19:36 2023 +0200 @@ -31,9 +31,8 @@ #ifdef __cplusplus -#include -#include -#include +#include +#include class Lcd_device { @@ -49,11 +48,11 @@ /* Framebuffer virtual and physical addresses. */ l4_addr_t fb_vaddr; - L4Re::Dma_space::Dma_addr fb_paddr; + l4re_dma_space_dma_addr_t fb_paddr; /* Memory capability for the framebuffer. */ - L4::Cap _fbmem; + l4re_ds_t _fbmem; /* Display operations. */ @@ -76,7 +75,7 @@ return fb_vaddr; } - virtual L4::Cap get_framebuffer_cap() + virtual l4re_ds_t get_framebuffer_cap() { return _fbmem; } diff -r c9a29e1ba843 -r 929b5f0a63e4 pkg/devices/lcd/include/lcd-jz4740-device.h --- a/pkg/devices/lcd/include/lcd-jz4740-device.h Sun Jun 11 15:42:11 2023 +0200 +++ b/pkg/devices/lcd/include/lcd-jz4740-device.h Sun Jun 18 00:19:36 2023 +0200 @@ -22,10 +22,9 @@ #pragma once #include +#include -#include "lcd-device.h" - -#include +#include #include #include @@ -42,7 +41,7 @@ /* DMA descriptor virtual and physical addresses. */ l4_addr_t desc_vaddr; - L4Re::Dma_space::Dma_addr desc_paddr; + l4re_dma_space_dma_addr_t desc_paddr; protected: /* Device-specific memory allocation. */ diff -r c9a29e1ba843 -r 929b5f0a63e4 pkg/devices/lcd/include/lcd-letux400.h --- a/pkg/devices/lcd/include/lcd-letux400.h Sun Jun 11 15:42:11 2023 +0200 +++ b/pkg/devices/lcd/include/lcd-letux400.h Sun Jun 18 00:19:36 2023 +0200 @@ -1,7 +1,7 @@ /* * LCD device support for the Letux 400 notebook computer. * - * Copyright (C) 2018, 2020 Paul Boddie + * Copyright (C) 2018, 2020, 2023 Paul Boddie * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -21,7 +21,7 @@ #pragma once -#include "lcd-jz4740-device.h" +#include #ifdef __cplusplus diff -r c9a29e1ba843 -r 929b5f0a63e4 pkg/devices/lcd/include/lcd-qi_lb60.h --- a/pkg/devices/lcd/include/lcd-qi_lb60.h Sun Jun 11 15:42:11 2023 +0200 +++ b/pkg/devices/lcd/include/lcd-qi_lb60.h Sun Jun 18 00:19:36 2023 +0200 @@ -1,7 +1,7 @@ /* * LCD device support for the Ben NanoNote. * - * Copyright (C) 2018, 2020 Paul Boddie + * Copyright (C) 2018, 2020, 2023 Paul Boddie * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -21,7 +21,7 @@ #pragma once -#include "lcd-jz4740-device.h" +#include #ifdef __cplusplus diff -r c9a29e1ba843 -r 929b5f0a63e4 pkg/devices/lcd/src/common/Makefile --- a/pkg/devices/lcd/src/common/Makefile Sun Jun 11 15:42:11 2023 +0200 +++ b/pkg/devices/lcd/src/common/Makefile Sun Jun 18 00:19:36 2023 +0200 @@ -17,11 +17,15 @@ CLIENT_INTERFACES_CC = activation +# Generated and plain source files. + EXPORTED_INTERFACES_H = $(call exported_interfaces_h,$(CLIENT_INTERFACES_CC)) +PLAIN_SRC_CC = lcd-device.cc + # Normal definitions. -SRC_CC = lcd-device.cc +SRC_CC = $(PLAIN_SRC_CC) REQUIRES_LIBS = l4re_c l4re_c-util libdrivers-lcd-headers @@ -30,4 +34,4 @@ include $(L4DIR)/mk/lib.mk include $(IDL_MK_DIR)/interface_rules.mk -$(SRC_CC): $(EXPORTED_INTERFACES_H) +$(PLAIN_SRC_CC): $(EXPORTED_INTERFACES_H) diff -r c9a29e1ba843 -r 929b5f0a63e4 pkg/devices/lcd/src/jz4740/Makefile --- a/pkg/devices/lcd/src/jz4740/Makefile Sun Jun 11 15:42:11 2023 +0200 +++ b/pkg/devices/lcd/src/jz4740/Makefile Sun Jun 18 00:19:36 2023 +0200 @@ -30,7 +30,7 @@ REQUIRES_LIBS = \ l4re_c l4re_c-util \ libdevice-lcd libdrivers-lcd-jz4740 libdrivers-panel-loader \ - libdevice-util libipc + libdevice-util PRIVATE_INCDIR = $(PKGDIR)/lcd/include $(IDL_BUILD_DIR) $(IDL_EXPORT_DIR) diff -r c9a29e1ba843 -r 929b5f0a63e4 pkg/devices/lcd/src/jz4740/lcd-jz4740-device.cc --- a/pkg/devices/lcd/src/jz4740/lcd-jz4740-device.cc Sun Jun 11 15:42:11 2023 +0200 +++ b/pkg/devices/lcd/src/jz4740/lcd-jz4740-device.cc Sun Jun 18 00:19:36 2023 +0200 @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -144,10 +145,14 @@ // Create the DMA space. dma = ipc_cap_alloc(); - if (l4_is_invalid_cap(dma)) return 1; + + if (l4_is_invalid_cap(dma)) + return 1; vbus = l4re_env_get_cap("vbus"); - if (l4_is_invalid_cap(vbus)) return 1; + + if (l4_is_invalid_cap(vbus)) + return 1; if (l4_error(l4_factory_create(l4re_env()->mem_alloc, L4RE_PROTO_DMA_SPACE, dma))) return 1; @@ -176,16 +181,23 @@ // NOTE: necessitate 64 word alignment for the framebuffer. const l4_size_t alloc_flags = L4RE_MA_CONTINUOUS | L4RE_MA_PINNED; + const l4re_rm_flags_t attach_flags = L4RE_RM_F_SEARCH_ADDR | L4RE_RM_F_RW; // Map the allocated memory, obtaining virtual addresses. fb_vaddr = 0; desc_vaddr = 0; - if (ipc_allocate_align(fb_size, alloc_flags, 8, &fb_vaddr, &_fbmem)) + if (ipc_new_dataspace(fb_size, alloc_flags, 8, &_fbmem)) return 1; - if (ipc_allocate_align(desc_size, alloc_flags, 6, &desc_vaddr, &descmem)) + if (ipc_new_dataspace(desc_size, alloc_flags, 6, &descmem)) + return 1; + + if (ipc_attach_dataspace_align(_fbmem, fb_size, attach_flags, 8, (void **) &fb_vaddr)) + return 1; + + if (ipc_attach_dataspace_align(descmem, desc_size, attach_flags, 6, (void **) &desc_vaddr)) return 1; // Obtain physical addresses for the framebuffer and descriptors. @@ -201,7 +213,7 @@ return 1; if (l4re_dma_space_map(dma, descmem | L4_CAP_FPAGE_RW, 0, &desc_size_out, 0, - L4RE_DMA_SPACE_TO_DEVICE, &desc_paddr)) + L4RE_DMA_SPACE_TO_DEVICE, &desc_paddr)) return 1; // Test the mapped region sizes. diff -r c9a29e1ba843 -r 929b5f0a63e4 pkg/devices/lib/keypad/include/keypad-common.h --- a/pkg/devices/lib/keypad/include/keypad-common.h Sun Jun 11 15:42:11 2023 +0200 +++ b/pkg/devices/lib/keypad/include/keypad-common.h Sun Jun 18 00:19:36 2023 +0200 @@ -29,26 +29,26 @@ void *keypad_get(void) { - return reinterpret_cast(Keypad::get_keypad()); + return reinterpret_cast(Keypad_generic::get_keypad()); } /* Number of keypad columns. */ int keypad_columns(void *keypad) { - return static_cast(keypad)->columns(); + return static_cast(keypad)->columns(); } /* Number of keypad rows, used by each value in the column array. */ int keypad_rows(void *keypad) { - return static_cast(keypad)->rows(); + return static_cast(keypad)->rows(); } /* Keycode accessors. */ int keypad_code(void *keypad, int column, int row) { - return static_cast(keypad)->code(column, row); + return static_cast(keypad)->code(column, row); } diff -r c9a29e1ba843 -r 929b5f0a63e4 pkg/devices/lib/keypad/include/keypad-loader.h --- a/pkg/devices/lib/keypad/include/keypad-loader.h Sun Jun 11 15:42:11 2023 +0200 +++ b/pkg/devices/lib/keypad/include/keypad-loader.h Sun Jun 18 00:19:36 2023 +0200 @@ -23,4 +23,4 @@ #include "keypad.h" -Keypad *load_keypad(); +Keypad_generic *load_keypad(); diff -r c9a29e1ba843 -r 929b5f0a63e4 pkg/devices/lib/keypad/include/keypad.h --- a/pkg/devices/lib/keypad/include/keypad.h Sun Jun 11 15:42:11 2023 +0200 +++ b/pkg/devices/lib/keypad/include/keypad.h Sun Jun 18 00:19:36 2023 +0200 @@ -1,7 +1,7 @@ /* * Keypad description access. * - * Copyright (C) 2018 Paul Boddie + * Copyright (C) 2018, 2023 Paul Boddie * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -25,13 +25,13 @@ #ifdef __cplusplus -class Keypad +class Keypad_generic { public: virtual int columns(void) = 0; virtual int rows(void) = 0; virtual int code(int column, int row) = 0; - static Keypad *get_keypad(); + static Keypad_generic *get_keypad(); }; #endif diff -r c9a29e1ba843 -r 929b5f0a63e4 pkg/devices/lib/keypad/src/letux400/keypad-letux400.cc --- a/pkg/devices/lib/keypad/src/letux400/keypad-letux400.cc Sun Jun 11 15:42:11 2023 +0200 +++ b/pkg/devices/lib/keypad/src/letux400/keypad-letux400.cc Sun Jun 18 00:19:36 2023 +0200 @@ -1,7 +1,7 @@ /* * Letux 400 key mapping. * - * Copyright (C) 2018 Paul Boddie + * Copyright (C) 2018, 2023 Paul Boddie * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -29,7 +29,7 @@ Jz4730_keypad_gpio_outputs_count = 17, }; -class Keypad_letux400 : public Keypad +class Keypad_letux400 : public Keypad_generic { /* Keycode definitions. */ @@ -100,7 +100,7 @@ /* Definition access. */ -Keypad *Keypad::get_keypad() +Keypad_generic *Keypad_generic::get_keypad() { return &Keypad_letux400::keypad; } diff -r c9a29e1ba843 -r 929b5f0a63e4 pkg/devices/lib/keypad/src/loader/keypad-loader.cc --- a/pkg/devices/lib/keypad/src/loader/keypad-loader.cc Sun Jun 11 15:42:11 2023 +0200 +++ b/pkg/devices/lib/keypad/src/loader/keypad-loader.cc Sun Jun 18 00:19:36 2023 +0200 @@ -1,7 +1,7 @@ /* * Client functionality for keypad library access. * - * Copyright (C) 2018 Paul Boddie + * Copyright (C) 2018, 2023 Paul Boddie * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -23,7 +23,7 @@ #include "keypad.h" #include "keypad-loader.h" -Keypad *load_keypad() +Keypad_generic *load_keypad() { // Load the keypad library using details in the specified file. @@ -34,5 +34,5 @@ // Return the keypad details. - return (Keypad *) keypad_get(); + return (Keypad_generic *) keypad_get(); } diff -r c9a29e1ba843 -r 929b5f0a63e4 pkg/devices/lib/keypad/src/qi_lb60/keypad-qi_lb60.cc --- a/pkg/devices/lib/keypad/src/qi_lb60/keypad-qi_lb60.cc Sun Jun 11 15:42:11 2023 +0200 +++ b/pkg/devices/lib/keypad/src/qi_lb60/keypad-qi_lb60.cc Sun Jun 18 00:19:36 2023 +0200 @@ -1,7 +1,7 @@ /* * Ben NanoNote key mapping. * - * Copyright (C) 2018 Paul Boddie + * Copyright (C) 2018, 2023 Paul Boddie * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -29,7 +29,7 @@ Jz4740_keypad_gpio_outputs_count = 8, }; -class Keypad_qi_lb60 : public Keypad +class Keypad_qi_lb60 : public Keypad_generic { /* Keycode definitions. */ @@ -94,7 +94,7 @@ /* Definition access. */ -Keypad *Keypad::get_keypad() +Keypad_generic *Keypad_generic::get_keypad() { return &Keypad_qi_lb60::keypad; } diff -r c9a29e1ba843 -r 929b5f0a63e4 pkg/devices/util/src/Makefile --- a/pkg/devices/util/src/Makefile Sun Jun 11 15:42:11 2023 +0200 +++ b/pkg/devices/util/src/Makefile Sun Jun 18 00:19:36 2023 +0200 @@ -8,6 +8,6 @@ PRIVATE_INCDIR += $(PKGDIR)/util/include -REQUIRES_LIBS := libio l4re_c l4re_c-util libdl +REQUIRES_LIBS := libio l4re_c l4re_c-util libdl libipc include $(L4DIR)/mk/lib.mk diff -r c9a29e1ba843 -r 929b5f0a63e4 pkg/devices/util/src/dataspace.cc --- a/pkg/devices/util/src/dataspace.cc Sun Jun 11 15:42:11 2023 +0200 +++ b/pkg/devices/util/src/dataspace.cc Sun Jun 18 00:19:36 2023 +0200 @@ -39,7 +39,12 @@ /* Allocate memory for the data and map it to a virtual address. */ - if (ipc_allocate_align(mem_size, L4RE_MA_CONTINUOUS, 0, allocated, &mem)) + if (ipc_new_dataspace(mem_size, L4RE_MA_CONTINUOUS, 0, &mem)) + return L4_INVALID_CAP; + + if (ipc_attach_dataspace_align(mem, mem_size, + L4RE_RM_F_SEARCH_ADDR | L4RE_RM_F_RW, + 0, allocated)) return L4_INVALID_CAP; return mem; diff -r c9a29e1ba843 -r 929b5f0a63e4 pkg/landfall-examples/input_event_client/Makefile --- a/pkg/landfall-examples/input_event_client/Makefile Sun Jun 11 15:42:11 2023 +0200 +++ b/pkg/landfall-examples/input_event_client/Makefile Sun Jun 18 00:19:36 2023 +0200 @@ -2,8 +2,37 @@ L4DIR ?= $(PKGDIR)/../.. TARGET = ex_input_event_client -SRC_CC = input_event_client.cc -SRC_DATA = unifont.tff -REQUIRES_LIBS = l4re_c-util mag-gfx libdevice-input-event-client + +# Locations for interface input and generated output. + +IDL_DIR = $(L4DIR)/pkg/devices/idl +IDL_MK_DIR = $(L4DIR)/idl4re/mk +IDL_BUILD_DIR = . +IDL_EXPORT_DIR = . + +include $(IDL_MK_DIR)/idl.mk + +# Individual interfaces. + +CLIENT_INTERFACES_CC = event icu + +# Generated and plain source files. + +CLIENT_INTERFACES_SRC_CC = $(call interfaces_to_client_cc,$(CLIENT_INTERFACES_CC)) + +PLAIN_SRC_CC = input_event_client.cc + +# Normal definitions. + +SRC_CC = $(CLIENT_INTERFACES_SRC_CC) $(PLAIN_SRC_CC) + +SRC_DATA = unifont.tff + +REQUIRES_LIBS = l4re_c-util mag-gfx libdevice-input-event-loop libipc + +PRIVATE_INCDIR = $(IDL_BUILD_DIR) $(IDL_EXPORT_DIR) include $(L4DIR)/mk/prog.mk +include $(IDL_MK_DIR)/interface_rules.mk + +$(PLAIN_SRC_CC): $(CLIENT_INTERFACES_SRC_CC) diff -r c9a29e1ba843 -r 929b5f0a63e4 pkg/landfall-examples/input_event_client/input_event_client.cc --- a/pkg/landfall-examples/input_event_client/input_event_client.cc Sun Jun 11 15:42:11 2023 +0200 +++ b/pkg/landfall-examples/input_event_client/input_event_client.cc Sun Jun 18 00:19:36 2023 +0200 @@ -45,25 +45,32 @@ #include +#include +#include +#include +#include +#include +#include + #include #include -#include -#include -#include -#include -#include -#include - #include #include #include #include #include +#include + #include #include +#include "event_client.h" +#include "icu_client.h" + + + /* Video abstractions. */ static l4re_util_video_goos_fb_t gfb; @@ -260,39 +267,52 @@ /* 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"); - if (!event_server.is_valid()) return 1; + l4_cap_idx_t event_cap = l4re_env_get_cap("ev"); + + if (l4_is_invalid_cap(event_cap)) + return 1; /* Obtain a capability for the event buffer. */ - L4::Cap mem = L4Re::Util::cap_alloc.alloc(); - if (!mem.is_valid()) return 1; - if (event_server->get_buffer(mem)) return 1; + l4re_ds_t mem = ipc_cap_alloc(); + + if (l4_is_invalid_cap(mem)) + return 1; + + client_Event event_obj(event_cap); + client_ICU icu_obj(event_cap); + + if (event_obj.get_buffer(&mem)) + return 1; /* Attach the event buffer to this task. */ void *evmem = 0; - if (L4Re::Env::env()->rm()->attach(&evmem, mem->size(), - L4Re::Rm::F::Search_addr | - L4Re::Rm::F::RW, - L4::Ipc::make_cap_rw(mem))) + if (l4re_rm_attach(&evmem, l4re_ds_size(mem), + L4RE_RM_F_SEARCH_ADDR | L4RE_RM_F_RW, + mem, 0, + L4_PAGESHIFT)) return 1; - L4Re::Event_buffer event_buffer = L4Re::Event_buffer(evmem, mem->size()); + L4Re::Event_buffer event_buffer(evmem, l4re_ds_size(mem)); /* Obtain an interrupt capability. */ - L4::Cap irq = L4Re::Util::cap_alloc.alloc(); - if (!irq.is_valid()) return 1; + l4_cap_idx_t irq = ipc_cap_alloc(); + + if (l4_is_invalid_cap(irq)) + return 1; /* Create an interrupt object. */ - if (l4_error(L4Re::Env::env()->factory()->create(irq))) return 1; + if (l4_error(l4_factory_create_irq(l4re_env()->factory, irq))) + return 1; /* Bind the interrupt to the event capability. */ - if (l4_error(event_server->bind(0, irq))) return 1; + if (icu_obj.bind(0, irq)) + return 1; /* Create an event handler. */ diff -r c9a29e1ba843 -r 929b5f0a63e4 pkg/landfall-examples/keypad_ds_client/Makefile --- a/pkg/landfall-examples/keypad_ds_client/Makefile Sun Jun 11 15:42:11 2023 +0200 +++ b/pkg/landfall-examples/keypad_ds_client/Makefile Sun Jun 18 00:19:36 2023 +0200 @@ -2,9 +2,35 @@ L4DIR ?= $(PKGDIR)/../.. TARGET = ex_keypad_ds_client -#SRC_CC = keypad_ds_client.cc -#REQUIRES_LIBS = l4re_c-util libdevice-keypad-client -SRC_C = keypad_ds_client_c.c -REQUIRES_LIBS = l4re_c-util libdevice-keypad-ops + +# Locations for interface input and generated output. + +IDL_DIR = $(L4DIR)/pkg/devices/idl +IDL_MK_DIR = $(L4DIR)/idl4re/mk +IDL_BUILD_DIR = . +IDL_EXPORT_DIR = . + +include $(IDL_MK_DIR)/idl.mk + +# Individual interfaces. + +CLIENT_INTERFACES_CC = keypad + +# Generated and plain source files. + +CLIENT_INTERFACES_SRC_CC = $(call interfaces_to_client_cc,$(CLIENT_INTERFACES_CC)) + +PLAIN_SRC_CC = keypad_ds_client.cc + +# Normal definitions. + +SRC_CC = $(CLIENT_INTERFACES_SRC_CC) $(PLAIN_SRC_CC) + +REQUIRES_LIBS = l4re_c l4re_c-util libipc + +PRIVATE_INCDIR = $(IDL_BUILD_DIR) $(IDL_EXPORT_DIR) include $(L4DIR)/mk/prog.mk +include $(IDL_MK_DIR)/interface_rules.mk + +$(PLAIN_SRC_CC): $(CLIENT_INTERFACES_SRC_CC) diff -r c9a29e1ba843 -r 929b5f0a63e4 pkg/landfall-examples/keypad_ds_client/keypad_ds_client.cc --- a/pkg/landfall-examples/keypad_ds_client/keypad_ds_client.cc Sun Jun 11 15:42:11 2023 +0200 +++ b/pkg/landfall-examples/keypad_ds_client/keypad_ds_client.cc Sun Jun 18 00:19:36 2023 +0200 @@ -19,23 +19,24 @@ * Boston, MA 02110-1301, USA */ -#include - -#include -#include -#include -#include -#include +#include +#include +#include #include #include -#include +#include + #include #include #include #include +#include "keypad_client.h" + + + /* Video abstractions. */ static l4re_util_video_goos_fb_t gfb; @@ -44,8 +45,7 @@ /* Keypad status and dimensions. */ -uint32_t *keypad = 0; -void *keymem = 0; +uint32_t *keymem = 0; int columns, rows; @@ -109,7 +109,7 @@ row++, mask >>= 1) show_keystate(column * colsize, row * rowsize, colsize, rowsize, - keypad[column] & mask ? 0xffffff : 0); + keymem[column] & mask ? 0xffffff : 0); /* Refresh the display. */ @@ -120,8 +120,8 @@ int main(int argc, char *argv[]) { - L4::Cap keypad_server; - L4::Cap mem; + l4_cap_idx_t keypad_cap; + l4re_ds_t mem; /* Obtain the keypad matrix dimensions. */ @@ -142,31 +142,37 @@ /* Obtain a reference to the keypad. */ - keypad_server = L4Re::Env::env()->get_cap("keypad"); - if (!keypad_server.is_valid()) return 1; + keypad_cap = l4re_env_get_cap("keypad"); + + if (l4_is_invalid_cap(keypad_cap)) + return 1; /* Obtain a capability for the keypad data. */ - mem = L4Re::Util::cap_alloc.alloc(); - if (!mem.is_valid()) return 1; + mem = ipc_cap_alloc(); + + if (l4_is_invalid_cap(mem)) + return 1; /* Obtain a reference to the keypad data. */ - if (keypad_server->get_keypad_data(mem)) return 1; + client_Keypad keypad(keypad_cap); + + if (keypad.get_keypad_data(&mem)) + return 1; /* Attach the keypad data to a region in this task. */ - if (L4Re::Env::env()->rm()->attach(&keymem, mem->size(), - L4Re::Rm::F::Search_addr | - L4Re::Rm::F::R, - L4::Ipc::make_cap_rw(mem))) + if (l4re_rm_attach((void **) &keymem, l4re_ds_size(mem), + L4RE_RM_F_SEARCH_ADDR | L4RE_RM_F_R, + mem, 0, + L4_PAGESHIFT)) return 1; /* Show the keypad state. */ - keypad = (uint32_t *) keymem; - - while (1) show_keypad(); + while (1) + show_keypad(); return 0; } diff -r c9a29e1ba843 -r 929b5f0a63e4 pkg/landfall-examples/keypad_ds_client/keypad_ds_client_c.c --- a/pkg/landfall-examples/keypad_ds_client/keypad_ds_client_c.c Sun Jun 11 15:42:11 2023 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,179 +0,0 @@ -/* - * Display the keypad matrix using the specified dimensions. - * - * Copyright (C) 2018, 2023 Paul Boddie - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA - */ - -#include - -#include -#include -#include -#include -#include - -#include -#include - -#include -#include -#include -#include - -/* Video abstractions. */ - -static l4re_util_video_goos_fb_t gfb; -static l4re_video_view_info_t fbi; -static void *fb; - -/* Keypad status and dimensions. */ - -uint32_t *keypad = 0; -void *keymem = 0; -int columns, rows; - - - -static uint32_t bitmask(uint32_t size) -{ - return (1 << size) - 1; -} - -static uint32_t truncate_channel(uint32_t value, uint32_t size) -{ - return (value >> (8 - size)) & bitmask(size); -} - -static void set_pixel(uint32_t pos, uint8_t bpp, uint32_t value) -{ - if (bpp <= 8) *(uint8_t *) pos = value; - else if (bpp <= 16) *(uint16_t *) pos = value; - else *(uint32_t *) pos = value; -} - -/* Show the state of a key on the display. */ - -static void show_keystate(uint32_t x, uint32_t y, uint32_t w, uint32_t h, uint32_t rgb) -{ - uint8_t bpp = l4re_video_bits_per_pixel(&fbi.pixel_info); - uint8_t bytes_per_pixel = fbi.pixel_info.bytes_per_pixel; - uint32_t bytes_per_line = fbi.bytes_per_line; - uint32_t pos; - uint32_t col, row; - - rgb = (truncate_channel(rgb >> 16, fbi.pixel_info.r.size) << fbi.pixel_info.r.shift) | - (truncate_channel(rgb >> 8, fbi.pixel_info.g.size) << fbi.pixel_info.g.shift) | - (truncate_channel(rgb, fbi.pixel_info.b.size) << fbi.pixel_info.b.shift); - - for (row = 0; row < h; row++) - { - pos = (uint32_t) fb + (y + row) * bytes_per_line + x * bytes_per_pixel; - - for (col = 0; col < w; col++) - { - set_pixel(pos, bpp, rgb); - pos += bytes_per_pixel; - } - } -} - -/* Show the keypad status on the display. */ - -static void show_keypad(void) -{ - uint32_t colsize = fbi.width / columns, - rowsize = fbi.height / rows; - uint8_t column, row; - uint32_t mask; - - for (column = 0; column < columns; column++) - - for (row = 0, mask = 1 << (rows - 1); - row < rows; - row++, mask >>= 1) - - show_keystate(column * colsize, row * rowsize, colsize, rowsize, - keypad[column] & mask ? 0xffffff : 0); - - /* Refresh the display. */ - - l4re_util_video_goos_fb_refresh(&gfb, 0, 0, fbi.width, fbi.height); -} - - - -int main(int argc, char *argv[]) -{ - l4_cap_idx_t keypad_server; - l4re_ds_t mem; - l4_msgtag_t tag; - - /* Obtain the keypad matrix dimensions. */ - - if (argc < 3) - return 1; - - columns = atoi(argv[1]); - rows = atoi(argv[2]); - - if (l4re_util_video_goos_fb_setup_name(&gfb, "fb")) - return 1; - - if (l4re_util_video_goos_fb_view_info(&gfb, &fbi)) - return 1; - - if (!(fb = l4re_util_video_goos_fb_attach_buffer(&gfb))) - return 1; - - /* Obtain a reference to the keypad. */ - - keypad_server = l4re_env_get_cap("keypad"); - if (l4_is_invalid_cap(keypad_server)) return 1; - - /* Obtain a capability for the keypad data. */ - - mem = l4re_util_cap_alloc(); - if (l4_is_invalid_cap(mem)) return 1; - - /* Obtain a reference to the keypad data. */ - - l4_utcb_br()->bdr = 0; - l4_utcb_br()->br[0] = L4_RCV_ITEM_SINGLE_CAP | mem; - - tag = l4_ipc_call(keypad_server, l4_utcb(), - l4_msgtag(Keypad_op_get_keypad_data, 0, 0, 0), /* zero words, zero *sent* items */ - L4_IPC_NEVER); - - if (l4_ipc_error(tag, l4_utcb())) return 1; - - /* Attach the keypad data to a region in this task. */ - - if (l4re_rm_attach(&keymem, l4re_ds_size(mem), - L4RE_RM_F_SEARCH_ADDR | L4RE_RM_F_R, - mem, 0, - L4_PAGESHIFT)) - return 1; - - /* Show the keypad state. */ - - keypad = (uint32_t *) keymem; - - while (1) show_keypad(); - - return 0; -} diff -r c9a29e1ba843 -r 929b5f0a63e4 pkg/landfall-examples/letux400_backlight/letux400_backlight.cc --- a/pkg/landfall-examples/letux400_backlight/letux400_backlight.cc Sun Jun 11 15:42:11 2023 +0200 +++ b/pkg/landfall-examples/letux400_backlight/letux400_backlight.cc Sun Jun 18 00:19:36 2023 +0200 @@ -4,7 +4,7 @@ * Fn+Down/Up adjusts the brightness. * Zzz+Down/Up disables/enables the backlight. * - * Copyright (C) 2018, 2020 Paul Boddie + * Copyright (C) 2018, 2020, 2023 Paul Boddie * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -33,6 +33,8 @@ #include "activation_client.h" #include "backlight_client.h" + + /* Backlight level. */ enum Letux400_backlight_levels @@ -114,13 +116,15 @@ { /* Load the keypad library using details from the configured library. */ - Keypad *keypad = (Keypad *) load_keypad(); + Keypad_generic *keypad = (Keypad_generic *) load_keypad(); Input_keypad_client client(keypad); /* Obtain a reference to the backlight device. */ l4_cap_idx_t backlight = l4re_env_get_cap("backlight"); - if (!l4_is_valid_cap(backlight)) return 1; + + if (!l4_is_valid_cap(backlight)) + return 1; /* NOTE: The component framework should permit the use of a compound client object. */ diff -r c9a29e1ba843 -r 929b5f0a63e4 pkg/landfall-examples/qi_lb60_backlight/qi_lb60_backlight.cc --- a/pkg/landfall-examples/qi_lb60_backlight/qi_lb60_backlight.cc Sun Jun 11 15:42:11 2023 +0200 +++ b/pkg/landfall-examples/qi_lb60_backlight/qi_lb60_backlight.cc Sun Jun 18 00:19:36 2023 +0200 @@ -4,7 +4,7 @@ * Fn+Volume Down/Up adjusts the brightness. * Red Arrow+Volume Down/Up disables/enables the backlight. * - * Copyright (C) 2018, 2020 Paul Boddie + * Copyright (C) 2018, 2020, 2023 Paul Boddie * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -33,6 +33,8 @@ #include "activation_client.h" #include "backlight_client.h" + + /* Backlight level. */ enum Qi_lb60_backlight_levels @@ -114,13 +116,15 @@ { // Load the keypad details from the configured library. - Keypad *keypad = (Keypad *) load_keypad(); + Keypad_generic *keypad = (Keypad_generic *) load_keypad(); Input_keypad_client client(keypad); /* Obtain a reference to the backlight device. */ l4_cap_idx_t backlight = l4re_env_get_cap("backlight"); - if (!l4_is_valid_cap(backlight)) return 1; + + if (!l4_is_valid_cap(backlight)) + return 1; /* NOTE: The component framework should permit the use of a compound client object. */