1 /******************************************************************************
3 * Module Name: exresnte - AML Interpreter object resolution
5 *****************************************************************************/
8 * Copyright (C) 2000 - 2013, Intel Corp.
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
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.
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 #define __EXRESNTE_C__
46 #include <contrib/dev/acpica/include/acpi.h>
47 #include <contrib/dev/acpica/include/accommon.h>
48 #include <contrib/dev/acpica/include/acdispat.h>
49 #include <contrib/dev/acpica/include/acinterp.h>
50 #include <contrib/dev/acpica/include/acnamesp.h>
53 #define _COMPONENT ACPI_EXECUTER
54 ACPI_MODULE_NAME ("exresnte")
57 /*******************************************************************************
59 * FUNCTION: AcpiExResolveNodeToValue
61 * PARAMETERS: ObjectPtr - Pointer to a location that contains
62 * a pointer to a NS node, and will receive a
63 * pointer to the resolved object.
64 * WalkState - Current state. Valid only if executing AML
65 * code. NULL if simply resolving an object
69 * DESCRIPTION: Resolve a Namespace node to a valued object
71 * Note: for some of the data types, the pointer attached to the Node
72 * can be either a pointer to an actual internal object or a pointer into the
73 * AML stream itself. These types are currently:
81 ******************************************************************************/
84 AcpiExResolveNodeToValue (
85 ACPI_NAMESPACE_NODE **ObjectPtr,
86 ACPI_WALK_STATE *WalkState)
89 ACPI_STATUS Status = AE_OK;
90 ACPI_OPERAND_OBJECT *SourceDesc;
91 ACPI_OPERAND_OBJECT *ObjDesc = NULL;
92 ACPI_NAMESPACE_NODE *Node;
93 ACPI_OBJECT_TYPE EntryType;
96 ACPI_FUNCTION_TRACE (ExResolveNodeToValue);
100 * The stack pointer points to a ACPI_NAMESPACE_NODE (Node). Get the
101 * object that is attached to the Node.
104 SourceDesc = AcpiNsGetAttachedObject (Node);
105 EntryType = AcpiNsGetType ((ACPI_HANDLE) Node);
107 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Entry=%p SourceDesc=%p [%s]\n",
108 Node, SourceDesc, AcpiUtGetTypeName (EntryType)));
110 if ((EntryType == ACPI_TYPE_LOCAL_ALIAS) ||
111 (EntryType == ACPI_TYPE_LOCAL_METHOD_ALIAS))
113 /* There is always exactly one level of indirection */
115 Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, Node->Object);
116 SourceDesc = AcpiNsGetAttachedObject (Node);
117 EntryType = AcpiNsGetType ((ACPI_HANDLE) Node);
122 * Several object types require no further processing:
123 * 1) Device/Thermal objects don't have a "real" subobject, return the Node
124 * 2) Method locals and arguments have a pseudo-Node
125 * 3) 10/2007: Added method type to assist with Package construction.
127 if ((EntryType == ACPI_TYPE_DEVICE) ||
128 (EntryType == ACPI_TYPE_THERMAL) ||
129 (EntryType == ACPI_TYPE_METHOD) ||
130 (Node->Flags & (ANOBJ_METHOD_ARG | ANOBJ_METHOD_LOCAL)))
132 return_ACPI_STATUS (AE_OK);
137 ACPI_ERROR ((AE_INFO, "No object attached to node %p",
139 return_ACPI_STATUS (AE_AML_NO_OPERAND);
143 * Action is based on the type of the Node, which indicates the type
144 * of the attached object or pointer
148 case ACPI_TYPE_PACKAGE:
150 if (SourceDesc->Common.Type != ACPI_TYPE_PACKAGE)
152 ACPI_ERROR ((AE_INFO, "Object not a Package, type %s",
153 AcpiUtGetObjectTypeName (SourceDesc)));
154 return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
157 Status = AcpiDsGetPackageArguments (SourceDesc);
158 if (ACPI_SUCCESS (Status))
160 /* Return an additional reference to the object */
162 ObjDesc = SourceDesc;
163 AcpiUtAddReference (ObjDesc);
168 case ACPI_TYPE_BUFFER:
170 if (SourceDesc->Common.Type != ACPI_TYPE_BUFFER)
172 ACPI_ERROR ((AE_INFO, "Object not a Buffer, type %s",
173 AcpiUtGetObjectTypeName (SourceDesc)));
174 return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
177 Status = AcpiDsGetBufferArguments (SourceDesc);
178 if (ACPI_SUCCESS (Status))
180 /* Return an additional reference to the object */
182 ObjDesc = SourceDesc;
183 AcpiUtAddReference (ObjDesc);
188 case ACPI_TYPE_STRING:
190 if (SourceDesc->Common.Type != ACPI_TYPE_STRING)
192 ACPI_ERROR ((AE_INFO, "Object not a String, type %s",
193 AcpiUtGetObjectTypeName (SourceDesc)));
194 return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
197 /* Return an additional reference to the object */
199 ObjDesc = SourceDesc;
200 AcpiUtAddReference (ObjDesc);
204 case ACPI_TYPE_INTEGER:
206 if (SourceDesc->Common.Type != ACPI_TYPE_INTEGER)
208 ACPI_ERROR ((AE_INFO, "Object not a Integer, type %s",
209 AcpiUtGetObjectTypeName (SourceDesc)));
210 return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
213 /* Return an additional reference to the object */
215 ObjDesc = SourceDesc;
216 AcpiUtAddReference (ObjDesc);
220 case ACPI_TYPE_BUFFER_FIELD:
221 case ACPI_TYPE_LOCAL_REGION_FIELD:
222 case ACPI_TYPE_LOCAL_BANK_FIELD:
223 case ACPI_TYPE_LOCAL_INDEX_FIELD:
225 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
226 "FieldRead Node=%p SourceDesc=%p Type=%X\n",
227 Node, SourceDesc, EntryType));
229 Status = AcpiExReadDataFromField (WalkState, SourceDesc, &ObjDesc);
232 /* For these objects, just return the object attached to the Node */
234 case ACPI_TYPE_MUTEX:
235 case ACPI_TYPE_POWER:
236 case ACPI_TYPE_PROCESSOR:
237 case ACPI_TYPE_EVENT:
238 case ACPI_TYPE_REGION:
240 /* Return an additional reference to the object */
242 ObjDesc = SourceDesc;
243 AcpiUtAddReference (ObjDesc);
246 /* TYPE_ANY is untyped, and thus there is no object associated with it */
250 ACPI_ERROR ((AE_INFO,
251 "Untyped entry %p, no attached object!", Node));
253 return_ACPI_STATUS (AE_AML_OPERAND_TYPE); /* Cannot be AE_TYPE */
256 case ACPI_TYPE_LOCAL_REFERENCE:
258 switch (SourceDesc->Reference.Class)
260 case ACPI_REFCLASS_TABLE: /* This is a DdbHandle */
261 case ACPI_REFCLASS_REFOF:
262 case ACPI_REFCLASS_INDEX:
264 /* Return an additional reference to the object */
266 ObjDesc = SourceDesc;
267 AcpiUtAddReference (ObjDesc);
271 /* No named references are allowed here */
273 ACPI_ERROR ((AE_INFO,
274 "Unsupported Reference type 0x%X",
275 SourceDesc->Reference.Class));
277 return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
284 /* Default case is for unknown types */
286 ACPI_ERROR ((AE_INFO,
287 "Node %p - Unknown object type 0x%X",
290 return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
292 } /* switch (EntryType) */
295 /* Return the object descriptor */
297 *ObjectPtr = (void *) ObjDesc;
298 return_ACPI_STATUS (Status);