Reorganize: also the APIC tables will be dumped in ACPIVERBOSE, and the

callback functions will be modified to be suitable also with other tables.
This commit is contained in:
jruoho 2010-08-07 09:41:19 +00:00
parent 77da05df17
commit 6e6e026403
6 changed files with 133 additions and 310 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: mpacpi.c,v 1.88 2010/08/04 10:02:12 jruoho Exp $ */
/* $NetBSD: mpacpi.c,v 1.89 2010/08/07 09:41:19 jruoho Exp $ */
/*
* Copyright (c) 2003 Wasabi Systems, Inc.
@ -36,7 +36,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: mpacpi.c,v 1.88 2010/08/04 10:02:12 jruoho Exp $");
__KERNEL_RCSID(0, "$NetBSD: mpacpi.c,v 1.89 2010/08/07 09:41:19 jruoho Exp $");
#include "acpica.h"
#include "opt_acpi.h"
@ -71,7 +71,6 @@ __KERNEL_RCSID(0, "$NetBSD: mpacpi.c,v 1.88 2010/08/04 10:02:12 jruoho Exp $");
#include <dev/acpi/acpica.h>
#include <dev/acpi/acpireg.h>
#include <dev/acpi/acpivar.h>
#include <dev/acpi/acpi_madt.h>
#include <dev/cons.h>
@ -169,7 +168,7 @@ mpacpi_ioapicprint(void *aux, const char *pnp)
/*
* Handle special interrupt sources and overrides from the MADT.
* This is a callback function for acpi_madt_walk().
* This is a callback function for acpi_madt_walk() (see acpi.c).
*/
static ACPI_STATUS
mpacpi_nonpci_intr(ACPI_SUBTABLE_HEADER *hdrp, void *aux)

View File

@ -1,4 +1,4 @@
/* $NetBSD: acpi.c,v 1.211 2010/08/06 23:38:34 jruoho Exp $ */
/* $NetBSD: acpi.c,v 1.212 2010/08/07 09:41:19 jruoho Exp $ */
/*-
* Copyright (c) 2003, 2007 The NetBSD Foundation, Inc.
@ -29,6 +29,41 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
/*
* Copyright (c) 2003 Wasabi Systems, Inc.
* All rights reserved.
*
* Written by Frank van der Linden 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.
*/
/*
* Copyright 2001, 2003 Wasabi Systems, Inc.
* All rights reserved.
@ -65,7 +100,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: acpi.c,v 1.211 2010/08/06 23:38:34 jruoho Exp $");
__KERNEL_RCSID(0, "$NetBSD: acpi.c,v 1.212 2010/08/07 09:41:19 jruoho Exp $");
#include "opt_acpi.h"
#include "opt_pcifixup.h"
@ -128,6 +163,7 @@ static uint64_t acpi_root_pointer;
extern kmutex_t acpi_interrupt_list_mtx;
extern struct cfdriver acpi_cd;
static ACPI_HANDLE acpi_scopes[4];
static ACPI_TABLE_HEADER *madt_header;
/*
* This structure provides a context for the ACPI
@ -1605,34 +1641,8 @@ sysctl_hw_acpi_sleepstates(SYSCTLFN_ARGS)
}
/*
* Miscellaneous.
* Tables.
*/
static bool
acpi_is_scope(struct acpi_devnode *ad)
{
int i;
/*
* Return true if the node is a root scope.
*/
if (ad->ad_parent == NULL)
return false;
if (ad->ad_parent->ad_handle != ACPI_ROOT_OBJECT)
return false;
for (i = 0; i < __arraycount(acpi_scopes); i++) {
if (acpi_scopes[i] == NULL)
continue;
if (ad->ad_handle == acpi_scopes[i])
return true;
}
return false;
}
ACPI_PHYSICAL_ADDRESS
acpi_OsGetRootPointer(void)
{
@ -1689,6 +1699,83 @@ acpi_unmap_rsdt(ACPI_TABLE_HEADER *rsdt)
AcpiOsUnmapMemory(rsdt, sizeof(ACPI_TABLE_HEADER));
}
/*
* XXX: Refactor to be a generic function that maps tables.
*/
ACPI_STATUS
acpi_madt_map(void)
{
ACPI_STATUS rv;
if (madt_header != NULL)
return AE_ALREADY_EXISTS;
rv = AcpiGetTable(ACPI_SIG_MADT, 1, &madt_header);
if (ACPI_FAILURE(rv))
return rv;
return AE_OK;
}
void
acpi_madt_unmap(void)
{
madt_header = NULL;
}
/*
* XXX: Refactor to be a generic function that walks tables.
*/
void
acpi_madt_walk(ACPI_STATUS (*func)(ACPI_SUBTABLE_HEADER *, void *), void *aux)
{
ACPI_SUBTABLE_HEADER *hdrp;
char *madtend, *where;
madtend = (char *)madt_header + madt_header->Length;
where = (char *)madt_header + sizeof (ACPI_TABLE_MADT);
while (where < madtend) {
hdrp = (ACPI_SUBTABLE_HEADER *)where;
if (ACPI_FAILURE(func(hdrp, aux)))
break;
where += hdrp->Length;
}
}
/*
* Miscellaneous.
*/
static bool
acpi_is_scope(struct acpi_devnode *ad)
{
int i;
/*
* Return true if the node is a root scope.
*/
if (ad->ad_parent == NULL)
return false;
if (ad->ad_parent->ad_handle != ACPI_ROOT_OBJECT)
return false;
for (i = 0; i < __arraycount(acpi_scopes); i++) {
if (acpi_scopes[i] == NULL)
continue;
if (ad->ad_handle == acpi_scopes[i])
return true;
}
return false;
}
/*
* ACPIVERBOSE.
*/

