1 -- vim: ft=lua ts=2 et sw=2 2 3 -- Start Mag to multiplex the framebuffer showing only a single program. 4 -- This example shows a framebuffer terminal showing the hello example's output. 5 -- The target platform is the Ben NanoNote. 6 7 local L4 = require("L4"); 8 9 local l = L4.default_loader; 10 11 -- Define general access to peripherals. 12 13 local io_buses = { 14 cpm = l:new_channel(); 15 gpio = l:new_channel(); 16 lcd = l:new_channel(); 17 }; 18 19 l:start({ 20 caps = { 21 cpm = io_buses.cpm:svr(), 22 gpio = io_buses.gpio:svr(), 23 lcd = io_buses.lcd:svr(), 24 25 icu = L4.Env.icu, 26 sigma0 = L4.cast(L4.Proto.Factory, L4.Env.sigma0):create(L4.Proto.Sigma0), 27 }, 28 }, 29 "rom/io rom/hw_devices.io rom/mips-qi_lb60-common.io"); 30 31 -- Expose a SPI peripheral as a device. 32 33 local spi = l:new_channel(); 34 35 l:startv({ 36 caps = { 37 vbus = io_buses.gpio, 38 spi = spi:svr(), 39 }, 40 }, 41 "rom/dev_spi_jz4740", "C23", "C22", "C21"); -- specifying clock, data, enable pin details 42 43 -- Expose a SPI backlight device for the Ben. 44 45 local backlight = l:new_channel(); -- exposes backlight device 46 47 l:start({ 48 caps = { 49 spi = spi, 50 backlight = backlight:svr(), 51 }, 52 }, 53 "rom/dev_backlight_spi_ili8960"); 54 55 -- Expose a display device for the Ben. 56 57 local display = l:new_channel(); -- exposes display device 58 59 l:start({ 60 caps = { 61 backlight = backlight, 62 display = display:svr(), 63 vbus = io_buses.gpio, 64 }, 65 }, 66 "rom/dev_display_qi_lb60"); 67 68 -- Expose a panel definition for the Ben. 69 70 local panel = l:new_channel(); -- exposes panel 71 72 l:start({ 73 caps = { 74 panel = panel:svr(), 75 }, 76 }, 77 "rom/dev_panel_qi_lb60"); 78 79 -- Expose the CPM peripheral. 80 81 local cpm = l:new_channel(); 82 83 l:start({ 84 caps = { 85 vbus = io_buses.cpm, 86 cpm = cpm:svr(), 87 }, 88 }, 89 "rom/dev_cpm_jz4740"); 90 91 -- Expose a framebuffer device. 92 93 local fbdrv_fb = l:new_channel(); 94 95 l:start({ 96 caps = { 97 vbus = io_buses.lcd, 98 fb = fbdrv_fb:svr(), 99 cpm = cpm, 100 display = display, -- needed by LCD driver 101 panel = panel, 102 }, 103 }, 104 "rom/fb-drv"); 105 106 -- Multiplex the framebuffer. 107 108 local mag_caps = { 109 mag = l:new_channel(), 110 svc = l:new_channel(), 111 }; 112 113 l:start({ 114 caps = { 115 vbus = io_buses.gpio, -- needed by input driver 116 fb = fbdrv_fb, 117 mag = mag_caps.mag:svr(), 118 svc = mag_caps.svc:svr(), 119 ev = ev, 120 }, 121 }, 122 "rom/mag"); 123 124 -- Show the terminal. 125 126 local term = l:new_channel(); 127 128 l:start({ 129 caps = { 130 fb = mag_caps.svc:create(L4.Proto.Goos, "g=320x230+0+0", "barheight=10"), 131 term = term:svr(), 132 }, 133 }, 134 "rom/fbterminal"); 135 136 -- Show the hello example. 137 138 l:start({ 139 log_cap = term, 140 }, 141 "rom/hello");