1 | Syslinux LUA User Guide |
---|
2 | ======================= |
---|
3 | Marcel Ritter <Marcel.Ritter@rrze.uni-erlangen.de> |
---|
4 | |
---|
5 | Invocation |
---|
6 | ---------- |
---|
7 | |
---|
8 | Running +lua.c32+ only results in an interactive shell. |
---|
9 | ...................................................... |
---|
10 | KERNEL lua.c32 |
---|
11 | ...................................................... |
---|
12 | |
---|
13 | By using the +APPEND+ parameter you can specify a lua |
---|
14 | script to be executed: |
---|
15 | ...................................................... |
---|
16 | KERNEL lua.c32 |
---|
17 | APPEND /testit.lua |
---|
18 | ...................................................... |
---|
19 | |
---|
20 | Modules |
---|
21 | ------- |
---|
22 | |
---|
23 | Modules must be explicitly loaded into the namespace |
---|
24 | before use, for example: |
---|
25 | ...................................................... |
---|
26 | syslinux = require ("syslinux") |
---|
27 | ...................................................... |
---|
28 | |
---|
29 | SYSLINUX |
---|
30 | ~~~~~~~~ |
---|
31 | |
---|
32 | .syslinux.version() |
---|
33 | |
---|
34 | Returns version string |
---|
35 | |
---|
36 | .syslinux.derivative() |
---|
37 | |
---|
38 | Returns running Syslinux's derivative (ISOLINUX, PXELINUX or SYSLINUX). |
---|
39 | See com32/lua/test/syslinux-derivative.lua for an example. |
---|
40 | |
---|
41 | .syslinux.sleep(s) |
---|
42 | |
---|
43 | Sleep for +s+ seconds |
---|
44 | |
---|
45 | .syslinux.msleep(ms) |
---|
46 | |
---|
47 | Sleep for +ms+ milliseconds |
---|
48 | |
---|
49 | .run_command(command) |
---|
50 | |
---|
51 | Execute syslinux command line +command+. |
---|
52 | |
---|
53 | _Example_: |
---|
54 | ...................................................... |
---|
55 | syslinux.run_command("memdisk initrd=/dos/BIOS/FSC-P7935-108.img raw") |
---|
56 | ...................................................... |
---|
57 | |
---|
58 | .run_default() |
---|
59 | |
---|
60 | FIXME |
---|
61 | |
---|
62 | .local_boot() |
---|
63 | |
---|
64 | FIXME |
---|
65 | |
---|
66 | .final_cleanup() |
---|
67 | |
---|
68 | FIXME |
---|
69 | |
---|
70 | .boot_linux(kernel, cmdline, [mem_limit], [videomode]) |
---|
71 | |
---|
72 | FIXME |
---|
73 | |
---|
74 | .run_kernel_image(kernel, cmdline, ipappend_flags, type) |
---|
75 | |
---|
76 | FIXME |
---|
77 | |
---|
78 | .loadfile(filname) |
---|
79 | |
---|
80 | Load file +filename+ (via TFTP) |
---|
81 | |
---|
82 | .filesize(file) |
---|
83 | |
---|
84 | Return size of +file+ (loaded by loadfile()) |
---|
85 | |
---|
86 | .filename(file) |
---|
87 | |
---|
88 | Return name of +file+ (loaded by loadfile()) |
---|
89 | |
---|
90 | .in itramfs_init() |
---|
91 | |
---|
92 | Return empty initramfs object |
---|
93 | |
---|
94 | .initramfs_load_archive(initramfs, filename) |
---|
95 | |
---|
96 | Load contents of +filename+ into +initramfs+. Initialize |
---|
97 | +initramfs+ with initramfs_init() before use. |
---|
98 | |
---|
99 | .initramfs_add_file(initramfs, file) |
---|
100 | |
---|
101 | Adds +file+ to +initramfs+. +initramfs+ needs to be |
---|
102 | initialized, +file+ has been loaded by loadfile(). |
---|
103 | |
---|
104 | _Example_: |
---|
105 | ...................................................... |
---|
106 | -- get nice output |
---|
107 | printf = function(s,...) |
---|
108 | return io.write(s:format(...)) |
---|
109 | end -- function |
---|
110 | |
---|
111 | kernel = syslinux.loadfile("/SuSE-11.1/x86_64/linux") |
---|
112 | |
---|
113 | printf("Filename/size: %s %d\n", syslinux.filename(kernel), syslinux.filesize(kernel)) |
---|
114 | |
---|
115 | initrd = syslinux.loadfile("/SuSE-11.1/x86_64/initrd") |
---|
116 | |
---|
117 | printf("Filename/size: %s %d\n", syslinux.filename(initrd), syslinux.filesize(initrd)) |
---|
118 | |
---|
119 | initrd = syslinux.initramfs_init() |
---|
120 | syslinux.initramfs_load_archive(initrd, "/SuSE-11.1/x86_64/initrd"); |
---|
121 | |
---|
122 | syslinux.boot_it(kernel, initrd, "init=/bin/bash") |
---|
123 | |
---|
124 | syslinux.sleep(20) |
---|
125 | |
---|
126 | ...................................................... |
---|
127 | |
---|
128 | |
---|
129 | |
---|
130 | DMI |
---|
131 | ~~~ |
---|
132 | |
---|
133 | .dmi_supported() |
---|
134 | |
---|
135 | Returns +true+ if DMI is supported on machine, +false+ otherwise. |
---|
136 | |
---|
137 | .dmi_gettable() |
---|
138 | |
---|
139 | Returns a list if key-value pairs. The key is one of the DMI property strings: |
---|
140 | FIXME list |
---|
141 | |
---|
142 | _Example_: |
---|
143 | ...................................................... |
---|
144 | if (dmi.supported()) then |
---|
145 | |
---|
146 | dmitable = dmi.gettable() |
---|
147 | |
---|
148 | for k,v in pairs(dmitable) do |
---|
149 | print(k, v) |
---|
150 | end |
---|
151 | |
---|
152 | print(dmitable["system.manufacturer"]) |
---|
153 | print(dmitable["system.product_name"]) |
---|
154 | print(dmitable["bios.bios_revision"]) |
---|
155 | |
---|
156 | if ( string.match(dmitable["system.product_name"], "ESPRIMO P7935") ) then |
---|
157 | print("Matches") |
---|
158 | syslinux.run_command("memdisk initrd=/dos/BIOS/FSC-P7935-108.img raw") |
---|
159 | else |
---|
160 | print("Does not match") |
---|
161 | syslinux.run_command("memdisk initrd=/dos/BIOS/FSC-P7935-108.img raw") |
---|
162 | end |
---|
163 | |
---|
164 | end |
---|
165 | |
---|
166 | ...................................................... |
---|
167 | |
---|
168 | |
---|
169 | PCI |
---|
170 | ~~~ |
---|
171 | |
---|
172 | .pci_getinfo() |
---|
173 | |
---|
174 | Return list of value pairs (device_index, device) of all PCI devices. |
---|
175 | |
---|
176 | .pci_getidlist(filename) |
---|
177 | |
---|
178 | Load a tab separated list of PCI IDs and their description. |
---|
179 | Sample files can be found here: http://pciids.sourceforge.net/ |
---|
180 | |
---|
181 | |
---|
182 | _Example_: |
---|
183 | ...................................................... |
---|
184 | -- get nice output |
---|
185 | printf = function(s,...) |
---|
186 | return io.write(s:format(...)) |
---|
187 | end |
---|
188 | |
---|
189 | -- get device info |
---|
190 | pciinfo = pci.getinfo() |
---|
191 | |
---|
192 | -- get plain text device description |
---|
193 | pciids = pci.getidlist("/pci.ids") |
---|
194 | |
---|
195 | -- list all pci busses |
---|
196 | for dind,device in pairs(pciinfo) do |
---|
197 | |
---|
198 | -- search for device description |
---|
199 | search = string.format("%04x%04x", device['vendor'], device['product']) |
---|
200 | |
---|
201 | printf(" %04x:%04x:%04x:%04x = ", device['vendor'], device['product'], |
---|
202 | device['sub_vendor'], device['sub_product']) |
---|
203 | |
---|
204 | if ( pciids[search] ) then |
---|
205 | printf("%s\n", pciids[search]) |
---|
206 | else |
---|
207 | printf("Unknown\n") |
---|
208 | end |
---|
209 | end |
---|
210 | |
---|
211 | -- print(pciids["8086"]) |
---|
212 | -- print(pciids["10543009"]) |
---|
213 | -- print(pciids["00700003"]) |
---|
214 | -- print(pciids["0070e817"]) |
---|
215 | -- print(pciids["1002437a1002437a"]) |
---|
216 | ...................................................... |
---|
217 | |
---|
218 | |
---|
219 | VESA |
---|
220 | ~~~~ |
---|
221 | |
---|
222 | .getmodes() |
---|
223 | |
---|
224 | Return list of available VESA modes. |
---|
225 | |
---|
226 | _Example_: |
---|
227 | ...................................................... |
---|
228 | -- get nice output |
---|
229 | printf = function(s,...) |
---|
230 | return io.write(s:format(...)) |
---|
231 | end |
---|
232 | |
---|
233 | -- list available vesa modes |
---|
234 | -- only one supported right now, not of much use |
---|
235 | modes = vesa.getmodes() |
---|
236 | |
---|
237 | for mind,mode in pairs(modes) do |
---|
238 | printf("%04x: %dx%dx%d\n", mode['mode'], mode['hres'], mode['vres'], mode['bpp']) |
---|
239 | end |
---|
240 | ...................................................... |
---|
241 | |
---|
242 | |
---|
243 | .setmode() |
---|
244 | |
---|
245 | Set (only currently supported) VESA mode. |
---|
246 | |
---|
247 | .load_background(filename) |
---|
248 | |
---|
249 | Load +filename+ from TFTP, and use it as background image. |
---|
250 | |
---|
251 | _Example_: |
---|
252 | ...................................................... |
---|
253 | -- get nice output |
---|
254 | printf = function(s,...) |
---|
255 | return io.write(s:format(...)) |
---|
256 | end |
---|
257 | |
---|
258 | -- lets go to graphics land |
---|
259 | vesa.setmode() |
---|
260 | |
---|
261 | printf("Hello World! - VESA mode") |
---|
262 | |
---|
263 | -- some text to display "typing style" |
---|
264 | textline=[[ |
---|
265 | From syslinux GSOC 2009 home page: |
---|
266 | |
---|
267 | Finish the Lua engine |
---|
268 | |
---|
269 | We already have a Lua interpreter integrated with the Syslinux build. However, right now it is not very useful. We need to create a set of bindings to the Syslinux functionality, and have an array of documentation and examples so users can use them. |
---|
270 | |
---|
271 | This is not a documentation project, but the documentation deliverable will be particularly important for this one, since the intended target is system administrators, not developers. |
---|
272 | ]] |
---|
273 | |
---|
274 | |
---|
275 | -- do display loop |
---|
276 | -- keep in mind: background change will not erase text! |
---|
277 | while ( true ) do |
---|
278 | |
---|
279 | vesa.load_background("/background1.jpg") |
---|
280 | |
---|
281 | syslinux.sleep(1) |
---|
282 | |
---|
283 | for i = 1, #textline do |
---|
284 | local c = textline:sub(i,i) |
---|
285 | printf("%s", c) |
---|
286 | syslinux.msleep(200) |
---|
287 | end |
---|
288 | |
---|
289 | syslinux.sleep(10) |
---|
290 | |
---|
291 | ...................................................... |
---|
292 | |
---|