acenv.h 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * IA64 specific ACPICA environments and implementation
  4. *
  5. * Copyright (C) 2014, Intel Corporation
  6. * Author: Lv Zheng <[email protected]>
  7. */
  8. #ifndef _ASM_IA64_ACENV_H
  9. #define _ASM_IA64_ACENV_H
  10. #include <asm/intrinsics.h>
  11. #define COMPILER_DEPENDENT_INT64 long
  12. #define COMPILER_DEPENDENT_UINT64 unsigned long
  13. /* Asm macros */
  14. static inline int
  15. ia64_acpi_acquire_global_lock(unsigned int *lock)
  16. {
  17. unsigned int old, new, val;
  18. do {
  19. old = *lock;
  20. new = (((old & ~0x3) + 2) + ((old >> 1) & 0x1));
  21. val = ia64_cmpxchg4_acq(lock, new, old);
  22. } while (unlikely (val != old));
  23. return (new < 3) ? -1 : 0;
  24. }
  25. static inline int
  26. ia64_acpi_release_global_lock(unsigned int *lock)
  27. {
  28. unsigned int old, new, val;
  29. do {
  30. old = *lock;
  31. new = old & ~0x3;
  32. val = ia64_cmpxchg4_acq(lock, new, old);
  33. } while (unlikely (val != old));
  34. return old & 0x1;
  35. }
  36. #define ACPI_ACQUIRE_GLOBAL_LOCK(facs, Acq) \
  37. ((Acq) = ia64_acpi_acquire_global_lock(&facs->global_lock))
  38. #define ACPI_RELEASE_GLOBAL_LOCK(facs, Acq) \
  39. ((Acq) = ia64_acpi_release_global_lock(&facs->global_lock))
  40. #endif /* _ASM_IA64_ACENV_H */