From owner-svn-src-head@freebsd.org Tue Feb 20 21:32:38 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 04F13F051C4; Tue, 20 Feb 2018 21:32:38 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id A15A271207; Tue, 20 Feb 2018 21:32:36 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 9C3F974AB; Tue, 20 Feb 2018 21:32:36 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w1KLWaI6088454; Tue, 20 Feb 2018 21:32:36 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w1KLWaYY088452; Tue, 20 Feb 2018 21:32:36 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201802202132.w1KLWaYY088452@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Tue, 20 Feb 2018 21:32:36 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r329673 - head/stand/lua X-SVN-Group: head X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: head/stand/lua X-SVN-Commit-Revision: 329673 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 20 Feb 2018 21:32:39 -0000 Author: kevans Date: Tue Feb 20 21:32:36 2018 New Revision: 329673 URL: https://svnweb.freebsd.org/changeset/base/329673 Log: 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. Modified: head/stand/lua/core.lua head/stand/lua/menu.lua Modified: head/stand/lua/core.lua ============================================================================== --- head/stand/lua/core.lua Tue Feb 20 21:27:17 2018 (r329672) +++ head/stand/lua/core.lua Tue Feb 20 21:32:36 2018 (r329673) @@ -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; Modified: head/stand/lua/menu.lua ============================================================================== --- head/stand/lua/menu.lua Tue Feb 20 21:27:17 2018 (r329672) +++ head/stand/lua/menu.lua Tue Feb 20 21:32:36 2018 (r329673) @@ -390,7 +390,6 @@ function menu.run(m) if (m == menu.welcome) then screen.defcursor(); print("Exiting menu!"); - config.loadelf(); return false; end