Author: tkreuzer
Date: Sat Jun 4 15:42:32 2011
New Revision: 52079
URL:
http://svn.reactos.org/svn/reactos?rev=52079&view=rev
Log:
[NTOSKRNL/DDK]
- add definition for KeMemoryBarrierWithoutFence
- add x64 version of KeMemoryBarrier and some related defines
- Use KeMemoryBarrierWithoutFence in spinlocks as suggested by Alex
Modified:
trunk/reactos/include/ddk/wdm.h
trunk/reactos/include/xdk/amd64/ke.h
trunk/reactos/include/xdk/x86/ke.h
trunk/reactos/ntoskrnl/include/internal/spinlock.h
trunk/reactos/ntoskrnl/ke/amd64/spinlock.c
Modified: trunk/reactos/include/ddk/wdm.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/ddk/wdm.h?rev=5207…
==============================================================================
--- trunk/reactos/include/ddk/wdm.h [iso-8859-1] (original)
+++ trunk/reactos/include/ddk/wdm.h [iso-8859-1] Sat Jun 4 15:42:32 2011
@@ -170,7 +170,7 @@
#elif defined(_WDM_INCLUDED_)
typedef struct _DMA_ADAPTER *PADAPTER_OBJECT;
#else
-typedef struct _ADAPTER_OBJECT *PADAPTER_OBJECT;
+typedef struct _ADAPTER_OBJECT *PADAPTER_OBJECT;
#endif
#ifndef DEFINE_GUIDEX
@@ -191,7 +191,7 @@
#ifdef __cplusplus
inline int IsEqualGUIDAligned(REFGUID guid1, REFGUID guid2)
{
- return ( (*(PLONGLONG)(&guid1) == *(PLONGLONG)(&guid2)) &&
+ return ( (*(PLONGLONG)(&guid1) == *(PLONGLONG)(&guid2)) &&
(*((PLONGLONG)(&guid1) + 1) == *((PLONGLONG)(&guid2) + 1)) );
}
#else
@@ -7718,6 +7718,8 @@
#endif
}
+#define KeMemoryBarrierWithoutFence() _ReadWriteBarrier()
+
NTHALAPI
KIRQL
NTAPI
@@ -7875,6 +7877,21 @@
#define KeGetDcacheFillSize() 1L
#define YieldProcessor _mm_pause
+#define FastFence __faststorefence
+#define LoadFence _mm_lfence
+#define MemoryFence _mm_mfence
+#define StoreFence _mm_sfence
+#define LFENCE_ACQUIRE() LoadFence()
+
+FORCEINLINE
+VOID
+KeMemoryBarrier(VOID)
+{
+ FastFence();
+ LFENCE_ACQUIRE();
+}
+
+#define KeMemoryBarrierWithoutFence() _ReadWriteBarrier()
FORCEINLINE
KIRQL
@@ -13290,14 +13307,14 @@
#if defined(_WIN2K_COMPAT_SLIST_USAGE) && defined(_X86_)
NTKERNELAPI
-PSINGLE_LIST_ENTRY
+PSINGLE_LIST_ENTRY
FASTCALL
ExInterlockedPopEntrySList(
IN PSLIST_HEADER ListHead,
IN PKSPIN_LOCK Lock);
NTKERNELAPI
-PSINGLE_LIST_ENTRY
+PSINGLE_LIST_ENTRY
FASTCALL
ExInterlockedPushEntrySList(
IN PSLIST_HEADER ListHead,
Modified: trunk/reactos/include/xdk/amd64/ke.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/xdk/amd64/ke.h?rev…
==============================================================================
--- trunk/reactos/include/xdk/amd64/ke.h [iso-8859-1] (original)
+++ trunk/reactos/include/xdk/amd64/ke.h [iso-8859-1] Sat Jun 4 15:42:32 2011
@@ -45,6 +45,22 @@
#define KeGetDcacheFillSize() 1L
#define YieldProcessor _mm_pause
+#define FastFence __faststorefence
+#define LoadFence _mm_lfence
+#define MemoryFence _mm_mfence
+#define StoreFence _mm_sfence
+#define LFENCE_ACQUIRE() LoadFence()
+
+FORCEINLINE
+VOID
+KeMemoryBarrier(VOID)
+{
+ // FIXME: Do we really need lfence after the __faststorefence ?
+ FastFence();
+ LFENCE_ACQUIRE();
+}
+
+#define KeMemoryBarrierWithoutFence() _ReadWriteBarrier()
FORCEINLINE
KIRQL
Modified: trunk/reactos/include/xdk/x86/ke.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/xdk/x86/ke.h?rev=5…
==============================================================================
--- trunk/reactos/include/xdk/x86/ke.h [iso-8859-1] (original)
+++ trunk/reactos/include/xdk/x86/ke.h [iso-8859-1] Sat Jun 4 15:42:32 2011
@@ -58,6 +58,8 @@
__asm xchg [Barrier], eax
#endif
}
+
+#define KeMemoryBarrierWithoutFence() _ReadWriteBarrier()
NTHALAPI
KIRQL
Modified: trunk/reactos/ntoskrnl/include/internal/spinlock.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/…
==============================================================================
--- trunk/reactos/ntoskrnl/include/internal/spinlock.h [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/include/internal/spinlock.h [iso-8859-1] Sat Jun 4 15:42:32
2011
@@ -24,7 +24,7 @@
/* Add an explicit memory barrier to prevent the compiler from reordering
memory accesses across the borders of spinlocks */
- _ReadWriteBarrier();
+ KeMemoryBarrierWithoutFence();
}
//
@@ -39,7 +39,7 @@
/* Add an explicit memory barrier to prevent the compiler from reordering
memory accesses across the borders of spinlocks */
- _ReadWriteBarrier();
+ KeMemoryBarrierWithoutFence();
}
#else
Modified: trunk/reactos/ntoskrnl/ke/amd64/spinlock.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ke/amd64/spinlock…
==============================================================================
--- trunk/reactos/ntoskrnl/ke/amd64/spinlock.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/ke/amd64/spinlock.c [iso-8859-1] Sat Jun 4 15:42:32 2011
@@ -173,7 +173,7 @@
/* Add an explicit memory barrier to prevent the compiler from reordering
memory accesses across the borders of spinlocks */
- _ReadWriteBarrier();
+ KeMemoryBarrierWithoutFence();
/* Always return true on UP Machines */
return TRUE;
@@ -196,7 +196,7 @@
/* Add an explicit memory barrier to prevent the compiler from reordering
memory accesses across the borders of spinlocks */
- _ReadWriteBarrier();
+ KeMemoryBarrierWithoutFence();
/* Always return true on UP Machines */
return TRUE;