Some pretty printing for ACPIVERBOSE.

This commit is contained in:
jruoho 2010-04-22 21:58:08 +00:00
parent 871c771cc1
commit bdb6986f24
3 changed files with 40 additions and 66 deletions

View File

@ -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 bool acpi_resume(device_t, const pmf_qual_t *);
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 @@ acpi_build_tree(struct acpi_softc *sc)
(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 @@ acpi_print_tree(struct acpi_devnode *ad, uint32_t level)
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 @@ acpi_rescan_capabilities(struct acpi_softc *sc)
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");
}
}
}

View File

@ -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 @@ ACPI_MODULE_NAME ("acpi_pci")
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_pciroot_bus_callback(ACPI_RESOURCE *res, void *context)
}
/*
* 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 @@ acpi_pcidev_scan_rec(struct acpi_devnode *ad)
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 @@ acpi_pcidev_ppb_downbus(uint16_t segment, uint16_t bus, uint16_t device,
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("%s@%"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:
*

View File

@ -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,