aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/utilities/utmisc.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/acpi/utilities/utmisc.c')
-rw-r--r--drivers/acpi/utilities/utmisc.c187
1 files changed, 101 insertions, 86 deletions
diff --git a/drivers/acpi/utilities/utmisc.c b/drivers/acpi/utilities/utmisc.c
index f6598547389b..f6de4ed3d527 100644
--- a/drivers/acpi/utilities/utmisc.c
+++ b/drivers/acpi/utilities/utmisc.c
@@ -49,12 +49,57 @@
49#define _COMPONENT ACPI_UTILITIES 49#define _COMPONENT ACPI_UTILITIES
50 ACPI_MODULE_NAME ("utmisc") 50 ACPI_MODULE_NAME ("utmisc")
51 51
52/* Local prototypes */
53
54static acpi_status
55acpi_ut_create_mutex (
56 acpi_mutex_handle mutex_id);
57
58static acpi_status
59acpi_ut_delete_mutex (
60 acpi_mutex_handle mutex_id);
61
62
63/*******************************************************************************
64 *
65 * FUNCTION: acpi_ut_strupr (strupr)
66 *
67 * PARAMETERS: src_string - The source string to convert
68 *
69 * RETURN: Converted src_string (same as input pointer)
70 *
71 * DESCRIPTION: Convert string to uppercase
72 *
73 * NOTE: This is not a POSIX function, so it appears here, not in utclib.c
74 *
75 ******************************************************************************/
76
77char *
78acpi_ut_strupr (
79 char *src_string)
80{
81 char *string;
82
83
84 ACPI_FUNCTION_ENTRY ();
85
86
87 /* Walk entire string, uppercasing the letters */
88
89 for (string = src_string; *string; string++) {
90 *string = (char) ACPI_TOUPPER (*string);
91 }
92
93 return (src_string);
94}
95
52 96
53/******************************************************************************* 97/*******************************************************************************
54 * 98 *
55 * FUNCTION: acpi_ut_print_string 99 * FUNCTION: acpi_ut_print_string
56 * 100 *
57 * PARAMETERS: String - Null terminated ASCII string 101 * PARAMETERS: String - Null terminated ASCII string
102 * max_length - Maximum output length
58 * 103 *
59 * RETURN: None 104 * RETURN: None
60 * 105 *
@@ -148,6 +193,8 @@ acpi_ut_print_string (
148 * 193 *
149 * PARAMETERS: Value - Value to be converted 194 * PARAMETERS: Value - Value to be converted
150 * 195 *
196 * RETURN: u32 integer with bytes swapped
197 *
151 * DESCRIPTION: Convert a 32-bit value to big-endian (swap the bytes) 198 * DESCRIPTION: Convert a 32-bit value to big-endian (swap the bytes)
152 * 199 *
153 ******************************************************************************/ 200 ******************************************************************************/
@@ -160,7 +207,6 @@ acpi_ut_dword_byte_swap (
160 u32 value; 207 u32 value;
161 u8 bytes[4]; 208 u8 bytes[4];
162 } out; 209 } out;
163
164 union { 210 union {
165 u32 value; 211 u32 value;
166 u8 bytes[4]; 212 u8 bytes[4];
@@ -219,7 +265,8 @@ acpi_ut_set_integer_width (
219 * 265 *
220 * FUNCTION: acpi_ut_display_init_pathname 266 * FUNCTION: acpi_ut_display_init_pathname
221 * 267 *
222 * PARAMETERS: obj_handle - Handle whose pathname will be displayed 268 * PARAMETERS: Type - Object type of the node
269 * obj_handle - Handle whose pathname will be displayed
223 * Path - Additional path string to be appended. 270 * Path - Additional path string to be appended.
224 * (NULL if no extra path) 271 * (NULL if no extra path)
225 * 272 *
@@ -270,7 +317,8 @@ acpi_ut_display_init_pathname (
270 317
271 /* Print the object type and pathname */ 318 /* Print the object type and pathname */
272 319
273 acpi_os_printf ("%-12s %s", acpi_ut_get_type_name (type), (char *) buffer.pointer); 320 acpi_os_printf ("%-12s %s",
321 acpi_ut_get_type_name (type), (char *) buffer.pointer);
274 322
275 /* Extra path is used to append names like _STA, _INI, etc. */ 323 /* Extra path is used to append names like _STA, _INI, etc. */
276 324
@@ -288,9 +336,9 @@ acpi_ut_display_init_pathname (
288 * 336 *
289 * FUNCTION: acpi_ut_valid_acpi_name 337 * FUNCTION: acpi_ut_valid_acpi_name
290 * 338 *
291 * PARAMETERS: Character - The character to be examined 339 * PARAMETERS: Name - The name to be examined
292 * 340 *
293 * RETURN: 1 if Character may appear in a name, else 0 341 * RETURN: TRUE if the name is valid, FALSE otherwise
294 * 342 *
295 * DESCRIPTION: Check for a valid ACPI name. Each character must be one of: 343 * DESCRIPTION: Check for a valid ACPI name. Each character must be one of:
296 * 1) Upper case alpha 344 * 1) Upper case alpha
@@ -495,40 +543,6 @@ error_exit:
495 543
496/******************************************************************************* 544/*******************************************************************************
497 * 545 *
498 * FUNCTION: acpi_ut_strupr
499 *
500 * PARAMETERS: src_string - The source string to convert to
501 *
502 * RETURN: src_string
503 *
504 * DESCRIPTION: Convert string to uppercase
505 *
506 ******************************************************************************/
507#ifdef ACPI_FUTURE_USAGE
508char *
509acpi_ut_strupr (
510 char *src_string)
511{
512 char *string;
513
514
515 ACPI_FUNCTION_ENTRY ();
516
517
518 /* Walk entire string, uppercasing the letters */
519
520 for (string = src_string; *string; ) {
521 *string = (char) ACPI_TOUPPER (*string);
522 string++;
523 }
524
525 return (src_string);
526}
527#endif /* ACPI_FUTURE_USAGE */
528
529
530/*******************************************************************************
531 *
532 * FUNCTION: acpi_ut_mutex_initialize 546 * FUNCTION: acpi_ut_mutex_initialize
533 * 547 *
534 * PARAMETERS: None. 548 * PARAMETERS: None.
@@ -611,7 +625,7 @@ acpi_ut_mutex_terminate (
611 * 625 *
612 ******************************************************************************/ 626 ******************************************************************************/
613 627
614acpi_status 628static acpi_status
615acpi_ut_create_mutex ( 629acpi_ut_create_mutex (
616 acpi_mutex_handle mutex_id) 630 acpi_mutex_handle mutex_id)
617{ 631{
@@ -648,7 +662,7 @@ acpi_ut_create_mutex (
648 * 662 *
649 ******************************************************************************/ 663 ******************************************************************************/
650 664
651acpi_status 665static acpi_status
652acpi_ut_delete_mutex ( 666acpi_ut_delete_mutex (
653 acpi_mutex_handle mutex_id) 667 acpi_mutex_handle mutex_id)
654{ 668{
@@ -715,16 +729,16 @@ acpi_ut_acquire_mutex (
715 if (acpi_gbl_mutex_info[i].owner_id == this_thread_id) { 729 if (acpi_gbl_mutex_info[i].owner_id == this_thread_id) {
716 if (i == mutex_id) { 730 if (i == mutex_id) {
717 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 731 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
718 "Mutex [%s] already acquired by this thread [%X]\n", 732 "Mutex [%s] already acquired by this thread [%X]\n",
719 acpi_ut_get_mutex_name (mutex_id), this_thread_id)); 733 acpi_ut_get_mutex_name (mutex_id), this_thread_id));
720 734
721 return (AE_ALREADY_ACQUIRED); 735 return (AE_ALREADY_ACQUIRED);
722 } 736 }
723 737
724 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 738 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
725 "Invalid acquire order: Thread %X owns [%s], wants [%s]\n", 739 "Invalid acquire order: Thread %X owns [%s], wants [%s]\n",
726 this_thread_id, acpi_ut_get_mutex_name (i), 740 this_thread_id, acpi_ut_get_mutex_name (i),
727 acpi_ut_get_mutex_name (mutex_id))); 741 acpi_ut_get_mutex_name (mutex_id)));
728 742
729 return (AE_ACQUIRE_DEADLOCK); 743 return (AE_ACQUIRE_DEADLOCK);
730 } 744 }
@@ -733,22 +747,23 @@ acpi_ut_acquire_mutex (
733#endif 747#endif
734 748
735 ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, 749 ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX,
736 "Thread %X attempting to acquire Mutex [%s]\n", 750 "Thread %X attempting to acquire Mutex [%s]\n",
737 this_thread_id, acpi_ut_get_mutex_name (mutex_id))); 751 this_thread_id, acpi_ut_get_mutex_name (mutex_id)));
738 752
739 status = acpi_os_wait_semaphore (acpi_gbl_mutex_info[mutex_id].mutex, 753 status = acpi_os_wait_semaphore (acpi_gbl_mutex_info[mutex_id].mutex,
740 1, ACPI_WAIT_FOREVER); 754 1, ACPI_WAIT_FOREVER);
741 if (ACPI_SUCCESS (status)) { 755 if (ACPI_SUCCESS (status)) {
742 ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Thread %X acquired Mutex [%s]\n", 756 ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Thread %X acquired Mutex [%s]\n",
743 this_thread_id, acpi_ut_get_mutex_name (mutex_id))); 757 this_thread_id, acpi_ut_get_mutex_name (mutex_id)));
744 758
745 acpi_gbl_mutex_info[mutex_id].use_count++; 759 acpi_gbl_mutex_info[mutex_id].use_count++;
746 acpi_gbl_mutex_info[mutex_id].owner_id = this_thread_id; 760 acpi_gbl_mutex_info[mutex_id].owner_id = this_thread_id;
747 } 761 }
748 else { 762 else {
749 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Thread %X could not acquire Mutex [%s] %s\n", 763 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
750 this_thread_id, acpi_ut_get_mutex_name (mutex_id), 764 "Thread %X could not acquire Mutex [%s] %s\n",
751 acpi_format_exception (status))); 765 this_thread_id, acpi_ut_get_mutex_name (mutex_id),
766 acpi_format_exception (status)));
752 } 767 }
753 768
754 return (status); 769 return (status);
@@ -793,8 +808,8 @@ acpi_ut_release_mutex (
793 */ 808 */
794 if (acpi_gbl_mutex_info[mutex_id].owner_id == ACPI_MUTEX_NOT_ACQUIRED) { 809 if (acpi_gbl_mutex_info[mutex_id].owner_id == ACPI_MUTEX_NOT_ACQUIRED) {
795 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 810 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
796 "Mutex [%s] is not acquired, cannot release\n", 811 "Mutex [%s] is not acquired, cannot release\n",
797 acpi_ut_get_mutex_name (mutex_id))); 812 acpi_ut_get_mutex_name (mutex_id)));
798 813
799 return (AE_NOT_ACQUIRED); 814 return (AE_NOT_ACQUIRED);
800 } 815 }
@@ -812,8 +827,8 @@ acpi_ut_release_mutex (
812 } 827 }
813 828
814 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 829 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
815 "Invalid release order: owns [%s], releasing [%s]\n", 830 "Invalid release order: owns [%s], releasing [%s]\n",
816 acpi_ut_get_mutex_name (i), acpi_ut_get_mutex_name (mutex_id))); 831 acpi_ut_get_mutex_name (i), acpi_ut_get_mutex_name (mutex_id)));
817 832
818 return (AE_RELEASE_DEADLOCK); 833 return (AE_RELEASE_DEADLOCK);
819 } 834 }
@@ -826,13 +841,14 @@ acpi_ut_release_mutex (
826 status = acpi_os_signal_semaphore (acpi_gbl_mutex_info[mutex_id].mutex, 1); 841 status = acpi_os_signal_semaphore (acpi_gbl_mutex_info[mutex_id].mutex, 1);
827 842
828 if (ACPI_FAILURE (status)) { 843 if (ACPI_FAILURE (status)) {
829 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Thread %X could not release Mutex [%s] %s\n", 844 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
830 this_thread_id, acpi_ut_get_mutex_name (mutex_id), 845 "Thread %X could not release Mutex [%s] %s\n",
831 acpi_format_exception (status))); 846 this_thread_id, acpi_ut_get_mutex_name (mutex_id),
847 acpi_format_exception (status)));
832 } 848 }
833 else { 849 else {
834 ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Thread %X released Mutex [%s]\n", 850 ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Thread %X released Mutex [%s]\n",
835 this_thread_id, acpi_ut_get_mutex_name (mutex_id))); 851 this_thread_id, acpi_ut_get_mutex_name (mutex_id)));
836 } 852 }
837 853
838 return (status); 854 return (status);
@@ -843,11 +859,11 @@ acpi_ut_release_mutex (
843 * 859 *
844 * FUNCTION: acpi_ut_create_update_state_and_push 860 * FUNCTION: acpi_ut_create_update_state_and_push
845 * 861 *
846 * PARAMETERS: *Object - Object to be added to the new state 862 * PARAMETERS: Object - Object to be added to the new state
847 * Action - Increment/Decrement 863 * Action - Increment/Decrement
848 * state_list - List the state will be added to 864 * state_list - List the state will be added to
849 * 865 *
850 * RETURN: None 866 * RETURN: Status
851 * 867 *
852 * DESCRIPTION: Create a new state and push it 868 * DESCRIPTION: Create a new state and push it
853 * 869 *
@@ -885,15 +901,16 @@ acpi_ut_create_update_state_and_push (
885 * 901 *
886 * FUNCTION: acpi_ut_create_pkg_state_and_push 902 * FUNCTION: acpi_ut_create_pkg_state_and_push
887 * 903 *
888 * PARAMETERS: *Object - Object to be added to the new state 904 * PARAMETERS: Object - Object to be added to the new state
889 * Action - Increment/Decrement 905 * Action - Increment/Decrement
890 * state_list - List the state will be added to 906 * state_list - List the state will be added to
891 * 907 *
892 * RETURN: None 908 * RETURN: Status
893 * 909 *
894 * DESCRIPTION: Create a new state and push it 910 * DESCRIPTION: Create a new state and push it
895 * 911 *
896 ******************************************************************************/ 912 ******************************************************************************/
913
897#ifdef ACPI_FUTURE_USAGE 914#ifdef ACPI_FUTURE_USAGE
898acpi_status 915acpi_status
899acpi_ut_create_pkg_state_and_push ( 916acpi_ut_create_pkg_state_and_push (
@@ -925,7 +942,7 @@ acpi_ut_create_pkg_state_and_push (
925 * PARAMETERS: list_head - Head of the state stack 942 * PARAMETERS: list_head - Head of the state stack
926 * State - State object to push 943 * State - State object to push
927 * 944 *
928 * RETURN: Status 945 * RETURN: None
929 * 946 *
930 * DESCRIPTION: Push a state object onto a state stack 947 * DESCRIPTION: Push a state object onto a state stack
931 * 948 *
@@ -954,7 +971,7 @@ acpi_ut_push_generic_state (
954 * 971 *
955 * PARAMETERS: list_head - Head of the state stack 972 * PARAMETERS: list_head - Head of the state stack
956 * 973 *
957 * RETURN: Status 974 * RETURN: The popped state object
958 * 975 *
959 * DESCRIPTION: Pop a state object from a state stack 976 * DESCRIPTION: Pop a state object from a state stack
960 * 977 *
@@ -989,7 +1006,7 @@ acpi_ut_pop_generic_state (
989 * 1006 *
990 * PARAMETERS: None 1007 * PARAMETERS: None
991 * 1008 *
992 * RETURN: Status 1009 * RETURN: The new state object. NULL on failure.
993 * 1010 *
994 * DESCRIPTION: Create a generic state object. Attempt to obtain one from 1011 * DESCRIPTION: Create a generic state object. Attempt to obtain one from
995 * the global state cache; If none available, create a new one. 1012 * the global state cache; If none available, create a new one.
@@ -997,7 +1014,8 @@ acpi_ut_pop_generic_state (
997 ******************************************************************************/ 1014 ******************************************************************************/
998 1015
999union acpi_generic_state * 1016union acpi_generic_state *
1000acpi_ut_create_generic_state (void) 1017acpi_ut_create_generic_state (
1018 void)
1001{ 1019{
1002 union acpi_generic_state *state; 1020 union acpi_generic_state *state;
1003 1021
@@ -1023,7 +1041,7 @@ acpi_ut_create_generic_state (void)
1023 * 1041 *
1024 * PARAMETERS: None 1042 * PARAMETERS: None
1025 * 1043 *
1026 * RETURN: Thread State 1044 * RETURN: New Thread State. NULL on failure
1027 * 1045 *
1028 * DESCRIPTION: Create a "Thread State" - a flavor of the generic state used 1046 * DESCRIPTION: Create a "Thread State" - a flavor of the generic state used
1029 * to track per-thread info during method execution 1047 * to track per-thread info during method execution
@@ -1060,11 +1078,10 @@ acpi_ut_create_thread_state (
1060 * 1078 *
1061 * FUNCTION: acpi_ut_create_update_state 1079 * FUNCTION: acpi_ut_create_update_state
1062 * 1080 *
1063 * PARAMETERS: Object - Initial Object to be installed in the 1081 * PARAMETERS: Object - Initial Object to be installed in the state
1064 * state 1082 * Action - Update action to be performed
1065 * Action - Update action to be performed
1066 * 1083 *
1067 * RETURN: Status 1084 * RETURN: New state object, null on failure
1068 * 1085 *
1069 * DESCRIPTION: Create an "Update State" - a flavor of the generic state used 1086 * DESCRIPTION: Create an "Update State" - a flavor of the generic state used
1070 * to update reference counts and delete complex objects such 1087 * to update reference counts and delete complex objects such
@@ -1104,11 +1121,10 @@ acpi_ut_create_update_state (
1104 * 1121 *
1105 * FUNCTION: acpi_ut_create_pkg_state 1122 * FUNCTION: acpi_ut_create_pkg_state
1106 * 1123 *
1107 * PARAMETERS: Object - Initial Object to be installed in the 1124 * PARAMETERS: Object - Initial Object to be installed in the state
1108 * state 1125 * Action - Update action to be performed
1109 * Action - Update action to be performed
1110 * 1126 *
1111 * RETURN: Status 1127 * RETURN: New state object, null on failure
1112 * 1128 *
1113 * DESCRIPTION: Create a "Package State" 1129 * DESCRIPTION: Create a "Package State"
1114 * 1130 *
@@ -1151,7 +1167,7 @@ acpi_ut_create_pkg_state (
1151 * 1167 *
1152 * PARAMETERS: None 1168 * PARAMETERS: None
1153 * 1169 *
1154 * RETURN: Status 1170 * RETURN: New state object, null on failure
1155 * 1171 *
1156 * DESCRIPTION: Create a "Control State" - a flavor of the generic state used 1172 * DESCRIPTION: Create a "Control State" - a flavor of the generic state used
1157 * to support nested IF/WHILE constructs in the AML. 1173 * to support nested IF/WHILE constructs in the AML.
@@ -1190,7 +1206,7 @@ acpi_ut_create_control_state (
1190 * 1206 *
1191 * PARAMETERS: State - The state object to be deleted 1207 * PARAMETERS: State - The state object to be deleted
1192 * 1208 *
1193 * RETURN: Status 1209 * RETURN: None
1194 * 1210 *
1195 * DESCRIPTION: Put a state object back into the global state cache. The object 1211 * DESCRIPTION: Put a state object back into the global state cache. The object
1196 * is not actually freed at this time. 1212 * is not actually freed at this time.
@@ -1216,7 +1232,7 @@ acpi_ut_delete_generic_state (
1216 * 1232 *
1217 * PARAMETERS: None 1233 * PARAMETERS: None
1218 * 1234 *
1219 * RETURN: Status 1235 * RETURN: None
1220 * 1236 *
1221 * DESCRIPTION: Purge the global state object cache. Used during subsystem 1237 * DESCRIPTION: Purge the global state object cache. Used during subsystem
1222 * termination. 1238 * termination.
@@ -1240,7 +1256,10 @@ acpi_ut_delete_generic_state_cache (
1240 * 1256 *
1241 * FUNCTION: acpi_ut_walk_package_tree 1257 * FUNCTION: acpi_ut_walk_package_tree
1242 * 1258 *
1243 * PARAMETERS: obj_desc - The Package object on which to resolve refs 1259 * PARAMETERS: source_object - The package to walk
1260 * target_object - Target object (if package is being copied)
1261 * walk_callback - Called once for each package element
1262 * Context - Passed to the callback function
1244 * 1263 *
1245 * RETURN: Status 1264 * RETURN: Status
1246 * 1265 *
@@ -1359,7 +1378,7 @@ acpi_ut_walk_package_tree (
1359 * PARAMETERS: Buffer - Buffer to be scanned 1378 * PARAMETERS: Buffer - Buffer to be scanned
1360 * Length - number of bytes to examine 1379 * Length - number of bytes to examine
1361 * 1380 *
1362 * RETURN: checksum 1381 * RETURN: The generated checksum
1363 * 1382 *
1364 * DESCRIPTION: Generate a checksum on a raw buffer 1383 * DESCRIPTION: Generate a checksum on a raw buffer
1365 * 1384 *
@@ -1442,7 +1461,6 @@ acpi_ut_get_resource_end_tag (
1442 * PARAMETERS: module_name - Caller's module name (for error output) 1461 * PARAMETERS: module_name - Caller's module name (for error output)
1443 * line_number - Caller's line number (for error output) 1462 * line_number - Caller's line number (for error output)
1444 * component_id - Caller's component ID (for error output) 1463 * component_id - Caller's component ID (for error output)
1445 * Message - Error message to use on failure
1446 * 1464 *
1447 * RETURN: None 1465 * RETURN: None
1448 * 1466 *
@@ -1457,7 +1475,6 @@ acpi_ut_report_error (
1457 u32 component_id) 1475 u32 component_id)
1458{ 1476{
1459 1477
1460
1461 acpi_os_printf ("%8s-%04d: *** Error: ", module_name, line_number); 1478 acpi_os_printf ("%8s-%04d: *** Error: ", module_name, line_number);
1462} 1479}
1463 1480
@@ -1469,7 +1486,6 @@ acpi_ut_report_error (
1469 * PARAMETERS: module_name - Caller's module name (for error output) 1486 * PARAMETERS: module_name - Caller's module name (for error output)
1470 * line_number - Caller's line number (for error output) 1487 * line_number - Caller's line number (for error output)
1471 * component_id - Caller's component ID (for error output) 1488 * component_id - Caller's component ID (for error output)
1472 * Message - Error message to use on failure
1473 * 1489 *
1474 * RETURN: None 1490 * RETURN: None
1475 * 1491 *
@@ -1495,7 +1511,6 @@ acpi_ut_report_warning (
1495 * PARAMETERS: module_name - Caller's module name (for error output) 1511 * PARAMETERS: module_name - Caller's module name (for error output)
1496 * line_number - Caller's line number (for error output) 1512 * line_number - Caller's line number (for error output)
1497 * component_id - Caller's component ID (for error output) 1513 * component_id - Caller's component ID (for error output)
1498 * Message - Error message to use on failure
1499 * 1514 *
1500 * RETURN: None 1515 * RETURN: None
1501 * 1516 *