[ros-diffs] [tkreuzer] 44893: [NTOS] Move spinlock inline functions into their own header, so they can be shared with hal.

tkreuzer at svn.reactos.org tkreuzer at svn.reactos.org
Sat Jan 2 20:41:03 CET 2010


Author: tkreuzer
Date: Sat Jan  2 20:41:03 2010
New Revision: 44893

URL: http://svn.reactos.org/svn/reactos?rev=44893&view=rev
Log:
[NTOS]
Move spinlock inline functions into their own header, so they can be shared with hal.

Added:
    branches/ros-amd64-bringup/reactos/ntoskrnl/include/internal/spinlock.h   (with props)
Modified:
    branches/ros-amd64-bringup/reactos/ntoskrnl/include/internal/ke_x.h
    branches/ros-amd64-bringup/reactos/ntoskrnl/include/internal/ntoskrnl.h

Modified: branches/ros-amd64-bringup/reactos/ntoskrnl/include/internal/ke_x.h
URL: http://svn.reactos.org/svn/reactos/branches/ros-amd64-bringup/reactos/ntoskrnl/include/internal/ke_x.h?rev=44893&r1=44892&r2=44893&view=diff
==============================================================================
--- branches/ros-amd64-bringup/reactos/ntoskrnl/include/internal/ke_x.h [iso-8859-1] (original)
+++ branches/ros-amd64-bringup/reactos/ntoskrnl/include/internal/ke_x.h [iso-8859-1] Sat Jan  2 20:41:03 2010
@@ -101,32 +101,7 @@
     }                                                                       \
 }
 
-VOID
-NTAPI
-Kii386SpinOnSpinLock(PKSPIN_LOCK SpinLock, ULONG Flags);
-
 #ifndef CONFIG_SMP
-//
-// Spinlock Acquire at IRQL >= DISPATCH_LEVEL
-//
-FORCEINLINE
-VOID
-KxAcquireSpinLock(IN PKSPIN_LOCK SpinLock)
-{
-    /* On UP builds, spinlocks don't exist at IRQL >= DISPATCH */
-    UNREFERENCED_PARAMETER(SpinLock);
-}
-
-//
-// Spinlock Release at IRQL >= DISPATCH_LEVEL
-//
-FORCEINLINE
-VOID
-KxReleaseSpinLock(IN PKSPIN_LOCK SpinLock)
-{
-    /* On UP builds, spinlocks don't exist at IRQL >= DISPATCH */
-    UNREFERENCED_PARAMETER(SpinLock);
-}
 
 //
 // This routine protects against multiple CPU acquires, it's meaningless on UP.
@@ -306,62 +281,6 @@
 }
 
 #else
-
-//
-// Spinlock Acquisition at IRQL >= DISPATCH_LEVEL
-//
-FORCEINLINE
-VOID
-KxAcquireSpinLock(IN PKSPIN_LOCK SpinLock)
-{
-#ifdef DBG
-    /* Make sure that we don't own the lock already */
-    if (((KSPIN_LOCK)KeGetCurrentThread() | 1) == *SpinLock)
-    {
-        /* We do, bugcheck! */
-        KeBugCheckEx(SPIN_LOCK_ALREADY_OWNED, (ULONG_PTR)SpinLock, 0, 0, 0);
-    }
-#endif
-
-    /* Try to acquire the lock */
-    while (InterlockedBitTestAndSet((PLONG)SpinLock, 0))
-    {
-#if defined(_M_IX86) && defined(DBG)
-        /* On x86 debug builds, we use a much slower but useful routine */
-        Kii386SpinOnSpinLock(SpinLock, 5);
-#else
-        /* It's locked... spin until it's unlocked */
-        while (*(volatile KSPIN_LOCK *)SpinLock & 1)
-        {
-                /* Yield and keep looping */
-                YieldProcessor();
-        }
-#endif
-    }
-#ifdef DBG
-    /* On debug builds, we OR in the KTHREAD */
-    *SpinLock = (KSPIN_LOCK)KeGetCurrentThread() | 1;
-#endif
-}
-
-//
-// Spinlock Release at IRQL >= DISPATCH_LEVEL
-//
-FORCEINLINE
-VOID
-KxReleaseSpinLock(IN PKSPIN_LOCK SpinLock)
-{
-#if DBG
-    /* Make sure that the threads match */
-    if (((KSPIN_LOCK)KeGetCurrentThread() | 1) != *SpinLock)
-    {
-        /* They don't, bugcheck */
-        KeBugCheckEx(SPIN_LOCK_NOT_OWNED, (ULONG_PTR)SpinLock, 0, 0, 0);
-    }
-#endif
-    /* Clear the lock */
-    InterlockedAnd((PLONG)SpinLock, 0);
-}
 
 FORCEINLINE
 VOID

