mirror of
https://github.com/freebsd/freebsd-src
synced 2024-09-06 17:18:32 +00:00
loader: lua: assume late ACPI detection if the feature isn't enabled
While we're here, enable the feature in the places we detect ACPI. This lets us side-step the existing issues and provide a path forward for folks upgrading from previous releases that haven't updated their ESP yet. Let's also fix core.setACPI: the hint already indicates that the user's disabled it more consistently than loader.acpi_disabled_by_user. Even more, the latter is wrong because we set it by default if we did not detect ACPI. The ACPI hint remains even when we're setting defaults because ACPI loaded into the kernel will make some noise if it's not hinted off, even when we didn't detect it. imp notes that this will result in some relatively harmless noise on platforms that don't support ACPI but aren't using the UEFI loader, as we would enable the ACPI module for loading on them and then loader would not be able to find it. These are non-fatal, but should probably be fixed by just declaring support for EARLY_ACPI in those loaders since we know they won't have ACPI early on -- punting on this for the time being, though, in favor of providing a safer upgrade path sooner. Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D42727
This commit is contained in:
parent
1631382cf2
commit
e183039f08
|
@ -909,6 +909,7 @@ acpi_detect(void)
|
||||||
char buf[24];
|
char buf[24];
|
||||||
int revision;
|
int revision;
|
||||||
|
|
||||||
|
feature_enable(FEATURE_EARLY_ACPI);
|
||||||
if ((rsdp = efi_get_table(&acpi20)) == NULL)
|
if ((rsdp = efi_get_table(&acpi20)) == NULL)
|
||||||
if ((rsdp = efi_get_table(&acpi)) == NULL)
|
if ((rsdp = efi_get_table(&acpi)) == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -54,6 +54,8 @@ biosacpi_detect(void)
|
||||||
char buf[24];
|
char buf[24];
|
||||||
int revision;
|
int revision;
|
||||||
|
|
||||||
|
feature_enable(FEATURE_EARLY_ACPI);
|
||||||
|
|
||||||
/* locate and validate the RSDP */
|
/* locate and validate the RSDP */
|
||||||
if ((rsdp = biosacpi_find_rsdp()) == NULL)
|
if ((rsdp = biosacpi_find_rsdp()) == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -133,17 +133,20 @@ function core.setSingleUser(single_user)
|
||||||
end
|
end
|
||||||
|
|
||||||
function core.hasACPI()
|
function core.hasACPI()
|
||||||
return loader.getenv("acpi.rsdp") ~= nil
|
-- We can't trust acpi.rsdp to be set if the loader binary doesn't do
|
||||||
end
|
-- ACPI detection early enough. UEFI loader historically didn't, so
|
||||||
|
-- we'll fallback to assuming ACPI is enabled if this binary does not
|
||||||
|
-- declare that it probes for ACPI early enough
|
||||||
|
if loader.getenv("acpi.rsdp") ~= nil then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
function core.isX86()
|
return not core.hasFeature("EARLY_ACPI")
|
||||||
return loader.machine_arch == "i386" or loader.machine_arch == "amd64"
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function core.getACPI()
|
function core.getACPI()
|
||||||
if not core.hasACPI() then
|
if not core.hasACPI() then
|
||||||
-- x86 requires ACPI pretty much
|
return false
|
||||||
return false or core.isX86()
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Otherwise, respect disabled if it's set
|
-- Otherwise, respect disabled if it's set
|
||||||
|
@ -157,13 +160,11 @@ function core.setACPI(acpi)
|
||||||
end
|
end
|
||||||
|
|
||||||
if acpi then
|
if acpi then
|
||||||
loader.setenv("acpi_load", "YES")
|
config.enableModule("acpi")
|
||||||
loader.setenv("hint.acpi.0.disabled", "0")
|
loader.setenv("hint.acpi.0.disabled", "0")
|
||||||
loader.unsetenv("loader.acpi_disabled_by_user")
|
|
||||||
else
|
else
|
||||||
loader.unsetenv("acpi_load")
|
config.disableModule("acpi")
|
||||||
loader.setenv("hint.acpi.0.disabled", "1")
|
loader.setenv("hint.acpi.0.disabled", "1")
|
||||||
loader.setenv("loader.acpi_disabled_by_user", "1")
|
|
||||||
end
|
end
|
||||||
core.acpi = acpi
|
core.acpi = acpi
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue