1 /****************************************************************************** 2 * 3 * Module Name: dsopcode - Dispatcher support for regions and fields 4 * 5 *****************************************************************************/ 6 7 /****************************************************************************** 8 * 9 * 1. Copyright Notice 10 * 11 * Some or all of this work - Copyright (c) 1999 - 2019, Intel Corp. 12 * All rights reserved. 13 * 14 * 2. License 15 * 16 * 2.1. This is your license from Intel Corp. under its intellectual property 17 * rights. You may have additional license terms from the party that provided 18 * you this software, covering your right to use that party's intellectual 19 * property rights. 20 * 21 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a 22 * copy of the source code appearing in this file ("Covered Code") an 23 * irrevocable, perpetual, worldwide license under Intel's copyrights in the 24 * base code distributed originally by Intel ("Original Intel Code") to copy, 25 * make derivatives, distribute, use and display any portion of the Covered 26 * Code in any form, with the right to sublicense such rights; and 27 * 28 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent 29 * license (with the right to sublicense), under only those claims of Intel 30 * patents that are infringed by the Original Intel Code, to make, use, sell, 31 * offer to sell, and import the Covered Code and derivative works thereof 32 * solely to the minimum extent necessary to exercise the above copyright 33 * license, and in no event shall the patent license extend to any additions 34 * to or modifications of the Original Intel Code. No other license or right 35 * is granted directly or by implication, estoppel or otherwise; 36 * 37 * The above copyright and patent license is granted only if the following 38 * conditions are met: 39 * 40 * 3. Conditions 41 * 42 * 3.1. Redistribution of Source with Rights to Further Distribute Source. 43 * Redistribution of source code of any substantial portion of the Covered 44 * Code or modification with rights to further distribute source must include 45 * the above Copyright Notice, the above License, this list of Conditions, 46 * and the following Disclaimer and Export Compliance provision. In addition, 47 * Licensee must cause all Covered Code to which Licensee contributes to 48 * contain a file documenting the changes Licensee made to create that Covered 49 * Code and the date of any change. Licensee must include in that file the 50 * documentation of any changes made by any predecessor Licensee. Licensee 51 * must include a prominent statement that the modification is derived, 52 * directly or indirectly, from Original Intel Code. 53 * 54 * 3.2. Redistribution of Source with no Rights to Further Distribute Source. 55 * Redistribution of source code of any substantial portion of the Covered 56 * Code or modification without rights to further distribute source must 57 * include the following Disclaimer and Export Compliance provision in the 58 * documentation and/or other materials provided with distribution. In 59 * addition, Licensee may not authorize further sublicense of source of any 60 * portion of the Covered Code, and must include terms to the effect that the 61 * license from Licensee to its licensee is limited to the intellectual 62 * property embodied in the software Licensee provides to its licensee, and 63 * not to intellectual property embodied in modifications its licensee may 64 * make. 65 * 66 * 3.3. Redistribution of Executable. Redistribution in executable form of any 67 * substantial portion of the Covered Code or modification must reproduce the 68 * above Copyright Notice, and the following Disclaimer and Export Compliance 69 * provision in the documentation and/or other materials provided with the 70 * distribution. 71 * 72 * 3.4. Intel retains all right, title, and interest in and to the Original 73 * Intel Code. 74 * 75 * 3.5. Neither the name Intel nor any other trademark owned or controlled by 76 * Intel shall be used in advertising or otherwise to promote the sale, use or 77 * other dealings in products derived from or relating to the Covered Code 78 * without prior written authorization from Intel. 79 * 80 * 4. Disclaimer and Export Compliance 81 * 82 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED 83 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE 84 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, 85 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY 86 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY 87 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A 88 * PARTICULAR PURPOSE. 89 * 90 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES 91 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR 92 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, 93 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY 94 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL 95 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS 96 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY 97 * LIMITED REMEDY. 98 * 99 * 4.3. Licensee shall not export, either directly or indirectly, any of this 100 * software or system incorporating such software without first obtaining any 101 * required license or other approval from the U. S. Department of Commerce or 102 * any other agency or department of the United States Government. In the 103 * event Licensee exports any such software from the United States or 104 * re-exports any such software from a foreign destination, Licensee shall 105 * ensure that the distribution and export/re-export of the software is in 106 * compliance with all laws, regulations, orders, or other restrictions of the 107 * U.S. Export Administration Regulations. Licensee agrees that neither it nor 108 * any of its subsidiaries will export/re-export any technical data, process, 109 * software, or service, directly or indirectly, to any country for which the 110 * United States government or any agency thereof requires an export license, 111 * other governmental approval, or letter of assurance, without first obtaining 112 * such license, approval or letter. 113 * 114 ***************************************************************************** 115 * 116 * Alternatively, you may choose to be licensed under the terms of the 117 * following license: 118 * 119 * Redistribution and use in source and binary forms, with or without 120 * modification, are permitted provided that the following conditions 121 * are met: 122 * 1. Redistributions of source code must retain the above copyright 123 * notice, this list of conditions, and the following disclaimer, 124 * without modification. 125 * 2. Redistributions in binary form must reproduce at minimum a disclaimer 126 * substantially similar to the "NO WARRANTY" disclaimer below 127 * ("Disclaimer") and any redistribution must be conditioned upon 128 * including a substantially similar Disclaimer requirement for further 129 * binary redistribution. 130 * 3. Neither the names of the above-listed copyright holders nor the names 131 * of any contributors may be used to endorse or promote products derived 132 * from this software without specific prior written permission. 133 * 134 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 135 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 136 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 137 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 138 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 139 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 140 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 141 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 142 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 143 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 144 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 145 * 146 * Alternatively, you may choose to be licensed under the terms of the 147 * GNU General Public License ("GPL") version 2 as published by the Free 148 * Software Foundation. 149 * 150 *****************************************************************************/ 151 152 #include <contrib/dev/acpica/include/acpi.h> 153 #include <contrib/dev/acpica/include/accommon.h> 154 #include <contrib/dev/acpica/include/acparser.h> 155 #include <contrib/dev/acpica/include/amlcode.h> 156 #include <contrib/dev/acpica/include/acdispat.h> 157 #include <contrib/dev/acpica/include/acinterp.h> 158 #include <contrib/dev/acpica/include/acnamesp.h> 159 #include <contrib/dev/acpica/include/acevents.h> 160 #include <contrib/dev/acpica/include/actables.h> 161 162 #define _COMPONENT ACPI_DISPATCHER 163 ACPI_MODULE_NAME ("dsopcode") 164 165 /* Local prototypes */ 166 167 static ACPI_STATUS 168 AcpiDsInitBufferField ( 169 UINT16 AmlOpcode, 170 ACPI_OPERAND_OBJECT *ObjDesc, 171 ACPI_OPERAND_OBJECT *BufferDesc, 172 ACPI_OPERAND_OBJECT *OffsetDesc, 173 ACPI_OPERAND_OBJECT *LengthDesc, 174 ACPI_OPERAND_OBJECT *ResultDesc); 175 176 177 /******************************************************************************* 178 * 179 * FUNCTION: AcpiDsInitializeRegion 180 * 181 * PARAMETERS: ObjHandle - Region namespace node 182 * 183 * RETURN: Status 184 * 185 * DESCRIPTION: Front end to EvInitializeRegion 186 * 187 ******************************************************************************/ 188 189 ACPI_STATUS 190 AcpiDsInitializeRegion ( 191 ACPI_HANDLE ObjHandle) 192 { 193 ACPI_OPERAND_OBJECT *ObjDesc; 194 ACPI_STATUS Status; 195 196 197 ObjDesc = AcpiNsGetAttachedObject (ObjHandle); 198 199 /* Namespace is NOT locked */ 200 201 Status = AcpiEvInitializeRegion (ObjDesc); 202 return (Status); 203 } 204 205 206 /******************************************************************************* 207 * 208 * FUNCTION: AcpiDsInitBufferField 209 * 210 * PARAMETERS: AmlOpcode - CreateXxxField 211 * ObjDesc - BufferField object 212 * BufferDesc - Host Buffer 213 * OffsetDesc - Offset into buffer 214 * LengthDesc - Length of field (CREATE_FIELD_OP only) 215 * ResultDesc - Where to store the result 216 * 217 * RETURN: Status 218 * 219 * DESCRIPTION: Perform actual initialization of a buffer field 220 * 221 ******************************************************************************/ 222 223 static ACPI_STATUS 224 AcpiDsInitBufferField ( 225 UINT16 AmlOpcode, 226 ACPI_OPERAND_OBJECT *ObjDesc, 227 ACPI_OPERAND_OBJECT *BufferDesc, 228 ACPI_OPERAND_OBJECT *OffsetDesc, 229 ACPI_OPERAND_OBJECT *LengthDesc, 230 ACPI_OPERAND_OBJECT *ResultDesc) 231 { 232 UINT32 Offset; 233 UINT32 BitOffset; 234 UINT32 BitCount; 235 UINT8 FieldFlags; 236 ACPI_STATUS Status; 237 238 239 ACPI_FUNCTION_TRACE_PTR (DsInitBufferField, ObjDesc); 240 241 242 /* Host object must be a Buffer */ 243 244 if (BufferDesc->Common.Type != ACPI_TYPE_BUFFER) 245 { 246 ACPI_ERROR ((AE_INFO, 247 "Target of Create Field is not a Buffer object - %s", 248 AcpiUtGetObjectTypeName (BufferDesc))); 249 250 Status = AE_AML_OPERAND_TYPE; 251 goto Cleanup; 252 } 253 254 /* 255 * The last parameter to all of these opcodes (ResultDesc) started 256 * out as a NameString, and should therefore now be a NS node 257 * after resolution in AcpiExResolveOperands(). 258 */ 259 if (ACPI_GET_DESCRIPTOR_TYPE (ResultDesc) != ACPI_DESC_TYPE_NAMED) 260 { 261 ACPI_ERROR ((AE_INFO, 262 "(%s) destination not a NS Node [%s]", 263 AcpiPsGetOpcodeName (AmlOpcode), 264 AcpiUtGetDescriptorName (ResultDesc))); 265 266 Status = AE_AML_OPERAND_TYPE; 267 goto Cleanup; 268 } 269 270 Offset = (UINT32) OffsetDesc->Integer.Value; 271 272 /* 273 * Setup the Bit offsets and counts, according to the opcode 274 */ 275 switch (AmlOpcode) 276 { 277 case AML_CREATE_FIELD_OP: 278 279 /* Offset is in bits, count is in bits */ 280 281 FieldFlags = AML_FIELD_ACCESS_BYTE; 282 BitOffset = Offset; 283 BitCount = (UINT32) LengthDesc->Integer.Value; 284 285 /* Must have a valid (>0) bit count */ 286 287 if (BitCount == 0) 288 { 289 ACPI_BIOS_ERROR ((AE_INFO, 290 "Attempt to CreateField of length zero")); 291 Status = AE_AML_OPERAND_VALUE; 292 goto Cleanup; 293 } 294 break; 295 296 case AML_CREATE_BIT_FIELD_OP: 297 298 /* Offset is in bits, Field is one bit */ 299 300 BitOffset = Offset; 301 BitCount = 1; 302 FieldFlags = AML_FIELD_ACCESS_BYTE; 303 break; 304 305 case AML_CREATE_BYTE_FIELD_OP: 306 307 /* Offset is in bytes, field is one byte */ 308 309 BitOffset = 8 * Offset; 310 BitCount = 8; 311 FieldFlags = AML_FIELD_ACCESS_BYTE; 312 break; 313 314 case AML_CREATE_WORD_FIELD_OP: 315 316 /* Offset is in bytes, field is one word */ 317 318 BitOffset = 8 * Offset; 319 BitCount = 16; 320 FieldFlags = AML_FIELD_ACCESS_WORD; 321 break; 322 323 case AML_CREATE_DWORD_FIELD_OP: 324 325 /* Offset is in bytes, field is one dword */ 326 327 BitOffset = 8 * Offset; 328 BitCount = 32; 329 FieldFlags = AML_FIELD_ACCESS_DWORD; 330 break; 331 332 case AML_CREATE_QWORD_FIELD_OP: 333 334 /* Offset is in bytes, field is one qword */ 335 336 BitOffset = 8 * Offset; 337 BitCount = 64; 338 FieldFlags = AML_FIELD_ACCESS_QWORD; 339 break; 340 341 default: 342 343 ACPI_ERROR ((AE_INFO, 344 "Unknown field creation opcode 0x%02X", 345 AmlOpcode)); 346 Status = AE_AML_BAD_OPCODE; 347 goto Cleanup; 348 } 349 350 /* Entire field must fit within the current length of the buffer */ 351 352 if ((BitOffset + BitCount) > 353 (8 * (UINT32) BufferDesc->Buffer.Length)) 354 { 355 Status = AE_AML_BUFFER_LIMIT; 356 ACPI_BIOS_EXCEPTION ((AE_INFO, Status, 357 "Field [%4.4s] at bit offset/length %u/%u " 358 "exceeds size of target Buffer (%u bits)", 359 AcpiUtGetNodeName (ResultDesc), BitOffset, BitCount, 360 8 * (UINT32) BufferDesc->Buffer.Length)); 361 goto Cleanup; 362 } 363 364 /* 365 * Initialize areas of the field object that are common to all fields 366 * For FieldFlags, use LOCK_RULE = 0 (NO_LOCK), 367 * UPDATE_RULE = 0 (UPDATE_PRESERVE) 368 */ 369 Status = AcpiExPrepCommonFieldObject ( 370 ObjDesc, FieldFlags, 0, BitOffset, BitCount); 371 if (ACPI_FAILURE (Status)) 372 { 373 goto Cleanup; 374 } 375 376 ObjDesc->BufferField.BufferObj = BufferDesc; 377 378 /* Reference count for BufferDesc inherits ObjDesc count */ 379 380 BufferDesc->Common.ReferenceCount = (UINT16) 381 (BufferDesc->Common.ReferenceCount + ObjDesc->Common.ReferenceCount); 382 383 384 Cleanup: 385 386 /* Always delete the operands */ 387 388 AcpiUtRemoveReference (OffsetDesc); 389 AcpiUtRemoveReference (BufferDesc); 390 391 if (AmlOpcode == AML_CREATE_FIELD_OP) 392 { 393 AcpiUtRemoveReference (LengthDesc); 394 } 395 396 /* On failure, delete the result descriptor */ 397 398 if (ACPI_FAILURE (Status)) 399 { 400 AcpiUtRemoveReference (ResultDesc); /* Result descriptor */ 401 } 402 else 403 { 404 /* Now the address and length are valid for this BufferField */ 405 406 ObjDesc->BufferField.Flags |= AOPOBJ_DATA_VALID; 407 } 408 409 return_ACPI_STATUS (Status); 410 } 411 412 413 /******************************************************************************* 414 * 415 * FUNCTION: AcpiDsEvalBufferFieldOperands 416 * 417 * PARAMETERS: WalkState - Current walk 418 * Op - A valid BufferField Op object 419 * 420 * RETURN: Status 421 * 422 * DESCRIPTION: Get BufferField Buffer and Index 423 * Called from AcpiDsExecEndOp during BufferField parse tree walk 424 * 425 ******************************************************************************/ 426 427 ACPI_STATUS 428 AcpiDsEvalBufferFieldOperands ( 429 ACPI_WALK_STATE *WalkState, 430 ACPI_PARSE_OBJECT *Op) 431 { 432 ACPI_STATUS Status; 433 ACPI_OPERAND_OBJECT *ObjDesc; 434 ACPI_NAMESPACE_NODE *Node; 435 ACPI_PARSE_OBJECT *NextOp; 436 437 438 ACPI_FUNCTION_TRACE_PTR (DsEvalBufferFieldOperands, Op); 439 440 441 /* 442 * This is where we evaluate the address and length fields of the 443 * CreateXxxField declaration 444 */ 445 Node = Op->Common.Node; 446 447 /* NextOp points to the op that holds the Buffer */ 448 449 NextOp = Op->Common.Value.Arg; 450 451 /* Evaluate/create the address and length operands */ 452 453 Status = AcpiDsCreateOperands (WalkState, NextOp); 454 if (ACPI_FAILURE (Status)) 455 { 456 return_ACPI_STATUS (Status); 457 } 458 459 ObjDesc = AcpiNsGetAttachedObject (Node); 460 if (!ObjDesc) 461 { 462 return_ACPI_STATUS (AE_NOT_EXIST); 463 } 464 465 /* Resolve the operands */ 466 467 Status = AcpiExResolveOperands ( 468 Op->Common.AmlOpcode, ACPI_WALK_OPERANDS, WalkState); 469 if (ACPI_FAILURE (Status)) 470 { 471 ACPI_ERROR ((AE_INFO, "(%s) bad operand(s), status 0x%X", 472 AcpiPsGetOpcodeName (Op->Common.AmlOpcode), Status)); 473 474 return_ACPI_STATUS (Status); 475 } 476 477 /* Initialize the Buffer Field */ 478 479 if (Op->Common.AmlOpcode == AML_CREATE_FIELD_OP) 480 { 481 /* NOTE: Slightly different operands for this opcode */ 482 483 Status = AcpiDsInitBufferField (Op->Common.AmlOpcode, ObjDesc, 484 WalkState->Operands[0], WalkState->Operands[1], 485 WalkState->Operands[2], WalkState->Operands[3]); 486 } 487 else 488 { 489 /* All other, CreateXxxField opcodes */ 490 491 Status = AcpiDsInitBufferField (Op->Common.AmlOpcode, ObjDesc, 492 WalkState->Operands[0], WalkState->Operands[1], 493 NULL, WalkState->Operands[2]); 494 } 495 496 return_ACPI_STATUS (Status); 497 } 498 499 500 /******************************************************************************* 501 * 502 * FUNCTION: AcpiDsEvalRegionOperands 503 * 504 * PARAMETERS: WalkState - Current walk 505 * Op - A valid region Op object 506 * 507 * RETURN: Status 508 * 509 * DESCRIPTION: Get region address and length 510 * Called from AcpiDsExecEndOp during OpRegion parse tree walk 511 * 512 ******************************************************************************/ 513 514 ACPI_STATUS 515 AcpiDsEvalRegionOperands ( 516 ACPI_WALK_STATE *WalkState, 517 ACPI_PARSE_OBJECT *Op) 518 { 519 ACPI_STATUS Status; 520 ACPI_OPERAND_OBJECT *ObjDesc; 521 ACPI_OPERAND_OBJECT *OperandDesc; 522 ACPI_NAMESPACE_NODE *Node; 523 ACPI_PARSE_OBJECT *NextOp; 524 ACPI_ADR_SPACE_TYPE SpaceId; 525 526 527 ACPI_FUNCTION_TRACE_PTR (DsEvalRegionOperands, Op); 528 529 530 /* 531 * This is where we evaluate the address and length fields of the 532 * OpRegion declaration 533 */ 534 Node = Op->Common.Node; 535 536 /* NextOp points to the op that holds the SpaceID */ 537 538 NextOp = Op->Common.Value.Arg; 539 SpaceId = (ACPI_ADR_SPACE_TYPE) NextOp->Common.Value.Integer; 540 541 /* NextOp points to address op */ 542 543 NextOp = NextOp->Common.Next; 544 545 /* Evaluate/create the address and length operands */ 546 547 Status = AcpiDsCreateOperands (WalkState, NextOp); 548 if (ACPI_FAILURE (Status)) 549 { 550 return_ACPI_STATUS (Status); 551 } 552 553 /* Resolve the length and address operands to numbers */ 554 555 Status = AcpiExResolveOperands ( 556 Op->Common.AmlOpcode, ACPI_WALK_OPERANDS, WalkState); 557 if (ACPI_FAILURE (Status)) 558 { 559 return_ACPI_STATUS (Status); 560 } 561 562 ObjDesc = AcpiNsGetAttachedObject (Node); 563 if (!ObjDesc) 564 { 565 return_ACPI_STATUS (AE_NOT_EXIST); 566 } 567 568 /* 569 * Get the length operand and save it 570 * (at Top of stack) 571 */ 572 OperandDesc = WalkState->Operands[WalkState->NumOperands - 1]; 573 574 ObjDesc->Region.Length = (UINT32) OperandDesc->Integer.Value; 575 AcpiUtRemoveReference (OperandDesc); 576 577 /* A zero-length operation region is unusable. Just warn */ 578 579 if (!ObjDesc->Region.Length && (SpaceId < ACPI_NUM_PREDEFINED_REGIONS)) 580 { 581 ACPI_WARNING ((AE_INFO, 582 "Operation Region [%4.4s] has zero length (SpaceId %X)", 583 Node->Name.Ascii, SpaceId)); 584 } 585 586 /* 587 * Get the address and save it 588 * (at top of stack - 1) 589 */ 590 OperandDesc = WalkState->Operands[WalkState->NumOperands - 2]; 591 592 ObjDesc->Region.Address = (ACPI_PHYSICAL_ADDRESS) 593 OperandDesc->Integer.Value; 594 AcpiUtRemoveReference (OperandDesc); 595 596 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "RgnObj %p Addr %8.8X%8.8X Len %X\n", 597 ObjDesc, ACPI_FORMAT_UINT64 (ObjDesc->Region.Address), 598 ObjDesc->Region.Length)); 599 600 Status = AcpiUtAddAddressRange (ObjDesc->Region.SpaceId, 601 ObjDesc->Region.Address, ObjDesc->Region.Length, Node); 602 603 /* Now the address and length are valid for this opregion */ 604 605 ObjDesc->Region.Flags |= AOPOBJ_DATA_VALID; 606 return_ACPI_STATUS (Status); 607 } 608 609 610 /******************************************************************************* 611 * 612 * FUNCTION: AcpiDsEvalTableRegionOperands 613 * 614 * PARAMETERS: WalkState - Current walk 615 * Op - A valid region Op object 616 * 617 * RETURN: Status 618 * 619 * DESCRIPTION: Get region address and length. 620 * Called from AcpiDsExecEndOp during DataTableRegion parse 621 * tree walk. 622 * 623 ******************************************************************************/ 624 625 ACPI_STATUS 626 AcpiDsEvalTableRegionOperands ( 627 ACPI_WALK_STATE *WalkState, 628 ACPI_PARSE_OBJECT *Op) 629 { 630 ACPI_STATUS Status; 631 ACPI_OPERAND_OBJECT *ObjDesc; 632 ACPI_OPERAND_OBJECT **Operand; 633 ACPI_NAMESPACE_NODE *Node; 634 ACPI_PARSE_OBJECT *NextOp; 635 ACPI_TABLE_HEADER *Table; 636 UINT32 TableIndex; 637 638 639 ACPI_FUNCTION_TRACE_PTR (DsEvalTableRegionOperands, Op); 640 641 642 /* 643 * This is where we evaluate the Signature string, OemId string, 644 * and OemTableId string of the Data Table Region declaration 645 */ 646 Node = Op->Common.Node; 647 648 /* NextOp points to Signature string op */ 649 650 NextOp = Op->Common.Value.Arg; 651 652 /* 653 * Evaluate/create the Signature string, OemId string, 654 * and OemTableId string operands 655 */ 656 Status = AcpiDsCreateOperands (WalkState, NextOp); 657 if (ACPI_FAILURE (Status)) 658 { 659 return_ACPI_STATUS (Status); 660 } 661 662 Operand = &WalkState->Operands[0]; 663 664 /* 665 * Resolve the Signature string, OemId string, 666 * and OemTableId string operands 667 */ 668 Status = AcpiExResolveOperands ( 669 Op->Common.AmlOpcode, ACPI_WALK_OPERANDS, WalkState); 670 if (ACPI_FAILURE (Status)) 671 { 672 goto Cleanup; 673 } 674 675 /* Find the ACPI table */ 676 677 Status = AcpiTbFindTable ( 678 Operand[0]->String.Pointer, 679 Operand[1]->String.Pointer, 680 Operand[2]->String.Pointer, &TableIndex); 681 if (ACPI_FAILURE (Status)) 682 { 683 if (Status == AE_NOT_FOUND) 684 { 685 ACPI_ERROR ((AE_INFO, 686 "ACPI Table [%4.4s] OEM:(%s, %s) not found in RSDT/XSDT", 687 Operand[0]->String.Pointer, 688 Operand[1]->String.Pointer, 689 Operand[2]->String.Pointer)); 690 } 691 goto Cleanup; 692 } 693 694 Status = AcpiGetTableByIndex (TableIndex, &Table); 695 if (ACPI_FAILURE (Status)) 696 { 697 goto Cleanup; 698 } 699 700 ObjDesc = AcpiNsGetAttachedObject (Node); 701 if (!ObjDesc) 702 { 703 Status = AE_NOT_EXIST; 704 goto Cleanup; 705 } 706 707 ObjDesc->Region.Address = ACPI_PTR_TO_PHYSADDR (Table); 708 ObjDesc->Region.Length = Table->Length; 709 710 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "RgnObj %p Addr %8.8X%8.8X Len %X\n", 711 ObjDesc, ACPI_FORMAT_UINT64 (ObjDesc->Region.Address), 712 ObjDesc->Region.Length)); 713 714 /* Now the address and length are valid for this opregion */ 715 716 ObjDesc->Region.Flags |= AOPOBJ_DATA_VALID; 717 718 Cleanup: 719 AcpiUtRemoveReference (Operand[0]); 720 AcpiUtRemoveReference (Operand[1]); 721 AcpiUtRemoveReference (Operand[2]); 722 723 return_ACPI_STATUS (Status); 724 } 725 726 727 /******************************************************************************* 728 * 729 * FUNCTION: AcpiDsEvalDataObjectOperands 730 * 731 * PARAMETERS: WalkState - Current walk 732 * Op - A valid DataObject Op object 733 * ObjDesc - DataObject 734 * 735 * RETURN: Status 736 * 737 * DESCRIPTION: Get the operands and complete the following data object types: 738 * Buffer, Package. 739 * 740 ******************************************************************************/ 741 742 ACPI_STATUS 743 AcpiDsEvalDataObjectOperands ( 744 ACPI_WALK_STATE *WalkState, 745 ACPI_PARSE_OBJECT *Op, 746 ACPI_OPERAND_OBJECT *ObjDesc) 747 { 748 ACPI_STATUS Status; 749 ACPI_OPERAND_OBJECT *ArgDesc; 750 UINT32 Length; 751 752 753 ACPI_FUNCTION_TRACE (DsEvalDataObjectOperands); 754 755 756 /* The first operand (for all of these data objects) is the length */ 757 758 /* 759 * Set proper index into operand stack for AcpiDsObjStackPush 760 * invoked inside AcpiDsCreateOperand. 761 */ 762 WalkState->OperandIndex = WalkState->NumOperands; 763 764 /* Ignore if child is not valid */ 765 766 if (!Op->Common.Value.Arg) 767 { 768 ACPI_ERROR ((AE_INFO, 769 "Missing child while evaluating opcode %4.4X, Op %p", 770 Op->Common.AmlOpcode, Op)); 771 return_ACPI_STATUS (AE_OK); 772 } 773 774 Status = AcpiDsCreateOperand (WalkState, Op->Common.Value.Arg, 1); 775 if (ACPI_FAILURE (Status)) 776 { 777 return_ACPI_STATUS (Status); 778 } 779 780 Status = AcpiExResolveOperands (WalkState->Opcode, 781 &(WalkState->Operands [WalkState->NumOperands -1]), 782 WalkState); 783 if (ACPI_FAILURE (Status)) 784 { 785 return_ACPI_STATUS (Status); 786 } 787 788 /* Extract length operand */ 789 790 ArgDesc = WalkState->Operands [WalkState->NumOperands - 1]; 791 Length = (UINT32) ArgDesc->Integer.Value; 792 793 /* Cleanup for length operand */ 794 795 Status = AcpiDsObjStackPop (1, WalkState); 796 if (ACPI_FAILURE (Status)) 797 { 798 return_ACPI_STATUS (Status); 799 } 800 801 AcpiUtRemoveReference (ArgDesc); 802 803 /* 804 * Create the actual data object 805 */ 806 switch (Op->Common.AmlOpcode) 807 { 808 case AML_BUFFER_OP: 809 810 Status = AcpiDsBuildInternalBufferObj ( 811 WalkState, Op, Length, &ObjDesc); 812 break; 813 814 case AML_PACKAGE_OP: 815 case AML_VARIABLE_PACKAGE_OP: 816 817 Status = AcpiDsBuildInternalPackageObj ( 818 WalkState, Op, Length, &ObjDesc); 819 break; 820 821 default: 822 823 return_ACPI_STATUS (AE_AML_BAD_OPCODE); 824 } 825 826 if (ACPI_SUCCESS (Status)) 827 { 828 /* 829 * Return the object in the WalkState, unless the parent is a package - 830 * in this case, the return object will be stored in the parse tree 831 * for the package. 832 */ 833 if ((!Op->Common.Parent) || 834 ((Op->Common.Parent->Common.AmlOpcode != AML_PACKAGE_OP) && 835 (Op->Common.Parent->Common.AmlOpcode != AML_VARIABLE_PACKAGE_OP) && 836 (Op->Common.Parent->Common.AmlOpcode != AML_NAME_OP))) 837 { 838 WalkState->ResultObj = ObjDesc; 839 } 840 } 841 842 return_ACPI_STATUS (Status); 843 } 844 845 846 /******************************************************************************* 847 * 848 * FUNCTION: AcpiDsEvalBankFieldOperands 849 * 850 * PARAMETERS: WalkState - Current walk 851 * Op - A valid BankField Op object 852 * 853 * RETURN: Status 854 * 855 * DESCRIPTION: Get BankField BankValue 856 * Called from AcpiDsExecEndOp during BankField parse tree walk 857 * 858 ******************************************************************************/ 859 860 ACPI_STATUS 861 AcpiDsEvalBankFieldOperands ( 862 ACPI_WALK_STATE *WalkState, 863 ACPI_PARSE_OBJECT *Op) 864 { 865 ACPI_STATUS Status; 866 ACPI_OPERAND_OBJECT *ObjDesc; 867 ACPI_OPERAND_OBJECT *OperandDesc; 868 ACPI_NAMESPACE_NODE *Node; 869 ACPI_PARSE_OBJECT *NextOp; 870 ACPI_PARSE_OBJECT *Arg; 871 872 873 ACPI_FUNCTION_TRACE_PTR (DsEvalBankFieldOperands, Op); 874 875 876 /* 877 * This is where we evaluate the BankValue field of the 878 * BankField declaration 879 */ 880 881 /* NextOp points to the op that holds the Region */ 882 883 NextOp = Op->Common.Value.Arg; 884 885 /* NextOp points to the op that holds the Bank Register */ 886 887 NextOp = NextOp->Common.Next; 888 889 /* NextOp points to the op that holds the Bank Value */ 890 891 NextOp = NextOp->Common.Next; 892 893 /* 894 * Set proper index into operand stack for AcpiDsObjStackPush 895 * invoked inside AcpiDsCreateOperand. 896 * 897 * We use WalkState->Operands[0] to store the evaluated BankValue 898 */ 899 WalkState->OperandIndex = 0; 900 901 Status = AcpiDsCreateOperand (WalkState, NextOp, 0); 902 if (ACPI_FAILURE (Status)) 903 { 904 return_ACPI_STATUS (Status); 905 } 906 907 Status = AcpiExResolveToValue (&WalkState->Operands[0], WalkState); 908 if (ACPI_FAILURE (Status)) 909 { 910 return_ACPI_STATUS (Status); 911 } 912 913 ACPI_DUMP_OPERANDS (ACPI_WALK_OPERANDS, 914 AcpiPsGetOpcodeName (Op->Common.AmlOpcode), 1); 915 /* 916 * Get the BankValue operand and save it 917 * (at Top of stack) 918 */ 919 OperandDesc = WalkState->Operands[0]; 920 921 /* Arg points to the start Bank Field */ 922 923 Arg = AcpiPsGetArg (Op, 4); 924 while (Arg) 925 { 926 /* Ignore OFFSET and ACCESSAS terms here */ 927 928 if (Arg->Common.AmlOpcode == AML_INT_NAMEDFIELD_OP) 929 { 930 Node = Arg->Common.Node; 931 932 ObjDesc = AcpiNsGetAttachedObject (Node); 933 if (!ObjDesc) 934 { 935 return_ACPI_STATUS (AE_NOT_EXIST); 936 } 937 938 ObjDesc->BankField.Value = (UINT32) OperandDesc->Integer.Value; 939 } 940 941 /* Move to next field in the list */ 942 943 Arg = Arg->Common.Next; 944 } 945 946 AcpiUtRemoveReference (OperandDesc); 947 return_ACPI_STATUS (Status); 948 } 949