diff options
Diffstat (limited to 'drivers/acpi/utilities/utmisc.c')
-rw-r--r-- | drivers/acpi/utilities/utmisc.c | 431 |
1 files changed, 171 insertions, 260 deletions
diff --git a/drivers/acpi/utilities/utmisc.c b/drivers/acpi/utilities/utmisc.c index 1d350b302a34..474fe7cb6c09 100644 --- a/drivers/acpi/utilities/utmisc.c +++ b/drivers/acpi/utilities/utmisc.c | |||
@@ -41,14 +41,11 @@ | |||
41 | * POSSIBILITY OF SUCH DAMAGES. | 41 | * POSSIBILITY OF SUCH DAMAGES. |
42 | */ | 42 | */ |
43 | 43 | ||
44 | |||
45 | #include <acpi/acpi.h> | 44 | #include <acpi/acpi.h> |
46 | #include <acpi/acnamesp.h> | 45 | #include <acpi/acnamesp.h> |
47 | 46 | ||
48 | |||
49 | #define _COMPONENT ACPI_UTILITIES | 47 | #define _COMPONENT ACPI_UTILITIES |
50 | ACPI_MODULE_NAME ("utmisc") | 48 | ACPI_MODULE_NAME("utmisc") |
51 | |||
52 | 49 | ||
53 | /******************************************************************************* | 50 | /******************************************************************************* |
54 | * | 51 | * |
@@ -63,23 +60,18 @@ | |||
63 | * when the method exits or the table is unloaded. | 60 | * when the method exits or the table is unloaded. |
64 | * | 61 | * |
65 | ******************************************************************************/ | 62 | ******************************************************************************/ |
66 | 63 | acpi_status acpi_ut_allocate_owner_id(acpi_owner_id * owner_id) | |
67 | acpi_status | ||
68 | acpi_ut_allocate_owner_id ( | ||
69 | acpi_owner_id *owner_id) | ||
70 | { | 64 | { |
71 | acpi_native_uint i; | 65 | acpi_native_uint i; |
72 | acpi_status status; | 66 | acpi_status status; |
73 | |||
74 | |||
75 | ACPI_FUNCTION_TRACE ("ut_allocate_owner_id"); | ||
76 | 67 | ||
68 | ACPI_FUNCTION_TRACE("ut_allocate_owner_id"); | ||
77 | 69 | ||
78 | /* Mutex for the global ID mask */ | 70 | /* Mutex for the global ID mask */ |
79 | 71 | ||
80 | status = acpi_ut_acquire_mutex (ACPI_MTX_CACHES); | 72 | status = acpi_ut_acquire_mutex(ACPI_MTX_CACHES); |
81 | if (ACPI_FAILURE (status)) { | 73 | if (ACPI_FAILURE(status)) { |
82 | return_ACPI_STATUS (status); | 74 | return_ACPI_STATUS(status); |
83 | } | 75 | } |
84 | 76 | ||
85 | /* Find a free owner ID */ | 77 | /* Find a free owner ID */ |
@@ -101,15 +93,13 @@ acpi_ut_allocate_owner_id ( | |||
101 | */ | 93 | */ |
102 | *owner_id = 0; | 94 | *owner_id = 0; |
103 | status = AE_OWNER_ID_LIMIT; | 95 | status = AE_OWNER_ID_LIMIT; |
104 | ACPI_REPORT_ERROR (( | 96 | ACPI_REPORT_ERROR(("Could not allocate new owner_id (32 max), AE_OWNER_ID_LIMIT\n")); |
105 | "Could not allocate new owner_id (32 max), AE_OWNER_ID_LIMIT\n")); | ||
106 | 97 | ||
107 | exit: | 98 | exit: |
108 | (void) acpi_ut_release_mutex (ACPI_MTX_CACHES); | 99 | (void)acpi_ut_release_mutex(ACPI_MTX_CACHES); |
109 | return_ACPI_STATUS (status); | 100 | return_ACPI_STATUS(status); |
110 | } | 101 | } |
111 | 102 | ||
112 | |||
113 | /******************************************************************************* | 103 | /******************************************************************************* |
114 | * | 104 | * |
115 | * FUNCTION: acpi_ut_release_owner_id | 105 | * FUNCTION: acpi_ut_release_owner_id |
@@ -124,16 +114,12 @@ exit: | |||
124 | * | 114 | * |
125 | ******************************************************************************/ | 115 | ******************************************************************************/ |
126 | 116 | ||
127 | void | 117 | void acpi_ut_release_owner_id(acpi_owner_id * owner_id_ptr) |
128 | acpi_ut_release_owner_id ( | ||
129 | acpi_owner_id *owner_id_ptr) | ||
130 | { | 118 | { |
131 | acpi_owner_id owner_id = *owner_id_ptr; | 119 | acpi_owner_id owner_id = *owner_id_ptr; |
132 | acpi_status status; | 120 | acpi_status status; |
133 | |||
134 | |||
135 | ACPI_FUNCTION_TRACE ("ut_release_owner_id"); | ||
136 | 121 | ||
122 | ACPI_FUNCTION_TRACE("ut_release_owner_id"); | ||
137 | 123 | ||
138 | /* Always clear the input owner_id (zero is an invalid ID) */ | 124 | /* Always clear the input owner_id (zero is an invalid ID) */ |
139 | 125 | ||
@@ -142,18 +128,18 @@ acpi_ut_release_owner_id ( | |||
142 | /* Zero is not a valid owner_iD */ | 128 | /* Zero is not a valid owner_iD */ |
143 | 129 | ||
144 | if ((owner_id == 0) || (owner_id > 32)) { | 130 | if ((owner_id == 0) || (owner_id > 32)) { |
145 | ACPI_REPORT_ERROR (("Invalid owner_id: %2.2X\n", owner_id)); | 131 | ACPI_REPORT_ERROR(("Invalid owner_id: %2.2X\n", owner_id)); |
146 | return_VOID; | 132 | return_VOID; |
147 | } | 133 | } |
148 | 134 | ||
149 | /* Mutex for the global ID mask */ | 135 | /* Mutex for the global ID mask */ |
150 | 136 | ||
151 | status = acpi_ut_acquire_mutex (ACPI_MTX_CACHES); | 137 | status = acpi_ut_acquire_mutex(ACPI_MTX_CACHES); |
152 | if (ACPI_FAILURE (status)) { | 138 | if (ACPI_FAILURE(status)) { |
153 | return_VOID; | 139 | return_VOID; |
154 | } | 140 | } |
155 | 141 | ||
156 | owner_id--; /* Normalize to zero */ | 142 | owner_id--; /* Normalize to zero */ |
157 | 143 | ||
158 | /* Free the owner ID only if it is valid */ | 144 | /* Free the owner ID only if it is valid */ |
159 | 145 | ||
@@ -161,11 +147,10 @@ acpi_ut_release_owner_id ( | |||
161 | acpi_gbl_owner_id_mask ^= (1 << owner_id); | 147 | acpi_gbl_owner_id_mask ^= (1 << owner_id); |
162 | } | 148 | } |
163 | 149 | ||
164 | (void) acpi_ut_release_mutex (ACPI_MTX_CACHES); | 150 | (void)acpi_ut_release_mutex(ACPI_MTX_CACHES); |
165 | return_VOID; | 151 | return_VOID; |
166 | } | 152 | } |
167 | 153 | ||
168 | |||
169 | /******************************************************************************* | 154 | /******************************************************************************* |
170 | * | 155 | * |
171 | * FUNCTION: acpi_ut_strupr (strupr) | 156 | * FUNCTION: acpi_ut_strupr (strupr) |
@@ -180,15 +165,11 @@ acpi_ut_release_owner_id ( | |||
180 | * | 165 | * |
181 | ******************************************************************************/ | 166 | ******************************************************************************/ |
182 | 167 | ||
183 | void | 168 | void acpi_ut_strupr(char *src_string) |
184 | acpi_ut_strupr ( | ||
185 | char *src_string) | ||
186 | { | 169 | { |
187 | char *string; | 170 | char *string; |
188 | |||
189 | |||
190 | ACPI_FUNCTION_ENTRY (); | ||
191 | 171 | ||
172 | ACPI_FUNCTION_ENTRY(); | ||
192 | 173 | ||
193 | if (!src_string) { | 174 | if (!src_string) { |
194 | return; | 175 | return; |
@@ -197,13 +178,12 @@ acpi_ut_strupr ( | |||
197 | /* Walk entire string, uppercasing the letters */ | 178 | /* Walk entire string, uppercasing the letters */ |
198 | 179 | ||
199 | for (string = src_string; *string; string++) { | 180 | for (string = src_string; *string; string++) { |
200 | *string = (char) ACPI_TOUPPER (*string); | 181 | *string = (char)ACPI_TOUPPER(*string); |
201 | } | 182 | } |
202 | 183 | ||
203 | return; | 184 | return; |
204 | } | 185 | } |
205 | 186 | ||
206 | |||
207 | /******************************************************************************* | 187 | /******************************************************************************* |
208 | * | 188 | * |
209 | * FUNCTION: acpi_ut_print_string | 189 | * FUNCTION: acpi_ut_print_string |
@@ -218,85 +198,77 @@ acpi_ut_strupr ( | |||
218 | * | 198 | * |
219 | ******************************************************************************/ | 199 | ******************************************************************************/ |
220 | 200 | ||
221 | void | 201 | void acpi_ut_print_string(char *string, u8 max_length) |
222 | acpi_ut_print_string ( | ||
223 | char *string, | ||
224 | u8 max_length) | ||
225 | { | 202 | { |
226 | u32 i; | 203 | u32 i; |
227 | |||
228 | 204 | ||
229 | if (!string) { | 205 | if (!string) { |
230 | acpi_os_printf ("<\"NULL STRING PTR\">"); | 206 | acpi_os_printf("<\"NULL STRING PTR\">"); |
231 | return; | 207 | return; |
232 | } | 208 | } |
233 | 209 | ||
234 | acpi_os_printf ("\""); | 210 | acpi_os_printf("\""); |
235 | for (i = 0; string[i] && (i < max_length); i++) { | 211 | for (i = 0; string[i] && (i < max_length); i++) { |
236 | /* Escape sequences */ | 212 | /* Escape sequences */ |
237 | 213 | ||
238 | switch (string[i]) { | 214 | switch (string[i]) { |
239 | case 0x07: | 215 | case 0x07: |
240 | acpi_os_printf ("\\a"); /* BELL */ | 216 | acpi_os_printf("\\a"); /* BELL */ |
241 | break; | 217 | break; |
242 | 218 | ||
243 | case 0x08: | 219 | case 0x08: |
244 | acpi_os_printf ("\\b"); /* BACKSPACE */ | 220 | acpi_os_printf("\\b"); /* BACKSPACE */ |
245 | break; | 221 | break; |
246 | 222 | ||
247 | case 0x0C: | 223 | case 0x0C: |
248 | acpi_os_printf ("\\f"); /* FORMFEED */ | 224 | acpi_os_printf("\\f"); /* FORMFEED */ |
249 | break; | 225 | break; |
250 | 226 | ||
251 | case 0x0A: | 227 | case 0x0A: |
252 | acpi_os_printf ("\\n"); /* LINEFEED */ | 228 | acpi_os_printf("\\n"); /* LINEFEED */ |
253 | break; | 229 | break; |
254 | 230 | ||
255 | case 0x0D: | 231 | case 0x0D: |
256 | acpi_os_printf ("\\r"); /* CARRIAGE RETURN*/ | 232 | acpi_os_printf("\\r"); /* CARRIAGE RETURN */ |
257 | break; | 233 | break; |
258 | 234 | ||
259 | case 0x09: | 235 | case 0x09: |
260 | acpi_os_printf ("\\t"); /* HORIZONTAL TAB */ | 236 | acpi_os_printf("\\t"); /* HORIZONTAL TAB */ |
261 | break; | 237 | break; |
262 | 238 | ||
263 | case 0x0B: | 239 | case 0x0B: |
264 | acpi_os_printf ("\\v"); /* VERTICAL TAB */ | 240 | acpi_os_printf("\\v"); /* VERTICAL TAB */ |
265 | break; | 241 | break; |
266 | 242 | ||
267 | case '\'': /* Single Quote */ | 243 | case '\'': /* Single Quote */ |
268 | case '\"': /* Double Quote */ | 244 | case '\"': /* Double Quote */ |
269 | case '\\': /* Backslash */ | 245 | case '\\': /* Backslash */ |
270 | acpi_os_printf ("\\%c", (int) string[i]); | 246 | acpi_os_printf("\\%c", (int)string[i]); |
271 | break; | 247 | break; |
272 | 248 | ||
273 | default: | 249 | default: |
274 | 250 | ||
275 | /* Check for printable character or hex escape */ | 251 | /* Check for printable character or hex escape */ |
276 | 252 | ||
277 | if (ACPI_IS_PRINT (string[i])) | 253 | if (ACPI_IS_PRINT(string[i])) { |
278 | { | ||
279 | /* This is a normal character */ | 254 | /* This is a normal character */ |
280 | 255 | ||
281 | acpi_os_printf ("%c", (int) string[i]); | 256 | acpi_os_printf("%c", (int)string[i]); |
282 | } | 257 | } else { |
283 | else | ||
284 | { | ||
285 | /* All others will be Hex escapes */ | 258 | /* All others will be Hex escapes */ |
286 | 259 | ||
287 | acpi_os_printf ("\\x%2.2X", (s32) string[i]); | 260 | acpi_os_printf("\\x%2.2X", (s32) string[i]); |
288 | } | 261 | } |
289 | break; | 262 | break; |
290 | } | 263 | } |
291 | } | 264 | } |
292 | acpi_os_printf ("\""); | 265 | acpi_os_printf("\""); |
293 | 266 | ||
294 | if (i == max_length && string[i]) { | 267 | if (i == max_length && string[i]) { |
295 | acpi_os_printf ("..."); | 268 | acpi_os_printf("..."); |
296 | } | 269 | } |
297 | } | 270 | } |
298 | 271 | ||
299 | |||
300 | /******************************************************************************* | 272 | /******************************************************************************* |
301 | * | 273 | * |
302 | * FUNCTION: acpi_ut_dword_byte_swap | 274 | * FUNCTION: acpi_ut_dword_byte_swap |
@@ -309,22 +281,18 @@ acpi_ut_print_string ( | |||
309 | * | 281 | * |
310 | ******************************************************************************/ | 282 | ******************************************************************************/ |
311 | 283 | ||
312 | u32 | 284 | u32 acpi_ut_dword_byte_swap(u32 value) |
313 | acpi_ut_dword_byte_swap ( | ||
314 | u32 value) | ||
315 | { | 285 | { |
316 | union { | 286 | union { |
317 | u32 value; | 287 | u32 value; |
318 | u8 bytes[4]; | 288 | u8 bytes[4]; |
319 | } out; | 289 | } out; |
320 | union { | 290 | union { |
321 | u32 value; | 291 | u32 value; |
322 | u8 bytes[4]; | 292 | u8 bytes[4]; |
323 | } in; | 293 | } in; |
324 | 294 | ||
325 | 295 | ACPI_FUNCTION_ENTRY(); | |
326 | ACPI_FUNCTION_ENTRY (); | ||
327 | |||
328 | 296 | ||
329 | in.value = value; | 297 | in.value = value; |
330 | 298 | ||
@@ -336,7 +304,6 @@ acpi_ut_dword_byte_swap ( | |||
336 | return (out.value); | 304 | return (out.value); |
337 | } | 305 | } |
338 | 306 | ||
339 | |||
340 | /******************************************************************************* | 307 | /******************************************************************************* |
341 | * | 308 | * |
342 | * FUNCTION: acpi_ut_set_integer_width | 309 | * FUNCTION: acpi_ut_set_integer_width |
@@ -352,24 +319,20 @@ acpi_ut_dword_byte_swap ( | |||
352 | * | 319 | * |
353 | ******************************************************************************/ | 320 | ******************************************************************************/ |
354 | 321 | ||
355 | void | 322 | void acpi_ut_set_integer_width(u8 revision) |
356 | acpi_ut_set_integer_width ( | ||
357 | u8 revision) | ||
358 | { | 323 | { |
359 | 324 | ||
360 | if (revision <= 1) { | 325 | if (revision <= 1) { |
361 | acpi_gbl_integer_bit_width = 32; | 326 | acpi_gbl_integer_bit_width = 32; |
362 | acpi_gbl_integer_nybble_width = 8; | 327 | acpi_gbl_integer_nybble_width = 8; |
363 | acpi_gbl_integer_byte_width = 4; | 328 | acpi_gbl_integer_byte_width = 4; |
364 | } | 329 | } else { |
365 | else { | ||
366 | acpi_gbl_integer_bit_width = 64; | 330 | acpi_gbl_integer_bit_width = 64; |
367 | acpi_gbl_integer_nybble_width = 16; | 331 | acpi_gbl_integer_nybble_width = 16; |
368 | acpi_gbl_integer_byte_width = 8; | 332 | acpi_gbl_integer_byte_width = 8; |
369 | } | 333 | } |
370 | } | 334 | } |
371 | 335 | ||
372 | |||
373 | #ifdef ACPI_DEBUG_OUTPUT | 336 | #ifdef ACPI_DEBUG_OUTPUT |
374 | /******************************************************************************* | 337 | /******************************************************************************* |
375 | * | 338 | * |
@@ -387,17 +350,14 @@ acpi_ut_set_integer_width ( | |||
387 | ******************************************************************************/ | 350 | ******************************************************************************/ |
388 | 351 | ||
389 | void | 352 | void |
390 | acpi_ut_display_init_pathname ( | 353 | acpi_ut_display_init_pathname(u8 type, |
391 | u8 type, | 354 | struct acpi_namespace_node *obj_handle, |
392 | struct acpi_namespace_node *obj_handle, | 355 | char *path) |
393 | char *path) | ||
394 | { | 356 | { |
395 | acpi_status status; | 357 | acpi_status status; |
396 | struct acpi_buffer buffer; | 358 | struct acpi_buffer buffer; |
397 | |||
398 | |||
399 | ACPI_FUNCTION_ENTRY (); | ||
400 | 359 | ||
360 | ACPI_FUNCTION_ENTRY(); | ||
401 | 361 | ||
402 | /* Only print the path if the appropriate debug level is enabled */ | 362 | /* Only print the path if the appropriate debug level is enabled */ |
403 | 363 | ||
@@ -408,8 +368,8 @@ acpi_ut_display_init_pathname ( | |||
408 | /* Get the full pathname to the node */ | 368 | /* Get the full pathname to the node */ |
409 | 369 | ||
410 | buffer.length = ACPI_ALLOCATE_LOCAL_BUFFER; | 370 | buffer.length = ACPI_ALLOCATE_LOCAL_BUFFER; |
411 | status = acpi_ns_handle_to_pathname (obj_handle, &buffer); | 371 | status = acpi_ns_handle_to_pathname(obj_handle, &buffer); |
412 | if (ACPI_FAILURE (status)) { | 372 | if (ACPI_FAILURE(status)) { |
413 | return; | 373 | return; |
414 | } | 374 | } |
415 | 375 | ||
@@ -417,31 +377,30 @@ acpi_ut_display_init_pathname ( | |||
417 | 377 | ||
418 | switch (type) { | 378 | switch (type) { |
419 | case ACPI_TYPE_METHOD: | 379 | case ACPI_TYPE_METHOD: |
420 | acpi_os_printf ("Executing "); | 380 | acpi_os_printf("Executing "); |
421 | break; | 381 | break; |
422 | 382 | ||
423 | default: | 383 | default: |
424 | acpi_os_printf ("Initializing "); | 384 | acpi_os_printf("Initializing "); |
425 | break; | 385 | break; |
426 | } | 386 | } |
427 | 387 | ||
428 | /* Print the object type and pathname */ | 388 | /* Print the object type and pathname */ |
429 | 389 | ||
430 | acpi_os_printf ("%-12s %s", | 390 | acpi_os_printf("%-12s %s", |
431 | acpi_ut_get_type_name (type), (char *) buffer.pointer); | 391 | acpi_ut_get_type_name(type), (char *)buffer.pointer); |
432 | 392 | ||
433 | /* Extra path is used to append names like _STA, _INI, etc. */ | 393 | /* Extra path is used to append names like _STA, _INI, etc. */ |
434 | 394 | ||
435 | if (path) { | 395 | if (path) { |
436 | acpi_os_printf (".%s", path); | 396 | acpi_os_printf(".%s", path); |
437 | } | 397 | } |
438 | acpi_os_printf ("\n"); | 398 | acpi_os_printf("\n"); |
439 | 399 | ||
440 | ACPI_MEM_FREE (buffer.pointer); | 400 | ACPI_MEM_FREE(buffer.pointer); |
441 | } | 401 | } |
442 | #endif | 402 | #endif |
443 | 403 | ||
444 | |||
445 | /******************************************************************************* | 404 | /******************************************************************************* |
446 | * | 405 | * |
447 | * FUNCTION: acpi_ut_valid_acpi_name | 406 | * FUNCTION: acpi_ut_valid_acpi_name |
@@ -457,25 +416,21 @@ acpi_ut_display_init_pathname ( | |||
457 | * | 416 | * |
458 | ******************************************************************************/ | 417 | ******************************************************************************/ |
459 | 418 | ||
460 | u8 | 419 | u8 acpi_ut_valid_acpi_name(u32 name) |
461 | acpi_ut_valid_acpi_name ( | ||
462 | u32 name) | ||
463 | { | 420 | { |
464 | char *name_ptr = (char *) &name; | 421 | char *name_ptr = (char *)&name; |
465 | char character; | 422 | char character; |
466 | acpi_native_uint i; | 423 | acpi_native_uint i; |
467 | |||
468 | |||
469 | ACPI_FUNCTION_ENTRY (); | ||
470 | 424 | ||
425 | ACPI_FUNCTION_ENTRY(); | ||
471 | 426 | ||
472 | for (i = 0; i < ACPI_NAME_SIZE; i++) { | 427 | for (i = 0; i < ACPI_NAME_SIZE; i++) { |
473 | character = *name_ptr; | 428 | character = *name_ptr; |
474 | name_ptr++; | 429 | name_ptr++; |
475 | 430 | ||
476 | if (!((character == '_') || | 431 | if (!((character == '_') || |
477 | (character >= 'A' && character <= 'Z') || | 432 | (character >= 'A' && character <= 'Z') || |
478 | (character >= '0' && character <= '9'))) { | 433 | (character >= '0' && character <= '9'))) { |
479 | return (FALSE); | 434 | return (FALSE); |
480 | } | 435 | } |
481 | } | 436 | } |
@@ -483,7 +438,6 @@ acpi_ut_valid_acpi_name ( | |||
483 | return (TRUE); | 438 | return (TRUE); |
484 | } | 439 | } |
485 | 440 | ||
486 | |||
487 | /******************************************************************************* | 441 | /******************************************************************************* |
488 | * | 442 | * |
489 | * FUNCTION: acpi_ut_valid_acpi_character | 443 | * FUNCTION: acpi_ut_valid_acpi_character |
@@ -496,19 +450,16 @@ acpi_ut_valid_acpi_name ( | |||
496 | * | 450 | * |
497 | ******************************************************************************/ | 451 | ******************************************************************************/ |
498 | 452 | ||
499 | u8 | 453 | u8 acpi_ut_valid_acpi_character(char character) |
500 | acpi_ut_valid_acpi_character ( | ||
501 | char character) | ||
502 | { | 454 | { |
503 | 455 | ||
504 | ACPI_FUNCTION_ENTRY (); | 456 | ACPI_FUNCTION_ENTRY(); |
505 | 457 | ||
506 | return ((u8) ((character == '_') || | 458 | return ((u8) ((character == '_') || |
507 | (character >= 'A' && character <= 'Z') || | 459 | (character >= 'A' && character <= 'Z') || |
508 | (character >= '0' && character <= '9'))); | 460 | (character >= '0' && character <= '9'))); |
509 | } | 461 | } |
510 | 462 | ||
511 | |||
512 | /******************************************************************************* | 463 | /******************************************************************************* |
513 | * | 464 | * |
514 | * FUNCTION: acpi_ut_strtoul64 | 465 | * FUNCTION: acpi_ut_strtoul64 |
@@ -525,18 +476,13 @@ acpi_ut_valid_acpi_character ( | |||
525 | ******************************************************************************/ | 476 | ******************************************************************************/ |
526 | 477 | ||
527 | acpi_status | 478 | acpi_status |
528 | acpi_ut_strtoul64 ( | 479 | acpi_ut_strtoul64(char *string, u32 base, acpi_integer * ret_integer) |
529 | char *string, | ||
530 | u32 base, | ||
531 | acpi_integer *ret_integer) | ||
532 | { | 480 | { |
533 | u32 this_digit = 0; | 481 | u32 this_digit = 0; |
534 | acpi_integer return_value = 0; | 482 | acpi_integer return_value = 0; |
535 | acpi_integer quotient; | 483 | acpi_integer quotient; |
536 | |||
537 | |||
538 | ACPI_FUNCTION_TRACE ("ut_stroul64"); | ||
539 | 484 | ||
485 | ACPI_FUNCTION_TRACE("ut_stroul64"); | ||
540 | 486 | ||
541 | if ((!string) || !(*string)) { | 487 | if ((!string) || !(*string)) { |
542 | goto error_exit; | 488 | goto error_exit; |
@@ -550,12 +496,12 @@ acpi_ut_strtoul64 ( | |||
550 | 496 | ||
551 | default: | 497 | default: |
552 | /* Invalid Base */ | 498 | /* Invalid Base */ |
553 | return_ACPI_STATUS (AE_BAD_PARAMETER); | 499 | return_ACPI_STATUS(AE_BAD_PARAMETER); |
554 | } | 500 | } |
555 | 501 | ||
556 | /* Skip over any white space in the buffer */ | 502 | /* Skip over any white space in the buffer */ |
557 | 503 | ||
558 | while (ACPI_IS_SPACE (*string) || *string == '\t') { | 504 | while (ACPI_IS_SPACE(*string) || *string == '\t') { |
559 | string++; | 505 | string++; |
560 | } | 506 | } |
561 | 507 | ||
@@ -564,12 +510,10 @@ acpi_ut_strtoul64 ( | |||
564 | * determine if it is decimal or hexadecimal: | 510 | * determine if it is decimal or hexadecimal: |
565 | */ | 511 | */ |
566 | if (base == 0) { | 512 | if (base == 0) { |
567 | if ((*string == '0') && | 513 | if ((*string == '0') && (ACPI_TOLOWER(*(string + 1)) == 'x')) { |
568 | (ACPI_TOLOWER (*(string + 1)) == 'x')) { | ||
569 | base = 16; | 514 | base = 16; |
570 | string += 2; | 515 | string += 2; |
571 | } | 516 | } else { |
572 | else { | ||
573 | base = 10; | 517 | base = 10; |
574 | } | 518 | } |
575 | } | 519 | } |
@@ -579,8 +523,7 @@ acpi_ut_strtoul64 ( | |||
579 | * 0 or 0x, if they are present. | 523 | * 0 or 0x, if they are present. |
580 | */ | 524 | */ |
581 | if ((base == 16) && | 525 | if ((base == 16) && |
582 | (*string == '0') && | 526 | (*string == '0') && (ACPI_TOLOWER(*(string + 1)) == 'x')) { |
583 | (ACPI_TOLOWER (*(string + 1)) == 'x')) { | ||
584 | string += 2; | 527 | string += 2; |
585 | } | 528 | } |
586 | 529 | ||
@@ -593,25 +536,23 @@ acpi_ut_strtoul64 ( | |||
593 | /* Main loop: convert the string to a 64-bit integer */ | 536 | /* Main loop: convert the string to a 64-bit integer */ |
594 | 537 | ||
595 | while (*string) { | 538 | while (*string) { |
596 | if (ACPI_IS_DIGIT (*string)) { | 539 | if (ACPI_IS_DIGIT(*string)) { |
597 | /* Convert ASCII 0-9 to Decimal value */ | 540 | /* Convert ASCII 0-9 to Decimal value */ |
598 | 541 | ||
599 | this_digit = ((u8) *string) - '0'; | 542 | this_digit = ((u8) * string) - '0'; |
600 | } | 543 | } else { |
601 | else { | ||
602 | if (base == 10) { | 544 | if (base == 10) { |
603 | /* Digit is out of range */ | 545 | /* Digit is out of range */ |
604 | 546 | ||
605 | goto error_exit; | 547 | goto error_exit; |
606 | } | 548 | } |
607 | 549 | ||
608 | this_digit = (u8) ACPI_TOUPPER (*string); | 550 | this_digit = (u8) ACPI_TOUPPER(*string); |
609 | if (ACPI_IS_XDIGIT ((char) this_digit)) { | 551 | if (ACPI_IS_XDIGIT((char)this_digit)) { |
610 | /* Convert ASCII Hex char to value */ | 552 | /* Convert ASCII Hex char to value */ |
611 | 553 | ||
612 | this_digit = this_digit - 'A' + 10; | 554 | this_digit = this_digit - 'A' + 10; |
613 | } | 555 | } else { |
614 | else { | ||
615 | /* | 556 | /* |
616 | * We allow non-hex chars, just stop now, same as end-of-string. | 557 | * We allow non-hex chars, just stop now, same as end-of-string. |
617 | * See ACPI spec, string-to-integer conversion. | 558 | * See ACPI spec, string-to-integer conversion. |
@@ -622,8 +563,10 @@ acpi_ut_strtoul64 ( | |||
622 | 563 | ||
623 | /* Divide the digit into the correct position */ | 564 | /* Divide the digit into the correct position */ |
624 | 565 | ||
625 | (void) acpi_ut_short_divide ((ACPI_INTEGER_MAX - (acpi_integer) this_digit), | 566 | (void) |
626 | base, "ient, NULL); | 567 | acpi_ut_short_divide((ACPI_INTEGER_MAX - |
568 | (acpi_integer) this_digit), base, | ||
569 | "ient, NULL); | ||
627 | if (return_value > quotient) { | 570 | if (return_value > quotient) { |
628 | goto error_exit; | 571 | goto error_exit; |
629 | } | 572 | } |
@@ -636,21 +579,18 @@ acpi_ut_strtoul64 ( | |||
636 | /* All done, normal exit */ | 579 | /* All done, normal exit */ |
637 | 580 | ||
638 | *ret_integer = return_value; | 581 | *ret_integer = return_value; |
639 | return_ACPI_STATUS (AE_OK); | 582 | return_ACPI_STATUS(AE_OK); |
640 | 583 | ||
641 | 584 | error_exit: | |
642 | error_exit: | ||
643 | /* Base was set/validated above */ | 585 | /* Base was set/validated above */ |
644 | 586 | ||
645 | if (base == 10) { | 587 | if (base == 10) { |
646 | return_ACPI_STATUS (AE_BAD_DECIMAL_CONSTANT); | 588 | return_ACPI_STATUS(AE_BAD_DECIMAL_CONSTANT); |
647 | } | 589 | } else { |
648 | else { | 590 | return_ACPI_STATUS(AE_BAD_HEX_CONSTANT); |
649 | return_ACPI_STATUS (AE_BAD_HEX_CONSTANT); | ||
650 | } | 591 | } |
651 | } | 592 | } |
652 | 593 | ||
653 | |||
654 | /******************************************************************************* | 594 | /******************************************************************************* |
655 | * | 595 | * |
656 | * FUNCTION: acpi_ut_create_update_state_and_push | 596 | * FUNCTION: acpi_ut_create_update_state_and_push |
@@ -666,16 +606,13 @@ error_exit: | |||
666 | ******************************************************************************/ | 606 | ******************************************************************************/ |
667 | 607 | ||
668 | acpi_status | 608 | acpi_status |
669 | acpi_ut_create_update_state_and_push ( | 609 | acpi_ut_create_update_state_and_push(union acpi_operand_object *object, |
670 | union acpi_operand_object *object, | 610 | u16 action, |
671 | u16 action, | 611 | union acpi_generic_state **state_list) |
672 | union acpi_generic_state **state_list) | ||
673 | { | 612 | { |
674 | union acpi_generic_state *state; | 613 | union acpi_generic_state *state; |
675 | |||
676 | |||
677 | ACPI_FUNCTION_ENTRY (); | ||
678 | 614 | ||
615 | ACPI_FUNCTION_ENTRY(); | ||
679 | 616 | ||
680 | /* Ignore null objects; these are expected */ | 617 | /* Ignore null objects; these are expected */ |
681 | 618 | ||
@@ -683,16 +620,15 @@ acpi_ut_create_update_state_and_push ( | |||
683 | return (AE_OK); | 620 | return (AE_OK); |
684 | } | 621 | } |
685 | 622 | ||
686 | state = acpi_ut_create_update_state (object, action); | 623 | state = acpi_ut_create_update_state(object, action); |
687 | if (!state) { | 624 | if (!state) { |
688 | return (AE_NO_MEMORY); | 625 | return (AE_NO_MEMORY); |
689 | } | 626 | } |
690 | 627 | ||
691 | acpi_ut_push_generic_state (state_list, state); | 628 | acpi_ut_push_generic_state(state_list, state); |
692 | return (AE_OK); | 629 | return (AE_OK); |
693 | } | 630 | } |
694 | 631 | ||
695 | |||
696 | /******************************************************************************* | 632 | /******************************************************************************* |
697 | * | 633 | * |
698 | * FUNCTION: acpi_ut_walk_package_tree | 634 | * FUNCTION: acpi_ut_walk_package_tree |
@@ -709,33 +645,29 @@ acpi_ut_create_update_state_and_push ( | |||
709 | ******************************************************************************/ | 645 | ******************************************************************************/ |
710 | 646 | ||
711 | acpi_status | 647 | acpi_status |
712 | acpi_ut_walk_package_tree ( | 648 | acpi_ut_walk_package_tree(union acpi_operand_object * source_object, |
713 | union acpi_operand_object *source_object, | 649 | void *target_object, |
714 | void *target_object, | 650 | acpi_pkg_callback walk_callback, void *context) |
715 | acpi_pkg_callback walk_callback, | ||
716 | void *context) | ||
717 | { | 651 | { |
718 | acpi_status status = AE_OK; | 652 | acpi_status status = AE_OK; |
719 | union acpi_generic_state *state_list = NULL; | 653 | union acpi_generic_state *state_list = NULL; |
720 | union acpi_generic_state *state; | 654 | union acpi_generic_state *state; |
721 | u32 this_index; | 655 | u32 this_index; |
722 | union acpi_operand_object *this_source_obj; | 656 | union acpi_operand_object *this_source_obj; |
723 | |||
724 | 657 | ||
725 | ACPI_FUNCTION_TRACE ("ut_walk_package_tree"); | 658 | ACPI_FUNCTION_TRACE("ut_walk_package_tree"); |
726 | 659 | ||
727 | 660 | state = acpi_ut_create_pkg_state(source_object, target_object, 0); | |
728 | state = acpi_ut_create_pkg_state (source_object, target_object, 0); | ||
729 | if (!state) { | 661 | if (!state) { |
730 | return_ACPI_STATUS (AE_NO_MEMORY); | 662 | return_ACPI_STATUS(AE_NO_MEMORY); |
731 | } | 663 | } |
732 | 664 | ||
733 | while (state) { | 665 | while (state) { |
734 | /* Get one element of the package */ | 666 | /* Get one element of the package */ |
735 | 667 | ||
736 | this_index = state->pkg.index; | 668 | this_index = state->pkg.index; |
737 | this_source_obj = (union acpi_operand_object *) | 669 | this_source_obj = (union acpi_operand_object *) |
738 | state->pkg.source_object->package.elements[this_index]; | 670 | state->pkg.source_object->package.elements[this_index]; |
739 | 671 | ||
740 | /* | 672 | /* |
741 | * Check for: | 673 | * Check for: |
@@ -746,16 +678,20 @@ acpi_ut_walk_package_tree ( | |||
746 | * case below. | 678 | * case below. |
747 | */ | 679 | */ |
748 | if ((!this_source_obj) || | 680 | if ((!this_source_obj) || |
749 | (ACPI_GET_DESCRIPTOR_TYPE (this_source_obj) != ACPI_DESC_TYPE_OPERAND) || | 681 | (ACPI_GET_DESCRIPTOR_TYPE(this_source_obj) != |
750 | (ACPI_GET_OBJECT_TYPE (this_source_obj) != ACPI_TYPE_PACKAGE)) { | 682 | ACPI_DESC_TYPE_OPERAND) |
751 | status = walk_callback (ACPI_COPY_TYPE_SIMPLE, this_source_obj, | 683 | || (ACPI_GET_OBJECT_TYPE(this_source_obj) != |
752 | state, context); | 684 | ACPI_TYPE_PACKAGE)) { |
753 | if (ACPI_FAILURE (status)) { | 685 | status = |
754 | return_ACPI_STATUS (status); | 686 | walk_callback(ACPI_COPY_TYPE_SIMPLE, |
687 | this_source_obj, state, context); | ||
688 | if (ACPI_FAILURE(status)) { | ||
689 | return_ACPI_STATUS(status); | ||
755 | } | 690 | } |
756 | 691 | ||
757 | state->pkg.index++; | 692 | state->pkg.index++; |
758 | while (state->pkg.index >= state->pkg.source_object->package.count) { | 693 | while (state->pkg.index >= |
694 | state->pkg.source_object->package.count) { | ||
759 | /* | 695 | /* |
760 | * We've handled all of the objects at this level, This means | 696 | * We've handled all of the objects at this level, This means |
761 | * that we have just completed a package. That package may | 697 | * that we have just completed a package. That package may |
@@ -763,8 +699,8 @@ acpi_ut_walk_package_tree ( | |||
763 | * | 699 | * |
764 | * Delete this state and pop the previous state (package). | 700 | * Delete this state and pop the previous state (package). |
765 | */ | 701 | */ |
766 | acpi_ut_delete_generic_state (state); | 702 | acpi_ut_delete_generic_state(state); |
767 | state = acpi_ut_pop_generic_state (&state_list); | 703 | state = acpi_ut_pop_generic_state(&state_list); |
768 | 704 | ||
769 | /* Finished when there are no more states */ | 705 | /* Finished when there are no more states */ |
770 | 706 | ||
@@ -774,7 +710,7 @@ acpi_ut_walk_package_tree ( | |||
774 | * package just add the length of the package objects | 710 | * package just add the length of the package objects |
775 | * and exit | 711 | * and exit |
776 | */ | 712 | */ |
777 | return_ACPI_STATUS (AE_OK); | 713 | return_ACPI_STATUS(AE_OK); |
778 | } | 714 | } |
779 | 715 | ||
780 | /* | 716 | /* |
@@ -783,35 +719,35 @@ acpi_ut_walk_package_tree ( | |||
783 | */ | 719 | */ |
784 | state->pkg.index++; | 720 | state->pkg.index++; |
785 | } | 721 | } |
786 | } | 722 | } else { |
787 | else { | ||
788 | /* This is a subobject of type package */ | 723 | /* This is a subobject of type package */ |
789 | 724 | ||
790 | status = walk_callback (ACPI_COPY_TYPE_PACKAGE, this_source_obj, | 725 | status = |
791 | state, context); | 726 | walk_callback(ACPI_COPY_TYPE_PACKAGE, |
792 | if (ACPI_FAILURE (status)) { | 727 | this_source_obj, state, context); |
793 | return_ACPI_STATUS (status); | 728 | if (ACPI_FAILURE(status)) { |
729 | return_ACPI_STATUS(status); | ||
794 | } | 730 | } |
795 | 731 | ||
796 | /* | 732 | /* |
797 | * Push the current state and create a new one | 733 | * Push the current state and create a new one |
798 | * The callback above returned a new target package object. | 734 | * The callback above returned a new target package object. |
799 | */ | 735 | */ |
800 | acpi_ut_push_generic_state (&state_list, state); | 736 | acpi_ut_push_generic_state(&state_list, state); |
801 | state = acpi_ut_create_pkg_state (this_source_obj, | 737 | state = acpi_ut_create_pkg_state(this_source_obj, |
802 | state->pkg.this_target_obj, 0); | 738 | state->pkg. |
739 | this_target_obj, 0); | ||
803 | if (!state) { | 740 | if (!state) { |
804 | return_ACPI_STATUS (AE_NO_MEMORY); | 741 | return_ACPI_STATUS(AE_NO_MEMORY); |
805 | } | 742 | } |
806 | } | 743 | } |
807 | } | 744 | } |
808 | 745 | ||
809 | /* We should never get here */ | 746 | /* We should never get here */ |
810 | 747 | ||
811 | return_ACPI_STATUS (AE_AML_INTERNAL); | 748 | return_ACPI_STATUS(AE_AML_INTERNAL); |
812 | } | 749 | } |
813 | 750 | ||
814 | |||
815 | /******************************************************************************* | 751 | /******************************************************************************* |
816 | * | 752 | * |
817 | * FUNCTION: acpi_ut_generate_checksum | 753 | * FUNCTION: acpi_ut_generate_checksum |
@@ -825,23 +761,18 @@ acpi_ut_walk_package_tree ( | |||
825 | * | 761 | * |
826 | ******************************************************************************/ | 762 | ******************************************************************************/ |
827 | 763 | ||
828 | u8 | 764 | u8 acpi_ut_generate_checksum(u8 * buffer, u32 length) |
829 | acpi_ut_generate_checksum ( | ||
830 | u8 *buffer, | ||
831 | u32 length) | ||
832 | { | 765 | { |
833 | u32 i; | 766 | u32 i; |
834 | signed char sum = 0; | 767 | signed char sum = 0; |
835 | |||
836 | 768 | ||
837 | for (i = 0; i < length; i++) { | 769 | for (i = 0; i < length; i++) { |
838 | sum = (signed char) (sum + buffer[i]); | 770 | sum = (signed char)(sum + buffer[i]); |
839 | } | 771 | } |
840 | 772 | ||
841 | return ((u8) (0 - sum)); | 773 | return ((u8) (0 - sum)); |
842 | } | 774 | } |
843 | 775 | ||
844 | |||
845 | /******************************************************************************* | 776 | /******************************************************************************* |
846 | * | 777 | * |
847 | * FUNCTION: acpi_ut_get_resource_end_tag | 778 | * FUNCTION: acpi_ut_get_resource_end_tag |
@@ -854,17 +785,13 @@ acpi_ut_generate_checksum ( | |||
854 | * | 785 | * |
855 | ******************************************************************************/ | 786 | ******************************************************************************/ |
856 | 787 | ||
857 | 788 | u8 *acpi_ut_get_resource_end_tag(union acpi_operand_object * obj_desc) | |
858 | u8 * | ||
859 | acpi_ut_get_resource_end_tag ( | ||
860 | union acpi_operand_object *obj_desc) | ||
861 | { | 789 | { |
862 | u8 buffer_byte; | 790 | u8 buffer_byte; |
863 | u8 *buffer; | 791 | u8 *buffer; |
864 | u8 *end_buffer; | 792 | u8 *end_buffer; |
865 | 793 | ||
866 | 794 | buffer = obj_desc->buffer.pointer; | |
867 | buffer = obj_desc->buffer.pointer; | ||
868 | end_buffer = buffer + obj_desc->buffer.length; | 795 | end_buffer = buffer + obj_desc->buffer.length; |
869 | 796 | ||
870 | while (buffer < end_buffer) { | 797 | while (buffer < end_buffer) { |
@@ -872,12 +799,12 @@ acpi_ut_get_resource_end_tag ( | |||
872 | if (buffer_byte & ACPI_RDESC_TYPE_MASK) { | 799 | if (buffer_byte & ACPI_RDESC_TYPE_MASK) { |
873 | /* Large Descriptor - Length is next 2 bytes */ | 800 | /* Large Descriptor - Length is next 2 bytes */ |
874 | 801 | ||
875 | buffer += ((*(buffer+1) | (*(buffer+2) << 8)) + 3); | 802 | buffer += ((*(buffer + 1) | (*(buffer + 2) << 8)) + 3); |
876 | } | 803 | } else { |
877 | else { | ||
878 | /* Small Descriptor. End Tag will be found here */ | 804 | /* Small Descriptor. End Tag will be found here */ |
879 | 805 | ||
880 | if ((buffer_byte & ACPI_RDESC_SMALL_MASK) == ACPI_RDESC_TYPE_END_TAG) { | 806 | if ((buffer_byte & ACPI_RDESC_SMALL_MASK) == |
807 | ACPI_RDESC_TYPE_END_TAG) { | ||
881 | /* Found the end tag descriptor, all done. */ | 808 | /* Found the end tag descriptor, all done. */ |
882 | 809 | ||
883 | return (buffer); | 810 | return (buffer); |
@@ -894,7 +821,6 @@ acpi_ut_get_resource_end_tag ( | |||
894 | return (NULL); | 821 | return (NULL); |
895 | } | 822 | } |
896 | 823 | ||
897 | |||
898 | /******************************************************************************* | 824 | /******************************************************************************* |
899 | * | 825 | * |
900 | * FUNCTION: acpi_ut_report_error | 826 | * FUNCTION: acpi_ut_report_error |
@@ -909,17 +835,12 @@ acpi_ut_get_resource_end_tag ( | |||
909 | * | 835 | * |
910 | ******************************************************************************/ | 836 | ******************************************************************************/ |
911 | 837 | ||
912 | void | 838 | void acpi_ut_report_error(char *module_name, u32 line_number, u32 component_id) |
913 | acpi_ut_report_error ( | ||
914 | char *module_name, | ||
915 | u32 line_number, | ||
916 | u32 component_id) | ||
917 | { | 839 | { |
918 | 840 | ||
919 | acpi_os_printf ("%8s-%04d: *** Error: ", module_name, line_number); | 841 | acpi_os_printf("%8s-%04d: *** Error: ", module_name, line_number); |
920 | } | 842 | } |
921 | 843 | ||
922 | |||
923 | /******************************************************************************* | 844 | /******************************************************************************* |
924 | * | 845 | * |
925 | * FUNCTION: acpi_ut_report_warning | 846 | * FUNCTION: acpi_ut_report_warning |
@@ -935,16 +856,12 @@ acpi_ut_report_error ( | |||
935 | ******************************************************************************/ | 856 | ******************************************************************************/ |
936 | 857 | ||
937 | void | 858 | void |
938 | acpi_ut_report_warning ( | 859 | acpi_ut_report_warning(char *module_name, u32 line_number, u32 component_id) |
939 | char *module_name, | ||
940 | u32 line_number, | ||
941 | u32 component_id) | ||
942 | { | 860 | { |
943 | 861 | ||
944 | acpi_os_printf ("%8s-%04d: *** Warning: ", module_name, line_number); | 862 | acpi_os_printf("%8s-%04d: *** Warning: ", module_name, line_number); |
945 | } | 863 | } |
946 | 864 | ||
947 | |||
948 | /******************************************************************************* | 865 | /******************************************************************************* |
949 | * | 866 | * |
950 | * FUNCTION: acpi_ut_report_info | 867 | * FUNCTION: acpi_ut_report_info |
@@ -959,14 +876,8 @@ acpi_ut_report_warning ( | |||
959 | * | 876 | * |
960 | ******************************************************************************/ | 877 | ******************************************************************************/ |
961 | 878 | ||
962 | void | 879 | void acpi_ut_report_info(char *module_name, u32 line_number, u32 component_id) |
963 | acpi_ut_report_info ( | ||
964 | char *module_name, | ||
965 | u32 line_number, | ||
966 | u32 component_id) | ||
967 | { | 880 | { |
968 | 881 | ||
969 | acpi_os_printf ("%8s-%04d: *** Info: ", module_name, line_number); | 882 | acpi_os_printf("%8s-%04d: *** Info: ", module_name, line_number); |
970 | } | 883 | } |
971 | |||
972 | |||