aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/executer/exsystem.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/acpi/executer/exsystem.c')
-rw-r--r--drivers/acpi/executer/exsystem.c183
1 files changed, 72 insertions, 111 deletions
diff --git a/drivers/acpi/executer/exsystem.c b/drivers/acpi/executer/exsystem.c
index cafa702108dc..8a88b841237d 100644
--- a/drivers/acpi/executer/exsystem.c
+++ b/drivers/acpi/executer/exsystem.c
@@ -42,14 +42,12 @@
42 * POSSIBILITY OF SUCH DAMAGES. 42 * POSSIBILITY OF SUCH DAMAGES.
43 */ 43 */
44 44
45
46#include <acpi/acpi.h> 45#include <acpi/acpi.h>
47#include <acpi/acinterp.h> 46#include <acpi/acinterp.h>
48#include <acpi/acevents.h> 47#include <acpi/acevents.h>
49 48
50#define _COMPONENT ACPI_EXECUTER 49#define _COMPONENT ACPI_EXECUTER
51 ACPI_MODULE_NAME ("exsystem") 50ACPI_MODULE_NAME("exsystem")
52
53 51
54/******************************************************************************* 52/*******************************************************************************
55 * 53 *
@@ -65,49 +63,42 @@
65 * interpreter is released. 63 * interpreter is released.
66 * 64 *
67 ******************************************************************************/ 65 ******************************************************************************/
68 66acpi_status acpi_ex_system_wait_semaphore(acpi_handle semaphore, u16 timeout)
69acpi_status
70acpi_ex_system_wait_semaphore (
71 acpi_handle semaphore,
72 u16 timeout)
73{ 67{
74 acpi_status status; 68 acpi_status status;
75 acpi_status status2; 69 acpi_status status2;
76
77 70
78 ACPI_FUNCTION_TRACE ("ex_system_wait_semaphore"); 71 ACPI_FUNCTION_TRACE("ex_system_wait_semaphore");
79 72
80 73 status = acpi_os_wait_semaphore(semaphore, 1, 0);
81 status = acpi_os_wait_semaphore (semaphore, 1, 0); 74 if (ACPI_SUCCESS(status)) {
82 if (ACPI_SUCCESS (status)) { 75 return_ACPI_STATUS(status);
83 return_ACPI_STATUS (status);
84 } 76 }
85 77
86 if (status == AE_TIME) { 78 if (status == AE_TIME) {
87 /* We must wait, so unlock the interpreter */ 79 /* We must wait, so unlock the interpreter */
88 80
89 acpi_ex_exit_interpreter (); 81 acpi_ex_exit_interpreter();
90 82
91 status = acpi_os_wait_semaphore (semaphore, 1, timeout); 83 status = acpi_os_wait_semaphore(semaphore, 1, timeout);
92 84
93 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, 85 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
94 "*** Thread awake after blocking, %s\n", 86 "*** Thread awake after blocking, %s\n",
95 acpi_format_exception (status))); 87 acpi_format_exception(status)));
96 88
97 /* Reacquire the interpreter */ 89 /* Reacquire the interpreter */
98 90
99 status2 = acpi_ex_enter_interpreter (); 91 status2 = acpi_ex_enter_interpreter();
100 if (ACPI_FAILURE (status2)) { 92 if (ACPI_FAILURE(status2)) {
101 /* Report fatal error, could not acquire interpreter */ 93 /* Report fatal error, could not acquire interpreter */
102 94
103 return_ACPI_STATUS (status2); 95 return_ACPI_STATUS(status2);
104 } 96 }
105 } 97 }
106 98
107 return_ACPI_STATUS (status); 99 return_ACPI_STATUS(status);
108} 100}
109 101
110
111/******************************************************************************* 102/*******************************************************************************
112 * 103 *
113 * FUNCTION: acpi_ex_system_do_stall 104 * FUNCTION: acpi_ex_system_do_stall
@@ -125,35 +116,29 @@ acpi_ex_system_wait_semaphore (
125 * 116 *
126 ******************************************************************************/ 117 ******************************************************************************/
127 118
128acpi_status 119acpi_status acpi_ex_system_do_stall(u32 how_long)
129acpi_ex_system_do_stall (
130 u32 how_long)
131{ 120{
132 acpi_status status = AE_OK; 121 acpi_status status = AE_OK;
133
134 122
135 ACPI_FUNCTION_ENTRY (); 123 ACPI_FUNCTION_ENTRY();
136 124
137 125 if (how_long > 255) { /* 255 microseconds */
138 if (how_long > 255) /* 255 microseconds */ {
139 /* 126 /*
140 * Longer than 255 usec, this is an error 127 * Longer than 255 usec, this is an error
141 * 128 *
142 * (ACPI specifies 100 usec as max, but this gives some slack in 129 * (ACPI specifies 100 usec as max, but this gives some slack in
143 * order to support existing BIOSs) 130 * order to support existing BIOSs)
144 */ 131 */
145 ACPI_REPORT_ERROR (("Stall: Time parameter is too large (%d)\n", 132 ACPI_REPORT_ERROR(("Stall: Time parameter is too large (%d)\n",
146 how_long)); 133 how_long));
147 status = AE_AML_OPERAND_VALUE; 134 status = AE_AML_OPERAND_VALUE;
148 } 135 } else {
149 else { 136 acpi_os_stall(how_long);
150 acpi_os_stall (how_long);
151 } 137 }
152 138
153 return (status); 139 return (status);
154} 140}
155 141
156
157/******************************************************************************* 142/*******************************************************************************
158 * 143 *
159 * FUNCTION: acpi_ex_system_do_suspend 144 * FUNCTION: acpi_ex_system_do_suspend
@@ -167,29 +152,24 @@ acpi_ex_system_do_stall (
167 * 152 *
168 ******************************************************************************/ 153 ******************************************************************************/
169 154
170acpi_status 155acpi_status acpi_ex_system_do_suspend(acpi_integer how_long)
171acpi_ex_system_do_suspend (
172 acpi_integer how_long)
173{ 156{
174 acpi_status status; 157 acpi_status status;
175
176
177 ACPI_FUNCTION_ENTRY ();
178 158
159 ACPI_FUNCTION_ENTRY();
179 160
180 /* Since this thread will sleep, we must release the interpreter */ 161 /* Since this thread will sleep, we must release the interpreter */
181 162
182 acpi_ex_exit_interpreter (); 163 acpi_ex_exit_interpreter();
183 164
184 acpi_os_sleep (how_long); 165 acpi_os_sleep(how_long);
185 166
186 /* And now we must get the interpreter again */ 167 /* And now we must get the interpreter again */
187 168
188 status = acpi_ex_enter_interpreter (); 169 status = acpi_ex_enter_interpreter();
189 return (status); 170 return (status);
190} 171}
191 172
192
193/******************************************************************************* 173/*******************************************************************************
194 * 174 *
195 * FUNCTION: acpi_ex_system_acquire_mutex 175 * FUNCTION: acpi_ex_system_acquire_mutex
@@ -206,33 +186,30 @@ acpi_ex_system_do_suspend (
206 ******************************************************************************/ 186 ******************************************************************************/
207 187
208acpi_status 188acpi_status
209acpi_ex_system_acquire_mutex ( 189acpi_ex_system_acquire_mutex(union acpi_operand_object * time_desc,
210 union acpi_operand_object *time_desc, 190 union acpi_operand_object * obj_desc)
211 union acpi_operand_object *obj_desc)
212{ 191{
213 acpi_status status = AE_OK; 192 acpi_status status = AE_OK;
214
215
216 ACPI_FUNCTION_TRACE_PTR ("ex_system_acquire_mutex", obj_desc);
217 193
194 ACPI_FUNCTION_TRACE_PTR("ex_system_acquire_mutex", obj_desc);
218 195
219 if (!obj_desc) { 196 if (!obj_desc) {
220 return_ACPI_STATUS (AE_BAD_PARAMETER); 197 return_ACPI_STATUS(AE_BAD_PARAMETER);
221 } 198 }
222 199
223 /* Support for the _GL_ Mutex object -- go get the global lock */ 200 /* Support for the _GL_ Mutex object -- go get the global lock */
224 201
225 if (obj_desc->mutex.semaphore == acpi_gbl_global_lock_semaphore) { 202 if (obj_desc->mutex.semaphore == acpi_gbl_global_lock_semaphore) {
226 status = acpi_ev_acquire_global_lock ((u16) time_desc->integer.value); 203 status =
227 return_ACPI_STATUS (status); 204 acpi_ev_acquire_global_lock((u16) time_desc->integer.value);
205 return_ACPI_STATUS(status);
228 } 206 }
229 207
230 status = acpi_ex_system_wait_semaphore (obj_desc->mutex.semaphore, 208 status = acpi_ex_system_wait_semaphore(obj_desc->mutex.semaphore,
231 (u16) time_desc->integer.value); 209 (u16) time_desc->integer.value);
232 return_ACPI_STATUS (status); 210 return_ACPI_STATUS(status);
233} 211}
234 212
235
236/******************************************************************************* 213/*******************************************************************************
237 * 214 *
238 * FUNCTION: acpi_ex_system_release_mutex 215 * FUNCTION: acpi_ex_system_release_mutex
@@ -248,32 +225,27 @@ acpi_ex_system_acquire_mutex (
248 * 225 *
249 ******************************************************************************/ 226 ******************************************************************************/
250 227
251acpi_status 228acpi_status acpi_ex_system_release_mutex(union acpi_operand_object *obj_desc)
252acpi_ex_system_release_mutex (
253 union acpi_operand_object *obj_desc)
254{ 229{
255 acpi_status status = AE_OK; 230 acpi_status status = AE_OK;
256
257
258 ACPI_FUNCTION_TRACE ("ex_system_release_mutex");
259 231
232 ACPI_FUNCTION_TRACE("ex_system_release_mutex");
260 233
261 if (!obj_desc) { 234 if (!obj_desc) {
262 return_ACPI_STATUS (AE_BAD_PARAMETER); 235 return_ACPI_STATUS(AE_BAD_PARAMETER);
263 } 236 }
264 237
265 /* Support for the _GL_ Mutex object -- release the global lock */ 238 /* Support for the _GL_ Mutex object -- release the global lock */
266 239
267 if (obj_desc->mutex.semaphore == acpi_gbl_global_lock_semaphore) { 240 if (obj_desc->mutex.semaphore == acpi_gbl_global_lock_semaphore) {
268 status = acpi_ev_release_global_lock (); 241 status = acpi_ev_release_global_lock();
269 return_ACPI_STATUS (status); 242 return_ACPI_STATUS(status);
270 } 243 }
271 244
272 status = acpi_os_signal_semaphore (obj_desc->mutex.semaphore, 1); 245 status = acpi_os_signal_semaphore(obj_desc->mutex.semaphore, 1);
273 return_ACPI_STATUS (status); 246 return_ACPI_STATUS(status);
274} 247}
275 248
276
277/******************************************************************************* 249/*******************************************************************************
278 * 250 *
279 * FUNCTION: acpi_ex_system_signal_event 251 * FUNCTION: acpi_ex_system_signal_event
@@ -287,24 +259,19 @@ acpi_ex_system_release_mutex (
287 * 259 *
288 ******************************************************************************/ 260 ******************************************************************************/
289 261
290acpi_status 262acpi_status acpi_ex_system_signal_event(union acpi_operand_object *obj_desc)
291acpi_ex_system_signal_event (
292 union acpi_operand_object *obj_desc)
293{ 263{
294 acpi_status status = AE_OK; 264 acpi_status status = AE_OK;
295
296
297 ACPI_FUNCTION_TRACE ("ex_system_signal_event");
298 265
266 ACPI_FUNCTION_TRACE("ex_system_signal_event");
299 267
300 if (obj_desc) { 268 if (obj_desc) {
301 status = acpi_os_signal_semaphore (obj_desc->event.semaphore, 1); 269 status = acpi_os_signal_semaphore(obj_desc->event.semaphore, 1);
302 } 270 }
303 271
304 return_ACPI_STATUS (status); 272 return_ACPI_STATUS(status);
305} 273}
306 274
307
308/******************************************************************************* 275/*******************************************************************************
309 * 276 *
310 * FUNCTION: acpi_ex_system_wait_event 277 * FUNCTION: acpi_ex_system_wait_event
@@ -321,25 +288,23 @@ acpi_ex_system_signal_event (
321 ******************************************************************************/ 288 ******************************************************************************/
322 289
323acpi_status 290acpi_status
324acpi_ex_system_wait_event ( 291acpi_ex_system_wait_event(union acpi_operand_object *time_desc,
325 union acpi_operand_object *time_desc, 292 union acpi_operand_object *obj_desc)
326 union acpi_operand_object *obj_desc)
327{ 293{
328 acpi_status status = AE_OK; 294 acpi_status status = AE_OK;
329
330
331 ACPI_FUNCTION_TRACE ("ex_system_wait_event");
332 295
296 ACPI_FUNCTION_TRACE("ex_system_wait_event");
333 297
334 if (obj_desc) { 298 if (obj_desc) {
335 status = acpi_ex_system_wait_semaphore (obj_desc->event.semaphore, 299 status =
336 (u16) time_desc->integer.value); 300 acpi_ex_system_wait_semaphore(obj_desc->event.semaphore,
301 (u16) time_desc->integer.
302 value);
337 } 303 }
338 304
339 return_ACPI_STATUS (status); 305 return_ACPI_STATUS(status);
340} 306}
341 307
342
343/******************************************************************************* 308/*******************************************************************************
344 * 309 *
345 * FUNCTION: acpi_ex_system_reset_event 310 * FUNCTION: acpi_ex_system_reset_event
@@ -352,27 +317,23 @@ acpi_ex_system_wait_event (
352 * 317 *
353 ******************************************************************************/ 318 ******************************************************************************/
354 319
355acpi_status 320acpi_status acpi_ex_system_reset_event(union acpi_operand_object *obj_desc)
356acpi_ex_system_reset_event (
357 union acpi_operand_object *obj_desc)
358{ 321{
359 acpi_status status = AE_OK; 322 acpi_status status = AE_OK;
360 void *temp_semaphore; 323 void *temp_semaphore;
361
362
363 ACPI_FUNCTION_ENTRY ();
364 324
325 ACPI_FUNCTION_ENTRY();
365 326
366 /* 327 /*
367 * We are going to simply delete the existing semaphore and 328 * We are going to simply delete the existing semaphore and
368 * create a new one! 329 * create a new one!
369 */ 330 */
370 status = acpi_os_create_semaphore (ACPI_NO_UNIT_LIMIT, 0, &temp_semaphore); 331 status =
371 if (ACPI_SUCCESS (status)) { 332 acpi_os_create_semaphore(ACPI_NO_UNIT_LIMIT, 0, &temp_semaphore);
372 (void) acpi_os_delete_semaphore (obj_desc->event.semaphore); 333 if (ACPI_SUCCESS(status)) {
334 (void)acpi_os_delete_semaphore(obj_desc->event.semaphore);
373 obj_desc->event.semaphore = temp_semaphore; 335 obj_desc->event.semaphore = temp_semaphore;
374 } 336 }
375 337
376 return (status); 338 return (status);
377} 339}
378