ReactOS  0.4.15-dev-2993-g14fbe80
spinlock.c File Reference
#include <ntoskrnl.h>
#include <debug.h>
Include dependency graph for spinlock.c:

Go to the source code of this file.

Macros

#define NDEBUG
 
#define LQ_WAIT   1
 
#define LQ_OWN   2
 

Functions

 _IRQL_requires_min_ (DISPATCH_LEVEL)
 
KIRQL NTAPI KeAcquireInterruptSpinLock (IN PKINTERRUPT Interrupt)
 
VOID NTAPI KeReleaseInterruptSpinLock (IN PKINTERRUPT Interrupt, IN KIRQL OldIrql)
 
VOID NTAPI _KeInitializeSpinLock (IN PKSPIN_LOCK SpinLock)
 
VOID NTAPI KeAcquireSpinLockAtDpcLevel (IN PKSPIN_LOCK SpinLock)
 
VOID NTAPI KeReleaseSpinLockFromDpcLevel (IN PKSPIN_LOCK SpinLock)
 
VOID FASTCALL KefAcquireSpinLockAtDpcLevel (IN PKSPIN_LOCK SpinLock)
 
VOID FASTCALL KefReleaseSpinLockFromDpcLevel (IN PKSPIN_LOCK SpinLock)
 
VOID FASTCALL KiAcquireSpinLock (IN PKSPIN_LOCK SpinLock)
 
VOID FASTCALL KiReleaseSpinLock (IN PKSPIN_LOCK SpinLock)
 
BOOLEAN FASTCALL KeTryToAcquireSpinLockAtDpcLevel (IN OUT PKSPIN_LOCK SpinLock)
 
VOID FASTCALL KeAcquireInStackQueuedSpinLockAtDpcLevel (IN PKSPIN_LOCK SpinLock, IN PKLOCK_QUEUE_HANDLE LockHandle)
 
VOID FASTCALL KeReleaseInStackQueuedSpinLockFromDpcLevel (IN PKLOCK_QUEUE_HANDLE LockHandle)
 
KIRQL FASTCALL KeAcquireSpinLockForDpc (IN PKSPIN_LOCK SpinLock)
 
VOID FASTCALL KeReleaseSpinLockForDpc (IN PKSPIN_LOCK SpinLock, IN KIRQL OldIrql)
 
VOID FASTCALL KeAcquireInStackQueuedSpinLockForDpc (IN PKSPIN_LOCK SpinLock, IN PKLOCK_QUEUE_HANDLE LockHandle)
 
VOID FASTCALL KeReleaseInStackQueuedSpinLockForDpc (IN PKLOCK_QUEUE_HANDLE LockHandle)
 
BOOLEAN FASTCALL KeTestSpinLock (IN PKSPIN_LOCK SpinLock)
 

Macro Definition Documentation

◆ LQ_OWN

#define LQ_OWN   2

Definition at line 16 of file spinlock.c.

◆ LQ_WAIT

#define LQ_WAIT   1

Definition at line 15 of file spinlock.c.

◆ NDEBUG

#define NDEBUG

Definition at line 12 of file spinlock.c.

Function Documentation

◆ _IRQL_requires_min_()

_IRQL_requires_min_ ( DISPATCH_LEVEL  )

Definition at line 97 of file spinlock.c.

103 {
104 #if defined(CONFIG_SMP) || DBG
105  /* Make sure we are at DPC or above! */
107  {
108  /* We aren't -- bugcheck */
109  KeBugCheckEx(IRQL_NOT_GREATER_OR_EQUAL,
110  (ULONG_PTR)LockHandle->Lock,
112  0,
113  0);
114  }
115 #endif
116 
117  /* Do the inlined function */
118  KxAcquireSpinLock(LockHandle->Lock);
119 }
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
*LockHandle LockHandle _Out_ PKLOCK_QUEUE_HANDLE LockHandle
Definition: kefuncs.h:729
VOID NTAPI KeBugCheckEx(_In_ ULONG BugCheckCode, _In_ ULONG_PTR BugCheckParameter1, _In_ ULONG_PTR BugCheckParameter2, _In_ ULONG_PTR BugCheckParameter3, _In_ ULONG_PTR BugCheckParameter4)
Definition: rtlcompat.c:108

