[syslinux] Lua.c32 wiki page

Marcel Ritter Marcel.Ritter at rrze.uni-erlangen.de
Mon Aug 9 21:57:53 PDT 2010


  Am 09.08.2010 23:37, schrieb Dag Wieers:
> On Mon, 9 Aug 2010, Marcel Ritter wrote:
>
>>  Am 09.08.2010 18:25, schrieb Dag Wieers:
>>>  Hi,
>>>
>>>  I have been experimenting a bit with lua.c32 and I have created a 
>>> small
>>>  lua.c32 wiki page at:
>>>
>>>      http://syslinux.zytor.com/wiki/index.php/Lua.c32
>>>
>>>  With my minimal knowledge about Lua (and the inconvenience of not 
>>> being
>>>  able to copy&paste or edit scripts) I discovered that the dmi 
>>> module has 2
>>>  functions (supported, gettable) and a syslinux module with 1 function
>>>  (run_command).
>>
>> Did you take a look at com32/lua/doc/syslinux.asc?
>> I tried to document the (very basic) functions calls there, including
>> some examples.
>
> Well, I only found that out after I discovered that I was using 4.01 
> and not 4.02 :-) I did import your examples into the wiki, I hope that 
> is ok with you ?
Of course, that's what they're for :-)
I was happy to see, that my lua patch got included into syslinux
some weeks ago :-)
> The examples make it very obvious how to use lua.c32 so I hope this 
> will creation some traction within the community.
>
>
>>>  Do we have some information available about these functions ? And 
>>> what is
>>>  planned for Lua in the future, I haven't seen this discussed here ?
>>>
>>>  What could be useful is:
>>>
>>>   - a way to find the boot-method (and device/name) 
>>> (syslinux.bootloader,
>>>     syslinux.bootdevice)
>>>
>>>   - a way to query syslinux information (syslinux.version, 
>>> syslinux.api)
>>>
>>>   - a way to provide syslinux a generated .cfg (syslinux.load())
>>>
>>>   - a way to query for pci device (and match pci.ids or modules.list)
>>>
>>>   - a way to query other hardware info
>>>
>>>   - an implementation of the os module, now one cannot exit lacking
>>>     os.exit()
>>>
>>>  - the dmi module could export its information as module variables, 
>>> rather
>>>     than a function that exports a table
>>
>> If someone can point me to the corresponding com32 code, I'll do my best
>> to add some more lua bindings - but this could take some time, due to 
>> the
>> lack of spare time, sorry.
>
> Some of the above is already possible with 4.02. Sorry for the confusion.
>
> On the other hand the usage of some of the functions and the lack of 
> consistency of the function names, make me realize we can do a better 
> job before people start to rely on it.
>
> I would propose to:
>
>  - change functions that return a fixed value and do not require 
> arguments
>    into values (avoid the function-call)
>      eg. syslinux.version vs syslinux.version()
Ok - I'll have to look into this.
Creating lua functions seems to be better documented than an
simple variable assignment  :-)
>  - change functions that return a table and not require arguments into
>    real tables (avoid the extra assignment and function-call)
>      eg. dmi.table vs dmi.gettable()
One thing I don't like about this is:
If I get it right, to assign a variable the code necessary will have
to be executed on every start of the lua interpreter, even if the
return value is never used. The above example is relatively
heavy and may cause trouble on some machines.
I think this solution is ok for simple assignments like syslinux.version,
but we might get into trouble doing that for all kind of functions.
>
>  - make functions more consistent, now some use underscores (local_boot,
>    run_kernel, load_background) vs no underscores (loadfile, getmodes())
Is there a coding style to define those things for syslinux/lua?
I just took whatever came to my mind - feel free to change them
to whatever you like.
>  - some functionality does not seem syslinux specific (filename, filesize)
If I recall correctly I needed those options because I wanted to
use the existing com32 functions, instead of copying code to
a second location.
>  - some functions can be merged (sleep, msleep)
I didn't find the mail concerning this, but I think I did only one of them.
>  - some functions have questionable (confusing?) names (boot_it,
>    boot_linux, run_command, run_kernel_image)
I know - I hat quite some trouble to get a kernel booting at all, the
last thing I was thinking about was proper function names, sorry.
>
> If we want to do it right, now is the time.
>
That's right, I guess at the moment there are only very few people
aware of lua in syslinux, and even less are using it already.

Bye,
    Marcel




More information about the Syslinux mailing list