prevent buffer overflow, LoadString accepts the size of the buffer in TCHARs, not...
[reactos.git] / reactos / hal / halx86 / generic / 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 <ddk/ntddk.h>
21
22 #include <internal/debug.h>
23
24 /* FUNCTIONS ***************************************************************/
25
26 VOID STDCALL
27 KeAcquireSpinLock (
28 PKSPIN_LOCK SpinLock,
29 PKIRQL OldIrql
30 )
31 /*
32 * FUNCTION: Acquires a spinlock
33 * ARGUMENTS:
34 * SpinLock = Spinlock to acquire
35 * OldIrql (OUT) = Caller supplied storage for the previous irql
36 */
37 {
38 *OldIrql = KfAcquireSpinLock(SpinLock);
39 }
40
41 KIRQL FASTCALL
42 KeAcquireSpinLockRaiseToSynch (
43 PKSPIN_LOCK SpinLock
44 )
45 {
46 KIRQL OldIrql;
47
48 OldIrql = KfRaiseIrql(SYNCH_LEVEL);
49 KiAcquireSpinLock(SpinLock);
50
51 return OldIrql;
52 }
53
54 VOID STDCALL
55 KeReleaseSpinLock (
56 PKSPIN_LOCK SpinLock,
57 KIRQL NewIrql
58 )
59 /*
60 * FUNCTION: Releases a spinlock
61 * ARGUMENTS:
62 * SpinLock = Spinlock to release
63 * NewIrql = Irql level before acquiring the spinlock
64 */
65 {
66 KfReleaseSpinLock(SpinLock, NewIrql);
67 }
68
69 KIRQL FASTCALL
70 KfAcquireSpinLock (
71 PKSPIN_LOCK SpinLock
72 )
73 {
74 KIRQL OldIrql;
75
76 ASSERT(KeGetCurrentIrql() <= DISPATCH_LEVEL);
77
78 OldIrql = KfRaiseIrql(DISPATCH_LEVEL);
79 KiAcquireSpinLock(SpinLock);
80
81 return OldIrql;
82 }
83
84 VOID FASTCALL
85 KfReleaseSpinLock (
86 PKSPIN_LOCK SpinLock,
87 KIRQL NewIrql
88 )
89 /*
90 * FUNCTION: Releases a spinlock
91 * ARGUMENTS:
92 * SpinLock = Spinlock to release
93 * NewIrql = Irql level before acquiring the spinlock
94 */
95 {
96 ASSERT(KeGetCurrentIrql() == DISPATCH_LEVEL || KeGetCurrentIrql() == SYNCH_LEVEL);
97 KiReleaseSpinLock(SpinLock);
98 KfLowerIrql(NewIrql);
99 }
100
101
102 /*
103 * @unimplemented
104 */
105 VOID
106 FASTCALL
107 KeAcquireInStackQueuedSpinLock(
108 IN PKSPIN_LOCK SpinLock,
109 IN PKLOCK_QUEUE_HANDLE LockHandle
110 )
111 {
112 UNIMPLEMENTED;
113 }
114
115
116 /*
117 * @unimplemented
118 */
119 VOID
120 FASTCALL
121 KeReleaseInStackQueuedSpinLock(
122 IN PKLOCK_QUEUE_HANDLE LockHandle
123 )
124 {
125 UNIMPLEMENTED;
126 }
127
128 /* EOF */