◆ _KeInitializeSpinLock()

VOID NTAPI _KeInitializeSpinLock ( IN PKSPIN_LOCK  SpinLock)

Definition at line 186 of file spinlock.c.

187 {
188  /* Clear it */
189  *SpinLock = 0;
190 }
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFSPINLOCK * SpinLock
Definition: wdfsync.h:225

◆ KeAcquireInStackQueuedSpinLockAtDpcLevel()

VOID FASTCALL KeAcquireInStackQueuedSpinLockAtDpcLevel ( IN PKSPIN_LOCK  SpinLock,
IN PKLOCK_QUEUE_HANDLE  LockHandle 
)

Definition at line 363 of file spinlock.c.

365 {
366  /* Set it up properly */
369 #ifdef CONFIG_SMP
370 #if 0
371  KeAcquireQueuedSpinLockAtDpcLevel(LockHandle->LockQueue.Next);
372 #else
373  /* Make sure we are at DPC or above! */
375  {
376  /* We aren't -- bugcheck */
377  KeBugCheckEx(IRQL_NOT_GREATER_OR_EQUAL,
380  0,
381  0);
382  }
383 #endif
384 #endif
385 
386  /* Acquire the lock */
387  KxAcquireSpinLock(LockHandle->LockQueue.Lock); // HACK
388 }
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
PKSPIN_LOCK volatile Lock
Definition: ketypes.h:611
struct _KSPIN_LOCK_QUEUE *volatile Next
Definition: ketypes.h:610
uint32_t ULONG_PTR
Definition: typedefs.h:65
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFSPINLOCK * SpinLock
Definition: wdfsync.h:225
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
#define NULL
Definition: types.h:112
KSPIN_LOCK_QUEUE LockQueue
Definition: ketypes.h:615
*LockHandle LockHandle _Out_ PKLOCK_QUEUE_HANDLE LockHandle
Definition: kefuncs.h:729
VOID NTAPI KeBugCheckEx(_In_ ULONG BugCheckCode, _In_ ULONG_PTR BugCheckParameter1, _In_ ULONG_PTR BugCheckParameter2, _In_ ULONG_PTR BugCheckParameter3, _In_ ULONG_PTR BugCheckParameter4)
Definition: rtlcompat.c:108

Referenced by KeAcquireInStackQueuedSpinLockForDpc(), KiAcquireApcLockAtSynchLevel(), and KiAcquireDeviceQueueLock().

◆ KeAcquireInStackQueuedSpinLockForDpc()

VOID FASTCALL KeAcquireInStackQueuedSpinLockForDpc ( IN PKSPIN_LOCK  SpinLock,
IN PKLOCK_QUEUE_HANDLE  LockHandle 
)

Definition at line 446 of file spinlock.c.

448 {
452  else
454 }
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
VOID FASTCALL KeAcquireInStackQueuedSpinLock(IN PKSPIN_LOCK SpinLock, IN PKLOCK_QUEUE_HANDLE LockHandle)
Definition: spinlock.c:130
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFSPINLOCK * SpinLock
Definition: wdfsync.h:225
VOID FASTCALL KeAcquireInStackQueuedSpinLockAtDpcLevel(IN PKSPIN_LOCK SpinLock, IN PKLOCK_QUEUE_HANDLE LockHandle)
Definition: spinlock.c:363
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
*LockHandle LockHandle _Out_ PKLOCK_QUEUE_HANDLE LockHandle
Definition: kefuncs.h:729

◆ KeAcquireInterruptSpinLock()

KIRQL NTAPI KeAcquireInterruptSpinLock ( IN PKINTERRUPT  Interrupt)

Definition at line 154 of file spinlock.c.

