1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/conf/landfall-examples/mips-qi_lb60-dl-example.cfg Sun May 27 22:08:58 2018 +0200
1.3 @@ -0,0 +1,165 @@
1.4 +-- vim: ft=lua ts=2 et sw=2
1.5 +
1.6 +-- Start Mag to multiplex the framebuffer showing only a single program.
1.7 +-- This example shows a framebuffer terminal showing the dl_test example's output.
1.8 +-- The target platform is the Ben NanoNote.
1.9 +
1.10 +local L4 = require("L4");
1.11 +
1.12 +local l = L4.default_loader;
1.13 +
1.14 +-- Define general access to peripherals.
1.15 +
1.16 +local io_buses = {
1.17 + cpm = l:new_channel();
1.18 + gpio = l:new_channel();
1.19 + lcd = l:new_channel();
1.20 + };
1.21 +
1.22 +l:start({
1.23 + caps = {
1.24 + cpm = io_buses.cpm:svr(),
1.25 + gpio = io_buses.gpio:svr(),
1.26 + lcd = io_buses.lcd:svr(),
1.27 +
1.28 + icu = L4.Env.icu,
1.29 + sigma0 = L4.cast(L4.Proto.Factory, L4.Env.sigma0):create(L4.Proto.Sigma0),
1.30 + },
1.31 + },
1.32 + "rom/io rom/hw_devices.io rom/mips-qi_lb60-common.io");
1.33 +
1.34 +-- Expose a SPI peripheral as a device.
1.35 +
1.36 +local spi = l:new_channel();
1.37 +
1.38 +l:startv({
1.39 + caps = {
1.40 + vbus = io_buses.gpio,
1.41 + spi = spi:svr(),
1.42 + },
1.43 + },
1.44 + "rom/dev_spi_jz4740", "C23", "C22", "C21"); -- specifying clock, data, enable pin details
1.45 +
1.46 +-- Expose a SPI backlight device for the Ben.
1.47 +
1.48 +local backlight = l:new_channel(); -- exposes backlight device
1.49 +
1.50 +l:start({
1.51 + caps = {
1.52 + spi = spi,
1.53 + backlight = backlight:svr(),
1.54 + },
1.55 + },
1.56 + "rom/dev_backlight_spi_ili8960");
1.57 +
1.58 +-- Expose a display device for the Ben.
1.59 +
1.60 +local display = l:new_channel(); -- exposes display device
1.61 +
1.62 +l:start({
1.63 + caps = {
1.64 + backlight = backlight,
1.65 + display = display:svr(),
1.66 + vbus = io_buses.gpio,
1.67 + },
1.68 + },
1.69 + "rom/dev_display_qi_lb60");
1.70 +
1.71 +-- Expose a panel definition for the Ben.
1.72 +
1.73 +local panel = l:new_channel(); -- exposes panel
1.74 +
1.75 +l:start({
1.76 + caps = {
1.77 + panel = panel:svr(),
1.78 + },
1.79 + },
1.80 + "rom/dev_panel_qi_lb60");
1.81 +
1.82 +-- Expose the CPM peripheral.
1.83 +
1.84 +local cpm = l:new_channel();
1.85 +
1.86 +l:start({
1.87 + caps = {
1.88 + vbus = io_buses.cpm,
1.89 + cpm = cpm:svr(),
1.90 + },
1.91 + },
1.92 + "rom/dev_cpm_jz4740");
1.93 +
1.94 +-- Expose a framebuffer device.
1.95 +
1.96 +local fbdrv_fb = l:new_channel();
1.97 +
1.98 +l:start({
1.99 + caps = {
1.100 + vbus = io_buses.lcd,
1.101 + fb = fbdrv_fb:svr(),
1.102 + cpm = cpm,
1.103 + display = display, -- needed by LCD driver
1.104 + panel = panel,
1.105 + },
1.106 + },
1.107 + "rom/fb-drv");
1.108 +
1.109 +-- Expose the keypad matrix.
1.110 +
1.111 +local keypad = l:new_channel();
1.112 +
1.113 +l:start({
1.114 + caps = {
1.115 + vbus = io_buses.gpio,
1.116 + keypad = keypad:svr(),
1.117 + },
1.118 + },
1.119 + "rom/dev_keypad_qi_lb60");
1.120 +
1.121 +-- Expose the keypad events.
1.122 +
1.123 +local ev = l:new_channel();
1.124 +
1.125 +l:start({
1.126 + caps = {
1.127 + keypad = keypad,
1.128 + ev = ev:svr(),
1.129 + },
1.130 + },
1.131 + "rom/dev_input_keypad_qi_lb60");
1.132 +
1.133 +-- Multiplex the framebuffer.
1.134 +
1.135 +local mag_caps = {
1.136 + mag = l:new_channel(),
1.137 + svc = l:new_channel(),
1.138 + };
1.139 +
1.140 +l:start({
1.141 + caps = {
1.142 + vbus = io_buses.gpio, -- needed by input driver
1.143 + fb = fbdrv_fb,
1.144 + mag = mag_caps.mag:svr(),
1.145 + svc = mag_caps.svc:svr(),
1.146 + ev = ev,
1.147 + },
1.148 + },
1.149 + "rom/mag");
1.150 +
1.151 +-- Show the terminal.
1.152 +
1.153 +local term = l:new_channel();
1.154 +
1.155 +l:start({
1.156 + caps = {
1.157 + fb = mag_caps.svc:create(L4.Proto.Goos, "g=320x230+0+0", "barheight=10"),
1.158 + term = term:svr(),
1.159 + },
1.160 + },
1.161 + "rom/fbterminal");
1.162 +
1.163 +-- Show the hello example.
1.164 +
1.165 +l:start({
1.166 + log_cap = term,
1.167 + },
1.168 + "rom/ex_dl_test");
4.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
4.2 +++ b/pkg/landfall-examples/dl_test/dl_test.c Sun May 27 22:08:58 2018 +0200
4.3 @@ -0,0 +1,52 @@
4.4 +/*
4.5 + * Test dynamic loading.
4.6 + *
4.7 + * (c) 2018 Paul Boddie <paul@boddie.org.uk>
4.8 + *
4.9 + * This program is free software; you can redistribute it and/or
4.10 + * modify it under the terms of the GNU General Public License as
4.11 + * published by the Free Software Foundation; either version 2 of
4.12 + * the License, or (at your option) any later version.
4.13 + *
4.14 + * This program is distributed in the hope that it will be useful,
4.15 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
4.16 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4.17 + * GNU General Public License for more details.
4.18 + *
4.19 + * You should have received a copy of the GNU General Public License
4.20 + * along with this program; if not, write to the Free Software
4.21 + * Foundation, Inc., 51 Franklin Street, Fifth Floor,
4.22 + * Boston, MA 02110-1301, USA
4.23 + */
4.24 +
4.25 +#include <l4/util/util.h>
4.26 +#include <dlfcn.h>
4.27 +#include <stdio.h>
4.28 +
4.29 +static const char *libname = "rom/libdl_test_data.so";
4.30 +
4.31 +int main(void)
4.32 +{
4.33 + const char *buffer;
4.34 +
4.35 + /* Obtain the linked data. */
4.36 +
4.37 + void *handle = dlopen(libname, RTLD_NOW);
4.38 + const char *(*get_data)(void);
4.39 +
4.40 + if (handle == NULL)
4.41 + {
4.42 + printf("Could not open %s\n", libname);
4.43 + return 1;
4.44 + }
4.45 +
4.46 + get_data = dlsym(handle, "get_data");
4.47 +
4.48 + /* Load and show the data. */
4.49 +
4.50 + buffer = get_data();
4.51 + puts(buffer);
4.52 +
4.53 + l4_sleep_forever();
4.54 + return 0;
4.55 +}
6.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
6.2 +++ b/pkg/landfall-examples/dl_test_data/dl_test_data.c Sun May 27 22:08:58 2018 +0200
6.3 @@ -0,0 +1,29 @@
6.4 +/*
6.5 + * Test dynamic loading.
6.6 + *
6.7 + * (c) 2018 Paul Boddie <paul@boddie.org.uk>
6.8 + *
6.9 + * This program is free software; you can redistribute it and/or
6.10 + * modify it under the terms of the GNU General Public License as
6.11 + * published by the Free Software Foundation; either version 2 of
6.12 + * the License, or (at your option) any later version.
6.13 + *
6.14 + * This program is distributed in the hope that it will be useful,
6.15 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
6.16 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
6.17 + * GNU General Public License for more details.
6.18 + *
6.19 + * You should have received a copy of the GNU General Public License
6.20 + * along with this program; if not, write to the Free Software
6.21 + * Foundation, Inc., 51 Franklin Street, Fifth Floor,
6.22 + * Boston, MA 02110-1301, USA
6.23 + */
6.24 +
6.25 +static const char *buffer = "Hello shared!";
6.26 +
6.27 +const char *get_data(void);
6.28 +
6.29 +const char *get_data(void)
6.30 +{
6.31 + return buffer;
6.32 +}