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