2006-11-16 20:52:13 +00:00
|
|
|
/*
|
2001-08-21 20:18:27 +00:00
|
|
|
* COPYRIGHT: See COPYING in the top level directory
|
|
|
|
* PROJECT: ReactOS kernel
|
|
|
|
* FILE: ntoskrnl/hal/x86/spinlock.c
|
|
|
|
* PURPOSE: Implements spinlocks
|
|
|
|
* PROGRAMMER: David Welch (welch@cwcom.net)
|
|
|
|
* Eric Kohl (ekohl@rz-online.de)
|
|
|
|
* UPDATE HISTORY:
|
|
|
|
* 09/06/2000 Created
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* NOTE: On a uniprocessor machine spinlocks are implemented by raising
|
|
|
|
* the irq level
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* INCLUDES ****************************************************************/
|
|
|
|
|
2005-06-18 14:29:31 +00:00
|
|
|
#include <hal.h>
|
2005-06-19 22:53:49 +00:00
|
|
|
#define NDEBUG
|
|
|
|
#include <debug.h>
|
2001-08-21 20:18:27 +00:00
|
|
|
|
2005-05-05 19:15:25 +00:00
|
|
|
/* Hmm, needed for KDBG := 1. Why? */
|
|
|
|
#undef KeGetCurrentIrql
|
|
|
|
|
2001-08-21 20:18:27 +00:00
|
|
|
/* FUNCTIONS ***************************************************************/
|
|
|
|
|
2005-06-18 14:29:31 +00:00
|
|
|
#undef KeAcquireSpinLock
|
2008-11-29 23:16:39 +00:00
|
|
|
VOID NTAPI
|
2001-08-21 20:18:27 +00:00
|
|
|
KeAcquireSpinLock (
|
|
|
|
PKSPIN_LOCK SpinLock,
|
|
|
|
PKIRQL OldIrql
|
|
|
|
)
|
|
|
|
/*
|
|
|
|
* FUNCTION: Acquires a spinlock
|
|
|
|
* ARGUMENTS:
|
|
|
|
* SpinLock = Spinlock to acquire
|
|
|
|
* OldIrql (OUT) = Caller supplied storage for the previous irql
|
|
|
|
*/
|
|
|
|
{
|
2004-01-18 22:35:26 +00:00
|
|
|
*OldIrql = KfAcquireSpinLock(SpinLock);
|
2001-08-21 20:18:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
KIRQL FASTCALL
|
|
|
|
KeAcquireSpinLockRaiseToSynch (
|
|
|
|
PKSPIN_LOCK SpinLock
|
|
|
|
)
|
|
|
|
{
|
2003-11-05 22:37:42 +00:00
|
|
|
KIRQL OldIrql;
|
2003-11-06 21:13:21 +00:00
|
|
|
|
2006-01-08 06:30:00 +00:00
|
|
|
OldIrql = KfRaiseIrql(CLOCK2_LEVEL);
|
2004-01-18 22:35:26 +00:00
|
|
|
KiAcquireSpinLock(SpinLock);
|
2003-11-05 22:37:42 +00:00
|
|
|
|
|
|
|
return OldIrql;
|
2001-08-21 20:18:27 +00:00
|
|
|
}
|
|
|
|
|
2005-06-18 14:29:31 +00:00
|
|
|
#undef KeReleaseSpinLock
|
2008-11-29 23:16:39 +00:00
|
|
|
VOID NTAPI
|
2001-08-21 20:18:27 +00:00
|
|
|
KeReleaseSpinLock (
|
|
|
|
PKSPIN_LOCK SpinLock,
|
|
|
|
KIRQL NewIrql
|
|
|
|
)
|
|
|
|
/*
|
|
|
|
* FUNCTION: Releases a spinlock
|
|
|
|
* ARGUMENTS:
|
|
|
|
* SpinLock = Spinlock to release
|
|
|
|
* NewIrql = Irql level before acquiring the spinlock
|
|
|
|
*/
|
|
|
|
{
|
2004-01-18 22:35:26 +00:00
|
|
|
KfReleaseSpinLock(SpinLock, NewIrql);
|
2001-08-21 20:18:27 +00:00
|
|
|
}
|
|
|
|
|
2006-11-16 20:52:13 +00:00
|
|
|
LOGICAL
|
|
|
|
FASTCALL
|
|
|
|
KeTryToAcquireQueuedSpinLock(
|
|
|
|
KSPIN_LOCK_QUEUE_NUMBER LockNumber,
|
|
|
|
PKIRQL OldIrql)
|
|
|
|
{
|
|
|
|
UNIMPLEMENTED;
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
BOOLEAN
|
|
|
|
FASTCALL
|
|
|
|
KeTryToAcquireQueuedSpinLockRaiseToSynch(
|
|
|
|
KSPIN_LOCK_QUEUE_NUMBER LockNumber,
|
|
|
|
PKIRQL OldIrql)
|
|
|
|
{
|
|
|
|
UNIMPLEMENTED;
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2001-08-21 20:18:27 +00:00
|
|
|
KIRQL FASTCALL
|
|
|
|
KfAcquireSpinLock (
|
|
|
|
PKSPIN_LOCK SpinLock
|
|
|
|
)
|
|
|
|
{
|
|
|
|
KIRQL OldIrql;
|
|
|
|
|
2004-10-22 20:08:22 +00:00
|
|
|
ASSERT(KeGetCurrentIrql() <= DISPATCH_LEVEL);
|
2007-10-19 23:21:45 +00:00
|
|
|
|
2004-01-18 22:35:26 +00:00
|
|
|
OldIrql = KfRaiseIrql(DISPATCH_LEVEL);
|
|
|
|
KiAcquireSpinLock(SpinLock);
|
2001-08-21 20:18:27 +00:00
|
|
|
|
|
|
|
return OldIrql;
|
|
|
|
}
|
|
|
|
|
|
|
|
VOID FASTCALL
|
|
|
|
KfReleaseSpinLock (
|
|
|
|
PKSPIN_LOCK SpinLock,
|
|
|
|
KIRQL NewIrql
|
|
|
|
)
|
|
|
|
/*
|
|
|
|
* FUNCTION: Releases a spinlock
|
|
|
|
* ARGUMENTS:
|
|
|
|
* SpinLock = Spinlock to release
|
|
|
|
* NewIrql = Irql level before acquiring the spinlock
|
|
|
|
*/
|
|
|
|
{
|
2004-10-22 20:08:22 +00:00
|
|
|
ASSERT(KeGetCurrentIrql() == DISPATCH_LEVEL || KeGetCurrentIrql() == SYNCH_LEVEL);
|
2004-01-18 22:35:26 +00:00
|
|
|
KiReleaseSpinLock(SpinLock);
|
|
|
|
KfLowerIrql(NewIrql);
|
2001-08-21 20:18:27 +00:00
|
|
|
}
|
|
|
|
|
2005-03-29 17:29:02 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* @unimplemented
|
|
|
|
*/
|
|
|
|
VOID
|
|
|
|
FASTCALL
|
|
|
|
KeAcquireInStackQueuedSpinLock(
|
|
|
|
IN PKSPIN_LOCK SpinLock,
|
|
|
|
IN PKLOCK_QUEUE_HANDLE LockHandle
|
|
|
|
)
|
|
|
|
{
|
|
|
|
UNIMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2006-09-10 16:09:58 +00:00
|
|
|
/*
|
|
|
|
* @unimplemented
|
|
|
|
*/
|
|
|
|
VOID
|
|
|
|
FASTCALL
|
|
|
|
KeAcquireInStackQueuedSpinLockRaiseToSynch(
|
|
|
|
IN PKSPIN_LOCK SpinLock,
|
|
|
|
IN PKLOCK_QUEUE_HANDLE LockHandle
|
|
|
|
)
|
|
|
|
{
|
|
|
|
UNIMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2005-03-29 17:29:02 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* @unimplemented
|
|
|
|
*/
|
|
|
|
VOID
|
|
|
|
FASTCALL
|
|
|
|
KeReleaseInStackQueuedSpinLock(
|
|
|
|
IN PKLOCK_QUEUE_HANDLE LockHandle
|
|
|
|
)
|
|
|
|
{
|
|
|
|
UNIMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2006-06-02 20:15:54 +00:00
|
|
|
/*
|
|
|
|
* @unimplemented
|
|
|
|
*/
|
|
|
|
KIRQL
|
|
|
|
FASTCALL
|
2007-09-24 14:01:54 +00:00
|
|
|
KeAcquireQueuedSpinLock(IN KSPIN_LOCK_QUEUE_NUMBER Number)
|
2006-06-02 20:15:54 +00:00
|
|
|
{
|
|
|
|
UNIMPLEMENTED;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-11-30 11:24:03 +00:00
|
|
|
/*
|
|
|
|
* @unimplemented
|
|
|
|
*/
|
|
|
|
KIRQL
|
|
|
|
FASTCALL
|
|
|
|
KeAcquireQueuedSpinLockRaiseToSynch(IN KSPIN_LOCK_QUEUE_NUMBER LockNumber)
|
|
|
|
{
|
|
|
|
UNIMPLEMENTED;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-06-02 20:15:54 +00:00
|
|
|
/*
|
|
|
|
* @unimplemented
|
|
|
|
*/
|
|
|
|
VOID
|
|
|
|
FASTCALL
|
2007-09-24 14:01:54 +00:00
|
|
|
KeReleaseQueuedSpinLock(IN KSPIN_LOCK_QUEUE_NUMBER Number,
|
2006-06-02 20:15:54 +00:00
|
|
|
IN KIRQL OldIrql)
|
|
|
|
{
|
|
|
|
UNIMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2001-08-21 20:18:27 +00:00
|
|
|
/* EOF */
|