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