1 /****************************************************************************** 2 * 3 * Module Name: dswload - Dispatcher namespace load callbacks 4 * 5 *****************************************************************************/ 6 7 /****************************************************************************** 8 * 9 * 1. Copyright Notice 10 * 11 * Some or all of this work - Copyright (c) 1999 - 2020, 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/compiler/aslcompiler.h> 153 #include <contrib/dev/acpica/include/amlcode.h> 154 #include <contrib/dev/acpica/include/acdispat.h> 155 #include <contrib/dev/acpica/include/acnamesp.h> 156 #include <contrib/dev/acpica/include/acparser.h> 157 #include "aslcompiler.y.h" 158 159 160 #define _COMPONENT ACPI_COMPILER 161 ACPI_MODULE_NAME ("aslload") 162 163 /* Local prototypes */ 164 165 static ACPI_STATUS 166 LdLoadFieldElements ( 167 UINT32 AmlType, 168 ACPI_PARSE_OBJECT *Op, 169 ACPI_WALK_STATE *WalkState); 170 171 static ACPI_STATUS 172 LdLoadResourceElements ( 173 ACPI_PARSE_OBJECT *Op, 174 ACPI_WALK_STATE *WalkState); 175 176 static ACPI_STATUS 177 LdNamespace1Begin ( 178 ACPI_PARSE_OBJECT *Op, 179 UINT32 Level, 180 void *Context); 181 182 static ACPI_STATUS 183 LdNamespace2Begin ( 184 ACPI_PARSE_OBJECT *Op, 185 UINT32 Level, 186 void *Context); 187 188 static ACPI_STATUS 189 LdCommonNamespaceEnd ( 190 ACPI_PARSE_OBJECT *Op, 191 UINT32 Level, 192 void *Context); 193 194 static void 195 LdCheckSpecialNames ( 196 ACPI_NAMESPACE_NODE *Node, 197 ACPI_PARSE_OBJECT *Op); 198 199 static ACPI_STATUS 200 LdAnalyzeExternals ( 201 ACPI_NAMESPACE_NODE *Node, 202 ACPI_PARSE_OBJECT *Op, 203 ACPI_OBJECT_TYPE ExternalOpType, 204 ACPI_OBJECT_TYPE ObjectType, 205 ACPI_WALK_STATE *WalkState); 206 207 208 /******************************************************************************* 209 * 210 * FUNCTION: LdLoadNamespace 211 * 212 * PARAMETERS: RootOp - Root of the parse tree 213 * 214 * RETURN: Status 215 * 216 * DESCRIPTION: Perform a walk of the parse tree that in turn loads all of the 217 * named ASL/AML objects into the namespace. The namespace is 218 * constructed in order to resolve named references and references 219 * to named fields within resource templates/descriptors. 220 * 221 ******************************************************************************/ 222 223 ACPI_STATUS 224 LdLoadNamespace ( 225 ACPI_PARSE_OBJECT *RootOp) 226 { 227 ACPI_WALK_STATE *WalkState; 228 229 230 /* Create a new walk state */ 231 232 WalkState = AcpiDsCreateWalkState (0, NULL, NULL, NULL); 233 if (!WalkState) 234 { 235 return (AE_NO_MEMORY); 236 } 237 238 /* Walk the entire parse tree, first pass */ 239 240 TrWalkParseTree (RootOp, ASL_WALK_VISIT_TWICE, LdNamespace1Begin, 241 LdCommonNamespaceEnd, WalkState); 242 243 /* Second pass to handle forward references */ 244 245 TrWalkParseTree (RootOp, ASL_WALK_VISIT_TWICE, LdNamespace2Begin, 246 LdCommonNamespaceEnd, WalkState); 247 248 /* Dump the namespace if debug is enabled */ 249 250 if (AcpiDbgLevel & ACPI_LV_TABLES) 251 { 252 AcpiNsDumpTables (ACPI_NS_ALL, ACPI_UINT32_MAX); 253 } 254 255 ACPI_FREE (WalkState); 256 return (AE_OK); 257 } 258 259 260 /******************************************************************************* 261 * 262 * FUNCTION: LdLoadFieldElements 263 * 264 * PARAMETERS: AmlType - Type to search 265 * Op - Parent node (Field) 266 * WalkState - Current walk state 267 * 268 * RETURN: Status 269 * 270 * DESCRIPTION: Enter the named elements of the field (children of the parent) 271 * into the namespace. 272 * 273 ******************************************************************************/ 274 275 static ACPI_STATUS 276 LdLoadFieldElements ( 277 UINT32 AmlType, 278 ACPI_PARSE_OBJECT *Op, 279 ACPI_WALK_STATE *WalkState) 280 { 281 ACPI_PARSE_OBJECT *Child = NULL; 282 ACPI_PARSE_OBJECT *SourceRegion; 283 ACPI_NAMESPACE_NODE *Node; 284 ACPI_STATUS Status; 285 char *ExternalPath; 286 287 288 SourceRegion = UtGetArg (Op, 0); 289 if (SourceRegion) 290 { 291 Status = AcpiNsLookup (WalkState->ScopeInfo, 292 SourceRegion->Asl.Value.String, AmlType, ACPI_IMODE_EXECUTE, 293 ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE, NULL, &Node); 294 if (Status == AE_NOT_FOUND) 295 { 296 /* 297 * If the named object is not found, it means that it is either a 298 * forward reference or the named object does not exist. 299 */ 300 SourceRegion->Asl.CompileFlags |= OP_NOT_FOUND_DURING_LOAD; 301 } 302 } 303 304 /* Get the first named field element */ 305 306 switch (Op->Asl.AmlOpcode) 307 { 308 case AML_BANK_FIELD_OP: 309 310 Child = UtGetArg (Op, 6); 311 break; 312 313 case AML_INDEX_FIELD_OP: 314 315 Child = UtGetArg (Op, 5); 316 break; 317 318 case AML_FIELD_OP: 319 320 Child = UtGetArg (Op, 4); 321 break; 322 323 default: 324 325 /* No other opcodes should arrive here */ 326 327 return (AE_BAD_PARAMETER); 328 } 329 330 /* Enter all elements into the namespace */ 331 332 while (Child) 333 { 334 switch (Child->Asl.AmlOpcode) 335 { 336 case AML_INT_RESERVEDFIELD_OP: 337 case AML_INT_ACCESSFIELD_OP: 338 case AML_INT_CONNECTION_OP: 339 break; 340 341 default: 342 343 Status = AcpiNsLookup (WalkState->ScopeInfo, 344 Child->Asl.Value.String, 345 ACPI_TYPE_LOCAL_REGION_FIELD, 346 ACPI_IMODE_LOAD_PASS1, 347 ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE | 348 ACPI_NS_ERROR_IF_FOUND, NULL, &Node); 349 if (ACPI_FAILURE (Status)) 350 { 351 if (Status != AE_ALREADY_EXISTS) 352 { 353 AslError (ASL_ERROR, ASL_MSG_CORE_EXCEPTION, Child, 354 Child->Asl.Value.String); 355 return (Status); 356 } 357 else if (Status == AE_ALREADY_EXISTS && 358 (Node->Flags & ANOBJ_IS_EXTERNAL)) 359 { 360 Node->Type = (UINT8) ACPI_TYPE_LOCAL_REGION_FIELD; 361 Node->Flags &= ~ANOBJ_IS_EXTERNAL; 362 } 363 else 364 { 365 /* 366 * The name already exists in this scope 367 * But continue processing the elements 368 */ 369 ExternalPath = AcpiNsGetNormalizedPathname (Node, TRUE); 370 371 AslDualParseOpError (ASL_ERROR, ASL_MSG_NAME_EXISTS, Child, 372 ExternalPath, ASL_MSG_FOUND_HERE, Node->Op, 373 ExternalPath); 374 375 if (ExternalPath) 376 { 377 ACPI_FREE (ExternalPath); 378 } 379 } 380 } 381 else 382 { 383 Child->Asl.Node = Node; 384 Node->Op = Child; 385 } 386 break; 387 } 388 389 Child = Child->Asl.Next; 390 } 391 392 return (AE_OK); 393 } 394 395 396 /******************************************************************************* 397 * 398 * FUNCTION: LdLoadResourceElements 399 * 400 * PARAMETERS: Op - Parent node (Resource Descriptor) 401 * WalkState - Current walk state 402 * 403 * RETURN: Status 404 * 405 * DESCRIPTION: Enter the named elements of the resource descriptor (children 406 * of the parent) into the namespace. 407 * 408 * NOTE: In the real AML namespace, these named elements never exist. But 409 * we simply use the namespace here as a symbol table so we can look 410 * them up as they are referenced. 411 * 412 ******************************************************************************/ 413 414 static ACPI_STATUS 415 LdLoadResourceElements ( 416 ACPI_PARSE_OBJECT *Op, 417 ACPI_WALK_STATE *WalkState) 418 { 419 ACPI_PARSE_OBJECT *InitializerOp = NULL; 420 ACPI_NAMESPACE_NODE *Node; 421 ACPI_STATUS Status; 422 char *ExternalPath; 423 424 425 /* 426 * Enter the resource name into the namespace. Name must not already exist. 427 * This opens a scope, so later field names are guaranteed to be new/unique. 428 */ 429 Status = AcpiNsLookup (WalkState->ScopeInfo, Op->Asl.Namepath, 430 ACPI_TYPE_LOCAL_RESOURCE, ACPI_IMODE_LOAD_PASS1, 431 ACPI_NS_NO_UPSEARCH | ACPI_NS_ERROR_IF_FOUND, 432 WalkState, &Node); 433 if (ACPI_FAILURE (Status)) 434 { 435 if (Status == AE_ALREADY_EXISTS) 436 { 437 /* Actual node causing the error was saved in ParentMethod */ 438 439 ExternalPath = AcpiNsGetNormalizedPathname (Node, TRUE); 440 441 AslDualParseOpError (ASL_ERROR, ASL_MSG_NAME_EXISTS, 442 (ACPI_PARSE_OBJECT *) Op->Asl.ParentMethod, 443 ExternalPath, ASL_MSG_FOUND_HERE, Node->Op, 444 ExternalPath); 445 446 if (ExternalPath) 447 { 448 ACPI_FREE (ExternalPath); 449 } 450 return (AE_OK); 451 } 452 return (Status); 453 } 454 455 Node->Value = (UINT32) Op->Asl.Value.Integer; 456 Node->Op = Op; 457 Op->Asl.Node = Node; 458 459 /* 460 * Now enter the predefined fields, for easy lookup when referenced 461 * by the source ASL 462 */ 463 InitializerOp = ASL_GET_CHILD_NODE (Op); 464 while (InitializerOp) 465 { 466 if (InitializerOp->Asl.ExternalName) 467 { 468 Status = AcpiNsLookup (WalkState->ScopeInfo, 469 InitializerOp->Asl.ExternalName, 470 ACPI_TYPE_LOCAL_RESOURCE_FIELD, ACPI_IMODE_LOAD_PASS1, 471 ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE, NULL, &Node); 472 if (ACPI_FAILURE (Status)) 473 { 474 return (Status); 475 } 476 477 /* 478 * Store the field offset and length in the namespace node 479 * so it can be used when the field is referenced 480 */ 481 Node->Value = InitializerOp->Asl.Value.Tag.BitOffset; 482 Node->Length = InitializerOp->Asl.Value.Tag.BitLength; 483 InitializerOp->Asl.Node = Node; 484 Node->Op = InitializerOp; 485 } 486 487 InitializerOp = ASL_GET_PEER_NODE (InitializerOp); 488 } 489 490 return (AE_OK); 491 } 492 493 494 /******************************************************************************* 495 * 496 * FUNCTION: LdNamespace1Begin 497 * 498 * PARAMETERS: ASL_WALK_CALLBACK 499 * 500 * RETURN: Status 501 * 502 * DESCRIPTION: Descending callback used during the parse tree walk. If this 503 * is a named AML opcode, enter into the namespace 504 * 505 ******************************************************************************/ 506 507 static ACPI_STATUS 508 LdNamespace1Begin ( 509 ACPI_PARSE_OBJECT *Op, 510 UINT32 Level, 511 void *Context) 512 { 513 ACPI_WALK_STATE *WalkState = (ACPI_WALK_STATE *) Context; 514 ACPI_NAMESPACE_NODE *Node; 515 ACPI_PARSE_OBJECT *MethodOp; 516 ACPI_STATUS Status; 517 ACPI_OBJECT_TYPE ObjectType; 518 ACPI_OBJECT_TYPE ActualObjectType = ACPI_TYPE_ANY; 519 char *Path; 520 UINT32 Flags = ACPI_NS_NO_UPSEARCH; 521 ACPI_PARSE_OBJECT *Arg; 522 UINT32 i; 523 BOOLEAN ForceNewScope = FALSE; 524 const ACPI_OPCODE_INFO *OpInfo; 525 ACPI_PARSE_OBJECT *ParentOp; 526 char *ExternalPath; 527 528 529 ACPI_FUNCTION_NAME (LdNamespace1Begin); 530 531 532 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Op %p [%s]\n", 533 Op, Op->Asl.ParseOpName)); 534 535 /* 536 * We are only interested in opcodes that have an associated name 537 * (or multiple names) 538 */ 539 switch (Op->Asl.AmlOpcode) 540 { 541 case AML_INDEX_FIELD_OP: 542 543 Status = LdLoadFieldElements (ACPI_TYPE_LOCAL_REGION_FIELD, Op, WalkState); 544 return (Status); 545 546 case AML_BANK_FIELD_OP: 547 case AML_FIELD_OP: 548 549 Status = LdLoadFieldElements (ACPI_TYPE_REGION, Op, WalkState); 550 return (Status); 551 552 case AML_INT_CONNECTION_OP: 553 554 if (Op->Asl.Child->Asl.AmlOpcode != AML_INT_NAMEPATH_OP) 555 { 556 break; 557 } 558 559 Arg = Op->Asl.Child; 560 Status = AcpiNsLookup (WalkState->ScopeInfo, Arg->Asl.ExternalName, 561 ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, 562 WalkState, &Node); 563 if (ACPI_FAILURE (Status)) 564 { 565 break; 566 } 567 568 break; 569 570 default: 571 572 /* All other opcodes go below */ 573 574 break; 575 } 576 577 /* Check if this object has already been installed in the namespace */ 578 579 if (Op->Asl.Node) 580 { 581 return (AE_OK); 582 } 583 584 /* Check for a possible illegal forward reference */ 585 586 if ((Op->Asl.ParseOpcode == PARSEOP_NAMESEG) || 587 (Op->Asl.ParseOpcode == PARSEOP_NAMESTRING) || 588 (Op->Asl.ParseOpcode == PARSEOP_METHODCALL)) 589 { 590 /* 591 * Op->Asl.Namepath will be NULL for these opcodes. 592 * These opcodes are guaranteed to have a parent. 593 * Examine the parent opcode. 594 */ 595 ParentOp = Op->Asl.Parent; 596 OpInfo = AcpiPsGetOpcodeInfo (ParentOp->Asl.AmlOpcode); 597 598 /* 599 * Exclude all operators that actually declare a new name: 600 * Name (ABCD, 1) -> Ignore (AML_CLASS_NAMED_OBJECT) 601 * We only want references to named objects: 602 * Store (2, WXYZ) -> Attempt to resolve the name 603 */ 604 if ((Op->Asl.ParseOpcode != PARSEOP_METHODCALL) && 605 (OpInfo->Class == AML_CLASS_NAMED_OBJECT)) 606 { 607 return (AE_OK); 608 } 609 610 /* 611 * Check if the referenced object exists at this point during 612 * the load: 613 * 1) If it exists, then this cannot be a forward reference. 614 * 2) If it does not exist, it could be a forward reference or 615 * it truly does not exist (and no external declaration). 616 */ 617 Status = AcpiNsLookup (WalkState->ScopeInfo, 618 Op->Asl.Value.Name, ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE, 619 ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE, 620 WalkState, &Node); 621 if (Status == AE_NOT_FOUND) 622 { 623 /* 624 * This is either a forward reference or the object truly 625 * does not exist. The two cases can only be differentiated 626 * during the cross-reference stage later. Mark the Op/Name 627 * as not-found for now to indicate the need for further 628 * processing. 629 * 630 * Special case: Allow forward references from elements of 631 * Package objects. This provides compatibility with other 632 * ACPI implementations. To correctly implement this, the 633 * ACPICA table load defers package resolution until the entire 634 * namespace has been loaded. 635 */ 636 if ((ParentOp->Asl.ParseOpcode != PARSEOP_PACKAGE) && 637 (ParentOp->Asl.ParseOpcode != PARSEOP_VAR_PACKAGE)) 638 { 639 Op->Asl.CompileFlags |= OP_NOT_FOUND_DURING_LOAD; 640 } 641 642 return (AE_OK); 643 } 644 645 return (Status); 646 } 647 648 Path = Op->Asl.Namepath; 649 if (!Path) 650 { 651 return (AE_OK); 652 } 653 654 /* Map the raw opcode into an internal object type */ 655 656 switch (Op->Asl.ParseOpcode) 657 { 658 case PARSEOP_NAME: 659 660 Arg = Op->Asl.Child; /* Get the NameSeg/NameString node */ 661 Arg = Arg->Asl.Next; /* First peer is the object to be associated with the name */ 662 663 /* 664 * If this name refers to a ResourceTemplate, we will need to open 665 * a new scope so that the resource subfield names can be entered into 666 * the namespace underneath this name 667 */ 668 if (Op->Asl.CompileFlags & OP_IS_RESOURCE_DESC) 669 { 670 ForceNewScope = TRUE; 671 } 672 673 /* Get the data type associated with the named object, not the name itself */ 674 675 /* Log2 loop to convert from Btype (binary) to Etype (encoded) */ 676 677 ObjectType = 1; 678 for (i = 1; i < Arg->Asl.AcpiBtype; i *= 2) 679 { 680 ObjectType++; 681 } 682 break; 683 684 case PARSEOP_EXTERNAL: 685 /* 686 * "External" simply enters a name and type into the namespace. 687 * We must be careful to not open a new scope, however, no matter 688 * what type the external name refers to (e.g., a method) 689 * 690 * first child is name, next child is ObjectType 691 */ 692 ActualObjectType = (UINT8) Op->Asl.Child->Asl.Next->Asl.Value.Integer; 693 ObjectType = ACPI_TYPE_ANY; 694 695 /* 696 * We will mark every new node along the path as "External". This 697 * allows some or all of the nodes to be created later in the ASL 698 * code. Handles cases like this: 699 * 700 * External (\_SB_.PCI0.ABCD, IntObj) 701 * Scope (_SB_) 702 * { 703 * Device (PCI0) 704 * { 705 * } 706 * } 707 * Method (X) 708 * { 709 * Store (\_SB_.PCI0.ABCD, Local0) 710 * } 711 */ 712 Flags |= ACPI_NS_EXTERNAL; 713 break; 714 715 case PARSEOP_DEFAULT_ARG: 716 717 if (Op->Asl.CompileFlags == OP_IS_RESOURCE_DESC) 718 { 719 Status = LdLoadResourceElements (Op, WalkState); 720 return_ACPI_STATUS (Status); 721 } 722 723 ObjectType = AslMapNamedOpcodeToDataType (Op->Asl.AmlOpcode); 724 break; 725 726 case PARSEOP_SCOPE: 727 /* 728 * The name referenced by Scope(Name) must already exist at this point. 729 * In other words, forward references for Scope() are not supported. 730 * The only real reason for this is that the MS interpreter cannot 731 * handle this case. Perhaps someday this case can go away. 732 */ 733 Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ACPI_TYPE_ANY, 734 ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, WalkState, &Node); 735 if (ACPI_FAILURE (Status)) 736 { 737 if (Status == AE_NOT_FOUND) 738 { 739 /* The name was not found, go ahead and create it */ 740 741 Status = AcpiNsLookup (WalkState->ScopeInfo, Path, 742 ACPI_TYPE_LOCAL_SCOPE, ACPI_IMODE_LOAD_PASS1, 743 Flags, WalkState, &Node); 744 if (ACPI_FAILURE (Status)) 745 { 746 return_ACPI_STATUS (Status); 747 } 748 749 /* However, this is an error -- operand to Scope must exist */ 750 751 if (strlen (Op->Asl.ExternalName) == ACPI_NAMESEG_SIZE) 752 { 753 AslError (ASL_ERROR, ASL_MSG_NOT_FOUND, Op, 754 Op->Asl.ExternalName); 755 } 756 else 757 { 758 AslError (ASL_ERROR, ASL_MSG_NAMEPATH_NOT_EXIST, Op, 759 Op->Asl.ExternalName); 760 } 761 762 goto FinishNode; 763 } 764 765 AslCoreSubsystemError (Op, Status, 766 "Failure from namespace lookup", FALSE); 767 768 return_ACPI_STATUS (Status); 769 } 770 else /* Status AE_OK */ 771 { 772 /* 773 * Do not allow references to external scopes from the DSDT. 774 * This is because the DSDT is always loaded first, and the 775 * external reference cannot be resolved -- causing a runtime 776 * error because Scope() must be resolved immediately. 777 * 10/2015. 778 */ 779 if ((Node->Flags & ANOBJ_IS_EXTERNAL) && 780 (ACPI_COMPARE_NAMESEG (AslGbl_TableSignature, "DSDT"))) 781 { 782 /* However, allowed if the reference is within a method */ 783 784 MethodOp = Op->Asl.Parent; 785 while (MethodOp && 786 (MethodOp->Asl.ParseOpcode != PARSEOP_METHOD)) 787 { 788 MethodOp = MethodOp->Asl.Parent; 789 } 790 791 if (!MethodOp) 792 { 793 /* Not in a control method, error */ 794 795 AslError (ASL_ERROR, ASL_MSG_CROSS_TABLE_SCOPE, Op, NULL); 796 } 797 } 798 } 799 800 /* We found a node with this name, now check the type */ 801 802 switch (Node->Type) 803 { 804 case ACPI_TYPE_LOCAL_SCOPE: 805 case ACPI_TYPE_DEVICE: 806 case ACPI_TYPE_POWER: 807 case ACPI_TYPE_PROCESSOR: 808 case ACPI_TYPE_THERMAL: 809 810 /* These are acceptable types - they all open a new scope */ 811 break; 812 813 case ACPI_TYPE_INTEGER: 814 case ACPI_TYPE_STRING: 815 case ACPI_TYPE_BUFFER: 816 /* 817 * These types we will allow, but we will change the type. 818 * This enables some existing code of the form: 819 * 820 * Name (DEB, 0) 821 * Scope (DEB) { ... } 822 * 823 * Which is used to workaround the fact that the MS interpreter 824 * does not allow Scope() forward references. 825 */ 826 sprintf (AslGbl_MsgBuffer, "%s [%s], changing type to [Scope]", 827 Op->Asl.ExternalName, AcpiUtGetTypeName (Node->Type)); 828 AslError (ASL_REMARK, ASL_MSG_SCOPE_TYPE, Op, AslGbl_MsgBuffer); 829 830 /* Switch the type to scope, open the new scope */ 831 832 Node->Type = ACPI_TYPE_LOCAL_SCOPE; 833 Status = AcpiDsScopeStackPush (Node, ACPI_TYPE_LOCAL_SCOPE, 834 WalkState); 835 if (ACPI_FAILURE (Status)) 836 { 837 return_ACPI_STATUS (Status); 838 } 839 break; 840 841 default: 842 843 /* All other types are an error */ 844 845 sprintf (AslGbl_MsgBuffer, "%s [%s]", Op->Asl.ExternalName, 846 AcpiUtGetTypeName (Node->Type)); 847 AslError (ASL_ERROR, ASL_MSG_SCOPE_TYPE, Op, AslGbl_MsgBuffer); 848 849 /* 850 * However, switch the type to be an actual scope so 851 * that compilation can continue without generating a whole 852 * cascade of additional errors. Open the new scope. 853 */ 854 Node->Type = ACPI_TYPE_LOCAL_SCOPE; 855 Status = AcpiDsScopeStackPush (Node, ACPI_TYPE_LOCAL_SCOPE, 856 WalkState); 857 if (ACPI_FAILURE (Status)) 858 { 859 return_ACPI_STATUS (Status); 860 } 861 break; 862 } 863 864 Status = AE_OK; 865 goto FinishNode; 866 867 default: 868 869 ObjectType = AslMapNamedOpcodeToDataType (Op->Asl.AmlOpcode); 870 break; 871 } 872 873 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Loading name: %s, (%s)\n", 874 Op->Asl.ExternalName, AcpiUtGetTypeName (ObjectType))); 875 876 /* The name must not already exist */ 877 878 Flags |= ACPI_NS_ERROR_IF_FOUND; 879 880 /* 881 * For opcodes that enter new names into the namespace, 882 * all prefix NameSegs must exist. 883 */ 884 WalkState->OpInfo = AcpiPsGetOpcodeInfo (Op->Asl.AmlOpcode); 885 if (((WalkState->OpInfo->Flags & AML_NAMED) || 886 (WalkState->OpInfo->Flags & AML_CREATE)) && 887 (Op->Asl.AmlOpcode != AML_EXTERNAL_OP)) 888 { 889 Flags |= ACPI_NS_PREFIX_MUST_EXIST; 890 } 891 892 /* 893 * Enter the named type into the internal namespace. We enter the name 894 * as we go downward in the parse tree. Any necessary subobjects that 895 * involve arguments to the opcode must be created as we go back up the 896 * parse tree later. 897 */ 898 Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ObjectType, 899 ACPI_IMODE_LOAD_PASS1, Flags, WalkState, &Node); 900 if (ACPI_FAILURE (Status)) 901 { 902 if (Status == AE_ALREADY_EXISTS) 903 { 904 /* The name already exists in this scope */ 905 906 if (Node->Type == ACPI_TYPE_LOCAL_SCOPE) 907 { 908 /* Allow multiple references to the same scope */ 909 910 Node->Type = (UINT8) ObjectType; 911 Status = AE_OK; 912 } 913 else if ((Node->Flags & ANOBJ_IS_EXTERNAL) || 914 (Op->Asl.ParseOpcode == PARSEOP_EXTERNAL)) 915 { 916 Status = LdAnalyzeExternals (Node, Op, ActualObjectType, 917 ObjectType, WalkState); 918 if (ACPI_FAILURE (Status)) 919 { 920 if (Status == AE_ERROR) 921 { 922 /* 923 * The use of AE_ERROR here indicates that there was a 924 * compiler error emitted in LdAnalyzeExternals which 925 * means that the caller should proceed to the next Op 926 * for analysis of subsequent parse objects. 927 */ 928 Status = AE_OK; 929 } 930 return_ACPI_STATUS (Status); 931 } 932 } 933 else 934 { 935 /* Valid error, object already exists */ 936 937 ExternalPath = AcpiNsGetNormalizedPathname (Node, TRUE); 938 939 AslDualParseOpError (ASL_ERROR, ASL_MSG_NAME_EXISTS, Op, 940 ExternalPath, ASL_MSG_FOUND_HERE, Node->Op, 941 ExternalPath); 942 943 if (ExternalPath) 944 { 945 ACPI_FREE (ExternalPath); 946 } 947 return_ACPI_STATUS (AE_OK); 948 } 949 } 950 else if (AE_NOT_FOUND) 951 { 952 /* 953 * One or more prefix NameSegs of the NamePath do not exist 954 * (all of them must exist). Attempt to continue compilation 955 * by setting the current scope to the root. 956 */ 957 Node = AcpiGbl_RootNode; 958 Status = AE_OK; 959 } 960 else 961 { 962 /* Flag all other errors as coming from the ACPICA core */ 963 964 AslCoreSubsystemError (Op, Status, 965 "Failure from namespace lookup", FALSE); 966 return_ACPI_STATUS (Status); 967 } 968 } 969 970 /* Check special names like _WAK and _PTS */ 971 972 LdCheckSpecialNames (Node, Op); 973 974 if (ForceNewScope) 975 { 976 Status = AcpiDsScopeStackPush (Node, ObjectType, WalkState); 977 if (ACPI_FAILURE (Status)) 978 { 979 return_ACPI_STATUS (Status); 980 } 981 } 982 983 FinishNode: 984 /* 985 * Point the parse node to the new namespace node, and point 986 * the Node back to the original Parse node 987 */ 988 Op->Asl.Node = Node; 989 Node->Op = Op; 990 991 /* 992 * Set the actual data type if appropriate (EXTERNAL term only) 993 * As of 11/19/2019, ASL External() does not support parameter 994 * counts. When an External method is loaded, the parameter count is 995 * recorded in the external's arg count parameter. The parameter count may 996 * or may not be known in the declaration. If the value of this node turns 997 * out to be ASL_EXTERNAL_METHOD_UNKNOWN_PARAMS, it indicates that 998 * we do not know the parameter count and that we must look at the usage of 999 * the External method call to get this information. 1000 */ 1001 if (ActualObjectType != ACPI_TYPE_ANY) 1002 { 1003 Node->Type = (UINT8) ActualObjectType; 1004 Node->Value = (UINT32) 1005 Op->Asl.Child->Asl.Next->Asl.Next->Asl.Value.Integer; 1006 } 1007 1008 if (Op->Asl.ParseOpcode == PARSEOP_METHOD) 1009 { 1010 /* 1011 * Get the method argument count from "Extra" and save 1012 * it in the namespace node 1013 */ 1014 Node->Value = (UINT32) Op->Asl.Extra; 1015 } 1016 1017 return_ACPI_STATUS (Status); 1018 } 1019 1020 1021 /******************************************************************************* 1022 * 1023 * FUNCTION: LdAnalyzeExternals 1024 * 1025 * PARAMETERS: Node - Node that represents the named object 1026 * Op - Named object declaring this named object 1027 * ExternalOpType - Type of ExternalOp 1028 * ObjectType - Type of Declared object 1029 * WalkState - Current WalkState 1030 * 1031 * RETURN: Status 1032 * 1033 * DESCRIPTION: Node and Op represents an identically named object declaration 1034 * that is either declared by the ASL external keyword or declared 1035 * by operators that declare named objects (i.e. Name, Device, 1036 * OperationRegion, and etc.). This function ensures that the 1037 * declarations do not contradict each other. 1038 * 1039 ******************************************************************************/ 1040 1041 static ACPI_STATUS 1042 LdAnalyzeExternals ( 1043 ACPI_NAMESPACE_NODE *Node, 1044 ACPI_PARSE_OBJECT *Op, 1045 ACPI_OBJECT_TYPE ExternalOpType, 1046 ACPI_OBJECT_TYPE ObjectType, 1047 ACPI_WALK_STATE *WalkState) 1048 { 1049 ACPI_STATUS Status = AE_OK; 1050 ACPI_OBJECT_TYPE ActualExternalOpType; 1051 ACPI_OBJECT_TYPE ActualOpType; 1052 ACPI_PARSE_OBJECT *ExternalOp; 1053 ACPI_PARSE_OBJECT *ActualOp; 1054 1055 1056 /* 1057 * The declaration represented by Node and Op must have the same type. 1058 * The type of the external Op is represented by ExternalOpType. However, 1059 * the type of the pre-existing declaration depends on whether if Op 1060 * is an external declaration or an actual declaration. 1061 */ 1062 if (Op->Asl.ParseOpcode == PARSEOP_EXTERNAL) 1063 { 1064 ActualExternalOpType = ExternalOpType; 1065 ActualOpType = Node->Type; 1066 } 1067 else 1068 { 1069 ActualExternalOpType = Node->Type; 1070 ActualOpType = ObjectType; 1071 } 1072 1073 if ((ActualOpType != ACPI_TYPE_ANY) && 1074 (ActualExternalOpType != ACPI_TYPE_ANY) && 1075 (ActualExternalOpType != ActualOpType)) 1076 { 1077 if (Op->Asl.ParseOpcode == PARSEOP_EXTERNAL && 1078 Node->Op->Asl.ParseOpcode == PARSEOP_EXTERNAL) 1079 { 1080 AslDualParseOpError (ASL_ERROR, 1081 ASL_MSG_DUPLICATE_EXTERN_MISMATCH, Op, NULL, 1082 ASL_MSG_DUPLICATE_EXTERN_FOUND_HERE, Node->Op, NULL); 1083 } 1084 else 1085 { 1086 if (Op->Asl.ParseOpcode == PARSEOP_EXTERNAL && 1087 Node->Op->Asl.ParseOpcode != PARSEOP_EXTERNAL) 1088 { 1089 ExternalOp = Op; 1090 ActualOp = Node->Op; 1091 } 1092 else 1093 { 1094 ExternalOp = Node->Op; 1095 ActualOp = Op; 1096 } 1097 AslDualParseOpError (ASL_ERROR, 1098 ASL_MSG_DECLARATION_TYPE_MISMATCH, ExternalOp, NULL, 1099 ASL_MSG_TYPE_MISMATCH_FOUND_HERE, ActualOp, NULL); 1100 } 1101 } 1102 1103 if ((Node->Flags & ANOBJ_IS_EXTERNAL) && 1104 (Op->Asl.ParseOpcode != PARSEOP_EXTERNAL)) 1105 { 1106 /* 1107 * Allow one create on an object or segment that was 1108 * previously declared External 1109 */ 1110 Node->Flags &= ~ANOBJ_IS_EXTERNAL; 1111 Node->Type = (UINT8) ObjectType; 1112 1113 /* Just retyped a node, probably will need to open a scope */ 1114 1115 if (AcpiNsOpensScope (ObjectType)) 1116 { 1117 Status = AcpiDsScopeStackPush (Node, ObjectType, WalkState); 1118 if (ACPI_FAILURE (Status)) 1119 { 1120 return (Status); 1121 } 1122 } 1123 1124 Status = AE_OK; 1125 } 1126 else if (!(Node->Flags & ANOBJ_IS_EXTERNAL) && 1127 (Op->Asl.ParseOpcode == PARSEOP_EXTERNAL)) 1128 { 1129 /* 1130 * Allow externals in same scope as the definition of the 1131 * actual object. Similar to C. Allows multiple definition 1132 * blocks that refer to each other in the same file. 1133 */ 1134 Status = AE_OK; 1135 } 1136 else if ((Node->Flags & ANOBJ_IS_EXTERNAL) && 1137 (Op->Asl.ParseOpcode == PARSEOP_EXTERNAL) && 1138 (ObjectType == ACPI_TYPE_ANY)) 1139 { 1140 /* Allow update of externals of unknown type. */ 1141 1142 if (AcpiNsOpensScope (ExternalOpType)) 1143 { 1144 Node->Type = (UINT8) ExternalOpType; 1145 Status = AE_OK; 1146 } 1147 else 1148 { 1149 sprintf (AslGbl_MsgBuffer, "%s [%s]", Op->Asl.ExternalName, 1150 AcpiUtGetTypeName (Node->Type)); 1151 AslError (ASL_ERROR, ASL_MSG_SCOPE_TYPE, Op, AslGbl_MsgBuffer); 1152 Status = AE_ERROR; 1153 } 1154 } 1155 1156 return (Status); 1157 } 1158 1159 1160 /******************************************************************************* 1161 * 1162 * FUNCTION: LdCheckSpecialNames 1163 * 1164 * PARAMETERS: Node - Node that represents the named object 1165 * Op - Named object declaring this named object 1166 * 1167 * RETURN: None 1168 * 1169 * DESCRIPTION: Check if certain named objects are declared in the incorrect 1170 * scope. Special named objects are listed in 1171 * AslGbl_SpecialNamedObjects and can only be declared at the root 1172 * scope. _UID inside of a processor declaration must not be a 1173 * string. 1174 * 1175 ******************************************************************************/ 1176 1177 static void 1178 LdCheckSpecialNames ( 1179 ACPI_NAMESPACE_NODE *Node, 1180 ACPI_PARSE_OBJECT *Op) 1181 { 1182 UINT32 i; 1183 1184 1185 for (i = 0; i < MAX_SPECIAL_NAMES; i++) 1186 { 1187 if (ACPI_COMPARE_NAMESEG(Node->Name.Ascii, AslGbl_SpecialNamedObjects[i]) && 1188 Node->Parent != AcpiGbl_RootNode) 1189 { 1190 AslError (ASL_ERROR, ASL_MSG_INVALID_SPECIAL_NAME, Op, Op->Asl.ExternalName); 1191 return; 1192 } 1193 } 1194 1195 if (ACPI_COMPARE_NAMESEG (Node->Name.Ascii, "_UID") && 1196 Node->Parent->Type == ACPI_TYPE_PROCESSOR && 1197 Node->Type == ACPI_TYPE_STRING) 1198 { 1199 AslError (ASL_ERROR, ASL_MSG_INVALID_PROCESSOR_UID , Op, "found a string"); 1200 } 1201 } 1202 1203 1204 /******************************************************************************* 1205 * 1206 * FUNCTION: LdNamespace2Begin 1207 * 1208 * PARAMETERS: ASL_WALK_CALLBACK 1209 * 1210 * RETURN: Status 1211 * 1212 * DESCRIPTION: Descending callback used during the pass 2 parse tree walk. 1213 * Second pass resolves some forward references. 1214 * 1215 * Notes: 1216 * Currently only needs to handle the Alias operator. 1217 * Could be used to allow forward references from the Scope() operator, but 1218 * the MS interpreter does not allow this, so this compiler does not either. 1219 * 1220 ******************************************************************************/ 1221 1222 static ACPI_STATUS 1223 LdNamespace2Begin ( 1224 ACPI_PARSE_OBJECT *Op, 1225 UINT32 Level, 1226 void *Context) 1227 { 1228 ACPI_WALK_STATE *WalkState = (ACPI_WALK_STATE *) Context; 1229 ACPI_STATUS Status; 1230 ACPI_NAMESPACE_NODE *Node; 1231 ACPI_OBJECT_TYPE ObjectType; 1232 BOOLEAN ForceNewScope = FALSE; 1233 ACPI_PARSE_OBJECT *Arg; 1234 char *Path; 1235 ACPI_NAMESPACE_NODE *TargetNode; 1236 1237 1238 ACPI_FUNCTION_NAME (LdNamespace2Begin); 1239 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Op %p [%s]\n", 1240 Op, Op->Asl.ParseOpName)); 1241 1242 1243 /* Ignore Ops with no namespace node */ 1244 1245 Node = Op->Asl.Node; 1246 if (!Node) 1247 { 1248 return (AE_OK); 1249 } 1250 1251 /* Get the type to determine if we should push the scope */ 1252 1253 if ((Op->Asl.ParseOpcode == PARSEOP_DEFAULT_ARG) && 1254 (Op->Asl.CompileFlags == OP_IS_RESOURCE_DESC)) 1255 { 1256 ObjectType = ACPI_TYPE_LOCAL_RESOURCE; 1257 } 1258 else 1259 { 1260 ObjectType = AslMapNamedOpcodeToDataType (Op->Asl.AmlOpcode); 1261 } 1262 1263 /* Push scope for Resource Templates */ 1264 1265 if (Op->Asl.ParseOpcode == PARSEOP_NAME) 1266 { 1267 if (Op->Asl.CompileFlags & OP_IS_RESOURCE_DESC) 1268 { 1269 ForceNewScope = TRUE; 1270 } 1271 } 1272 1273 /* Push the scope stack */ 1274 1275 if (ForceNewScope || AcpiNsOpensScope (ObjectType)) 1276 { 1277 Status = AcpiDsScopeStackPush (Node, ObjectType, WalkState); 1278 if (ACPI_FAILURE (Status)) 1279 { 1280 return_ACPI_STATUS (Status); 1281 } 1282 } 1283 1284 if (Op->Asl.ParseOpcode == PARSEOP_ALIAS) 1285 { 1286 /* 1287 * Complete the alias node by getting and saving the target node. 1288 * First child is the alias target 1289 */ 1290 Arg = Op->Asl.Child; 1291 1292 /* Get the target pathname */ 1293 1294 Path = Arg->Asl.Namepath; 1295 if (!Path) 1296 { 1297 Status = UtInternalizeName (Arg->Asl.ExternalName, &Path); 1298 if (ACPI_FAILURE (Status)) 1299 { 1300 return (Status); 1301 } 1302 } 1303 1304 /* Get the NS node associated with the target. It must exist. */ 1305 1306 Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ACPI_TYPE_ANY, 1307 ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE, 1308 WalkState, &TargetNode); 1309 if (ACPI_FAILURE (Status)) 1310 { 1311 if (Status == AE_NOT_FOUND) 1312 { 1313 /* Standalone NameSeg vs. NamePath */ 1314 1315 if (strlen (Arg->Asl.ExternalName) == ACPI_NAMESEG_SIZE) 1316 { 1317 AslError (ASL_ERROR, ASL_MSG_NOT_FOUND, Op, 1318 Arg->Asl.ExternalName); 1319 } 1320 else 1321 { 1322 AslError (ASL_ERROR, ASL_MSG_NAMEPATH_NOT_EXIST, Op, 1323 Arg->Asl.ExternalName); 1324 } 1325 1326 #if 0 1327 /* 1328 * NOTE: Removed 10/2018 to enhance compiler error reporting. No 1329 * regressions seen. 1330 */ 1331 /* 1332 * The name was not found, go ahead and create it. 1333 * This prevents more errors later. 1334 */ 1335 Status = AcpiNsLookup (WalkState->ScopeInfo, Path, 1336 ACPI_TYPE_ANY, ACPI_IMODE_LOAD_PASS1, 1337 ACPI_NS_NO_UPSEARCH, WalkState, &Node); 1338 #endif 1339 return (Status); 1340 /* Removed: return (AE_OK)*/ 1341 } 1342 1343 AslCoreSubsystemError (Op, Status, 1344 "Failure from namespace lookup", FALSE); 1345 return (AE_OK); 1346 } 1347 1348 /* Save the target node within the alias node */ 1349 1350 Node->Object = ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, TargetNode); 1351 } 1352 1353 return (AE_OK); 1354 } 1355 1356 1357 /******************************************************************************* 1358 * 1359 * FUNCTION: LdCommonNamespaceEnd 1360 * 1361 * PARAMETERS: ASL_WALK_CALLBACK 1362 * 1363 * RETURN: Status 1364 * 1365 * DESCRIPTION: Ascending callback used during the loading of the namespace, 1366 * We only need to worry about managing the scope stack here. 1367 * 1368 ******************************************************************************/ 1369 1370 static ACPI_STATUS 1371 LdCommonNamespaceEnd ( 1372 ACPI_PARSE_OBJECT *Op, 1373 UINT32 Level, 1374 void *Context) 1375 { 1376 ACPI_WALK_STATE *WalkState = (ACPI_WALK_STATE *) Context; 1377 ACPI_OBJECT_TYPE ObjectType; 1378 BOOLEAN ForceNewScope = FALSE; 1379 1380 1381 ACPI_FUNCTION_NAME (LdCommonNamespaceEnd); 1382 1383 1384 /* We are only interested in opcodes that have an associated name */ 1385 1386 if (!Op->Asl.Namepath) 1387 { 1388 return (AE_OK); 1389 } 1390 1391 /* Get the type to determine if we should pop the scope */ 1392 1393 if ((Op->Asl.ParseOpcode == PARSEOP_DEFAULT_ARG) && 1394 (Op->Asl.CompileFlags == OP_IS_RESOURCE_DESC)) 1395 { 1396 /* TBD: Merge into AcpiDsMapNamedOpcodeToDataType */ 1397 1398 ObjectType = ACPI_TYPE_LOCAL_RESOURCE; 1399 } 1400 else 1401 { 1402 ObjectType = AslMapNamedOpcodeToDataType (Op->Asl.AmlOpcode); 1403 } 1404 1405 /* Pop scope that was pushed for Resource Templates */ 1406 1407 if (Op->Asl.ParseOpcode == PARSEOP_NAME) 1408 { 1409 if (Op->Asl.CompileFlags & OP_IS_RESOURCE_DESC) 1410 { 1411 ForceNewScope = TRUE; 1412 } 1413 } 1414 1415 /* Pop the scope stack */ 1416 1417 if (ForceNewScope || AcpiNsOpensScope (ObjectType)) 1418 { 1419 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, 1420 "(%s): Popping scope for Op [%s] %p\n", 1421 AcpiUtGetTypeName (ObjectType), Op->Asl.ParseOpName, Op)); 1422 1423 (void) AcpiDsScopeStackPop (WalkState); 1424 } 1425 1426 return (AE_OK); 1427 } 1428