paul@87 | 1 | -- vim: ft=lua ts=2 et sw=2 |
paul@87 | 2 | |
paul@87 | 3 | -- Start Mag to multiplex the framebuffer showing only a single program. |
paul@87 | 4 | -- This example shows a framebuffer terminal showing the hello example's output. |
paul@87 | 5 | -- The target platform is the MIPS Creator CI20. |
paul@87 | 6 | |
paul@87 | 7 | local L4 = require("L4"); |
paul@87 | 8 | |
paul@87 | 9 | local l = L4.default_loader; |
paul@87 | 10 | |
paul@87 | 11 | -- Define general access to peripherals. |
paul@87 | 12 | |
paul@87 | 13 | local io_buses = { |
paul@87 | 14 | cpm = l:new_channel(); |
paul@87 | 15 | gpio = l:new_channel(); |
paul@87 | 16 | hdmi = l:new_channel(); |
paul@87 | 17 | lcd = l:new_channel(); |
paul@87 | 18 | }; |
paul@87 | 19 | |
paul@87 | 20 | l:start({ |
paul@87 | 21 | caps = { |
paul@87 | 22 | cpm = io_buses.cpm:svr(), |
paul@87 | 23 | gpio = io_buses.gpio:svr(), |
paul@87 | 24 | hdmi = io_buses.hdmi:svr(), |
paul@87 | 25 | lcd = io_buses.lcd:svr(), |
paul@87 | 26 | |
paul@87 | 27 | icu = L4.Env.icu, |
paul@87 | 28 | sigma0 = L4.cast(L4.Proto.Factory, L4.Env.sigma0):create(L4.Proto.Sigma0), |
paul@87 | 29 | }, |
paul@87 | 30 | }, |
paul@87 | 31 | "rom/io rom/hw_devices.io rom/mips-ci20-common.io"); |
paul@87 | 32 | |
paul@87 | 33 | -- Expose the CPM peripheral. |
paul@87 | 34 | |
paul@87 | 35 | local cpm = l:new_channel(); |
paul@87 | 36 | |
paul@87 | 37 | l:start({ |
paul@87 | 38 | caps = { |
paul@87 | 39 | vbus = io_buses.cpm, |
paul@87 | 40 | cpm = cpm:svr(), |
paul@87 | 41 | }, |
paul@87 | 42 | }, |
paul@87 | 43 | "rom/dev_cpm_jz4780"); |
paul@87 | 44 | |
paul@87 | 45 | -- Expose a display device for the CI20. |
paul@87 | 46 | |
paul@87 | 47 | local display = l:new_channel(); -- exposes display device |
paul@87 | 48 | |
paul@87 | 49 | l:start({ |
paul@87 | 50 | caps = { |
paul@87 | 51 | cpm = cpm, |
paul@87 | 52 | display = display:svr(), |
paul@87 | 53 | icu = L4.Env.icu, |
paul@87 | 54 | vbus = io_buses.hdmi, -- for HDMI resource access |
paul@87 | 55 | }, |
paul@87 | 56 | }, |
paul@87 | 57 | "rom/dev_display_ci20_hdmi"); |
paul@87 | 58 | |
paul@87 | 59 | -- Expose a framebuffer device. |
paul@87 | 60 | |
paul@87 | 61 | local fbdrv_fb = l:new_channel(); |
paul@87 | 62 | |
paul@87 | 63 | l:start({ |
paul@87 | 64 | caps = { |
paul@87 | 65 | vbus = io_buses.lcd, |
paul@87 | 66 | fb = fbdrv_fb:svr(), |
paul@87 | 67 | cpm = cpm, |
paul@87 | 68 | display = display, -- needed by LCD driver |
paul@87 | 69 | }, |
paul@87 | 70 | }, |
paul@87 | 71 | "rom/fb-drv"); |
paul@87 | 72 | |
paul@87 | 73 | -- Multiplex the framebuffer. |
paul@87 | 74 | |
paul@87 | 75 | local mag_caps = { |
paul@87 | 76 | mag = l:new_channel(), |
paul@87 | 77 | svc = l:new_channel(), |
paul@87 | 78 | }; |
paul@87 | 79 | |
paul@87 | 80 | l:start({ |
paul@87 | 81 | caps = { |
paul@87 | 82 | vbus = io_buses.gpio, -- needed by input driver |
paul@87 | 83 | fb = fbdrv_fb, |
paul@87 | 84 | mag = mag_caps.mag:svr(), |
paul@87 | 85 | svc = mag_caps.svc:svr(), |
paul@87 | 86 | }, |
paul@87 | 87 | }, |
paul@87 | 88 | "rom/mag"); |
paul@87 | 89 | |
paul@87 | 90 | -- Show the terminal. |
paul@87 | 91 | |
paul@87 | 92 | local term = l:new_channel(); |
paul@87 | 93 | |
paul@87 | 94 | l:start({ |
paul@87 | 95 | caps = { |
paul@87 | 96 | fb = mag_caps.svc:create(L4.Proto.Goos, "g=1280x1014+0+0", "barheight=10"), |
paul@87 | 97 | term = term:svr(), |
paul@87 | 98 | }, |
paul@87 | 99 | }, |
paul@87 | 100 | "rom/fbterminal"); |
paul@87 | 101 | |
paul@87 | 102 | -- Show the hello example. |
paul@87 | 103 | |
paul@87 | 104 | l:start({ |
paul@87 | 105 | log_cap = term, |
paul@87 | 106 | }, |
paul@87 | 107 | "rom/hello"); |