summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authorPaul Irofti <pirofti@cvs.openbsd.org>2013-01-18 04:07:07 +0000
committerPaul Irofti <pirofti@cvs.openbsd.org>2013-01-18 04:07:07 +0000
commit8eab50fa57aaa9e66e3672281b7569edc3a5b67d (patch)
tree253c16cf8e3cde066cca970a535fbabb19f8c599 /sys/dev
parent964d1f83f8ad7f160d3145f69e16283e9a16c1d0 (diff)
acpi: Add global lock enter and leave routines.
I think this diff is the way to go if we want to have proper locking in our acpi drivers. This doesn't hook onto anything from the kernel and is just building framework towards locking. Okay mlarkin@, kettenis@.
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/acpi/dsdt.c26
-rw-r--r--sys/dev/acpi/dsdt.h5
2 files changed, 29 insertions, 2 deletions
diff --git a/sys/dev/acpi/dsdt.c b/sys/dev/acpi/dsdt.c
index fb70fb0e3fa..8bfc1bb255e 100644
--- a/sys/dev/acpi/dsdt.c
+++ b/sys/dev/acpi/dsdt.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dsdt.c,v 1.197 2012/07/16 15:27:11 deraadt Exp $ */
+/* $OpenBSD: dsdt.c,v 1.198 2013/01/18 04:07:06 pirofti Exp $ */
/*
* Copyright (c) 2005 Jordan Hargrave <jordan@openbsd.org>
*
@@ -731,6 +731,30 @@ long acpi_release_global_lock(void*);
static long global_lock_count = 0;
#define acpi_acquire_global_lock(x) 1
#define acpi_release_global_lock(x) 0
+
+void
+acpi_glk_enter(void)
+{
+ acpi_acquire_glk(&acpi_softc->sc_facs->global_lock);
+}
+
+void
+acpi_glk_leave(void)
+{
+ int x;
+
+ if (acpi_release_glk(&acpi_softc->sc_facs->global_lock)) {
+ /*
+ * If pending, notify the BIOS that the lock was released
+ * by the OSPM. No locking is needed because nobody outside
+ * the ACPI thread is touching this register.
+ */
+ x = acpi_read_pmreg(acpi_softc, ACPIREG_PM1_CNT, 0);
+ x |= ACPI_PM1_GBL_RLS;
+ acpi_write_pmreg(acpi_softc, ACPIREG_PM1_CNT, 0, x);
+ }
+}
+
void
aml_lockfield(struct aml_scope *scope, struct aml_value *field)
{
diff --git a/sys/dev/acpi/dsdt.h b/sys/dev/acpi/dsdt.h
index 9333cb4ef32..ab0ace47b1e 100644
--- a/sys/dev/acpi/dsdt.h
+++ b/sys/dev/acpi/dsdt.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: dsdt.h,v 1.60 2012/07/16 15:27:11 deraadt Exp $ */
+/* $OpenBSD: dsdt.h,v 1.61 2013/01/18 04:07:06 pirofti Exp $ */
/*
* Copyright (c) 2005 Marco Peereboom <marco@openbsd.org>
*
@@ -279,4 +279,7 @@ void aml_notify_dev(const char *, int);
void acpi_freedevlist(struct acpi_devlist_head *);
+void acpi_glk_enter(void);
+void acpi_glk_leave(void);
+
#endif /* __DEV_ACPI_DSDT_H__ */