155 {
156  KIRQL OldIrql;
157 
158  /* Raise IRQL */
159  KeRaiseIrql(Interrupt->SynchronizeIrql, &OldIrql);
160 
161  /* Acquire spinlock on MP */
163  return OldIrql;
164 }
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_INTERRUPT_CONFIG _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFINTERRUPT * Interrupt
Definition: wdfinterrupt.h:372
VOID NTAPI KeAcquireSpinLockAtDpcLevel(IN PKSPIN_LOCK SpinLock)
Definition: spinlock.c:198
UCHAR KIRQL
Definition: env_spec_w32.h:591
KIRQL OldIrql
Definition: mm.h:1502
VOID NTAPI KeRaiseIrql(KIRQL NewIrql, PKIRQL OldIrql)
Definition: spinlock.c:27

Referenced by i8042DpcRoutineMouseTimeout(), i8042KbdDpcRoutine(), i8042MouDpcRoutine(), i8042PacketDpc(), i8042StartPacket(), InPortDpcForIsr(), KeConnectInterrupt(), KeDisconnectInterrupt(), KiInterruptDispatch2(), Mx::MxAcquireInterruptSpinLock(), PortAcquireSpinLock(), and StartProcedure().

◆ KeAcquireSpinLockAtDpcLevel()

VOID NTAPI KeAcquireSpinLockAtDpcLevel ( IN PKSPIN_LOCK  SpinLock)

Definition at line 198 of file spinlock.c.

199 {
200  /* Make sure we are at DPC or above! */
202  {
203  /* We aren't -- bugcheck */
204  KeBugCheckEx(IRQL_NOT_GREATER_OR_EQUAL,
207  0,
208  0);
209  }
210 
211  /* Do the inlined function */
212  KxAcquireSpinLock(SpinLock);
213 }
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
uint32_t ULONG_PTR
Definition: typedefs.h:65
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFSPINLOCK * SpinLock
Definition: wdfsync.h:225
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
VOID NTAPI KeBugCheckEx(_In_ ULONG BugCheckCode, _In_ ULONG_PTR BugCheckParameter1, _In_ ULONG_PTR BugCheckParameter2, _In_ ULONG_PTR BugCheckParameter3, _In_ ULONG_PTR BugCheckParameter4)
Definition: rtlcompat.c:108

Referenced by _Function_class_(), AcpiOsAcquireLock(), CancelQueued(), CcPerformReadAhead(), CcPurgeCacheSection(), CcRosCreateVacb(), CcRosDeleteFileCache(), CcRosFreeUnusedVacb(), CcRosInitializeFileCache(), CcRosLookupVacb(), CcRosMarkDirtyVacb(), CcRosReleaseFileCache(), CcRosTraceCacheMap(), CcRosUnmarkDirtyVacb(), ClasspReleaseQueue(), EthFilterDprIndicateReceiveComplete(), ExpTimerApcKernelRoutine(), ExTimerRundown(), CPortPinWaveCyclic::GeneratePositionEvents(), HalpPCISynchronizeType1(), HalpPCISynchronizeType2(), InterfacePciDevicePresent(), InterfacePciDevicePresentEx(), IntVideoPortResetDisplayParametersEx(), IServiceGroupDpc(), KdbpSymFindModule(), KdbSymProcessSymbols(), KeAcquireInterruptSpinLock(), KeIpiGenericCall(), KeStartProfile(), KeStopProfile(), KeSynchronizeExecution(), KiRetireDpcList(), KsCancelRoutine(), KsMoveIrpsOnCancelableQueue(), KsRemoveIrpFromCancelableQueue(), MiniDoRequest(), MiniportWorker(), MiniRequestComplete(), MiniReset(), MiniTimerDpcFunction(), NdisAcquireReadWriteLock(), NdisDprAcquireSpinLock(), NdisDprAllocatePacket(), NdisDprFreePacket(), NtCancelTimer(), NtSetTimer(), ProtocolReceive(), RxTimerDispatch(), ScsiPortDpcForIsr(), ScsiPortIoTimer(), ScsiPortStartIo(), SpiAllocateSrbStructures(), SpiMiniportTimerDpc(), SpiProcessCompletedRequest(), TcpipAcquireSpinLockAtDpcLevel(), USBPORT_CancelActiveTransferIrp(), USBPORT_CancelPendingTransferIrp(), USBPORT_ClosePipe(), USBPORT_DpcHandler(), USBPORT_EndpointWorker(), USBPORT_FlushCancelList(), USBPORT_FlushPendingTransfers(), USBPORT_GetEndpointState(), USBPORT_IsrDpc(), USBPORT_IsrDpcHandler(), USBPORT_ReopenPipe(), USBPORT_ResetPipe(), USBPORT_RestoreDevice(), USBPORT_WorkerThreadHandler(), USBSTOR_Cancel(), USBSTOR_TimerRoutine(), and VideoPortAcquireSpinLockAtDpcLevel().

