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