1 /******************************************************************************* 2 * 3 * Module Name: dbnames - Debugger commands for the acpi namespace 4 * 5 ******************************************************************************/ 6 7 /****************************************************************************** 8 * 9 * 1. Copyright Notice 10 * 11 * Some or all of this work - Copyright (c) 1999 - 2018, Intel Corp. 12 * All rights reserved. 13 * 14 * 2. License 15 * 16 * 2.1. This is your license from Intel Corp. under its intellectual property 17 * rights. You may have additional license terms from the party that provided 18 * you this software, covering your right to use that party's intellectual 19 * property rights. 20 * 21 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a 22 * copy of the source code appearing in this file ("Covered Code") an 23 * irrevocable, perpetual, worldwide license under Intel's copyrights in the 24 * base code distributed originally by Intel ("Original Intel Code") to copy, 25 * make derivatives, distribute, use and display any portion of the Covered 26 * Code in any form, with the right to sublicense such rights; and 27 * 28 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent 29 * license (with the right to sublicense), under only those claims of Intel 30 * patents that are infringed by the Original Intel Code, to make, use, sell, 31 * offer to sell, and import the Covered Code and derivative works thereof 32 * solely to the minimum extent necessary to exercise the above copyright 33 * license, and in no event shall the patent license extend to any additions 34 * to or modifications of the Original Intel Code. No other license or right 35 * is granted directly or by implication, estoppel or otherwise; 36 * 37 * The above copyright and patent license is granted only if the following 38 * conditions are met: 39 * 40 * 3. Conditions 41 * 42 * 3.1. Redistribution of Source with Rights to Further Distribute Source. 43 * Redistribution of source code of any substantial portion of the Covered 44 * Code or modification with rights to further distribute source must include 45 * the above Copyright Notice, the above License, this list of Conditions, 46 * and the following Disclaimer and Export Compliance provision. In addition, 47 * Licensee must cause all Covered Code to which Licensee contributes to 48 * contain a file documenting the changes Licensee made to create that Covered 49 * Code and the date of any change. Licensee must include in that file the 50 * documentation of any changes made by any predecessor Licensee. Licensee 51 * must include a prominent statement that the modification is derived, 52 * directly or indirectly, from Original Intel Code. 53 * 54 * 3.2. Redistribution of Source with no Rights to Further Distribute Source. 55 * Redistribution of source code of any substantial portion of the Covered 56 * Code or modification without rights to further distribute source must 57 * include the following Disclaimer and Export Compliance provision in the 58 * documentation and/or other materials provided with distribution. In 59 * addition, Licensee may not authorize further sublicense of source of any 60 * portion of the Covered Code, and must include terms to the effect that the 61 * license from Licensee to its licensee is limited to the intellectual 62 * property embodied in the software Licensee provides to its licensee, and 63 * not to intellectual property embodied in modifications its licensee may 64 * make. 65 * 66 * 3.3. Redistribution of Executable. Redistribution in executable form of any 67 * substantial portion of the Covered Code or modification must reproduce the 68 * above Copyright Notice, and the following Disclaimer and Export Compliance 69 * provision in the documentation and/or other materials provided with the 70 * distribution. 71 * 72 * 3.4. Intel retains all right, title, and interest in and to the Original 73 * Intel Code. 74 * 75 * 3.5. Neither the name Intel nor any other trademark owned or controlled by 76 * Intel shall be used in advertising or otherwise to promote the sale, use or 77 * other dealings in products derived from or relating to the Covered Code 78 * without prior written authorization from Intel. 79 * 80 * 4. Disclaimer and Export Compliance 81 * 82 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED 83 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE 84 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, 85 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY 86 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY 87 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A 88 * PARTICULAR PURPOSE. 89 * 90 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES 91 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR 92 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, 93 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY 94 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL 95 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS 96 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY 97 * LIMITED REMEDY. 98 * 99 * 4.3. Licensee shall not export, either directly or indirectly, any of this 100 * software or system incorporating such software without first obtaining any 101 * required license or other approval from the U. S. Department of Commerce or 102 * any other agency or department of the United States Government. In the 103 * event Licensee exports any such software from the United States or 104 * re-exports any such software from a foreign destination, Licensee shall 105 * ensure that the distribution and export/re-export of the software is in 106 * compliance with all laws, regulations, orders, or other restrictions of the 107 * U.S. Export Administration Regulations. Licensee agrees that neither it nor 108 * any of its subsidiaries will export/re-export any technical data, process, 109 * software, or service, directly or indirectly, to any country for which the 110 * United States government or any agency thereof requires an export license, 111 * other governmental approval, or letter of assurance, without first obtaining 112 * such license, approval or letter. 113 * 114 ***************************************************************************** 115 * 116 * Alternatively, you may choose to be licensed under the terms of the 117 * following license: 118 * 119 * Redistribution and use in source and binary forms, with or without 120 * modification, are permitted provided that the following conditions 121 * are met: 122 * 1. Redistributions of source code must retain the above copyright 123 * notice, this list of conditions, and the following disclaimer, 124 * without modification. 125 * 2. Redistributions in binary form must reproduce at minimum a disclaimer 126 * substantially similar to the "NO WARRANTY" disclaimer below 127 * ("Disclaimer") and any redistribution must be conditioned upon 128 * including a substantially similar Disclaimer requirement for further 129 * binary redistribution. 130 * 3. Neither the names of the above-listed copyright holders nor the names 131 * of any contributors may be used to endorse or promote products derived 132 * from this software without specific prior written permission. 133 * 134 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 135 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 136 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 137 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 138 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 139 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 140 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 141 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 142 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 143 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 144 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 145 * 146 * Alternatively, you may choose to be licensed under the terms of the 147 * GNU General Public License ("GPL") version 2 as published by the Free 148 * Software Foundation. 149 * 150 *****************************************************************************/ 151 152 #include <contrib/dev/acpica/include/acpi.h> 153 #include <contrib/dev/acpica/include/accommon.h> 154 #include <contrib/dev/acpica/include/acnamesp.h> 155 #include <contrib/dev/acpica/include/acdebug.h> 156 #include <contrib/dev/acpica/include/acpredef.h> 157 158 159 #define _COMPONENT ACPI_CA_DEBUGGER 160 ACPI_MODULE_NAME ("dbnames") 161 162 163 /* Local prototypes */ 164 165 static ACPI_STATUS 166 AcpiDbWalkAndMatchName ( 167 ACPI_HANDLE ObjHandle, 168 UINT32 NestingLevel, 169 void *Context, 170 void **ReturnValue); 171 172 static ACPI_STATUS 173 AcpiDbWalkForPredefinedNames ( 174 ACPI_HANDLE ObjHandle, 175 UINT32 NestingLevel, 176 void *Context, 177 void **ReturnValue); 178 179 static ACPI_STATUS 180 AcpiDbWalkForSpecificObjects ( 181 ACPI_HANDLE ObjHandle, 182 UINT32 NestingLevel, 183 void *Context, 184 void **ReturnValue); 185 186 static ACPI_STATUS 187 AcpiDbWalkForObjectCounts ( 188 ACPI_HANDLE ObjHandle, 189 UINT32 NestingLevel, 190 void *Context, 191 void **ReturnValue); 192 193 static ACPI_STATUS 194 AcpiDbIntegrityWalk ( 195 ACPI_HANDLE ObjHandle, 196 UINT32 NestingLevel, 197 void *Context, 198 void **ReturnValue); 199 200 static ACPI_STATUS 201 AcpiDbWalkForReferences ( 202 ACPI_HANDLE ObjHandle, 203 UINT32 NestingLevel, 204 void *Context, 205 void **ReturnValue); 206 207 static ACPI_STATUS 208 AcpiDbBusWalk ( 209 ACPI_HANDLE ObjHandle, 210 UINT32 NestingLevel, 211 void *Context, 212 void **ReturnValue); 213 214 /* 215 * Arguments for the Objects command 216 * These object types map directly to the ACPI_TYPES 217 */ 218 static ACPI_DB_ARGUMENT_INFO AcpiDbObjectTypes [] = 219 { 220 {"ANY"}, 221 {"INTEGERS"}, 222 {"STRINGS"}, 223 {"BUFFERS"}, 224 {"PACKAGES"}, 225 {"FIELDS"}, 226 {"DEVICES"}, 227 {"EVENTS"}, 228 {"METHODS"}, 229 {"MUTEXES"}, 230 {"REGIONS"}, 231 {"POWERRESOURCES"}, 232 {"PROCESSORS"}, 233 {"THERMALZONES"}, 234 {"BUFFERFIELDS"}, 235 {"DDBHANDLES"}, 236 {"DEBUG"}, 237 {"REGIONFIELDS"}, 238 {"BANKFIELDS"}, 239 {"INDEXFIELDS"}, 240 {"REFERENCES"}, 241 {"ALIASES"}, 242 {"METHODALIASES"}, 243 {"NOTIFY"}, 244 {"ADDRESSHANDLER"}, 245 {"RESOURCE"}, 246 {"RESOURCEFIELD"}, 247 {"SCOPES"}, 248 {NULL} /* Must be null terminated */ 249 }; 250 251 252 /******************************************************************************* 253 * 254 * FUNCTION: AcpiDbSetScope 255 * 256 * PARAMETERS: Name - New scope path 257 * 258 * RETURN: Status 259 * 260 * DESCRIPTION: Set the "current scope" as maintained by this utility. 261 * The scope is used as a prefix to ACPI paths. 262 * 263 ******************************************************************************/ 264 265 void 266 AcpiDbSetScope ( 267 char *Name) 268 { 269 ACPI_STATUS Status; 270 ACPI_NAMESPACE_NODE *Node; 271 272 273 if (!Name || Name[0] == 0) 274 { 275 AcpiOsPrintf ("Current scope: %s\n", AcpiGbl_DbScopeBuf); 276 return; 277 } 278 279 AcpiDbPrepNamestring (Name); 280 281 if (ACPI_IS_ROOT_PREFIX (Name[0])) 282 { 283 /* Validate new scope from the root */ 284 285 Status = AcpiNsGetNode (AcpiGbl_RootNode, Name, 286 ACPI_NS_NO_UPSEARCH, &Node); 287 if (ACPI_FAILURE (Status)) 288 { 289 goto ErrorExit; 290 } 291 292 AcpiGbl_DbScopeBuf[0] = 0; 293 } 294 else 295 { 296 /* Validate new scope relative to old scope */ 297 298 Status = AcpiNsGetNode (AcpiGbl_DbScopeNode, Name, 299 ACPI_NS_NO_UPSEARCH, &Node); 300 if (ACPI_FAILURE (Status)) 301 { 302 goto ErrorExit; 303 } 304 } 305 306 /* Build the final pathname */ 307 308 if (AcpiUtSafeStrcat (AcpiGbl_DbScopeBuf, sizeof (AcpiGbl_DbScopeBuf), 309 Name)) 310 { 311 Status = AE_BUFFER_OVERFLOW; 312 goto ErrorExit; 313 } 314 315 if (AcpiUtSafeStrcat (AcpiGbl_DbScopeBuf, sizeof (AcpiGbl_DbScopeBuf), 316 "\\")) 317 { 318 Status = AE_BUFFER_OVERFLOW; 319 goto ErrorExit; 320 } 321 322 AcpiGbl_DbScopeNode = Node; 323 AcpiOsPrintf ("New scope: %s\n", AcpiGbl_DbScopeBuf); 324 return; 325 326 ErrorExit: 327 328 AcpiOsPrintf ("Could not attach scope: %s, %s\n", 329 Name, AcpiFormatException (Status)); 330 } 331 332 333 /******************************************************************************* 334 * 335 * FUNCTION: AcpiDbDumpNamespace 336 * 337 * PARAMETERS: StartArg - Node to begin namespace dump 338 * DepthArg - Maximum tree depth to be dumped 339 * 340 * RETURN: None 341 * 342 * DESCRIPTION: Dump entire namespace or a subtree. Each node is displayed 343 * with type and other information. 344 * 345 ******************************************************************************/ 346 347 void 348 AcpiDbDumpNamespace ( 349 char *StartArg, 350 char *DepthArg) 351 { 352 ACPI_HANDLE SubtreeEntry = AcpiGbl_RootNode; 353 UINT32 MaxDepth = ACPI_UINT32_MAX; 354 355 356 /* No argument given, just start at the root and dump entire namespace */ 357 358 if (StartArg) 359 { 360 SubtreeEntry = AcpiDbConvertToNode (StartArg); 361 if (!SubtreeEntry) 362 { 363 return; 364 } 365 366 /* Now we can check for the depth argument */ 367 368 if (DepthArg) 369 { 370 MaxDepth = strtoul (DepthArg, NULL, 0); 371 } 372 } 373 374 AcpiDbSetOutputDestination (ACPI_DB_DUPLICATE_OUTPUT); 375 376 if (((ACPI_NAMESPACE_NODE *) SubtreeEntry)->Parent) 377 { 378 AcpiOsPrintf ("ACPI Namespace (from %4.4s (%p) subtree):\n", 379 ((ACPI_NAMESPACE_NODE *) SubtreeEntry)->Name.Ascii, SubtreeEntry); 380 } 381 else 382 { 383 AcpiOsPrintf ("ACPI Namespace (from %s):\n", 384 ACPI_NAMESPACE_ROOT); 385 } 386 387 /* Display the subtree */ 388 389 AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT); 390 AcpiNsDumpObjects (ACPI_TYPE_ANY, ACPI_DISPLAY_SUMMARY, MaxDepth, 391 ACPI_OWNER_ID_MAX, SubtreeEntry); 392 AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT); 393 } 394 395 396 /******************************************************************************* 397 * 398 * FUNCTION: AcpiDbDumpNamespacePaths 399 * 400 * PARAMETERS: None 401 * 402 * RETURN: None 403 * 404 * DESCRIPTION: Dump entire namespace with full object pathnames and object 405 * type information. Alternative to "namespace" command. 406 * 407 ******************************************************************************/ 408 409 void 410 AcpiDbDumpNamespacePaths ( 411 void) 412 { 413 414 AcpiDbSetOutputDestination (ACPI_DB_DUPLICATE_OUTPUT); 415 AcpiOsPrintf ("ACPI Namespace (from root):\n"); 416 417 /* Display the entire namespace */ 418 419 AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT); 420 AcpiNsDumpObjectPaths (ACPI_TYPE_ANY, ACPI_DISPLAY_SUMMARY, 421 ACPI_UINT32_MAX, ACPI_OWNER_ID_MAX, AcpiGbl_RootNode); 422 423 AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT); 424 } 425 426 427 /******************************************************************************* 428 * 429 * FUNCTION: AcpiDbDumpNamespaceByOwner 430 * 431 * PARAMETERS: OwnerArg - Owner ID whose nodes will be displayed 432 * DepthArg - Maximum tree depth to be dumped 433 * 434 * RETURN: None 435 * 436 * DESCRIPTION: Dump elements of the namespace that are owned by the OwnerId. 437 * 438 ******************************************************************************/ 439 440 void 441 AcpiDbDumpNamespaceByOwner ( 442 char *OwnerArg, 443 char *DepthArg) 444 { 445 ACPI_HANDLE SubtreeEntry = AcpiGbl_RootNode; 446 UINT32 MaxDepth = ACPI_UINT32_MAX; 447 ACPI_OWNER_ID OwnerId; 448 449 450 OwnerId = (ACPI_OWNER_ID) strtoul (OwnerArg, NULL, 0); 451 452 /* Now we can check for the depth argument */ 453 454 if (DepthArg) 455 { 456 MaxDepth = strtoul (DepthArg, NULL, 0); 457 } 458 459 AcpiDbSetOutputDestination (ACPI_DB_DUPLICATE_OUTPUT); 460 AcpiOsPrintf ("ACPI Namespace by owner %X:\n", OwnerId); 461 462 /* Display the subtree */ 463 464 AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT); 465 AcpiNsDumpObjects (ACPI_TYPE_ANY, ACPI_DISPLAY_SUMMARY, MaxDepth, 466 OwnerId, SubtreeEntry); 467 AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT); 468 } 469 470 471 /******************************************************************************* 472 * 473 * FUNCTION: AcpiDbWalkAndMatchName 474 * 475 * PARAMETERS: Callback from WalkNamespace 476 * 477 * RETURN: Status 478 * 479 * DESCRIPTION: Find a particular name/names within the namespace. Wildcards 480 * are supported -- '?' matches any character. 481 * 482 ******************************************************************************/ 483 484 static ACPI_STATUS 485 AcpiDbWalkAndMatchName ( 486 ACPI_HANDLE ObjHandle, 487 UINT32 NestingLevel, 488 void *Context, 489 void **ReturnValue) 490 { 491 ACPI_STATUS Status; 492 char *RequestedName = (char *) Context; 493 UINT32 i; 494 ACPI_BUFFER Buffer; 495 ACPI_WALK_INFO Info; 496 497 498 /* Check for a name match */ 499 500 for (i = 0; i < 4; i++) 501 { 502 /* Wildcard support */ 503 504 if ((RequestedName[i] != '?') && 505 (RequestedName[i] != ((ACPI_NAMESPACE_NODE *) 506 ObjHandle)->Name.Ascii[i])) 507 { 508 /* No match, just exit */ 509 510 return (AE_OK); 511 } 512 } 513 514 /* Get the full pathname to this object */ 515 516 Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER; 517 Status = AcpiNsHandleToPathname (ObjHandle, &Buffer, TRUE); 518 if (ACPI_FAILURE (Status)) 519 { 520 AcpiOsPrintf ("Could Not get pathname for object %p\n", 521 ObjHandle); 522 } 523 else 524 { 525 Info.OwnerId = ACPI_OWNER_ID_MAX; 526 Info.DebugLevel = ACPI_UINT32_MAX; 527 Info.DisplayType = ACPI_DISPLAY_SUMMARY | ACPI_DISPLAY_SHORT; 528 529 AcpiOsPrintf ("%32s", (char *) Buffer.Pointer); 530 (void) AcpiNsDumpOneObject (ObjHandle, NestingLevel, &Info, NULL); 531 ACPI_FREE (Buffer.Pointer); 532 } 533 534 return (AE_OK); 535 } 536 537 538 /******************************************************************************* 539 * 540 * FUNCTION: AcpiDbFindNameInNamespace 541 * 542 * PARAMETERS: NameArg - The 4-character ACPI name to find. 543 * wildcards are supported. 544 * 545 * RETURN: None 546 * 547 * DESCRIPTION: Search the namespace for a given name (with wildcards) 548 * 549 ******************************************************************************/ 550 551 ACPI_STATUS 552 AcpiDbFindNameInNamespace ( 553 char *NameArg) 554 { 555 char AcpiName[5] = "____"; 556 char *AcpiNamePtr = AcpiName; 557 558 559 if (strlen (NameArg) > ACPI_NAME_SIZE) 560 { 561 AcpiOsPrintf ("Name must be no longer than 4 characters\n"); 562 return (AE_OK); 563 } 564 565 /* Pad out name with underscores as necessary to create a 4-char name */ 566 567 AcpiUtStrupr (NameArg); 568 while (*NameArg) 569 { 570 *AcpiNamePtr = *NameArg; 571 AcpiNamePtr++; 572 NameArg++; 573 } 574 575 /* Walk the namespace from the root */ 576 577 (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, 578 ACPI_UINT32_MAX, AcpiDbWalkAndMatchName, NULL, AcpiName, NULL); 579 580 AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT); 581 return (AE_OK); 582 } 583 584 585 /******************************************************************************* 586 * 587 * FUNCTION: AcpiDbWalkForPredefinedNames 588 * 589 * PARAMETERS: Callback from WalkNamespace 590 * 591 * RETURN: Status 592 * 593 * DESCRIPTION: Detect and display predefined ACPI names (names that start with 594 * an underscore) 595 * 596 ******************************************************************************/ 597 598 static ACPI_STATUS 599 AcpiDbWalkForPredefinedNames ( 600 ACPI_HANDLE ObjHandle, 601 UINT32 NestingLevel, 602 void *Context, 603 void **ReturnValue) 604 { 605 ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle; 606 UINT32 *Count = (UINT32 *) Context; 607 const ACPI_PREDEFINED_INFO *Predefined; 608 const ACPI_PREDEFINED_INFO *Package = NULL; 609 char *Pathname; 610 char StringBuffer[48]; 611 612 613 Predefined = AcpiUtMatchPredefinedMethod (Node->Name.Ascii); 614 if (!Predefined) 615 { 616 return (AE_OK); 617 } 618 619 Pathname = AcpiNsGetNormalizedPathname (Node, TRUE); 620 if (!Pathname) 621 { 622 return (AE_OK); 623 } 624 625 /* If method returns a package, the info is in the next table entry */ 626 627 if (Predefined->Info.ExpectedBtypes & ACPI_RTYPE_PACKAGE) 628 { 629 Package = Predefined + 1; 630 } 631 632 AcpiUtGetExpectedReturnTypes (StringBuffer, 633 Predefined->Info.ExpectedBtypes); 634 635 AcpiOsPrintf ("%-32s Arguments %X, Return Types: %s", Pathname, 636 METHOD_GET_ARG_COUNT (Predefined->Info.ArgumentList), 637 StringBuffer); 638 639 if (Package) 640 { 641 AcpiOsPrintf (" (PkgType %2.2X, ObjType %2.2X, Count %2.2X)", 642 Package->RetInfo.Type, Package->RetInfo.ObjectType1, 643 Package->RetInfo.Count1); 644 } 645 646 AcpiOsPrintf("\n"); 647 648 /* Check that the declared argument count matches the ACPI spec */ 649 650 AcpiNsCheckAcpiCompliance (Pathname, Node, Predefined); 651 652 ACPI_FREE (Pathname); 653 (*Count)++; 654 return (AE_OK); 655 } 656 657 658 /******************************************************************************* 659 * 660 * FUNCTION: AcpiDbCheckPredefinedNames 661 * 662 * PARAMETERS: None 663 * 664 * RETURN: None 665 * 666 * DESCRIPTION: Validate all predefined names in the namespace 667 * 668 ******************************************************************************/ 669 670 void 671 AcpiDbCheckPredefinedNames ( 672 void) 673 { 674 UINT32 Count = 0; 675 676 677 /* Search all nodes in namespace */ 678 679 (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, 680 ACPI_UINT32_MAX, AcpiDbWalkForPredefinedNames, 681 NULL, (void *) &Count, NULL); 682 683 AcpiOsPrintf ("Found %u predefined names in the namespace\n", Count); 684 } 685 686 687 /******************************************************************************* 688 * 689 * FUNCTION: AcpiDbWalkForObjectCounts 690 * 691 * PARAMETERS: Callback from WalkNamespace 692 * 693 * RETURN: Status 694 * 695 * DESCRIPTION: Display short info about objects in the namespace 696 * 697 ******************************************************************************/ 698 699 static ACPI_STATUS 700 AcpiDbWalkForObjectCounts ( 701 ACPI_HANDLE ObjHandle, 702 UINT32 NestingLevel, 703 void *Context, 704 void **ReturnValue) 705 { 706 ACPI_OBJECT_INFO *Info = (ACPI_OBJECT_INFO *) Context; 707 ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle; 708 709 710 if (Node->Type > ACPI_TYPE_NS_NODE_MAX) 711 { 712 AcpiOsPrintf ("[%4.4s]: Unknown object type %X\n", 713 Node->Name.Ascii, Node->Type); 714 } 715 else 716 { 717 Info->Types[Node->Type]++; 718 } 719 720 return (AE_OK); 721 } 722 723 724 /******************************************************************************* 725 * 726 * FUNCTION: AcpiDbWalkForSpecificObjects 727 * 728 * PARAMETERS: Callback from WalkNamespace 729 * 730 * RETURN: Status 731 * 732 * DESCRIPTION: Display short info about objects in the namespace 733 * 734 ******************************************************************************/ 735 736 static ACPI_STATUS 737 AcpiDbWalkForSpecificObjects ( 738 ACPI_HANDLE ObjHandle, 739 UINT32 NestingLevel, 740 void *Context, 741 void **ReturnValue) 742 { 743 ACPI_WALK_INFO *Info = (ACPI_WALK_INFO *) Context; 744 ACPI_BUFFER Buffer; 745 ACPI_STATUS Status; 746 747 748 Info->Count++; 749 750 /* Get and display the full pathname to this object */ 751 752 Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER; 753 Status = AcpiNsHandleToPathname (ObjHandle, &Buffer, TRUE); 754 if (ACPI_FAILURE (Status)) 755 { 756 AcpiOsPrintf ("Could Not get pathname for object %p\n", ObjHandle); 757 return (AE_OK); 758 } 759 760 AcpiOsPrintf ("%32s", (char *) Buffer.Pointer); 761 ACPI_FREE (Buffer.Pointer); 762 763 /* Dump short info about the object */ 764 765 (void) AcpiNsDumpOneObject (ObjHandle, NestingLevel, Info, NULL); 766 return (AE_OK); 767 } 768 769 770 /******************************************************************************* 771 * 772 * FUNCTION: AcpiDbDisplayObjects 773 * 774 * PARAMETERS: ObjTypeArg - Type of object to display 775 * DisplayCountArg - Max depth to display 776 * 777 * RETURN: None 778 * 779 * DESCRIPTION: Display objects in the namespace of the requested type 780 * 781 ******************************************************************************/ 782 783 ACPI_STATUS 784 AcpiDbDisplayObjects ( 785 char *ObjTypeArg, 786 char *DisplayCountArg) 787 { 788 ACPI_WALK_INFO Info; 789 ACPI_OBJECT_TYPE Type; 790 ACPI_OBJECT_INFO *ObjectInfo; 791 UINT32 i; 792 UINT32 TotalObjects = 0; 793 794 795 /* No argument means display summary/count of all object types */ 796 797 if (!ObjTypeArg) 798 { 799 ObjectInfo = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_OBJECT_INFO)); 800 801 /* Walk the namespace from the root */ 802 803 (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, 804 ACPI_UINT32_MAX, AcpiDbWalkForObjectCounts, NULL, 805 (void *) ObjectInfo, NULL); 806 807 AcpiOsPrintf ("\nSummary of namespace objects:\n\n"); 808 809 for (i = 0; i < ACPI_TOTAL_TYPES; i++) 810 { 811 AcpiOsPrintf ("%8u %s\n", ObjectInfo->Types[i], 812 AcpiUtGetTypeName (i)); 813 814 TotalObjects += ObjectInfo->Types[i]; 815 } 816 817 AcpiOsPrintf ("\n%8u Total namespace objects\n\n", 818 TotalObjects); 819 820 ACPI_FREE (ObjectInfo); 821 return (AE_OK); 822 } 823 824 /* Get the object type */ 825 826 Type = AcpiDbMatchArgument (ObjTypeArg, AcpiDbObjectTypes); 827 if (Type == ACPI_TYPE_NOT_FOUND) 828 { 829 AcpiOsPrintf ("Invalid or unsupported argument\n"); 830 return (AE_OK); 831 } 832 833 AcpiDbSetOutputDestination (ACPI_DB_DUPLICATE_OUTPUT); 834 AcpiOsPrintf ( 835 "Objects of type [%s] defined in the current ACPI Namespace:\n", 836 AcpiUtGetTypeName (Type)); 837 838 AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT); 839 840 Info.Count = 0; 841 Info.OwnerId = ACPI_OWNER_ID_MAX; 842 Info.DebugLevel = ACPI_UINT32_MAX; 843 Info.DisplayType = ACPI_DISPLAY_SUMMARY | ACPI_DISPLAY_SHORT; 844 845 /* Walk the namespace from the root */ 846 847 (void) AcpiWalkNamespace (Type, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX, 848 AcpiDbWalkForSpecificObjects, NULL, (void *) &Info, NULL); 849 850 AcpiOsPrintf ( 851 "\nFound %u objects of type [%s] in the current ACPI Namespace\n", 852 Info.Count, AcpiUtGetTypeName (Type)); 853 854 AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT); 855 return (AE_OK); 856 } 857 858 859 /******************************************************************************* 860 * 861 * FUNCTION: AcpiDbIntegrityWalk 862 * 863 * PARAMETERS: Callback from WalkNamespace 864 * 865 * RETURN: Status 866 * 867 * DESCRIPTION: Examine one NS node for valid values. 868 * 869 ******************************************************************************/ 870 871 static ACPI_STATUS 872 AcpiDbIntegrityWalk ( 873 ACPI_HANDLE ObjHandle, 874 UINT32 NestingLevel, 875 void *Context, 876 void **ReturnValue) 877 { 878 ACPI_INTEGRITY_INFO *Info = (ACPI_INTEGRITY_INFO *) Context; 879 ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle; 880 ACPI_OPERAND_OBJECT *Object; 881 BOOLEAN Alias = TRUE; 882 883 884 Info->Nodes++; 885 886 /* Verify the NS node, and dereference aliases */ 887 888 while (Alias) 889 { 890 if (ACPI_GET_DESCRIPTOR_TYPE (Node) != ACPI_DESC_TYPE_NAMED) 891 { 892 AcpiOsPrintf ( 893 "Invalid Descriptor Type for Node %p [%s] - " 894 "is %2.2X should be %2.2X\n", 895 Node, AcpiUtGetDescriptorName (Node), 896 ACPI_GET_DESCRIPTOR_TYPE (Node), ACPI_DESC_TYPE_NAMED); 897 return (AE_OK); 898 } 899 900 if ((Node->Type == ACPI_TYPE_LOCAL_ALIAS) || 901 (Node->Type == ACPI_TYPE_LOCAL_METHOD_ALIAS)) 902 { 903 Node = (ACPI_NAMESPACE_NODE *) Node->Object; 904 } 905 else 906 { 907 Alias = FALSE; 908 } 909 } 910 911 if (Node->Type > ACPI_TYPE_LOCAL_MAX) 912 { 913 AcpiOsPrintf ("Invalid Object Type for Node %p, Type = %X\n", 914 Node, Node->Type); 915 return (AE_OK); 916 } 917 918 if (!AcpiUtValidNameseg (Node->Name.Ascii)) 919 { 920 AcpiOsPrintf ("Invalid AcpiName for Node %p\n", Node); 921 return (AE_OK); 922 } 923 924 Object = AcpiNsGetAttachedObject (Node); 925 if (Object) 926 { 927 Info->Objects++; 928 if (ACPI_GET_DESCRIPTOR_TYPE (Object) != ACPI_DESC_TYPE_OPERAND) 929 { 930 AcpiOsPrintf ("Invalid Descriptor Type for Object %p [%s]\n", 931 Object, AcpiUtGetDescriptorName (Object)); 932 } 933 } 934 935 return (AE_OK); 936 } 937 938 939 /******************************************************************************* 940 * 941 * FUNCTION: AcpiDbCheckIntegrity 942 * 943 * PARAMETERS: None 944 * 945 * RETURN: None 946 * 947 * DESCRIPTION: Check entire namespace for data structure integrity 948 * 949 ******************************************************************************/ 950 951 void 952 AcpiDbCheckIntegrity ( 953 void) 954 { 955 ACPI_INTEGRITY_INFO Info = {0,0}; 956 957 /* Search all nodes in namespace */ 958 959 (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, 960 ACPI_UINT32_MAX, AcpiDbIntegrityWalk, NULL, (void *) &Info, NULL); 961 962 AcpiOsPrintf ("Verified %u namespace nodes with %u Objects\n", 963 Info.Nodes, Info.Objects); 964 } 965 966 967 /******************************************************************************* 968 * 969 * FUNCTION: AcpiDbWalkForReferences 970 * 971 * PARAMETERS: Callback from WalkNamespace 972 * 973 * RETURN: Status 974 * 975 * DESCRIPTION: Check if this namespace object refers to the target object 976 * that is passed in as the context value. 977 * 978 * Note: Currently doesn't check subobjects within the Node's object 979 * 980 ******************************************************************************/ 981 982 static ACPI_STATUS 983 AcpiDbWalkForReferences ( 984 ACPI_HANDLE ObjHandle, 985 UINT32 NestingLevel, 986 void *Context, 987 void **ReturnValue) 988 { 989 ACPI_OPERAND_OBJECT *ObjDesc = (ACPI_OPERAND_OBJECT *) Context; 990 ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle; 991 992 993 /* Check for match against the namespace node itself */ 994 995 if (Node == (void *) ObjDesc) 996 { 997 AcpiOsPrintf ("Object is a Node [%4.4s]\n", 998 AcpiUtGetNodeName (Node)); 999 } 1000 1001 /* Check for match against the object attached to the node */ 1002 1003 if (AcpiNsGetAttachedObject (Node) == ObjDesc) 1004 { 1005 AcpiOsPrintf ("Reference at Node->Object %p [%4.4s]\n", 1006 Node, AcpiUtGetNodeName (Node)); 1007 } 1008 1009 return (AE_OK); 1010 } 1011 1012 1013 /******************************************************************************* 1014 * 1015 * FUNCTION: AcpiDbFindReferences 1016 * 1017 * PARAMETERS: ObjectArg - String with hex value of the object 1018 * 1019 * RETURN: None 1020 * 1021 * DESCRIPTION: Search namespace for all references to the input object 1022 * 1023 ******************************************************************************/ 1024 1025 void 1026 AcpiDbFindReferences ( 1027 char *ObjectArg) 1028 { 1029 ACPI_OPERAND_OBJECT *ObjDesc; 1030 ACPI_SIZE Address; 1031 1032 1033 /* Convert string to object pointer */ 1034 1035 Address = strtoul (ObjectArg, NULL, 16); 1036 ObjDesc = ACPI_TO_POINTER (Address); 1037 1038 /* Search all nodes in namespace */ 1039 1040 (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, 1041 ACPI_UINT32_MAX, AcpiDbWalkForReferences, NULL, 1042 (void *) ObjDesc, NULL); 1043 } 1044 1045 1046 /******************************************************************************* 1047 * 1048 * FUNCTION: AcpiDbBusWalk 1049 * 1050 * PARAMETERS: Callback from WalkNamespace 1051 * 1052 * RETURN: Status 1053 * 1054 * DESCRIPTION: Display info about device objects that have a corresponding 1055 * _PRT method. 1056 * 1057 ******************************************************************************/ 1058 1059 static ACPI_STATUS 1060 AcpiDbBusWalk ( 1061 ACPI_HANDLE ObjHandle, 1062 UINT32 NestingLevel, 1063 void *Context, 1064 void **ReturnValue) 1065 { 1066 ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle; 1067 ACPI_STATUS Status; 1068 ACPI_BUFFER Buffer; 1069 ACPI_NAMESPACE_NODE *TempNode; 1070 ACPI_DEVICE_INFO *Info; 1071 UINT32 i; 1072 1073 1074 if ((Node->Type != ACPI_TYPE_DEVICE) && 1075 (Node->Type != ACPI_TYPE_PROCESSOR)) 1076 { 1077 return (AE_OK); 1078 } 1079 1080 /* Exit if there is no _PRT under this device */ 1081 1082 Status = AcpiGetHandle (Node, METHOD_NAME__PRT, 1083 ACPI_CAST_PTR (ACPI_HANDLE, &TempNode)); 1084 if (ACPI_FAILURE (Status)) 1085 { 1086 return (AE_OK); 1087 } 1088 1089 /* Get the full path to this device object */ 1090 1091 Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER; 1092 Status = AcpiNsHandleToPathname (ObjHandle, &Buffer, TRUE); 1093 if (ACPI_FAILURE (Status)) 1094 { 1095 AcpiOsPrintf ("Could Not get pathname for object %p\n", 1096 ObjHandle); 1097 return (AE_OK); 1098 } 1099 1100 Status = AcpiGetObjectInfo (ObjHandle, &Info); 1101 if (ACPI_FAILURE (Status)) 1102 { 1103 return (AE_OK); 1104 } 1105 1106 /* Display the full path */ 1107 1108 AcpiOsPrintf ("%-32s Type %X", (char *) Buffer.Pointer, Node->Type); 1109 ACPI_FREE (Buffer.Pointer); 1110 1111 if (Info->Flags & ACPI_PCI_ROOT_BRIDGE) 1112 { 1113 AcpiOsPrintf (" - Is PCI Root Bridge"); 1114 } 1115 AcpiOsPrintf ("\n"); 1116 1117 /* _PRT info */ 1118 1119 AcpiOsPrintf ("_PRT: %p\n", TempNode); 1120 1121 /* Dump _ADR, _HID, _UID, _CID */ 1122 1123 if (Info->Valid & ACPI_VALID_ADR) 1124 { 1125 AcpiOsPrintf ("_ADR: %8.8X%8.8X\n", 1126 ACPI_FORMAT_UINT64 (Info->Address)); 1127 } 1128 else 1129 { 1130 AcpiOsPrintf ("_ADR: <Not Present>\n"); 1131 } 1132 1133 if (Info->Valid & ACPI_VALID_HID) 1134 { 1135 AcpiOsPrintf ("_HID: %s\n", Info->HardwareId.String); 1136 } 1137 else 1138 { 1139 AcpiOsPrintf ("_HID: <Not Present>\n"); 1140 } 1141 1142 if (Info->Valid & ACPI_VALID_UID) 1143 { 1144 AcpiOsPrintf ("_UID: %s\n", Info->UniqueId.String); 1145 } 1146 else 1147 { 1148 AcpiOsPrintf ("_UID: <Not Present>\n"); 1149 } 1150 1151 if (Info->Valid & ACPI_VALID_CID) 1152 { 1153 for (i = 0; i < Info->CompatibleIdList.Count; i++) 1154 { 1155 AcpiOsPrintf ("_CID: %s\n", 1156 Info->CompatibleIdList.Ids[i].String); 1157 } 1158 } 1159 else 1160 { 1161 AcpiOsPrintf ("_CID: <Not Present>\n"); 1162 } 1163 1164 ACPI_FREE (Info); 1165 return (AE_OK); 1166 } 1167 1168 1169 /******************************************************************************* 1170 * 1171 * FUNCTION: AcpiDbGetBusInfo 1172 * 1173 * PARAMETERS: None 1174 * 1175 * RETURN: None 1176 * 1177 * DESCRIPTION: Display info about system busses. 1178 * 1179 ******************************************************************************/ 1180 1181 void 1182 AcpiDbGetBusInfo ( 1183 void) 1184 { 1185 /* Search all nodes in namespace */ 1186 1187 (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, 1188 ACPI_UINT32_MAX, AcpiDbBusWalk, NULL, NULL, NULL); 1189 } 1190