2 /******************************************************************************
4 * Module Name: exresnte - AML Interpreter object resolution
6 *****************************************************************************/
9 * Copyright (C) 2000 - 2011, Intel Corp.
10 * All rights reserved.
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
15 * 1. Redistributions of source code must retain the above copyright
16 * notice, this list of conditions, and the following disclaimer,
17 * without modification.
18 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
19 * substantially similar to the "NO WARRANTY" disclaimer below
20 * ("Disclaimer") and any redistribution must be conditioned upon
21 * including a substantially similar Disclaimer requirement for further
22 * binary redistribution.
23 * 3. Neither the names of the above-listed copyright holders nor the names
24 * of any contributors may be used to endorse or promote products derived
25 * from this software without specific prior written permission.
27 * Alternatively, this software may be distributed under the terms of the
28 * GNU General Public License ("GPL") version 2 as published by the Free
29 * Software Foundation.
32 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
33 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
34 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
35 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
36 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
37 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
38 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
39 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
40 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
41 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
42 * POSSIBILITY OF SUCH DAMAGES.
45 #define __EXRESNTE_C__
47 #include <contrib/dev/acpica/include/acpi.h>
48 #include <contrib/dev/acpica/include/accommon.h>
49 #include <contrib/dev/acpica/include/acdispat.h>
50 #include <contrib/dev/acpica/include/acinterp.h>
51 #include <contrib/dev/acpica/include/acnamesp.h>
54 #define _COMPONENT ACPI_EXECUTER
55 ACPI_MODULE_NAME ("exresnte")
58 /*******************************************************************************
60 * FUNCTION: AcpiExResolveNodeToValue
62 * PARAMETERS: ObjectPtr - Pointer to a location that contains
63 * a pointer to a NS node, and will receive a
64 * pointer to the resolved object.
65 * WalkState - Current state. Valid only if executing AML
66 * code. NULL if simply resolving an object
70 * DESCRIPTION: Resolve a Namespace node to a valued object
72 * Note: for some of the data types, the pointer attached to the Node
73 * can be either a pointer to an actual internal object or a pointer into the
74 * AML stream itself. These types are currently:
82 ******************************************************************************/
85 AcpiExResolveNodeToValue (
86 ACPI_NAMESPACE_NODE **ObjectPtr,
87 ACPI_WALK_STATE *WalkState)
90 ACPI_STATUS Status = AE_OK;
91 ACPI_OPERAND_OBJECT *SourceDesc;
92 ACPI_OPERAND_OBJECT *ObjDesc = NULL;
93 ACPI_NAMESPACE_NODE *Node;
94 ACPI_OBJECT_TYPE EntryType;
97 ACPI_FUNCTION_TRACE (ExResolveNodeToValue);
101 * The stack pointer points to a ACPI_NAMESPACE_NODE (Node). Get the
102 * object that is attached to the Node.
105 SourceDesc = AcpiNsGetAttachedObject (Node);
106 EntryType = AcpiNsGetType ((ACPI_HANDLE) Node);
108 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Entry=%p SourceDesc=%p [%s]\n",
109 Node, SourceDesc, AcpiUtGetTypeName (EntryType)));
111 if ((EntryType == ACPI_TYPE_LOCAL_ALIAS) ||
112 (EntryType == ACPI_TYPE_LOCAL_METHOD_ALIAS))
114 /* There is always exactly one level of indirection */
116 Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, Node->Object);
117 SourceDesc = AcpiNsGetAttachedObject (Node);
118 EntryType = AcpiNsGetType ((ACPI_HANDLE) Node);
123 * Several object types require no further processing:
124 * 1) Device/Thermal objects don't have a "real" subobject, return the Node
125 * 2) Method locals and arguments have a pseudo-Node
126 * 3) 10/2007: Added method type to assist with Package construction.
128 if ((EntryType == ACPI_TYPE_DEVICE) ||
129 (EntryType == ACPI_TYPE_THERMAL) ||
130 (EntryType == ACPI_TYPE_METHOD) ||
131 (Node->Flags & (ANOBJ_METHOD_ARG | ANOBJ_METHOD_LOCAL)))
133 return_ACPI_STATUS (AE_OK);
138 ACPI_ERROR ((AE_INFO, "No object attached to node %p",
140 return_ACPI_STATUS (AE_AML_NO_OPERAND);
144 * Action is based on the type of the Node, which indicates the type
145 * of the attached object or pointer
149 case ACPI_TYPE_PACKAGE:
151 if (SourceDesc->Common.Type != ACPI_TYPE_PACKAGE)
153 ACPI_ERROR ((AE_INFO, "Object not a Package, type %s",
154 AcpiUtGetObjectTypeName (SourceDesc)));
155 return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
158 Status = AcpiDsGetPackageArguments (SourceDesc);
159 if (ACPI_SUCCESS (Status))
161 /* Return an additional reference to the object */
163 ObjDesc = SourceDesc;
164 AcpiUtAddReference (ObjDesc);
169 case ACPI_TYPE_BUFFER:
171 if (SourceDesc->Common.Type != ACPI_TYPE_BUFFER)
173 ACPI_ERROR ((AE_INFO, "Object not a Buffer, type %s",
174 AcpiUtGetObjectTypeName (SourceDesc)));
175 return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
178 Status = AcpiDsGetBufferArguments (SourceDesc);
179 if (ACPI_SUCCESS (Status))
181 /* Return an additional reference to the object */
183 ObjDesc = SourceDesc;
184 AcpiUtAddReference (ObjDesc);
189 case ACPI_TYPE_STRING:
191 if (SourceDesc->Common.Type != ACPI_TYPE_STRING)
193 ACPI_ERROR ((AE_INFO, "Object not a String, type %s",
194 AcpiUtGetObjectTypeName (SourceDesc)));
195 return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
198 /* Return an additional reference to the object */
200 ObjDesc = SourceDesc;
201 AcpiUtAddReference (ObjDesc);
205 case ACPI_TYPE_INTEGER:
207 if (SourceDesc->Common.Type != ACPI_TYPE_INTEGER)
209 ACPI_ERROR ((AE_INFO, "Object not a Integer, type %s",
210 AcpiUtGetObjectTypeName (SourceDesc)));
211 return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
214 /* Return an additional reference to the object */
216 ObjDesc = SourceDesc;
217 AcpiUtAddReference (ObjDesc);
221 case ACPI_TYPE_BUFFER_FIELD:
222 case ACPI_TYPE_LOCAL_REGION_FIELD:
223 case ACPI_TYPE_LOCAL_BANK_FIELD:
224 case ACPI_TYPE_LOCAL_INDEX_FIELD:
226 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
227 "FieldRead Node=%p SourceDesc=%p Type=%X\n",
228 Node, SourceDesc, EntryType));
230 Status = AcpiExReadDataFromField (WalkState, SourceDesc, &ObjDesc);
233 /* For these objects, just return the object attached to the Node */
235 case ACPI_TYPE_MUTEX:
236 case ACPI_TYPE_POWER:
237 case ACPI_TYPE_PROCESSOR:
238 case ACPI_TYPE_EVENT:
239 case ACPI_TYPE_REGION:
241 /* Return an additional reference to the object */
243 ObjDesc = SourceDesc;
244 AcpiUtAddReference (ObjDesc);
247 /* TYPE_ANY is untyped, and thus there is no object associated with it */
251 ACPI_ERROR ((AE_INFO,
252 "Untyped entry %p, no attached object!", Node));
254 return_ACPI_STATUS (AE_AML_OPERAND_TYPE); /* Cannot be AE_TYPE */
257 case ACPI_TYPE_LOCAL_REFERENCE:
259 switch (SourceDesc->Reference.Class)
261 case ACPI_REFCLASS_TABLE: /* This is a DdbHandle */
262 case ACPI_REFCLASS_REFOF:
263 case ACPI_REFCLASS_INDEX:
265 /* Return an additional reference to the object */
267 ObjDesc = SourceDesc;
268 AcpiUtAddReference (ObjDesc);
272 /* No named references are allowed here */
274 ACPI_ERROR ((AE_INFO,
275 "Unsupported Reference type 0x%X",
276 SourceDesc->Reference.Class));
278 return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
285 /* Default case is for unknown types */
287 ACPI_ERROR ((AE_INFO,
288 "Node %p - Unknown object type 0x%X",
291 return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
293 } /* switch (EntryType) */
296 /* Return the object descriptor */
298 *ObjectPtr = (void *) ObjDesc;
299 return_ACPI_STATUS (Status);