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 find a PCI root bridge by seg...



details:   https://anonhg.NetBSD.org/src/rev/e6b80c1ae322
branches:  trunk
changeset: 836393:e6b80c1ae322
user:      jmcneill <jmcneill%NetBSD.org@localhost>
date:      Mon Oct 15 10:00:30 2018 +0000

description:
Add a function to find a PCI root bridge by segment and bus number.

diffstat:

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

diffs (68 lines):

diff -r 28050592551c -r e6b80c1ae322 sys/dev/acpi/acpi_pci.c
--- a/sys/dev/acpi/acpi_pci.c   Mon Oct 15 09:27:30 2018 +0000
+++ b/sys/dev/acpi/acpi_pci.c   Mon Oct 15 10:00:30 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_pci.c,v 1.22 2018/05/05 17:16:23 christos Exp $ */
+/* $NetBSD: acpi_pci.c,v 1.23 2018/10/15 10:00:30 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.22 2018/05/05 17:16:23 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_pci.c,v 1.23 2018/10/15 10:00:30 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/device.h>
@@ -383,6 +383,33 @@
        return NULL;
 }
 
+/*
+ * acpi_pciroot_find:
+ *
+ *     Finds a PCI root bridge in the ACPI name space.
+ *
+ *     Returns an ACPI device node on success and NULL on failure.
+ */
+struct acpi_devnode *
+acpi_pciroot_find(uint16_t segment, uint16_t bus)
+{
+       struct acpi_softc *sc = acpi_softc;
+       struct acpi_devnode *ad;
+
+       if (sc == NULL)
+               return NULL;
+
+       SIMPLEQ_FOREACH(ad, &sc->ad_head, ad_list) {
+
+               if (ad->ad_pciinfo != NULL &&
+                   (ad->ad_pciinfo->ap_flags & ACPI_PCI_INFO_BRIDGE) &&
+                   ad->ad_pciinfo->ap_segment == segment &&
+                   ad->ad_pciinfo->ap_bus == bus)
+                       return ad;
+       }
+
+       return NULL;
+}
 
 /*
  * acpi_pcidev_find_dev:
diff -r 28050592551c -r e6b80c1ae322 sys/dev/acpi/acpi_pci.h
--- a/sys/dev/acpi/acpi_pci.h   Mon Oct 15 09:27:30 2018 +0000
+++ b/sys/dev/acpi/acpi_pci.h   Mon Oct 15 10:00:30 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_pci.h,v 1.8 2010/12/31 10:56:39 jruoho Exp $ */
+/* $NetBSD: acpi_pci.h,v 1.9 2018/10/15 10:00:30 jmcneill Exp $ */
 
 /*
  * Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -37,5 +37,6 @@
 struct acpi_devnode    *acpi_pcidev_find(uint16_t, uint16_t,
                                          uint16_t, uint16_t);
 device_t                acpi_pcidev_find_dev(struct acpi_devnode *);
+struct acpi_devnode    *acpi_pciroot_find(uint16_t, uint16_t);
 
 #endif /* !_SYS_DEV_ACPI_ACPI_PCI_H */



Home | Main Index | Thread Index | Old Index