14 * All rights reserved. 15 * 16 * 2. License 17 * 18 * 2.1. This is your license from Intel Corp. under its intellectual property 19 * rights. You may have additional license terms from the party that provided 20 * you this software, covering your right to use that party's intellectual 21 * property rights. 22 * 23 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a 24 * copy of the source code appearing in this file ("Covered Code") an 25 * irrevocable, perpetual, worldwide license under Intel's copyrights in the 26 * base code distributed originally by Intel ("Original Intel Code") to copy, 27 * make derivatives, distribute, use and display any portion of the Covered 28 * Code in any form, with the right to sublicense such rights; and 29 * 30 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent 31 * license (with the right to sublicense), under only those claims of Intel 32 * patents that are infringed by the Original Intel Code, to make, use, sell, 33 * offer to sell, and import the Covered Code and derivative works thereof 34 * solely to the minimum extent necessary to exercise the above copyright 35 * license, and in no event shall the patent license extend to any additions 36 * to or modifications of the Original Intel Code. No other license or right 37 * is granted directly or by implication, estoppel or otherwise; 38 * 39 * The above copyright and patent license is granted only if the following 40 * conditions are met: 41 * 42 * 3. Conditions 43 * 44 * 3.1. Redistribution of Source with Rights to Further Distribute Source. 45 * Redistribution of source code of any substantial portion of the Covered 46 * Code or modification with rights to further distribute source must include 47 * the above Copyright Notice, the above License, this list of Conditions, 48 * and the following Disclaimer and Export Compliance provision. In addition, 49 * Licensee must cause all Covered Code to which Licensee contributes to 50 * contain a file documenting the changes Licensee made to create that Covered 51 * Code and the date of any change. Licensee must include in that file the 52 * documentation of any changes made by any predecessor Licensee. Licensee 53 * must include a prominent statement that the modification is derived, 54 * directly or indirectly, from Original Intel Code. 55 * 56 * 3.2. Redistribution of Source with no Rights to Further Distribute Source. 57 * Redistribution of source code of any substantial portion of the Covered 58 * Code or modification without rights to further distribute source must 59 * include the following Disclaimer and Export Compliance provision in the 60 * documentation and/or other materials provided with distribution. In 61 * addition, Licensee may not authorize further sublicense of source of any 62 * portion of the Covered Code, and must include terms to the effect that the 63 * license from Licensee to its licensee is limited to the intellectual 64 * property embodied in the software Licensee provides to its licensee, and 65 * not to intellectual property embodied in modifications its licensee may 66 * make. 67 * 68 * 3.3. Redistribution of Executable. Redistribution in executable form of any 69 * substantial portion of the Covered Code or modification must reproduce the 70 * above Copyright Notice, and the following Disclaimer and Export Compliance 71 * provision in the documentation and/or other materials provided with the 72 * distribution. 73 * 74 * 3.4. Intel retains all right, title, and interest in and to the Original 75 * Intel Code. 76 * 77 * 3.5. Neither the name Intel nor any other trademark owned or controlled by 78 * Intel shall be used in advertising or otherwise to promote the sale, use or 79 * other dealings in products derived from or relating to the Covered Code 80 * without prior written authorization from Intel. 81 * 82 * 4. Disclaimer and Export Compliance 83 * 84 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED 85 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE 86 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, 87 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY 88 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY 89 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A 90 * PARTICULAR PURPOSE. 91 * 92 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES 93 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR 94 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, 95 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY 96 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL 97 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS 98 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY 99 * LIMITED REMEDY. 100 * 101 * 4.3. Licensee shall not export, either directly or indirectly, any of this 102 * software or system incorporating such software without first obtaining any 103 * required license or other approval from the U. S. Department of Commerce or 104 * any other agency or department of the United States Government. In the 105 * event Licensee exports any such software from the United States or 106 * re-exports any such software from a foreign destination, Licensee shall 107 * ensure that the distribution and export/re-export of the software is in 108 * compliance with all laws, regulations, orders, or other restrictions of the 109 * U.S. Export Administration Regulations. Licensee agrees that neither it nor 110 * any of its subsidiaries will export/re-export any technical data, process, 111 * software, or service, directly or indirectly, to any country for which the 112 * United States government or any agency thereof requires an export license, 113 * other governmental approval, or letter of assurance, without first obtaining 114 * such license, approval or letter. 115 * 116 *****************************************************************************/ 117 118#define __DSOPCODE_C__ 119 120#include "acpi.h" 121#include "acparser.h" 122#include "amlcode.h" 123#include "acdispat.h" 124#include "acinterp.h" 125#include "acnamesp.h" 126#include "acevents.h" 127 128#define _COMPONENT ACPI_DISPATCHER 129 ACPI_MODULE_NAME ("dsopcode") 130 131 132/***************************************************************************** 133 * 134 * FUNCTION: AcpiDsExecuteArguments 135 * 136 * PARAMETERS: Node - Parent NS node 137 * AmlLength - Length of executable AML 138 * AmlStart - Pointer to the AML 139 * 140 * RETURN: Status. 141 * 142 * DESCRIPTION: Late (deferred) execution of region or field arguments 143 * 144 ****************************************************************************/ 145 146ACPI_STATUS 147AcpiDsExecuteArguments ( 148 ACPI_NAMESPACE_NODE *Node, 149 ACPI_NAMESPACE_NODE *ScopeNode, 150 UINT32 AmlLength, 151 UINT8 *AmlStart) 152{ 153 ACPI_STATUS Status; 154 ACPI_PARSE_OBJECT *Op; 155 ACPI_WALK_STATE *WalkState; 156 ACPI_PARSE_OBJECT *Arg; 157 158 159 ACPI_FUNCTION_TRACE ("DsExecuteArguments"); 160 161 162 /* 163 * Allocate a new parser op to be the root of the parsed tree 164 */ 165 Op = AcpiPsAllocOp (AML_INT_EVAL_SUBTREE_OP); 166 if (!Op) 167 { 168 return_ACPI_STATUS (AE_NO_MEMORY); 169 } 170 171 /* Save the Node for use in AcpiPsParseAml */ 172 173 Op->Common.Node = ScopeNode; 174 175 /* Create and initialize a new parser state */ 176 177 WalkState = AcpiDsCreateWalkState (0, NULL, NULL, NULL); 178 if (!WalkState) 179 { 180 return_ACPI_STATUS (AE_NO_MEMORY); 181 } 182 183 Status = AcpiDsInitAmlWalk (WalkState, Op, NULL, AmlStart, 184 AmlLength, NULL, NULL, 1); 185 if (ACPI_FAILURE (Status)) 186 { 187 AcpiDsDeleteWalkState (WalkState); 188 return_ACPI_STATUS (Status); 189 } 190 191 /* Mark this parse as a deferred opcode */ 192 193 WalkState->ParseFlags = ACPI_PARSE_DEFERRED_OP; 194 WalkState->DeferredNode = Node; 195 196 /* Pass1: Parse the entire declaration */ 197 198 Status = AcpiPsParseAml (WalkState); 199 if (ACPI_FAILURE (Status)) 200 { 201 AcpiPsDeleteParseTree (Op); 202 return_ACPI_STATUS (Status); 203 } 204 205 /* Get and init the Op created above */ 206 207 Arg = Op->Common.Value.Arg; 208 Op->Common.Node = Node; 209 Arg->Common.Node = Node; 210 AcpiPsDeleteParseTree (Op); 211 212 /* Evaluate the deferred arguments */ 213 214 Op = AcpiPsAllocOp (AML_INT_EVAL_SUBTREE_OP); 215 if (!Op) 216 { 217 return_ACPI_STATUS (AE_NO_MEMORY); 218 } 219 220 Op->Common.Node = ScopeNode; 221 222 /* Create and initialize a new parser state */ 223 224 WalkState = AcpiDsCreateWalkState (0, NULL, NULL, NULL); 225 if (!WalkState) 226 { 227 return_ACPI_STATUS (AE_NO_MEMORY); 228 } 229 230 /* Execute the opcode and arguments */ 231 232 Status = AcpiDsInitAmlWalk (WalkState, Op, NULL, AmlStart, 233 AmlLength, NULL, NULL, 3); 234 if (ACPI_FAILURE (Status)) 235 { 236 AcpiDsDeleteWalkState (WalkState); 237 return_ACPI_STATUS (Status); 238 } 239 240 /* Mark this execution as a deferred opcode */ 241 242 WalkState->DeferredNode = Node; 243 Status = AcpiPsParseAml (WalkState); 244 AcpiPsDeleteParseTree (Op); 245 return_ACPI_STATUS (Status); 246} 247 248 249/***************************************************************************** 250 * 251 * FUNCTION: AcpiDsGetBufferFieldArguments 252 * 253 * PARAMETERS: ObjDesc - A valid BufferField object 254 * 255 * RETURN: Status. 256 * 257 * DESCRIPTION: Get BufferField Buffer and Index. This implements the late 258 * evaluation of these field attributes. 259 * 260 ****************************************************************************/ 261 262ACPI_STATUS 263AcpiDsGetBufferFieldArguments ( 264 ACPI_OPERAND_OBJECT *ObjDesc) 265{ 266 ACPI_OPERAND_OBJECT *ExtraDesc; 267 ACPI_NAMESPACE_NODE *Node; 268 ACPI_STATUS Status; 269 270 271 ACPI_FUNCTION_TRACE_PTR ("DsGetBufferFieldArguments", ObjDesc); 272 273 274 if (ObjDesc->Common.Flags & AOPOBJ_DATA_VALID) 275 { 276 return_ACPI_STATUS (AE_OK); 277 } 278 279 /* Get the AML pointer (method object) and BufferField node */ 280 281 ExtraDesc = AcpiNsGetSecondaryObject (ObjDesc); 282 Node = ObjDesc->BufferField.Node; 283 284 ACPI_DEBUG_EXEC(AcpiUtDisplayInitPathname (ACPI_TYPE_BUFFER_FIELD, Node, NULL)); 285 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[%4.4s] BufferField Arg Init\n", 286 AcpiUtGetNodeName (Node))); 287 288 /* Execute the AML code for the TermArg arguments */ 289 290 Status = AcpiDsExecuteArguments (Node, AcpiNsGetParentNode (Node), 291 ExtraDesc->Extra.AmlLength, ExtraDesc->Extra.AmlStart); 292 return_ACPI_STATUS (Status); 293} 294 295 296/***************************************************************************** 297 * 298 * FUNCTION: AcpiDsGetBufferArguments 299 * 300 * PARAMETERS: ObjDesc - A valid Buffer object 301 * 302 * RETURN: Status. 303 * 304 * DESCRIPTION: Get Buffer length and initializer byte list. This implements 305 * the late evaluation of these attributes. 306 * 307 ****************************************************************************/ 308 309ACPI_STATUS 310AcpiDsGetBufferArguments ( 311 ACPI_OPERAND_OBJECT *ObjDesc) 312{ 313 ACPI_NAMESPACE_NODE *Node; 314 ACPI_STATUS Status; 315 316 317 ACPI_FUNCTION_TRACE_PTR ("DsGetBufferArguments", ObjDesc); 318 319 320 if (ObjDesc->Common.Flags & AOPOBJ_DATA_VALID) 321 { 322 return_ACPI_STATUS (AE_OK); 323 } 324 325 /* Get the Buffer node */ 326 327 Node = ObjDesc->Buffer.Node; 328 if (!Node) 329 {
| 14 * All rights reserved. 15 * 16 * 2. License 17 * 18 * 2.1. This is your license from Intel Corp. under its intellectual property 19 * rights. You may have additional license terms from the party that provided 20 * you this software, covering your right to use that party's intellectual 21 * property rights. 22 * 23 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a 24 * copy of the source code appearing in this file ("Covered Code") an 25 * irrevocable, perpetual, worldwide license under Intel's copyrights in the 26 * base code distributed originally by Intel ("Original Intel Code") to copy, 27 * make derivatives, distribute, use and display any portion of the Covered 28 * Code in any form, with the right to sublicense such rights; and 29 * 30 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent 31 * license (with the right to sublicense), under only those claims of Intel 32 * patents that are infringed by the Original Intel Code, to make, use, sell, 33 * offer to sell, and import the Covered Code and derivative works thereof 34 * solely to the minimum extent necessary to exercise the above copyright 35 * license, and in no event shall the patent license extend to any additions 36 * to or modifications of the Original Intel Code. No other license or right 37 * is granted directly or by implication, estoppel or otherwise; 38 * 39 * The above copyright and patent license is granted only if the following 40 * conditions are met: 41 * 42 * 3. Conditions 43 * 44 * 3.1. Redistribution of Source with Rights to Further Distribute Source. 45 * Redistribution of source code of any substantial portion of the Covered 46 * Code or modification with rights to further distribute source must include 47 * the above Copyright Notice, the above License, this list of Conditions, 48 * and the following Disclaimer and Export Compliance provision. In addition, 49 * Licensee must cause all Covered Code to which Licensee contributes to 50 * contain a file documenting the changes Licensee made to create that Covered 51 * Code and the date of any change. Licensee must include in that file the 52 * documentation of any changes made by any predecessor Licensee. Licensee 53 * must include a prominent statement that the modification is derived, 54 * directly or indirectly, from Original Intel Code. 55 * 56 * 3.2. Redistribution of Source with no Rights to Further Distribute Source. 57 * Redistribution of source code of any substantial portion of the Covered 58 * Code or modification without rights to further distribute source must 59 * include the following Disclaimer and Export Compliance provision in the 60 * documentation and/or other materials provided with distribution. In 61 * addition, Licensee may not authorize further sublicense of source of any 62 * portion of the Covered Code, and must include terms to the effect that the 63 * license from Licensee to its licensee is limited to the intellectual 64 * property embodied in the software Licensee provides to its licensee, and 65 * not to intellectual property embodied in modifications its licensee may 66 * make. 67 * 68 * 3.3. Redistribution of Executable. Redistribution in executable form of any 69 * substantial portion of the Covered Code or modification must reproduce the 70 * above Copyright Notice, and the following Disclaimer and Export Compliance 71 * provision in the documentation and/or other materials provided with the 72 * distribution. 73 * 74 * 3.4. Intel retains all right, title, and interest in and to the Original 75 * Intel Code. 76 * 77 * 3.5. Neither the name Intel nor any other trademark owned or controlled by 78 * Intel shall be used in advertising or otherwise to promote the sale, use or 79 * other dealings in products derived from or relating to the Covered Code 80 * without prior written authorization from Intel. 81 * 82 * 4. Disclaimer and Export Compliance 83 * 84 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED 85 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE 86 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, 87 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY 88 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY 89 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A 90 * PARTICULAR PURPOSE. 91 * 92 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES 93 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR 94 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, 95 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY 96 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL 97 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS 98 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY 99 * LIMITED REMEDY. 100 * 101 * 4.3. Licensee shall not export, either directly or indirectly, any of this 102 * software or system incorporating such software without first obtaining any 103 * required license or other approval from the U. S. Department of Commerce or 104 * any other agency or department of the United States Government. In the 105 * event Licensee exports any such software from the United States or 106 * re-exports any such software from a foreign destination, Licensee shall 107 * ensure that the distribution and export/re-export of the software is in 108 * compliance with all laws, regulations, orders, or other restrictions of the 109 * U.S. Export Administration Regulations. Licensee agrees that neither it nor 110 * any of its subsidiaries will export/re-export any technical data, process, 111 * software, or service, directly or indirectly, to any country for which the 112 * United States government or any agency thereof requires an export license, 113 * other governmental approval, or letter of assurance, without first obtaining 114 * such license, approval or letter. 115 * 116 *****************************************************************************/ 117 118#define __DSOPCODE_C__ 119 120#include "acpi.h" 121#include "acparser.h" 122#include "amlcode.h" 123#include "acdispat.h" 124#include "acinterp.h" 125#include "acnamesp.h" 126#include "acevents.h" 127 128#define _COMPONENT ACPI_DISPATCHER 129 ACPI_MODULE_NAME ("dsopcode") 130 131 132/***************************************************************************** 133 * 134 * FUNCTION: AcpiDsExecuteArguments 135 * 136 * PARAMETERS: Node - Parent NS node 137 * AmlLength - Length of executable AML 138 * AmlStart - Pointer to the AML 139 * 140 * RETURN: Status. 141 * 142 * DESCRIPTION: Late (deferred) execution of region or field arguments 143 * 144 ****************************************************************************/ 145 146ACPI_STATUS 147AcpiDsExecuteArguments ( 148 ACPI_NAMESPACE_NODE *Node, 149 ACPI_NAMESPACE_NODE *ScopeNode, 150 UINT32 AmlLength, 151 UINT8 *AmlStart) 152{ 153 ACPI_STATUS Status; 154 ACPI_PARSE_OBJECT *Op; 155 ACPI_WALK_STATE *WalkState; 156 ACPI_PARSE_OBJECT *Arg; 157 158 159 ACPI_FUNCTION_TRACE ("DsExecuteArguments"); 160 161 162 /* 163 * Allocate a new parser op to be the root of the parsed tree 164 */ 165 Op = AcpiPsAllocOp (AML_INT_EVAL_SUBTREE_OP); 166 if (!Op) 167 { 168 return_ACPI_STATUS (AE_NO_MEMORY); 169 } 170 171 /* Save the Node for use in AcpiPsParseAml */ 172 173 Op->Common.Node = ScopeNode; 174 175 /* Create and initialize a new parser state */ 176 177 WalkState = AcpiDsCreateWalkState (0, NULL, NULL, NULL); 178 if (!WalkState) 179 { 180 return_ACPI_STATUS (AE_NO_MEMORY); 181 } 182 183 Status = AcpiDsInitAmlWalk (WalkState, Op, NULL, AmlStart, 184 AmlLength, NULL, NULL, 1); 185 if (ACPI_FAILURE (Status)) 186 { 187 AcpiDsDeleteWalkState (WalkState); 188 return_ACPI_STATUS (Status); 189 } 190 191 /* Mark this parse as a deferred opcode */ 192 193 WalkState->ParseFlags = ACPI_PARSE_DEFERRED_OP; 194 WalkState->DeferredNode = Node; 195 196 /* Pass1: Parse the entire declaration */ 197 198 Status = AcpiPsParseAml (WalkState); 199 if (ACPI_FAILURE (Status)) 200 { 201 AcpiPsDeleteParseTree (Op); 202 return_ACPI_STATUS (Status); 203 } 204 205 /* Get and init the Op created above */ 206 207 Arg = Op->Common.Value.Arg; 208 Op->Common.Node = Node; 209 Arg->Common.Node = Node; 210 AcpiPsDeleteParseTree (Op); 211 212 /* Evaluate the deferred arguments */ 213 214 Op = AcpiPsAllocOp (AML_INT_EVAL_SUBTREE_OP); 215 if (!Op) 216 { 217 return_ACPI_STATUS (AE_NO_MEMORY); 218 } 219 220 Op->Common.Node = ScopeNode; 221 222 /* Create and initialize a new parser state */ 223 224 WalkState = AcpiDsCreateWalkState (0, NULL, NULL, NULL); 225 if (!WalkState) 226 { 227 return_ACPI_STATUS (AE_NO_MEMORY); 228 } 229 230 /* Execute the opcode and arguments */ 231 232 Status = AcpiDsInitAmlWalk (WalkState, Op, NULL, AmlStart, 233 AmlLength, NULL, NULL, 3); 234 if (ACPI_FAILURE (Status)) 235 { 236 AcpiDsDeleteWalkState (WalkState); 237 return_ACPI_STATUS (Status); 238 } 239 240 /* Mark this execution as a deferred opcode */ 241 242 WalkState->DeferredNode = Node; 243 Status = AcpiPsParseAml (WalkState); 244 AcpiPsDeleteParseTree (Op); 245 return_ACPI_STATUS (Status); 246} 247 248 249/***************************************************************************** 250 * 251 * FUNCTION: AcpiDsGetBufferFieldArguments 252 * 253 * PARAMETERS: ObjDesc - A valid BufferField object 254 * 255 * RETURN: Status. 256 * 257 * DESCRIPTION: Get BufferField Buffer and Index. This implements the late 258 * evaluation of these field attributes. 259 * 260 ****************************************************************************/ 261 262ACPI_STATUS 263AcpiDsGetBufferFieldArguments ( 264 ACPI_OPERAND_OBJECT *ObjDesc) 265{ 266 ACPI_OPERAND_OBJECT *ExtraDesc; 267 ACPI_NAMESPACE_NODE *Node; 268 ACPI_STATUS Status; 269 270 271 ACPI_FUNCTION_TRACE_PTR ("DsGetBufferFieldArguments", ObjDesc); 272 273 274 if (ObjDesc->Common.Flags & AOPOBJ_DATA_VALID) 275 { 276 return_ACPI_STATUS (AE_OK); 277 } 278 279 /* Get the AML pointer (method object) and BufferField node */ 280 281 ExtraDesc = AcpiNsGetSecondaryObject (ObjDesc); 282 Node = ObjDesc->BufferField.Node; 283 284 ACPI_DEBUG_EXEC(AcpiUtDisplayInitPathname (ACPI_TYPE_BUFFER_FIELD, Node, NULL)); 285 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[%4.4s] BufferField Arg Init\n", 286 AcpiUtGetNodeName (Node))); 287 288 /* Execute the AML code for the TermArg arguments */ 289 290 Status = AcpiDsExecuteArguments (Node, AcpiNsGetParentNode (Node), 291 ExtraDesc->Extra.AmlLength, ExtraDesc->Extra.AmlStart); 292 return_ACPI_STATUS (Status); 293} 294 295 296/***************************************************************************** 297 * 298 * FUNCTION: AcpiDsGetBufferArguments 299 * 300 * PARAMETERS: ObjDesc - A valid Buffer object 301 * 302 * RETURN: Status. 303 * 304 * DESCRIPTION: Get Buffer length and initializer byte list. This implements 305 * the late evaluation of these attributes. 306 * 307 ****************************************************************************/ 308 309ACPI_STATUS 310AcpiDsGetBufferArguments ( 311 ACPI_OPERAND_OBJECT *ObjDesc) 312{ 313 ACPI_NAMESPACE_NODE *Node; 314 ACPI_STATUS Status; 315 316 317 ACPI_FUNCTION_TRACE_PTR ("DsGetBufferArguments", ObjDesc); 318 319 320 if (ObjDesc->Common.Flags & AOPOBJ_DATA_VALID) 321 { 322 return_ACPI_STATUS (AE_OK); 323 } 324 325 /* Get the Buffer node */ 326 327 Node = ObjDesc->Buffer.Node; 328 if (!Node) 329 {
|
380 "No pointer back to NS node in package %p\n", ObjDesc)); 381 return_ACPI_STATUS (AE_AML_INTERNAL); 382 } 383 384 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Package Arg Init\n")); 385 386 /* Execute the AML code for the TermArg arguments */ 387 388 Status = AcpiDsExecuteArguments (Node, Node, 389 ObjDesc->Package.AmlLength, ObjDesc->Package.AmlStart); 390 return_ACPI_STATUS (Status); 391} 392 393 394/***************************************************************************** 395 * 396 * FUNCTION: AcpiDsGetRegionArguments 397 * 398 * PARAMETERS: ObjDesc - A valid region object 399 * 400 * RETURN: Status. 401 * 402 * DESCRIPTION: Get region address and length. This implements the late 403 * evaluation of these region attributes. 404 * 405 ****************************************************************************/ 406 407ACPI_STATUS 408AcpiDsGetRegionArguments ( 409 ACPI_OPERAND_OBJECT *ObjDesc) 410{ 411 ACPI_NAMESPACE_NODE *Node; 412 ACPI_STATUS Status; 413 ACPI_OPERAND_OBJECT *ExtraDesc; 414 415 416 ACPI_FUNCTION_TRACE_PTR ("DsGetRegionArguments", ObjDesc); 417 418 419 if (ObjDesc->Region.Flags & AOPOBJ_DATA_VALID) 420 { 421 return_ACPI_STATUS (AE_OK); 422 } 423 424 ExtraDesc = AcpiNsGetSecondaryObject (ObjDesc); 425 if (!ExtraDesc) 426 { 427 return_ACPI_STATUS (AE_NOT_EXIST); 428 } 429 430 /* Get the Region node */ 431 432 Node = ObjDesc->Region.Node; 433 434 ACPI_DEBUG_EXEC (AcpiUtDisplayInitPathname (ACPI_TYPE_REGION, Node, NULL)); 435 436 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[%4.4s] OpRegion Arg Init at AML %p\n", 437 AcpiUtGetNodeName (Node), ExtraDesc->Extra.AmlStart)); 438 439 /* Execute the argument AML */ 440 441 Status = AcpiDsExecuteArguments (Node, AcpiNsGetParentNode (Node), 442 ExtraDesc->Extra.AmlLength, ExtraDesc->Extra.AmlStart); 443 return_ACPI_STATUS (Status); 444} 445 446 447/***************************************************************************** 448 * 449 * FUNCTION: AcpiDsInitializeRegion 450 * 451 * PARAMETERS: Op - A valid region Op object 452 * 453 * RETURN: Status 454 * 455 * DESCRIPTION: Front end to EvInitializeRegion 456 * 457 ****************************************************************************/ 458 459ACPI_STATUS 460AcpiDsInitializeRegion ( 461 ACPI_HANDLE ObjHandle) 462{ 463 ACPI_OPERAND_OBJECT *ObjDesc; 464 ACPI_STATUS Status; 465 466 467 ObjDesc = AcpiNsGetAttachedObject (ObjHandle); 468 469 /* Namespace is NOT locked */ 470 471 Status = AcpiEvInitializeRegion (ObjDesc, FALSE); 472 return (Status); 473} 474 475 476/***************************************************************************** 477 * 478 * FUNCTION: AcpiDsInitBufferField 479 * 480 * PARAMETERS: AmlOpcode - CreateXxxField 481 * ObjDesc - BufferField object 482 * BufferDesc - Host Buffer 483 * OffsetDesc - Offset into buffer 484 * Length - Length of field (CREATE_FIELD_OP only) 485 * Result - Where to store the result 486 * 487 * RETURN: Status 488 * 489 * DESCRIPTION: Perform actual initialization of a buffer field 490 * 491 ****************************************************************************/ 492 493ACPI_STATUS 494AcpiDsInitBufferField ( 495 UINT16 AmlOpcode, 496 ACPI_OPERAND_OBJECT *ObjDesc, 497 ACPI_OPERAND_OBJECT *BufferDesc, 498 ACPI_OPERAND_OBJECT *OffsetDesc, 499 ACPI_OPERAND_OBJECT *LengthDesc, 500 ACPI_OPERAND_OBJECT *ResultDesc) 501{ 502 UINT32 Offset; 503 UINT32 BitOffset; 504 UINT32 BitCount; 505 UINT8 FieldFlags; 506 ACPI_STATUS Status; 507 508 509 ACPI_FUNCTION_TRACE_PTR ("DsInitBufferField", ObjDesc); 510 511 512 /* Host object must be a Buffer */ 513 514 if (ACPI_GET_OBJECT_TYPE (BufferDesc) != ACPI_TYPE_BUFFER) 515 { 516 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 517 "Target of Create Field is not a Buffer object - %s\n", 518 AcpiUtGetObjectTypeName (BufferDesc))); 519 520 Status = AE_AML_OPERAND_TYPE; 521 goto Cleanup; 522 } 523 524 /* 525 * The last parameter to all of these opcodes (ResultDesc) started 526 * out as a NameString, and should therefore now be a NS node 527 * after resolution in AcpiExResolveOperands(). 528 */ 529 if (ACPI_GET_DESCRIPTOR_TYPE (ResultDesc) != ACPI_DESC_TYPE_NAMED) 530 { 531 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "(%s) destination not a NS Node [%s]\n", 532 AcpiPsGetOpcodeName (AmlOpcode), AcpiUtGetDescriptorName (ResultDesc))); 533 534 Status = AE_AML_OPERAND_TYPE; 535 goto Cleanup; 536 } 537 538 Offset = (UINT32) OffsetDesc->Integer.Value; 539 540 /* 541 * Setup the Bit offsets and counts, according to the opcode 542 */ 543 switch (AmlOpcode) 544 { 545 case AML_CREATE_FIELD_OP: 546 547 /* Offset is in bits, count is in bits */ 548 549 BitOffset = Offset; 550 BitCount = (UINT32) LengthDesc->Integer.Value; 551 FieldFlags = AML_FIELD_ACCESS_BYTE; 552 break; 553 554 case AML_CREATE_BIT_FIELD_OP: 555 556 /* Offset is in bits, Field is one bit */ 557 558 BitOffset = Offset; 559 BitCount = 1; 560 FieldFlags = AML_FIELD_ACCESS_BYTE; 561 break; 562 563 case AML_CREATE_BYTE_FIELD_OP: 564 565 /* Offset is in bytes, field is one byte */ 566 567 BitOffset = 8 * Offset; 568 BitCount = 8; 569 FieldFlags = AML_FIELD_ACCESS_BYTE; 570 break; 571 572 case AML_CREATE_WORD_FIELD_OP: 573 574 /* Offset is in bytes, field is one word */ 575 576 BitOffset = 8 * Offset; 577 BitCount = 16; 578 FieldFlags = AML_FIELD_ACCESS_WORD; 579 break; 580 581 case AML_CREATE_DWORD_FIELD_OP: 582 583 /* Offset is in bytes, field is one dword */ 584 585 BitOffset = 8 * Offset; 586 BitCount = 32; 587 FieldFlags = AML_FIELD_ACCESS_DWORD; 588 break; 589 590 case AML_CREATE_QWORD_FIELD_OP: 591 592 /* Offset is in bytes, field is one qword */ 593 594 BitOffset = 8 * Offset; 595 BitCount = 64; 596 FieldFlags = AML_FIELD_ACCESS_QWORD; 597 break; 598 599 default: 600 601 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 602 "Unknown field creation opcode %02x\n", 603 AmlOpcode)); 604 Status = AE_AML_BAD_OPCODE; 605 goto Cleanup; 606 } 607 608 /* Entire field must fit within the current length of the buffer */ 609 610 if ((BitOffset + BitCount) > 611 (8 * (UINT32) BufferDesc->Buffer.Length)) 612 { 613 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 614 "Field [%4.4s] size %d exceeds Buffer [%4.4s] size %d (bits)\n", 615 AcpiUtGetNodeName (ResultDesc), 616 BitOffset + BitCount, 617 AcpiUtGetNodeName (BufferDesc->Buffer.Node), 618 8 * (UINT32) BufferDesc->Buffer.Length)); 619 Status = AE_AML_BUFFER_LIMIT; 620 goto Cleanup; 621 } 622 623 /* 624 * Initialize areas of the field object that are common to all fields 625 * For FieldFlags, use LOCK_RULE = 0 (NO_LOCK), UPDATE_RULE = 0 (UPDATE_PRESERVE) 626 */ 627 Status = AcpiExPrepCommonFieldObject (ObjDesc, FieldFlags, 0, 628 BitOffset, BitCount); 629 if (ACPI_FAILURE (Status)) 630 { 631 goto Cleanup; 632 } 633 634 ObjDesc->BufferField.BufferObj = BufferDesc; 635 636 /* Reference count for BufferDesc inherits ObjDesc count */ 637 638 BufferDesc->Common.ReferenceCount = (UINT16) (BufferDesc->Common.ReferenceCount + 639 ObjDesc->Common.ReferenceCount); 640 641 642Cleanup: 643 644 /* Always delete the operands */ 645 646 AcpiUtRemoveReference (OffsetDesc); 647 AcpiUtRemoveReference (BufferDesc); 648 649 if (AmlOpcode == AML_CREATE_FIELD_OP) 650 { 651 AcpiUtRemoveReference (LengthDesc); 652 } 653 654 /* On failure, delete the result descriptor */ 655 656 if (ACPI_FAILURE (Status)) 657 { 658 AcpiUtRemoveReference (ResultDesc); /* Result descriptor */ 659 } 660 else 661 { 662 /* Now the address and length are valid for this BufferField */ 663 664 ObjDesc->BufferField.Flags |= AOPOBJ_DATA_VALID; 665 } 666 667 return_ACPI_STATUS (Status); 668} 669 670 671/***************************************************************************** 672 * 673 * FUNCTION: AcpiDsEvalBufferFieldOperands 674 * 675 * PARAMETERS: WalkState - Current walk 676 * Op - A valid BufferField Op object 677 * 678 * RETURN: Status 679 * 680 * DESCRIPTION: Get BufferField Buffer and Index 681 * Called from AcpiDsExecEndOp during BufferField parse tree walk 682 * 683 ****************************************************************************/ 684 685ACPI_STATUS 686AcpiDsEvalBufferFieldOperands ( 687 ACPI_WALK_STATE *WalkState, 688 ACPI_PARSE_OBJECT *Op) 689{ 690 ACPI_STATUS Status; 691 ACPI_OPERAND_OBJECT *ObjDesc; 692 ACPI_NAMESPACE_NODE *Node; 693 ACPI_PARSE_OBJECT *NextOp; 694 695 696 ACPI_FUNCTION_TRACE_PTR ("DsEvalBufferFieldOperands", Op); 697 698 699 /* 700 * This is where we evaluate the address and length fields of the 701 * CreateXxxField declaration 702 */ 703 Node = Op->Common.Node; 704 705 /* NextOp points to the op that holds the Buffer */ 706 707 NextOp = Op->Common.Value.Arg; 708 709 /* Evaluate/create the address and length operands */ 710 711 Status = AcpiDsCreateOperands (WalkState, NextOp); 712 if (ACPI_FAILURE (Status)) 713 { 714 return_ACPI_STATUS (Status); 715 } 716 717 ObjDesc = AcpiNsGetAttachedObject (Node); 718 if (!ObjDesc) 719 { 720 return_ACPI_STATUS (AE_NOT_EXIST); 721 } 722 723 /* Resolve the operands */ 724 725 Status = AcpiExResolveOperands (Op->Common.AmlOpcode, 726 ACPI_WALK_OPERANDS, WalkState); 727 728 ACPI_DUMP_OPERANDS (ACPI_WALK_OPERANDS, ACPI_IMODE_EXECUTE, 729 AcpiPsGetOpcodeName (Op->Common.AmlOpcode), 730 WalkState->NumOperands, "after AcpiExResolveOperands"); 731 732 if (ACPI_FAILURE (Status)) 733 { 734 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "(%s) bad operand(s) (%X)\n", 735 AcpiPsGetOpcodeName (Op->Common.AmlOpcode), Status)); 736 737 return_ACPI_STATUS (Status); 738 } 739 740 /* Initialize the Buffer Field */ 741 742 if (Op->Common.AmlOpcode == AML_CREATE_FIELD_OP) 743 { 744 /* NOTE: Slightly different operands for this opcode */ 745 746 Status = AcpiDsInitBufferField (Op->Common.AmlOpcode, ObjDesc, 747 WalkState->Operands[0], WalkState->Operands[1], 748 WalkState->Operands[2], WalkState->Operands[3]); 749 } 750 else 751 { 752 /* All other, CreateXxxField opcodes */ 753 754 Status = AcpiDsInitBufferField (Op->Common.AmlOpcode, ObjDesc, 755 WalkState->Operands[0], WalkState->Operands[1], 756 NULL, WalkState->Operands[2]); 757 } 758 759 return_ACPI_STATUS (Status); 760} 761 762 763/***************************************************************************** 764 * 765 * FUNCTION: AcpiDsEvalRegionOperands 766 * 767 * PARAMETERS: WalkState - Current walk 768 * Op - A valid region Op object 769 * 770 * RETURN: Status 771 * 772 * DESCRIPTION: Get region address and length 773 * Called from AcpiDsExecEndOp during OpRegion parse tree walk 774 * 775 ****************************************************************************/ 776 777ACPI_STATUS 778AcpiDsEvalRegionOperands ( 779 ACPI_WALK_STATE *WalkState, 780 ACPI_PARSE_OBJECT *Op) 781{ 782 ACPI_STATUS Status; 783 ACPI_OPERAND_OBJECT *ObjDesc; 784 ACPI_OPERAND_OBJECT *OperandDesc; 785 ACPI_NAMESPACE_NODE *Node; 786 ACPI_PARSE_OBJECT *NextOp; 787 788 789 ACPI_FUNCTION_TRACE_PTR ("DsEvalRegionOperands", Op); 790 791 792 /* 793 * This is where we evaluate the address and length fields of the OpRegion declaration 794 */ 795 Node = Op->Common.Node; 796 797 /* NextOp points to the op that holds the SpaceID */ 798 799 NextOp = Op->Common.Value.Arg; 800 801 /* NextOp points to address op */ 802 803 NextOp = NextOp->Common.Next; 804 805 /* Evaluate/create the address and length operands */ 806 807 Status = AcpiDsCreateOperands (WalkState, NextOp); 808 if (ACPI_FAILURE (Status)) 809 { 810 return_ACPI_STATUS (Status); 811 } 812 813 /* Resolve the length and address operands to numbers */ 814 815 Status = AcpiExResolveOperands (Op->Common.AmlOpcode, ACPI_WALK_OPERANDS, WalkState); 816 if (ACPI_FAILURE (Status)) 817 { 818 return_ACPI_STATUS (Status); 819 } 820 821 ACPI_DUMP_OPERANDS (ACPI_WALK_OPERANDS, ACPI_IMODE_EXECUTE, 822 AcpiPsGetOpcodeName (Op->Common.AmlOpcode), 823 1, "after AcpiExResolveOperands"); 824 825 ObjDesc = AcpiNsGetAttachedObject (Node); 826 if (!ObjDesc) 827 { 828 return_ACPI_STATUS (AE_NOT_EXIST); 829 } 830 831 /* 832 * Get the length operand and save it 833 * (at Top of stack) 834 */ 835 OperandDesc = WalkState->Operands[WalkState->NumOperands - 1]; 836 837 ObjDesc->Region.Length = (UINT32) OperandDesc->Integer.Value; 838 AcpiUtRemoveReference (OperandDesc); 839 840 /* 841 * Get the address and save it 842 * (at top of stack - 1) 843 */ 844 OperandDesc = WalkState->Operands[WalkState->NumOperands - 2]; 845 846 ObjDesc->Region.Address = (ACPI_PHYSICAL_ADDRESS) OperandDesc->Integer.Value; 847 AcpiUtRemoveReference (OperandDesc); 848 849 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "RgnObj %p Addr %8.8X%8.8X Len %X\n", 850 ObjDesc, 851 ACPI_FORMAT_UINT64 (ObjDesc->Region.Address), 852 ObjDesc->Region.Length)); 853 854 /* Now the address and length are valid for this opregion */ 855 856 ObjDesc->Region.Flags |= AOPOBJ_DATA_VALID; 857 858 return_ACPI_STATUS (Status); 859} 860 861 862/***************************************************************************** 863 * 864 * FUNCTION: AcpiDsEvalDataObjectOperands 865 * 866 * PARAMETERS: WalkState - Current walk 867 * Op - A valid DataObject Op object 868 * ObjDesc - DataObject 869 * 870 * RETURN: Status 871 * 872 * DESCRIPTION: Get the operands and complete the following data objec types: 873 * Buffer 874 * Package 875 * 876 ****************************************************************************/ 877 878ACPI_STATUS 879AcpiDsEvalDataObjectOperands ( 880 ACPI_WALK_STATE *WalkState, 881 ACPI_PARSE_OBJECT *Op, 882 ACPI_OPERAND_OBJECT *ObjDesc) 883{ 884 ACPI_STATUS Status; 885 ACPI_OPERAND_OBJECT *ArgDesc; 886 UINT32 Length; 887 888 889 ACPI_FUNCTION_TRACE ("DsEvalDataObjectOperands"); 890 891 892 /* The first operand (for all of these data objects) is the length */ 893 894 Status = AcpiDsCreateOperand (WalkState, Op->Common.Value.Arg, 1); 895 if (ACPI_FAILURE (Status)) 896 { 897 return_ACPI_STATUS (Status); 898 } 899 900 Status = AcpiExResolveOperands (WalkState->Opcode, 901 &(WalkState->Operands [WalkState->NumOperands -1]), 902 WalkState); 903 if (ACPI_FAILURE (Status)) 904 { 905 return_ACPI_STATUS (Status); 906 } 907 908 /* Extract length operand */ 909 910 ArgDesc = WalkState->Operands [WalkState->NumOperands - 1]; 911 Length = (UINT32) ArgDesc->Integer.Value; 912 913 /* Cleanup for length operand */ 914 915 Status = AcpiDsObjStackPop (1, WalkState); 916 if (ACPI_FAILURE (Status)) 917 { 918 return_ACPI_STATUS (Status); 919 } 920 921 AcpiUtRemoveReference (ArgDesc); 922 923 /* 924 * Create the actual data object 925 */ 926 switch (Op->Common.AmlOpcode) 927 { 928 case AML_BUFFER_OP: 929 930 Status = AcpiDsBuildInternalBufferObj (WalkState, Op, Length, &ObjDesc); 931 break; 932 933 case AML_PACKAGE_OP: 934 case AML_VAR_PACKAGE_OP: 935 936 Status = AcpiDsBuildInternalPackageObj (WalkState, Op, Length, &ObjDesc); 937 break; 938 939 default: 940 return_ACPI_STATUS (AE_AML_BAD_OPCODE); 941 } 942 943 if (ACPI_SUCCESS (Status)) 944 { 945 /* 946 * Return the object in the WalkState, unless the parent is a package -- 947 * in this case, the return object will be stored in the parse tree 948 * for the package. 949 */ 950 if ((!Op->Common.Parent) || 951 ((Op->Common.Parent->Common.AmlOpcode != AML_PACKAGE_OP) && 952 (Op->Common.Parent->Common.AmlOpcode != AML_VAR_PACKAGE_OP) && 953 (Op->Common.Parent->Common.AmlOpcode != AML_NAME_OP))) 954 { 955 WalkState->ResultObj = ObjDesc; 956 } 957 } 958 959 return_ACPI_STATUS (Status); 960} 961 962 963/******************************************************************************* 964 * 965 * FUNCTION: AcpiDsExecBeginControlOp 966 * 967 * PARAMETERS: WalkList - The list that owns the walk stack 968 * Op - The control Op 969 * 970 * RETURN: Status 971 * 972 * DESCRIPTION: Handles all control ops encountered during control method 973 * execution. 974 * 975 ******************************************************************************/ 976 977ACPI_STATUS 978AcpiDsExecBeginControlOp ( 979 ACPI_WALK_STATE *WalkState, 980 ACPI_PARSE_OBJECT *Op) 981{ 982 ACPI_STATUS Status = AE_OK; 983 ACPI_GENERIC_STATE *ControlState; 984 985 986 ACPI_FUNCTION_NAME ("DsExecBeginControlOp"); 987 988 989 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Op=%p Opcode=%2.2X State=%p\n", Op, 990 Op->Common.AmlOpcode, WalkState)); 991 992 switch (Op->Common.AmlOpcode) 993 { 994 case AML_IF_OP: 995 case AML_WHILE_OP: 996 997 /* 998 * IF/WHILE: Create a new control state to manage these 999 * constructs. We need to manage these as a stack, in order 1000 * to handle nesting. 1001 */ 1002 ControlState = AcpiUtCreateControlState (); 1003 if (!ControlState) 1004 { 1005 Status = AE_NO_MEMORY; 1006 break; 1007 } 1008 /* 1009 * Save a pointer to the predicate for multiple executions 1010 * of a loop 1011 */ 1012 ControlState->Control.AmlPredicateStart = WalkState->ParserState.Aml - 1; 1013 ControlState->Control.PackageEnd = WalkState->ParserState.PkgEnd; 1014 ControlState->Control.Opcode = Op->Common.AmlOpcode; 1015 1016 1017 /* Push the control state on this walk's control stack */ 1018 1019 AcpiUtPushGenericState (&WalkState->ControlState, ControlState); 1020 break; 1021 1022 case AML_ELSE_OP: 1023 1024 /* Predicate is in the state object */ 1025 /* If predicate is true, the IF was executed, ignore ELSE part */ 1026 1027 if (WalkState->LastPredicate) 1028 { 1029 Status = AE_CTRL_TRUE; 1030 } 1031 1032 break; 1033 1034 case AML_RETURN_OP: 1035 1036 break; 1037 1038 default: 1039 break; 1040 } 1041 1042 return (Status); 1043} 1044 1045 1046/******************************************************************************* 1047 * 1048 * FUNCTION: AcpiDsExecEndControlOp 1049 * 1050 * PARAMETERS: WalkList - The list that owns the walk stack 1051 * Op - The control Op 1052 * 1053 * RETURN: Status 1054 * 1055 * DESCRIPTION: Handles all control ops encountered during control method 1056 * execution. 1057 * 1058 ******************************************************************************/ 1059 1060ACPI_STATUS 1061AcpiDsExecEndControlOp ( 1062 ACPI_WALK_STATE *WalkState, 1063 ACPI_PARSE_OBJECT *Op) 1064{ 1065 ACPI_STATUS Status = AE_OK; 1066 ACPI_GENERIC_STATE *ControlState; 1067 1068 1069 ACPI_FUNCTION_NAME ("DsExecEndControlOp"); 1070 1071 1072 switch (Op->Common.AmlOpcode) 1073 { 1074 case AML_IF_OP: 1075 1076 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "[IF_OP] Op=%p\n", Op)); 1077 1078 /* 1079 * Save the result of the predicate in case there is an 1080 * ELSE to come 1081 */ 1082 WalkState->LastPredicate = 1083 (BOOLEAN) WalkState->ControlState->Common.Value; 1084 1085 /* 1086 * Pop the control state that was created at the start 1087 * of the IF and free it 1088 */ 1089 ControlState = AcpiUtPopGenericState (&WalkState->ControlState); 1090 AcpiUtDeleteGenericState (ControlState); 1091 break; 1092 1093 1094 case AML_ELSE_OP: 1095 1096 break; 1097 1098 1099 case AML_WHILE_OP: 1100 1101 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "[WHILE_OP] Op=%p\n", Op)); 1102 1103 if (WalkState->ControlState->Common.Value) 1104 { 1105 /* Predicate was true, go back and evaluate it again! */ 1106 1107 Status = AE_CTRL_PENDING; 1108 } 1109 1110 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "[WHILE_OP] termination! Op=%p\n", Op)); 1111 1112 /* Pop this control state and free it */ 1113 1114 ControlState = AcpiUtPopGenericState (&WalkState->ControlState); 1115 1116 WalkState->AmlLastWhile = ControlState->Control.AmlPredicateStart; 1117 AcpiUtDeleteGenericState (ControlState); 1118 break; 1119 1120 1121 case AML_RETURN_OP: 1122 1123 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, 1124 "[RETURN_OP] Op=%p Arg=%p\n",Op, Op->Common.Value.Arg)); 1125 1126 /* 1127 * One optional operand -- the return value 1128 * It can be either an immediate operand or a result that 1129 * has been bubbled up the tree 1130 */ 1131 if (Op->Common.Value.Arg) 1132 { 1133 /* Return statement has an immediate operand */ 1134 1135 Status = AcpiDsCreateOperands (WalkState, Op->Common.Value.Arg); 1136 if (ACPI_FAILURE (Status)) 1137 { 1138 return (Status); 1139 } 1140 1141 /* 1142 * If value being returned is a Reference (such as 1143 * an arg or local), resolve it now because it may 1144 * cease to exist at the end of the method. 1145 */ 1146 Status = AcpiExResolveToValue (&WalkState->Operands [0], WalkState); 1147 if (ACPI_FAILURE (Status)) 1148 { 1149 return (Status); 1150 } 1151 1152 /* 1153 * Get the return value and save as the last result 1154 * value. This is the only place where WalkState->ReturnDesc 1155 * is set to anything other than zero! 1156 */ 1157 WalkState->ReturnDesc = WalkState->Operands[0]; 1158 } 1159 else if ((WalkState->Results) && 1160 (WalkState->Results->Results.NumResults > 0)) 1161 { 1162 /* 1163 * The return value has come from a previous calculation. 1164 * 1165 * If value being returned is a Reference (such as 1166 * an arg or local), resolve it now because it may 1167 * cease to exist at the end of the method. 1168 * 1169 * Allow references created by the Index operator to return unchanged. 1170 */ 1171 if ((ACPI_GET_DESCRIPTOR_TYPE (WalkState->Results->Results.ObjDesc[0]) == ACPI_DESC_TYPE_OPERAND) && 1172 (ACPI_GET_OBJECT_TYPE (WalkState->Results->Results.ObjDesc [0]) == ACPI_TYPE_LOCAL_REFERENCE) && 1173 ((WalkState->Results->Results.ObjDesc [0])->Reference.Opcode != AML_INDEX_OP)) 1174 { 1175 Status = AcpiExResolveToValue (&WalkState->Results->Results.ObjDesc [0], WalkState); 1176 if (ACPI_FAILURE (Status)) 1177 { 1178 return (Status); 1179 } 1180 } 1181 1182 WalkState->ReturnDesc = WalkState->Results->Results.ObjDesc [0]; 1183 } 1184 else 1185 { 1186 /* No return operand */ 1187 1188 if (WalkState->NumOperands) 1189 { 1190 AcpiUtRemoveReference (WalkState->Operands [0]); 1191 } 1192 1193 WalkState->Operands [0] = NULL; 1194 WalkState->NumOperands = 0; 1195 WalkState->ReturnDesc = NULL; 1196 } 1197 1198 1199 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, 1200 "Completed RETURN_OP State=%p, RetVal=%p\n", 1201 WalkState, WalkState->ReturnDesc)); 1202 1203 /* End the control method execution right now */ 1204 1205 Status = AE_CTRL_TERMINATE; 1206 break; 1207 1208 1209 case AML_NOOP_OP: 1210 1211 /* Just do nothing! */ 1212 break; 1213 1214 1215 case AML_BREAK_POINT_OP: 1216 1217 /* Call up to the OS service layer to handle this */ 1218 1219 Status = AcpiOsSignal (ACPI_SIGNAL_BREAKPOINT, "Executed AML Breakpoint opcode"); 1220 1221 /* If and when it returns, all done. */ 1222 1223 break; 1224 1225 1226 case AML_BREAK_OP: 1227 case AML_CONTINUE_OP: /* ACPI 2.0 */ 1228 1229 1230 /* Pop and delete control states until we find a while */ 1231 1232 while (WalkState->ControlState && 1233 (WalkState->ControlState->Control.Opcode != AML_WHILE_OP)) 1234 { 1235 ControlState = AcpiUtPopGenericState (&WalkState->ControlState); 1236 AcpiUtDeleteGenericState (ControlState); 1237 } 1238 1239 /* No while found? */ 1240 1241 if (!WalkState->ControlState) 1242 { 1243 return (AE_AML_NO_WHILE); 1244 } 1245 1246 /* Was: WalkState->AmlLastWhile = WalkState->ControlState->Control.AmlPredicateStart; */ 1247 1248 WalkState->AmlLastWhile = WalkState->ControlState->Control.PackageEnd; 1249 1250 /* Return status depending on opcode */ 1251 1252 if (Op->Common.AmlOpcode == AML_BREAK_OP) 1253 { 1254 Status = AE_CTRL_BREAK; 1255 } 1256 else 1257 { 1258 Status = AE_CTRL_CONTINUE; 1259 } 1260 break; 1261 1262 1263 default: 1264 1265 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown control opcode=%X Op=%p\n", 1266 Op->Common.AmlOpcode, Op)); 1267 1268 Status = AE_AML_BAD_OPCODE; 1269 break; 1270 } 1271 1272 return (Status); 1273} 1274
| 380 "No pointer back to NS node in package %p\n", ObjDesc)); 381 return_ACPI_STATUS (AE_AML_INTERNAL); 382 } 383 384 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Package Arg Init\n")); 385 386 /* Execute the AML code for the TermArg arguments */ 387 388 Status = AcpiDsExecuteArguments (Node, Node, 389 ObjDesc->Package.AmlLength, ObjDesc->Package.AmlStart); 390 return_ACPI_STATUS (Status); 391} 392 393 394/***************************************************************************** 395 * 396 * FUNCTION: AcpiDsGetRegionArguments 397 * 398 * PARAMETERS: ObjDesc - A valid region object 399 * 400 * RETURN: Status. 401 * 402 * DESCRIPTION: Get region address and length. This implements the late 403 * evaluation of these region attributes. 404 * 405 ****************************************************************************/ 406 407ACPI_STATUS 408AcpiDsGetRegionArguments ( 409 ACPI_OPERAND_OBJECT *ObjDesc) 410{ 411 ACPI_NAMESPACE_NODE *Node; 412 ACPI_STATUS Status; 413 ACPI_OPERAND_OBJECT *ExtraDesc; 414 415 416 ACPI_FUNCTION_TRACE_PTR ("DsGetRegionArguments", ObjDesc); 417 418 419 if (ObjDesc->Region.Flags & AOPOBJ_DATA_VALID) 420 { 421 return_ACPI_STATUS (AE_OK); 422 } 423 424 ExtraDesc = AcpiNsGetSecondaryObject (ObjDesc); 425 if (!ExtraDesc) 426 { 427 return_ACPI_STATUS (AE_NOT_EXIST); 428 } 429 430 /* Get the Region node */ 431 432 Node = ObjDesc->Region.Node; 433 434 ACPI_DEBUG_EXEC (AcpiUtDisplayInitPathname (ACPI_TYPE_REGION, Node, NULL)); 435 436 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[%4.4s] OpRegion Arg Init at AML %p\n", 437 AcpiUtGetNodeName (Node), ExtraDesc->Extra.AmlStart)); 438 439 /* Execute the argument AML */ 440 441 Status = AcpiDsExecuteArguments (Node, AcpiNsGetParentNode (Node), 442 ExtraDesc->Extra.AmlLength, ExtraDesc->Extra.AmlStart); 443 return_ACPI_STATUS (Status); 444} 445 446 447/***************************************************************************** 448 * 449 * FUNCTION: AcpiDsInitializeRegion 450 * 451 * PARAMETERS: Op - A valid region Op object 452 * 453 * RETURN: Status 454 * 455 * DESCRIPTION: Front end to EvInitializeRegion 456 * 457 ****************************************************************************/ 458 459ACPI_STATUS 460AcpiDsInitializeRegion ( 461 ACPI_HANDLE ObjHandle) 462{ 463 ACPI_OPERAND_OBJECT *ObjDesc; 464 ACPI_STATUS Status; 465 466 467 ObjDesc = AcpiNsGetAttachedObject (ObjHandle); 468 469 /* Namespace is NOT locked */ 470 471 Status = AcpiEvInitializeRegion (ObjDesc, FALSE); 472 return (Status); 473} 474 475 476/***************************************************************************** 477 * 478 * FUNCTION: AcpiDsInitBufferField 479 * 480 * PARAMETERS: AmlOpcode - CreateXxxField 481 * ObjDesc - BufferField object 482 * BufferDesc - Host Buffer 483 * OffsetDesc - Offset into buffer 484 * Length - Length of field (CREATE_FIELD_OP only) 485 * Result - Where to store the result 486 * 487 * RETURN: Status 488 * 489 * DESCRIPTION: Perform actual initialization of a buffer field 490 * 491 ****************************************************************************/ 492 493ACPI_STATUS 494AcpiDsInitBufferField ( 495 UINT16 AmlOpcode, 496 ACPI_OPERAND_OBJECT *ObjDesc, 497 ACPI_OPERAND_OBJECT *BufferDesc, 498 ACPI_OPERAND_OBJECT *OffsetDesc, 499 ACPI_OPERAND_OBJECT *LengthDesc, 500 ACPI_OPERAND_OBJECT *ResultDesc) 501{ 502 UINT32 Offset; 503 UINT32 BitOffset; 504 UINT32 BitCount; 505 UINT8 FieldFlags; 506 ACPI_STATUS Status; 507 508 509 ACPI_FUNCTION_TRACE_PTR ("DsInitBufferField", ObjDesc); 510 511 512 /* Host object must be a Buffer */ 513 514 if (ACPI_GET_OBJECT_TYPE (BufferDesc) != ACPI_TYPE_BUFFER) 515 { 516 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 517 "Target of Create Field is not a Buffer object - %s\n", 518 AcpiUtGetObjectTypeName (BufferDesc))); 519 520 Status = AE_AML_OPERAND_TYPE; 521 goto Cleanup; 522 } 523 524 /* 525 * The last parameter to all of these opcodes (ResultDesc) started 526 * out as a NameString, and should therefore now be a NS node 527 * after resolution in AcpiExResolveOperands(). 528 */ 529 if (ACPI_GET_DESCRIPTOR_TYPE (ResultDesc) != ACPI_DESC_TYPE_NAMED) 530 { 531 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "(%s) destination not a NS Node [%s]\n", 532 AcpiPsGetOpcodeName (AmlOpcode), AcpiUtGetDescriptorName (ResultDesc))); 533 534 Status = AE_AML_OPERAND_TYPE; 535 goto Cleanup; 536 } 537 538 Offset = (UINT32) OffsetDesc->Integer.Value; 539 540 /* 541 * Setup the Bit offsets and counts, according to the opcode 542 */ 543 switch (AmlOpcode) 544 { 545 case AML_CREATE_FIELD_OP: 546 547 /* Offset is in bits, count is in bits */ 548 549 BitOffset = Offset; 550 BitCount = (UINT32) LengthDesc->Integer.Value; 551 FieldFlags = AML_FIELD_ACCESS_BYTE; 552 break; 553 554 case AML_CREATE_BIT_FIELD_OP: 555 556 /* Offset is in bits, Field is one bit */ 557 558 BitOffset = Offset; 559 BitCount = 1; 560 FieldFlags = AML_FIELD_ACCESS_BYTE; 561 break; 562 563 case AML_CREATE_BYTE_FIELD_OP: 564 565 /* Offset is in bytes, field is one byte */ 566 567 BitOffset = 8 * Offset; 568 BitCount = 8; 569 FieldFlags = AML_FIELD_ACCESS_BYTE; 570 break; 571 572 case AML_CREATE_WORD_FIELD_OP: 573 574 /* Offset is in bytes, field is one word */ 575 576 BitOffset = 8 * Offset; 577 BitCount = 16; 578 FieldFlags = AML_FIELD_ACCESS_WORD; 579 break; 580 581 case AML_CREATE_DWORD_FIELD_OP: 582 583 /* Offset is in bytes, field is one dword */ 584 585 BitOffset = 8 * Offset; 586 BitCount = 32; 587 FieldFlags = AML_FIELD_ACCESS_DWORD; 588 break; 589 590 case AML_CREATE_QWORD_FIELD_OP: 591 592 /* Offset is in bytes, field is one qword */ 593 594 BitOffset = 8 * Offset; 595 BitCount = 64; 596 FieldFlags = AML_FIELD_ACCESS_QWORD; 597 break; 598 599 default: 600 601 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 602 "Unknown field creation opcode %02x\n", 603 AmlOpcode)); 604 Status = AE_AML_BAD_OPCODE; 605 goto Cleanup; 606 } 607 608 /* Entire field must fit within the current length of the buffer */ 609 610 if ((BitOffset + BitCount) > 611 (8 * (UINT32) BufferDesc->Buffer.Length)) 612 { 613 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 614 "Field [%4.4s] size %d exceeds Buffer [%4.4s] size %d (bits)\n", 615 AcpiUtGetNodeName (ResultDesc), 616 BitOffset + BitCount, 617 AcpiUtGetNodeName (BufferDesc->Buffer.Node), 618 8 * (UINT32) BufferDesc->Buffer.Length)); 619 Status = AE_AML_BUFFER_LIMIT; 620 goto Cleanup; 621 } 622 623 /* 624 * Initialize areas of the field object that are common to all fields 625 * For FieldFlags, use LOCK_RULE = 0 (NO_LOCK), UPDATE_RULE = 0 (UPDATE_PRESERVE) 626 */ 627 Status = AcpiExPrepCommonFieldObject (ObjDesc, FieldFlags, 0, 628 BitOffset, BitCount); 629 if (ACPI_FAILURE (Status)) 630 { 631 goto Cleanup; 632 } 633 634 ObjDesc->BufferField.BufferObj = BufferDesc; 635 636 /* Reference count for BufferDesc inherits ObjDesc count */ 637 638 BufferDesc->Common.ReferenceCount = (UINT16) (BufferDesc->Common.ReferenceCount + 639 ObjDesc->Common.ReferenceCount); 640 641 642Cleanup: 643 644 /* Always delete the operands */ 645 646 AcpiUtRemoveReference (OffsetDesc); 647 AcpiUtRemoveReference (BufferDesc); 648 649 if (AmlOpcode == AML_CREATE_FIELD_OP) 650 { 651 AcpiUtRemoveReference (LengthDesc); 652 } 653 654 /* On failure, delete the result descriptor */ 655 656 if (ACPI_FAILURE (Status)) 657 { 658 AcpiUtRemoveReference (ResultDesc); /* Result descriptor */ 659 } 660 else 661 { 662 /* Now the address and length are valid for this BufferField */ 663 664 ObjDesc->BufferField.Flags |= AOPOBJ_DATA_VALID; 665 } 666 667 return_ACPI_STATUS (Status); 668} 669 670 671/***************************************************************************** 672 * 673 * FUNCTION: AcpiDsEvalBufferFieldOperands 674 * 675 * PARAMETERS: WalkState - Current walk 676 * Op - A valid BufferField Op object 677 * 678 * RETURN: Status 679 * 680 * DESCRIPTION: Get BufferField Buffer and Index 681 * Called from AcpiDsExecEndOp during BufferField parse tree walk 682 * 683 ****************************************************************************/ 684 685ACPI_STATUS 686AcpiDsEvalBufferFieldOperands ( 687 ACPI_WALK_STATE *WalkState, 688 ACPI_PARSE_OBJECT *Op) 689{ 690 ACPI_STATUS Status; 691 ACPI_OPERAND_OBJECT *ObjDesc; 692 ACPI_NAMESPACE_NODE *Node; 693 ACPI_PARSE_OBJECT *NextOp; 694 695 696 ACPI_FUNCTION_TRACE_PTR ("DsEvalBufferFieldOperands", Op); 697 698 699 /* 700 * This is where we evaluate the address and length fields of the 701 * CreateXxxField declaration 702 */ 703 Node = Op->Common.Node; 704 705 /* NextOp points to the op that holds the Buffer */ 706 707 NextOp = Op->Common.Value.Arg; 708 709 /* Evaluate/create the address and length operands */ 710 711 Status = AcpiDsCreateOperands (WalkState, NextOp); 712 if (ACPI_FAILURE (Status)) 713 { 714 return_ACPI_STATUS (Status); 715 } 716 717 ObjDesc = AcpiNsGetAttachedObject (Node); 718 if (!ObjDesc) 719 { 720 return_ACPI_STATUS (AE_NOT_EXIST); 721 } 722 723 /* Resolve the operands */ 724 725 Status = AcpiExResolveOperands (Op->Common.AmlOpcode, 726 ACPI_WALK_OPERANDS, WalkState); 727 728 ACPI_DUMP_OPERANDS (ACPI_WALK_OPERANDS, ACPI_IMODE_EXECUTE, 729 AcpiPsGetOpcodeName (Op->Common.AmlOpcode), 730 WalkState->NumOperands, "after AcpiExResolveOperands"); 731 732 if (ACPI_FAILURE (Status)) 733 { 734 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "(%s) bad operand(s) (%X)\n", 735 AcpiPsGetOpcodeName (Op->Common.AmlOpcode), Status)); 736 737 return_ACPI_STATUS (Status); 738 } 739 740 /* Initialize the Buffer Field */ 741 742 if (Op->Common.AmlOpcode == AML_CREATE_FIELD_OP) 743 { 744 /* NOTE: Slightly different operands for this opcode */ 745 746 Status = AcpiDsInitBufferField (Op->Common.AmlOpcode, ObjDesc, 747 WalkState->Operands[0], WalkState->Operands[1], 748 WalkState->Operands[2], WalkState->Operands[3]); 749 } 750 else 751 { 752 /* All other, CreateXxxField opcodes */ 753 754 Status = AcpiDsInitBufferField (Op->Common.AmlOpcode, ObjDesc, 755 WalkState->Operands[0], WalkState->Operands[1], 756 NULL, WalkState->Operands[2]); 757 } 758 759 return_ACPI_STATUS (Status); 760} 761 762 763/***************************************************************************** 764 * 765 * FUNCTION: AcpiDsEvalRegionOperands 766 * 767 * PARAMETERS: WalkState - Current walk 768 * Op - A valid region Op object 769 * 770 * RETURN: Status 771 * 772 * DESCRIPTION: Get region address and length 773 * Called from AcpiDsExecEndOp during OpRegion parse tree walk 774 * 775 ****************************************************************************/ 776 777ACPI_STATUS 778AcpiDsEvalRegionOperands ( 779 ACPI_WALK_STATE *WalkState, 780 ACPI_PARSE_OBJECT *Op) 781{ 782 ACPI_STATUS Status; 783 ACPI_OPERAND_OBJECT *ObjDesc; 784 ACPI_OPERAND_OBJECT *OperandDesc; 785 ACPI_NAMESPACE_NODE *Node; 786 ACPI_PARSE_OBJECT *NextOp; 787 788 789 ACPI_FUNCTION_TRACE_PTR ("DsEvalRegionOperands", Op); 790 791 792 /* 793 * This is where we evaluate the address and length fields of the OpRegion declaration 794 */ 795 Node = Op->Common.Node; 796 797 /* NextOp points to the op that holds the SpaceID */ 798 799 NextOp = Op->Common.Value.Arg; 800 801 /* NextOp points to address op */ 802 803 NextOp = NextOp->Common.Next; 804 805 /* Evaluate/create the address and length operands */ 806 807 Status = AcpiDsCreateOperands (WalkState, NextOp); 808 if (ACPI_FAILURE (Status)) 809 { 810 return_ACPI_STATUS (Status); 811 } 812 813 /* Resolve the length and address operands to numbers */ 814 815 Status = AcpiExResolveOperands (Op->Common.AmlOpcode, ACPI_WALK_OPERANDS, WalkState); 816 if (ACPI_FAILURE (Status)) 817 { 818 return_ACPI_STATUS (Status); 819 } 820 821 ACPI_DUMP_OPERANDS (ACPI_WALK_OPERANDS, ACPI_IMODE_EXECUTE, 822 AcpiPsGetOpcodeName (Op->Common.AmlOpcode), 823 1, "after AcpiExResolveOperands"); 824 825 ObjDesc = AcpiNsGetAttachedObject (Node); 826 if (!ObjDesc) 827 { 828 return_ACPI_STATUS (AE_NOT_EXIST); 829 } 830 831 /* 832 * Get the length operand and save it 833 * (at Top of stack) 834 */ 835 OperandDesc = WalkState->Operands[WalkState->NumOperands - 1]; 836 837 ObjDesc->Region.Length = (UINT32) OperandDesc->Integer.Value; 838 AcpiUtRemoveReference (OperandDesc); 839 840 /* 841 * Get the address and save it 842 * (at top of stack - 1) 843 */ 844 OperandDesc = WalkState->Operands[WalkState->NumOperands - 2]; 845 846 ObjDesc->Region.Address = (ACPI_PHYSICAL_ADDRESS) OperandDesc->Integer.Value; 847 AcpiUtRemoveReference (OperandDesc); 848 849 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "RgnObj %p Addr %8.8X%8.8X Len %X\n", 850 ObjDesc, 851 ACPI_FORMAT_UINT64 (ObjDesc->Region.Address), 852 ObjDesc->Region.Length)); 853 854 /* Now the address and length are valid for this opregion */ 855 856 ObjDesc->Region.Flags |= AOPOBJ_DATA_VALID; 857 858 return_ACPI_STATUS (Status); 859} 860 861 862/***************************************************************************** 863 * 864 * FUNCTION: AcpiDsEvalDataObjectOperands 865 * 866 * PARAMETERS: WalkState - Current walk 867 * Op - A valid DataObject Op object 868 * ObjDesc - DataObject 869 * 870 * RETURN: Status 871 * 872 * DESCRIPTION: Get the operands and complete the following data objec types: 873 * Buffer 874 * Package 875 * 876 ****************************************************************************/ 877 878ACPI_STATUS 879AcpiDsEvalDataObjectOperands ( 880 ACPI_WALK_STATE *WalkState, 881 ACPI_PARSE_OBJECT *Op, 882 ACPI_OPERAND_OBJECT *ObjDesc) 883{ 884 ACPI_STATUS Status; 885 ACPI_OPERAND_OBJECT *ArgDesc; 886 UINT32 Length; 887 888 889 ACPI_FUNCTION_TRACE ("DsEvalDataObjectOperands"); 890 891 892 /* The first operand (for all of these data objects) is the length */ 893 894 Status = AcpiDsCreateOperand (WalkState, Op->Common.Value.Arg, 1); 895 if (ACPI_FAILURE (Status)) 896 { 897 return_ACPI_STATUS (Status); 898 } 899 900 Status = AcpiExResolveOperands (WalkState->Opcode, 901 &(WalkState->Operands [WalkState->NumOperands -1]), 902 WalkState); 903 if (ACPI_FAILURE (Status)) 904 { 905 return_ACPI_STATUS (Status); 906 } 907 908 /* Extract length operand */ 909 910 ArgDesc = WalkState->Operands [WalkState->NumOperands - 1]; 911 Length = (UINT32) ArgDesc->Integer.Value; 912 913 /* Cleanup for length operand */ 914 915 Status = AcpiDsObjStackPop (1, WalkState); 916 if (ACPI_FAILURE (Status)) 917 { 918 return_ACPI_STATUS (Status); 919 } 920 921 AcpiUtRemoveReference (ArgDesc); 922 923 /* 924 * Create the actual data object 925 */ 926 switch (Op->Common.AmlOpcode) 927 { 928 case AML_BUFFER_OP: 929 930 Status = AcpiDsBuildInternalBufferObj (WalkState, Op, Length, &ObjDesc); 931 break; 932 933 case AML_PACKAGE_OP: 934 case AML_VAR_PACKAGE_OP: 935 936 Status = AcpiDsBuildInternalPackageObj (WalkState, Op, Length, &ObjDesc); 937 break; 938 939 default: 940 return_ACPI_STATUS (AE_AML_BAD_OPCODE); 941 } 942 943 if (ACPI_SUCCESS (Status)) 944 { 945 /* 946 * Return the object in the WalkState, unless the parent is a package -- 947 * in this case, the return object will be stored in the parse tree 948 * for the package. 949 */ 950 if ((!Op->Common.Parent) || 951 ((Op->Common.Parent->Common.AmlOpcode != AML_PACKAGE_OP) && 952 (Op->Common.Parent->Common.AmlOpcode != AML_VAR_PACKAGE_OP) && 953 (Op->Common.Parent->Common.AmlOpcode != AML_NAME_OP))) 954 { 955 WalkState->ResultObj = ObjDesc; 956 } 957 } 958 959 return_ACPI_STATUS (Status); 960} 961 962 963/******************************************************************************* 964 * 965 * FUNCTION: AcpiDsExecBeginControlOp 966 * 967 * PARAMETERS: WalkList - The list that owns the walk stack 968 * Op - The control Op 969 * 970 * RETURN: Status 971 * 972 * DESCRIPTION: Handles all control ops encountered during control method 973 * execution. 974 * 975 ******************************************************************************/ 976 977ACPI_STATUS 978AcpiDsExecBeginControlOp ( 979 ACPI_WALK_STATE *WalkState, 980 ACPI_PARSE_OBJECT *Op) 981{ 982 ACPI_STATUS Status = AE_OK; 983 ACPI_GENERIC_STATE *ControlState; 984 985 986 ACPI_FUNCTION_NAME ("DsExecBeginControlOp"); 987 988 989 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Op=%p Opcode=%2.2X State=%p\n", Op, 990 Op->Common.AmlOpcode, WalkState)); 991 992 switch (Op->Common.AmlOpcode) 993 { 994 case AML_IF_OP: 995 case AML_WHILE_OP: 996 997 /* 998 * IF/WHILE: Create a new control state to manage these 999 * constructs. We need to manage these as a stack, in order 1000 * to handle nesting. 1001 */ 1002 ControlState = AcpiUtCreateControlState (); 1003 if (!ControlState) 1004 { 1005 Status = AE_NO_MEMORY; 1006 break; 1007 } 1008 /* 1009 * Save a pointer to the predicate for multiple executions 1010 * of a loop 1011 */ 1012 ControlState->Control.AmlPredicateStart = WalkState->ParserState.Aml - 1; 1013 ControlState->Control.PackageEnd = WalkState->ParserState.PkgEnd; 1014 ControlState->Control.Opcode = Op->Common.AmlOpcode; 1015 1016 1017 /* Push the control state on this walk's control stack */ 1018 1019 AcpiUtPushGenericState (&WalkState->ControlState, ControlState); 1020 break; 1021 1022 case AML_ELSE_OP: 1023 1024 /* Predicate is in the state object */ 1025 /* If predicate is true, the IF was executed, ignore ELSE part */ 1026 1027 if (WalkState->LastPredicate) 1028 { 1029 Status = AE_CTRL_TRUE; 1030 } 1031 1032 break; 1033 1034 case AML_RETURN_OP: 1035 1036 break; 1037 1038 default: 1039 break; 1040 } 1041 1042 return (Status); 1043} 1044 1045 1046/******************************************************************************* 1047 * 1048 * FUNCTION: AcpiDsExecEndControlOp 1049 * 1050 * PARAMETERS: WalkList - The list that owns the walk stack 1051 * Op - The control Op 1052 * 1053 * RETURN: Status 1054 * 1055 * DESCRIPTION: Handles all control ops encountered during control method 1056 * execution. 1057 * 1058 ******************************************************************************/ 1059 1060ACPI_STATUS 1061AcpiDsExecEndControlOp ( 1062 ACPI_WALK_STATE *WalkState, 1063 ACPI_PARSE_OBJECT *Op) 1064{ 1065 ACPI_STATUS Status = AE_OK; 1066 ACPI_GENERIC_STATE *ControlState; 1067 1068 1069 ACPI_FUNCTION_NAME ("DsExecEndControlOp"); 1070 1071 1072 switch (Op->Common.AmlOpcode) 1073 { 1074 case AML_IF_OP: 1075 1076 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "[IF_OP] Op=%p\n", Op)); 1077 1078 /* 1079 * Save the result of the predicate in case there is an 1080 * ELSE to come 1081 */ 1082 WalkState->LastPredicate = 1083 (BOOLEAN) WalkState->ControlState->Common.Value; 1084 1085 /* 1086 * Pop the control state that was created at the start 1087 * of the IF and free it 1088 */ 1089 ControlState = AcpiUtPopGenericState (&WalkState->ControlState); 1090 AcpiUtDeleteGenericState (ControlState); 1091 break; 1092 1093 1094 case AML_ELSE_OP: 1095 1096 break; 1097 1098 1099 case AML_WHILE_OP: 1100 1101 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "[WHILE_OP] Op=%p\n", Op)); 1102 1103 if (WalkState->ControlState->Common.Value) 1104 { 1105 /* Predicate was true, go back and evaluate it again! */ 1106 1107 Status = AE_CTRL_PENDING; 1108 } 1109 1110 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "[WHILE_OP] termination! Op=%p\n", Op)); 1111 1112 /* Pop this control state and free it */ 1113 1114 ControlState = AcpiUtPopGenericState (&WalkState->ControlState); 1115 1116 WalkState->AmlLastWhile = ControlState->Control.AmlPredicateStart; 1117 AcpiUtDeleteGenericState (ControlState); 1118 break; 1119 1120 1121 case AML_RETURN_OP: 1122 1123 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, 1124 "[RETURN_OP] Op=%p Arg=%p\n",Op, Op->Common.Value.Arg)); 1125 1126 /* 1127 * One optional operand -- the return value 1128 * It can be either an immediate operand or a result that 1129 * has been bubbled up the tree 1130 */ 1131 if (Op->Common.Value.Arg) 1132 { 1133 /* Return statement has an immediate operand */ 1134 1135 Status = AcpiDsCreateOperands (WalkState, Op->Common.Value.Arg); 1136 if (ACPI_FAILURE (Status)) 1137 { 1138 return (Status); 1139 } 1140 1141 /* 1142 * If value being returned is a Reference (such as 1143 * an arg or local), resolve it now because it may 1144 * cease to exist at the end of the method. 1145 */ 1146 Status = AcpiExResolveToValue (&WalkState->Operands [0], WalkState); 1147 if (ACPI_FAILURE (Status)) 1148 { 1149 return (Status); 1150 } 1151 1152 /* 1153 * Get the return value and save as the last result 1154 * value. This is the only place where WalkState->ReturnDesc 1155 * is set to anything other than zero! 1156 */ 1157 WalkState->ReturnDesc = WalkState->Operands[0]; 1158 } 1159 else if ((WalkState->Results) && 1160 (WalkState->Results->Results.NumResults > 0)) 1161 { 1162 /* 1163 * The return value has come from a previous calculation. 1164 * 1165 * If value being returned is a Reference (such as 1166 * an arg or local), resolve it now because it may 1167 * cease to exist at the end of the method. 1168 * 1169 * Allow references created by the Index operator to return unchanged. 1170 */ 1171 if ((ACPI_GET_DESCRIPTOR_TYPE (WalkState->Results->Results.ObjDesc[0]) == ACPI_DESC_TYPE_OPERAND) && 1172 (ACPI_GET_OBJECT_TYPE (WalkState->Results->Results.ObjDesc [0]) == ACPI_TYPE_LOCAL_REFERENCE) && 1173 ((WalkState->Results->Results.ObjDesc [0])->Reference.Opcode != AML_INDEX_OP)) 1174 { 1175 Status = AcpiExResolveToValue (&WalkState->Results->Results.ObjDesc [0], WalkState); 1176 if (ACPI_FAILURE (Status)) 1177 { 1178 return (Status); 1179 } 1180 } 1181 1182 WalkState->ReturnDesc = WalkState->Results->Results.ObjDesc [0]; 1183 } 1184 else 1185 { 1186 /* No return operand */ 1187 1188 if (WalkState->NumOperands) 1189 { 1190 AcpiUtRemoveReference (WalkState->Operands [0]); 1191 } 1192 1193 WalkState->Operands [0] = NULL; 1194 WalkState->NumOperands = 0; 1195 WalkState->ReturnDesc = NULL; 1196 } 1197 1198 1199 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, 1200 "Completed RETURN_OP State=%p, RetVal=%p\n", 1201 WalkState, WalkState->ReturnDesc)); 1202 1203 /* End the control method execution right now */ 1204 1205 Status = AE_CTRL_TERMINATE; 1206 break; 1207 1208 1209 case AML_NOOP_OP: 1210 1211 /* Just do nothing! */ 1212 break; 1213 1214 1215 case AML_BREAK_POINT_OP: 1216 1217 /* Call up to the OS service layer to handle this */ 1218 1219 Status = AcpiOsSignal (ACPI_SIGNAL_BREAKPOINT, "Executed AML Breakpoint opcode"); 1220 1221 /* If and when it returns, all done. */ 1222 1223 break; 1224 1225 1226 case AML_BREAK_OP: 1227 case AML_CONTINUE_OP: /* ACPI 2.0 */ 1228 1229 1230 /* Pop and delete control states until we find a while */ 1231 1232 while (WalkState->ControlState && 1233 (WalkState->ControlState->Control.Opcode != AML_WHILE_OP)) 1234 { 1235 ControlState = AcpiUtPopGenericState (&WalkState->ControlState); 1236 AcpiUtDeleteGenericState (ControlState); 1237 } 1238 1239 /* No while found? */ 1240 1241 if (!WalkState->ControlState) 1242 { 1243 return (AE_AML_NO_WHILE); 1244 } 1245 1246 /* Was: WalkState->AmlLastWhile = WalkState->ControlState->Control.AmlPredicateStart; */ 1247 1248 WalkState->AmlLastWhile = WalkState->ControlState->Control.PackageEnd; 1249 1250 /* Return status depending on opcode */ 1251 1252 if (Op->Common.AmlOpcode == AML_BREAK_OP) 1253 { 1254 Status = AE_CTRL_BREAK; 1255 } 1256 else 1257 { 1258 Status = AE_CTRL_CONTINUE; 1259 } 1260 break; 1261 1262 1263 default: 1264 1265 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown control opcode=%X Op=%p\n", 1266 Op->Common.AmlOpcode, Op)); 1267 1268 Status = AE_AML_BAD_OPCODE; 1269 break; 1270 } 1271 1272 return (Status); 1273} 1274
|