1 /******************************************************************************
3 * Module Name: dsargs - Support for execution of dynamic arguments for static
4 * objects (regions, fields, buffer fields, etc.)
6 *****************************************************************************/
9 * Copyright (C) 2000 - 2013, Intel Corp.
10 * All rights reserved.
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
15 * 1. Redistributions of source code must retain the above copyright
16 * notice, this list of conditions, and the following disclaimer,
17 * without modification.
18 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
19 * substantially similar to the "NO WARRANTY" disclaimer below
20 * ("Disclaimer") and any redistribution must be conditioned upon
21 * including a substantially similar Disclaimer requirement for further
22 * binary redistribution.
23 * 3. Neither the names of the above-listed copyright holders nor the names
24 * of any contributors may be used to endorse or promote products derived
25 * from this software without specific prior written permission.
27 * Alternatively, this software may be distributed under the terms of the
28 * GNU General Public License ("GPL") version 2 as published by the Free
29 * Software Foundation.
32 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
33 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
34 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
35 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
36 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
37 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
38 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
39 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
40 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
41 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
42 * POSSIBILITY OF SUCH DAMAGES.
54 #define _COMPONENT ACPI_DISPATCHER
55 ACPI_MODULE_NAME ("dsargs")
57 /* Local prototypes */
60 AcpiDsExecuteArguments (
61 ACPI_NAMESPACE_NODE
*Node
,
62 ACPI_NAMESPACE_NODE
*ScopeNode
,
67 /*******************************************************************************
69 * FUNCTION: AcpiDsExecuteArguments
71 * PARAMETERS: Node - Object NS node
72 * ScopeNode - Parent NS node
73 * AmlLength - Length of executable AML
74 * AmlStart - Pointer to the AML
78 * DESCRIPTION: Late (deferred) execution of region or field arguments
80 ******************************************************************************/
83 AcpiDsExecuteArguments (
84 ACPI_NAMESPACE_NODE
*Node
,
85 ACPI_NAMESPACE_NODE
*ScopeNode
,
90 ACPI_PARSE_OBJECT
*Op
;
91 ACPI_WALK_STATE
*WalkState
;
94 ACPI_FUNCTION_TRACE (DsExecuteArguments
);
97 /* Allocate a new parser op to be the root of the parsed tree */
99 Op
= AcpiPsAllocOp (AML_INT_EVAL_SUBTREE_OP
);
102 return_ACPI_STATUS (AE_NO_MEMORY
);
105 /* Save the Node for use in AcpiPsParseAml */
107 Op
->Common
.Node
= ScopeNode
;
109 /* Create and initialize a new parser state */
111 WalkState
= AcpiDsCreateWalkState (0, NULL
, NULL
, NULL
);
114 Status
= AE_NO_MEMORY
;
118 Status
= AcpiDsInitAmlWalk (WalkState
, Op
, NULL
, AmlStart
,
119 AmlLength
, NULL
, ACPI_IMODE_LOAD_PASS1
);
120 if (ACPI_FAILURE (Status
))
122 AcpiDsDeleteWalkState (WalkState
);
126 /* Mark this parse as a deferred opcode */
128 WalkState
->ParseFlags
= ACPI_PARSE_DEFERRED_OP
;
129 WalkState
->DeferredNode
= Node
;
131 /* Pass1: Parse the entire declaration */
133 Status
= AcpiPsParseAml (WalkState
);
134 if (ACPI_FAILURE (Status
))
139 /* Get and init the Op created above */
141 Op
->Common
.Node
= Node
;
142 AcpiPsDeleteParseTree (Op
);
144 /* Evaluate the deferred arguments */
146 Op
= AcpiPsAllocOp (AML_INT_EVAL_SUBTREE_OP
);
149 return_ACPI_STATUS (AE_NO_MEMORY
);
152 Op
->Common
.Node
= ScopeNode
;
154 /* Create and initialize a new parser state */
156 WalkState
= AcpiDsCreateWalkState (0, NULL
, NULL
, NULL
);
159 Status
= AE_NO_MEMORY
;
163 /* Execute the opcode and arguments */
165 Status
= AcpiDsInitAmlWalk (WalkState
, Op
, NULL
, AmlStart
,
166 AmlLength
, NULL
, ACPI_IMODE_EXECUTE
);
167 if (ACPI_FAILURE (Status
))
169 AcpiDsDeleteWalkState (WalkState
);
173 /* Mark this execution as a deferred opcode */
175 WalkState
->DeferredNode
= Node
;
176 Status
= AcpiPsParseAml (WalkState
);
179 AcpiPsDeleteParseTree (Op
);
180 return_ACPI_STATUS (Status
);
184 /*******************************************************************************
186 * FUNCTION: AcpiDsGetBufferFieldArguments
188 * PARAMETERS: ObjDesc - A valid BufferField object
192 * DESCRIPTION: Get BufferField Buffer and Index. This implements the late
193 * evaluation of these field attributes.
195 ******************************************************************************/
198 AcpiDsGetBufferFieldArguments (
199 ACPI_OPERAND_OBJECT
*ObjDesc
)
201 ACPI_OPERAND_OBJECT
*ExtraDesc
;
202 ACPI_NAMESPACE_NODE
*Node
;
206 ACPI_FUNCTION_TRACE_PTR (DsGetBufferFieldArguments
, ObjDesc
);
209 if (ObjDesc
->Common
.Flags
& AOPOBJ_DATA_VALID
)
211 return_ACPI_STATUS (AE_OK
);
214 /* Get the AML pointer (method object) and BufferField node */
216 ExtraDesc
= AcpiNsGetSecondaryObject (ObjDesc
);
217 Node
= ObjDesc
->BufferField
.Node
;
219 ACPI_DEBUG_EXEC (AcpiUtDisplayInitPathname (ACPI_TYPE_BUFFER_FIELD
,
222 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC
, "[%4.4s] BufferField Arg Init\n",
223 AcpiUtGetNodeName (Node
)));
225 /* Execute the AML code for the TermArg arguments */
227 Status
= AcpiDsExecuteArguments (Node
, Node
->Parent
,
228 ExtraDesc
->Extra
.AmlLength
, ExtraDesc
->Extra
.AmlStart
);
229 return_ACPI_STATUS (Status
);
233 /*******************************************************************************
235 * FUNCTION: AcpiDsGetBankFieldArguments
237 * PARAMETERS: ObjDesc - A valid BankField object
241 * DESCRIPTION: Get BankField BankValue. This implements the late
242 * evaluation of these field attributes.
244 ******************************************************************************/
247 AcpiDsGetBankFieldArguments (
248 ACPI_OPERAND_OBJECT
*ObjDesc
)
250 ACPI_OPERAND_OBJECT
*ExtraDesc
;
251 ACPI_NAMESPACE_NODE
*Node
;
255 ACPI_FUNCTION_TRACE_PTR (DsGetBankFieldArguments
, ObjDesc
);
258 if (ObjDesc
->Common
.Flags
& AOPOBJ_DATA_VALID
)
260 return_ACPI_STATUS (AE_OK
);
263 /* Get the AML pointer (method object) and BankField node */
265 ExtraDesc
= AcpiNsGetSecondaryObject (ObjDesc
);
266 Node
= ObjDesc
->BankField
.Node
;
268 ACPI_DEBUG_EXEC (AcpiUtDisplayInitPathname (ACPI_TYPE_LOCAL_BANK_FIELD
,
271 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC
, "[%4.4s] BankField Arg Init\n",
272 AcpiUtGetNodeName (Node
)));
274 /* Execute the AML code for the TermArg arguments */
276 Status
= AcpiDsExecuteArguments (Node
, Node
->Parent
,
277 ExtraDesc
->Extra
.AmlLength
, ExtraDesc
->Extra
.AmlStart
);
278 return_ACPI_STATUS (Status
);
282 /*******************************************************************************
284 * FUNCTION: AcpiDsGetBufferArguments
286 * PARAMETERS: ObjDesc - A valid Buffer object
290 * DESCRIPTION: Get Buffer length and initializer byte list. This implements
291 * the late evaluation of these attributes.
293 ******************************************************************************/
296 AcpiDsGetBufferArguments (
297 ACPI_OPERAND_OBJECT
*ObjDesc
)
299 ACPI_NAMESPACE_NODE
*Node
;
303 ACPI_FUNCTION_TRACE_PTR (DsGetBufferArguments
, ObjDesc
);
306 if (ObjDesc
->Common
.Flags
& AOPOBJ_DATA_VALID
)
308 return_ACPI_STATUS (AE_OK
);
311 /* Get the Buffer node */
313 Node
= ObjDesc
->Buffer
.Node
;
316 ACPI_ERROR ((AE_INFO
,
317 "No pointer back to namespace node in buffer object %p", ObjDesc
));
318 return_ACPI_STATUS (AE_AML_INTERNAL
);
321 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC
, "Buffer Arg Init\n"));
323 /* Execute the AML code for the TermArg arguments */
325 Status
= AcpiDsExecuteArguments (Node
, Node
,
326 ObjDesc
->Buffer
.AmlLength
, ObjDesc
->Buffer
.AmlStart
);
327 return_ACPI_STATUS (Status
);
331 /*******************************************************************************
333 * FUNCTION: AcpiDsGetPackageArguments
335 * PARAMETERS: ObjDesc - A valid Package object
339 * DESCRIPTION: Get Package length and initializer byte list. This implements
340 * the late evaluation of these attributes.
342 ******************************************************************************/
345 AcpiDsGetPackageArguments (
346 ACPI_OPERAND_OBJECT
*ObjDesc
)
348 ACPI_NAMESPACE_NODE
*Node
;
352 ACPI_FUNCTION_TRACE_PTR (DsGetPackageArguments
, ObjDesc
);
355 if (ObjDesc
->Common
.Flags
& AOPOBJ_DATA_VALID
)
357 return_ACPI_STATUS (AE_OK
);
360 /* Get the Package node */
362 Node
= ObjDesc
->Package
.Node
;
365 ACPI_ERROR ((AE_INFO
,
366 "No pointer back to namespace node in package %p", ObjDesc
));
367 return_ACPI_STATUS (AE_AML_INTERNAL
);
370 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC
, "Package Arg Init\n"));
372 /* Execute the AML code for the TermArg arguments */
374 Status
= AcpiDsExecuteArguments (Node
, Node
,
375 ObjDesc
->Package
.AmlLength
, ObjDesc
->Package
.AmlStart
);
376 return_ACPI_STATUS (Status
);
380 /*******************************************************************************
382 * FUNCTION: AcpiDsGetRegionArguments
384 * PARAMETERS: ObjDesc - A valid region object
388 * DESCRIPTION: Get region address and length. This implements the late
389 * evaluation of these region attributes.
391 ******************************************************************************/
394 AcpiDsGetRegionArguments (
395 ACPI_OPERAND_OBJECT
*ObjDesc
)
397 ACPI_NAMESPACE_NODE
*Node
;
399 ACPI_OPERAND_OBJECT
*ExtraDesc
;
402 ACPI_FUNCTION_TRACE_PTR (DsGetRegionArguments
, ObjDesc
);
405 if (ObjDesc
->Region
.Flags
& AOPOBJ_DATA_VALID
)
407 return_ACPI_STATUS (AE_OK
);
410 ExtraDesc
= AcpiNsGetSecondaryObject (ObjDesc
);
413 return_ACPI_STATUS (AE_NOT_EXIST
);
416 /* Get the Region node */
418 Node
= ObjDesc
->Region
.Node
;
420 ACPI_DEBUG_EXEC (AcpiUtDisplayInitPathname (ACPI_TYPE_REGION
, Node
, NULL
));
422 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC
, "[%4.4s] OpRegion Arg Init at AML %p\n",
423 AcpiUtGetNodeName (Node
), ExtraDesc
->Extra
.AmlStart
));
425 /* Execute the argument AML */
427 Status
= AcpiDsExecuteArguments (Node
, ExtraDesc
->Extra
.ScopeNode
,
428 ExtraDesc
->Extra
.AmlLength
, ExtraDesc
->Extra
.AmlStart
);
429 if (ACPI_FAILURE (Status
))
431 return_ACPI_STATUS (Status
);
434 Status
= AcpiUtAddAddressRange (ObjDesc
->Region
.SpaceId
,
435 ObjDesc
->Region
.Address
, ObjDesc
->Region
.Length
,
437 return_ACPI_STATUS (Status
);