uteval.c revision f6a22b0bc417042e83117f52ab1a03696af185ab
11da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/****************************************************************************** 21da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 31da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Module Name: uteval - Object evaluation 41da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 51da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *****************************************************************************/ 61da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 71da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* 8a8357b0c95484b46944728712f8810d3b37bf588Bob Moore * Copyright (C) 2000 - 2010, Intel Corp. 91da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * All rights reserved. 101da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 111da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Redistribution and use in source and binary forms, with or without 121da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * modification, are permitted provided that the following conditions 131da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * are met: 141da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 1. Redistributions of source code must retain the above copyright 151da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * notice, this list of conditions, and the following disclaimer, 161da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * without modification. 171da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 2. Redistributions in binary form must reproduce at minimum a disclaimer 181da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * substantially similar to the "NO WARRANTY" disclaimer below 191da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * ("Disclaimer") and any redistribution must be conditioned upon 201da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * including a substantially similar Disclaimer requirement for further 211da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * binary redistribution. 221da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 3. Neither the names of the above-listed copyright holders nor the names 231da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * of any contributors may be used to endorse or promote products derived 241da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * from this software without specific prior written permission. 251da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 261da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Alternatively, this software may be distributed under the terms of the 271da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * GNU General Public License ("GPL") version 2 as published by the Free 281da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Software Foundation. 291da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 301da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * NO WARRANTY 311da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 321da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 331da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR 341da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 351da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 361da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 371da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 381da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 391da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 401da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 411da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * POSSIBILITY OF SUCH DAMAGES. 421da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds */ 431da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 441da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#include <acpi/acpi.h> 45e2f7a7772880458edff1b1cc5a988947229fac26Len Brown#include "accommon.h" 46e2f7a7772880458edff1b1cc5a988947229fac26Len Brown#include "acnamesp.h" 471da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 481da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define _COMPONENT ACPI_UTILITIES 494be44fcd3bf648b782f4460fd06dfae6c42ded4bLen BrownACPI_MODULE_NAME("uteval") 501da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 51b229cf92eee616c7cb5ad8cdb35a19b119f00bc8Bob Moore/* 52b229cf92eee616c7cb5ad8cdb35a19b119f00bc8Bob Moore * Strings supported by the _OSI predefined (internal) method. 537f0719039085cc40114abce84cf29fe57da226f4Bob Moore * 547f0719039085cc40114abce84cf29fe57da226f4Bob Moore * March 2009: Removed "Linux" as this host no longer wants to respond true 557f0719039085cc40114abce84cf29fe57da226f4Bob Moore * for this string. Basically, the only safe OS strings are windows-related 567f0719039085cc40114abce84cf29fe57da226f4Bob Moore * and in many or most cases represent the only test path within the 577f0719039085cc40114abce84cf29fe57da226f4Bob Moore * BIOS-provided ASL code. 587f0719039085cc40114abce84cf29fe57da226f4Bob Moore * 597f0719039085cc40114abce84cf29fe57da226f4Bob Moore * The second element of each entry is used to track the newest version of 607f0719039085cc40114abce84cf29fe57da226f4Bob Moore * Windows that the BIOS has requested. 61b229cf92eee616c7cb5ad8cdb35a19b119f00bc8Bob Moore */ 627f0719039085cc40114abce84cf29fe57da226f4Bob Moorestatic struct acpi_interface_info acpi_interfaces_supported[] = { 63b229cf92eee616c7cb5ad8cdb35a19b119f00bc8Bob Moore /* Operating System Vendor Strings */ 64b229cf92eee616c7cb5ad8cdb35a19b119f00bc8Bob Moore 657f0719039085cc40114abce84cf29fe57da226f4Bob Moore {"Windows 2000", ACPI_OSI_WIN_2000}, /* Windows 2000 */ 667f0719039085cc40114abce84cf29fe57da226f4Bob Moore {"Windows 2001", ACPI_OSI_WIN_XP}, /* Windows XP */ 677f0719039085cc40114abce84cf29fe57da226f4Bob Moore {"Windows 2001 SP1", ACPI_OSI_WIN_XP_SP1}, /* Windows XP SP1 */ 687f0719039085cc40114abce84cf29fe57da226f4Bob Moore {"Windows 2001.1", ACPI_OSI_WINSRV_2003}, /* Windows Server 2003 */ 697f0719039085cc40114abce84cf29fe57da226f4Bob Moore {"Windows 2001 SP2", ACPI_OSI_WIN_XP_SP2}, /* Windows XP SP2 */ 707f0719039085cc40114abce84cf29fe57da226f4Bob Moore {"Windows 2001.1 SP1", ACPI_OSI_WINSRV_2003_SP1}, /* Windows Server 2003 SP1 - Added 03/2006 */ 717f0719039085cc40114abce84cf29fe57da226f4Bob Moore {"Windows 2006", ACPI_OSI_WIN_VISTA}, /* Windows Vista - Added 03/2006 */ 72eb752552464dbb7a99f8a975ec3b9355893cedd4Bob Moore {"Windows 2006.1", ACPI_OSI_WINSRV_2008}, /* Windows Server 2008 - Added 09/2009 */ 73eb752552464dbb7a99f8a975ec3b9355893cedd4Bob Moore {"Windows 2006 SP1", ACPI_OSI_WIN_VISTA_SP1}, /* Windows Vista SP1 - Added 09/2009 */ 74eb752552464dbb7a99f8a975ec3b9355893cedd4Bob Moore {"Windows 2009", ACPI_OSI_WIN_7}, /* Windows 7 and Server 2008 R2 - Added 09/2009 */ 75b229cf92eee616c7cb5ad8cdb35a19b119f00bc8Bob Moore 76b229cf92eee616c7cb5ad8cdb35a19b119f00bc8Bob Moore /* Feature Group Strings */ 77b229cf92eee616c7cb5ad8cdb35a19b119f00bc8Bob Moore 787f0719039085cc40114abce84cf29fe57da226f4Bob Moore {"Extended Address Space Descriptor", 0} 797f0719039085cc40114abce84cf29fe57da226f4Bob Moore 807f0719039085cc40114abce84cf29fe57da226f4Bob Moore /* 817f0719039085cc40114abce84cf29fe57da226f4Bob Moore * All "optional" feature group strings (features that are implemented 827f0719039085cc40114abce84cf29fe57da226f4Bob Moore * by the host) should be implemented in the host version of 837f0719039085cc40114abce84cf29fe57da226f4Bob Moore * acpi_os_validate_interface and should not be added here. 847f0719039085cc40114abce84cf29fe57da226f4Bob Moore */ 85b229cf92eee616c7cb5ad8cdb35a19b119f00bc8Bob Moore}; 86b229cf92eee616c7cb5ad8cdb35a19b119f00bc8Bob Moore 871da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/******************************************************************************* 881da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 891da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * FUNCTION: acpi_ut_osi_implementation 901da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 911da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * PARAMETERS: walk_state - Current walk state 921da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 931da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * RETURN: Status 941da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 95b229cf92eee616c7cb5ad8cdb35a19b119f00bc8Bob Moore * DESCRIPTION: Implementation of the _OSI predefined control method 961da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 971da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds ******************************************************************************/ 981da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 994be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brownacpi_status acpi_ut_osi_implementation(struct acpi_walk_state *walk_state) 1001da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds{ 101b229cf92eee616c7cb5ad8cdb35a19b119f00bc8Bob Moore acpi_status status; 1024be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown union acpi_operand_object *string_desc; 1034be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown union acpi_operand_object *return_desc; 104c114e4b6c606c7f174b752f946fcfb0e7e61a347Bob Moore u32 return_value; 10567a119f990063f5662574f6d6414fe9bc5ece86aBob Moore u32 i; 1061da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 107b229cf92eee616c7cb5ad8cdb35a19b119f00bc8Bob Moore ACPI_FUNCTION_TRACE(ut_osi_implementation); 1081da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 1091da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* Validate the string input argument */ 1101da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 1111da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds string_desc = walk_state->arguments[0].object; 1121da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds if (!string_desc || (string_desc->common.type != ACPI_TYPE_STRING)) { 1134be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown return_ACPI_STATUS(AE_TYPE); 1141da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } 1151da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 116b229cf92eee616c7cb5ad8cdb35a19b119f00bc8Bob Moore /* Create a return object */ 1171da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 1184be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown return_desc = acpi_ut_create_internal_object(ACPI_TYPE_INTEGER); 1191da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds if (!return_desc) { 1204be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown return_ACPI_STATUS(AE_NO_MEMORY); 1211da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } 1221da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 123c114e4b6c606c7f174b752f946fcfb0e7e61a347Bob Moore /* Default return value is 0, NOT SUPPORTED */ 1241da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 125c114e4b6c606c7f174b752f946fcfb0e7e61a347Bob Moore return_value = 0; 126b229cf92eee616c7cb5ad8cdb35a19b119f00bc8Bob Moore 127b229cf92eee616c7cb5ad8cdb35a19b119f00bc8Bob Moore /* Compare input string to static table of supported interfaces */ 12852fc0b026e99b5d5d585095148d997d5634bbc25Bob Moore 129b229cf92eee616c7cb5ad8cdb35a19b119f00bc8Bob Moore for (i = 0; i < ACPI_ARRAY_LENGTH(acpi_interfaces_supported); i++) { 130ec41f193eadb6301f3c052b5e0dbc0b5636982e8Bob Moore if (!ACPI_STRCMP(string_desc->string.pointer, 1317f0719039085cc40114abce84cf29fe57da226f4Bob Moore acpi_interfaces_supported[i].name)) { 1327f0719039085cc40114abce84cf29fe57da226f4Bob Moore /* 1337f0719039085cc40114abce84cf29fe57da226f4Bob Moore * The interface is supported. 1347f0719039085cc40114abce84cf29fe57da226f4Bob Moore * Update the osi_data if necessary. We keep track of the latest 1357f0719039085cc40114abce84cf29fe57da226f4Bob Moore * version of Windows that has been requested by the BIOS. 1367f0719039085cc40114abce84cf29fe57da226f4Bob Moore */ 1377f0719039085cc40114abce84cf29fe57da226f4Bob Moore if (acpi_interfaces_supported[i].value > 1387f0719039085cc40114abce84cf29fe57da226f4Bob Moore acpi_gbl_osi_data) { 1397f0719039085cc40114abce84cf29fe57da226f4Bob Moore acpi_gbl_osi_data = 1407f0719039085cc40114abce84cf29fe57da226f4Bob Moore acpi_interfaces_supported[i].value; 1417f0719039085cc40114abce84cf29fe57da226f4Bob Moore } 142c114e4b6c606c7f174b752f946fcfb0e7e61a347Bob Moore 143c114e4b6c606c7f174b752f946fcfb0e7e61a347Bob Moore return_value = ACPI_UINT32_MAX; 144c114e4b6c606c7f174b752f946fcfb0e7e61a347Bob Moore goto exit; 1451da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } 1461da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } 1471da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 148b229cf92eee616c7cb5ad8cdb35a19b119f00bc8Bob Moore /* 149b229cf92eee616c7cb5ad8cdb35a19b119f00bc8Bob Moore * Did not match the string in the static table, call the host OSL to 150b229cf92eee616c7cb5ad8cdb35a19b119f00bc8Bob Moore * check for a match with one of the optional strings (such as 151b229cf92eee616c7cb5ad8cdb35a19b119f00bc8Bob Moore * "Module Device", "3.0 Thermal Model", etc.) 152b229cf92eee616c7cb5ad8cdb35a19b119f00bc8Bob Moore */ 153b229cf92eee616c7cb5ad8cdb35a19b119f00bc8Bob Moore status = acpi_os_validate_interface(string_desc->string.pointer); 154b229cf92eee616c7cb5ad8cdb35a19b119f00bc8Bob Moore if (ACPI_SUCCESS(status)) { 155c114e4b6c606c7f174b752f946fcfb0e7e61a347Bob Moore 156c114e4b6c606c7f174b752f946fcfb0e7e61a347Bob Moore /* The interface is supported */ 157c114e4b6c606c7f174b752f946fcfb0e7e61a347Bob Moore 158c114e4b6c606c7f174b752f946fcfb0e7e61a347Bob Moore return_value = ACPI_UINT32_MAX; 159b229cf92eee616c7cb5ad8cdb35a19b119f00bc8Bob Moore } 160b229cf92eee616c7cb5ad8cdb35a19b119f00bc8Bob Moore 161c114e4b6c606c7f174b752f946fcfb0e7e61a347Bob Mooreexit: 162c114e4b6c606c7f174b752f946fcfb0e7e61a347Bob Moore ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, 163c114e4b6c606c7f174b752f946fcfb0e7e61a347Bob Moore "ACPI: BIOS _OSI(%s) is %ssupported\n", 164c114e4b6c606c7f174b752f946fcfb0e7e61a347Bob Moore string_desc->string.pointer, return_value == 0 ? "not " : "")); 165c114e4b6c606c7f174b752f946fcfb0e7e61a347Bob Moore 166c114e4b6c606c7f174b752f946fcfb0e7e61a347Bob Moore /* Complete the return value */ 167b229cf92eee616c7cb5ad8cdb35a19b119f00bc8Bob Moore 168c114e4b6c606c7f174b752f946fcfb0e7e61a347Bob Moore return_desc->integer.value = return_value; 169c114e4b6c606c7f174b752f946fcfb0e7e61a347Bob Moore walk_state->return_desc = return_desc; 170c114e4b6c606c7f174b752f946fcfb0e7e61a347Bob Moore return_ACPI_STATUS (AE_OK); 1711da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds} 1721da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 1731da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/******************************************************************************* 1741da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 175ae00d812436dc968f4a5dea7757b6a94910b6dc4Len Brown * FUNCTION: acpi_osi_invalidate 176ae00d812436dc968f4a5dea7757b6a94910b6dc4Len Brown * 177ae00d812436dc968f4a5dea7757b6a94910b6dc4Len Brown * PARAMETERS: interface_string 178ae00d812436dc968f4a5dea7757b6a94910b6dc4Len Brown * 179ae00d812436dc968f4a5dea7757b6a94910b6dc4Len Brown * RETURN: Status 180ae00d812436dc968f4a5dea7757b6a94910b6dc4Len Brown * 181ae00d812436dc968f4a5dea7757b6a94910b6dc4Len Brown * DESCRIPTION: invalidate string in pre-defiend _OSI string list 182ae00d812436dc968f4a5dea7757b6a94910b6dc4Len Brown * 183ae00d812436dc968f4a5dea7757b6a94910b6dc4Len Brown ******************************************************************************/ 184ae00d812436dc968f4a5dea7757b6a94910b6dc4Len Brown 185ae00d812436dc968f4a5dea7757b6a94910b6dc4Len Brownacpi_status acpi_osi_invalidate(char *interface) 186ae00d812436dc968f4a5dea7757b6a94910b6dc4Len Brown{ 187ae00d812436dc968f4a5dea7757b6a94910b6dc4Len Brown int i; 188ae00d812436dc968f4a5dea7757b6a94910b6dc4Len Brown 189ae00d812436dc968f4a5dea7757b6a94910b6dc4Len Brown for (i = 0; i < ACPI_ARRAY_LENGTH(acpi_interfaces_supported); i++) { 1907f0719039085cc40114abce84cf29fe57da226f4Bob Moore if (!ACPI_STRCMP(interface, acpi_interfaces_supported[i].name)) { 1917f0719039085cc40114abce84cf29fe57da226f4Bob Moore *acpi_interfaces_supported[i].name = '\0'; 192ae00d812436dc968f4a5dea7757b6a94910b6dc4Len Brown return AE_OK; 193ae00d812436dc968f4a5dea7757b6a94910b6dc4Len Brown } 194ae00d812436dc968f4a5dea7757b6a94910b6dc4Len Brown } 195ae00d812436dc968f4a5dea7757b6a94910b6dc4Len Brown return AE_NOT_FOUND; 196ae00d812436dc968f4a5dea7757b6a94910b6dc4Len Brown} 197ae00d812436dc968f4a5dea7757b6a94910b6dc4Len Brown 198ae00d812436dc968f4a5dea7757b6a94910b6dc4Len Brown/******************************************************************************* 199ae00d812436dc968f4a5dea7757b6a94910b6dc4Len Brown * 2001da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * FUNCTION: acpi_ut_evaluate_object 2011da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 2021da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * PARAMETERS: prefix_node - Starting node 2031da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Path - Path to object from starting node 2041da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * expected_return_types - Bitmap of allowed return types 2051da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * return_desc - Where a return value is stored 2061da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 2071da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * RETURN: Status 2081da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 2091da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * DESCRIPTION: Evaluates a namespace object and verifies the type of the 21015b8dd53f5ffaf8e2d9095c423f713423f576c0fBob Moore * return object. Common code that simplifies accessing objects 2111da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * that have required return objects of fixed types. 2121da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 2131da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * NOTE: Internal function, no parameter validation 2141da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 2151da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds ******************************************************************************/ 2161da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 2171da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsacpi_status 2184be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brownacpi_ut_evaluate_object(struct acpi_namespace_node *prefix_node, 2194be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown char *path, 2204be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown u32 expected_return_btypes, 2214be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown union acpi_operand_object **return_desc) 2221da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds{ 2234119532c95547821dbe72d6916dfa1b2148475b3Bob Moore struct acpi_evaluate_info *info; 2244be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown acpi_status status; 2254be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown u32 return_btype; 2261da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 227b229cf92eee616c7cb5ad8cdb35a19b119f00bc8Bob Moore ACPI_FUNCTION_TRACE(ut_evaluate_object); 2281da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 2294119532c95547821dbe72d6916dfa1b2148475b3Bob Moore /* Allocate the evaluation information block */ 2304119532c95547821dbe72d6916dfa1b2148475b3Bob Moore 2314119532c95547821dbe72d6916dfa1b2148475b3Bob Moore info = ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_evaluate_info)); 2324119532c95547821dbe72d6916dfa1b2148475b3Bob Moore if (!info) { 2334119532c95547821dbe72d6916dfa1b2148475b3Bob Moore return_ACPI_STATUS(AE_NO_MEMORY); 2344119532c95547821dbe72d6916dfa1b2148475b3Bob Moore } 2354119532c95547821dbe72d6916dfa1b2148475b3Bob Moore 2364119532c95547821dbe72d6916dfa1b2148475b3Bob Moore info->prefix_node = prefix_node; 2374119532c95547821dbe72d6916dfa1b2148475b3Bob Moore info->pathname = path; 2381da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 2391da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* Evaluate the object/method */ 2401da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 2414119532c95547821dbe72d6916dfa1b2148475b3Bob Moore status = acpi_ns_evaluate(info); 2424be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown if (ACPI_FAILURE(status)) { 2431da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds if (status == AE_NOT_FOUND) { 2444be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown ACPI_DEBUG_PRINT((ACPI_DB_EXEC, 2454be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown "[%4.4s.%s] was not found\n", 2464be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown acpi_ut_get_node_name(prefix_node), 2474be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown path)); 2484be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown } else { 249b8e4d89357fc434618a59c1047cac72641191805Bob Moore ACPI_ERROR_METHOD("Method execution failed", 250b8e4d89357fc434618a59c1047cac72641191805Bob Moore prefix_node, path, status); 2511da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } 2521da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 2534119532c95547821dbe72d6916dfa1b2148475b3Bob Moore goto cleanup; 2541da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } 2551da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 2561da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* Did we get a return object? */ 2571da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 2584119532c95547821dbe72d6916dfa1b2148475b3Bob Moore if (!info->return_object) { 2591da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds if (expected_return_btypes) { 260b8e4d89357fc434618a59c1047cac72641191805Bob Moore ACPI_ERROR_METHOD("No object was returned from", 261b8e4d89357fc434618a59c1047cac72641191805Bob Moore prefix_node, path, AE_NOT_EXIST); 2621da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 2634119532c95547821dbe72d6916dfa1b2148475b3Bob Moore status = AE_NOT_EXIST; 2641da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } 2651da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 2664119532c95547821dbe72d6916dfa1b2148475b3Bob Moore goto cleanup; 2671da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } 2681da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 2691da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* Map the return object type to the bitmapped type */ 2701da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 2713371c19c294a4cb3649aa4e84606be8a1d999e61Bob Moore switch ((info->return_object)->common.type) { 2721da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds case ACPI_TYPE_INTEGER: 2731da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds return_btype = ACPI_BTYPE_INTEGER; 2741da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds break; 2751da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 2761da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds case ACPI_TYPE_BUFFER: 2771da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds return_btype = ACPI_BTYPE_BUFFER; 2781da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds break; 2791da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 2801da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds case ACPI_TYPE_STRING: 2811da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds return_btype = ACPI_BTYPE_STRING; 2821da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds break; 2831da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 2841da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds case ACPI_TYPE_PACKAGE: 2851da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds return_btype = ACPI_BTYPE_PACKAGE; 2861da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds break; 2871da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 2881da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds default: 2891da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds return_btype = 0; 2901da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds break; 2911da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } 2921da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 2934be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown if ((acpi_gbl_enable_interpreter_slack) && (!expected_return_btypes)) { 2941da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* 29515b8dd53f5ffaf8e2d9095c423f713423f576c0fBob Moore * We received a return object, but one was not expected. This can 2961da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * happen frequently if the "implicit return" feature is enabled. 2971da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Just delete the return object and return AE_OK. 2981da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds */ 2994119532c95547821dbe72d6916dfa1b2148475b3Bob Moore acpi_ut_remove_reference(info->return_object); 3004119532c95547821dbe72d6916dfa1b2148475b3Bob Moore goto cleanup; 3011da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } 3021da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 3031da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* Is the return object one of the expected types? */ 3041da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 3051da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds if (!(expected_return_btypes & return_btype)) { 306b8e4d89357fc434618a59c1047cac72641191805Bob Moore ACPI_ERROR_METHOD("Return object type is incorrect", 307b8e4d89357fc434618a59c1047cac72641191805Bob Moore prefix_node, path, AE_TYPE); 308b8e4d89357fc434618a59c1047cac72641191805Bob Moore 309b8e4d89357fc434618a59c1047cac72641191805Bob Moore ACPI_ERROR((AE_INFO, 310f6a22b0bc417042e83117f52ab1a03696af185abBob Moore "Type returned from %s was incorrect: %s, expected Btypes: 0x%X", 311b8e4d89357fc434618a59c1047cac72641191805Bob Moore path, 3124119532c95547821dbe72d6916dfa1b2148475b3Bob Moore acpi_ut_get_object_type_name(info->return_object), 313b8e4d89357fc434618a59c1047cac72641191805Bob Moore expected_return_btypes)); 3141da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 3151da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* On error exit, we must delete the return object */ 3161da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 3174119532c95547821dbe72d6916dfa1b2148475b3Bob Moore acpi_ut_remove_reference(info->return_object); 3184119532c95547821dbe72d6916dfa1b2148475b3Bob Moore status = AE_TYPE; 3194119532c95547821dbe72d6916dfa1b2148475b3Bob Moore goto cleanup; 3201da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } 3211da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 3221da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* Object type is OK, return it */ 3231da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 3244119532c95547821dbe72d6916dfa1b2148475b3Bob Moore *return_desc = info->return_object; 3254119532c95547821dbe72d6916dfa1b2148475b3Bob Moore 3264119532c95547821dbe72d6916dfa1b2148475b3Bob Moore cleanup: 3274119532c95547821dbe72d6916dfa1b2148475b3Bob Moore ACPI_FREE(info); 3284119532c95547821dbe72d6916dfa1b2148475b3Bob Moore return_ACPI_STATUS(status); 3291da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds} 3301da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 3311da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/******************************************************************************* 3321da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 3331da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * FUNCTION: acpi_ut_evaluate_numeric_object 3341da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 33544f6c01242da4e162f28d8e1216a8c7a91174605Robert Moore * PARAMETERS: object_name - Object name to be evaluated 3361da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * device_node - Node for the device 33715b8dd53f5ffaf8e2d9095c423f713423f576c0fBob Moore * Value - Where the value is returned 3381da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 3391da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * RETURN: Status 3401da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 3411da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * DESCRIPTION: Evaluates a numeric namespace object for a selected device 34215b8dd53f5ffaf8e2d9095c423f713423f576c0fBob Moore * and stores result in *Value. 3431da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 3441da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * NOTE: Internal function, no parameter validation 3451da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 3461da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds ******************************************************************************/ 3471da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 3481da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsacpi_status 3494be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brownacpi_ut_evaluate_numeric_object(char *object_name, 3504be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown struct acpi_namespace_node *device_node, 3515df7e6cb42da36c7d878239bebc81907b15f3943Bob Moore u64 *value) 3521da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds{ 3534be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown union acpi_operand_object *obj_desc; 3544be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown acpi_status status; 3551da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 356b229cf92eee616c7cb5ad8cdb35a19b119f00bc8Bob Moore ACPI_FUNCTION_TRACE(ut_evaluate_numeric_object); 3571da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 3584be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown status = acpi_ut_evaluate_object(device_node, object_name, 3594be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown ACPI_BTYPE_INTEGER, &obj_desc); 3604be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown if (ACPI_FAILURE(status)) { 3614be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown return_ACPI_STATUS(status); 3621da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } 3631da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 3641da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* Get the returned Integer */ 3651da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 36615b8dd53f5ffaf8e2d9095c423f713423f576c0fBob Moore *value = obj_desc->integer.value; 3671da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 3681da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* On exit, we must delete the return object */ 3691da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 3704be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown acpi_ut_remove_reference(obj_desc); 3714be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown return_ACPI_STATUS(status); 3721da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds} 3731da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 3741da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/******************************************************************************* 3751da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 3761da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * FUNCTION: acpi_ut_execute_STA 3771da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 3781da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * PARAMETERS: device_node - Node for the device 37944f6c01242da4e162f28d8e1216a8c7a91174605Robert Moore * Flags - Where the status flags are returned 3801da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 3811da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * RETURN: Status 3821da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 3831da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * DESCRIPTION: Executes _STA for selected device and stores results in 3841da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * *Flags. 3851da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 3861da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * NOTE: Internal function, no parameter validation 3871da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 3881da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds ******************************************************************************/ 3891da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 3901da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsacpi_status 3914be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brownacpi_ut_execute_STA(struct acpi_namespace_node *device_node, u32 * flags) 3921da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds{ 3934be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown union acpi_operand_object *obj_desc; 3944be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown acpi_status status; 3951da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 396b229cf92eee616c7cb5ad8cdb35a19b119f00bc8Bob Moore ACPI_FUNCTION_TRACE(ut_execute_STA); 3971da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 3984be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown status = acpi_ut_evaluate_object(device_node, METHOD_NAME__STA, 3994be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown ACPI_BTYPE_INTEGER, &obj_desc); 4004be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown if (ACPI_FAILURE(status)) { 4011da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds if (AE_NOT_FOUND == status) { 4024be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown ACPI_DEBUG_PRINT((ACPI_DB_EXEC, 4034be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown "_STA on %4.4s was not found, assuming device is present\n", 4044be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown acpi_ut_get_node_name(device_node))); 4051da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 406defba1d8f233c0d5cf3e1ea6aeb898eca7231860Bob Moore *flags = ACPI_UINT32_MAX; 4071da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds status = AE_OK; 4081da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } 4091da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 4104be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown return_ACPI_STATUS(status); 4111da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } 4121da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 4131da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* Extract the status flags */ 4141da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 4151da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *flags = (u32) obj_desc->integer.value; 4161da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 4171da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* On exit, we must delete the return object */ 4181da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 4194be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown acpi_ut_remove_reference(obj_desc); 4204be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown return_ACPI_STATUS(status); 4211da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds} 4221da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 4231da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/******************************************************************************* 4241da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 42515b8dd53f5ffaf8e2d9095c423f713423f576c0fBob Moore * FUNCTION: acpi_ut_execute_power_methods 4261da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 4271da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * PARAMETERS: device_node - Node for the device 42815b8dd53f5ffaf8e2d9095c423f713423f576c0fBob Moore * method_names - Array of power method names 42915b8dd53f5ffaf8e2d9095c423f713423f576c0fBob Moore * method_count - Number of methods to execute 43015b8dd53f5ffaf8e2d9095c423f713423f576c0fBob Moore * out_values - Where the power method values are returned 4311da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 43215b8dd53f5ffaf8e2d9095c423f713423f576c0fBob Moore * RETURN: Status, out_values 4331da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 43415b8dd53f5ffaf8e2d9095c423f713423f576c0fBob Moore * DESCRIPTION: Executes the specified power methods for the device and returns 43515b8dd53f5ffaf8e2d9095c423f713423f576c0fBob Moore * the result(s). 4361da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 4371da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * NOTE: Internal function, no parameter validation 4381da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 43915b8dd53f5ffaf8e2d9095c423f713423f576c0fBob Moore******************************************************************************/ 4401da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 4411da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsacpi_status 44215b8dd53f5ffaf8e2d9095c423f713423f576c0fBob Mooreacpi_ut_execute_power_methods(struct acpi_namespace_node *device_node, 44315b8dd53f5ffaf8e2d9095c423f713423f576c0fBob Moore const char **method_names, 44415b8dd53f5ffaf8e2d9095c423f713423f576c0fBob Moore u8 method_count, u8 *out_values) 4451da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds{ 4464be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown union acpi_operand_object *obj_desc; 4474be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown acpi_status status; 44815b8dd53f5ffaf8e2d9095c423f713423f576c0fBob Moore acpi_status final_status = AE_NOT_FOUND; 4494be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown u32 i; 4501da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 45115b8dd53f5ffaf8e2d9095c423f713423f576c0fBob Moore ACPI_FUNCTION_TRACE(ut_execute_power_methods); 4521da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 45315b8dd53f5ffaf8e2d9095c423f713423f576c0fBob Moore for (i = 0; i < method_count; i++) { 45415b8dd53f5ffaf8e2d9095c423f713423f576c0fBob Moore /* 45515b8dd53f5ffaf8e2d9095c423f713423f576c0fBob Moore * Execute the power method (_sx_d or _sx_w). The only allowable 45615b8dd53f5ffaf8e2d9095c423f713423f576c0fBob Moore * return type is an Integer. 45715b8dd53f5ffaf8e2d9095c423f713423f576c0fBob Moore */ 4584be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown status = acpi_ut_evaluate_object(device_node, 459defba1d8f233c0d5cf3e1ea6aeb898eca7231860Bob Moore ACPI_CAST_PTR(char, 46015b8dd53f5ffaf8e2d9095c423f713423f576c0fBob Moore method_names[i]), 461defba1d8f233c0d5cf3e1ea6aeb898eca7231860Bob Moore ACPI_BTYPE_INTEGER, &obj_desc); 46215b8dd53f5ffaf8e2d9095c423f713423f576c0fBob Moore if (ACPI_SUCCESS(status)) { 46315b8dd53f5ffaf8e2d9095c423f713423f576c0fBob Moore out_values[i] = (u8)obj_desc->integer.value; 4641da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 4651da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* Delete the return object */ 4661da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 4674be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown acpi_ut_remove_reference(obj_desc); 46815b8dd53f5ffaf8e2d9095c423f713423f576c0fBob Moore final_status = AE_OK; /* At least one value is valid */ 46915b8dd53f5ffaf8e2d9095c423f713423f576c0fBob Moore continue; 4701da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } 47115b8dd53f5ffaf8e2d9095c423f713423f576c0fBob Moore 47215b8dd53f5ffaf8e2d9095c423f713423f576c0fBob Moore out_values[i] = ACPI_UINT8_MAX; 47315b8dd53f5ffaf8e2d9095c423f713423f576c0fBob Moore if (status == AE_NOT_FOUND) { 47415b8dd53f5ffaf8e2d9095c423f713423f576c0fBob Moore continue; /* Ignore if not found */ 47515b8dd53f5ffaf8e2d9095c423f713423f576c0fBob Moore } 47615b8dd53f5ffaf8e2d9095c423f713423f576c0fBob Moore 47715b8dd53f5ffaf8e2d9095c423f713423f576c0fBob Moore ACPI_DEBUG_PRINT((ACPI_DB_EXEC, 47815b8dd53f5ffaf8e2d9095c423f713423f576c0fBob Moore "Failed %s on Device %4.4s, %s\n", 47915b8dd53f5ffaf8e2d9095c423f713423f576c0fBob Moore ACPI_CAST_PTR(char, method_names[i]), 48015b8dd53f5ffaf8e2d9095c423f713423f576c0fBob Moore acpi_ut_get_node_name(device_node), 48115b8dd53f5ffaf8e2d9095c423f713423f576c0fBob Moore acpi_format_exception(status))); 4821da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } 4831da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 48415b8dd53f5ffaf8e2d9095c423f713423f576c0fBob Moore return_ACPI_STATUS(final_status); 4851da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds} 486