Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /****************************************************************************** |
| 2 | * |
| 3 | * Module Name: uteval - Object evaluation |
| 4 | * |
| 5 | *****************************************************************************/ |
| 6 | |
| 7 | /* |
Bob Moore | a8357b0 | 2010-01-22 19:07:36 +0800 | [diff] [blame] | 8 | * Copyright (C) 2000 - 2010, 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" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 47 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 48 | #define _COMPONENT ACPI_UTILITIES |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 49 | ACPI_MODULE_NAME("uteval") |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 50 | |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 51 | /* |
| 52 | * Strings supported by the _OSI predefined (internal) method. |
Bob Moore | 7f07190 | 2009-03-19 09:37:47 +0800 | [diff] [blame] | 53 | * |
| 54 | * March 2009: Removed "Linux" as this host no longer wants to respond true |
| 55 | * for this string. Basically, the only safe OS strings are windows-related |
| 56 | * and in many or most cases represent the only test path within the |
| 57 | * BIOS-provided ASL code. |
| 58 | * |
| 59 | * The second element of each entry is used to track the newest version of |
| 60 | * Windows that the BIOS has requested. |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 61 | */ |
Bob Moore | 7f07190 | 2009-03-19 09:37:47 +0800 | [diff] [blame] | 62 | static struct acpi_interface_info acpi_interfaces_supported[] = { |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 63 | /* Operating System Vendor Strings */ |
| 64 | |
Bob Moore | 7f07190 | 2009-03-19 09:37:47 +0800 | [diff] [blame] | 65 | {"Windows 2000", ACPI_OSI_WIN_2000}, /* Windows 2000 */ |
| 66 | {"Windows 2001", ACPI_OSI_WIN_XP}, /* Windows XP */ |
| 67 | {"Windows 2001 SP1", ACPI_OSI_WIN_XP_SP1}, /* Windows XP SP1 */ |
| 68 | {"Windows 2001.1", ACPI_OSI_WINSRV_2003}, /* Windows Server 2003 */ |
| 69 | {"Windows 2001 SP2", ACPI_OSI_WIN_XP_SP2}, /* Windows XP SP2 */ |
| 70 | {"Windows 2001.1 SP1", ACPI_OSI_WINSRV_2003_SP1}, /* Windows Server 2003 SP1 - Added 03/2006 */ |
| 71 | {"Windows 2006", ACPI_OSI_WIN_VISTA}, /* Windows Vista - Added 03/2006 */ |
Bob Moore | eb75255 | 2009-09-03 10:05:08 +0800 | [diff] [blame] | 72 | {"Windows 2006.1", ACPI_OSI_WINSRV_2008}, /* Windows Server 2008 - Added 09/2009 */ |
| 73 | {"Windows 2006 SP1", ACPI_OSI_WIN_VISTA_SP1}, /* Windows Vista SP1 - Added 09/2009 */ |
| 74 | {"Windows 2009", ACPI_OSI_WIN_7}, /* Windows 7 and Server 2008 R2 - Added 09/2009 */ |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 75 | |
| 76 | /* Feature Group Strings */ |
| 77 | |
Bob Moore | 7f07190 | 2009-03-19 09:37:47 +0800 | [diff] [blame] | 78 | {"Extended Address Space Descriptor", 0} |
| 79 | |
| 80 | /* |
| 81 | * All "optional" feature group strings (features that are implemented |
| 82 | * by the host) should be implemented in the host version of |
| 83 | * acpi_os_validate_interface and should not be added here. |
| 84 | */ |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 85 | }; |
| 86 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 87 | /******************************************************************************* |
| 88 | * |
| 89 | * FUNCTION: acpi_ut_osi_implementation |
| 90 | * |
| 91 | * PARAMETERS: walk_state - Current walk state |
| 92 | * |
| 93 | * RETURN: Status |
| 94 | * |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 95 | * DESCRIPTION: Implementation of the _OSI predefined control method |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 96 | * |
| 97 | ******************************************************************************/ |
| 98 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 99 | acpi_status acpi_ut_osi_implementation(struct acpi_walk_state *walk_state) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 100 | { |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 101 | acpi_status status; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 102 | union acpi_operand_object *string_desc; |
| 103 | union acpi_operand_object *return_desc; |
Bob Moore | c114e4b | 2009-02-23 11:00:00 +0800 | [diff] [blame] | 104 | u32 return_value; |
Bob Moore | 67a119f | 2008-06-10 13:42:13 +0800 | [diff] [blame] | 105 | u32 i; |
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_FUNCTION_TRACE(ut_osi_implementation); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 108 | |
| 109 | /* Validate the string input argument */ |
| 110 | |
| 111 | string_desc = walk_state->arguments[0].object; |
| 112 | if (!string_desc || (string_desc->common.type != ACPI_TYPE_STRING)) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 113 | return_ACPI_STATUS(AE_TYPE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 114 | } |
| 115 | |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 116 | /* Create a return object */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 117 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 118 | return_desc = acpi_ut_create_internal_object(ACPI_TYPE_INTEGER); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 119 | if (!return_desc) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 120 | return_ACPI_STATUS(AE_NO_MEMORY); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 121 | } |
| 122 | |
Bob Moore | c114e4b | 2009-02-23 11:00:00 +0800 | [diff] [blame] | 123 | /* Default return value is 0, NOT SUPPORTED */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 124 | |
Bob Moore | c114e4b | 2009-02-23 11:00:00 +0800 | [diff] [blame] | 125 | return_value = 0; |
Bob Moore | 52fc0b0 | 2006-10-02 00:00:00 -0400 | [diff] [blame] | 126 | |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 127 | /* Compare input string to static table of supported interfaces */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 128 | |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 129 | for (i = 0; i < ACPI_ARRAY_LENGTH(acpi_interfaces_supported); i++) { |
Bob Moore | ec41f19 | 2009-02-18 15:03:30 +0800 | [diff] [blame] | 130 | if (!ACPI_STRCMP(string_desc->string.pointer, |
Bob Moore | 7f07190 | 2009-03-19 09:37:47 +0800 | [diff] [blame] | 131 | acpi_interfaces_supported[i].name)) { |
| 132 | /* |
| 133 | * The interface is supported. |
| 134 | * Update the osi_data if necessary. We keep track of the latest |
| 135 | * version of Windows that has been requested by the BIOS. |
| 136 | */ |
| 137 | if (acpi_interfaces_supported[i].value > |
| 138 | acpi_gbl_osi_data) { |
| 139 | acpi_gbl_osi_data = |
| 140 | acpi_interfaces_supported[i].value; |
| 141 | } |
Bob Moore | c114e4b | 2009-02-23 11:00:00 +0800 | [diff] [blame] | 142 | |
| 143 | return_value = ACPI_UINT32_MAX; |
| 144 | goto exit; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 145 | } |
| 146 | } |
| 147 | |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 148 | /* |
| 149 | * Did not match the string in the static table, call the host OSL to |
| 150 | * check for a match with one of the optional strings (such as |
| 151 | * "Module Device", "3.0 Thermal Model", etc.) |
| 152 | */ |
| 153 | status = acpi_os_validate_interface(string_desc->string.pointer); |
| 154 | if (ACPI_SUCCESS(status)) { |
Bob Moore | c114e4b | 2009-02-23 11:00:00 +0800 | [diff] [blame] | 155 | |
| 156 | /* The interface is supported */ |
| 157 | |
| 158 | return_value = ACPI_UINT32_MAX; |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 159 | } |
| 160 | |
Bob Moore | c114e4b | 2009-02-23 11:00:00 +0800 | [diff] [blame] | 161 | exit: |
| 162 | ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, |
| 163 | "ACPI: BIOS _OSI(%s) is %ssupported\n", |
| 164 | string_desc->string.pointer, return_value == 0 ? "not " : "")); |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 165 | |
Bob Moore | c114e4b | 2009-02-23 11:00:00 +0800 | [diff] [blame] | 166 | /* Complete the return value */ |
| 167 | |
| 168 | return_desc->integer.value = return_value; |
| 169 | walk_state->return_desc = return_desc; |
| 170 | return_ACPI_STATUS (AE_OK); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 171 | } |
| 172 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 173 | /******************************************************************************* |
| 174 | * |
Len Brown | ae00d81 | 2007-05-29 18:43:33 -0400 | [diff] [blame] | 175 | * FUNCTION: acpi_osi_invalidate |
| 176 | * |
| 177 | * PARAMETERS: interface_string |
| 178 | * |
| 179 | * RETURN: Status |
| 180 | * |
| 181 | * DESCRIPTION: invalidate string in pre-defiend _OSI string list |
| 182 | * |
| 183 | ******************************************************************************/ |
| 184 | |
| 185 | acpi_status acpi_osi_invalidate(char *interface) |
| 186 | { |
| 187 | int i; |
| 188 | |
| 189 | for (i = 0; i < ACPI_ARRAY_LENGTH(acpi_interfaces_supported); i++) { |
Bob Moore | 7f07190 | 2009-03-19 09:37:47 +0800 | [diff] [blame] | 190 | if (!ACPI_STRCMP(interface, acpi_interfaces_supported[i].name)) { |
| 191 | *acpi_interfaces_supported[i].name = '\0'; |
Len Brown | ae00d81 | 2007-05-29 18:43:33 -0400 | [diff] [blame] | 192 | return AE_OK; |
| 193 | } |
| 194 | } |
| 195 | return AE_NOT_FOUND; |
| 196 | } |
| 197 | |
| 198 | /******************************************************************************* |
| 199 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 200 | * FUNCTION: acpi_ut_evaluate_object |
| 201 | * |
| 202 | * PARAMETERS: prefix_node - Starting node |
| 203 | * Path - Path to object from starting node |
| 204 | * expected_return_types - Bitmap of allowed return types |
| 205 | * return_desc - Where a return value is stored |
| 206 | * |
| 207 | * RETURN: Status |
| 208 | * |
| 209 | * DESCRIPTION: Evaluates a namespace object and verifies the type of the |
Bob Moore | 15b8dd5 | 2009-06-29 13:39:29 +0800 | [diff] [blame] | 210 | * return object. Common code that simplifies accessing objects |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 211 | * that have required return objects of fixed types. |
| 212 | * |
| 213 | * NOTE: Internal function, no parameter validation |
| 214 | * |
| 215 | ******************************************************************************/ |
| 216 | |
| 217 | acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 218 | acpi_ut_evaluate_object(struct acpi_namespace_node *prefix_node, |
| 219 | char *path, |
| 220 | u32 expected_return_btypes, |
| 221 | union acpi_operand_object **return_desc) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 222 | { |
Bob Moore | 4119532 | 2006-05-26 16:36:00 -0400 | [diff] [blame] | 223 | struct acpi_evaluate_info *info; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 224 | acpi_status status; |
| 225 | u32 return_btype; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 226 | |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 227 | ACPI_FUNCTION_TRACE(ut_evaluate_object); |
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 | /* Allocate the evaluation information block */ |
| 230 | |
| 231 | info = ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_evaluate_info)); |
| 232 | if (!info) { |
| 233 | return_ACPI_STATUS(AE_NO_MEMORY); |
| 234 | } |
| 235 | |
| 236 | info->prefix_node = prefix_node; |
| 237 | info->pathname = path; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 238 | |
| 239 | /* Evaluate the object/method */ |
| 240 | |
Bob Moore | 4119532 | 2006-05-26 16:36:00 -0400 | [diff] [blame] | 241 | status = acpi_ns_evaluate(info); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 242 | if (ACPI_FAILURE(status)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 243 | if (status == AE_NOT_FOUND) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 244 | ACPI_DEBUG_PRINT((ACPI_DB_EXEC, |
| 245 | "[%4.4s.%s] was not found\n", |
| 246 | acpi_ut_get_node_name(prefix_node), |
| 247 | path)); |
| 248 | } else { |
Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 249 | ACPI_ERROR_METHOD("Method execution failed", |
| 250 | prefix_node, path, status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 251 | } |
| 252 | |
Bob Moore | 4119532 | 2006-05-26 16:36:00 -0400 | [diff] [blame] | 253 | goto cleanup; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 254 | } |
| 255 | |
| 256 | /* Did we get a return object? */ |
| 257 | |
Bob Moore | 4119532 | 2006-05-26 16:36:00 -0400 | [diff] [blame] | 258 | if (!info->return_object) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 259 | if (expected_return_btypes) { |
Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 260 | ACPI_ERROR_METHOD("No object was returned from", |
| 261 | prefix_node, path, AE_NOT_EXIST); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 262 | |
Bob Moore | 4119532 | 2006-05-26 16:36:00 -0400 | [diff] [blame] | 263 | status = AE_NOT_EXIST; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 264 | } |
| 265 | |
Bob Moore | 4119532 | 2006-05-26 16:36:00 -0400 | [diff] [blame] | 266 | goto cleanup; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 267 | } |
| 268 | |
| 269 | /* Map the return object type to the bitmapped type */ |
| 270 | |
Bob Moore | 3371c19 | 2009-02-18 14:44:03 +0800 | [diff] [blame] | 271 | switch ((info->return_object)->common.type) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 272 | case ACPI_TYPE_INTEGER: |
| 273 | return_btype = ACPI_BTYPE_INTEGER; |
| 274 | break; |
| 275 | |
| 276 | case ACPI_TYPE_BUFFER: |
| 277 | return_btype = ACPI_BTYPE_BUFFER; |
| 278 | break; |
| 279 | |
| 280 | case ACPI_TYPE_STRING: |
| 281 | return_btype = ACPI_BTYPE_STRING; |
| 282 | break; |
| 283 | |
| 284 | case ACPI_TYPE_PACKAGE: |
| 285 | return_btype = ACPI_BTYPE_PACKAGE; |
| 286 | break; |
| 287 | |
| 288 | default: |
| 289 | return_btype = 0; |
| 290 | break; |
| 291 | } |
| 292 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 293 | if ((acpi_gbl_enable_interpreter_slack) && (!expected_return_btypes)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 294 | /* |
Bob Moore | 15b8dd5 | 2009-06-29 13:39:29 +0800 | [diff] [blame] | 295 | * We received a return object, but one was not expected. This can |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 296 | * happen frequently if the "implicit return" feature is enabled. |
| 297 | * Just delete the return object and return AE_OK. |
| 298 | */ |
Bob Moore | 4119532 | 2006-05-26 16:36:00 -0400 | [diff] [blame] | 299 | acpi_ut_remove_reference(info->return_object); |
| 300 | goto cleanup; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 301 | } |
| 302 | |
| 303 | /* Is the return object one of the expected types? */ |
| 304 | |
| 305 | if (!(expected_return_btypes & return_btype)) { |
Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 306 | ACPI_ERROR_METHOD("Return object type is incorrect", |
| 307 | prefix_node, path, AE_TYPE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 308 | |
Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 309 | ACPI_ERROR((AE_INFO, |
Bob Moore | f6a22b0 | 2010-03-05 17:56:40 +0800 | [diff] [blame] | 310 | "Type returned from %s was incorrect: %s, expected Btypes: 0x%X", |
Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 311 | path, |
Bob Moore | 4119532 | 2006-05-26 16:36:00 -0400 | [diff] [blame] | 312 | acpi_ut_get_object_type_name(info->return_object), |
Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 313 | expected_return_btypes)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 314 | |
| 315 | /* On error exit, we must delete the return object */ |
| 316 | |
Bob Moore | 4119532 | 2006-05-26 16:36:00 -0400 | [diff] [blame] | 317 | acpi_ut_remove_reference(info->return_object); |
| 318 | status = AE_TYPE; |
| 319 | goto cleanup; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 320 | } |
| 321 | |
| 322 | /* Object type is OK, return it */ |
| 323 | |
Bob Moore | 4119532 | 2006-05-26 16:36:00 -0400 | [diff] [blame] | 324 | *return_desc = info->return_object; |
| 325 | |
| 326 | cleanup: |
| 327 | ACPI_FREE(info); |
| 328 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 329 | } |
| 330 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 331 | /******************************************************************************* |
| 332 | * |
| 333 | * FUNCTION: acpi_ut_evaluate_numeric_object |
| 334 | * |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 335 | * PARAMETERS: object_name - Object name to be evaluated |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 336 | * device_node - Node for the device |
Bob Moore | 15b8dd5 | 2009-06-29 13:39:29 +0800 | [diff] [blame] | 337 | * Value - Where the value is returned |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 338 | * |
| 339 | * RETURN: Status |
| 340 | * |
| 341 | * DESCRIPTION: Evaluates a numeric namespace object for a selected device |
Bob Moore | 15b8dd5 | 2009-06-29 13:39:29 +0800 | [diff] [blame] | 342 | * and stores result in *Value. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 343 | * |
| 344 | * NOTE: Internal function, no parameter validation |
| 345 | * |
| 346 | ******************************************************************************/ |
| 347 | |
| 348 | acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 349 | acpi_ut_evaluate_numeric_object(char *object_name, |
| 350 | struct acpi_namespace_node *device_node, |
Bob Moore | 5df7e6c | 2010-01-21 10:06:32 +0800 | [diff] [blame] | 351 | u64 *value) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 352 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 353 | union acpi_operand_object *obj_desc; |
| 354 | acpi_status status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 355 | |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 356 | ACPI_FUNCTION_TRACE(ut_evaluate_numeric_object); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 357 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 358 | status = acpi_ut_evaluate_object(device_node, object_name, |
| 359 | ACPI_BTYPE_INTEGER, &obj_desc); |
| 360 | if (ACPI_FAILURE(status)) { |
| 361 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 362 | } |
| 363 | |
| 364 | /* Get the returned Integer */ |
| 365 | |
Bob Moore | 15b8dd5 | 2009-06-29 13:39:29 +0800 | [diff] [blame] | 366 | *value = obj_desc->integer.value; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 367 | |
| 368 | /* On exit, we must delete the return object */ |
| 369 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 370 | acpi_ut_remove_reference(obj_desc); |
| 371 | return_ACPI_STATUS(status); |
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 | * |
| 376 | * FUNCTION: acpi_ut_execute_STA |
| 377 | * |
| 378 | * PARAMETERS: device_node - Node for the device |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 379 | * Flags - Where the status flags are returned |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 380 | * |
| 381 | * RETURN: Status |
| 382 | * |
| 383 | * DESCRIPTION: Executes _STA for selected device and stores results in |
| 384 | * *Flags. |
| 385 | * |
| 386 | * NOTE: Internal function, no parameter validation |
| 387 | * |
| 388 | ******************************************************************************/ |
| 389 | |
| 390 | acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 391 | acpi_ut_execute_STA(struct acpi_namespace_node *device_node, u32 * flags) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 392 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 393 | union acpi_operand_object *obj_desc; |
| 394 | acpi_status status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 395 | |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 396 | ACPI_FUNCTION_TRACE(ut_execute_STA); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 397 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 398 | status = acpi_ut_evaluate_object(device_node, METHOD_NAME__STA, |
| 399 | ACPI_BTYPE_INTEGER, &obj_desc); |
| 400 | if (ACPI_FAILURE(status)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 401 | if (AE_NOT_FOUND == status) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 402 | ACPI_DEBUG_PRINT((ACPI_DB_EXEC, |
| 403 | "_STA on %4.4s was not found, assuming device is present\n", |
| 404 | acpi_ut_get_node_name(device_node))); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 405 | |
Bob Moore | defba1d | 2005-12-16 17:05:00 -0500 | [diff] [blame] | 406 | *flags = ACPI_UINT32_MAX; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 407 | status = AE_OK; |
| 408 | } |
| 409 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 410 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 411 | } |
| 412 | |
| 413 | /* Extract the status flags */ |
| 414 | |
| 415 | *flags = (u32) obj_desc->integer.value; |
| 416 | |
| 417 | /* On exit, we must delete the return object */ |
| 418 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 419 | acpi_ut_remove_reference(obj_desc); |
| 420 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 421 | } |
| 422 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 423 | /******************************************************************************* |
| 424 | * |
Bob Moore | 15b8dd5 | 2009-06-29 13:39:29 +0800 | [diff] [blame] | 425 | * FUNCTION: acpi_ut_execute_power_methods |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 426 | * |
| 427 | * PARAMETERS: device_node - Node for the device |
Bob Moore | 15b8dd5 | 2009-06-29 13:39:29 +0800 | [diff] [blame] | 428 | * method_names - Array of power method names |
| 429 | * method_count - Number of methods to execute |
| 430 | * out_values - Where the power method values are returned |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 431 | * |
Bob Moore | 15b8dd5 | 2009-06-29 13:39:29 +0800 | [diff] [blame] | 432 | * RETURN: Status, out_values |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 433 | * |
Bob Moore | 15b8dd5 | 2009-06-29 13:39:29 +0800 | [diff] [blame] | 434 | * DESCRIPTION: Executes the specified power methods for the device and returns |
| 435 | * the result(s). |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 436 | * |
| 437 | * NOTE: Internal function, no parameter validation |
| 438 | * |
Bob Moore | 15b8dd5 | 2009-06-29 13:39:29 +0800 | [diff] [blame] | 439 | ******************************************************************************/ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 440 | |
| 441 | acpi_status |
Bob Moore | 15b8dd5 | 2009-06-29 13:39:29 +0800 | [diff] [blame] | 442 | acpi_ut_execute_power_methods(struct acpi_namespace_node *device_node, |
| 443 | const char **method_names, |
| 444 | u8 method_count, u8 *out_values) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 445 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 446 | union acpi_operand_object *obj_desc; |
| 447 | acpi_status status; |
Bob Moore | 15b8dd5 | 2009-06-29 13:39:29 +0800 | [diff] [blame] | 448 | acpi_status final_status = AE_NOT_FOUND; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 449 | u32 i; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 450 | |
Bob Moore | 15b8dd5 | 2009-06-29 13:39:29 +0800 | [diff] [blame] | 451 | ACPI_FUNCTION_TRACE(ut_execute_power_methods); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 452 | |
Bob Moore | 15b8dd5 | 2009-06-29 13:39:29 +0800 | [diff] [blame] | 453 | for (i = 0; i < method_count; i++) { |
| 454 | /* |
| 455 | * Execute the power method (_sx_d or _sx_w). The only allowable |
| 456 | * return type is an Integer. |
| 457 | */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 458 | status = acpi_ut_evaluate_object(device_node, |
Bob Moore | defba1d | 2005-12-16 17:05:00 -0500 | [diff] [blame] | 459 | ACPI_CAST_PTR(char, |
Bob Moore | 15b8dd5 | 2009-06-29 13:39:29 +0800 | [diff] [blame] | 460 | method_names[i]), |
Bob Moore | defba1d | 2005-12-16 17:05:00 -0500 | [diff] [blame] | 461 | ACPI_BTYPE_INTEGER, &obj_desc); |
Bob Moore | 15b8dd5 | 2009-06-29 13:39:29 +0800 | [diff] [blame] | 462 | if (ACPI_SUCCESS(status)) { |
| 463 | out_values[i] = (u8)obj_desc->integer.value; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 464 | |
| 465 | /* Delete the return object */ |
| 466 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 467 | acpi_ut_remove_reference(obj_desc); |
Bob Moore | 15b8dd5 | 2009-06-29 13:39:29 +0800 | [diff] [blame] | 468 | final_status = AE_OK; /* At least one value is valid */ |
| 469 | continue; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 470 | } |
Bob Moore | 15b8dd5 | 2009-06-29 13:39:29 +0800 | [diff] [blame] | 471 | |
| 472 | out_values[i] = ACPI_UINT8_MAX; |
| 473 | if (status == AE_NOT_FOUND) { |
| 474 | continue; /* Ignore if not found */ |
| 475 | } |
| 476 | |
| 477 | ACPI_DEBUG_PRINT((ACPI_DB_EXEC, |
| 478 | "Failed %s on Device %4.4s, %s\n", |
| 479 | ACPI_CAST_PTR(char, method_names[i]), |
| 480 | acpi_ut_get_node_name(device_node), |
| 481 | acpi_format_exception(status))); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 482 | } |
| 483 | |
Bob Moore | 15b8dd5 | 2009-06-29 13:39:29 +0800 | [diff] [blame] | 484 | return_ACPI_STATUS(final_status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 485 | } |