diff options
author | Paul Irofti <pirofti@cvs.openbsd.org> | 2013-01-18 06:02:52 +0000 |
---|---|---|
committer | Paul Irofti <pirofti@cvs.openbsd.org> | 2013-01-18 06:02:52 +0000 |
commit | 6d5e6800c9d483f813e31c19054627f83924736f (patch) | |
tree | 2e0e22eba9765e38b47b5c5a6af38150eb9487f1 | |
parent | 6ad2c3f827b6618734afcdeb74154959221bb129 (diff) |
acpi: add acpiec_lock and acpi_unlock routines.
The routines check if the AML requires us to acquire the global lock by
checking a flag stored in the soft state at attach and locks or unlocks
if true.
This is just building locking framework and is not hooked in any way to
the kernel.
Okay kettenis@.
-rw-r--r-- | sys/dev/acpi/acpiec.c | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/sys/dev/acpi/acpiec.c b/sys/dev/acpi/acpiec.c index e6a5e01854a..52ff105ee8f 100644 --- a/sys/dev/acpi/acpiec.c +++ b/sys/dev/acpi/acpiec.c @@ -1,4 +1,4 @@ -/* $OpenBSD: acpiec.c,v 1.46 2012/07/13 10:37:40 pirofti Exp $ */ +/* $OpenBSD: acpiec.c,v 1.47 2013/01/18 06:02:51 pirofti Exp $ */ /* * Copyright (c) 2006 Can Erkin Acar <canacar@openbsd.org> * @@ -59,6 +59,9 @@ void acpiec_get_events(struct acpiec_softc *); int acpiec_gpehandler(struct acpi_softc *, int, void *); +void acpiec_lock(struct acpiec_softc *); +void acpiec_unlock(struct acpiec_softc *); + /* EC Status bits */ #define EC_STAT_SMI_EVT 0x40 /* SMI event pending */ #define EC_STAT_SCI_EVT 0x20 /* SCI event pending */ @@ -524,3 +527,27 @@ acpiec_reg(struct acpiec_softc *sc) return (0); } + +void +acpiec_lock(struct acpiec_softc *sc) +{ + KASSERT(sc->sc_ecbusy == 0); + + sc->sc_ecbusy = 1; + + if (sc->sc_glk) { + acpi_glk_enter(); + } +} + +void +acpiec_unlock(struct acpiec_softc *sc) +{ + KASSERT(sc->sc_ecbusy == 1); + + if (sc->sc_glk) { + acpi_glk_leave(); + } + + sc->sc_ecbusy = 0; +} |