blob: 5d54e36ab4536eb151acf54cf4a11c89dd9796de [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/******************************************************************************
2 *
3 * Module Name: uteval - Object evaluation
4 *
5 *****************************************************************************/
6
7/*
Len Brown75a44ce2008-04-23 23:00:13 -04008 * Copyright (C) 2000 - 2008, Intel Corp.
Linus Torvalds1da177e2005-04-16 15:20:36 -07009 * 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 Torvalds1da177e2005-04-16 15:20:36 -070044#include <acpi/acpi.h>
Len Browne2f7a772009-01-09 00:30:03 -050045#include "accommon.h"
46#include "acnamesp.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070047
Linus Torvalds1da177e2005-04-16 15:20:36 -070048#define _COMPONENT ACPI_UTILITIES
Len Brown4be44fc2005-08-05 00:44:28 -040049ACPI_MODULE_NAME("uteval")
Linus Torvalds1da177e2005-04-16 15:20:36 -070050
Bob Mooreb229cf92006-04-21 17:15:00 -040051/*
52 * Strings supported by the _OSI predefined (internal) method.
Bob Moore7f071902009-03-19 09:37:47 +080053 *
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 Mooreb229cf92006-04-21 17:15:00 -040061 */
Bob Moore7f071902009-03-19 09:37:47 +080062static struct acpi_interface_info acpi_interfaces_supported[] = {
Bob Mooreb229cf92006-04-21 17:15:00 -040063 /* Operating System Vendor Strings */
64
Bob Moore7f071902009-03-19 09:37:47 +080065 {"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 Mooreeb752552009-09-03 10:05:08 +080072 {"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 Mooreb229cf92006-04-21 17:15:00 -040075
76 /* Feature Group Strings */
77
Bob Moore7f071902009-03-19 09:37:47 +080078 {"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 Mooreb229cf92006-04-21 17:15:00 -040085};
86
Linus Torvalds1da177e2005-04-16 15:20:36 -070087/*******************************************************************************
88 *
89 * FUNCTION: acpi_ut_osi_implementation
90 *
91 * PARAMETERS: walk_state - Current walk state
92 *
93 * RETURN: Status
94 *
Bob Mooreb229cf92006-04-21 17:15:00 -040095 * DESCRIPTION: Implementation of the _OSI predefined control method
Linus Torvalds1da177e2005-04-16 15:20:36 -070096 *
97 ******************************************************************************/
98
Len Brown4be44fc2005-08-05 00:44:28 -040099acpi_status acpi_ut_osi_implementation(struct acpi_walk_state *walk_state)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700100{
Bob Mooreb229cf92006-04-21 17:15:00 -0400101 acpi_status status;
Len Brown4be44fc2005-08-05 00:44:28 -0400102 union acpi_operand_object *string_desc;
103 union acpi_operand_object *return_desc;
Bob Moorec114e4b2009-02-23 11:00:00 +0800104 u32 return_value;
Bob Moore67a119f2008-06-10 13:42:13 +0800105 u32 i;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700106
Bob Mooreb229cf92006-04-21 17:15:00 -0400107 ACPI_FUNCTION_TRACE(ut_osi_implementation);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700108
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 Brown4be44fc2005-08-05 00:44:28 -0400113 return_ACPI_STATUS(AE_TYPE);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700114 }
115
Bob Mooreb229cf92006-04-21 17:15:00 -0400116 /* Create a return object */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700117
Len Brown4be44fc2005-08-05 00:44:28 -0400118 return_desc = acpi_ut_create_internal_object(ACPI_TYPE_INTEGER);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700119 if (!return_desc) {
Len Brown4be44fc2005-08-05 00:44:28 -0400120 return_ACPI_STATUS(AE_NO_MEMORY);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700121 }
122
Bob Moorec114e4b2009-02-23 11:00:00 +0800123 /* Default return value is 0, NOT SUPPORTED */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700124
Bob Moorec114e4b2009-02-23 11:00:00 +0800125 return_value = 0;
Bob Moore52fc0b02006-10-02 00:00:00 -0400126
Bob Mooreb229cf92006-04-21 17:15:00 -0400127 /* Compare input string to static table of supported interfaces */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700128
Bob Mooreb229cf92006-04-21 17:15:00 -0400129 for (i = 0; i < ACPI_ARRAY_LENGTH(acpi_interfaces_supported); i++) {
Bob Mooreec41f192009-02-18 15:03:30 +0800130 if (!ACPI_STRCMP(string_desc->string.pointer,
Bob Moore7f071902009-03-19 09:37:47 +0800131 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 Moorec114e4b2009-02-23 11:00:00 +0800142
143 return_value = ACPI_UINT32_MAX;
144 goto exit;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700145 }
146 }
147
Bob Mooreb229cf92006-04-21 17:15:00 -0400148 /*
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 Moorec114e4b2009-02-23 11:00:00 +0800155
156 /* The interface is supported */
157
158 return_value = ACPI_UINT32_MAX;
Bob Mooreb229cf92006-04-21 17:15:00 -0400159 }
160
Bob Moorec114e4b2009-02-23 11:00:00 +0800161exit:
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 Mooreb229cf92006-04-21 17:15:00 -0400165
Bob Moorec114e4b2009-02-23 11:00:00 +0800166 /* 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 Torvalds1da177e2005-04-16 15:20:36 -0700171}
172
Linus Torvalds1da177e2005-04-16 15:20:36 -0700173/*******************************************************************************
174 *
Len Brownae00d812007-05-29 18:43:33 -0400175 * 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
185acpi_status acpi_osi_invalidate(char *interface)
186{
187 int i;
188
189 for (i = 0; i < ACPI_ARRAY_LENGTH(acpi_interfaces_supported); i++) {
Bob Moore7f071902009-03-19 09:37:47 +0800190 if (!ACPI_STRCMP(interface, acpi_interfaces_supported[i].name)) {
191 *acpi_interfaces_supported[i].name = '\0';
Len Brownae00d812007-05-29 18:43:33 -0400192 return AE_OK;
193 }
194 }
195 return AE_NOT_FOUND;
196}
197
198/*******************************************************************************
199 *
Linus Torvalds1da177e2005-04-16 15:20:36 -0700200 * 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 Moore15b8dd52009-06-29 13:39:29 +0800210 * return object. Common code that simplifies accessing objects
Linus Torvalds1da177e2005-04-16 15:20:36 -0700211 * that have required return objects of fixed types.
212 *
213 * NOTE: Internal function, no parameter validation
214 *
215 ******************************************************************************/
216
217acpi_status
Len Brown4be44fc2005-08-05 00:44:28 -0400218acpi_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 Torvalds1da177e2005-04-16 15:20:36 -0700222{
Bob Moore41195322006-05-26 16:36:00 -0400223 struct acpi_evaluate_info *info;
Len Brown4be44fc2005-08-05 00:44:28 -0400224 acpi_status status;
225 u32 return_btype;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700226
Bob Mooreb229cf92006-04-21 17:15:00 -0400227 ACPI_FUNCTION_TRACE(ut_evaluate_object);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700228
Bob Moore41195322006-05-26 16:36:00 -0400229 /* 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 Torvalds1da177e2005-04-16 15:20:36 -0700238
239 /* Evaluate the object/method */
240
Bob Moore41195322006-05-26 16:36:00 -0400241 status = acpi_ns_evaluate(info);
Len Brown4be44fc2005-08-05 00:44:28 -0400242 if (ACPI_FAILURE(status)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700243 if (status == AE_NOT_FOUND) {
Len Brown4be44fc2005-08-05 00:44:28 -0400244 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 Mooreb8e4d892006-01-27 16:43:00 -0500249 ACPI_ERROR_METHOD("Method execution failed",
250 prefix_node, path, status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700251 }
252
Bob Moore41195322006-05-26 16:36:00 -0400253 goto cleanup;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700254 }
255
256 /* Did we get a return object? */
257
Bob Moore41195322006-05-26 16:36:00 -0400258 if (!info->return_object) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700259 if (expected_return_btypes) {
Bob Mooreb8e4d892006-01-27 16:43:00 -0500260 ACPI_ERROR_METHOD("No object was returned from",
261 prefix_node, path, AE_NOT_EXIST);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700262
Bob Moore41195322006-05-26 16:36:00 -0400263 status = AE_NOT_EXIST;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700264 }
265
Bob Moore41195322006-05-26 16:36:00 -0400266 goto cleanup;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700267 }
268
269 /* Map the return object type to the bitmapped type */
270
Bob Moore3371c192009-02-18 14:44:03 +0800271 switch ((info->return_object)->common.type) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700272 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 Brown4be44fc2005-08-05 00:44:28 -0400293 if ((acpi_gbl_enable_interpreter_slack) && (!expected_return_btypes)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700294 /*
Bob Moore15b8dd52009-06-29 13:39:29 +0800295 * We received a return object, but one was not expected. This can
Linus Torvalds1da177e2005-04-16 15:20:36 -0700296 * happen frequently if the "implicit return" feature is enabled.
297 * Just delete the return object and return AE_OK.
298 */
Bob Moore41195322006-05-26 16:36:00 -0400299 acpi_ut_remove_reference(info->return_object);
300 goto cleanup;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700301 }
302
303 /* Is the return object one of the expected types? */
304
305 if (!(expected_return_btypes & return_btype)) {
Bob Mooreb8e4d892006-01-27 16:43:00 -0500306 ACPI_ERROR_METHOD("Return object type is incorrect",
307 prefix_node, path, AE_TYPE);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700308
Bob Mooreb8e4d892006-01-27 16:43:00 -0500309 ACPI_ERROR((AE_INFO,
310 "Type returned from %s was incorrect: %s, expected Btypes: %X",
311 path,
Bob Moore41195322006-05-26 16:36:00 -0400312 acpi_ut_get_object_type_name(info->return_object),
Bob Mooreb8e4d892006-01-27 16:43:00 -0500313 expected_return_btypes));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700314
315 /* On error exit, we must delete the return object */
316
Bob Moore41195322006-05-26 16:36:00 -0400317 acpi_ut_remove_reference(info->return_object);
318 status = AE_TYPE;
319 goto cleanup;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700320 }
321
322 /* Object type is OK, return it */
323
Bob Moore41195322006-05-26 16:36:00 -0400324 *return_desc = info->return_object;
325
326 cleanup:
327 ACPI_FREE(info);
328 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700329}
330
Linus Torvalds1da177e2005-04-16 15:20:36 -0700331/*******************************************************************************
332 *
333 * FUNCTION: acpi_ut_evaluate_numeric_object
334 *
Robert Moore44f6c012005-04-18 22:49:35 -0400335 * PARAMETERS: object_name - Object name to be evaluated
Linus Torvalds1da177e2005-04-16 15:20:36 -0700336 * device_node - Node for the device
Bob Moore15b8dd52009-06-29 13:39:29 +0800337 * Value - Where the value is returned
Linus Torvalds1da177e2005-04-16 15:20:36 -0700338 *
339 * RETURN: Status
340 *
341 * DESCRIPTION: Evaluates a numeric namespace object for a selected device
Bob Moore15b8dd52009-06-29 13:39:29 +0800342 * and stores result in *Value.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700343 *
344 * NOTE: Internal function, no parameter validation
345 *
346 ******************************************************************************/
347
348acpi_status
Len Brown4be44fc2005-08-05 00:44:28 -0400349acpi_ut_evaluate_numeric_object(char *object_name,
350 struct acpi_namespace_node *device_node,
Bob Moore15b8dd52009-06-29 13:39:29 +0800351 acpi_integer *value)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700352{
Len Brown4be44fc2005-08-05 00:44:28 -0400353 union acpi_operand_object *obj_desc;
354 acpi_status status;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700355
Bob Mooreb229cf92006-04-21 17:15:00 -0400356 ACPI_FUNCTION_TRACE(ut_evaluate_numeric_object);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700357
Len Brown4be44fc2005-08-05 00:44:28 -0400358 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 Torvalds1da177e2005-04-16 15:20:36 -0700362 }
363
364 /* Get the returned Integer */
365
Bob Moore15b8dd52009-06-29 13:39:29 +0800366 *value = obj_desc->integer.value;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700367
368 /* On exit, we must delete the return object */
369
Len Brown4be44fc2005-08-05 00:44:28 -0400370 acpi_ut_remove_reference(obj_desc);
371 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700372}
373
Linus Torvalds1da177e2005-04-16 15:20:36 -0700374/*******************************************************************************
375 *
376 * FUNCTION: acpi_ut_execute_STA
377 *
378 * PARAMETERS: device_node - Node for the device
Robert Moore44f6c012005-04-18 22:49:35 -0400379 * Flags - Where the status flags are returned
Linus Torvalds1da177e2005-04-16 15:20:36 -0700380 *
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
390acpi_status
Len Brown4be44fc2005-08-05 00:44:28 -0400391acpi_ut_execute_STA(struct acpi_namespace_node *device_node, u32 * flags)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700392{
Len Brown4be44fc2005-08-05 00:44:28 -0400393 union acpi_operand_object *obj_desc;
394 acpi_status status;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700395
Bob Mooreb229cf92006-04-21 17:15:00 -0400396 ACPI_FUNCTION_TRACE(ut_execute_STA);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700397
Len Brown4be44fc2005-08-05 00:44:28 -0400398 status = acpi_ut_evaluate_object(device_node, METHOD_NAME__STA,
399 ACPI_BTYPE_INTEGER, &obj_desc);
400 if (ACPI_FAILURE(status)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700401 if (AE_NOT_FOUND == status) {
Len Brown4be44fc2005-08-05 00:44:28 -0400402 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 Torvalds1da177e2005-04-16 15:20:36 -0700405
Bob Mooredefba1d2005-12-16 17:05:00 -0500406 *flags = ACPI_UINT32_MAX;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700407 status = AE_OK;
408 }
409
Len Brown4be44fc2005-08-05 00:44:28 -0400410 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700411 }
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 Brown4be44fc2005-08-05 00:44:28 -0400419 acpi_ut_remove_reference(obj_desc);
420 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700421}
422
Linus Torvalds1da177e2005-04-16 15:20:36 -0700423/*******************************************************************************
424 *
Bob Moore15b8dd52009-06-29 13:39:29 +0800425 * FUNCTION: acpi_ut_execute_power_methods
Linus Torvalds1da177e2005-04-16 15:20:36 -0700426 *
427 * PARAMETERS: device_node - Node for the device
Bob Moore15b8dd52009-06-29 13:39:29 +0800428 * 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 Torvalds1da177e2005-04-16 15:20:36 -0700431 *
Bob Moore15b8dd52009-06-29 13:39:29 +0800432 * RETURN: Status, out_values
Linus Torvalds1da177e2005-04-16 15:20:36 -0700433 *
Bob Moore15b8dd52009-06-29 13:39:29 +0800434 * DESCRIPTION: Executes the specified power methods for the device and returns
435 * the result(s).
Linus Torvalds1da177e2005-04-16 15:20:36 -0700436 *
437 * NOTE: Internal function, no parameter validation
438 *
Bob Moore15b8dd52009-06-29 13:39:29 +0800439******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700440
441acpi_status
Bob Moore15b8dd52009-06-29 13:39:29 +0800442acpi_ut_execute_power_methods(struct acpi_namespace_node *device_node,
443 const char **method_names,
444 u8 method_count, u8 *out_values)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700445{
Len Brown4be44fc2005-08-05 00:44:28 -0400446 union acpi_operand_object *obj_desc;
447 acpi_status status;
Bob Moore15b8dd52009-06-29 13:39:29 +0800448 acpi_status final_status = AE_NOT_FOUND;
Len Brown4be44fc2005-08-05 00:44:28 -0400449 u32 i;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700450
Bob Moore15b8dd52009-06-29 13:39:29 +0800451 ACPI_FUNCTION_TRACE(ut_execute_power_methods);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700452
Bob Moore15b8dd52009-06-29 13:39:29 +0800453 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 Brown4be44fc2005-08-05 00:44:28 -0400458 status = acpi_ut_evaluate_object(device_node,
Bob Mooredefba1d2005-12-16 17:05:00 -0500459 ACPI_CAST_PTR(char,
Bob Moore15b8dd52009-06-29 13:39:29 +0800460 method_names[i]),
Bob Mooredefba1d2005-12-16 17:05:00 -0500461 ACPI_BTYPE_INTEGER, &obj_desc);
Bob Moore15b8dd52009-06-29 13:39:29 +0800462 if (ACPI_SUCCESS(status)) {
463 out_values[i] = (u8)obj_desc->integer.value;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700464
465 /* Delete the return object */
466
Len Brown4be44fc2005-08-05 00:44:28 -0400467 acpi_ut_remove_reference(obj_desc);
Bob Moore15b8dd52009-06-29 13:39:29 +0800468 final_status = AE_OK; /* At least one value is valid */
469 continue;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700470 }
Bob Moore15b8dd52009-06-29 13:39:29 +0800471
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 Torvalds1da177e2005-04-16 15:20:36 -0700482 }
483
Bob Moore15b8dd52009-06-29 13:39:29 +0800484 return_ACPI_STATUS(final_status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700485}