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 Letux 400 notebook computer. 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 dma = l:new_channel(); 16 gpio = l:new_channel(); 17 lcd = l:new_channel(); 18 pwm = l:new_channel(); -- exposes GPIO, PWM 19 }; 20 21 l:start({ 22 caps = { 23 cpm = io_buses.cpm:svr(), 24 dma = io_buses.dma:svr(), 25 gpio = io_buses.gpio:svr(), 26 lcd = io_buses.lcd:svr(), 27 pwm = io_buses.pwm:svr(), 28 29 icu = L4.Env.icu, 30 sigma0 = L4.cast(L4.Proto.Factory, L4.Env.sigma0):create(L4.Proto.Sigma0), 31 }, 32 }, 33 "rom/io rom/hw_devices.io rom/mips-letux400-common.io"); 34 35 -- Expose a PWM peripheral as a device. 36 37 local pwm = l:new_channel(); 38 39 l:startv({ 40 caps = { 41 vbus = io_buses.pwm, 42 pwm = pwm:svr(), 43 }, 44 }, 45 "rom/dev_pwm_jz4730", "0", "250", "299", "47"); -- specifying peripheral number, parameters 46 47 -- Expose a PWM backlight device. 48 49 local backlight = l:new_channel(); -- exposes backlight device 50 51 l:startv({ 52 caps = { 53 pwm = pwm, 54 backlight = backlight:svr(), 55 }, 56 }, 57 "rom/dev_backlight_pwm", "0", "300"); -- specifying limits 58 59 -- Expose a display device for the Letux. 60 61 local display = l:new_channel(); -- exposes display device 62 63 l:start({ 64 caps = { 65 backlight = backlight, 66 display = display:svr(), 67 vbus = io_buses.gpio, 68 }, 69 }, 70 "rom/dev_display_letux400"); 71 72 -- Expose the CPM peripheral. 73 74 local cpm = l:new_channel(); 75 76 l:start({ 77 caps = { 78 vbus = io_buses.cpm, 79 cpm = cpm:svr(), 80 }, 81 }, 82 "rom/dev_cpm_jz4730"); 83 84 -- Expose a framebuffer device. 85 86 local fbdrv_fb = l:new_channel(); 87 88 l:start({ 89 caps = { 90 vbus = io_buses.lcd, 91 fb = fbdrv_fb:svr(), 92 cpm = cpm, 93 display = display, -- needed by LCD driver 94 }, 95 }, 96 "rom/fb-drv"); 97 98 -- Multiplex the framebuffer. 99 100 local mag_caps = { 101 mag = l:new_channel(), 102 svc = l:new_channel(), 103 }; 104 105 l:start({ 106 caps = { 107 vbus = io_buses.gpio, -- needed by input driver 108 fb = fbdrv_fb, 109 mag = mag_caps.mag:svr(), 110 svc = mag_caps.svc:svr(), 111 }, 112 }, 113 "rom/mag"); 114 115 -- Show the terminal. 116 117 local term = l:new_channel(); 118 119 l:start({ 120 caps = { 121 fb = mag_caps.svc:create(L4.Proto.Goos, "g=800x460+0+0", "barheight=20"), 122 term = term:svr(), 123 }, 124 }, 125 "rom/fbterminal"); 126 127 -- Show the DMA example. 128 129 l:start({ 130 caps = { 131 icu = L4.Env.icu, 132 vbus = io_buses.dma, 133 }, 134 log_cap = term, 135 }, 136 "rom/ex_letux400_dma");