xref: /openbmc/linux/drivers/acpi/acpica/uteval.c (revision 5df7e6cb42da36c7d878239bebc81907b15f3943)
195b482a8SLen Brown /******************************************************************************
295b482a8SLen Brown  *
395b482a8SLen Brown  * Module Name: uteval - Object evaluation
495b482a8SLen Brown  *
595b482a8SLen Brown  *****************************************************************************/
695b482a8SLen Brown 
795b482a8SLen Brown /*
8a8357b0cSBob Moore  * Copyright (C) 2000 - 2010, Intel Corp.
995b482a8SLen Brown  * All rights reserved.
1095b482a8SLen Brown  *
1195b482a8SLen Brown  * Redistribution and use in source and binary forms, with or without
1295b482a8SLen Brown  * modification, are permitted provided that the following conditions
1395b482a8SLen Brown  * are met:
1495b482a8SLen Brown  * 1. Redistributions of source code must retain the above copyright
1595b482a8SLen Brown  *    notice, this list of conditions, and the following disclaimer,
1695b482a8SLen Brown  *    without modification.
1795b482a8SLen Brown  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
1895b482a8SLen Brown  *    substantially similar to the "NO WARRANTY" disclaimer below
1995b482a8SLen Brown  *    ("Disclaimer") and any redistribution must be conditioned upon
2095b482a8SLen Brown  *    including a substantially similar Disclaimer requirement for further
2195b482a8SLen Brown  *    binary redistribution.
2295b482a8SLen Brown  * 3. Neither the names of the above-listed copyright holders nor the names
2395b482a8SLen Brown  *    of any contributors may be used to endorse or promote products derived
2495b482a8SLen Brown  *    from this software without specific prior written permission.
2595b482a8SLen Brown  *
2695b482a8SLen Brown  * Alternatively, this software may be distributed under the terms of the
2795b482a8SLen Brown  * GNU General Public License ("GPL") version 2 as published by the Free
2895b482a8SLen Brown  * Software Foundation.
2995b482a8SLen Brown  *
3095b482a8SLen Brown  * NO WARRANTY
3195b482a8SLen Brown  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
3295b482a8SLen Brown  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
3395b482a8SLen Brown  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
3495b482a8SLen Brown  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
3595b482a8SLen Brown  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
3695b482a8SLen Brown  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
3795b482a8SLen Brown  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
3895b482a8SLen Brown  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
3995b482a8SLen Brown  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
4095b482a8SLen Brown  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
4195b482a8SLen Brown  * POSSIBILITY OF SUCH DAMAGES.
4295b482a8SLen Brown  */
4395b482a8SLen Brown 
4495b482a8SLen Brown #include <acpi/acpi.h>
45e2f7a777SLen Brown #include "accommon.h"
46e2f7a777SLen Brown #include "acnamesp.h"
4795b482a8SLen Brown 
4895b482a8SLen Brown #define _COMPONENT          ACPI_UTILITIES
4995b482a8SLen Brown ACPI_MODULE_NAME("uteval")
5095b482a8SLen Brown 
5195b482a8SLen Brown /*
5295b482a8SLen Brown  * Strings supported by the _OSI predefined (internal) method.
537f071903SBob Moore  *
547f071903SBob Moore  * March 2009: Removed "Linux" as this host no longer wants to respond true
557f071903SBob Moore  * for this string. Basically, the only safe OS strings are windows-related
567f071903SBob Moore  * and in many or most cases represent the only test path within the
577f071903SBob Moore  * BIOS-provided ASL code.
587f071903SBob Moore  *
597f071903SBob Moore  * The second element of each entry is used to track the newest version of
607f071903SBob Moore  * Windows that the BIOS has requested.
6195b482a8SLen Brown  */
627f071903SBob Moore static struct acpi_interface_info acpi_interfaces_supported[] = {
6395b482a8SLen Brown 	/* Operating System Vendor Strings */
6495b482a8SLen Brown 
657f071903SBob Moore 	{"Windows 2000", ACPI_OSI_WIN_2000},	/* Windows 2000 */
667f071903SBob Moore 	{"Windows 2001", ACPI_OSI_WIN_XP},	/* Windows XP */
677f071903SBob Moore 	{"Windows 2001 SP1", ACPI_OSI_WIN_XP_SP1},	/* Windows XP SP1 */
687f071903SBob Moore 	{"Windows 2001.1", ACPI_OSI_WINSRV_2003},	/* Windows Server 2003 */
697f071903SBob Moore 	{"Windows 2001 SP2", ACPI_OSI_WIN_XP_SP2},	/* Windows XP SP2 */
707f071903SBob Moore 	{"Windows 2001.1 SP1", ACPI_OSI_WINSRV_2003_SP1},	/* Windows Server 2003 SP1 - Added 03/2006 */
717f071903SBob Moore 	{"Windows 2006", ACPI_OSI_WIN_VISTA},	/* Windows Vista - Added 03/2006 */
72eb752552SBob Moore 	{"Windows 2006.1", ACPI_OSI_WINSRV_2008},	/* Windows Server 2008 - Added 09/2009 */
73eb752552SBob Moore 	{"Windows 2006 SP1", ACPI_OSI_WIN_VISTA_SP1},	/* Windows Vista SP1 - Added 09/2009 */
74eb752552SBob Moore 	{"Windows 2009", ACPI_OSI_WIN_7},	/* Windows 7 and Server 2008 R2 - Added 09/2009 */
7595b482a8SLen Brown 
7695b482a8SLen Brown 	/* Feature Group Strings */
7795b482a8SLen Brown 
787f071903SBob Moore 	{"Extended Address Space Descriptor", 0}
797f071903SBob Moore 
8095b482a8SLen Brown 	/*
8195b482a8SLen Brown 	 * All "optional" feature group strings (features that are implemented
8295b482a8SLen Brown 	 * by the host) should be implemented in the host version of
8395b482a8SLen Brown 	 * acpi_os_validate_interface and should not be added here.
8495b482a8SLen Brown 	 */
8595b482a8SLen Brown };
8695b482a8SLen Brown 
8795b482a8SLen Brown /*******************************************************************************
8895b482a8SLen Brown  *
8995b482a8SLen Brown  * FUNCTION:    acpi_ut_osi_implementation
9095b482a8SLen Brown  *
9195b482a8SLen Brown  * PARAMETERS:  walk_state          - Current walk state
9295b482a8SLen Brown  *
9395b482a8SLen Brown  * RETURN:      Status
9495b482a8SLen Brown  *
9595b482a8SLen Brown  * DESCRIPTION: Implementation of the _OSI predefined control method
9695b482a8SLen Brown  *
9795b482a8SLen Brown  ******************************************************************************/
9895b482a8SLen Brown 
9995b482a8SLen Brown acpi_status acpi_ut_osi_implementation(struct acpi_walk_state *walk_state)
10095b482a8SLen Brown {
10195b482a8SLen Brown 	acpi_status status;
10295b482a8SLen Brown 	union acpi_operand_object *string_desc;
10395b482a8SLen Brown 	union acpi_operand_object *return_desc;
104c114e4b6SBob Moore 	u32 return_value;
10595b482a8SLen Brown 	u32 i;
10695b482a8SLen Brown 
10795b482a8SLen Brown 	ACPI_FUNCTION_TRACE(ut_osi_implementation);
10895b482a8SLen Brown 
10995b482a8SLen Brown 	/* Validate the string input argument */
11095b482a8SLen Brown 
11195b482a8SLen Brown 	string_desc = walk_state->arguments[0].object;
11295b482a8SLen Brown 	if (!string_desc || (string_desc->common.type != ACPI_TYPE_STRING)) {
11395b482a8SLen Brown 		return_ACPI_STATUS(AE_TYPE);
11495b482a8SLen Brown 	}
11595b482a8SLen Brown 
11695b482a8SLen Brown 	/* Create a return object */
11795b482a8SLen Brown 
11895b482a8SLen Brown 	return_desc = acpi_ut_create_internal_object(ACPI_TYPE_INTEGER);
11995b482a8SLen Brown 	if (!return_desc) {
12095b482a8SLen Brown 		return_ACPI_STATUS(AE_NO_MEMORY);
12195b482a8SLen Brown 	}
12295b482a8SLen Brown 
123c114e4b6SBob Moore 	/* Default return value is 0, NOT SUPPORTED */
12495b482a8SLen Brown 
125c114e4b6SBob Moore 	return_value = 0;
12695b482a8SLen Brown 
12795b482a8SLen Brown 	/* Compare input string to static table of supported interfaces */
12895b482a8SLen Brown 
12995b482a8SLen Brown 	for (i = 0; i < ACPI_ARRAY_LENGTH(acpi_interfaces_supported); i++) {
130ec41f193SBob Moore 		if (!ACPI_STRCMP(string_desc->string.pointer,
1317f071903SBob Moore 				 acpi_interfaces_supported[i].name)) {
1327f071903SBob Moore 			/*
1337f071903SBob Moore 			 * The interface is supported.
1347f071903SBob Moore 			 * Update the osi_data if necessary. We keep track of the latest
1357f071903SBob Moore 			 * version of Windows that has been requested by the BIOS.
1367f071903SBob Moore 			 */
1377f071903SBob Moore 			if (acpi_interfaces_supported[i].value >
1387f071903SBob Moore 			    acpi_gbl_osi_data) {
1397f071903SBob Moore 				acpi_gbl_osi_data =
1407f071903SBob Moore 				    acpi_interfaces_supported[i].value;
1417f071903SBob Moore 			}
142c114e4b6SBob Moore 
143c114e4b6SBob Moore 			return_value = ACPI_UINT32_MAX;
144c114e4b6SBob Moore 			goto exit;
14595b482a8SLen Brown 		}
14695b482a8SLen Brown 	}
14795b482a8SLen Brown 
14895b482a8SLen Brown 	/*
14995b482a8SLen Brown 	 * Did not match the string in the static table, call the host OSL to
15095b482a8SLen Brown 	 * check for a match with one of the optional strings (such as
15195b482a8SLen Brown 	 * "Module Device", "3.0 Thermal Model", etc.)
15295b482a8SLen Brown 	 */
15395b482a8SLen Brown 	status = acpi_os_validate_interface(string_desc->string.pointer);
15495b482a8SLen Brown 	if (ACPI_SUCCESS(status)) {
155c114e4b6SBob Moore 
156c114e4b6SBob Moore 		/* The interface is supported */
157c114e4b6SBob Moore 
158c114e4b6SBob Moore 		return_value = ACPI_UINT32_MAX;
15995b482a8SLen Brown 	}
16095b482a8SLen Brown 
161c114e4b6SBob Moore exit:
162c114e4b6SBob Moore 	ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO,
163c114e4b6SBob Moore 		"ACPI: BIOS _OSI(%s) is %ssupported\n",
164c114e4b6SBob Moore 		string_desc->string.pointer, return_value == 0 ? "not " : ""));
16595b482a8SLen Brown 
166c114e4b6SBob Moore 	/* Complete the return value */
167c114e4b6SBob Moore 
168c114e4b6SBob Moore 	return_desc->integer.value = return_value;
169c114e4b6SBob Moore 	walk_state->return_desc = return_desc;
17095b482a8SLen Brown 	return_ACPI_STATUS (AE_OK);
17195b482a8SLen Brown }
17295b482a8SLen Brown 
17395b482a8SLen Brown /*******************************************************************************
17495b482a8SLen Brown  *
17595b482a8SLen Brown  * FUNCTION:    acpi_osi_invalidate
17695b482a8SLen Brown  *
17795b482a8SLen Brown  * PARAMETERS:  interface_string
17895b482a8SLen Brown  *
17995b482a8SLen Brown  * RETURN:      Status
18095b482a8SLen Brown  *
18195b482a8SLen Brown  * DESCRIPTION: invalidate string in pre-defiend _OSI string list
18295b482a8SLen Brown  *
18395b482a8SLen Brown  ******************************************************************************/
18495b482a8SLen Brown 
18595b482a8SLen Brown acpi_status acpi_osi_invalidate(char *interface)
18695b482a8SLen Brown {
18795b482a8SLen Brown 	int i;
18895b482a8SLen Brown 
18995b482a8SLen Brown 	for (i = 0; i < ACPI_ARRAY_LENGTH(acpi_interfaces_supported); i++) {
1907f071903SBob Moore 		if (!ACPI_STRCMP(interface, acpi_interfaces_supported[i].name)) {
1917f071903SBob Moore 			*acpi_interfaces_supported[i].name = '\0';
19295b482a8SLen Brown 			return AE_OK;
19395b482a8SLen Brown 		}
19495b482a8SLen Brown 	}
19595b482a8SLen Brown 	return AE_NOT_FOUND;
19695b482a8SLen Brown }
19795b482a8SLen Brown 
19895b482a8SLen Brown /*******************************************************************************
19995b482a8SLen Brown  *
20095b482a8SLen Brown  * FUNCTION:    acpi_ut_evaluate_object
20195b482a8SLen Brown  *
20295b482a8SLen Brown  * PARAMETERS:  prefix_node         - Starting node
20395b482a8SLen Brown  *              Path                - Path to object from starting node
20495b482a8SLen Brown  *              expected_return_types - Bitmap of allowed return types
20595b482a8SLen Brown  *              return_desc         - Where a return value is stored
20695b482a8SLen Brown  *
20795b482a8SLen Brown  * RETURN:      Status
20895b482a8SLen Brown  *
20995b482a8SLen Brown  * DESCRIPTION: Evaluates a namespace object and verifies the type of the
21095b482a8SLen Brown  *              return object. Common code that simplifies accessing objects
21195b482a8SLen Brown  *              that have required return objects of fixed types.
21295b482a8SLen Brown  *
21395b482a8SLen Brown  *              NOTE: Internal function, no parameter validation
21495b482a8SLen Brown  *
21595b482a8SLen Brown  ******************************************************************************/
21695b482a8SLen Brown 
21795b482a8SLen Brown acpi_status
21895b482a8SLen Brown acpi_ut_evaluate_object(struct acpi_namespace_node *prefix_node,
21995b482a8SLen Brown 			char *path,
22095b482a8SLen Brown 			u32 expected_return_btypes,
22195b482a8SLen Brown 			union acpi_operand_object **return_desc)
22295b482a8SLen Brown {
22395b482a8SLen Brown 	struct acpi_evaluate_info *info;
22495b482a8SLen Brown 	acpi_status status;
22595b482a8SLen Brown 	u32 return_btype;
22695b482a8SLen Brown 
22795b482a8SLen Brown 	ACPI_FUNCTION_TRACE(ut_evaluate_object);
22895b482a8SLen Brown 
22995b482a8SLen Brown 	/* Allocate the evaluation information block */
23095b482a8SLen Brown 
23195b482a8SLen Brown 	info = ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_evaluate_info));
23295b482a8SLen Brown 	if (!info) {
23395b482a8SLen Brown 		return_ACPI_STATUS(AE_NO_MEMORY);
23495b482a8SLen Brown 	}
23595b482a8SLen Brown 
23695b482a8SLen Brown 	info->prefix_node = prefix_node;
23795b482a8SLen Brown 	info->pathname = path;
23895b482a8SLen Brown 
23995b482a8SLen Brown 	/* Evaluate the object/method */
24095b482a8SLen Brown 
24195b482a8SLen Brown 	status = acpi_ns_evaluate(info);
24295b482a8SLen Brown 	if (ACPI_FAILURE(status)) {
24395b482a8SLen Brown 		if (status == AE_NOT_FOUND) {
24495b482a8SLen Brown 			ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
24595b482a8SLen Brown 					  "[%4.4s.%s] was not found\n",
24695b482a8SLen Brown 					  acpi_ut_get_node_name(prefix_node),
24795b482a8SLen Brown 					  path));
24895b482a8SLen Brown 		} else {
24995b482a8SLen Brown 			ACPI_ERROR_METHOD("Method execution failed",
25095b482a8SLen Brown 					  prefix_node, path, status);
25195b482a8SLen Brown 		}
25295b482a8SLen Brown 
25395b482a8SLen Brown 		goto cleanup;
25495b482a8SLen Brown 	}
25595b482a8SLen Brown 
25695b482a8SLen Brown 	/* Did we get a return object? */
25795b482a8SLen Brown 
25895b482a8SLen Brown 	if (!info->return_object) {
25995b482a8SLen Brown 		if (expected_return_btypes) {
26095b482a8SLen Brown 			ACPI_ERROR_METHOD("No object was returned from",
26195b482a8SLen Brown 					  prefix_node, path, AE_NOT_EXIST);
26295b482a8SLen Brown 
26395b482a8SLen Brown 			status = AE_NOT_EXIST;
26495b482a8SLen Brown 		}
26595b482a8SLen Brown 
26695b482a8SLen Brown 		goto cleanup;
26795b482a8SLen Brown 	}
26895b482a8SLen Brown 
26995b482a8SLen Brown 	/* Map the return object type to the bitmapped type */
27095b482a8SLen Brown 
2713371c19cSBob Moore 	switch ((info->return_object)->common.type) {
27295b482a8SLen Brown 	case ACPI_TYPE_INTEGER:
27395b482a8SLen Brown 		return_btype = ACPI_BTYPE_INTEGER;
27495b482a8SLen Brown 		break;
27595b482a8SLen Brown 
27695b482a8SLen Brown 	case ACPI_TYPE_BUFFER:
27795b482a8SLen Brown 		return_btype = ACPI_BTYPE_BUFFER;
27895b482a8SLen Brown 		break;
27995b482a8SLen Brown 
28095b482a8SLen Brown 	case ACPI_TYPE_STRING:
28195b482a8SLen Brown 		return_btype = ACPI_BTYPE_STRING;
28295b482a8SLen Brown 		break;
28395b482a8SLen Brown 
28495b482a8SLen Brown 	case ACPI_TYPE_PACKAGE:
28595b482a8SLen Brown 		return_btype = ACPI_BTYPE_PACKAGE;
28695b482a8SLen Brown 		break;
28795b482a8SLen Brown 
28895b482a8SLen Brown 	default:
28995b482a8SLen Brown 		return_btype = 0;
29095b482a8SLen Brown 		break;
29195b482a8SLen Brown 	}
29295b482a8SLen Brown 
29395b482a8SLen Brown 	if ((acpi_gbl_enable_interpreter_slack) && (!expected_return_btypes)) {
29495b482a8SLen Brown 		/*
29595b482a8SLen Brown 		 * We received a return object, but one was not expected. This can
29695b482a8SLen Brown 		 * happen frequently if the "implicit return" feature is enabled.
29795b482a8SLen Brown 		 * Just delete the return object and return AE_OK.
29895b482a8SLen Brown 		 */
29995b482a8SLen Brown 		acpi_ut_remove_reference(info->return_object);
30095b482a8SLen Brown 		goto cleanup;
30195b482a8SLen Brown 	}
30295b482a8SLen Brown 
30395b482a8SLen Brown 	/* Is the return object one of the expected types? */
30495b482a8SLen Brown 
30595b482a8SLen Brown 	if (!(expected_return_btypes & return_btype)) {
30695b482a8SLen Brown 		ACPI_ERROR_METHOD("Return object type is incorrect",
30795b482a8SLen Brown 				  prefix_node, path, AE_TYPE);
30895b482a8SLen Brown 
30995b482a8SLen Brown 		ACPI_ERROR((AE_INFO,
31095b482a8SLen Brown 			    "Type returned from %s was incorrect: %s, expected Btypes: %X",
31195b482a8SLen Brown 			    path,
31295b482a8SLen Brown 			    acpi_ut_get_object_type_name(info->return_object),
31395b482a8SLen Brown 			    expected_return_btypes));
31495b482a8SLen Brown 
31595b482a8SLen Brown 		/* On error exit, we must delete the return object */
31695b482a8SLen Brown 
31795b482a8SLen Brown 		acpi_ut_remove_reference(info->return_object);
31895b482a8SLen Brown 		status = AE_TYPE;
31995b482a8SLen Brown 		goto cleanup;
32095b482a8SLen Brown 	}
32195b482a8SLen Brown 
32295b482a8SLen Brown 	/* Object type is OK, return it */
32395b482a8SLen Brown 
32495b482a8SLen Brown 	*return_desc = info->return_object;
32595b482a8SLen Brown 
32695b482a8SLen Brown       cleanup:
32795b482a8SLen Brown 	ACPI_FREE(info);
32895b482a8SLen Brown 	return_ACPI_STATUS(status);
32995b482a8SLen Brown }
33095b482a8SLen Brown 
33195b482a8SLen Brown /*******************************************************************************
33295b482a8SLen Brown  *
33395b482a8SLen Brown  * FUNCTION:    acpi_ut_evaluate_numeric_object
33495b482a8SLen Brown  *
33595b482a8SLen Brown  * PARAMETERS:  object_name         - Object name to be evaluated
33695b482a8SLen Brown  *              device_node         - Node for the device
33715b8dd53SBob Moore  *              Value               - Where the value is returned
33895b482a8SLen Brown  *
33995b482a8SLen Brown  * RETURN:      Status
34095b482a8SLen Brown  *
34195b482a8SLen Brown  * DESCRIPTION: Evaluates a numeric namespace object for a selected device
34215b8dd53SBob Moore  *              and stores result in *Value.
34395b482a8SLen Brown  *
34495b482a8SLen Brown  *              NOTE: Internal function, no parameter validation
34595b482a8SLen Brown  *
34695b482a8SLen Brown  ******************************************************************************/
34795b482a8SLen Brown 
34895b482a8SLen Brown acpi_status
34995b482a8SLen Brown acpi_ut_evaluate_numeric_object(char *object_name,
35095b482a8SLen Brown 				struct acpi_namespace_node *device_node,
351*5df7e6cbSBob Moore 				u64 *value)
35295b482a8SLen Brown {
35395b482a8SLen Brown 	union acpi_operand_object *obj_desc;
35495b482a8SLen Brown 	acpi_status status;
35595b482a8SLen Brown 
35695b482a8SLen Brown 	ACPI_FUNCTION_TRACE(ut_evaluate_numeric_object);
35795b482a8SLen Brown 
35895b482a8SLen Brown 	status = acpi_ut_evaluate_object(device_node, object_name,
35995b482a8SLen Brown 					 ACPI_BTYPE_INTEGER, &obj_desc);
36095b482a8SLen Brown 	if (ACPI_FAILURE(status)) {
36195b482a8SLen Brown 		return_ACPI_STATUS(status);
36295b482a8SLen Brown 	}
36395b482a8SLen Brown 
36495b482a8SLen Brown 	/* Get the returned Integer */
36595b482a8SLen Brown 
36615b8dd53SBob Moore 	*value = obj_desc->integer.value;
36795b482a8SLen Brown 
36895b482a8SLen Brown 	/* On exit, we must delete the return object */
36995b482a8SLen Brown 
37095b482a8SLen Brown 	acpi_ut_remove_reference(obj_desc);
37195b482a8SLen Brown 	return_ACPI_STATUS(status);
37295b482a8SLen Brown }
37395b482a8SLen Brown 
37495b482a8SLen Brown /*******************************************************************************
37595b482a8SLen Brown  *
37695b482a8SLen Brown  * FUNCTION:    acpi_ut_execute_STA
37795b482a8SLen Brown  *
37895b482a8SLen Brown  * PARAMETERS:  device_node         - Node for the device
37995b482a8SLen Brown  *              Flags               - Where the status flags are returned
38095b482a8SLen Brown  *
38195b482a8SLen Brown  * RETURN:      Status
38295b482a8SLen Brown  *
38395b482a8SLen Brown  * DESCRIPTION: Executes _STA for selected device and stores results in
38495b482a8SLen Brown  *              *Flags.
38595b482a8SLen Brown  *
38695b482a8SLen Brown  *              NOTE: Internal function, no parameter validation
38795b482a8SLen Brown  *
38895b482a8SLen Brown  ******************************************************************************/
38995b482a8SLen Brown 
39095b482a8SLen Brown acpi_status
39195b482a8SLen Brown acpi_ut_execute_STA(struct acpi_namespace_node *device_node, u32 * flags)
39295b482a8SLen Brown {
39395b482a8SLen Brown 	union acpi_operand_object *obj_desc;
39495b482a8SLen Brown 	acpi_status status;
39595b482a8SLen Brown 
39695b482a8SLen Brown 	ACPI_FUNCTION_TRACE(ut_execute_STA);
39795b482a8SLen Brown 
39895b482a8SLen Brown 	status = acpi_ut_evaluate_object(device_node, METHOD_NAME__STA,
39995b482a8SLen Brown 					 ACPI_BTYPE_INTEGER, &obj_desc);
40095b482a8SLen Brown 	if (ACPI_FAILURE(status)) {
40195b482a8SLen Brown 		if (AE_NOT_FOUND == status) {
40295b482a8SLen Brown 			ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
40395b482a8SLen Brown 					  "_STA on %4.4s was not found, assuming device is present\n",
40495b482a8SLen Brown 					  acpi_ut_get_node_name(device_node)));
40595b482a8SLen Brown 
40695b482a8SLen Brown 			*flags = ACPI_UINT32_MAX;
40795b482a8SLen Brown 			status = AE_OK;
40895b482a8SLen Brown 		}
40995b482a8SLen Brown 
41095b482a8SLen Brown 		return_ACPI_STATUS(status);
41195b482a8SLen Brown 	}
41295b482a8SLen Brown 
41395b482a8SLen Brown 	/* Extract the status flags */
41495b482a8SLen Brown 
41595b482a8SLen Brown 	*flags = (u32) obj_desc->integer.value;
41695b482a8SLen Brown 
41795b482a8SLen Brown 	/* On exit, we must delete the return object */
41895b482a8SLen Brown 
41995b482a8SLen Brown 	acpi_ut_remove_reference(obj_desc);
42095b482a8SLen Brown 	return_ACPI_STATUS(status);
42195b482a8SLen Brown }
42295b482a8SLen Brown 
42395b482a8SLen Brown /*******************************************************************************
42495b482a8SLen Brown  *
42515b8dd53SBob Moore  * FUNCTION:    acpi_ut_execute_power_methods
42695b482a8SLen Brown  *
42795b482a8SLen Brown  * PARAMETERS:  device_node         - Node for the device
42815b8dd53SBob Moore  *              method_names        - Array of power method names
42915b8dd53SBob Moore  *              method_count        - Number of methods to execute
43015b8dd53SBob Moore  *              out_values          - Where the power method values are returned
43195b482a8SLen Brown  *
43215b8dd53SBob Moore  * RETURN:      Status, out_values
43395b482a8SLen Brown  *
43415b8dd53SBob Moore  * DESCRIPTION: Executes the specified power methods for the device and returns
43515b8dd53SBob Moore  *              the result(s).
43695b482a8SLen Brown  *
43795b482a8SLen Brown  *              NOTE: Internal function, no parameter validation
43895b482a8SLen Brown  *
43995b482a8SLen Brown ******************************************************************************/
44095b482a8SLen Brown 
44195b482a8SLen Brown acpi_status
44215b8dd53SBob Moore acpi_ut_execute_power_methods(struct acpi_namespace_node *device_node,
44315b8dd53SBob Moore 			      const char **method_names,
44415b8dd53SBob Moore 			      u8 method_count, u8 *out_values)
44595b482a8SLen Brown {
44695b482a8SLen Brown 	union acpi_operand_object *obj_desc;
44795b482a8SLen Brown 	acpi_status status;
44815b8dd53SBob Moore 	acpi_status final_status = AE_NOT_FOUND;
44995b482a8SLen Brown 	u32 i;
45095b482a8SLen Brown 
45115b8dd53SBob Moore 	ACPI_FUNCTION_TRACE(ut_execute_power_methods);
45295b482a8SLen Brown 
45315b8dd53SBob Moore 	for (i = 0; i < method_count; i++) {
45415b8dd53SBob Moore 		/*
45515b8dd53SBob Moore 		 * Execute the power method (_sx_d or _sx_w). The only allowable
45615b8dd53SBob Moore 		 * return type is an Integer.
45715b8dd53SBob Moore 		 */
45895b482a8SLen Brown 		status = acpi_ut_evaluate_object(device_node,
45995b482a8SLen Brown 						 ACPI_CAST_PTR(char,
46015b8dd53SBob Moore 							       method_names[i]),
46195b482a8SLen Brown 						 ACPI_BTYPE_INTEGER, &obj_desc);
46215b8dd53SBob Moore 		if (ACPI_SUCCESS(status)) {
46315b8dd53SBob Moore 			out_values[i] = (u8)obj_desc->integer.value;
46495b482a8SLen Brown 
46595b482a8SLen Brown 			/* Delete the return object */
46695b482a8SLen Brown 
46795b482a8SLen Brown 			acpi_ut_remove_reference(obj_desc);
46815b8dd53SBob Moore 			final_status = AE_OK;	/* At least one value is valid */
46915b8dd53SBob Moore 			continue;
47095b482a8SLen Brown 		}
47195b482a8SLen Brown 
47215b8dd53SBob Moore 		out_values[i] = ACPI_UINT8_MAX;
47315b8dd53SBob Moore 		if (status == AE_NOT_FOUND) {
47415b8dd53SBob Moore 			continue;	/* Ignore if not found */
47515b8dd53SBob Moore 		}
47615b8dd53SBob Moore 
47715b8dd53SBob Moore 		ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
47815b8dd53SBob Moore 				  "Failed %s on Device %4.4s, %s\n",
47915b8dd53SBob Moore 				  ACPI_CAST_PTR(char, method_names[i]),
48015b8dd53SBob Moore 				  acpi_ut_get_node_name(device_node),
48115b8dd53SBob Moore 				  acpi_format_exception(status)));
48215b8dd53SBob Moore 	}
48315b8dd53SBob Moore 
48415b8dd53SBob Moore 	return_ACPI_STATUS(final_status);
48595b482a8SLen Brown }
486