s390/ptrace: get rid of long longs in psw_bits
[linux/fpc-iii.git] / drivers / acpi / acpica / exresnte.c
blob1b372ef693088a3e656003f966cfe798e2e280d8
1 /******************************************************************************
3 * Module Name: exresnte - AML Interpreter object resolution
5 *****************************************************************************/
7 /*
8 * Copyright (C) 2000 - 2015, Intel Corp.
9 * All rights reserved.
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.
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.
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.
44 #include <acpi/acpi.h>
45 #include "accommon.h"
46 #include "acdispat.h"
47 #include "acinterp.h"
48 #include "acnamesp.h"
50 #define _COMPONENT ACPI_EXECUTER
51 ACPI_MODULE_NAME("exresnte")
53 /*******************************************************************************
55 * FUNCTION: acpi_ex_resolve_node_to_value
57 * PARAMETERS: object_ptr - Pointer to a location that contains
58 * a pointer to a NS node, and will receive a
59 * pointer to the resolved object.
60 * walk_state - Current state. Valid only if executing AML
61 * code. NULL if simply resolving an object
63 * RETURN: Status
65 * DESCRIPTION: Resolve a Namespace node to a valued object
67 * Note: for some of the data types, the pointer attached to the Node
68 * can be either a pointer to an actual internal object or a pointer into the
69 * AML stream itself. These types are currently:
71 * ACPI_TYPE_INTEGER
72 * ACPI_TYPE_STRING
73 * ACPI_TYPE_BUFFER
74 * ACPI_TYPE_MUTEX
75 * ACPI_TYPE_PACKAGE
77 ******************************************************************************/
78 acpi_status
79 acpi_ex_resolve_node_to_value(struct acpi_namespace_node **object_ptr,
80 struct acpi_walk_state *walk_state)
82 acpi_status status = AE_OK;
83 union acpi_operand_object *source_desc;
84 union acpi_operand_object *obj_desc = NULL;
85 struct acpi_namespace_node *node;
86 acpi_object_type entry_type;
88 ACPI_FUNCTION_TRACE(ex_resolve_node_to_value);
91 * The stack pointer points to a struct acpi_namespace_node (Node). Get the
92 * object that is attached to the Node.
94 node = *object_ptr;
95 source_desc = acpi_ns_get_attached_object(node);
96 entry_type = acpi_ns_get_type((acpi_handle) node);
98 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Entry=%p SourceDesc=%p [%s]\n",
99 node, source_desc,
100 acpi_ut_get_type_name(entry_type)));
102 if ((entry_type == ACPI_TYPE_LOCAL_ALIAS) ||
103 (entry_type == ACPI_TYPE_LOCAL_METHOD_ALIAS)) {
105 /* There is always exactly one level of indirection */
107 node = ACPI_CAST_PTR(struct acpi_namespace_node, node->object);
108 source_desc = acpi_ns_get_attached_object(node);
109 entry_type = acpi_ns_get_type((acpi_handle) node);
110 *object_ptr = node;
114 * Several object types require no further processing:
115 * 1) Device/Thermal objects don't have a "real" subobject, return the Node
116 * 2) Method locals and arguments have a pseudo-Node
117 * 3) 10/2007: Added method type to assist with Package construction.
119 if ((entry_type == ACPI_TYPE_DEVICE) ||
120 (entry_type == ACPI_TYPE_THERMAL) ||
121 (entry_type == ACPI_TYPE_METHOD) ||
122 (node->flags & (ANOBJ_METHOD_ARG | ANOBJ_METHOD_LOCAL))) {
123 return_ACPI_STATUS(AE_OK);
126 if (!source_desc) {
127 ACPI_ERROR((AE_INFO, "No object attached to node [%4.4s] %p",
128 node->name.ascii, node));
129 return_ACPI_STATUS(AE_AML_UNINITIALIZED_NODE);
133 * Action is based on the type of the Node, which indicates the type
134 * of the attached object or pointer
136 switch (entry_type) {
137 case ACPI_TYPE_PACKAGE:
139 if (source_desc->common.type != ACPI_TYPE_PACKAGE) {
140 ACPI_ERROR((AE_INFO, "Object not a Package, type %s",
141 acpi_ut_get_object_type_name(source_desc)));
142 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
145 status = acpi_ds_get_package_arguments(source_desc);
146 if (ACPI_SUCCESS(status)) {
148 /* Return an additional reference to the object */
150 obj_desc = source_desc;
151 acpi_ut_add_reference(obj_desc);
153 break;
155 case ACPI_TYPE_BUFFER:
157 if (source_desc->common.type != ACPI_TYPE_BUFFER) {
158 ACPI_ERROR((AE_INFO, "Object not a Buffer, type %s",
159 acpi_ut_get_object_type_name(source_desc)));
160 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
163 status = acpi_ds_get_buffer_arguments(source_desc);
164 if (ACPI_SUCCESS(status)) {
166 /* Return an additional reference to the object */
168 obj_desc = source_desc;
169 acpi_ut_add_reference(obj_desc);
171 break;
173 case ACPI_TYPE_STRING:
175 if (source_desc->common.type != ACPI_TYPE_STRING) {
176 ACPI_ERROR((AE_INFO, "Object not a String, type %s",
177 acpi_ut_get_object_type_name(source_desc)));
178 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
181 /* Return an additional reference to the object */
183 obj_desc = source_desc;
184 acpi_ut_add_reference(obj_desc);
185 break;
187 case ACPI_TYPE_INTEGER:
189 if (source_desc->common.type != ACPI_TYPE_INTEGER) {
190 ACPI_ERROR((AE_INFO, "Object not a Integer, type %s",
191 acpi_ut_get_object_type_name(source_desc)));
192 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
195 /* Return an additional reference to the object */
197 obj_desc = source_desc;
198 acpi_ut_add_reference(obj_desc);
199 break;
201 case ACPI_TYPE_BUFFER_FIELD:
202 case ACPI_TYPE_LOCAL_REGION_FIELD:
203 case ACPI_TYPE_LOCAL_BANK_FIELD:
204 case ACPI_TYPE_LOCAL_INDEX_FIELD:
206 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
207 "FieldRead Node=%p SourceDesc=%p Type=%X\n",
208 node, source_desc, entry_type));
210 status =
211 acpi_ex_read_data_from_field(walk_state, source_desc,
212 &obj_desc);
213 break;
215 /* For these objects, just return the object attached to the Node */
217 case ACPI_TYPE_MUTEX:
218 case ACPI_TYPE_POWER:
219 case ACPI_TYPE_PROCESSOR:
220 case ACPI_TYPE_EVENT:
221 case ACPI_TYPE_REGION:
223 /* Return an additional reference to the object */
225 obj_desc = source_desc;
226 acpi_ut_add_reference(obj_desc);
227 break;
229 /* TYPE_ANY is untyped, and thus there is no object associated with it */
231 case ACPI_TYPE_ANY:
233 ACPI_ERROR((AE_INFO,
234 "Untyped entry %p, no attached object!", node));
236 return_ACPI_STATUS(AE_AML_OPERAND_TYPE); /* Cannot be AE_TYPE */
238 case ACPI_TYPE_LOCAL_REFERENCE:
240 switch (source_desc->reference.class) {
241 case ACPI_REFCLASS_TABLE: /* This is a ddb_handle */
242 case ACPI_REFCLASS_REFOF:
243 case ACPI_REFCLASS_INDEX:
245 /* Return an additional reference to the object */
247 obj_desc = source_desc;
248 acpi_ut_add_reference(obj_desc);
249 break;
251 default:
253 /* No named references are allowed here */
255 ACPI_ERROR((AE_INFO,
256 "Unsupported Reference type 0x%X",
257 source_desc->reference.class));
259 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
261 break;
263 default:
265 /* Default case is for unknown types */
267 ACPI_ERROR((AE_INFO,
268 "Node %p - Unknown object type 0x%X",
269 node, entry_type));
271 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
273 } /* switch (entry_type) */
275 /* Return the object descriptor */
277 *object_ptr = (void *)obj_desc;
278 return_ACPI_STATUS(status);