aboutsummaryrefslogtreecommitdiff
path: root/stand
diff options
context:
space:
mode:
authorWarner Losh <imp@FreeBSD.org>2024-02-27 03:19:58 +0000
committerWarner Losh <imp@FreeBSD.org>2024-02-27 03:49:46 +0000
commit9398a495eb305d5bf240bc998ee2f6128d75f4ca (patch)
tree4ce977c384e7289e13d4e160a4749efa9243fb60 /stand
parent8bfb23abf882afdca0a0530ef1231ac59963bc4a (diff)
downloadsrc-9398a495eb305d5bf240bc998ee2f6128d75f4ca.tar.gz
src-9398a495eb305d5bf240bc998ee2f6128d75f4ca.zip
loader: Add loader.exit
Add loader.exit(status). While one can get alomst this behavior with loader.perform("quit"), quit doesn't allow a value to be returned to the firmware. The interpretation of 'status' is firmware specific. This can be used when autobooting doesn't work in scripts, for example, to allow the firmware to try something else... Sponsored by: Netflix Reviewed by: kevans Differential Revision: https://reviews.freebsd.org/D44094
Diffstat (limited to 'stand')
-rw-r--r--stand/liblua/lutils.c16
-rw-r--r--stand/lua/loader.lua.84
2 files changed, 16 insertions, 4 deletions
diff --git a/stand/liblua/lutils.c b/stand/liblua/lutils.c
index 0be9f5f28ac3..874dc8bf7d5d 100644
--- a/stand/liblua/lutils.c
+++ b/stand/liblua/lutils.c
@@ -110,6 +110,13 @@ lua_perform(lua_State *L)
}
static int
+lua_exit(lua_State *L)
+{
+ exit(luaL_checkinteger(L, 1));
+ return 0;
+}
+
+static int
lua_command_error(lua_State *L)
{
@@ -380,14 +387,15 @@ lua_writefile(lua_State *L)
#define REG_SIMPLE(n) { #n, lua_ ## n }
static const struct luaL_Reg loaderlib[] = {
- REG_SIMPLE(delay),
- REG_SIMPLE(command_error),
REG_SIMPLE(command),
- REG_SIMPLE(interpret),
- REG_SIMPLE(parse),
+ REG_SIMPLE(command_error),
+ REG_SIMPLE(delay),
+ REG_SIMPLE(exit),
REG_SIMPLE(getenv),
REG_SIMPLE(has_command),
REG_SIMPLE(has_feature),
+ REG_SIMPLE(interpret),
+ REG_SIMPLE(parse),
REG_SIMPLE(perform),
REG_SIMPLE(printc), /* Also registered as the global 'printc' */
REG_SIMPLE(setenv),
diff --git a/stand/lua/loader.lua.8 b/stand/lua/loader.lua.8
index ff3b91ddfb09..e5aee7e8602d 100644
--- a/stand/lua/loader.lua.8
+++ b/stand/lua/loader.lua.8
@@ -61,6 +61,10 @@ Returns the error string from the last command to fail.
Like
.Fn perform
but the arguments are already parsed onto the stack.
+.It Fn exit status
+Exit the boot loader back to the firmware with a status of
+.Va status .
+The interpretation of this value is firmware specific.
.It Fn interpret str
Execute the loader builtin command
.Va str