Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/acpi acpi: Add acpi_resource_parse_any().



details:   https://anonhg.NetBSD.org/src/rev/ce62db663b8b
branches:  trunk
changeset: 985075:ce62db663b8b
user:      jmcneill <jmcneill%NetBSD.org@localhost>
date:      Sat Aug 07 18:39:40 2021 +0000

description:
acpi: Add acpi_resource_parse_any().

Like acpi_resource_parse(), but doesn't exclude "produced" resources.

diffstat:

 sys/dev/acpi/acpi_resource.c |  54 +++++++++++++++++++++++++++++++++++++++----
 sys/dev/acpi/acpivar.h       |   4 ++-
 2 files changed, 52 insertions(+), 6 deletions(-)

diffs (128 lines):

diff -r 188b5dd54bd4 -r ce62db663b8b sys/dev/acpi/acpi_resource.c
--- a/sys/dev/acpi/acpi_resource.c      Sat Aug 07 18:16:42 2021 +0000
+++ b/sys/dev/acpi/acpi_resource.c      Sat Aug 07 18:39:40 2021 +0000
@@ -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 @@
 
 struct resource_parse_callback_arg {
        const struct acpi_resource_parse_ops *ops;
+       bool include_producer;
        device_t dev;
        void *context;
 };
@@ -247,7 +248,8 @@
        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 @@
 #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 @@
                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 @@
                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_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.
diff -r 188b5dd54bd4 -r ce62db663b8b sys/dev/acpi/acpivar.h
--- a/sys/dev/acpi/acpivar.h    Sat Aug 07 18:16:42 2021 +0000
+++ b/sys/dev/acpi/acpivar.h    Sat Aug 07 18:39:40 2021 +0000
@@ -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 @@
 
 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 *);
 



Home | Main Index | Thread Index | Old Index