Module Name:    src
Committed By:   jruoho
Date:           Thu Apr 22 21:58:09 UTC 2010

Modified Files:
        src/sys/dev/acpi: acpi.c acpi_pci.c acpi_pci.h

Log Message:
Some pretty printing for ACPIVERBOSE.


To generate a diff of this commit:
cvs rdiff -u -r1.181 -r1.182 src/sys/dev/acpi/acpi.c
cvs rdiff -u -r1.8 -r1.9 src/sys/dev/acpi/acpi_pci.c
cvs rdiff -u -r1.4 -r1.5 src/sys/dev/acpi/acpi_pci.h

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.c
diff -u src/sys/dev/acpi/acpi.c:1.181 src/sys/dev/acpi/acpi.c:1.182
--- src/sys/dev/acpi/acpi.c:1.181	Thu Apr 22 18:40:09 2010
+++ src/sys/dev/acpi/acpi.c	Thu Apr 22 21:58:08 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: acpi.c,v 1.181 2010/04/22 18:40:09 jruoho Exp $	*/
+/*	$NetBSD: acpi.c,v 1.182 2010/04/22 21:58:08 jruoho Exp $	*/
 
 /*-
  * Copyright (c) 2003, 2007 The NetBSD Foundation, Inc.
@@ -65,7 +65,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: acpi.c,v 1.181 2010/04/22 18:40:09 jruoho Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi.c,v 1.182 2010/04/22 21:58:08 jruoho Exp $");
 
 #include "opt_acpi.h"
 #include "opt_pcifixup.h"
@@ -169,7 +169,7 @@
 
 static void		acpi_build_tree(struct acpi_softc *);
 
-#ifdef ACPI_DEBUG
+#ifdef ACPIVERBOSE
 static void		acpi_print_tree(struct acpi_devnode *, uint32_t);
 #endif
 
@@ -597,17 +597,18 @@
 	(void)AcpiWalkNamespace(ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, UINT32_MAX,
 	    acpi_make_devnode, acpi_make_devnode_post, &awc, NULL);
 
-#ifdef ACPI_DEBUG
-	acpi_print_tree(sc->sc_root, 0);
-#endif
-
 	acpi_rescan1(sc, NULL, NULL);
 	acpi_rescan_capabilities(sc);
 
-	acpi_pcidev_scan(sc);
+	(void)acpi_pcidev_scan(sc->sc_root);
+
+#ifdef ACPIVERBOSE
+	aprint_normal("\n");
+	acpi_print_tree(sc->sc_root, 0);
+#endif
 }
 
-#ifdef ACPI_DEBUG
+#ifdef ACPIVERBOSE
 static void
 acpi_print_tree(struct acpi_devnode *ad, uint32_t level)
 {
@@ -615,9 +616,28 @@
 	uint32_t i;
 
 	for (i = 0; i < level; i++)
-		aprint_normal("           ");
+		aprint_normal("    ");
 
-	aprint_normal("[%02u] %-5s\n", ad->ad_type, ad->ad_name);
+	aprint_normal("%-5s [%02u] [%c%c] ", ad->ad_name, ad->ad_type,
+	    ((ad->ad_flags & ACPI_DEVICE_POWER)  != 0) ? 'P' : 'x',
+	    ((ad->ad_flags & ACPI_DEVICE_WAKEUP) != 0) ? 'W' : 'x');
+
+	if (ad->ad_pciinfo == NULL)
+		aprint_normal("@ xx:xx:xx:xx ");
+	else {
+		aprint_normal("@ 0x%02x:0x%02x:0x%02x:0x%02x ",
+		    ad->ad_pciinfo->ap_segment, ad->ad_pciinfo->ap_bus,
+		    ad->ad_pciinfo->ap_device, ad->ad_pciinfo->ap_function);
+
+		if ((ad->ad_devinfo->Flags & ACPI_PCI_ROOT_BRIDGE) != 0)
+			aprint_normal("[R] ");
+
+		if (ad->ad_pciinfo->ap_bridge != false)
+			aprint_normal("[B] -> 0x%02X",
+			    ad->ad_pciinfo->ap_downbus);
+	}
+
+	aprint_normal("\n\n");
 
 	SIMPLEQ_FOREACH(child, &ad->ad_child_head, ad_child_list)
 	    acpi_print_tree(child, level + 1);
@@ -1047,18 +1067,6 @@
 			ad->ad_flags |= ACPI_DEVICE_WAKEUP;
 			acpi_wakedev_add(ad);
 		}
-
-		if (ad->ad_flags != 0) {
-			aprint_debug_dev(sc->sc_dev, "%-5s ", ad->ad_name);
-
-			if ((ad->ad_flags & ACPI_DEVICE_WAKEUP) != 0)
-				aprint_debug("wake-up ");
-
-			if ((ad->ad_flags & ACPI_DEVICE_POWER) != 0)
-				aprint_debug("power (D%d) ", ad->ad_state);
-
-			aprint_debug("\n");
-		}
 	}
 }
 

Index: src/sys/dev/acpi/acpi_pci.c
diff -u src/sys/dev/acpi/acpi_pci.c:1.8 src/sys/dev/acpi/acpi_pci.c:1.9
--- src/sys/dev/acpi/acpi_pci.c:1.8	Thu Apr 22 15:25:46 2010
+++ src/sys/dev/acpi/acpi_pci.c	Thu Apr 22 21:58:08 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_pci.c,v 1.8 2010/04/22 15:25:46 jruoho Exp $ */
+/* $NetBSD: acpi_pci.c,v 1.9 2010/04/22 21:58:08 jruoho Exp $ */
 
 /*
  * Copyright (c) 2009, 2010 The NetBSD Foundation, Inc.
@@ -33,7 +33,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: acpi_pci.c,v 1.8 2010/04/22 15:25:46 jruoho Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_pci.c,v 1.9 2010/04/22 21:58:08 jruoho Exp $");
 
 #include <sys/param.h>
 #include <sys/device.h>
@@ -57,8 +57,6 @@
 static ACPI_STATUS	  acpi_pcidev_pciroot_bus(ACPI_HANDLE, uint16_t *);
 static ACPI_STATUS	  acpi_pcidev_pciroot_bus_callback(ACPI_RESOURCE *,
 							   void *);
-static ACPI_STATUS	  acpi_pcidev_scan_rec(struct acpi_devnode *);
-
 
 /*
  * Regarding PCI Segment Groups, the ACPI spec says (cf. ACPI 4.0, p. 277):
@@ -154,15 +152,15 @@
 }
 
 /*
- * acpi_pcidev_scan_rec:
+ * acpi_pcidev_scan:
  *
  *	Scan the ACPI device tree for PCI devices.  A node is detected as a
  *	PCI device if it has an ancestor that is a PCI root bridge and such
  *	that all intermediate nodes are PCI-to-PCI bridges.  Depth-first
  *	recursive implementation.
  */
