diff options
author | jkim <jkim@FreeBSD.org> | 2012-02-10 23:30:29 +0000 |
---|---|---|
committer | jkim <jkim@FreeBSD.org> | 2012-02-10 23:30:29 +0000 |
commit | fccbffe7d83251aeb28395fd853f38f45bf3782d (patch) | |
tree | 53561c642a2bbcb3ebfff7f191b74dc0c00e3999 | |
parent | 194724f00c0873d87ed81c40c5f8c8c17d5a51f6 (diff) | |
download | FreeBSD-src-fccbffe7d83251aeb28395fd853f38f45bf3782d.zip FreeBSD-src-fccbffe7d83251aeb28395fd853f38f45bf3782d.tar.gz |
De-obfuscate acpi_acquire_global_lock(). It seems the function was directly
translated from i386 assembly version.
-rw-r--r-- | sys/dev/acpica/Osd/OsdSynch.c | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/sys/dev/acpica/Osd/OsdSynch.c b/sys/dev/acpica/Osd/OsdSynch.c index 84e331c..dedfa6e 100644 --- a/sys/dev/acpica/Osd/OsdSynch.c +++ b/sys/dev/acpica/Osd/OsdSynch.c @@ -566,11 +566,8 @@ AcpiOsReleaseLock(ACPI_SPINLOCK Handle, ACPI_CPU_FLAGS Flags) } /* Section 5.2.10.1: global lock acquire/release functions */ -#define GL_ACQUIRED (-1) -#define GL_BUSY 0 #define GL_BIT_PENDING 0x01 #define GL_BIT_OWNED 0x02 -#define GL_BIT_MASK (GL_BIT_PENDING | GL_BIT_OWNED) /* * Acquire the global lock. If busy, set the pending bit. The caller @@ -584,11 +581,12 @@ acpi_acquire_global_lock(uint32_t *lock) do { old = *lock; - new = ((old & ~GL_BIT_MASK) | GL_BIT_OWNED) | - ((old >> 1) & GL_BIT_PENDING); + new = (old & ~GL_BIT_PENDING) | GL_BIT_OWNED; + if ((old & GL_BIT_OWNED) != 0) + new |= GL_BIT_PENDING; } while (atomic_cmpset_acq_int(lock, old, new) == 0); - return ((new < GL_BIT_MASK) ? GL_ACQUIRED : GL_BUSY); + return ((new & GL_BIT_PENDING) == 0); } /* @@ -603,8 +601,8 @@ acpi_release_global_lock(uint32_t *lock) do { old = *lock; - new = old & ~GL_BIT_MASK; + new = old & ~(GL_BIT_PENDING | GL_BIT_OWNED); } while (atomic_cmpset_rel_int(lock, old, new) == 0); - return (old & GL_BIT_PENDING); + return ((old & GL_BIT_PENDING) != 0); } |