https://git.reactos.org/?p=reactos.git;a=commitdiff;h=56d0bc31ce6ac76ac3c3fca4820c3e6d441c5a52

commit 56d0bc31ce6ac76ac3c3fca4820c3e6d441c5a52
Author:     Jérôme Gardou <[email protected]>
AuthorDate: Wed May 26 17:03:55 2021 +0200
Commit:     Jérôme Gardou <[email protected]>
CommitDate: Tue Jun 29 11:49:20 2021 +0200

    [HAL] Hack KeTryToAcquireQueuedSpinlock & 
KeTryToAcquireQueuedSpinLockRaiseToSynch into a somewhat working implementation
---
 hal/halx86/generic/spinlock.c | 37 +++++++++++--------------------------
 1 file changed, 11 insertions(+), 26 deletions(-)

diff --git a/hal/halx86/generic/spinlock.c b/hal/halx86/generic/spinlock.c
index 2a2082ca131..4ffce2e665e 100644
--- a/hal/halx86/generic/spinlock.c
+++ b/hal/halx86/generic/spinlock.c
@@ -172,6 +172,7 @@ KeReleaseInStackQueuedSpinLock(IN PKLOCK_QUEUE_HANDLE 
LockHandle)
     KeLowerIrql(LockHandle->OldIrql);
 }
 
+#ifndef _MINIHAL_
 /*
  * @implemented
  */
@@ -180,20 +181,12 @@ FASTCALL
 KeTryToAcquireQueuedSpinLockRaiseToSynch(IN KSPIN_LOCK_QUEUE_NUMBER LockNumber,
                                          IN PKIRQL OldIrql)
 {
-#ifdef CONFIG_SMP
-    ERROR_DBGBREAK("FIXME: Unused\n"); // FIXME: Unused
-    return FALSE;
-#endif
+    PKSPIN_LOCK Lock = KeGetCurrentPrcb()->LockQueue[LockNumber].Lock;
 
-    /* Simply raise to synch */
+    /* KM tests demonstrate that this raises IRQL even if locking fails */
     KeRaiseIrql(SYNCH_LEVEL, OldIrql);
-
-    /* Add an explicit memory barrier to prevent the compiler from reordering
-       memory accesses across the borders of spinlocks */
-    KeMemoryBarrierWithoutFence();
-
-    /* Always return true on UP Machines */
-    return TRUE;
+    /* HACK */
+    return KeTryToAcquireSpinLockAtDpcLevel(Lock);
 }
 
 /*
@@ -204,23 +197,15 @@ FASTCALL
 KeTryToAcquireQueuedSpinLock(IN KSPIN_LOCK_QUEUE_NUMBER LockNumber,
                              OUT PKIRQL OldIrql)
 {
-#ifdef CONFIG_SMP
-    ERROR_DBGBREAK("FIXME: Unused\n"); // FIXME: Unused
-    return FALSE;
-#endif
+    PKSPIN_LOCK Lock = KeGetCurrentPrcb()->LockQueue[LockNumber].Lock;
 
-    /* Simply raise to dispatch */
+    /* KM tests demonstrate that this raises IRQL even if locking fails */
     KeRaiseIrql(DISPATCH_LEVEL, OldIrql);
-
-    /* Add an explicit memory barrier to prevent the compiler from reordering
-       memory accesses across the borders of spinlocks */
-    KeMemoryBarrierWithoutFence();
-
-    /* Always return true on UP Machines */
-    return TRUE;
+    /* HACK */
+    return KeTryToAcquireSpinLockAtDpcLevel(Lock);
 }
-
-#endif
+#endif /* !defined(_MINIHAL_) */
+#endif /* defined(_M_IX86) */
 
 VOID
 NTAPI

Reply via email to