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