diff options
author | Bob Moore <robert.moore@intel.com> | 2013-01-11 07:08:51 -0500 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2013-01-11 07:08:51 -0500 |
commit | 42f8fb75c43cc67f06424f991009b3af674f93eb (patch) | |
tree | 01821d5eca5f97d474bee62e7f92fe481adb31b8 /drivers/acpi/acpica/utmisc.c | |
parent | 4f8429166818dd615891990040ce13373893ee9a (diff) |
ACPICA: Source restructuring: split large files into 8 new files.
Created logical splits for eight new files. Improves modularity
and configurability.
Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'drivers/acpi/acpica/utmisc.c')
-rw-r--r-- | drivers/acpi/acpica/utmisc.c | 828 |
1 files changed, 68 insertions, 760 deletions
diff --git a/drivers/acpi/acpica/utmisc.c b/drivers/acpi/acpica/utmisc.c index 28819929863c..7ebf4e49266a 100644 --- a/drivers/acpi/acpica/utmisc.c +++ b/drivers/acpi/acpica/utmisc.c | |||
@@ -48,36 +48,6 @@ | |||
48 | #define _COMPONENT ACPI_UTILITIES | 48 | #define _COMPONENT ACPI_UTILITIES |
49 | ACPI_MODULE_NAME("utmisc") | 49 | ACPI_MODULE_NAME("utmisc") |
50 | 50 | ||
51 | #if defined ACPI_ASL_COMPILER || defined ACPI_EXEC_APP | ||
52 | /******************************************************************************* | ||
53 | * | ||
54 | * FUNCTION: ut_convert_backslashes | ||
55 | * | ||
56 | * PARAMETERS: pathname - File pathname string to be converted | ||
57 | * | ||
58 | * RETURN: Modifies the input Pathname | ||
59 | * | ||
60 | * DESCRIPTION: Convert all backslashes (0x5C) to forward slashes (0x2F) within | ||
61 | * the entire input file pathname string. | ||
62 | * | ||
63 | ******************************************************************************/ | ||
64 | void ut_convert_backslashes(char *pathname) | ||
65 | { | ||
66 | |||
67 | if (!pathname) { | ||
68 | return; | ||
69 | } | ||
70 | |||
71 | while (*pathname) { | ||
72 | if (*pathname == '\\') { | ||
73 | *pathname = '/'; | ||
74 | } | ||
75 | |||
76 | pathname++; | ||
77 | } | ||
78 | } | ||
79 | #endif | ||
80 | |||
81 | /******************************************************************************* | 51 | /******************************************************************************* |
82 | * | 52 | * |
83 | * FUNCTION: acpi_ut_is_pci_root_bridge | 53 | * FUNCTION: acpi_ut_is_pci_root_bridge |
@@ -89,7 +59,6 @@ void ut_convert_backslashes(char *pathname) | |||
89 | * DESCRIPTION: Determine if the input ID is a PCI Root Bridge ID. | 59 | * DESCRIPTION: Determine if the input ID is a PCI Root Bridge ID. |
90 | * | 60 | * |
91 | ******************************************************************************/ | 61 | ******************************************************************************/ |
92 | |||
93 | u8 acpi_ut_is_pci_root_bridge(char *id) | 62 | u8 acpi_ut_is_pci_root_bridge(char *id) |
94 | { | 63 | { |
95 | 64 | ||
@@ -136,362 +105,6 @@ u8 acpi_ut_is_aml_table(struct acpi_table_header *table) | |||
136 | 105 | ||
137 | /******************************************************************************* | 106 | /******************************************************************************* |
138 | * | 107 | * |
139 | * FUNCTION: acpi_ut_allocate_owner_id | ||
140 | * | ||
141 | * PARAMETERS: owner_id - Where the new owner ID is returned | ||
142 | * | ||
143 | * RETURN: Status | ||
144 | * | ||
145 | * DESCRIPTION: Allocate a table or method owner ID. The owner ID is used to | ||
146 | * track objects created by the table or method, to be deleted | ||
147 | * when the method exits or the table is unloaded. | ||
148 | * | ||
149 | ******************************************************************************/ | ||
150 | |||
151 | acpi_status acpi_ut_allocate_owner_id(acpi_owner_id * owner_id) | ||
152 | { | ||
153 | u32 i; | ||
154 | u32 j; | ||
155 | u32 k; | ||
156 | acpi_status status; | ||
157 | |||
158 | ACPI_FUNCTION_TRACE(ut_allocate_owner_id); | ||
159 | |||
160 | /* Guard against multiple allocations of ID to the same location */ | ||
161 | |||
162 | if (*owner_id) { | ||
163 | ACPI_ERROR((AE_INFO, "Owner ID [0x%2.2X] already exists", | ||
164 | *owner_id)); | ||
165 | return_ACPI_STATUS(AE_ALREADY_EXISTS); | ||
166 | } | ||
167 | |||
168 | /* Mutex for the global ID mask */ | ||
169 | |||
170 | status = acpi_ut_acquire_mutex(ACPI_MTX_CACHES); | ||
171 | if (ACPI_FAILURE(status)) { | ||
172 | return_ACPI_STATUS(status); | ||
173 | } | ||
174 | |||
175 | /* | ||
176 | * Find a free owner ID, cycle through all possible IDs on repeated | ||
177 | * allocations. (ACPI_NUM_OWNERID_MASKS + 1) because first index may have | ||
178 | * to be scanned twice. | ||
179 | */ | ||
180 | for (i = 0, j = acpi_gbl_last_owner_id_index; | ||
181 | i < (ACPI_NUM_OWNERID_MASKS + 1); i++, j++) { | ||
182 | if (j >= ACPI_NUM_OWNERID_MASKS) { | ||
183 | j = 0; /* Wraparound to start of mask array */ | ||
184 | } | ||
185 | |||
186 | for (k = acpi_gbl_next_owner_id_offset; k < 32; k++) { | ||
187 | if (acpi_gbl_owner_id_mask[j] == ACPI_UINT32_MAX) { | ||
188 | |||
189 | /* There are no free IDs in this mask */ | ||
190 | |||
191 | break; | ||
192 | } | ||
193 | |||
194 | if (!(acpi_gbl_owner_id_mask[j] & (1 << k))) { | ||
195 | /* | ||
196 | * Found a free ID. The actual ID is the bit index plus one, | ||
197 | * making zero an invalid Owner ID. Save this as the last ID | ||
198 | * allocated and update the global ID mask. | ||
199 | */ | ||
200 | acpi_gbl_owner_id_mask[j] |= (1 << k); | ||
201 | |||
202 | acpi_gbl_last_owner_id_index = (u8)j; | ||
203 | acpi_gbl_next_owner_id_offset = (u8)(k + 1); | ||
204 | |||
205 | /* | ||
206 | * Construct encoded ID from the index and bit position | ||
207 | * | ||
208 | * Note: Last [j].k (bit 255) is never used and is marked | ||
209 | * permanently allocated (prevents +1 overflow) | ||
210 | */ | ||
211 | *owner_id = | ||
212 | (acpi_owner_id) ((k + 1) + ACPI_MUL_32(j)); | ||
213 | |||
214 | ACPI_DEBUG_PRINT((ACPI_DB_VALUES, | ||
215 | "Allocated OwnerId: %2.2X\n", | ||
216 | (unsigned int)*owner_id)); | ||
217 | goto exit; | ||
218 | } | ||
219 | } | ||
220 | |||
221 | acpi_gbl_next_owner_id_offset = 0; | ||
222 | } | ||
223 | |||
224 | /* | ||
225 | * All owner_ids have been allocated. This typically should | ||
226 | * not happen since the IDs are reused after deallocation. The IDs are | ||
227 | * allocated upon table load (one per table) and method execution, and | ||
228 | * they are released when a table is unloaded or a method completes | ||
229 | * execution. | ||
230 | * | ||
231 | * If this error happens, there may be very deep nesting of invoked control | ||
232 | * methods, or there may be a bug where the IDs are not released. | ||
233 | */ | ||
234 | status = AE_OWNER_ID_LIMIT; | ||
235 | ACPI_ERROR((AE_INFO, | ||
236 | "Could not allocate new OwnerId (255 max), AE_OWNER_ID_LIMIT")); | ||
237 | |||
238 | exit: | ||
239 | (void)acpi_ut_release_mutex(ACPI_MTX_CACHES); | ||
240 | return_ACPI_STATUS(status); | ||
241 | } | ||
242 | |||
243 | /******************************************************************************* | ||
244 | * | ||
245 | * FUNCTION: acpi_ut_release_owner_id | ||
246 | * | ||
247 | * PARAMETERS: owner_id_ptr - Pointer to a previously allocated owner_ID | ||
248 | * | ||
249 | * RETURN: None. No error is returned because we are either exiting a | ||
250 | * control method or unloading a table. Either way, we would | ||
251 | * ignore any error anyway. | ||
252 | * | ||
253 | * DESCRIPTION: Release a table or method owner ID. Valid IDs are 1 - 255 | ||
254 | * | ||
255 | ******************************************************************************/ | ||
256 | |||
257 | void acpi_ut_release_owner_id(acpi_owner_id * owner_id_ptr) | ||
258 | { | ||
259 | acpi_owner_id owner_id = *owner_id_ptr; | ||
260 | acpi_status status; | ||
261 | u32 index; | ||
262 | u32 bit; | ||
263 | |||
264 | ACPI_FUNCTION_TRACE_U32(ut_release_owner_id, owner_id); | ||
265 | |||
266 | /* Always clear the input owner_id (zero is an invalid ID) */ | ||
267 | |||
268 | *owner_id_ptr = 0; | ||
269 | |||
270 | /* Zero is not a valid owner_ID */ | ||
271 | |||
272 | if (owner_id == 0) { | ||
273 | ACPI_ERROR((AE_INFO, "Invalid OwnerId: 0x%2.2X", owner_id)); | ||
274 | return_VOID; | ||
275 | } | ||
276 | |||
277 | /* Mutex for the global ID mask */ | ||
278 | |||
279 | status = acpi_ut_acquire_mutex(ACPI_MTX_CACHES); | ||
280 | if (ACPI_FAILURE(status)) { | ||
281 | return_VOID; | ||
282 | } | ||
283 | |||
284 | /* Normalize the ID to zero */ | ||
285 | |||
286 | owner_id--; | ||
287 | |||
288 | /* Decode ID to index/offset pair */ | ||
289 | |||
290 | index = ACPI_DIV_32(owner_id); | ||
291 | bit = 1 << ACPI_MOD_32(owner_id); | ||
292 | |||
293 | /* Free the owner ID only if it is valid */ | ||
294 | |||
295 | if (acpi_gbl_owner_id_mask[index] & bit) { | ||
296 | acpi_gbl_owner_id_mask[index] ^= bit; | ||
297 | } else { | ||
298 | ACPI_ERROR((AE_INFO, | ||
299 | "Release of non-allocated OwnerId: 0x%2.2X", | ||
300 | owner_id + 1)); | ||
301 | } | ||
302 | |||
303 | (void)acpi_ut_release_mutex(ACPI_MTX_CACHES); | ||
304 | return_VOID; | ||
305 | } | ||
306 | |||
307 | /******************************************************************************* | ||
308 | * | ||
309 | * FUNCTION: acpi_ut_strupr (strupr) | ||
310 | * | ||
311 | * PARAMETERS: src_string - The source string to convert | ||
312 | * | ||
313 | * RETURN: None | ||
314 | * | ||
315 | * DESCRIPTION: Convert string to uppercase | ||
316 | * | ||
317 | * NOTE: This is not a POSIX function, so it appears here, not in utclib.c | ||
318 | * | ||
319 | ******************************************************************************/ | ||
320 | |||
321 | void acpi_ut_strupr(char *src_string) | ||
322 | { | ||
323 | char *string; | ||
324 | |||
325 | ACPI_FUNCTION_ENTRY(); | ||
326 | |||
327 | if (!src_string) { | ||
328 | return; | ||
329 | } | ||
330 | |||
331 | /* Walk entire string, uppercasing the letters */ | ||
332 | |||
333 | for (string = src_string; *string; string++) { | ||
334 | *string = (char)ACPI_TOUPPER(*string); | ||
335 | } | ||
336 | |||
337 | return; | ||
338 | } | ||
339 | |||
340 | #ifdef ACPI_ASL_COMPILER | ||
341 | /******************************************************************************* | ||
342 | * | ||
343 | * FUNCTION: acpi_ut_strlwr (strlwr) | ||
344 | * | ||
345 | * PARAMETERS: src_string - The source string to convert | ||
346 | * | ||
347 | * RETURN: None | ||
348 | * | ||
349 | * DESCRIPTION: Convert string to lowercase | ||
350 | * | ||
351 | * NOTE: This is not a POSIX function, so it appears here, not in utclib.c | ||
352 | * | ||
353 | ******************************************************************************/ | ||
354 | |||
355 | void acpi_ut_strlwr(char *src_string) | ||
356 | { | ||
357 | char *string; | ||
358 | |||
359 | ACPI_FUNCTION_ENTRY(); | ||
360 | |||
361 | if (!src_string) { | ||
362 | return; | ||
363 | } | ||
364 | |||
365 | /* Walk entire string, lowercasing the letters */ | ||
366 | |||
367 | for (string = src_string; *string; string++) { | ||
368 | *string = (char)ACPI_TOLOWER(*string); | ||
369 | } | ||
370 | |||
371 | return; | ||
372 | } | ||
373 | |||
374 | /****************************************************************************** | ||
375 | * | ||
376 | * FUNCTION: acpi_ut_stricmp | ||
377 | * | ||
378 | * PARAMETERS: string1 - first string to compare | ||
379 | * string2 - second string to compare | ||
380 | * | ||
381 | * RETURN: int that signifies string relationship. Zero means strings | ||
382 | * are equal. | ||
383 | * | ||
384 | * DESCRIPTION: Implementation of the non-ANSI stricmp function (compare | ||
385 | * strings with no case sensitivity) | ||
386 | * | ||
387 | ******************************************************************************/ | ||
388 | |||
389 | int acpi_ut_stricmp(char *string1, char *string2) | ||
390 | { | ||
391 | int c1; | ||
392 | int c2; | ||
393 | |||
394 | do { | ||
395 | c1 = tolower((int)*string1); | ||
396 | c2 = tolower((int)*string2); | ||
397 | |||
398 | string1++; | ||
399 | string2++; | ||
400 | } | ||
401 | while ((c1 == c2) && (c1)); | ||
402 | |||
403 | return (c1 - c2); | ||
404 | } | ||
405 | #endif | ||
406 | |||
407 | /******************************************************************************* | ||
408 | * | ||
409 | * FUNCTION: acpi_ut_print_string | ||
410 | * | ||
411 | * PARAMETERS: string - Null terminated ASCII string | ||
412 | * max_length - Maximum output length | ||
413 | * | ||
414 | * RETURN: None | ||
415 | * | ||
416 | * DESCRIPTION: Dump an ASCII string with support for ACPI-defined escape | ||
417 | * sequences. | ||
418 | * | ||
419 | ******************************************************************************/ | ||
420 | |||
421 | void acpi_ut_print_string(char *string, u8 max_length) | ||
422 | { | ||
423 | u32 i; | ||
424 | |||
425 | if (!string) { | ||
426 | acpi_os_printf("<\"NULL STRING PTR\">"); | ||
427 | return; | ||
428 | } | ||
429 | |||
430 | acpi_os_printf("\""); | ||
431 | for (i = 0; string[i] && (i < max_length); i++) { | ||
432 | |||
433 | /* Escape sequences */ | ||
434 | |||
435 | switch (string[i]) { | ||
436 | case 0x07: | ||
437 | acpi_os_printf("\\a"); /* BELL */ | ||
438 | break; | ||
439 | |||
440 | case 0x08: | ||
441 | acpi_os_printf("\\b"); /* BACKSPACE */ | ||
442 | break; | ||
443 | |||
444 | case 0x0C: | ||
445 | acpi_os_printf("\\f"); /* FORMFEED */ | ||
446 | break; | ||
447 | |||
448 | case 0x0A: | ||
449 | acpi_os_printf("\\n"); /* LINEFEED */ | ||
450 | break; | ||
451 | |||
452 | case 0x0D: | ||
453 | acpi_os_printf("\\r"); /* CARRIAGE RETURN */ | ||
454 | break; | ||
455 | |||
456 | case 0x09: | ||
457 | acpi_os_printf("\\t"); /* HORIZONTAL TAB */ | ||
458 | break; | ||
459 | |||
460 | case 0x0B: | ||
461 | acpi_os_printf("\\v"); /* VERTICAL TAB */ | ||
462 | break; | ||
463 | |||
464 | case '\'': /* Single Quote */ | ||
465 | case '\"': /* Double Quote */ | ||
466 | case '\\': /* Backslash */ | ||
467 | acpi_os_printf("\\%c", (int)string[i]); | ||
468 | break; | ||
469 | |||
470 | default: | ||
471 | |||
472 | /* Check for printable character or hex escape */ | ||
473 | |||
474 | if (ACPI_IS_PRINT(string[i])) { | ||
475 | /* This is a normal character */ | ||
476 | |||
477 | acpi_os_printf("%c", (int)string[i]); | ||
478 | } else { | ||
479 | /* All others will be Hex escapes */ | ||
480 | |||
481 | acpi_os_printf("\\x%2.2X", (s32) string[i]); | ||
482 | } | ||
483 | break; | ||
484 | } | ||
485 | } | ||
486 | acpi_os_printf("\""); | ||
487 | |||
488 | if (i == max_length && string[i]) { | ||
489 | acpi_os_printf("..."); | ||
490 | } | ||
491 | } | ||
492 | |||
493 | /******************************************************************************* | ||
494 | * | ||
495 | * FUNCTION: acpi_ut_dword_byte_swap | 108 | * FUNCTION: acpi_ut_dword_byte_swap |
496 | * | 109 | * |
497 | * PARAMETERS: value - Value to be converted | 110 | * PARAMETERS: value - Value to be converted |
@@ -559,379 +172,6 @@ void acpi_ut_set_integer_width(u8 revision) | |||
559 | } | 172 | } |
560 | } | 173 | } |
561 | 174 | ||
562 | #ifdef ACPI_DEBUG_OUTPUT | ||
563 | /******************************************************************************* | ||
564 | * | ||
565 | * FUNCTION: acpi_ut_display_init_pathname | ||
566 | * | ||
567 | * PARAMETERS: type - Object type of the node | ||
568 | * obj_handle - Handle whose pathname will be displayed | ||
569 | * path - Additional path string to be appended. | ||
570 | * (NULL if no extra path) | ||
571 | * | ||
572 | * RETURN: acpi_status | ||
573 | * | ||
574 | * DESCRIPTION: Display full pathname of an object, DEBUG ONLY | ||
575 | * | ||
576 | ******************************************************************************/ | ||
577 | |||
578 | void | ||
579 | acpi_ut_display_init_pathname(u8 type, | ||
580 | struct acpi_namespace_node *obj_handle, | ||
581 | char *path) | ||
582 | { | ||
583 | acpi_status status; | ||
584 | struct acpi_buffer buffer; | ||
585 | |||
586 | ACPI_FUNCTION_ENTRY(); | ||
587 | |||
588 | /* Only print the path if the appropriate debug level is enabled */ | ||
589 | |||
590 | if (!(acpi_dbg_level & ACPI_LV_INIT_NAMES)) { | ||
591 | return; | ||
592 | } | ||
593 | |||
594 | /* Get the full pathname to the node */ | ||
595 | |||
596 | buffer.length = ACPI_ALLOCATE_LOCAL_BUFFER; | ||
597 | status = acpi_ns_handle_to_pathname(obj_handle, &buffer); | ||
598 | if (ACPI_FAILURE(status)) { | ||
599 | return; | ||
600 | } | ||
601 | |||
602 | /* Print what we're doing */ | ||
603 | |||
604 | switch (type) { | ||
605 | case ACPI_TYPE_METHOD: | ||
606 | acpi_os_printf("Executing "); | ||
607 | break; | ||
608 | |||
609 | default: | ||
610 | acpi_os_printf("Initializing "); | ||
611 | break; | ||
612 | } | ||
613 | |||
614 | /* Print the object type and pathname */ | ||
615 | |||
616 | acpi_os_printf("%-12s %s", | ||
617 | acpi_ut_get_type_name(type), (char *)buffer.pointer); | ||
618 | |||
619 | /* Extra path is used to append names like _STA, _INI, etc. */ | ||
620 | |||
621 | if (path) { | ||
622 | acpi_os_printf(".%s", path); | ||
623 | } | ||
624 | acpi_os_printf("\n"); | ||
625 | |||
626 | ACPI_FREE(buffer.pointer); | ||
627 | } | ||
628 | #endif | ||
629 | |||
630 | /******************************************************************************* | ||
631 | * | ||
632 | * FUNCTION: acpi_ut_valid_acpi_char | ||
633 | * | ||
634 | * PARAMETERS: char - The character to be examined | ||
635 | * position - Byte position (0-3) | ||
636 | * | ||
637 | * RETURN: TRUE if the character is valid, FALSE otherwise | ||
638 | * | ||
639 | * DESCRIPTION: Check for a valid ACPI character. Must be one of: | ||
640 | * 1) Upper case alpha | ||
641 | * 2) numeric | ||
642 | * 3) underscore | ||
643 | * | ||
644 | * We allow a '!' as the last character because of the ASF! table | ||
645 | * | ||
646 | ******************************************************************************/ | ||
647 | |||
648 | u8 acpi_ut_valid_acpi_char(char character, u32 position) | ||
649 | { | ||
650 | |||
651 | if (!((character >= 'A' && character <= 'Z') || | ||
652 | (character >= '0' && character <= '9') || (character == '_'))) { | ||
653 | |||
654 | /* Allow a '!' in the last position */ | ||
655 | |||
656 | if (character == '!' && position == 3) { | ||
657 | return (TRUE); | ||
658 | } | ||
659 | |||
660 | return (FALSE); | ||
661 | } | ||
662 | |||
663 | return (TRUE); | ||
664 | } | ||
665 | |||
666 | /******************************************************************************* | ||
667 | * | ||
668 | * FUNCTION: acpi_ut_valid_acpi_name | ||
669 | * | ||
670 | * PARAMETERS: name - The name to be examined | ||
671 | * | ||
672 | * RETURN: TRUE if the name is valid, FALSE otherwise | ||
673 | * | ||
674 | * DESCRIPTION: Check for a valid ACPI name. Each character must be one of: | ||
675 | * 1) Upper case alpha | ||
676 | * 2) numeric | ||
677 | * 3) underscore | ||
678 | * | ||
679 | ******************************************************************************/ | ||
680 | |||
681 | u8 acpi_ut_valid_acpi_name(u32 name) | ||
682 | { | ||
683 | u32 i; | ||
684 | |||
685 | ACPI_FUNCTION_ENTRY(); | ||
686 | |||
687 | for (i = 0; i < ACPI_NAME_SIZE; i++) { | ||
688 | if (!acpi_ut_valid_acpi_char | ||
689 | ((ACPI_CAST_PTR(char, &name))[i], i)) { | ||
690 | return (FALSE); | ||
691 | } | ||
692 | } | ||
693 | |||
694 | return (TRUE); | ||
695 | } | ||
696 | |||
697 | /******************************************************************************* | ||
698 | * | ||
699 | * FUNCTION: acpi_ut_repair_name | ||
700 | * | ||
701 | * PARAMETERS: name - The ACPI name to be repaired | ||
702 | * | ||
703 | * RETURN: Repaired version of the name | ||
704 | * | ||
705 | * DESCRIPTION: Repair an ACPI name: Change invalid characters to '*' and | ||
706 | * return the new name. NOTE: the Name parameter must reside in | ||
707 | * read/write memory, cannot be a const. | ||
708 | * | ||
709 | * An ACPI Name must consist of valid ACPI characters. We will repair the name | ||
710 | * if necessary because we don't want to abort because of this, but we want | ||
711 | * all namespace names to be printable. A warning message is appropriate. | ||
712 | * | ||
713 | * This issue came up because there are in fact machines that exhibit | ||
714 | * this problem, and we want to be able to enable ACPI support for them, | ||
715 | * even though there are a few bad names. | ||
716 | * | ||
717 | ******************************************************************************/ | ||
718 | |||
719 | void acpi_ut_repair_name(char *name) | ||
720 | { | ||
721 | u32 i; | ||
722 | u8 found_bad_char = FALSE; | ||
723 | u32 original_name; | ||
724 | |||
725 | ACPI_FUNCTION_NAME(ut_repair_name); | ||
726 | |||
727 | ACPI_MOVE_NAME(&original_name, name); | ||
728 | |||
729 | /* Check each character in the name */ | ||
730 | |||
731 | for (i = 0; i < ACPI_NAME_SIZE; i++) { | ||
732 | if (acpi_ut_valid_acpi_char(name[i], i)) { | ||
733 | continue; | ||
734 | } | ||
735 | |||
736 | /* | ||
737 | * Replace a bad character with something printable, yet technically | ||
738 | * still invalid. This prevents any collisions with existing "good" | ||
739 | * names in the namespace. | ||
740 | */ | ||
741 | name[i] = '*'; | ||
742 | found_bad_char = TRUE; | ||
743 | } | ||
744 | |||
745 | if (found_bad_char) { | ||
746 | |||
747 | /* Report warning only if in strict mode or debug mode */ | ||
748 | |||
749 | if (!acpi_gbl_enable_interpreter_slack) { | ||
750 | ACPI_WARNING((AE_INFO, | ||
751 | "Invalid character(s) in name (0x%.8X), repaired: [%4.4s]", | ||
752 | original_name, name)); | ||
753 | } else { | ||
754 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, | ||
755 | "Invalid character(s) in name (0x%.8X), repaired: [%4.4s]", | ||
756 | original_name, name)); | ||
757 | } | ||
758 | } | ||
759 | } | ||
760 | |||
761 | /******************************************************************************* | ||
762 | * | ||
763 | * FUNCTION: acpi_ut_strtoul64 | ||
764 | * | ||
765 | * PARAMETERS: string - Null terminated string | ||
766 | * base - Radix of the string: 16 or ACPI_ANY_BASE; | ||
767 | * ACPI_ANY_BASE means 'in behalf of to_integer' | ||
768 | * ret_integer - Where the converted integer is returned | ||
769 | * | ||
770 | * RETURN: Status and Converted value | ||
771 | * | ||
772 | * DESCRIPTION: Convert a string into an unsigned value. Performs either a | ||
773 | * 32-bit or 64-bit conversion, depending on the current mode | ||
774 | * of the interpreter. | ||
775 | * NOTE: Does not support Octal strings, not needed. | ||
776 | * | ||
777 | ******************************************************************************/ | ||
778 | |||
779 | acpi_status acpi_ut_strtoul64(char *string, u32 base, u64 *ret_integer) | ||
780 | { | ||
781 | u32 this_digit = 0; | ||
782 | u64 return_value = 0; | ||
783 | u64 quotient; | ||
784 | u64 dividend; | ||
785 | u32 to_integer_op = (base == ACPI_ANY_BASE); | ||
786 | u32 mode32 = (acpi_gbl_integer_byte_width == 4); | ||
787 | u8 valid_digits = 0; | ||
788 | u8 sign_of0x = 0; | ||
789 | u8 term = 0; | ||
790 | |||
791 | ACPI_FUNCTION_TRACE_STR(ut_stroul64, string); | ||
792 | |||
793 | switch (base) { | ||
794 | case ACPI_ANY_BASE: | ||
795 | case 16: | ||
796 | break; | ||
797 | |||
798 | default: | ||
799 | /* Invalid Base */ | ||
800 | return_ACPI_STATUS(AE_BAD_PARAMETER); | ||
801 | } | ||
802 | |||
803 | if (!string) { | ||
804 | goto error_exit; | ||
805 | } | ||
806 | |||
807 | /* Skip over any white space in the buffer */ | ||
808 | |||
809 | while ((*string) && (ACPI_IS_SPACE(*string) || *string == '\t')) { | ||
810 | string++; | ||
811 | } | ||
812 | |||
813 | if (to_integer_op) { | ||
814 | /* | ||
815 | * Base equal to ACPI_ANY_BASE means 'ToInteger operation case'. | ||
816 | * We need to determine if it is decimal or hexadecimal. | ||
817 | */ | ||
818 | if ((*string == '0') && (ACPI_TOLOWER(*(string + 1)) == 'x')) { | ||
819 | sign_of0x = 1; | ||
820 | base = 16; | ||
821 | |||
822 | /* Skip over the leading '0x' */ | ||
823 | string += 2; | ||
824 | } else { | ||
825 | base = 10; | ||
826 | } | ||
827 | } | ||
828 | |||
829 | /* Any string left? Check that '0x' is not followed by white space. */ | ||
830 | |||
831 | if (!(*string) || ACPI_IS_SPACE(*string) || *string == '\t') { | ||
832 | if (to_integer_op) { | ||
833 | goto error_exit; | ||
834 | } else { | ||
835 | goto all_done; | ||
836 | } | ||
837 | } | ||
838 | |||
839 | /* | ||
840 | * Perform a 32-bit or 64-bit conversion, depending upon the current | ||
841 | * execution mode of the interpreter | ||
842 | */ | ||
843 | dividend = (mode32) ? ACPI_UINT32_MAX : ACPI_UINT64_MAX; | ||
844 | |||
845 | /* Main loop: convert the string to a 32- or 64-bit integer */ | ||
846 | |||
847 | while (*string) { | ||
848 | if (ACPI_IS_DIGIT(*string)) { | ||
849 | |||
850 | /* Convert ASCII 0-9 to Decimal value */ | ||
851 | |||
852 | this_digit = ((u8)*string) - '0'; | ||
853 | } else if (base == 10) { | ||
854 | |||
855 | /* Digit is out of range; possible in to_integer case only */ | ||
856 | |||
857 | term = 1; | ||
858 | } else { | ||
859 | this_digit = (u8)ACPI_TOUPPER(*string); | ||
860 | if (ACPI_IS_XDIGIT((char)this_digit)) { | ||
861 | |||
862 | /* Convert ASCII Hex char to value */ | ||
863 | |||
864 | this_digit = this_digit - 'A' + 10; | ||
865 | } else { | ||
866 | term = 1; | ||
867 | } | ||
868 | } | ||
869 | |||
870 | if (term) { | ||
871 | if (to_integer_op) { | ||
872 | goto error_exit; | ||
873 | } else { | ||
874 | break; | ||
875 | } | ||
876 | } else if ((valid_digits == 0) && (this_digit == 0) | ||
877 | && !sign_of0x) { | ||
878 | |||
879 | /* Skip zeros */ | ||
880 | string++; | ||
881 | continue; | ||
882 | } | ||
883 | |||
884 | valid_digits++; | ||
885 | |||
886 | if (sign_of0x | ||
887 | && ((valid_digits > 16) | ||
888 | || ((valid_digits > 8) && mode32))) { | ||
889 | /* | ||
890 | * This is to_integer operation case. | ||
891 | * No any restrictions for string-to-integer conversion, | ||
892 | * see ACPI spec. | ||
893 | */ | ||
894 | goto error_exit; | ||
895 | } | ||
896 | |||
897 | /* Divide the digit into the correct position */ | ||
898 | |||
899 | (void)acpi_ut_short_divide((dividend - (u64)this_digit), | ||
900 | base, "ient, NULL); | ||
901 | |||
902 | if (return_value > quotient) { | ||
903 | if (to_integer_op) { | ||
904 | goto error_exit; | ||
905 | } else { | ||
906 | break; | ||
907 | } | ||
908 | } | ||
909 | |||
910 | return_value *= base; | ||
911 | return_value += this_digit; | ||
912 | string++; | ||
913 | } | ||
914 | |||
915 | /* All done, normal exit */ | ||
916 | |||
917 | all_done: | ||
918 | |||
919 | ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Converted value: %8.8X%8.8X\n", | ||
920 | ACPI_FORMAT_UINT64(return_value))); | ||
921 | |||
922 | *ret_integer = return_value; | ||
923 | return_ACPI_STATUS(AE_OK); | ||
924 | |||
925 | error_exit: | ||
926 | /* Base was set/validated above */ | ||
927 | |||
928 | if (base == 10) { | ||
929 | return_ACPI_STATUS(AE_BAD_DECIMAL_CONSTANT); | ||
930 | } else { | ||
931 | return_ACPI_STATUS(AE_BAD_HEX_CONSTANT); | ||
932 | } | ||
933 | } | ||
934 | |||
935 | /******************************************************************************* | 175 | /******************************************************************************* |
936 | * | 176 | * |
937 | * FUNCTION: acpi_ut_create_update_state_and_push | 177 | * FUNCTION: acpi_ut_create_update_state_and_push |
@@ -1097,3 +337,71 @@ acpi_ut_walk_package_tree(union acpi_operand_object *source_object, | |||
1097 | 337 | ||
1098 | return_ACPI_STATUS(AE_AML_INTERNAL); | 338 | return_ACPI_STATUS(AE_AML_INTERNAL); |
1099 | } | 339 | } |
340 | |||
341 | #ifdef ACPI_DEBUG_OUTPUT | ||
342 | /******************************************************************************* | ||
343 | * | ||
344 | * FUNCTION: acpi_ut_display_init_pathname | ||
345 | * | ||
346 | * PARAMETERS: type - Object type of the node | ||
347 | * obj_handle - Handle whose pathname will be displayed | ||
348 | * path - Additional path string to be appended. | ||
349 | * (NULL if no extra path) | ||
350 | * | ||
351 | * RETURN: acpi_status | ||
352 | * | ||
353 | * DESCRIPTION: Display full pathname of an object, DEBUG ONLY | ||
354 | * | ||
355 | ******************************************************************************/ | ||
356 | |||
357 | void | ||
358 | acpi_ut_display_init_pathname(u8 type, | ||
359 | struct acpi_namespace_node *obj_handle, | ||
360 | char *path) | ||
361 | { | ||
362 | acpi_status status; | ||
363 | struct acpi_buffer buffer; | ||
364 | |||
365 | ACPI_FUNCTION_ENTRY(); | ||
366 | |||
367 | /* Only print the path if the appropriate debug level is enabled */ | ||
368 | |||
369 | if (!(acpi_dbg_level & ACPI_LV_INIT_NAMES)) { | ||
370 | return; | ||
371 | } | ||
372 | |||
373 | /* Get the full pathname to the node */ | ||
374 | |||
375 | buffer.length = ACPI_ALLOCATE_LOCAL_BUFFER; | ||
376 | status = acpi_ns_handle_to_pathname(obj_handle, &buffer); | ||
377 | if (ACPI_FAILURE(status)) { | ||
378 | return; | ||
379 | } | ||
380 | |||
381 | /* Print what we're doing */ | ||
382 | |||
383 | switch (type) { | ||
384 | case ACPI_TYPE_METHOD: | ||
385 | acpi_os_printf("Executing "); | ||
386 | break; | ||
387 | |||
388 | default: | ||
389 | acpi_os_printf("Initializing "); | ||
390 | break; | ||
391 | } | ||
392 | |||
393 | /* Print the object type and pathname */ | ||
394 | |||
395 | acpi_os_printf("%-12s %s", | ||
396 | acpi_ut_get_type_name(type), (char *)buffer.pointer); | ||
397 | |||
398 | /* Extra path is used to append names like _STA, _INI, etc. */ | ||
399 | |||
400 | if (path) { | ||
401 | acpi_os_printf(".%s", path); | ||
402 | } | ||
403 | acpi_os_printf("\n"); | ||
404 | |||
405 | ACPI_FREE(buffer.pointer); | ||
406 | } | ||
407 | #endif | ||