diff --git a/drivers/bus/acpi/include/platform/acmsc.h b/drivers/bus/acpi/include/platform/acmsc.h new file mode 100644 index 00000000000..612edf938c2 --- /dev/null +++ b/drivers/bus/acpi/include/platform/acmsc.h @@ -0,0 +1,67 @@ +#ifndef __ACMSC_H__ +#define __ACMSC_H__ + +#define COMPILER_DEPENDENT_UINT64 unsigned __int64 + +#if defined(_M_IX86) + +#define ACPI_ASM_MACROS +#define causeinterrupt(level) +#define BREAKPOINT3 +#define halt() { __asm { sti } __asm { hlt } } +#define wbinvd() + +__forceinline void _ACPI_ACQUIRE_GLOBAL_LOCK(void * GLptr, unsigned char * Acq_) +{ + unsigned char Acq; + + __asm + { + mov ecx, [GLptr] + + L1: mov eax, [ecx] + mov edx, eax + and edx, ecx + bts edx, 1 + adc edx, 0 + lock cmpxchg [ecx], edx + jne L1 + cmp dl, 3 + sbb eax, eax + + mov [Acq], al + }; + + *Acq_ = Acq; +} + +#define ACPI_ACQUIRE_GLOBAL_LOCK(GLptr, Acq) \ + _ACPI_ACQUIRE_GLOBAL_LOCK((GLptr), (unsigned char *)&(Acq)) + +__forceinline void _ACPI_RELEASE_GLOBAL_LOCK(void * GLptr, unsigned char * Acq_) +{ + unsigned char Acq; + + __asm + { + mov ecx, [GLptr] + + L1: mov eax, [ecx] + mov edx, eax + and edx, ecx + lock cmpxchg [ecx], edx + jnz L1 + and eax, 1 + + mov [Acq], al + }; + + *Acq_ = Acq; +} + +#define ACPI_RELEASE_GLOBAL_LOCK(GLptr, Acq) \ + _ACPI_RELEASE_GLOBAL_LOCK((GLptr), (unsigned char *)&(Acq)) + +#endif + +#endif /* __ACMSC_H__ */ diff --git a/drivers/bus/acpi/include/platform/acwin.h b/drivers/bus/acpi/include/platform/acwin.h index 297f29f6ae9..cfab7728f6f 100644 --- a/drivers/bus/acpi/include/platform/acwin.h +++ b/drivers/bus/acpi/include/platform/acwin.h @@ -47,14 +47,25 @@ #endif -/* ReactOS uses GCC */ +#if defined(__GNUC__) #include "acgcc.h" #undef disable -#define disable() __asm__("cli\n\t"); +#define disable() __asm__("cli\n\t") #undef enable -#define enable() __asm__("sti\n\t"); +#define enable() __asm__("sti\n\t") + +#elif defined(_MSC_VER) + +#include "acmsc.h" + +#undef disable +#define disable() __asm { cli } +#undef enable +#define enable() __asm { sti } + +#endif #undef DEBUGGER_THREADING #define DEBUGGER_THREADING DEBUGGER_SINGLE_THREADED