Module Name: src Committed By: jmcneill Date: Sat Aug 7 18:39:40 UTC 2021
Modified Files: src/sys/dev/acpi: acpi_resource.c acpivar.h Log Message: acpi: Add acpi_resource_parse_any(). Like acpi_resource_parse(), but doesn't exclude "produced" resources. To generate a diff of this commit: cvs rdiff -u -r1.41 -r1.42 src/sys/dev/acpi/acpi_resource.c cvs rdiff -u -r1.86 -r1.87 src/sys/dev/acpi/acpivar.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/dev/acpi/acpi_resource.c diff -u src/sys/dev/acpi/acpi_resource.c:1.41 src/sys/dev/acpi/acpi_resource.c:1.42 --- src/sys/dev/acpi/acpi_resource.c:1.41 Tue Dec 31 17:26:04 2019 +++ src/sys/dev/acpi/acpi_resource.c Sat Aug 7 18:39:40 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: acpi_resource.c,v 1.41 2019/12/31 17:26:04 jmcneill Exp $ */ +/* $NetBSD: acpi_resource.c,v 1.42 2021/08/07 18:39:40 jmcneill Exp $ */ /* * Copyright 2001 Wasabi Systems, Inc. @@ -67,7 +67,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: acpi_resource.c,v 1.41 2019/12/31 17:26:04 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: acpi_resource.c,v 1.42 2021/08/07 18:39:40 jmcneill Exp $"); #include <sys/param.h> #include <sys/device.h> @@ -83,6 +83,7 @@ static ACPI_STATUS acpi_resource_parse_c struct resource_parse_callback_arg { const struct acpi_resource_parse_ops *ops; + bool include_producer; device_t dev; void *context; }; @@ -247,7 +248,8 @@ acpi_resource_parse_callback(ACPI_RESOUR case ACPI_RESOURCE_TYPE_ADDRESS32: /* XXX Only fixed size supported for now */ if (res->Data.Address32.Address.AddressLength == 0 || - res->Data.Address32.ProducerConsumer != ACPI_CONSUMER) + (!arg->include_producer && + res->Data.Address32.ProducerConsumer != ACPI_CONSUMER)) break; #define ADDRESS32_FIXED2(r) \ ((r)->Data.Address32.MinAddressFixed == ACPI_ADDRESS_FIXED && \ @@ -302,7 +304,8 @@ acpi_resource_parse_callback(ACPI_RESOUR #ifdef _LP64 /* XXX Only fixed size supported for now */ if (res->Data.Address64.Address.AddressLength == 0 || - res->Data.Address64.ProducerConsumer != ACPI_CONSUMER) + (!arg->include_producer && + res->Data.Address64.ProducerConsumer != ACPI_CONSUMER)) break; #define ADDRESS64_FIXED2(r) \ ((r)->Data.Address64.MinAddressFixed == ACPI_ADDRESS_FIXED && \ @@ -357,7 +360,8 @@ acpi_resource_parse_callback(ACPI_RESOUR break; case ACPI_RESOURCE_TYPE_EXTENDED_IRQ: - if (res->Data.ExtendedIrq.ProducerConsumer != ACPI_CONSUMER) { + if (!arg->include_producer && + res->Data.ExtendedIrq.ProducerConsumer != ACPI_CONSUMER) { ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, "ignored ExtIRQ producer\n")); break; @@ -420,6 +424,7 @@ acpi_resource_parse(device_t dev, ACPI_H cbarg.context = arg; cbarg.ops = ops; cbarg.dev = dev; + cbarg.include_producer = false; rv = AcpiWalkResources(handle, path, acpi_resource_parse_callback, &cbarg); @@ -436,6 +441,45 @@ acpi_resource_parse(device_t dev, ACPI_H } /* + * acpi_resource_parse_any: + * + * Parse a device node's resources and fill them in for the + * client. Like acpi_resource_parse, but doesn't skip ResourceProducer + * type resources. + */ +ACPI_STATUS +acpi_resource_parse_any(device_t dev, ACPI_HANDLE handle, const char *path, + void *arg, const struct acpi_resource_parse_ops *ops) +{ + struct resource_parse_callback_arg cbarg; + ACPI_STATUS rv; + + ACPI_FUNCTION_TRACE(__func__); + + if (ops->init) + (*ops->init)(dev, arg, &cbarg.context); + else + cbarg.context = arg; + cbarg.ops = ops; + cbarg.dev = dev; + cbarg.include_producer = true; + + rv = AcpiWalkResources(handle, path, acpi_resource_parse_callback, + &cbarg); + if (ACPI_FAILURE(rv)) { + aprint_error_dev(dev, "ACPI: unable to get %s resources: %s\n", + path, AcpiFormatException(rv)); + return_ACPI_STATUS(rv); + } + + if (ops->fini) + (*ops->fini)(dev, cbarg.context); + + return_ACPI_STATUS(AE_OK); +} + + +/* * acpi_resource_print: * * Print the resources assigned to a device. Index: src/sys/dev/acpi/acpivar.h diff -u src/sys/dev/acpi/acpivar.h:1.86 src/sys/dev/acpi/acpivar.h:1.87 --- src/sys/dev/acpi/acpivar.h:1.86 Wed May 12 23:22:33 2021 +++ src/sys/dev/acpi/acpivar.h Sat Aug 7 18:39:40 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: acpivar.h,v 1.86 2021/05/12 23:22:33 thorpej Exp $ */ +/* $NetBSD: acpivar.h,v 1.87 2021/08/07 18:39:40 jmcneill Exp $ */ /* * Copyright 2001 Wasabi Systems, Inc. @@ -330,6 +330,8 @@ void acpi_deregister_notify(struct acpi ACPI_STATUS acpi_resource_parse(device_t, ACPI_HANDLE, const char *, void *, const struct acpi_resource_parse_ops *); +ACPI_STATUS acpi_resource_parse_any(device_t, ACPI_HANDLE, const char *, + void *, const struct acpi_resource_parse_ops *); void acpi_resource_print(device_t, struct acpi_resources *); void acpi_resource_cleanup(struct acpi_resources *);