1088b4f5fSWarner Losh-- 272e39d71SKyle Evans-- SPDX-License-Identifier: BSD-2-Clause-FreeBSD 372e39d71SKyle Evans-- 4088b4f5fSWarner Losh-- Copyright (c) 2015 Pedro Souza <pedrosouza@freebsd.org> 5beaafe4fSKyle Evans-- Copyright (c) 2018 Kyle Evans <kevans@FreeBSD.org> 6088b4f5fSWarner Losh-- All rights reserved. 7088b4f5fSWarner Losh-- 8088b4f5fSWarner Losh-- Redistribution and use in source and binary forms, with or without 9088b4f5fSWarner Losh-- modification, are permitted provided that the following conditions 10088b4f5fSWarner Losh-- are met: 11088b4f5fSWarner Losh-- 1. Redistributions of source code must retain the above copyright 12088b4f5fSWarner Losh-- notice, this list of conditions and the following disclaimer. 13088b4f5fSWarner Losh-- 2. Redistributions in binary form must reproduce the above copyright 14088b4f5fSWarner Losh-- notice, this list of conditions and the following disclaimer in the 15088b4f5fSWarner Losh-- documentation and/or other materials provided with the distribution. 16088b4f5fSWarner Losh-- 17088b4f5fSWarner Losh-- THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 18088b4f5fSWarner Losh-- ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19088b4f5fSWarner Losh-- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20088b4f5fSWarner Losh-- ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 21088b4f5fSWarner Losh-- FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22088b4f5fSWarner Losh-- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23088b4f5fSWarner Losh-- OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24088b4f5fSWarner Losh-- HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25088b4f5fSWarner Losh-- LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26088b4f5fSWarner Losh-- OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27088b4f5fSWarner Losh-- SUCH DAMAGE. 28088b4f5fSWarner Losh-- 29088b4f5fSWarner Losh-- $FreeBSD$ 30088b4f5fSWarner Losh-- 31088b4f5fSWarner Losh 32011eae6cSKyle Evanslocal config = require("config") 33aea262bfSKyle Evanslocal hook = require("hook") 34fa4a2394SKyle Evans 35aedd6be5SKyle Evanslocal core = {} 36088b4f5fSWarner Losh 371613f091SKyle Evanslocal default_safe_mode = false 381613f091SKyle Evanslocal default_single_user = false 391613f091SKyle Evanslocal default_verbose = false 401613f091SKyle Evans 41322a2dddSKyle Evanslocal function composeLoaderCmd(cmd_name, argstr) 429f71d421SKyle Evans if argstr ~= nil then 43aedd6be5SKyle Evans cmd_name = cmd_name .. " " .. argstr 446d4ed94dSKyle Evans end 45aedd6be5SKyle Evans return cmd_name 466d4ed94dSKyle Evansend 476d4ed94dSKyle Evans 481613f091SKyle Evanslocal function recordDefaults() 491613f091SKyle Evans -- On i386, hint.acpi.0.rsdp will be set before we're loaded. On !i386, 501613f091SKyle Evans -- it will generally be set upon execution of the kernel. Because of 511613f091SKyle Evans -- this, we can't (or don't really want to) detect/disable ACPI on !i386 521613f091SKyle Evans -- reliably. Just set it enabled if we detect it and leave well enough 531613f091SKyle Evans -- alone if we don't. 541613f091SKyle Evans local boot_acpi = core.isSystem386() and core.getACPIPresent(false) 551613f091SKyle Evans local boot_single = loader.getenv("boot_single") or "no" 561613f091SKyle Evans local boot_verbose = loader.getenv("boot_verbose") or "no" 571613f091SKyle Evans default_single_user = boot_single:lower() ~= "no" 581613f091SKyle Evans default_verbose = boot_verbose:lower() ~= "no" 591613f091SKyle Evans 601613f091SKyle Evans if boot_acpi then 611613f091SKyle Evans core.setACPI(true) 621613f091SKyle Evans end 631613f091SKyle Evans core.setSingleUser(default_single_user) 641613f091SKyle Evans core.setVerbose(default_verbose) 651613f091SKyle Evansend 661613f091SKyle Evans 671613f091SKyle Evans 6807faaf78SKyle Evans-- Globals 695beb5507SKyle Evans-- try_include will return the loaded module on success, or false and the error 705beb5507SKyle Evans-- message on failure. 7107faaf78SKyle Evansfunction try_include(module) 72bac5966eSKyle Evans if module:sub(1, 1) ~= "/" then 73366f9979SKyle Evans local lua_path = loader.lua_path 74bac5966eSKyle Evans -- XXX Temporary compat shim; this should be removed once the 75bac5966eSKyle Evans -- loader.lua_path export has sufficiently spread. 76bac5966eSKyle Evans if lua_path == nil then 77bac5966eSKyle Evans lua_path = "/boot/lua" 7807faaf78SKyle Evans end 79bac5966eSKyle Evans module = lua_path .. "/" .. module 80bac5966eSKyle Evans -- We only attempt to append an extension if an absolute path 81bac5966eSKyle Evans -- wasn't specified. This assumes that the caller either wants 82bac5966eSKyle Evans -- to treat this like it would require() and specify just the 83bac5966eSKyle Evans -- base filename, or they know what they're doing as they've 84bac5966eSKyle Evans -- specified an absolute path and we shouldn't impede. 85bac5966eSKyle Evans if module:match(".lua$") == nil then 86bac5966eSKyle Evans module = module .. ".lua" 87bac5966eSKyle Evans end 88bac5966eSKyle Evans end 89bac5966eSKyle Evans if lfs.attributes(module, "mode") ~= "file" then 90bac5966eSKyle Evans return 91bac5966eSKyle Evans end 92bac5966eSKyle Evans 93bac5966eSKyle Evans return dofile(module) 9407faaf78SKyle Evansend 9507faaf78SKyle Evans 96b5746545SKyle Evans-- Module exports 97fe672a15SKyle Evans-- Commonly appearing constants 98aedd6be5SKyle Evanscore.KEY_BACKSPACE = 8 99aedd6be5SKyle Evanscore.KEY_ENTER = 13 100aedd6be5SKyle Evanscore.KEY_DELETE = 127 101fe672a15SKyle Evans 102230061c5SKyle Evans-- Note that this is a decimal representation, despite the leading 0 that in 103230061c5SKyle Evans-- other contexts (outside of Lua) may mean 'octal' 104aedd6be5SKyle Evanscore.KEYSTR_ESCAPE = "\027" 1052bb86aefSKyle Evanscore.KEYSTR_CSI = core.KEYSTR_ESCAPE .. "[" 106*73531a2aSRyan Moellercore.KEYSTR_RESET = core.KEYSTR_ESCAPE .. "c" 10739006570SKyle Evans 108aedd6be5SKyle Evanscore.MENU_RETURN = "return" 109aedd6be5SKyle Evanscore.MENU_ENTRY = "entry" 110aedd6be5SKyle Evanscore.MENU_SEPARATOR = "separator" 111aedd6be5SKyle Evanscore.MENU_SUBMENU = "submenu" 112aedd6be5SKyle Evanscore.MENU_CAROUSEL_ENTRY = "carousel_entry" 113a7cf0562SKyle Evans 11404af4229SKyle Evansfunction core.setVerbose(verbose) 11504af4229SKyle Evans if verbose == nil then 11604af4229SKyle Evans verbose = not core.verbose 117088b4f5fSWarner Losh end 118088b4f5fSWarner Losh 11904af4229SKyle Evans if verbose then 120aedd6be5SKyle Evans loader.setenv("boot_verbose", "YES") 121088b4f5fSWarner Losh else 122aedd6be5SKyle Evans loader.unsetenv("boot_verbose") 123088b4f5fSWarner Losh end 12404af4229SKyle Evans core.verbose = verbose 125088b4f5fSWarner Loshend 126088b4f5fSWarner Losh 12704af4229SKyle Evansfunction core.setSingleUser(single_user) 12804af4229SKyle Evans if single_user == nil then 12904af4229SKyle Evans single_user = not core.su 130088b4f5fSWarner Losh end 131088b4f5fSWarner Losh 13204af4229SKyle Evans if single_user then 133aedd6be5SKyle Evans loader.setenv("boot_single", "YES") 134088b4f5fSWarner Losh else 135aedd6be5SKyle Evans loader.unsetenv("boot_single") 136088b4f5fSWarner Losh end 13704af4229SKyle Evans core.su = single_user 138088b4f5fSWarner Loshend 139088b4f5fSWarner Losh 14004af4229SKyle Evansfunction core.getACPIPresent(checking_system_defaults) 141aedd6be5SKyle Evans local c = loader.getenv("hint.acpi.0.rsdp") 1426401094fSKyle Evans 1439f71d421SKyle Evans if c ~= nil then 14404af4229SKyle Evans if checking_system_defaults then 145aedd6be5SKyle Evans return true 1466401094fSKyle Evans end 1476401094fSKyle Evans -- Otherwise, respect disabled if it's set 148aedd6be5SKyle Evans c = loader.getenv("hint.acpi.0.disabled") 1499f71d421SKyle Evans return c == nil or tonumber(c) ~= 1 1506401094fSKyle Evans end 151aedd6be5SKyle Evans return false 1526401094fSKyle Evansend 1536401094fSKyle Evans 15404af4229SKyle Evansfunction core.setACPI(acpi) 15504af4229SKyle Evans if acpi == nil then 15604af4229SKyle Evans acpi = not core.acpi 157088b4f5fSWarner Losh end 158088b4f5fSWarner Losh 15904af4229SKyle Evans if acpi then 160aedd6be5SKyle Evans loader.setenv("acpi_load", "YES") 161aedd6be5SKyle Evans loader.setenv("hint.acpi.0.disabled", "0") 162aedd6be5SKyle Evans loader.unsetenv("loader.acpi_disabled_by_user") 163088b4f5fSWarner Losh else 164aedd6be5SKyle Evans loader.unsetenv("acpi_load") 165aedd6be5SKyle Evans loader.setenv("hint.acpi.0.disabled", "1") 166aedd6be5SKyle Evans loader.setenv("loader.acpi_disabled_by_user", "1") 167088b4f5fSWarner Losh end 16804af4229SKyle Evans core.acpi = acpi 169088b4f5fSWarner Loshend 170088b4f5fSWarner Losh 17104af4229SKyle Evansfunction core.setSafeMode(safe_mode) 17204af4229SKyle Evans if safe_mode == nil then 17304af4229SKyle Evans safe_mode = not core.sm 174088b4f5fSWarner Losh end 17504af4229SKyle Evans if safe_mode then 176aedd6be5SKyle Evans loader.setenv("kern.smp.disabled", "1") 177aedd6be5SKyle Evans loader.setenv("hw.ata.ata_dma", "0") 178aedd6be5SKyle Evans loader.setenv("hw.ata.atapi_dma", "0") 179aedd6be5SKyle Evans loader.setenv("hw.ata.wc", "0") 180aedd6be5SKyle Evans loader.setenv("hw.eisa_slots", "0") 181aedd6be5SKyle Evans loader.setenv("kern.eventtimer.periodic", "1") 182aedd6be5SKyle Evans loader.setenv("kern.geom.part.check_integrity", "0") 183088b4f5fSWarner Losh else 184aedd6be5SKyle Evans loader.unsetenv("kern.smp.disabled") 185aedd6be5SKyle Evans loader.unsetenv("hw.ata.ata_dma") 186aedd6be5SKyle Evans loader.unsetenv("hw.ata.atapi_dma") 187aedd6be5SKyle Evans loader.unsetenv("hw.ata.wc") 188aedd6be5SKyle Evans loader.unsetenv("hw.eisa_slots") 189aedd6be5SKyle Evans loader.unsetenv("kern.eventtimer.periodic") 190aedd6be5SKyle Evans loader.unsetenv("kern.geom.part.check_integrity") 191088b4f5fSWarner Losh end 19204af4229SKyle Evans core.sm = safe_mode 193088b4f5fSWarner Loshend 194088b4f5fSWarner Losh 195aea262bfSKyle Evansfunction core.clearCachedKernels() 19635b0c718SKyle Evans -- Clear the kernel cache on config changes, autodetect might have 19735b0c718SKyle Evans -- changed or if we've switched boot environments then we could have 19835b0c718SKyle Evans -- a new kernel set. 19935b0c718SKyle Evans core.cached_kernels = nil 20035b0c718SKyle Evansend 20135b0c718SKyle Evans 202088b4f5fSWarner Loshfunction core.kernelList() 20335b0c718SKyle Evans if core.cached_kernels ~= nil then 20435b0c718SKyle Evans return core.cached_kernels 20535b0c718SKyle Evans end 20635b0c718SKyle Evans 207aedd6be5SKyle Evans local k = loader.getenv("kernel") 2083f4eb56bSKyle Evans local v = loader.getenv("kernels") 2093889e6cdSKyle Evans local autodetect = loader.getenv("kernels_autodetect") or "" 210088b4f5fSWarner Losh 211aedd6be5SKyle Evans local kernels = {} 212aedd6be5SKyle Evans local unique = {} 213aedd6be5SKyle Evans local i = 0 2149f71d421SKyle Evans if k ~= nil then 215aedd6be5SKyle Evans i = i + 1 216aedd6be5SKyle Evans kernels[i] = k 217aedd6be5SKyle Evans unique[k] = true 218088b4f5fSWarner Losh end 219088b4f5fSWarner Losh 2203f4eb56bSKyle Evans if v ~= nil then 221a5003419SKyle Evans for n in v:gmatch("([^;, ]+)[;, ]?") do 2229f71d421SKyle Evans if unique[n] == nil then 223aedd6be5SKyle Evans i = i + 1 224aedd6be5SKyle Evans kernels[i] = n 225aedd6be5SKyle Evans unique[n] = true 226088b4f5fSWarner Losh end 227088b4f5fSWarner Losh end 2283889e6cdSKyle Evans end 229a108046fSConrad Meyer 2303889e6cdSKyle Evans -- Base whether we autodetect kernels or not on a loader.conf(5) 2313889e6cdSKyle Evans -- setting, kernels_autodetect. If it's set to 'yes', we'll add 2323889e6cdSKyle Evans -- any kernels we detect based on the criteria described. 2333889e6cdSKyle Evans if autodetect:lower() ~= "yes" then 23435b0c718SKyle Evans core.cached_kernels = kernels 23535b0c718SKyle Evans return core.cached_kernels 2363f4eb56bSKyle Evans end 2373f4eb56bSKyle Evans 238a108046fSConrad Meyer -- Automatically detect other bootable kernel directories using a 239a108046fSConrad Meyer -- heuristic. Any directory in /boot that contains an ordinary file 240a108046fSConrad Meyer -- named "kernel" is considered eligible. 241a108046fSConrad Meyer for file in lfs.dir("/boot") do 242aedd6be5SKyle Evans local fname = "/boot/" .. file 243a108046fSConrad Meyer 2449f71d421SKyle Evans if file == "." or file == ".." then 245aedd6be5SKyle Evans goto continue 246a108046fSConrad Meyer end 247a108046fSConrad Meyer 2489f71d421SKyle Evans if lfs.attributes(fname, "mode") ~= "directory" then 249aedd6be5SKyle Evans goto continue 250a108046fSConrad Meyer end 251a108046fSConrad Meyer 2529f71d421SKyle Evans if lfs.attributes(fname .. "/kernel", "mode") ~= "file" then 253aedd6be5SKyle Evans goto continue 254a108046fSConrad Meyer end 255a108046fSConrad Meyer 2569f71d421SKyle Evans if unique[file] == nil then 257aedd6be5SKyle Evans i = i + 1 258aedd6be5SKyle Evans kernels[i] = file 259aedd6be5SKyle Evans unique[file] = true 260a108046fSConrad Meyer end 261a108046fSConrad Meyer 262a108046fSConrad Meyer ::continue:: 263a108046fSConrad Meyer end 26435b0c718SKyle Evans core.cached_kernels = kernels 26535b0c718SKyle Evans return core.cached_kernels 266088b4f5fSWarner Loshend 267088b4f5fSWarner Losh 2687efc058fSKyle Evansfunction core.bootenvDefault() 2697efc058fSKyle Evans return loader.getenv("zfs_be_active") 2707efc058fSKyle Evansend 2717efc058fSKyle Evans 2727efc058fSKyle Evansfunction core.bootenvList() 2737efc058fSKyle Evans local bootenv_count = tonumber(loader.getenv("bootenvs_count")) 2747efc058fSKyle Evans local bootenvs = {} 2757efc058fSKyle Evans local curenv 2767efc058fSKyle Evans local envcount = 0 2777efc058fSKyle Evans local unique = {} 2787efc058fSKyle Evans 2797efc058fSKyle Evans if bootenv_count == nil or bootenv_count <= 0 then 2807efc058fSKyle Evans return bootenvs 2817efc058fSKyle Evans end 2827efc058fSKyle Evans 2837efc058fSKyle Evans -- Currently selected bootenv is always first/default 2847efc058fSKyle Evans curenv = core.bootenvDefault() 2857efc058fSKyle Evans if curenv ~= nil then 2867efc058fSKyle Evans envcount = envcount + 1 2877efc058fSKyle Evans bootenvs[envcount] = curenv 2887efc058fSKyle Evans unique[curenv] = true 2897efc058fSKyle Evans end 2907efc058fSKyle Evans 2917efc058fSKyle Evans for curenv_idx = 0, bootenv_count - 1 do 2927efc058fSKyle Evans curenv = loader.getenv("bootenvs[" .. curenv_idx .. "]") 2937efc058fSKyle Evans if curenv ~= nil and unique[curenv] == nil then 2947efc058fSKyle Evans envcount = envcount + 1 2957efc058fSKyle Evans bootenvs[envcount] = curenv 2967efc058fSKyle Evans unique[curenv] = true 2977efc058fSKyle Evans end 2987efc058fSKyle Evans end 2997efc058fSKyle Evans return bootenvs 3007efc058fSKyle Evansend 3017efc058fSKyle Evans 302088b4f5fSWarner Loshfunction core.setDefaults() 303aedd6be5SKyle Evans core.setACPI(core.getACPIPresent(true)) 3041613f091SKyle Evans core.setSafeMode(default_safe_mode) 3051613f091SKyle Evans core.setSingleUser(default_single_user) 3061613f091SKyle Evans core.setVerbose(default_verbose) 307088b4f5fSWarner Loshend 308088b4f5fSWarner Losh 3096d4ed94dSKyle Evansfunction core.autoboot(argstr) 310a2a7830eSKyle Evans -- loadelf() only if we've not already loaded a kernel 311a2a7830eSKyle Evans if loader.getenv("kernelname") == nil then 312aedd6be5SKyle Evans config.loadelf() 313a2a7830eSKyle Evans end 314322a2dddSKyle Evans loader.perform(composeLoaderCmd("autoboot", argstr)) 315088b4f5fSWarner Loshend 316088b4f5fSWarner Losh 3176d4ed94dSKyle Evansfunction core.boot(argstr) 318a2a7830eSKyle Evans -- loadelf() only if we've not already loaded a kernel 319a2a7830eSKyle Evans if loader.getenv("kernelname") == nil then 320aedd6be5SKyle Evans config.loadelf() 321a2a7830eSKyle Evans end 322322a2dddSKyle Evans loader.perform(composeLoaderCmd("boot", argstr)) 323088b4f5fSWarner Loshend 324088b4f5fSWarner Losh 325e07fc39cSKyle Evansfunction core.isSingleUserBoot() 326aedd6be5SKyle Evans local single_user = loader.getenv("boot_single") 327aedd6be5SKyle Evans return single_user ~= nil and single_user:lower() == "yes" 328e07fc39cSKyle Evansend 329e07fc39cSKyle Evans 3305f8cfbe1SKyle Evansfunction core.isUEFIBoot() 3315f8cfbe1SKyle Evans local efiver = loader.getenv("efi-version") 3325f8cfbe1SKyle Evans 3335f8cfbe1SKyle Evans return efiver ~= nil 3345f8cfbe1SKyle Evansend 3355f8cfbe1SKyle Evans 3367efc058fSKyle Evansfunction core.isZFSBoot() 3377efc058fSKyle Evans local c = loader.getenv("currdev") 3387efc058fSKyle Evans 3397efc058fSKyle Evans if c ~= nil then 3407efc058fSKyle Evans return c:match("^zfs:") ~= nil 3417efc058fSKyle Evans end 3427efc058fSKyle Evans return false 3437efc058fSKyle Evansend 3447efc058fSKyle Evans 34590a25417SKyle Evansfunction core.isSerialConsole() 34690a25417SKyle Evans local c = loader.getenv("console") 34790a25417SKyle Evans if c ~= nil then 34890a25417SKyle Evans if c:find("comconsole") ~= nil then 34990a25417SKyle Evans return true 35090a25417SKyle Evans end 35190a25417SKyle Evans end 35290a25417SKyle Evans return false 35390a25417SKyle Evansend 35490a25417SKyle Evans 355b140d14bSKyle Evansfunction core.isSerialBoot() 356aedd6be5SKyle Evans local s = loader.getenv("boot_serial") 3579f71d421SKyle Evans if s ~= nil then 358aedd6be5SKyle Evans return true 359088b4f5fSWarner Losh end 360088b4f5fSWarner Losh 361aedd6be5SKyle Evans local m = loader.getenv("boot_multicons") 3629f71d421SKyle Evans if m ~= nil then 363aedd6be5SKyle Evans return true 364088b4f5fSWarner Losh end 365aedd6be5SKyle Evans return false 366088b4f5fSWarner Loshend 367088b4f5fSWarner Losh 368c1ab36f5SKyle Evansfunction core.isSystem386() 3699f71d421SKyle Evans return loader.machine_arch == "i386" 370c1ab36f5SKyle Evansend 371c1ab36f5SKyle Evans 3729937e979SKyle Evans-- Is the menu skipped in the environment in which we've booted? 3739937e979SKyle Evansfunction core.isMenuSkipped() 374b83a355dSKyle Evans return string.lower(loader.getenv("beastie_disable") or "") == "yes" 3759937e979SKyle Evansend 3769937e979SKyle Evans 3775c1b5165SKyle Evans-- This may be a better candidate for a 'utility' module. 378ee4e69f1SKyle Evansfunction core.deepCopyTable(tbl) 379aedd6be5SKyle Evans local new_tbl = {} 3805c1b5165SKyle Evans for k, v in pairs(tbl) do 3819f71d421SKyle Evans if type(v) == "table" then 382ee4e69f1SKyle Evans new_tbl[k] = core.deepCopyTable(v) 3835c1b5165SKyle Evans else 384aedd6be5SKyle Evans new_tbl[k] = v 3855c1b5165SKyle Evans end 3865c1b5165SKyle Evans end 387aedd6be5SKyle Evans return new_tbl 3885c1b5165SKyle Evansend 3895c1b5165SKyle Evans 3906d4ed94dSKyle Evans-- XXX This should go away if we get the table lib into shape for importing. 3916d4ed94dSKyle Evans-- As of now, it requires some 'os' functions, so we'll implement this in lua 3926d4ed94dSKyle Evans-- for our uses 3936d4ed94dSKyle Evansfunction core.popFrontTable(tbl) 3946d4ed94dSKyle Evans -- Shouldn't reasonably happen 3959f71d421SKyle Evans if #tbl == 0 then 396aedd6be5SKyle Evans return nil, nil 3979f71d421SKyle Evans elseif #tbl == 1 then 398aedd6be5SKyle Evans return tbl[1], {} 3996d4ed94dSKyle Evans end 4006d4ed94dSKyle Evans 401aedd6be5SKyle Evans local first_value = tbl[1] 402aedd6be5SKyle Evans local new_tbl = {} 4036d4ed94dSKyle Evans -- This is not a cheap operation 4046d4ed94dSKyle Evans for k, v in ipairs(tbl) do 4059f71d421SKyle Evans if k > 1 then 406aedd6be5SKyle Evans new_tbl[k - 1] = v 4076d4ed94dSKyle Evans end 4086d4ed94dSKyle Evans end 4096d4ed94dSKyle Evans 410aedd6be5SKyle Evans return first_value, new_tbl 4116d4ed94dSKyle Evansend 4126d4ed94dSKyle Evans 4131613f091SKyle EvansrecordDefaults() 414aea262bfSKyle Evanshook.register("config.reloaded", core.clearCachedKernels) 415aedd6be5SKyle Evansreturn core 416