diff options
Diffstat (limited to 'lib/acpi')
-rw-r--r-- | lib/acpi/Makefile | 2 | ||||
-rw-r--r-- | lib/acpi/acpi.c | 50 | ||||
-rw-r--r-- | lib/acpi/acpi_device.c | 1 | ||||
-rw-r--r-- | lib/acpi/acpi_dp.c | 1 | ||||
-rw-r--r-- | lib/acpi/acpi_table.c | 5 | ||||
-rw-r--r-- | lib/acpi/acpi_writer.c | 6 | ||||
-rw-r--r-- | lib/acpi/acpigen.c | 1 | ||||
-rw-r--r-- | lib/acpi/base.c | 26 | ||||
-rw-r--r-- | lib/acpi/csrt.c | 2 | ||||
-rw-r--r-- | lib/acpi/dsdt.c | 2 | ||||
-rw-r--r-- | lib/acpi/facs.c | 2 | ||||
-rw-r--r-- | lib/acpi/mcfg.c | 4 | ||||
-rw-r--r-- | lib/acpi/ssdt.c | 6 |
13 files changed, 73 insertions, 35 deletions
diff --git a/lib/acpi/Makefile b/lib/acpi/Makefile index c1c9675b5d..cc2868488a 100644 --- a/lib/acpi/Makefile +++ b/lib/acpi/Makefile @@ -12,7 +12,7 @@ obj-$(CONFIG_$(SPL_)ACPIGEN) += acpi_table.o obj-y += acpi_writer.o # With QEMU the ACPI tables come from there, not from U-Boot -ifndef CONFIG_QEMU +ifndef CONFIG_QFW_ACPI obj-y += base.o obj-y += csrt.o obj-y += mcfg.o diff --git a/lib/acpi/acpi.c b/lib/acpi/acpi.c index 14b15754f4..f4d5c1e25d 100644 --- a/lib/acpi/acpi.c +++ b/lib/acpi/acpi.c @@ -5,7 +5,6 @@ * Copyright 2023 Google LLC */ -#include <common.h> #include <mapmem.h> #include <acpi/acpi_table.h> #include <asm/global_data.h> @@ -16,28 +15,59 @@ struct acpi_table_header *acpi_find_table(const char *sig) { struct acpi_rsdp *rsdp; struct acpi_rsdt *rsdt; + struct acpi_xsdt *xsdt; 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); + if (rsdp->xsdt_address) { + xsdt = nomap_sysmem(rsdp->xsdt_address, 0); + len = xsdt->header.length - sizeof(xsdt->header); + count = len / sizeof(u64); + } else { + if (!rsdp->rsdt_address) + return NULL; + rsdt = nomap_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 (rsdp->xsdt_address) + hdr = nomap_sysmem(xsdt->entry[i], 0); + else + hdr = nomap_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); + if (!memcmp(sig, "DSDT", ACPI_NAME_LEN)) { + void *dsdt; + + if (fadt->header.revision >= 3 && fadt->x_dsdt) + dsdt = nomap_sysmem(fadt->x_dsdt, 0); + else if (fadt->dsdt) + dsdt = nomap_sysmem(fadt->dsdt, 0); + else + dsdt = NULL; + return dsdt; + } + + if (!memcmp(sig, "FACS", ACPI_NAME_LEN)) { + void *facs; + + if (fadt->header.revision >= 3 && + fadt->x_firmware_ctrl) + facs = nomap_sysmem(fadt->x_firmware_ctrl, 0); + else if (fadt->firmware_ctrl) + facs = nomap_sysmem(fadt->firmware_ctrl, 0); + else + facs = NULL; + return facs; + } } } diff --git a/lib/acpi/acpi_device.c b/lib/acpi/acpi_device.c index 1b838fdbd6..ed94194346 100644 --- a/lib/acpi/acpi_device.c +++ b/lib/acpi/acpi_device.c @@ -6,7 +6,6 @@ * Mostly taken from coreboot file of the same name */ -#include <common.h> #include <dm.h> #include <irq.h> #include <log.h> diff --git a/lib/acpi/acpi_dp.c b/lib/acpi/acpi_dp.c index 7e3e3259d8..6733809986 100644 --- a/lib/acpi/acpi_dp.c +++ b/lib/acpi/acpi_dp.c @@ -6,7 +6,6 @@ * Mostly taken from coreboot file acpi_device.c */ -#include <common.h> #include <dm.h> #include <log.h> #include <malloc.h> diff --git a/lib/acpi/acpi_table.c b/lib/acpi/acpi_table.c index a8d4b47000..39dd53ec40 100644 --- a/lib/acpi/acpi_table.c +++ b/lib/acpi/acpi_table.c @@ -5,7 +5,6 @@ * Copyright 2019 Google LLC */ -#include <common.h> #include <dm.h> #include <cpu.h> #include <log.h> @@ -168,7 +167,7 @@ int acpi_add_table(struct acpi_ctx *ctx, void *table) } /* Add table to the RSDT */ - rsdt->entry[i] = map_to_sysmem(table); + rsdt->entry[i] = nomap_to_sysmem(table); /* Fix RSDT length or the kernel will assume invalid entries */ rsdt->header.length = sizeof(struct acpi_table_header) + @@ -186,7 +185,7 @@ int acpi_add_table(struct acpi_ctx *ctx, void *table) xsdt = ctx->xsdt; /* Add table to the XSDT */ - xsdt->entry[i] = map_to_sysmem(table); + xsdt->entry[i] = nomap_to_sysmem(table); /* Fix XSDT length */ xsdt->header.length = sizeof(struct acpi_table_header) + diff --git a/lib/acpi/acpi_writer.c b/lib/acpi/acpi_writer.c index 946f90e8e7..bbb9b54786 100644 --- a/lib/acpi/acpi_writer.c +++ b/lib/acpi/acpi_writer.c @@ -7,13 +7,13 @@ #define LOG_CATEGORY LOGC_ACPI -#include <common.h> #include <log.h> #include <malloc.h> #include <mapmem.h> #include <acpi/acpi_table.h> #include <asm/global_data.h> #include <dm/acpi.h> +#include <linux/errno.h> DECLARE_GLOBAL_DATA_PTR; @@ -48,7 +48,7 @@ int acpi_write_one(struct acpi_ctx *ctx, const struct acpi_writer *entry) return 0; } -#ifndef CONFIG_QEMU +#ifndef CONFIG_QFW_ACPI static int acpi_write_all(struct acpi_ctx *ctx) { const struct acpi_writer *writer = @@ -115,7 +115,7 @@ ulong acpi_get_rsdp_addr(void) return map_to_sysmem(gd->acpi_ctx->rsdp); } -#endif /* QEMU */ +#endif /* QFW_ACPI */ void acpi_setup_ctx(struct acpi_ctx *ctx, ulong start) { diff --git a/lib/acpi/acpigen.c b/lib/acpi/acpigen.c index e395226e3d..b95cabb914 100644 --- a/lib/acpi/acpigen.c +++ b/lib/acpi/acpigen.c @@ -8,7 +8,6 @@ #define LOG_CATEGORY LOGC_ACPI -#include <common.h> #include <dm.h> #include <log.h> #include <uuid.h> diff --git a/lib/acpi/base.c b/lib/acpi/base.c index 2057bd2bef..8b6af2bc43 100644 --- a/lib/acpi/base.c +++ b/lib/acpi/base.c @@ -7,11 +7,13 @@ #define LOG_CATEGORY LOGC_ACPI -#include <common.h> #include <acpi/acpi_table.h> #include <dm/acpi.h> #include <mapmem.h> #include <tables_csum.h> +#include <linux/sizes.h> +#include <linux/errno.h> +#include <linux/string.h> void acpi_write_rsdp(struct acpi_rsdp *rsdp, struct acpi_rsdt *rsdt, struct acpi_xsdt *xsdt) @@ -21,10 +23,13 @@ void acpi_write_rsdp(struct acpi_rsdp *rsdp, struct acpi_rsdt *rsdt, memcpy(rsdp->signature, RSDP_SIG, 8); memcpy(rsdp->oem_id, OEM_ID, 6); - rsdp->length = sizeof(struct acpi_rsdp); - rsdp->rsdt_address = map_to_sysmem(rsdt); + if (rsdt) + rsdp->rsdt_address = nomap_to_sysmem(rsdt); + + if (xsdt) + rsdp->xsdt_address = nomap_to_sysmem(xsdt); - rsdp->xsdt_address = map_to_sysmem(xsdt); + rsdp->length = sizeof(struct acpi_rsdp); rsdp->revision = ACPI_RSDP_REV_ACPI_2_0; /* Calculate checksums */ @@ -68,11 +73,15 @@ static void acpi_write_xsdt(struct acpi_xsdt *xsdt) static int acpi_write_base(struct acpi_ctx *ctx, const struct acpi_writer *entry) { - /* We need at least an RSDP and an RSDT Table */ + /* We need at least an RSDP and an XSDT Table */ ctx->rsdp = ctx->current; acpi_inc_align(ctx, sizeof(struct acpi_rsdp)); - ctx->rsdt = ctx->current; - acpi_inc_align(ctx, sizeof(struct acpi_rsdt)); + if (map_to_sysmem(ctx->current) < SZ_4G - SZ_64K) { + ctx->rsdt = ctx->current; + acpi_inc_align(ctx, sizeof(struct acpi_rsdt)); + } else { + ctx->rsdt = 0; + } ctx->xsdt = ctx->current; acpi_inc_align(ctx, sizeof(struct acpi_xsdt)); @@ -80,7 +89,8 @@ static int acpi_write_base(struct acpi_ctx *ctx, memset(ctx->base, '\0', ctx->current - ctx->base); acpi_write_rsdp(ctx->rsdp, ctx->rsdt, ctx->xsdt); - acpi_write_rsdt(ctx->rsdt); + if (ctx->rsdt) + acpi_write_rsdt(ctx->rsdt); acpi_write_xsdt(ctx->xsdt); return 0; diff --git a/lib/acpi/csrt.c b/lib/acpi/csrt.c index 2ba86f2295..00927e5340 100644 --- a/lib/acpi/csrt.c +++ b/lib/acpi/csrt.c @@ -7,11 +7,11 @@ #define LOG_CATEGORY LOGC_ACPI -#include <common.h> #include <mapmem.h> #include <tables_csum.h> #include <acpi/acpi_table.h> #include <dm/acpi.h> +#include <linux/string.h> __weak int acpi_fill_csrt(struct acpi_ctx *ctx) { diff --git a/lib/acpi/dsdt.c b/lib/acpi/dsdt.c index db98cc20e1..206e1e2678 100644 --- a/lib/acpi/dsdt.c +++ b/lib/acpi/dsdt.c @@ -7,10 +7,10 @@ #define LOG_CATEGORY LOGC_ACPI -#include <common.h> #include <acpi/acpi_table.h> #include <dm/acpi.h> #include <tables_csum.h> +#include <linux/string.h> /* * IASL compiles the dsdt entries and writes the hex values diff --git a/lib/acpi/facs.c b/lib/acpi/facs.c index e89f43ca5c..86c28120c7 100644 --- a/lib/acpi/facs.c +++ b/lib/acpi/facs.c @@ -7,9 +7,9 @@ #define LOG_CATEGORY LOGC_ACPI -#include <common.h> #include <acpi/acpi_table.h> #include <dm/acpi.h> +#include <linux/string.h> int acpi_write_facs(struct acpi_ctx *ctx, const struct acpi_writer *entry) { diff --git a/lib/acpi/mcfg.c b/lib/acpi/mcfg.c index 7404ae586a..8b8a5bfafa 100644 --- a/lib/acpi/mcfg.c +++ b/lib/acpi/mcfg.c @@ -7,11 +7,13 @@ #define LOG_CATEGORY LOGC_ACPI -#include <common.h> #include <mapmem.h> #include <tables_csum.h> #include <acpi/acpi_table.h> #include <dm/acpi.h> +#include <linux/errno.h> +#include <linux/string.h> +#include <linux/types.h> int acpi_create_mcfg_mmconfig(struct acpi_mcfg_mmconfig *mmconfig, u32 base, u16 seg_nr, u8 start, u8 end) diff --git a/lib/acpi/ssdt.c b/lib/acpi/ssdt.c index 659c1aad40..b0a96f846e 100644 --- a/lib/acpi/ssdt.c +++ b/lib/acpi/ssdt.c @@ -7,10 +7,11 @@ #define LOG_CATEGORY LOGC_ACPI -#include <common.h> #include <acpi/acpi_table.h> #include <dm/acpi.h> #include <tables_csum.h> +#include <linux/errno.h> +#include <linux/string.h> int acpi_write_ssdt(struct acpi_ctx *ctx, const struct acpi_writer *entry) { @@ -18,10 +19,9 @@ int acpi_write_ssdt(struct acpi_ctx *ctx, const struct acpi_writer *entry) int ret; ssdt = ctx->current; - memset((void *)ssdt, '\0', sizeof(struct acpi_table_header)); + memset(ssdt, '\0', sizeof(struct acpi_table_header)); acpi_fill_header(ssdt, "SSDT"); - memcpy(ssdt->oem_table_id, OEM_TABLE_ID, sizeof(ssdt->oem_table_id)); ssdt->revision = acpi_get_table_revision(ACPITAB_SSDT); ssdt->aslc_revision = 1; ssdt->length = sizeof(struct acpi_table_header); |