# HG changeset patch # User Paul Boddie # Date 1609462175 -3600 # Node ID 8fd418104ecd92f766b665d25b27f01311ab398c # Parent df0bac1946f4f5333513b3b3d91c3185d86701fe Converted the CPM device to use interface descriptions and generated components. This affects the CI20 display device and the LCD device. diff -r df0bac1946f4 -r 8fd418104ecd pkg/devices/Control --- a/pkg/devices/Control Fri Jan 01 00:49:07 2021 +0100 +++ b/pkg/devices/Control Fri Jan 01 01:49:35 2021 +0100 @@ -13,9 +13,6 @@ provides: devices-keypad-qi_lb60 provides: devices-pwm-jz4730 provides: devices-spi-jz4740 -provides: libdevice-cpm-client -provides: libdevice-cpm-server -provides: libdevice-display-client provides: libdevice-display-ops provides: libdevice-fb-client provides: libdevice-fb-lcd diff -r df0bac1946f4 -r 8fd418104ecd pkg/devices/cpm/Makefile --- a/pkg/devices/cpm/Makefile Fri Jan 01 00:49:07 2021 +0100 +++ b/pkg/devices/cpm/Makefile Fri Jan 01 01:49:35 2021 +0100 @@ -1,8 +1,6 @@ PKGDIR ?= .. L4DIR ?= $(PKGDIR)/../.. -TARGET := include src +TARGET := src include $(L4DIR)/mk/subdir.mk - -src: include diff -r df0bac1946f4 -r 8fd418104ecd pkg/devices/cpm/include/Makefile --- a/pkg/devices/cpm/include/Makefile Fri Jan 01 00:49:07 2021 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,4 +0,0 @@ -PKGDIR = ../.. -L4DIR ?= $(PKGDIR)/../.. - -include $(L4DIR)/mk/include.mk diff -r df0bac1946f4 -r 8fd418104ecd pkg/devices/cpm/include/cpm-client.h --- a/pkg/devices/cpm/include/cpm-client.h Fri Jan 01 00:49:07 2021 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,48 +0,0 @@ -/* - * CPM client to access CPM servers. - * - * 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 - * 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 - -class Cpm_device_interface : public L4::Kobject_t -{ - L4_KOBJECT(Cpm_device_interface) - -public: - int get_lcd_pixel_frequency(uint32_t *frequency) throw(); - - int set_hdmi_frequency(uint32_t frequency) throw(); - int set_lcd_frequencies(uint32_t pclk, uint8_t multiplier) throw(); - - int start_hdmi() throw(); - int stop_hdmi() throw(); - - int start_lcd() throw(); - int stop_lcd() throw(); - - int update_output_frequency() throw(); -}; - -#endif diff -r df0bac1946f4 -r 8fd418104ecd pkg/devices/cpm/include/cpm-ops.h --- a/pkg/devices/cpm/include/cpm-ops.h Fri Jan 01 00:49:07 2021 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,33 +0,0 @@ -/* - * CPM server operations. - * - * 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 - * 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 { - Cpm_op_set_lcd_frequencies, - Cpm_op_start_lcd, - Cpm_op_stop_lcd, - Cpm_op_update_output_frequency, - Cpm_op_get_lcd_pixel_frequency, - Cpm_op_set_hdmi_frequency, - Cpm_op_start_hdmi, - Cpm_op_stop_hdmi, -}; diff -r df0bac1946f4 -r 8fd418104ecd pkg/devices/cpm/include/cpm-server.h --- a/pkg/devices/cpm/include/cpm-server.h Fri Jan 01 00:49:07 2021 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,49 +0,0 @@ -/* - * Common CPM server functionality. - * - * Copyright (C) 2018 Paul Boddie - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA - */ - -#pragma once - -#include - -#ifdef __cplusplus - -#include -#include -#include - -/* Server object to provide CPM access. */ - -class Cpm_server : public L4::Server_object_t -{ -private: - Cpm_chip *_chip; - -public: - /* Initialise the server with a peripheral reference. */ - - explicit Cpm_server(Cpm_chip *chip) - : _chip(chip) - {} - - int dispatch(l4_umword_t obj, L4::Ipc::Iostream &ios); -}; - -#endif diff -r df0bac1946f4 -r 8fd418104ecd pkg/devices/cpm/src/Makefile --- a/pkg/devices/cpm/src/Makefile Fri Jan 01 00:49:07 2021 +0100 +++ b/pkg/devices/cpm/src/Makefile Fri Jan 01 01:49:35 2021 +0100 @@ -1,10 +1,6 @@ PKGDIR ?= ../.. L4DIR ?= $(PKGDIR)/../.. -TARGET := client jz4730 jz4740 jz4780 server +TARGET := jz4730 jz4740 jz4780 include $(L4DIR)/mk/subdir.mk - -jz4730: server -jz4740: server -jz4780: server diff -r df0bac1946f4 -r 8fd418104ecd pkg/devices/cpm/src/client/Makefile --- a/pkg/devices/cpm/src/client/Makefile Fri Jan 01 00:49:07 2021 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,13 +0,0 @@ -PKGDIR ?= ../../.. -L4DIR ?= $(PKGDIR)/../.. - -TARGET = libdevice_cpm_client.o.a libdevice_cpm_client.o.so -PC_FILENAME := libdevice-cpm-client - -SRC_CC := cpm-client.cc - -PRIVATE_INCDIR += $(PKGDIR)/cpm/include - -REQUIRES_LIBS := l4re_c l4re_c-util - -include $(L4DIR)/mk/lib.mk diff -r df0bac1946f4 -r 8fd418104ecd pkg/devices/cpm/src/client/cpm-client.cc --- a/pkg/devices/cpm/src/client/cpm-client.cc Fri Jan 01 00:49:07 2021 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,101 +0,0 @@ -/* - * CPM client to access CPM servers. - * - * 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 - * published by the Free Software Foundation; either version 2 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA - */ - -#include -#include - -#include "cpm-client.h" -#include "cpm-ops.h" - -int -Cpm_device_interface::get_lcd_pixel_frequency(uint32_t *frequency) throw() -{ - L4::Ipc::Iostream s(l4_utcb()); - int err = l4_error(s.call(cap(), Cpm_op_get_lcd_pixel_frequency)); - uint32_t _frequency; - - if (err) - return err; - - s >> _frequency; - *frequency = _frequency; - return L4_EOK; -} - -int -Cpm_device_interface::set_hdmi_frequency(uint32_t frequency) throw() -{ - L4::Ipc::Iostream s(l4_utcb()); - - s << frequency; - - return l4_error(s.call(cap(), Cpm_op_set_hdmi_frequency)); -} - -int -Cpm_device_interface::start_hdmi() throw() -{ - L4::Ipc::Iostream s(l4_utcb()); - - return l4_error(s.call(cap(), Cpm_op_start_hdmi)); -} - -int -Cpm_device_interface::stop_hdmi() throw() -{ - L4::Ipc::Iostream s(l4_utcb()); - - return l4_error(s.call(cap(), Cpm_op_stop_hdmi)); -} - -int -Cpm_device_interface::set_lcd_frequencies(uint32_t pclk, uint8_t multiplier) throw() -{ - L4::Ipc::Iostream s(l4_utcb()); - - s << pclk << multiplier; - - return l4_error(s.call(cap(), Cpm_op_set_lcd_frequencies)); -} - -int -Cpm_device_interface::start_lcd() throw() -{ - L4::Ipc::Iostream s(l4_utcb()); - - return l4_error(s.call(cap(), Cpm_op_start_lcd)); -} - -int -Cpm_device_interface::stop_lcd() throw() -{ - L4::Ipc::Iostream s(l4_utcb()); - - return l4_error(s.call(cap(), Cpm_op_stop_lcd)); -} - -int -Cpm_device_interface::update_output_frequency() throw() -{ - L4::Ipc::Iostream s(l4_utcb()); - - return l4_error(s.call(cap(), Cpm_op_update_output_frequency)); -} diff -r df0bac1946f4 -r 8fd418104ecd pkg/devices/cpm/src/jz4730/Makefile --- a/pkg/devices/cpm/src/jz4730/Makefile Fri Jan 01 00:49:07 2021 +0100 +++ b/pkg/devices/cpm/src/jz4730/Makefile Fri Jan 01 01:49:35 2021 +0100 @@ -3,12 +3,36 @@ TARGET = dev_cpm_jz4730 MODE = shared -PC_FILENAME := devices-cpm-jz4730 +PC_FILENAME = devices-cpm-jz4730 + +# Locations for interface input and generated output. -SRC_CC := cpm-jz4730.cc +IDL_DIR = $(PKGDIR)/idl +IDL_MK_DIR = $(L4DIR)/idl4re/mk +IDL_BUILD_DIR = . +IDL_EXPORT_DIR = . + +include $(IDL_MK_DIR)/idl.mk + +# Individual interfaces. -PRIVATE_INCDIR += $(PKGDIR)/cpm/include +SERVER_INTERFACES_CC = cpm + +# Generated and plain source files. + +SERVER_INTERFACES_SRC_CC = $(call interfaces_to_server_cc,$(SERVER_INTERFACES_CC)) + +PLAIN_SRC_CC = cpm-jz4730.cc -REQUIRES_LIBS := l4re_c l4re_c-util libdrivers-cpm libdevice-cpm-server libdevice-util +# Normal definitions. + +SRC_CC = $(SERVER_INTERFACES_SRC_CC) $(PLAIN_SRC_CC) + +REQUIRES_LIBS = l4re_c l4re_c-util libdrivers-cpm libdevice-util libipc + +PRIVATE_INCDIR = $(IDL_BUILD_DIR) $(IDL_EXPORT_DIR) include $(L4DIR)/mk/prog.mk +include $(IDL_MK_DIR)/interface_rules.mk + +$(PLAIN_SRC_CC): $(SERVER_INTERFACES_SRC_CC) diff -r df0bac1946f4 -r 8fd418104ecd pkg/devices/cpm/src/jz4730/cpm-jz4730.cc --- a/pkg/devices/cpm/src/jz4730/cpm-jz4730.cc Fri Jan 01 00:49:07 2021 +0100 +++ b/pkg/devices/cpm/src/jz4730/cpm-jz4730.cc Fri Jan 01 01:49:35 2021 +0100 @@ -1,7 +1,7 @@ /* * JZ4730 CPM server. * - * 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,21 +21,19 @@ #include #include -#include "cpm-server.h" + +#include -#include -#include -#include +#include +#include "cpm_server.h" -#include - -// Virtual addresses for the CPM and LCD register blocks. +/* Virtual addresses for the CPM and LCD register blocks. */ static l4_addr_t cpm_virt_base = 0, cpm_virt_base_end = 0; -// Access to peripheral memory. +/* Access to peripheral memory. */ static int setup_memory() { @@ -47,7 +45,42 @@ -static L4Re::Util::Registry_server<> server; +/* CPM server. */ + +class server_CPM : public CPM +{ + Cpm_jz4730_chip *_chip; + +public: + explicit server_CPM(Cpm_jz4730_chip *chip) + : _chip(chip) + { + } + + long set_lcd_frequencies(uint32_t pclk, uint8_t multiplier) + { + _chip->set_lcd_frequencies(pclk, multiplier); + return L4_EOK; + } + + long start_lcd() + { + _chip->start_lcd(); + return L4_EOK; + } + + long stop_lcd() + { + _chip->stop_lcd(); + return L4_EOK; + } + + long update_output_frequency() + { + _chip->update_output_frequency(); + return L4_EOK; + } +}; @@ -63,11 +96,14 @@ /* Initialise and register a server object. */ - Cpm_server server_obj(&cpm_device); - server.registry()->register_obj(&server_obj, "cpm"); + server_CPM obj(&cpm_device); + l4_cap_idx_t server; + + if (ipc_server_bind("cpm", (l4_umword_t) &obj, &server)) return 1; /* Enter the IPC server loop. */ - server.loop(); + ipc_server_loop(CPM_expected_items, &obj, + (ipc_server_handler_type) handle_CPM); return 0; } diff -r df0bac1946f4 -r 8fd418104ecd pkg/devices/cpm/src/jz4740/Makefile --- a/pkg/devices/cpm/src/jz4740/Makefile Fri Jan 01 00:49:07 2021 +0100 +++ b/pkg/devices/cpm/src/jz4740/Makefile Fri Jan 01 01:49:35 2021 +0100 @@ -3,12 +3,36 @@ TARGET = dev_cpm_jz4740 MODE = shared -PC_FILENAME := devices-cpm-jz4740 +PC_FILENAME = devices-cpm-jz4740 + +# Locations for interface input and generated output. -SRC_CC := cpm-jz4740.cc +IDL_DIR = $(PKGDIR)/idl +IDL_MK_DIR = $(L4DIR)/idl4re/mk +IDL_BUILD_DIR = . +IDL_EXPORT_DIR = . + +include $(IDL_MK_DIR)/idl.mk + +# Individual interfaces. -PRIVATE_INCDIR += $(PKGDIR)/cpm/include +SERVER_INTERFACES_CC = cpm + +# Generated and plain source files. + +SERVER_INTERFACES_SRC_CC = $(call interfaces_to_server_cc,$(SERVER_INTERFACES_CC)) + +PLAIN_SRC_CC = cpm-jz4740.cc -REQUIRES_LIBS := l4re_c l4re_c-util libdrivers-cpm libdevice-cpm-server libdevice-util +# Normal definitions. + +SRC_CC = $(SERVER_INTERFACES_SRC_CC) $(PLAIN_SRC_CC) + +REQUIRES_LIBS = l4re_c l4re_c-util libdrivers-cpm libdevice-util libipc + +PRIVATE_INCDIR = $(IDL_BUILD_DIR) $(IDL_EXPORT_DIR) include $(L4DIR)/mk/prog.mk +include $(IDL_MK_DIR)/interface_rules.mk + +$(PLAIN_SRC_CC): $(SERVER_INTERFACES_SRC_CC) diff -r df0bac1946f4 -r 8fd418104ecd pkg/devices/cpm/src/jz4740/cpm-jz4740.cc --- a/pkg/devices/cpm/src/jz4740/cpm-jz4740.cc Fri Jan 01 00:49:07 2021 +0100 +++ b/pkg/devices/cpm/src/jz4740/cpm-jz4740.cc Fri Jan 01 01:49:35 2021 +0100 @@ -1,7 +1,7 @@ /* * JZ4740 CPM server. * - * 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,13 +21,11 @@ #include #include -#include "cpm-server.h" + +#include -#include -#include -#include - -#include +#include +#include "cpm_server.h" // Virtual addresses for the CPM and LCD register blocks. @@ -47,7 +45,42 @@ -static L4Re::Util::Registry_server<> server; +/* CPM server. */ + +class server_CPM : public CPM +{ + Cpm_jz4740_chip *_chip; + +public: + explicit server_CPM(Cpm_jz4740_chip *chip) + : _chip(chip) + { + } + + long set_lcd_frequencies(uint32_t pclk, uint8_t multiplier) + { + _chip->set_lcd_frequencies(pclk, multiplier); + return L4_EOK; + } + + long start_lcd() + { + _chip->start_lcd(); + return L4_EOK; + } + + long stop_lcd() + { + _chip->stop_lcd(); + return L4_EOK; + } + + long update_output_frequency() + { + _chip->update_output_frequency(); + return L4_EOK; + } +}; @@ -62,12 +95,15 @@ Cpm_jz4740_chip cpm_device(cpm_virt_base, 12000000); /* Initialise and register a server object. */ - - Cpm_server server_obj(&cpm_device); - server.registry()->register_obj(&server_obj, "cpm"); - + + server_CPM obj(&cpm_device); + l4_cap_idx_t server; + + if (ipc_server_bind("cpm", (l4_umword_t) &obj, &server)) return 1; + /* Enter the IPC server loop. */ - - server.loop(); + + ipc_server_loop(CPM_expected_items, &obj, + (ipc_server_handler_type) handle_CPM); return 0; } diff -r df0bac1946f4 -r 8fd418104ecd pkg/devices/cpm/src/jz4780/Makefile --- a/pkg/devices/cpm/src/jz4780/Makefile Fri Jan 01 00:49:07 2021 +0100 +++ b/pkg/devices/cpm/src/jz4780/Makefile Fri Jan 01 01:49:35 2021 +0100 @@ -3,12 +3,36 @@ TARGET = dev_cpm_jz4780 MODE = shared -PC_FILENAME := devices-cpm-jz4780 +PC_FILENAME = devices-cpm-jz4780 + +# Locations for interface input and generated output. -SRC_CC := cpm-jz4780.cc +IDL_DIR = $(PKGDIR)/idl +IDL_MK_DIR = $(L4DIR)/idl4re/mk +IDL_BUILD_DIR = . +IDL_EXPORT_DIR = . + +include $(IDL_MK_DIR)/idl.mk + +# Individual interfaces. -PRIVATE_INCDIR += $(PKGDIR)/cpm/include +SERVER_INTERFACES_CC = cpm + +# Generated and plain source files. + +SERVER_INTERFACES_SRC_CC = $(call interfaces_to_server_cc,$(SERVER_INTERFACES_CC)) + +PLAIN_SRC_CC = cpm-jz4780.cc -REQUIRES_LIBS := l4re_c l4re_c-util libdrivers-cpm libdevice-cpm-server libdevice-util +# Normal definitions. + +SRC_CC = $(SERVER_INTERFACES_SRC_CC) $(PLAIN_SRC_CC) + +REQUIRES_LIBS = l4re_c l4re_c-util libdrivers-cpm libdevice-util libipc + +PRIVATE_INCDIR = $(IDL_BUILD_DIR) $(IDL_EXPORT_DIR) include $(L4DIR)/mk/prog.mk +include $(IDL_MK_DIR)/interface_rules.mk + +$(PLAIN_SRC_CC): $(SERVER_INTERFACES_SRC_CC) diff -r df0bac1946f4 -r 8fd418104ecd pkg/devices/cpm/src/jz4780/cpm-jz4780.cc --- a/pkg/devices/cpm/src/jz4780/cpm-jz4780.cc Fri Jan 01 00:49:07 2021 +0100 +++ b/pkg/devices/cpm/src/jz4780/cpm-jz4780.cc Fri Jan 01 01:49:35 2021 +0100 @@ -1,7 +1,7 @@ /* * JZ4780 CPM server. * - * 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,13 +21,11 @@ #include #include -#include "cpm-server.h" + +#include -#include -#include -#include - -#include +#include +#include "cpm_server.h" // Virtual addresses for the CPM and LCD register blocks. @@ -47,7 +45,66 @@ -static L4Re::Util::Registry_server<> server; +/* CPM server. */ + +class server_CPM : public CPM +{ + Cpm_jz4780_chip *_chip; + +public: + explicit server_CPM(Cpm_jz4780_chip *chip) + : _chip(chip) + { + } + + long get_lcd_pixel_frequency(uint8_t controller, uint32_t *frequency) + { + *frequency = _chip->get_lcd_pixel_frequency(controller); + return L4_EOK; + } + + long set_hdmi_frequency(uint32_t frequency) + { + _chip->set_hdmi_frequency(frequency); + return L4_EOK; + } + + long set_lcd_frequencies(uint32_t pclk, uint8_t multiplier) + { + _chip->set_lcd_frequencies(pclk, multiplier); + return L4_EOK; + } + + long start_hdmi() + { + _chip->start_hdmi(); + return L4_EOK; + } + + long stop_hdmi() + { + _chip->stop_hdmi(); + return L4_EOK; + } + + long start_lcd() + { + _chip->start_lcd(); + return L4_EOK; + } + + long stop_lcd() + { + _chip->stop_lcd(); + return L4_EOK; + } + + long update_output_frequency() + { + _chip->update_output_frequency(); + return L4_EOK; + } +}; @@ -63,11 +120,14 @@ /* Initialise and register a server object. */ - Cpm_server server_obj(&cpm_device); - server.registry()->register_obj(&server_obj, "cpm"); + server_CPM obj(&cpm_device); + l4_cap_idx_t server; + + if (ipc_server_bind("cpm", (l4_umword_t) &obj, &server)) return 1; /* Enter the IPC server loop. */ - server.loop(); + ipc_server_loop(CPM_expected_items, &obj, + (ipc_server_handler_type) handle_CPM); return 0; } diff -r df0bac1946f4 -r 8fd418104ecd pkg/devices/cpm/src/server/Makefile --- a/pkg/devices/cpm/src/server/Makefile Fri Jan 01 00:49:07 2021 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,13 +0,0 @@ -PKGDIR ?= ../../.. -L4DIR ?= $(PKGDIR)/../.. - -TARGET = libdevice_cpm_server.o.a libdevice_cpm_server.o.so -PC_FILENAME := libdevice-cpm-server - -SRC_CC := cpm-server.cc - -PRIVATE_INCDIR += $(PKGDIR)/cpm/include - -REQUIRES_LIBS := l4re_c l4re_c-util libdrivers-cpm - -include $(L4DIR)/mk/lib.mk diff -r df0bac1946f4 -r 8fd418104ecd pkg/devices/cpm/src/server/cpm-server.cc --- a/pkg/devices/cpm/src/server/cpm-server.cc Fri Jan 01 00:49:07 2021 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,87 +0,0 @@ -/* - * Common CPM server functionality. - * - * 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 - * 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 "cpm-client.h" -#include "cpm-server.h" -#include "cpm-ops.h" - -#include -#include -#include -#include - -/* Handle invocations. */ - -int -Cpm_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 Cpm_op_get_lcd_pixel_frequency: - ios << _chip->get_lcd_pixel_frequency(); - return L4_EOK; - - case Cpm_op_set_hdmi_frequency: - uint32_t frequency; - ios >> frequency; - _chip->set_hdmi_frequency(frequency); - return L4_EOK; - - case Cpm_op_start_hdmi: - _chip->start_hdmi(); - return L4_EOK; - - case Cpm_op_stop_hdmi: - _chip->stop_hdmi(); - return L4_EOK; - - case Cpm_op_set_lcd_frequencies: - uint32_t pclk; - int multiplier; - ios >> pclk; - ios >> multiplier; - _chip->set_lcd_frequencies(pclk, multiplier); - return L4_EOK; - - case Cpm_op_start_lcd: - _chip->start_lcd(); - return L4_EOK; - - case Cpm_op_stop_lcd: - _chip->stop_lcd(); - return L4_EOK; - - case Cpm_op_update_output_frequency: - _chip->update_output_frequency(); - return L4_EOK; - - default: - return -L4_EBADPROTO; - } -} diff -r df0bac1946f4 -r 8fd418104ecd pkg/devices/display/Makefile --- a/pkg/devices/display/Makefile Fri Jan 01 00:49:07 2021 +0100 +++ b/pkg/devices/display/Makefile Fri Jan 01 01:49:35 2021 +0100 @@ -1,8 +1,6 @@ PKGDIR ?= .. L4DIR ?= $(PKGDIR)/../.. -TARGET := include src +TARGET := src include $(L4DIR)/mk/subdir.mk - -src: include diff -r df0bac1946f4 -r 8fd418104ecd pkg/devices/display/include/Makefile --- a/pkg/devices/display/include/Makefile Fri Jan 01 00:49:07 2021 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,6 +0,0 @@ -PKGDIR = ../.. -L4DIR ?= $(PKGDIR)/../.. - -PC_FILENAME := libdevice-display-ops - -include $(L4DIR)/mk/include.mk diff -r df0bac1946f4 -r 8fd418104ecd pkg/devices/display/include/display-client.h --- a/pkg/devices/display/include/display-client.h Fri Jan 01 00:49:07 2021 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,40 +0,0 @@ -/* - * Display client to access display 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 "display-ops.h" - -#include - -class Display_device_interface : public L4::Kobject_t -{ - L4_KOBJECT(Display_device_interface) - -public: - int disable() throw(); - int enable() throw(); -}; - -#endif diff -r df0bac1946f4 -r 8fd418104ecd pkg/devices/display/include/display-ops.h --- a/pkg/devices/display/include/display-ops.h Fri Jan 01 00:49:07 2021 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,24 +0,0 @@ -/* - * Display 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 { Display_op_disable, Display_op_enable }; diff -r df0bac1946f4 -r 8fd418104ecd pkg/devices/display/src/Makefile --- a/pkg/devices/display/src/Makefile Fri Jan 01 00:49:07 2021 +0100 +++ b/pkg/devices/display/src/Makefile Fri Jan 01 01:49:35 2021 +0100 @@ -1,6 +1,6 @@ PKGDIR ?= ../.. L4DIR ?= $(PKGDIR)/../.. -TARGET := ci20 client letux400 qi_lb60 +TARGET := ci20 letux400 qi_lb60 include $(L4DIR)/mk/subdir.mk diff -r df0bac1946f4 -r 8fd418104ecd pkg/devices/display/src/ci20/Makefile --- a/pkg/devices/display/src/ci20/Makefile Fri Jan 01 00:49:07 2021 +0100 +++ b/pkg/devices/display/src/ci20/Makefile Fri Jan 01 01:49:35 2021 +0100 @@ -3,12 +3,40 @@ TARGET = dev_display_ci20_hdmi MODE = shared -PC_FILENAME := devices-display-ci20_hdmi +PC_FILENAME = devices-display-ci20_hdmi + +# Locations for interface input and generated output. -SRC_CC := display-ci20_hdmi.cc +IDL_DIR = $(PKGDIR)/idl +IDL_MK_DIR = $(L4DIR)/idl4re/mk +IDL_BUILD_DIR = . +IDL_EXPORT_DIR = . + +include $(IDL_MK_DIR)/idl.mk + +# Individual interfaces. + +CLIENT_INTERFACES_CC = cpm icu -PRIVATE_INCDIR += $(PKGDIR)/display/include +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)) -REQUIRES_LIBS := l4re_c l4re_c-util libdevice-cpm-client libdrivers-hdmi-jz4780 libdrivers-lcd-jz4740 libdrivers-panel-loader libdevice-util +PLAIN_SRC_CC = display-ci20_hdmi.cc + +# Normal definitions. + +SRC_CC = $(CLIENT_INTERFACES_SRC_CC) $(SERVER_INTERFACES_SRC_CC) $(PLAIN_SRC_CC) + +REQUIRES_LIBS = l4re_c l4re_c-util libdrivers-hdmi-jz4780 libdrivers-lcd-jz4740 libdrivers-panel-loader libdevice-util libipc + +PRIVATE_INCDIR = $(IDL_BUILD_DIR) $(IDL_EXPORT_DIR) include $(L4DIR)/mk/prog.mk +include $(IDL_MK_DIR)/interface_rules.mk + +$(PLAIN_SRC_CC): $(CLIENT_INTERFACES_SRC_CC) $(SERVER_INTERFACES_SRC_CC) diff -r df0bac1946f4 -r 8fd418104ecd pkg/devices/display/src/ci20/display-ci20_hdmi.cc --- a/pkg/devices/display/src/ci20/display-ci20_hdmi.cc Fri Jan 01 00:49:07 2021 +0100 +++ b/pkg/devices/display/src/ci20/display-ci20_hdmi.cc Fri Jan 01 01:49:35 2021 +0100 @@ -19,33 +19,30 @@ * Boston, MA 02110-1301, USA */ -#include #include #include #include #include #include -#include -#include -#include -#include -#include -#include +#include -#include "display-ops.h" +#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; static l4_uint32_t hdmi_irq_start, hdmi_irq_end; -static L4::Cap hdmi_irq; -static L4::Cap icu; +static l4_cap_idx_t hdmi_irq, icu; -/* CPM device abstractions. */ +/* Device abstractions. */ static Hdmi_jz4780_chip *hdmi = 0; -static L4::Cap cpm_device; +static CPM *cpm_device; @@ -59,8 +56,11 @@ /* Obtain a reference to the CPM device. */ - cpm_device = L4Re::Env::env()->get_cap("cpm"); - if (!cpm_device.is_valid()) return 1; + l4_cap_idx_t cpm = l4re_env_get_cap("cpm"); + if (!l4_is_valid_cap(cpm)) return 1; + + static client_CPM cpm_obj(cpm); + cpm_device = &cpm_obj; /* Start the HDMI peripheral. */ @@ -75,23 +75,24 @@ /* Obtain access to the HDMI interrupt using the ICU. */ - icu = L4Re::Env::env()->get_cap("icu"); + icu = l4re_env_get_cap("icu"); + if (!l4_is_valid_cap(icu)) return 1; - hdmi_irq = L4Re::Util::cap_alloc.alloc(); - L4Re::Env::env()->factory()->create(hdmi_irq); - - if (!hdmi_irq.is_valid() || !icu.is_valid()) return 1; + if (ipc_create_irq(&hdmi_irq)) return 1; /* Bind the IRQ object to the interrupt in this thread. */ - int err = l4_error(icu->bind(hdmi_irq_start, hdmi_irq)); + client_ICU icu_obj(icu); + + long err = icu_obj.bind(hdmi_irq_start, hdmi_irq); if (err) return err; - hdmi_irq->bind_thread(L4Re::Env::env()->main_thread(), 0); + err = ipc_bind_irq(hdmi_irq, 0, l4re_env()->main_thread); + if (err) return err; /* Obtain an abstraction for the HDMI peripheral. */ - hdmi = new Hdmi_jz4780_chip(hdmi_virt_base, hdmi_virt_base_end, hdmi_irq.cap(), panel); + hdmi = new Hdmi_jz4780_chip(hdmi_virt_base, hdmi_virt_base_end, hdmi_irq, panel); return 0; } @@ -100,56 +101,33 @@ /* Display device. */ -class Display_device_server : public L4::Server_object_t +class server_DisplayObject : public Activation { public: - /* 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) { + return L4_EOK; } /* Switch the display on. */ - void enable(void) + long enable(void) { uint32_t frequency; // NOTE: Should test to see if it is connected. - if (!cpm_device->get_lcd_pixel_frequency(&frequency)) + if (!cpm_device->get_lcd_pixel_frequency(0, &frequency)) { hdmi->enable(frequency); } + + return L4_EOK; } }; -static L4Re::Util::Registry_server<> server; - int main(void) @@ -158,11 +136,14 @@ /* Initialise and register a new server object. */ - Display_device_server server_obj; - server.registry()->register_obj(&server_obj, "display"); + server_DisplayObject 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 df0bac1946f4 -r 8fd418104ecd pkg/devices/display/src/client/Makefile --- a/pkg/devices/display/src/client/Makefile Fri Jan 01 00:49:07 2021 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,13 +0,0 @@ -PKGDIR ?= ../../.. -L4DIR ?= $(PKGDIR)/../.. - -TARGET = libdevice_display_client.o.a libdevice_display_client.o.so -PC_FILENAME := libdevice-display-client - -SRC_CC := display-client.cc - -PRIVATE_INCDIR += $(PKGDIR)/display/include - -REQUIRES_LIBS := l4re_c l4re_c-util - -include $(L4DIR)/mk/lib.mk diff -r df0bac1946f4 -r 8fd418104ecd pkg/devices/display/src/client/display-client.cc --- a/pkg/devices/display/src/client/display-client.cc Fri Jan 01 00:49:07 2021 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,44 +0,0 @@ -/* - * Display client to access display servers. - * - * Copyright (C) 2018 Paul Boddie - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA - */ - -#include -#include -#include - -#include "display-client.h" - -#include - -int -Display_device_interface::disable() throw() -{ - L4::Ipc::Iostream s(l4_utcb()); - - return l4_error(s.call(cap(), Display_op_disable)); -} - -int -Display_device_interface::enable() throw() -{ - L4::Ipc::Iostream s(l4_utcb()); - - return l4_error(s.call(cap(), Display_op_enable)); -} diff -r df0bac1946f4 -r 8fd418104ecd pkg/devices/idl/cpm.idl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/pkg/devices/idl/cpm.idl Fri Jan 01 01:49:35 2021 +0100 @@ -0,0 +1,25 @@ +#include +#include + +/* A clock and power management interface, currently with Ingenic-specific SoC + details. */ + +[protocol(LANDFALL_CPM)] +interface CPM +{ + void get_lcd_pixel_frequency(in uint8_t controller, out uint32_t frequency); + + void set_hdmi_frequency(in uint32_t frequency); + + void set_lcd_frequencies(in uint32_t pclk, in uint8_t multiplier); + + void start_hdmi(); + + void stop_hdmi(); + + void start_lcd(); + + void stop_lcd(); + + void update_output_frequency(); +}; diff -r df0bac1946f4 -r 8fd418104ecd pkg/devices/idl/icu.idl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/pkg/devices/idl/icu.idl Fri Jan 01 01:49:35 2021 +0100 @@ -0,0 +1,9 @@ +#include + +/* An interrupt controller interface. */ + +[protocol(L4_PROTO_IRQ)] +interface ICU +{ + [opcode(L4_ICU_OP_BIND)] void bind(in int num, in cap irq); +}; diff -r df0bac1946f4 -r 8fd418104ecd pkg/devices/include/protocols.h --- a/pkg/devices/include/protocols.h Fri Jan 01 00:49:07 2021 +0100 +++ b/pkg/devices/include/protocols.h Fri Jan 01 01:49:35 2021 +0100 @@ -23,5 +23,8 @@ #define LANDFALL_ACTIVATION 0x1f01 #define LANDFALL_BACKLIGHT 0x1f02 +#define LANDFALL_CPM 0x1f03 #define LANDFALL_PWM 0x1f10 #define LANDFALL_SPI 0x1f13 + +// vim: tabstop=2 expandtab shiftwidth=2 diff -r df0bac1946f4 -r 8fd418104ecd pkg/devices/lcd/include/lcd-device.h --- a/pkg/devices/lcd/include/lcd-device.h Fri Jan 01 00:49:07 2021 +0100 +++ b/pkg/devices/lcd/include/lcd-device.h Fri Jan 01 01:49:35 2021 +0100 @@ -21,7 +21,7 @@ #pragma once -#include +#include #include #include diff -r df0bac1946f4 -r 8fd418104ecd pkg/devices/lcd/src/common/Makefile --- a/pkg/devices/lcd/src/common/Makefile Fri Jan 01 00:49:07 2021 +0100 +++ b/pkg/devices/lcd/src/common/Makefile Fri Jan 01 01:49:35 2021 +0100 @@ -9,7 +9,7 @@ IDL_DIR = $(PKGDIR)/idl IDL_MK_DIR = $(L4DIR)/idl4re/mk IDL_BUILD_DIR = . -IDL_EXPORT_DIR = $(OBJ_BASE)/include/l4/devices/activation +IDL_EXPORT_DIR = $(OBJ_BASE)/include/l4/devices/lcd include $(IDL_MK_DIR)/idl.mk diff -r df0bac1946f4 -r 8fd418104ecd pkg/devices/lcd/src/jz4740/Makefile --- a/pkg/devices/lcd/src/jz4740/Makefile Fri Jan 01 00:49:07 2021 +0100 +++ b/pkg/devices/lcd/src/jz4740/Makefile Fri Jan 01 01:49:35 2021 +0100 @@ -9,13 +9,13 @@ IDL_DIR = $(PKGDIR)/idl IDL_MK_DIR = $(L4DIR)/idl4re/mk IDL_BUILD_DIR = . -IDL_EXPORT_DIR = $(OBJ_BASE)/include/l4/devices/activation +IDL_EXPORT_DIR = $(OBJ_BASE)/include/l4/devices/lcd include $(IDL_MK_DIR)/idl.mk # Individual interfaces. -CLIENT_INTERFACES_CC = activation +CLIENT_INTERFACES_CC = activation cpm # Generated and plain source files. @@ -29,7 +29,6 @@ REQUIRES_LIBS = \ l4re_c l4re_c-util \ - libdevice-cpm-client \ libdevice-lcd libdrivers-lcd-jz4740 libdrivers-panel-loader \ libdevice-util libipc diff -r df0bac1946f4 -r 8fd418104ecd pkg/devices/lcd/src/jz4740/lcd-jz4740-device.cc --- a/pkg/devices/lcd/src/jz4740/lcd-jz4740-device.cc Fri Jan 01 00:49:07 2021 +0100 +++ b/pkg/devices/lcd/src/jz4740/lcd-jz4740-device.cc Fri Jan 01 01:49:35 2021 +0100 @@ -19,7 +19,6 @@ * Boston, MA 02110-1301, USA */ -#include #include #include #include @@ -37,6 +36,7 @@ #include #include "activation_client.h" +#include "cpm_client.h" // Virtual addresses for the LCD register block. @@ -46,8 +46,8 @@ static Lcd_jz4740_chip *lcd_chip = 0; -static L4::Cap cpm_device; static Activation *display_device; +static CPM *cpm_device; @@ -265,8 +265,8 @@ // Obtain access to the CPM and display devices. - cpm_device = L4Re::Env::env()->get_cap("cpm"); - if (!cpm_device.is_valid()) return 1; + l4_cap_idx_t cpm = l4re_env_get_cap("cpm"); + 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; @@ -274,6 +274,9 @@ static client_Activation display_obj(display); display_device = &display_obj; + static client_CPM cpm_obj(cpm); + cpm_device = &cpm_obj; + // Load the panel data from the configured library. struct Jz4740_lcd_panel *panel = (struct Jz4740_lcd_panel *) load_panel();