De-obfuscate acpi_acquire_global_lock(). It seems the function was directly

translated from i386 assembly version.
This commit is contained in:
Jung-uk Kim
2012-02-10 23:30:29 +00:00
parent 4c322abc56
commit 731634f7fe
+6 -8
View File
@@ -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);
}