View File

@ -1,225 +0,0 @@
/* $NetBSD: acpi_madt.c,v 1.21 2010/03/05 14:00:17 jruoho Exp $ */
/*
* Copyright (c) 2003 Wasabi Systems, Inc.
* All rights reserved.
*
* Written by Frank van der Linden 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>
__KERNEL_RCSID(0, "$NetBSD: acpi_madt.c,v 1.21 2010/03/05 14:00:17 jruoho Exp $");
#include <sys/param.h>
#include <sys/systm.h>
#include <dev/acpi/acpivar.h>
#include <dev/acpi/acpi_madt.h>
#ifdef ACPI_MADT_DEBUG
static void acpi_madt_print(void);
static ACPI_STATUS acpi_madt_print_entry(ACPI_SUBTABLE_HEADER *, void *);
static void acpi_print_lapic(ACPI_MADT_LOCAL_APIC *);
static void acpi_print_ioapic(ACPI_MADT_IO_APIC *);
static void acpi_print_intsrc_ovr(ACPI_MADT_INTERRUPT_OVERRIDE *);
static void acpi_print_intsrc_nmi(ACPI_MADT_NMI_SOURCE *);
static void acpi_print_lapic_nmi(ACPI_MADT_LOCAL_APIC_NMI *);
static void acpi_print_lapic_ovr(ACPI_MADT_LOCAL_APIC_OVERRIDE *);
static void acpi_print_iosapic(ACPI_MADT_IO_SAPIC *);
static void acpi_print_local_sapic(ACPI_MADT_LOCAL_SAPIC *);
static void acpi_print_platint(ACPI_MADT_INTERRUPT_SOURCE *);
#endif
static ACPI_TABLE_HEADER *madt_header;
ACPI_STATUS
acpi_madt_map(void)
{
ACPI_STATUS rv;
if (madt_header != NULL)
return AE_ALREADY_EXISTS;
rv = AcpiGetTable(ACPI_SIG_MADT, 1, &madt_header);
if (ACPI_FAILURE(rv))
return rv;
#ifdef ACPI_MADT_DEBUG
acpi_madt_print();
#endif
return AE_OK;
}
void
acpi_madt_unmap(void)
{
madt_header = NULL;
}
#ifdef ACPI_MADT_DEBUG
static void
acpi_print_lapic(ACPI_MADT_LOCAL_APIC *p)
{
printf("lapic: processor id %u apid %u enabled: %s\n",
p->ProcessorId, p->Id,
(p->LapicFlags & ACPI_MADT_ENABLED) ? "yes" : "no");
}
static void
acpi_print_ioapic(ACPI_MADT_IO_APIC *p)
{
printf("ioapic: apid %u address 0x%x vector base 0x%x\n",
p->Id, p->Address, p->GlobalIrqBase);
}
static void
acpi_print_intsrc_ovr(ACPI_MADT_INTERRUPT_OVERRIDE *p)
{
printf("int override: bus %u src int %u global int %u\n",
p->Bus, p->SourceIrq, p->GlobalIrq);
}
static void
acpi_print_intsrc_nmi(ACPI_MADT_NMI_SOURCE *p)
{
printf("ioapic NMI: int %u\n", p->GlobalIrq);
}
static void
acpi_print_lapic_nmi(ACPI_MADT_LOCAL_APIC_NMI *p)
{
printf("lapic NMI: cpu id %u input %u\n", p->ProcessorId, p->Lint);
}
static void
acpi_print_lapic_ovr(ACPI_MADT_LOCAL_APIC_OVERRIDE *p)
{
printf("lapic addr override: 0x%"PRIx64"\n", p->Address);
}
static void
acpi_print_iosapic(ACPI_MADT_IO_SAPIC *p)
{
printf("iosapic: sapid %u address 0x%"PRIx64" int vector base 0x%x\n",
p->Id, p->Address, p->GlobalIrqBase);
}
static void
acpi_print_local_sapic(ACPI_MADT_LOCAL_SAPIC *p)
{
printf("local sapic: cpu id %u sapid %u sapeid %u enabled: %s\n",
p->ProcessorId, p->Id, p->Eid,
(p->LapicFlags & ACPI_MADT_ENABLED) ? "yes" : "no");
}
static void
acpi_print_platint(ACPI_MADT_INTERRUPT_SOURCE *p)
{
printf("platform int: type %u cpu id %u cpu eid %u vector %u int %u%s\n",
p->Type, p->Id, p->Eid, p->IoSapicVector, p->GlobalIrq,
(p->Flags & ACPI_MADT_CPEI_OVERRIDE) ? " CPEI" : "");
}
#endif
void
acpi_madt_walk(ACPI_STATUS (*func)(ACPI_SUBTABLE_HEADER *, void *), void *aux)
{
char *madtend, *where;
ACPI_SUBTABLE_HEADER *hdrp;
madtend = (char *)madt_header + madt_header->Length;
where = (char *)madt_header + sizeof (ACPI_TABLE_MADT);
while (where < madtend) {
hdrp = (ACPI_SUBTABLE_HEADER *)where;
if (ACPI_FAILURE(func(hdrp, aux)))
break;
where += hdrp->Length;
}
}
#ifdef ACPI_MADT_DEBUG
static void
acpi_madt_print(void)
{
ACPI_TABLE_MADT *ap;
ap = (ACPI_TABLE_MADT *)madt_header;
printf("\n\nACPI MADT table:\n");
/* printf("default local APIC address: %x\n", ap->LocalApicAddress); */
printf("system dual 8259%s present\n",
(ap->Flags & ACPI_MADT_PCAT_COMPAT) ? "" : " not");
printf("entries:\n");
acpi_madt_walk(acpi_madt_print_entry, NULL);
}
static ACPI_STATUS
acpi_madt_print_entry(ACPI_SUBTABLE_HEADER *hdrp, void *aux)
{
switch (hdrp->Type) {
case ACPI_MADT_TYPE_LOCAL_APIC:
acpi_print_lapic((void *)hdrp);
break;
case ACPI_MADT_TYPE_IO_APIC:
acpi_print_ioapic((void *)hdrp);
break;
case ACPI_MADT_TYPE_INTERRUPT_OVERRIDE:
acpi_print_intsrc_ovr((void *)hdrp);
break;
case ACPI_MADT_TYPE_NMI_SOURCE:
acpi_print_intsrc_nmi((void *)hdrp);
break;
case ACPI_MADT_TYPE_LOCAL_APIC_NMI:
acpi_print_lapic_nmi((void *)hdrp);
break;
case ACPI_MADT_TYPE_LOCAL_APIC_OVERRIDE:
acpi_print_lapic_ovr((void *)hdrp);
break;
case ACPI_MADT_TYPE_IO_SAPIC:
acpi_print_iosapic((void *)hdrp);
break;
case ACPI_MADT_TYPE_LOCAL_SAPIC:
acpi_print_local_sapic((void *)hdrp);
break;
case ACPI_MADT_TYPE_INTERRUPT_SOURCE:
acpi_print_platint((void *)hdrp);
break;
default:
printf("Unknown MADT entry type %u\n", hdrp->Type);
break;
}
return AE_OK;
}
#endif

