acenv.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /*
  2. * IA64 specific ACPICA environments and implementation
  3. *
  4. * Copyright (C) 2014, Intel Corporation
  5. * Author: Lv Zheng <lv.zheng@intel.com>
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License version 2 as
  9. * published by the Free Software Foundation.
  10. */
  11. #ifndef _ASM_IA64_ACENV_H
  12. #define _ASM_IA64_ACENV_H
  13. #include <asm/intrinsics.h>
  14. #define COMPILER_DEPENDENT_INT64 long
  15. #define COMPILER_DEPENDENT_UINT64 unsigned long
  16. /* Asm macros */
  17. static inline int
  18. ia64_acpi_acquire_global_lock(unsigned int *lock)
  19. {
  20. unsigned int old, new, val;
  21. do {
  22. old = *lock;
  23. new = (((old & ~0x3) + 2) + ((old >> 1) & 0x1));
  24. val = ia64_cmpxchg4_acq(lock, new, old);
  25. } while (unlikely (val != old));
  26. return (new < 3) ? -1 : 0;
  27. }
  28. static inline int
  29. ia64_acpi_release_global_lock(unsigned int *lock)
  30. {
  31. unsigned int old, new, val;
  32. do {
  33. old = *lock;
  34. new = old & ~0x3;
  35. val = ia64_cmpxchg4_acq(lock, new, old);
  36. } while (unlikely (val != old));
  37. return old & 0x1;
  38. }
  39. #define ACPI_ACQUIRE_GLOBAL_LOCK(facs, Acq) \
  40. ((Acq) = ia64_acpi_acquire_global_lock(&facs->global_lock))
  41. #define ACPI_RELEASE_GLOBAL_LOCK(facs, Acq) \
  42. ((Acq) = ia64_acpi_release_global_lock(&facs->global_lock))
  43. #endif /* _ASM_IA64_ACENV_H */