# HG changeset patch # User Paul Boddie # Date 1609365108 -3600 # Node ID bdfa043cbc67d8c273f33d8bc1c2ba6872f90a27 # Parent 06667c54641063e65d05778298bcc98ef086ec04 Introduced interface usage for the Ben NanoNote display and LCD devices. diff -r 06667c546410 -r bdfa043cbc67 pkg/devices/backlight/src/spi-ili8960/backlight-spi-ili8960.cc --- a/pkg/devices/backlight/src/spi-ili8960/backlight-spi-ili8960.cc Wed Dec 30 22:48:28 2020 +0100 +++ b/pkg/devices/backlight/src/spi-ili8960/backlight-spi-ili8960.cc Wed Dec 30 22:51:48 2020 +0100 @@ -102,13 +102,7 @@ server_BacklightObject obj; l4_cap_idx_t server; - long err = ipc_server_bind("backlight", (l4_umword_t) &obj, &server); - - if (err) - { - printf("Could not bind server: %s\n", l4sys_errtostr(err)); - return 1; - } + if (ipc_server_bind("backlight", (l4_umword_t) &obj, &server)) return 1; /* Enter the IPC server loop. */ diff -r 06667c546410 -r bdfa043cbc67 pkg/devices/display/src/qi_lb60/Makefile --- a/pkg/devices/display/src/qi_lb60/Makefile Wed Dec 30 22:48:28 2020 +0100 +++ b/pkg/devices/display/src/qi_lb60/Makefile Wed Dec 30 22:51:48 2020 +0100 @@ -18,15 +18,19 @@ CLIENT_INTERFACES_CC = activation +SERVER_INTERFACES_CC = activation + # 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)) + PLAIN_SRC_CC = display-qi_lb60.cc # Normal definitions. -SRC_CC = $(CLIENT_INTERFACES_SRC_CC) $(PLAIN_SRC_CC) +SRC_CC = $(CLIENT_INTERFACES_SRC_CC) $(SERVER_INTERFACES_SRC_CC) $(PLAIN_SRC_CC) REQUIRES_LIBS = l4re_c l4re_c-util libdrivers-lcd-jz4740 libdrivers-gpio libdevice-util libipc @@ -35,4 +39,4 @@ include $(L4DIR)/mk/prog.mk include $(IDL_MK_DIR)/interface_rules.mk -$(PLAIN_SRC_CC): $(CLIENT_INTERFACES_SRC_CC) +$(PLAIN_SRC_CC): $(CLIENT_INTERFACES_SRC_CC) $(SERVER_INTERFACES_SRC_CC) diff -r 06667c546410 -r bdfa043cbc67 pkg/devices/display/src/qi_lb60/display-qi_lb60.cc --- a/pkg/devices/display/src/qi_lb60/display-qi_lb60.cc Wed Dec 30 22:48:28 2020 +0100 +++ b/pkg/devices/display/src/qi_lb60/display-qi_lb60.cc Wed Dec 30 22:51:48 2020 +0100 @@ -24,14 +24,11 @@ #include #include -#include -#include #include -#include -#include +#include #include "activation_client.h" -#include "display-ops.h" +#include "activation_server.h" /* Virtual address for the GPIO register block. */ @@ -69,9 +66,9 @@ -/* Display device. */ +/* Display device only implementing the activation interface. */ -class Display_device_server : public L4::Server_object_t +class server_DisplayObject : 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}; @@ -79,58 +76,34 @@ Activation *_backlight; public: - explicit Display_device_server(Activation *backlight) + explicit server_DisplayObject(Activation *backlight) : _backlight(backlight) { } - /* Dispatch incoming requests. */ - - int dispatch(l4_umword_t obj, L4::Ipc::Iostream &ios) - { - l4_msgtag_t tag; - - (void) obj; - ios >> tag; - - switch (tag.label()) - { - case Display_op_disable: - disable(); - return L4_EOK; - - case Display_op_enable: - enable(); - return L4_EOK; - - default: - return -L4_EBADPROTO; - } - } - /* Switch the display off. */ - void disable(void) + long disable(void) { /* Configure SLCD8 pins. */ gpio_port_c->multi_setup(slcd8_mask, Hw::Gpio_chip::Input, 0); _backlight->disable(); + return L4_EOK; } /* Switch the display on. */ - void enable(void) + long enable(void) { /* Configure SLCD8 pins. */ gpio_port_c->multi_config_pad(slcd8_mask, Hw::Gpio_chip::Function_alt, 0); _backlight->enable(); + return L4_EOK; } }; -static L4Re::Util::Registry_server<> server; - int main(void) @@ -154,11 +127,14 @@ /* Initialise and register a new server object. */ - Display_device_server server_obj(&backlight_obj); - server.registry()->register_obj(&server_obj, "display"); + server_DisplayObject obj(&backlight_obj); + l4_cap_idx_t server; + + if (ipc_server_bind("display", (l4_umword_t) &obj, &server)) return 1; /* Enter the IPC server loop. */ - server.loop(); + ipc_server_loop(Activation_expected_items, &obj, + (ipc_server_handler_type) handle_Activation); return 0; } diff -r 06667c546410 -r bdfa043cbc67 pkg/devices/lcd/include/lcd-device.h --- a/pkg/devices/lcd/include/lcd-device.h Wed Dec 30 22:48:28 2020 +0100 +++ b/pkg/devices/lcd/include/lcd-device.h Wed Dec 30 22:51:48 2020 +0100 @@ -1,7 +1,7 @@ /* * LCD device support. * - * Copyright (C) 2018 Paul Boddie + * Copyright (C) 2018, 2020 Paul Boddie * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -21,7 +21,7 @@ #pragma once -#include +#include #include #include @@ -43,7 +43,7 @@ /* Display server abstraction. */ - L4::Cap _display; + Activation *_display; /* Framebuffer virtual and physical addresses. */ @@ -61,7 +61,7 @@ public: /* Initialise a device with a controller and display object reference. */ - Lcd_device(Lcd_chip *chip, L4::Cap display) + Lcd_device(Lcd_chip *chip, Activation *display) : _chip(chip), _display(display) { /* Subclasses must set up any memory. */ diff -r 06667c546410 -r bdfa043cbc67 pkg/devices/lcd/include/lcd-jz4740-device.h --- a/pkg/devices/lcd/include/lcd-jz4740-device.h Wed Dec 30 22:48:28 2020 +0100 +++ b/pkg/devices/lcd/include/lcd-jz4740-device.h Wed Dec 30 22:51:48 2020 +0100 @@ -47,7 +47,7 @@ public: /* Inherit constructor. */ - Lcd_jz4740_device(Lcd_chip *chip, L4::Cap display) + Lcd_jz4740_device(Lcd_chip *chip, Activation *display) : Lcd_device(chip, display) { _setup_memory(); diff -r 06667c546410 -r bdfa043cbc67 pkg/devices/lcd/include/lcd-letux400.h --- a/pkg/devices/lcd/include/lcd-letux400.h Wed Dec 30 22:48:28 2020 +0100 +++ b/pkg/devices/lcd/include/lcd-letux400.h Wed Dec 30 22:51:48 2020 +0100 @@ -1,7 +1,7 @@ /* * LCD device support for the Letux 400 notebook computer. * - * Copyright (C) 2018 Paul Boddie + * Copyright (C) 2018, 2020 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 @@ -30,7 +30,7 @@ public: /* Inherit constructor. */ - Lcd_letux400(Lcd_chip *chip, L4::Cap display) + Lcd_letux400(Lcd_chip *chip, Activation *display) : Lcd_jz4740_device(chip, display) { } diff -r 06667c546410 -r bdfa043cbc67 pkg/devices/lcd/include/lcd-qi_lb60.h --- a/pkg/devices/lcd/include/lcd-qi_lb60.h Wed Dec 30 22:48:28 2020 +0100 +++ b/pkg/devices/lcd/include/lcd-qi_lb60.h Wed Dec 30 22:51:48 2020 +0100 @@ -1,7 +1,7 @@ /* * LCD device support for the Ben NanoNote. * - * Copyright (C) 2018 Paul Boddie + * Copyright (C) 2018, 2020 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 @@ -30,7 +30,7 @@ public: /* Inherit constructor. */ - Lcd_qi_lb60(Lcd_chip *chip, L4::Cap display) + Lcd_qi_lb60(Lcd_chip *chip, Activation *display) : Lcd_jz4740_device(chip, display) { } diff -r 06667c546410 -r bdfa043cbc67 pkg/devices/lcd/src/common/Makefile --- a/pkg/devices/lcd/src/common/Makefile Wed Dec 30 22:48:28 2020 +0100 +++ b/pkg/devices/lcd/src/common/Makefile Wed Dec 30 22:51:48 2020 +0100 @@ -2,12 +2,32 @@ L4DIR ?= $(PKGDIR)/../.. TARGET = liblcd_device.o.a liblcd_device.o.so -PC_FILENAME := libdevice-lcd +PC_FILENAME = libdevice-lcd + +# Locations for interface input and generated output. -SRC_CC := lcd-device.cc +IDL_DIR = $(PKGDIR)/idl +IDL_MK_DIR = $(L4DIR)/idl4re/mk +IDL_BUILD_DIR = . +IDL_EXPORT_DIR = $(OBJ_BASE)/include/l4/devices/activation + +include $(IDL_MK_DIR)/idl.mk -PRIVATE_INCDIR += $(PKGDIR)/lcd/include +# Individual interfaces. + +CLIENT_INTERFACES_CC = activation + +EXPORTED_INTERFACES_H = $(call exported_interfaces_h,$(CLIENT_INTERFACES_CC)) -REQUIRES_LIBS := l4re_c l4re_c-util libdevice-display-client libdrivers-lcd-headers +# Normal definitions. + +SRC_CC = lcd-device.cc + +REQUIRES_LIBS = l4re_c l4re_c-util libdrivers-lcd-headers + +PRIVATE_INCDIR = $(PKGDIR)/lcd/include $(IDL_BUILD_DIR) $(IDL_EXPORT_DIR) include $(L4DIR)/mk/lib.mk +include $(IDL_MK_DIR)/interface_rules.mk + +$(SRC_CC): $(EXPORTED_INTERFACES_H) diff -r 06667c546410 -r bdfa043cbc67 pkg/devices/lcd/src/jz4740/Makefile --- a/pkg/devices/lcd/src/jz4740/Makefile Wed Dec 30 22:48:28 2020 +0100 +++ b/pkg/devices/lcd/src/jz4740/Makefile Wed Dec 30 22:51:48 2020 +0100 @@ -2,12 +2,40 @@ L4DIR ?= $(PKGDIR)/../.. TARGET = liblcd_dev_jz4740.o.a liblcd_dev_jz4740.o.so -PC_FILENAME := libdevice-lcd-jz4740 +PC_FILENAME = libdevice-lcd-jz4740 + +# Locations for interface input and generated output. -SRC_CC := lcd-jz4740-device.cc +IDL_DIR = $(PKGDIR)/idl +IDL_MK_DIR = $(L4DIR)/idl4re/mk +IDL_BUILD_DIR = . +IDL_EXPORT_DIR = $(OBJ_BASE)/include/l4/devices/activation + +include $(IDL_MK_DIR)/idl.mk + +# Individual interfaces. + +CLIENT_INTERFACES_CC = activation -PRIVATE_INCDIR += $(PKGDIR)/lcd/include +# Generated and plain source files. + +CLIENT_INTERFACES_SRC_CC = $(call interfaces_to_client_cc,$(CLIENT_INTERFACES_CC)) + +PLAIN_SRC_CC = lcd-jz4740-device.cc + +# Normal definitions. -REQUIRES_LIBS := l4re_c l4re_c-util libdevice-lcd libdrivers-lcd-jz4740 libdrivers-panel-loader libdevice-cpm-client libdevice-util +SRC_CC = $(CLIENT_INTERFACES_SRC_CC) $(PLAIN_SRC_CC) + +REQUIRES_LIBS = \ + l4re_c l4re_c-util \ + libdevice-cpm-client \ + libdevice-lcd libdrivers-lcd-jz4740 libdrivers-panel-loader \ + libdevice-util libipc + +PRIVATE_INCDIR = $(PKGDIR)/lcd/include $(IDL_BUILD_DIR) $(IDL_EXPORT_DIR) include $(L4DIR)/mk/lib.mk +include $(IDL_MK_DIR)/interface_rules.mk + +$(PLAIN_SRC_CC): $(CLIENT_INTERFACES_SRC_CC) diff -r 06667c546410 -r bdfa043cbc67 pkg/devices/lcd/src/jz4740/lcd-jz4740-device.cc --- a/pkg/devices/lcd/src/jz4740/lcd-jz4740-device.cc Wed Dec 30 22:48:28 2020 +0100 +++ b/pkg/devices/lcd/src/jz4740/lcd-jz4740-device.cc Wed Dec 30 22:51:48 2020 +0100 @@ -20,7 +20,6 @@ */ #include -#include #include #include #include @@ -29,6 +28,7 @@ #include #include +#include #include #include #include @@ -36,6 +36,8 @@ #include +#include "activation_client.h" + // Virtual addresses for the LCD register block. static l4_addr_t lcd_virt_base = 0, lcd_virt_base_end = 0; @@ -45,7 +47,7 @@ static Lcd_jz4740_chip *lcd_chip = 0; static L4::Cap cpm_device; -static L4::Cap display_device; +static Activation *display_device; @@ -266,8 +268,11 @@ cpm_device = L4Re::Env::env()->get_cap("cpm"); if (!cpm_device.is_valid()) return 1; - display_device = L4Re::Env::env()->get_cap("display"); - if (!display_device.is_valid()) return 1; + l4_cap_idx_t display = l4re_env_get_cap("display"); + if (!l4_is_valid_cap(display)) return 1; + + static client_Activation display_obj(display); + display_device = &display_obj; // Load the panel data from the configured library.