aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/executer/exutils.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/acpi/executer/exutils.c')
-rw-r--r--drivers/acpi/executer/exutils.c171
1 files changed, 62 insertions, 109 deletions
diff --git a/drivers/acpi/executer/exutils.c b/drivers/acpi/executer/exutils.c
index d00b0dcba96a..1ee79d8c8f88 100644
--- a/drivers/acpi/executer/exutils.c
+++ b/drivers/acpi/executer/exutils.c
@@ -42,7 +42,6 @@
42 * POSSIBILITY OF SUCH DAMAGES. 42 * POSSIBILITY OF SUCH DAMAGES.
43 */ 43 */
44 44
45
46/* 45/*
47 * DEFINE_AML_GLOBALS is tested in amlcode.h 46 * DEFINE_AML_GLOBALS is tested in amlcode.h
48 * to determine whether certain global names should be "defined" or only 47 * to determine whether certain global names should be "defined" or only
@@ -65,15 +64,10 @@
65#include <acpi/acevents.h> 64#include <acpi/acevents.h>
66 65
67#define _COMPONENT ACPI_EXECUTER 66#define _COMPONENT ACPI_EXECUTER
68 ACPI_MODULE_NAME ("exutils") 67ACPI_MODULE_NAME("exutils")
69 68
70/* Local prototypes */ 69/* Local prototypes */
71 70static u32 acpi_ex_digits_needed(acpi_integer value, u32 base);
72static u32
73acpi_ex_digits_needed (
74 acpi_integer value,
75 u32 base);
76
77 71
78#ifndef ACPI_NO_METHOD_EXECUTION 72#ifndef ACPI_NO_METHOD_EXECUTION
79/******************************************************************************* 73/*******************************************************************************
@@ -89,24 +83,20 @@ acpi_ex_digits_needed (
89 * 83 *
90 ******************************************************************************/ 84 ******************************************************************************/
91 85
92acpi_status 86acpi_status acpi_ex_enter_interpreter(void)
93acpi_ex_enter_interpreter (
94 void)
95{ 87{
96 acpi_status status; 88 acpi_status status;
97
98 ACPI_FUNCTION_TRACE ("ex_enter_interpreter");
99 89
90 ACPI_FUNCTION_TRACE("ex_enter_interpreter");
100 91
101 status = acpi_ut_acquire_mutex (ACPI_MTX_EXECUTE); 92 status = acpi_ut_acquire_mutex(ACPI_MTX_EXECUTE);
102 if (ACPI_FAILURE (status)) { 93 if (ACPI_FAILURE(status)) {
103 ACPI_REPORT_ERROR (("Could not acquire interpreter mutex\n")); 94 ACPI_REPORT_ERROR(("Could not acquire interpreter mutex\n"));
104 } 95 }
105 96
106 return_ACPI_STATUS (status); 97 return_ACPI_STATUS(status);
107} 98}
108 99
109
110/******************************************************************************* 100/*******************************************************************************
111 * 101 *
112 * FUNCTION: acpi_ex_exit_interpreter 102 * FUNCTION: acpi_ex_exit_interpreter
@@ -129,25 +119,20 @@ acpi_ex_enter_interpreter (
129 * 119 *
130 ******************************************************************************/ 120 ******************************************************************************/
131 121
132void 122void acpi_ex_exit_interpreter(void)
133acpi_ex_exit_interpreter (
134 void)
135{ 123{
136 acpi_status status; 124 acpi_status status;
137
138
139 ACPI_FUNCTION_TRACE ("ex_exit_interpreter");
140 125
126 ACPI_FUNCTION_TRACE("ex_exit_interpreter");
141 127
142 status = acpi_ut_release_mutex (ACPI_MTX_EXECUTE); 128 status = acpi_ut_release_mutex(ACPI_MTX_EXECUTE);
143 if (ACPI_FAILURE (status)) { 129 if (ACPI_FAILURE(status)) {
144 ACPI_REPORT_ERROR (("Could not release interpreter mutex\n")); 130 ACPI_REPORT_ERROR(("Could not release interpreter mutex\n"));
145 } 131 }
146 132
147 return_VOID; 133 return_VOID;
148} 134}
149 135
150
151/******************************************************************************* 136/*******************************************************************************
152 * 137 *
153 * FUNCTION: acpi_ex_truncate_for32bit_table 138 * FUNCTION: acpi_ex_truncate_for32bit_table
@@ -161,20 +146,17 @@ acpi_ex_exit_interpreter (
161 * 146 *
162 ******************************************************************************/ 147 ******************************************************************************/
163 148
164void 149void acpi_ex_truncate_for32bit_table(union acpi_operand_object *obj_desc)
165acpi_ex_truncate_for32bit_table (
166 union acpi_operand_object *obj_desc)
167{ 150{
168 151
169 ACPI_FUNCTION_ENTRY (); 152 ACPI_FUNCTION_ENTRY();
170
171 153
172 /* 154 /*
173 * Object must be a valid number and we must be executing 155 * Object must be a valid number and we must be executing
174 * a control method 156 * a control method
175 */ 157 */
176 if ((!obj_desc) || 158 if ((!obj_desc) ||
177 (ACPI_GET_OBJECT_TYPE (obj_desc) != ACPI_TYPE_INTEGER)) { 159 (ACPI_GET_OBJECT_TYPE(obj_desc) != ACPI_TYPE_INTEGER)) {
178 return; 160 return;
179 } 161 }
180 162
@@ -187,7 +169,6 @@ acpi_ex_truncate_for32bit_table (
187 } 169 }
188} 170}
189 171
190
191/******************************************************************************* 172/*******************************************************************************
192 * 173 *
193 * FUNCTION: acpi_ex_acquire_global_lock 174 * FUNCTION: acpi_ex_acquire_global_lock
@@ -203,37 +184,31 @@ acpi_ex_truncate_for32bit_table (
203 * 184 *
204 ******************************************************************************/ 185 ******************************************************************************/
205 186
206u8 187u8 acpi_ex_acquire_global_lock(u32 field_flags)
207acpi_ex_acquire_global_lock (
208 u32 field_flags)
209{ 188{
210 u8 locked = FALSE; 189 u8 locked = FALSE;
211 acpi_status status; 190 acpi_status status;
212
213
214 ACPI_FUNCTION_TRACE ("ex_acquire_global_lock");
215 191
192 ACPI_FUNCTION_TRACE("ex_acquire_global_lock");
216 193
217 /* Only attempt lock if the always_lock bit is set */ 194 /* Only attempt lock if the always_lock bit is set */
218 195
219 if (field_flags & AML_FIELD_LOCK_RULE_MASK) { 196 if (field_flags & AML_FIELD_LOCK_RULE_MASK) {
220 /* We should attempt to get the lock, wait forever */ 197 /* We should attempt to get the lock, wait forever */
221 198
222 status = acpi_ev_acquire_global_lock (ACPI_WAIT_FOREVER); 199 status = acpi_ev_acquire_global_lock(ACPI_WAIT_FOREVER);
223 if (ACPI_SUCCESS (status)) { 200 if (ACPI_SUCCESS(status)) {
224 locked = TRUE; 201 locked = TRUE;
225 } 202 } else {
226 else { 203 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
227 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 204 "Could not acquire Global Lock, %s\n",
228 "Could not acquire Global Lock, %s\n", 205 acpi_format_exception(status)));
229 acpi_format_exception (status)));
230 } 206 }
231 } 207 }
232 208
233 return_VALUE (locked); 209 return_VALUE(locked);
234} 210}
235 211
236
237/******************************************************************************* 212/*******************************************************************************
238 * 213 *
239 * FUNCTION: acpi_ex_release_global_lock 214 * FUNCTION: acpi_ex_release_global_lock
@@ -247,34 +222,28 @@ acpi_ex_acquire_global_lock (
247 * 222 *
248 ******************************************************************************/ 223 ******************************************************************************/
249 224
250void 225void acpi_ex_release_global_lock(u8 locked_by_me)
251acpi_ex_release_global_lock (
252 u8 locked_by_me)
253{ 226{
254 acpi_status status; 227 acpi_status status;
255
256
257 ACPI_FUNCTION_TRACE ("ex_release_global_lock");
258 228
229 ACPI_FUNCTION_TRACE("ex_release_global_lock");
259 230
260 /* Only attempt unlock if the caller locked it */ 231 /* Only attempt unlock if the caller locked it */
261 232
262 if (locked_by_me) { 233 if (locked_by_me) {
263 /* OK, now release the lock */ 234 /* OK, now release the lock */
264 235
265 status = acpi_ev_release_global_lock (); 236 status = acpi_ev_release_global_lock();
266 if (ACPI_FAILURE (status)) { 237 if (ACPI_FAILURE(status)) {
267 /* Report the error, but there isn't much else we can do */ 238 /* Report the error, but there isn't much else we can do */
268 239
269 ACPI_REPORT_ERROR (("Could not release ACPI Global Lock, %s\n", 240 ACPI_REPORT_ERROR(("Could not release ACPI Global Lock, %s\n", acpi_format_exception(status)));
270 acpi_format_exception (status)));
271 } 241 }
272 } 242 }
273 243
274 return_VOID; 244 return_VOID;
275} 245}
276 246
277
278/******************************************************************************* 247/*******************************************************************************
279 * 248 *
280 * FUNCTION: acpi_ex_digits_needed 249 * FUNCTION: acpi_ex_digits_needed
@@ -289,22 +258,17 @@ acpi_ex_release_global_lock (
289 * 258 *
290 ******************************************************************************/ 259 ******************************************************************************/
291 260
292static u32 261static u32 acpi_ex_digits_needed(acpi_integer value, u32 base)
293acpi_ex_digits_needed (
294 acpi_integer value,
295 u32 base)
296{ 262{
297 u32 num_digits; 263 u32 num_digits;
298 acpi_integer current_value; 264 acpi_integer current_value;
299
300
301 ACPI_FUNCTION_TRACE ("ex_digits_needed");
302 265
266 ACPI_FUNCTION_TRACE("ex_digits_needed");
303 267
304 /* acpi_integer is unsigned, so we don't worry about a '-' prefix */ 268 /* acpi_integer is unsigned, so we don't worry about a '-' prefix */
305 269
306 if (value == 0) { 270 if (value == 0) {
307 return_VALUE (1); 271 return_VALUE(1);
308 } 272 }
309 273
310 current_value = value; 274 current_value = value;
@@ -313,14 +277,14 @@ acpi_ex_digits_needed (
313 /* Count the digits in the requested base */ 277 /* Count the digits in the requested base */
314 278
315 while (current_value) { 279 while (current_value) {
316 (void) acpi_ut_short_divide (current_value, base, &current_value, NULL); 280 (void)acpi_ut_short_divide(current_value, base, &current_value,
281 NULL);
317 num_digits++; 282 num_digits++;
318 } 283 }
319 284
320 return_VALUE (num_digits); 285 return_VALUE(num_digits);
321} 286}
322 287
323
324/******************************************************************************* 288/*******************************************************************************
325 * 289 *
326 * FUNCTION: acpi_ex_eisa_id_to_string 290 * FUNCTION: acpi_ex_eisa_id_to_string
@@ -334,32 +298,26 @@ acpi_ex_digits_needed (
334 * 298 *
335 ******************************************************************************/ 299 ******************************************************************************/
336 300
337void 301void acpi_ex_eisa_id_to_string(u32 numeric_id, char *out_string)
338acpi_ex_eisa_id_to_string (
339 u32 numeric_id,
340 char *out_string)
341{ 302{
342 u32 eisa_id; 303 u32 eisa_id;
343
344
345 ACPI_FUNCTION_ENTRY ();
346 304
305 ACPI_FUNCTION_ENTRY();
347 306
348 /* Swap ID to big-endian to get contiguous bits */ 307 /* Swap ID to big-endian to get contiguous bits */
349 308
350 eisa_id = acpi_ut_dword_byte_swap (numeric_id); 309 eisa_id = acpi_ut_dword_byte_swap(numeric_id);
351 310
352 out_string[0] = (char) ('@' + (((unsigned long) eisa_id >> 26) & 0x1f)); 311 out_string[0] = (char)('@' + (((unsigned long)eisa_id >> 26) & 0x1f));
353 out_string[1] = (char) ('@' + ((eisa_id >> 21) & 0x1f)); 312 out_string[1] = (char)('@' + ((eisa_id >> 21) & 0x1f));
354 out_string[2] = (char) ('@' + ((eisa_id >> 16) & 0x1f)); 313 out_string[2] = (char)('@' + ((eisa_id >> 16) & 0x1f));
355 out_string[3] = acpi_ut_hex_to_ascii_char ((acpi_integer) eisa_id, 12); 314 out_string[3] = acpi_ut_hex_to_ascii_char((acpi_integer) eisa_id, 12);
356 out_string[4] = acpi_ut_hex_to_ascii_char ((acpi_integer) eisa_id, 8); 315 out_string[4] = acpi_ut_hex_to_ascii_char((acpi_integer) eisa_id, 8);
357 out_string[5] = acpi_ut_hex_to_ascii_char ((acpi_integer) eisa_id, 4); 316 out_string[5] = acpi_ut_hex_to_ascii_char((acpi_integer) eisa_id, 4);
358 out_string[6] = acpi_ut_hex_to_ascii_char ((acpi_integer) eisa_id, 0); 317 out_string[6] = acpi_ut_hex_to_ascii_char((acpi_integer) eisa_id, 0);
359 out_string[7] = 0; 318 out_string[7] = 0;
360} 319}
361 320
362
363/******************************************************************************* 321/*******************************************************************************
364 * 322 *
365 * FUNCTION: acpi_ex_unsigned_integer_to_string 323 * FUNCTION: acpi_ex_unsigned_integer_to_string
@@ -374,25 +332,20 @@ acpi_ex_eisa_id_to_string (
374 * 332 *
375 ******************************************************************************/ 333 ******************************************************************************/
376 334
377void 335void acpi_ex_unsigned_integer_to_string(acpi_integer value, char *out_string)
378acpi_ex_unsigned_integer_to_string (
379 acpi_integer value,
380 char *out_string)
381{ 336{
382 u32 count; 337 u32 count;
383 u32 digits_needed; 338 u32 digits_needed;
384 u32 remainder; 339 u32 remainder;
385
386
387 ACPI_FUNCTION_ENTRY ();
388 340
341 ACPI_FUNCTION_ENTRY();
389 342
390 digits_needed = acpi_ex_digits_needed (value, 10); 343 digits_needed = acpi_ex_digits_needed(value, 10);
391 out_string[digits_needed] = 0; 344 out_string[digits_needed] = 0;
392 345
393 for (count = digits_needed; count > 0; count--) { 346 for (count = digits_needed; count > 0; count--) {
394 (void) acpi_ut_short_divide (value, 10, &value, &remainder); 347 (void)acpi_ut_short_divide(value, 10, &value, &remainder);
395 out_string[count-1] = (char) ('0' + remainder);\ 348 out_string[count - 1] = (char)('0' + remainder);
396 } 349 }
397} 350}
398 351