◆ KeAcquireSpinLockForDpc()

KIRQL FASTCALL KeAcquireSpinLockForDpc ( IN PKSPIN_LOCK  SpinLock)

Definition at line 424 of file spinlock.c.

425 {
427  return 0;
428 }
#define UNIMPLEMENTED
Definition: debug.h:115

◆ KefAcquireSpinLockAtDpcLevel()

VOID FASTCALL KefAcquireSpinLockAtDpcLevel ( IN PKSPIN_LOCK  SpinLock)

Definition at line 243 of file spinlock.c.

244 {
245  /* Make sure we are at DPC or above! */
247  {
248  /* We aren't -- bugcheck */
249  KeBugCheckEx(IRQL_NOT_GREATER_OR_EQUAL,
252  0,
253  0);
254  }
255 
256  /* Do the inlined function */
257  KxAcquireSpinLock(SpinLock);
258 }
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
uint32_t ULONG_PTR
Definition: typedefs.h:65
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFSPINLOCK * SpinLock
Definition: wdfsync.h:225
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
VOID NTAPI KeBugCheckEx(_In_ ULONG BugCheckCode, _In_ ULONG_PTR BugCheckParameter1, _In_ ULONG_PTR BugCheckParameter2, _In_ ULONG_PTR BugCheckParameter3, _In_ ULONG_PTR BugCheckParameter4)
Definition: rtlcompat.c:108

◆ KefReleaseSpinLockFromDpcLevel()

VOID FASTCALL KefReleaseSpinLockFromDpcLevel ( IN PKSPIN_LOCK  SpinLock)

Definition at line 265 of file spinlock.c.

266 {
267  /* Make sure we are at DPC or above! */
269  {
270  /* We aren't -- bugcheck */
271  KeBugCheckEx(IRQL_NOT_GREATER_OR_EQUAL,
274  0,
275  0);
276  }
277 
278  /* Do the inlined function */
279  KxReleaseSpinLock(SpinLock);
280 }
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
uint32_t ULONG_PTR
Definition: typedefs.h:65
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFSPINLOCK * SpinLock
Definition: wdfsync.h:225
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
VOID NTAPI KeBugCheckEx(_In_ ULONG BugCheckCode, _In_ ULONG_PTR BugCheckParameter1, _In_ ULONG_PTR BugCheckParameter2, _In_ ULONG_PTR BugCheckParameter3, _In_ ULONG_PTR BugCheckParameter4)
Definition: rtlcompat.c:108

◆ KeReleaseInStackQueuedSpinLockForDpc()

VOID FASTCALL KeReleaseInStackQueuedSpinLockForDpc ( IN PKLOCK_QUEUE_HANDLE  LockHandle)

Definition at line 461 of file spinlock.c.

462 {
465  else
467 
468 }
VOID FASTCALL KeReleaseInStackQueuedSpinLock(IN PKLOCK_QUEUE_HANDLE LockHandle)
Definition: spinlock.c:166
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
*LockHandle LockHandle _Out_ PKLOCK_QUEUE_HANDLE LockHandle
Definition: kefuncs.h:729
VOID FASTCALL KeReleaseInStackQueuedSpinLockFromDpcLevel(IN PKLOCK_QUEUE_HANDLE LockHandle)
Definition: spinlock.c:395

