diff --git a/reactos/ntoskrnl/ex/i386/fastinterlck_asm.S b/reactos/ntoskrnl/ex/i386/fastinterlck_asm.S index 89cc8786e39..3bfc090da21 100644 --- a/reactos/ntoskrnl/ex/i386/fastinterlck_asm.S +++ b/reactos/ntoskrnl/ex/i386/fastinterlck_asm.S @@ -8,28 +8,9 @@ /* INCLUDES ******************************************************************/ #include +#include .intel_syntax noprefix -//#define CONFIG_SMP - -#ifdef CONFIG_SMP -#define LOCK lock -#define ACQUIRE_SPINLOCK(x, y) \ - lock bts dword ptr [x], 0; \ - jb y -#define RELEASE_SPINLOCK(x) mov byte ptr [x], 0 -#define SPIN_ON_LOCK(x, y) \ -1: \ - test dword ptr [x], 1; \ - jz y; \ - pause; \ - jmp 1b -#else -#define LOCK -#define ACQUIRE_SPINLOCK(x, y) -#define RELEASE_SPINLOCK(x) -#endif - /* FUNCTIONS ****************************************************************/ /* diff --git a/reactos/ntoskrnl/ex/i386/interlck_asm.S b/reactos/ntoskrnl/ex/i386/interlck_asm.S index 9ba31c70ff0..0a81f482ffc 100644 --- a/reactos/ntoskrnl/ex/i386/interlck_asm.S +++ b/reactos/ntoskrnl/ex/i386/interlck_asm.S @@ -8,28 +8,9 @@ /* INCLUDES ******************************************************************/ #include +#include .intel_syntax noprefix -//#define CONFIG_SMP - -#ifdef CONFIG_SMP -#define LOCK lock -#define ACQUIRE_SPINLOCK(x, y) \ - lock bts dword ptr [x], 0; \ - jb y -#define RELEASE_SPINLOCK(x) mov byte ptr [x], 0 -#define SPIN_ON_LOCK(x, y) \ -1: \ - test dword ptr [x], 1; \ - jz y; \ - pause; \ - jmp 1b -#else -#define LOCK -#define ACQUIRE_SPINLOCK(x, y) -#define RELEASE_SPINLOCK(x) -#endif - /* FUNCTIONS ****************************************************************/ /* diff --git a/reactos/ntoskrnl/include/internal/i386/asmmacro.S b/reactos/ntoskrnl/include/internal/i386/asmmacro.S new file mode 100644 index 00000000000..45c7a9c796c --- /dev/null +++ b/reactos/ntoskrnl/include/internal/i386/asmmacro.S @@ -0,0 +1,52 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS kernel + * FILE: ntoskrnlinclude/i386/asmmacro.S + * PURPOSE: Assembly Macros for Spinlocks and common Trap Code (TODO) + * PROGRAMMERS: Alex Ionescu (alex@relsoft.net) + */ + +/* INCLUDES ******************************************************************/ +#include +.intel_syntax noprefix + +// +// These macros are inlined equivalents of KiAcquire/ReleaseSpinlock, that is, +// they will not be compiled into non-SMP builds. Usage is as follows: +// +// .BeginYourFunction +// mov reg, lockaddr +// ACQUIRE_SPINLOCK(reg, .spin) +// +// RELEASE_SPINLOCK(reg) +// +// retn +// #IFDEF CONFIG_SMP +// .spin +// +/ SPIN_ON_LOCK(reg, .BeginYourFunction) +// #ENDIF +// +#ifdef CONFIG_SMP +#define LOCK lock +#define ACQUIRE_SPINLOCK(x, y) \ + lock bts dword ptr [x], 0; \ + jb y +#define RELEASE_SPINLOCK(x) mov byte ptr [x], 0 +#define SPIN_ON_LOCK(x, y) \ +1: \ + test dword ptr [x], 1; \ + jz y; \ + pause; \ + jmp 1b +#else +#define LOCK +#define ACQUIRE_SPINLOCK(x, y) +#define RELEASE_SPINLOCK(x) +#endif + +// +// These macros control common execution paths for Traps and System Call Code +// TODO +// +