- Get MP hal and Generic HAL to build too.
[reactos.git] / reactos / hal / halx86 / mp / spinlock.c
1 /* $Id$
2 *
3 * COPYRIGHT: See COPYING in the top level directory
4 * PROJECT: ReactOS kernel
5 * FILE: ntoskrnl/hal/x86/spinlock.c
6 * PURPOSE: Implements spinlocks
7 * PROGRAMMER: David Welch (welch@cwcom.net)
8 * Eric Kohl (ekohl@rz-online.de)
9 * UPDATE HISTORY:
10 * 09/06/2000 Created
11 */
12
13 /*
14 * NOTE: On a uniprocessor machine spinlocks are implemented by raising
15 * the irq level
16 */
17
18 /* INCLUDES ****************************************************************/
19
20 #include <hal.h>
21 #define NDEBUG
22 #include <debug.h>
23
24 /* Hmm, needed for KDBG := 1. Why? */
25 #undef KeGetCurrentIrql
26
27 /* FUNCTIONS ***************************************************************/
28
29 #undef KeAcquireSpinLock
30 VOID STDCALL
31 KeAcquireSpinLock (
32 PKSPIN_LOCK SpinLock,
33 PKIRQL OldIrql
34 )
35 /*
36 * FUNCTION: Acquires a spinlock
37 * ARGUMENTS:
38 * SpinLock = Spinlock to acquire
39 * OldIrql (OUT) = Caller supplied storage for the previous irql
40 */
41 {
42 *OldIrql = KfAcquireSpinLock(SpinLock);
43 }
44
45 KIRQL FASTCALL
46 KeAcquireSpinLockRaiseToSynch (
47 PKSPIN_LOCK SpinLock
48 )
49 {
50 KIRQL OldIrql;
51
52 OldIrql = KfRaiseIrql(CLOCK2_LEVEL);
53 KiAcquireSpinLock(SpinLock);
54
55 return OldIrql;
56 }
57
58 #undef KeReleaseSpinLock
59 VOID STDCALL
60 KeReleaseSpinLock (
61 PKSPIN_LOCK SpinLock,
62 KIRQL NewIrql
63 )
64 /*
65 * FUNCTION: Releases a spinlock
66 * ARGUMENTS:
67 * SpinLock = Spinlock to release
68 * NewIrql = Irql level before acquiring the spinlock
69 */
70 {
71 KfReleaseSpinLock(SpinLock, NewIrql);
72 }
73
74 KIRQL FASTCALL
75 KfAcquireSpinLock (
76 PKSPIN_LOCK SpinLock
77 )
78 {
79 KIRQL OldIrql;
80
81 ASSERT(KeGetCurrentIrql() <= DISPATCH_LEVEL);
82
83 OldIrql = KfRaiseIrql(DISPATCH_LEVEL);
84 KiAcquireSpinLock(SpinLock);
85
86 return OldIrql;
87 }
88
89 VOID FASTCALL
90 KfReleaseSpinLock (
91 PKSPIN_LOCK SpinLock,
92 KIRQL NewIrql
93 )
94 /*
95 * FUNCTION: Releases a spinlock
96 * ARGUMENTS:
97 * SpinLock = Spinlock to release
98 * NewIrql = Irql level before acquiring the spinlock
99 */
100 {
101 ASSERT(KeGetCurrentIrql() == DISPATCH_LEVEL || KeGetCurrentIrql() == SYNCH_LEVEL);
102 KiReleaseSpinLock(SpinLock);
103 KfLowerIrql(NewIrql);
104 }
105
106
107 /*
108 * @unimplemented
109 */
110 VOID
111 FASTCALL
112 KeAcquireInStackQueuedSpinLock(
113 IN PKSPIN_LOCK SpinLock,
114 IN PKLOCK_QUEUE_HANDLE LockHandle
115 )
116 {
117 UNIMPLEMENTED;
118 }
119
120
121 /*
122 * @unimplemented
123 */
124 VOID
125 FASTCALL
126 KeReleaseInStackQueuedSpinLock(
127 IN PKLOCK_QUEUE_HANDLE LockHandle
128 )
129 {
130 UNIMPLEMENTED;
131 }
132
133 /* EOF */