◆ KeReleaseInStackQueuedSpinLockFromDpcLevel()

VOID FASTCALL KeReleaseInStackQueuedSpinLockFromDpcLevel ( IN PKLOCK_QUEUE_HANDLE  LockHandle)

Definition at line 395 of file spinlock.c.

396 {
397 #ifdef CONFIG_SMP
398 #if 0
399  /* Call the internal function */
400  KeReleaseQueuedSpinLockFromDpcLevel(LockHandle->LockQueue.Next);
401 #else
402  /* Make sure we are at DPC or above! */
404  {
405  /* We aren't -- bugcheck */
406  KeBugCheckEx(IRQL_NOT_GREATER_OR_EQUAL,
409  0,
410  0);
411  }
412 #endif
413 #endif
414 
415  /* Release the lock */
416  KxReleaseSpinLock(LockHandle->LockQueue.Lock); // HACK
417 }
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
PKSPIN_LOCK volatile Lock
Definition: ketypes.h:611
struct _KSPIN_LOCK_QUEUE *volatile Next
Definition: ketypes.h:610
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
KSPIN_LOCK_QUEUE LockQueue
Definition: ketypes.h:615
*LockHandle LockHandle _Out_ PKLOCK_QUEUE_HANDLE LockHandle
Definition: kefuncs.h:729
VOID NTAPI KeBugCheckEx(_In_ ULONG BugCheckCode, _In_ ULONG_PTR BugCheckParameter1, _In_ ULONG_PTR BugCheckParameter2, _In_ ULONG_PTR BugCheckParameter3, _In_ ULONG_PTR BugCheckParameter4)
Definition: rtlcompat.c:108

Referenced by KeReleaseInStackQueuedSpinLockForDpc(), KiReleaseApcLockFromSynchLevel(), KiReleaseDeviceQueueLock(), and KiReleaseProcessLockFromSynchLevel().

◆ KeReleaseInterruptSpinLock()

VOID NTAPI KeReleaseInterruptSpinLock ( IN PKINTERRUPT  Interrupt,
IN KIRQL  OldIrql 
)

Definition at line 171 of file spinlock.c.

173 {
174  /* Release lock on MP */
176 
177  /* Lower IRQL */
179 }
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_INTERRUPT_CONFIG _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFINTERRUPT * Interrupt
Definition: wdfinterrupt.h:372
KIRQL OldIrql
Definition: mm.h:1502
VOID NTAPI KeReleaseSpinLockFromDpcLevel(IN PKSPIN_LOCK SpinLock)
Definition: spinlock.c:221
VOID NTAPI KeLowerIrql(KIRQL NewIrql)
Definition: spinlock.c:39

Referenced by i8042DpcRoutineMouseTimeout(), i8042KbdDpcRoutine(), i8042MouDpcRoutine(), i8042PacketDpc(), i8042StartPacket(), InPortDpcForIsr(), KeConnectInterrupt(), KeDisconnectInterrupt(), KiInterruptDispatch2(), Mx::MxReleaseInterruptSpinLock(), PortReleaseSpinLock(), and StartProcedure().

◆ KeReleaseSpinLockForDpc()

VOID FASTCALL KeReleaseSpinLockForDpc ( IN PKSPIN_LOCK  SpinLock,
IN KIRQL  OldIrql 
)

Definition at line 435 of file spinlock.c.

437 {
439 }
#define UNIMPLEMENTED
Definition: debug.h:115

◆ KeReleaseSpinLockFromDpcLevel()

VOID NTAPI KeReleaseSpinLockFromDpcLevel ( IN PKSPIN_LOCK  SpinLock)

Definition at line 221 of file spinlock.c.

