This source file includes following definitions.
- ACPI_MODULE_NAME
- acpi_ev_remove_global_lock_handler
- acpi_ev_global_lock_handler
- acpi_ev_acquire_global_lock
- acpi_ev_release_global_lock
1
2
3
4
5
6
7
8
9
10 #include <acpi/acpi.h>
11 #include "accommon.h"
12 #include "acevents.h"
13 #include "acinterp.h"
14
15 #define _COMPONENT ACPI_EVENTS
16 ACPI_MODULE_NAME("evglock")
17 #if (!ACPI_REDUCED_HARDWARE)
18
19 static u32 acpi_ev_global_lock_handler(void *context);
20
21
22
23
24
25
26
27
28
29
30
31
32
33 acpi_status acpi_ev_init_global_lock_handler(void)
34 {
35 acpi_status status;
36
37 ACPI_FUNCTION_TRACE(ev_init_global_lock_handler);
38
39
40
41 if (acpi_gbl_reduced_hardware) {
42 return_ACPI_STATUS(AE_OK);
43 }
44
45
46
47 status = acpi_install_fixed_event_handler(ACPI_EVENT_GLOBAL,
48 acpi_ev_global_lock_handler,
49 NULL);
50
51
52
53
54
55
56
57 acpi_gbl_global_lock_present = FALSE;
58 if (status == AE_NO_HARDWARE_RESPONSE) {
59 ACPI_ERROR((AE_INFO,
60 "No response from Global Lock hardware, disabling lock"));
61
62 return_ACPI_STATUS(AE_OK);
63 }
64
65 status = acpi_os_create_lock(&acpi_gbl_global_lock_pending_lock);
66 if (ACPI_FAILURE(status)) {
67 return_ACPI_STATUS(status);
68 }
69
70 acpi_gbl_global_lock_pending = FALSE;
71 acpi_gbl_global_lock_present = TRUE;
72 return_ACPI_STATUS(status);
73 }
74
75
76
77
78
79
80
81
82
83
84
85
86
87 acpi_status acpi_ev_remove_global_lock_handler(void)
88 {
89 acpi_status status;
90
91 ACPI_FUNCTION_TRACE(ev_remove_global_lock_handler);
92
93 acpi_gbl_global_lock_present = FALSE;
94 status = acpi_remove_fixed_event_handler(ACPI_EVENT_GLOBAL,
95 acpi_ev_global_lock_handler);
96
97 acpi_os_delete_lock(acpi_gbl_global_lock_pending_lock);
98 return_ACPI_STATUS(status);
99 }
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115 static u32 acpi_ev_global_lock_handler(void *context)
116 {
117 acpi_status status;
118 acpi_cpu_flags flags;
119
120 flags = acpi_os_acquire_lock(acpi_gbl_global_lock_pending_lock);
121
122
123
124
125
126
127 if (!acpi_gbl_global_lock_pending) {
128 goto cleanup_and_exit;
129 }
130
131
132
133
134
135 status = acpi_os_signal_semaphore(acpi_gbl_global_lock_semaphore, 1);
136 if (ACPI_FAILURE(status)) {
137 ACPI_ERROR((AE_INFO, "Could not signal Global Lock semaphore"));
138 }
139
140 acpi_gbl_global_lock_pending = FALSE;
141
142 cleanup_and_exit:
143
144 acpi_os_release_lock(acpi_gbl_global_lock_pending_lock, flags);
145 return (ACPI_INTERRUPT_HANDLED);
146 }
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170 acpi_status acpi_ev_acquire_global_lock(u16 timeout)
171 {
172 acpi_cpu_flags flags;
173 acpi_status status;
174 u8 acquired = FALSE;
175
176 ACPI_FUNCTION_TRACE(ev_acquire_global_lock);
177
178
179
180
181
182 status =
183 acpi_ex_system_wait_mutex(acpi_gbl_global_lock_mutex->mutex.
184 os_mutex, timeout);
185 if (ACPI_FAILURE(status)) {
186 return_ACPI_STATUS(status);
187 }
188
189
190
191
192
193
194
195
196
197 acpi_gbl_global_lock_handle++;
198 if (acpi_gbl_global_lock_handle == 0) {
199 acpi_gbl_global_lock_handle = 1;
200 }
201
202
203
204
205
206 if (!acpi_gbl_global_lock_present) {
207 acpi_gbl_global_lock_acquired = TRUE;
208 return_ACPI_STATUS(AE_OK);
209 }
210
211 flags = acpi_os_acquire_lock(acpi_gbl_global_lock_pending_lock);
212
213 do {
214
215
216
217 ACPI_ACQUIRE_GLOBAL_LOCK(acpi_gbl_FACS, acquired);
218 if (acquired) {
219 acpi_gbl_global_lock_acquired = TRUE;
220 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
221 "Acquired hardware Global Lock\n"));
222 break;
223 }
224
225
226
227
228
229
230 acpi_gbl_global_lock_pending = TRUE;
231 acpi_os_release_lock(acpi_gbl_global_lock_pending_lock, flags);
232
233 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
234 "Waiting for hardware Global Lock\n"));
235
236
237
238
239
240 status =
241 acpi_ex_system_wait_semaphore
242 (acpi_gbl_global_lock_semaphore, ACPI_WAIT_FOREVER);
243
244 flags = acpi_os_acquire_lock(acpi_gbl_global_lock_pending_lock);
245
246 } while (ACPI_SUCCESS(status));
247
248 acpi_gbl_global_lock_pending = FALSE;
249 acpi_os_release_lock(acpi_gbl_global_lock_pending_lock, flags);
250
251 return_ACPI_STATUS(status);
252 }
253
254
255
256
257
258
259
260
261
262
263
264
265
266 acpi_status acpi_ev_release_global_lock(void)
267 {
268 u8 pending = FALSE;
269 acpi_status status = AE_OK;
270
271 ACPI_FUNCTION_TRACE(ev_release_global_lock);
272
273
274
275 if (!acpi_gbl_global_lock_acquired) {
276 ACPI_WARNING((AE_INFO,
277 "Cannot release the ACPI Global Lock, it has not been acquired"));
278 return_ACPI_STATUS(AE_NOT_ACQUIRED);
279 }
280
281 if (acpi_gbl_global_lock_present) {
282
283
284
285 ACPI_RELEASE_GLOBAL_LOCK(acpi_gbl_FACS, pending);
286
287
288
289
290
291 if (pending) {
292 status =
293 acpi_write_bit_register
294 (ACPI_BITREG_GLOBAL_LOCK_RELEASE,
295 ACPI_ENABLE_EVENT);
296 }
297
298 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
299 "Released hardware Global Lock\n"));
300 }
301
302 acpi_gbl_global_lock_acquired = FALSE;
303
304
305
306 acpi_os_release_mutex(acpi_gbl_global_lock_mutex->mutex.os_mutex);
307 return_ACPI_STATUS(status);
308 }
309
310 #endif