diff options
author | Tom Rini <trini@konsulko.com> | 2023-05-11 08:40:33 -0400 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2023-05-11 08:40:33 -0400 |
commit | e94fbdd2729fdcd570035d43f67adda8e0dfc115 (patch) | |
tree | fc4d5d6f989618994e0af5bb61f9918e4c8a7478 /lib/acpi/acpi.c | |
parent | 0a9a4384c1483a88776bca38e28f09be51161034 (diff) | |
parent | b982f89c583c6c03f4d1f94d29991ccf691a0f7c (diff) |
Merge https://source.denx.de/u-boot/custodians/u-boot-x86
- Various fixes for Google chromebooks
- Various minor enhancements for coreboot
Diffstat (limited to 'lib/acpi/acpi.c')
-rw-r--r-- | lib/acpi/acpi.c | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/lib/acpi/acpi.c b/lib/acpi/acpi.c new file mode 100644 index 00000000000..14b15754f49 --- /dev/null +++ b/lib/acpi/acpi.c @@ -0,0 +1,45 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Utility functions for ACPI + * + * Copyright 2023 Google LLC + */ + +#include <common.h> +#include <mapmem.h> +#include <acpi/acpi_table.h> +#include <asm/global_data.h> + +DECLARE_GLOBAL_DATA_PTR; + +struct acpi_table_header *acpi_find_table(const char *sig) +{ + struct acpi_rsdp *rsdp; + struct acpi_rsdt *rsdt; + int len, i, count; + + rsdp = map_sysmem(gd_acpi_start(), 0); + if (!rsdp) + return NULL; + rsdt = map_sysmem(rsdp->rsdt_address, 0); + len = rsdt->header.length - sizeof(rsdt->header); + count = len / sizeof(u32); + for (i = 0; i < count; i++) { + struct acpi_table_header *hdr; + + hdr = map_sysmem(rsdt->entry[i], 0); + if (!memcmp(hdr->signature, sig, ACPI_NAME_LEN)) + return hdr; + if (!memcmp(hdr->signature, "FACP", ACPI_NAME_LEN)) { + struct acpi_fadt *fadt = (struct acpi_fadt *)hdr; + + if (!memcmp(sig, "DSDT", ACPI_NAME_LEN) && fadt->dsdt) + return map_sysmem(fadt->dsdt, 0); + if (!memcmp(sig, "FACS", ACPI_NAME_LEN) && + fadt->firmware_ctrl) + return map_sysmem(fadt->firmware_ctrl, 0); + } + } + + return NULL; +} |