Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F149352572
D42459.1789903363.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
8 KB
Referenced Files
None
Subscribers
None
D42459.1789903363.diff
View Options
diff --git a/stand/efi/loader/arch/amd64/elf64_freebsd.c b/stand/efi/loader/arch/amd64/elf64_freebsd.c
--- a/stand/efi/loader/arch/amd64/elf64_freebsd.c
+++ b/stand/efi/loader/arch/amd64/elf64_freebsd.c
@@ -41,17 +41,8 @@
#include "bootstrap.h"
-#include "platform/acfreebsd.h"
-#include "acconfig.h"
-#define ACPI_SYSTEM_XFACE
-#include "actypes.h"
-#include "actbl.h"
-
#include "loader_efi.h"
-static EFI_GUID acpi_guid = ACPI_TABLE_GUID;
-static EFI_GUID acpi20_guid = ACPI_20_TABLE_GUID;
-
extern int bi_load(char *args, vm_offset_t *modulep, vm_offset_t *kernendp,
bool exit_bs);
@@ -104,9 +95,6 @@
Elf_Ehdr *ehdr;
vm_offset_t modulep, kernend, trampcode, trampstack;
int err, i;
- ACPI_TABLE_RSDP *rsdp;
- char buf[24];
- int revision;
bool copy_auto;
copy_auto = copy_staging == COPY_STAGING_AUTO;
@@ -114,38 +102,6 @@
copy_staging = fp->f_kernphys_relocatable ?
COPY_STAGING_DISABLE : COPY_STAGING_ENABLE;
- /*
- * Report the RSDP to the kernel. While this can be found with
- * a BIOS boot, the RSDP may be elsewhere when booted from UEFI.
- */
-
- rsdp = efi_get_table(&acpi20_guid);
- if (rsdp == NULL) {
- rsdp = efi_get_table(&acpi_guid);
- }
- if (rsdp != NULL) {
- sprintf(buf, "0x%016llx", (unsigned long long)rsdp);
- setenv("acpi.rsdp", buf, 1);
- revision = rsdp->Revision;
- if (revision == 0)
- revision = 1;
- sprintf(buf, "%d", revision);
- setenv("acpi.revision", buf, 1);
- strncpy(buf, rsdp->OemId, sizeof(rsdp->OemId));
- buf[sizeof(rsdp->OemId)] = '\0';
- setenv("acpi.oem", buf, 1);
- sprintf(buf, "0x%016x", rsdp->RsdtPhysicalAddress);
- setenv("acpi.rsdt", buf, 1);
- if (revision >= 2) {
- /* XXX extended checksum? */
- sprintf(buf, "0x%016llx",
- (unsigned long long)rsdp->XsdtPhysicalAddress);
- setenv("acpi.xsdt", buf, 1);
- sprintf(buf, "%d", rsdp->Length);
- setenv("acpi.xsdt_length", buf, 1);
- }
- }
-
if ((md = file_findmetadata(fp, MODINFOMD_ELFHDR)) == NULL)
return (EFTYPE);
ehdr = (Elf_Ehdr *)&(md->md_data);
diff --git a/stand/efi/loader/arch/arm64/exec.c b/stand/efi/loader/arch/arm64/exec.c
--- a/stand/efi/loader/arch/arm64/exec.c
+++ b/stand/efi/loader/arch/arm64/exec.c
@@ -40,16 +40,6 @@
#include "loader_efi.h"
#include "cache.h"
-#include "platform/acfreebsd.h"
-#include "acconfig.h"
-#define ACPI_SYSTEM_XFACE
-#define ACPI_USE_SYSTEM_INTTYPES
-#include "actypes.h"
-#include "actbl.h"
-
-static EFI_GUID acpi_guid = ACPI_TABLE_GUID;
-static EFI_GUID acpi20_guid = ACPI_20_TABLE_GUID;
-
static int elf64_exec(struct preloaded_file *amp);
static int elf64_obj_exec(struct preloaded_file *amp);
@@ -73,52 +63,10 @@
vm_offset_t clean_addr;
size_t clean_size;
struct file_metadata *md;
- ACPI_TABLE_RSDP *rsdp;
Elf_Ehdr *ehdr;
- char buf[24];
- int err, revision;
+ int err;
void (*entry)(vm_offset_t);
- /*
- * Report the RSDP to the kernel. The old code used the 'hints' method
- * to communicate this to the kernel, but this is now considered legacy.
- * Instead, move to setting different tunables that start with acpi.
- * The old 'hints' can be removed before we branch for FreeBSD 15.
- */
-
- rsdp = efi_get_table(&acpi20_guid);
- if (rsdp == NULL) {
- rsdp = efi_get_table(&acpi_guid);
- }
- if (rsdp != NULL) {
- sprintf(buf, "0x%016llx", (unsigned long long)rsdp);
- setenv("hint.acpi.0.rsdp", buf, 1);
- setenv("acpi.rsdp", buf, 1);
- revision = rsdp->Revision;
- if (revision == 0)
- revision = 1;
- sprintf(buf, "%d", revision);
- setenv("hint.acpi.0.revision", buf, 1);
- setenv("acpi.revision", buf, 1);
- strncpy(buf, rsdp->OemId, sizeof(rsdp->OemId));
- buf[sizeof(rsdp->OemId)] = '\0';
- setenv("hint.acpi.0.oem", buf, 1);
- setenv("acpi.oem", buf, 1);
- sprintf(buf, "0x%016x", rsdp->RsdtPhysicalAddress);
- setenv("hint.acpi.0.rsdt", buf, 1);
- setenv("acpi.rsdt", buf, 1);
- if (revision >= 2) {
- /* XXX extended checksum? */
- sprintf(buf, "0x%016llx",
- (unsigned long long)rsdp->XsdtPhysicalAddress);
- setenv("hint.acpi.0.xsdt", buf, 1);
- setenv("acpi.xsdt", buf, 1);
- sprintf(buf, "%d", rsdp->Length);
- setenv("hint.acpi.0.xsdt_length", buf, 1);
- setenv("acpi.xsdt_length", buf, 1);
- }
- }
-
if ((md = file_findmetadata(fp, MODINFOMD_ELFHDR)) == NULL)
return(EFTYPE);
diff --git a/stand/efi/loader/main.c b/stand/efi/loader/main.c
--- a/stand/efi/loader/main.c
+++ b/stand/efi/loader/main.c
@@ -60,6 +60,12 @@
#include "efizfs.h"
#include "framebuffer.h"
+#include "platform/acfreebsd.h"
+#include "acconfig.h"
+#define ACPI_SYSTEM_XFACE
+#include "actypes.h"
+#include "actbl.h"
+
#include "loader_efi.h"
struct arch_switch archsw; /* MI/MD interface boundary */
@@ -896,6 +902,45 @@
return ((caddr_t)x);
}
+static void
+acpi_detect(void)
+{
+ ACPI_TABLE_RSDP *rsdp;
+ char buf[24];
+ int revision;
+
+ if ((rsdp = efi_get_table(&acpi20)) == NULL)
+ if ((rsdp = efi_get_table(&acpi)) == NULL)
+ return;
+
+ sprintf(buf, "0x%016llx", (unsigned long long)rsdp);
+ setenv("hint.acpi.0.rsdp", buf, 1);
+ setenv("acpi.rsdp", buf, 1);
+ revision = rsdp->Revision;
+ if (revision == 0)
+ revision = 1;
+ sprintf(buf, "%d", revision);
+ setenv("hint.acpi.0.revision", buf, 1);
+ setenv("acpi.revision", buf, 1);
+ strncpy(buf, rsdp->OemId, sizeof(rsdp->OemId));
+ buf[sizeof(rsdp->OemId)] = '\0';
+ setenv("hint.acpi.0.oem", buf, 1);
+ setenv("acpi.oem", buf, 1);
+ sprintf(buf, "0x%016x", rsdp->RsdtPhysicalAddress);
+ setenv("hint.acpi.0.rsdt", buf, 1);
+ setenv("acpi.rsdt", buf, 1);
+ if (revision >= 2) {
+ /* XXX extended checksum? */
+ sprintf(buf, "0x%016llx",
+ (unsigned long long)rsdp->XsdtPhysicalAddress);
+ setenv("hint.acpi.0.xsdt", buf, 1);
+ setenv("acpi.xsdt", buf, 1);
+ sprintf(buf, "%d", rsdp->Length);
+ setenv("hint.acpi.0.xsdt_length", buf, 1);
+ setenv("acpi.xsdt_length", buf, 1);
+ }
+}
+
EFI_STATUS
main(int argc, CHAR16 *argv[])
{
@@ -942,6 +987,9 @@
/* Get our loaded image protocol interface structure. */
(void) OpenProtocolByHandle(IH, &imgid, (void **)&boot_img);
+ /* Report the RSDP early. */
+ acpi_detect();
+
/*
* Chicken-and-egg problem; we want to have console output early, but
* some console attributes may depend on reading from eg. the boot
diff --git a/stand/lua/core.lua b/stand/lua/core.lua
--- a/stand/lua/core.lua
+++ b/stand/lua/core.lua
@@ -32,6 +32,7 @@
local core = {}
+local default_acpi = false
local default_safe_mode = false
local default_single_user = false
local default_verbose = false
@@ -46,20 +47,14 @@
end
local function recordDefaults()
- -- On i386, hint.acpi.0.rsdp will be set before we're loaded. On !i386,
- -- it will generally be set upon execution of the kernel. Because of
- -- this, we can't (or don't really want to) detect/disable ACPI on !i386
- -- reliably. Just set it enabled if we detect it and leave well enough
- -- alone if we don't.
- local boot_acpi = core.isSystem386() and core.getACPIPresent(false)
local boot_single = loader.getenv("boot_single") or "no"
local boot_verbose = loader.getenv("boot_verbose") or "no"
+
+ default_acpi = core.getACPI()
default_single_user = boot_single:lower() ~= "no"
default_verbose = boot_verbose:lower() ~= "no"
- if boot_acpi then
- core.setACPI(true)
- end
+ core.setACPI(default_acpi)
core.setSingleUser(default_single_user)
core.setVerbose(default_verbose)
end
@@ -137,18 +132,18 @@
core.su = single_user
end
-function core.getACPIPresent(checking_system_defaults)
- local c = loader.getenv("hint.acpi.0.rsdp")
+function core.hasACPI()
+ return loader.getenv("acpi.rsdp") ~= nil
+end
- if c ~= nil then
- if checking_system_defaults then
- return true
- end
- -- Otherwise, respect disabled if it's set
- c = loader.getenv("hint.acpi.0.disabled")
- return c == nil or tonumber(c) ~= 1
+function core.getACPI()
+ if not core.hasACPI() then
+ return false
end
- return false
+
+ -- Otherwise, respect disabled if it's set
+ local c = loader.getenv("hint.acpi.0.disabled")
+ return c == nil or tonumber(c) ~= 1
end
function core.setACPI(acpi)
@@ -358,7 +353,7 @@
end
function core.setDefaults()
- core.setACPI(core.getACPIPresent(true))
+ core.setACPI(default_acpi)
core.setSafeMode(default_safe_mode)
core.setSingleUser(default_single_user)
core.setVerbose(default_verbose)
@@ -441,10 +436,6 @@
return false
end
-function core.isSystem386()
- return loader.machine_arch == "i386"
-end
-
-- Is the menu skipped in the environment in which we've booted?
function core.isMenuSkipped()
return string.lower(loader.getenv("beastie_disable") or "") == "yes"
diff --git a/stand/lua/menu.lua b/stand/lua/menu.lua
--- a/stand/lua/menu.lua
+++ b/stand/lua/menu.lua
@@ -176,7 +176,7 @@
-- acpi
{
entry_type = core.MENU_ENTRY,
- visible = core.isSystem386,
+ visible = core.hasACPI,
name = function()
return OnOff(color.highlight("A") ..
"CPI :", core.acpi)
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Sep 20, 11:22 AM (10 h, 28 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
29816436
Default Alt Text
D42459.1789903363.diff (8 KB)
Attached To
Mode
D42459: loader: fix EFI ACPI detection
Attached
Detach File
Event Timeline
Log In to Comment