dsobject.c revision 1.1.1.17 1 1.1 jruoho /******************************************************************************
2 1.1 jruoho *
3 1.1 jruoho * Module Name: dsobject - Dispatcher object management routines
4 1.1 jruoho *
5 1.1 jruoho *****************************************************************************/
6 1.1 jruoho
7 1.1.1.2 jruoho /*
8 1.1.1.17 christos * Copyright (C) 2000 - 2021, Intel Corp.
9 1.1 jruoho * All rights reserved.
10 1.1 jruoho *
11 1.1.1.2 jruoho * Redistribution and use in source and binary forms, with or without
12 1.1.1.2 jruoho * modification, are permitted provided that the following conditions
13 1.1.1.2 jruoho * are met:
14 1.1.1.2 jruoho * 1. Redistributions of source code must retain the above copyright
15 1.1.1.2 jruoho * notice, this list of conditions, and the following disclaimer,
16 1.1.1.2 jruoho * without modification.
17 1.1.1.2 jruoho * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 1.1.1.2 jruoho * substantially similar to the "NO WARRANTY" disclaimer below
19 1.1.1.2 jruoho * ("Disclaimer") and any redistribution must be conditioned upon
20 1.1.1.2 jruoho * including a substantially similar Disclaimer requirement for further
21 1.1.1.2 jruoho * binary redistribution.
22 1.1.1.2 jruoho * 3. Neither the names of the above-listed copyright holders nor the names
23 1.1.1.2 jruoho * of any contributors may be used to endorse or promote products derived
24 1.1.1.2 jruoho * from this software without specific prior written permission.
25 1.1.1.2 jruoho *
26 1.1.1.2 jruoho * Alternatively, this software may be distributed under the terms of the
27 1.1.1.2 jruoho * GNU General Public License ("GPL") version 2 as published by the Free
28 1.1.1.2 jruoho * Software Foundation.
29 1.1.1.2 jruoho *
30 1.1.1.2 jruoho * NO WARRANTY
31 1.1.1.2 jruoho * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 1.1.1.2 jruoho * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 1.1.1.17 christos * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
34 1.1.1.2 jruoho * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 1.1.1.2 jruoho * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 1.1.1.2 jruoho * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 1.1.1.2 jruoho * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 1.1.1.2 jruoho * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 1.1.1.2 jruoho * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 1.1.1.2 jruoho * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 1.1.1.2 jruoho * POSSIBILITY OF SUCH DAMAGES.
42 1.1.1.2 jruoho */
43 1.1 jruoho
44 1.1 jruoho #include "acpi.h"
45 1.1 jruoho #include "accommon.h"
46 1.1 jruoho #include "acparser.h"
47 1.1 jruoho #include "amlcode.h"
48 1.1 jruoho #include "acdispat.h"
49 1.1 jruoho #include "acnamesp.h"
50 1.1 jruoho #include "acinterp.h"
51 1.1 jruoho
52 1.1 jruoho #define _COMPONENT ACPI_DISPATCHER
53 1.1 jruoho ACPI_MODULE_NAME ("dsobject")
54 1.1 jruoho
55 1.1 jruoho
56 1.1 jruoho /*******************************************************************************
57 1.1 jruoho *
58 1.1 jruoho * FUNCTION: AcpiDsBuildInternalObject
59 1.1 jruoho *
60 1.1 jruoho * PARAMETERS: WalkState - Current walk state
61 1.1 jruoho * Op - Parser object to be translated
62 1.1 jruoho * ObjDescPtr - Where the ACPI internal object is returned
63 1.1 jruoho *
64 1.1 jruoho * RETURN: Status
65 1.1 jruoho *
66 1.1 jruoho * DESCRIPTION: Translate a parser Op object to the equivalent namespace object
67 1.1 jruoho * Simple objects are any objects other than a package object!
68 1.1 jruoho *
69 1.1 jruoho ******************************************************************************/
70 1.1 jruoho
71 1.1.1.11 christos ACPI_STATUS
72 1.1 jruoho AcpiDsBuildInternalObject (
73 1.1 jruoho ACPI_WALK_STATE *WalkState,
74 1.1 jruoho ACPI_PARSE_OBJECT *Op,
75 1.1 jruoho ACPI_OPERAND_OBJECT **ObjDescPtr)
76 1.1 jruoho {
77 1.1 jruoho ACPI_OPERAND_OBJECT *ObjDesc;
78 1.1 jruoho ACPI_STATUS Status;
79 1.1 jruoho
80 1.1 jruoho
81 1.1 jruoho ACPI_FUNCTION_TRACE (DsBuildInternalObject);
82 1.1 jruoho
83 1.1 jruoho
84 1.1 jruoho *ObjDescPtr = NULL;
85 1.1 jruoho if (Op->Common.AmlOpcode == AML_INT_NAMEPATH_OP)
86 1.1 jruoho {
87 1.1 jruoho /*
88 1.1 jruoho * This is a named object reference. If this name was
89 1.1.1.11 christos * previously looked up in the namespace, it was stored in
90 1.1.1.11 christos * this op. Otherwise, go ahead and look it up now
91 1.1 jruoho */
92 1.1 jruoho if (!Op->Common.Node)
93 1.1 jruoho {
94 1.1.1.11 christos /* Check if we are resolving a named reference within a package */
95 1.1 jruoho
96 1.1.1.11 christos if ((Op->Common.Parent->Common.AmlOpcode == AML_PACKAGE_OP) ||
97 1.1.1.11 christos (Op->Common.Parent->Common.AmlOpcode == AML_VARIABLE_PACKAGE_OP))
98 1.1 jruoho {
99 1.1 jruoho /*
100 1.1.1.11 christos * We won't resolve package elements here, we will do this
101 1.1.1.11 christos * after all ACPI tables are loaded into the namespace. This
102 1.1.1.11 christos * behavior supports both forward references to named objects
103 1.1.1.11 christos * and external references to objects in other tables.
104 1.1 jruoho */
105 1.1.1.11 christos goto CreateNewObject;
106 1.1.1.11 christos }
107 1.1.1.11 christos else
108 1.1.1.11 christos {
109 1.1.1.11 christos Status = AcpiNsLookup (WalkState->ScopeInfo,
110 1.1.1.11 christos Op->Common.Value.String,
111 1.1.1.11 christos ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE,
112 1.1.1.11 christos ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE, NULL,
113 1.1.1.11 christos ACPI_CAST_INDIRECT_PTR (
114 1.1.1.11 christos ACPI_NAMESPACE_NODE, &(Op->Common.Node)));
115 1.1.1.11 christos if (ACPI_FAILURE (Status))
116 1.1.1.11 christos {
117 1.1.1.12 christos ACPI_ERROR_NAMESPACE (WalkState->ScopeInfo,
118 1.1.1.12 christos Op->Common.Value.String, Status);
119 1.1.1.11 christos return_ACPI_STATUS (Status);
120 1.1.1.11 christos }
121 1.1 jruoho }
122 1.1 jruoho }
123 1.1 jruoho }
124 1.1 jruoho
125 1.1.1.11 christos CreateNewObject:
126 1.1.1.11 christos
127 1.1 jruoho /* Create and init a new internal ACPI object */
128 1.1 jruoho
129 1.1 jruoho ObjDesc = AcpiUtCreateInternalObject (
130 1.1.1.7 christos (AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode))->ObjectType);
131 1.1 jruoho if (!ObjDesc)
132 1.1 jruoho {
133 1.1 jruoho return_ACPI_STATUS (AE_NO_MEMORY);
134 1.1 jruoho }
135 1.1 jruoho
136 1.1.1.7 christos Status = AcpiDsInitObjectFromOp (
137 1.1.1.7 christos WalkState, Op, Op->Common.AmlOpcode, &ObjDesc);
138 1.1 jruoho if (ACPI_FAILURE (Status))
139 1.1 jruoho {
140 1.1 jruoho AcpiUtRemoveReference (ObjDesc);
141 1.1 jruoho return_ACPI_STATUS (Status);
142 1.1 jruoho }
143 1.1 jruoho
144 1.1.1.11 christos /*
145 1.1.1.11 christos * Handling for unresolved package reference elements.
146 1.1.1.11 christos * These are elements that are namepaths.
147 1.1.1.11 christos */
148 1.1.1.11 christos if ((Op->Common.Parent->Common.AmlOpcode == AML_PACKAGE_OP) ||
149 1.1.1.11 christos (Op->Common.Parent->Common.AmlOpcode == AML_VARIABLE_PACKAGE_OP))
150 1.1.1.11 christos {
151 1.1.1.11 christos ObjDesc->Reference.Resolved = TRUE;
152 1.1.1.11 christos
153 1.1.1.11 christos if ((Op->Common.AmlOpcode == AML_INT_NAMEPATH_OP) &&
154 1.1.1.11 christos !ObjDesc->Reference.Node)
155 1.1.1.11 christos {
156 1.1.1.11 christos /*
157 1.1.1.11 christos * Name was unresolved above.
158 1.1.1.11 christos * Get the prefix node for later lookup
159 1.1.1.11 christos */
160 1.1.1.11 christos ObjDesc->Reference.Node = WalkState->ScopeInfo->Scope.Node;
161 1.1.1.11 christos ObjDesc->Reference.Aml = Op->Common.Aml;
162 1.1.1.11 christos ObjDesc->Reference.Resolved = FALSE;
163 1.1.1.11 christos }
164 1.1.1.11 christos }
165 1.1.1.11 christos
166 1.1 jruoho *ObjDescPtr = ObjDesc;
167 1.1 jruoho return_ACPI_STATUS (Status);
168 1.1 jruoho }
169 1.1 jruoho
170 1.1 jruoho
171 1.1 jruoho /*******************************************************************************
172 1.1 jruoho *
173 1.1 jruoho * FUNCTION: AcpiDsBuildInternalBufferObj
174 1.1 jruoho *
175 1.1 jruoho * PARAMETERS: WalkState - Current walk state
176 1.1 jruoho * Op - Parser object to be translated
177 1.1 jruoho * BufferLength - Length of the buffer
178 1.1 jruoho * ObjDescPtr - Where the ACPI internal object is returned
179 1.1 jruoho *
180 1.1 jruoho * RETURN: Status
181 1.1 jruoho *
182 1.1 jruoho * DESCRIPTION: Translate a parser Op package object to the equivalent
183 1.1 jruoho * namespace object
184 1.1 jruoho *
185 1.1 jruoho ******************************************************************************/
186 1.1 jruoho
187 1.1 jruoho ACPI_STATUS
188 1.1 jruoho AcpiDsBuildInternalBufferObj (
189 1.1 jruoho ACPI_WALK_STATE *WalkState,
190 1.1 jruoho ACPI_PARSE_OBJECT *Op,
191 1.1 jruoho UINT32 BufferLength,
192 1.1 jruoho ACPI_OPERAND_OBJECT **ObjDescPtr)
193 1.1 jruoho {
194 1.1 jruoho ACPI_PARSE_OBJECT *Arg;
195 1.1 jruoho ACPI_OPERAND_OBJECT *ObjDesc;
196 1.1 jruoho ACPI_PARSE_OBJECT *ByteList;
197 1.1 jruoho UINT32 ByteListLength = 0;
198 1.1 jruoho
199 1.1 jruoho
200 1.1 jruoho ACPI_FUNCTION_TRACE (DsBuildInternalBufferObj);
201 1.1 jruoho
202 1.1 jruoho
203 1.1 jruoho /*
204 1.1 jruoho * If we are evaluating a Named buffer object "Name (xxxx, Buffer)".
205 1.1 jruoho * The buffer object already exists (from the NS node), otherwise it must
206 1.1 jruoho * be created.
207 1.1 jruoho */
208 1.1 jruoho ObjDesc = *ObjDescPtr;
209 1.1 jruoho if (!ObjDesc)
210 1.1 jruoho {
211 1.1 jruoho /* Create a new buffer object */
212 1.1 jruoho
213 1.1 jruoho ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_BUFFER);
214 1.1 jruoho *ObjDescPtr = ObjDesc;
215 1.1 jruoho if (!ObjDesc)
216 1.1 jruoho {
217 1.1 jruoho return_ACPI_STATUS (AE_NO_MEMORY);
218 1.1 jruoho }
219 1.1 jruoho }
220 1.1 jruoho
221 1.1 jruoho /*
222 1.1 jruoho * Second arg is the buffer data (optional) ByteList can be either
223 1.1.1.3 christos * individual bytes or a string initializer. In either case, a
224 1.1 jruoho * ByteList appears in the AML.
225 1.1 jruoho */
226 1.1 jruoho Arg = Op->Common.Value.Arg; /* skip first arg */
227 1.1 jruoho
228 1.1 jruoho ByteList = Arg->Named.Next;
229 1.1 jruoho if (ByteList)
230 1.1 jruoho {
231 1.1 jruoho if (ByteList->Common.AmlOpcode != AML_INT_BYTELIST_OP)
232 1.1 jruoho {
233 1.1 jruoho ACPI_ERROR ((AE_INFO,
234 1.1 jruoho "Expecting bytelist, found AML opcode 0x%X in op %p",
235 1.1 jruoho ByteList->Common.AmlOpcode, ByteList));
236 1.1 jruoho
237 1.1 jruoho AcpiUtRemoveReference (ObjDesc);
238 1.1 jruoho return (AE_TYPE);
239 1.1 jruoho }
240 1.1 jruoho
241 1.1 jruoho ByteListLength = (UINT32) ByteList->Common.Value.Integer;
242 1.1 jruoho }
243 1.1 jruoho
244 1.1 jruoho /*
245 1.1 jruoho * The buffer length (number of bytes) will be the larger of:
246 1.1 jruoho * 1) The specified buffer length and
247 1.1 jruoho * 2) The length of the initializer byte list
248 1.1 jruoho */
249 1.1 jruoho ObjDesc->Buffer.Length = BufferLength;
250 1.1 jruoho if (ByteListLength > BufferLength)
251 1.1 jruoho {
252 1.1 jruoho ObjDesc->Buffer.Length = ByteListLength;
253 1.1 jruoho }
254 1.1 jruoho
255 1.1 jruoho /* Allocate the buffer */
256 1.1 jruoho
257 1.1 jruoho if (ObjDesc->Buffer.Length == 0)
258 1.1 jruoho {
259 1.1 jruoho ObjDesc->Buffer.Pointer = NULL;
260 1.1 jruoho ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
261 1.1 jruoho "Buffer defined with zero length in AML, creating\n"));
262 1.1 jruoho }
263 1.1 jruoho else
264 1.1 jruoho {
265 1.1.1.7 christos ObjDesc->Buffer.Pointer =
266 1.1.1.7 christos ACPI_ALLOCATE_ZEROED (ObjDesc->Buffer.Length);
267 1.1 jruoho if (!ObjDesc->Buffer.Pointer)
268 1.1 jruoho {
269 1.1 jruoho AcpiUtDeleteObjectDesc (ObjDesc);
270 1.1 jruoho return_ACPI_STATUS (AE_NO_MEMORY);
271 1.1 jruoho }
272 1.1 jruoho
273 1.1 jruoho /* Initialize buffer from the ByteList (if present) */
274 1.1 jruoho
275 1.1 jruoho if (ByteList)
276 1.1 jruoho {
277 1.1.1.6 christos memcpy (ObjDesc->Buffer.Pointer, ByteList->Named.Data,
278 1.1.1.7 christos ByteListLength);
279 1.1 jruoho }
280 1.1 jruoho }
281 1.1 jruoho
282 1.1 jruoho ObjDesc->Buffer.Flags |= AOPOBJ_DATA_VALID;
283 1.1 jruoho Op->Common.Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, ObjDesc);
284 1.1 jruoho return_ACPI_STATUS (AE_OK);
285 1.1 jruoho }
286 1.1 jruoho
287 1.1 jruoho /*******************************************************************************
288 1.1 jruoho *
289 1.1 jruoho * FUNCTION: AcpiDsCreateNode
290 1.1 jruoho *
291 1.1 jruoho * PARAMETERS: WalkState - Current walk state
292 1.1 jruoho * Node - NS Node to be initialized
293 1.1 jruoho * Op - Parser object to be translated
294 1.1 jruoho *
295 1.1 jruoho * RETURN: Status
296 1.1 jruoho *
297 1.1 jruoho * DESCRIPTION: Create the object to be associated with a namespace node
298 1.1 jruoho *
299 1.1 jruoho ******************************************************************************/
300 1.1 jruoho
301 1.1 jruoho ACPI_STATUS
302 1.1 jruoho AcpiDsCreateNode (
303 1.1 jruoho ACPI_WALK_STATE *WalkState,
304 1.1 jruoho ACPI_NAMESPACE_NODE *Node,
305 1.1 jruoho ACPI_PARSE_OBJECT *Op)
306 1.1 jruoho {
307 1.1 jruoho ACPI_STATUS Status;
308 1.1 jruoho ACPI_OPERAND_OBJECT *ObjDesc;
309 1.1 jruoho
310 1.1 jruoho
311 1.1 jruoho ACPI_FUNCTION_TRACE_PTR (DsCreateNode, Op);
312 1.1 jruoho
313 1.1 jruoho
314 1.1 jruoho /*
315 1.1 jruoho * Because of the execution pass through the non-control-method
316 1.1.1.3 christos * parts of the table, we can arrive here twice. Only init
317 1.1 jruoho * the named object node the first time through
318 1.1 jruoho */
319 1.1 jruoho if (AcpiNsGetAttachedObject (Node))
320 1.1 jruoho {
321 1.1 jruoho return_ACPI_STATUS (AE_OK);
322 1.1 jruoho }
323 1.1 jruoho
324 1.1 jruoho if (!Op->Common.Value.Arg)
325 1.1 jruoho {
326 1.1 jruoho /* No arguments, there is nothing to do */
327 1.1 jruoho
328 1.1 jruoho return_ACPI_STATUS (AE_OK);
329 1.1 jruoho }
330 1.1 jruoho
331 1.1 jruoho /* Build an internal object for the argument(s) */
332 1.1 jruoho
333 1.1.1.7 christos Status = AcpiDsBuildInternalObject (
334 1.1.1.7 christos WalkState, Op->Common.Value.Arg, &ObjDesc);
335 1.1 jruoho if (ACPI_FAILURE (Status))
336 1.1 jruoho {
337 1.1 jruoho return_ACPI_STATUS (Status);
338 1.1 jruoho }
339 1.1 jruoho
340 1.1 jruoho /* Re-type the object according to its argument */
341 1.1 jruoho
342 1.1 jruoho Node->Type = ObjDesc->Common.Type;
343 1.1 jruoho
344 1.1 jruoho /* Attach obj to node */
345 1.1 jruoho
346 1.1 jruoho Status = AcpiNsAttachObject (Node, ObjDesc, Node->Type);
347 1.1 jruoho
348 1.1 jruoho /* Remove local reference to the object */
349 1.1 jruoho
350 1.1 jruoho AcpiUtRemoveReference (ObjDesc);
351 1.1 jruoho return_ACPI_STATUS (Status);
352 1.1 jruoho }
353 1.1 jruoho
354 1.1 jruoho
355 1.1 jruoho /*******************************************************************************
356 1.1 jruoho *
357 1.1 jruoho * FUNCTION: AcpiDsInitObjectFromOp
358 1.1 jruoho *
359 1.1 jruoho * PARAMETERS: WalkState - Current walk state
360 1.1 jruoho * Op - Parser op used to init the internal object
361 1.1 jruoho * Opcode - AML opcode associated with the object
362 1.1 jruoho * RetObjDesc - Namespace object to be initialized
363 1.1 jruoho *
364 1.1 jruoho * RETURN: Status
365 1.1 jruoho *
366 1.1 jruoho * DESCRIPTION: Initialize a namespace object from a parser Op and its
367 1.1.1.3 christos * associated arguments. The namespace object is a more compact
368 1.1 jruoho * representation of the Op and its arguments.
369 1.1 jruoho *
370 1.1 jruoho ******************************************************************************/
371 1.1 jruoho
372 1.1 jruoho ACPI_STATUS
373 1.1 jruoho AcpiDsInitObjectFromOp (
374 1.1 jruoho ACPI_WALK_STATE *WalkState,
375 1.1 jruoho ACPI_PARSE_OBJECT *Op,
376 1.1 jruoho UINT16 Opcode,
377 1.1 jruoho ACPI_OPERAND_OBJECT **RetObjDesc)
378 1.1 jruoho {
379 1.1 jruoho const ACPI_OPCODE_INFO *OpInfo;
380 1.1 jruoho ACPI_OPERAND_OBJECT *ObjDesc;
381 1.1 jruoho ACPI_STATUS Status = AE_OK;
382 1.1 jruoho
383 1.1 jruoho
384 1.1 jruoho ACPI_FUNCTION_TRACE (DsInitObjectFromOp);
385 1.1 jruoho
386 1.1 jruoho
387 1.1 jruoho ObjDesc = *RetObjDesc;
388 1.1 jruoho OpInfo = AcpiPsGetOpcodeInfo (Opcode);
389 1.1 jruoho if (OpInfo->Class == AML_CLASS_UNKNOWN)
390 1.1 jruoho {
391 1.1 jruoho /* Unknown opcode */
392 1.1 jruoho
393 1.1 jruoho return_ACPI_STATUS (AE_TYPE);
394 1.1 jruoho }
395 1.1 jruoho
396 1.1 jruoho /* Perform per-object initialization */
397 1.1 jruoho
398 1.1 jruoho switch (ObjDesc->Common.Type)
399 1.1 jruoho {
400 1.1 jruoho case ACPI_TYPE_BUFFER:
401 1.1 jruoho /*
402 1.1 jruoho * Defer evaluation of Buffer TermArg operand
403 1.1 jruoho */
404 1.1.1.7 christos ObjDesc->Buffer.Node = ACPI_CAST_PTR (
405 1.1.1.7 christos ACPI_NAMESPACE_NODE, WalkState->Operands[0]);
406 1.1.1.7 christos ObjDesc->Buffer.AmlStart = Op->Named.Data;
407 1.1 jruoho ObjDesc->Buffer.AmlLength = Op->Named.Length;
408 1.1 jruoho break;
409 1.1 jruoho
410 1.1 jruoho case ACPI_TYPE_PACKAGE:
411 1.1 jruoho /*
412 1.1.1.11 christos * Defer evaluation of Package TermArg operand and all
413 1.1.1.11 christos * package elements. (01/2017): We defer the element
414 1.1.1.11 christos * resolution to allow forward references from the package
415 1.1.1.11 christos * in order to provide compatibility with other ACPI
416 1.1.1.11 christos * implementations.
417 1.1 jruoho */
418 1.1.1.7 christos ObjDesc->Package.Node = ACPI_CAST_PTR (
419 1.1.1.7 christos ACPI_NAMESPACE_NODE, WalkState->Operands[0]);
420 1.1.1.11 christos
421 1.1.1.11 christos if (!Op->Named.Data)
422 1.1.1.11 christos {
423 1.1.1.11 christos return_ACPI_STATUS (AE_OK);
424 1.1.1.11 christos }
425 1.1.1.11 christos
426 1.1.1.7 christos ObjDesc->Package.AmlStart = Op->Named.Data;
427 1.1 jruoho ObjDesc->Package.AmlLength = Op->Named.Length;
428 1.1 jruoho break;
429 1.1 jruoho
430 1.1 jruoho case ACPI_TYPE_INTEGER:
431 1.1 jruoho
432 1.1 jruoho switch (OpInfo->Type)
433 1.1 jruoho {
434 1.1 jruoho case AML_TYPE_CONSTANT:
435 1.1 jruoho /*
436 1.1 jruoho * Resolve AML Constants here - AND ONLY HERE!
437 1.1 jruoho * All constants are integers.
438 1.1 jruoho * We mark the integer with a flag that indicates that it started
439 1.1 jruoho * life as a constant -- so that stores to constants will perform
440 1.1 jruoho * as expected (noop). ZeroOp is used as a placeholder for optional
441 1.1 jruoho * target operands.
442 1.1 jruoho */
443 1.1 jruoho ObjDesc->Common.Flags = AOPOBJ_AML_CONSTANT;
444 1.1 jruoho
445 1.1 jruoho switch (Opcode)
446 1.1 jruoho {
447 1.1 jruoho case AML_ZERO_OP:
448 1.1 jruoho
449 1.1 jruoho ObjDesc->Integer.Value = 0;
450 1.1 jruoho break;
451 1.1 jruoho
452 1.1 jruoho case AML_ONE_OP:
453 1.1 jruoho
454 1.1 jruoho ObjDesc->Integer.Value = 1;
455 1.1 jruoho break;
456 1.1 jruoho
457 1.1 jruoho case AML_ONES_OP:
458 1.1 jruoho
459 1.1 jruoho ObjDesc->Integer.Value = ACPI_UINT64_MAX;
460 1.1 jruoho
461 1.1 jruoho /* Truncate value if we are executing from a 32-bit ACPI table */
462 1.1 jruoho
463 1.1.1.3 christos (void) AcpiExTruncateFor32bitTable (ObjDesc);
464 1.1 jruoho break;
465 1.1 jruoho
466 1.1 jruoho case AML_REVISION_OP:
467 1.1 jruoho
468 1.1 jruoho ObjDesc->Integer.Value = ACPI_CA_VERSION;
469 1.1 jruoho break;
470 1.1 jruoho
471 1.1 jruoho default:
472 1.1 jruoho
473 1.1 jruoho ACPI_ERROR ((AE_INFO,
474 1.1 jruoho "Unknown constant opcode 0x%X", Opcode));
475 1.1 jruoho Status = AE_AML_OPERAND_TYPE;
476 1.1 jruoho break;
477 1.1 jruoho }
478 1.1 jruoho break;
479 1.1 jruoho
480 1.1 jruoho case AML_TYPE_LITERAL:
481 1.1 jruoho
482 1.1 jruoho ObjDesc->Integer.Value = Op->Common.Value.Integer;
483 1.1.1.3 christos
484 1.1.1.3 christos if (AcpiExTruncateFor32bitTable (ObjDesc))
485 1.1.1.3 christos {
486 1.1.1.3 christos /* Warn if we found a 64-bit constant in a 32-bit table */
487 1.1.1.3 christos
488 1.1.1.3 christos ACPI_WARNING ((AE_INFO,
489 1.1.1.3 christos "Truncated 64-bit constant found in 32-bit table: %8.8X%8.8X => %8.8X",
490 1.1.1.3 christos ACPI_FORMAT_UINT64 (Op->Common.Value.Integer),
491 1.1.1.3 christos (UINT32) ObjDesc->Integer.Value));
492 1.1.1.3 christos }
493 1.1 jruoho break;
494 1.1 jruoho
495 1.1 jruoho default:
496 1.1.1.3 christos
497 1.1 jruoho ACPI_ERROR ((AE_INFO, "Unknown Integer type 0x%X",
498 1.1 jruoho OpInfo->Type));
499 1.1 jruoho Status = AE_AML_OPERAND_TYPE;
500 1.1 jruoho break;
501 1.1 jruoho }
502 1.1 jruoho break;
503 1.1 jruoho
504 1.1 jruoho case ACPI_TYPE_STRING:
505 1.1 jruoho
506 1.1 jruoho ObjDesc->String.Pointer = Op->Common.Value.String;
507 1.1.1.6 christos ObjDesc->String.Length = (UINT32) strlen (Op->Common.Value.String);
508 1.1 jruoho
509 1.1 jruoho /*
510 1.1 jruoho * The string is contained in the ACPI table, don't ever try
511 1.1 jruoho * to delete it
512 1.1 jruoho */
513 1.1 jruoho ObjDesc->Common.Flags |= AOPOBJ_STATIC_POINTER;
514 1.1 jruoho break;
515 1.1 jruoho
516 1.1 jruoho case ACPI_TYPE_METHOD:
517 1.1 jruoho break;
518 1.1 jruoho
519 1.1 jruoho case ACPI_TYPE_LOCAL_REFERENCE:
520 1.1 jruoho
521 1.1 jruoho switch (OpInfo->Type)
522 1.1 jruoho {
523 1.1 jruoho case AML_TYPE_LOCAL_VARIABLE:
524 1.1 jruoho
525 1.1.1.10 christos /* Local ID (0-7) is (AML opcode - base AML_FIRST_LOCAL_OP) */
526 1.1 jruoho
527 1.1.1.10 christos ObjDesc->Reference.Value = ((UINT32) Opcode) - AML_FIRST_LOCAL_OP;
528 1.1 jruoho ObjDesc->Reference.Class = ACPI_REFCLASS_LOCAL;
529 1.1 jruoho
530 1.1 jruoho Status = AcpiDsMethodDataGetNode (ACPI_REFCLASS_LOCAL,
531 1.1.1.7 christos ObjDesc->Reference.Value, WalkState,
532 1.1.1.7 christos ACPI_CAST_INDIRECT_PTR (ACPI_NAMESPACE_NODE,
533 1.1.1.7 christos &ObjDesc->Reference.Object));
534 1.1 jruoho break;
535 1.1 jruoho
536 1.1 jruoho case AML_TYPE_METHOD_ARGUMENT:
537 1.1 jruoho
538 1.1.1.10 christos /* Arg ID (0-6) is (AML opcode - base AML_FIRST_ARG_OP) */
539 1.1 jruoho
540 1.1.1.10 christos ObjDesc->Reference.Value = ((UINT32) Opcode) - AML_FIRST_ARG_OP;
541 1.1 jruoho ObjDesc->Reference.Class = ACPI_REFCLASS_ARG;
542 1.1 jruoho
543 1.1 jruoho Status = AcpiDsMethodDataGetNode (ACPI_REFCLASS_ARG,
544 1.1.1.7 christos ObjDesc->Reference.Value, WalkState,
545 1.1.1.7 christos ACPI_CAST_INDIRECT_PTR (ACPI_NAMESPACE_NODE,
546 1.1.1.7 christos &ObjDesc->Reference.Object));
547 1.1 jruoho break;
548 1.1 jruoho
549 1.1 jruoho default: /* Object name or Debug object */
550 1.1 jruoho
551 1.1 jruoho switch (Op->Common.AmlOpcode)
552 1.1 jruoho {
553 1.1 jruoho case AML_INT_NAMEPATH_OP:
554 1.1 jruoho
555 1.1 jruoho /* Node was saved in Op */
556 1.1 jruoho
557 1.1 jruoho ObjDesc->Reference.Node = Op->Common.Node;
558 1.1 jruoho ObjDesc->Reference.Class = ACPI_REFCLASS_NAME;
559 1.1.1.11 christos if (Op->Common.Node)
560 1.1.1.11 christos {
561 1.1.1.11 christos ObjDesc->Reference.Object = Op->Common.Node->Object;
562 1.1.1.11 christos }
563 1.1 jruoho break;
564 1.1 jruoho
565 1.1 jruoho case AML_DEBUG_OP:
566 1.1 jruoho
567 1.1 jruoho ObjDesc->Reference.Class = ACPI_REFCLASS_DEBUG;
568 1.1 jruoho break;
569 1.1 jruoho
570 1.1 jruoho default:
571 1.1 jruoho
572 1.1 jruoho ACPI_ERROR ((AE_INFO,
573 1.1 jruoho "Unimplemented reference type for AML opcode: 0x%4.4X", Opcode));
574 1.1 jruoho return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
575 1.1 jruoho }
576 1.1 jruoho break;
577 1.1 jruoho }
578 1.1 jruoho break;
579 1.1 jruoho
580 1.1 jruoho default:
581 1.1 jruoho
582 1.1 jruoho ACPI_ERROR ((AE_INFO, "Unimplemented data type: 0x%X",
583 1.1 jruoho ObjDesc->Common.Type));
584 1.1 jruoho
585 1.1 jruoho Status = AE_AML_OPERAND_TYPE;
586 1.1 jruoho break;
587 1.1 jruoho }
588 1.1 jruoho
589 1.1 jruoho return_ACPI_STATUS (Status);
590 1.1 jruoho }
591