git: 1066a70e149a - main - kboot: Need to find the ACPI tables
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 09 Dec 2022 05:02:29 UTC
The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=1066a70e149abb383c49a4587de21eebf9b7e1d5 commit 1066a70e149abb383c49a4587de21eebf9b7e1d5 Author: Warner Losh <imp@FreeBSD.org> AuthorDate: 2022-12-09 04:56:06 +0000 Commit: Warner Losh <imp@FreeBSD.org> CommitDate: 2022-12-09 04:57:31 +0000 kboot: Need to find the ACPI tables We need to pass the ACPI tables to the laucnhed kernel (at least for x86 and aarch64). Find it using the Linux standard way. Sponsored by: Netflix --- stand/kboot/kboot.h | 3 +++ stand/kboot/main.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) diff --git a/stand/kboot/kboot.h b/stand/kboot/kboot.h index e3d169ee5ac0..72be7299995b 100644 --- a/stand/kboot/kboot.h +++ b/stand/kboot/kboot.h @@ -9,6 +9,9 @@ #define DEVT_HOSTDISK 1234 +bool has_acpi(void); +vm_offset_t acpi_rsdp(void); + void do_init(void); extern const char *hostfs_root; diff --git a/stand/kboot/main.c b/stand/kboot/main.c index 2bbe14d79253..88657d908b34 100644 --- a/stand/kboot/main.c +++ b/stand/kboot/main.c @@ -102,6 +102,50 @@ parse_args(int argc, const char **argv) return (howto); } +static vm_offset_t rsdp; + +static vm_offset_t +kboot_rsdp_from_efi(void) +{ + char buffer[512 + 1]; + char *walker, *ep; + + if (!file2str("/sys/firmware/efi/systab", buffer, sizeof(buffer))) + return (0); /* Not an EFI system */ + ep = buffer + strlen(buffer); + walker = buffer; + while (walker < ep) { + if (strncmp("ACPI20=", walker, 7) == 0) + return((vm_offset_t)strtoull(walker + 7, NULL, 0)); + if (strncmp("ACPI=", walker, 5) == 0) + return((vm_offset_t)strtoull(walker + 5, NULL, 0)); + walker += strcspn(walker, "\n"); + } + return (0); +} + +static void +find_acpi() +{ + rsdp = kboot_rsdp_from_efi(); +#if 0 /* maybe for amd64 */ + if (rsdp == 0) + rsdp = find_rsdp_arch(); +#endif +} + +vm_offset_t +acpi_rsdp() +{ + return (rsdp); +} + +bool +has_acpi() +{ + return rsdp != 0; +} + int main(int argc, const char **argv) { @@ -146,6 +190,11 @@ main(int argc, const char **argv) setenv("LINES", "24", 1); setenv("usefdt", "1", 1); + /* + * Find acpi, if it exists + */ + find_acpi(); + interact(); /* doesn't return */ return (0);