dsobject.c revision 1.1.1.2.2.2 1 1.1.1.2.2.2 bouyer /******************************************************************************
2 1.1.1.2.2.2 bouyer *
3 1.1.1.2.2.2 bouyer * Module Name: dsobject - Dispatcher object management routines
4 1.1.1.2.2.2 bouyer *
5 1.1.1.2.2.2 bouyer *****************************************************************************/
6 1.1.1.2.2.2 bouyer
7 1.1.1.2.2.2 bouyer /*
8 1.1.1.2.2.2 bouyer * Copyright (C) 2000 - 2011, Intel Corp.
9 1.1.1.2.2.2 bouyer * All rights reserved.
10 1.1.1.2.2.2 bouyer *
11 1.1.1.2.2.2 bouyer * Redistribution and use in source and binary forms, with or without
12 1.1.1.2.2.2 bouyer * modification, are permitted provided that the following conditions
13 1.1.1.2.2.2 bouyer * are met:
14 1.1.1.2.2.2 bouyer * 1. Redistributions of source code must retain the above copyright
15 1.1.1.2.2.2 bouyer * notice, this list of conditions, and the following disclaimer,
16 1.1.1.2.2.2 bouyer * without modification.
17 1.1.1.2.2.2 bouyer * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 1.1.1.2.2.2 bouyer * substantially similar to the "NO WARRANTY" disclaimer below
19 1.1.1.2.2.2 bouyer * ("Disclaimer") and any redistribution must be conditioned upon
20 1.1.1.2.2.2 bouyer * including a substantially similar Disclaimer requirement for further
21 1.1.1.2.2.2 bouyer * binary redistribution.
22 1.1.1.2.2.2 bouyer * 3. Neither the names of the above-listed copyright holders nor the names
23 1.1.1.2.2.2 bouyer * of any contributors may be used to endorse or promote products derived
24 1.1.1.2.2.2 bouyer * from this software without specific prior written permission.
25 1.1.1.2.2.2 bouyer *
26 1.1.1.2.2.2 bouyer * Alternatively, this software may be distributed under the terms of the
27 1.1.1.2.2.2 bouyer * GNU General Public License ("GPL") version 2 as published by the Free
28 1.1.1.2.2.2 bouyer * Software Foundation.
29 1.1.1.2.2.2 bouyer *
30 1.1.1.2.2.2 bouyer * NO WARRANTY
31 1.1.1.2.2.2 bouyer * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 1.1.1.2.2.2 bouyer * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 1.1.1.2.2.2 bouyer * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 1.1.1.2.2.2 bouyer * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 1.1.1.2.2.2 bouyer * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 1.1.1.2.2.2 bouyer * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 1.1.1.2.2.2 bouyer * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 1.1.1.2.2.2 bouyer * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 1.1.1.2.2.2 bouyer * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 1.1.1.2.2.2 bouyer * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 1.1.1.2.2.2 bouyer * POSSIBILITY OF SUCH DAMAGES.
42 1.1.1.2.2.2 bouyer */
43 1.1.1.2.2.2 bouyer
44 1.1.1.2.2.2 bouyer #define __DSOBJECT_C__
45 1.1.1.2.2.2 bouyer
46 1.1.1.2.2.2 bouyer #include "acpi.h"
47 1.1.1.2.2.2 bouyer #include "accommon.h"
48 1.1.1.2.2.2 bouyer #include "acparser.h"
49 1.1.1.2.2.2 bouyer #include "amlcode.h"
50 1.1.1.2.2.2 bouyer #include "acdispat.h"
51 1.1.1.2.2.2 bouyer #include "acnamesp.h"
52 1.1.1.2.2.2 bouyer #include "acinterp.h"
53 1.1.1.2.2.2 bouyer
54 1.1.1.2.2.2 bouyer #define _COMPONENT ACPI_DISPATCHER
55 1.1.1.2.2.2 bouyer ACPI_MODULE_NAME ("dsobject")
56 1.1.1.2.2.2 bouyer
57 1.1.1.2.2.2 bouyer /* Local prototypes */
58 1.1.1.2.2.2 bouyer
59 1.1.1.2.2.2 bouyer static ACPI_STATUS
60 1.1.1.2.2.2 bouyer AcpiDsBuildInternalObject (
61 1.1.1.2.2.2 bouyer ACPI_WALK_STATE *WalkState,
62 1.1.1.2.2.2 bouyer ACPI_PARSE_OBJECT *Op,
63 1.1.1.2.2.2 bouyer ACPI_OPERAND_OBJECT **ObjDescPtr);
64 1.1.1.2.2.2 bouyer
65 1.1.1.2.2.2 bouyer
66 1.1.1.2.2.2 bouyer #ifndef ACPI_NO_METHOD_EXECUTION
67 1.1.1.2.2.2 bouyer /*******************************************************************************
68 1.1.1.2.2.2 bouyer *
69 1.1.1.2.2.2 bouyer * FUNCTION: AcpiDsBuildInternalObject
70 1.1.1.2.2.2 bouyer *
71 1.1.1.2.2.2 bouyer * PARAMETERS: WalkState - Current walk state
72 1.1.1.2.2.2 bouyer * Op - Parser object to be translated
73 1.1.1.2.2.2 bouyer * ObjDescPtr - Where the ACPI internal object is returned
74 1.1.1.2.2.2 bouyer *
75 1.1.1.2.2.2 bouyer * RETURN: Status
76 1.1.1.2.2.2 bouyer *
77 1.1.1.2.2.2 bouyer * DESCRIPTION: Translate a parser Op object to the equivalent namespace object
78 1.1.1.2.2.2 bouyer * Simple objects are any objects other than a package object!
79 1.1.1.2.2.2 bouyer *
80 1.1.1.2.2.2 bouyer ******************************************************************************/
81 1.1.1.2.2.2 bouyer
82 1.1.1.2.2.2 bouyer static ACPI_STATUS
83 1.1.1.2.2.2 bouyer AcpiDsBuildInternalObject (
84 1.1.1.2.2.2 bouyer ACPI_WALK_STATE *WalkState,
85 1.1.1.2.2.2 bouyer ACPI_PARSE_OBJECT *Op,
86 1.1.1.2.2.2 bouyer ACPI_OPERAND_OBJECT **ObjDescPtr)
87 1.1.1.2.2.2 bouyer {
88 1.1.1.2.2.2 bouyer ACPI_OPERAND_OBJECT *ObjDesc;
89 1.1.1.2.2.2 bouyer ACPI_STATUS Status;
90 1.1.1.2.2.2 bouyer ACPI_OBJECT_TYPE Type;
91 1.1.1.2.2.2 bouyer
92 1.1.1.2.2.2 bouyer
93 1.1.1.2.2.2 bouyer ACPI_FUNCTION_TRACE (DsBuildInternalObject);
94 1.1.1.2.2.2 bouyer
95 1.1.1.2.2.2 bouyer
96 1.1.1.2.2.2 bouyer *ObjDescPtr = NULL;
97 1.1.1.2.2.2 bouyer if (Op->Common.AmlOpcode == AML_INT_NAMEPATH_OP)
98 1.1.1.2.2.2 bouyer {
99 1.1.1.2.2.2 bouyer /*
100 1.1.1.2.2.2 bouyer * This is a named object reference. If this name was
101 1.1.1.2.2.2 bouyer * previously looked up in the namespace, it was stored in this op.
102 1.1.1.2.2.2 bouyer * Otherwise, go ahead and look it up now
103 1.1.1.2.2.2 bouyer */
104 1.1.1.2.2.2 bouyer if (!Op->Common.Node)
105 1.1.1.2.2.2 bouyer {
106 1.1.1.2.2.2 bouyer Status = AcpiNsLookup (WalkState->ScopeInfo,
107 1.1.1.2.2.2 bouyer Op->Common.Value.String,
108 1.1.1.2.2.2 bouyer ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE,
109 1.1.1.2.2.2 bouyer ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE, NULL,
110 1.1.1.2.2.2 bouyer ACPI_CAST_INDIRECT_PTR (ACPI_NAMESPACE_NODE, &(Op->Common.Node)));
111 1.1.1.2.2.2 bouyer if (ACPI_FAILURE (Status))
112 1.1.1.2.2.2 bouyer {
113 1.1.1.2.2.2 bouyer /* Check if we are resolving a named reference within a package */
114 1.1.1.2.2.2 bouyer
115 1.1.1.2.2.2 bouyer if ((Status == AE_NOT_FOUND) && (AcpiGbl_EnableInterpreterSlack) &&
116 1.1.1.2.2.2 bouyer
117 1.1.1.2.2.2 bouyer ((Op->Common.Parent->Common.AmlOpcode == AML_PACKAGE_OP) ||
118 1.1.1.2.2.2 bouyer (Op->Common.Parent->Common.AmlOpcode == AML_VAR_PACKAGE_OP)))
119 1.1.1.2.2.2 bouyer {
120 1.1.1.2.2.2 bouyer /*
121 1.1.1.2.2.2 bouyer * We didn't find the target and we are populating elements
122 1.1.1.2.2.2 bouyer * of a package - ignore if slack enabled. Some ASL code
123 1.1.1.2.2.2 bouyer * contains dangling invalid references in packages and
124 1.1.1.2.2.2 bouyer * expects that no exception will be issued. Leave the
125 1.1.1.2.2.2 bouyer * element as a null element. It cannot be used, but it
126 1.1.1.2.2.2 bouyer * can be overwritten by subsequent ASL code - this is
127 1.1.1.2.2.2 bouyer * typically the case.
128 1.1.1.2.2.2 bouyer */
129 1.1.1.2.2.2 bouyer ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
130 1.1.1.2.2.2 bouyer "Ignoring unresolved reference in package [%4.4s]\n",
131 1.1.1.2.2.2 bouyer WalkState->ScopeInfo->Scope.Node->Name.Ascii));
132 1.1.1.2.2.2 bouyer
133 1.1.1.2.2.2 bouyer return_ACPI_STATUS (AE_OK);
134 1.1.1.2.2.2 bouyer }
135 1.1.1.2.2.2 bouyer else
136 1.1.1.2.2.2 bouyer {
137 1.1.1.2.2.2 bouyer ACPI_ERROR_NAMESPACE (Op->Common.Value.String, Status);
138 1.1.1.2.2.2 bouyer }
139 1.1.1.2.2.2 bouyer
140 1.1.1.2.2.2 bouyer return_ACPI_STATUS (Status);
141 1.1.1.2.2.2 bouyer }
142 1.1.1.2.2.2 bouyer }
143 1.1.1.2.2.2 bouyer
144 1.1.1.2.2.2 bouyer /* Special object resolution for elements of a package */
145 1.1.1.2.2.2 bouyer
146 1.1.1.2.2.2 bouyer if ((Op->Common.Parent->Common.AmlOpcode == AML_PACKAGE_OP) ||
147 1.1.1.2.2.2 bouyer (Op->Common.Parent->Common.AmlOpcode == AML_VAR_PACKAGE_OP))
148 1.1.1.2.2.2 bouyer {
149 1.1.1.2.2.2 bouyer /*
150 1.1.1.2.2.2 bouyer * Attempt to resolve the node to a value before we insert it into
151 1.1.1.2.2.2 bouyer * the package. If this is a reference to a common data type,
152 1.1.1.2.2.2 bouyer * resolve it immediately. According to the ACPI spec, package
153 1.1.1.2.2.2 bouyer * elements can only be "data objects" or method references.
154 1.1.1.2.2.2 bouyer * Attempt to resolve to an Integer, Buffer, String or Package.
155 1.1.1.2.2.2 bouyer * If cannot, return the named reference (for things like Devices,
156 1.1.1.2.2.2 bouyer * Methods, etc.) Buffer Fields and Fields will resolve to simple
157 1.1.1.2.2.2 bouyer * objects (int/buf/str/pkg).
158 1.1.1.2.2.2 bouyer *
159 1.1.1.2.2.2 bouyer * NOTE: References to things like Devices, Methods, Mutexes, etc.
160 1.1.1.2.2.2 bouyer * will remain as named references. This behavior is not described
161 1.1.1.2.2.2 bouyer * in the ACPI spec, but it appears to be an oversight.
162 1.1.1.2.2.2 bouyer */
163 1.1.1.2.2.2 bouyer ObjDesc = ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, Op->Common.Node);
164 1.1.1.2.2.2 bouyer
165 1.1.1.2.2.2 bouyer Status = AcpiExResolveNodeToValue (
166 1.1.1.2.2.2 bouyer ACPI_CAST_INDIRECT_PTR (ACPI_NAMESPACE_NODE, &ObjDesc),
167 1.1.1.2.2.2 bouyer WalkState);
168 1.1.1.2.2.2 bouyer if (ACPI_FAILURE (Status))
169 1.1.1.2.2.2 bouyer {
170 1.1.1.2.2.2 bouyer return_ACPI_STATUS (Status);
171 1.1.1.2.2.2 bouyer }
172 1.1.1.2.2.2 bouyer
173 1.1.1.2.2.2 bouyer /*
174 1.1.1.2.2.2 bouyer * Special handling for Alias objects. We need to setup the type
175 1.1.1.2.2.2 bouyer * and the Op->Common.Node to point to the Alias target. Note,
176 1.1.1.2.2.2 bouyer * Alias has at most one level of indirection internally.
177 1.1.1.2.2.2 bouyer */
178 1.1.1.2.2.2 bouyer Type = Op->Common.Node->Type;
179 1.1.1.2.2.2 bouyer if (Type == ACPI_TYPE_LOCAL_ALIAS)
180 1.1.1.2.2.2 bouyer {
181 1.1.1.2.2.2 bouyer Type = ObjDesc->Common.Type;
182 1.1.1.2.2.2 bouyer Op->Common.Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE,
183 1.1.1.2.2.2 bouyer Op->Common.Node->Object);
184 1.1.1.2.2.2 bouyer }
185 1.1.1.2.2.2 bouyer
186 1.1.1.2.2.2 bouyer switch (Type)
187 1.1.1.2.2.2 bouyer {
188 1.1.1.2.2.2 bouyer /*
189 1.1.1.2.2.2 bouyer * For these types, we need the actual node, not the subobject.
190 1.1.1.2.2.2 bouyer * However, the subobject did not get an extra reference count above.
191 1.1.1.2.2.2 bouyer *
192 1.1.1.2.2.2 bouyer * TBD: should ExResolveNodeToValue be changed to fix this?
193 1.1.1.2.2.2 bouyer */
194 1.1.1.2.2.2 bouyer case ACPI_TYPE_DEVICE:
195 1.1.1.2.2.2 bouyer case ACPI_TYPE_THERMAL:
196 1.1.1.2.2.2 bouyer
197 1.1.1.2.2.2 bouyer AcpiUtAddReference (Op->Common.Node->Object);
198 1.1.1.2.2.2 bouyer
199 1.1.1.2.2.2 bouyer /*lint -fallthrough */
200 1.1.1.2.2.2 bouyer /*
201 1.1.1.2.2.2 bouyer * For these types, we need the actual node, not the subobject.
202 1.1.1.2.2.2 bouyer * The subobject got an extra reference count in ExResolveNodeToValue.
203 1.1.1.2.2.2 bouyer */
204 1.1.1.2.2.2 bouyer case ACPI_TYPE_MUTEX:
205 1.1.1.2.2.2 bouyer case ACPI_TYPE_METHOD:
206 1.1.1.2.2.2 bouyer case ACPI_TYPE_POWER:
207 1.1.1.2.2.2 bouyer case ACPI_TYPE_PROCESSOR:
208 1.1.1.2.2.2 bouyer case ACPI_TYPE_EVENT:
209 1.1.1.2.2.2 bouyer case ACPI_TYPE_REGION:
210 1.1.1.2.2.2 bouyer
211 1.1.1.2.2.2 bouyer /* We will create a reference object for these types below */
212 1.1.1.2.2.2 bouyer break;
213 1.1.1.2.2.2 bouyer
214 1.1.1.2.2.2 bouyer default:
215 1.1.1.2.2.2 bouyer /*
216 1.1.1.2.2.2 bouyer * All other types - the node was resolved to an actual
217 1.1.1.2.2.2 bouyer * object, we are done.
218 1.1.1.2.2.2 bouyer */
219 1.1.1.2.2.2 bouyer goto Exit;
220 1.1.1.2.2.2 bouyer }
221 1.1.1.2.2.2 bouyer }
222 1.1.1.2.2.2 bouyer }
223 1.1.1.2.2.2 bouyer
224 1.1.1.2.2.2 bouyer /* Create and init a new internal ACPI object */
225 1.1.1.2.2.2 bouyer
226 1.1.1.2.2.2 bouyer ObjDesc = AcpiUtCreateInternalObject (
227 1.1.1.2.2.2 bouyer (AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode))->ObjectType);
228 1.1.1.2.2.2 bouyer if (!ObjDesc)
229 1.1.1.2.2.2 bouyer {
230 1.1.1.2.2.2 bouyer return_ACPI_STATUS (AE_NO_MEMORY);
231 1.1.1.2.2.2 bouyer }
232 1.1.1.2.2.2 bouyer
233 1.1.1.2.2.2 bouyer Status = AcpiDsInitObjectFromOp (WalkState, Op, Op->Common.AmlOpcode,
234 1.1.1.2.2.2 bouyer &ObjDesc);
235 1.1.1.2.2.2 bouyer if (ACPI_FAILURE (Status))
236 1.1.1.2.2.2 bouyer {
237 1.1.1.2.2.2 bouyer AcpiUtRemoveReference (ObjDesc);
238 1.1.1.2.2.2 bouyer return_ACPI_STATUS (Status);
239 1.1.1.2.2.2 bouyer }
240 1.1.1.2.2.2 bouyer
241 1.1.1.2.2.2 bouyer Exit:
242 1.1.1.2.2.2 bouyer *ObjDescPtr = ObjDesc;
243 1.1.1.2.2.2 bouyer return_ACPI_STATUS (Status);
244 1.1.1.2.2.2 bouyer }
245 1.1.1.2.2.2 bouyer
246 1.1.1.2.2.2 bouyer
247 1.1.1.2.2.2 bouyer /*******************************************************************************
248 1.1.1.2.2.2 bouyer *
249 1.1.1.2.2.2 bouyer * FUNCTION: AcpiDsBuildInternalBufferObj
250 1.1.1.2.2.2 bouyer *
251 1.1.1.2.2.2 bouyer * PARAMETERS: WalkState - Current walk state
252 1.1.1.2.2.2 bouyer * Op - Parser object to be translated
253 1.1.1.2.2.2 bouyer * BufferLength - Length of the buffer
254 1.1.1.2.2.2 bouyer * ObjDescPtr - Where the ACPI internal object is returned
255 1.1.1.2.2.2 bouyer *
256 1.1.1.2.2.2 bouyer * RETURN: Status
257 1.1.1.2.2.2 bouyer *
258 1.1.1.2.2.2 bouyer * DESCRIPTION: Translate a parser Op package object to the equivalent
259 1.1.1.2.2.2 bouyer * namespace object
260 1.1.1.2.2.2 bouyer *
261 1.1.1.2.2.2 bouyer ******************************************************************************/
262 1.1.1.2.2.2 bouyer
263 1.1.1.2.2.2 bouyer ACPI_STATUS
264 1.1.1.2.2.2 bouyer AcpiDsBuildInternalBufferObj (
265 1.1.1.2.2.2 bouyer ACPI_WALK_STATE *WalkState,
266 1.1.1.2.2.2 bouyer ACPI_PARSE_OBJECT *Op,
267 1.1.1.2.2.2 bouyer UINT32 BufferLength,
268 1.1.1.2.2.2 bouyer ACPI_OPERAND_OBJECT **ObjDescPtr)
269 1.1.1.2.2.2 bouyer {
270 1.1.1.2.2.2 bouyer ACPI_PARSE_OBJECT *Arg;
271 1.1.1.2.2.2 bouyer ACPI_OPERAND_OBJECT *ObjDesc;
272 1.1.1.2.2.2 bouyer ACPI_PARSE_OBJECT *ByteList;
273 1.1.1.2.2.2 bouyer UINT32 ByteListLength = 0;
274 1.1.1.2.2.2 bouyer
275 1.1.1.2.2.2 bouyer
276 1.1.1.2.2.2 bouyer ACPI_FUNCTION_TRACE (DsBuildInternalBufferObj);
277 1.1.1.2.2.2 bouyer
278 1.1.1.2.2.2 bouyer
279 1.1.1.2.2.2 bouyer /*
280 1.1.1.2.2.2 bouyer * If we are evaluating a Named buffer object "Name (xxxx, Buffer)".
281 1.1.1.2.2.2 bouyer * The buffer object already exists (from the NS node), otherwise it must
282 1.1.1.2.2.2 bouyer * be created.
283 1.1.1.2.2.2 bouyer */
284 1.1.1.2.2.2 bouyer ObjDesc = *ObjDescPtr;
285 1.1.1.2.2.2 bouyer if (!ObjDesc)
286 1.1.1.2.2.2 bouyer {
287 1.1.1.2.2.2 bouyer /* Create a new buffer object */
288 1.1.1.2.2.2 bouyer
289 1.1.1.2.2.2 bouyer ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_BUFFER);
290 1.1.1.2.2.2 bouyer *ObjDescPtr = ObjDesc;
291 1.1.1.2.2.2 bouyer if (!ObjDesc)
292 1.1.1.2.2.2 bouyer {
293 1.1.1.2.2.2 bouyer return_ACPI_STATUS (AE_NO_MEMORY);
294 1.1.1.2.2.2 bouyer }
295 1.1.1.2.2.2 bouyer }
296 1.1.1.2.2.2 bouyer
297 1.1.1.2.2.2 bouyer /*
298 1.1.1.2.2.2 bouyer * Second arg is the buffer data (optional) ByteList can be either
299 1.1.1.2.2.2 bouyer * individual bytes or a string initializer. In either case, a
300 1.1.1.2.2.2 bouyer * ByteList appears in the AML.
301 1.1.1.2.2.2 bouyer */
302 1.1.1.2.2.2 bouyer Arg = Op->Common.Value.Arg; /* skip first arg */
303 1.1.1.2.2.2 bouyer
304 1.1.1.2.2.2 bouyer ByteList = Arg->Named.Next;
305 1.1.1.2.2.2 bouyer if (ByteList)
306 1.1.1.2.2.2 bouyer {
307 1.1.1.2.2.2 bouyer if (ByteList->Common.AmlOpcode != AML_INT_BYTELIST_OP)
308 1.1.1.2.2.2 bouyer {
309 1.1.1.2.2.2 bouyer ACPI_ERROR ((AE_INFO,
310 1.1.1.2.2.2 bouyer "Expecting bytelist, found AML opcode 0x%X in op %p",
311 1.1.1.2.2.2 bouyer ByteList->Common.AmlOpcode, ByteList));
312 1.1.1.2.2.2 bouyer
313 1.1.1.2.2.2 bouyer AcpiUtRemoveReference (ObjDesc);
314 1.1.1.2.2.2 bouyer return (AE_TYPE);
315 1.1.1.2.2.2 bouyer }
316 1.1.1.2.2.2 bouyer
317 1.1.1.2.2.2 bouyer ByteListLength = (UINT32) ByteList->Common.Value.Integer;
318 1.1.1.2.2.2 bouyer }
319 1.1.1.2.2.2 bouyer
320 1.1.1.2.2.2 bouyer /*
321 1.1.1.2.2.2 bouyer * The buffer length (number of bytes) will be the larger of:
322 1.1.1.2.2.2 bouyer * 1) The specified buffer length and
323 1.1.1.2.2.2 bouyer * 2) The length of the initializer byte list
324 1.1.1.2.2.2 bouyer */
325 1.1.1.2.2.2 bouyer ObjDesc->Buffer.Length = BufferLength;
326 1.1.1.2.2.2 bouyer if (ByteListLength > BufferLength)
327 1.1.1.2.2.2 bouyer {
328 1.1.1.2.2.2 bouyer ObjDesc->Buffer.Length = ByteListLength;
329 1.1.1.2.2.2 bouyer }
330 1.1.1.2.2.2 bouyer
331 1.1.1.2.2.2 bouyer /* Allocate the buffer */
332 1.1.1.2.2.2 bouyer
333 1.1.1.2.2.2 bouyer if (ObjDesc->Buffer.Length == 0)
334 1.1.1.2.2.2 bouyer {
335 1.1.1.2.2.2 bouyer ObjDesc->Buffer.Pointer = NULL;
336 1.1.1.2.2.2 bouyer ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
337 1.1.1.2.2.2 bouyer "Buffer defined with zero length in AML, creating\n"));
338 1.1.1.2.2.2 bouyer }
339 1.1.1.2.2.2 bouyer else
340 1.1.1.2.2.2 bouyer {
341 1.1.1.2.2.2 bouyer ObjDesc->Buffer.Pointer = ACPI_ALLOCATE_ZEROED (
342 1.1.1.2.2.2 bouyer ObjDesc->Buffer.Length);
343 1.1.1.2.2.2 bouyer if (!ObjDesc->Buffer.Pointer)
344 1.1.1.2.2.2 bouyer {
345 1.1.1.2.2.2 bouyer AcpiUtDeleteObjectDesc (ObjDesc);
346 1.1.1.2.2.2 bouyer return_ACPI_STATUS (AE_NO_MEMORY);
347 1.1.1.2.2.2 bouyer }
348 1.1.1.2.2.2 bouyer
349 1.1.1.2.2.2 bouyer /* Initialize buffer from the ByteList (if present) */
350 1.1.1.2.2.2 bouyer
351 1.1.1.2.2.2 bouyer if (ByteList)
352 1.1.1.2.2.2 bouyer {
353 1.1.1.2.2.2 bouyer ACPI_MEMCPY (ObjDesc->Buffer.Pointer, ByteList->Named.Data,
354 1.1.1.2.2.2 bouyer ByteListLength);
355 1.1.1.2.2.2 bouyer }
356 1.1.1.2.2.2 bouyer }
357 1.1.1.2.2.2 bouyer
358 1.1.1.2.2.2 bouyer ObjDesc->Buffer.Flags |= AOPOBJ_DATA_VALID;
359 1.1.1.2.2.2 bouyer Op->Common.Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, ObjDesc);
360 1.1.1.2.2.2 bouyer return_ACPI_STATUS (AE_OK);
361 1.1.1.2.2.2 bouyer }
362 1.1.1.2.2.2 bouyer
363 1.1.1.2.2.2 bouyer
364 1.1.1.2.2.2 bouyer /*******************************************************************************
365 1.1.1.2.2.2 bouyer *
366 1.1.1.2.2.2 bouyer * FUNCTION: AcpiDsBuildInternalPackageObj
367 1.1.1.2.2.2 bouyer *
368 1.1.1.2.2.2 bouyer * PARAMETERS: WalkState - Current walk state
369 1.1.1.2.2.2 bouyer * Op - Parser object to be translated
370 1.1.1.2.2.2 bouyer * ElementCount - Number of elements in the package - this is
371 1.1.1.2.2.2 bouyer * the NumElements argument to Package()
372 1.1.1.2.2.2 bouyer * ObjDescPtr - Where the ACPI internal object is returned
373 1.1.1.2.2.2 bouyer *
374 1.1.1.2.2.2 bouyer * RETURN: Status
375 1.1.1.2.2.2 bouyer *
376 1.1.1.2.2.2 bouyer * DESCRIPTION: Translate a parser Op package object to the equivalent
377 1.1.1.2.2.2 bouyer * namespace object
378 1.1.1.2.2.2 bouyer *
379 1.1.1.2.2.2 bouyer * NOTE: The number of elements in the package will be always be the NumElements
380 1.1.1.2.2.2 bouyer * count, regardless of the number of elements in the package list. If
381 1.1.1.2.2.2 bouyer * NumElements is smaller, only that many package list elements are used.
382 1.1.1.2.2.2 bouyer * if NumElements is larger, the Package object is padded out with
383 1.1.1.2.2.2 bouyer * objects of type Uninitialized (as per ACPI spec.)
384 1.1.1.2.2.2 bouyer *
385 1.1.1.2.2.2 bouyer * Even though the ASL compilers do not allow NumElements to be smaller
386 1.1.1.2.2.2 bouyer * than the Package list length (for the fixed length package opcode), some
387 1.1.1.2.2.2 bouyer * BIOS code modifies the AML on the fly to adjust the NumElements, and
388 1.1.1.2.2.2 bouyer * this code compensates for that. This also provides compatibility with
389 1.1.1.2.2.2 bouyer * other AML interpreters.
390 1.1.1.2.2.2 bouyer *
391 1.1.1.2.2.2 bouyer ******************************************************************************/
392 1.1.1.2.2.2 bouyer
393 1.1.1.2.2.2 bouyer ACPI_STATUS
394 1.1.1.2.2.2 bouyer AcpiDsBuildInternalPackageObj (
395 1.1.1.2.2.2 bouyer ACPI_WALK_STATE *WalkState,
396 1.1.1.2.2.2 bouyer ACPI_PARSE_OBJECT *Op,
397 1.1.1.2.2.2 bouyer UINT32 ElementCount,
398 1.1.1.2.2.2 bouyer ACPI_OPERAND_OBJECT **ObjDescPtr)
399 1.1.1.2.2.2 bouyer {
400 1.1.1.2.2.2 bouyer ACPI_PARSE_OBJECT *Arg;
401 1.1.1.2.2.2 bouyer ACPI_PARSE_OBJECT *Parent;
402 1.1.1.2.2.2 bouyer ACPI_OPERAND_OBJECT *ObjDesc = NULL;
403 1.1.1.2.2.2 bouyer ACPI_STATUS Status = AE_OK;
404 1.1.1.2.2.2 bouyer UINT32 i;
405 1.1.1.2.2.2 bouyer UINT16 Index;
406 1.1.1.2.2.2 bouyer UINT16 ReferenceCount;
407 1.1.1.2.2.2 bouyer
408 1.1.1.2.2.2 bouyer
409 1.1.1.2.2.2 bouyer ACPI_FUNCTION_TRACE (DsBuildInternalPackageObj);
410 1.1.1.2.2.2 bouyer
411 1.1.1.2.2.2 bouyer
412 1.1.1.2.2.2 bouyer /* Find the parent of a possibly nested package */
413 1.1.1.2.2.2 bouyer
414 1.1.1.2.2.2 bouyer Parent = Op->Common.Parent;
415 1.1.1.2.2.2 bouyer while ((Parent->Common.AmlOpcode == AML_PACKAGE_OP) ||
416 1.1.1.2.2.2 bouyer (Parent->Common.AmlOpcode == AML_VAR_PACKAGE_OP))
417 1.1.1.2.2.2 bouyer {
418 1.1.1.2.2.2 bouyer Parent = Parent->Common.Parent;
419 1.1.1.2.2.2 bouyer }
420 1.1.1.2.2.2 bouyer
421 1.1.1.2.2.2 bouyer /*
422 1.1.1.2.2.2 bouyer * If we are evaluating a Named package object "Name (xxxx, Package)",
423 1.1.1.2.2.2 bouyer * the package object already exists, otherwise it must be created.
424 1.1.1.2.2.2 bouyer */
425 1.1.1.2.2.2 bouyer ObjDesc = *ObjDescPtr;
426 1.1.1.2.2.2 bouyer if (!ObjDesc)
427 1.1.1.2.2.2 bouyer {
428 1.1.1.2.2.2 bouyer ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_PACKAGE);
429 1.1.1.2.2.2 bouyer *ObjDescPtr = ObjDesc;
430 1.1.1.2.2.2 bouyer if (!ObjDesc)
431 1.1.1.2.2.2 bouyer {
432 1.1.1.2.2.2 bouyer return_ACPI_STATUS (AE_NO_MEMORY);
433 1.1.1.2.2.2 bouyer }
434 1.1.1.2.2.2 bouyer
435 1.1.1.2.2.2 bouyer ObjDesc->Package.Node = Parent->Common.Node;
436 1.1.1.2.2.2 bouyer }
437 1.1.1.2.2.2 bouyer
438 1.1.1.2.2.2 bouyer /*
439 1.1.1.2.2.2 bouyer * Allocate the element array (array of pointers to the individual
440 1.1.1.2.2.2 bouyer * objects) based on the NumElements parameter. Add an extra pointer slot
441 1.1.1.2.2.2 bouyer * so that the list is always null terminated.
442 1.1.1.2.2.2 bouyer */
443 1.1.1.2.2.2 bouyer ObjDesc->Package.Elements = ACPI_ALLOCATE_ZEROED (
444 1.1.1.2.2.2 bouyer ((ACPI_SIZE) ElementCount + 1) * sizeof (void *));
445 1.1.1.2.2.2 bouyer
446 1.1.1.2.2.2 bouyer if (!ObjDesc->Package.Elements)
447 1.1.1.2.2.2 bouyer {
448 1.1.1.2.2.2 bouyer AcpiUtDeleteObjectDesc (ObjDesc);
449 1.1.1.2.2.2 bouyer return_ACPI_STATUS (AE_NO_MEMORY);
450 1.1.1.2.2.2 bouyer }
451 1.1.1.2.2.2 bouyer
452 1.1.1.2.2.2 bouyer ObjDesc->Package.Count = ElementCount;
453 1.1.1.2.2.2 bouyer
454 1.1.1.2.2.2 bouyer /*
455 1.1.1.2.2.2 bouyer * Initialize the elements of the package, up to the NumElements count.
456 1.1.1.2.2.2 bouyer * Package is automatically padded with uninitialized (NULL) elements
457 1.1.1.2.2.2 bouyer * if NumElements is greater than the package list length. Likewise,
458 1.1.1.2.2.2 bouyer * Package is truncated if NumElements is less than the list length.
459 1.1.1.2.2.2 bouyer */
460 1.1.1.2.2.2 bouyer Arg = Op->Common.Value.Arg;
461 1.1.1.2.2.2 bouyer Arg = Arg->Common.Next;
462 1.1.1.2.2.2 bouyer for (i = 0; Arg && (i < ElementCount); i++)
463 1.1.1.2.2.2 bouyer {
464 1.1.1.2.2.2 bouyer if (Arg->Common.AmlOpcode == AML_INT_RETURN_VALUE_OP)
465 1.1.1.2.2.2 bouyer {
466 1.1.1.2.2.2 bouyer if (Arg->Common.Node->Type == ACPI_TYPE_METHOD)
467 1.1.1.2.2.2 bouyer {
468 1.1.1.2.2.2 bouyer /*
469 1.1.1.2.2.2 bouyer * A method reference "looks" to the parser to be a method
470 1.1.1.2.2.2 bouyer * invocation, so we special case it here
471 1.1.1.2.2.2 bouyer */
472 1.1.1.2.2.2 bouyer Arg->Common.AmlOpcode = AML_INT_NAMEPATH_OP;
473 1.1.1.2.2.2 bouyer Status = AcpiDsBuildInternalObject (WalkState, Arg,
474 1.1.1.2.2.2 bouyer &ObjDesc->Package.Elements[i]);
475 1.1.1.2.2.2 bouyer }
476 1.1.1.2.2.2 bouyer else
477 1.1.1.2.2.2 bouyer {
478 1.1.1.2.2.2 bouyer /* This package element is already built, just get it */
479 1.1.1.2.2.2 bouyer
480 1.1.1.2.2.2 bouyer ObjDesc->Package.Elements[i] =
481 1.1.1.2.2.2 bouyer ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, Arg->Common.Node);
482 1.1.1.2.2.2 bouyer }
483 1.1.1.2.2.2 bouyer }
484 1.1.1.2.2.2 bouyer else
485 1.1.1.2.2.2 bouyer {
486 1.1.1.2.2.2 bouyer Status = AcpiDsBuildInternalObject (WalkState, Arg,
487 1.1.1.2.2.2 bouyer &ObjDesc->Package.Elements[i]);
488 1.1.1.2.2.2 bouyer }
489 1.1.1.2.2.2 bouyer
490 1.1.1.2.2.2 bouyer if (*ObjDescPtr)
491 1.1.1.2.2.2 bouyer {
492 1.1.1.2.2.2 bouyer /* Existing package, get existing reference count */
493 1.1.1.2.2.2 bouyer
494 1.1.1.2.2.2 bouyer ReferenceCount = (*ObjDescPtr)->Common.ReferenceCount;
495 1.1.1.2.2.2 bouyer if (ReferenceCount > 1)
496 1.1.1.2.2.2 bouyer {
497 1.1.1.2.2.2 bouyer /* Make new element ref count match original ref count */
498 1.1.1.2.2.2 bouyer
499 1.1.1.2.2.2 bouyer for (Index = 0; Index < (ReferenceCount - 1); Index++)
500 1.1.1.2.2.2 bouyer {
501 1.1.1.2.2.2 bouyer AcpiUtAddReference ((ObjDesc->Package.Elements[i]));
502 1.1.1.2.2.2 bouyer }
503 1.1.1.2.2.2 bouyer }
504 1.1.1.2.2.2 bouyer }
505 1.1.1.2.2.2 bouyer
506 1.1.1.2.2.2 bouyer Arg = Arg->Common.Next;
507 1.1.1.2.2.2 bouyer }
508 1.1.1.2.2.2 bouyer
509 1.1.1.2.2.2 bouyer /* Check for match between NumElements and actual length of PackageList */
510 1.1.1.2.2.2 bouyer
511 1.1.1.2.2.2 bouyer if (Arg)
512 1.1.1.2.2.2 bouyer {
513 1.1.1.2.2.2 bouyer /*
514 1.1.1.2.2.2 bouyer * NumElements was exhausted, but there are remaining elements in the
515 1.1.1.2.2.2 bouyer * PackageList. Truncate the package to NumElements.
516 1.1.1.2.2.2 bouyer *
517 1.1.1.2.2.2 bouyer * Note: technically, this is an error, from ACPI spec: "It is an error
518 1.1.1.2.2.2 bouyer * for NumElements to be less than the number of elements in the
519 1.1.1.2.2.2 bouyer * PackageList". However, we just print a message and
520 1.1.1.2.2.2 bouyer * no exception is returned. This provides Windows compatibility. Some
521 1.1.1.2.2.2 bouyer * BIOSs will alter the NumElements on the fly, creating this type
522 1.1.1.2.2.2 bouyer * of ill-formed package object.
523 1.1.1.2.2.2 bouyer */
524 1.1.1.2.2.2 bouyer while (Arg)
525 1.1.1.2.2.2 bouyer {
526 1.1.1.2.2.2 bouyer /*
527 1.1.1.2.2.2 bouyer * We must delete any package elements that were created earlier
528 1.1.1.2.2.2 bouyer * and are not going to be used because of the package truncation.
529 1.1.1.2.2.2 bouyer */
530 1.1.1.2.2.2 bouyer if (Arg->Common.Node)
531 1.1.1.2.2.2 bouyer {
532 1.1.1.2.2.2 bouyer AcpiUtRemoveReference (
533 1.1.1.2.2.2 bouyer ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, Arg->Common.Node));
534 1.1.1.2.2.2 bouyer Arg->Common.Node = NULL;
535 1.1.1.2.2.2 bouyer }
536 1.1.1.2.2.2 bouyer
537 1.1.1.2.2.2 bouyer /* Find out how many elements there really are */
538 1.1.1.2.2.2 bouyer
539 1.1.1.2.2.2 bouyer i++;
540 1.1.1.2.2.2 bouyer Arg = Arg->Common.Next;
541 1.1.1.2.2.2 bouyer }
542 1.1.1.2.2.2 bouyer
543 1.1.1.2.2.2 bouyer ACPI_INFO ((AE_INFO,
544 1.1.1.2.2.2 bouyer "Actual Package length (%u) is larger than NumElements field (%u), truncated\n",
545 1.1.1.2.2.2 bouyer i, ElementCount));
546 1.1.1.2.2.2 bouyer }
547 1.1.1.2.2.2 bouyer else if (i < ElementCount)
548 1.1.1.2.2.2 bouyer {
549 1.1.1.2.2.2 bouyer /*
550 1.1.1.2.2.2 bouyer * Arg list (elements) was exhausted, but we did not reach NumElements count.
551 1.1.1.2.2.2 bouyer * Note: this is not an error, the package is padded out with NULLs.
552 1.1.1.2.2.2 bouyer */
553 1.1.1.2.2.2 bouyer ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
554 1.1.1.2.2.2 bouyer "Package List length (%u) smaller than NumElements count (%u), padded with null elements\n",
555 1.1.1.2.2.2 bouyer i, ElementCount));
556 1.1.1.2.2.2 bouyer }
557 1.1.1.2.2.2 bouyer
558 1.1.1.2.2.2 bouyer ObjDesc->Package.Flags |= AOPOBJ_DATA_VALID;
559 1.1.1.2.2.2 bouyer Op->Common.Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, ObjDesc);
560 1.1.1.2.2.2 bouyer return_ACPI_STATUS (Status);
561 1.1.1.2.2.2 bouyer }
562 1.1.1.2.2.2 bouyer
563 1.1.1.2.2.2 bouyer
564 1.1.1.2.2.2 bouyer /*******************************************************************************
565 1.1.1.2.2.2 bouyer *
566 1.1.1.2.2.2 bouyer * FUNCTION: AcpiDsCreateNode
567 1.1.1.2.2.2 bouyer *
568 1.1.1.2.2.2 bouyer * PARAMETERS: WalkState - Current walk state
569 1.1.1.2.2.2 bouyer * Node - NS Node to be initialized
570 1.1.1.2.2.2 bouyer * Op - Parser object to be translated
571 1.1.1.2.2.2 bouyer *
572 1.1.1.2.2.2 bouyer * RETURN: Status
573 1.1.1.2.2.2 bouyer *
574 1.1.1.2.2.2 bouyer * DESCRIPTION: Create the object to be associated with a namespace node
575 1.1.1.2.2.2 bouyer *
576 1.1.1.2.2.2 bouyer ******************************************************************************/
577 1.1.1.2.2.2 bouyer
578 1.1.1.2.2.2 bouyer ACPI_STATUS
579 1.1.1.2.2.2 bouyer AcpiDsCreateNode (
580 1.1.1.2.2.2 bouyer ACPI_WALK_STATE *WalkState,
581 1.1.1.2.2.2 bouyer ACPI_NAMESPACE_NODE *Node,
582 1.1.1.2.2.2 bouyer ACPI_PARSE_OBJECT *Op)
583 1.1.1.2.2.2 bouyer {
584 1.1.1.2.2.2 bouyer ACPI_STATUS Status;
585 1.1.1.2.2.2 bouyer ACPI_OPERAND_OBJECT *ObjDesc;
586 1.1.1.2.2.2 bouyer
587 1.1.1.2.2.2 bouyer
588 1.1.1.2.2.2 bouyer ACPI_FUNCTION_TRACE_PTR (DsCreateNode, Op);
589 1.1.1.2.2.2 bouyer
590 1.1.1.2.2.2 bouyer
591 1.1.1.2.2.2 bouyer /*
592 1.1.1.2.2.2 bouyer * Because of the execution pass through the non-control-method
593 1.1.1.2.2.2 bouyer * parts of the table, we can arrive here twice. Only init
594 1.1.1.2.2.2 bouyer * the named object node the first time through
595 1.1.1.2.2.2 bouyer */
596 1.1.1.2.2.2 bouyer if (AcpiNsGetAttachedObject (Node))
597 1.1.1.2.2.2 bouyer {
598 1.1.1.2.2.2 bouyer return_ACPI_STATUS (AE_OK);
599 1.1.1.2.2.2 bouyer }
600 1.1.1.2.2.2 bouyer
601 1.1.1.2.2.2 bouyer if (!Op->Common.Value.Arg)
602 1.1.1.2.2.2 bouyer {
603 1.1.1.2.2.2 bouyer /* No arguments, there is nothing to do */
604 1.1.1.2.2.2 bouyer
605 1.1.1.2.2.2 bouyer return_ACPI_STATUS (AE_OK);
606 1.1.1.2.2.2 bouyer }
607 1.1.1.2.2.2 bouyer
608 1.1.1.2.2.2 bouyer /* Build an internal object for the argument(s) */
609 1.1.1.2.2.2 bouyer
610 1.1.1.2.2.2 bouyer Status = AcpiDsBuildInternalObject (WalkState, Op->Common.Value.Arg,
611 1.1.1.2.2.2 bouyer &ObjDesc);
612 1.1.1.2.2.2 bouyer if (ACPI_FAILURE (Status))
613 1.1.1.2.2.2 bouyer {
614 1.1.1.2.2.2 bouyer return_ACPI_STATUS (Status);
615 1.1.1.2.2.2 bouyer }
616 1.1.1.2.2.2 bouyer
617 1.1.1.2.2.2 bouyer /* Re-type the object according to its argument */
618 1.1.1.2.2.2 bouyer
619 1.1.1.2.2.2 bouyer Node->Type = ObjDesc->Common.Type;
620 1.1.1.2.2.2 bouyer
621 1.1.1.2.2.2 bouyer /* Attach obj to node */
622 1.1.1.2.2.2 bouyer
623 1.1.1.2.2.2 bouyer Status = AcpiNsAttachObject (Node, ObjDesc, Node->Type);
624 1.1.1.2.2.2 bouyer
625 1.1.1.2.2.2 bouyer /* Remove local reference to the object */
626 1.1.1.2.2.2 bouyer
627 1.1.1.2.2.2 bouyer AcpiUtRemoveReference (ObjDesc);
628 1.1.1.2.2.2 bouyer return_ACPI_STATUS (Status);
629 1.1.1.2.2.2 bouyer }
630 1.1.1.2.2.2 bouyer
631 1.1.1.2.2.2 bouyer #endif /* ACPI_NO_METHOD_EXECUTION */
632 1.1.1.2.2.2 bouyer
633 1.1.1.2.2.2 bouyer
634 1.1.1.2.2.2 bouyer /*******************************************************************************
635 1.1.1.2.2.2 bouyer *
636 1.1.1.2.2.2 bouyer * FUNCTION: AcpiDsInitObjectFromOp
637 1.1.1.2.2.2 bouyer *
638 1.1.1.2.2.2 bouyer * PARAMETERS: WalkState - Current walk state
639 1.1.1.2.2.2 bouyer * Op - Parser op used to init the internal object
640 1.1.1.2.2.2 bouyer * Opcode - AML opcode associated with the object
641 1.1.1.2.2.2 bouyer * RetObjDesc - Namespace object to be initialized
642 1.1.1.2.2.2 bouyer *
643 1.1.1.2.2.2 bouyer * RETURN: Status
644 1.1.1.2.2.2 bouyer *
645 1.1.1.2.2.2 bouyer * DESCRIPTION: Initialize a namespace object from a parser Op and its
646 1.1.1.2.2.2 bouyer * associated arguments. The namespace object is a more compact
647 1.1.1.2.2.2 bouyer * representation of the Op and its arguments.
648 1.1.1.2.2.2 bouyer *
649 1.1.1.2.2.2 bouyer ******************************************************************************/
650 1.1.1.2.2.2 bouyer
651 1.1.1.2.2.2 bouyer ACPI_STATUS
652 1.1.1.2.2.2 bouyer AcpiDsInitObjectFromOp (
653 1.1.1.2.2.2 bouyer ACPI_WALK_STATE *WalkState,
654 1.1.1.2.2.2 bouyer ACPI_PARSE_OBJECT *Op,
655 1.1.1.2.2.2 bouyer UINT16 Opcode,
656 1.1.1.2.2.2 bouyer ACPI_OPERAND_OBJECT **RetObjDesc)
657 1.1.1.2.2.2 bouyer {
658 1.1.1.2.2.2 bouyer const ACPI_OPCODE_INFO *OpInfo;
659 1.1.1.2.2.2 bouyer ACPI_OPERAND_OBJECT *ObjDesc;
660 1.1.1.2.2.2 bouyer ACPI_STATUS Status = AE_OK;
661 1.1.1.2.2.2 bouyer
662 1.1.1.2.2.2 bouyer
663 1.1.1.2.2.2 bouyer ACPI_FUNCTION_TRACE (DsInitObjectFromOp);
664 1.1.1.2.2.2 bouyer
665 1.1.1.2.2.2 bouyer
666 1.1.1.2.2.2 bouyer ObjDesc = *RetObjDesc;
667 1.1.1.2.2.2 bouyer OpInfo = AcpiPsGetOpcodeInfo (Opcode);
668 1.1.1.2.2.2 bouyer if (OpInfo->Class == AML_CLASS_UNKNOWN)
669 1.1.1.2.2.2 bouyer {
670 1.1.1.2.2.2 bouyer /* Unknown opcode */
671 1.1.1.2.2.2 bouyer
672 1.1.1.2.2.2 bouyer return_ACPI_STATUS (AE_TYPE);
673 1.1.1.2.2.2 bouyer }
674 1.1.1.2.2.2 bouyer
675 1.1.1.2.2.2 bouyer /* Perform per-object initialization */
676 1.1.1.2.2.2 bouyer
677 1.1.1.2.2.2 bouyer switch (ObjDesc->Common.Type)
678 1.1.1.2.2.2 bouyer {
679 1.1.1.2.2.2 bouyer case ACPI_TYPE_BUFFER:
680 1.1.1.2.2.2 bouyer
681 1.1.1.2.2.2 bouyer /*
682 1.1.1.2.2.2 bouyer * Defer evaluation of Buffer TermArg operand
683 1.1.1.2.2.2 bouyer */
684 1.1.1.2.2.2 bouyer ObjDesc->Buffer.Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE,
685 1.1.1.2.2.2 bouyer WalkState->Operands[0]);
686 1.1.1.2.2.2 bouyer ObjDesc->Buffer.AmlStart = Op->Named.Data;
687 1.1.1.2.2.2 bouyer ObjDesc->Buffer.AmlLength = Op->Named.Length;
688 1.1.1.2.2.2 bouyer break;
689 1.1.1.2.2.2 bouyer
690 1.1.1.2.2.2 bouyer
691 1.1.1.2.2.2 bouyer case ACPI_TYPE_PACKAGE:
692 1.1.1.2.2.2 bouyer
693 1.1.1.2.2.2 bouyer /*
694 1.1.1.2.2.2 bouyer * Defer evaluation of Package TermArg operand
695 1.1.1.2.2.2 bouyer */
696 1.1.1.2.2.2 bouyer ObjDesc->Package.Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE,
697 1.1.1.2.2.2 bouyer WalkState->Operands[0]);
698 1.1.1.2.2.2 bouyer ObjDesc->Package.AmlStart = Op->Named.Data;
699 1.1.1.2.2.2 bouyer ObjDesc->Package.AmlLength = Op->Named.Length;
700 1.1.1.2.2.2 bouyer break;
701 1.1.1.2.2.2 bouyer
702 1.1.1.2.2.2 bouyer
703 1.1.1.2.2.2 bouyer case ACPI_TYPE_INTEGER:
704 1.1.1.2.2.2 bouyer
705 1.1.1.2.2.2 bouyer switch (OpInfo->Type)
706 1.1.1.2.2.2 bouyer {
707 1.1.1.2.2.2 bouyer case AML_TYPE_CONSTANT:
708 1.1.1.2.2.2 bouyer /*
709 1.1.1.2.2.2 bouyer * Resolve AML Constants here - AND ONLY HERE!
710 1.1.1.2.2.2 bouyer * All constants are integers.
711 1.1.1.2.2.2 bouyer * We mark the integer with a flag that indicates that it started
712 1.1.1.2.2.2 bouyer * life as a constant -- so that stores to constants will perform
713 1.1.1.2.2.2 bouyer * as expected (noop). ZeroOp is used as a placeholder for optional
714 1.1.1.2.2.2 bouyer * target operands.
715 1.1.1.2.2.2 bouyer */
716 1.1.1.2.2.2 bouyer ObjDesc->Common.Flags = AOPOBJ_AML_CONSTANT;
717 1.1.1.2.2.2 bouyer
718 1.1.1.2.2.2 bouyer switch (Opcode)
719 1.1.1.2.2.2 bouyer {
720 1.1.1.2.2.2 bouyer case AML_ZERO_OP:
721 1.1.1.2.2.2 bouyer
722 1.1.1.2.2.2 bouyer ObjDesc->Integer.Value = 0;
723 1.1.1.2.2.2 bouyer break;
724 1.1.1.2.2.2 bouyer
725 1.1.1.2.2.2 bouyer case AML_ONE_OP:
726 1.1.1.2.2.2 bouyer
727 1.1.1.2.2.2 bouyer ObjDesc->Integer.Value = 1;
728 1.1.1.2.2.2 bouyer break;
729 1.1.1.2.2.2 bouyer
730 1.1.1.2.2.2 bouyer case AML_ONES_OP:
731 1.1.1.2.2.2 bouyer
732 1.1.1.2.2.2 bouyer ObjDesc->Integer.Value = ACPI_UINT64_MAX;
733 1.1.1.2.2.2 bouyer
734 1.1.1.2.2.2 bouyer /* Truncate value if we are executing from a 32-bit ACPI table */
735 1.1.1.2.2.2 bouyer
736 1.1.1.2.2.2 bouyer #ifndef ACPI_NO_METHOD_EXECUTION
737 1.1.1.2.2.2 bouyer AcpiExTruncateFor32bitTable (ObjDesc);
738 1.1.1.2.2.2 bouyer #endif
739 1.1.1.2.2.2 bouyer break;
740 1.1.1.2.2.2 bouyer
741 1.1.1.2.2.2 bouyer case AML_REVISION_OP:
742 1.1.1.2.2.2 bouyer
743 1.1.1.2.2.2 bouyer ObjDesc->Integer.Value = ACPI_CA_VERSION;
744 1.1.1.2.2.2 bouyer break;
745 1.1.1.2.2.2 bouyer
746 1.1.1.2.2.2 bouyer default:
747 1.1.1.2.2.2 bouyer
748 1.1.1.2.2.2 bouyer ACPI_ERROR ((AE_INFO,
749 1.1.1.2.2.2 bouyer "Unknown constant opcode 0x%X", Opcode));
750 1.1.1.2.2.2 bouyer Status = AE_AML_OPERAND_TYPE;
751 1.1.1.2.2.2 bouyer break;
752 1.1.1.2.2.2 bouyer }
753 1.1.1.2.2.2 bouyer break;
754 1.1.1.2.2.2 bouyer
755 1.1.1.2.2.2 bouyer
756 1.1.1.2.2.2 bouyer case AML_TYPE_LITERAL:
757 1.1.1.2.2.2 bouyer
758 1.1.1.2.2.2 bouyer ObjDesc->Integer.Value = Op->Common.Value.Integer;
759 1.1.1.2.2.2 bouyer #ifndef ACPI_NO_METHOD_EXECUTION
760 1.1.1.2.2.2 bouyer AcpiExTruncateFor32bitTable (ObjDesc);
761 1.1.1.2.2.2 bouyer #endif
762 1.1.1.2.2.2 bouyer break;
763 1.1.1.2.2.2 bouyer
764 1.1.1.2.2.2 bouyer
765 1.1.1.2.2.2 bouyer default:
766 1.1.1.2.2.2 bouyer ACPI_ERROR ((AE_INFO, "Unknown Integer type 0x%X",
767 1.1.1.2.2.2 bouyer OpInfo->Type));
768 1.1.1.2.2.2 bouyer Status = AE_AML_OPERAND_TYPE;
769 1.1.1.2.2.2 bouyer break;
770 1.1.1.2.2.2 bouyer }
771 1.1.1.2.2.2 bouyer break;
772 1.1.1.2.2.2 bouyer
773 1.1.1.2.2.2 bouyer
774 1.1.1.2.2.2 bouyer case ACPI_TYPE_STRING:
775 1.1.1.2.2.2 bouyer
776 1.1.1.2.2.2 bouyer ObjDesc->String.Pointer = Op->Common.Value.String;
777 1.1.1.2.2.2 bouyer ObjDesc->String.Length = (UINT32) ACPI_STRLEN (Op->Common.Value.String);
778 1.1.1.2.2.2 bouyer
779 1.1.1.2.2.2 bouyer /*
780 1.1.1.2.2.2 bouyer * The string is contained in the ACPI table, don't ever try
781 1.1.1.2.2.2 bouyer * to delete it
782 1.1.1.2.2.2 bouyer */
783 1.1.1.2.2.2 bouyer ObjDesc->Common.Flags |= AOPOBJ_STATIC_POINTER;
784 1.1.1.2.2.2 bouyer break;
785 1.1.1.2.2.2 bouyer
786 1.1.1.2.2.2 bouyer
787 1.1.1.2.2.2 bouyer case ACPI_TYPE_METHOD:
788 1.1.1.2.2.2 bouyer break;
789 1.1.1.2.2.2 bouyer
790 1.1.1.2.2.2 bouyer
791 1.1.1.2.2.2 bouyer case ACPI_TYPE_LOCAL_REFERENCE:
792 1.1.1.2.2.2 bouyer
793 1.1.1.2.2.2 bouyer switch (OpInfo->Type)
794 1.1.1.2.2.2 bouyer {
795 1.1.1.2.2.2 bouyer case AML_TYPE_LOCAL_VARIABLE:
796 1.1.1.2.2.2 bouyer
797 1.1.1.2.2.2 bouyer /* Local ID (0-7) is (AML opcode - base AML_LOCAL_OP) */
798 1.1.1.2.2.2 bouyer
799 1.1.1.2.2.2 bouyer ObjDesc->Reference.Value = ((UINT32) Opcode) - AML_LOCAL_OP;
800 1.1.1.2.2.2 bouyer ObjDesc->Reference.Class = ACPI_REFCLASS_LOCAL;
801 1.1.1.2.2.2 bouyer
802 1.1.1.2.2.2 bouyer #ifndef ACPI_NO_METHOD_EXECUTION
803 1.1.1.2.2.2 bouyer Status = AcpiDsMethodDataGetNode (ACPI_REFCLASS_LOCAL,
804 1.1.1.2.2.2 bouyer ObjDesc->Reference.Value, WalkState,
805 1.1.1.2.2.2 bouyer ACPI_CAST_INDIRECT_PTR (ACPI_NAMESPACE_NODE,
806 1.1.1.2.2.2 bouyer &ObjDesc->Reference.Object));
807 1.1.1.2.2.2 bouyer #endif
808 1.1.1.2.2.2 bouyer break;
809 1.1.1.2.2.2 bouyer
810 1.1.1.2.2.2 bouyer
811 1.1.1.2.2.2 bouyer case AML_TYPE_METHOD_ARGUMENT:
812 1.1.1.2.2.2 bouyer
813 1.1.1.2.2.2 bouyer /* Arg ID (0-6) is (AML opcode - base AML_ARG_OP) */
814 1.1.1.2.2.2 bouyer
815 1.1.1.2.2.2 bouyer ObjDesc->Reference.Value = ((UINT32) Opcode) - AML_ARG_OP;
816 1.1.1.2.2.2 bouyer ObjDesc->Reference.Class = ACPI_REFCLASS_ARG;
817 1.1.1.2.2.2 bouyer
818 1.1.1.2.2.2 bouyer #ifndef ACPI_NO_METHOD_EXECUTION
819 1.1.1.2.2.2 bouyer Status = AcpiDsMethodDataGetNode (ACPI_REFCLASS_ARG,
820 1.1.1.2.2.2 bouyer ObjDesc->Reference.Value, WalkState,
821 1.1.1.2.2.2 bouyer ACPI_CAST_INDIRECT_PTR (ACPI_NAMESPACE_NODE,
822 1.1.1.2.2.2 bouyer &ObjDesc->Reference.Object));
823 1.1.1.2.2.2 bouyer #endif
824 1.1.1.2.2.2 bouyer break;
825 1.1.1.2.2.2 bouyer
826 1.1.1.2.2.2 bouyer default: /* Object name or Debug object */
827 1.1.1.2.2.2 bouyer
828 1.1.1.2.2.2 bouyer switch (Op->Common.AmlOpcode)
829 1.1.1.2.2.2 bouyer {
830 1.1.1.2.2.2 bouyer case AML_INT_NAMEPATH_OP:
831 1.1.1.2.2.2 bouyer
832 1.1.1.2.2.2 bouyer /* Node was saved in Op */
833 1.1.1.2.2.2 bouyer
834 1.1.1.2.2.2 bouyer ObjDesc->Reference.Node = Op->Common.Node;
835 1.1.1.2.2.2 bouyer ObjDesc->Reference.Object = Op->Common.Node->Object;
836 1.1.1.2.2.2 bouyer ObjDesc->Reference.Class = ACPI_REFCLASS_NAME;
837 1.1.1.2.2.2 bouyer break;
838 1.1.1.2.2.2 bouyer
839 1.1.1.2.2.2 bouyer case AML_DEBUG_OP:
840 1.1.1.2.2.2 bouyer
841 1.1.1.2.2.2 bouyer ObjDesc->Reference.Class = ACPI_REFCLASS_DEBUG;
842 1.1.1.2.2.2 bouyer break;
843 1.1.1.2.2.2 bouyer
844 1.1.1.2.2.2 bouyer default:
845 1.1.1.2.2.2 bouyer
846 1.1.1.2.2.2 bouyer ACPI_ERROR ((AE_INFO,
847 1.1.1.2.2.2 bouyer "Unimplemented reference type for AML opcode: 0x%4.4X", Opcode));
848 1.1.1.2.2.2 bouyer return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
849 1.1.1.2.2.2 bouyer }
850 1.1.1.2.2.2 bouyer break;
851 1.1.1.2.2.2 bouyer }
852 1.1.1.2.2.2 bouyer break;
853 1.1.1.2.2.2 bouyer
854 1.1.1.2.2.2 bouyer
855 1.1.1.2.2.2 bouyer default:
856 1.1.1.2.2.2 bouyer
857 1.1.1.2.2.2 bouyer ACPI_ERROR ((AE_INFO, "Unimplemented data type: 0x%X",
858 1.1.1.2.2.2 bouyer ObjDesc->Common.Type));
859 1.1.1.2.2.2 bouyer
860 1.1.1.2.2.2 bouyer Status = AE_AML_OPERAND_TYPE;
861 1.1.1.2.2.2 bouyer break;
862 1.1.1.2.2.2 bouyer }
863 1.1.1.2.2.2 bouyer
864 1.1.1.2.2.2 bouyer return_ACPI_STATUS (Status);
865 1.1.1.2.2.2 bouyer }
866 1.1.1.2.2.2 bouyer
867 1.1.1.2.2.2 bouyer
868