lualoader: Intercept boot cli command

This should be functional and roughly equivalent to the Forth version.

Stop doing a loadelf() on menu exit now that we can DTRT with boot
invocations. autoboot interception will follow not long after.
This commit is contained in:
Kyle Evans 2018-02-20 21:32:36 +00:00
parent 683ca3a432
commit f0cb3b6b25
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=329673
2 changed files with 32 additions and 1 deletions

View File

@ -37,6 +37,38 @@ local compose_loader_cmd = function(cmd_name, argstr)
return cmd_name;
end
-- Parses arguments to boot and returns two values: kernel_name, argstr
-- Defaults to nil and "" respectively.
local parse_boot_args = function(argv)
if (#argv == 0) then
return nil, "";
end
local kernel_name;
local argstr = "";
for k, v in ipairs(argv) do
if (v:sub(1,1) ~= "-") then
kernel_name = v;
else
argstr = argstr .. " " .. v;
end
end
return kernel_name, argstr;
end
-- Globals
function boot(...)
local argv = {...};
local cmd_name = "";
cmd_name, argv = core.popFrontTable(argv);
local kernel, argstr = parse_boot_args(argv);
if (kernel ~= nil) then
loader.perform("unload");
config.selectkernel(kernel);
end
core.boot(argstr);
end
-- Module exports
-- Commonly appearing constants
core.KEY_BACKSPACE = 8;

View File

@ -390,7 +390,6 @@ function menu.run(m)
if (m == menu.welcome) then
screen.defcursor();
print("Exiting menu!");
config.loadelf();
return false;
end