dswload.c revision 87031
1238722Skargl/****************************************************************************** 2251315Skargl * 3238722Skargl * Module Name: dswload - Dispatcher namespace load callbacks 4238722Skargl * $Revision: 54 $ 5238722Skargl * 6238722Skargl *****************************************************************************/ 7238722Skargl 8238722Skargl/****************************************************************************** 9238722Skargl * 10238722Skargl * 1. Copyright Notice 11238722Skargl * 12238722Skargl * Some or all of this work - Copyright (c) 1999, 2000, 2001, Intel Corp. 13238722Skargl * All rights reserved. 14238722Skargl * 15238722Skargl * 2. License 16238722Skargl * 17238722Skargl * 2.1. This is your license from Intel Corp. under its intellectual property 18238722Skargl * rights. You may have additional license terms from the party that provided 19238722Skargl * you this software, covering your right to use that party's intellectual 20238722Skargl * property rights. 21238722Skargl * 22238722Skargl * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a 23238722Skargl * copy of the source code appearing in this file ("Covered Code") an 24238722Skargl * irrevocable, perpetual, worldwide license under Intel's copyrights in the 25238722Skargl * base code distributed originally by Intel ("Original Intel Code") to copy, 26238722Skargl * make derivatives, distribute, use and display any portion of the Covered 27238722Skargl * Code in any form, with the right to sublicense such rights; and 28238722Skargl * 29238722Skargl * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent 30240864Skargl * license (with the right to sublicense), under only those claims of Intel 31240864Skargl * patents that are infringed by the Original Intel Code, to make, use, sell, 32240864Skargl * offer to sell, and import the Covered Code and derivative works thereof 33240864Skargl * solely to the minimum extent necessary to exercise the above copyright 34238722Skargl * license, and in no event shall the patent license extend to any additions 35238722Skargl * to or modifications of the Original Intel Code. No other license or right 36238783Skargl * is granted directly or by implication, estoppel or otherwise; 37238722Skargl * 38238722Skargl * The above copyright and patent license is granted only if the following 39238722Skargl * conditions are met: 40240864Skargl * 41238722Skargl * 3. Conditions 42238722Skargl * 43240864Skargl * 3.1. Redistribution of Source with Rights to Further Distribute Source. 44238722Skargl * Redistribution of source code of any substantial portion of the Covered 45238722Skargl * Code or modification with rights to further distribute source must include 46240864Skargl * the above Copyright Notice, the above License, this list of Conditions, 47240864Skargl * and the following Disclaimer and Export Compliance provision. In addition, 48240864Skargl * Licensee must cause all Covered Code to which Licensee contributes to 49238722Skargl * contain a file documenting the changes Licensee made to create that Covered 50238722Skargl * Code and the date of any change. Licensee must include in that file the 51240864Skargl * documentation of any changes made by any predecessor Licensee. Licensee 52240864Skargl * must include a prominent statement that the modification is derived, 53238722Skargl * directly or indirectly, from Original Intel Code. 54238722Skargl * 55251321Skargl * 3.2. Redistribution of Source with no Rights to Further Distribute Source. 56251321Skargl * Redistribution of source code of any substantial portion of the Covered 57251321Skargl * Code or modification without rights to further distribute source must 58251321Skargl * include the following Disclaimer and Export Compliance provision in the 59251321Skargl * documentation and/or other materials provided with distribution. In 60251321Skargl * addition, Licensee may not authorize further sublicense of source of any 61251321Skargl * portion of the Covered Code, and must include terms to the effect that the 62251321Skargl * license from Licensee to its licensee is limited to the intellectual 63251321Skargl * property embodied in the software Licensee provides to its licensee, and 64251321Skargl * not to intellectual property embodied in modifications its licensee may 65238722Skargl * make. 66238722Skargl * 67238722Skargl * 3.3. Redistribution of Executable. Redistribution in executable form of any 68238722Skargl * substantial portion of the Covered Code or modification must reproduce the 69251321Skargl * above Copyright Notice, and the following Disclaimer and Export Compliance 70238722Skargl * provision in the documentation and/or other materials provided with the 71238722Skargl * distribution. 72238722Skargl * 73238722Skargl * 3.4. Intel retains all right, title, and interest in and to the Original 74238722Skargl * Intel Code. 75238722Skargl * 76238722Skargl * 3.5. Neither the name Intel nor any other trademark owned or controlled by 77238722Skargl * Intel shall be used in advertising or otherwise to promote the sale, use or 78238722Skargl * other dealings in products derived from or relating to the Covered Code 79238722Skargl * without prior written authorization from Intel. 80238722Skargl * 81238722Skargl * 4. Disclaimer and Export Compliance 82238722Skargl * 83238722Skargl * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED 84238722Skargl * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE 85238722Skargl * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, 86238722Skargl * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY 87238722Skargl * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY 88238722Skargl * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A 89238722Skargl * PARTICULAR PURPOSE. 90238722Skargl * 91238722Skargl * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES 92238722Skargl * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR 93238722Skargl * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, 94238722Skargl * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY 95238722Skargl * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL 96238722Skargl * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS 97238722Skargl * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY 98238722Skargl * LIMITED REMEDY. 99238722Skargl * 100238722Skargl * 4.3. Licensee shall not export, either directly or indirectly, any of this 101238722Skargl * software or system incorporating such software without first obtaining any 102238722Skargl * required license or other approval from the U. S. Department of Commerce or 103238722Skargl * any other agency or department of the United States Government. In the 104238722Skargl * event Licensee exports any such software from the United States or 105238722Skargl * re-exports any such software from a foreign destination, Licensee shall 106238722Skargl * ensure that the distribution and export/re-export of the software is in 107238722Skargl * compliance with all laws, regulations, orders, or other restrictions of the 108238722Skargl * U.S. Export Administration Regulations. Licensee agrees that neither it nor 109238722Skargl * any of its subsidiaries will export/re-export any technical data, process, 110238722Skargl * software, or service, directly or indirectly, to any country for which the 111238722Skargl * United States government or any agency thereof requires an export license, 112238722Skargl * other governmental approval, or letter of assurance, without first obtaining 113238722Skargl * such license, approval or letter. 114238722Skargl * 115238722Skargl *****************************************************************************/ 116238722Skargl 117238722Skargl#define __DSWLOAD_C__ 118238722Skargl 119238722Skargl#include "acpi.h" 120238722Skargl#include "acparser.h" 121238722Skargl#include "amlcode.h" 122238722Skargl#include "acdispat.h" 123238722Skargl#include "acinterp.h" 124238722Skargl#include "acnamesp.h" 125238722Skargl#include "acevents.h" 126238722Skargl 127238722Skargl 128238722Skargl#define _COMPONENT ACPI_DISPATCHER 129238722Skargl MODULE_NAME ("dswload") 130238722Skargl 131238722Skargl 132238722Skargl/******************************************************************************* 133238722Skargl * 134238722Skargl * FUNCTION: AcpiDsInitCallbacks 135238722Skargl * 136238722Skargl * PARAMETERS: WalkState - Current state of the parse tree walk 137238722Skargl * PassNumber - 1, 2, or 3 138238722Skargl * 139238722Skargl * RETURN: Status 140238722Skargl * 141238722Skargl * DESCRIPTION: Init walk state callbacks 142238722Skargl * 143238722Skargl ******************************************************************************/ 144238722Skargl 145238722SkarglACPI_STATUS 146238722SkarglAcpiDsInitCallbacks ( 147238722Skargl ACPI_WALK_STATE *WalkState, 148238722Skargl UINT32 PassNumber) 149238722Skargl{ 150238722Skargl 151238722Skargl switch (PassNumber) 152238722Skargl { 153238722Skargl case 1: 154238722Skargl WalkState->ParseFlags = ACPI_PARSE_LOAD_PASS1 | ACPI_PARSE_DELETE_TREE; 155238722Skargl WalkState->DescendingCallback = AcpiDsLoad1BeginOp; 156238722Skargl WalkState->AscendingCallback = AcpiDsLoad1EndOp; 157238722Skargl break; 158238722Skargl 159238722Skargl case 2: 160238722Skargl WalkState->ParseFlags = ACPI_PARSE_LOAD_PASS1 | ACPI_PARSE_DELETE_TREE; 161238722Skargl WalkState->DescendingCallback = AcpiDsLoad2BeginOp; 162238722Skargl WalkState->AscendingCallback = AcpiDsLoad2EndOp; 163238722Skargl break; 164238722Skargl 165238722Skargl case 3: 166238722Skargl WalkState->ParseFlags |= ACPI_PARSE_EXECUTE | ACPI_PARSE_DELETE_TREE; 167238722Skargl WalkState->DescendingCallback = AcpiDsExecBeginOp; 168238722Skargl WalkState->AscendingCallback = AcpiDsExecEndOp; 169238722Skargl break; 170238722Skargl 171238722Skargl default: 172238722Skargl return (AE_BAD_PARAMETER); 173238722Skargl break; 174238722Skargl } 175238722Skargl 176238722Skargl return (AE_OK); 177238722Skargl} 178238722Skargl 179238722Skargl 180238722Skargl/******************************************************************************* 181238722Skargl * 182238722Skargl * FUNCTION: AcpiDsLoad1BeginOp 183238722Skargl * 184238722Skargl * PARAMETERS: WalkState - Current state of the parse tree walk 185238722Skargl * Op - Op that has been just been reached in the 186238722Skargl * walk; Arguments have not been evaluated yet. 187238722Skargl * 188238722Skargl * RETURN: Status 189238722Skargl * 190238722Skargl * DESCRIPTION: Descending callback used during the loading of ACPI tables. 191238722Skargl * 192238722Skargl ******************************************************************************/ 193238722Skargl 194238722SkarglACPI_STATUS 195238722SkarglAcpiDsLoad1BeginOp ( 196238722Skargl ACPI_WALK_STATE *WalkState, 197238722Skargl ACPI_PARSE_OBJECT **OutOp) 198238722Skargl{ 199238722Skargl ACPI_PARSE_OBJECT *Op; 200238722Skargl ACPI_NAMESPACE_NODE *Node; 201238722Skargl ACPI_STATUS Status; 202238722Skargl ACPI_OBJECT_TYPE8 ObjectType; 203238722Skargl NATIVE_CHAR *Path; 204238722Skargl 205238722Skargl 206238722Skargl PROC_NAME ("DsLoad1BeginOp"); 207238722Skargl 208238722Skargl Op = WalkState->Op; 209238722Skargl ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Op=%p State=%p\n", Op, WalkState)); 210238722Skargl 211238923Skargl 212238722Skargl if (Op && (Op->Opcode == AML_INT_NAMEDFIELD_OP)) 213238722Skargl { 214240866Skargl ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Op=%p State=%p\n", Op, WalkState)); 215240866Skargl } 216240866Skargl 217240866Skargl /* We are only interested in opcodes that have an associated name */ 218238722Skargl 219238722Skargl if (WalkState->Op) 220238722Skargl { 221238722Skargl if (!(WalkState->OpInfo->Flags & AML_NAMED)) 222238722Skargl { 223240866Skargl *OutOp = Op; 224238722Skargl return (AE_OK); 225238722Skargl } 226238722Skargl 227238722Skargl /* Check if this object has already been installed in the namespace */ 228240864Skargl 229238722Skargl if (Op->Node) 230238722Skargl { 231240864Skargl *OutOp = Op; 232238784Skargl return (AE_OK); 233238722Skargl } 234238722Skargl } 235238722Skargl 236238722Skargl Path = AcpiPsGetNextNamestring (&WalkState->ParserState); 237238722Skargl 238238722Skargl /* Map the raw opcode into an internal object type */ 239238722Skargl 240238722Skargl ObjectType = WalkState->OpInfo->ObjectType; 241238722Skargl 242238722Skargl ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, 243238722Skargl "State=%p Op=%p Type=%x\n", WalkState, Op, ObjectType)); 244238722Skargl 245238722Skargl /* 246238722Skargl * Enter the named type into the internal namespace. We enter the name 247238722Skargl * as we go downward in the parse tree. Any necessary subobjects that involve 248251321Skargl * arguments to the opcode must be created as we go back up the parse tree later. 249251321Skargl */ 250251321Skargl Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ObjectType, 251251321Skargl IMODE_LOAD_PASS1, NS_NO_UPSEARCH, WalkState, &(Node)); 252238722Skargl 253238722Skargl if (ACPI_FAILURE (Status)) 254238722Skargl { 255238722Skargl return (Status); 256238722Skargl } 257238722Skargl 258238722Skargl if (!Op) 259238722Skargl { 260238722Skargl /* Create a new op */ 261238722Skargl 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