blob: 5503307b8bb70c1c450ce9410c164a47f85dd1b7 [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 Mooreb229cf92006-04-21 17:15:00 -040072
73 /* Feature Group Strings */
74
Bob Moore7f071902009-03-19 09:37:47 +080075 {"Extended Address Space Descriptor", 0}
76
77 /*
78 * All "optional" feature group strings (features that are implemented
79 * by the host) should be implemented in the host version of
80 * acpi_os_validate_interface and should not be added here.
81 */
Bob Mooreb229cf92006-04-21 17:15:00 -040082};
83
Linus Torvalds1da177e2005-04-16 15:20:36 -070084/*******************************************************************************
85 *
86 * FUNCTION: acpi_ut_osi_implementation
87 *
88 * PARAMETERS: walk_state - Current walk state
89 *
90 * RETURN: Status
91 *
Bob Mooreb229cf92006-04-21 17:15:00 -040092 * DESCRIPTION: Implementation of the _OSI predefined control method
Linus Torvalds1da177e2005-04-16 15:20:36 -070093 *
94 ******************************************************************************/
95
Len Brown4be44fc2005-08-05 00:44:28 -040096acpi_status acpi_ut_osi_implementation(struct acpi_walk_state *walk_state)
Linus Torvalds1da177e2005-04-16 15:20:36 -070097{
Bob Mooreb229cf92006-04-21 17:15:00 -040098 acpi_status status;
Len Brown4be44fc2005-08-05 00:44:28 -040099 union acpi_operand_object *string_desc;
100 union acpi_operand_object *return_desc;
Bob Moorec114e4b2009-02-23 11:00:00 +0800101 u32 return_value;
Bob Moore67a119f2008-06-10 13:42:13 +0800102 u32 i;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700103
Bob Mooreb229cf92006-04-21 17:15:00 -0400104 ACPI_FUNCTION_TRACE(ut_osi_implementation);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700105
106 /* Validate the string input argument */
107
108 string_desc = walk_state->arguments[0].object;
109 if (!string_desc || (string_desc->common.type != ACPI_TYPE_STRING)) {
Len Brown4be44fc2005-08-05 00:44:28 -0400110 return_ACPI_STATUS(AE_TYPE);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700111 }
112
Bob Mooreb229cf92006-04-21 17:15:00 -0400113 /* Create a return object */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700114
Len Brown4be44fc2005-08-05 00:44:28 -0400115 return_desc = acpi_ut_create_internal_object(ACPI_TYPE_INTEGER);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700116 if (!return_desc) {
Len Brown4be44fc2005-08-05 00:44:28 -0400117 return_ACPI_STATUS(AE_NO_MEMORY);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700118 }
119
Bob Moorec114e4b2009-02-23 11:00:00 +0800120 /* Default return value is 0, NOT SUPPORTED */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700121
Bob Moorec114e4b2009-02-23 11:00:00 +0800122 return_value = 0;
Bob Moore52fc0b02006-10-02 00:00:00 -0400123
Bob Mooreb229cf92006-04-21 17:15:00 -0400124 /* Compare input string to static table of supported interfaces */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700125
Bob Mooreb229cf92006-04-21 17:15:00 -0400126 for (i = 0; i < ACPI_ARRAY_LENGTH(acpi_interfaces_supported); i++) {
Bob Mooreec41f192009-02-18 15:03:30 +0800127 if (!ACPI_STRCMP(string_desc->string.pointer,
Bob Moore7f071902009-03-19 09:37:47 +0800128 acpi_interfaces_supported[i].name)) {
129 /*
130 * The interface is supported.
131 * Update the osi_data if necessary. We keep track of the latest
132 * version of Windows that has been requested by the BIOS.
133 */
134 if (acpi_interfaces_supported[i].value >
135 acpi_gbl_osi_data) {
136 acpi_gbl_osi_data =
137 acpi_interfaces_supported[i].value;
138 }
Bob Moorec114e4b2009-02-23 11:00:00 +0800139
140 return_value = ACPI_UINT32_MAX;
141 goto exit;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700142 }
143 }
144
Bob Mooreb229cf92006-04-21 17:15:00 -0400145 /*
146 * Did not match the string in the static table, call the host OSL to
147 * check for a match with one of the optional strings (such as
148 * "Module Device", "3.0 Thermal Model", etc.)
149 */
150 status = acpi_os_validate_interface(string_desc->string.pointer);
151 if (ACPI_SUCCESS(status)) {
Bob Moorec114e4b2009-02-23 11:00:00 +0800152
153 /* The interface is supported */
154
155 return_value = ACPI_UINT32_MAX;
Bob Mooreb229cf92006-04-21 17:15:00 -0400156 }
157
Bob Moorec114e4b2009-02-23 11:00:00 +0800158exit:
159 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO,
160 "ACPI: BIOS _OSI(%s) is %ssupported\n",
161 string_desc->string.pointer, return_value == 0 ? "not " : ""));
Bob Mooreb229cf92006-04-21 17:15:00 -0400162
Bob Moorec114e4b2009-02-23 11:00:00 +0800163 /* Complete the return value */
164
165 return_desc->integer.value = return_value;
166 walk_state->return_desc = return_desc;
167 return_ACPI_STATUS (AE_OK);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700168}
169
Linus Torvalds1da177e2005-04-16 15:20:36 -0700170/*******************************************************************************
171 *
Len Brownae00d812007-05-29 18:43:33 -0400172 * FUNCTION: acpi_osi_invalidate
173 *
174 * PARAMETERS: interface_string
175 *
176 * RETURN: Status
177 *
178 * DESCRIPTION: invalidate string in pre-defiend _OSI string list
179 *
180 ******************************************************************************/
181
182acpi_status acpi_osi_invalidate(char *interface)
183{
184 int i;
185
186 for (i = 0; i < ACPI_ARRAY_LENGTH(acpi_interfaces_supported); i++) {
Bob Moore7f071902009-03-19 09:37:47 +0800187 if (!ACPI_STRCMP(interface, acpi_interfaces_supported[i].name)) {
188 *acpi_interfaces_supported[i].name = '\0';
Len Brownae00d812007-05-29 18:43:33 -0400189 return AE_OK;
190 }
191 }
192 return AE_NOT_FOUND;
193}
194
195/*******************************************************************************
196 *
Linus Torvalds1da177e2005-04-16 15:20:36 -0700197 * FUNCTION: acpi_ut_evaluate_object
198 *
199 * PARAMETERS: prefix_node - Starting node
200 * Path - Path to object from starting node
201 * expected_return_types - Bitmap of allowed return types
202 * return_desc - Where a return value is stored
203 *
204 * RETURN: Status
205 *
206 * DESCRIPTION: Evaluates a namespace object and verifies the type of the
Bob Moore15b8dd52009-06-29 13:39:29 +0800207 * return object. Common code that simplifies accessing objects
Linus Torvalds1da177e2005-04-16 15:20:36 -0700208 * that have required return objects of fixed types.
209 *
210 * NOTE: Internal function, no parameter validation
211 *
212 ******************************************************************************/
213
214acpi_status
Len Brown4be44fc2005-08-05 00:44:28 -0400215acpi_ut_evaluate_object(struct acpi_namespace_node *prefix_node,
216 char *path,
217 u32 expected_return_btypes,
218 union acpi_operand_object **return_desc)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700219{
Bob Moore41195322006-05-26 16:36:00 -0400220 struct acpi_evaluate_info *info;
Len Brown4be44fc2005-08-05 00:44:28 -0400221 acpi_status status;
222 u32 return_btype;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700223
Bob Mooreb229cf92006-04-21 17:15:00 -0400224 ACPI_FUNCTION_TRACE(ut_evaluate_object);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700225
Bob Moore41195322006-05-26 16:36:00 -0400226 /* Allocate the evaluation information block */
227
228 info = ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_evaluate_info));
229 if (!info) {
230 return_ACPI_STATUS(AE_NO_MEMORY);
231 }
232
233 info->prefix_node = prefix_node;
234 info->pathname = path;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700235
236 /* Evaluate the object/method */
237
Bob Moore41195322006-05-26 16:36:00 -0400238 status = acpi_ns_evaluate(info);
Len Brown4be44fc2005-08-05 00:44:28 -0400239 if (ACPI_FAILURE(status)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700240 if (status == AE_NOT_FOUND) {
Len Brown4be44fc2005-08-05 00:44:28 -0400241 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
242 "[%4.4s.%s] was not found\n",
243 acpi_ut_get_node_name(prefix_node),
244 path));
245 } else {
Bob Mooreb8e4d892006-01-27 16:43:00 -0500246 ACPI_ERROR_METHOD("Method execution failed",
247 prefix_node, path, status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700248 }
249
Bob Moore41195322006-05-26 16:36:00 -0400250 goto cleanup;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700251 }
252
253 /* Did we get a return object? */
254
Bob Moore41195322006-05-26 16:36:00 -0400255 if (!info->return_object) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700256 if (expected_return_btypes) {
Bob Mooreb8e4d892006-01-27 16:43:00 -0500257 ACPI_ERROR_METHOD("No object was returned from",
258 prefix_node, path, AE_NOT_EXIST);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700259
Bob Moore41195322006-05-26 16:36:00 -0400260 status = AE_NOT_EXIST;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700261 }
262
Bob Moore41195322006-05-26 16:36:00 -0400263 goto cleanup;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700264 }
265
266 /* Map the return object type to the bitmapped type */
267
Bob Moore3371c192009-02-18 14:44:03 +0800268 switch ((info->return_object)->common.type) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700269 case ACPI_TYPE_INTEGER:
270 return_btype = ACPI_BTYPE_INTEGER;
271 break;
272
273 case ACPI_TYPE_BUFFER:
274 return_btype = ACPI_BTYPE_BUFFER;
275 break;
276
277 case ACPI_TYPE_STRING:
278 return_btype = ACPI_BTYPE_STRING;
279 break;
280
281 case ACPI_TYPE_PACKAGE:
282 return_btype = ACPI_BTYPE_PACKAGE;
283 break;
284
285 default:
286 return_btype = 0;
287 break;
288 }
289
Len Brown4be44fc2005-08-05 00:44:28 -0400290 if ((acpi_gbl_enable_interpreter_slack) && (!expected_return_btypes)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700291 /*
Bob Moore15b8dd52009-06-29 13:39:29 +0800292 * We received a return object, but one was not expected. This can
Linus Torvalds1da177e2005-04-16 15:20:36 -0700293 * happen frequently if the "implicit return" feature is enabled.
294 * Just delete the return object and return AE_OK.
295 */
Bob Moore41195322006-05-26 16:36:00 -0400296 acpi_ut_remove_reference(info->return_object);
297 goto cleanup;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700298 }
299
300 /* Is the return object one of the expected types? */
301
302 if (!(expected_return_btypes & return_btype)) {
Bob Mooreb8e4d892006-01-27 16:43:00 -0500303 ACPI_ERROR_METHOD("Return object type is incorrect",
304 prefix_node, path, AE_TYPE);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700305
Bob Mooreb8e4d892006-01-27 16:43:00 -0500306 ACPI_ERROR((AE_INFO,
307 "Type returned from %s was incorrect: %s, expected Btypes: %X",
308 path,
Bob Moore41195322006-05-26 16:36:00 -0400309 acpi_ut_get_object_type_name(info->return_object),
Bob Mooreb8e4d892006-01-27 16:43:00 -0500310 expected_return_btypes));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700311
312 /* On error exit, we must delete the return object */
313
Bob Moore41195322006-05-26 16:36:00 -0400314 acpi_ut_remove_reference(info->return_object);
315 status = AE_TYPE;
316 goto cleanup;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700317 }
318
319 /* Object type is OK, return it */
320
Bob Moore41195322006-05-26 16:36:00 -0400321 *return_desc = info->return_object;
322
323 cleanup:
324 ACPI_FREE(info);
325 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700326}
327
Linus Torvalds1da177e2005-04-16 15:20:36 -0700328/*******************************************************************************
329 *
330 * FUNCTION: acpi_ut_evaluate_numeric_object
331 *
Robert Moore44f6c012005-04-18 22:49:35 -0400332 * PARAMETERS: object_name - Object name to be evaluated
Linus Torvalds1da177e2005-04-16 15:20:36 -0700333 * device_node - Node for the device
Bob Moore15b8dd52009-06-29 13:39:29 +0800334 * Value - Where the value is returned
Linus Torvalds1da177e2005-04-16 15:20:36 -0700335 *
336 * RETURN: Status
337 *
338 * DESCRIPTION: Evaluates a numeric namespace object for a selected device
Bob Moore15b8dd52009-06-29 13:39:29 +0800339 * and stores result in *Value.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700340 *
341 * NOTE: Internal function, no parameter validation
342 *
343 ******************************************************************************/
344
345acpi_status
Len Brown4be44fc2005-08-05 00:44:28 -0400346acpi_ut_evaluate_numeric_object(char *object_name,
347 struct acpi_namespace_node *device_node,
Bob Moore15b8dd52009-06-29 13:39:29 +0800348 acpi_integer *value)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700349{
Len Brown4be44fc2005-08-05 00:44:28 -0400350 union acpi_operand_object *obj_desc;
351 acpi_status status;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700352
Bob Mooreb229cf92006-04-21 17:15:00 -0400353 ACPI_FUNCTION_TRACE(ut_evaluate_numeric_object);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700354
Len Brown4be44fc2005-08-05 00:44:28 -0400355 status = acpi_ut_evaluate_object(device_node, object_name,
356 ACPI_BTYPE_INTEGER, &obj_desc);
357 if (ACPI_FAILURE(status)) {
358 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700359 }
360
361 /* Get the returned Integer */
362
Bob Moore15b8dd52009-06-29 13:39:29 +0800363 *value = obj_desc->integer.value;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700364
365 /* On exit, we must delete the return object */
366
Len Brown4be44fc2005-08-05 00:44:28 -0400367 acpi_ut_remove_reference(obj_desc);
368 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700369}
370
Linus Torvalds1da177e2005-04-16 15:20:36 -0700371/*******************************************************************************
372 *
373 * FUNCTION: acpi_ut_execute_STA
374 *
375 * PARAMETERS: device_node - Node for the device
Robert Moore44f6c012005-04-18 22:49:35 -0400376 * Flags - Where the status flags are returned
Linus Torvalds1da177e2005-04-16 15:20:36 -0700377 *
378 * RETURN: Status
379 *
380 * DESCRIPTION: Executes _STA for selected device and stores results in
381 * *Flags.
382 *
383 * NOTE: Internal function, no parameter validation
384 *
385 ******************************************************************************/
386
387acpi_status
Len Brown4be44fc2005-08-05 00:44:28 -0400388acpi_ut_execute_STA(struct acpi_namespace_node *device_node, u32 * flags)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700389{
Len Brown4be44fc2005-08-05 00:44:28 -0400390 union acpi_operand_object *obj_desc;
391 acpi_status status;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700392
Bob Mooreb229cf92006-04-21 17:15:00 -0400393 ACPI_FUNCTION_TRACE(ut_execute_STA);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700394
Len Brown4be44fc2005-08-05 00:44:28 -0400395 status = acpi_ut_evaluate_object(device_node, METHOD_NAME__STA,
396 ACPI_BTYPE_INTEGER, &obj_desc);
397 if (ACPI_FAILURE(status)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700398 if (AE_NOT_FOUND == status) {
Len Brown4be44fc2005-08-05 00:44:28 -0400399 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
400 "_STA on %4.4s was not found, assuming device is present\n",
401 acpi_ut_get_node_name(device_node)));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700402
Bob Mooredefba1d2005-12-16 17:05:00 -0500403 *flags = ACPI_UINT32_MAX;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700404 status = AE_OK;
405 }
406
Len Brown4be44fc2005-08-05 00:44:28 -0400407 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700408 }
409
410 /* Extract the status flags */
411
412 *flags = (u32) obj_desc->integer.value;
413
414 /* On exit, we must delete the return object */
415
Len Brown4be44fc2005-08-05 00:44:28 -0400416 acpi_ut_remove_reference(obj_desc);
417 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700418}
419
Linus Torvalds1da177e2005-04-16 15:20:36 -0700420/*******************************************************************************
421 *
Bob Moore15b8dd52009-06-29 13:39:29 +0800422 * FUNCTION: acpi_ut_execute_power_methods
Linus Torvalds1da177e2005-04-16 15:20:36 -0700423 *
424 * PARAMETERS: device_node - Node for the device
Bob Moore15b8dd52009-06-29 13:39:29 +0800425 * method_names - Array of power method names
426 * method_count - Number of methods to execute
427 * out_values - Where the power method values are returned
Linus Torvalds1da177e2005-04-16 15:20:36 -0700428 *
Bob Moore15b8dd52009-06-29 13:39:29 +0800429 * RETURN: Status, out_values
Linus Torvalds1da177e2005-04-16 15:20:36 -0700430 *
Bob Moore15b8dd52009-06-29 13:39:29 +0800431 * DESCRIPTION: Executes the specified power methods for the device and returns
432 * the result(s).
Linus Torvalds1da177e2005-04-16 15:20:36 -0700433 *
434 * NOTE: Internal function, no parameter validation
435 *
Bob Moore15b8dd52009-06-29 13:39:29 +0800436******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700437
438acpi_status
Bob Moore15b8dd52009-06-29 13:39:29 +0800439acpi_ut_execute_power_methods(struct acpi_namespace_node *device_node,
440 const char **method_names,
441 u8 method_count, u8 *out_values)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700442{
Len Brown4be44fc2005-08-05 00:44:28 -0400443 union acpi_operand_object *obj_desc;
444 acpi_status status;
Bob Moore15b8dd52009-06-29 13:39:29 +0800445 acpi_status final_status = AE_NOT_FOUND;
Len Brown4be44fc2005-08-05 00:44:28 -0400446 u32 i;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700447
Bob Moore15b8dd52009-06-29 13:39:29 +0800448 ACPI_FUNCTION_TRACE(ut_execute_power_methods);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700449
Bob Moore15b8dd52009-06-29 13:39:29 +0800450 for (i = 0; i < method_count; i++) {
451 /*
452 * Execute the power method (_sx_d or _sx_w). The only allowable
453 * return type is an Integer.
454 */
Len Brown4be44fc2005-08-05 00:44:28 -0400455 status = acpi_ut_evaluate_object(device_node,
Bob Mooredefba1d2005-12-16 17:05:00 -0500456 ACPI_CAST_PTR(char,
Bob Moore15b8dd52009-06-29 13:39:29 +0800457 method_names[i]),
Bob Mooredefba1d2005-12-16 17:05:00 -0500458 ACPI_BTYPE_INTEGER, &obj_desc);
Bob Moore15b8dd52009-06-29 13:39:29 +0800459 if (ACPI_SUCCESS(status)) {
460 out_values[i] = (u8)obj_desc->integer.value;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700461
462 /* Delete the return object */
463
Len Brown4be44fc2005-08-05 00:44:28 -0400464 acpi_ut_remove_reference(obj_desc);
Bob Moore15b8dd52009-06-29 13:39:29 +0800465 final_status = AE_OK; /* At least one value is valid */
466 continue;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700467 }
Bob Moore15b8dd52009-06-29 13:39:29 +0800468
469 out_values[i] = ACPI_UINT8_MAX;
470 if (status == AE_NOT_FOUND) {
471 continue; /* Ignore if not found */
472 }
473
474 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
475 "Failed %s on Device %4.4s, %s\n",
476 ACPI_CAST_PTR(char, method_names[i]),
477 acpi_ut_get_node_name(device_node),
478 acpi_format_exception(status)));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700479 }
480
Bob Moore15b8dd52009-06-29 13:39:29 +0800481 return_ACPI_STATUS(final_status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700482}