summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authorJordan Hargrave <jordan@cvs.openbsd.org>2006-02-19 21:32:31 +0000
committerJordan Hargrave <jordan@cvs.openbsd.org>2006-02-19 21:32:31 +0000
commitacd11f0a841e26b98d96e0d4bf0c332918a4c61f (patch)
tree0e1f1cc671890acb71f93abb9d73c46a10bb513b /sys/dev
parent0e97777a0da89008117a500d0aae5580257dbc8a (diff)
Added code for aml_notify GPE notification callback
ok marco@
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/acpi/acpi.c21
-rw-r--r--sys/dev/acpi/acpivar.h5
-rw-r--r--sys/dev/acpi/dsdt.c56
-rw-r--r--sys/dev/acpi/dsdt.h7
4 files changed, 85 insertions, 4 deletions
diff --git a/sys/dev/acpi/acpi.c b/sys/dev/acpi/acpi.c
index b5d102a54ee..06111abcad1 100644
--- a/sys/dev/acpi/acpi.c
+++ b/sys/dev/acpi/acpi.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: acpi.c,v 1.35 2006/02/19 19:03:49 grange Exp $ */
+/* $OpenBSD: acpi.c,v 1.36 2006/02/19 21:32:30 jordan Exp $ */
/*
* Copyright (c) 2005 Thorsten Lockert <tholo@sigmasoft.com>
* Copyright (c) 2005 Jordan Hargrave <jordan@openbsd.org>
@@ -527,6 +527,19 @@ acpi_foundhid(struct aml_node *node, void *arg)
aaa.aaa_memt = sc->sc_memt;
aaa.aaa_node = node->parent;
config_found(self, &aaa, acpi_print);
+ } else if (!strcmp(dev, ACPI_DEV_LD) ||
+ !strcmp(dev, ACPI_DEV_PBD) ||
+ !strcmp(dev, ACPI_DEV_SBD)) {
+#if 0
+ struct acpi_attach_args aaa;
+
+ memset(&aaa, 0, sizeof(aaa));
+ aaa.aaa_name = "acpibtn";
+ aaa.aaa_iot = sc->sc_iot;
+ aaa.aaa_memt = sc->sc_memt;
+ aaa.aaa_node = node->parent;
+ config_found(self, &aaa, acpi_print);
+#endif
}
}
@@ -1242,6 +1255,9 @@ acpi_isr_thread(void *arg)
if (sc->sc_powerbtn) {
sc->sc_powerbtn = 0;
+
+ if (sc->sc_pbtndev)
+ aml_notify(sc->sc_pbtndev, 0x80);
acpi_evindex++;
dnprintf(1,"power button pressed\n");
KNOTE(sc->sc_note, ACPI_EVENT_COMPOSE(ACPI_EV_PWRBTN,
@@ -1253,6 +1269,9 @@ acpi_isr_thread(void *arg)
}
if (sc->sc_sleepbtn) {
sc->sc_sleepbtn = 0;
+
+ if (sc->sc_sbtndev)
+ aml_notify(sc->sc_sbtndev, 0x80);
acpi_evindex++;
dnprintf(1,"sleep button pressed\n");
KNOTE(sc->sc_note, ACPI_EVENT_COMPOSE(ACPI_EV_SLPBTN,
diff --git a/sys/dev/acpi/acpivar.h b/sys/dev/acpi/acpivar.h
index 5dbd010417b..1e1c37789b9 100644
--- a/sys/dev/acpi/acpivar.h
+++ b/sys/dev/acpi/acpivar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: acpivar.h,v 1.16 2006/02/19 04:50:46 marco Exp $ */
+/* $OpenBSD: acpivar.h,v 1.17 2006/02/19 21:32:30 jordan Exp $ */
/*
* Copyright (c) 2005 Thorsten Lockert <tholo@sigmasoft.com>
*
@@ -147,6 +147,9 @@ struct acpi_softc {
u_int32_t sc_gpe_sts;
u_int32_t sc_gpe_en;
struct acpi_thread *sc_thread;
+
+ struct aml_node *sc_pbtndev;
+ struct aml_node *sc_sbtndev;
};
#define GPE_NONE 0x00
diff --git a/sys/dev/acpi/dsdt.c b/sys/dev/acpi/dsdt.c
index cd8508a5e2a..5fb1713ef8d 100644
--- a/sys/dev/acpi/dsdt.c
+++ b/sys/dev/acpi/dsdt.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dsdt.c,v 1.24 2006/02/19 04:50:47 marco Exp $ */
+/* $OpenBSD: dsdt.c,v 1.25 2006/02/19 21:32:30 jordan Exp $ */
/*
* Copyright (c) 2005 Jordan Hargrave <jordan@openbsd.org>
*
@@ -233,6 +233,56 @@ aml_setbit(u_int8_t *pb, int bit, int val)
}
}
+/*=====================================
+ * This code handles AML notifications
+ *=====================================*/
+struct aml_notify_data
+{
+ struct aml_node *node;
+ void *cbarg;
+ int (*cbproc)(struct aml_node *, int, void *);
+
+ SLIST_ENTRY(aml_notify_data) link;
+};
+
+SLIST_HEAD(aml_notify_head, aml_notify_data);
+struct aml_notify_head aml_notify_list =
+ SLIST_HEAD_INITIALIZER(&aml_notify_list);
+
+void aml_register_notify(struct aml_node *node,
+ int (*proc)(struct aml_node *, int, void *),
+ void *arg)
+{
+ struct aml_notify_data *pdata;
+
+ dnprintf(10, "aml_register_notify: %s %x\n",
+ node->name, cbproc);
+ pdata = acpi_os_allocmem(sizeof(struct aml_notify_data));
+ pdata->node = node;
+ pdata->cbarg = arg;
+ pdata->cbproc = proc;
+
+ SLIST_INSERT_HEAD(&aml_notify_list, pdata, link);
+}
+
+void aml_notify(struct aml_node *node, int notify_value)
+{
+ struct aml_notify_data *pdata = NULL;
+
+ SLIST_FOREACH(pdata, &aml_notify_list, link)
+ if (pdata->node == node) {
+ pdata->cbproc(node, notify_value, pdata->cbarg);
+ }
+}
+
+void _aml_notify(struct aml_node *, void *);
+
+void
+_aml_notify(struct aml_node *node, void *arg)
+{
+ aml_notify(node, *(int64_t *)arg);
+}
+
void
aml_addchildnode(struct aml_node *parent,
struct aml_node *child)
@@ -2361,12 +2411,16 @@ aml_eparseval(struct acpi_context *ctx, int deref)
lhs = aml_eparseval(ctx, 1);
i1 = aml_eparseint(ctx, AML_ANYINT);
dnprintf(10, "NOTIFY: %llx %s\n", i1, lhs->name);
+ aml_find_node(aml_root.child, lhs->name,
+ _aml_notify,
+ &i1);
break;
case AMLOP_LOAD:
case AMLOP_STORE:
rhs = aml_eparseval(ctx, 1);
lhs = aml_eparseval(ctx, 0);
rv = aml_esetnodevalue(ctx, lhs, rhs, 0);
+
break;
case AMLOP_COPYOBJECT:
rhs = aml_eparseval(ctx, 1);
diff --git a/sys/dev/acpi/dsdt.h b/sys/dev/acpi/dsdt.h
index 1316c724cde..3ed580943f9 100644
--- a/sys/dev/acpi/dsdt.h
+++ b/sys/dev/acpi/dsdt.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: dsdt.h,v 1.7 2006/02/19 04:50:47 marco Exp $ */
+/* $OpenBSD: dsdt.h,v 1.8 2006/02/19 21:32:30 jordan Exp $ */
/*
* Copyright (c) 2005 Marco Peereboom <marco@openbsd.org>
*
@@ -45,4 +45,9 @@ int64_t aml_val2int(struct acpi_context *, struct aml_value *);
struct aml_node *aml_searchname(struct aml_node *, const char *);
+void aml_register_notify(struct aml_node *,
+ int (*)(struct aml_node *, int, void *),
+ void *);
+void aml_notify(struct aml_node *, int);
+
#endif /* __DEV_ACPI_DSDT_H__ */