6 * 7 *****************************************************************************/ 8 9/****************************************************************************** 10 * 11 * 1. Copyright Notice 12 * 13 * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. 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;
| 6 * 7 *****************************************************************************/ 8 9/****************************************************************************** 10 * 11 * 1. Copyright Notice 12 * 13 * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. 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;
|
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, 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 { 330 ACPI_REPORT_ERROR (( 331 "No pointer back to NS node in buffer obj %p\n", ObjDesc)); 332 return_ACPI_STATUS (AE_AML_INTERNAL); 333 } 334 335 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Buffer Arg Init\n")); 336 337 /* Execute the AML code for the TermArg arguments */ 338 339 Status = AcpiDsExecuteArguments (Node, Node, 340 ObjDesc->Buffer.AmlLength, ObjDesc->Buffer.AmlStart); 341 return_ACPI_STATUS (Status); 342} 343 344 345/***************************************************************************** 346 * 347 * FUNCTION: AcpiDsGetPackageArguments 348 * 349 * PARAMETERS: ObjDesc - A valid Package object 350 * 351 * RETURN: Status. 352 * 353 * DESCRIPTION: Get Package length and initializer byte list. This implements 354 * the late evaluation of these attributes. 355 * 356 ****************************************************************************/ 357 358ACPI_STATUS 359AcpiDsGetPackageArguments ( 360 ACPI_OPERAND_OBJECT *ObjDesc) 361{ 362 ACPI_NAMESPACE_NODE *Node; 363 ACPI_STATUS Status; 364 365 366 ACPI_FUNCTION_TRACE_PTR ("DsGetPackageArguments", ObjDesc); 367 368 369 if (ObjDesc->Common.Flags & AOPOBJ_DATA_VALID) 370 { 371 return_ACPI_STATUS (AE_OK); 372 } 373 374 /* Get the Package node */ 375 376 Node = ObjDesc->Package.Node; 377 if (!Node) 378 { 379 ACPI_REPORT_ERROR (( 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
| 207 AcpiPsDeleteParseTree (Op); 208 209 /* Evaluate the deferred arguments */ 210 211 Op = AcpiPsAllocOp (AML_INT_EVAL_SUBTREE_OP); 212 if (!Op) 213 { 214 return_ACPI_STATUS (AE_NO_MEMORY); 215 } 216 217 Op->Common.Node = ScopeNode; 218 219 /* Create and initialize a new parser state */ 220 221 WalkState = AcpiDsCreateWalkState (0, NULL, NULL, NULL); 222 if (!WalkState) 223 { 224 return_ACPI_STATUS (AE_NO_MEMORY); 225 } 226 227 /* Execute the opcode and arguments */ 228 229 Status = AcpiDsInitAmlWalk (WalkState, Op, NULL, AmlStart, 230 AmlLength, NULL, 3); 231 if (ACPI_FAILURE (Status)) 232 { 233 AcpiDsDeleteWalkState (WalkState); 234 return_ACPI_STATUS (Status); 235 } 236 237 /* Mark this execution as a deferred opcode */ 238 239 WalkState->DeferredNode = Node; 240 Status = AcpiPsParseAml (WalkState); 241 AcpiPsDeleteParseTree (Op); 242 return_ACPI_STATUS (Status); 243} 244 245 246/***************************************************************************** 247 * 248 * FUNCTION: AcpiDsGetBufferFieldArguments 249 * 250 * PARAMETERS: ObjDesc - A valid BufferField object 251 * 252 * RETURN: Status. 253 * 254 * DESCRIPTION: Get BufferField Buffer and Index. This implements the late 255 * evaluation of these field attributes. 256 * 257 ****************************************************************************/ 258 259ACPI_STATUS 260AcpiDsGetBufferFieldArguments ( 261 ACPI_OPERAND_OBJECT *ObjDesc) 262{ 263 ACPI_OPERAND_OBJECT *ExtraDesc; 264 ACPI_NAMESPACE_NODE *Node; 265 ACPI_STATUS Status; 266 267 268 ACPI_FUNCTION_TRACE_PTR ("DsGetBufferFieldArguments", ObjDesc); 269 270 271 if (ObjDesc->Common.Flags & AOPOBJ_DATA_VALID) 272 { 273 return_ACPI_STATUS (AE_OK); 274 } 275 276 /* Get the AML pointer (method object) and BufferField node */ 277 278 ExtraDesc = AcpiNsGetSecondaryObject (ObjDesc); 279 Node = ObjDesc->BufferField.Node; 280 281 ACPI_DEBUG_EXEC(AcpiUtDisplayInitPathname (ACPI_TYPE_BUFFER_FIELD, Node, NULL)); 282 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[%4.4s] BufferField Arg Init\n", 283 AcpiUtGetNodeName (Node))); 284 285 /* Execute the AML code for the TermArg arguments */ 286 287 Status = AcpiDsExecuteArguments (Node, AcpiNsGetParentNode (Node), 288 ExtraDesc->Extra.AmlLength, ExtraDesc->Extra.AmlStart); 289 return_ACPI_STATUS (Status); 290} 291 292 293/***************************************************************************** 294 * 295 * FUNCTION: AcpiDsGetBufferArguments 296 * 297 * PARAMETERS: ObjDesc - A valid Buffer object 298 * 299 * RETURN: Status. 300 * 301 * DESCRIPTION: Get Buffer length and initializer byte list. This implements 302 * the late evaluation of these attributes. 303 * 304 ****************************************************************************/ 305 306ACPI_STATUS 307AcpiDsGetBufferArguments ( 308 ACPI_OPERAND_OBJECT *ObjDesc) 309{ 310 ACPI_NAMESPACE_NODE *Node; 311 ACPI_STATUS Status; 312 313 314 ACPI_FUNCTION_TRACE_PTR ("DsGetBufferArguments", ObjDesc); 315 316 317 if (ObjDesc->Common.Flags & AOPOBJ_DATA_VALID) 318 { 319 return_ACPI_STATUS (AE_OK); 320 } 321 322 /* Get the Buffer node */ 323 324 Node = ObjDesc->Buffer.Node; 325 if (!Node) 326 { 327 ACPI_REPORT_ERROR (( 328 "No pointer back to NS node in buffer obj %p\n", ObjDesc)); 329 return_ACPI_STATUS (AE_AML_INTERNAL); 330 } 331 332 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Buffer Arg Init\n")); 333 334 /* Execute the AML code for the TermArg arguments */ 335 336 Status = AcpiDsExecuteArguments (Node, Node, 337 ObjDesc->Buffer.AmlLength, ObjDesc->Buffer.AmlStart); 338 return_ACPI_STATUS (Status); 339} 340 341 342/***************************************************************************** 343 * 344 * FUNCTION: AcpiDsGetPackageArguments 345 * 346 * PARAMETERS: ObjDesc - A valid Package object 347 * 348 * RETURN: Status. 349 * 350 * DESCRIPTION: Get Package length and initializer byte list. This implements 351 * the late evaluation of these attributes. 352 * 353 ****************************************************************************/ 354 355ACPI_STATUS 356AcpiDsGetPackageArguments ( 357 ACPI_OPERAND_OBJECT *ObjDesc) 358{ 359 ACPI_NAMESPACE_NODE *Node; 360 ACPI_STATUS Status; 361 362 363 ACPI_FUNCTION_TRACE_PTR ("DsGetPackageArguments", ObjDesc); 364 365 366 if (ObjDesc->Common.Flags & AOPOBJ_DATA_VALID) 367 { 368 return_ACPI_STATUS (AE_OK); 369 } 370 371 /* Get the Package node */ 372 373 Node = ObjDesc->Package.Node; 374 if (!Node) 375 { 376 ACPI_REPORT_ERROR (( 377 "No pointer back to NS node in package %p\n", ObjDesc)); 378 return_ACPI_STATUS (AE_AML_INTERNAL); 379 } 380 381 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Package Arg Init\n")); 382 383 /* Execute the AML code for the TermArg arguments */ 384 385 Status = AcpiDsExecuteArguments (Node, Node, 386 ObjDesc->Package.AmlLength, ObjDesc->Package.AmlStart); 387 return_ACPI_STATUS (Status); 388} 389 390 391/***************************************************************************** 392 * 393 * FUNCTION: AcpiDsGetRegionArguments 394 * 395 * PARAMETERS: ObjDesc - A valid region object 396 * 397 * RETURN: Status. 398 * 399 * DESCRIPTION: Get region address and length. This implements the late 400 * evaluation of these region attributes. 401 * 402 ****************************************************************************/ 403 404ACPI_STATUS 405AcpiDsGetRegionArguments ( 406 ACPI_OPERAND_OBJECT *ObjDesc) 407{ 408 ACPI_NAMESPACE_NODE *Node; 409 ACPI_STATUS Status; 410 ACPI_OPERAND_OBJECT *ExtraDesc; 411 412 413 ACPI_FUNCTION_TRACE_PTR ("DsGetRegionArguments", ObjDesc); 414 415 416 if (ObjDesc->Region.Flags & AOPOBJ_DATA_VALID) 417 { 418 return_ACPI_STATUS (AE_OK); 419 } 420 421 ExtraDesc = AcpiNsGetSecondaryObject (ObjDesc); 422 if (!ExtraDesc) 423 { 424 return_ACPI_STATUS (AE_NOT_EXIST); 425 } 426 427 /* Get the Region node */ 428 429 Node = ObjDesc->Region.Node; 430 431 ACPI_DEBUG_EXEC (AcpiUtDisplayInitPathname (ACPI_TYPE_REGION, Node, NULL)); 432 433 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[%4.4s] OpRegion Arg Init at AML %p\n", 434 AcpiUtGetNodeName (Node), ExtraDesc->Extra.AmlStart)); 435 436 /* Execute the argument AML */ 437 438 Status = AcpiDsExecuteArguments (Node, AcpiNsGetParentNode (Node), 439 ExtraDesc->Extra.AmlLength, ExtraDesc->Extra.AmlStart); 440 return_ACPI_STATUS (Status); 441} 442 443 444/***************************************************************************** 445 * 446 * FUNCTION: AcpiDsInitializeRegion 447 * 448 * PARAMETERS: Op - A valid region Op object 449 * 450 * RETURN: Status 451 * 452 * DESCRIPTION: Front end to EvInitializeRegion 453 * 454 ****************************************************************************/ 455 456ACPI_STATUS 457AcpiDsInitializeRegion ( 458 ACPI_HANDLE ObjHandle) 459{ 460 ACPI_OPERAND_OBJECT *ObjDesc; 461 ACPI_STATUS Status; 462 463 464 ObjDesc = AcpiNsGetAttachedObject (ObjHandle); 465 466 /* Namespace is NOT locked */ 467 468 Status = AcpiEvInitializeRegion (ObjDesc, FALSE); 469 return (Status); 470} 471 472 473/***************************************************************************** 474 * 475 * FUNCTION: AcpiDsInitBufferField 476 * 477 * PARAMETERS: AmlOpcode - CreateXxxField 478 * ObjDesc - BufferField object 479 * BufferDesc - Host Buffer 480 * OffsetDesc - Offset into buffer 481 * Length - Length of field (CREATE_FIELD_OP only) 482 * Result - Where to store the result 483 * 484 * RETURN: Status 485 * 486 * DESCRIPTION: Perform actual initialization of a buffer field 487 * 488 ****************************************************************************/ 489 490ACPI_STATUS 491AcpiDsInitBufferField ( 492 UINT16 AmlOpcode, 493 ACPI_OPERAND_OBJECT *ObjDesc, 494 ACPI_OPERAND_OBJECT *BufferDesc, 495 ACPI_OPERAND_OBJECT *OffsetDesc, 496 ACPI_OPERAND_OBJECT *LengthDesc, 497 ACPI_OPERAND_OBJECT *ResultDesc) 498{ 499 UINT32 Offset; 500 UINT32 BitOffset; 501 UINT32 BitCount; 502 UINT8 FieldFlags; 503 ACPI_STATUS Status; 504 505 506 ACPI_FUNCTION_TRACE_PTR ("DsInitBufferField", ObjDesc); 507 508 509 /* Host object must be a Buffer */ 510 511 if (ACPI_GET_OBJECT_TYPE (BufferDesc) != ACPI_TYPE_BUFFER) 512 { 513 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 514 "Target of Create Field is not a Buffer object - %s\n", 515 AcpiUtGetObjectTypeName (BufferDesc))); 516 517 Status = AE_AML_OPERAND_TYPE; 518 goto Cleanup; 519 } 520 521 /* 522 * The last parameter to all of these opcodes (ResultDesc) started 523 * out as a NameString, and should therefore now be a NS node 524 * after resolution in AcpiExResolveOperands(). 525 */ 526 if (ACPI_GET_DESCRIPTOR_TYPE (ResultDesc) != ACPI_DESC_TYPE_NAMED) 527 { 528 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "(%s) destination not a NS Node [%s]\n", 529 AcpiPsGetOpcodeName (AmlOpcode), AcpiUtGetDescriptorName (ResultDesc))); 530 531 Status = AE_AML_OPERAND_TYPE; 532 goto Cleanup; 533 } 534 535 Offset = (UINT32) OffsetDesc->Integer.Value; 536 537 /* 538 * Setup the Bit offsets and counts, according to the opcode 539 */ 540 switch (AmlOpcode) 541 { 542 case AML_CREATE_FIELD_OP: 543 544 /* Offset is in bits, count is in bits */ 545 546 BitOffset = Offset; 547 BitCount = (UINT32) LengthDesc->Integer.Value; 548 FieldFlags = AML_FIELD_ACCESS_BYTE; 549 break; 550 551 case AML_CREATE_BIT_FIELD_OP: 552 553 /* Offset is in bits, Field is one bit */ 554 555 BitOffset = Offset; 556 BitCount = 1; 557 FieldFlags = AML_FIELD_ACCESS_BYTE; 558 break; 559 560 case AML_CREATE_BYTE_FIELD_OP: 561 562 /* Offset is in bytes, field is one byte */ 563 564 BitOffset = 8 * Offset; 565 BitCount = 8; 566 FieldFlags = AML_FIELD_ACCESS_BYTE; 567 break; 568 569 case AML_CREATE_WORD_FIELD_OP: 570 571 /* Offset is in bytes, field is one word */ 572 573 BitOffset = 8 * Offset; 574 BitCount = 16; 575 FieldFlags = AML_FIELD_ACCESS_WORD; 576 break; 577 578 case AML_CREATE_DWORD_FIELD_OP: 579 580 /* Offset is in bytes, field is one dword */ 581 582 BitOffset = 8 * Offset; 583 BitCount = 32; 584 FieldFlags = AML_FIELD_ACCESS_DWORD; 585 break; 586 587 case AML_CREATE_QWORD_FIELD_OP: 588 589 /* Offset is in bytes, field is one qword */ 590 591 BitOffset = 8 * Offset; 592 BitCount = 64; 593 FieldFlags = AML_FIELD_ACCESS_QWORD; 594 break; 595 596 default: 597 598 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 599 "Unknown field creation opcode %02x\n", 600 AmlOpcode)); 601 Status = AE_AML_BAD_OPCODE; 602 goto Cleanup; 603 } 604 605 /* Entire field must fit within the current length of the buffer */ 606 607 if ((BitOffset + BitCount) > 608 (8 * (UINT32) BufferDesc->Buffer.Length)) 609 { 610 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 611 "Field [%4.4s] size %d exceeds Buffer [%4.4s] size %d (bits)\n", 612 AcpiUtGetNodeName (ResultDesc), 613 BitOffset + BitCount, 614 AcpiUtGetNodeName (BufferDesc->Buffer.Node), 615 8 * (UINT32) BufferDesc->Buffer.Length)); 616 Status = AE_AML_BUFFER_LIMIT; 617 goto Cleanup; 618 } 619 620 /* 621 * Initialize areas of the field object that are common to all fields 622 * For FieldFlags, use LOCK_RULE = 0 (NO_LOCK), UPDATE_RULE = 0 (UPDATE_PRESERVE) 623 */ 624 Status = AcpiExPrepCommonFieldObject (ObjDesc, FieldFlags, 0, 625 BitOffset, BitCount); 626 if (ACPI_FAILURE (Status)) 627 { 628 goto Cleanup; 629 } 630 631 ObjDesc->BufferField.BufferObj = BufferDesc; 632 633 /* Reference count for BufferDesc inherits ObjDesc count */ 634 635 BufferDesc->Common.ReferenceCount = (UINT16) (BufferDesc->Common.ReferenceCount + 636 ObjDesc->Common.ReferenceCount); 637 638 639Cleanup: 640 641 /* Always delete the operands */ 642 643 AcpiUtRemoveReference (OffsetDesc); 644 AcpiUtRemoveReference (BufferDesc); 645 646 if (AmlOpcode == AML_CREATE_FIELD_OP) 647 { 648 AcpiUtRemoveReference (LengthDesc); 649 } 650 651 /* On failure, delete the result descriptor */ 652 653 if (ACPI_FAILURE (Status)) 654 { 655 AcpiUtRemoveReference (ResultDesc); /* Result descriptor */ 656 } 657 else 658 { 659 /* Now the address and length are valid for this BufferField */ 660 661 ObjDesc->BufferField.Flags |= AOPOBJ_DATA_VALID; 662 } 663 664 return_ACPI_STATUS (Status); 665} 666 667 668/***************************************************************************** 669 * 670 * FUNCTION: AcpiDsEvalBufferFieldOperands 671 * 672 * PARAMETERS: WalkState - Current walk 673 * Op - A valid BufferField Op object 674 * 675 * RETURN: Status 676 * 677 * DESCRIPTION: Get BufferField Buffer and Index 678 * Called from AcpiDsExecEndOp during BufferField parse tree walk 679 * 680 ****************************************************************************/ 681 682ACPI_STATUS 683AcpiDsEvalBufferFieldOperands ( 684 ACPI_WALK_STATE *WalkState, 685 ACPI_PARSE_OBJECT *Op) 686{ 687 ACPI_STATUS Status; 688 ACPI_OPERAND_OBJECT *ObjDesc; 689 ACPI_NAMESPACE_NODE *Node; 690 ACPI_PARSE_OBJECT *NextOp; 691 692 693 ACPI_FUNCTION_TRACE_PTR ("DsEvalBufferFieldOperands", Op); 694 695 696 /* 697 * This is where we evaluate the address and length fields of the 698 * CreateXxxField declaration 699 */ 700 Node = Op->Common.Node; 701 702 /* NextOp points to the op that holds the Buffer */ 703 704 NextOp = Op->Common.Value.Arg; 705 706 /* Evaluate/create the address and length operands */ 707 708 Status = AcpiDsCreateOperands (WalkState, NextOp); 709 if (ACPI_FAILURE (Status)) 710 { 711 return_ACPI_STATUS (Status); 712 } 713 714 ObjDesc = AcpiNsGetAttachedObject (Node); 715 if (!ObjDesc) 716 { 717 return_ACPI_STATUS (AE_NOT_EXIST); 718 } 719 720 /* Resolve the operands */ 721 722 Status = AcpiExResolveOperands (Op->Common.AmlOpcode, 723 ACPI_WALK_OPERANDS, WalkState); 724 725 ACPI_DUMP_OPERANDS (ACPI_WALK_OPERANDS, ACPI_IMODE_EXECUTE, 726 AcpiPsGetOpcodeName (Op->Common.AmlOpcode), 727 WalkState->NumOperands, "after AcpiExResolveOperands"); 728 729 if (ACPI_FAILURE (Status)) 730 { 731 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "(%s) bad operand(s) (%X)\n", 732 AcpiPsGetOpcodeName (Op->Common.AmlOpcode), Status)); 733 734 return_ACPI_STATUS (Status); 735 } 736 737 /* Initialize the Buffer Field */ 738 739 if (Op->Common.AmlOpcode == AML_CREATE_FIELD_OP) 740 { 741 /* NOTE: Slightly different operands for this opcode */ 742 743 Status = AcpiDsInitBufferField (Op->Common.AmlOpcode, ObjDesc, 744 WalkState->Operands[0], WalkState->Operands[1], 745 WalkState->Operands[2], WalkState->Operands[3]); 746 } 747 else 748 { 749 /* All other, CreateXxxField opcodes */ 750 751 Status = AcpiDsInitBufferField (Op->Common.AmlOpcode, ObjDesc, 752 WalkState->Operands[0], WalkState->Operands[1], 753 NULL, WalkState->Operands[2]); 754 } 755 756 return_ACPI_STATUS (Status); 757} 758 759 760/***************************************************************************** 761 * 762 * FUNCTION: AcpiDsEvalRegionOperands 763 * 764 * PARAMETERS: WalkState - Current walk 765 * Op - A valid region Op object 766 * 767 * RETURN: Status 768 * 769 * DESCRIPTION: Get region address and length 770 * Called from AcpiDsExecEndOp during OpRegion parse tree walk 771 * 772 ****************************************************************************/ 773 774ACPI_STATUS 775AcpiDsEvalRegionOperands ( 776 ACPI_WALK_STATE *WalkState, 777 ACPI_PARSE_OBJECT *Op) 778{ 779 ACPI_STATUS Status; 780 ACPI_OPERAND_OBJECT *ObjDesc; 781 ACPI_OPERAND_OBJECT *OperandDesc; 782 ACPI_NAMESPACE_NODE *Node; 783 ACPI_PARSE_OBJECT *NextOp; 784 785 786 ACPI_FUNCTION_TRACE_PTR ("DsEvalRegionOperands", Op); 787 788 789 /* 790 * This is where we evaluate the address and length fields of the OpRegion declaration 791 */ 792 Node = Op->Common.Node; 793 794 /* NextOp points to the op that holds the SpaceID */ 795 796 NextOp = Op->Common.Value.Arg; 797 798 /* NextOp points to address op */ 799 800 NextOp = NextOp->Common.Next; 801 802 /* Evaluate/create the address and length operands */ 803 804 Status = AcpiDsCreateOperands (WalkState, NextOp); 805 if (ACPI_FAILURE (Status)) 806 { 807 return_ACPI_STATUS (Status); 808 } 809 810 /* Resolve the length and address operands to numbers */ 811 812 Status = AcpiExResolveOperands (Op->Common.AmlOpcode, ACPI_WALK_OPERANDS, WalkState); 813 if (ACPI_FAILURE (Status)) 814 { 815 return_ACPI_STATUS (Status); 816 } 817 818 ACPI_DUMP_OPERANDS (ACPI_WALK_OPERANDS, ACPI_IMODE_EXECUTE, 819 AcpiPsGetOpcodeName (Op->Common.AmlOpcode), 820 1, "after AcpiExResolveOperands"); 821 822 ObjDesc = AcpiNsGetAttachedObject (Node); 823 if (!ObjDesc) 824 { 825 return_ACPI_STATUS (AE_NOT_EXIST); 826 } 827 828 /* 829 * Get the length operand and save it 830 * (at Top of stack) 831 */ 832 OperandDesc = WalkState->Operands[WalkState->NumOperands - 1]; 833 834 ObjDesc->Region.Length = (UINT32) OperandDesc->Integer.Value; 835 AcpiUtRemoveReference (OperandDesc); 836 837 /* 838 * Get the address and save it 839 * (at top of stack - 1) 840 */ 841 OperandDesc = WalkState->Operands[WalkState->NumOperands - 2]; 842 843 ObjDesc->Region.Address = (ACPI_PHYSICAL_ADDRESS) OperandDesc->Integer.Value; 844 AcpiUtRemoveReference (OperandDesc); 845 846 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "RgnObj %p Addr %8.8X%8.8X Len %X\n", 847 ObjDesc, 848 ACPI_FORMAT_UINT64 (ObjDesc->Region.Address), 849 ObjDesc->Region.Length)); 850 851 /* Now the address and length are valid for this opregion */ 852 853 ObjDesc->Region.Flags |= AOPOBJ_DATA_VALID; 854 855 return_ACPI_STATUS (Status); 856} 857 858 859/***************************************************************************** 860 * 861 * FUNCTION: AcpiDsEvalDataObjectOperands 862 * 863 * PARAMETERS: WalkState - Current walk 864 * Op - A valid DataObject Op object 865 * ObjDesc - DataObject 866 * 867 * RETURN: Status 868 * 869 * DESCRIPTION: Get the operands and complete the following data objec types: 870 * Buffer 871 * Package 872 * 873 ****************************************************************************/ 874 875ACPI_STATUS 876AcpiDsEvalDataObjectOperands ( 877 ACPI_WALK_STATE *WalkState, 878 ACPI_PARSE_OBJECT *Op, 879 ACPI_OPERAND_OBJECT *ObjDesc) 880{ 881 ACPI_STATUS Status; 882 ACPI_OPERAND_OBJECT *ArgDesc; 883 UINT32 Length; 884 885 886 ACPI_FUNCTION_TRACE ("DsEvalDataObjectOperands"); 887 888 889 /* The first operand (for all of these data objects) is the length */ 890 891 Status = AcpiDsCreateOperand (WalkState, Op->Common.Value.Arg, 1); 892 if (ACPI_FAILURE (Status)) 893 { 894 return_ACPI_STATUS (Status); 895 } 896 897 Status = AcpiExResolveOperands (WalkState->Opcode, 898 &(WalkState->Operands [WalkState->NumOperands -1]), 899 WalkState); 900 if (ACPI_FAILURE (Status)) 901 { 902 return_ACPI_STATUS (Status); 903 } 904 905 /* Extract length operand */ 906 907 ArgDesc = WalkState->Operands [WalkState->NumOperands - 1]; 908 Length = (UINT32) ArgDesc->Integer.Value; 909 910 /* Cleanup for length operand */ 911 912 Status = AcpiDsObjStackPop (1, WalkState); 913 if (ACPI_FAILURE (Status)) 914 { 915 return_ACPI_STATUS (Status); 916 } 917 918 AcpiUtRemoveReference (ArgDesc); 919 920 /* 921 * Create the actual data object 922 */ 923 switch (Op->Common.AmlOpcode) 924 { 925 case AML_BUFFER_OP: 926 927 Status = AcpiDsBuildInternalBufferObj (WalkState, Op, Length, &ObjDesc); 928 break; 929 930 case AML_PACKAGE_OP: 931 case AML_VAR_PACKAGE_OP: 932 933 Status = AcpiDsBuildInternalPackageObj (WalkState, Op, Length, &ObjDesc); 934 break; 935 936 default: 937 return_ACPI_STATUS (AE_AML_BAD_OPCODE); 938 } 939 940 if (ACPI_SUCCESS (Status)) 941 { 942 /* 943 * Return the object in the WalkState, unless the parent is a package -- 944 * in this case, the return object will be stored in the parse tree 945 * for the package. 946 */ 947 if ((!Op->Common.Parent) || 948 ((Op->Common.Parent->Common.AmlOpcode != AML_PACKAGE_OP) && 949 (Op->Common.Parent->Common.AmlOpcode != AML_VAR_PACKAGE_OP) && 950 (Op->Common.Parent->Common.AmlOpcode != AML_NAME_OP))) 951 { 952 WalkState->ResultObj = ObjDesc; 953 } 954 } 955 956 return_ACPI_STATUS (Status); 957} 958 959 960/******************************************************************************* 961 * 962 * FUNCTION: AcpiDsExecBeginControlOp 963 * 964 * PARAMETERS: WalkList - The list that owns the walk stack 965 * Op - The control Op 966 * 967 * RETURN: Status 968 * 969 * DESCRIPTION: Handles all control ops encountered during control method 970 * execution. 971 * 972 ******************************************************************************/ 973 974ACPI_STATUS 975AcpiDsExecBeginControlOp ( 976 ACPI_WALK_STATE *WalkState, 977 ACPI_PARSE_OBJECT *Op) 978{ 979 ACPI_STATUS Status = AE_OK; 980 ACPI_GENERIC_STATE *ControlState; 981 982 983 ACPI_FUNCTION_NAME ("DsExecBeginControlOp"); 984 985 986 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Op=%p Opcode=%2.2X State=%p\n", Op, 987 Op->Common.AmlOpcode, WalkState)); 988 989 switch (Op->Common.AmlOpcode) 990 { 991 case AML_IF_OP: 992 case AML_WHILE_OP: 993 994 /* 995 * IF/WHILE: Create a new control state to manage these 996 * constructs. We need to manage these as a stack, in order 997 * to handle nesting. 998 */ 999 ControlState = AcpiUtCreateControlState (); 1000 if (!ControlState) 1001 { 1002 Status = AE_NO_MEMORY; 1003 break; 1004 } 1005 /* 1006 * Save a pointer to the predicate for multiple executions 1007 * of a loop 1008 */ 1009 ControlState->Control.AmlPredicateStart = WalkState->ParserState.Aml - 1; 1010 ControlState->Control.PackageEnd = WalkState->ParserState.PkgEnd; 1011 ControlState->Control.Opcode = Op->Common.AmlOpcode; 1012 1013 1014 /* Push the control state on this walk's control stack */ 1015 1016 AcpiUtPushGenericState (&WalkState->ControlState, ControlState); 1017 break; 1018 1019 case AML_ELSE_OP: 1020 1021 /* Predicate is in the state object */ 1022 /* If predicate is true, the IF was executed, ignore ELSE part */ 1023 1024 if (WalkState->LastPredicate) 1025 { 1026 Status = AE_CTRL_TRUE; 1027 } 1028 1029 break; 1030 1031 case AML_RETURN_OP: 1032 1033 break; 1034 1035 default: 1036 break; 1037 } 1038 1039 return (Status); 1040} 1041 1042 1043/******************************************************************************* 1044 * 1045 * FUNCTION: AcpiDsExecEndControlOp 1046 * 1047 * PARAMETERS: WalkList - The list that owns the walk stack 1048 * Op - The control Op 1049 * 1050 * RETURN: Status 1051 * 1052 * DESCRIPTION: Handles all control ops encountered during control method 1053 * execution. 1054 * 1055 ******************************************************************************/ 1056 1057ACPI_STATUS 1058AcpiDsExecEndControlOp ( 1059 ACPI_WALK_STATE *WalkState, 1060 ACPI_PARSE_OBJECT *Op) 1061{ 1062 ACPI_STATUS Status = AE_OK; 1063 ACPI_GENERIC_STATE *ControlState; 1064 1065 1066 ACPI_FUNCTION_NAME ("DsExecEndControlOp"); 1067 1068 1069 switch (Op->Common.AmlOpcode) 1070 { 1071 case AML_IF_OP: 1072 1073 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "[IF_OP] Op=%p\n", Op)); 1074 1075 /* 1076 * Save the result of the predicate in case there is an 1077 * ELSE to come 1078 */ 1079 WalkState->LastPredicate = 1080 (BOOLEAN) WalkState->ControlState->Common.Value; 1081 1082 /* 1083 * Pop the control state that was created at the start 1084 * of the IF and free it 1085 */ 1086 ControlState = AcpiUtPopGenericState (&WalkState->ControlState); 1087 AcpiUtDeleteGenericState (ControlState); 1088 break; 1089 1090 1091 case AML_ELSE_OP: 1092 1093 break; 1094 1095 1096 case AML_WHILE_OP: 1097 1098 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "[WHILE_OP] Op=%p\n", Op)); 1099 1100 if (WalkState->ControlState->Common.Value) 1101 { 1102 /* Predicate was true, go back and evaluate it again! */ 1103 1104 Status = AE_CTRL_PENDING; 1105 } 1106 1107 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "[WHILE_OP] termination! Op=%p\n", Op)); 1108 1109 /* Pop this control state and free it */ 1110 1111 ControlState = AcpiUtPopGenericState (&WalkState->ControlState); 1112 1113 WalkState->AmlLastWhile = ControlState->Control.AmlPredicateStart; 1114 AcpiUtDeleteGenericState (ControlState); 1115 break; 1116 1117 1118 case AML_RETURN_OP: 1119 1120 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, 1121 "[RETURN_OP] Op=%p Arg=%p\n",Op, Op->Common.Value.Arg)); 1122 1123 /* 1124 * One optional operand -- the return value 1125 * It can be either an immediate operand or a result that 1126 * has been bubbled up the tree 1127 */ 1128 if (Op->Common.Value.Arg) 1129 { 1130 /* Return statement has an immediate operand */ 1131 1132 Status = AcpiDsCreateOperands (WalkState, Op->Common.Value.Arg); 1133 if (ACPI_FAILURE (Status)) 1134 { 1135 return (Status); 1136 } 1137 1138 /* 1139 * If value being returned is a Reference (such as 1140 * an arg or local), resolve it now because it may 1141 * cease to exist at the end of the method. 1142 */ 1143 Status = AcpiExResolveToValue (&WalkState->Operands [0], WalkState); 1144 if (ACPI_FAILURE (Status)) 1145 { 1146 return (Status); 1147 } 1148 1149 /* 1150 * Get the return value and save as the last result 1151 * value. This is the only place where WalkState->ReturnDesc 1152 * is set to anything other than zero! 1153 */ 1154 WalkState->ReturnDesc = WalkState->Operands[0]; 1155 } 1156 else if ((WalkState->Results) && 1157 (WalkState->Results->Results.NumResults > 0)) 1158 { 1159 /* 1160 * The return value has come from a previous calculation. 1161 * 1162 * If value being returned is a Reference (such as 1163 * an arg or local), resolve it now because it may 1164 * cease to exist at the end of the method. 1165 * 1166 * Allow references created by the Index operator to return unchanged. 1167 */ 1168 if ((ACPI_GET_DESCRIPTOR_TYPE (WalkState->Results->Results.ObjDesc[0]) == ACPI_DESC_TYPE_OPERAND) && 1169 (ACPI_GET_OBJECT_TYPE (WalkState->Results->Results.ObjDesc [0]) == ACPI_TYPE_LOCAL_REFERENCE) && 1170 ((WalkState->Results->Results.ObjDesc [0])->Reference.Opcode != AML_INDEX_OP)) 1171 { 1172 Status = AcpiExResolveToValue (&WalkState->Results->Results.ObjDesc [0], WalkState); 1173 if (ACPI_FAILURE (Status)) 1174 { 1175 return (Status); 1176 } 1177 } 1178 1179 WalkState->ReturnDesc = WalkState->Results->Results.ObjDesc [0]; 1180 } 1181 else 1182 { 1183 /* No return operand */ 1184 1185 if (WalkState->NumOperands) 1186 { 1187 AcpiUtRemoveReference (WalkState->Operands [0]); 1188 } 1189 1190 WalkState->Operands [0] = NULL; 1191 WalkState->NumOperands = 0; 1192 WalkState->ReturnDesc = NULL; 1193 } 1194 1195 1196 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, 1197 "Completed RETURN_OP State=%p, RetVal=%p\n", 1198 WalkState, WalkState->ReturnDesc)); 1199 1200 /* End the control method execution right now */ 1201 1202 Status = AE_CTRL_TERMINATE; 1203 break; 1204 1205 1206 case AML_NOOP_OP: 1207 1208 /* Just do nothing! */ 1209 break; 1210 1211 1212 case AML_BREAK_POINT_OP: 1213 1214 /* Call up to the OS service layer to handle this */ 1215 1216 Status = AcpiOsSignal (ACPI_SIGNAL_BREAKPOINT, "Executed AML Breakpoint opcode"); 1217 1218 /* If and when it returns, all done. */ 1219 1220 break; 1221 1222 1223 case AML_BREAK_OP: 1224 case AML_CONTINUE_OP: /* ACPI 2.0 */ 1225 1226 1227 /* Pop and delete control states until we find a while */ 1228 1229 while (WalkState->ControlState && 1230 (WalkState->ControlState->Control.Opcode != AML_WHILE_OP)) 1231 { 1232 ControlState = AcpiUtPopGenericState (&WalkState->ControlState); 1233 AcpiUtDeleteGenericState (ControlState); 1234 } 1235 1236 /* No while found? */ 1237 1238 if (!WalkState->ControlState) 1239 { 1240 return (AE_AML_NO_WHILE); 1241 } 1242 1243 /* Was: WalkState->AmlLastWhile = WalkState->ControlState->Control.AmlPredicateStart; */ 1244 1245 WalkState->AmlLastWhile = WalkState->ControlState->Control.PackageEnd; 1246 1247 /* Return status depending on opcode */ 1248 1249 if (Op->Common.AmlOpcode == AML_BREAK_OP) 1250 { 1251 Status = AE_CTRL_BREAK; 1252 } 1253 else 1254 { 1255 Status = AE_CTRL_CONTINUE; 1256 } 1257 break; 1258 1259 1260 default: 1261 1262 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown control opcode=%X Op=%p\n", 1263 Op->Common.AmlOpcode, Op)); 1264 1265 Status = AE_AML_BAD_OPCODE; 1266 break; 1267 } 1268 1269 return (Status); 1270} 1271
|