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_print_tree: print ACPI and PCI autoconf(9)...



details:   https://anonhg.NetBSD.org/src/rev/75d1ededa1a8
branches:  trunk
changeset: 757024:75d1ededa1a8
user:      gsutre <gsutre%NetBSD.org@localhost>
date:      Wed Aug 11 10:32:42 2010 +0000

description:
acpi_print_tree: print ACPI and PCI autoconf(9) device names.

ok jruoho@

diffstat:

 sys/dev/acpi/acpi_verbose.c |  50 ++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 47 insertions(+), 3 deletions(-)

diffs (106 lines):

diff -r f53ab87b891d -r 75d1ededa1a8 sys/dev/acpi/acpi_verbose.c
--- a/sys/dev/acpi/acpi_verbose.c       Wed Aug 11 10:30:30 2010 +0000
+++ b/sys/dev/acpi/acpi_verbose.c       Wed Aug 11 10:32:42 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: acpi_verbose.c,v 1.9 2010/08/07 18:59:53 jruoho Exp $ */
+/*     $NetBSD: acpi_verbose.c,v 1.10 2010/08/11 10:32:42 gsutre Exp $ */
 
 /*-
  * Copyright (c) 2003, 2007, 2010 The NetBSD Foundation, Inc.
@@ -65,7 +65,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: acpi_verbose.c,v 1.9 2010/08/07 18:59:53 jruoho Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_verbose.c,v 1.10 2010/08/11 10:32:42 gsutre Exp $");
 
 #include <sys/param.h>
 #include <sys/device.h>
@@ -77,8 +77,12 @@
 #include <dev/acpi/acpivar.h>
 #include <dev/acpi/acpidevs_data.h>
 
+#include <dev/pci/pcivar.h>
+
 #include <prop/proplib.h>
 
+#include "locators.h"
+
 static bool       acpiverbose_modcmd_prop(prop_dictionary_t);
 
 void              acpi_print_verbose_real(struct acpi_softc *);
@@ -88,6 +92,7 @@
 static void       acpi_print_fadt(struct acpi_softc *);
 static void       acpi_print_devnodes(struct acpi_softc *);
 static void       acpi_print_tree(struct acpi_devnode *, uint32_t);
+static device_t           device_find_by_acpi_pci_info(const struct acpi_pci_info *);
 
 extern ACPI_TABLE_HEADER *madt_header;
 
@@ -455,6 +460,7 @@
 acpi_print_tree(struct acpi_devnode *ad, uint32_t level)
 {
        struct acpi_devnode *child;
+       device_t pcidev;
        uint32_t i;
 
        for (i = 0; i < level; i++)
@@ -464,6 +470,9 @@
            ((ad->ad_flags & ACPI_DEVICE_POWER)  != 0) ? 'P' : ' ',
            ((ad->ad_flags & ACPI_DEVICE_WAKEUP) != 0) ? 'W' : ' ');
 
+       if (ad->ad_device != NULL)
+               aprint_normal("<%s> ", device_xname(ad->ad_device));
+
        if (ad->ad_pciinfo != NULL) {
 
                aprint_normal("(PCI) @ 0x%02X:0x%02X:0x%02X:0x%02X ",
@@ -474,8 +483,12 @@
                        aprint_normal("[R] ");
 
                if (ad->ad_pciinfo->ap_bridge != false)
-                       aprint_normal("[B] -> 0x%02X",
+                       aprint_normal("[B] -> 0x%02X ",
                            ad->ad_pciinfo->ap_downbus);
+
+               pcidev = device_find_by_acpi_pci_info(ad->ad_pciinfo);
+               if (pcidev != NULL)
+                       aprint_normal("<%s>", device_xname(pcidev));
        }
 
        aprint_normal("\n");
@@ -483,3 +496,34 @@
        SIMPLEQ_FOREACH(child, &ad->ad_child_head, ad_child_list)
            acpi_print_tree(child, level + 1);
 }
+
+/*
+ * device_find_by_acpi_pci_info:
+ *
+ *     Returns the device corresponding to the given PCI info, or NULL
+ *     if it doesn't exist.
+ */
+static device_t
+device_find_by_acpi_pci_info(const struct acpi_pci_info *ap)
+{
+       device_t dv, pr;
+       struct pci_softc *pci;
+       deviter_t di;
+
+       for (dv = deviter_first(&di, DEVITER_F_ROOT_FIRST); dv != NULL;
+            dv = deviter_next(&di)) {
+               pr = device_parent(dv);
+               if ((pr == NULL) || !device_is_a(pr, "pci"))
+                       continue;
+               if (dv->dv_locators == NULL)    /* This should not happen. */
+                       continue;
+               pci = device_private(pr);
+               if (pci->sc_bus == ap->ap_bus &&
+                   device_locator(dv, PCICF_DEV) == ap->ap_device &&
+                   device_locator(dv, PCICF_FUNCTION) == ap->ap_function)
+                       break;
+       }
+       deviter_release(&di);
+
+       return dv;
+}



Home | Main Index | Thread Index | Old Index