- Separate UP and MP spinlock functions.
authorAlex Ionescu <aionescu@gmail.com>
Thu, 5 Jan 2006 13:51:06 +0000 (13:51 +0000)
committerAlex Ionescu <aionescu@gmail.com>
Thu, 5 Jan 2006 13:51:06 +0000 (13:51 +0000)
- Optimize UP spinlock functions so they don't call ntoskrnl anymore and only raise/lower irql.
- Implemented Queued Spinlocks and In-Stack Queued Spinlocks for UP machines.
* Implemented KeAcquireInStackQueuedSpinLock, KeReleaseInStackQueuedSpinLock, KeAcquireQueuedSpinLock, KeReleaseQueuedSpinLock, KeTryToAcquireQueuedSpinLock, KeTryToAcquireQueuedSpinLockRaiseToSynch, KeAcquireQueuedSpinLockRaisetoSynch.

svn path=/trunk/; revision=20575

reactos/hal/halx86/generic/generic.xml
reactos/hal/halx86/mp/halmp.xml
reactos/hal/halx86/mp/spinlock.c [moved from reactos/hal/halx86/generic/spinlock.c with 100% similarity]
reactos/hal/halx86/up/halup.xml
reactos/hal/halx86/up/spinlock.c [new file with mode: 0644]

index 2566f0e..8d4ea80 100644 (file)
@@ -18,7 +18,6 @@
        <file>pci.c</file>
        <file>portio.c</file>
        <file>reboot.c</file>
        <file>pci.c</file>
        <file>portio.c</file>
        <file>reboot.c</file>
-       <file>spinlock.c</file>
        <file>sysbus.c</file>
        <file>sysinfo.c</file>
        <file>time.c</file>
        <file>sysbus.c</file>
        <file>sysinfo.c</file>
        <file>time.c</file>
index 660cb13..b2facb9 100644 (file)
@@ -20,5 +20,6 @@
        <file>mpsirql.c</file>
        <file>processor_mp.c</file>
        <file>resource_mp.c</file>
        <file>mpsirql.c</file>
        <file>processor_mp.c</file>
        <file>resource_mp.c</file>
+       <file>spinlock.c</file>
        <file>halmp.rc</file>
 </module>
        <file>halmp.rc</file>
 </module>
index eb550f5..d07deb6 100644 (file)
@@ -11,5 +11,6 @@
        <library>hal_generic_pc</library>
        <library>ntoskrnl</library>
        <file>halinit_up.c</file>
        <library>hal_generic_pc</library>
        <library>ntoskrnl</library>
        <file>halinit_up.c</file>
+       <file>spinlock.c</file>
        <file>halup.rc</file>
 </module>
        <file>halup.rc</file>
 </module>
