Zebediah Figura : hal: Implement KeAcquireSpinLock().
Alexandre Julliard
julliard at winehq.org
Thu Jan 24 14:42:54 CST 2019
Module: wine
Branch: master
Commit: 389b8fc3934f4445535f03a5530e3846732d6c5f
URL: https://source.winehq.org/git/wine.git/?a=commit;h=389b8fc3934f4445535f03a5530e3846732d6c5f
Author: Zebediah Figura <z.figura12 at gmail.com>
Date: Wed Jan 23 23:50:36 2019 -0600
hal: Implement KeAcquireSpinLock().
Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/hal/hal.c | 19 ++++++++++++++++---
dlls/hal/hal.spec | 2 +-
include/ddk/wdm.h | 3 +++
3 files changed, 20 insertions(+), 4 deletions(-)
diff --git a/dlls/hal/hal.c b/dlls/hal/hal.c
index 924fd9e..fca4f23 100644
--- a/dlls/hal/hal.c
+++ b/dlls/hal/hal.c
@@ -69,11 +69,24 @@ BOOLEAN WINAPI DECLSPEC_HIDDEN __regs_ExTryToAcquireFastMutex(PFAST_MUTEX FastMu
}
DEFINE_FASTCALL1_ENTRYPOINT( KfAcquireSpinLock )
-KIRQL WINAPI DECLSPEC_HIDDEN __regs_KfAcquireSpinLock(PKSPIN_LOCK SpinLock)
+KIRQL WINAPI DECLSPEC_HIDDEN __regs_KfAcquireSpinLock( KSPIN_LOCK *lock )
{
- FIXME( "(%p) stub!\n", SpinLock );
+ KIRQL irql;
+ KeAcquireSpinLock( lock, &irql );
+ return irql;
+}
- return 0;
+static inline void small_pause(void)
+{
+ __asm__ __volatile__( "rep;nop" : : : "memory" );
+}
+
+void WINAPI KeAcquireSpinLock( KSPIN_LOCK *lock, KIRQL *irql )
+{
+ TRACE("lock %p, irql %p.\n", lock, irql);
+ while (!InterlockedCompareExchangePointer( (void **)lock, (void *)1, (void *)0 ))
+ small_pause();
+ *irql = 0;
}
DEFINE_FASTCALL2_ENTRYPOINT( KfReleaseSpinLock )
diff --git a/dlls/hal/hal.spec b/dlls/hal/hal.spec
index 8596052..b4ec512 100644
--- a/dlls/hal/hal.spec
+++ b/dlls/hal/hal.spec
@@ -68,7 +68,7 @@
@ stub IoSetPartitionInformation
@ stub IoWritePartitionTable
@ stub KdComPortInUse
-@ stub KeAcquireSpinLock
+@ stdcall -arch=i386 KeAcquireSpinLock(ptr ptr)
@ stub KeFlushWriteBuffer
@ stdcall -arch=arm,arm64,i386 KeGetCurrentIrql()
@ stub KeLowerIrql
diff --git a/include/ddk/wdm.h b/include/ddk/wdm.h
index d964ecb..2822c69 100644
--- a/include/ddk/wdm.h
+++ b/include/ddk/wdm.h
@@ -1419,6 +1419,9 @@ void WINAPI IoReleaseCancelSpinLock(KIRQL);
NTSTATUS WINAPI IoSetDeviceInterfaceState(UNICODE_STRING*,BOOLEAN);
NTSTATUS WINAPI IoWMIRegistrationControl(PDEVICE_OBJECT,ULONG);
+#ifdef __i386__
+void WINAPI KeAcquireSpinLock(KSPIN_LOCK*,KIRQL*);
+#endif
BOOLEAN WINAPI KeCancelTimer(KTIMER*);
void WINAPI KeClearEvent(PRKEVENT);
NTSTATUS WINAPI KeDelayExecutionThread(KPROCESSOR_MODE,BOOLEAN,LARGE_INTEGER*);
More information about the wine-cvs
mailing list