Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/ntoskrnl.exe/ntoskrnl.exe.spec | 2 +- dlls/ntoskrnl.exe/sync.c | 11 ++++++++++- include/ddk/wdm.h | 1 + 3 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/dlls/ntoskrnl.exe/ntoskrnl.exe.spec b/dlls/ntoskrnl.exe/ntoskrnl.exe.spec index 28794d16de..e861000f26 100644 --- a/dlls/ntoskrnl.exe/ntoskrnl.exe.spec +++ b/dlls/ntoskrnl.exe/ntoskrnl.exe.spec @@ -594,7 +594,7 @@ @ stdcall KeReleaseMutex(ptr long) @ stdcall KeReleaseSemaphore(ptr long long long) @ stdcall -arch=arm,arm64,x86_64 KeReleaseSpinLock(ptr long) -@ stub KeReleaseSpinLockFromDpcLevel +@ stdcall KeReleaseSpinLockFromDpcLevel(ptr) @ stub KeRemoveByKeyDeviceQueue @ stub KeRemoveByKeyDeviceQueueIfBusy @ stub KeRemoveDeviceQueue diff --git a/dlls/ntoskrnl.exe/sync.c b/dlls/ntoskrnl.exe/sync.c index 475fcf1804..b439695fd7 100644 --- a/dlls/ntoskrnl.exe/sync.c +++ b/dlls/ntoskrnl.exe/sync.c @@ -386,7 +386,6 @@ void WINAPI KeInitializeSpinLock( KSPIN_LOCK *lock ) *lock = 0; }
-#ifndef __i386__ static inline void small_pause(void) { #ifdef __x86_64__ @@ -396,6 +395,16 @@ static inline void small_pause(void) #endif }
+/*********************************************************************** + * KeReleaseSpinLockFromDpcLevel (NTOSKRNL.EXE.@) + */ +void WINAPI KeReleaseSpinLockFromDpcLevel( KSPIN_LOCK *lock ) +{ + TRACE("lock %p.\n", lock); + InterlockedExchangePointer( (void **)lock, 0 ); +} + +#ifndef __i386__ /*********************************************************************** * KeReleaseSpinLock (NTOSKRNL.EXE.@) */ diff --git a/include/ddk/wdm.h b/include/ddk/wdm.h index ccaf5feb57..908e71c72d 100644 --- a/include/ddk/wdm.h +++ b/include/ddk/wdm.h @@ -1471,6 +1471,7 @@ BOOLEAN WINAPI KeRegisterBugCheckReasonCallback(KBUGCHECK_REASON_CALLBACK_RECO LONG WINAPI KeReleaseMutex(PRKMUTEX,BOOLEAN); LONG WINAPI KeReleaseSemaphore(PRKSEMAPHORE,KPRIORITY,LONG,BOOLEAN); void WINAPI KeReleaseSpinLock(KSPIN_LOCK*,KIRQL); +void WINAPI KeReleaseSpinLockFromDpcLevel(KSPIN_LOCK*); LONG WINAPI KeResetEvent(PRKEVENT); LONG WINAPI KeSetEvent(PRKEVENT,KPRIORITY,BOOLEAN); KPRIORITY WINAPI KeSetPriorityThread(PKTHREAD,KPRIORITY);
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/ntoskrnl.exe/ntoskrnl.exe.spec | 2 +- dlls/ntoskrnl.exe/sync.c | 10 ++++++++++ include/ddk/wdm.h | 1 + 3 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/dlls/ntoskrnl.exe/ntoskrnl.exe.spec b/dlls/ntoskrnl.exe/ntoskrnl.exe.spec index e861000f26..33aa108cd7 100644 --- a/dlls/ntoskrnl.exe/ntoskrnl.exe.spec +++ b/dlls/ntoskrnl.exe/ntoskrnl.exe.spec @@ -510,7 +510,7 @@ @ stub Ke386QueryIoAccessMap @ stdcall Ke386SetIoAccessMap(long ptr) @ stub KeAcquireInterruptSpinLock -@ stub KeAcquireSpinLockAtDpcLevel +@ stdcall KeAcquireSpinLockAtDpcLevel(ptr) @ stdcall -arch=arm,arm64,x86_64 KeAcquireSpinLockRaiseToDpc(ptr) @ stub KeAddSystemServiceTable @ stub KeAreApcsDisabled diff --git a/dlls/ntoskrnl.exe/sync.c b/dlls/ntoskrnl.exe/sync.c index b439695fd7..31a3ad7209 100644 --- a/dlls/ntoskrnl.exe/sync.c +++ b/dlls/ntoskrnl.exe/sync.c @@ -395,6 +395,16 @@ static inline void small_pause(void) #endif }
+/*********************************************************************** + * KeAcquireSpinLockAtDpcLevel (NTOSKRNL.EXE.@) + */ +void WINAPI KeAcquireSpinLockAtDpcLevel( KSPIN_LOCK *lock ) +{ + TRACE("lock %p.\n", lock); + while (!InterlockedCompareExchangePointer( (void **)lock, (void *)1, (void *)0 )) + small_pause(); +} + /*********************************************************************** * KeReleaseSpinLockFromDpcLevel (NTOSKRNL.EXE.@) */ diff --git a/include/ddk/wdm.h b/include/ddk/wdm.h index 908e71c72d..81f41f5a97 100644 --- a/include/ddk/wdm.h +++ b/include/ddk/wdm.h @@ -1454,6 +1454,7 @@ void WINAPI KeAcquireSpinLock(KSPIN_LOCK*,KIRQL*); #define KeAcquireSpinLock( lock, irql ) *(irql) = KeAcquireSpinLockRaiseToDpc( lock ) KIRQL WINAPI KeAcquireSpinLockRaiseToDpc(KSPIN_LOCK*); #endif +void WINAPI KeAcquireSpinLockAtDpcLevel(KSPIN_LOCK*); BOOLEAN WINAPI KeCancelTimer(KTIMER*); void WINAPI KeClearEvent(PRKEVENT); NTSTATUS WINAPI KeDelayExecutionThread(KPROCESSOR_MODE,BOOLEAN,LARGE_INTEGER*);
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/ntoskrnl.exe/sync.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/dlls/ntoskrnl.exe/sync.c b/dlls/ntoskrnl.exe/sync.c index 31a3ad7209..2a4685c5b3 100644 --- a/dlls/ntoskrnl.exe/sync.c +++ b/dlls/ntoskrnl.exe/sync.c @@ -421,7 +421,7 @@ void WINAPI KeReleaseSpinLockFromDpcLevel( KSPIN_LOCK *lock ) void WINAPI KeReleaseSpinLock( KSPIN_LOCK *lock, KIRQL irql ) { TRACE("lock %p, irql %u.\n", lock, irql); - InterlockedExchangePointer( (void **)lock, 0 ); + KeReleaseSpinLockFromDpcLevel( lock ); }
/*********************************************************************** @@ -430,8 +430,7 @@ void WINAPI KeReleaseSpinLock( KSPIN_LOCK *lock, KIRQL irql ) KIRQL WINAPI KeAcquireSpinLockRaiseToDpc( KSPIN_LOCK *lock ) { TRACE("lock %p.\n", lock); - while (!InterlockedCompareExchangePointer( (void **)lock, (void *)1, (void *)0 )) - small_pause(); + KeAcquireSpinLockAtDpcLevel( lock ); return 0; } #endif
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/hal/Makefile.in | 1 + dlls/hal/hal.c | 10 ++-------- 2 files changed, 3 insertions(+), 8 deletions(-)
diff --git a/dlls/hal/Makefile.in b/dlls/hal/Makefile.in index cc2620e921..63211a18d7 100644 --- a/dlls/hal/Makefile.in +++ b/dlls/hal/Makefile.in @@ -1,5 +1,6 @@ MODULE = hal.dll IMPORTLIB = hal +IMPORTS = ntoskrnl
C_SRCS = \ hal.c diff --git a/dlls/hal/hal.c b/dlls/hal/hal.c index fca4f23403..5b3ee44cff 100644 --- a/dlls/hal/hal.c +++ b/dlls/hal/hal.c @@ -76,16 +76,10 @@ KIRQL WINAPI DECLSPEC_HIDDEN __regs_KfAcquireSpinLock( KSPIN_LOCK *lock ) return irql; }
-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(); + KeAcquireSpinLockAtDpcLevel( lock ); *irql = 0; }
@@ -98,7 +92,7 @@ void WINAPI DECLSPEC_HIDDEN __regs_KfReleaseSpinLock( KSPIN_LOCK *lock, KIRQL ir void WINAPI KeReleaseSpinLock( KSPIN_LOCK *lock, KIRQL irql ) { TRACE("lock %p, irql %u.\n", lock, irql); - InterlockedExchangePointer( (void **)lock, 0 ); + KeReleaseSpinLockFromDpcLevel( lock ); } #endif /* __i386__ */