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 - 2016, 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.
52 #define _COMPONENT ACPI_DISPATCHER
53 ACPI_MODULE_NAME ("dsargs")
55 /* Local prototypes */
58 AcpiDsExecuteArguments (
59 ACPI_NAMESPACE_NODE
*Node
,
60 ACPI_NAMESPACE_NODE
*ScopeNode
,
65 /*******************************************************************************
67 * FUNCTION: AcpiDsExecuteArguments
69 * PARAMETERS: Node - Object NS node
70 * ScopeNode - Parent NS node
71 * AmlLength - Length of executable AML
72 * AmlStart - Pointer to the AML
76 * DESCRIPTION: Late (deferred) execution of region or field arguments
78 ******************************************************************************/
81 AcpiDsExecuteArguments (
82 ACPI_NAMESPACE_NODE
*Node
,
83 ACPI_NAMESPACE_NODE
*ScopeNode
,
88 ACPI_PARSE_OBJECT
*Op
;
89 ACPI_WALK_STATE
*WalkState
;
92 ACPI_FUNCTION_TRACE (DsExecuteArguments
);
95 /* Allocate a new parser op to be the root of the parsed tree */
97 Op
= AcpiPsAllocOp (AML_INT_EVAL_SUBTREE_OP
, AmlStart
);
100 return_ACPI_STATUS (AE_NO_MEMORY
);
103 /* Save the Node for use in AcpiPsParseAml */
105 Op
->Common
.Node
= ScopeNode
;
107 /* Create and initialize a new parser state */
109 WalkState
= AcpiDsCreateWalkState (0, NULL
, NULL
, NULL
);
112 Status
= AE_NO_MEMORY
;
116 Status
= AcpiDsInitAmlWalk (WalkState
, Op
, NULL
, AmlStart
,
117 AmlLength
, NULL
, ACPI_IMODE_LOAD_PASS1
);
118 if (ACPI_FAILURE (Status
))
120 AcpiDsDeleteWalkState (WalkState
);
124 /* Mark this parse as a deferred opcode */
126 WalkState
->ParseFlags
= ACPI_PARSE_DEFERRED_OP
;
127 WalkState
->DeferredNode
= Node
;
129 /* Pass1: Parse the entire declaration */
131 Status
= AcpiPsParseAml (WalkState
);
132 if (ACPI_FAILURE (Status
))
137 /* Get and init the Op created above */
139 Op
->Common
.Node
= Node
;
140 AcpiPsDeleteParseTree (Op
);
142 /* Evaluate the deferred arguments */
144 Op
= AcpiPsAllocOp (AML_INT_EVAL_SUBTREE_OP
, AmlStart
);
147 return_ACPI_STATUS (AE_NO_MEMORY
);
150 Op
->Common
.Node
= ScopeNode
;
152 /* Create and initialize a new parser state */
154 WalkState
= AcpiDsCreateWalkState (0, NULL
, NULL
, NULL
);
157 Status
= AE_NO_MEMORY
;
161 /* Execute the opcode and arguments */
163 Status
= AcpiDsInitAmlWalk (WalkState
, Op
, NULL
, AmlStart
,
164 AmlLength
, NULL
, ACPI_IMODE_EXECUTE
);
165 if (ACPI_FAILURE (Status
))
167 AcpiDsDeleteWalkState (WalkState
);
171 /* Mark this execution as a deferred opcode */
173 WalkState
->DeferredNode
= Node
;
174 Status
= AcpiPsParseAml (WalkState
);
177 AcpiPsDeleteParseTree (Op
);
178 return_ACPI_STATUS (Status
);
182 /*******************************************************************************
184 * FUNCTION: AcpiDsGetBufferFieldArguments
186 * PARAMETERS: ObjDesc - A valid BufferField object
190 * DESCRIPTION: Get BufferField Buffer and Index. This implements the late
191 * evaluation of these field attributes.
193 ******************************************************************************/
196 AcpiDsGetBufferFieldArguments (
197 ACPI_OPERAND_OBJECT
*ObjDesc
)
199 ACPI_OPERAND_OBJECT
*ExtraDesc
;
200 ACPI_NAMESPACE_NODE
*Node
;
204 ACPI_FUNCTION_TRACE_PTR (DsGetBufferFieldArguments
, ObjDesc
);
207 if (ObjDesc
->Common
.Flags
& AOPOBJ_DATA_VALID
)
209 return_ACPI_STATUS (AE_OK
);
212 /* Get the AML pointer (method object) and BufferField node */
214 ExtraDesc
= AcpiNsGetSecondaryObject (ObjDesc
);
215 Node
= ObjDesc
->BufferField
.Node
;
217 ACPI_DEBUG_EXEC (AcpiUtDisplayInitPathname (
218 ACPI_TYPE_BUFFER_FIELD
, Node
, NULL
));
220 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC
, "[%4.4s] BufferField Arg Init\n",
221 AcpiUtGetNodeName (Node
)));
223 /* Execute the AML code for the TermArg arguments */
225 Status
= AcpiDsExecuteArguments (Node
, Node
->Parent
,
226 ExtraDesc
->Extra
.AmlLength
, ExtraDesc
->Extra
.AmlStart
);
227 return_ACPI_STATUS (Status
);
231 /*******************************************************************************
233 * FUNCTION: AcpiDsGetBankFieldArguments
235 * PARAMETERS: ObjDesc - A valid BankField object
239 * DESCRIPTION: Get BankField BankValue. This implements the late
240 * evaluation of these field attributes.
242 ******************************************************************************/
245 AcpiDsGetBankFieldArguments (
246 ACPI_OPERAND_OBJECT
*ObjDesc
)
248 ACPI_OPERAND_OBJECT
*ExtraDesc
;
249 ACPI_NAMESPACE_NODE
*Node
;
253 ACPI_FUNCTION_TRACE_PTR (DsGetBankFieldArguments
, ObjDesc
);
256 if (ObjDesc
->Common
.Flags
& AOPOBJ_DATA_VALID
)
258 return_ACPI_STATUS (AE_OK
);
261 /* Get the AML pointer (method object) and BankField node */
263 ExtraDesc
= AcpiNsGetSecondaryObject (ObjDesc
);
264 Node
= ObjDesc
->BankField
.Node
;
266 ACPI_DEBUG_EXEC (AcpiUtDisplayInitPathname (
267 ACPI_TYPE_LOCAL_BANK_FIELD
, Node
, NULL
));
269 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC
, "[%4.4s] BankField Arg Init\n",
270 AcpiUtGetNodeName (Node
)));
272 /* Execute the AML code for the TermArg arguments */
274 Status
= AcpiDsExecuteArguments (Node
, Node
->Parent
,
275 ExtraDesc
->Extra
.AmlLength
, ExtraDesc
->Extra
.AmlStart
);
276 return_ACPI_STATUS (Status
);
280 /*******************************************************************************
282 * FUNCTION: AcpiDsGetBufferArguments
284 * PARAMETERS: ObjDesc - A valid Buffer object
288 * DESCRIPTION: Get Buffer length and initializer byte list. This implements
289 * the late evaluation of these attributes.
291 ******************************************************************************/
294 AcpiDsGetBufferArguments (
295 ACPI_OPERAND_OBJECT
*ObjDesc
)
297 ACPI_NAMESPACE_NODE
*Node
;
301 ACPI_FUNCTION_TRACE_PTR (DsGetBufferArguments
, ObjDesc
);
304 if (ObjDesc
->Common
.Flags
& AOPOBJ_DATA_VALID
)
306 return_ACPI_STATUS (AE_OK
);
309 /* Get the Buffer node */
311 Node
= ObjDesc
->Buffer
.Node
;
314 ACPI_ERROR ((AE_INFO
,
315 "No pointer back to namespace node in buffer object %p",
317 return_ACPI_STATUS (AE_AML_INTERNAL
);
320 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC
, "Buffer Arg Init\n"));
322 /* Execute the AML code for the TermArg arguments */
324 Status
= AcpiDsExecuteArguments (Node
, Node
,
325 ObjDesc
->Buffer
.AmlLength
, ObjDesc
->Buffer
.AmlStart
);
326 return_ACPI_STATUS (Status
);
330 /*******************************************************************************
332 * FUNCTION: AcpiDsGetPackageArguments
334 * PARAMETERS: ObjDesc - A valid Package object
338 * DESCRIPTION: Get Package length and initializer byte list. This implements
339 * the late evaluation of these attributes.
341 ******************************************************************************/
344 AcpiDsGetPackageArguments (
345 ACPI_OPERAND_OBJECT
*ObjDesc
)
347 ACPI_NAMESPACE_NODE
*Node
;
351 ACPI_FUNCTION_TRACE_PTR (DsGetPackageArguments
, ObjDesc
);
354 if (ObjDesc
->Common
.Flags
& AOPOBJ_DATA_VALID
)
356 return_ACPI_STATUS (AE_OK
);
359 /* Get the Package node */
361 Node
= ObjDesc
->Package
.Node
;
364 ACPI_ERROR ((AE_INFO
,
365 "No pointer back to namespace node in package %p", ObjDesc
));
366 return_ACPI_STATUS (AE_AML_INTERNAL
);
369 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC
, "Package Arg Init\n"));
371 /* Execute the AML code for the TermArg arguments */
373 Status
= AcpiDsExecuteArguments (Node
, Node
,
374 ObjDesc
->Package
.AmlLength
, ObjDesc
->Package
.AmlStart
);
375 return_ACPI_STATUS (Status
);
379 /*******************************************************************************
381 * FUNCTION: AcpiDsGetRegionArguments
383 * PARAMETERS: ObjDesc - A valid region object
387 * DESCRIPTION: Get region address and length. This implements the late
388 * evaluation of these region attributes.
390 ******************************************************************************/
393 AcpiDsGetRegionArguments (
394 ACPI_OPERAND_OBJECT
*ObjDesc
)
396 ACPI_NAMESPACE_NODE
*Node
;
398 ACPI_OPERAND_OBJECT
*ExtraDesc
;
401 ACPI_FUNCTION_TRACE_PTR (DsGetRegionArguments
, ObjDesc
);
404 if (ObjDesc
->Region
.Flags
& AOPOBJ_DATA_VALID
)
406 return_ACPI_STATUS (AE_OK
);
409 ExtraDesc
= AcpiNsGetSecondaryObject (ObjDesc
);
412 return_ACPI_STATUS (AE_NOT_EXIST
);
415 /* Get the Region node */
417 Node
= ObjDesc
->Region
.Node
;
419 ACPI_DEBUG_EXEC (AcpiUtDisplayInitPathname (
420 ACPI_TYPE_REGION
, Node
, NULL
));
422 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC
,
423 "[%4.4s] OpRegion Arg Init at AML %p\n",
424 AcpiUtGetNodeName (Node
), ExtraDesc
->Extra
.AmlStart
));
426 /* Execute the argument AML */
428 Status
= AcpiDsExecuteArguments (Node
, ExtraDesc
->Extra
.ScopeNode
,
429 ExtraDesc
->Extra
.AmlLength
, ExtraDesc
->Extra
.AmlStart
);
430 if (ACPI_FAILURE (Status
))
432 return_ACPI_STATUS (Status
);
435 Status
= AcpiUtAddAddressRange (ObjDesc
->Region
.SpaceId
,
436 ObjDesc
->Region
.Address
, ObjDesc
->Region
.Length
, Node
);
437 return_ACPI_STATUS (Status
);