core.lua (1631382cf2820245cc72965498ff174bb548dd63) | core.lua (e183039f0882009c455c3b59fe1ab58a4fd25a5e) |
---|---|
1-- 2-- SPDX-License-Identifier: BSD-2-Clause 3-- 4-- Copyright (c) 2015 Pedro Souza <pedrosouza@freebsd.org> 5-- Copyright (c) 2018 Kyle Evans <kevans@FreeBSD.org> 6-- All rights reserved. 7-- 8-- Redistribution and use in source and binary forms, with or without --- 119 unchanged lines hidden (view full) --- 128 loader.setenv("boot_single", "YES") 129 else 130 loader.unsetenv("boot_single") 131 end 132 core.su = single_user 133end 134 135function core.hasACPI() | 1-- 2-- SPDX-License-Identifier: BSD-2-Clause 3-- 4-- Copyright (c) 2015 Pedro Souza <pedrosouza@freebsd.org> 5-- Copyright (c) 2018 Kyle Evans <kevans@FreeBSD.org> 6-- All rights reserved. 7-- 8-- Redistribution and use in source and binary forms, with or without --- 119 unchanged lines hidden (view full) --- 128 loader.setenv("boot_single", "YES") 129 else 130 loader.unsetenv("boot_single") 131 end 132 core.su = single_user 133end 134 135function core.hasACPI() |
136 return loader.getenv("acpi.rsdp") ~= nil 137end | 136 -- We can't trust acpi.rsdp to be set if the loader binary doesn't do 137 -- ACPI detection early enough. UEFI loader historically didn't, so 138 -- we'll fallback to assuming ACPI is enabled if this binary does not 139 -- declare that it probes for ACPI early enough 140 if loader.getenv("acpi.rsdp") ~= nil then 141 return true 142 end |
138 | 143 |
139function core.isX86() 140 return loader.machine_arch == "i386" or loader.machine_arch == "amd64" | 144 return not core.hasFeature("EARLY_ACPI") |
141end 142 143function core.getACPI() 144 if not core.hasACPI() then | 145end 146 147function core.getACPI() 148 if not core.hasACPI() then |
145 -- x86 requires ACPI pretty much 146 return false or core.isX86() | 149 return false |
147 end 148 149 -- Otherwise, respect disabled if it's set 150 local c = loader.getenv("hint.acpi.0.disabled") 151 return c == nil or tonumber(c) ~= 1 152end 153 154function core.setACPI(acpi) 155 if acpi == nil then 156 acpi = not core.acpi 157 end 158 159 if acpi then | 150 end 151 152 -- Otherwise, respect disabled if it's set 153 local c = loader.getenv("hint.acpi.0.disabled") 154 return c == nil or tonumber(c) ~= 1 155end 156 157function core.setACPI(acpi) 158 if acpi == nil then 159 acpi = not core.acpi 160 end 161 162 if acpi then |
160 loader.setenv("acpi_load", "YES") | 163 config.enableModule("acpi") |
161 loader.setenv("hint.acpi.0.disabled", "0") | 164 loader.setenv("hint.acpi.0.disabled", "0") |
162 loader.unsetenv("loader.acpi_disabled_by_user") | |
163 else | 165 else |
164 loader.unsetenv("acpi_load") | 166 config.disableModule("acpi") |
165 loader.setenv("hint.acpi.0.disabled", "1") | 167 loader.setenv("hint.acpi.0.disabled", "1") |
166 loader.setenv("loader.acpi_disabled_by_user", "1") | |
167 end 168 core.acpi = acpi 169end 170 171function core.setSafeMode(safe_mode) 172 if safe_mode == nil then 173 safe_mode = not core.sm 174 end --- 352 unchanged lines hidden --- | 168 end 169 core.acpi = acpi 170end 171 172function core.setSafeMode(safe_mode) 173 if safe_mode == nil then 174 safe_mode = not core.sm 175 end --- 352 unchanged lines hidden --- |