222 {
223  /* Make sure we are at DPC or above! */
225  {
226  /* We aren't -- bugcheck */
227  KeBugCheckEx(IRQL_NOT_GREATER_OR_EQUAL,
230  0,
231  0);
232  }
233 
234  /* Do the inlined function */
235  KxReleaseSpinLock(SpinLock);
236 }
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
uint32_t ULONG_PTR
Definition: typedefs.h:65
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFSPINLOCK * SpinLock
Definition: wdfsync.h:225
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
VOID NTAPI KeBugCheckEx(_In_ ULONG BugCheckCode, _In_ ULONG_PTR BugCheckParameter1, _In_ ULONG_PTR BugCheckParameter2, _In_ ULONG_PTR BugCheckParameter3, _In_ ULONG_PTR BugCheckParameter4)
Definition: rtlcompat.c:108

Referenced by _Function_class_(), AcpiOsReleaseLock(), CcPerformReadAhead(), CcPurgeCacheSection(), CcRosCreateVacb(), CcRosDeleteFileCache(), CcRosFreeUnusedVacb(), CcRosInitializeFileCache(), CcRosLookupVacb(), CcRosMarkDirtyVacb(), CcRosReleaseFileCache(), CcRosTraceCacheMap(), CcRosUnmarkDirtyVacb(), ClasspReleaseQueue(), EthFilterDprIndicateReceiveComplete(), ExpTimerApcKernelRoutine(), ExTimerRundown(), CPortPinWaveCyclic::GeneratePositionEvents(), InterfacePciDevicePresent(), InterfacePciDevicePresentEx(), IntVideoPortResetDisplayParametersEx(), IServiceGroupDpc(), KdbpSymFindModule(), KdbSymProcessSymbols(), KeIpiGenericCall(), KeReleaseInterruptSpinLock(), KeStartProfile(), KeStopProfile(), KeSynchronizeExecution(), KiRetireDpcList(), KsMoveIrpsOnCancelableQueue(), KsRemoveIrpFromCancelableQueue(), MiniDoRequest(), MiniportWorker(), MiniRequestComplete(), MiniReset(), MiniTimerDpcFunction(), NdisAcquireReadWriteLock(), NdisDprAllocatePacket(), NdisDprFreePacket(), NdisDprReleaseSpinLock(), NtCancelTimer(), NtSetTimer(), ProtocolReceive(), RxTimerDispatch(), ScsiPortDpcForIsr(), ScsiPortIoTimer(), ScsiPortStartIo(), SpiAllocateSrbStructures(), SpiGetNextRequestFromLun(), SpiMiniportTimerDpc(), SpiProcessCompletedRequest(), TcpipReleaseSpinLockFromDpcLevel(), USBPORT_CancelActiveTransferIrp(), USBPORT_CancelPendingTransferIrp(), USBPORT_ClosePipe(), USBPORT_DpcHandler(), USBPORT_EndpointWorker(), USBPORT_FlushCancelList(), USBPORT_FlushPendingTransfers(), USBPORT_GetEndpointState(), USBPORT_IsrDpc(), USBPORT_IsrDpcHandler(), USBPORT_ReopenPipe(), USBPORT_ResetPipe(), USBPORT_RestoreDevice(), USBPORT_WorkerThreadHandler(), USBSTOR_Cancel(), USBSTOR_TimerRoutine(), and VideoPortReleaseSpinLockFromDpcLevel().

◆ KeTestSpinLock()

BOOLEAN FASTCALL KeTestSpinLock ( IN PKSPIN_LOCK  SpinLock)

Definition at line 475 of file spinlock.c.

476 {
477  /* Test this spinlock */
478  if (*SpinLock)
479  {
480  /* Spinlock is busy, yield execution */
481  YieldProcessor();
482 
483  /* Return busy flag */
484  return FALSE;
485  }
486 
487  /* Spinlock appears to be free */
488  return TRUE;
489 }
#define TRUE
Definition: types.h:120
FORCEINLINE VOID YieldProcessor(VOID)
Definition: ke.h:32
#define FALSE
Definition: types.h:117
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFSPINLOCK * SpinLock
Definition: wdfsync.h:225

Referenced by InbvAcquireLock(), IntVideoPortResetDisplayParametersEx(), and KdpAcquireLock().

