exresolv.c revision 1.1.1.16 1 1.1 jruoho /******************************************************************************
2 1.1 jruoho *
3 1.1 jruoho * Module Name: exresolv - AML Interpreter object resolution
4 1.1 jruoho *
5 1.1 jruoho *****************************************************************************/
6 1.1 jruoho
7 1.1.1.16 christos /******************************************************************************
8 1.1.1.16 christos *
9 1.1.1.16 christos * 1. Copyright Notice
10 1.1.1.16 christos *
11 1.1.1.16 christos * Some or all of this work - Copyright (c) 1999 - 2024, Intel Corp.
12 1.1 jruoho * All rights reserved.
13 1.1 jruoho *
14 1.1.1.16 christos * 2. License
15 1.1.1.16 christos *
16 1.1.1.16 christos * 2.1. This is your license from Intel Corp. under its intellectual property
17 1.1.1.16 christos * rights. You may have additional license terms from the party that provided
18 1.1.1.16 christos * you this software, covering your right to use that party's intellectual
19 1.1.1.16 christos * property rights.
20 1.1.1.16 christos *
21 1.1.1.16 christos * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
22 1.1.1.16 christos * copy of the source code appearing in this file ("Covered Code") an
23 1.1.1.16 christos * irrevocable, perpetual, worldwide license under Intel's copyrights in the
24 1.1.1.16 christos * base code distributed originally by Intel ("Original Intel Code") to copy,
25 1.1.1.16 christos * make derivatives, distribute, use and display any portion of the Covered
26 1.1.1.16 christos * Code in any form, with the right to sublicense such rights; and
27 1.1.1.16 christos *
28 1.1.1.16 christos * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
29 1.1.1.16 christos * license (with the right to sublicense), under only those claims of Intel
30 1.1.1.16 christos * patents that are infringed by the Original Intel Code, to make, use, sell,
31 1.1.1.16 christos * offer to sell, and import the Covered Code and derivative works thereof
32 1.1.1.16 christos * solely to the minimum extent necessary to exercise the above copyright
33 1.1.1.16 christos * license, and in no event shall the patent license extend to any additions
34 1.1.1.16 christos * to or modifications of the Original Intel Code. No other license or right
35 1.1.1.16 christos * is granted directly or by implication, estoppel or otherwise;
36 1.1.1.16 christos *
37 1.1.1.16 christos * The above copyright and patent license is granted only if the following
38 1.1.1.16 christos * conditions are met:
39 1.1.1.16 christos *
40 1.1.1.16 christos * 3. Conditions
41 1.1.1.16 christos *
42 1.1.1.16 christos * 3.1. Redistribution of Source with Rights to Further Distribute Source.
43 1.1.1.16 christos * Redistribution of source code of any substantial portion of the Covered
44 1.1.1.16 christos * Code or modification with rights to further distribute source must include
45 1.1.1.16 christos * the above Copyright Notice, the above License, this list of Conditions,
46 1.1.1.16 christos * and the following Disclaimer and Export Compliance provision. In addition,
47 1.1.1.16 christos * Licensee must cause all Covered Code to which Licensee contributes to
48 1.1.1.16 christos * contain a file documenting the changes Licensee made to create that Covered
49 1.1.1.16 christos * Code and the date of any change. Licensee must include in that file the
50 1.1.1.16 christos * documentation of any changes made by any predecessor Licensee. Licensee
51 1.1.1.16 christos * must include a prominent statement that the modification is derived,
52 1.1.1.16 christos * directly or indirectly, from Original Intel Code.
53 1.1.1.16 christos *
54 1.1.1.16 christos * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
55 1.1.1.16 christos * Redistribution of source code of any substantial portion of the Covered
56 1.1.1.16 christos * Code or modification without rights to further distribute source must
57 1.1.1.16 christos * include the following Disclaimer and Export Compliance provision in the
58 1.1.1.16 christos * documentation and/or other materials provided with distribution. In
59 1.1.1.16 christos * addition, Licensee may not authorize further sublicense of source of any
60 1.1.1.16 christos * portion of the Covered Code, and must include terms to the effect that the
61 1.1.1.16 christos * license from Licensee to its licensee is limited to the intellectual
62 1.1.1.16 christos * property embodied in the software Licensee provides to its licensee, and
63 1.1.1.16 christos * not to intellectual property embodied in modifications its licensee may
64 1.1.1.16 christos * make.
65 1.1.1.16 christos *
66 1.1.1.16 christos * 3.3. Redistribution of Executable. Redistribution in executable form of any
67 1.1.1.16 christos * substantial portion of the Covered Code or modification must reproduce the
68 1.1.1.16 christos * above Copyright Notice, and the following Disclaimer and Export Compliance
69 1.1.1.16 christos * provision in the documentation and/or other materials provided with the
70 1.1.1.16 christos * distribution.
71 1.1.1.16 christos *
72 1.1.1.16 christos * 3.4. Intel retains all right, title, and interest in and to the Original
73 1.1.1.16 christos * Intel Code.
74 1.1.1.16 christos *
75 1.1.1.16 christos * 3.5. Neither the name Intel nor any other trademark owned or controlled by
76 1.1.1.16 christos * Intel shall be used in advertising or otherwise to promote the sale, use or
77 1.1.1.16 christos * other dealings in products derived from or relating to the Covered Code
78 1.1.1.16 christos * without prior written authorization from Intel.
79 1.1.1.16 christos *
80 1.1.1.16 christos * 4. Disclaimer and Export Compliance
81 1.1.1.16 christos *
82 1.1.1.16 christos * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
83 1.1.1.16 christos * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
84 1.1.1.16 christos * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
85 1.1.1.16 christos * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
86 1.1.1.16 christos * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
87 1.1.1.16 christos * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
88 1.1.1.16 christos * PARTICULAR PURPOSE.
89 1.1.1.16 christos *
90 1.1.1.16 christos * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
91 1.1.1.16 christos * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
92 1.1.1.16 christos * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
93 1.1.1.16 christos * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
94 1.1.1.16 christos * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
95 1.1.1.16 christos * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
96 1.1.1.16 christos * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
97 1.1.1.16 christos * LIMITED REMEDY.
98 1.1.1.16 christos *
99 1.1.1.16 christos * 4.3. Licensee shall not export, either directly or indirectly, any of this
100 1.1.1.16 christos * software or system incorporating such software without first obtaining any
101 1.1.1.16 christos * required license or other approval from the U. S. Department of Commerce or
102 1.1.1.16 christos * any other agency or department of the United States Government. In the
103 1.1.1.16 christos * event Licensee exports any such software from the United States or
104 1.1.1.16 christos * re-exports any such software from a foreign destination, Licensee shall
105 1.1.1.16 christos * ensure that the distribution and export/re-export of the software is in
106 1.1.1.16 christos * compliance with all laws, regulations, orders, or other restrictions of the
107 1.1.1.16 christos * U.S. Export Administration Regulations. Licensee agrees that neither it nor
108 1.1.1.16 christos * any of its subsidiaries will export/re-export any technical data, process,
109 1.1.1.16 christos * software, or service, directly or indirectly, to any country for which the
110 1.1.1.16 christos * United States government or any agency thereof requires an export license,
111 1.1.1.16 christos * other governmental approval, or letter of assurance, without first obtaining
112 1.1.1.16 christos * such license, approval or letter.
113 1.1.1.16 christos *
114 1.1.1.16 christos *****************************************************************************
115 1.1.1.16 christos *
116 1.1.1.16 christos * Alternatively, you may choose to be licensed under the terms of the
117 1.1.1.16 christos * following license:
118 1.1.1.16 christos *
119 1.1.1.2 jruoho * Redistribution and use in source and binary forms, with or without
120 1.1.1.2 jruoho * modification, are permitted provided that the following conditions
121 1.1.1.2 jruoho * are met:
122 1.1.1.2 jruoho * 1. Redistributions of source code must retain the above copyright
123 1.1.1.2 jruoho * notice, this list of conditions, and the following disclaimer,
124 1.1.1.2 jruoho * without modification.
125 1.1.1.2 jruoho * 2. Redistributions in binary form must reproduce at minimum a disclaimer
126 1.1.1.2 jruoho * substantially similar to the "NO WARRANTY" disclaimer below
127 1.1.1.2 jruoho * ("Disclaimer") and any redistribution must be conditioned upon
128 1.1.1.2 jruoho * including a substantially similar Disclaimer requirement for further
129 1.1.1.2 jruoho * binary redistribution.
130 1.1.1.2 jruoho * 3. Neither the names of the above-listed copyright holders nor the names
131 1.1.1.2 jruoho * of any contributors may be used to endorse or promote products derived
132 1.1.1.2 jruoho * from this software without specific prior written permission.
133 1.1.1.2 jruoho *
134 1.1.1.2 jruoho * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
135 1.1.1.2 jruoho * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
136 1.1.1.13 christos * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
137 1.1.1.2 jruoho * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
138 1.1.1.16 christos * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
139 1.1.1.16 christos * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
140 1.1.1.16 christos * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
141 1.1.1.16 christos * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
142 1.1.1.16 christos * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
143 1.1.1.16 christos * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
144 1.1.1.16 christos * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
145 1.1.1.16 christos *
146 1.1.1.16 christos * Alternatively, you may choose to be licensed under the terms of the
147 1.1.1.16 christos * GNU General Public License ("GPL") version 2 as published by the Free
148 1.1.1.16 christos * Software Foundation.
149 1.1.1.16 christos *
150 1.1.1.16 christos *****************************************************************************/
151 1.1 jruoho
152 1.1 jruoho #include "acpi.h"
153 1.1 jruoho #include "accommon.h"
154 1.1 jruoho #include "amlcode.h"
155 1.1 jruoho #include "acdispat.h"
156 1.1 jruoho #include "acinterp.h"
157 1.1 jruoho #include "acnamesp.h"
158 1.1 jruoho
159 1.1 jruoho
160 1.1 jruoho #define _COMPONENT ACPI_EXECUTER
161 1.1 jruoho ACPI_MODULE_NAME ("exresolv")
162 1.1 jruoho
163 1.1 jruoho /* Local prototypes */
164 1.1 jruoho
165 1.1 jruoho static ACPI_STATUS
166 1.1 jruoho AcpiExResolveObjectToValue (
167 1.1 jruoho ACPI_OPERAND_OBJECT **StackPtr,
168 1.1 jruoho ACPI_WALK_STATE *WalkState);
169 1.1 jruoho
170 1.1 jruoho
171 1.1 jruoho /*******************************************************************************
172 1.1 jruoho *
173 1.1 jruoho * FUNCTION: AcpiExResolveToValue
174 1.1 jruoho *
175 1.1 jruoho * PARAMETERS: **StackPtr - Points to entry on ObjStack, which can
176 1.1 jruoho * be either an (ACPI_OPERAND_OBJECT *)
177 1.1 jruoho * or an ACPI_HANDLE.
178 1.1 jruoho * WalkState - Current method state
179 1.1 jruoho *
180 1.1 jruoho * RETURN: Status
181 1.1 jruoho *
182 1.1 jruoho * DESCRIPTION: Convert Reference objects to values
183 1.1 jruoho *
184 1.1 jruoho ******************************************************************************/
185 1.1 jruoho
186 1.1 jruoho ACPI_STATUS
187 1.1 jruoho AcpiExResolveToValue (
188 1.1 jruoho ACPI_OPERAND_OBJECT **StackPtr,
189 1.1 jruoho ACPI_WALK_STATE *WalkState)
190 1.1 jruoho {
191 1.1 jruoho ACPI_STATUS Status;
192 1.1 jruoho
193 1.1 jruoho
194 1.1 jruoho ACPI_FUNCTION_TRACE_PTR (ExResolveToValue, StackPtr);
195 1.1 jruoho
196 1.1 jruoho
197 1.1 jruoho if (!StackPtr || !*StackPtr)
198 1.1 jruoho {
199 1.1 jruoho ACPI_ERROR ((AE_INFO, "Internal - null pointer"));
200 1.1 jruoho return_ACPI_STATUS (AE_AML_NO_OPERAND);
201 1.1 jruoho }
202 1.1 jruoho
203 1.1 jruoho /*
204 1.1 jruoho * The entity pointed to by the StackPtr can be either
205 1.1 jruoho * 1) A valid ACPI_OPERAND_OBJECT, or
206 1.1 jruoho * 2) A ACPI_NAMESPACE_NODE (NamedObj)
207 1.1 jruoho */
208 1.1 jruoho if (ACPI_GET_DESCRIPTOR_TYPE (*StackPtr) == ACPI_DESC_TYPE_OPERAND)
209 1.1 jruoho {
210 1.1 jruoho Status = AcpiExResolveObjectToValue (StackPtr, WalkState);
211 1.1 jruoho if (ACPI_FAILURE (Status))
212 1.1 jruoho {
213 1.1 jruoho return_ACPI_STATUS (Status);
214 1.1 jruoho }
215 1.1 jruoho
216 1.1 jruoho if (!*StackPtr)
217 1.1 jruoho {
218 1.1 jruoho ACPI_ERROR ((AE_INFO, "Internal - null pointer"));
219 1.1 jruoho return_ACPI_STATUS (AE_AML_NO_OPERAND);
220 1.1 jruoho }
221 1.1 jruoho }
222 1.1 jruoho
223 1.1 jruoho /*
224 1.1 jruoho * Object on the stack may have changed if AcpiExResolveObjectToValue()
225 1.1 jruoho * was called (i.e., we can't use an _else_ here.)
226 1.1 jruoho */
227 1.1 jruoho if (ACPI_GET_DESCRIPTOR_TYPE (*StackPtr) == ACPI_DESC_TYPE_NAMED)
228 1.1 jruoho {
229 1.1 jruoho Status = AcpiExResolveNodeToValue (
230 1.1.1.6 christos ACPI_CAST_INDIRECT_PTR (ACPI_NAMESPACE_NODE, StackPtr),
231 1.1.1.6 christos WalkState);
232 1.1 jruoho if (ACPI_FAILURE (Status))
233 1.1 jruoho {
234 1.1 jruoho return_ACPI_STATUS (Status);
235 1.1 jruoho }
236 1.1 jruoho }
237 1.1 jruoho
238 1.1 jruoho ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Resolved object %p\n", *StackPtr));
239 1.1 jruoho return_ACPI_STATUS (AE_OK);
240 1.1 jruoho }
241 1.1 jruoho
242 1.1 jruoho
243 1.1 jruoho /*******************************************************************************
244 1.1 jruoho *
245 1.1 jruoho * FUNCTION: AcpiExResolveObjectToValue
246 1.1 jruoho *
247 1.1 jruoho * PARAMETERS: StackPtr - Pointer to an internal object
248 1.1 jruoho * WalkState - Current method state
249 1.1 jruoho *
250 1.1 jruoho * RETURN: Status
251 1.1 jruoho *
252 1.1 jruoho * DESCRIPTION: Retrieve the value from an internal object. The Reference type
253 1.1 jruoho * uses the associated AML opcode to determine the value.
254 1.1 jruoho *
255 1.1 jruoho ******************************************************************************/
256 1.1 jruoho
257 1.1 jruoho static ACPI_STATUS
258 1.1 jruoho AcpiExResolveObjectToValue (
259 1.1 jruoho ACPI_OPERAND_OBJECT **StackPtr,
260 1.1 jruoho ACPI_WALK_STATE *WalkState)
261 1.1 jruoho {
262 1.1 jruoho ACPI_STATUS Status = AE_OK;
263 1.1 jruoho ACPI_OPERAND_OBJECT *StackDesc;
264 1.1 jruoho ACPI_OPERAND_OBJECT *ObjDesc = NULL;
265 1.1 jruoho UINT8 RefType;
266 1.1 jruoho
267 1.1 jruoho
268 1.1 jruoho ACPI_FUNCTION_TRACE (ExResolveObjectToValue);
269 1.1 jruoho
270 1.1 jruoho
271 1.1 jruoho StackDesc = *StackPtr;
272 1.1 jruoho
273 1.1.1.3 christos /* This is an object of type ACPI_OPERAND_OBJECT */
274 1.1 jruoho
275 1.1 jruoho switch (StackDesc->Common.Type)
276 1.1 jruoho {
277 1.1 jruoho case ACPI_TYPE_LOCAL_REFERENCE:
278 1.1 jruoho
279 1.1 jruoho RefType = StackDesc->Reference.Class;
280 1.1 jruoho
281 1.1 jruoho switch (RefType)
282 1.1 jruoho {
283 1.1 jruoho case ACPI_REFCLASS_LOCAL:
284 1.1 jruoho case ACPI_REFCLASS_ARG:
285 1.1 jruoho /*
286 1.1 jruoho * Get the local from the method's state info
287 1.1 jruoho * Note: this increments the local's object reference count
288 1.1 jruoho */
289 1.1 jruoho Status = AcpiDsMethodDataGetValue (RefType,
290 1.1.1.6 christos StackDesc->Reference.Value, WalkState, &ObjDesc);
291 1.1 jruoho if (ACPI_FAILURE (Status))
292 1.1 jruoho {
293 1.1 jruoho return_ACPI_STATUS (Status);
294 1.1 jruoho }
295 1.1 jruoho
296 1.1 jruoho ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[Arg/Local %X] ValueObj is %p\n",
297 1.1 jruoho StackDesc->Reference.Value, ObjDesc));
298 1.1 jruoho
299 1.1 jruoho /*
300 1.1 jruoho * Now we can delete the original Reference Object and
301 1.1 jruoho * replace it with the resolved value
302 1.1 jruoho */
303 1.1 jruoho AcpiUtRemoveReference (StackDesc);
304 1.1 jruoho *StackPtr = ObjDesc;
305 1.1 jruoho break;
306 1.1 jruoho
307 1.1 jruoho case ACPI_REFCLASS_INDEX:
308 1.1 jruoho
309 1.1 jruoho switch (StackDesc->Reference.TargetType)
310 1.1 jruoho {
311 1.1 jruoho case ACPI_TYPE_BUFFER_FIELD:
312 1.1 jruoho
313 1.1 jruoho /* Just return - do not dereference */
314 1.1 jruoho break;
315 1.1 jruoho
316 1.1 jruoho case ACPI_TYPE_PACKAGE:
317 1.1 jruoho
318 1.1 jruoho /* If method call or CopyObject - do not dereference */
319 1.1 jruoho
320 1.1 jruoho if ((WalkState->Opcode == AML_INT_METHODCALL_OP) ||
321 1.1.1.8 christos (WalkState->Opcode == AML_COPY_OBJECT_OP))
322 1.1 jruoho {
323 1.1 jruoho break;
324 1.1 jruoho }
325 1.1 jruoho
326 1.1 jruoho /* Otherwise, dereference the PackageIndex to a package element */
327 1.1 jruoho
328 1.1 jruoho ObjDesc = *StackDesc->Reference.Where;
329 1.1 jruoho if (ObjDesc)
330 1.1 jruoho {
331 1.1 jruoho /*
332 1.1 jruoho * Valid object descriptor, copy pointer to return value
333 1.1 jruoho * (i.e., dereference the package index)
334 1.1 jruoho * Delete the ref object, increment the returned object
335 1.1 jruoho */
336 1.1 jruoho AcpiUtAddReference (ObjDesc);
337 1.1 jruoho *StackPtr = ObjDesc;
338 1.1 jruoho }
339 1.1 jruoho else
340 1.1 jruoho {
341 1.1 jruoho /*
342 1.1 jruoho * A NULL object descriptor means an uninitialized element of
343 1.1 jruoho * the package, can't dereference it
344 1.1 jruoho */
345 1.1 jruoho ACPI_ERROR ((AE_INFO,
346 1.1.1.6 christos "Attempt to dereference an Index to "
347 1.1.1.6 christos "NULL package element Idx=%p",
348 1.1 jruoho StackDesc));
349 1.1 jruoho Status = AE_AML_UNINITIALIZED_ELEMENT;
350 1.1 jruoho }
351 1.1 jruoho break;
352 1.1 jruoho
353 1.1 jruoho default:
354 1.1 jruoho
355 1.1 jruoho /* Invalid reference object */
356 1.1 jruoho
357 1.1 jruoho ACPI_ERROR ((AE_INFO,
358 1.1 jruoho "Unknown TargetType 0x%X in Index/Reference object %p",
359 1.1 jruoho StackDesc->Reference.TargetType, StackDesc));
360 1.1 jruoho Status = AE_AML_INTERNAL;
361 1.1 jruoho break;
362 1.1 jruoho }
363 1.1 jruoho break;
364 1.1 jruoho
365 1.1 jruoho case ACPI_REFCLASS_REFOF:
366 1.1 jruoho case ACPI_REFCLASS_DEBUG:
367 1.1 jruoho case ACPI_REFCLASS_TABLE:
368 1.1 jruoho
369 1.1 jruoho /* Just leave the object as-is, do not dereference */
370 1.1 jruoho
371 1.1 jruoho break;
372 1.1 jruoho
373 1.1 jruoho case ACPI_REFCLASS_NAME: /* Reference to a named object */
374 1.1 jruoho
375 1.1 jruoho /* Dereference the name */
376 1.1 jruoho
377 1.1 jruoho if ((StackDesc->Reference.Node->Type == ACPI_TYPE_DEVICE) ||
378 1.1 jruoho (StackDesc->Reference.Node->Type == ACPI_TYPE_THERMAL))
379 1.1 jruoho {
380 1.1 jruoho /* These node types do not have 'real' subobjects */
381 1.1 jruoho
382 1.1 jruoho *StackPtr = (void *) StackDesc->Reference.Node;
383 1.1 jruoho }
384 1.1 jruoho else
385 1.1 jruoho {
386 1.1 jruoho /* Get the object pointed to by the namespace node */
387 1.1 jruoho
388 1.1 jruoho *StackPtr = (StackDesc->Reference.Node)->Object;
389 1.1 jruoho AcpiUtAddReference (*StackPtr);
390 1.1 jruoho }
391 1.1 jruoho
392 1.1 jruoho AcpiUtRemoveReference (StackDesc);
393 1.1 jruoho break;
394 1.1 jruoho
395 1.1 jruoho default:
396 1.1 jruoho
397 1.1 jruoho ACPI_ERROR ((AE_INFO,
398 1.1.1.6 christos "Unknown Reference type 0x%X in %p",
399 1.1.1.6 christos RefType, StackDesc));
400 1.1 jruoho Status = AE_AML_INTERNAL;
401 1.1 jruoho break;
402 1.1 jruoho }
403 1.1 jruoho break;
404 1.1 jruoho
405 1.1 jruoho case ACPI_TYPE_BUFFER:
406 1.1 jruoho
407 1.1 jruoho Status = AcpiDsGetBufferArguments (StackDesc);
408 1.1 jruoho break;
409 1.1 jruoho
410 1.1 jruoho case ACPI_TYPE_PACKAGE:
411 1.1 jruoho
412 1.1 jruoho Status = AcpiDsGetPackageArguments (StackDesc);
413 1.1 jruoho break;
414 1.1 jruoho
415 1.1 jruoho case ACPI_TYPE_BUFFER_FIELD:
416 1.1 jruoho case ACPI_TYPE_LOCAL_REGION_FIELD:
417 1.1 jruoho case ACPI_TYPE_LOCAL_BANK_FIELD:
418 1.1 jruoho case ACPI_TYPE_LOCAL_INDEX_FIELD:
419 1.1 jruoho
420 1.1.1.6 christos ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
421 1.1.1.6 christos "FieldRead SourceDesc=%p Type=%X\n",
422 1.1 jruoho StackDesc, StackDesc->Common.Type));
423 1.1 jruoho
424 1.1 jruoho Status = AcpiExReadDataFromField (WalkState, StackDesc, &ObjDesc);
425 1.1 jruoho
426 1.1 jruoho /* Remove a reference to the original operand, then override */
427 1.1 jruoho
428 1.1 jruoho AcpiUtRemoveReference (*StackPtr);
429 1.1 jruoho *StackPtr = (void *) ObjDesc;
430 1.1 jruoho break;
431 1.1 jruoho
432 1.1 jruoho default:
433 1.1.1.3 christos
434 1.1 jruoho break;
435 1.1 jruoho }
436 1.1 jruoho
437 1.1 jruoho return_ACPI_STATUS (Status);
438 1.1 jruoho }
439 1.1 jruoho
440 1.1 jruoho
441 1.1 jruoho /*******************************************************************************
442 1.1 jruoho *
443 1.1 jruoho * FUNCTION: AcpiExResolveMultiple
444 1.1 jruoho *
445 1.1 jruoho * PARAMETERS: WalkState - Current state (contains AML opcode)
446 1.1 jruoho * Operand - Starting point for resolution
447 1.1 jruoho * ReturnType - Where the object type is returned
448 1.1 jruoho * ReturnDesc - Where the resolved object is returned
449 1.1 jruoho *
450 1.1 jruoho * RETURN: Status
451 1.1 jruoho *
452 1.1.1.3 christos * DESCRIPTION: Return the base object and type. Traverse a reference list if
453 1.1 jruoho * necessary to get to the base object.
454 1.1 jruoho *
455 1.1 jruoho ******************************************************************************/
456 1.1 jruoho
457 1.1 jruoho ACPI_STATUS
458 1.1 jruoho AcpiExResolveMultiple (
459 1.1 jruoho ACPI_WALK_STATE *WalkState,
460 1.1 jruoho ACPI_OPERAND_OBJECT *Operand,
461 1.1 jruoho ACPI_OBJECT_TYPE *ReturnType,
462 1.1 jruoho ACPI_OPERAND_OBJECT **ReturnDesc)
463 1.1 jruoho {
464 1.1.1.6 christos ACPI_OPERAND_OBJECT *ObjDesc = ACPI_CAST_PTR (void, Operand);
465 1.1.1.6 christos ACPI_NAMESPACE_NODE *Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, Operand);
466 1.1 jruoho ACPI_OBJECT_TYPE Type;
467 1.1 jruoho ACPI_STATUS Status;
468 1.1 jruoho
469 1.1 jruoho
470 1.1 jruoho ACPI_FUNCTION_TRACE (AcpiExResolveMultiple);
471 1.1 jruoho
472 1.1 jruoho
473 1.1 jruoho /* Operand can be either a namespace node or an operand descriptor */
474 1.1 jruoho
475 1.1 jruoho switch (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc))
476 1.1 jruoho {
477 1.1 jruoho case ACPI_DESC_TYPE_OPERAND:
478 1.1.1.3 christos
479 1.1 jruoho Type = ObjDesc->Common.Type;
480 1.1 jruoho break;
481 1.1 jruoho
482 1.1 jruoho case ACPI_DESC_TYPE_NAMED:
483 1.1.1.3 christos
484 1.1 jruoho Type = ((ACPI_NAMESPACE_NODE *) ObjDesc)->Type;
485 1.1.1.6 christos ObjDesc = AcpiNsGetAttachedObject (Node);
486 1.1 jruoho
487 1.1 jruoho /* If we had an Alias node, use the attached object for type info */
488 1.1 jruoho
489 1.1 jruoho if (Type == ACPI_TYPE_LOCAL_ALIAS)
490 1.1 jruoho {
491 1.1 jruoho Type = ((ACPI_NAMESPACE_NODE *) ObjDesc)->Type;
492 1.1.1.6 christos ObjDesc = AcpiNsGetAttachedObject (
493 1.1.1.6 christos (ACPI_NAMESPACE_NODE *) ObjDesc);
494 1.1.1.6 christos }
495 1.1.1.6 christos
496 1.1.1.9 christos switch (Type)
497 1.1.1.6 christos {
498 1.1.1.9 christos case ACPI_TYPE_DEVICE:
499 1.1.1.9 christos case ACPI_TYPE_THERMAL:
500 1.1.1.9 christos
501 1.1.1.9 christos /* These types have no attached subobject */
502 1.1.1.9 christos break;
503 1.1.1.9 christos
504 1.1.1.9 christos default:
505 1.1.1.9 christos
506 1.1.1.9 christos /* All other types require a subobject */
507 1.1.1.9 christos
508 1.1.1.9 christos if (!ObjDesc)
509 1.1.1.9 christos {
510 1.1.1.9 christos ACPI_ERROR ((AE_INFO,
511 1.1.1.9 christos "[%4.4s] Node is unresolved or uninitialized",
512 1.1.1.9 christos AcpiUtGetNodeName (Node)));
513 1.1.1.9 christos return_ACPI_STATUS (AE_AML_UNINITIALIZED_NODE);
514 1.1.1.9 christos }
515 1.1.1.9 christos break;
516 1.1 jruoho }
517 1.1 jruoho break;
518 1.1 jruoho
519 1.1 jruoho default:
520 1.1 jruoho return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
521 1.1 jruoho }
522 1.1 jruoho
523 1.1 jruoho /* If type is anything other than a reference, we are done */
524 1.1 jruoho
525 1.1 jruoho if (Type != ACPI_TYPE_LOCAL_REFERENCE)
526 1.1 jruoho {
527 1.1 jruoho goto Exit;
528 1.1 jruoho }
529 1.1 jruoho
530 1.1 jruoho /*
531 1.1 jruoho * For reference objects created via the RefOf, Index, or Load/LoadTable
532 1.1 jruoho * operators, we need to get to the base object (as per the ACPI
533 1.1 jruoho * specification of the ObjectType and SizeOf operators). This means
534 1.1 jruoho * traversing the list of possibly many nested references.
535 1.1 jruoho */
536 1.1 jruoho while (ObjDesc->Common.Type == ACPI_TYPE_LOCAL_REFERENCE)
537 1.1 jruoho {
538 1.1 jruoho switch (ObjDesc->Reference.Class)
539 1.1 jruoho {
540 1.1 jruoho case ACPI_REFCLASS_REFOF:
541 1.1 jruoho case ACPI_REFCLASS_NAME:
542 1.1 jruoho
543 1.1 jruoho /* Dereference the reference pointer */
544 1.1 jruoho
545 1.1 jruoho if (ObjDesc->Reference.Class == ACPI_REFCLASS_REFOF)
546 1.1 jruoho {
547 1.1 jruoho Node = ObjDesc->Reference.Object;
548 1.1 jruoho }
549 1.1 jruoho else /* AML_INT_NAMEPATH_OP */
550 1.1 jruoho {
551 1.1 jruoho Node = ObjDesc->Reference.Node;
552 1.1 jruoho }
553 1.1 jruoho
554 1.1 jruoho /* All "References" point to a NS node */
555 1.1 jruoho
556 1.1 jruoho if (ACPI_GET_DESCRIPTOR_TYPE (Node) != ACPI_DESC_TYPE_NAMED)
557 1.1 jruoho {
558 1.1 jruoho ACPI_ERROR ((AE_INFO,
559 1.1 jruoho "Not a namespace node %p [%s]",
560 1.1 jruoho Node, AcpiUtGetDescriptorName (Node)));
561 1.1 jruoho return_ACPI_STATUS (AE_AML_INTERNAL);
562 1.1 jruoho }
563 1.1 jruoho
564 1.1 jruoho /* Get the attached object */
565 1.1 jruoho
566 1.1 jruoho ObjDesc = AcpiNsGetAttachedObject (Node);
567 1.1 jruoho if (!ObjDesc)
568 1.1 jruoho {
569 1.1 jruoho /* No object, use the NS node type */
570 1.1 jruoho
571 1.1 jruoho Type = AcpiNsGetType (Node);
572 1.1 jruoho goto Exit;
573 1.1 jruoho }
574 1.1 jruoho
575 1.1 jruoho /* Check for circular references */
576 1.1 jruoho
577 1.1 jruoho if (ObjDesc == Operand)
578 1.1 jruoho {
579 1.1 jruoho return_ACPI_STATUS (AE_AML_CIRCULAR_REFERENCE);
580 1.1 jruoho }
581 1.1 jruoho break;
582 1.1 jruoho
583 1.1 jruoho case ACPI_REFCLASS_INDEX:
584 1.1 jruoho
585 1.1 jruoho /* Get the type of this reference (index into another object) */
586 1.1 jruoho
587 1.1 jruoho Type = ObjDesc->Reference.TargetType;
588 1.1 jruoho if (Type != ACPI_TYPE_PACKAGE)
589 1.1 jruoho {
590 1.1 jruoho goto Exit;
591 1.1 jruoho }
592 1.1 jruoho
593 1.1 jruoho /*
594 1.1 jruoho * The main object is a package, we want to get the type
595 1.1 jruoho * of the individual package element that is referenced by
596 1.1 jruoho * the index.
597 1.1 jruoho *
598 1.1 jruoho * This could of course in turn be another reference object.
599 1.1 jruoho */
600 1.1 jruoho ObjDesc = *(ObjDesc->Reference.Where);
601 1.1 jruoho if (!ObjDesc)
602 1.1 jruoho {
603 1.1 jruoho /* NULL package elements are allowed */
604 1.1 jruoho
605 1.1 jruoho Type = 0; /* Uninitialized */
606 1.1 jruoho goto Exit;
607 1.1 jruoho }
608 1.1 jruoho break;
609 1.1 jruoho
610 1.1 jruoho case ACPI_REFCLASS_TABLE:
611 1.1 jruoho
612 1.1 jruoho Type = ACPI_TYPE_DDB_HANDLE;
613 1.1 jruoho goto Exit;
614 1.1 jruoho
615 1.1 jruoho case ACPI_REFCLASS_LOCAL:
616 1.1 jruoho case ACPI_REFCLASS_ARG:
617 1.1 jruoho
618 1.1 jruoho if (ReturnDesc)
619 1.1 jruoho {
620 1.1 jruoho Status = AcpiDsMethodDataGetValue (ObjDesc->Reference.Class,
621 1.1.1.6 christos ObjDesc->Reference.Value, WalkState, &ObjDesc);
622 1.1 jruoho if (ACPI_FAILURE (Status))
623 1.1 jruoho {
624 1.1 jruoho return_ACPI_STATUS (Status);
625 1.1 jruoho }
626 1.1 jruoho AcpiUtRemoveReference (ObjDesc);
627 1.1 jruoho }
628 1.1 jruoho else
629 1.1 jruoho {
630 1.1 jruoho Status = AcpiDsMethodDataGetNode (ObjDesc->Reference.Class,
631 1.1.1.6 christos ObjDesc->Reference.Value, WalkState, &Node);
632 1.1 jruoho if (ACPI_FAILURE (Status))
633 1.1 jruoho {
634 1.1 jruoho return_ACPI_STATUS (Status);
635 1.1 jruoho }
636 1.1 jruoho
637 1.1 jruoho ObjDesc = AcpiNsGetAttachedObject (Node);
638 1.1 jruoho if (!ObjDesc)
639 1.1 jruoho {
640 1.1 jruoho Type = ACPI_TYPE_ANY;
641 1.1 jruoho goto Exit;
642 1.1 jruoho }
643 1.1 jruoho }
644 1.1 jruoho break;
645 1.1 jruoho
646 1.1 jruoho case ACPI_REFCLASS_DEBUG:
647 1.1 jruoho
648 1.1 jruoho /* The Debug Object is of type "DebugObject" */
649 1.1 jruoho
650 1.1 jruoho Type = ACPI_TYPE_DEBUG_OBJECT;
651 1.1 jruoho goto Exit;
652 1.1 jruoho
653 1.1 jruoho default:
654 1.1 jruoho
655 1.1 jruoho ACPI_ERROR ((AE_INFO,
656 1.1.1.6 christos "Unknown Reference Class 0x%2.2X",
657 1.1.1.6 christos ObjDesc->Reference.Class));
658 1.1 jruoho return_ACPI_STATUS (AE_AML_INTERNAL);
659 1.1 jruoho }
660 1.1 jruoho }
661 1.1 jruoho
662 1.1 jruoho /*
663 1.1 jruoho * Now we are guaranteed to have an object that has not been created
664 1.1 jruoho * via the RefOf or Index operators.
665 1.1 jruoho */
666 1.1 jruoho Type = ObjDesc->Common.Type;
667 1.1 jruoho
668 1.1 jruoho
669 1.1 jruoho Exit:
670 1.1 jruoho /* Convert internal types to external types */
671 1.1 jruoho
672 1.1 jruoho switch (Type)
673 1.1 jruoho {
674 1.1 jruoho case ACPI_TYPE_LOCAL_REGION_FIELD:
675 1.1 jruoho case ACPI_TYPE_LOCAL_BANK_FIELD:
676 1.1 jruoho case ACPI_TYPE_LOCAL_INDEX_FIELD:
677 1.1 jruoho
678 1.1 jruoho Type = ACPI_TYPE_FIELD_UNIT;
679 1.1 jruoho break;
680 1.1 jruoho
681 1.1 jruoho case ACPI_TYPE_LOCAL_SCOPE:
682 1.1 jruoho
683 1.1 jruoho /* Per ACPI Specification, Scope is untyped */
684 1.1 jruoho
685 1.1 jruoho Type = ACPI_TYPE_ANY;
686 1.1 jruoho break;
687 1.1 jruoho
688 1.1 jruoho default:
689 1.1.1.3 christos
690 1.1 jruoho /* No change to Type required */
691 1.1.1.3 christos
692 1.1 jruoho break;
693 1.1 jruoho }
694 1.1 jruoho
695 1.1 jruoho *ReturnType = Type;
696 1.1 jruoho if (ReturnDesc)
697 1.1 jruoho {
698 1.1 jruoho *ReturnDesc = ObjDesc;
699 1.1 jruoho }
700 1.1 jruoho return_ACPI_STATUS (AE_OK);
701 1.1 jruoho }
702