Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/acpi Add a function to report whether the operating ...



details:   https://anonhg.NetBSD.org/src/rev/bc89c55cbd82
branches:  trunk
changeset: 836512:bc89c55cbd82
user:      jmcneill <jmcneill%NetBSD.org@localhost>
date:      Sun Oct 21 11:04:26 2018 +0000

description:
Add a function to report whether the operating system may ignore the boot
configuration of PCI resources for a given bus.

diffstat:

 sys/dev/acpi/acpi_pci.c |  63 +++++++++++++++++++++++++++++++++++++++++++++++-
 sys/dev/acpi/acpi_pci.h |   3 +-
 2 files changed, 63 insertions(+), 3 deletions(-)

diffs (104 lines):

diff -r cf00e23b67b6 -r bc89c55cbd82 sys/dev/acpi/acpi_pci.c
--- a/sys/dev/acpi/acpi_pci.c   Sun Oct 21 07:08:40 2018 +0000
+++ b/sys/dev/acpi/acpi_pci.c   Sun Oct 21 11:04:26 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_pci.c,v 1.23 2018/10/15 10:00:30 jmcneill Exp $ */
+/* $NetBSD: acpi_pci.c,v 1.24 2018/10/21 11:04:26 jmcneill Exp $ */
 
 /*
  * Copyright (c) 2009, 2010 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: acpi_pci.c,v 1.23 2018/10/15 10:00:30 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_pci.c,v 1.24 2018/10/21 11:04:26 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/device.h>
@@ -58,6 +58,14 @@
                                                           void *);
 
 /*
+ * UUID for _DSM control method, from PCI Firmware Specification.
+ */
+static UINT8 acpi_pci_dsm_uuid[ACPI_UUID_LENGTH] = {
+       0xd0, 0x37, 0xc9, 0xe5, 0x53, 0x35, 0x7a, 0x4d,
+       0x91, 0x17, 0xea, 0x4d, 0x19, 0xc3, 0x43, 0x4d
+};
+
+/*
  * Regarding PCI Segment Groups (ACPI 4.0, p. 277):
  *
  * "The optional _SEG object is located under a PCI host bridge and
@@ -459,3 +467,54 @@
 
        return dv;
 }
+
+/*
+ * acpi_pci_ignore_boot_config:
+ *
+ *     Returns 1 if the operating system may ignore the boot configuration
+ *     of PCI resources.
+ */
+ACPI_INTEGER
+acpi_pci_ignore_boot_config(ACPI_HANDLE handle)
+{
+       ACPI_OBJECT_LIST objs;
+       ACPI_OBJECT obj[4], *pobj;
+       ACPI_BUFFER buf;
+       ACPI_INTEGER ret;
+
+       objs.Count = 4;
+       objs.Pointer = obj;
+       obj[0].Type = ACPI_TYPE_BUFFER;
+       obj[0].Buffer.Length = ACPI_UUID_LENGTH;
+       obj[0].Buffer.Pointer = acpi_pci_dsm_uuid;
+       obj[1].Type = ACPI_TYPE_INTEGER;
+       obj[1].Integer.Value = 1;
+       obj[2].Type = ACPI_TYPE_INTEGER;
+       obj[2].Integer.Value = 5;
+       obj[3].Type = ACPI_TYPE_PACKAGE;
+       obj[3].Package.Count = 0;
+       obj[3].Package.Elements = NULL;
+
+       buf.Pointer = NULL;
+       buf.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
+
+       if (ACPI_FAILURE(AcpiEvaluateObject(handle, "_DSM", &objs, &buf)) || buf.Pointer == NULL)
+               return 0;
+
+       ret = 0;
+
+       pobj = buf.Pointer;
+       switch (pobj->Type) {
+       case ACPI_TYPE_INTEGER:
+               ret = pobj->Integer.Value;
+               break;
+       case ACPI_TYPE_PACKAGE:
+               if (pobj->Package.Count == 1 && pobj->Package.Elements[0].Type == ACPI_TYPE_INTEGER)
+                       ret = pobj->Package.Elements[0].Integer.Value;
+               break;
+       }
+
+       ACPI_FREE(buf.Pointer);
+
+       return ret;
+}
diff -r cf00e23b67b6 -r bc89c55cbd82 sys/dev/acpi/acpi_pci.h
--- a/sys/dev/acpi/acpi_pci.h   Sun Oct 21 07:08:40 2018 +0000
+++ b/sys/dev/acpi/acpi_pci.h   Sun Oct 21 11:04:26 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_pci.h,v 1.9 2018/10/15 10:00:30 jmcneill Exp $ */
+/* $NetBSD: acpi_pci.h,v 1.10 2018/10/21 11:04:26 jmcneill Exp $ */
 
 /*
  * Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -38,5 +38,6 @@
                                          uint16_t, uint16_t);
 device_t                acpi_pcidev_find_dev(struct acpi_devnode *);
 struct acpi_devnode    *acpi_pciroot_find(uint16_t, uint16_t);
+ACPI_INTEGER            acpi_pci_ignore_boot_config(ACPI_HANDLE);
 
 #endif /* !_SYS_DEV_ACPI_ACPI_PCI_H */



Home | Main Index | Thread Index | Old Index