◆ KeTryToAcquireSpinLockAtDpcLevel()

BOOLEAN FASTCALL KeTryToAcquireSpinLockAtDpcLevel ( IN OUT PKSPIN_LOCK  SpinLock)

Definition at line 309 of file spinlock.c.

310 {
311 #if DBG
312  /* Make sure we are at DPC or above! */
314  {
315  /* We aren't -- bugcheck */
316  KeBugCheckEx(IRQL_NOT_GREATER_OR_EQUAL,
319  0,
320  0);
321  }
322 
323  /* Make sure that we don't own the lock already */
324  if (((KSPIN_LOCK)KeGetCurrentThread() | 1) == *SpinLock)
325  {
326  /* We do, bugcheck! */
327  KeBugCheckEx(SPIN_LOCK_ALREADY_OWNED, (ULONG_PTR)SpinLock, 0, 0, 0);
328  }
329 #endif
330 
331 #ifdef CONFIG_SMP
332  /* Check if it's already acquired */
333  if (!(*SpinLock))
334  {
335  /* Try to acquire it */
337  {
338  /* Someone else acquired it */
339  return FALSE;
340  }
341  }
342  else
343  {
344  /* It was already acquired */
345  return FALSE;
346  }
347 #endif
348 
349 #if DBG
350  /* On debug builds, we OR in the KTHREAD */
352 #endif
353 
354  /* All is well, return TRUE */
355  return TRUE;
356 }
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
#define TRUE
Definition: types.h:120
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define FALSE
Definition: types.h:117
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFSPINLOCK * SpinLock
Definition: wdfsync.h:225
#define InterlockedBitTestAndSet
Definition: interlocked.h:30
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
ULONG KSPIN_LOCK
Definition: env_spec_w32.h:72
#define ULONG_PTR
Definition: config.h:101
#define KeGetCurrentThread
Definition: hal.h:55
signed int * PLONG
Definition: retypes.h:5
VOID NTAPI KeBugCheckEx(_In_ ULONG BugCheckCode, _In_ ULONG_PTR BugCheckParameter1, _In_ ULONG_PTR BugCheckParameter2, _In_ ULONG_PTR BugCheckParameter3, _In_ ULONG_PTR BugCheckParameter4)
Definition: rtlcompat.c:108

Referenced by KdEnterDebugger(), KdpAcquireLock(), KdPollBreakIn(), KeTryToAcquireQueuedSpinLock(), and KeTryToAcquireQueuedSpinLockRaiseToSynch().

◆ KiAcquireSpinLock()

VOID FASTCALL KiAcquireSpinLock ( IN PKSPIN_LOCK  SpinLock)

Definition at line 287 of file spinlock.c.

288 {
289  /* Do the inlined function */
290  KxAcquireSpinLock(SpinLock);
291 }
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFSPINLOCK * SpinLock
Definition: wdfsync.h:225

Referenced by HalpPCISynchronizeType1(), HalpPCISynchronizeType2(), InbvAcquireLock(), KdpPortLock(), KeConnectInterrupt(), KeDisconnectInterrupt(), KeDumpIrqList(), KeInsertQueueDpc(), KeRemoveQueueDpc(), and KiInterruptDispatch2().

◆ KiReleaseSpinLock()

VOID FASTCALL KiReleaseSpinLock ( IN PKSPIN_LOCK  SpinLock)

Definition at line 298 of file spinlock.c.

299 {
300  /* Do the inlined function */
301  KxReleaseSpinLock(SpinLock);
302 }
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFSPINLOCK * SpinLock
Definition: wdfsync.h:225

Referenced by HalpPCIReleaseSynchronzationType1(), HalpPCIReleaseSynchronzationType2(), InbvReleaseLock(), KdpPortUnlock(), KdpReleaseLock(), KeConnectInterrupt(), KeDisconnectInterrupt(), KeDumpIrqList(), KeInsertQueueDpc(), KeRemoveQueueDpc(), and KiInterruptDispatch2().