| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /****************************************************************************** | 
|  | 2 | * | 
|  | 3 | * Module Name: uteval - Object evaluation | 
|  | 4 | * | 
|  | 5 | *****************************************************************************/ | 
|  | 6 |  | 
|  | 7 | /* | 
| Bob Moore | 4a90c7e | 2006-01-13 16:22:00 -0500 | [diff] [blame] | 8 | * Copyright (C) 2000 - 2006, R. Byron Moore | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 9 | * All rights reserved. | 
|  | 10 | * | 
|  | 11 | * Redistribution and use in source and binary forms, with or without | 
|  | 12 | * modification, are permitted provided that the following conditions | 
|  | 13 | * are met: | 
|  | 14 | * 1. Redistributions of source code must retain the above copyright | 
|  | 15 | *    notice, this list of conditions, and the following disclaimer, | 
|  | 16 | *    without modification. | 
|  | 17 | * 2. Redistributions in binary form must reproduce at minimum a disclaimer | 
|  | 18 | *    substantially similar to the "NO WARRANTY" disclaimer below | 
|  | 19 | *    ("Disclaimer") and any redistribution must be conditioned upon | 
|  | 20 | *    including a substantially similar Disclaimer requirement for further | 
|  | 21 | *    binary redistribution. | 
|  | 22 | * 3. Neither the names of the above-listed copyright holders nor the names | 
|  | 23 | *    of any contributors may be used to endorse or promote products derived | 
|  | 24 | *    from this software without specific prior written permission. | 
|  | 25 | * | 
|  | 26 | * Alternatively, this software may be distributed under the terms of the | 
|  | 27 | * GNU General Public License ("GPL") version 2 as published by the Free | 
|  | 28 | * Software Foundation. | 
|  | 29 | * | 
|  | 30 | * NO WARRANTY | 
|  | 31 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 
|  | 32 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 
|  | 33 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR | 
|  | 34 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 
|  | 35 | * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | 
|  | 36 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | 
|  | 37 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 
|  | 38 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | 
|  | 39 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING | 
|  | 40 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 
|  | 41 | * POSSIBILITY OF SUCH DAMAGES. | 
|  | 42 | */ | 
|  | 43 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 44 | #include <acpi/acpi.h> | 
|  | 45 | #include <acpi/acnamesp.h> | 
|  | 46 | #include <acpi/acinterp.h> | 
|  | 47 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 48 | #define _COMPONENT          ACPI_UTILITIES | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 49 | ACPI_MODULE_NAME("uteval") | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 50 |  | 
| Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 51 | /* Local prototypes */ | 
| Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 52 | static void | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 53 | acpi_ut_copy_id_string(char *destination, char *source, acpi_size max_length); | 
| Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 54 |  | 
|  | 55 | static acpi_status | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 56 | acpi_ut_translate_one_cid(union acpi_operand_object *obj_desc, | 
|  | 57 | struct acpi_compatible_id *one_cid); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 58 |  | 
| Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 59 | /* | 
|  | 60 | * Strings supported by the _OSI predefined (internal) method. | 
|  | 61 | */ | 
|  | 62 | static const char *acpi_interfaces_supported[] = { | 
|  | 63 | /* Operating System Vendor Strings */ | 
|  | 64 |  | 
|  | 65 | "Linux", | 
|  | 66 | "Windows 2000", | 
|  | 67 | "Windows 2001", | 
|  | 68 | "Windows 2001 SP0", | 
|  | 69 | "Windows 2001 SP1", | 
|  | 70 | "Windows 2001 SP2", | 
|  | 71 | "Windows 2001 SP3", | 
|  | 72 | "Windows 2001 SP4", | 
|  | 73 | "Windows 2001.1", | 
|  | 74 | "Windows 2001.1 SP1",	/* Added 03/2006 */ | 
|  | 75 | "Windows 2006",		/* Added 03/2006 */ | 
|  | 76 |  | 
|  | 77 | /* Feature Group Strings */ | 
|  | 78 |  | 
|  | 79 | "Extended Address Space Descriptor" | 
|  | 80 | /* | 
|  | 81 | * All "optional" feature group strings (features that are implemented | 
|  | 82 | * by the host) should be implemented in the host version of | 
|  | 83 | * acpi_os_validate_interface and should not be added here. | 
|  | 84 | */ | 
|  | 85 | }; | 
|  | 86 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 87 | /******************************************************************************* | 
|  | 88 | * | 
|  | 89 | * FUNCTION:    acpi_ut_osi_implementation | 
|  | 90 | * | 
|  | 91 | * PARAMETERS:  walk_state          - Current walk state | 
|  | 92 | * | 
|  | 93 | * RETURN:      Status | 
|  | 94 | * | 
| Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 95 | * DESCRIPTION: Implementation of the _OSI predefined control method | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 96 | * | 
|  | 97 | ******************************************************************************/ | 
|  | 98 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 99 | acpi_status acpi_ut_osi_implementation(struct acpi_walk_state *walk_state) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 100 | { | 
| Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 101 | acpi_status status; | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 102 | union acpi_operand_object *string_desc; | 
|  | 103 | union acpi_operand_object *return_desc; | 
|  | 104 | acpi_native_uint i; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 105 |  | 
| Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 106 | ACPI_FUNCTION_TRACE(ut_osi_implementation); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 107 |  | 
|  | 108 | /* Validate the string input argument */ | 
|  | 109 |  | 
|  | 110 | string_desc = walk_state->arguments[0].object; | 
|  | 111 | if (!string_desc || (string_desc->common.type != ACPI_TYPE_STRING)) { | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 112 | return_ACPI_STATUS(AE_TYPE); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 113 | } | 
|  | 114 |  | 
| Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 115 | /* Create a return object */ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 116 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 117 | return_desc = acpi_ut_create_internal_object(ACPI_TYPE_INTEGER); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 118 | if (!return_desc) { | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 119 | return_ACPI_STATUS(AE_NO_MEMORY); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 120 | } | 
|  | 121 |  | 
| Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 122 | /* Default return value is SUPPORTED */ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 123 |  | 
| Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 124 | return_desc->integer.value = ACPI_UINT32_MAX; | 
|  | 125 | walk_state->return_desc = return_desc; | 
| Bob Moore | 52fc0b0 | 2006-10-02 00:00:00 -0400 | [diff] [blame] | 126 |  | 
| Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 127 | /* Compare input string to static table of supported interfaces */ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 128 |  | 
| Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 129 | for (i = 0; i < ACPI_ARRAY_LENGTH(acpi_interfaces_supported); i++) { | 
|  | 130 | if (!ACPI_STRCMP | 
|  | 131 | (string_desc->string.pointer, | 
|  | 132 | acpi_interfaces_supported[i])) { | 
|  | 133 |  | 
|  | 134 | /* The interface is supported */ | 
|  | 135 |  | 
|  | 136 | return_ACPI_STATUS(AE_CTRL_TERMINATE); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 137 | } | 
|  | 138 | } | 
|  | 139 |  | 
| Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 140 | /* | 
|  | 141 | * Did not match the string in the static table, call the host OSL to | 
|  | 142 | * check for a match with one of the optional strings (such as | 
|  | 143 | * "Module Device", "3.0 Thermal Model", etc.) | 
|  | 144 | */ | 
|  | 145 | status = acpi_os_validate_interface(string_desc->string.pointer); | 
|  | 146 | if (ACPI_SUCCESS(status)) { | 
|  | 147 |  | 
|  | 148 | /* The interface is supported */ | 
|  | 149 |  | 
|  | 150 | return_ACPI_STATUS(AE_CTRL_TERMINATE); | 
|  | 151 | } | 
|  | 152 |  | 
|  | 153 | /* The interface is not supported */ | 
|  | 154 |  | 
|  | 155 | return_desc->integer.value = 0; | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 156 | return_ACPI_STATUS(AE_CTRL_TERMINATE); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 157 | } | 
|  | 158 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 159 | /******************************************************************************* | 
|  | 160 | * | 
|  | 161 | * FUNCTION:    acpi_ut_evaluate_object | 
|  | 162 | * | 
|  | 163 | * PARAMETERS:  prefix_node         - Starting node | 
|  | 164 | *              Path                - Path to object from starting node | 
|  | 165 | *              expected_return_types - Bitmap of allowed return types | 
|  | 166 | *              return_desc         - Where a return value is stored | 
|  | 167 | * | 
|  | 168 | * RETURN:      Status | 
|  | 169 | * | 
|  | 170 | * DESCRIPTION: Evaluates a namespace object and verifies the type of the | 
|  | 171 | *              return object.  Common code that simplifies accessing objects | 
|  | 172 | *              that have required return objects of fixed types. | 
|  | 173 | * | 
|  | 174 | *              NOTE: Internal function, no parameter validation | 
|  | 175 | * | 
|  | 176 | ******************************************************************************/ | 
|  | 177 |  | 
|  | 178 | acpi_status | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 179 | acpi_ut_evaluate_object(struct acpi_namespace_node *prefix_node, | 
|  | 180 | char *path, | 
|  | 181 | u32 expected_return_btypes, | 
|  | 182 | union acpi_operand_object **return_desc) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 183 | { | 
| Bob Moore | 4119532 | 2006-05-26 16:36:00 -0400 | [diff] [blame] | 184 | struct acpi_evaluate_info *info; | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 185 | acpi_status status; | 
|  | 186 | u32 return_btype; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 187 |  | 
| Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 188 | ACPI_FUNCTION_TRACE(ut_evaluate_object); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 189 |  | 
| Bob Moore | 4119532 | 2006-05-26 16:36:00 -0400 | [diff] [blame] | 190 | /* Allocate the evaluation information block */ | 
|  | 191 |  | 
|  | 192 | info = ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_evaluate_info)); | 
|  | 193 | if (!info) { | 
|  | 194 | return_ACPI_STATUS(AE_NO_MEMORY); | 
|  | 195 | } | 
|  | 196 |  | 
|  | 197 | info->prefix_node = prefix_node; | 
|  | 198 | info->pathname = path; | 
|  | 199 | info->parameter_type = ACPI_PARAM_ARGS; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 200 |  | 
|  | 201 | /* Evaluate the object/method */ | 
|  | 202 |  | 
| Bob Moore | 4119532 | 2006-05-26 16:36:00 -0400 | [diff] [blame] | 203 | status = acpi_ns_evaluate(info); | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 204 | if (ACPI_FAILURE(status)) { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 205 | if (status == AE_NOT_FOUND) { | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 206 | ACPI_DEBUG_PRINT((ACPI_DB_EXEC, | 
|  | 207 | "[%4.4s.%s] was not found\n", | 
|  | 208 | acpi_ut_get_node_name(prefix_node), | 
|  | 209 | path)); | 
|  | 210 | } else { | 
| Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 211 | ACPI_ERROR_METHOD("Method execution failed", | 
|  | 212 | prefix_node, path, status); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 213 | } | 
|  | 214 |  | 
| Bob Moore | 4119532 | 2006-05-26 16:36:00 -0400 | [diff] [blame] | 215 | goto cleanup; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 216 | } | 
|  | 217 |  | 
|  | 218 | /* Did we get a return object? */ | 
|  | 219 |  | 
| Bob Moore | 4119532 | 2006-05-26 16:36:00 -0400 | [diff] [blame] | 220 | if (!info->return_object) { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 221 | if (expected_return_btypes) { | 
| Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 222 | ACPI_ERROR_METHOD("No object was returned from", | 
|  | 223 | prefix_node, path, AE_NOT_EXIST); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 224 |  | 
| Bob Moore | 4119532 | 2006-05-26 16:36:00 -0400 | [diff] [blame] | 225 | status = AE_NOT_EXIST; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 226 | } | 
|  | 227 |  | 
| Bob Moore | 4119532 | 2006-05-26 16:36:00 -0400 | [diff] [blame] | 228 | goto cleanup; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 229 | } | 
|  | 230 |  | 
|  | 231 | /* Map the return object type to the bitmapped type */ | 
|  | 232 |  | 
| Bob Moore | 4119532 | 2006-05-26 16:36:00 -0400 | [diff] [blame] | 233 | switch (ACPI_GET_OBJECT_TYPE(info->return_object)) { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 234 | case ACPI_TYPE_INTEGER: | 
|  | 235 | return_btype = ACPI_BTYPE_INTEGER; | 
|  | 236 | break; | 
|  | 237 |  | 
|  | 238 | case ACPI_TYPE_BUFFER: | 
|  | 239 | return_btype = ACPI_BTYPE_BUFFER; | 
|  | 240 | break; | 
|  | 241 |  | 
|  | 242 | case ACPI_TYPE_STRING: | 
|  | 243 | return_btype = ACPI_BTYPE_STRING; | 
|  | 244 | break; | 
|  | 245 |  | 
|  | 246 | case ACPI_TYPE_PACKAGE: | 
|  | 247 | return_btype = ACPI_BTYPE_PACKAGE; | 
|  | 248 | break; | 
|  | 249 |  | 
|  | 250 | default: | 
|  | 251 | return_btype = 0; | 
|  | 252 | break; | 
|  | 253 | } | 
|  | 254 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 255 | if ((acpi_gbl_enable_interpreter_slack) && (!expected_return_btypes)) { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 256 | /* | 
|  | 257 | * We received a return object, but one was not expected.  This can | 
|  | 258 | * happen frequently if the "implicit return" feature is enabled. | 
|  | 259 | * Just delete the return object and return AE_OK. | 
|  | 260 | */ | 
| Bob Moore | 4119532 | 2006-05-26 16:36:00 -0400 | [diff] [blame] | 261 | acpi_ut_remove_reference(info->return_object); | 
|  | 262 | goto cleanup; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 263 | } | 
|  | 264 |  | 
|  | 265 | /* Is the return object one of the expected types? */ | 
|  | 266 |  | 
|  | 267 | if (!(expected_return_btypes & return_btype)) { | 
| Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 268 | ACPI_ERROR_METHOD("Return object type is incorrect", | 
|  | 269 | prefix_node, path, AE_TYPE); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 270 |  | 
| Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 271 | ACPI_ERROR((AE_INFO, | 
|  | 272 | "Type returned from %s was incorrect: %s, expected Btypes: %X", | 
|  | 273 | path, | 
| Bob Moore | 4119532 | 2006-05-26 16:36:00 -0400 | [diff] [blame] | 274 | acpi_ut_get_object_type_name(info->return_object), | 
| Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 275 | expected_return_btypes)); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 276 |  | 
|  | 277 | /* On error exit, we must delete the return object */ | 
|  | 278 |  | 
| Bob Moore | 4119532 | 2006-05-26 16:36:00 -0400 | [diff] [blame] | 279 | acpi_ut_remove_reference(info->return_object); | 
|  | 280 | status = AE_TYPE; | 
|  | 281 | goto cleanup; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 282 | } | 
|  | 283 |  | 
|  | 284 | /* Object type is OK, return it */ | 
|  | 285 |  | 
| Bob Moore | 4119532 | 2006-05-26 16:36:00 -0400 | [diff] [blame] | 286 | *return_desc = info->return_object; | 
|  | 287 |  | 
|  | 288 | cleanup: | 
|  | 289 | ACPI_FREE(info); | 
|  | 290 | return_ACPI_STATUS(status); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 291 | } | 
|  | 292 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 293 | /******************************************************************************* | 
|  | 294 | * | 
|  | 295 | * FUNCTION:    acpi_ut_evaluate_numeric_object | 
|  | 296 | * | 
| Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 297 | * PARAMETERS:  object_name         - Object name to be evaluated | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 298 | *              device_node         - Node for the device | 
| Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 299 | *              Address             - Where the value is returned | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 300 | * | 
|  | 301 | * RETURN:      Status | 
|  | 302 | * | 
|  | 303 | * DESCRIPTION: Evaluates a numeric namespace object for a selected device | 
|  | 304 | *              and stores result in *Address. | 
|  | 305 | * | 
|  | 306 | *              NOTE: Internal function, no parameter validation | 
|  | 307 | * | 
|  | 308 | ******************************************************************************/ | 
|  | 309 |  | 
|  | 310 | acpi_status | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 311 | acpi_ut_evaluate_numeric_object(char *object_name, | 
|  | 312 | struct acpi_namespace_node *device_node, | 
|  | 313 | acpi_integer * address) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 314 | { | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 315 | union acpi_operand_object *obj_desc; | 
|  | 316 | acpi_status status; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 317 |  | 
| Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 318 | ACPI_FUNCTION_TRACE(ut_evaluate_numeric_object); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 319 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 320 | status = acpi_ut_evaluate_object(device_node, object_name, | 
|  | 321 | ACPI_BTYPE_INTEGER, &obj_desc); | 
|  | 322 | if (ACPI_FAILURE(status)) { | 
|  | 323 | return_ACPI_STATUS(status); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 324 | } | 
|  | 325 |  | 
|  | 326 | /* Get the returned Integer */ | 
|  | 327 |  | 
|  | 328 | *address = obj_desc->integer.value; | 
|  | 329 |  | 
|  | 330 | /* On exit, we must delete the return object */ | 
|  | 331 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 332 | acpi_ut_remove_reference(obj_desc); | 
|  | 333 | return_ACPI_STATUS(status); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 334 | } | 
|  | 335 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 336 | /******************************************************************************* | 
|  | 337 | * | 
|  | 338 | * FUNCTION:    acpi_ut_copy_id_string | 
|  | 339 | * | 
|  | 340 | * PARAMETERS:  Destination         - Where to copy the string | 
|  | 341 | *              Source              - Source string | 
|  | 342 | *              max_length          - Length of the destination buffer | 
|  | 343 | * | 
|  | 344 | * RETURN:      None | 
|  | 345 | * | 
|  | 346 | * DESCRIPTION: Copies an ID string for the _HID, _CID, and _UID methods. | 
|  | 347 | *              Performs removal of a leading asterisk if present -- workaround | 
|  | 348 | *              for a known issue on a bunch of machines. | 
|  | 349 | * | 
|  | 350 | ******************************************************************************/ | 
|  | 351 |  | 
|  | 352 | static void | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 353 | acpi_ut_copy_id_string(char *destination, char *source, acpi_size max_length) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 354 | { | 
|  | 355 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 356 | /* | 
|  | 357 | * Workaround for ID strings that have a leading asterisk. This construct | 
|  | 358 | * is not allowed by the ACPI specification  (ID strings must be | 
|  | 359 | * alphanumeric), but enough existing machines have this embedded in their | 
|  | 360 | * ID strings that the following code is useful. | 
|  | 361 | */ | 
|  | 362 | if (*source == '*') { | 
|  | 363 | source++; | 
|  | 364 | } | 
|  | 365 |  | 
|  | 366 | /* Do the actual copy */ | 
|  | 367 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 368 | ACPI_STRNCPY(destination, source, max_length); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 369 | } | 
|  | 370 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 371 | /******************************************************************************* | 
|  | 372 | * | 
|  | 373 | * FUNCTION:    acpi_ut_execute_HID | 
|  | 374 | * | 
|  | 375 | * PARAMETERS:  device_node         - Node for the device | 
| Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 376 | *              Hid                 - Where the HID is returned | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 377 | * | 
|  | 378 | * RETURN:      Status | 
|  | 379 | * | 
|  | 380 | * DESCRIPTION: Executes the _HID control method that returns the hardware | 
|  | 381 | *              ID of the device. | 
|  | 382 | * | 
|  | 383 | *              NOTE: Internal function, no parameter validation | 
|  | 384 | * | 
|  | 385 | ******************************************************************************/ | 
|  | 386 |  | 
|  | 387 | acpi_status | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 388 | acpi_ut_execute_HID(struct acpi_namespace_node *device_node, | 
|  | 389 | struct acpi_device_id *hid) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 390 | { | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 391 | union acpi_operand_object *obj_desc; | 
|  | 392 | acpi_status status; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 393 |  | 
| Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 394 | ACPI_FUNCTION_TRACE(ut_execute_HID); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 395 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 396 | status = acpi_ut_evaluate_object(device_node, METHOD_NAME__HID, | 
|  | 397 | ACPI_BTYPE_INTEGER | ACPI_BTYPE_STRING, | 
|  | 398 | &obj_desc); | 
|  | 399 | if (ACPI_FAILURE(status)) { | 
|  | 400 | return_ACPI_STATUS(status); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 401 | } | 
|  | 402 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 403 | if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_INTEGER) { | 
| Bob Moore | 52fc0b0 | 2006-10-02 00:00:00 -0400 | [diff] [blame] | 404 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 405 | /* Convert the Numeric HID to string */ | 
|  | 406 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 407 | acpi_ex_eisa_id_to_string((u32) obj_desc->integer.value, | 
|  | 408 | hid->value); | 
|  | 409 | } else { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 410 | /* Copy the String HID from the returned object */ | 
|  | 411 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 412 | acpi_ut_copy_id_string(hid->value, obj_desc->string.pointer, | 
|  | 413 | sizeof(hid->value)); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 414 | } | 
|  | 415 |  | 
|  | 416 | /* On exit, we must delete the return object */ | 
|  | 417 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 418 | acpi_ut_remove_reference(obj_desc); | 
|  | 419 | return_ACPI_STATUS(status); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 420 | } | 
|  | 421 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 422 | /******************************************************************************* | 
|  | 423 | * | 
|  | 424 | * FUNCTION:    acpi_ut_translate_one_cid | 
|  | 425 | * | 
|  | 426 | * PARAMETERS:  obj_desc            - _CID object, must be integer or string | 
|  | 427 | *              one_cid             - Where the CID string is returned | 
|  | 428 | * | 
|  | 429 | * RETURN:      Status | 
|  | 430 | * | 
|  | 431 | * DESCRIPTION: Return a numeric or string _CID value as a string. | 
|  | 432 | *              (Compatible ID) | 
|  | 433 | * | 
|  | 434 | *              NOTE:  Assumes a maximum _CID string length of | 
|  | 435 | *                     ACPI_MAX_CID_LENGTH. | 
|  | 436 | * | 
|  | 437 | ******************************************************************************/ | 
|  | 438 |  | 
|  | 439 | static acpi_status | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 440 | acpi_ut_translate_one_cid(union acpi_operand_object *obj_desc, | 
|  | 441 | struct acpi_compatible_id *one_cid) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 442 | { | 
|  | 443 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 444 | switch (ACPI_GET_OBJECT_TYPE(obj_desc)) { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 445 | case ACPI_TYPE_INTEGER: | 
|  | 446 |  | 
|  | 447 | /* Convert the Numeric CID to string */ | 
|  | 448 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 449 | acpi_ex_eisa_id_to_string((u32) obj_desc->integer.value, | 
|  | 450 | one_cid->value); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 451 | return (AE_OK); | 
|  | 452 |  | 
|  | 453 | case ACPI_TYPE_STRING: | 
|  | 454 |  | 
|  | 455 | if (obj_desc->string.length > ACPI_MAX_CID_LENGTH) { | 
|  | 456 | return (AE_AML_STRING_LIMIT); | 
|  | 457 | } | 
|  | 458 |  | 
|  | 459 | /* Copy the String CID from the returned object */ | 
|  | 460 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 461 | acpi_ut_copy_id_string(one_cid->value, obj_desc->string.pointer, | 
|  | 462 | ACPI_MAX_CID_LENGTH); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 463 | return (AE_OK); | 
|  | 464 |  | 
|  | 465 | default: | 
|  | 466 |  | 
|  | 467 | return (AE_TYPE); | 
|  | 468 | } | 
|  | 469 | } | 
|  | 470 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 471 | /******************************************************************************* | 
|  | 472 | * | 
|  | 473 | * FUNCTION:    acpi_ut_execute_CID | 
|  | 474 | * | 
|  | 475 | * PARAMETERS:  device_node         - Node for the device | 
| Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 476 | *              return_cid_list     - Where the CID list is returned | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 477 | * | 
|  | 478 | * RETURN:      Status | 
|  | 479 | * | 
|  | 480 | * DESCRIPTION: Executes the _CID control method that returns one or more | 
|  | 481 | *              compatible hardware IDs for the device. | 
|  | 482 | * | 
|  | 483 | *              NOTE: Internal function, no parameter validation | 
|  | 484 | * | 
|  | 485 | ******************************************************************************/ | 
|  | 486 |  | 
|  | 487 | acpi_status | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 488 | acpi_ut_execute_CID(struct acpi_namespace_node * device_node, | 
|  | 489 | struct acpi_compatible_id_list ** return_cid_list) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 490 | { | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 491 | union acpi_operand_object *obj_desc; | 
|  | 492 | acpi_status status; | 
|  | 493 | u32 count; | 
|  | 494 | u32 size; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 495 | struct acpi_compatible_id_list *cid_list; | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 496 | acpi_native_uint i; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 497 |  | 
| Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 498 | ACPI_FUNCTION_TRACE(ut_execute_CID); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 499 |  | 
|  | 500 | /* Evaluate the _CID method for this device */ | 
|  | 501 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 502 | status = acpi_ut_evaluate_object(device_node, METHOD_NAME__CID, | 
|  | 503 | ACPI_BTYPE_INTEGER | ACPI_BTYPE_STRING | 
|  | 504 | | ACPI_BTYPE_PACKAGE, &obj_desc); | 
|  | 505 | if (ACPI_FAILURE(status)) { | 
|  | 506 | return_ACPI_STATUS(status); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 507 | } | 
|  | 508 |  | 
|  | 509 | /* Get the number of _CIDs returned */ | 
|  | 510 |  | 
|  | 511 | count = 1; | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 512 | if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_PACKAGE) { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 513 | count = obj_desc->package.count; | 
|  | 514 | } | 
|  | 515 |  | 
|  | 516 | /* Allocate a worst-case buffer for the _CIDs */ | 
|  | 517 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 518 | size = (((count - 1) * sizeof(struct acpi_compatible_id)) + | 
|  | 519 | sizeof(struct acpi_compatible_id_list)); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 520 |  | 
| Bob Moore | 8313524 | 2006-10-03 00:00:00 -0400 | [diff] [blame] | 521 | cid_list = ACPI_ALLOCATE_ZEROED((acpi_size) size); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 522 | if (!cid_list) { | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 523 | return_ACPI_STATUS(AE_NO_MEMORY); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 524 | } | 
|  | 525 |  | 
|  | 526 | /* Init CID list */ | 
|  | 527 |  | 
|  | 528 | cid_list->count = count; | 
|  | 529 | cid_list->size = size; | 
|  | 530 |  | 
|  | 531 | /* | 
| Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 532 | *  A _CID can return either a single compatible ID or a package of | 
|  | 533 | *  compatible IDs.  Each compatible ID can be one of the following: | 
|  | 534 | *  1) Integer (32 bit compressed EISA ID) or | 
|  | 535 | *  2) String (PCI ID format, e.g. "PCI\VEN_vvvv&DEV_dddd&SUBSYS_ssssssss") | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 536 | */ | 
|  | 537 |  | 
|  | 538 | /* The _CID object can be either a single CID or a package (list) of CIDs */ | 
|  | 539 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 540 | if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_PACKAGE) { | 
| Bob Moore | 52fc0b0 | 2006-10-02 00:00:00 -0400 | [diff] [blame] | 541 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 542 | /* Translate each package element */ | 
|  | 543 |  | 
|  | 544 | for (i = 0; i < count; i++) { | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 545 | status = | 
|  | 546 | acpi_ut_translate_one_cid(obj_desc->package. | 
|  | 547 | elements[i], | 
|  | 548 | &cid_list->id[i]); | 
|  | 549 | if (ACPI_FAILURE(status)) { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 550 | break; | 
|  | 551 | } | 
|  | 552 | } | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 553 | } else { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 554 | /* Only one CID, translate to a string */ | 
|  | 555 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 556 | status = acpi_ut_translate_one_cid(obj_desc, cid_list->id); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 557 | } | 
|  | 558 |  | 
|  | 559 | /* Cleanup on error */ | 
|  | 560 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 561 | if (ACPI_FAILURE(status)) { | 
| Bob Moore | 8313524 | 2006-10-03 00:00:00 -0400 | [diff] [blame] | 562 | ACPI_FREE(cid_list); | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 563 | } else { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 564 | *return_cid_list = cid_list; | 
|  | 565 | } | 
|  | 566 |  | 
|  | 567 | /* On exit, we must delete the _CID return object */ | 
|  | 568 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 569 | acpi_ut_remove_reference(obj_desc); | 
|  | 570 | return_ACPI_STATUS(status); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 571 | } | 
|  | 572 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 573 | /******************************************************************************* | 
|  | 574 | * | 
|  | 575 | * FUNCTION:    acpi_ut_execute_UID | 
|  | 576 | * | 
|  | 577 | * PARAMETERS:  device_node         - Node for the device | 
| Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 578 | *              Uid                 - Where the UID is returned | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 579 | * | 
|  | 580 | * RETURN:      Status | 
|  | 581 | * | 
|  | 582 | * DESCRIPTION: Executes the _UID control method that returns the hardware | 
|  | 583 | *              ID of the device. | 
|  | 584 | * | 
|  | 585 | *              NOTE: Internal function, no parameter validation | 
|  | 586 | * | 
|  | 587 | ******************************************************************************/ | 
|  | 588 |  | 
|  | 589 | acpi_status | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 590 | acpi_ut_execute_UID(struct acpi_namespace_node *device_node, | 
|  | 591 | struct acpi_device_id *uid) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 592 | { | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 593 | union acpi_operand_object *obj_desc; | 
|  | 594 | acpi_status status; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 595 |  | 
| Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 596 | ACPI_FUNCTION_TRACE(ut_execute_UID); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 597 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 598 | status = acpi_ut_evaluate_object(device_node, METHOD_NAME__UID, | 
|  | 599 | ACPI_BTYPE_INTEGER | ACPI_BTYPE_STRING, | 
|  | 600 | &obj_desc); | 
|  | 601 | if (ACPI_FAILURE(status)) { | 
|  | 602 | return_ACPI_STATUS(status); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 603 | } | 
|  | 604 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 605 | if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_INTEGER) { | 
| Bob Moore | 52fc0b0 | 2006-10-02 00:00:00 -0400 | [diff] [blame] | 606 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 607 | /* Convert the Numeric UID to string */ | 
|  | 608 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 609 | acpi_ex_unsigned_integer_to_string(obj_desc->integer.value, | 
|  | 610 | uid->value); | 
|  | 611 | } else { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 612 | /* Copy the String UID from the returned object */ | 
|  | 613 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 614 | acpi_ut_copy_id_string(uid->value, obj_desc->string.pointer, | 
|  | 615 | sizeof(uid->value)); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 616 | } | 
|  | 617 |  | 
|  | 618 | /* On exit, we must delete the return object */ | 
|  | 619 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 620 | acpi_ut_remove_reference(obj_desc); | 
|  | 621 | return_ACPI_STATUS(status); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 622 | } | 
|  | 623 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 624 | /******************************************************************************* | 
|  | 625 | * | 
|  | 626 | * FUNCTION:    acpi_ut_execute_STA | 
|  | 627 | * | 
|  | 628 | * PARAMETERS:  device_node         - Node for the device | 
| Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 629 | *              Flags               - Where the status flags are returned | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 630 | * | 
|  | 631 | * RETURN:      Status | 
|  | 632 | * | 
|  | 633 | * DESCRIPTION: Executes _STA for selected device and stores results in | 
|  | 634 | *              *Flags. | 
|  | 635 | * | 
|  | 636 | *              NOTE: Internal function, no parameter validation | 
|  | 637 | * | 
|  | 638 | ******************************************************************************/ | 
|  | 639 |  | 
|  | 640 | acpi_status | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 641 | acpi_ut_execute_STA(struct acpi_namespace_node *device_node, u32 * flags) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 642 | { | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 643 | union acpi_operand_object *obj_desc; | 
|  | 644 | acpi_status status; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 645 |  | 
| Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 646 | ACPI_FUNCTION_TRACE(ut_execute_STA); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 647 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 648 | status = acpi_ut_evaluate_object(device_node, METHOD_NAME__STA, | 
|  | 649 | ACPI_BTYPE_INTEGER, &obj_desc); | 
|  | 650 | if (ACPI_FAILURE(status)) { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 651 | if (AE_NOT_FOUND == status) { | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 652 | ACPI_DEBUG_PRINT((ACPI_DB_EXEC, | 
|  | 653 | "_STA on %4.4s was not found, assuming device is present\n", | 
|  | 654 | acpi_ut_get_node_name(device_node))); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 655 |  | 
| Bob Moore | defba1d | 2005-12-16 17:05:00 -0500 | [diff] [blame] | 656 | *flags = ACPI_UINT32_MAX; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 657 | status = AE_OK; | 
|  | 658 | } | 
|  | 659 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 660 | return_ACPI_STATUS(status); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 661 | } | 
|  | 662 |  | 
|  | 663 | /* Extract the status flags */ | 
|  | 664 |  | 
|  | 665 | *flags = (u32) obj_desc->integer.value; | 
|  | 666 |  | 
|  | 667 | /* On exit, we must delete the return object */ | 
|  | 668 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 669 | acpi_ut_remove_reference(obj_desc); | 
|  | 670 | return_ACPI_STATUS(status); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 671 | } | 
|  | 672 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 673 | /******************************************************************************* | 
|  | 674 | * | 
|  | 675 | * FUNCTION:    acpi_ut_execute_Sxds | 
|  | 676 | * | 
|  | 677 | * PARAMETERS:  device_node         - Node for the device | 
| Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 678 | *              Flags               - Where the status flags are returned | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 679 | * | 
|  | 680 | * RETURN:      Status | 
|  | 681 | * | 
|  | 682 | * DESCRIPTION: Executes _STA for selected device and stores results in | 
|  | 683 | *              *Flags. | 
|  | 684 | * | 
|  | 685 | *              NOTE: Internal function, no parameter validation | 
|  | 686 | * | 
|  | 687 | ******************************************************************************/ | 
|  | 688 |  | 
|  | 689 | acpi_status | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 690 | acpi_ut_execute_sxds(struct acpi_namespace_node *device_node, u8 * highest) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 691 | { | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 692 | union acpi_operand_object *obj_desc; | 
|  | 693 | acpi_status status; | 
|  | 694 | u32 i; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 695 |  | 
| Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 696 | ACPI_FUNCTION_TRACE(ut_execute_sxds); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 697 |  | 
|  | 698 | for (i = 0; i < 4; i++) { | 
|  | 699 | highest[i] = 0xFF; | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 700 | status = acpi_ut_evaluate_object(device_node, | 
| Bob Moore | defba1d | 2005-12-16 17:05:00 -0500 | [diff] [blame] | 701 | ACPI_CAST_PTR(char, | 
|  | 702 | acpi_gbl_highest_dstate_names | 
|  | 703 | [i]), | 
|  | 704 | ACPI_BTYPE_INTEGER, &obj_desc); | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 705 | if (ACPI_FAILURE(status)) { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 706 | if (status != AE_NOT_FOUND) { | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 707 | ACPI_DEBUG_PRINT((ACPI_DB_EXEC, | 
|  | 708 | "%s on Device %4.4s, %s\n", | 
| Bob Moore | defba1d | 2005-12-16 17:05:00 -0500 | [diff] [blame] | 709 | ACPI_CAST_PTR(char, | 
|  | 710 | acpi_gbl_highest_dstate_names | 
|  | 711 | [i]), | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 712 | acpi_ut_get_node_name | 
|  | 713 | (device_node), | 
|  | 714 | acpi_format_exception | 
|  | 715 | (status))); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 716 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 717 | return_ACPI_STATUS(status); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 718 | } | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 719 | } else { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 720 | /* Extract the Dstate value */ | 
|  | 721 |  | 
|  | 722 | highest[i] = (u8) obj_desc->integer.value; | 
|  | 723 |  | 
|  | 724 | /* Delete the return object */ | 
|  | 725 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 726 | acpi_ut_remove_reference(obj_desc); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 727 | } | 
|  | 728 | } | 
|  | 729 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 730 | return_ACPI_STATUS(AE_OK); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 731 | } |