1Syslinux LUA User Guide
2=======================
3Marcel Ritter <Marcel.Ritter@rrze.uni-erlangen.de>
4
5Invocation
6----------
7
8Running +lua.c32+ only results in an interactive shell.
9......................................................
10KERNEL lua.c32
11......................................................
12
13By using the +APPEND+ parameter you can specify a lua
14script to be executed:
15......................................................
16KERNEL lua.c32
17APPEND /testit.lua
18......................................................
19
20Modules
21-------
22
23Modules must be explicitly loaded into the namespace
24before use, for example:
25......................................................
26syslinux = require ("syslinux")
27......................................................
28
29SYSLINUX
30~~~~~~~~
31
32.syslinux.version()
33
34Returns version string
35
36.syslinux.derivative()
37
38Returns running Syslinux's derivative (ISOLINUX, PXELINUX or SYSLINUX).
39See com32/lua/test/syslinux-derivative.lua for an example.
40
41.syslinux.sleep(s)
42
43Sleep for +s+ seconds
44
45.syslinux.msleep(ms)
46
47Sleep for +ms+ milliseconds
48
49.run_command(command)
50
51Execute 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
60FIXME
61
62.local_boot()
63
64FIXME
65
66.final_cleanup()
67
68FIXME
69
70.boot_linux(kernel, cmdline, [mem_limit], [videomode])
71
72FIXME
73
74.run_kernel_image(kernel, cmdline, ipappend_flags, type)
75
76FIXME
77
78.loadfile(filname)
79
80Load file +filename+ (via TFTP)
81
82.filesize(file)
83
84Return size of +file+ (loaded by loadfile())
85
86.filename(file)
87
88Return name of +file+ (loaded by loadfile())
89
90.in itramfs_init()
91
92Return empty initramfs object
93
94.initramfs_load_archive(initramfs, filename)
95
96Load contents of +filename+ into +initramfs+. Initialize
97+initramfs+ with initramfs_init() before use.
98
99.initramfs_add_file(initramfs, file)
100
101Adds +file+ to +initramfs+. +initramfs+ needs to be
102initialized, +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
130DMI
131~~~
132
133.dmi_supported()
134
135Returns +true+ if DMI is supported on machine, +false+ otherwise.
136
137.dmi_gettable()
138
139Returns a list if key-value pairs. The key is one of the DMI property strings:
140FIXME 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
169PCI
170~~~
171
172.pci_getinfo()
173
174Return list of value pairs (device_index, device) of all PCI devices.
175
176.pci_getidlist(filename)
177
178Load a tab separated list of PCI IDs and their description.
179Sample files can be found here: http://pciids.sourceforge.net/
180
181
182_Example_:
183......................................................
184-- get nice output
185printf = function(s,...)
186           return io.write(s:format(...))
187         end
188
189-- get device info
190pciinfo = pci.getinfo()
191
192-- get plain text device description
193pciids = pci.getidlist("/pci.ids")
194
195-- list all pci busses
196for 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
209end
210
211-- print(pciids["8086"])
212-- print(pciids["10543009"])
213-- print(pciids["00700003"])
214-- print(pciids["0070e817"])
215-- print(pciids["1002437a1002437a"])
216......................................................
217
218
219VESA
220~~~~
221
222.getmodes()
223
224Return 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
245Set (only currently supported) VESA mode.
246
247.load_background(filename)
248
249Load +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
293