From nobody Tue Feb 27 03:50:16 2024 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4TkNmT1wwdz5CLrt; Tue, 27 Feb 2024 03:50:17 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4TkNmT0tdFz47qm; Tue, 27 Feb 2024 03:50:17 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1709005817; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=P2Xj0RqDxN/DWwlRryINQBcfGF3YRs6jpQTcvt2jrJU=; b=es6EmSJAeV7i4j097DUBCkVFJbRfopbSnvSnv1QJtM6SGPM6p07nK6Camu+KsCC58y6pJ8 /ECAsnj92CogjYipGuvyDPs1BdEvxZ+x4pU0dvzc7uma+jGXx2dzx2GWKd6pgGNfX2sHIZ 0i5k2bZOzY5LVXVOmrZOLAvXOCYobfu4eNZ3thkTO1zl+bfCSmcm9/TCfEvzcfLlWyAeUS CnjN6sOUAkn2MANsoyFtDw4cGbTBOg4ZfCaqP/aLX2qzw2KjNSJqnnNo7GDSIOfNPCw3wR dyP+d43XxRlP6W71lDqFQNgjS+/3cwdDRq6NkJgZnc3J1qTHV6CdAUyO36dWIA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1709005817; a=rsa-sha256; cv=none; b=rFU16UcPzUZJnjxVCl1sptWH3+d8WIWo5pUC0rGb5DXNOn2tDgtb+UDvbsCSmxMYJT6H5H t284hN9TSeOUdNAnGiwmG29LPMGb67rvi0Y54B2MRPR5yqNKd5NThRfyHBkHX6sFx1WPYY Gn9Mo01owK/K/1OpOhUC5Hi5yP9rHWdhAYJtpXgaYU2Rj9bdIPHwJFRJLODeZw5aTHNqOo 4rTMu5NmUr1yFJVudk/hMY4ZuIZW1e7WL4Fur4EiEDB7v663niRE8Y6JaSoxBjOmiRYY6f KDAWLw7UuIHP/5keZFWYjE6lQiDzT1jf3blNeCFyydm2ChlGD37XtvsSpR0S9A== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1709005817; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=P2Xj0RqDxN/DWwlRryINQBcfGF3YRs6jpQTcvt2jrJU=; b=GNNU05i8UF//pSOYg0VaIrjQH9KSHGLiYE40bI0xX42PC0bJ7GPP1LbGLZmbO5BFGG8t42 QSq7QL5EWGjC/R9d22kIKpTgfIWm/+NsYOCfPyqwFzG1iooK0TLztR+IrW8qCLMgvVskAp uvdspPhn1vBz9BdmY62pmz5dlbb8TY/QHNxyjZRktW/KeFfGFKKZ/MKyF3/Giz+0ZRRYWY iy6vHPGh/z62oIZsATRDK+lBKcz9AjTv+/koFEwq/mML7+YJ3SM1NxdZeI/85IMQFUPcM6 tXCAZdvTdKrs9ff/2GxlsTy+GBn5q9CzqkUIyMIHUVWc36rsXy4MdlBJ1p73FQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4TkNmS73QjzwmP; Tue, 27 Feb 2024 03:50:16 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 41R3oGp9079553; Tue, 27 Feb 2024 03:50:16 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 41R3oGEc079548; Tue, 27 Feb 2024 03:50:16 GMT (envelope-from git) Date: Tue, 27 Feb 2024 03:50:16 GMT Message-Id: <202402270350.41R3oGEc079548@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Warner Losh Subject: git: 9398a495eb30 - main - loader: Add loader.exit List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: imp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 9398a495eb305d5bf240bc998ee2f6128d75f4ca Auto-Submitted: auto-generated The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=9398a495eb305d5bf240bc998ee2f6128d75f4ca commit 9398a495eb305d5bf240bc998ee2f6128d75f4ca Author: Warner Losh AuthorDate: 2024-02-27 03:19:58 +0000 Commit: Warner Losh CommitDate: 2024-02-27 03:49:46 +0000 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 --- stand/liblua/lutils.c | 16 ++++++++++++---- stand/lua/loader.lua.8 | 4 ++++ 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 @@ -109,6 +109,13 @@ lua_perform(lua_State *L) return 1; } +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