1.1 --- a/pkg/devices/display/src/ci20/display-ci20_hdmi.cc Fri Jan 01 00:49:07 2021 +0100
1.2 +++ b/pkg/devices/display/src/ci20/display-ci20_hdmi.cc Fri Jan 01 01:49:35 2021 +0100
1.3 @@ -19,33 +19,30 @@
1.4 * Boston, MA 02110-1301, USA
1.5 */
1.6
1.7 -#include <l4/devices/cpm-client.h>
1.8 #include <l4/devices/hdmi-jz4780.h>
1.9 #include <l4/devices/lcd-jz4740-config.h>
1.10 #include <l4/devices/lcd-jz4740-panel.h>
1.11 #include <l4/devices/panel-loader.h>
1.12 #include <l4/devices/memory.h>
1.13
1.14 -#include <l4/cxx/ipc_server>
1.15 -#include <l4/re/env>
1.16 -#include <l4/re/util/object_registry>
1.17 -#include <l4/sys/capability>
1.18 -#include <l4/sys/factory>
1.19 -#include <l4/sys/icu.h>
1.20 +#include <l4/re/env.h>
1.21
1.22 -#include "display-ops.h"
1.23 +#include <ipc/irq.h>
1.24 +#include <ipc/server.h>
1.25 +#include "activation_server.h"
1.26 +#include "cpm_client.h"
1.27 +#include "icu_client.h"
1.28
1.29 /* Virtual addresses for the HDMI register block plus interrupt capability. */
1.30
1.31 static l4_addr_t hdmi_virt_base = 0, hdmi_virt_base_end = 0;
1.32 static l4_uint32_t hdmi_irq_start, hdmi_irq_end;
1.33 -static L4::Cap<L4::Irq> hdmi_irq;
1.34 -static L4::Cap<L4::Icu> icu;
1.35 +static l4_cap_idx_t hdmi_irq, icu;
1.36
1.37 -/* CPM device abstractions. */
1.38 +/* Device abstractions. */
1.39
1.40 static Hdmi_jz4780_chip *hdmi = 0;
1.41 -static L4::Cap<Cpm_device_interface> cpm_device;
1.42 +static CPM *cpm_device;
1.43
1.44
1.45
1.46 @@ -59,8 +56,11 @@
1.47
1.48 /* Obtain a reference to the CPM device. */
1.49
1.50 - cpm_device = L4Re::Env::env()->get_cap<Cpm_device_interface>("cpm");
1.51 - if (!cpm_device.is_valid()) return 1;
1.52 + l4_cap_idx_t cpm = l4re_env_get_cap("cpm");
1.53 + if (!l4_is_valid_cap(cpm)) return 1;
1.54 +
1.55 + static client_CPM cpm_obj(cpm);
1.56 + cpm_device = &cpm_obj;
1.57
1.58 /* Start the HDMI peripheral. */
1.59
1.60 @@ -75,23 +75,24 @@
1.61
1.62 /* Obtain access to the HDMI interrupt using the ICU. */
1.63
1.64 - icu = L4Re::Env::env()->get_cap<L4::Icu>("icu");
1.65 + icu = l4re_env_get_cap("icu");
1.66 + if (!l4_is_valid_cap(icu)) return 1;
1.67
1.68 - hdmi_irq = L4Re::Util::cap_alloc.alloc<L4::Irq>();
1.69 - L4Re::Env::env()->factory()->create(hdmi_irq);
1.70 -
1.71 - if (!hdmi_irq.is_valid() || !icu.is_valid()) return 1;
1.72 + if (ipc_create_irq(&hdmi_irq)) return 1;
1.73
1.74 /* Bind the IRQ object to the interrupt in this thread. */
1.75
1.76 - int err = l4_error(icu->bind(hdmi_irq_start, hdmi_irq));
1.77 + client_ICU icu_obj(icu);
1.78 +
1.79 + long err = icu_obj.bind(hdmi_irq_start, hdmi_irq);
1.80 if (err) return err;
1.81
1.82 - hdmi_irq->bind_thread(L4Re::Env::env()->main_thread(), 0);
1.83 + err = ipc_bind_irq(hdmi_irq, 0, l4re_env()->main_thread);
1.84 + if (err) return err;
1.85
1.86 /* Obtain an abstraction for the HDMI peripheral. */
1.87
1.88 - hdmi = new Hdmi_jz4780_chip(hdmi_virt_base, hdmi_virt_base_end, hdmi_irq.cap(), panel);
1.89 + hdmi = new Hdmi_jz4780_chip(hdmi_virt_base, hdmi_virt_base_end, hdmi_irq, panel);
1.90
1.91 return 0;
1.92 }
1.93 @@ -100,56 +101,33 @@
1.94
1.95 /* Display device. */
1.96
1.97 -class Display_device_server : public L4::Server_object_t<L4::Kobject>
1.98 +class server_DisplayObject : public Activation
1.99 {
1.100 public:
1.101 - /* Dispatch incoming requests. */
1.102 -
1.103 - int dispatch(l4_umword_t obj, L4::Ipc::Iostream &ios)
1.104 - {
1.105 - l4_msgtag_t tag;
1.106 -
1.107 - (void) obj;
1.108 - ios >> tag;
1.109 -
1.110 - switch (tag.label())
1.111 - {
1.112 - case Display_op_disable:
1.113 - disable();
1.114 - return L4_EOK;
1.115 -
1.116 - case Display_op_enable:
1.117 - enable();
1.118 - return L4_EOK;
1.119 -
1.120 - default:
1.121 - return -L4_EBADPROTO;
1.122 - }
1.123 - }
1.124 -
1.125 /* Switch the display off. */
1.126
1.127 - void disable(void)
1.128 + long disable(void)
1.129 {
1.130 + return L4_EOK;
1.131 }
1.132
1.133 /* Switch the display on. */
1.134
1.135 - void enable(void)
1.136 + long enable(void)
1.137 {
1.138 uint32_t frequency;
1.139
1.140 // NOTE: Should test to see if it is connected.
1.141
1.142 - if (!cpm_device->get_lcd_pixel_frequency(&frequency))
1.143 + if (!cpm_device->get_lcd_pixel_frequency(0, &frequency))
1.144 {
1.145 hdmi->enable(frequency);
1.146 }
1.147 +
1.148 + return L4_EOK;
1.149 }
1.150 };
1.151
1.152 -static L4Re::Util::Registry_server<> server;
1.153 -
1.154
1.155
1.156 int main(void)
1.157 @@ -158,11 +136,14 @@
1.158
1.159 /* Initialise and register a new server object. */
1.160
1.161 - Display_device_server server_obj;
1.162 - server.registry()->register_obj(&server_obj, "display");
1.163 + server_DisplayObject obj;
1.164 + l4_cap_idx_t server;
1.165 +
1.166 + if (ipc_server_bind("display", (l4_umword_t) &obj, &server)) return 1;
1.167
1.168 /* Enter the IPC server loop. */
1.169
1.170 - server.loop();
1.171 + ipc_server_loop(Activation_expected_items, &obj,
1.172 + (ipc_server_handler_type) handle_Activation);
1.173 return 0;
1.174 }