2010-08-07 12:59:51 +04:00
|
|
|
/* $NetBSD: acpi_verbose.c,v 1.7 2010/08/07 08:59:51 jruoho Exp $ */
|
2010-06-01 00:32:28 +04:00
|
|
|
|
|
|
|
/*-
|
2010-08-07 12:59:51 +04:00
|
|
|
* Copyright (c) 2003, 2007, 2010 The NetBSD Foundation, Inc.
|
2010-06-01 00:32:28 +04:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* This code is derived from software contributed to The NetBSD Foundation
|
2010-08-07 12:59:51 +04:00
|
|
|
* by Charles M. Hannum of By Noon Software, Inc, and Jukka Ruohonen.
|
2010-06-01 00:32:28 +04:00
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
|
|
|
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
|
|
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
|
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
|
|
|
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
* POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright 2001, 2003 Wasabi Systems, Inc.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Written by Jason R. Thorpe for Wasabi Systems, Inc.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
|
|
|
* This product includes software developed for the NetBSD Project by
|
|
|
|
* Wasabi Systems, Inc.
|
|
|
|
* 4. The name of Wasabi Systems, Inc. may not be used to endorse
|
|
|
|
* or promote products derived from this software without specific prior
|
|
|
|
* written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
|
|
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
|
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WASABI SYSTEMS, INC
|
|
|
|
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
* POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <sys/cdefs.h>
|
2010-08-07 12:59:51 +04:00
|
|
|
__KERNEL_RCSID(0, "$NetBSD: acpi_verbose.c,v 1.7 2010/08/07 08:59:51 jruoho Exp $");
|
2010-06-01 00:32:28 +04:00
|
|
|
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/device.h>
|
|
|
|
#include <sys/kernel.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/module.h>
|
|
|
|
|
|
|
|
#include <dev/acpi/acpireg.h>
|
|
|
|
#include <dev/acpi/acpivar.h>
|
|
|
|
#include <dev/acpi/acpidevs_data.h>
|
|
|
|
|
2010-08-07 03:38:34 +04:00
|
|
|
void acpi_print_verbose_real(struct acpi_softc *);
|
|
|
|
void acpi_print_dev_real(const char *);
|
2010-08-07 12:59:51 +04:00
|
|
|
static void acpi_print_fadt(struct acpi_softc *);
|
2010-08-07 03:38:34 +04:00
|
|
|
static void acpi_print_devnodes(struct acpi_softc *);
|
|
|
|
static void acpi_print_tree(struct acpi_devnode *, uint32_t);
|
2010-06-01 00:32:28 +04:00
|
|
|
|
2010-08-07 02:45:00 +04:00
|
|
|
MODULE(MODULE_CLASS_MISC, acpiverbose, NULL);
|
2010-06-05 10:07:12 +04:00
|
|
|
|
2010-06-01 00:32:28 +04:00
|
|
|
static int
|
|
|
|
acpiverbose_modcmd(modcmd_t cmd, void *arg)
|
|
|
|
{
|
2010-08-07 03:38:34 +04:00
|
|
|
static void (*saved_print_verbose)(struct acpi_softc *);
|
2010-06-07 05:45:27 +04:00
|
|
|
static void (*saved_print_dev)(const char *);
|
|
|
|
|
2010-06-01 00:32:28 +04:00
|
|
|
switch (cmd) {
|
2010-08-07 03:38:34 +04:00
|
|
|
|
2010-06-01 00:32:28 +04:00
|
|
|
case MODULE_CMD_INIT:
|
2010-08-07 03:38:34 +04:00
|
|
|
saved_print_verbose = acpi_print_verbose;
|
2010-06-07 05:45:27 +04:00
|
|
|
saved_print_dev = acpi_print_dev;
|
2010-08-07 03:38:34 +04:00
|
|
|
acpi_print_verbose = acpi_print_verbose_real;
|
2010-06-01 00:32:28 +04:00
|
|
|
acpi_print_dev = acpi_print_dev_real;
|
2010-07-25 16:54:46 +04:00
|
|
|
acpi_verbose_loaded = 1;
|
2010-06-01 00:32:28 +04:00
|
|
|
return 0;
|
2010-08-07 03:38:34 +04:00
|
|
|
|
2010-06-01 00:32:28 +04:00
|
|
|
case MODULE_CMD_FINI:
|
2010-08-07 03:38:34 +04:00
|
|
|
acpi_print_verbose = saved_print_verbose;
|
2010-06-07 05:45:27 +04:00
|
|
|
acpi_print_dev = saved_print_dev;
|
|
|
|
acpi_verbose_loaded = 0;
|
2010-06-01 00:32:28 +04:00
|
|
|
return 0;
|
2010-08-07 03:38:34 +04:00
|
|
|
|
2010-06-01 00:32:28 +04:00
|
|
|
default:
|
|
|
|
return ENOTTY;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2010-08-07 03:38:34 +04:00
|
|
|
acpi_print_verbose_real(struct acpi_softc *sc)
|
|
|
|
{
|
|
|
|
|
2010-08-07 12:59:51 +04:00
|
|
|
acpi_print_fadt(sc);
|
2010-08-07 03:38:34 +04:00
|
|
|
acpi_print_devnodes(sc);
|
|
|
|
acpi_print_tree(sc->sc_root, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
acpi_print_dev_real(const char *pnpstr)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < __arraycount(acpi_knowndevs); i++) {
|
|
|
|
|
|
|
|
if (strcmp(acpi_knowndevs[i].pnp, pnpstr) == 0)
|
|
|
|
aprint_normal("[%s] ", acpi_knowndevs[i].str);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-08-07 12:59:51 +04:00
|
|
|
static void
|
|
|
|
acpi_print_fadt(struct acpi_softc *sc)
|
|
|
|
{
|
|
|
|
uint32_t i;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* See ACPI 4.0, section 5.2.9.
|
|
|
|
*/
|
|
|
|
struct acpi_fadt {
|
|
|
|
uint32_t fadt_offset;
|
|
|
|
const char *fadt_name;
|
|
|
|
uint64_t fadt_value;
|
|
|
|
};
|
|
|
|
|
|
|
|
const struct acpi_fadt acpi_fadt_table[] = {
|
|
|
|
|
|
|
|
{ 36, "FACS", AcpiGbl_FADT.Facs },
|
|
|
|
{ 40, "DSDT", AcpiGbl_FADT.Dsdt },
|
|
|
|
{ 44, "INT_MODEL", AcpiGbl_FADT.Model },
|
|
|
|
{ 45, "PM_PROFILE", AcpiGbl_FADT.PreferredProfile },
|
|
|
|
{ 46, "SCI_INT", AcpiGbl_FADT.SciInterrupt },
|
|
|
|
{ 48, "SMI_CMD", AcpiGbl_FADT.SmiCommand },
|
|
|
|
{ 52, "ACPI_ENABLE", AcpiGbl_FADT.AcpiEnable },
|
|
|
|
{ 53, "ACPI_DISABLE", AcpiGbl_FADT.AcpiDisable },
|
|
|
|
{ 54, "S4BIOS_REQ", AcpiGbl_FADT.S4BiosRequest },
|
|
|
|
{ 55, "PSTATE_CNT", AcpiGbl_FADT.PstateControl },
|
|
|
|
{ 56, "PM1a_EVT_BLK", AcpiGbl_FADT.Pm1aEventBlock },
|
|
|
|
{ 60, "PM1b_EVT_BLK", AcpiGbl_FADT.Pm1bEventBlock },
|
|
|
|
{ 64, "PM1a_CNT_BLK", AcpiGbl_FADT.Pm1aControlBlock },
|
|
|
|
{ 68, "PM1b_CNT_BLK", AcpiGbl_FADT.Pm1bControlBlock },
|
|
|
|
{ 72, "PM2_CNT_BLK", AcpiGbl_FADT.Pm2ControlBlock },
|
|
|
|
{ 76, "PM_TMR_BLK", AcpiGbl_FADT.PmTimerBlock },
|
|
|
|
{ 80, "GPE0_BLK", AcpiGbl_FADT.Gpe0Block },
|
|
|
|
{ 84, "GPE1_BLK", AcpiGbl_FADT.Gpe1Block },
|
|
|
|
{ 88, "PM1_EVT_LEN", AcpiGbl_FADT.Pm1EventLength },
|
|
|
|
{ 89, "PM1_CNT_LEN", AcpiGbl_FADT.Pm1ControlLength },
|
|
|
|
{ 90, "PM2_CNT_LEN", AcpiGbl_FADT.Pm2ControlLength },
|
|
|
|
{ 91, "PM_TMR_LEN", AcpiGbl_FADT.PmTimerLength },
|
|
|
|
{ 92, "GPE0_BLK_LEN", AcpiGbl_FADT.Gpe0BlockLength },
|
|
|
|
{ 93, "GPE1_BLK_LEN", AcpiGbl_FADT.Gpe1BlockLength },
|
|
|
|
{ 94, "GPE1_BASE", AcpiGbl_FADT.Gpe1Base },
|
|
|
|
{ 95, "CST_CNT", AcpiGbl_FADT.CstControl },
|
|
|
|
{ 96, "P_LVL2_LAT", AcpiGbl_FADT.C2Latency },
|
|
|
|
{ 98, "P_LVL3_LAT", AcpiGbl_FADT.C3Latency },
|
|
|
|
{ 100, "FLUSH_SIZE", AcpiGbl_FADT.FlushSize },
|
|
|
|
{ 102, "FLUSH_STRIDE", AcpiGbl_FADT.FlushStride },
|
|
|
|
{ 104, "DUTY_OFFSET", AcpiGbl_FADT.DutyOffset },
|
|
|
|
{ 105, "DUTY_WIDTH", AcpiGbl_FADT.DutyWidth },
|
|
|
|
{ 106, "DAY_ALRM", AcpiGbl_FADT.DayAlarm },
|
|
|
|
{ 107, "MON_ALRM", AcpiGbl_FADT.MonthAlarm },
|
|
|
|
{ 108, "CENTURY", AcpiGbl_FADT.Century },
|
|
|
|
{ 109, "IAPC_BOOT_ARCH",AcpiGbl_FADT.BootFlags },
|
|
|
|
{ 128, "RESET_VALUE", AcpiGbl_FADT.ResetValue },
|
|
|
|
};
|
|
|
|
|
|
|
|
const struct acpi_fadt acpi_fadt_flags[] = {
|
|
|
|
|
|
|
|
{ 0, "WBINVD", ACPI_FADT_WBINVD },
|
|
|
|
{ 1, "WBINVD_FLUSH", ACPI_FADT_WBINVD_FLUSH },
|
|
|
|
{ 2, "PROC_C1", ACPI_FADT_C1_SUPPORTED },
|
|
|
|
{ 3, "P_LVL2_UP", ACPI_FADT_C2_MP_SUPPORTED },
|
|
|
|
{ 4, "PWR_BUTTON", ACPI_FADT_POWER_BUTTON },
|
|
|
|
{ 5, "SLP_BUTTON", ACPI_FADT_SLEEP_BUTTON },
|
|
|
|
{ 6, "FIX_RTC", ACPI_FADT_FIXED_RTC },
|
|
|
|
{ 7, "RTC_S4", ACPI_FADT_S4_RTC_WAKE },
|
|
|
|
{ 8, "TMR_VAL_EXT", ACPI_FADT_32BIT_TIMER },
|
|
|
|
{ 9, "DCK_CAP", ACPI_FADT_DOCKING_SUPPORTED },
|
|
|
|
{ 10, "RESET_REG_SUP",ACPI_FADT_RESET_REGISTER },
|
|
|
|
{ 11, "SEALED_CASE", ACPI_FADT_SEALED_CASE },
|
|
|
|
{ 12, "HEADLESS", ACPI_FADT_HEADLESS },
|
|
|
|
{ 13, "CPU_SW_SLP", ACPI_FADT_SLEEP_TYPE },
|
|
|
|
{ 14, "PCI_EXP_WAK", ACPI_FADT_PCI_EXPRESS_WAKE },
|
|
|
|
{ 15, "PLATFORM_CLK", ACPI_FADT_PLATFORM_CLOCK },
|
|
|
|
{ 16, "S4_RTC_STS", ACPI_FADT_S4_RTC_VALID },
|
|
|
|
{ 17, "REMOTE_POWER", ACPI_FADT_REMOTE_POWER_ON },
|
|
|
|
{ 18, "APIC_CLUSTER", ACPI_FADT_APIC_CLUSTER },
|
|
|
|
{ 19, "APIC_PHYSICAL",ACPI_FADT_APIC_PHYSICAL },
|
|
|
|
};
|
|
|
|
|
|
|
|
for (i = 0; i < __arraycount(acpi_fadt_table); i++) {
|
|
|
|
|
|
|
|
aprint_normal_dev(sc->sc_dev,
|
|
|
|
"[FADT] %-15s: 0x%016" PRIX64"\n",
|
|
|
|
acpi_fadt_table[i].fadt_name,
|
|
|
|
acpi_fadt_table[i].fadt_value);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < __arraycount(acpi_fadt_flags); i++) {
|
|
|
|
|
|
|
|
aprint_normal_dev(sc->sc_dev,
|
|
|
|
"[FADT] %-15s: 0x%016" PRIX64"\n",
|
|
|
|
acpi_fadt_flags[i].fadt_name, AcpiGbl_FADT.Flags &
|
|
|
|
acpi_fadt_flags[i].fadt_value);
|
|
|
|
|
|
|
|
KASSERT(i == acpi_fadt_flags[i].fadt_offset);
|
|
|
|
KASSERT(__BIT(acpi_fadt_flags[i].fadt_offset) ==
|
|
|
|
acpi_fadt_flags[i].fadt_value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-08-07 03:38:34 +04:00
|
|
|
static void
|
|
|
|
acpi_print_devnodes(struct acpi_softc *sc)
|
2010-06-01 00:32:28 +04:00
|
|
|
{
|
|
|
|
struct acpi_devnode *ad;
|
|
|
|
ACPI_DEVICE_INFO *di;
|
|
|
|
|
|
|
|
SIMPLEQ_FOREACH(ad, &sc->ad_head, ad_list) {
|
|
|
|
|
|
|
|
di = ad->ad_devinfo;
|
|
|
|
aprint_normal_dev(sc->sc_dev, "%-5s ", ad->ad_name);
|
|
|
|
|
|
|
|
aprint_normal("HID %-10s ",
|
|
|
|
((di->Valid & ACPI_VALID_HID) != 0) ?
|
|
|
|
di->HardwareId.String: "-");
|
|
|
|
|
|
|
|
aprint_normal("UID %-4s ",
|
|
|
|
((di->Valid & ACPI_VALID_UID) != 0) ?
|
|
|
|
di->UniqueId.String : "-");
|
|
|
|
|
|
|
|
if ((di->Valid & ACPI_VALID_STA) != 0)
|
|
|
|
aprint_normal("STA 0x%08X ", di->CurrentStatus);
|
|
|
|
else
|
|
|
|
aprint_normal("STA %10s ", "-");
|
|
|
|
|
|
|
|
if ((di->Valid & ACPI_VALID_ADR) != 0)
|
|
|
|
aprint_normal("ADR 0x%016" PRIX64"", di->Address);
|
|
|
|
else
|
|
|
|
aprint_normal("ADR -");
|
|
|
|
|
|
|
|
aprint_normal("\n");
|
|
|
|
}
|
|
|
|
aprint_normal("\n");
|
|
|
|
}
|
|
|
|
|
2010-08-07 03:38:34 +04:00
|
|
|
static void
|
|
|
|
acpi_print_tree(struct acpi_devnode *ad, uint32_t level)
|
2010-06-01 00:32:28 +04:00
|
|
|
{
|
|
|
|
struct acpi_devnode *child;
|
|
|
|
uint32_t i;
|
|
|
|
|
|
|
|
for (i = 0; i < level; i++)
|
|
|
|
aprint_normal(" ");
|
|
|
|
|
|
|
|
aprint_normal("%-5s [%02u] [%c%c] ", ad->ad_name, ad->ad_type,
|
|
|
|
((ad->ad_flags & ACPI_DEVICE_POWER) != 0) ? 'P' : ' ',
|
|
|
|
((ad->ad_flags & ACPI_DEVICE_WAKEUP) != 0) ? 'W' : ' ');
|
|
|
|
|
|
|
|
if (ad->ad_pciinfo != NULL) {
|
|
|
|
|
|
|
|
aprint_normal("(PCI) @ 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");
|
|
|
|
|
|
|
|
SIMPLEQ_FOREACH(child, &ad->ad_child_head, ad_child_list)
|
|
|
|
acpi_print_tree(child, level + 1);
|
|
|
|
}
|