xref: /reactos/hal/halarm/generic/spinlock.c (revision 34593d93)
1 /*
2  * PROJECT:         ReactOS HAL
3  * LICENSE:         BSD - See COPYING.ARM in the top level directory
4  * FILE:            hal/halarm/generic/spinlock.c
5  * PURPOSE:         SpinLock Routines
6  * PROGRAMMERS:     ReactOS Portable Systems Group
7  */
8 
9 /* INCLUDES ******************************************************************/
10 
11 #include <hal.h>
12 #define NDEBUG
13 #include <debug.h>
14 
15 #undef KeAcquireSpinLock
16 #undef KeReleaseSpinLock
17 #undef KeRaiseIrql
18 #undef KeLowerIrql
19 
20 /* FUNCTIONS *****************************************************************/
21 
22 /*
23  * @implemented
24  */
25 VOID
26 NTAPI
KeRaiseIrql(KIRQL NewIrql,PKIRQL OldIrql)27 KeRaiseIrql(KIRQL NewIrql,
28             PKIRQL OldIrql)
29 {
30     /* Call the fastcall function */
31     *OldIrql = KfRaiseIrql(NewIrql);
32 }
33 
34 /*
35  * @implemented
36  */
37 VOID
38 NTAPI
KeLowerIrql(KIRQL NewIrql)39 KeLowerIrql(KIRQL NewIrql)
40 {
41     /* Call the fastcall function */
42     KfLowerIrql(NewIrql);
43 }
44 
45 /*
46  * @implemented
47  */
48 VOID
49 NTAPI
KeAcquireSpinLock(PKSPIN_LOCK SpinLock,PKIRQL OldIrql)50 KeAcquireSpinLock(PKSPIN_LOCK SpinLock,
51                   PKIRQL OldIrql)
52 {
53     /* Call the fastcall function */
54     *OldIrql = KfAcquireSpinLock(SpinLock);
55 }
56 
57 /*
58  * @implemented
59  */
60 KIRQL
61 FASTCALL
KeAcquireSpinLockRaiseToSynch(PKSPIN_LOCK SpinLock)62 KeAcquireSpinLockRaiseToSynch(PKSPIN_LOCK SpinLock)
63 {
64     /* Simply raise to dispatch */
65     return KfRaiseIrql(DISPATCH_LEVEL);
66 }
67 
68 /*
69  * @implemented
70  */
71 VOID
72 NTAPI
KeReleaseSpinLock(PKSPIN_LOCK SpinLock,KIRQL NewIrql)73 KeReleaseSpinLock(PKSPIN_LOCK SpinLock,
74                   KIRQL NewIrql)
75 {
76     /* Call the fastcall function */
77     KfReleaseSpinLock(SpinLock, NewIrql);
78 }
79 
80 /*
81  * @implemented
82  */
83 KIRQL
84 FASTCALL
KfAcquireSpinLock(PKSPIN_LOCK SpinLock)85 KfAcquireSpinLock(PKSPIN_LOCK SpinLock)
86 {
87     /* Simply raise to dispatch */
88     return KfRaiseIrql(DISPATCH_LEVEL);
89 }
90 
91 /*
92  * @implemented
93  */
94 VOID
95 FASTCALL
KfReleaseSpinLock(PKSPIN_LOCK SpinLock,KIRQL OldIrql)96 KfReleaseSpinLock(PKSPIN_LOCK SpinLock,
97                   KIRQL OldIrql)
98 {
99     /* Simply lower IRQL back */
100     KeLowerIrql(OldIrql);
101 }
102 
103 /*
104  * @implemented
105  */
106 KIRQL
107 FASTCALL
KeAcquireQueuedSpinLock(IN KSPIN_LOCK_QUEUE_NUMBER LockNumber)108 KeAcquireQueuedSpinLock(IN KSPIN_LOCK_QUEUE_NUMBER LockNumber)
109 {
110     /* Simply raise to dispatch */
111     return KfRaiseIrql(DISPATCH_LEVEL);
112 }
113 
114 /*
115  * @implemented
116  */
117 KIRQL
118 FASTCALL
KeAcquireQueuedSpinLockRaiseToSynch(IN KSPIN_LOCK_QUEUE_NUMBER LockNumber)119 KeAcquireQueuedSpinLockRaiseToSynch(IN KSPIN_LOCK_QUEUE_NUMBER LockNumber)
120 {
121     /* Simply raise to dispatch */
122     return KfRaiseIrql(DISPATCH_LEVEL);
123 }
124 
125 /*
126  * @implemented
127  */
128 VOID
129 FASTCALL
KeAcquireInStackQueuedSpinLock(IN PKSPIN_LOCK SpinLock,IN PKLOCK_QUEUE_HANDLE LockHandle)130 KeAcquireInStackQueuedSpinLock(IN PKSPIN_LOCK SpinLock,
131                                IN PKLOCK_QUEUE_HANDLE LockHandle)
132 {
133     /* Simply raise to dispatch */
134     LockHandle->OldIrql = KfRaiseIrql(DISPATCH_LEVEL);
135 }
136 
137 /*
138  * @implemented
139  */
140 VOID
141 FASTCALL
KeAcquireInStackQueuedSpinLockRaiseToSynch(IN PKSPIN_LOCK SpinLock,IN PKLOCK_QUEUE_HANDLE LockHandle)142 KeAcquireInStackQueuedSpinLockRaiseToSynch(IN PKSPIN_LOCK SpinLock,
143                                            IN PKLOCK_QUEUE_HANDLE LockHandle)
144 {
145     /* Simply raise to dispatch */
146     LockHandle->OldIrql = KfRaiseIrql(DISPATCH_LEVEL);
147 }
148 
149 /*
150  * @implemented
151  */
152 VOID
153 FASTCALL
KeReleaseQueuedSpinLock(IN KSPIN_LOCK_QUEUE_NUMBER LockNumber,IN KIRQL OldIrql)154 KeReleaseQueuedSpinLock(IN KSPIN_LOCK_QUEUE_NUMBER LockNumber,
155                         IN KIRQL OldIrql)
156 {
157     /* Simply lower IRQL back */
158     KfLowerIrql(OldIrql);
159 }
160 
161 /*
162  * @implemented
163  */
164 VOID
165 FASTCALL
KeReleaseInStackQueuedSpinLock(IN PKLOCK_QUEUE_HANDLE LockHandle)166 KeReleaseInStackQueuedSpinLock(IN PKLOCK_QUEUE_HANDLE LockHandle)
167 {
168     /* Simply lower IRQL back */
169     KfLowerIrql(LockHandle->OldIrql);
170 }
171 
172 /*
173  * @implemented
174  */
175 BOOLEAN
176 FASTCALL
KeTryToAcquireQueuedSpinLockRaiseToSynch(IN KSPIN_LOCK_QUEUE_NUMBER LockNumber,IN PKIRQL OldIrql)177 KeTryToAcquireQueuedSpinLockRaiseToSynch(IN KSPIN_LOCK_QUEUE_NUMBER LockNumber,
178                                          IN PKIRQL OldIrql)
179 {
180     /* Simply raise to synch */
181     KeRaiseIrql(SYNCH_LEVEL, OldIrql);
182 
183     /* Always return true on UP Machines */
184     return TRUE;
185 }
186 
187 /*
188  * @implemented
189  */
190 LOGICAL
191 FASTCALL
KeTryToAcquireQueuedSpinLock(IN KSPIN_LOCK_QUEUE_NUMBER LockNumber,OUT PKIRQL OldIrql)192 KeTryToAcquireQueuedSpinLock(IN KSPIN_LOCK_QUEUE_NUMBER LockNumber,
193                              OUT PKIRQL OldIrql)
194 {
195     /* Simply raise to dispatch */
196     KeRaiseIrql(DISPATCH_LEVEL, OldIrql);
197 
198     /* Always return true on UP Machines */
199     return TRUE;
200 }
201 
202 /* EOF */
203