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