# HG changeset patch # User Paul Boddie # Date 1686490931 -7200 # Node ID c9a29e1ba843b5df69e4f29ec0f8f97a94496e64 # Parent bd0a7c48777939cfe557864a64ac13cc7351f862 Introduced a variety of changes and updates for testing. diff -r bd0a7c487779 -r c9a29e1ba843 pkg/devices/backlight/src/pwm/Makefile --- a/pkg/devices/backlight/src/pwm/Makefile Sat Jun 10 23:59:44 2023 +0200 +++ b/pkg/devices/backlight/src/pwm/Makefile Sun Jun 11 15:42:11 2023 +0200 @@ -14,24 +14,17 @@ include $(IDL_MK_DIR)/idl.mk -# Compound interface definitions. - -backlight_object_NAME = BacklightObject -backlight_object_INTERFACES = activation backlight - -COMP_INTERFACES_CC = backlight_object - # Individual interfaces. CLIENT_INTERFACES_CC = activation pwm -SERVER_INTERFACES_CC = $(call common_interfaces,$(COMP_INTERFACES_CC)) +SERVER_INTERFACES_CC = backlight_object # Generated and plain source files. CLIENT_INTERFACES_SRC_CC = $(call interfaces_to_client_cc,$(CLIENT_INTERFACES_CC)) -SERVER_INTERFACES_SRC_CC = $(call interfaces_to_server_cc,$(SERVER_INTERFACES_CC) $(COMP_INTERFACES_CC)) +SERVER_INTERFACES_SRC_CC = $(call interfaces_to_server_cc,$(SERVER_INTERFACES_CC)) PLAIN_SRC_CC = backlight-pwm.cc diff -r bd0a7c487779 -r c9a29e1ba843 pkg/devices/backlight/src/pwm/backlight-pwm.cc --- a/pkg/devices/backlight/src/pwm/backlight-pwm.cc Sat Jun 10 23:59:44 2023 +0200 +++ b/pkg/devices/backlight/src/pwm/backlight-pwm.cc Sun Jun 11 15:42:11 2023 +0200 @@ -1,7 +1,7 @@ /* * Access a PWM server to update a display panel 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 @@ -24,6 +24,7 @@ #include #include + #include "backlight_object_server.h" #include "activation_client.h" #include "pwm_client.h" @@ -32,14 +33,14 @@ /* Backlight device. */ -class server_BacklightObject : public BacklightObject +class BacklightObject_server : public BacklightObject { Activation *_activation; PWM *_pwm; int _min, _max; public: - explicit server_BacklightObject(Activation *activation, PWM *pwm, + explicit BacklightObject_server(Activation *activation, PWM *pwm, int min, int max) : _activation(activation), _pwm(pwm), _min(min), _max(max) { @@ -84,7 +85,9 @@ /* Obtain a reference to the PWM device. */ l4_cap_idx_t pwm = l4re_env_get_cap("pwm"); - if (!l4_is_valid_cap(pwm)) return 1; + + if (!l4_is_valid_cap(pwm)) + return 1; client_Activation activation_obj(pwm); client_PWM pwm_obj(pwm); @@ -94,14 +97,12 @@ min = atoi(argv[1]); max = atoi(argv[2]); - server_BacklightObject obj(&activation_obj, &pwm_obj, min, max); - l4_cap_idx_t server; + BacklightObject_server obj(&activation_obj, &pwm_obj, min, max); - if (ipc_server_bind("backlight", (l4_umword_t) &obj, &server)) return 1; + /* Bind and start the IPC server loop. */ - /* Enter the IPC server loop. */ + if (ipc_server_loop_for(BacklightObject, &obj, "backlight")) + return 1; - ipc_server_loop(BacklightObject_expected_items, &obj, - (ipc_server_handler_type) handle_BacklightObject); return 0; } diff -r bd0a7c487779 -r c9a29e1ba843 pkg/devices/backlight/src/spi-ili8960/Makefile --- a/pkg/devices/backlight/src/spi-ili8960/Makefile Sat Jun 10 23:59:44 2023 +0200 +++ b/pkg/devices/backlight/src/spi-ili8960/Makefile Sun Jun 11 15:42:11 2023 +0200 @@ -14,24 +14,17 @@ include $(IDL_MK_DIR)/idl.mk -# Compound interface definitions. - -backlight_object_NAME = BacklightObject -backlight_object_INTERFACES = activation backlight - -COMP_INTERFACES_CC = backlight_object - # Individual interfaces. CLIENT_INTERFACES_CC = spi -SERVER_INTERFACES_CC = $(call common_interfaces,$(COMP_INTERFACES_CC)) +SERVER_INTERFACES_CC = backlight_object # Generated and plain source files. CLIENT_INTERFACES_SRC_CC = $(call interfaces_to_client_cc,$(CLIENT_INTERFACES_CC)) -SERVER_INTERFACES_SRC_CC = $(call interfaces_to_server_cc,$(SERVER_INTERFACES_CC) $(COMP_INTERFACES_CC)) +SERVER_INTERFACES_SRC_CC = $(call interfaces_to_server_cc,$(SERVER_INTERFACES_CC)) PLAIN_SRC_CC = backlight-spi-ili8960.cc diff -r bd0a7c487779 -r c9a29e1ba843 pkg/devices/backlight/src/spi-ili8960/backlight-spi-ili8960.cc --- a/pkg/devices/backlight/src/spi-ili8960/backlight-spi-ili8960.cc Sat Jun 10 23:59:44 2023 +0200 +++ b/pkg/devices/backlight/src/spi-ili8960/backlight-spi-ili8960.cc Sun Jun 11 15:42:11 2023 +0200 @@ -5,7 +5,7 @@ * the Giantplus GPM940B0 panel datasheet also describes this controller * interface. * - * 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 @@ -26,6 +26,7 @@ #include #include + #include "backlight_object_server.h" #include "spi_client.h" @@ -33,7 +34,7 @@ /* Backlight device. */ -class server_BacklightObject : public BacklightObject +class BacklightObject_server : public BacklightObject { SPI *_spi; int _min = 55, _max = 90, _start = 70; @@ -54,7 +55,7 @@ } public: - explicit server_BacklightObject(SPI *spi) + explicit BacklightObject_server(SPI *spi) : _spi(spi) { } @@ -92,20 +93,20 @@ /* Obtain a reference to the SPI device. */ l4_cap_idx_t spi = l4re_env_get_cap("spi"); - if (!l4_is_valid_cap(spi)) return 1; + + if (!l4_is_valid_cap(spi)) + return 1; client_SPI spi_obj(spi); /* Initialise and register a new server object. */ - server_BacklightObject obj(&spi_obj); - l4_cap_idx_t server; + BacklightObject_server obj(&spi_obj); - if (ipc_server_bind("backlight", (l4_umword_t) &obj, &server)) return 1; + /* Bind and start the IPC server loop. */ - /* Enter the IPC server loop. */ + if (ipc_server_loop_for(BacklightObject, &obj, "backlight")) + return 1; - ipc_server_loop(BacklightObject_expected_items, &obj, - (ipc_server_handler_type) handle_BacklightObject); return 0; } diff -r bd0a7c487779 -r c9a29e1ba843 pkg/devices/cpm/src/jz4730/cpm-jz4730.cc --- a/pkg/devices/cpm/src/jz4730/cpm-jz4730.cc Sat Jun 10 23:59:44 2023 +0200 +++ b/pkg/devices/cpm/src/jz4730/cpm-jz4730.cc Sun Jun 11 15:42:11 2023 +0200 @@ -1,7 +1,7 @@ /* * JZ4730 CPM server. * - * Copyright (C) 2018, 2020, 2021 Paul Boddie + * Copyright (C) 2018, 2020, 2021, 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,6 +25,7 @@ #include #include + #include "cpm_server.h" /* Virtual addresses for the CPM and LCD register blocks. */ @@ -47,12 +48,12 @@ /* CPM server. */ -class server_CPM : public CPM +class CPM_server : public CPM { Cpm_jz4730_chip *_chip; public: - explicit server_CPM(Cpm_jz4730_chip *chip) + explicit CPM_server(Cpm_jz4730_chip *chip) : _chip(chip) { } @@ -94,7 +95,8 @@ int main(void) { - if (setup_memory()) return 1; + if (setup_memory()) + return 1; /* Initialise the CPM abstraction. */ @@ -102,14 +104,12 @@ /* Initialise and register a server object. */ - server_CPM obj(&cpm_device); - l4_cap_idx_t server; + CPM_server obj(&cpm_device); - if (ipc_server_bind("cpm", (l4_umword_t) &obj, &server)) return 1; + /* Bind and start the IPC server loop. */ - /* Enter the IPC server loop. */ + if (ipc_server_loop_for(CPM, &obj, "cpm")) + return 1; - ipc_server_loop(CPM_expected_items, &obj, - (ipc_server_handler_type) handle_CPM); return 0; } diff -r bd0a7c487779 -r c9a29e1ba843 pkg/devices/cpm/src/jz4740/cpm-jz4740.cc --- a/pkg/devices/cpm/src/jz4740/cpm-jz4740.cc Sat Jun 10 23:59:44 2023 +0200 +++ b/pkg/devices/cpm/src/jz4740/cpm-jz4740.cc Sun Jun 11 15:42:11 2023 +0200 @@ -1,7 +1,7 @@ /* * JZ4740 CPM server. * - * Copyright (C) 2018, 2020, 2021 Paul Boddie + * Copyright (C) 2018, 2020, 2021, 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,6 +25,7 @@ #include #include + #include "cpm_server.h" // Virtual addresses for the CPM and LCD register blocks. @@ -47,12 +48,12 @@ /* CPM server. */ -class server_CPM : public CPM +class CPM_server : public CPM { Cpm_jz4740_chip *_chip; public: - explicit server_CPM(Cpm_jz4740_chip *chip) + explicit CPM_server(Cpm_jz4740_chip *chip) : _chip(chip) { } @@ -94,7 +95,8 @@ int main(void) { - if (setup_memory()) return 1; + if (setup_memory()) + return 1; /* Initialise the CPM abstraction. */ @@ -102,14 +104,12 @@ /* Initialise and register a server object. */ - server_CPM obj(&cpm_device); - l4_cap_idx_t server; + CPM_server obj(&cpm_device); - if (ipc_server_bind("cpm", (l4_umword_t) &obj, &server)) return 1; + /* Bind and start the IPC server loop. */ - /* Enter the IPC server loop. */ - - ipc_server_loop(CPM_expected_items, &obj, - (ipc_server_handler_type) handle_CPM); + if (ipc_server_loop_for(CPM, &obj, "cpm")) + return 1; + return 0; } diff -r bd0a7c487779 -r c9a29e1ba843 pkg/devices/cpm/src/jz4780/cpm-jz4780.cc --- a/pkg/devices/cpm/src/jz4780/cpm-jz4780.cc Sat Jun 10 23:59:44 2023 +0200 +++ b/pkg/devices/cpm/src/jz4780/cpm-jz4780.cc Sun Jun 11 15:42:11 2023 +0200 @@ -1,7 +1,7 @@ /* * JZ4780 CPM server. * - * Copyright (C) 2018, 2020, 2021 Paul Boddie + * Copyright (C) 2018, 2020, 2021, 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,6 +25,7 @@ #include #include + #include "cpm_server.h" // Virtual addresses for the CPM and LCD register blocks. @@ -47,12 +48,12 @@ /* CPM server. */ -class server_CPM : public CPM +class CPM_server : public CPM { Cpm_jz4780_chip *_chip; public: - explicit server_CPM(Cpm_jz4780_chip *chip) + explicit CPM_server(Cpm_jz4780_chip *chip) : _chip(chip) { } @@ -100,7 +101,8 @@ int main(void) { - if (setup_memory()) return 1; + if (setup_memory()) + return 1; /* Initialise the CPM abstraction. */ @@ -108,14 +110,12 @@ /* Initialise and register a server object. */ - server_CPM obj(&cpm_device); - l4_cap_idx_t server; + CPM_server obj(&cpm_device); - if (ipc_server_bind("cpm", (l4_umword_t) &obj, &server)) return 1; + /* Bind and start the IPC server loop. */ - /* Enter the IPC server loop. */ + if (ipc_server_loop_for(CPM, &obj, "cpm")) + return 1; - ipc_server_loop(CPM_expected_items, &obj, - (ipc_server_handler_type) handle_CPM); return 0; } diff -r bd0a7c487779 -r c9a29e1ba843 pkg/devices/display/src/ci20/display-ci20_hdmi.cc --- a/pkg/devices/display/src/ci20/display-ci20_hdmi.cc Sat Jun 10 23:59:44 2023 +0200 +++ b/pkg/devices/display/src/ci20/display-ci20_hdmi.cc Sun Jun 11 15:42:11 2023 +0200 @@ -1,7 +1,7 @@ /* * Export MIPS Creator CI20 HDMI display operations as a server. * - * Copyright (C) 2018, 2020, 2021 Paul Boddie + * Copyright (C) 2018, 2020, 2021, 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,10 +29,13 @@ #include #include + #include "activation_server.h" #include "cpm_client.h" #include "icu_client.h" + + /* Virtual addresses for the HDMI register block plus interrupt capability. */ static l4_addr_t hdmi_virt_base = 0, hdmi_virt_base_end = 0; @@ -101,7 +104,7 @@ /* Display device. */ -class server_DisplayObject : public Activation +class DisplayObject_server : public Activation { public: /* Switch the display off. */ @@ -132,18 +135,17 @@ int main(void) { - if (setup_memory()) return 1; + if (setup_memory()) + return 1; /* Initialise and register a new server object. */ - server_DisplayObject obj; - l4_cap_idx_t server; + DisplayObject_server obj; - if (ipc_server_bind("display", (l4_umword_t) &obj, &server)) return 1; + /* Bind and start the IPC server loop. */ - /* Enter the IPC server loop. */ + if (ipc_server_loop_for(Activation, &obj, "display")) + return 1; - ipc_server_loop(Activation_expected_items, &obj, - (ipc_server_handler_type) handle_Activation); return 0; } diff -r bd0a7c487779 -r c9a29e1ba843 pkg/devices/display/src/letux400/display-letux400.cc --- a/pkg/devices/display/src/letux400/display-letux400.cc Sat Jun 10 23:59:44 2023 +0200 +++ b/pkg/devices/display/src/letux400/display-letux400.cc Sun Jun 11 15:42:11 2023 +0200 @@ -1,7 +1,7 @@ /* * Export Letux 400 display operations as a server. * - * 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 @@ -25,9 +25,12 @@ #include #include + #include "activation_client.h" #include "activation_server.h" + + /* Virtual address for the GPIO register block. */ static l4_addr_t gpio_virt_base = 0, gpio_virt_base_end = 0; @@ -66,7 +69,7 @@ /* Display device only implementing the activation interface. */ -class server_DisplayObject : public Activation +class DisplayObject_server : public Activation { Pin_slice lcd_mask1 = {.offset=0, .mask=Jz4730_lcd_gpio_func1}; Pin_slice lcd_mask2 = {.offset=0, .mask=Jz4730_lcd_gpio_func2}; @@ -74,7 +77,7 @@ Activation *_backlight; public: - explicit server_DisplayObject(Activation *backlight) + explicit DisplayObject_server(Activation *backlight) : _backlight(backlight) { /* Set functions for the LCD pins. */ @@ -111,7 +114,8 @@ int main(void) { - if (setup_memory()) return 1; + if (setup_memory()) + return 1; /* Initialise the GPIO abstractions. */ @@ -124,7 +128,9 @@ /* 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; /* Use the activation interface with the backlight. */ @@ -132,14 +138,12 @@ /* Initialise and register a new server object. */ - server_DisplayObject obj(&backlight_obj); - l4_cap_idx_t server; - - if (ipc_server_bind("display", (l4_umword_t) &obj, &server)) return 1; + DisplayObject_server obj(&backlight_obj); /* Enter the IPC server loop. */ - ipc_server_loop(Activation_expected_items, &obj, - (ipc_server_handler_type) handle_Activation); + if (ipc_server_loop_for(Activation, &obj, "display")) + return 1; + return 0; } diff -r bd0a7c487779 -r c9a29e1ba843 pkg/devices/display/src/qi_lb60/display-qi_lb60.cc --- a/pkg/devices/display/src/qi_lb60/display-qi_lb60.cc Sat Jun 10 23:59:44 2023 +0200 +++ b/pkg/devices/display/src/qi_lb60/display-qi_lb60.cc Sun Jun 11 15:42:11 2023 +0200 @@ -1,7 +1,7 @@ /* * Export Ben NanoNote display operations as a server. * - * 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 @@ -27,9 +27,12 @@ #include #include + #include "activation_client.h" #include "activation_server.h" + + /* Virtual address for the GPIO register block. */ static l4_addr_t gpio_virt_base = 0, gpio_virt_base_end = 0; @@ -68,7 +71,7 @@ /* Display device only implementing the activation interface. */ -class server_DisplayObject : public Activation +class DisplayObject_server : public Activation { Pin_slice slcd8_mask = {.offset=0, .mask=(1 << Jz4740_lcd_gpio_cs) | (1 << Jz4740_lcd_gpio_rs) | (1 << Jz4740_lcd_gpio_clk) | Jz4740_lcd_gpio_d0_d7}; @@ -76,7 +79,7 @@ Activation *_backlight; public: - explicit server_DisplayObject(Activation *backlight) + explicit DisplayObject_server(Activation *backlight) : _backlight(backlight) { } @@ -108,7 +111,8 @@ int main(void) { - if (setup_memory()) return 1; + if (setup_memory()) + return 1; /* Initialise the GPIO abstraction. */ @@ -119,7 +123,9 @@ /* 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; /* Use the activation interface with the backlight. */ @@ -127,14 +133,12 @@ /* Initialise and register a new server object. */ - server_DisplayObject obj(&backlight_obj); - l4_cap_idx_t server; + DisplayObject_server obj(&backlight_obj); - if (ipc_server_bind("display", (l4_umword_t) &obj, &server)) return 1; + /* Bind and start the IPC server loop. */ - /* Enter the IPC server loop. */ + if (ipc_server_loop_for(Activation, &obj, "display")) + return 1; - ipc_server_loop(Activation_expected_items, &obj, - (ipc_server_handler_type) handle_Activation); return 0; } diff -r bd0a7c487779 -r c9a29e1ba843 pkg/devices/fb/include/fb-client.h --- a/pkg/devices/fb/include/fb-client.h Sat Jun 10 23:59:44 2023 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,41 +0,0 @@ -/* - * Framebuffer client to access framebuffer 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 - -class Framebuffer_device_interface : public L4::Kobject_t -{ - L4_KOBJECT(Framebuffer_device_interface) - -public: - int get_framebuffer(L4::Cap mem) throw(); - l4_size_t get_framebuffer_size() throw(); - int get_view_info(l4re_video_view_info_t *view_info) throw(); -}; - -#endif diff -r bd0a7c487779 -r c9a29e1ba843 pkg/devices/fb/include/fb-lcd.h --- a/pkg/devices/fb/include/fb-lcd.h Sat Jun 10 23:59:44 2023 +0200 +++ b/pkg/devices/fb/include/fb-lcd.h Sun Jun 11 15:42:11 2023 +0200 @@ -1,7 +1,7 @@ /* * LCD framebuffer server functionality. * - * 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,26 +21,28 @@ #pragma once -#include -#include "fb-server.h" - #ifdef __cplusplus -#include -#include +#include +#include + +#include "fb-server.h" class Framebuffer_lcd_server : public Framebuffer_server { Lcd_device *_device; +protected: + /* Specialised methods. */ + + l4_size_t _get_framebuffer_size(); + void _get_view_info(l4re_video_view_info_t *view_info); + public: - explicit Framebuffer_lcd_server(L4::Cap mem, Lcd_device *device) + explicit Framebuffer_lcd_server(l4re_ds_t mem, Lcd_device *device) : Framebuffer_server(mem), _device(device) { } - - l4_size_t get_framebuffer_size(); - void get_view_info(l4re_video_view_info_t *view_info); }; #endif diff -r bd0a7c487779 -r c9a29e1ba843 pkg/devices/fb/include/fb-ops.h --- a/pkg/devices/fb/include/fb-ops.h Sat Jun 10 23:59:44 2023 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,28 +0,0 @@ -/* - * Framebuffer 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 { - Framebuffer_op_get_framebuffer, - Framebuffer_op_get_framebuffer_size, - Framebuffer_op_get_view_info, -}; diff -r bd0a7c487779 -r c9a29e1ba843 pkg/devices/fb/include/fb-server.h --- a/pkg/devices/fb/include/fb-server.h Sat Jun 10 23:59:44 2023 +0200 +++ b/pkg/devices/fb/include/fb-server.h Sun Jun 11 15:42:11 2023 +0200 @@ -1,7 +1,7 @@ /* * Common framebuffer server functionality. * - * 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,32 +23,36 @@ #ifdef __cplusplus -#include -#include -#include -#include +#include #include +#include "framebuffer_interface.h" + /* Server object to provide framebuffer data access. */ -class Framebuffer_server : public L4::Server_object_t +class Framebuffer_server : public Framebuffer { private: - L4::Cap _mem; + l4re_ds_t _mem; + +protected: + /* Specialised methods for overriding. */ + + virtual l4_size_t _get_framebuffer_size() = 0; + virtual void _get_view_info(l4re_video_view_info_t *view_info) = 0; public: /* Initialise the server with a capability referencing the exported memory. */ - explicit Framebuffer_server(L4::Cap mem) + explicit Framebuffer_server(l4re_ds_t mem) : _mem(mem) {} - int dispatch(l4_umword_t obj, L4::Ipc::Iostream &ios); - /* Operation methods. */ - virtual l4_size_t get_framebuffer_size() = 0; - virtual void get_view_info(l4re_video_view_info_t *view_info) = 0; + virtual long get_framebuffer(l4_cap_idx_t *mem); + virtual long get_framebuffer_size(l4_size_t *size); + virtual long get_view_info(l4re_video_view_info_t *view_info); }; #endif diff -r bd0a7c487779 -r c9a29e1ba843 pkg/devices/fb/src/Makefile --- a/pkg/devices/fb/src/Makefile Sat Jun 10 23:59:44 2023 +0200 +++ b/pkg/devices/fb/src/Makefile Sun Jun 11 15:42:11 2023 +0200 @@ -1,7 +1,7 @@ PKGDIR ?= ../.. L4DIR ?= $(PKGDIR)/../.. -TARGET := client jz4740 lcd server +TARGET := jz4740 lcd server include $(L4DIR)/mk/subdir.mk diff -r bd0a7c487779 -r c9a29e1ba843 pkg/devices/fb/src/client/Makefile --- a/pkg/devices/fb/src/client/Makefile Sat Jun 10 23:59:44 2023 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,13 +0,0 @@ -PKGDIR ?= ../../.. -L4DIR ?= $(PKGDIR)/../.. - -TARGET = libdevice_fb_client.o.a -PC_FILENAME := libdevice-fb-client - -SRC_CC := fb-client.cc - -PRIVATE_INCDIR += $(PKGDIR)/fb/include - -REQUIRES_LIBS := l4re_c l4re_c-util - -include $(L4DIR)/mk/lib.mk diff -r bd0a7c487779 -r c9a29e1ba843 pkg/devices/fb/src/client/fb-client.cc --- a/pkg/devices/fb/src/client/fb-client.cc Sat Jun 10 23:59:44 2023 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,72 +0,0 @@ -/* - * Framebuffer client to access framebuffer 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 "fb-client.h" -#include "fb-ops.h" - -#include -#include - -#include - -int -Framebuffer_device_interface::get_framebuffer(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(), Framebuffer_op_get_framebuffer)); -} - -l4_size_t -Framebuffer_device_interface::get_framebuffer_size() throw() -{ - L4::Ipc::Iostream s(l4_utcb()); - l4_size_t size; - - /* Return zero on failure. */ - - if (l4_error(s.call(cap(), Framebuffer_op_get_framebuffer_size))) - return 0; - - s >> size; - return size; -} - -int -Framebuffer_device_interface::get_view_info(l4re_video_view_info_t *view_info) throw() -{ - L4::Ipc::Iostream s(l4_utcb()); - - int err = l4_error(s.call(cap(), Framebuffer_op_get_view_info)); - if (err) return err; - - unsigned long expected = sizeof(*view_info); - unsigned long size = expected; - - s >> L4::Ipc::buf_cp_in((uint8_t *) view_info, expected); - - if (size != expected) return -L4_EIO; - return L4_EOK; -} diff -r bd0a7c487779 -r c9a29e1ba843 pkg/devices/fb/src/jz4740/Makefile --- a/pkg/devices/fb/src/jz4740/Makefile Sat Jun 10 23:59:44 2023 +0200 +++ b/pkg/devices/fb/src/jz4740/Makefile Sun Jun 11 15:42:11 2023 +0200 @@ -2,12 +2,12 @@ L4DIR ?= $(PKGDIR)/../.. TARGET = dev_fb_jz4740 -PC_FILENAME := devices-fb-jz4740 +PC_FILENAME = devices-fb-jz4740 -SRC_CC := fb-jz4740.cc +SRC_CC = fb-jz4740.cc -PRIVATE_INCDIR += $(PKGDIR)/fb/include +PRIVATE_INCDIR = $(PKGDIR)/fb/include -REQUIRES_LIBS := l4re_c l4re_c-util libdevice-fb-lcd libdevice-lcd-jz4740 +REQUIRES_LIBS = l4re_c l4re_c-util libdevice-fb-lcd libdevice-lcd-jz4740 include $(L4DIR)/mk/prog.mk diff -r bd0a7c487779 -r c9a29e1ba843 pkg/devices/fb/src/lcd/Makefile --- a/pkg/devices/fb/src/lcd/Makefile Sat Jun 10 23:59:44 2023 +0200 +++ b/pkg/devices/fb/src/lcd/Makefile Sun Jun 11 15:42:11 2023 +0200 @@ -2,12 +2,12 @@ L4DIR ?= $(PKGDIR)/../.. TARGET = libdevice_fb_lcd.o.a -PC_FILENAME := libdevice-fb-lcd +PC_FILENAME = libdevice-fb-lcd -SRC_CC := fb-lcd.cc +SRC_CC = fb-lcd.cc -PRIVATE_INCDIR += $(PKGDIR)/fb/include +REQUIRES_LIBS = l4re_c l4re_c-util libdevice-fb-server libdevice-lcd -REQUIRES_LIBS := l4re_c l4re_c-util libdevice-fb-server libdevice-lcd +PRIVATE_INCDIR = $(PKGDIR)/fb/include include $(L4DIR)/mk/lib.mk diff -r bd0a7c487779 -r c9a29e1ba843 pkg/devices/fb/src/lcd/fb-lcd.cc --- a/pkg/devices/fb/src/lcd/fb-lcd.cc Sat Jun 10 23:59:44 2023 +0200 +++ b/pkg/devices/fb/src/lcd/fb-lcd.cc Sun Jun 11 15:42:11 2023 +0200 @@ -1,7 +1,7 @@ /* * Export the framebuffer as a data space accessible 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 @@ -20,61 +20,55 @@ */ #include -#include "fb-lcd.h" -#include "fb-server.h" + +#include -#include -#include -#include -#include +#include "fb-lcd.h" +#include "framebuffer_server.h" // Device-specific methods. -l4_size_t -Framebuffer_lcd_server::get_framebuffer_size() +l4_size_t Framebuffer_lcd_server::_get_framebuffer_size() { return _device->get_framebuffer_size(); } -void -Framebuffer_lcd_server::get_view_info(l4re_video_view_info_t *view_info) +void Framebuffer_lcd_server::_get_view_info(l4re_video_view_info_t *view_info) { _device->get_view_info(view_info); } -static L4Re::Util::Registry_server<> server; - - - // Main program. int run() { - // Obtain the LCD device. + /* Obtain the LCD device. */ Lcd_device *lcd_device = Lcd_device::get_device(); - // Memory allocation capability for the framebuffer data. + /* Memory allocation capability for the framebuffer data. */ - L4::Cap mem = lcd_device->get_framebuffer_cap(); + l4re_ds_t mem = lcd_device->get_framebuffer_cap(); - if (!mem.is_valid()) return 1; + if (l4_is_invalid_cap(mem)) + return 1; - // Enable the LCD device. + /* Enable the LCD device. */ lcd_device->enable(); - // Initialise and register a server object. + /* Initialise and register a server object. */ + + Framebuffer_lcd_server obj(mem, lcd_device); - Framebuffer_lcd_server server_obj(mem, lcd_device); - server.registry()->register_obj(&server_obj, "fb"); + /* Bind and start the IPC server loop. */ - // Enter the IPC server loop. + if (ipc_server_loop_for(Framebuffer, &obj, "fb")) + return 1; - server.loop(); return 0; } diff -r bd0a7c487779 -r c9a29e1ba843 pkg/devices/fb/src/server/Makefile --- a/pkg/devices/fb/src/server/Makefile Sat Jun 10 23:59:44 2023 +0200 +++ b/pkg/devices/fb/src/server/Makefile Sun Jun 11 15:42:11 2023 +0200 @@ -2,12 +2,12 @@ L4DIR ?= $(PKGDIR)/../.. TARGET = libdevice_fb_server.o.a -PC_FILENAME := libdevice-fb-server +PC_FILENAME = libdevice-fb-server -SRC_CC := fb-server.cc +SRC_CC = fb-server.cc -PRIVATE_INCDIR += $(PKGDIR)/fb/include +PRIVATE_INCDIR = $(PKGDIR)/fb/include -REQUIRES_LIBS := l4re_c l4re_c-util +REQUIRES_LIBS = l4re_c l4re_c-util include $(L4DIR)/mk/lib.mk diff -r bd0a7c487779 -r c9a29e1ba843 pkg/devices/fb/src/server/fb-server.cc --- a/pkg/devices/fb/src/server/fb-server.cc Sat Jun 10 23:59:44 2023 +0200 +++ b/pkg/devices/fb/src/server/fb-server.cc Sun Jun 11 15:42:11 2023 +0200 @@ -1,7 +1,7 @@ /* * Common framebuffer server functionality. * - * 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,50 +19,25 @@ * Boston, MA 02110-1301, USA */ -#include "fb-client.h" #include "fb-server.h" -#include "fb-ops.h" - -#include -#include -#include -#include -#include - -/* Handle invocations. */ - -int -Framebuffer_server::dispatch(l4_umword_t obj, L4::Ipc::Iostream &ios) +long Framebuffer_server::get_framebuffer(l4_cap_idx_t *fb) { - l4_msgtag_t tag; - - (void) obj; - ios >> tag; + *fb = _mem; + return L4_EOK; +} - switch (tag.label()) - { - case L4::Meta::Protocol: - return L4::Util::handle_meta_request(ios); - - case Framebuffer_op_get_framebuffer: - ios << _mem; - return L4_EOK; - - case Framebuffer_op_get_framebuffer_size: - ios << get_framebuffer_size(); - return L4_EOK; +long Framebuffer_server::get_framebuffer_size(l4_size_t *size) +{ + *size = _get_framebuffer_size(); + return L4_EOK; +} - case Framebuffer_op_get_view_info: - l4re_video_view_info_t view_info; - get_view_info(&view_info); - - /* Serialise the view information structure. */ +long Framebuffer_server::get_view_info(l4re_video_view_info_t *view_info) +{ + _get_view_info(view_info); + return L4_EOK; +} - ios << L4::Ipc::buf_cp_out((uint8_t *) &view_info, sizeof(view_info)); - return L4_EOK; - - default: - return -L4_EBADPROTO; - } -} +/* vim: tabstop=2 expandtab shiftwidth=2 +*/ diff -r bd0a7c487779 -r c9a29e1ba843 pkg/devices/idl/backlight_object.idl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/pkg/devices/idl/backlight_object.idl Sun Jun 11 15:42:11 2023 +0200 @@ -0,0 +1,4 @@ +import "activation.idl"; +import "backlight.idl"; + +interface BacklightObject composes Activation, Backlight; diff -r bd0a7c487779 -r c9a29e1ba843 pkg/devices/idl/event.idl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/pkg/devices/idl/event.idl Sun Jun 11 15:42:11 2023 +0200 @@ -0,0 +1,9 @@ +#include + +/* An event interface. */ + +[protocol(L4RE_PROTO_EVENT)] +interface Event +{ + void get_buffer(out cap mem); +}; diff -r bd0a7c487779 -r c9a29e1ba843 pkg/devices/idl/framebuffer.idl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/pkg/devices/idl/framebuffer.idl Sun Jun 11 15:42:11 2023 +0200 @@ -0,0 +1,18 @@ +#include +#include + +[protocol(LANDFALL_FRAMEBUFFER)] +interface Framebuffer +{ + /* Return a framebuffer capability. */ + + void get_framebuffer(out cap mem); + + /* Return the framebuffer size. */ + + void get_framebuffer_size(out l4_size_t size); + + /* Return view information. */ + + void get_view_info(out l4re_video_view_info_t view_info); +}; diff -r bd0a7c487779 -r c9a29e1ba843 pkg/devices/idl/keypad.idl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/pkg/devices/idl/keypad.idl Sun Jun 11 15:42:11 2023 +0200 @@ -0,0 +1,7 @@ +#include + +[protocol(LANDFALL_KEYPAD)] +interface Keypad +{ + void get_keypad_data(out cap data); +}; diff -r bd0a7c487779 -r c9a29e1ba843 pkg/devices/include/protocols.h --- a/pkg/devices/include/protocols.h Sat Jun 10 23:59:44 2023 +0200 +++ b/pkg/devices/include/protocols.h Sun Jun 11 15:42:11 2023 +0200 @@ -1,7 +1,7 @@ /* * Interface protocols. * - * Copyright (C) 2020 Paul Boddie + * Copyright (C) 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,10 +21,11 @@ #pragma once -#define LANDFALL_ACTIVATION 0x1f01 -#define LANDFALL_BACKLIGHT 0x1f02 -#define LANDFALL_CPM 0x1f03 -#define LANDFALL_PWM 0x1f10 -#define LANDFALL_SPI 0x1f13 +#define LANDFALL_ACTIVATION 0x1f01 +#define LANDFALL_BACKLIGHT 0x1f02 +#define LANDFALL_CPM 0x1f03 +#define LANDFALL_FRAMEBUFFER 0x1f04 +#define LANDFALL_PWM 0x1f10 +#define LANDFALL_SPI 0x1f13 // vim: tabstop=2 expandtab shiftwidth=2 diff -r bd0a7c487779 -r c9a29e1ba843 pkg/devices/input/include/input-keypad-client.h --- a/pkg/devices/input/include/input-keypad-client.h Sat Jun 10 23:59:44 2023 +0200 +++ b/pkg/devices/input/include/input-keypad-client.h Sun Jun 11 15:42:11 2023 +0200 @@ -1,7 +1,7 @@ /* * Common keypad client functionality for input event generation. * - * 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 @@ -31,6 +31,8 @@ #include + + /* Input event and handler. */ typedef struct @@ -55,8 +57,8 @@ { /* Memory and keypad access capabilities. */ - L4::Cap _mem; - L4::Cap _keypad_server; + l4re_ds_t _mem; + l4_cap_idx_t _keypad_cap; /* Keypad layout details. */ diff -r bd0a7c487779 -r c9a29e1ba843 pkg/devices/input/src/keypad/Makefile --- a/pkg/devices/input/src/keypad/Makefile Sat Jun 10 23:59:44 2023 +0200 +++ b/pkg/devices/input/src/keypad/Makefile Sun Jun 11 15:42:11 2023 +0200 @@ -2,12 +2,12 @@ L4DIR ?= $(PKGDIR)/../.. TARGET = libinput_keypad.o.a -PC_FILENAME := libdevice-input-keypad +PC_FILENAME = libdevice-input-keypad -SRC_CC := input-keypad-client.cc +SRC_CC = input-keypad-client.cc -PRIVATE_INCDIR += $(PKGDIR)/input/include +PRIVATE_INCDIR = $(PKGDIR)/input/include -REQUIRES_LIBS := l4re_c l4re_c-util libdrivers-keypad-headers libdevice-keypad-client +REQUIRES_LIBS = l4re_c l4re_c-util libdrivers-keypad-headers libdevice-keypad-client include $(L4DIR)/mk/lib.mk diff -r bd0a7c487779 -r c9a29e1ba843 pkg/devices/input/src/keypad/input-keypad-client.cc --- a/pkg/devices/input/src/keypad/input-keypad-client.cc Sat Jun 10 23:59:44 2023 +0200 +++ b/pkg/devices/input/src/keypad/input-keypad-client.cc Sun Jun 11 15:42:11 2023 +0200 @@ -24,72 +24,76 @@ #include #include -#include -#include -#include -#include +#include #include #include #include +#include +#include + #include +#include "keypad_interface.h" + + + /* Obtain a capability for the keypad data. */ -void -Input_keypad_client::init_memory() +void Input_keypad_client::init_memory() { - _mem = L4Re::Util::cap_alloc.alloc(); + _mem = ipc_cap_alloc(); } /* Obtain a reference to the keypad. */ -void -Input_keypad_client::init_keypad() +void Input_keypad_client::init_keypad() { - _keypad_server = L4Re::Env::env()->get_cap("keypad"); + _keypad_cap = l4re_env_get_cap("keypad"); } /* Access the keypad server memory. */ -void -Input_keypad_client::init_keypad_data() +void Input_keypad_client::init_keypad_data() { - if (!_mem.is_valid()) + if (l4_is_invalid_cap(_mem)) return; - if (!_keypad_server.is_valid()) + if (l4_is_invalid_cap(_keypad_server)) return; /* Obtain a reference to the keypad data. */ - if (_keypad_server->get_keypad_data(_mem)) + client_Keypad keypad(_keypad_cap); + + if (keypad.get_keypad_data(_mem)) return; /* 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))) + unsigned long size; + + if (ipc_dataspace_size(_mem, &size)) + return; + + if (ipc_attach_dataspace(_mem, size, &_keymem)) return; /* Allocate memory for a copy of the keypad data. */ - _keymem_previous = malloc(_mem->size()); + _keymem_previous = malloc(size); } /* Release capabilities and the memory for a copy of the keypad data. */ -void -Input_keypad_client::release_keypad_data() +void Input_keypad_client::release_keypad_data() { - if (_mem.is_valid()) - L4Re::Util::cap_alloc.free(_mem); + if (l4_is_valid_cap(_mem)) + ipc_cap_free(_mem); - if (_keypad_server.is_valid()) - L4Re::Util::cap_alloc.free(_keypad_server); + if (l4_is_valid_cap(_keypad_cap)) + ipc_cap_free(_keypad_cap); if (_keymem_previous && (_keymem_previous != NULL)) free(_keymem_previous); @@ -97,8 +101,7 @@ /* Scan the keypad, compare old and new states, and generate key events. */ -void -Input_keypad_client::scan_keypad() +void Input_keypad_client::scan_keypad() { uint32_t *keymem = (uint32_t *) _keymem; uint32_t *keymem_previous = (uint32_t *) _keymem_previous; @@ -147,8 +150,7 @@ /* Perform keypad scanning in a separate thread. */ -void * -Input_keypad_client::scan_mainloop(void *data) +void *Input_keypad_client::scan_mainloop(void *data) { /* Since this is a static method, obtain instance details from the data. */ @@ -165,8 +167,7 @@ /* Thread initialisation for the keypad scanning activity. */ -void -Input_keypad_client::attach(Input_handler handler, void *priv) +void Input_keypad_client::attach(Input_handler handler, void *priv) { pthread_attr_t thread_attr; struct sched_param sp; diff -r bd0a7c487779 -r c9a29e1ba843 pkg/devices/keypad/include/keypad-server.h --- a/pkg/devices/keypad/include/keypad-server.h Sat Jun 10 23:59:44 2023 +0200 +++ b/pkg/devices/keypad/include/keypad-server.h Sun Jun 11 15:42:11 2023 +0200 @@ -1,7 +1,7 @@ /* * Common keypad server functionality. * - * 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,27 +21,29 @@ #pragma once -#include -#include -#include +#include + +#include + + #ifdef __cplusplus /* Server object to provide keypad data access. */ -class Keypad_server : public L4::Server_object_t +class Keypad_server : public Keypad { private: - L4::Cap _mem; + l4re_ds_t _mem; public: /* Initialise the server with a capability referencing the exported memory. */ - explicit Keypad_server(L4::Cap mem) + explicit Keypad_server(l4re_ds_t mem) : _mem(mem) {} - int dispatch(l4_umword_t obj, L4::Ipc::Iostream &ios); + long get_keypad_data(l4_cap_idx_t *data); }; #endif diff -r bd0a7c487779 -r c9a29e1ba843 pkg/devices/keypad/src/server/keypad-server.cc --- a/pkg/devices/keypad/src/server/keypad-server.cc Sat Jun 10 23:59:44 2023 +0200 +++ b/pkg/devices/keypad/src/server/keypad-server.cc Sun Jun 11 15:42:11 2023 +0200 @@ -1,7 +1,7 @@ /* * Common keypad server functionality. * - * 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,34 +19,12 @@ * Boston, MA 02110-1301, USA */ -#include "keypad-client.h" #include "keypad-server.h" -#include -#include -#include -#include -/* Handle invocations. */ - -int -Keypad_server::dispatch(l4_umword_t obj, L4::Ipc::Iostream &ios) -{ - l4_msgtag_t tag; - (void) obj; - ios >> tag; - - switch (tag.label()) - { - case L4::Meta::Protocol: - return L4::Util::handle_meta_request(ios); - - case Keypad_op_get_keypad_data: - ios << _mem; - return L4_EOK; - - default: - return -L4_EBADPROTO; - } +long Keypad_server::get_keypad_data(l4_cap_idx_t *data) +{ + *data = _mem; + return L4_EOK; } diff -r bd0a7c487779 -r c9a29e1ba843 pkg/devices/lcd/include/lcd-jz4740-device.h --- a/pkg/devices/lcd/include/lcd-jz4740-device.h Sat Jun 10 23:59:44 2023 +0200 +++ b/pkg/devices/lcd/include/lcd-jz4740-device.h Sun Jun 11 15:42:11 2023 +0200 @@ -29,6 +29,8 @@ #include #include + + /* C++ language interface. */ #ifdef __cplusplus diff -r bd0a7c487779 -r c9a29e1ba843 pkg/devices/lcd/src/common/lcd-device.cc --- a/pkg/devices/lcd/src/common/lcd-device.cc Sat Jun 10 23:59:44 2023 +0200 +++ b/pkg/devices/lcd/src/common/lcd-device.cc Sun Jun 11 15:42:11 2023 +0200 @@ -1,7 +1,7 @@ /* * Common LCD device functionality. * - * 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,6 +21,10 @@ #include "lcd-device.h" + + +/* Display activation. */ + void Lcd_device::disable_display() { _display->disable(); @@ -31,7 +35,9 @@ _display->enable(); } -// C language interface. + + +/* C language interface. */ void *lcd_get_device() { diff -r bd0a7c487779 -r c9a29e1ba843 pkg/devices/lcd/src/jz4740/lcd-jz4740-device.cc --- a/pkg/devices/lcd/src/jz4740/lcd-jz4740-device.cc Sat Jun 10 23:59:44 2023 +0200 +++ b/pkg/devices/lcd/src/jz4740/lcd-jz4740-device.cc Sun Jun 11 15:42:11 2023 +0200 @@ -25,22 +25,24 @@ #include #include "lcd-jz4740-device.h" -#include -#include -#include +#include +#include +#include #include -#include -#include -#include -#include +#include #include -#include +#include + +#include +#include #include #include "activation_client.h" #include "cpm_client.h" + + // Virtual addresses for the LCD register block. static l4_addr_t lcd_virt_base = 0, lcd_virt_base_end = 0; @@ -132,31 +134,22 @@ // Memory allocation capabilities. - L4::Cap descmem; - L4::Cap dma; + l4_cap_idx_t descmem, dma, vbus; // Test for existing setup. if (fb_vaddr) return 0; - // Obtain capabilities for allocating memory. - - _fbmem = L4Re::Util::cap_alloc.alloc(); - if (!_fbmem.is_valid()) return 1; - - descmem = L4Re::Util::cap_alloc.alloc(); - if (!descmem.is_valid()) return 1; - - dma = L4Re::Util::cap_alloc.alloc(); - if (!dma.is_valid()) return 1; - // Create the DMA space. - L4::Cap vbus = L4Re::Env::env()->get_cap("vbus"); - if (!vbus.is_valid()) return 1; + dma = ipc_cap_alloc(); + if (l4_is_invalid_cap(dma)) return 1; - if (l4_error(L4Re::Env::env()->user_factory()->create(dma))) + vbus = l4re_env_get_cap("vbus"); + 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; l4vbus_device_handle_t device = L4VBUS_NULL; @@ -165,9 +158,9 @@ if (!find_resource(&device, &dma_resource, L4VBUS_RESOURCE_DMA_DOMAIN)) return 1; - if (vbus->assign_dma_domain(dma_resource.start, - L4VBUS_DMAD_BIND | L4VBUS_DMAD_L4RE_DMA_SPACE, - dma)) + if (l4vbus_assign_dma_domain(vbus, dma_resource.start, + L4VBUS_DMAD_BIND | L4VBUS_DMAD_L4RE_DMA_SPACE, + dma)) return 1; // Obtain the memory requirements. @@ -182,23 +175,17 @@ // NOTE: A 64 word burst mode is available on the JZ4780 that would // NOTE: necessitate 64 word alignment for the framebuffer. - const l4_size_t alloc_flags = L4Re::Mem_alloc::Continuous | L4Re::Mem_alloc::Pinned; - - if (L4Re::Env::env()->mem_alloc()->alloc(fb_size, _fbmem, alloc_flags, 8) || - L4Re::Env::env()->mem_alloc()->alloc(desc_size, descmem, alloc_flags, 6)) - return 1; + const l4_size_t alloc_flags = L4RE_MA_CONTINUOUS | L4RE_MA_PINNED; // Map the allocated memory, obtaining virtual addresses. - const L4Re::Rm::F::Flags flags = L4Re::Rm::F::Search_addr | - L4Re::Rm::F::Eager_map | - L4Re::Rm::F::RW; - fb_vaddr = 0; desc_vaddr = 0; - if (L4Re::Env::env()->rm()->attach(&fb_vaddr, fb_size, flags, _fbmem, 0) || - L4Re::Env::env()->rm()->attach(&desc_vaddr, desc_size, flags, descmem, 0)) + if (ipc_allocate_align(fb_size, alloc_flags, 8, &fb_vaddr, &_fbmem)) + return 1; + + if (ipc_allocate_align(desc_size, alloc_flags, 6, &desc_vaddr, &descmem)) return 1; // Obtain physical addresses for the framebuffer and descriptors. @@ -209,16 +196,12 @@ fb_size_out = fb_size; desc_size_out = desc_size; - if (dma->map(L4::Ipc::make_cap_rw(_fbmem), 0, &fb_size_out, - L4Re::Dma_space::Attributes::None, - L4Re::Dma_space::Direction::To_device, - &fb_paddr)) + if (l4re_dma_space_map(dma, _fbmem | L4_CAP_FPAGE_RW, 0, &fb_size_out, 0, + L4RE_DMA_SPACE_TO_DEVICE, &fb_paddr)) return 1; - if (dma->map(L4::Ipc::make_cap_rw(descmem), 0, &desc_size_out, - L4Re::Dma_space::Attributes::None, - L4Re::Dma_space::Direction::To_device, - &desc_paddr)) + if (l4re_dma_space_map(dma, descmem | L4_CAP_FPAGE_RW, 0, &desc_size_out, 0, + L4RE_DMA_SPACE_TO_DEVICE, &desc_paddr)) return 1; // Test the mapped region sizes. @@ -231,8 +214,7 @@ // Populate a view information structure. -void -Lcd_jz4740_device::get_view_info(l4re_video_view_info_t *view_info) +void Lcd_jz4740_device::get_view_info(l4re_video_view_info_t *view_info) { // Populate the L4Re framebuffer description with details from the // somewhat similar panel description. @@ -303,10 +285,14 @@ // Obtain access to the CPM and display devices. l4_cap_idx_t cpm = l4re_env_get_cap("cpm"); - if (!l4_is_valid_cap(cpm)) return 1; + + if (!l4_is_valid_cap(cpm)) + return 1; l4_cap_idx_t display = l4re_env_get_cap("display"); - if (!l4_is_valid_cap(display)) return 1; + + if (!l4_is_valid_cap(display)) + return 1; static client_Activation display_obj(display); display_device = &display_obj; @@ -334,9 +320,11 @@ Lcd_device *Lcd_device::get_device() { - if (Lcd_jz4740_device::device) return Lcd_jz4740_device::device; + if (Lcd_jz4740_device::device) + return Lcd_jz4740_device::device; - if (setup_memory()) return 0; + if (setup_memory()) + return 0; // Initialise the common device. diff -r bd0a7c487779 -r c9a29e1ba843 pkg/devices/pwm/src/jz4730/Makefile --- a/pkg/devices/pwm/src/jz4730/Makefile Sat Jun 10 23:59:44 2023 +0200 +++ b/pkg/devices/pwm/src/jz4730/Makefile Sun Jun 11 15:42:11 2023 +0200 @@ -14,20 +14,13 @@ include $(IDL_MK_DIR)/idl.mk -# Compound interface definitions. - -pwm_object_NAME = PWMObject -pwm_object_INTERFACES = activation pwm - -COMP_INTERFACES_CC = pwm_object - # Individual interfaces. -SERVER_INTERFACES_CC = $(call common_interfaces,$(COMP_INTERFACES_CC)) +SERVER_INTERFACES_CC = pwm_object # Generated and plain source files. -SERVER_INTERFACES_SRC_CC = $(call interfaces_to_server_cc,$(SERVER_INTERFACES_CC) $(COMP_INTERFACES_CC)) +SERVER_INTERFACES_SRC_CC = $(call interfaces_to_server_cc,$(SERVER_INTERFACES_CC)) PLAIN_SRC_CC = pwm-jz4730.cc diff -r bd0a7c487779 -r c9a29e1ba843 pkg/devices/pwm/src/jz4730/pwm-jz4730.cc --- a/pkg/devices/pwm/src/jz4730/pwm-jz4730.cc Sat Jun 10 23:59:44 2023 +0200 +++ b/pkg/devices/pwm/src/jz4730/pwm-jz4730.cc Sun Jun 11 15:42:11 2023 +0200 @@ -1,7 +1,7 @@ /* * Export a JZ4730 PWM peripheral as a server. * - * 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 @@ -29,8 +29,11 @@ #include #include + #include "pwm_object_server.h" + + /* Virtual addresses for the GPIO and PWM register blocks. */ static l4_addr_t gpio_virt_base = 0, gpio_virt_base_end = 0; @@ -53,7 +56,7 @@ /* PWM peripheral device. */ -class server_PWMObject : public PWMObject +class PWMObject_server : public PWMObject { Pwm_jz4730_chip *_device = 0; int _duty, _period, _prescale; @@ -61,7 +64,7 @@ public: /* Associate the device with a particular memory region. */ - explicit server_PWMObject(Pwm_jz4730_chip *device, int duty, int period, + explicit PWMObject_server(Pwm_jz4730_chip *device, int duty, int period, int prescale) : _device(device), _duty(duty), _period(period), _prescale(prescale) { @@ -130,15 +133,13 @@ /* Initialise and register a new server object. */ - server_PWMObject obj(&pwm_device, duty, period, prescale); - l4_cap_idx_t server; + PWMObject_server obj(&pwm_device, duty, period, prescale); - if (ipc_server_bind("pwm", (l4_umword_t) &obj, &server)) return 1; + /* Bind and start the IPC server loop. */ - /* Enter the IPC server loop. */ + if (ipc_server_loop_for(PWMObject, &obj, "pwm")) + return 1; - ipc_server_loop(PWMObject_expected_items, &obj, - (ipc_server_handler_type) handle_PWMObject); return 0; } @@ -150,23 +151,29 @@ { int number, duty, period, prescale; - if (argc < 5) return 1; + if (argc < 5) + return 1; /* Interpret and restrict the device number. */ number = atoi(argv[1]); - if ((number < 0) || (number > 1)) return 1; + + if ((number < 0) || (number > 1)) + return 1; /* Interpret and restrict the initial parameters. */ duty = atoi(argv[2]); period = atoi(argv[3]); prescale = atoi(argv[4]); - if ((duty < 0) || (period < 0) || (prescale < 0)) return 1; + + if ((duty < 0) || (period < 0) || (prescale < 0)) + return 1; /* Obtain access to peripheral memory. */ - if (setup_memory()) return 1; + if (setup_memory()) + return 1; return run(number, duty, period, prescale); } diff -r bd0a7c487779 -r c9a29e1ba843 pkg/devices/spi/src/jz4740/spi-jz4740.cc --- a/pkg/devices/spi/src/jz4740/spi-jz4740.cc Sat Jun 10 23:59:44 2023 +0200 +++ b/pkg/devices/spi/src/jz4740/spi-jz4740.cc Sun Jun 11 15:42:11 2023 +0200 @@ -1,7 +1,7 @@ /* * Export JZ4740 GPIO pins as a SPI server. * - * 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 @@ -29,8 +29,11 @@ #include #include + #include "spi_server.h" + + /* Virtual addresses for the GPIO register block. */ static l4_addr_t gpio_virt_base = 0, gpio_virt_base_end = 0; @@ -49,7 +52,7 @@ /* SPI peripheral device. */ -class server_SPI : public SPI +class SPI_server : public SPI { Gpio_jz4740_chip *_clock_device = 0, *_data_device = 0, *_enable_device = 0; int _clock_pin, _data_pin, _enable_pin; @@ -57,7 +60,7 @@ public: /* Associate the device with a particular memory region. */ - explicit server_SPI(Gpio_jz4740_chip *clock_device, + explicit SPI_server(Gpio_jz4740_chip *clock_device, Gpio_jz4740_chip *data_device, Gpio_jz4740_chip *enable_device, int clock_pin, int data_pin, int enable_pin) @@ -141,17 +144,22 @@ { int clock_port, clock_pin, data_port, data_pin, enable_port, enable_pin; - if (argc < 4) return 1; + if (argc < 4) + return 1; /* Interpret the pin details. */ - if (!parse_pin(argv[1], "ABCD", &clock_port, &clock_pin)) return 1; - if (!parse_pin(argv[2], "ABCD", &data_port, &data_pin)) return 1; - if (!parse_pin(argv[3], "ABCD", &enable_port, &enable_pin)) return 1; + if (!parse_pin(argv[1], "ABCD", &clock_port, &clock_pin)) + return 1; + if (!parse_pin(argv[2], "ABCD", &data_port, &data_pin)) + return 1; + if (!parse_pin(argv[3], "ABCD", &enable_port, &enable_pin)) + return 1; /* Obtain access to peripheral memory. */ - if (setup_memory()) return 1; + if (setup_memory()) + return 1; /* Configure the clock pin. */ @@ -176,16 +184,13 @@ /* Initialise and register a new server object. */ - server_SPI obj(&gpio_port_clock, &gpio_port_data, &gpio_port_enable, + SPI_server obj(&gpio_port_clock, &gpio_port_data, &gpio_port_enable, clock_pin, data_pin, enable_pin); - l4_cap_idx_t server; - if (ipc_server_bind("spi", (l4_umword_t) &obj, &server)) return 1; + /* Bind and start the IPC server loop. */ - /* Enter the IPC server loop. */ - - ipc_server_loop(SPI_expected_items, &obj, - (ipc_server_handler_type) handle_SPI); + if (ipc_server_loop_for(SPI, &obj, "spi")) + return 1; return 0; } diff -r bd0a7c487779 -r c9a29e1ba843 pkg/devices/util/include/dataspace.h --- a/pkg/devices/util/include/dataspace.h Sat Jun 10 23:59:44 2023 +0200 +++ b/pkg/devices/util/include/dataspace.h Sun Jun 11 15:42:11 2023 +0200 @@ -1,7 +1,7 @@ /* * Data space allocation utility functions. * - * 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,8 +21,7 @@ #pragma once -#include -#include +#include #include -L4::Cap allocate_data(l4_size_t mem_size, void **allocated); +l4re_ds_t allocate_data(l4_size_t mem_size, void **allocated); diff -r bd0a7c487779 -r c9a29e1ba843 pkg/devices/util/include/event-loop.h --- a/pkg/devices/util/include/event-loop.h Sat Jun 10 23:59:44 2023 +0200 +++ b/pkg/devices/util/include/event-loop.h Sun Jun 11 15:42:11 2023 +0200 @@ -1,7 +1,7 @@ /* * Generic event loop functionality. * - * 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 @@ -26,6 +26,8 @@ #include #include + + /* Event loop abstraction. */ class Event_loop diff -r bd0a7c487779 -r c9a29e1ba843 pkg/devices/util/src/dataspace.cc --- a/pkg/devices/util/src/dataspace.cc Sat Jun 10 23:59:44 2023 +0200 +++ b/pkg/devices/util/src/dataspace.cc Sun Jun 11 15:42:11 2023 +0200 @@ -19,46 +19,28 @@ * Boston, MA 02110-1301, USA */ -#include -#include -#include -#include +#include + +#include #include "dataspace.h" -/* -Allocate and map a region containing data, using the given mem_size to indicate -the required region size, along with a pointer to be set to the allocated -region. Return a capability which may be invalid if allocation or mapping -failed. + + +/* Allocate and map a region containing data, using the given mem_size to + indicate the required region size, along with a pointer to be set to the + allocated region. Return a capability which may be invalid if allocation or + mapping failed. */ -L4::Cap allocate_data(l4_size_t mem_size, void **allocated) +l4re_ds_t allocate_data(l4_size_t mem_size, void **allocated) { - /* Obtain a capability for the allocated memory. */ - - L4::Cap mem = L4Re::Util::cap_alloc.alloc(); - - if (!mem.is_valid()) - return L4::Cap::Invalid; - - /* Allocate memory for the data. */ + l4re_ds_t mem; - if (L4Re::Env::env()->mem_alloc()->alloc(mem_size, mem, L4Re::Mem_alloc::Continuous)) - { - L4Re::Util::cap_alloc.free(mem); - return L4::Cap::Invalid; - } - - /* Map the memory to a virtual address. */ + /* Allocate memory for the data and map it to a virtual address. */ - if (L4Re::Env::env()->rm()->attach(allocated, mem->size(), - L4Re::Rm::F::Search_addr | L4Re::Rm::F::RW, - L4::Ipc::make_cap_rw(mem))) - { - L4Re::Util::cap_alloc.free(mem); - return L4::Cap::Invalid; - } + if (ipc_allocate_align(mem_size, L4RE_MA_CONTINUOUS, 0, allocated, &mem)) + return L4_INVALID_CAP; return mem; } diff -r bd0a7c487779 -r c9a29e1ba843 pkg/devices/util/src/event-loop.cc --- a/pkg/devices/util/src/event-loop.cc Sat Jun 10 23:59:44 2023 +0200 +++ b/pkg/devices/util/src/event-loop.cc Sun Jun 11 15:42:11 2023 +0200 @@ -1,7 +1,7 @@ /* * Generic event loop functionality. * - * 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 @@ -24,24 +24,23 @@ #include #include -#include + /* Main loop for event threads. */ -void * -Event_loop::event_loop(void *data) +void *Event_loop::event_loop(void *data) { Event_loop *self = reinterpret_cast(data); - while (1) self->handle(); + while (1) + self->handle(); return 0; } /* Event loop initiation. */ -void -Event_loop::start() +void Event_loop::start() { pthread_attr_t thread_attr; struct sched_param sp; diff -r bd0a7c487779 -r c9a29e1ba843 pkg/devices/util/src/memory.cc --- a/pkg/devices/util/src/memory.cc Sat Jun 10 23:59:44 2023 +0200 +++ b/pkg/devices/util/src/memory.cc Sun Jun 11 15:42:11 2023 +0200 @@ -28,6 +28,8 @@ #include "memory.h" + + int get_device(char const *hid, l4io_device_handle_t *dh, l4io_resource_handle_t *rh) { return l4io_lookup_device(hid, dh, 0, rh);