Modified: branches/ros-amd64-bringup/reactos/ntoskrnl/include/internal/ntoskrnl.h
URL: http://svn.reactos.org/svn/reactos/branches/ros-amd64-bringup/reactos/ntoskrnl/include/internal/ntoskrnl.h?rev=44893&r1=44892&r2=44893&view=diff
==============================================================================
--- branches/ros-amd64-bringup/reactos/ntoskrnl/include/internal/ntoskrnl.h [iso-8859-1] (original)
+++ branches/ros-amd64-bringup/reactos/ntoskrnl/include/internal/ntoskrnl.h [iso-8859-1] Sat Jan  2 20:41:03 2010
@@ -83,6 +83,7 @@
 #include "../kdbg/kdb.h"
 #endif
 #include "dbgk.h"
+#include "spinlock.h"
 #include "tag.h"
 #include "test.h"
 #include "inbv.h"

Added: branches/ros-amd64-bringup/reactos/ntoskrnl/include/internal/spinlock.h
URL: http://svn.reactos.org/svn/reactos/branches/ros-amd64-bringup/reactos/ntoskrnl/include/internal/spinlock.h?rev=44893&view=auto
==============================================================================
--- branches/ros-amd64-bringup/reactos/ntoskrnl/include/internal/spinlock.h (added)
+++ branches/ros-amd64-bringup/reactos/ntoskrnl/include/internal/spinlock.h [iso-8859-1] Sat Jan  2 20:41:03 2010
@@ -1,0 +1,95 @@
+/*
+* PROJECT:         ReactOS Kernel
+* LICENSE:         GPL - See COPYING in the top level directory
+* FILE:            ntoskrnl/include/spinlock.h
+* PURPOSE:         Internal Inlined Functions for spinlocks, shared with HAL
+* PROGRAMMERS:     Alex Ionescu (alex.ionescu at reactos.org)
+*/
+
+VOID
+NTAPI
+Kii386SpinOnSpinLock(PKSPIN_LOCK SpinLock, ULONG Flags);
+
+#ifndef CONFIG_SMP
+
+//
+// Spinlock Acquire at IRQL >= DISPATCH_LEVEL
+//
+FORCEINLINE
+VOID
+KxAcquireSpinLock(IN PKSPIN_LOCK SpinLock)
+{
+    /* On UP builds, spinlocks don't exist at IRQL >= DISPATCH */
+    UNREFERENCED_PARAMETER(SpinLock);
+}
+
+//
+// Spinlock Release at IRQL >= DISPATCH_LEVEL
+//
+FORCEINLINE
+VOID
+KxReleaseSpinLock(IN PKSPIN_LOCK SpinLock)
+{
+    /* On UP builds, spinlocks don't exist at IRQL >= DISPATCH */
+    UNREFERENCED_PARAMETER(SpinLock);
+}
+
+#else
+
+//
+// Spinlock Acquisition at IRQL >= DISPATCH_LEVEL
+//
+FORCEINLINE
+VOID
+KxAcquireSpinLock(IN PKSPIN_LOCK SpinLock)
+{
+#ifdef DBG
+    /* Make sure that we don't own the lock already */
+    if (((KSPIN_LOCK)KeGetCurrentThread() | 1) == *SpinLock)
+    {
+        /* We do, bugcheck! */
+        KeBugCheckEx(SPIN_LOCK_ALREADY_OWNED, (ULONG_PTR)SpinLock, 0, 0, 0);
+    }
+#endif
+
+    /* Try to acquire the lock */
+    while (InterlockedBitTestAndSet((PLONG)SpinLock, 0))
+    {
+#if defined(_M_IX86) && defined(DBG)
+        /* On x86 debug builds, we use a much slower but useful routine */
+        Kii386SpinOnSpinLock(SpinLock, 5);
+#else
+        /* It's locked... spin until it's unlocked */
+        while (*(volatile KSPIN_LOCK *)SpinLock & 1)
+        {
+                /* Yield and keep looping */
+                YieldProcessor();
+        }
+#endif
+    }
+#ifdef DBG
+    /* On debug builds, we OR in the KTHREAD */
+    *SpinLock = (KSPIN_LOCK)KeGetCurrentThread() | 1;
+#endif
+}
+
+//
+// Spinlock Release at IRQL >= DISPATCH_LEVEL
+//
+FORCEINLINE
+VOID
+KxReleaseSpinLock(IN PKSPIN_LOCK SpinLock)
+{
+#if DBG
+    /* Make sure that the threads match */
+    if (((KSPIN_LOCK)KeGetCurrentThread() | 1) != *SpinLock)
+    {
+        /* They don't, bugcheck */
+        KeBugCheckEx(SPIN_LOCK_NOT_OWNED, (ULONG_PTR)SpinLock, 0, 0, 0);
+    }
+#endif
+    /* Clear the lock */
+    InterlockedAnd((PLONG)SpinLock, 0);
+}
+
+#endif

Propchange: branches/ros-amd64-bringup/reactos/ntoskrnl/include/internal/spinlock.h
------------------------------------------------------------------------------
    svn:eol-style = native




More information about the Ros-diffs mailing list