Module Name:    src
Committed By:   gsutre
Date:           Wed Aug 11 10:32:42 UTC 2010

Modified Files:
        src/sys/dev/acpi: acpi_verbose.c

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

ok jruoho@


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/dev/acpi/acpi_verbose.c

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_verbose.c
diff -u src/sys/dev/acpi/acpi_verbose.c:1.9 src/sys/dev/acpi/acpi_verbose.c:1.10
--- src/sys/dev/acpi/acpi_verbose.c:1.9	Sat Aug  7 18:59:53 2010
+++ src/sys/dev/acpi/acpi_verbose.c	Wed Aug 11 10:32:42 2010
@@ -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;
+}

Reply via email to