aboutsummaryrefslogtreecommitdiffstats
path: root/com32/lua/doc/syslinux.asc
blob: 87dbb662ffeb6f15c7eff75d2baf7dfdf20fef03 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
Syslinux LUA User Guide
=======================
Marcel Ritter <Marcel.Ritter@rrze.uni-erlangen.de>

Invocation
----------

Running +lua.c32+ only results in an interactive shell.
......................................................
KERNEL lua.c32
......................................................

By using the +APPEND+ parameter you can specify a lua
script to be executed:
......................................................
KERNEL lua.c32
APPEND /testit.lua
......................................................

Modules
-------

Modules must be explicitly loaded into the namespace
before use, for example:
......................................................
local sl = require "syslinux"
......................................................
Using +local+, as above, is good practice in scripts, but it must be
omitted when working interactively.

SYSLINUX
~~~~~~~~

.version()

Returns version string

.derivative()

Returns running Syslinux's derivative (ISOLINUX, PXELINUX or SYSLINUX).

.sleep(s)

Sleep for +s+ seconds

.msleep(ms)

Sleep for +ms+ milliseconds

.run_command(command)

Execute syslinux command line +command+.

_Example_:
......................................................
local sl = require "syslinux"
sl.run_command("memdisk initrd=/dos/BIOS/FSC-P7935-108.img raw")
......................................................

.run_default()

FIXME

.local_boot()

FIXME

.final_cleanup()

FIXME

.boot_linux(kernel, cmdline, [mem_limit], [videomode])

FIXME

.IMAGE_TYPE

A table containing the possible kernel types for +run_kernel_image()+.

.run_kernel_image(kernel, cmdline, ipappend_flags, type)

Run the specified kernel. +type+ is one of the values of the +IMAGE_TYPE+ table.

FIXME

.loadfile(filname)

Load file +filename+

.filesize(file)

Return size of +file+ (loaded by loadfile())

.filename(file)

Return name of +file+ (loaded by loadfile())

.initramfs_init()

Return empty initramfs object

.initramfs_load_archive(initramfs, filename)

Load contents of +filename+ into +initramfs+. Initialize
+initramfs+ with initramfs_init() before use.

.initramfs_add_file(initramfs, file)

Adds +file+ to +initramfs+. +initramfs+ needs to be
initialized, +file+ has been loaded by loadfile().

_Example_:
......................................................
local sl = require "syslinux"

kernel = sl.loadfile("/SuSE-11.1/x86_64/linux")
print ("File name: " .. sl.filename (kernel) .. " size: " .. sl.filesize (kernel))

initrd = sl.loadfile("/SuSE-11.1/x86_64/initrd")
print ("File name: " .. sl.filename (initrd) .. " size: " .. sl.filesize (initrd))

initrd = sl.initramfs_init()
sl.initramfs_load_archive(initrd, "/SuSE-11.1/x86_64/initrd")

sl.boot_it(kernel, initrd, "init=/bin/bash")
......................................................

.KEY

Table containing the return values of +get_key()+ for special (eg. function)
keys.

.KEY_CTRL(key)

Return the code for the Ctrl-modified version of the given ASCII code.

.get_key(timeout)

Wait at most +timeout+ ms for a key press.
Return the ASCII code of the pressed key, some other value of the +KEY+
table, or +KEY.NONE+ on timeout.


DMI
~~~

.supported()

Returns +true+ if DMI is supported on machine, +false+ otherwise.

.gettable()

Returns a list of key-value pairs. The key is one of the DMI property strings:
FIXME list

_Example_:
......................................................
local sl = require "syslinux"
local dmi = require "dmi"

if (dmi.supported()) then

  dmitable = dmi.gettable()

  for k,v in pairs(dmitable) do
    print(k, v)
  end

  print(dmitable.system.manufacturer)
  print(dmitable.system.product_name)
  print(dmitable.bios.bios_revision)

  if ( string.match(dmitable.system.product_name, "ESPRIMO P7935") ) then
    print("Matches")
    sl.run_command("memdisk initrd=/dos/BIOS/FSC-P7935-108.img raw")
  else
    print("Does not match")
    sl.run_command("memdisk initrd=/dos/BIOS/FSC-P7935-108.img raw")
  end

end
......................................................


PCI
~~~

.getinfo()

Return list of value pairs (device_index, device) of all PCI devices.

.getidlist(filename)

Load a tab separated list of PCI IDs and their description. 
Sample files can be found here: http://pciids.sourceforge.net/


_Example_:
......................................................
local pci = require "pci"

pciids = pci.getidlist("/pci.ids")

for dind, device in pairs (pci.getinfo()) do
  local vendor = string.format ("%04x", device.vendor)
  local main_id = vendor .. string.format ("%04x", device.product)
  local sub_id =  string.format ("%04x%04x", device.sub_vendor, device.sub_product)
  io.write (string.format ("%s:%s = %s %s (%s)\n", main_id, sub_id, pciids[vendor],
                           pciids[main_id], pciids[main_id .. sub_id] or "unknown subdevice"))
end
......................................................


VESA
~~~~

.getmodes()

Return list of available VESA modes.

_Example_:
......................................................
local vesa = require "vesa"

-- get nice output
printf = function(s,...)
           return io.write(s:format(...))
         end

-- list available vesa modes
for mind,mode in pairs(vesa.getmodes()) do
   printf("%04x: %dx%dx%d\n", mode.mode, mode.hres, mode.vres, mode.bpp)
end
......................................................


.setmode()

Set (only currently supported) VESA mode.

.load_background(filename)

Load +filename+ from TFTP, and use it as background image.

_Example_:
......................................................
local sl = require "syslinux"
local vesa = require "vesa"

-- get nice output
printf = function(s,...)
           return io.write(s:format(...))
         end

-- lets go to graphics land
vesa.setmode()

printf("Hello World! - VESA mode")

-- some text to display "typing style"
textline=[[
From syslinux GSOC 2009 home page:

Finish the Lua engine

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.

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.
]]


-- do display loop
-- keep in mind: background change will not erase text!
while ( true ) do

vesa.load_background("/background1.jpg")

sl.sleep(1)

for i = 1, #textline do
    local c = textline:sub(i,i)
    printf("%s", c)
    sl.msleep(200)
end

sl.sleep(10)
......................................................