View File

@ -1,49 +0,0 @@
/* $NetBSD: acpi_madt.h,v 1.8 2010/03/05 08:30:48 jruoho Exp $ */
/*
* Copyright (c) 2003 Wasabi Systems, Inc.
* All rights reserved.
*
* Written by Frank van der Linden 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.
*/
#ifndef _SYS_DEV_ACPI_ACPI_MADT_H
#define _SYS_DEV_ACPI_ACPI_MADT_H
#define ACPI_PLATFORM_INT_PMI 1
#define ACPI_PLATFORM_INT_INIT 2
#define ACPI_PLATFORM_INT_CERR 3
ACPI_STATUS acpi_madt_map(void);
void acpi_madt_unmap(void);
void acpi_madt_walk(ACPI_STATUS (*)(ACPI_SUBTABLE_HEADER *, void *), void *);
#endif /* !_SYS_DEV_ACPI_ACPI_MADT_H */

View File

@ -1,4 +1,4 @@
/* $NetBSD: acpivar.h,v 1.59 2010/08/06 23:38:34 jruoho Exp $ */
/* $NetBSD: acpivar.h,v 1.60 2010/08/07 09:41:19 jruoho Exp $ */
/*
* Copyright 2001 Wasabi Systems, Inc.
@ -299,6 +299,18 @@ struct acpi_drq *acpi_res_drq(struct acpi_resources *, int);
*/
void acpi_enter_sleep_state(struct acpi_softc *, int);
/*
* MADT.
*/
#define ACPI_PLATFORM_INT_PMI 1
#define ACPI_PLATFORM_INT_INIT 2
#define ACPI_PLATFORM_INT_CERR 3
ACPI_STATUS acpi_madt_map(void);
void acpi_madt_unmap(void);
void acpi_madt_walk(ACPI_STATUS (*)(ACPI_SUBTABLE_HEADER *,
void *), void *);
/*
* Quirk handling.
*/

View File

@ -1,4 +1,4 @@
# $NetBSD: files.acpi,v 1.76 2010/07/18 09:29:12 jruoho Exp $
# $NetBSD: files.acpi,v 1.77 2010/08/07 09:41:19 jruoho Exp $
include "dev/acpi/acpica/files.acpica"
@ -14,7 +14,6 @@ device acpi: acpica, acpiapmbus, acpinodebus, acpiecdtbus, sysmon_power, sysmon_
attach acpi at acpibus
file dev/acpi/acpi.c acpi
file dev/acpi/acpi_debug.c acpi
file dev/acpi/acpi_madt.c acpi
file dev/acpi/acpi_pci.c acpi
file dev/acpi/acpi_pci_link.c acpi
file dev/acpi/acpi_power.c acpi