blob: 3f9eaeec98734852e98830969ccf826d399dabde [file] [log] [blame]
Lv Zheng07d83912014-05-12 15:46:38 +08001/*
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
12#ifndef _ASM_IA64_ACENV_H
13#define _ASM_IA64_ACENV_H
14
15#include <asm/intrinsics.h>
16
17#define COMPILER_DEPENDENT_INT64 long
18#define COMPILER_DEPENDENT_UINT64 unsigned long
19
Lv Zheng07d83912014-05-12 15:46:38 +080020/* Asm macros */
21
Lv Zheng07d83912014-05-12 15:46:38 +080022#ifdef CONFIG_ACPI
23
24static inline int
25ia64_acpi_acquire_global_lock(unsigned int *lock)
26{
27 unsigned int old, new, val;
28 do {
29 old = *lock;
30 new = (((old & ~0x3) + 2) + ((old >> 1) & 0x1));
31 val = ia64_cmpxchg4_acq(lock, new, old);
32 } while (unlikely (val != old));
33 return (new < 3) ? -1 : 0;
34}
35
36static inline int
37ia64_acpi_release_global_lock(unsigned int *lock)
38{
39 unsigned int old, new, val;
40 do {
41 old = *lock;
42 new = old & ~0x3;
43 val = ia64_cmpxchg4_acq(lock, new, old);
44 } while (unlikely (val != old));
45 return old & 0x1;
46}
47
48#define ACPI_ACQUIRE_GLOBAL_LOCK(facs, Acq) \
49 ((Acq) = ia64_acpi_acquire_global_lock(&facs->global_lock))
50
51#define ACPI_RELEASE_GLOBAL_LOCK(facs, Acq) \
52 ((Acq) = ia64_acpi_release_global_lock(&facs->global_lock))
53
54#endif
55
56#endif /* _ASM_IA64_ACENV_H */