Sat Aug 7 09:41:20 2010 UTC ()
Reorganize: also the APIC tables will be dumped in ACPIVERBOSE, and the
callback functions will be modified to be suitable also with other tables.


(jruoho)
diff -r1.88 -r1.89 src/sys/arch/x86/x86/mpacpi.c
diff -r1.211 -r1.212 src/sys/dev/acpi/acpi.c
diff -r1.21 -r0 src/sys/dev/acpi/acpi_madt.c
diff -r1.8 -r0 src/sys/dev/acpi/acpi_madt.h
diff -r1.59 -r1.60 src/sys/dev/acpi/acpivar.h
diff -r1.76 -r1.77 src/sys/dev/acpi/files.acpi

cvs diff -r1.88 -r1.89 src/sys/arch/x86/x86/mpacpi.c (expand / switch to context diff)
--- src/sys/arch/x86/x86/mpacpi.c 2010/08/04 10:02:12 1.88
+++ src/sys/arch/x86/x86/mpacpi.c 2010/08/07 09:41:19 1.89
@@ -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 @@
 #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 @@
 
 /*
  * 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)

cvs diff -r1.211 -r1.212 src/sys/dev/acpi/acpi.c (expand / switch to context diff)
--- src/sys/dev/acpi/acpi.c 2010/08/06 23:38:34 1.211
+++ src/sys/dev/acpi/acpi.c 2010/08/07 09:41:19 1.212
@@ -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.
@@ -30,6 +30,41 @@
  */
 
 /*
+ * 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 @@
 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 @@
 }
 
 /*
- * 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)
 {
@@ -1687,6 +1697,83 @@
 		return;
 
 	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;
 }
 
 /*

File Deleted: src/sys/dev/acpi/Attic/acpi_madt.c

File Deleted: src/sys/dev/acpi/Attic/acpi_madt.h

cvs diff -r1.59 -r1.60 src/sys/dev/acpi/acpivar.h (expand / switch to context diff)
--- src/sys/dev/acpi/acpivar.h 2010/08/06 23:38:34 1.59
+++ src/sys/dev/acpi/acpivar.h 2010/08/07 09:41:19 1.60
@@ -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.
@@ -298,6 +298,18 @@
  * Sleep state transition.
  */
 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.

cvs diff -r1.76 -r1.77 src/sys/dev/acpi/files.acpi (expand / switch to context diff)
--- src/sys/dev/acpi/files.acpi 2010/07/18 09:29:12 1.76
+++ src/sys/dev/acpi/files.acpi 2010/08/07 09:41:19 1.77
@@ -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 @@
 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