2 -- Copyright (c) 2015 Pedro Souza <pedrosouza@freebsd.org>
3 -- All rights reserved.
5 -- Redistribution and use in source and binary forms, with or without
6 -- modification, are permitted provided that the following conditions
8 -- 1. Redistributions of source code must retain the above copyright
9 -- notice, this list of conditions and the following disclaimer.
10 -- 2. Redistributions in binary form must reproduce the above copyright
11 -- notice, this list of conditions and the following disclaimer in the
12 -- documentation and/or other materials provided with the distribution.
14 -- THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 -- ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 -- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 -- ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 -- FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 -- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 -- OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 -- HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 -- LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 -- OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 function core.setVerbose(b)
37 loader.setenv("boot_verbose", "YES");
39 loader.unsetenv("boot_verbose");
44 function core.setSingleUser(b)
50 loader.setenv("boot_single", "YES");
52 loader.unsetenv("boot_single");
57 function core.setACPI(b)
63 loader.setenv("acpi_load", "YES");
64 loader.setenv("hint.acpi.0.disabled", "0");
65 loader.unsetenv("loader.acpi_disabled_by_user");
67 loader.unsetenv("acpi_load");
68 loader.setenv("hint.acpi.0.disabled", "1");
69 loader.setenv("loader.acpi_disabled_by_user", "1");
74 function core.setSafeMode(b)
79 loader.setenv("kern.smp.disabled", "1");
80 loader.setenv("hw.ata.ata_dma", "0");
81 loader.setenv("hw.ata.atapi_dma", "0");
82 loader.setenv("hw.ata.wc", "0");
83 loader.setenv("hw.eisa_slots", "0");
84 loader.setenv("kern.eventtimer.periodic", "1");
85 loader.setenv("kern.geom.part.check_integrity", "0");
87 loader.unsetenv("kern.smp.disabled");
88 loader.unsetenv("hw.ata.ata_dma");
89 loader.unsetenv("hw.ata.atapi_dma");
90 loader.unsetenv("hw.ata.wc");
91 loader.unsetenv("hw.eisa_slots");
92 loader.unsetenv("kern.eventtimer.periodic");
93 loader.unsetenv("kern.geom.part.check_integrity");
98 function core.kernelList()
99 local k = loader.getenv("kernel");
100 local v = loader.getenv("kernels") or "";
109 for n in v:gmatch("([^; ]+)[; ]?") do
118 function core.setDefaults()
120 core.setSafeMode(false);
121 core.setSingleUser(false);
122 core.setVerbose(false);
125 function core.autoboot()
126 loader.perform("autoboot");
130 loader.perform("boot");
133 function core.bootserial()
134 local c = loader.getenv("console");
137 if c:find("comconsole") ~= nil then
142 local s = loader.getenv("boot_serial");
147 local m = loader.getenv("boot_multicons");