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