Weekly report (ALL) - Lua loader

Pedro Arthur bygrandao at gmail.com
Sat Jul 26 00:21:36 UTC 2014

I realized I was not sending my weekly report to soc-status at FreeBSD.org
besides my mentor, so I decide to group all my previous report in a single

---------------------- WEEKLY REPORT 26/05 -----------------------
Lua loader (Pedro Souza)
I'll include in this report the work done in the weeks before the gsoc

Tasks done:
- Decouple forth interpreter from loader interpreter. Now any interpreter
should use the intereface:

typedef void interp_init_t(void *ctx);
typedef int    interp_run_t(void *ctx, const char *input);
typedef int    interp_incl_t(void *ctx, const char *filename);

struct interp {
    interp_init_t    *init;
    interp_run_t    *run;
    interp_incl_t    *incl;
    void         *context;

- Implemented the interpreter interfaces for the loader simple commands
(interp_simple) and forth (interp_forth).
- Included the lua 5.2.3 source code into head/sys/boot/
- Fixed the lua code to compile a minimal lua interpreter without C std
libs (using libstand) and implemented the missing functionalities (partial)
in head/sys/boot/lua/src/lstd.c
- Added interp_lua interface with interp_incl_t disabled (to not conflict
with loader.rc)
- Added "print" and "perform" functions to lua interpreter which prints to
the console and perform a loader comand (boot, load, ...) respectively.

Bugs found:
Some times when I compile and install a loader (in my case zfsloader) when
I reboot I get the message "Invalid format" from the boot2. I'm almost sure
it's a bug because I had the following code in my loader interp_init_t:
printf("some string");  <-- then I get the invalid format
I changed it to:
printf("some string __"); <-- and now it runs fine.
To be sure I changed it back to the previous code and got the same invalid
format error.
So always I do some change in the loader and I get a invalid format error I
just remove/add some characters in any printf string and it works fine.

Code repo: pedrosouza/lua_loader/head/
Wiki page: LuaLoader

---------------------- WEEKLY REPORT 09/06 -----------------------
This week I focused on checking if the lua interpreter was working
properly. Besides minor changes I did the following changes:

    Fixed a bug where numbers were not parsed.
    Implemented interp_lua_incl
    Improve double to string conversion.
    Sync branch with head

Now I'll start to work on the lua scripts.

---------------------- WEEKLY REPORT 16/06 -----------------------
This week I dedicated myself to read the Forth script files and
get a more deep understanding of them.
I also started to plan how I'll structure the lua scripts and which
function bindngs are needed. Some of those functions I already
implemented. I plan to have some kind of  loader menu done in
lua until the weekend.

---------------------- WEEKLY REPORT 23/06 -----------------------
This week I worked in the lua boot menu scripts, and added  some C
functions needed to the lua interpreter. The menu contains almost the
options found in the Forth menu and is functional.
 - Added getenv function to lua
 - Added std functions needed to support lua aux lib (lauxlib.c) and lua
base lib (lbaselib.c)
 - Added loader.lua, menu.lua, core.lua which provides a simple boot menu

---------------------- WEEKLY REPORT 30/06 -----------------------
This week I worked on the menu drawing, the menu box, brand and logo.
I also started reading the forth script which handles boot password and
I intend to implement it for the next week and polish the menu drawing.

---------------------- WEEKLY REPORT 07/07 -----------------------
This week I worked in the boot password check and the .conf file parsing.
Following there are the changes made:
- Added password.lua which handles boot & loader password.
- Added the lua string library (lstrlib.c)
- Added file handling functions (io.open, io.close and io.read)
- Added config.lua which parses .conf files (WIP)

---------------------- WEEKLY REPORT 14/07 -----------------------
This week I continued to work on the .conf files loading (parse & execute).
The loading code is
almost done it can correctly load modules, the only issue is the handling
of Forth commands
contained in 'exec' and possible 'module_after', 'module_before',
'module_error' which I've not found a
solution yet. I also started to work on the kernel loading from env var
'bootfile', 'kernel' and modules

---------------------- WEEKLY REPORT 21/07 -----------------------
This week I almost finished the kernel loading and module parsing. I also
started to read the
php.4th file but I was not able to fully understand it. I'll continue to
work on it but if someone has
experience with the pnp.4th script and can help me with it I would
appreciate it.


More information about the soc-status mailing list