diff --git a/reactos/hal/halx86/up/spinlock.c b/reactos/hal/halx86/up/spinlock.c
new file mode 100644 (file)
index 0000000..4ff00d3
--- /dev/null
@@ -0,0 +1,166 @@
+/*
+ * COPYRIGHT:       See COPYING in the top level directory
+ * PROJECT:         ReactOS kernel
+ * FILE:            ntoskrnl/hal/halx86/up/spinlock.c
+ * PURPOSE:         Implements spinlocks
+ * PROGRAMMER:      Alex Ionescu (alex@relsoft.net)
+ */
+
+/* INCLUDES ****************************************************************/
+
+#include <hal.h>
+#define NDEBUG
+#include <debug.h>
+
+#undef KeAcquireSpinLock
+#undef KeReleaseSpinLock
+
+/* FUNCTIONS ***************************************************************/
+
+/*
+ * @implemented
+ */
+VOID
+NTAPI
+KeAcquireSpinLock(PKSPIN_LOCK SpinLock,
+                  PKIRQL OldIrql)
+{
+    /* Call the fastcall function */
+    *OldIrql = KfAcquireSpinLock(SpinLock);
+}
+
+/*
+ * @implemented
+ */
+KIRQL
+FASTCALL
+KeAcquireSpinLockRaiseToSynch(PKSPIN_LOCK SpinLock)
+{
+    /* Simply raise to dispatch */
+    return KfRaiseIrql(DISPATCH_LEVEL);
+}
+
+/*
+ * @implemented
+ */
+VOID
+NTAPI
+KeReleaseSpinLock(PKSPIN_LOCK SpinLock,
+                  KIRQL NewIrql)
+{
+    /* Call the fastcall function */
+    KfReleaseSpinLock(SpinLock, NewIrql);
+}
+
+/*
+ * @implemented
+ */
+KIRQL
+FASTCALL
+KfAcquireSpinLock(PKSPIN_LOCK SpinLock)
+{
+    /* Simply raise to dispatch */
+    return KfRaiseIrql(DISPATCH_LEVEL);
+}
+
+/*
+ * @implemented
+ */
+VOID
+FASTCALL
+KfReleaseSpinLock(PKSPIN_LOCK SpinLock,
+                  KIRQL OldIrql)
+{
+    /* Simply lower IRQL back */
+    KfLowerIrql(OldIrql);
+}
+
+/*
+ * @implemented
+ */
+KIRQL
+FASTCALL
+KeAcquireQueuedSpinLock(IN PKLOCK_QUEUE_HANDLE LockHandle)
+{
+    /* Simply raise to dispatch */
+    return KfRaiseIrql(DISPATCH_LEVEL);
+}
+
+/*
+ * @implemented
+ */
+KIRQL
+FASTCALL
+KeAcquireQueuedSpinLockRaiseToSynch(IN PKLOCK_QUEUE_HANDLE LockHandle)
+{
+    /* Simply raise to dispatch */
+    return KfRaiseIrql(DISPATCH_LEVEL);
+}
+
+/*
+ * @implemented
+ */
+VOID
+FASTCALL
+KeAcquireInStackQueuedSpinLock(IN PKSPIN_LOCK SpinLock,
+                               IN PKLOCK_QUEUE_HANDLE LockHandle)
+{
+    /* Simply raise to dispatch */
+    LockHandle->OldIrql = KfRaiseIrql(DISPATCH_LEVEL);
+}
+
+/*
+ * @implemented
+ */
+VOID
+FASTCALL
+KeReleaseQueuedSpinLock(IN PKLOCK_QUEUE_HANDLE LockHandle,
+                        IN KIRQL OldIrql)
+{
+    /* Simply lower IRQL back */
+    KfLowerIrql(OldIrql);
+}
+
+/*
+ * @implemented
+ */
+VOID
+FASTCALL
+KeReleaseInStackQueuedSpinLock(IN PKLOCK_QUEUE_HANDLE LockHandle)
+{
+    /* Simply lower IRQL back */
+    KfLowerIrql(LockHandle->OldIrql);
+}
+
+/*
+ * @implemented
+ */
+BOOLEAN
+FASTCALL
+KeTryToAcquireQueuedSpinLockRaiseToSynch(IN PKLOCK_QUEUE_HANDLE LockHandle,
+                                         IN PKIRQL OldIrql)
+{
+    /* Simply raise to dispatch */
+    *OldIrql = KfRaiseIrql(DISPATCH_LEVEL);
+
+    /* Always return true on UP Machines */
+    return TRUE;
+}
+
+/*
+ * @implemented
+ */
+BOOLEAN
+FASTCALL
+KeTryToAcquireQueuedSpinLock(IN PKLOCK_QUEUE_HANDLE LockHandle,
+                             IN PKIRQL OldIrql)
+{
+    /* Simply raise to dispatch */
+    *OldIrql = KfRaiseIrql(DISPATCH_LEVEL);
+
+    /* Always return true on UP Machines */
+    return TRUE;
+}
+
+
+/* EOF */