-static ACPI_STATUS
-acpi_pcidev_scan_rec(struct acpi_devnode *ad)
+ACPI_STATUS
+acpi_pcidev_scan(struct acpi_devnode *ad)
 {
 	struct acpi_devnode *child;
 	struct acpi_pci_info *ap;
@@ -239,9 +237,10 @@
 
 		goto rec;
 	}
+
 rec:
 	SIMPLEQ_FOREACH(child, &ad->ad_child_head, ad_child_list) {
-		rv = acpi_pcidev_scan_rec(child);
+		rv = acpi_pcidev_scan(child);
 
 		if (ACPI_FAILURE(rv))
 			return rv;
@@ -298,39 +297,6 @@
 	return AE_OK;
 }
 
-static void
-acpi_pcidev_print(struct acpi_devnode *ad)
-{
-	aprint_debug(" ");
-	if (ad->ad_devinfo->Flags & ACPI_PCI_ROOT_BRIDGE)
-		aprint_debug("*");
-	aprint_debug("%...@%"PRIx16":%"PRIx16":%"PRIx16":%"PRIx16,
-	    ad->ad_name,
-	    ad->ad_pciinfo->ap_segment,
-	    ad->ad_pciinfo->ap_bus,
-	    ad->ad_pciinfo->ap_device,
-	    ad->ad_pciinfo->ap_function);
-	if (ad->ad_pciinfo->ap_bridge)
-		aprint_debug(">%"PRIx16, ad->ad_pciinfo->ap_downbus);
-}
-
-void
-acpi_pcidev_scan(struct acpi_softc *sc)
-{
-	struct acpi_devnode *ad;
-
-	acpi_pcidev_scan_rec(sc->sc_root);
-	aprint_debug_dev(sc->sc_dev, "pci devices:");
-
-	SIMPLEQ_FOREACH(ad, &sc->ad_head, ad_list) {
-
-		if (ad->ad_pciinfo != NULL)
-			acpi_pcidev_print(ad);
-	}
-
-	aprint_debug("\n");
-}
-
 /*
  * acpi_pcidev_find:
  *

Index: src/sys/dev/acpi/acpi_pci.h
diff -u src/sys/dev/acpi/acpi_pci.h:1.4 src/sys/dev/acpi/acpi_pci.h:1.5
--- src/sys/dev/acpi/acpi_pci.h:1.4	Thu Apr 22 14:50:31 2010
+++ src/sys/dev/acpi/acpi_pci.h	Thu Apr 22 21:58:08 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_pci.h,v 1.4 2010/04/22 14:50:31 jruoho Exp $ */
+/* $NetBSD: acpi_pci.h,v 1.5 2010/04/22 21:58:08 jruoho Exp $ */
 
 /*
  * Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 #ifndef _SYS_DEV_ACPI_ACPI_PCI_H
 #define _SYS_DEV_ACPI_ACPI_PCI_H
 
-void		acpi_pcidev_scan(struct acpi_softc *);
+ACPI_STATUS	acpi_pcidev_scan(struct acpi_devnode *);
 ACPI_STATUS	acpi_pcidev_find(uint16_t, uint16_t, uint16_t, uint16_t,
 		    struct acpi_devnode **);
 ACPI_STATUS	acpi_pcidev_ppb_downbus(uint16_t, uint16_t, uint16_t, uint16_t,

Reply via email to