Merging r37048, r37051, r37052, r37055 from the-real-msvc branch
[reactos.git] / reactos / drivers / bus / acpi / include / platform / acmsc.h
1 #ifndef __ACMSC_H__
2 #define __ACMSC_H__
3
4 #define COMPILER_DEPENDENT_UINT64 unsigned __int64
5
6 #if defined(_M_IX86)
7
8 #define ACPI_ASM_MACROS
9 #define causeinterrupt(level)
10 #define BREAKPOINT3
11 #define halt() { __asm { sti } __asm { hlt } }
12 #define wbinvd()
13
14 __forceinline void _ACPI_ACQUIRE_GLOBAL_LOCK(void * GLptr, unsigned char * Acq_)
15 {
16 unsigned char Acq;
17
18 __asm
19 {
20 mov ecx, [GLptr]
21
22 L1: mov eax, [ecx]
23 mov edx, eax
24 and edx, ecx
25 bts edx, 1
26 adc edx, 0
27 lock cmpxchg [ecx], edx
28 jne L1
29 cmp dl, 3
30 sbb eax, eax
31
32 mov [Acq], al
33 };
34
35 *Acq_ = Acq;
36 }
37
38 #define ACPI_ACQUIRE_GLOBAL_LOCK(GLptr, Acq) \
39 _ACPI_ACQUIRE_GLOBAL_LOCK((GLptr), (unsigned char *)&(Acq))
40
41 __forceinline void _ACPI_RELEASE_GLOBAL_LOCK(void * GLptr, unsigned char * Acq_)
42 {
43 unsigned char Acq;
44
45 __asm
46 {
47 mov ecx, [GLptr]
48
49 L1: mov eax, [ecx]
50 mov edx, eax
51 and edx, ecx
52 lock cmpxchg [ecx], edx
53 jnz L1
54 and eax, 1
55
56 mov [Acq], al
57 };
58
59 *Acq_ = Acq;
60 }
61
62 #define ACPI_RELEASE_GLOBAL_LOCK(GLptr, Acq) \
63 _ACPI_RELEASE_GLOBAL_LOCK((GLptr), (unsigned char *)&(Acq))
64
65 #endif
66
67 #endif /* __ACMSC_H__ */