From owner-svn-src-head@freebsd.org Tue Feb 20 21:23:02 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 F1D9DF0429F; Tue, 20 Feb 2018 21:23:01 +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 A5434706C6; Tue, 20 Feb 2018 21:23:01 +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 A00917307; Tue, 20 Feb 2018 21:23:01 +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 w1KLN11r083389; Tue, 20 Feb 2018 21:23:01 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w1KLN19M083388; Tue, 20 Feb 2018 21:23:01 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201802202123.w1KLN19M083388@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:23:01 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r329671 - head/stand/lua X-SVN-Group: head X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: head/stand/lua X-SVN-Commit-Revision: 329671 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:23:02 -0000 Author: kevans Date: Tue Feb 20 21:23:01 2018 New Revision: 329671 URL: https://svnweb.freebsd.org/changeset/base/329671 Log: 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. Modified: head/stand/lua/core.lua Modified: head/stand/lua/core.lua ============================================================================== --- head/stand/lua/core.lua Tue Feb 20 21:15:43 2018 (r329670) +++ head/stand/lua/core.lua Tue Feb 20 21:23:01 2018 (r329671) @@ -30,6 +30,13 @@ local config = require('config'); 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 -- Commonly appearing constants core.KEY_BACKSPACE = 8; @@ -182,14 +189,14 @@ function core.setDefaults() core.setVerbose(false); end -function core.autoboot() +function core.autoboot(argstr) config.loadelf(); - loader.perform("autoboot"); + loader.perform(compose_loader_cmd("autoboot", argstr)); end -function core.boot() +function core.boot(argstr) config.loadelf(); - loader.perform("boot"); + loader.perform(compose_loader_cmd("boot", argstr)); end function core.isSingleUserBoot() @@ -233,6 +240,29 @@ function core.shallowCopyTable(tbl) end end return new_tbl; +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