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 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 184 | struct acpi_parameter_info info; |
| 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 | |
| 190 | info.node = prefix_node; |
| 191 | info.parameters = NULL; |
| 192 | info.parameter_type = ACPI_PARAM_ARGS; |
| 193 | |
| 194 | /* Evaluate the object/method */ |
| 195 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 196 | status = acpi_ns_evaluate_relative(path, &info); |
| 197 | if (ACPI_FAILURE(status)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 198 | if (status == AE_NOT_FOUND) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 199 | ACPI_DEBUG_PRINT((ACPI_DB_EXEC, |
| 200 | "[%4.4s.%s] was not found\n", |
| 201 | acpi_ut_get_node_name(prefix_node), |
| 202 | path)); |
| 203 | } else { |
Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 204 | ACPI_ERROR_METHOD("Method execution failed", |
| 205 | prefix_node, path, status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 206 | } |
| 207 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 208 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 209 | } |
| 210 | |
| 211 | /* Did we get a return object? */ |
| 212 | |
| 213 | if (!info.return_object) { |
| 214 | if (expected_return_btypes) { |
Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 215 | ACPI_ERROR_METHOD("No object was returned from", |
| 216 | prefix_node, path, AE_NOT_EXIST); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 217 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 218 | return_ACPI_STATUS(AE_NOT_EXIST); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 219 | } |
| 220 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 221 | return_ACPI_STATUS(AE_OK); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 222 | } |
| 223 | |
| 224 | /* Map the return object type to the bitmapped type */ |
| 225 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 226 | switch (ACPI_GET_OBJECT_TYPE(info.return_object)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 227 | case ACPI_TYPE_INTEGER: |
| 228 | return_btype = ACPI_BTYPE_INTEGER; |
| 229 | break; |
| 230 | |
| 231 | case ACPI_TYPE_BUFFER: |
| 232 | return_btype = ACPI_BTYPE_BUFFER; |
| 233 | break; |
| 234 | |
| 235 | case ACPI_TYPE_STRING: |
| 236 | return_btype = ACPI_BTYPE_STRING; |
| 237 | break; |
| 238 | |
| 239 | case ACPI_TYPE_PACKAGE: |
| 240 | return_btype = ACPI_BTYPE_PACKAGE; |
| 241 | break; |
| 242 | |
| 243 | default: |
| 244 | return_btype = 0; |
| 245 | break; |
| 246 | } |
| 247 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 248 | if ((acpi_gbl_enable_interpreter_slack) && (!expected_return_btypes)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 249 | /* |
| 250 | * We received a return object, but one was not expected. This can |
| 251 | * happen frequently if the "implicit return" feature is enabled. |
| 252 | * Just delete the return object and return AE_OK. |
| 253 | */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 254 | acpi_ut_remove_reference(info.return_object); |
| 255 | return_ACPI_STATUS(AE_OK); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 256 | } |
| 257 | |
| 258 | /* Is the return object one of the expected types? */ |
| 259 | |
| 260 | if (!(expected_return_btypes & return_btype)) { |
Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 261 | ACPI_ERROR_METHOD("Return object type is incorrect", |
| 262 | prefix_node, path, AE_TYPE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 263 | |
Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 264 | ACPI_ERROR((AE_INFO, |
| 265 | "Type returned from %s was incorrect: %s, expected Btypes: %X", |
| 266 | path, |
| 267 | acpi_ut_get_object_type_name(info.return_object), |
| 268 | expected_return_btypes)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 269 | |
| 270 | /* On error exit, we must delete the return object */ |
| 271 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 272 | acpi_ut_remove_reference(info.return_object); |
| 273 | return_ACPI_STATUS(AE_TYPE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 274 | } |
| 275 | |
| 276 | /* Object type is OK, return it */ |
| 277 | |
| 278 | *return_desc = info.return_object; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 279 | return_ACPI_STATUS(AE_OK); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 280 | } |
| 281 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 282 | /******************************************************************************* |
| 283 | * |
| 284 | * FUNCTION: acpi_ut_evaluate_numeric_object |
| 285 | * |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 286 | * PARAMETERS: object_name - Object name to be evaluated |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 287 | * device_node - Node for the device |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 288 | * Address - Where the value is returned |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 289 | * |
| 290 | * RETURN: Status |
| 291 | * |
| 292 | * DESCRIPTION: Evaluates a numeric namespace object for a selected device |
| 293 | * and stores result in *Address. |
| 294 | * |
| 295 | * NOTE: Internal function, no parameter validation |
| 296 | * |
| 297 | ******************************************************************************/ |
| 298 | |
| 299 | acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 300 | acpi_ut_evaluate_numeric_object(char *object_name, |
| 301 | struct acpi_namespace_node *device_node, |
| 302 | acpi_integer * address) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 303 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 304 | union acpi_operand_object *obj_desc; |
| 305 | acpi_status status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 306 | |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame^] | 307 | ACPI_FUNCTION_TRACE(ut_evaluate_numeric_object); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 308 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 309 | status = acpi_ut_evaluate_object(device_node, object_name, |
| 310 | ACPI_BTYPE_INTEGER, &obj_desc); |
| 311 | if (ACPI_FAILURE(status)) { |
| 312 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 313 | } |
| 314 | |
| 315 | /* Get the returned Integer */ |
| 316 | |
| 317 | *address = obj_desc->integer.value; |
| 318 | |
| 319 | /* On exit, we must delete the return object */ |
| 320 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 321 | acpi_ut_remove_reference(obj_desc); |
| 322 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 323 | } |
| 324 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 325 | /******************************************************************************* |
| 326 | * |
| 327 | * FUNCTION: acpi_ut_copy_id_string |
| 328 | * |
| 329 | * PARAMETERS: Destination - Where to copy the string |
| 330 | * Source - Source string |
| 331 | * max_length - Length of the destination buffer |
| 332 | * |
| 333 | * RETURN: None |
| 334 | * |
| 335 | * DESCRIPTION: Copies an ID string for the _HID, _CID, and _UID methods. |
| 336 | * Performs removal of a leading asterisk if present -- workaround |
| 337 | * for a known issue on a bunch of machines. |
| 338 | * |
| 339 | ******************************************************************************/ |
| 340 | |
| 341 | static void |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 342 | 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] | 343 | { |
| 344 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 345 | /* |
| 346 | * Workaround for ID strings that have a leading asterisk. This construct |
| 347 | * is not allowed by the ACPI specification (ID strings must be |
| 348 | * alphanumeric), but enough existing machines have this embedded in their |
| 349 | * ID strings that the following code is useful. |
| 350 | */ |
| 351 | if (*source == '*') { |
| 352 | source++; |
| 353 | } |
| 354 | |
| 355 | /* Do the actual copy */ |
| 356 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 357 | ACPI_STRNCPY(destination, source, max_length); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 358 | } |
| 359 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 360 | /******************************************************************************* |
| 361 | * |
| 362 | * FUNCTION: acpi_ut_execute_HID |
| 363 | * |
| 364 | * PARAMETERS: device_node - Node for the device |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 365 | * Hid - Where the HID is returned |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 366 | * |
| 367 | * RETURN: Status |
| 368 | * |
| 369 | * DESCRIPTION: Executes the _HID control method that returns the hardware |
| 370 | * ID of the device. |
| 371 | * |
| 372 | * NOTE: Internal function, no parameter validation |
| 373 | * |
| 374 | ******************************************************************************/ |
| 375 | |
| 376 | acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 377 | acpi_ut_execute_HID(struct acpi_namespace_node *device_node, |
| 378 | struct acpi_device_id *hid) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 379 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 380 | union acpi_operand_object *obj_desc; |
| 381 | acpi_status status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 382 | |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame^] | 383 | ACPI_FUNCTION_TRACE(ut_execute_HID); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 384 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 385 | status = acpi_ut_evaluate_object(device_node, METHOD_NAME__HID, |
| 386 | ACPI_BTYPE_INTEGER | ACPI_BTYPE_STRING, |
| 387 | &obj_desc); |
| 388 | if (ACPI_FAILURE(status)) { |
| 389 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 390 | } |
| 391 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 392 | if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_INTEGER) { |
Bob Moore | 52fc0b0 | 2006-10-02 00:00:00 -0400 | [diff] [blame] | 393 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 394 | /* Convert the Numeric HID to string */ |
| 395 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 396 | acpi_ex_eisa_id_to_string((u32) obj_desc->integer.value, |
| 397 | hid->value); |
| 398 | } else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 399 | /* Copy the String HID from the returned object */ |
| 400 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 401 | acpi_ut_copy_id_string(hid->value, obj_desc->string.pointer, |
| 402 | sizeof(hid->value)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 403 | } |
| 404 | |
| 405 | /* On exit, we must delete the return object */ |
| 406 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 407 | acpi_ut_remove_reference(obj_desc); |
| 408 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 409 | } |
| 410 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 411 | /******************************************************************************* |
| 412 | * |
| 413 | * FUNCTION: acpi_ut_translate_one_cid |
| 414 | * |
| 415 | * PARAMETERS: obj_desc - _CID object, must be integer or string |
| 416 | * one_cid - Where the CID string is returned |
| 417 | * |
| 418 | * RETURN: Status |
| 419 | * |
| 420 | * DESCRIPTION: Return a numeric or string _CID value as a string. |
| 421 | * (Compatible ID) |
| 422 | * |
| 423 | * NOTE: Assumes a maximum _CID string length of |
| 424 | * ACPI_MAX_CID_LENGTH. |
| 425 | * |
| 426 | ******************************************************************************/ |
| 427 | |
| 428 | static acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 429 | acpi_ut_translate_one_cid(union acpi_operand_object *obj_desc, |
| 430 | struct acpi_compatible_id *one_cid) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 431 | { |
| 432 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 433 | switch (ACPI_GET_OBJECT_TYPE(obj_desc)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 434 | case ACPI_TYPE_INTEGER: |
| 435 | |
| 436 | /* Convert the Numeric CID to string */ |
| 437 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 438 | acpi_ex_eisa_id_to_string((u32) obj_desc->integer.value, |
| 439 | one_cid->value); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 440 | return (AE_OK); |
| 441 | |
| 442 | case ACPI_TYPE_STRING: |
| 443 | |
| 444 | if (obj_desc->string.length > ACPI_MAX_CID_LENGTH) { |
| 445 | return (AE_AML_STRING_LIMIT); |
| 446 | } |
| 447 | |
| 448 | /* Copy the String CID from the returned object */ |
| 449 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 450 | acpi_ut_copy_id_string(one_cid->value, obj_desc->string.pointer, |
| 451 | ACPI_MAX_CID_LENGTH); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 452 | return (AE_OK); |
| 453 | |
| 454 | default: |
| 455 | |
| 456 | return (AE_TYPE); |
| 457 | } |
| 458 | } |
| 459 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 460 | /******************************************************************************* |
| 461 | * |
| 462 | * FUNCTION: acpi_ut_execute_CID |
| 463 | * |
| 464 | * PARAMETERS: device_node - Node for the device |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 465 | * return_cid_list - Where the CID list is returned |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 466 | * |
| 467 | * RETURN: Status |
| 468 | * |
| 469 | * DESCRIPTION: Executes the _CID control method that returns one or more |
| 470 | * compatible hardware IDs for the device. |
| 471 | * |
| 472 | * NOTE: Internal function, no parameter validation |
| 473 | * |
| 474 | ******************************************************************************/ |
| 475 | |
| 476 | acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 477 | acpi_ut_execute_CID(struct acpi_namespace_node * device_node, |
| 478 | struct acpi_compatible_id_list ** return_cid_list) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 479 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 480 | union acpi_operand_object *obj_desc; |
| 481 | acpi_status status; |
| 482 | u32 count; |
| 483 | u32 size; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 484 | struct acpi_compatible_id_list *cid_list; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 485 | acpi_native_uint i; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 486 | |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame^] | 487 | ACPI_FUNCTION_TRACE(ut_execute_CID); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 488 | |
| 489 | /* Evaluate the _CID method for this device */ |
| 490 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 491 | status = acpi_ut_evaluate_object(device_node, METHOD_NAME__CID, |
| 492 | ACPI_BTYPE_INTEGER | ACPI_BTYPE_STRING |
| 493 | | ACPI_BTYPE_PACKAGE, &obj_desc); |
| 494 | if (ACPI_FAILURE(status)) { |
| 495 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 496 | } |
| 497 | |
| 498 | /* Get the number of _CIDs returned */ |
| 499 | |
| 500 | count = 1; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 501 | if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_PACKAGE) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 502 | count = obj_desc->package.count; |
| 503 | } |
| 504 | |
| 505 | /* Allocate a worst-case buffer for the _CIDs */ |
| 506 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 507 | size = (((count - 1) * sizeof(struct acpi_compatible_id)) + |
| 508 | sizeof(struct acpi_compatible_id_list)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 509 | |
Bob Moore | 8313524 | 2006-10-03 00:00:00 -0400 | [diff] [blame] | 510 | cid_list = ACPI_ALLOCATE_ZEROED((acpi_size) size); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 511 | if (!cid_list) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 512 | return_ACPI_STATUS(AE_NO_MEMORY); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 513 | } |
| 514 | |
| 515 | /* Init CID list */ |
| 516 | |
| 517 | cid_list->count = count; |
| 518 | cid_list->size = size; |
| 519 | |
| 520 | /* |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 521 | * A _CID can return either a single compatible ID or a package of |
| 522 | * compatible IDs. Each compatible ID can be one of the following: |
| 523 | * 1) Integer (32 bit compressed EISA ID) or |
| 524 | * 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] | 525 | */ |
| 526 | |
| 527 | /* The _CID object can be either a single CID or a package (list) of CIDs */ |
| 528 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 529 | if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_PACKAGE) { |
Bob Moore | 52fc0b0 | 2006-10-02 00:00:00 -0400 | [diff] [blame] | 530 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 531 | /* Translate each package element */ |
| 532 | |
| 533 | for (i = 0; i < count; i++) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 534 | status = |
| 535 | acpi_ut_translate_one_cid(obj_desc->package. |
| 536 | elements[i], |
| 537 | &cid_list->id[i]); |
| 538 | if (ACPI_FAILURE(status)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 539 | break; |
| 540 | } |
| 541 | } |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 542 | } else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 543 | /* Only one CID, translate to a string */ |
| 544 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 545 | status = acpi_ut_translate_one_cid(obj_desc, cid_list->id); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 546 | } |
| 547 | |
| 548 | /* Cleanup on error */ |
| 549 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 550 | if (ACPI_FAILURE(status)) { |
Bob Moore | 8313524 | 2006-10-03 00:00:00 -0400 | [diff] [blame] | 551 | ACPI_FREE(cid_list); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 552 | } else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 553 | *return_cid_list = cid_list; |
| 554 | } |
| 555 | |
| 556 | /* On exit, we must delete the _CID return object */ |
| 557 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 558 | acpi_ut_remove_reference(obj_desc); |
| 559 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 560 | } |
| 561 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 562 | /******************************************************************************* |
| 563 | * |
| 564 | * FUNCTION: acpi_ut_execute_UID |
| 565 | * |
| 566 | * PARAMETERS: device_node - Node for the device |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 567 | * Uid - Where the UID is returned |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 568 | * |
| 569 | * RETURN: Status |
| 570 | * |
| 571 | * DESCRIPTION: Executes the _UID control method that returns the hardware |
| 572 | * ID of the device. |
| 573 | * |
| 574 | * NOTE: Internal function, no parameter validation |
| 575 | * |
| 576 | ******************************************************************************/ |
| 577 | |
| 578 | acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 579 | acpi_ut_execute_UID(struct acpi_namespace_node *device_node, |
| 580 | struct acpi_device_id *uid) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 581 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 582 | union acpi_operand_object *obj_desc; |
| 583 | acpi_status status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 584 | |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame^] | 585 | ACPI_FUNCTION_TRACE(ut_execute_UID); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 586 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 587 | status = acpi_ut_evaluate_object(device_node, METHOD_NAME__UID, |
| 588 | ACPI_BTYPE_INTEGER | ACPI_BTYPE_STRING, |
| 589 | &obj_desc); |
| 590 | if (ACPI_FAILURE(status)) { |
| 591 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 592 | } |
| 593 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 594 | if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_INTEGER) { |
Bob Moore | 52fc0b0 | 2006-10-02 00:00:00 -0400 | [diff] [blame] | 595 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 596 | /* Convert the Numeric UID to string */ |
| 597 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 598 | acpi_ex_unsigned_integer_to_string(obj_desc->integer.value, |
| 599 | uid->value); |
| 600 | } else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 601 | /* Copy the String UID from the returned object */ |
| 602 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 603 | acpi_ut_copy_id_string(uid->value, obj_desc->string.pointer, |
| 604 | sizeof(uid->value)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 605 | } |
| 606 | |
| 607 | /* On exit, we must delete the return object */ |
| 608 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 609 | acpi_ut_remove_reference(obj_desc); |
| 610 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 611 | } |
| 612 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 613 | /******************************************************************************* |
| 614 | * |
| 615 | * FUNCTION: acpi_ut_execute_STA |
| 616 | * |
| 617 | * PARAMETERS: device_node - Node for the device |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 618 | * Flags - Where the status flags are returned |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 619 | * |
| 620 | * RETURN: Status |
| 621 | * |
| 622 | * DESCRIPTION: Executes _STA for selected device and stores results in |
| 623 | * *Flags. |
| 624 | * |
| 625 | * NOTE: Internal function, no parameter validation |
| 626 | * |
| 627 | ******************************************************************************/ |
| 628 | |
| 629 | acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 630 | acpi_ut_execute_STA(struct acpi_namespace_node *device_node, u32 * flags) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 631 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 632 | union acpi_operand_object *obj_desc; |
| 633 | acpi_status status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 634 | |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame^] | 635 | ACPI_FUNCTION_TRACE(ut_execute_STA); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 636 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 637 | status = acpi_ut_evaluate_object(device_node, METHOD_NAME__STA, |
| 638 | ACPI_BTYPE_INTEGER, &obj_desc); |
| 639 | if (ACPI_FAILURE(status)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 640 | if (AE_NOT_FOUND == status) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 641 | ACPI_DEBUG_PRINT((ACPI_DB_EXEC, |
| 642 | "_STA on %4.4s was not found, assuming device is present\n", |
| 643 | acpi_ut_get_node_name(device_node))); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 644 | |
Bob Moore | defba1d | 2005-12-16 17:05:00 -0500 | [diff] [blame] | 645 | *flags = ACPI_UINT32_MAX; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 646 | status = AE_OK; |
| 647 | } |
| 648 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 649 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 650 | } |
| 651 | |
| 652 | /* Extract the status flags */ |
| 653 | |
| 654 | *flags = (u32) obj_desc->integer.value; |
| 655 | |
| 656 | /* On exit, we must delete the return object */ |
| 657 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 658 | acpi_ut_remove_reference(obj_desc); |
| 659 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 660 | } |
| 661 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 662 | /******************************************************************************* |
| 663 | * |
| 664 | * FUNCTION: acpi_ut_execute_Sxds |
| 665 | * |
| 666 | * PARAMETERS: device_node - Node for the device |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 667 | * Flags - Where the status flags are returned |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 668 | * |
| 669 | * RETURN: Status |
| 670 | * |
| 671 | * DESCRIPTION: Executes _STA for selected device and stores results in |
| 672 | * *Flags. |
| 673 | * |
| 674 | * NOTE: Internal function, no parameter validation |
| 675 | * |
| 676 | ******************************************************************************/ |
| 677 | |
| 678 | acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 679 | acpi_ut_execute_sxds(struct acpi_namespace_node *device_node, u8 * highest) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 680 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 681 | union acpi_operand_object *obj_desc; |
| 682 | acpi_status status; |
| 683 | u32 i; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 684 | |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame^] | 685 | ACPI_FUNCTION_TRACE(ut_execute_sxds); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 686 | |
| 687 | for (i = 0; i < 4; i++) { |
| 688 | highest[i] = 0xFF; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 689 | status = acpi_ut_evaluate_object(device_node, |
Bob Moore | defba1d | 2005-12-16 17:05:00 -0500 | [diff] [blame] | 690 | ACPI_CAST_PTR(char, |
| 691 | acpi_gbl_highest_dstate_names |
| 692 | [i]), |
| 693 | ACPI_BTYPE_INTEGER, &obj_desc); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 694 | if (ACPI_FAILURE(status)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 695 | if (status != AE_NOT_FOUND) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 696 | ACPI_DEBUG_PRINT((ACPI_DB_EXEC, |
| 697 | "%s on Device %4.4s, %s\n", |
Bob Moore | defba1d | 2005-12-16 17:05:00 -0500 | [diff] [blame] | 698 | ACPI_CAST_PTR(char, |
| 699 | acpi_gbl_highest_dstate_names |
| 700 | [i]), |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 701 | acpi_ut_get_node_name |
| 702 | (device_node), |
| 703 | acpi_format_exception |
| 704 | (status))); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 705 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 706 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 707 | } |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 708 | } else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 709 | /* Extract the Dstate value */ |
| 710 | |
| 711 | highest[i] = (u8) obj_desc->integer.value; |
| 712 | |
| 713 | /* Delete the return object */ |
| 714 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 715 | acpi_ut_remove_reference(obj_desc); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 716 | } |
| 717 | } |
| 718 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 719 | return_ACPI_STATUS(AE_OK); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 720 | } |