dswload.c revision 87031
1/****************************************************************************** 2 * 3 * Module Name: dswload - Dispatcher namespace load callbacks 4 * $Revision: 54 $ 5 * 6 *****************************************************************************/ 7 8/****************************************************************************** 9 * 10 * 1. Copyright Notice 11 * 12 * Some or all of this work - Copyright (c) 1999, 2000, 2001, Intel Corp. 13 * All rights reserved. 14 * 15 * 2. License 16 * 17 * 2.1. This is your license from Intel Corp. under its intellectual property 18 * rights. You may have additional license terms from the party that provided 19 * you this software, covering your right to use that party's intellectual 20 * property rights. 21 * 22 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a 23 * copy of the source code appearing in this file ("Covered Code") an 24 * irrevocable, perpetual, worldwide license under Intel's copyrights in the 25 * base code distributed originally by Intel ("Original Intel Code") to copy, 26 * make derivatives, distribute, use and display any portion of the Covered 27 * Code in any form, with the right to sublicense such rights; and 28 * 29 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent 30 * license (with the right to sublicense), under only those claims of Intel 31 * patents that are infringed by the Original Intel Code, to make, use, sell, 32 * offer to sell, and import the Covered Code and derivative works thereof 33 * solely to the minimum extent necessary to exercise the above copyright 34 * license, and in no event shall the patent license extend to any additions 35 * to or modifications of the Original Intel Code. No other license or right 36 * is granted directly or by implication, estoppel or otherwise; 37 * 38 * The above copyright and patent license is granted only if the following 39 * conditions are met: 40 * 41 * 3. Conditions 42 * 43 * 3.1. Redistribution of Source with Rights to Further Distribute Source. 44 * Redistribution of source code of any substantial portion of the Covered 45 * Code or modification with rights to further distribute source must include 46 * the above Copyright Notice, the above License, this list of Conditions, 47 * and the following Disclaimer and Export Compliance provision. In addition, 48 * Licensee must cause all Covered Code to which Licensee contributes to 49 * contain a file documenting the changes Licensee made to create that Covered 50 * Code and the date of any change. Licensee must include in that file the 51 * documentation of any changes made by any predecessor Licensee. Licensee 52 * must include a prominent statement that the modification is derived, 53 * directly or indirectly, from Original Intel Code. 54 * 55 * 3.2. Redistribution of Source with no Rights to Further Distribute Source. 56 * Redistribution of source code of any substantial portion of the Covered 57 * Code or modification without rights to further distribute source must 58 * include the following Disclaimer and Export Compliance provision in the 59 * documentation and/or other materials provided with distribution. In 60 * addition, Licensee may not authorize further sublicense of source of any 61 * portion of the Covered Code, and must include terms to the effect that the 62 * license from Licensee to its licensee is limited to the intellectual 63 * property embodied in the software Licensee provides to its licensee, and 64 * not to intellectual property embodied in modifications its licensee may 65 * make. 66 * 67 * 3.3. Redistribution of Executable. Redistribution in executable form of any 68 * substantial portion of the Covered Code or modification must reproduce the 69 * above Copyright Notice, and the following Disclaimer and Export Compliance 70 * provision in the documentation and/or other materials provided with the 71 * distribution. 72 * 73 * 3.4. Intel retains all right, title, and interest in and to the Original 74 * Intel Code. 75 * 76 * 3.5. Neither the name Intel nor any other trademark owned or controlled by 77 * Intel shall be used in advertising or otherwise to promote the sale, use or 78 * other dealings in products derived from or relating to the Covered Code 79 * without prior written authorization from Intel. 80 * 81 * 4. Disclaimer and Export Compliance 82 * 83 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED 84 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE 85 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, 86 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY 87 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY 88 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A 89 * PARTICULAR PURPOSE. 90 * 91 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES 92 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR 93 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, 94 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY 95 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL 96 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS 97 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY 98 * LIMITED REMEDY. 99 * 100 * 4.3. Licensee shall not export, either directly or indirectly, any of this 101 * software or system incorporating such software without first obtaining any 102 * required license or other approval from the U. S. Department of Commerce or 103 * any other agency or department of the United States Government. In the 104 * event Licensee exports any such software from the United States or 105 * re-exports any such software from a foreign destination, Licensee shall 106 * ensure that the distribution and export/re-export of the software is in 107 * compliance with all laws, regulations, orders, or other restrictions of the 108 * U.S. Export Administration Regulations. Licensee agrees that neither it nor 109 * any of its subsidiaries will export/re-export any technical data, process, 110 * software, or service, directly or indirectly, to any country for which the 111 * United States government or any agency thereof requires an export license, 112 * other governmental approval, or letter of assurance, without first obtaining 113 * such license, approval or letter. 114 * 115 *****************************************************************************/ 116 117#define __DSWLOAD_C__ 118 119#include "acpi.h" 120#include "acparser.h" 121#include "amlcode.h" 122#include "acdispat.h" 123#include "acinterp.h" 124#include "acnamesp.h" 125#include "acevents.h" 126 127 128#define _COMPONENT ACPI_DISPATCHER 129 MODULE_NAME ("dswload") 130 131 132/******************************************************************************* 133 * 134 * FUNCTION: AcpiDsInitCallbacks 135 * 136 * PARAMETERS: WalkState - Current state of the parse tree walk 137 * PassNumber - 1, 2, or 3 138 * 139 * RETURN: Status 140 * 141 * DESCRIPTION: Init walk state callbacks 142 * 143 ******************************************************************************/ 144 145ACPI_STATUS 146AcpiDsInitCallbacks ( 147 ACPI_WALK_STATE *WalkState, 148 UINT32 PassNumber) 149{ 150 151 switch (PassNumber) 152 { 153 case 1: 154 WalkState->ParseFlags = ACPI_PARSE_LOAD_PASS1 | ACPI_PARSE_DELETE_TREE; 155 WalkState->DescendingCallback = AcpiDsLoad1BeginOp; 156 WalkState->AscendingCallback = AcpiDsLoad1EndOp; 157 break; 158 159 case 2: 160 WalkState->ParseFlags = ACPI_PARSE_LOAD_PASS1 | ACPI_PARSE_DELETE_TREE; 161 WalkState->DescendingCallback = AcpiDsLoad2BeginOp; 162 WalkState->AscendingCallback = AcpiDsLoad2EndOp; 163 break; 164 165 case 3: 166 WalkState->ParseFlags |= ACPI_PARSE_EXECUTE | ACPI_PARSE_DELETE_TREE; 167 WalkState->DescendingCallback = AcpiDsExecBeginOp; 168 WalkState->AscendingCallback = AcpiDsExecEndOp; 169 break; 170 171 default: 172 return (AE_BAD_PARAMETER); 173 break; 174 } 175 176 return (AE_OK); 177} 178 179 180/******************************************************************************* 181 * 182 * FUNCTION: AcpiDsLoad1BeginOp 183 * 184 * PARAMETERS: WalkState - Current state of the parse tree walk 185 * Op - Op that has been just been reached in the 186 * walk; Arguments have not been evaluated yet. 187 * 188 * RETURN: Status 189 * 190 * DESCRIPTION: Descending callback used during the loading of ACPI tables. 191 * 192 ******************************************************************************/ 193 194ACPI_STATUS 195AcpiDsLoad1BeginOp ( 196 ACPI_WALK_STATE *WalkState, 197 ACPI_PARSE_OBJECT **OutOp) 198{ 199 ACPI_PARSE_OBJECT *Op; 200 ACPI_NAMESPACE_NODE *Node; 201 ACPI_STATUS Status; 202 ACPI_OBJECT_TYPE8 ObjectType; 203 NATIVE_CHAR *Path; 204 205 206 PROC_NAME ("DsLoad1BeginOp"); 207 208 Op = WalkState->Op; 209 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Op=%p State=%p\n", Op, WalkState)); 210 211 212 if (Op && (Op->Opcode == AML_INT_NAMEDFIELD_OP)) 213 { 214 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Op=%p State=%p\n", Op, WalkState)); 215 } 216 217 /* We are only interested in opcodes that have an associated name */ 218 219 if (WalkState->Op) 220 { 221 if (!(WalkState->OpInfo->Flags & AML_NAMED)) 222 { 223 *OutOp = Op; 224 return (AE_OK); 225 } 226 227 /* Check if this object has already been installed in the namespace */ 228 229 if (Op->Node) 230 { 231 *OutOp = Op; 232 return (AE_OK); 233 } 234 } 235 236 Path = AcpiPsGetNextNamestring (&WalkState->ParserState); 237 238 /* Map the raw opcode into an internal object type */ 239 240 ObjectType = WalkState->OpInfo->ObjectType; 241 242 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, 243 "State=%p Op=%p Type=%x\n", WalkState, Op, ObjectType)); 244 245 /* 246 * Enter the named type into the internal namespace. We enter the name 247 * as we go downward in the parse tree. Any necessary subobjects that involve 248 * arguments to the opcode must be created as we go back up the parse tree later. 249 */ 250 Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ObjectType, 251 IMODE_LOAD_PASS1, NS_NO_UPSEARCH, WalkState, &(Node)); 252 253 if (ACPI_FAILURE (Status)) 254 { 255 return (Status); 256 } 257 258 if (!Op) 259 { 260 /* Create a new op */ 261 262 Op = AcpiPsAllocOp (WalkState->Opcode); 263 if (!Op) 264 { 265 return (AE_NO_MEMORY); 266 } 267 } 268 269 /* Initialize */ 270 271 ((ACPI_PARSE2_OBJECT *)Op)->Name = Node->Name; 272 273 /* 274 * Put the Node in the "op" object that the parser uses, so we 275 * can get it again quickly when this scope is closed 276 */ 277 Op->Node = Node; 278 AcpiPsAppendArg (AcpiPsGetParentScope (&WalkState->ParserState), Op); 279 280 *OutOp = Op; 281 return (Status); 282} 283 284 285/******************************************************************************* 286 * 287 * FUNCTION: AcpiDsLoad1EndOp 288 * 289 * PARAMETERS: WalkState - Current state of the parse tree walk 290 * Op - Op that has been just been completed in the 291 * walk; Arguments have now been evaluated. 292 * 293 * RETURN: Status 294 * 295 * DESCRIPTION: Ascending callback used during the loading of the namespace, 296 * both control methods and everything else. 297 * 298 ******************************************************************************/ 299 300ACPI_STATUS 301AcpiDsLoad1EndOp ( 302 ACPI_WALK_STATE *WalkState) 303{ 304 ACPI_PARSE_OBJECT *Op; 305 ACPI_OBJECT_TYPE8 ObjectType; 306 307 308 PROC_NAME ("DsLoad1EndOp"); 309 310 Op = WalkState->Op; 311 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Op=%p State=%p\n", Op, WalkState)); 312 313 314 /* We are only interested in opcodes that have an associated name */ 315 316 if (!(WalkState->OpInfo->Flags & (AML_NAMED | AML_FIELD))) 317 { 318 return (AE_OK); 319 } 320 321 /* Get the object type to determine if we should pop the scope */ 322 323 ObjectType = WalkState->OpInfo->ObjectType; 324 325 if (WalkState->OpInfo->Flags & AML_FIELD) 326 { 327 if (WalkState->Opcode == AML_FIELD_OP || 328 WalkState->Opcode == AML_BANK_FIELD_OP || 329 WalkState->Opcode == AML_INDEX_FIELD_OP) 330 { 331 AcpiDsInitFieldObjects (Op, WalkState); 332 } 333 return (AE_OK); 334 } 335 336 337 if (Op->Opcode == AML_REGION_OP) 338 { 339 /*Status = */AcpiExCreateRegion (((ACPI_PARSE2_OBJECT *) Op)->Data, 340 ((ACPI_PARSE2_OBJECT *) Op)->Length, 341 (ACPI_ADR_SPACE_TYPE) ((Op->Value.Arg)->Value.Integer), WalkState); 342 } 343 344 if (Op->Opcode == AML_NAME_OP) 345 { 346 /* For Name opcode, get the object type from the argument */ 347 348 if (Op->Value.Arg) 349 { 350 ObjectType = (AcpiPsGetOpcodeInfo ((Op->Value.Arg)->Opcode))->ObjectType; 351 Op->Node->Type = (UINT8) ObjectType; 352 } 353 } 354 355 /* Pop the scope stack */ 356 357 if (AcpiNsOpensScope (ObjectType)) 358 { 359 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "(%s): Popping scope for Op %p\n", 360 AcpiUtGetTypeName (ObjectType), Op)); 361 362 AcpiDsScopeStackPop (WalkState); 363 } 364 365 return (AE_OK); 366} 367 368 369/******************************************************************************* 370 * 371 * FUNCTION: AcpiDsLoad2BeginOp 372 * 373 * PARAMETERS: WalkState - Current state of the parse tree walk 374 * Op - Op that has been just been reached in the 375 * walk; Arguments have not been evaluated yet. 376 * 377 * RETURN: Status 378 * 379 * DESCRIPTION: Descending callback used during the loading of ACPI tables. 380 * 381 ******************************************************************************/ 382 383ACPI_STATUS 384AcpiDsLoad2BeginOp ( 385 ACPI_WALK_STATE *WalkState, 386 ACPI_PARSE_OBJECT **OutOp) 387{ 388 ACPI_PARSE_OBJECT *Op; 389 ACPI_NAMESPACE_NODE *Node; 390 ACPI_STATUS Status; 391 ACPI_OBJECT_TYPE8 ObjectType; 392 NATIVE_CHAR *BufferPtr; 393 void *Original = NULL; 394 395 396 PROC_NAME ("DsLoad2BeginOp"); 397 398 Op = WalkState->Op; 399 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Op=%p State=%p\n", Op, WalkState)); 400 401 402 if (Op) 403 { 404 /* We only care about Namespace opcodes here */ 405 406 if (!(WalkState->OpInfo->Flags & AML_NSOPCODE) && 407 WalkState->Opcode != AML_INT_NAMEPATH_OP) 408 { 409 return (AE_OK); 410 } 411 412 /* TBD: [Restructure] Temp! same code as in psparse */ 413 414 if (!(WalkState->OpInfo->Flags & AML_NAMED)) 415 { 416 return (AE_OK); 417 } 418 419 /* 420 * Get the name we are going to enter or lookup in the namespace 421 */ 422 if (WalkState->Opcode == AML_INT_NAMEPATH_OP) 423 { 424 /* For Namepath op, get the path string */ 425 426 BufferPtr = Op->Value.String; 427 if (!BufferPtr) 428 { 429 /* No name, just exit */ 430 431 return (AE_OK); 432 } 433 } 434 else 435 { 436 /* Get name from the op */ 437 438 BufferPtr = (NATIVE_CHAR *) &((ACPI_PARSE2_OBJECT *)Op)->Name; 439 } 440 } 441 else 442 { 443 BufferPtr = AcpiPsGetNextNamestring (&WalkState->ParserState); 444 } 445 446 447 /* Map the raw opcode into an internal object type */ 448 449 ObjectType = WalkState->OpInfo->ObjectType; 450 451 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, 452 "State=%p Op=%p Type=%x\n", WalkState, Op, ObjectType)); 453 454 455 if (WalkState->Opcode == AML_FIELD_OP || 456 WalkState->Opcode == AML_BANK_FIELD_OP || 457 WalkState->Opcode == AML_INDEX_FIELD_OP) 458 { 459 Node = NULL; 460 Status = AE_OK; 461 } 462 463 else if (WalkState->Opcode == AML_INT_NAMEPATH_OP) 464 { 465 /* 466 * The NamePath is an object reference to an existing object. Don't enter the 467 * name into the namespace, but look it up for use later 468 */ 469 Status = AcpiNsLookup (WalkState->ScopeInfo, BufferPtr, ObjectType, 470 IMODE_EXECUTE, NS_SEARCH_PARENT, WalkState, &(Node)); 471 } 472 473 else 474 { 475 if (Op && Op->Node) 476 { 477 Original = Op->Node; 478 Node = Op->Node; 479 480 if (AcpiNsOpensScope (ObjectType)) 481 { 482 Status = AcpiDsScopeStackPush (Node, ObjectType, WalkState); 483 if (ACPI_FAILURE (Status)) 484 { 485 return (Status); 486 } 487 488 } 489 return (AE_OK); 490 } 491 492 /* 493 * Enter the named type into the internal namespace. We enter the name 494 * as we go downward in the parse tree. Any necessary subobjects that involve 495 * arguments to the opcode must be created as we go back up the parse tree later. 496 */ 497 Status = AcpiNsLookup (WalkState->ScopeInfo, BufferPtr, ObjectType, 498 IMODE_EXECUTE, NS_NO_UPSEARCH, WalkState, &(Node)); 499 } 500 501 if (ACPI_SUCCESS (Status)) 502 { 503 if (!Op) 504 { 505 /* Create a new op */ 506 507 Op = AcpiPsAllocOp (WalkState->Opcode); 508 if (!Op) 509 { 510 return (AE_NO_MEMORY); 511 } 512 513 /* Initialize */ 514 515 ((ACPI_PARSE2_OBJECT *)Op)->Name = Node->Name; 516 *OutOp = Op; 517 } 518 519 /* 520 * Put the Node in the "op" object that the parser uses, so we 521 * can get it again quickly when this scope is closed 522 */ 523 Op->Node = Node; 524 525 if (Original) 526 { 527 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "old %p new %p\n", Original, Node)); 528 529 if (Original != Node) 530 { 531 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, 532 "Lookup match error: old %p new %p\n", Original, Node)); 533 } 534 } 535 } 536 537 return (Status); 538} 539 540 541/******************************************************************************* 542 * 543 * FUNCTION: AcpiDsLoad2EndOp 544 * 545 * PARAMETERS: WalkState - Current state of the parse tree walk 546 * Op - Op that has been just been completed in the 547 * walk; Arguments have now been evaluated. 548 * 549 * RETURN: Status 550 * 551 * DESCRIPTION: Ascending callback used during the loading of the namespace, 552 * both control methods and everything else. 553 * 554 ******************************************************************************/ 555 556ACPI_STATUS 557AcpiDsLoad2EndOp ( 558 ACPI_WALK_STATE *WalkState) 559{ 560 ACPI_PARSE_OBJECT *Op; 561 ACPI_STATUS Status = AE_OK; 562 ACPI_OBJECT_TYPE8 ObjectType; 563 ACPI_NAMESPACE_NODE *Node; 564 ACPI_PARSE_OBJECT *Arg; 565 ACPI_NAMESPACE_NODE *NewNode; 566 UINT32 i; 567 568 569 PROC_NAME ("DsLoad2EndOp"); 570 571 Op = WalkState->Op; 572 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Op=%p State=%p\n", Op, WalkState)); 573 574 575 /* Only interested in opcodes that have namespace objects */ 576 577 if (!(WalkState->OpInfo->Flags & AML_NSOBJECT)) 578 { 579 return (AE_OK); 580 } 581 582 if (Op->Opcode == AML_SCOPE_OP) 583 { 584 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, 585 "Ending scope Op=%p State=%p\n", Op, WalkState)); 586 587 if (((ACPI_PARSE2_OBJECT *)Op)->Name == -1) 588 { 589 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unnamed scope! Op=%p State=%p\n", 590 Op, WalkState)); 591 return (AE_OK); 592 } 593 } 594 595 596 ObjectType = WalkState->OpInfo->ObjectType; 597 598 /* 599 * Get the Node/name from the earlier lookup 600 * (It was saved in the *op structure) 601 */ 602 Node = Op->Node; 603 604 /* 605 * Put the Node on the object stack (Contains the ACPI Name of 606 * this object) 607 */ 608 WalkState->Operands[0] = (void *) Node; 609 WalkState->NumOperands = 1; 610 611 /* Pop the scope stack */ 612 613 if (AcpiNsOpensScope (ObjectType)) 614 { 615 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "(%s) Popping scope for Op %p\n", 616 AcpiUtGetTypeName (ObjectType), Op)); 617 AcpiDsScopeStackPop (WalkState); 618 } 619 620 /* 621 * Named operations are as follows: 622 * 623 * AML_ALIAS 624 * AML_BANKFIELD 625 * AML_CREATEBITFIELD 626 * AML_CREATEBYTEFIELD 627 * AML_CREATEDWORDFIELD 628 * AML_CREATEFIELD 629 * AML_CREATEQWORDFIELD 630 * AML_CREATEWORDFIELD 631 * AML_DATA_REGION 632 * AML_DEVICE 633 * AML_EVENT 634 * AML_FIELD 635 * AML_INDEXFIELD 636 * AML_METHOD 637 * AML_METHODCALL 638 * AML_MUTEX 639 * AML_NAME 640 * AML_NAMEDFIELD 641 * AML_OPREGION 642 * AML_POWERRES 643 * AML_PROCESSOR 644 * AML_SCOPE 645 * AML_THERMALZONE 646 */ 647 648 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, 649 "Create-Load [%s] State=%p Op=%p NamedObj=%p\n", 650 AcpiPsGetOpcodeName (Op->Opcode), WalkState, Op, Node)); 651 652 /* Decode the opcode */ 653 654 Arg = Op->Value.Arg; 655 656 switch (WalkState->OpInfo->Type) 657 { 658 case AML_TYPE_CREATE_FIELD: 659 660 /* 661 * Create the field object, but the field buffer and index must 662 * be evaluated later during the execution phase 663 */ 664 Status = AcpiDsCreateBufferField (Op, WalkState); 665 break; 666 667 668 case AML_TYPE_NAMED_FIELD: 669 670 switch (Op->Opcode) 671 { 672 case AML_INDEX_FIELD_OP: 673 674 Status = AcpiDsCreateIndexField (Op, (ACPI_HANDLE) Arg->Node, 675 WalkState); 676 break; 677 678 case AML_BANK_FIELD_OP: 679 680 Status = AcpiDsCreateBankField (Op, Arg->Node, WalkState); 681 break; 682 683 case AML_FIELD_OP: 684 685 Status = AcpiDsCreateField (Op, Arg->Node, WalkState); 686 break; 687 } 688 break; 689 690 691 case AML_TYPE_NAMED_SIMPLE: 692 693 Status = AcpiDsCreateOperands (WalkState, Arg); 694 if (ACPI_FAILURE (Status)) 695 { 696 goto Cleanup; 697 } 698 699 switch (Op->Opcode) 700 { 701 case AML_PROCESSOR_OP: 702 703 Status = AcpiExCreateProcessor (WalkState); 704 break; 705 706 case AML_POWER_RES_OP: 707 708 Status = AcpiExCreatePowerResource (WalkState); 709 break; 710 711 case AML_MUTEX_OP: 712 713 Status = AcpiExCreateMutex (WalkState); 714 break; 715 716 case AML_EVENT_OP: 717 718 Status = AcpiExCreateEvent (WalkState); 719 break; 720 721 case AML_DATA_REGION_OP: 722 723 Status = AcpiExCreateTableRegion (WalkState); 724 break; 725 726 case AML_ALIAS_OP: 727 728 Status = AcpiExCreateAlias (WalkState); 729 break; 730 731 default: 732 /* Unknown opcode */ 733 734 Status = AE_OK; 735 goto Cleanup; 736 break; 737 } 738 739 /* Delete operands */ 740 741 for (i = 1; i < WalkState->NumOperands; i++) 742 { 743 AcpiUtRemoveReference (WalkState->Operands[i]); 744 WalkState->Operands[i] = NULL; 745 } 746 747 break; 748 749 750 case AML_TYPE_NAMED_COMPLEX: 751 752 switch (Op->Opcode) 753 { 754 case AML_METHOD_OP: 755 /* 756 * MethodOp PkgLength NameString MethodFlags TermList 757 */ 758 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, 759 "LOADING-Method: State=%p Op=%p NamedObj=%p\n", 760 WalkState, Op, Node)); 761 762 if (!AcpiNsGetAttachedObject (Node)) 763 { 764 Status = AcpiDsCreateOperands (WalkState, Arg); 765 if (ACPI_FAILURE (Status)) 766 { 767 goto Cleanup; 768 } 769 770 Status = AcpiExCreateMethod (((ACPI_PARSE2_OBJECT *) Op)->Data, 771 ((ACPI_PARSE2_OBJECT *) Op)->Length, 772 WalkState); 773 } 774 break; 775 776 777 case AML_REGION_OP: 778 /* 779 * The OpRegion is not fully parsed at this time. Only valid argument is the SpaceId. 780 * (We must save the address of the AML of the address and length operands) 781 */ 782 /* 783 * If we have a valid region, initialize it 784 * Namespace is NOT locked at this point. 785 */ 786 Status = AcpiEvInitializeRegion (AcpiNsGetAttachedObject (Node), FALSE); 787 if (ACPI_FAILURE (Status)) 788 { 789 /* 790 * If AE_NOT_EXIST is returned, it is not fatal 791 * because many regions get created before a handler 792 * is installed for said region. 793 */ 794 if (AE_NOT_EXIST == Status) 795 { 796 Status = AE_OK; 797 } 798 } 799 break; 800 801 802 case AML_NAME_OP: 803 804 Status = AcpiDsCreateNode (WalkState, Node, Op); 805 break; 806 } 807 break; 808 809 810 case AML_CLASS_INTERNAL: 811 812 /* case AML_INT_NAMEPATH_OP: */ 813 break; 814 815 816 case AML_CLASS_METHOD_CALL: 817 818 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, 819 "RESOLVING-MethodCall: State=%p Op=%p NamedObj=%p\n", 820 WalkState, Op, Node)); 821 822 /* 823 * Lookup the method name and save the Node 824 */ 825 Status = AcpiNsLookup (WalkState->ScopeInfo, Arg->Value.String, 826 ACPI_TYPE_ANY, IMODE_LOAD_PASS2, 827 NS_SEARCH_PARENT | NS_DONT_OPEN_SCOPE, 828 WalkState, &(NewNode)); 829 if (ACPI_SUCCESS (Status)) 830 { 831 /* 832 * Make sure that what we found is indeed a method 833 * We didn't search for a method on purpose, to see if the name would resolve 834 */ 835 if (NewNode->Type != ACPI_TYPE_METHOD) 836 { 837 Status = AE_AML_OPERAND_TYPE; 838 } 839 840 /* We could put the returned object (Node) on the object stack for later, but 841 * for now, we will put it in the "op" object that the parser uses, so we 842 * can get it again at the end of this scope 843 */ 844 Op->Node = NewNode; 845 } 846 847 break; 848 849 850 default: 851 break; 852 } 853 854 855Cleanup: 856 857 /* Remove the Node pushed at the very beginning */ 858 859 WalkState->Operands[0] = NULL; 860 WalkState->NumOperands = 0; 861 return (Status); 862} 863 864 865