Lean Sheng Tan has submitted this change. ( https://review.coreboot.org/c/coreboot/+/79217?usp=email )
Change subject: acpigen.c: Add resource consumer functions for mmio ......................................................................
acpigen.c: Add resource consumer functions for mmio
Signed-off-by: Arthur Heymans arthur@aheymans.xyz Change-Id: Id9e4adcd976e1f56ef7f502d9df16dbefce95c3e Reviewed-on: https://review.coreboot.org/c/coreboot/+/79217 Reviewed-by: Nico Huber nico.h@gmx.de Reviewed-by: Tim Wawrzynczak inforichland@gmail.com Tested-by: build bot (Jenkins) no-reply@coreboot.org --- M src/acpi/acpigen.c M src/include/acpi/acpigen.h 2 files changed, 39 insertions(+), 26 deletions(-)
Approvals: Tim Wawrzynczak: Looks good to me, approved build bot (Jenkins): Verified Nico Huber: Looks good to me, but someone else must approve
diff --git a/src/acpi/acpigen.c b/src/acpi/acpigen.c index fe36113..ac95026 100644 --- a/src/acpi/acpigen.c +++ b/src/acpi/acpigen.c @@ -2296,42 +2296,54 @@ io_limit - io_base + 1); /* length */ }
-static void acpigen_resource_producer_mmio32(u32 mmio_base, u32 mmio_limit, u16 type_flags) +static void acpigen_resource_mmio32(u32 mmio_base, u32 mmio_limit, u16 gen_flags, + u16 type_flags) { acpigen_resource_dword(RSRC_TYPE_MEM, /* res_type */ - ADDR_SPACE_GENERAL_FLAG_MAX_FIXED - | ADDR_SPACE_GENERAL_FLAG_MIN_FIXED - | ADDR_SPACE_GENERAL_FLAG_DEC_POS - | ADDR_SPACE_GENERAL_FLAG_PRODUCER, /* gen_flags */ - type_flags, /* type_flags */ - 0, /* gran */ - mmio_base, /* range_min */ - mmio_limit, /* range_max */ - 0x0, /* translation */ - mmio_limit - mmio_base + 1); /* length */ + gen_flags, /* gen_flags */ + type_flags, /* type_flags */ + 0, /* gran */ + mmio_base, /* range_min */ + mmio_limit, /* range_max */ + 0x0, /* translation */ + mmio_limit - mmio_base + 1); /* length */ }
-static void acpigen_resource_producer_mmio64(u64 mmio_base, u64 mmio_limit, u16 type_flags) +static void acpigen_resource_mmio64(u64 mmio_base, u64 mmio_limit, u16 gen_flags, + u16 type_flags) { acpigen_resource_qword(RSRC_TYPE_MEM, /* res_type */ - ADDR_SPACE_GENERAL_FLAG_MAX_FIXED - | ADDR_SPACE_GENERAL_FLAG_MIN_FIXED - | ADDR_SPACE_GENERAL_FLAG_DEC_POS - | ADDR_SPACE_GENERAL_FLAG_PRODUCER, /* gen_flags */ - type_flags, /* type_flags */ - 0, /* gran */ - mmio_base, /* range_min */ - mmio_limit, /* range_max */ - 0x0, /* translation */ - mmio_limit - mmio_base + 1); /* length */ + gen_flags, /* gen_flags */ + type_flags, /* type_flags */ + 0, /* gran */ + mmio_base, /* range_min */ + mmio_limit, /* range_max */ + 0x0, /* translation */ + mmio_limit - mmio_base + 1); /* length */ +} + +static void acpigen_resource_mmio(u64 mmio_base, u64 mmio_limit, bool is_producer, u16 type_flags) +{ + const u16 gen_flags = ADDR_SPACE_GENERAL_FLAG_MAX_FIXED + | ADDR_SPACE_GENERAL_FLAG_MIN_FIXED + | ADDR_SPACE_GENERAL_FLAG_DEC_POS + | (is_producer ? ADDR_SPACE_GENERAL_FLAG_PRODUCER + : ADDR_SPACE_GENERAL_FLAG_CONSUMER); + + if (mmio_base < 4ULL * GiB && mmio_limit < 4ULL * GiB) + acpigen_resource_mmio32(mmio_base, mmio_limit, gen_flags, type_flags); + else + acpigen_resource_mmio64(mmio_base, mmio_limit, gen_flags, type_flags); }
void acpigen_resource_producer_mmio(u64 mmio_base, u64 mmio_limit, u16 type_flags) { - if (mmio_base < 4ULL * GiB && mmio_limit < 4ULL * GiB) - acpigen_resource_producer_mmio32(mmio_base, mmio_limit, type_flags); - else - acpigen_resource_producer_mmio64(mmio_base, mmio_limit, type_flags); + acpigen_resource_mmio(mmio_base, mmio_limit, true, type_flags); +} + +void acpigen_resource_consumer_mmio(u64 mmio_base, u64 mmio_limit, u16 type_flags) +{ + acpigen_resource_mmio(mmio_base, mmio_limit, false, type_flags); }
void acpigen_write_ADR(uint64_t adr) diff --git a/src/include/acpi/acpigen.h b/src/include/acpi/acpigen.h index 346ae73..7a5be51 100644 --- a/src/include/acpi/acpigen.h +++ b/src/include/acpi/acpigen.h @@ -691,6 +691,7 @@ void acpigen_resource_producer_bus_number(u16 bus_base, u16 bus_limit); void acpigen_resource_producer_io(u16 io_base, u16 io_limit); void acpigen_resource_producer_mmio(u64 mmio_base, u64 mmio_limit, u16 type_flags); +void acpigen_resource_consumer_mmio(u64 mmio_base, u64 mmio_limit, u16 type_flags);
/* Emits Notify(namestr, value) */ void acpigen_notify(const char *namestr, int value);