summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authorMarco Peereboom <marco@cvs.openbsd.org>2006-03-05 14:46:47 +0000
committerMarco Peereboom <marco@cvs.openbsd.org>2006-03-05 14:46:47 +0000
commit232055cb4d121ed9e93d5ddaa18e361e4011ec5f (patch)
tree0a1c8571e823f5381315fdc3d0324e99d2bf3ae7 /sys/dev
parentbe9b50319381ef4a0d73fa9de5e54198ea2d85e2 (diff)
Hook acpi to ddb since we need to be able to do some live debugging.
Lots and lots of help from miod@ and deraadt@ ok deraadt@ miod@
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/acpi/acpidebug.c91
-rw-r--r--sys/dev/acpi/acpidebug.h18
-rw-r--r--sys/dev/acpi/dsdt.c10
-rw-r--r--sys/dev/acpi/dsdt.h3
-rw-r--r--sys/dev/acpi/files.acpi3
5 files changed, 120 insertions, 5 deletions
diff --git a/sys/dev/acpi/acpidebug.c b/sys/dev/acpi/acpidebug.c
new file mode 100644
index 00000000000..863c1a5bb6c
--- /dev/null
+++ b/sys/dev/acpi/acpidebug.c
@@ -0,0 +1,91 @@
+/* $OpenBSD: acpidebug.c,v 1.1 2006/03/05 14:46:46 marco Exp $ */
+/*
+ * Copyright (c) 2006 Marco Peereboom <marco@openbsd.org>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <machine/db_machdep.h>
+#include <ddb/db_command.h>
+#include <ddb/db_output.h>
+
+#include <machine/bus.h>
+
+#include <dev/acpi/acpireg.h>
+#include <dev/acpi/acpivar.h>
+#include <dev/acpi/amltypes.h>
+#include <dev/acpi/acpidebug.h>
+#include <dev/acpi/dsdt.h>
+
+void db_aml_walktree(struct aml_node *);
+void db_aml_shownode(struct aml_node *);
+
+void
+db_aml_shownode(struct aml_node *node)
+{
+ db_printf(" opcode:%.4x mnem:%s %s ",
+ node->opcode, node->mnem, node->name ? node->name : "");
+
+ switch(node->opcode) {
+ case AMLOP_METHOD:
+ break;
+
+ case AMLOP_NAMECHAR:
+ db_printf("%s", node->value->name);
+ break;
+
+ case AMLOP_FIELD:
+ case AMLOP_BANKFIELD:
+ case AMLOP_INDEXFIELD:
+ break;
+
+ case AMLOP_BYTEPREFIX:
+ db_printf("byte: %.2x", node->value->v_integer);
+ break;
+ case AMLOP_WORDPREFIX:
+ db_printf("word: %.4x", node->value->v_integer);
+ break;
+ case AMLOP_DWORDPREFIX:
+ db_printf("dword: %.8x", node->value->v_integer);
+ break;
+ case AMLOP_STRINGPREFIX:
+ db_printf("string: %s", node->value->v_string);
+ break;
+ }
+ db_printf("\n");
+}
+
+void
+db_aml_walktree(struct aml_node *node)
+{
+ int i;
+
+ while(node) {
+ db_printf(" %d ", node->depth);
+ for(i = 0; i < node->depth; i++)
+ db_printf("..");
+
+ db_aml_shownode(node);
+ db_aml_walktree(node->child);
+ node = node->sibling;
+ }
+}
+
+/* ddb interface */
+void
+db_acpi_tree(db_expr_t addr, int haddr, db_expr_t count, char *modif)
+{
+ extern struct aml_node aml_root;
+
+ db_aml_walktree(aml_root.child);
+}
diff --git a/sys/dev/acpi/acpidebug.h b/sys/dev/acpi/acpidebug.h
new file mode 100644
index 00000000000..74721f97ac1
--- /dev/null
+++ b/sys/dev/acpi/acpidebug.h
@@ -0,0 +1,18 @@
+/* $OpenBSD: acpidebug.h,v 1.1 2006/03/05 14:46:46 marco Exp $ */
+/*
+ * Copyright (c) 2006 Marco Peereboom <marco@openbsd.org>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+void db_acpi_tree(db_expr_t, int, db_expr_t, char *);
diff --git a/sys/dev/acpi/dsdt.c b/sys/dev/acpi/dsdt.c
index e87855b6d1f..1ad2097edc2 100644
--- a/sys/dev/acpi/dsdt.c
+++ b/sys/dev/acpi/dsdt.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dsdt.c,v 1.31 2006/02/26 07:57:47 marco Exp $ */
+/* $OpenBSD: dsdt.c,v 1.32 2006/03/05 14:46:46 marco Exp $ */
/*
* Copyright (c) 2005 Jordan Hargrave <jordan@openbsd.org>
*
@@ -22,6 +22,11 @@
#include <machine/bus.h>
+#ifdef DDB
+#include <machine/db_machdep.h>
+#include <ddb/db_command.h>
+#endif
+
#include <dev/acpi/acpireg.h>
#include <dev/acpi/acpivar.h>
#include <dev/acpi/amltypes.h>
@@ -110,7 +115,6 @@ struct acpi_context *acpi_alloccontext(struct acpi_softc *sc,
int argc,
struct aml_value *argv);
-void aml_walkroot(void);
struct aml_node *aml_find_name(struct acpi_softc *, struct aml_node *, const char *);
int64_t aml_str2int(const char *, int, int);
@@ -2892,7 +2896,7 @@ aml_walktree(struct aml_node *node)
}
void
-aml_walkroot()
+aml_walkroot(void)
{
aml_walktree(aml_root.child);
}
diff --git a/sys/dev/acpi/dsdt.h b/sys/dev/acpi/dsdt.h
index 8c09586d580..419005fb7af 100644
--- a/sys/dev/acpi/dsdt.h
+++ b/sys/dev/acpi/dsdt.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: dsdt.h,v 1.9 2006/02/22 19:29:24 jordan Exp $ */
+/* $OpenBSD: dsdt.h,v 1.10 2006/03/05 14:46:46 marco Exp $ */
/*
* Copyright (c) 2005 Marco Peereboom <marco@openbsd.org>
*
@@ -30,6 +30,7 @@ int aml_eval_name(struct acpi_softc *, struct aml_node *, const char *,
void aml_showvalue(struct aml_value *);
void aml_walktree(struct aml_node *);
+void aml_walkroot(void);
struct aml_value *aml_allocint(uint64_t);
struct aml_value *aml_allocstr(const char *);
diff --git a/sys/dev/acpi/files.acpi b/sys/dev/acpi/files.acpi
index 23b85d8f8e9..10dd854347a 100644
--- a/sys/dev/acpi/files.acpi
+++ b/sys/dev/acpi/files.acpi
@@ -1,4 +1,4 @@
-# $OpenBSD: files.acpi,v 1.8 2006/02/26 02:49:28 marco Exp $
+# $OpenBSD: files.acpi,v 1.9 2006/03/05 14:46:46 marco Exp $
#
# Config file and device description for machine-independent ACPI code.
# Included by ports that need it.
@@ -9,6 +9,7 @@ attach acpi at mainbus
file dev/acpi/acpi.c acpi needs-flag
file dev/acpi/acpiutil.c acpi
file dev/acpi/dsdt.c acpi
+file dev/acpi/acpidebug.c acpi & ddb
# ACPI timer
device acpitimer