lualoader: Prepare for interception of "boot" CLI cmd
core.boot and core.autoboot may both take arguments; add a helper to cleanly append an argstring to the given loader command. Also provide a popFrontTable() that we'll use pop the command name off of an argv table. We don't have the table library included, and including it is non-trivial, so we'll implement this one function that we need in lua for the time being.
This commit is contained in:
parent
df9e50a99c
commit
6d4ed94d98
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=329671
@ -30,6 +30,13 @@ local config = require('config');
|
|||||||
|
|
||||||
local core = {};
|
local core = {};
|
||||||
|
|
||||||
|
local compose_loader_cmd = function(cmd_name, argstr)
|
||||||
|
if (argstr ~= nil) then
|
||||||
|
cmd_name = cmd_name .. " " .. argstr;
|
||||||
|
end
|
||||||
|
return cmd_name;
|
||||||
|
end
|
||||||
|
|
||||||
-- Module exports
|
-- Module exports
|
||||||
-- Commonly appearing constants
|
-- Commonly appearing constants
|
||||||
core.KEY_BACKSPACE = 8;
|
core.KEY_BACKSPACE = 8;
|
||||||
@ -182,14 +189,14 @@ function core.setDefaults()
|
|||||||
core.setVerbose(false);
|
core.setVerbose(false);
|
||||||
end
|
end
|
||||||
|
|
||||||
function core.autoboot()
|
function core.autoboot(argstr)
|
||||||
config.loadelf();
|
config.loadelf();
|
||||||
loader.perform("autoboot");
|
loader.perform(compose_loader_cmd("autoboot", argstr));
|
||||||
end
|
end
|
||||||
|
|
||||||
function core.boot()
|
function core.boot(argstr)
|
||||||
config.loadelf();
|
config.loadelf();
|
||||||
loader.perform("boot");
|
loader.perform(compose_loader_cmd("boot", argstr));
|
||||||
end
|
end
|
||||||
|
|
||||||
function core.isSingleUserBoot()
|
function core.isSingleUserBoot()
|
||||||
@ -235,6 +242,29 @@ function core.shallowCopyTable(tbl)
|
|||||||
return new_tbl;
|
return new_tbl;
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- XXX This should go away if we get the table lib into shape for importing.
|
||||||
|
-- As of now, it requires some 'os' functions, so we'll implement this in lua
|
||||||
|
-- for our uses
|
||||||
|
function core.popFrontTable(tbl)
|
||||||
|
-- Shouldn't reasonably happen
|
||||||
|
if (#tbl == 0) then
|
||||||
|
return nil, nil;
|
||||||
|
elseif (#tbl == 1) then
|
||||||
|
return tbl[1], {};
|
||||||
|
end
|
||||||
|
|
||||||
|
local first_value = tbl[1];
|
||||||
|
local new_tbl = {};
|
||||||
|
-- This is not a cheap operation
|
||||||
|
for k, v in ipairs(tbl) do
|
||||||
|
if (k > 1) then
|
||||||
|
new_tbl[k - 1] = v;
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return first_value, new_tbl;
|
||||||
|
end
|
||||||
|
|
||||||
-- On i386, hint.acpi.0.rsdp will be set before we're loaded. On !i386, it will
|
-- On i386, hint.acpi.0.rsdp will be set before we're loaded. On !i386, it will
|
||||||
-- generally be set upon execution of the kernel. Because of this, we can't (or
|
-- generally be set upon execution of the kernel. Because of this, we can't (or
|
||||||
-- don't really want to) detect/disable ACPI on !i386 reliably. Just set it
|
-- don't really want to) detect/disable ACPI on !i386 reliably. Just set it
|
||||||
|
Loading…
Reference in New Issue
Block a user