1.1 --- a/pkg/devices/Control Sun Jun 11 15:42:11 2023 +0200 1.2 +++ b/pkg/devices/Control Sun Jun 18 00:19:36 2023 +0200 1.3 @@ -13,16 +13,10 @@ 1.4 provides: devices-keypad-qi_lb60 1.5 provides: devices-pwm-jz4730 1.6 provides: devices-spi-jz4740 1.7 -provides: libdevice-display-ops 1.8 -provides: libdevice-fb-client 1.9 provides: libdevice-fb-lcd 1.10 -provides: libdevice-fb-ops 1.11 provides: libdevice-fb-server 1.12 -provides: libdevice-input-event-client 1.13 -provides: libdevice-input-event-ops 1.14 +provides: libdevice-input-event-loop 1.15 provides: libdevice-input-keypad 1.16 -provides: libdevice-keypad-client 1.17 -provides: libdevice-keypad-ops 1.18 provides: libdevice-keypad-server 1.19 provides: libdevice-lcd 1.20 provides: libdevice-lcd-jz4740 1.21 @@ -45,5 +39,5 @@ 1.22 provides: libdrivers-panel-loader 1.23 provides: libdrivers-panel-qi_lb60 1.24 provides: libdrivers-pwm 1.25 -requires: libc libc_be_l4re libdl l4re_c libio 1.26 +requires: libc libc_be_l4re libdl l4re_c libio libipc 1.27 Maintainer: paul@boddie.org.uk
2.1 --- a/pkg/devices/Makefile Sun Jun 11 15:42:11 2023 +0200 2.2 +++ b/pkg/devices/Makefile Sun Jun 18 00:19:36 2023 +0200 2.3 @@ -12,9 +12,9 @@ 2.4 2.5 backlight: pwm spi include 2.6 cpm: lib util 2.7 -display: backlight cpm lib util include 2.8 +display: backlight cpm lib util 2.9 fb: lcd lib util 2.10 -input: keypad lib 2.11 +input: keypad lib util 2.12 keypad: lib util 2.13 lcd: display lib util 2.14 lib: include util
3.1 --- a/pkg/devices/fb/include/Makefile Sun Jun 11 15:42:11 2023 +0200 3.2 +++ b/pkg/devices/fb/include/Makefile Sun Jun 18 00:19:36 2023 +0200 3.3 @@ -1,6 +1,4 @@ 3.4 PKGDIR = ../.. 3.5 L4DIR ?= $(PKGDIR)/../.. 3.6 3.7 -PC_FILENAME := libdevice-fb-ops 3.8 - 3.9 include $(L4DIR)/mk/include.mk
4.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 4.2 +++ b/pkg/devices/fb/include/fb-lcd-run.h Sun Jun 18 00:19:36 2023 +0200 4.3 @@ -0,0 +1,24 @@ 4.4 +/* 4.5 + * LCD framebuffer server functionality. 4.6 + * 4.7 + * Copyright (C) 2018, 2023 Paul Boddie <paul@boddie.org.uk> 4.8 + * 4.9 + * This program is free software; you can redistribute it and/or 4.10 + * modify it under the terms of the GNU General Public License as 4.11 + * published by the Free Software Foundation; either version 2 of 4.12 + * the License, or (at your option) any later version. 4.13 + * 4.14 + * This program is distributed in the hope that it will be useful, 4.15 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 4.16 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 4.17 + * GNU General Public License for more details. 4.18 + * 4.19 + * You should have received a copy of the GNU General Public License 4.20 + * along with this program; if not, write to the Free Software 4.21 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, 4.22 + * Boston, MA 02110-1301, USA 4.23 + */ 4.24 + 4.25 +#pragma once 4.26 + 4.27 +int fb_lcd_run(void);
5.1 --- a/pkg/devices/fb/include/fb-lcd.h Sun Jun 11 15:42:11 2023 +0200 5.2 +++ b/pkg/devices/fb/include/fb-lcd.h Sun Jun 18 00:19:36 2023 +0200 5.3 @@ -23,11 +23,10 @@ 5.4 5.5 #ifdef __cplusplus 5.6 5.7 +#include <l4/devices/fb-server.h> 5.8 #include <l4/devices/lcd-device.h> 5.9 #include <l4/re/c/dataspace.h> 5.10 5.11 -#include "fb-server.h" 5.12 - 5.13 class Framebuffer_lcd_server : public Framebuffer_server 5.14 { 5.15 Lcd_device *_device; 5.16 @@ -46,7 +45,3 @@ 5.17 }; 5.18 5.19 #endif 5.20 - 5.21 -/* Common initiation method. */ 5.22 - 5.23 -int run(void);
6.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 6.2 +++ b/pkg/devices/fb/include/fb-run.h Sun Jun 18 00:19:36 2023 +0200 6.3 @@ -0,0 +1,28 @@ 6.4 +/* 6.5 + * LCD framebuffer server functionality. 6.6 + * 6.7 + * Copyright (C) 2018, 2023 Paul Boddie <paul@boddie.org.uk> 6.8 + * 6.9 + * This program is free software; you can redistribute it and/or 6.10 + * modify it under the terms of the GNU General Public License as 6.11 + * published by the Free Software Foundation; either version 2 of 6.12 + * the License, or (at your option) any later version. 6.13 + * 6.14 + * This program is distributed in the hope that it will be useful, 6.15 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 6.16 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 6.17 + * GNU General Public License for more details. 6.18 + * 6.19 + * You should have received a copy of the GNU General Public License 6.20 + * along with this program; if not, write to the Free Software 6.21 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, 6.22 + * Boston, MA 02110-1301, USA 6.23 + */ 6.24 + 6.25 +#pragma once 6.26 + 6.27 +#include <l4/devices/fb/framebuffer_interface.h> 6.28 + 6.29 +/* Common initiation method. */ 6.30 + 6.31 +int run(Framebuffer *obj);
7.1 --- a/pkg/devices/fb/include/fb-server.h Sun Jun 11 15:42:11 2023 +0200 7.2 +++ b/pkg/devices/fb/include/fb-server.h Sun Jun 18 00:19:36 2023 +0200 7.3 @@ -23,11 +23,10 @@ 7.4 7.5 #ifdef __cplusplus 7.6 7.7 +#include <l4/devices/fb/framebuffer_interface.h> 7.8 #include <l4/re/c/dataspace.h> 7.9 #include <l4/sys/types.h> 7.10 7.11 -#include "framebuffer_interface.h" 7.12 - 7.13 /* Server object to provide framebuffer data access. */ 7.14 7.15 class Framebuffer_server : public Framebuffer
8.1 --- a/pkg/devices/fb/src/jz4740/fb-jz4740.cc Sun Jun 11 15:42:11 2023 +0200 8.2 +++ b/pkg/devices/fb/src/jz4740/fb-jz4740.cc Sun Jun 18 00:19:36 2023 +0200 8.3 @@ -1,7 +1,7 @@ 8.4 /* 8.5 * Export the framebuffer for the Ben NanoNote via the "fb" capability. 8.6 * 8.7 - * Copyright (C) 2018 Paul Boddie <paul@boddie.org.uk> 8.8 + * Copyright (C) 2018, 2023 Paul Boddie <paul@boddie.org.uk> 8.9 * 8.10 * This program is free software; you can redistribute it and/or 8.11 * modify it under the terms of the GNU General Public License as 8.12 @@ -19,11 +19,11 @@ 8.13 * Boston, MA 02110-1301, USA 8.14 */ 8.15 8.16 -#include "fb-lcd.h" 8.17 +#include "fb-lcd-run.h" 8.18 8.19 /* Main program. */ 8.20 8.21 int main() 8.22 { 8.23 - return run(); 8.24 + return fb_lcd_run(); 8.25 }
9.1 --- a/pkg/devices/fb/src/lcd/Makefile Sun Jun 11 15:42:11 2023 +0200 9.2 +++ b/pkg/devices/fb/src/lcd/Makefile Sun Jun 18 00:19:36 2023 +0200 9.3 @@ -4,7 +4,7 @@ 9.4 TARGET = libdevice_fb_lcd.o.a 9.5 PC_FILENAME = libdevice-fb-lcd 9.6 9.7 -SRC_CC = fb-lcd.cc 9.8 +SRC_CC = fb-lcd.cc fb-lcd-run.cc 9.9 9.10 REQUIRES_LIBS = l4re_c l4re_c-util libdevice-fb-server libdevice-lcd 9.11
10.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 10.2 +++ b/pkg/devices/fb/src/lcd/fb-lcd-run.cc Sun Jun 18 00:19:36 2023 +0200 10.3 @@ -0,0 +1,50 @@ 10.4 +/* 10.5 + * Export the framebuffer as a data space accessible via the "fb" capability. 10.6 + * 10.7 + * Copyright (C) 2018, 2023 Paul Boddie <paul@boddie.org.uk> 10.8 + * 10.9 + * This program is free software; you can redistribute it and/or 10.10 + * modify it under the terms of the GNU General Public License as 10.11 + * published by the Free Software Foundation; either version 2 of 10.12 + * the License, or (at your option) any later version. 10.13 + * 10.14 + * This program is distributed in the hope that it will be useful, 10.15 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 10.16 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10.17 + * GNU General Public License for more details. 10.18 + * 10.19 + * You should have received a copy of the GNU General Public License 10.20 + * along with this program; if not, write to the Free Software 10.21 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, 10.22 + * Boston, MA 02110-1301, USA 10.23 + */ 10.24 + 10.25 +#include "fb-lcd.h" 10.26 +#include "fb-lcd-run.h" 10.27 +#include "fb-run.h" 10.28 + 10.29 + 10.30 + 10.31 +int fb_lcd_run() 10.32 +{ 10.33 + /* Obtain the LCD device. */ 10.34 + 10.35 + Lcd_device *lcd_device = Lcd_device::get_device(); 10.36 + 10.37 + /* Memory allocation capability for the framebuffer data. */ 10.38 + 10.39 + l4re_ds_t mem = lcd_device->get_framebuffer_cap(); 10.40 + 10.41 + if (l4_is_invalid_cap(mem)) 10.42 + return 1; 10.43 + 10.44 + /* Enable the LCD device. */ 10.45 + 10.46 + lcd_device->enable(); 10.47 + 10.48 + /* Initialise and register a server object. */ 10.49 + 10.50 + Framebuffer_lcd_server obj(mem, lcd_device); 10.51 + 10.52 + return run(&obj); 10.53 +}
11.1 --- a/pkg/devices/fb/src/lcd/fb-lcd.cc Sun Jun 11 15:42:11 2023 +0200 11.2 +++ b/pkg/devices/fb/src/lcd/fb-lcd.cc Sun Jun 18 00:19:36 2023 +0200 11.3 @@ -1,5 +1,5 @@ 11.4 /* 11.5 - * Export the framebuffer as a data space accessible via the "fb" capability. 11.6 + * Common LCD framebuffer server functionality. 11.7 * 11.8 * Copyright (C) 2018, 2023 Paul Boddie <paul@boddie.org.uk> 11.9 * 11.10 @@ -19,12 +19,7 @@ 11.11 * Boston, MA 02110-1301, USA 11.12 */ 11.13 11.14 -#include <l4/devices/lcd-device.h> 11.15 - 11.16 -#include <ipc/server.h> 11.17 - 11.18 #include "fb-lcd.h" 11.19 -#include "framebuffer_server.h" 11.20 11.21 11.22 11.23 @@ -39,36 +34,3 @@ 11.24 { 11.25 _device->get_view_info(view_info); 11.26 } 11.27 - 11.28 - 11.29 - 11.30 -// Main program. 11.31 - 11.32 -int run() 11.33 -{ 11.34 - /* Obtain the LCD device. */ 11.35 - 11.36 - Lcd_device *lcd_device = Lcd_device::get_device(); 11.37 - 11.38 - /* Memory allocation capability for the framebuffer data. */ 11.39 - 11.40 - l4re_ds_t mem = lcd_device->get_framebuffer_cap(); 11.41 - 11.42 - if (l4_is_invalid_cap(mem)) 11.43 - return 1; 11.44 - 11.45 - /* Enable the LCD device. */ 11.46 - 11.47 - lcd_device->enable(); 11.48 - 11.49 - /* Initialise and register a server object. */ 11.50 - 11.51 - Framebuffer_lcd_server obj(mem, lcd_device); 11.52 - 11.53 - /* Bind and start the IPC server loop. */ 11.54 - 11.55 - if (ipc_server_loop_for(Framebuffer, &obj, "fb")) 11.56 - return 1; 11.57 - 11.58 - return 0; 11.59 -}
12.1 --- a/pkg/devices/fb/src/server/Makefile Sun Jun 11 15:42:11 2023 +0200 12.2 +++ b/pkg/devices/fb/src/server/Makefile Sun Jun 18 00:19:36 2023 +0200 12.3 @@ -4,10 +4,34 @@ 12.4 TARGET = libdevice_fb_server.o.a 12.5 PC_FILENAME = libdevice-fb-server 12.6 12.7 -SRC_CC = fb-server.cc 12.8 +# Locations for interface input and generated output. 12.9 + 12.10 +IDL_DIR = $(PKGDIR)/idl 12.11 +IDL_MK_DIR = $(L4DIR)/idl4re/mk 12.12 +IDL_BUILD_DIR = . 12.13 +IDL_EXPORT_DIR = $(OBJ_BASE)/include/l4/devices/fb 12.14 + 12.15 +include $(IDL_MK_DIR)/idl.mk 12.16 + 12.17 +# Individual interfaces. 12.18 + 12.19 +SERVER_INTERFACES_CC = framebuffer 12.20 12.21 -PRIVATE_INCDIR = $(PKGDIR)/fb/include 12.22 +# Generated and plain source files. 12.23 + 12.24 +SERVER_INTERFACES_SRC_CC = $(call interfaces_to_server_cc,$(SERVER_INTERFACES_CC)) 12.25 + 12.26 +PLAIN_SRC_CC = fb-run.cc fb-server.cc 12.27 12.28 -REQUIRES_LIBS = l4re_c l4re_c-util 12.29 +# Normal definitions. 12.30 + 12.31 +SRC_CC = $(SERVER_INTERFACES_SRC_CC) $(PLAIN_SRC_CC) 12.32 + 12.33 +REQUIRES_LIBS = l4re_c l4re_c-util libipc 12.34 + 12.35 +PRIVATE_INCDIR = $(PKGDIR)/fb/include $(IDL_BUILD_DIR) $(IDL_EXPORT_DIR) 12.36 12.37 include $(L4DIR)/mk/lib.mk 12.38 +include $(IDL_MK_DIR)/interface_rules.mk 12.39 + 12.40 +$(PLAIN_SRC_CC): $(SERVER_INTERFACES_SRC_CC)
13.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 13.2 +++ b/pkg/devices/fb/src/server/fb-run.cc Sun Jun 18 00:19:36 2023 +0200 13.3 @@ -0,0 +1,38 @@ 13.4 +/* 13.5 + * Export the framebuffer as a data space accessible via the "fb" capability. 13.6 + * 13.7 + * Copyright (C) 2018, 2023 Paul Boddie <paul@boddie.org.uk> 13.8 + * 13.9 + * This program is free software; you can redistribute it and/or 13.10 + * modify it under the terms of the GNU General Public License as 13.11 + * published by the Free Software Foundation; either version 2 of 13.12 + * the License, or (at your option) any later version. 13.13 + * 13.14 + * This program is distributed in the hope that it will be useful, 13.15 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 13.16 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13.17 + * GNU General Public License for more details. 13.18 + * 13.19 + * You should have received a copy of the GNU General Public License 13.20 + * along with this program; if not, write to the Free Software 13.21 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, 13.22 + * Boston, MA 02110-1301, USA 13.23 + */ 13.24 + 13.25 +#include "fb-run.h" 13.26 + 13.27 +#include <ipc/server.h> 13.28 + 13.29 +#include "framebuffer_server.h" 13.30 + 13.31 + 13.32 + 13.33 +int run(Framebuffer *obj) 13.34 +{ 13.35 + /* Bind and start the IPC server loop. */ 13.36 + 13.37 + if (ipc_server_loop_for(Framebuffer, obj, "fb")) 13.38 + return 1; 13.39 + 13.40 + return 0; 13.41 +}
14.1 --- a/pkg/devices/idl/event.idl Sun Jun 11 15:42:11 2023 +0200 14.2 +++ b/pkg/devices/idl/event.idl Sun Jun 18 00:19:36 2023 +0200 14.3 @@ -1,9 +1,10 @@ 14.4 -#include <l4/devices/protocols.h> 14.5 +#include <l4/re/protocols.h> 14.6 14.7 -/* An event interface. */ 14.8 +/* An event interface. 14.9 + See: pkg/l4re-core/l4re/include/event */ 14.10 14.11 [protocol(L4RE_PROTO_EVENT)] 14.12 interface Event 14.13 { 14.14 - void get_buffer(out cap mem); 14.15 + [opcode(0)] void get_buffer(out cap mem); 14.16 };
15.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 15.2 +++ b/pkg/devices/idl/input.idl Sun Jun 18 00:19:36 2023 +0200 15.3 @@ -0,0 +1,6 @@ 15.4 +import "event.idl"; 15.5 +import "icu.idl"; 15.6 + 15.7 +/* An input interface supporting events and IRQ binding. */ 15.8 + 15.9 +interface Input composes Event, ICU;
16.1 --- a/pkg/devices/idl/pwm.idl Sun Jun 11 15:42:11 2023 +0200 16.2 +++ b/pkg/devices/idl/pwm.idl Sun Jun 18 00:19:36 2023 +0200 16.3 @@ -1,8 +1,6 @@ 16.4 #include <l4/devices/protocols.h> 16.5 #include <stdint.h> 16.6 16.7 -/* A PWM interface. PWM devices may also support the Activation interface. */ 16.8 - 16.9 [protocol(LANDFALL_PWM)] 16.10 interface PWM 16.11 {
17.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 17.2 +++ b/pkg/devices/idl/pwm_object.idl Sun Jun 18 00:19:36 2023 +0200 17.3 @@ -0,0 +1,4 @@ 17.4 +import "activation.idl"; 17.5 +import "pwm.idl"; 17.6 + 17.7 +interface PWMObject composes Activation, PWM;
18.1 --- a/pkg/devices/include/protocols.h Sun Jun 11 15:42:11 2023 +0200 18.2 +++ b/pkg/devices/include/protocols.h Sun Jun 18 00:19:36 2023 +0200 18.3 @@ -25,6 +25,7 @@ 18.4 #define LANDFALL_BACKLIGHT 0x1f02 18.5 #define LANDFALL_CPM 0x1f03 18.6 #define LANDFALL_FRAMEBUFFER 0x1f04 18.7 +#define LANDFALL_KEYPAD 0x1f05 18.8 #define LANDFALL_PWM 0x1f10 18.9 #define LANDFALL_SPI 0x1f13 18.10
19.1 --- a/pkg/devices/input/include/Makefile Sun Jun 11 15:42:11 2023 +0200 19.2 +++ b/pkg/devices/input/include/Makefile Sun Jun 18 00:19:36 2023 +0200 19.3 @@ -1,6 +1,4 @@ 19.4 PKGDIR = ../.. 19.5 L4DIR ?= $(PKGDIR)/../.. 19.6 19.7 -PC_FILENAME := libdevice-input-event-ops 19.8 - 19.9 include $(L4DIR)/mk/include.mk
20.1 --- a/pkg/devices/input/include/input-event-client.h Sun Jun 11 15:42:11 2023 +0200 20.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 20.3 @@ -1,43 +0,0 @@ 20.4 -/* 20.5 - * Input event client to access input event servers. 20.6 - * 20.7 - * Copyright (C) 2018 Paul Boddie <paul@boddie.org.uk> 20.8 - * 20.9 - * This program is free software; you can redistribute it and/or 20.10 - * modify it under the terms of the GNU General Public License as 20.11 - * published by the Free Software Foundation; either version 2 of 20.12 - * the License, or (at your option) any later version. 20.13 - * 20.14 - * This program is distributed in the hope that it will be useful, 20.15 - * but WITHOUT ANY WARRANTY; without even the implied warranty of 20.16 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20.17 - * GNU General Public License for more details. 20.18 - * 20.19 - * You should have received a copy of the GNU General Public License 20.20 - * along with this program; if not, write to the Free Software 20.21 - * Foundation, Inc., 51 Franklin Street, Fifth Floor, 20.22 - * Boston, MA 02110-1301, USA 20.23 - */ 20.24 - 20.25 -#pragma once 20.26 - 20.27 -#ifdef __cplusplus 20.28 - 20.29 -#include <l4/re/dataspace> 20.30 -#include <l4/re/env> 20.31 -#include <l4/re/event> 20.32 -#include <l4/sys/capability> 20.33 -#include <l4/sys/icu> 20.34 -#include <l4/sys/types.h> 20.35 - 20.36 -class Input_event_interface : public L4::Kobject_t<Input_event_interface, 20.37 - L4::Kobject, 20.38 - /* PROTO_ANY */ 0, 20.39 - /* accepts one cap */ L4::Type_info::Demand_t<1> > 20.40 -{ 20.41 -public: 20.42 - int bind(unsigned irqnum, L4::Cap<L4::Irq> irq) throw(); 20.43 - int get_buffer(L4::Cap<L4Re::Dataspace> mem) throw(); 20.44 -}; 20.45 - 20.46 -#endif
21.1 --- a/pkg/devices/input/include/input-event-loop.h Sun Jun 11 15:42:11 2023 +0200 21.2 +++ b/pkg/devices/input/include/input-event-loop.h Sun Jun 18 00:19:36 2023 +0200 21.3 @@ -52,6 +52,13 @@ 21.4 { 21.5 } 21.6 21.7 + explicit Input_event_loop(L4Re::Event_buffer event_buffer, 21.8 + l4_cap_idx_t irq, 21.9 + int priority=0x20) 21.10 + : Event_handler_loop(priority), _event_buffer(event_buffer), _irq(L4::Cap<L4::Irq>(irq)) 21.11 + { 21.12 + } 21.13 + 21.14 /* Event handler method, dispatching to the provided handler. */ 21.15 21.16 virtual void handle();
22.1 --- a/pkg/devices/input/include/input-event-ops.h Sun Jun 11 15:42:11 2023 +0200 22.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 22.3 @@ -1,49 +0,0 @@ 22.4 -/* 22.5 - * Input event server operations. 22.6 - * 22.7 - * Copyright (C) 2018 Paul Boddie <paul@boddie.org.uk> 22.8 - * 22.9 - * This program is free software; you can redistribute it and/or 22.10 - * modify it under the terms of the GNU General Public License as 22.11 - * published by the Free Software Foundation; either version 2 of 22.12 - * the License, or (at your option) any later version. 22.13 - * 22.14 - * This program is distributed in the hope that it will be useful, 22.15 - * but WITHOUT ANY WARRANTY; without even the implied warranty of 22.16 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 22.17 - * GNU General Public License for more details. 22.18 - * 22.19 - * You should have received a copy of the GNU General Public License 22.20 - * along with this program; if not, write to the Free Software 22.21 - * Foundation, Inc., 51 Franklin Street, Fifth Floor, 22.22 - * Boston, MA 02110-1301, USA 22.23 - */ 22.24 - 22.25 -#pragma once 22.26 - 22.27 -#include <l4/re/protocols.h> 22.28 -#include <l4/sys/types.h> 22.29 - 22.30 -enum Input_event_protocols 22.31 -{ 22.32 - Input_event_proto_event = L4RE_PROTO_EVENT, 22.33 - Input_event_proto_icu = L4_PROTO_IRQ, 22.34 -}; 22.35 - 22.36 -enum Input_event_operations 22.37 -{ 22.38 - /* Event protocol operations. 22.39 - NOTE: These definitions should employ the values defined elsewhere. */ 22.40 - 22.41 - Input_event_op_get_buffer = 0, 22.42 - Input_event_op_get_num_streams = 1, 22.43 - Input_event_op_get_stream_info = 2, 22.44 - Input_event_op_get_stream_info_for_id = 3, 22.45 - Input_event_op_get_axis_info = 4, 22.46 - Input_event_op_get_stream_state_for_id = 5, 22.47 - 22.48 - /* IRQ protocol operations. 22.49 - See: pkg/l4re-core/l4sys/include/icu.h */ 22.50 - 22.51 - Input_event_op_bind = L4_ICU_OP_BIND, 22.52 -};
23.1 --- a/pkg/devices/input/include/input-event-server.h Sun Jun 11 15:42:11 2023 +0200 23.2 +++ b/pkg/devices/input/include/input-event-server.h Sun Jun 18 00:19:36 2023 +0200 23.3 @@ -23,35 +23,38 @@ 23.4 23.5 #ifdef __cplusplus 23.6 23.7 -#include "input-event-client.h" 23.8 +#include <l4/re/c/dataspace.h> 23.9 +#include <l4/re/env.h> 23.10 +#include <l4/re/event> 23.11 23.12 -#include <l4/cxx/ipc_server> 23.13 -#include <l4/re/dataspace> 23.14 -#include <l4/re/env> 23.15 -#include <l4/re/event> 23.16 -#include <l4/sys/icu> 23.17 -#include <l4/sys/types.h> 23.18 +#include "input_interface.h" 23.19 + 23.20 + 23.21 23.22 /* Server object to provide input event source access. */ 23.23 23.24 -class Input_event_server : public L4::Server_object_t<Input_event_interface> 23.25 +class Input_event_server : public Input 23.26 { 23.27 private: 23.28 - L4::Cap<L4Re::Dataspace> _mem; 23.29 - L4::Cap<L4::Irq> _irq; 23.30 + l4re_ds_t _mem; 23.31 + l4_cap_idx_t _irq; 23.32 L4Re::Event_buffer _events; 23.33 23.34 public: 23.35 /* Initialise the server with a capability referencing the exported memory 23.36 and an event buffer through which events will be communicated. */ 23.37 23.38 - explicit Input_event_server(L4::Cap<L4Re::Dataspace> mem, 23.39 + explicit Input_event_server(l4re_ds_t mem, 23.40 L4Re::Event_buffer events) 23.41 : _mem(mem), _events(events) 23.42 { 23.43 } 23.44 23.45 - int dispatch(l4_umword_t obj, L4::Ipc::Iostream &ios); 23.46 + /* Input event interface operations. */ 23.47 + 23.48 + virtual long get_buffer(l4re_ds_t *mem); 23.49 + 23.50 + virtual long bind(unsigned int irqnum, l4_cap_idx_t irq); 23.51 23.52 /* Event sending methods. */ 23.53
24.1 --- a/pkg/devices/input/include/input-keypad-client.h Sun Jun 11 15:42:11 2023 +0200 24.2 +++ b/pkg/devices/input/include/input-keypad-client.h Sun Jun 18 00:19:36 2023 +0200 24.3 @@ -22,11 +22,11 @@ 24.4 #pragma once 24.5 24.6 #include <l4/devices/keypad.h> 24.7 -#include <l4/devices/keypad-client.h> 24.8 24.9 #include <pthread.h> 24.10 #include <pthread-l4.h> 24.11 24.12 +#include <l4/re/c/dataspace.h> 24.13 #include <l4/re/event_enums.h> 24.14 24.15 #include <stdint.h> 24.16 @@ -48,9 +48,6 @@ 24.17 24.18 #ifdef __cplusplus 24.19 24.20 -#include <l4/re/dataspace> 24.21 -#include <l4/re/env> 24.22 - 24.23 /* Client object to provide input event access. */ 24.24 24.25 class Input_keypad_client 24.26 @@ -62,7 +59,7 @@ 24.27 24.28 /* Keypad layout details. */ 24.29 24.30 - Keypad *_keypad; 24.31 + Keypad_generic *_keypad; 24.32 24.33 /* Keypad memory. */ 24.34 24.35 @@ -90,7 +87,7 @@ 24.36 void scan_keypad(); 24.37 24.38 public: 24.39 - explicit Input_keypad_client(Keypad *keypad) : _keypad(keypad) 24.40 + explicit Input_keypad_client(Keypad_generic *keypad) : _keypad(keypad) 24.41 { 24.42 init_memory(); 24.43 init_keypad();
25.1 --- a/pkg/devices/input/src/Makefile Sun Jun 11 15:42:11 2023 +0200 25.2 +++ b/pkg/devices/input/src/Makefile Sun Jun 18 00:19:36 2023 +0200 25.3 @@ -1,8 +1,9 @@ 25.4 PKGDIR ?= ../.. 25.5 L4DIR ?= $(PKGDIR)/../.. 25.6 25.7 -TARGET := client keypad server 25.8 +TARGET := event_loop keypad server 25.9 25.10 include $(L4DIR)/mk/subdir.mk 25.11 25.12 +keypad: event_loop 25.13 server: keypad
26.1 --- a/pkg/devices/input/src/client/Makefile Sun Jun 11 15:42:11 2023 +0200 26.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 26.3 @@ -1,13 +0,0 @@ 26.4 -PKGDIR ?= ../../.. 26.5 -L4DIR ?= $(PKGDIR)/../.. 26.6 - 26.7 -TARGET = libdevice_input_event_client.o.a 26.8 -PC_FILENAME := libdevice-input-event-client 26.9 - 26.10 -SRC_CC := input-event-client.cc input-event-loop.cc 26.11 - 26.12 -PRIVATE_INCDIR += $(PKGDIR)/input/include 26.13 - 26.14 -REQUIRES_LIBS := l4re_c l4re_c-util libdrivers-keypad-headers libdevice-util 26.15 - 26.16 -include $(L4DIR)/mk/lib.mk
27.1 --- a/pkg/devices/input/src/client/input-event-client.cc Sun Jun 11 15:42:11 2023 +0200 27.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 27.3 @@ -1,53 +0,0 @@ 27.4 -/* 27.5 - * Input event client to access input event servers. This is a more narrow 27.6 - * alternative to the L4Re::Event interface. 27.7 - * 27.8 - * Copyright (C) 2018 Paul Boddie <paul@boddie.org.uk> 27.9 - * 27.10 - * This program is free software; you can redistribute it and/or 27.11 - * modify it under the terms of the GNU General Public License as 27.12 - * published by the Free Software Foundation; either version 2 of 27.13 - * the License, or (at your option) any later version. 27.14 - * 27.15 - * This program is distributed in the hope that it will be useful, 27.16 - * but WITHOUT ANY WARRANTY; without even the implied warranty of 27.17 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 27.18 - * GNU General Public License for more details. 27.19 - * 27.20 - * You should have received a copy of the GNU General Public License 27.21 - * along with this program; if not, write to the Free Software 27.22 - * Foundation, Inc., 51 Franklin Street, Fifth Floor, 27.23 - * Boston, MA 02110-1301, USA 27.24 - */ 27.25 - 27.26 -#include <l4/cxx/ipc_stream> 27.27 -#include <l4/re/env> 27.28 - 27.29 -#include "input-event-client.h" 27.30 -#include "input-event-ops.h" 27.31 - 27.32 -int 27.33 -Input_event_interface::get_buffer(L4::Cap<L4Re::Dataspace> mem) throw() 27.34 -{ 27.35 - L4::Ipc::Iostream s(l4_utcb()); 27.36 - 27.37 - s << Input_event_op_get_buffer; 27.38 - 27.39 - /* Send a "receive item" for requesting a capability. */ 27.40 - 27.41 - s << L4::Ipc::Small_buf(mem); 27.42 - 27.43 - return l4_error(s.call(cap(), Input_event_proto_event)); 27.44 -} 27.45 - 27.46 -int 27.47 -Input_event_interface::bind(unsigned irqnum, L4::Cap<L4::Irq> irq) throw() 27.48 -{ 27.49 - L4::Ipc::Iostream s(l4_utcb()); 27.50 - 27.51 - s << Input_event_op_bind; 27.52 - s << irqnum; 27.53 - s << irq; 27.54 - 27.55 - return l4_error(s.call(cap(), Input_event_proto_icu)); 27.56 -}
28.1 --- a/pkg/devices/input/src/client/input-event-loop.cc Sun Jun 11 15:42:11 2023 +0200 28.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 28.3 @@ -1,51 +0,0 @@ 28.4 -/* 28.5 - * Input event loop functionality. 28.6 - * 28.7 - * Copyright (C) 2018 Paul Boddie <paul@boddie.org.uk> 28.8 - * 28.9 - * This program is free software; you can redistribute it and/or 28.10 - * modify it under the terms of the GNU General Public License as 28.11 - * published by the Free Software Foundation; either version 2 of 28.12 - * the License, or (at your option) any later version. 28.13 - * 28.14 - * This program is distributed in the hope that it will be useful, 28.15 - * but WITHOUT ANY WARRANTY; without even the implied warranty of 28.16 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 28.17 - * GNU General Public License for more details. 28.18 - * 28.19 - * You should have received a copy of the GNU General Public License 28.20 - * along with this program; if not, write to the Free Software 28.21 - * Foundation, Inc., 51 Franklin Street, Fifth Floor, 28.22 - * Boston, MA 02110-1301, USA 28.23 - */ 28.24 - 28.25 -#include "input-event-loop.h" 28.26 - 28.27 -#include <l4/re/event> 28.28 - 28.29 -/* Handler for incoming interrupts signalling the presence of events. */ 28.30 - 28.31 -void 28.32 -Input_event_loop::handle() 28.33 -{ 28.34 - Event_type *event; 28.35 - 28.36 - if (!l4_error(_irq->receive())) 28.37 - { 28.38 - while ((event = _event_buffer.next())) 28.39 - { 28.40 - _handler(*event); 28.41 - event->free(); 28.42 - } 28.43 - } 28.44 -} 28.45 - 28.46 -/* Event loop initiation. */ 28.47 - 28.48 -void 28.49 -Input_event_loop::start(l4_umword_t label) 28.50 -{ 28.51 - Event_loop::start(); 28.52 - 28.53 - _irq->bind_thread(Pthread::L4::cap(_pthread), label); 28.54 -}
29.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 29.2 +++ b/pkg/devices/input/src/event_loop/Makefile Sun Jun 18 00:19:36 2023 +0200 29.3 @@ -0,0 +1,13 @@ 29.4 +PKGDIR ?= ../../.. 29.5 +L4DIR ?= $(PKGDIR)/../.. 29.6 + 29.7 +TARGET = libdevice_input_event_loop.o.a 29.8 +PC_FILENAME = libdevice-input-event-loop 29.9 + 29.10 +SRC_CC = input-event-loop.cc 29.11 + 29.12 +PRIVATE_INCDIR = $(PKGDIR)/input/include 29.13 + 29.14 +REQUIRES_LIBS = l4re_c l4re_c-util libdrivers-keypad-headers libdevice-util 29.15 + 29.16 +include $(L4DIR)/mk/lib.mk
30.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 30.2 +++ b/pkg/devices/input/src/event_loop/input-event-loop.cc Sun Jun 18 00:19:36 2023 +0200 30.3 @@ -0,0 +1,51 @@ 30.4 +/* 30.5 + * Input event loop functionality. 30.6 + * 30.7 + * Copyright (C) 2018 Paul Boddie <paul@boddie.org.uk> 30.8 + * 30.9 + * This program is free software; you can redistribute it and/or 30.10 + * modify it under the terms of the GNU General Public License as 30.11 + * published by the Free Software Foundation; either version 2 of 30.12 + * the License, or (at your option) any later version. 30.13 + * 30.14 + * This program is distributed in the hope that it will be useful, 30.15 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 30.16 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 30.17 + * GNU General Public License for more details. 30.18 + * 30.19 + * You should have received a copy of the GNU General Public License 30.20 + * along with this program; if not, write to the Free Software 30.21 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, 30.22 + * Boston, MA 02110-1301, USA 30.23 + */ 30.24 + 30.25 +#include "input-event-loop.h" 30.26 + 30.27 +#include <l4/re/event> 30.28 + 30.29 +/* Handler for incoming interrupts signalling the presence of events. */ 30.30 + 30.31 +void 30.32 +Input_event_loop::handle() 30.33 +{ 30.34 + Event_type *event; 30.35 + 30.36 + if (!l4_error(_irq->receive())) 30.37 + { 30.38 + while ((event = _event_buffer.next())) 30.39 + { 30.40 + _handler(*event); 30.41 + event->free(); 30.42 + } 30.43 + } 30.44 +} 30.45 + 30.46 +/* Event loop initiation. */ 30.47 + 30.48 +void 30.49 +Input_event_loop::start(l4_umword_t label) 30.50 +{ 30.51 + Event_loop::start(); 30.52 + 30.53 + _irq->bind_thread(Pthread::L4::cap(_pthread), label); 30.54 +}
31.1 --- a/pkg/devices/input/src/keypad/Makefile Sun Jun 11 15:42:11 2023 +0200 31.2 +++ b/pkg/devices/input/src/keypad/Makefile Sun Jun 18 00:19:36 2023 +0200 31.3 @@ -4,10 +4,34 @@ 31.4 TARGET = libinput_keypad.o.a 31.5 PC_FILENAME = libdevice-input-keypad 31.6 31.7 -SRC_CC = input-keypad-client.cc 31.8 +# Locations for interface input and generated output. 31.9 + 31.10 +IDL_DIR = $(PKGDIR)/idl 31.11 +IDL_MK_DIR = $(L4DIR)/idl4re/mk 31.12 +IDL_BUILD_DIR = . 31.13 +IDL_EXPORT_DIR = . 31.14 + 31.15 +include $(IDL_MK_DIR)/idl.mk 31.16 + 31.17 +# Individual interfaces. 31.18 + 31.19 +CLIENT_INTERFACES_CC = keypad 31.20 31.21 -PRIVATE_INCDIR = $(PKGDIR)/input/include 31.22 +# Generated and plain source files. 31.23 + 31.24 +CLIENT_INTERFACES_SRC_CC = $(call interfaces_to_client_cc,$(CLIENT_INTERFACES_CC)) 31.25 + 31.26 +PLAIN_SRC_CC = input-keypad-client.cc 31.27 31.28 -REQUIRES_LIBS = l4re_c l4re_c-util libdrivers-keypad-headers libdevice-keypad-client 31.29 +# Normal definitions. 31.30 + 31.31 +SRC_CC = $(CLIENT_INTERFACES_SRC_CC) $(PLAIN_SRC_CC) 31.32 + 31.33 +PRIVATE_INCDIR = $(PKGDIR)/input/include $(IDL_BUILD_DIR) $(IDL_EXPORT_DIR) 31.34 + 31.35 +REQUIRES_LIBS = l4re_c l4re_c-util libdrivers-keypad-headers libdevice-input-event-loop libipc 31.36 31.37 include $(L4DIR)/mk/lib.mk 31.38 +include $(IDL_MK_DIR)/interface_rules.mk 31.39 + 31.40 +$(PLAIN_SRC_CC): $(CLIENT_INTERFACES_SRC_CC)
32.1 --- a/pkg/devices/input/src/keypad/input-keypad-client.cc Sun Jun 11 15:42:11 2023 +0200 32.2 +++ b/pkg/devices/input/src/keypad/input-keypad-client.cc Sun Jun 18 00:19:36 2023 +0200 32.3 @@ -35,7 +35,7 @@ 32.4 32.5 #include <stdlib.h> 32.6 32.7 -#include "keypad_interface.h" 32.8 +#include "keypad_client.h" 32.9 32.10 32.11 32.12 @@ -57,17 +57,11 @@ 32.13 32.14 void Input_keypad_client::init_keypad_data() 32.15 { 32.16 - if (l4_is_invalid_cap(_mem)) 32.17 - return; 32.18 - 32.19 - if (l4_is_invalid_cap(_keypad_server)) 32.20 - return; 32.21 - 32.22 /* Obtain a reference to the keypad data. */ 32.23 32.24 client_Keypad keypad(_keypad_cap); 32.25 32.26 - if (keypad.get_keypad_data(_mem)) 32.27 + if (keypad.get_keypad_data(&_mem)) 32.28 return; 32.29 32.30 /* Attach the keypad data to a region in this task. */
33.1 --- a/pkg/devices/input/src/server/Makefile Sun Jun 11 15:42:11 2023 +0200 33.2 +++ b/pkg/devices/input/src/server/Makefile Sun Jun 18 00:19:36 2023 +0200 33.3 @@ -2,12 +2,36 @@ 33.4 L4DIR ?= $(PKGDIR)/../.. 33.5 33.6 TARGET = dev_input_keypad 33.7 -PC_FILENAME := devices-input-keypad-server 33.8 +PC_FILENAME = devices-input-keypad-server 33.9 + 33.10 +# Locations for interface input and generated output. 33.11 33.12 -SRC_CC := input-keypad-server.cc 33.13 +IDL_DIR = $(PKGDIR)/idl 33.14 +IDL_MK_DIR = $(L4DIR)/idl4re/mk 33.15 +IDL_BUILD_DIR = . 33.16 +IDL_EXPORT_DIR = . 33.17 + 33.18 +include $(IDL_MK_DIR)/idl.mk 33.19 + 33.20 +# Individual interfaces. 33.21 33.22 -PRIVATE_INCDIR += $(PKGDIR)/input/include 33.23 +SERVER_INTERFACES_CC = input 33.24 + 33.25 +# Generated and plain source files. 33.26 + 33.27 +SERVER_INTERFACES_SRC_CC = $(call interfaces_to_server_cc,$(SERVER_INTERFACES_CC)) 33.28 + 33.29 +PLAIN_SRC_CC = input-event-server.cc input-keypad-server.cc 33.30 33.31 -REQUIRES_LIBS := l4re_c l4re_c-util libdevice-input-keypad libdrivers-keypad-loader libdevice-util 33.32 +# Normal definitions. 33.33 + 33.34 +SRC_CC = $(SERVER_INTERFACES_SRC_CC) $(PLAIN_SRC_CC) 33.35 + 33.36 +PRIVATE_INCDIR = $(PKGDIR)/input/include $(IDL_BUILD_DIR) $(IDL_EXPORT_DIR) 33.37 + 33.38 +REQUIRES_LIBS = l4re_c l4re_c-util libdevice-input-keypad libdrivers-keypad-loader libdevice-util libipc 33.39 33.40 include $(L4DIR)/mk/prog.mk 33.41 +include $(IDL_MK_DIR)/interface_rules.mk 33.42 + 33.43 +$(PLAIN_SRC_CC): $(SERVER_INTERFACES_SRC_CC)
34.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 34.2 +++ b/pkg/devices/input/src/server/input-event-server.cc Sun Jun 18 00:19:36 2023 +0200 34.3 @@ -0,0 +1,67 @@ 34.4 +/* 34.5 + * Provide access to keypad events on the configured device. 34.6 + * 34.7 + * Copyright (C) 2018, 2023 Paul Boddie <paul@boddie.org.uk> 34.8 + * 34.9 + * This program is free software; you can redistribute it and/or 34.10 + * modify it under the terms of the GNU General Public License as 34.11 + * published by the Free Software Foundation; either version 2 of 34.12 + * the License, or (at your option) any later version. 34.13 + * 34.14 + * This program is distributed in the hope that it will be useful, 34.15 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 34.16 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 34.17 + * GNU General Public License for more details. 34.18 + * 34.19 + * You should have received a copy of the GNU General Public License 34.20 + * along with this program; if not, write to the Free Software 34.21 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, 34.22 + * Boston, MA 02110-1301, USA 34.23 + */ 34.24 + 34.25 +#include "input-event-server.h" 34.26 + 34.27 +#include <l4/re/event> 34.28 +#include <l4/sys/irq.h> 34.29 +#include <l4/sys/kip.h> 34.30 + 34.31 + 34.32 + 34.33 +/* Reset the buffer state and return the buffer memory capability. */ 34.34 + 34.35 +long Input_event_server::get_buffer(l4re_ds_t *mem) 34.36 +{ 34.37 + _events.reset(); 34.38 + *mem = _mem; 34.39 + return L4_EOK; 34.40 +} 34.41 + 34.42 +/* Obtain the interrupt capability. */ 34.43 + 34.44 +long Input_event_server::bind(unsigned int irqnum, l4_cap_idx_t irq) 34.45 +{ 34.46 + (void) irqnum; 34.47 + 34.48 + _irq = irq; 34.49 + return L4_EOK; 34.50 +} 34.51 + 34.52 + 34.53 + 34.54 +/* Event sending methods. */ 34.55 + 34.56 +void Input_event_server::send_event(int type, int code, int value) 34.57 +{ 34.58 + L4Re::Event_buffer::Event event; 34.59 + 34.60 + event.time = l4_kip_clock(l4re_kip()); 34.61 + event.payload.stream_id = 0; 34.62 + event.payload.type = type; 34.63 + event.payload.code = code; 34.64 + event.payload.value = value; 34.65 + 34.66 + /* Queue the event and trigger the interrupt. */ 34.67 + 34.68 + _events.put(event); 34.69 + l4_irq_trigger(_irq); 34.70 +}
35.1 --- a/pkg/devices/input/src/server/input-keypad-server.cc Sun Jun 11 15:42:11 2023 +0200 35.2 +++ b/pkg/devices/input/src/server/input-keypad-server.cc Sun Jun 18 00:19:36 2023 +0200 35.3 @@ -1,7 +1,7 @@ 35.4 /* 35.5 * Provide access to keypad events on the configured device. 35.6 * 35.7 - * Copyright (C) 2018 Paul Boddie <paul@boddie.org.uk> 35.8 + * Copyright (C) 2018, 2023 Paul Boddie <paul@boddie.org.uk> 35.9 * 35.10 * This program is free software; you can redistribute it and/or 35.11 * modify it under the terms of the GNU General Public License as 35.12 @@ -21,123 +21,16 @@ 35.13 35.14 #include <l4/devices/dataspace.h> 35.15 #include <l4/devices/keypad-loader.h> 35.16 -#include "input-event-client.h" 35.17 + 35.18 #include "input-event-server.h" 35.19 -#include "input-event-ops.h" 35.20 #include "input-keypad-client.h" 35.21 35.22 -#include <l4/cxx/ipc_stream> 35.23 -#include <l4/re/dataspace> 35.24 -#include <l4/re/env> 35.25 #include <l4/re/event> 35.26 -#include <l4/re/util/br_manager> 35.27 -#include <l4/re/util/cap_alloc> 35.28 -#include <l4/re/util/object_registry> 35.29 -#include <l4/sys/capability> 35.30 -#include <l4/sys/icu> 35.31 -#include <l4/sys/kip.h> 35.32 -#include <l4/sys/types.h> 35.33 -#include <l4/util/util.h> 35.34 - 35.35 -#include <stdio.h> 35.36 - 35.37 -/* Extract a fpage from the message buffers. Provide a Snd_fpage reference for 35.38 - modification. */ 35.39 - 35.40 -static 35.41 -void get_fpage(L4::Ipc::Iostream &ios, L4::Ipc::Snd_item &fpage) 35.42 -{ 35.43 - l4_msgtag_t tag = ios.tag(); 35.44 - 35.45 - if (!tag.items()) 35.46 - return; 35.47 - 35.48 - /* Extract the fpage details directly since the stream operator doesn't seem 35.49 - to work. */ 35.50 - 35.51 - l4_msg_regs_t *m = l4_utcb_mr_u(l4_utcb()); 35.52 - l4_umword_t b = m->mr[tag.words()], d = m->mr[tag.words() + 1]; 35.53 - fpage = L4::Ipc::Snd_item(b, d); 35.54 -} 35.55 - 35.56 -/* Handle invocations. */ 35.57 - 35.58 -int 35.59 -Input_event_server::dispatch(l4_umword_t obj, L4::Ipc::Iostream &ios) 35.60 -{ 35.61 - l4_msgtag_t tag; 35.62 - l4_umword_t op; 35.63 - unsigned irqnum; 35.64 - L4::Ipc::Snd_fpage fpage; 35.65 - 35.66 - (void) obj; 35.67 - ios >> tag; 35.68 - 35.69 - switch (tag.label()) 35.70 - { 35.71 - case L4::Meta::Protocol: 35.72 - return L4::Util::handle_meta_request<Input_event_interface>(ios); 35.73 35.74 - case L4RE_PROTO_EVENT: 35.75 - ios >> op; 35.76 - switch (op) 35.77 - { 35.78 - /* Reset the buffer state and return the buffer memory capability. */ 35.79 - 35.80 - case Input_event_op_get_buffer: 35.81 - _events.reset(); 35.82 - ios << _mem; 35.83 - return L4_EOK; 35.84 - 35.85 - default: 35.86 - return -L4_EINVAL; 35.87 - } 35.88 - 35.89 - case L4_PROTO_IRQ: 35.90 - ios >> op; 35.91 - switch (op) 35.92 - { 35.93 - /* Just obtain the interrupt capability. */ 35.94 - 35.95 - case Input_event_op_bind: 35.96 - ios >> irqnum; 35.97 - get_fpage(ios, fpage); 35.98 - 35.99 - if (!fpage.cap_received()) 35.100 - return -L4_EINVAL; 35.101 +#include <ipc/cap_alloc.h> 35.102 +#include <ipc/server.h> 35.103 35.104 - _irq = server_iface()->rcv_cap<L4::Irq>(0); 35.105 - return server_iface()->realloc_rcv_cap(0); 35.106 - 35.107 - default: 35.108 - return -L4_EINVAL; 35.109 - } 35.110 - 35.111 - default: 35.112 - return -L4_EBADPROTO; 35.113 - } 35.114 -} 35.115 - 35.116 - 35.117 - 35.118 -/* Event sending methods. */ 35.119 - 35.120 -void 35.121 -Input_event_server::send_event(int type, int code, int value) 35.122 -{ 35.123 - L4Re::Event_buffer::Event event; 35.124 - 35.125 - event.time = l4_kip_clock(l4re_kip()); 35.126 - event.payload.stream_id = 0; 35.127 - event.payload.type = type; 35.128 - event.payload.code = code; 35.129 - event.payload.value = value; 35.130 - 35.131 - /* Queue the event and trigger the interrupt. */ 35.132 - 35.133 - _events.put(event); 35.134 - _irq->trigger(); 35.135 -} 35.136 +#include "input_server.h" 35.137 35.138 35.139 35.140 @@ -150,43 +43,44 @@ 35.141 35.142 35.143 35.144 -static L4Re::Util::Registry_server<L4Re::Util::Br_manager_hooks> server; 35.145 - 35.146 - 35.147 - 35.148 int main(void) 35.149 { 35.150 - // Load the keypad details from the configured library. 35.151 + /* Load the keypad details from the configured library. */ 35.152 35.153 - Keypad *keypad = load_keypad(); 35.154 + Keypad_generic *keypad = load_keypad(); 35.155 Input_keypad_client client(keypad); 35.156 void *buffer; 35.157 35.158 - // Memory allocation capability for the event data. 35.159 + /* Memory allocation capability for the event data. */ 35.160 35.161 - L4::Cap<L4Re::Dataspace> mem = allocate_data(L4_PAGESIZE, &buffer); 35.162 - if (!mem.is_valid()) return 1; 35.163 + l4re_ds_t mem = allocate_data(L4_PAGESIZE, &buffer); 35.164 + 35.165 + if (l4_is_invalid_cap(mem)) 35.166 + return 1; 35.167 35.168 /* Obtain a capability for the interrupt. */ 35.169 35.170 - L4::Cap<L4::Irq> irq = L4Re::Util::cap_alloc.alloc<L4::Irq>(); 35.171 - if (!irq.is_valid()) return 1; 35.172 + l4_cap_idx_t irq = ipc_cap_alloc(); 35.173 35.174 - // Event buffer for the data. 35.175 + if (l4_is_invalid_cap(irq)) 35.176 + return 1; 35.177 + 35.178 + /* Event buffer for the data. */ 35.179 35.180 L4Re::Event_buffer events(buffer, L4_PAGESIZE); 35.181 35.182 - // Initialise and register a server object. 35.183 + /* Initialise and register a server object. */ 35.184 35.185 - Input_event_server server_obj(mem, events); 35.186 - server.registry()->register_obj(&server_obj, "ev"); 35.187 + Input_event_server obj(mem, events); 35.188 + 35.189 + /* Attach the event handler and wait for events. */ 35.190 35.191 - // Attach the event handler and wait for events. 35.192 + client.attach(handler, (void *) &obj); 35.193 35.194 - client.attach(handler, (void *) &server_obj); 35.195 + /* Bind and start the IPC server loop. */ 35.196 35.197 - // Enter the IPC server loop. 35.198 + if (ipc_server_loop_for(Input, &obj, "ev")) 35.199 + return 1; 35.200 35.201 - server.loop(); 35.202 return 0; 35.203 }
36.1 --- a/pkg/devices/keypad/include/Makefile Sun Jun 11 15:42:11 2023 +0200 36.2 +++ b/pkg/devices/keypad/include/Makefile Sun Jun 18 00:19:36 2023 +0200 36.3 @@ -1,6 +1,4 @@ 36.4 PKGDIR = ../.. 36.5 L4DIR ?= $(PKGDIR)/../.. 36.6 36.7 -PC_FILENAME := libdevice-keypad-ops 36.8 - 36.9 include $(L4DIR)/mk/include.mk
37.1 --- a/pkg/devices/keypad/include/keypad-client.h Sun Jun 11 15:42:11 2023 +0200 37.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 37.3 @@ -1,38 +0,0 @@ 37.4 -/* 37.5 - * Keypad client to access keypad servers. 37.6 - * 37.7 - * Copyright (C) 2018 Paul Boddie <paul@boddie.org.uk> 37.8 - * 37.9 - * This program is free software; you can redistribute it and/or 37.10 - * modify it under the terms of the GNU General Public License as 37.11 - * published by the Free Software Foundation; either version 2 of 37.12 - * the License, or (at your option) any later version. 37.13 - * 37.14 - * This program is distributed in the hope that it will be useful, 37.15 - * but WITHOUT ANY WARRANTY; without even the implied warranty of 37.16 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 37.17 - * GNU General Public License for more details. 37.18 - * 37.19 - * You should have received a copy of the GNU General Public License 37.20 - * along with this program; if not, write to the Free Software 37.21 - * Foundation, Inc., 51 Franklin Street, Fifth Floor, 37.22 - * Boston, MA 02110-1301, USA 37.23 - */ 37.24 - 37.25 -#pragma once 37.26 - 37.27 -#ifdef __cplusplus 37.28 - 37.29 -#include <l4/re/dataspace> 37.30 -#include <l4/re/env> 37.31 -#include "keypad-ops.h" 37.32 - 37.33 -class Keypad_device_interface : public L4::Kobject_t<Keypad_device_interface, L4::Kobject> 37.34 -{ 37.35 - L4_KOBJECT(Keypad_device_interface) 37.36 - 37.37 -public: 37.38 - int get_keypad_data(L4::Cap<L4Re::Dataspace> mem) throw(); 37.39 -}; 37.40 - 37.41 -#endif
38.1 --- a/pkg/devices/keypad/include/keypad-ops.h Sun Jun 11 15:42:11 2023 +0200 38.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 38.3 @@ -1,24 +0,0 @@ 38.4 -/* 38.5 - * Keypad server operations. 38.6 - * 38.7 - * Copyright (C) 2018 Paul Boddie <paul@boddie.org.uk> 38.8 - * 38.9 - * This program is free software; you can redistribute it and/or 38.10 - * modify it under the terms of the GNU General Public License as 38.11 - * published by the Free Software Foundation; either version 2 of 38.12 - * the License, or (at your option) any later version. 38.13 - * 38.14 - * This program is distributed in the hope that it will be useful, 38.15 - * but WITHOUT ANY WARRANTY; without even the implied warranty of 38.16 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 38.17 - * GNU General Public License for more details. 38.18 - * 38.19 - * You should have received a copy of the GNU General Public License 38.20 - * along with this program; if not, write to the Free Software 38.21 - * Foundation, Inc., 51 Franklin Street, Fifth Floor, 38.22 - * Boston, MA 02110-1301, USA 38.23 - */ 38.24 - 38.25 -#pragma once 38.26 - 38.27 -enum { Keypad_op_get_keypad_data };
39.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 39.2 +++ b/pkg/devices/keypad/include/keypad-run.h Sun Jun 18 00:19:36 2023 +0200 39.3 @@ -0,0 +1,26 @@ 39.4 +/* 39.5 + * Common keypad server functionality. 39.6 + * 39.7 + * Copyright (C) 2023 Paul Boddie <paul@boddie.org.uk> 39.8 + * 39.9 + * This program is free software; you can redistribute it and/or 39.10 + * modify it under the terms of the GNU General Public License as 39.11 + * published by the Free Software Foundation; either version 2 of 39.12 + * the License, or (at your option) any later version. 39.13 + * 39.14 + * This program is distributed in the hope that it will be useful, 39.15 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 39.16 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 39.17 + * GNU General Public License for more details. 39.18 + * 39.19 + * You should have received a copy of the GNU General Public License 39.20 + * along with this program; if not, write to the Free Software 39.21 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, 39.22 + * Boston, MA 02110-1301, USA 39.23 + */ 39.24 + 39.25 +#pragma once 39.26 + 39.27 +#include <l4/re/c/dataspace.h> 39.28 + 39.29 +long run(l4re_ds_t mem);
40.1 --- a/pkg/devices/keypad/include/keypad-server.h Sun Jun 11 15:42:11 2023 +0200 40.2 +++ b/pkg/devices/keypad/include/keypad-server.h Sun Jun 18 00:19:36 2023 +0200 40.3 @@ -23,7 +23,7 @@ 40.4 40.5 #include <l4/re/c/dataspace.h> 40.6 40.7 -#include <devices/keypad_interface.h> 40.8 +#include "keypad_interface.h" 40.9 40.10 40.11
41.1 --- a/pkg/devices/keypad/src/Makefile Sun Jun 11 15:42:11 2023 +0200 41.2 +++ b/pkg/devices/keypad/src/Makefile Sun Jun 18 00:19:36 2023 +0200 41.3 @@ -1,7 +1,7 @@ 41.4 PKGDIR ?= ../.. 41.5 L4DIR ?= $(PKGDIR)/../.. 41.6 41.7 -TARGET := client letux400 qi_lb60 server 41.8 +TARGET := letux400 qi_lb60 server 41.9 41.10 include $(L4DIR)/mk/subdir.mk 41.11
42.1 --- a/pkg/devices/keypad/src/client/Makefile Sun Jun 11 15:42:11 2023 +0200 42.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 42.3 @@ -1,13 +0,0 @@ 42.4 -PKGDIR ?= ../../.. 42.5 -L4DIR ?= $(PKGDIR)/../.. 42.6 - 42.7 -TARGET = libdevice_keypad_client.o.a 42.8 -PC_FILENAME := libdevice-keypad-client 42.9 - 42.10 -SRC_CC := keypad-client.cc 42.11 - 42.12 -PRIVATE_INCDIR += $(PKGDIR)/keypad/include 42.13 - 42.14 -REQUIRES_LIBS := l4re_c l4re_c-util 42.15 - 42.16 -include $(L4DIR)/mk/lib.mk
43.1 --- a/pkg/devices/keypad/src/client/keypad-client.cc Sun Jun 11 15:42:11 2023 +0200 43.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 43.3 @@ -1,37 +0,0 @@ 43.4 -/* 43.5 - * Keypad client to access keypad servers. 43.6 - * 43.7 - * Copyright (C) 2018 Paul Boddie <paul@boddie.org.uk> 43.8 - * 43.9 - * This program is free software; you can redistribute it and/or 43.10 - * modify it under the terms of the GNU General Public License as 43.11 - * published by the Free Software Foundation; either version 2 of 43.12 - * the License, or (at your option) any later version. 43.13 - * 43.14 - * This program is distributed in the hope that it will be useful, 43.15 - * but WITHOUT ANY WARRANTY; without even the implied warranty of 43.16 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 43.17 - * GNU General Public License for more details. 43.18 - * 43.19 - * You should have received a copy of the GNU General Public License 43.20 - * along with this program; if not, write to the Free Software 43.21 - * Foundation, Inc., 51 Franklin Street, Fifth Floor, 43.22 - * Boston, MA 02110-1301, USA 43.23 - */ 43.24 - 43.25 -#include <l4/cxx/ipc_stream> 43.26 -#include <l4/re/env> 43.27 - 43.28 -#include "keypad-client.h" 43.29 - 43.30 -int 43.31 -Keypad_device_interface::get_keypad_data(L4::Cap<L4Re::Dataspace> mem) throw() 43.32 -{ 43.33 - L4::Ipc::Iostream s(l4_utcb()); 43.34 - 43.35 - /* Send a "receive item" for requesting a capability. */ 43.36 - 43.37 - s << L4::Ipc::Small_buf(mem); 43.38 - 43.39 - return l4_error(s.call(cap(), Keypad_op_get_keypad_data)); 43.40 -}
44.1 --- a/pkg/devices/keypad/src/letux400/Makefile Sun Jun 11 15:42:11 2023 +0200 44.2 +++ b/pkg/devices/keypad/src/letux400/Makefile Sun Jun 18 00:19:36 2023 +0200 44.3 @@ -2,12 +2,12 @@ 44.4 L4DIR ?= $(PKGDIR)/../.. 44.5 44.6 TARGET = dev_keypad_letux400 44.7 -PC_FILENAME := devices-keypad-letux400 44.8 +PC_FILENAME = devices-keypad-letux400 44.9 44.10 -SRC_CC := keypad-letux400.cc 44.11 +SRC_CC = keypad-letux400.cc 44.12 44.13 -PRIVATE_INCDIR += $(PKGDIR)/keypad/include 44.14 +PRIVATE_INCDIR = $(PKGDIR)/keypad/include 44.15 44.16 -REQUIRES_LIBS := l4re_c l4re_c-util libdrivers-gpio libdevice-util libdevice-keypad-server 44.17 +REQUIRES_LIBS = l4re_c l4re_c-util libdrivers-gpio libdevice-util libdevice-keypad-server 44.18 44.19 include $(L4DIR)/mk/prog.mk
45.1 --- a/pkg/devices/keypad/src/letux400/keypad-letux400.cc Sun Jun 11 15:42:11 2023 +0200 45.2 +++ b/pkg/devices/keypad/src/letux400/keypad-letux400.cc Sun Jun 18 00:19:36 2023 +0200 45.3 @@ -2,7 +2,7 @@ 45.4 * Export the keypad GPIOs on the Letux 400 as a data space accessible via the 45.5 * "keypad" capability. 45.6 * 45.7 - * Copyright (C) 2018 Paul Boddie <paul@boddie.org.uk> 45.8 + * Copyright (C) 2018, 2023 Paul Boddie <paul@boddie.org.uk> 45.9 * 45.10 * This program is free software; you can redistribute it and/or 45.11 * modify it under the terms of the GNU General Public License as 45.12 @@ -23,17 +23,19 @@ 45.13 #include <l4/devices/gpio-jz4730.h> 45.14 #include <l4/devices/dataspace.h> 45.15 #include <l4/devices/memory.h> 45.16 -#include "keypad-server.h" 45.17 -#include "keypad-event-loop.h" 45.18 45.19 -#include <l4/re/dataspace> 45.20 -#include <l4/re/env> 45.21 -#include <l4/re/util/object_registry> 45.22 +#include <l4/re/c/dataspace.h> 45.23 +#include <l4/re/env.h> 45.24 45.25 #include <l4/sys/cache.h> 45.26 45.27 #include <stdint.h> 45.28 45.29 +#include "keypad-event-loop.h" 45.30 +#include "keypad-run.h" 45.31 + 45.32 + 45.33 + 45.34 enum Jz4730_keypad_gpio 45.35 { 45.36 Jz4730_keypad_gpio_inputs_count = 8, 45.37 @@ -128,24 +130,20 @@ 45.38 45.39 45.40 45.41 -static L4Re::Util::Registry_server<> server; 45.42 - 45.43 - 45.44 - 45.45 /* Main program. */ 45.46 45.47 int main(void) 45.48 { 45.49 + if (setup_memory()) 45.50 + return 1; 45.51 + 45.52 /* Memory allocation capability for the keypad data. */ 45.53 45.54 - L4::Cap<L4Re::Dataspace> mem; 45.55 l4_size_t mem_size = Jz4730_keypad_gpio_outputs_count * sizeof(uint32_t); 45.56 + l4re_ds_t mem = allocate_data(mem_size, &keymem); 45.57 45.58 - if (setup_memory()) return 1; 45.59 - 45.60 - mem = allocate_data(mem_size, &keymem); 45.61 - 45.62 - if (!mem.is_valid()) return 1; 45.63 + if (l4_is_invalid_cap(mem)) 45.64 + return 1; 45.65 45.66 keypad = (uint32_t *) keymem; 45.67 45.68 @@ -159,13 +157,7 @@ 45.69 loop.attach(scan_keypad); 45.70 loop.start(); 45.71 45.72 - /* Initialise and register a server object. */ 45.73 - 45.74 - Keypad_server server_obj(mem); 45.75 - server.registry()->register_obj(&server_obj, "keypad"); 45.76 + /* Start a server using the common server functionality. */ 45.77 45.78 - /* Enter the IPC server loop. */ 45.79 - 45.80 - server.loop(); 45.81 - return 0; 45.82 + return run(mem); 45.83 }
46.1 --- a/pkg/devices/keypad/src/qi_lb60/Makefile Sun Jun 11 15:42:11 2023 +0200 46.2 +++ b/pkg/devices/keypad/src/qi_lb60/Makefile Sun Jun 18 00:19:36 2023 +0200 46.3 @@ -2,12 +2,12 @@ 46.4 L4DIR ?= $(PKGDIR)/../.. 46.5 46.6 TARGET = dev_keypad_qi_lb60 46.7 -PC_FILENAME := devices-keypad-qi_lb60 46.8 +PC_FILENAME = devices-keypad-qi_lb60 46.9 46.10 -SRC_CC := keypad-qi_lb60.cc 46.11 +SRC_CC = keypad-qi_lb60.cc 46.12 46.13 -PRIVATE_INCDIR += $(PKGDIR)/keypad/include 46.14 +PRIVATE_INCDIR = $(PKGDIR)/keypad/include 46.15 46.16 -REQUIRES_LIBS := l4re_c l4re_c-util libdrivers-gpio libdevice-util libdevice-keypad-server 46.17 +REQUIRES_LIBS = l4re_c l4re_c-util libdrivers-gpio libdevice-util libdevice-keypad-server 46.18 46.19 include $(L4DIR)/mk/prog.mk
47.1 --- a/pkg/devices/keypad/src/qi_lb60/keypad-qi_lb60.cc Sun Jun 11 15:42:11 2023 +0200 47.2 +++ b/pkg/devices/keypad/src/qi_lb60/keypad-qi_lb60.cc Sun Jun 18 00:19:36 2023 +0200 47.3 @@ -2,7 +2,7 @@ 47.4 * Export the keypad GPIOs on the Ben NanoNote as a data space accessible via 47.5 * the "keypad" capability. 47.6 * 47.7 - * Copyright (C) 2018 Paul Boddie <paul@boddie.org.uk> 47.8 + * Copyright (C) 2018, 2023 Paul Boddie <paul@boddie.org.uk> 47.9 * 47.10 * This program is free software; you can redistribute it and/or 47.11 * modify it under the terms of the GNU General Public License as 47.12 @@ -23,17 +23,17 @@ 47.13 #include <l4/devices/gpio-jz4740.h> 47.14 #include <l4/devices/dataspace.h> 47.15 #include <l4/devices/memory.h> 47.16 -#include "keypad-server.h" 47.17 -#include "keypad-event-loop.h" 47.18 - 47.19 -#include <l4/re/dataspace> 47.20 -#include <l4/re/env> 47.21 -#include <l4/re/util/object_registry> 47.22 - 47.23 +#include <l4/re/c/dataspace.h> 47.24 +#include <l4/re/env.h> 47.25 #include <l4/sys/cache.h> 47.26 47.27 #include <stdint.h> 47.28 47.29 +#include "keypad-event-loop.h" 47.30 +#include "keypad-run.h" 47.31 + 47.32 + 47.33 + 47.34 enum Jz4740_keypad_gpio 47.35 { 47.36 Jz4740_keypad_gpio_inputs_count = 8, 47.37 @@ -128,24 +128,20 @@ 47.38 47.39 47.40 47.41 -static L4Re::Util::Registry_server<> server; 47.42 - 47.43 - 47.44 - 47.45 /* Main program. */ 47.46 47.47 int main(void) 47.48 { 47.49 + if (setup_memory()) 47.50 + return 1; 47.51 + 47.52 /* Memory allocation capability for the keypad data. */ 47.53 47.54 - L4::Cap<L4Re::Dataspace> mem; 47.55 l4_size_t mem_size = Jz4740_keypad_gpio_outputs_count * sizeof(uint32_t); 47.56 + l4re_ds_t mem = allocate_data(mem_size, &keymem); 47.57 47.58 - if (setup_memory()) return 1; 47.59 - 47.60 - mem = allocate_data(mem_size, &keymem); 47.61 - 47.62 - if (!mem.is_valid()) return 1; 47.63 + if (l4_is_invalid_cap(mem)) 47.64 + return 1; 47.65 47.66 keypad = (uint32_t *) keymem; 47.67 47.68 @@ -159,13 +155,7 @@ 47.69 loop.attach(scan_keypad); 47.70 loop.start(); 47.71 47.72 - /* Initialise and register a server object. */ 47.73 - 47.74 - Keypad_server server_obj(mem); 47.75 - server.registry()->register_obj(&server_obj, "keypad"); 47.76 + /* Start a server using the common server functionality. */ 47.77 47.78 - /* Enter the IPC server loop. */ 47.79 - 47.80 - server.loop(); 47.81 - return 0; 47.82 + return run(mem); 47.83 }
48.1 --- a/pkg/devices/keypad/src/server/Makefile Sun Jun 11 15:42:11 2023 +0200 48.2 +++ b/pkg/devices/keypad/src/server/Makefile Sun Jun 18 00:19:36 2023 +0200 48.3 @@ -2,12 +2,36 @@ 48.4 L4DIR ?= $(PKGDIR)/../.. 48.5 48.6 TARGET = libdevice_keypad_server.o.a 48.7 -PC_FILENAME := libdevice-keypad-server 48.8 +PC_FILENAME = libdevice-keypad-server 48.9 + 48.10 +# Locations for interface input and generated output. 48.11 48.12 -SRC_CC := keypad-server.cc 48.13 +IDL_DIR = $(PKGDIR)/idl 48.14 +IDL_MK_DIR = $(L4DIR)/idl4re/mk 48.15 +IDL_BUILD_DIR = . 48.16 +IDL_EXPORT_DIR = . 48.17 + 48.18 +include $(IDL_MK_DIR)/idl.mk 48.19 + 48.20 +# Individual interfaces. 48.21 48.22 -PRIVATE_INCDIR += $(PKGDIR)/keypad/include 48.23 +SERVER_INTERFACES_CC = keypad 48.24 + 48.25 +# Generated and plain source files. 48.26 + 48.27 +SERVER_INTERFACES_SRC_CC = $(call interfaces_to_server_cc,$(SERVER_INTERFACES_CC)) 48.28 + 48.29 +PLAIN_SRC_CC = keypad-run.cc keypad-server.cc 48.30 48.31 -REQUIRES_LIBS := l4re_c l4re_c-util 48.32 +# Normal definitions. 48.33 + 48.34 +SRC_CC = $(SERVER_INTERFACES_SRC_CC) $(PLAIN_SRC_CC) 48.35 + 48.36 +REQUIRES_LIBS = l4re_c l4re_c-util libipc 48.37 + 48.38 +PRIVATE_INCDIR = $(PKGDIR)/keypad/include $(IDL_BUILD_DIR) $(IDL_EXPORT_DIR) 48.39 48.40 include $(L4DIR)/mk/lib.mk 48.41 +include $(IDL_MK_DIR)/interface_rules.mk 48.42 + 48.43 +$(PLAIN_SRC_CC): $(SERVER_INTERFACES_SRC_CC)
49.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 49.2 +++ b/pkg/devices/keypad/src/server/keypad-run.cc Sun Jun 18 00:19:36 2023 +0200 49.3 @@ -0,0 +1,49 @@ 49.4 +/* 49.5 + * Common keypad server functionality. 49.6 + * 49.7 + * Copyright (C) 2023 Paul Boddie <paul@boddie.org.uk> 49.8 + * 49.9 + * This program is free software; you can redistribute it and/or 49.10 + * modify it under the terms of the GNU General Public License as 49.11 + * published by the Free Software Foundation; either version 2 of 49.12 + * the License, or (at your option) any later version. 49.13 + * 49.14 + * This program is distributed in the hope that it will be useful, 49.15 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 49.16 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 49.17 + * GNU General Public License for more details. 49.18 + * 49.19 + * You should have received a copy of the GNU General Public License 49.20 + * along with this program; if not, write to the Free Software 49.21 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, 49.22 + * Boston, MA 02110-1301, USA 49.23 + */ 49.24 + 49.25 +/* Common server functionality. */ 49.26 + 49.27 +#include "keypad-server.h" 49.28 + 49.29 +/* Server infrastructure. */ 49.30 + 49.31 +#include <ipc/server.h> 49.32 +#include "keypad_server.h" 49.33 + 49.34 +#include "keypad-run.h" 49.35 + 49.36 + 49.37 + 49.38 +/* Main program. */ 49.39 + 49.40 +long run(l4re_ds_t mem) 49.41 +{ 49.42 + /* Initialise and register a server object. */ 49.43 + 49.44 + Keypad_server obj(mem); 49.45 + 49.46 + /* Bind and start the IPC server loop. */ 49.47 + 49.48 + if (ipc_server_loop_for(Keypad, &obj, "keypad")) 49.49 + return 1; 49.50 + 49.51 + return 0; 49.52 +}
50.1 --- a/pkg/devices/lcd/include/lcd-ci20.h Sun Jun 11 15:42:11 2023 +0200 50.2 +++ b/pkg/devices/lcd/include/lcd-ci20.h Sun Jun 18 00:19:36 2023 +0200 50.3 @@ -1,7 +1,7 @@ 50.4 /* 50.5 * LCD device support for the MIPS Creator CI20. 50.6 * 50.7 - * Copyright (C) 2018, 2020 Paul Boddie <paul@boddie.org.uk> 50.8 + * Copyright (C) 2018, 2020, 2023 Paul Boddie <paul@boddie.org.uk> 50.9 * 50.10 * This program is free software; you can redistribute it and/or 50.11 * modify it under the terms of the GNU General Public License as 50.12 @@ -21,7 +21,7 @@ 50.13 50.14 #pragma once 50.15 50.16 -#include "lcd-jz4740-device.h" 50.17 +#include <l4/devices/lcd-jz4740-device.h> 50.18 50.19 #ifdef __cplusplus 50.20
51.1 --- a/pkg/devices/lcd/include/lcd-device.h Sun Jun 11 15:42:11 2023 +0200 51.2 +++ b/pkg/devices/lcd/include/lcd-device.h Sun Jun 18 00:19:36 2023 +0200 51.3 @@ -31,9 +31,8 @@ 51.4 51.5 #ifdef __cplusplus 51.6 51.7 -#include <l4/re/dataspace> 51.8 -#include <l4/re/dma_space> 51.9 -#include <l4/sys/capability> 51.10 +#include <l4/re/c/dataspace.h> 51.11 +#include <l4/re/c/dma_space.h> 51.12 51.13 class Lcd_device 51.14 { 51.15 @@ -49,11 +48,11 @@ 51.16 /* Framebuffer virtual and physical addresses. */ 51.17 51.18 l4_addr_t fb_vaddr; 51.19 - L4Re::Dma_space::Dma_addr fb_paddr; 51.20 + l4re_dma_space_dma_addr_t fb_paddr; 51.21 51.22 /* Memory capability for the framebuffer. */ 51.23 51.24 - L4::Cap<L4Re::Dataspace> _fbmem; 51.25 + l4re_ds_t _fbmem; 51.26 51.27 /* Display operations. */ 51.28 51.29 @@ -76,7 +75,7 @@ 51.30 return fb_vaddr; 51.31 } 51.32 51.33 - virtual L4::Cap<L4Re::Dataspace> get_framebuffer_cap() 51.34 + virtual l4re_ds_t get_framebuffer_cap() 51.35 { 51.36 return _fbmem; 51.37 }
52.1 --- a/pkg/devices/lcd/include/lcd-jz4740-device.h Sun Jun 11 15:42:11 2023 +0200 52.2 +++ b/pkg/devices/lcd/include/lcd-jz4740-device.h Sun Jun 18 00:19:36 2023 +0200 52.3 @@ -22,10 +22,9 @@ 52.4 #pragma once 52.5 52.6 #include <l4/devices/lcd.h> 52.7 +#include <l4/devices/lcd-device.h> 52.8 52.9 -#include "lcd-device.h" 52.10 - 52.11 -#include <l4/re/dma_space> 52.12 +#include <l4/re/c/dma_space.h> 52.13 #include <l4/re/c/video/view.h> 52.14 #include <l4/sys/types.h> 52.15 52.16 @@ -42,7 +41,7 @@ 52.17 /* DMA descriptor virtual and physical addresses. */ 52.18 52.19 l4_addr_t desc_vaddr; 52.20 - L4Re::Dma_space::Dma_addr desc_paddr; 52.21 + l4re_dma_space_dma_addr_t desc_paddr; 52.22 52.23 protected: 52.24 /* Device-specific memory allocation. */
53.1 --- a/pkg/devices/lcd/include/lcd-letux400.h Sun Jun 11 15:42:11 2023 +0200 53.2 +++ b/pkg/devices/lcd/include/lcd-letux400.h Sun Jun 18 00:19:36 2023 +0200 53.3 @@ -1,7 +1,7 @@ 53.4 /* 53.5 * LCD device support for the Letux 400 notebook computer. 53.6 * 53.7 - * Copyright (C) 2018, 2020 Paul Boddie <paul@boddie.org.uk> 53.8 + * Copyright (C) 2018, 2020, 2023 Paul Boddie <paul@boddie.org.uk> 53.9 * 53.10 * This program is free software; you can redistribute it and/or 53.11 * modify it under the terms of the GNU General Public License as 53.12 @@ -21,7 +21,7 @@ 53.13 53.14 #pragma once 53.15 53.16 -#include "lcd-jz4740-device.h" 53.17 +#include <l4/devices/lcd-jz4740-device.h> 53.18 53.19 #ifdef __cplusplus 53.20
54.1 --- a/pkg/devices/lcd/include/lcd-qi_lb60.h Sun Jun 11 15:42:11 2023 +0200 54.2 +++ b/pkg/devices/lcd/include/lcd-qi_lb60.h Sun Jun 18 00:19:36 2023 +0200 54.3 @@ -1,7 +1,7 @@ 54.4 /* 54.5 * LCD device support for the Ben NanoNote. 54.6 * 54.7 - * Copyright (C) 2018, 2020 Paul Boddie <paul@boddie.org.uk> 54.8 + * Copyright (C) 2018, 2020, 2023 Paul Boddie <paul@boddie.org.uk> 54.9 * 54.10 * This program is free software; you can redistribute it and/or 54.11 * modify it under the terms of the GNU General Public License as 54.12 @@ -21,7 +21,7 @@ 54.13 54.14 #pragma once 54.15 54.16 -#include "lcd-jz4740-device.h" 54.17 +#include <l4/devices/lcd-jz4740-device.h> 54.18 54.19 #ifdef __cplusplus 54.20
55.1 --- a/pkg/devices/lcd/src/common/Makefile Sun Jun 11 15:42:11 2023 +0200 55.2 +++ b/pkg/devices/lcd/src/common/Makefile Sun Jun 18 00:19:36 2023 +0200 55.3 @@ -17,11 +17,15 @@ 55.4 55.5 CLIENT_INTERFACES_CC = activation 55.6 55.7 +# Generated and plain source files. 55.8 + 55.9 EXPORTED_INTERFACES_H = $(call exported_interfaces_h,$(CLIENT_INTERFACES_CC)) 55.10 55.11 +PLAIN_SRC_CC = lcd-device.cc 55.12 + 55.13 # Normal definitions. 55.14 55.15 -SRC_CC = lcd-device.cc 55.16 +SRC_CC = $(PLAIN_SRC_CC) 55.17 55.18 REQUIRES_LIBS = l4re_c l4re_c-util libdrivers-lcd-headers 55.19 55.20 @@ -30,4 +34,4 @@ 55.21 include $(L4DIR)/mk/lib.mk 55.22 include $(IDL_MK_DIR)/interface_rules.mk 55.23 55.24 -$(SRC_CC): $(EXPORTED_INTERFACES_H) 55.25 +$(PLAIN_SRC_CC): $(EXPORTED_INTERFACES_H)
56.1 --- a/pkg/devices/lcd/src/jz4740/Makefile Sun Jun 11 15:42:11 2023 +0200 56.2 +++ b/pkg/devices/lcd/src/jz4740/Makefile Sun Jun 18 00:19:36 2023 +0200 56.3 @@ -30,7 +30,7 @@ 56.4 REQUIRES_LIBS = \ 56.5 l4re_c l4re_c-util \ 56.6 libdevice-lcd libdrivers-lcd-jz4740 libdrivers-panel-loader \ 56.7 - libdevice-util libipc 56.8 + libdevice-util 56.9 56.10 PRIVATE_INCDIR = $(PKGDIR)/lcd/include $(IDL_BUILD_DIR) $(IDL_EXPORT_DIR) 56.11
57.1 --- a/pkg/devices/lcd/src/jz4740/lcd-jz4740-device.cc Sun Jun 11 15:42:11 2023 +0200 57.2 +++ b/pkg/devices/lcd/src/jz4740/lcd-jz4740-device.cc Sun Jun 18 00:19:36 2023 +0200 57.3 @@ -29,6 +29,7 @@ 57.4 #include <l4/re/c/dma_space.h> 57.5 #include <l4/re/c/mem_alloc.h> 57.6 #include <l4/re/env.h> 57.7 +#include <l4/re/protocols.h> 57.8 #include <l4/sys/factory.h> 57.9 #include <l4/sys/types.h> 57.10 #include <l4/vbus/vbus.h> 57.11 @@ -144,10 +145,14 @@ 57.12 // Create the DMA space. 57.13 57.14 dma = ipc_cap_alloc(); 57.15 - if (l4_is_invalid_cap(dma)) return 1; 57.16 + 57.17 + if (l4_is_invalid_cap(dma)) 57.18 + return 1; 57.19 57.20 vbus = l4re_env_get_cap("vbus"); 57.21 - if (l4_is_invalid_cap(vbus)) return 1; 57.22 + 57.23 + if (l4_is_invalid_cap(vbus)) 57.24 + return 1; 57.25 57.26 if (l4_error(l4_factory_create(l4re_env()->mem_alloc, L4RE_PROTO_DMA_SPACE, dma))) 57.27 return 1; 57.28 @@ -176,16 +181,23 @@ 57.29 // NOTE: necessitate 64 word alignment for the framebuffer. 57.30 57.31 const l4_size_t alloc_flags = L4RE_MA_CONTINUOUS | L4RE_MA_PINNED; 57.32 + const l4re_rm_flags_t attach_flags = L4RE_RM_F_SEARCH_ADDR | L4RE_RM_F_RW; 57.33 57.34 // Map the allocated memory, obtaining virtual addresses. 57.35 57.36 fb_vaddr = 0; 57.37 desc_vaddr = 0; 57.38 57.39 - if (ipc_allocate_align(fb_size, alloc_flags, 8, &fb_vaddr, &_fbmem)) 57.40 + if (ipc_new_dataspace(fb_size, alloc_flags, 8, &_fbmem)) 57.41 return 1; 57.42 57.43 - if (ipc_allocate_align(desc_size, alloc_flags, 6, &desc_vaddr, &descmem)) 57.44 + if (ipc_new_dataspace(desc_size, alloc_flags, 6, &descmem)) 57.45 + return 1; 57.46 + 57.47 + if (ipc_attach_dataspace_align(_fbmem, fb_size, attach_flags, 8, (void **) &fb_vaddr)) 57.48 + return 1; 57.49 + 57.50 + if (ipc_attach_dataspace_align(descmem, desc_size, attach_flags, 6, (void **) &desc_vaddr)) 57.51 return 1; 57.52 57.53 // Obtain physical addresses for the framebuffer and descriptors. 57.54 @@ -201,7 +213,7 @@ 57.55 return 1; 57.56 57.57 if (l4re_dma_space_map(dma, descmem | L4_CAP_FPAGE_RW, 0, &desc_size_out, 0, 57.58 - L4RE_DMA_SPACE_TO_DEVICE, &desc_paddr)) 57.59 + L4RE_DMA_SPACE_TO_DEVICE, &desc_paddr)) 57.60 return 1; 57.61 57.62 // Test the mapped region sizes.
58.1 --- a/pkg/devices/lib/keypad/include/keypad-common.h Sun Jun 11 15:42:11 2023 +0200 58.2 +++ b/pkg/devices/lib/keypad/include/keypad-common.h Sun Jun 18 00:19:36 2023 +0200 58.3 @@ -29,26 +29,26 @@ 58.4 58.5 void *keypad_get(void) 58.6 { 58.7 - return reinterpret_cast<void *>(Keypad::get_keypad()); 58.8 + return reinterpret_cast<void *>(Keypad_generic::get_keypad()); 58.9 } 58.10 58.11 /* Number of keypad columns. */ 58.12 58.13 int keypad_columns(void *keypad) 58.14 { 58.15 - return static_cast<Keypad *>(keypad)->columns(); 58.16 + return static_cast<Keypad_generic *>(keypad)->columns(); 58.17 } 58.18 58.19 /* Number of keypad rows, used by each value in the column array. */ 58.20 58.21 int keypad_rows(void *keypad) 58.22 { 58.23 - return static_cast<Keypad *>(keypad)->rows(); 58.24 + return static_cast<Keypad_generic *>(keypad)->rows(); 58.25 } 58.26 58.27 /* Keycode accessors. */ 58.28 58.29 int keypad_code(void *keypad, int column, int row) 58.30 { 58.31 - return static_cast<Keypad *>(keypad)->code(column, row); 58.32 + return static_cast<Keypad_generic *>(keypad)->code(column, row); 58.33 }
59.1 --- a/pkg/devices/lib/keypad/include/keypad-loader.h Sun Jun 11 15:42:11 2023 +0200 59.2 +++ b/pkg/devices/lib/keypad/include/keypad-loader.h Sun Jun 18 00:19:36 2023 +0200 59.3 @@ -23,4 +23,4 @@ 59.4 59.5 #include "keypad.h" 59.6 59.7 -Keypad *load_keypad(); 59.8 +Keypad_generic *load_keypad();
60.1 --- a/pkg/devices/lib/keypad/include/keypad.h Sun Jun 11 15:42:11 2023 +0200 60.2 +++ b/pkg/devices/lib/keypad/include/keypad.h Sun Jun 18 00:19:36 2023 +0200 60.3 @@ -1,7 +1,7 @@ 60.4 /* 60.5 * Keypad description access. 60.6 * 60.7 - * Copyright (C) 2018 Paul Boddie <paul@boddie.org.uk> 60.8 + * Copyright (C) 2018, 2023 Paul Boddie <paul@boddie.org.uk> 60.9 * 60.10 * This program is free software; you can redistribute it and/or 60.11 * modify it under the terms of the GNU General Public License as 60.12 @@ -25,13 +25,13 @@ 60.13 60.14 #ifdef __cplusplus 60.15 60.16 -class Keypad 60.17 +class Keypad_generic 60.18 { 60.19 public: 60.20 virtual int columns(void) = 0; 60.21 virtual int rows(void) = 0; 60.22 virtual int code(int column, int row) = 0; 60.23 - static Keypad *get_keypad(); 60.24 + static Keypad_generic *get_keypad(); 60.25 }; 60.26 60.27 #endif
61.1 --- a/pkg/devices/lib/keypad/src/letux400/keypad-letux400.cc Sun Jun 11 15:42:11 2023 +0200 61.2 +++ b/pkg/devices/lib/keypad/src/letux400/keypad-letux400.cc Sun Jun 18 00:19:36 2023 +0200 61.3 @@ -1,7 +1,7 @@ 61.4 /* 61.5 * Letux 400 key mapping. 61.6 * 61.7 - * Copyright (C) 2018 Paul Boddie <paul@boddie.org.uk> 61.8 + * Copyright (C) 2018, 2023 Paul Boddie <paul@boddie.org.uk> 61.9 * 61.10 * This program is free software; you can redistribute it and/or 61.11 * modify it under the terms of the GNU General Public License as 61.12 @@ -29,7 +29,7 @@ 61.13 Jz4730_keypad_gpio_outputs_count = 17, 61.14 }; 61.15 61.16 -class Keypad_letux400 : public Keypad 61.17 +class Keypad_letux400 : public Keypad_generic 61.18 { 61.19 /* Keycode definitions. */ 61.20 61.21 @@ -100,7 +100,7 @@ 61.22 61.23 /* Definition access. */ 61.24 61.25 -Keypad *Keypad::get_keypad() 61.26 +Keypad_generic *Keypad_generic::get_keypad() 61.27 { 61.28 return &Keypad_letux400::keypad; 61.29 }
62.1 --- a/pkg/devices/lib/keypad/src/loader/keypad-loader.cc Sun Jun 11 15:42:11 2023 +0200 62.2 +++ b/pkg/devices/lib/keypad/src/loader/keypad-loader.cc Sun Jun 18 00:19:36 2023 +0200 62.3 @@ -1,7 +1,7 @@ 62.4 /* 62.5 * Client functionality for keypad library access. 62.6 * 62.7 - * Copyright (C) 2018 Paul Boddie <paul@boddie.org.uk> 62.8 + * Copyright (C) 2018, 2023 Paul Boddie <paul@boddie.org.uk> 62.9 * 62.10 * This program is free software; you can redistribute it and/or 62.11 * modify it under the terms of the GNU General Public License as 62.12 @@ -23,7 +23,7 @@ 62.13 #include "keypad.h" 62.14 #include "keypad-loader.h" 62.15 62.16 -Keypad *load_keypad() 62.17 +Keypad_generic *load_keypad() 62.18 { 62.19 // Load the keypad library using details in the specified file. 62.20 62.21 @@ -34,5 +34,5 @@ 62.22 62.23 // Return the keypad details. 62.24 62.25 - return (Keypad *) keypad_get(); 62.26 + return (Keypad_generic *) keypad_get(); 62.27 }
63.1 --- a/pkg/devices/lib/keypad/src/qi_lb60/keypad-qi_lb60.cc Sun Jun 11 15:42:11 2023 +0200 63.2 +++ b/pkg/devices/lib/keypad/src/qi_lb60/keypad-qi_lb60.cc Sun Jun 18 00:19:36 2023 +0200 63.3 @@ -1,7 +1,7 @@ 63.4 /* 63.5 * Ben NanoNote key mapping. 63.6 * 63.7 - * Copyright (C) 2018 Paul Boddie <paul@boddie.org.uk> 63.8 + * Copyright (C) 2018, 2023 Paul Boddie <paul@boddie.org.uk> 63.9 * 63.10 * This program is free software; you can redistribute it and/or 63.11 * modify it under the terms of the GNU General Public License as 63.12 @@ -29,7 +29,7 @@ 63.13 Jz4740_keypad_gpio_outputs_count = 8, 63.14 }; 63.15 63.16 -class Keypad_qi_lb60 : public Keypad 63.17 +class Keypad_qi_lb60 : public Keypad_generic 63.18 { 63.19 /* Keycode definitions. */ 63.20 63.21 @@ -94,7 +94,7 @@ 63.22 63.23 /* Definition access. */ 63.24 63.25 -Keypad *Keypad::get_keypad() 63.26 +Keypad_generic *Keypad_generic::get_keypad() 63.27 { 63.28 return &Keypad_qi_lb60::keypad; 63.29 }
64.1 --- a/pkg/devices/util/src/Makefile Sun Jun 11 15:42:11 2023 +0200 64.2 +++ b/pkg/devices/util/src/Makefile Sun Jun 18 00:19:36 2023 +0200 64.3 @@ -8,6 +8,6 @@ 64.4 64.5 PRIVATE_INCDIR += $(PKGDIR)/util/include 64.6 64.7 -REQUIRES_LIBS := libio l4re_c l4re_c-util libdl 64.8 +REQUIRES_LIBS := libio l4re_c l4re_c-util libdl libipc 64.9 64.10 include $(L4DIR)/mk/lib.mk
65.1 --- a/pkg/devices/util/src/dataspace.cc Sun Jun 11 15:42:11 2023 +0200 65.2 +++ b/pkg/devices/util/src/dataspace.cc Sun Jun 18 00:19:36 2023 +0200 65.3 @@ -39,7 +39,12 @@ 65.4 65.5 /* Allocate memory for the data and map it to a virtual address. */ 65.6 65.7 - if (ipc_allocate_align(mem_size, L4RE_MA_CONTINUOUS, 0, allocated, &mem)) 65.8 + if (ipc_new_dataspace(mem_size, L4RE_MA_CONTINUOUS, 0, &mem)) 65.9 + return L4_INVALID_CAP; 65.10 + 65.11 + if (ipc_attach_dataspace_align(mem, mem_size, 65.12 + L4RE_RM_F_SEARCH_ADDR | L4RE_RM_F_RW, 65.13 + 0, allocated)) 65.14 return L4_INVALID_CAP; 65.15 65.16 return mem;
66.1 --- a/pkg/landfall-examples/input_event_client/Makefile Sun Jun 11 15:42:11 2023 +0200 66.2 +++ b/pkg/landfall-examples/input_event_client/Makefile Sun Jun 18 00:19:36 2023 +0200 66.3 @@ -2,8 +2,37 @@ 66.4 L4DIR ?= $(PKGDIR)/../.. 66.5 66.6 TARGET = ex_input_event_client 66.7 -SRC_CC = input_event_client.cc 66.8 -SRC_DATA = unifont.tff 66.9 -REQUIRES_LIBS = l4re_c-util mag-gfx libdevice-input-event-client 66.10 + 66.11 +# Locations for interface input and generated output. 66.12 + 66.13 +IDL_DIR = $(L4DIR)/pkg/devices/idl 66.14 +IDL_MK_DIR = $(L4DIR)/idl4re/mk 66.15 +IDL_BUILD_DIR = . 66.16 +IDL_EXPORT_DIR = . 66.17 + 66.18 +include $(IDL_MK_DIR)/idl.mk 66.19 + 66.20 +# Individual interfaces. 66.21 + 66.22 +CLIENT_INTERFACES_CC = event icu 66.23 + 66.24 +# Generated and plain source files. 66.25 + 66.26 +CLIENT_INTERFACES_SRC_CC = $(call interfaces_to_client_cc,$(CLIENT_INTERFACES_CC)) 66.27 + 66.28 +PLAIN_SRC_CC = input_event_client.cc 66.29 + 66.30 +# Normal definitions. 66.31 + 66.32 +SRC_CC = $(CLIENT_INTERFACES_SRC_CC) $(PLAIN_SRC_CC) 66.33 + 66.34 +SRC_DATA = unifont.tff 66.35 + 66.36 +REQUIRES_LIBS = l4re_c-util mag-gfx libdevice-input-event-loop libipc 66.37 + 66.38 +PRIVATE_INCDIR = $(IDL_BUILD_DIR) $(IDL_EXPORT_DIR) 66.39 66.40 include $(L4DIR)/mk/prog.mk 66.41 +include $(IDL_MK_DIR)/interface_rules.mk 66.42 + 66.43 +$(PLAIN_SRC_CC): $(CLIENT_INTERFACES_SRC_CC)
67.1 --- a/pkg/landfall-examples/input_event_client/input_event_client.cc Sun Jun 11 15:42:11 2023 +0200 67.2 +++ b/pkg/landfall-examples/input_event_client/input_event_client.cc Sun Jun 18 00:19:36 2023 +0200 67.3 @@ -45,25 +45,32 @@ 67.4 67.5 #include <l4/devices/input-event-loop.h> 67.6 67.7 +#include <l4/re/c/rm.h> 67.8 +#include <l4/re/env.h> 67.9 +#include <l4/re/event> 67.10 +#include <l4/re/event_enums.h> 67.11 +#include <l4/sys/factory.h> 67.12 +#include <l4/util/util.h> 67.13 + 67.14 #include <l4/re/c/util/video/goos_fb.h> 67.15 #include <l4/re/c/video/view.h> 67.16 67.17 -#include <l4/re/env> 67.18 -#include <l4/re/event> 67.19 -#include <l4/re/event_enums.h> 67.20 -#include <l4/re/util/cap_alloc> 67.21 -#include <l4/sys/icu.h> 67.22 -#include <l4/util/util.h> 67.23 - 67.24 #include <l4/mag-gfx/canvas> 67.25 #include <l4/mag-gfx/font> 67.26 #include <l4/mag-gfx/geometry> 67.27 #include <l4/mag-gfx/gfx_colors> 67.28 #include <l4/mag-gfx/mem_factory> 67.29 67.30 +#include <ipc/cap_alloc.h> 67.31 + 67.32 #include <stdint.h> 67.33 #include <string.h> 67.34 67.35 +#include "event_client.h" 67.36 +#include "icu_client.h" 67.37 + 67.38 + 67.39 + 67.40 /* Video abstractions. */ 67.41 67.42 static l4re_util_video_goos_fb_t gfb; 67.43 @@ -260,39 +267,52 @@ 67.44 /* Obtain a reference to the event source. It should also be possible to use 67.45 the Input_event_interface for the core operations. */ 67.46 67.47 - L4::Cap<L4Re::Event> event_server = L4Re::Env::env()->get_cap<L4Re::Event>("ev"); 67.48 - if (!event_server.is_valid()) return 1; 67.49 + l4_cap_idx_t event_cap = l4re_env_get_cap("ev"); 67.50 + 67.51 + if (l4_is_invalid_cap(event_cap)) 67.52 + return 1; 67.53 67.54 /* Obtain a capability for the event buffer. */ 67.55 67.56 - L4::Cap<L4Re::Dataspace> mem = L4Re::Util::cap_alloc.alloc<L4Re::Dataspace>(); 67.57 - if (!mem.is_valid()) return 1; 67.58 - if (event_server->get_buffer(mem)) return 1; 67.59 + l4re_ds_t mem = ipc_cap_alloc(); 67.60 + 67.61 + if (l4_is_invalid_cap(mem)) 67.62 + return 1; 67.63 + 67.64 + client_Event event_obj(event_cap); 67.65 + client_ICU icu_obj(event_cap); 67.66 + 67.67 + if (event_obj.get_buffer(&mem)) 67.68 + return 1; 67.69 67.70 /* Attach the event buffer to this task. */ 67.71 67.72 void *evmem = 0; 67.73 67.74 - if (L4Re::Env::env()->rm()->attach(&evmem, mem->size(), 67.75 - L4Re::Rm::F::Search_addr | 67.76 - L4Re::Rm::F::RW, 67.77 - L4::Ipc::make_cap_rw(mem))) 67.78 + if (l4re_rm_attach(&evmem, l4re_ds_size(mem), 67.79 + L4RE_RM_F_SEARCH_ADDR | L4RE_RM_F_RW, 67.80 + mem, 0, 67.81 + L4_PAGESHIFT)) 67.82 return 1; 67.83 67.84 - L4Re::Event_buffer event_buffer = L4Re::Event_buffer(evmem, mem->size()); 67.85 + L4Re::Event_buffer event_buffer(evmem, l4re_ds_size(mem)); 67.86 67.87 /* Obtain an interrupt capability. */ 67.88 67.89 - L4::Cap<L4::Irq> irq = L4Re::Util::cap_alloc.alloc<L4::Irq>(); 67.90 - if (!irq.is_valid()) return 1; 67.91 + l4_cap_idx_t irq = ipc_cap_alloc(); 67.92 + 67.93 + if (l4_is_invalid_cap(irq)) 67.94 + return 1; 67.95 67.96 /* Create an interrupt object. */ 67.97 67.98 - if (l4_error(L4Re::Env::env()->factory()->create(irq))) return 1; 67.99 + if (l4_error(l4_factory_create_irq(l4re_env()->factory, irq))) 67.100 + return 1; 67.101 67.102 /* Bind the interrupt to the event capability. */ 67.103 67.104 - if (l4_error(event_server->bind(0, irq))) return 1; 67.105 + if (icu_obj.bind(0, irq)) 67.106 + return 1; 67.107 67.108 /* Create an event handler. */ 67.109
68.1 --- a/pkg/landfall-examples/keypad_ds_client/Makefile Sun Jun 11 15:42:11 2023 +0200 68.2 +++ b/pkg/landfall-examples/keypad_ds_client/Makefile Sun Jun 18 00:19:36 2023 +0200 68.3 @@ -2,9 +2,35 @@ 68.4 L4DIR ?= $(PKGDIR)/../.. 68.5 68.6 TARGET = ex_keypad_ds_client 68.7 -#SRC_CC = keypad_ds_client.cc 68.8 -#REQUIRES_LIBS = l4re_c-util libdevice-keypad-client 68.9 -SRC_C = keypad_ds_client_c.c 68.10 -REQUIRES_LIBS = l4re_c-util libdevice-keypad-ops 68.11 + 68.12 +# Locations for interface input and generated output. 68.13 + 68.14 +IDL_DIR = $(L4DIR)/pkg/devices/idl 68.15 +IDL_MK_DIR = $(L4DIR)/idl4re/mk 68.16 +IDL_BUILD_DIR = . 68.17 +IDL_EXPORT_DIR = . 68.18 + 68.19 +include $(IDL_MK_DIR)/idl.mk 68.20 + 68.21 +# Individual interfaces. 68.22 + 68.23 +CLIENT_INTERFACES_CC = keypad 68.24 + 68.25 +# Generated and plain source files. 68.26 + 68.27 +CLIENT_INTERFACES_SRC_CC = $(call interfaces_to_client_cc,$(CLIENT_INTERFACES_CC)) 68.28 + 68.29 +PLAIN_SRC_CC = keypad_ds_client.cc 68.30 + 68.31 +# Normal definitions. 68.32 + 68.33 +SRC_CC = $(CLIENT_INTERFACES_SRC_CC) $(PLAIN_SRC_CC) 68.34 + 68.35 +REQUIRES_LIBS = l4re_c l4re_c-util libipc 68.36 + 68.37 +PRIVATE_INCDIR = $(IDL_BUILD_DIR) $(IDL_EXPORT_DIR) 68.38 68.39 include $(L4DIR)/mk/prog.mk 68.40 +include $(IDL_MK_DIR)/interface_rules.mk 68.41 + 68.42 +$(PLAIN_SRC_CC): $(CLIENT_INTERFACES_SRC_CC)
69.1 --- a/pkg/landfall-examples/keypad_ds_client/keypad_ds_client.cc Sun Jun 11 15:42:11 2023 +0200 69.2 +++ b/pkg/landfall-examples/keypad_ds_client/keypad_ds_client.cc Sun Jun 18 00:19:36 2023 +0200 69.3 @@ -19,23 +19,24 @@ 69.4 * Boston, MA 02110-1301, USA 69.5 */ 69.6 69.7 -#include <l4/devices/keypad-client.h> 69.8 - 69.9 -#include <l4/cxx/ipc_server> 69.10 -#include <l4/re/dataspace> 69.11 -#include <l4/re/env> 69.12 -#include <l4/re/rm> 69.13 -#include <l4/re/util/cap_alloc> 69.14 +#include <l4/re/c/dataspace.h> 69.15 +#include <l4/re/c/rm.h> 69.16 +#include <l4/re/env.h> 69.17 69.18 #include <l4/re/c/util/video/goos_fb.h> 69.19 #include <l4/re/c/video/view.h> 69.20 69.21 -#include <l4/util/util.h> 69.22 +#include <ipc/cap_alloc.h> 69.23 + 69.24 #include <stdio.h> 69.25 #include <unistd.h> 69.26 #include <stdint.h> 69.27 #include <stdlib.h> 69.28 69.29 +#include "keypad_client.h" 69.30 + 69.31 + 69.32 + 69.33 /* Video abstractions. */ 69.34 69.35 static l4re_util_video_goos_fb_t gfb; 69.36 @@ -44,8 +45,7 @@ 69.37 69.38 /* Keypad status and dimensions. */ 69.39 69.40 -uint32_t *keypad = 0; 69.41 -void *keymem = 0; 69.42 +uint32_t *keymem = 0; 69.43 int columns, rows; 69.44 69.45 69.46 @@ -109,7 +109,7 @@ 69.47 row++, mask >>= 1) 69.48 69.49 show_keystate(column * colsize, row * rowsize, colsize, rowsize, 69.50 - keypad[column] & mask ? 0xffffff : 0); 69.51 + keymem[column] & mask ? 0xffffff : 0); 69.52 69.53 /* Refresh the display. */ 69.54 69.55 @@ -120,8 +120,8 @@ 69.56 69.57 int main(int argc, char *argv[]) 69.58 { 69.59 - L4::Cap<Keypad_device_interface> keypad_server; 69.60 - L4::Cap<L4Re::Dataspace> mem; 69.61 + l4_cap_idx_t keypad_cap; 69.62 + l4re_ds_t mem; 69.63 69.64 /* Obtain the keypad matrix dimensions. */ 69.65 69.66 @@ -142,31 +142,37 @@ 69.67 69.68 /* Obtain a reference to the keypad. */ 69.69 69.70 - keypad_server = L4Re::Env::env()->get_cap<Keypad_device_interface>("keypad"); 69.71 - if (!keypad_server.is_valid()) return 1; 69.72 + keypad_cap = l4re_env_get_cap("keypad"); 69.73 + 69.74 + if (l4_is_invalid_cap(keypad_cap)) 69.75 + return 1; 69.76 69.77 /* Obtain a capability for the keypad data. */ 69.78 69.79 - mem = L4Re::Util::cap_alloc.alloc<L4Re::Dataspace>(); 69.80 - if (!mem.is_valid()) return 1; 69.81 + mem = ipc_cap_alloc(); 69.82 + 69.83 + if (l4_is_invalid_cap(mem)) 69.84 + return 1; 69.85 69.86 /* Obtain a reference to the keypad data. */ 69.87 69.88 - if (keypad_server->get_keypad_data(mem)) return 1; 69.89 + client_Keypad keypad(keypad_cap); 69.90 + 69.91 + if (keypad.get_keypad_data(&mem)) 69.92 + return 1; 69.93 69.94 /* Attach the keypad data to a region in this task. */ 69.95 69.96 - if (L4Re::Env::env()->rm()->attach(&keymem, mem->size(), 69.97 - L4Re::Rm::F::Search_addr | 69.98 - L4Re::Rm::F::R, 69.99 - L4::Ipc::make_cap_rw(mem))) 69.100 + if (l4re_rm_attach((void **) &keymem, l4re_ds_size(mem), 69.101 + L4RE_RM_F_SEARCH_ADDR | L4RE_RM_F_R, 69.102 + mem, 0, 69.103 + L4_PAGESHIFT)) 69.104 return 1; 69.105 69.106 /* Show the keypad state. */ 69.107 69.108 - keypad = (uint32_t *) keymem; 69.109 - 69.110 - while (1) show_keypad(); 69.111 + while (1) 69.112 + show_keypad(); 69.113 69.114 return 0; 69.115 }
70.1 --- a/pkg/landfall-examples/keypad_ds_client/keypad_ds_client_c.c Sun Jun 11 15:42:11 2023 +0200 70.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 70.3 @@ -1,179 +0,0 @@ 70.4 -/* 70.5 - * Display the keypad matrix using the specified dimensions. 70.6 - * 70.7 - * Copyright (C) 2018, 2023 Paul Boddie <paul@boddie.org.uk> 70.8 - * 70.9 - * This program is free software; you can redistribute it and/or 70.10 - * modify it under the terms of the GNU General Public License as 70.11 - * published by the Free Software Foundation; either version 2 of 70.12 - * the License, or (at your option) any later version. 70.13 - * 70.14 - * This program is distributed in the hope that it will be useful, 70.15 - * but WITHOUT ANY WARRANTY; without even the implied warranty of 70.16 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 70.17 - * GNU General Public License for more details. 70.18 - * 70.19 - * You should have received a copy of the GNU General Public License 70.20 - * along with this program; if not, write to the Free Software 70.21 - * Foundation, Inc., 51 Franklin Street, Fifth Floor, 70.22 - * Boston, MA 02110-1301, USA 70.23 - */ 70.24 - 70.25 -#include <l4/devices/keypad-ops.h> 70.26 - 70.27 -#include <l4/re/c/rm.h> 70.28 -#include <l4/re/c/util/cap_alloc.h> 70.29 -#include <l4/re/env.h> 70.30 -#include <l4/util/util.h> 70.31 -#include <l4/sys/ipc.h> 70.32 - 70.33 -#include <l4/re/c/util/video/goos_fb.h> 70.34 -#include <l4/re/c/video/view.h> 70.35 - 70.36 -#include <stdio.h> 70.37 -#include <unistd.h> 70.38 -#include <stdint.h> 70.39 -#include <stdlib.h> 70.40 - 70.41 -/* Video abstractions. */ 70.42 - 70.43 -static l4re_util_video_goos_fb_t gfb; 70.44 -static l4re_video_view_info_t fbi; 70.45 -static void *fb; 70.46 - 70.47 -/* Keypad status and dimensions. */ 70.48 - 70.49 -uint32_t *keypad = 0; 70.50 -void *keymem = 0; 70.51 -int columns, rows; 70.52 - 70.53 - 70.54 - 70.55 -static uint32_t bitmask(uint32_t size) 70.56 -{ 70.57 - return (1 << size) - 1; 70.58 -} 70.59 - 70.60 -static uint32_t truncate_channel(uint32_t value, uint32_t size) 70.61 -{ 70.62 - return (value >> (8 - size)) & bitmask(size); 70.63 -} 70.64 - 70.65 -static void set_pixel(uint32_t pos, uint8_t bpp, uint32_t value) 70.66 -{ 70.67 - if (bpp <= 8) *(uint8_t *) pos = value; 70.68 - else if (bpp <= 16) *(uint16_t *) pos = value; 70.69 - else *(uint32_t *) pos = value; 70.70 -} 70.71 - 70.72 -/* Show the state of a key on the display. */ 70.73 - 70.74 -static void show_keystate(uint32_t x, uint32_t y, uint32_t w, uint32_t h, uint32_t rgb) 70.75 -{ 70.76 - uint8_t bpp = l4re_video_bits_per_pixel(&fbi.pixel_info); 70.77 - uint8_t bytes_per_pixel = fbi.pixel_info.bytes_per_pixel; 70.78 - uint32_t bytes_per_line = fbi.bytes_per_line; 70.79 - uint32_t pos; 70.80 - uint32_t col, row; 70.81 - 70.82 - rgb = (truncate_channel(rgb >> 16, fbi.pixel_info.r.size) << fbi.pixel_info.r.shift) | 70.83 - (truncate_channel(rgb >> 8, fbi.pixel_info.g.size) << fbi.pixel_info.g.shift) | 70.84 - (truncate_channel(rgb, fbi.pixel_info.b.size) << fbi.pixel_info.b.shift); 70.85 - 70.86 - for (row = 0; row < h; row++) 70.87 - { 70.88 - pos = (uint32_t) fb + (y + row) * bytes_per_line + x * bytes_per_pixel; 70.89 - 70.90 - for (col = 0; col < w; col++) 70.91 - { 70.92 - set_pixel(pos, bpp, rgb); 70.93 - pos += bytes_per_pixel; 70.94 - } 70.95 - } 70.96 -} 70.97 - 70.98 -/* Show the keypad status on the display. */ 70.99 - 70.100 -static void show_keypad(void) 70.101 -{ 70.102 - uint32_t colsize = fbi.width / columns, 70.103 - rowsize = fbi.height / rows; 70.104 - uint8_t column, row; 70.105 - uint32_t mask; 70.106 - 70.107 - for (column = 0; column < columns; column++) 70.108 - 70.109 - for (row = 0, mask = 1 << (rows - 1); 70.110 - row < rows; 70.111 - row++, mask >>= 1) 70.112 - 70.113 - show_keystate(column * colsize, row * rowsize, colsize, rowsize, 70.114 - keypad[column] & mask ? 0xffffff : 0); 70.115 - 70.116 - /* Refresh the display. */ 70.117 - 70.118 - l4re_util_video_goos_fb_refresh(&gfb, 0, 0, fbi.width, fbi.height); 70.119 -} 70.120 - 70.121 - 70.122 - 70.123 -int main(int argc, char *argv[]) 70.124 -{ 70.125 - l4_cap_idx_t keypad_server; 70.126 - l4re_ds_t mem; 70.127 - l4_msgtag_t tag; 70.128 - 70.129 - /* Obtain the keypad matrix dimensions. */ 70.130 - 70.131 - if (argc < 3) 70.132 - return 1; 70.133 - 70.134 - columns = atoi(argv[1]); 70.135 - rows = atoi(argv[2]); 70.136 - 70.137 - if (l4re_util_video_goos_fb_setup_name(&gfb, "fb")) 70.138 - return 1; 70.139 - 70.140 - if (l4re_util_video_goos_fb_view_info(&gfb, &fbi)) 70.141 - return 1; 70.142 - 70.143 - if (!(fb = l4re_util_video_goos_fb_attach_buffer(&gfb))) 70.144 - return 1; 70.145 - 70.146 - /* Obtain a reference to the keypad. */ 70.147 - 70.148 - keypad_server = l4re_env_get_cap("keypad"); 70.149 - if (l4_is_invalid_cap(keypad_server)) return 1; 70.150 - 70.151 - /* Obtain a capability for the keypad data. */ 70.152 - 70.153 - mem = l4re_util_cap_alloc(); 70.154 - if (l4_is_invalid_cap(mem)) return 1; 70.155 - 70.156 - /* Obtain a reference to the keypad data. */ 70.157 - 70.158 - l4_utcb_br()->bdr = 0; 70.159 - l4_utcb_br()->br[0] = L4_RCV_ITEM_SINGLE_CAP | mem; 70.160 - 70.161 - tag = l4_ipc_call(keypad_server, l4_utcb(), 70.162 - l4_msgtag(Keypad_op_get_keypad_data, 0, 0, 0), /* zero words, zero *sent* items */ 70.163 - L4_IPC_NEVER); 70.164 - 70.165 - if (l4_ipc_error(tag, l4_utcb())) return 1; 70.166 - 70.167 - /* Attach the keypad data to a region in this task. */ 70.168 - 70.169 - if (l4re_rm_attach(&keymem, l4re_ds_size(mem), 70.170 - L4RE_RM_F_SEARCH_ADDR | L4RE_RM_F_R, 70.171 - mem, 0, 70.172 - L4_PAGESHIFT)) 70.173 - return 1; 70.174 - 70.175 - /* Show the keypad state. */ 70.176 - 70.177 - keypad = (uint32_t *) keymem; 70.178 - 70.179 - while (1) show_keypad(); 70.180 - 70.181 - return 0; 70.182 -}
71.1 --- a/pkg/landfall-examples/letux400_backlight/letux400_backlight.cc Sun Jun 11 15:42:11 2023 +0200 71.2 +++ b/pkg/landfall-examples/letux400_backlight/letux400_backlight.cc Sun Jun 18 00:19:36 2023 +0200 71.3 @@ -4,7 +4,7 @@ 71.4 * Fn+Down/Up adjusts the brightness. 71.5 * Zzz+Down/Up disables/enables the backlight. 71.6 * 71.7 - * Copyright (C) 2018, 2020 Paul Boddie <paul@boddie.org.uk> 71.8 + * Copyright (C) 2018, 2020, 2023 Paul Boddie <paul@boddie.org.uk> 71.9 * 71.10 * This program is free software; you can redistribute it and/or 71.11 * modify it under the terms of the GNU General Public License as 71.12 @@ -33,6 +33,8 @@ 71.13 #include "activation_client.h" 71.14 #include "backlight_client.h" 71.15 71.16 + 71.17 + 71.18 /* Backlight level. */ 71.19 71.20 enum Letux400_backlight_levels 71.21 @@ -114,13 +116,15 @@ 71.22 { 71.23 /* Load the keypad library using details from the configured library. */ 71.24 71.25 - Keypad *keypad = (Keypad *) load_keypad(); 71.26 + Keypad_generic *keypad = (Keypad_generic *) load_keypad(); 71.27 Input_keypad_client client(keypad); 71.28 71.29 /* Obtain a reference to the backlight device. */ 71.30 71.31 l4_cap_idx_t backlight = l4re_env_get_cap("backlight"); 71.32 - if (!l4_is_valid_cap(backlight)) return 1; 71.33 + 71.34 + if (!l4_is_valid_cap(backlight)) 71.35 + return 1; 71.36 71.37 /* NOTE: The component framework should permit the use of a compound client 71.38 object. */
72.1 --- a/pkg/landfall-examples/qi_lb60_backlight/qi_lb60_backlight.cc Sun Jun 11 15:42:11 2023 +0200 72.2 +++ b/pkg/landfall-examples/qi_lb60_backlight/qi_lb60_backlight.cc Sun Jun 18 00:19:36 2023 +0200 72.3 @@ -4,7 +4,7 @@ 72.4 * Fn+Volume Down/Up adjusts the brightness. 72.5 * Red Arrow+Volume Down/Up disables/enables the backlight. 72.6 * 72.7 - * Copyright (C) 2018, 2020 Paul Boddie <paul@boddie.org.uk> 72.8 + * Copyright (C) 2018, 2020, 2023 Paul Boddie <paul@boddie.org.uk> 72.9 * 72.10 * This program is free software; you can redistribute it and/or 72.11 * modify it under the terms of the GNU General Public License as 72.12 @@ -33,6 +33,8 @@ 72.13 #include "activation_client.h" 72.14 #include "backlight_client.h" 72.15 72.16 + 72.17 + 72.18 /* Backlight level. */ 72.19 72.20 enum Qi_lb60_backlight_levels 72.21 @@ -114,13 +116,15 @@ 72.22 { 72.23 // Load the keypad details from the configured library. 72.24 72.25 - Keypad *keypad = (Keypad *) load_keypad(); 72.26 + Keypad_generic *keypad = (Keypad_generic *) load_keypad(); 72.27 Input_keypad_client client(keypad); 72.28 72.29 /* Obtain a reference to the backlight device. */ 72.30 72.31 l4_cap_idx_t backlight = l4re_env_get_cap("backlight"); 72.32 - if (!l4_is_valid_cap(backlight)) return 1; 72.33 + 72.34 + if (!l4_is_valid_cap(backlight)) 72.35 + return 1; 72.36 72.37 /* NOTE: The component framework should permit the use of a compound client 72.38 object. */