1/****************************************************************************** 2 * 3 * Module Name: asllookup- Namespace lookup |
4 * $Revision: 1.103 $ |
5 * 6 *****************************************************************************/ 7 8/****************************************************************************** 9 * 10 * 1. Copyright Notice 11 * |
12 * Some or all of this work - Copyright (c) 1999 - 2007, 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. --- 141 unchanged lines hidden (view full) --- 162 void *Context); 163 164static ACPI_STATUS 165LkNamespaceLocateEnd ( 166 ACPI_PARSE_OBJECT *Op, 167 UINT32 Level, 168 void *Context); 169 |
170static ACPI_STATUS 171LkIsObjectUsed ( 172 ACPI_HANDLE ObjHandle, 173 UINT32 Level, 174 void *Context, 175 void **ReturnValue); |
176 |
177 |
178/******************************************************************************* 179 * 180 * FUNCTION: LsDoOneNamespaceObject 181 * 182 * PARAMETERS: ACPI_WALK_CALLBACK 183 * 184 * RETURN: Status 185 * --- 12 unchanged lines hidden (view full) --- 198 ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle; 199 ACPI_OPERAND_OBJECT *ObjDesc; 200 ACPI_PARSE_OBJECT *Op; 201 202 203 Gbl_NumNamespaceObjects++; 204 205 FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, "%5d [%d] %*s %4.4s - %s", |
206 Gbl_NumNamespaceObjects, Level, (Level * 3), " ", 207 &Node->Name, 208 AcpiUtGetTypeName (Node->Type)); |
209 210 Op = Node->Op; 211 ObjDesc = ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, Node->Object); 212 213 if (!Op) 214 { 215 FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, "\n"); 216 return (AE_OK); 217 } 218 219 220 if ((ObjDesc) && |
221 (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) == ACPI_DESC_TYPE_OPERAND)) |
222 { 223 switch (Node->Type) 224 { 225 case ACPI_TYPE_INTEGER: 226 227 FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, 228 " [Initial Value 0x%8.8X%8.8X]", 229 ACPI_FORMAT_UINT64 (ObjDesc->Integer.Value)); --- 130 unchanged lines hidden (view full) --- 360 } 361 if ((Op->Asl.ParseOpcode == PARSEOP_NAMESEG) || 362 (Op->Asl.ParseOpcode == PARSEOP_NAMESTRING)) 363 { 364 Op = Op->Asl.Next; 365 } 366 Op = Op->Asl.Child; 367 |
368 if (Op && (Op->Asl.ParseOpcode == PARSEOP_INTEGER)) |
369 { 370 FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, 371 " [Initial Length 0x%.2X bytes]", 372 Op->Asl.Value.Integer); 373 } 374 break; 375 376 377 case ACPI_TYPE_METHOD: 378 379 FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, 380 " [Code Length 0x%.4X bytes]", 381 Op->Asl.AmlSubtreeLength); 382 break; 383 384 |
385 case ACPI_TYPE_LOCAL_RESOURCE: 386 387 FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, 388 " [Desc Offset 0x%.4X Bytes]", Node->Value); 389 break; 390 391 392 case ACPI_TYPE_LOCAL_RESOURCE_FIELD: 393 394 if (Node->Flags & 0x80) 395 { 396 FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, 397 " [Field Offset 0x%.4X Bits 0x%.4X Bytes]", 398 Node->Value, Node->Value / 8); 399 } 400 else 401 { 402 FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, 403 " [Field Offset 0x%.4X Bytes]", Node->Value); 404 } 405 break; 406 407 |
408 default: 409 /* Nothing to do for other types */ 410 break; 411 } 412 } 413 414 FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, "\n"); 415 return (AE_OK); 416} 417 418 |
419void 420LsSetupNsList (void * Handle) 421{ 422 423 Gbl_NsOutputFlag = TRUE; 424 Gbl_Files[ASL_FILE_NAMESPACE_OUTPUT].Handle = Handle; 425} 426 427 |
428/******************************************************************************* 429 * 430 * FUNCTION: LsDisplayNamespace 431 * 432 * PARAMETERS: None 433 * 434 * RETURN: Status 435 * --- 10 unchanged lines hidden (view full) --- 446 ACPI_STATUS Status; 447 448 449 if (!Gbl_NsOutputFlag) 450 { 451 return (AE_OK); 452 } 453 |
454 Gbl_NumNamespaceObjects = 0; 455 |
456 /* File header */ 457 458 FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, "Contents of ACPI Namespace\n\n"); 459 FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, "Count Depth Name - Type\n\n"); 460 461 /* Walk entire namespace from the root */ 462 463 Status = AcpiNsWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, --- 70 unchanged lines hidden (view full) --- 534 } 535 536 return (FALSE); 537} 538 539 540/******************************************************************************* 541 * |
542 * FUNCTION: LkGetNameOp 543 * 544 * PARAMETERS: Op - Current Op 545 * 546 * RETURN: NameOp associated with the input op 547 * 548 * DESCRIPTION: Find the name declaration op associated with the operator 549 * 550 ******************************************************************************/ 551 552ACPI_PARSE_OBJECT * 553LkGetNameOp ( 554 ACPI_PARSE_OBJECT *Op) 555{ 556 const ACPI_OPCODE_INFO *OpInfo; 557 ACPI_PARSE_OBJECT *NameOp = Op; 558 559 560 OpInfo = AcpiPsGetOpcodeInfo (Op->Asl.AmlOpcode); 561 562 563 /* Get the NamePath from the appropriate place */ 564 565 if (OpInfo->Flags & AML_NAMED) 566 { 567 /* For nearly all NAMED operators, the name reference is the first child */ 568 569 NameOp = Op->Asl.Child; 570 if (Op->Asl.AmlOpcode == AML_ALIAS_OP) 571 { 572 /* 573 * ALIAS is the only oddball opcode, the name declaration 574 * (alias name) is the second operand 575 */ 576 NameOp = Op->Asl.Child->Asl.Next; 577 } 578 } 579 else if (OpInfo->Flags & AML_CREATE) 580 { 581 /* Name must appear as the last parameter */ 582 583 NameOp = Op->Asl.Child; 584 while (!(NameOp->Asl.CompileFlags & NODE_IS_NAME_DECLARATION)) 585 { 586 NameOp = NameOp->Asl.Next; 587 } 588 } 589 590 return (NameOp); 591} 592 593 594/******************************************************************************* 595 * 596 * FUNCTION: LkIsObjectUsed 597 * 598 * PARAMETERS: ACPI_WALK_CALLBACK 599 * 600 * RETURN: Status 601 * 602 * DESCRIPTION: Check for an unreferenced namespace object and emit a warning. 603 * We have to be careful, because some types and names are 604 * typically or always unreferenced, we don't want to issue 605 * excessive warnings. 606 * 607 ******************************************************************************/ 608 609static ACPI_STATUS 610LkIsObjectUsed ( 611 ACPI_HANDLE ObjHandle, 612 UINT32 Level, 613 void *Context, 614 void **ReturnValue) 615{ 616 ACPI_NAMESPACE_NODE *Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, ObjHandle); 617 618 619 /* Referenced flag is set during the namespace xref */ 620 621 if (Node->Flags & ANOBJ_IS_REFERENCED) 622 { 623 return (AE_OK); 624 } 625 626 /* 627 * Ignore names that start with an underscore, 628 * these are the reserved ACPI names and are typically not referenced, 629 * they are called by the host OS. 630 */ 631 if (Node->Name.Ascii[0] == '_') 632 { 633 return (AE_OK); 634 } 635 636 /* There are some types that are typically not referenced, ignore them */ 637 638 switch (Node->Type) 639 { 640 case ACPI_TYPE_DEVICE: 641 case ACPI_TYPE_PROCESSOR: 642 case ACPI_TYPE_POWER: 643 case ACPI_TYPE_LOCAL_RESOURCE: 644 return (AE_OK); 645 646 default: 647 break; 648 } 649 650 /* All others are valid unreferenced namespace objects */ 651 652 if (Node->Op) 653 { 654 AslError (ASL_WARNING2, ASL_MSG_NOT_REFERENCED, LkGetNameOp (Node->Op), NULL); 655 } 656 return (AE_OK); 657} 658 659 660/******************************************************************************* 661 * 662 * FUNCTION: LkFindUnreferencedObjects 663 * 664 * PARAMETERS: None 665 * 666 * RETURN: None 667 * 668 * DESCRIPTION: Namespace walk to find objects that are not referenced in any 669 * way. Must be called after the namespace has been cross 670 * referenced. 671 * 672 ******************************************************************************/ 673 674void 675LkFindUnreferencedObjects ( 676 void) 677{ 678 679 /* Walk entire namespace from the supplied root */ 680 681 (void) AcpiNsWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, 682 ACPI_UINT32_MAX, FALSE, LkIsObjectUsed, 683 NULL, NULL); 684} 685 686 687/******************************************************************************* 688 * |
689 * FUNCTION: LkCrossReferenceNamespace 690 * 691 * PARAMETERS: None 692 * 693 * RETURN: Status 694 * 695 * DESCRIPTION: Perform a cross reference check of the parse tree against the 696 * namespace. Every named referenced within the parse tree --- 127 unchanged lines hidden (view full) --- 824 ACPI_PARSE_OBJECT *OwningOp; 825 ACPI_PARSE_OBJECT *SpaceIdOp; 826 UINT32 MinimumLength; 827 UINT32 Temp; 828 const ACPI_OPCODE_INFO *OpInfo; 829 UINT32 Flags; 830 831 |
832 ACPI_FUNCTION_TRACE_PTR (LkNamespaceLocateBegin, Op); |
833 834 /* 835 * If this node is the actual declaration of a name 836 * [such as the XXXX name in "Method (XXXX)"], 837 * we are not interested in it here. We only care about names that are 838 * references to other objects within the namespace and the parent objects 839 * of name declarations 840 */ --- 30 unchanged lines hidden (view full) --- 871 */ 872 Flags |= ACPI_NS_DONT_OPEN_SCOPE; 873 } 874 875 /* Get the NamePath from the appropriate place */ 876 877 if (OpInfo->Flags & AML_NAMED) 878 { |
879 /* For nearly all NAMED operators, the name reference is the first child */ |
880 881 Path = Op->Asl.Child->Asl.Value.String; 882 if (Op->Asl.AmlOpcode == AML_ALIAS_OP) 883 { 884 /* 885 * ALIAS is the only oddball opcode, the name declaration 886 * (alias name) is the second operand 887 */ --- 24 unchanged lines hidden (view full) --- 912 * Lookup the name in the namespace. Name must exist at this point, or it 913 * is an invalid reference. 914 * 915 * The namespace is also used as a lookup table for references to resource 916 * descriptors and the fields within them. 917 */ 918 Gbl_NsLookupCount++; 919 |
920 Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ObjectType, |
921 ACPI_IMODE_EXECUTE, Flags, WalkState, &(Node)); 922 if (ACPI_FAILURE (Status)) 923 { 924 if (Status == AE_NOT_FOUND) 925 { 926 /* 927 * We didn't find the name reference by path -- we can qualify this 928 * a little better before we print an error message --- 57 unchanged lines hidden (view full) --- 986 } 987 } 988 989 Status = AE_OK; 990 } 991 return (Status); 992 } 993 |
994 /* Check for a reference vs. name declaration */ 995 996 if (!(OpInfo->Flags & AML_NAMED) && 997 !(OpInfo->Flags & AML_CREATE)) 998 { 999 /* This node has been referenced, mark it for reference check */ 1000 1001 Node->Flags |= ANOBJ_IS_REFERENCED; 1002 } 1003 |
1004 /* Attempt to optimize the NamePath */ 1005 1006 OptOptimizeNamePath (Op, OpInfo->Flags, WalkState, Path, Node); 1007 1008 /* |
1009 * 1) Dereference an alias (A name reference that is an alias) 1010 * Aliases are not nested, the alias always points to the final object |
1011 */ 1012 if ((Op->Asl.ParseOpcode != PARSEOP_ALIAS) && 1013 (Node->Type == ACPI_TYPE_LOCAL_ALIAS)) 1014 { 1015 /* This node points back to the original PARSEOP_ALIAS */ 1016 1017 NextOp = Node->Op; 1018 1019 /* The first child is the alias target op */ 1020 1021 NextOp = NextOp->Asl.Child; 1022 |
1023 /* That in turn points back to original target alias node */ |
1024 1025 if (NextOp->Asl.Node) 1026 { 1027 Node = NextOp->Asl.Node; 1028 } |
1029 1030 /* Else - forward reference to alias, will be resolved later */ |
1031 } 1032 |
1033 /* 2) Check for a reference to a resource descriptor */ |
1034 |
1035 if ((Node->Type == ACPI_TYPE_LOCAL_RESOURCE_FIELD) || |
1036 (Node->Type == ACPI_TYPE_LOCAL_RESOURCE)) 1037 { 1038 /* 1039 * This was a reference to a field within a resource descriptor. Extract 1040 * the associated field offset (either a bit or byte offset depending on 1041 * the field type) and change the named reference into an integer for 1042 * AML code generation 1043 */ --- 56 unchanged lines hidden (view full) --- 1100 Op->Asl.AmlLength = 0; 1101 Op->Asl.ParseOpcode = PARSEOP_INTEGER; 1102 Op->Asl.Value.Integer = (UINT64) Temp; 1103 Op->Asl.CompileFlags |= NODE_IS_RESOURCE_FIELD; 1104 1105 OpcGenerateAmlOpcode (Op); 1106 } 1107 |
1108 /* 3) Check for a method invocation */ |
1109 1110 else if ((((Op->Asl.ParseOpcode == PARSEOP_NAMESTRING) || (Op->Asl.ParseOpcode == PARSEOP_NAMESEG)) && 1111 (Node->Type == ACPI_TYPE_METHOD) && 1112 (Op->Asl.Parent) && 1113 (Op->Asl.Parent->Asl.ParseOpcode != PARSEOP_METHOD)) || 1114 1115 (Op->Asl.ParseOpcode == PARSEOP_METHODCALL)) 1116 { --- 69 unchanged lines hidden (view full) --- 1186 else 1187 { 1188 AslError (ASL_ERROR, ASL_MSG_ARG_COUNT_HI, Op, MsgBuffer); 1189 } 1190 } 1191 } 1192 } 1193 |
1194 /* 4) Check for an ASL Field definition */ |
1195 1196 else if ((Op->Asl.Parent) && 1197 ((Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_FIELD) || 1198 (Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_BANKFIELD))) 1199 { 1200 /* 1201 * Offset checking for fields. If the parent operation region has a 1202 * constant length (known at compile time), we can check fields --- 124 unchanged lines hidden (view full) --- 1327 ACPI_PARSE_OBJECT *Op, 1328 UINT32 Level, 1329 void *Context) 1330{ 1331 ACPI_WALK_STATE *WalkState = (ACPI_WALK_STATE *) Context; 1332 const ACPI_OPCODE_INFO *OpInfo; 1333 1334 |
1335 ACPI_FUNCTION_TRACE (LkNamespaceLocateEnd); |
1336 1337 1338 /* We are only interested in opcodes that have an associated name */ 1339 1340 OpInfo = AcpiPsGetOpcodeInfo (Op->Asl.AmlOpcode); 1341 if (!(OpInfo->Flags & AML_NAMED)) 1342 { 1343 return (AE_OK); --- 27 unchanged lines hidden --- |