1 /******************************************************************************
3 * Module Name: exresnte - AML Interpreter object resolution
5 *****************************************************************************/
8 * Copyright (C) 2000 - 2016, 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.
51 #define _COMPONENT ACPI_EXECUTER
52 ACPI_MODULE_NAME ("exresnte")
55 /*******************************************************************************
57 * FUNCTION: AcpiExResolveNodeToValue
59 * PARAMETERS: ObjectPtr - Pointer to a location that contains
60 * a pointer to a NS node, and will receive a
61 * pointer to the resolved object.
62 * WalkState - Current state. Valid only if executing AML
63 * code. NULL if simply resolving an object
67 * DESCRIPTION: Resolve a Namespace node to a valued object
69 * Note: for some of the data types, the pointer attached to the Node
70 * can be either a pointer to an actual internal object or a pointer into the
71 * AML stream itself. These types are currently:
79 ******************************************************************************/
82 AcpiExResolveNodeToValue (
83 ACPI_NAMESPACE_NODE
**ObjectPtr
,
84 ACPI_WALK_STATE
*WalkState
)
87 ACPI_STATUS Status
= AE_OK
;
88 ACPI_OPERAND_OBJECT
*SourceDesc
;
89 ACPI_OPERAND_OBJECT
*ObjDesc
= NULL
;
90 ACPI_NAMESPACE_NODE
*Node
;
91 ACPI_OBJECT_TYPE EntryType
;
94 ACPI_FUNCTION_TRACE (ExResolveNodeToValue
);
98 * The stack pointer points to a ACPI_NAMESPACE_NODE (Node). Get the
99 * object that is attached to the Node.
102 SourceDesc
= AcpiNsGetAttachedObject (Node
);
103 EntryType
= AcpiNsGetType ((ACPI_HANDLE
) Node
);
105 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC
, "Entry=%p SourceDesc=%p [%s]\n",
106 Node
, SourceDesc
, AcpiUtGetTypeName (EntryType
)));
108 if ((EntryType
== ACPI_TYPE_LOCAL_ALIAS
) ||
109 (EntryType
== ACPI_TYPE_LOCAL_METHOD_ALIAS
))
111 /* There is always exactly one level of indirection */
113 Node
= ACPI_CAST_PTR (ACPI_NAMESPACE_NODE
, Node
->Object
);
114 SourceDesc
= AcpiNsGetAttachedObject (Node
);
115 EntryType
= AcpiNsGetType ((ACPI_HANDLE
) Node
);
120 * Several object types require no further processing:
121 * 1) Device/Thermal objects don't have a "real" subobject, return Node
122 * 2) Method locals and arguments have a pseudo-Node
123 * 3) 10/2007: Added method type to assist with Package construction.
125 if ((EntryType
== ACPI_TYPE_DEVICE
) ||
126 (EntryType
== ACPI_TYPE_THERMAL
) ||
127 (EntryType
== ACPI_TYPE_METHOD
) ||
128 (Node
->Flags
& (ANOBJ_METHOD_ARG
| ANOBJ_METHOD_LOCAL
)))
130 return_ACPI_STATUS (AE_OK
);
135 ACPI_ERROR ((AE_INFO
, "No object attached to node [%4.4s] %p",
136 Node
->Name
.Ascii
, Node
));
137 return_ACPI_STATUS (AE_AML_UNINITIALIZED_NODE
);
141 * Action is based on the type of the Node, which indicates the type
142 * of the attached object or pointer
146 case ACPI_TYPE_PACKAGE
:
148 if (SourceDesc
->Common
.Type
!= ACPI_TYPE_PACKAGE
)
150 ACPI_ERROR ((AE_INFO
, "Object not a Package, type %s",
151 AcpiUtGetObjectTypeName (SourceDesc
)));
152 return_ACPI_STATUS (AE_AML_OPERAND_TYPE
);
155 Status
= AcpiDsGetPackageArguments (SourceDesc
);
156 if (ACPI_SUCCESS (Status
))
158 /* Return an additional reference to the object */
160 ObjDesc
= SourceDesc
;
161 AcpiUtAddReference (ObjDesc
);
165 case ACPI_TYPE_BUFFER
:
167 if (SourceDesc
->Common
.Type
!= ACPI_TYPE_BUFFER
)
169 ACPI_ERROR ((AE_INFO
, "Object not a Buffer, type %s",
170 AcpiUtGetObjectTypeName (SourceDesc
)));
171 return_ACPI_STATUS (AE_AML_OPERAND_TYPE
);
174 Status
= AcpiDsGetBufferArguments (SourceDesc
);
175 if (ACPI_SUCCESS (Status
))
177 /* Return an additional reference to the object */
179 ObjDesc
= SourceDesc
;
180 AcpiUtAddReference (ObjDesc
);
184 case ACPI_TYPE_STRING
:
186 if (SourceDesc
->Common
.Type
!= ACPI_TYPE_STRING
)
188 ACPI_ERROR ((AE_INFO
, "Object not a String, type %s",
189 AcpiUtGetObjectTypeName (SourceDesc
)));
190 return_ACPI_STATUS (AE_AML_OPERAND_TYPE
);
193 /* Return an additional reference to the object */
195 ObjDesc
= SourceDesc
;
196 AcpiUtAddReference (ObjDesc
);
199 case ACPI_TYPE_INTEGER
:
201 if (SourceDesc
->Common
.Type
!= ACPI_TYPE_INTEGER
)
203 ACPI_ERROR ((AE_INFO
, "Object not a Integer, type %s",
204 AcpiUtGetObjectTypeName (SourceDesc
)));
205 return_ACPI_STATUS (AE_AML_OPERAND_TYPE
);
208 /* Return an additional reference to the object */
210 ObjDesc
= SourceDesc
;
211 AcpiUtAddReference (ObjDesc
);
214 case ACPI_TYPE_BUFFER_FIELD
:
215 case ACPI_TYPE_LOCAL_REGION_FIELD
:
216 case ACPI_TYPE_LOCAL_BANK_FIELD
:
217 case ACPI_TYPE_LOCAL_INDEX_FIELD
:
219 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC
,
220 "FieldRead Node=%p SourceDesc=%p Type=%X\n",
221 Node
, SourceDesc
, EntryType
));
223 Status
= AcpiExReadDataFromField (WalkState
, SourceDesc
, &ObjDesc
);
226 /* For these objects, just return the object attached to the Node */
228 case ACPI_TYPE_MUTEX
:
229 case ACPI_TYPE_POWER
:
230 case ACPI_TYPE_PROCESSOR
:
231 case ACPI_TYPE_EVENT
:
232 case ACPI_TYPE_REGION
:
234 /* Return an additional reference to the object */
236 ObjDesc
= SourceDesc
;
237 AcpiUtAddReference (ObjDesc
);
240 /* TYPE_ANY is untyped, and thus there is no object associated with it */
244 ACPI_ERROR ((AE_INFO
,
245 "Untyped entry %p, no attached object!", Node
));
247 return_ACPI_STATUS (AE_AML_OPERAND_TYPE
); /* Cannot be AE_TYPE */
249 case ACPI_TYPE_LOCAL_REFERENCE
:
251 switch (SourceDesc
->Reference
.Class
)
253 case ACPI_REFCLASS_TABLE
: /* This is a DdbHandle */
254 case ACPI_REFCLASS_REFOF
:
255 case ACPI_REFCLASS_INDEX
:
257 /* Return an additional reference to the object */
259 ObjDesc
= SourceDesc
;
260 AcpiUtAddReference (ObjDesc
);
265 /* No named references are allowed here */
267 ACPI_ERROR ((AE_INFO
,
268 "Unsupported Reference type 0x%X",
269 SourceDesc
->Reference
.Class
));
271 return_ACPI_STATUS (AE_AML_OPERAND_TYPE
);
277 /* Default case is for unknown types */
279 ACPI_ERROR ((AE_INFO
,
280 "Node %p - Unknown object type 0x%X",
283 return_ACPI_STATUS (AE_AML_OPERAND_TYPE
);
285 } /* switch (EntryType) */
288 /* Return the object descriptor */
290 *ObjectPtr
= (void *) ObjDesc
;
291 return_ACPI_STATUS (Status
);