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 - 2019, 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.Count = 0; 526 Info.OwnerId = ACPI_OWNER_ID_MAX; 527 Info.DebugLevel = ACPI_UINT32_MAX; 528 Info.DisplayType = ACPI_DISPLAY_SUMMARY | ACPI_DISPLAY_SHORT; 529 530 AcpiOsPrintf ("%32s", (char *) Buffer.Pointer); 531 (void) AcpiNsDumpOneObject (ObjHandle, NestingLevel, &Info, NULL); 532 ACPI_FREE (Buffer.Pointer); 533 } 534 535 return (AE_OK); 536 } 537 538 539 /******************************************************************************* 540 * 541 * FUNCTION: AcpiDbFindNameInNamespace 542 * 543 * PARAMETERS: NameArg - The 4-character ACPI name to find. 544 * wildcards are supported. 545 * 546 * RETURN: None 547 * 548 * DESCRIPTION: Search the namespace for a given name (with wildcards) 549 * 550 ******************************************************************************/ 551 552 ACPI_STATUS 553 AcpiDbFindNameInNamespace ( 554 char *NameArg) 555 { 556 char AcpiName[5] = "____"; 557 char *AcpiNamePtr = AcpiName; 558 559 560 if (strlen (NameArg) > ACPI_NAMESEG_SIZE) 561 { 562 AcpiOsPrintf ("Name must be no longer than 4 characters\n"); 563 return (AE_OK); 564 } 565 566 /* Pad out name with underscores as necessary to create a 4-char name */ 567 568 AcpiUtStrupr (NameArg); 569 while (*NameArg) 570 { 571 *AcpiNamePtr = *NameArg; 572 AcpiNamePtr++; 573 NameArg++; 574 } 575 576 /* Walk the namespace from the root */ 577 578 (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, 579 ACPI_UINT32_MAX, AcpiDbWalkAndMatchName, NULL, AcpiName, NULL); 580 581 AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT); 582 return (AE_OK); 583 } 584 585 586 /******************************************************************************* 587 * 588 * FUNCTION: AcpiDbWalkForPredefinedNames 589 * 590 * PARAMETERS: Callback from WalkNamespace 591 * 592 * RETURN: Status 593 * 594 * DESCRIPTION: Detect and display predefined ACPI names (names that start with 595 * an underscore) 596 * 597 ******************************************************************************/ 598 599 static ACPI_STATUS 600 AcpiDbWalkForPredefinedNames ( 601 ACPI_HANDLE ObjHandle, 602 UINT32 NestingLevel, 603 void *Context, 604 void **ReturnValue) 605 { 606 ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle; 607 UINT32 *Count = (UINT32 *) Context; 608 const ACPI_PREDEFINED_INFO *Predefined; 609 const ACPI_PREDEFINED_INFO *Package = NULL; 610 char *Pathname; 611 char StringBuffer[48]; 612 613 614 Predefined = AcpiUtMatchPredefinedMethod (Node->Name.Ascii); 615 if (!Predefined) 616 { 617 return (AE_OK); 618 } 619 620 Pathname = AcpiNsGetNormalizedPathname (Node, TRUE); 621 if (!Pathname) 622 { 623 return (AE_OK); 624 } 625 626 /* If method returns a package, the info is in the next table entry */ 627 628 if (Predefined->Info.ExpectedBtypes & ACPI_RTYPE_PACKAGE) 629 { 630 Package = Predefined + 1; 631 } 632 633 AcpiUtGetExpectedReturnTypes (StringBuffer, 634 Predefined->Info.ExpectedBtypes); 635 636 AcpiOsPrintf ("%-32s Arguments %X, Return Types: %s", Pathname, 637 METHOD_GET_ARG_COUNT (Predefined->Info.ArgumentList), 638 StringBuffer); 639 640 if (Package) 641 { 642 AcpiOsPrintf (" (PkgType %2.2X, ObjType %2.2X, Count %2.2X)", 643 Package->RetInfo.Type, Package->RetInfo.ObjectType1, 644 Package->RetInfo.Count1); 645 } 646 647 AcpiOsPrintf("\n"); 648 649 /* Check that the declared argument count matches the ACPI spec */ 650 651 AcpiNsCheckAcpiCompliance (Pathname, Node, Predefined); 652 653 ACPI_FREE (Pathname); 654 (*Count)++; 655 return (AE_OK); 656 } 657 658 659 /******************************************************************************* 660 * 661 * FUNCTION: AcpiDbCheckPredefinedNames 662 * 663 * PARAMETERS: None 664 * 665 * RETURN: None 666 * 667 * DESCRIPTION: Validate all predefined names in the namespace 668 * 669 ******************************************************************************/ 670 671 void 672 AcpiDbCheckPredefinedNames ( 673 void) 674 { 675 UINT32 Count = 0; 676 677 678 /* Search all nodes in namespace */ 679 680 (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, 681 ACPI_UINT32_MAX, AcpiDbWalkForPredefinedNames, 682 NULL, (void *) &Count, NULL); 683 684 AcpiOsPrintf ("Found %u predefined names in the namespace\n", Count); 685 } 686 687 688 /******************************************************************************* 689 * 690 * FUNCTION: AcpiDbWalkForObjectCounts 691 * 692 * PARAMETERS: Callback from WalkNamespace 693 * 694 * RETURN: Status 695 * 696 * DESCRIPTION: Display short info about objects in the namespace 697 * 698 ******************************************************************************/ 699 700 static ACPI_STATUS 701 AcpiDbWalkForObjectCounts ( 702 ACPI_HANDLE ObjHandle, 703 UINT32 NestingLevel, 704 void *Context, 705 void **ReturnValue) 706 { 707 ACPI_OBJECT_INFO *Info = (ACPI_OBJECT_INFO *) Context; 708 ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle; 709 710 711 if (Node->Type > ACPI_TYPE_NS_NODE_MAX) 712 { 713 AcpiOsPrintf ("[%4.4s]: Unknown object type %X\n", 714 Node->Name.Ascii, Node->Type); 715 } 716 else 717 { 718 Info->Types[Node->Type]++; 719 } 720 721 return (AE_OK); 722 } 723 724 725 /******************************************************************************* 726 * 727 * FUNCTION: AcpiDbWalkForSpecificObjects 728 * 729 * PARAMETERS: Callback from WalkNamespace 730 * 731 * RETURN: Status 732 * 733 * DESCRIPTION: Display short info about objects in the namespace 734 * 735 ******************************************************************************/ 736 737 static ACPI_STATUS 738 AcpiDbWalkForSpecificObjects ( 739 ACPI_HANDLE ObjHandle, 740 UINT32 NestingLevel, 741 void *Context, 742 void **ReturnValue) 743 { 744 ACPI_WALK_INFO *Info = (ACPI_WALK_INFO *) Context; 745 ACPI_BUFFER Buffer; 746 ACPI_STATUS Status; 747 748 749 Info->Count++; 750 751 /* Get and display the full pathname to this object */ 752 753 Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER; 754 Status = AcpiNsHandleToPathname (ObjHandle, &Buffer, TRUE); 755 if (ACPI_FAILURE (Status)) 756 { 757 AcpiOsPrintf ("Could Not get pathname for object %p\n", ObjHandle); 758 return (AE_OK); 759 } 760 761 AcpiOsPrintf ("%32s", (char *) Buffer.Pointer); 762 ACPI_FREE (Buffer.Pointer); 763 764 /* Dump short info about the object */ 765 766 (void) AcpiNsDumpOneObject (ObjHandle, NestingLevel, Info, NULL); 767 return (AE_OK); 768 } 769 770 771 /******************************************************************************* 772 * 773 * FUNCTION: AcpiDbDisplayObjects 774 * 775 * PARAMETERS: ObjTypeArg - Type of object to display 776 * DisplayCountArg - Max depth to display 777 * 778 * RETURN: None 779 * 780 * DESCRIPTION: Display objects in the namespace of the requested type 781 * 782 ******************************************************************************/ 783 784 ACPI_STATUS 785 AcpiDbDisplayObjects ( 786 char *ObjTypeArg, 787 char *DisplayCountArg) 788 { 789 ACPI_WALK_INFO Info; 790 ACPI_OBJECT_TYPE Type; 791 ACPI_OBJECT_INFO *ObjectInfo; 792 UINT32 i; 793 UINT32 TotalObjects = 0; 794 795 796 /* No argument means display summary/count of all object types */ 797 798 if (!ObjTypeArg) 799 { 800 ObjectInfo = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_OBJECT_INFO)); 801 802 /* Walk the namespace from the root */ 803 804 (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, 805 ACPI_UINT32_MAX, AcpiDbWalkForObjectCounts, NULL, 806 (void *) ObjectInfo, NULL); 807 808 AcpiOsPrintf ("\nSummary of namespace objects:\n\n"); 809 810 for (i = 0; i < ACPI_TOTAL_TYPES; i++) 811 { 812 AcpiOsPrintf ("%8u %s\n", ObjectInfo->Types[i], 813 AcpiUtGetTypeName (i)); 814 815 TotalObjects += ObjectInfo->Types[i]; 816 } 817 818 AcpiOsPrintf ("\n%8u Total namespace objects\n\n", 819 TotalObjects); 820 821 ACPI_FREE (ObjectInfo); 822 return (AE_OK); 823 } 824 825 /* Get the object type */ 826 827 Type = AcpiDbMatchArgument (ObjTypeArg, AcpiDbObjectTypes); 828 if (Type == ACPI_TYPE_NOT_FOUND) 829 { 830 AcpiOsPrintf ("Invalid or unsupported argument\n"); 831 return (AE_OK); 832 } 833 834 AcpiDbSetOutputDestination (ACPI_DB_DUPLICATE_OUTPUT); 835 AcpiOsPrintf ( 836 "Objects of type [%s] defined in the current ACPI Namespace:\n", 837 AcpiUtGetTypeName (Type)); 838 839 AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT); 840 841 Info.Count = 0; 842 Info.OwnerId = ACPI_OWNER_ID_MAX; 843 Info.DebugLevel = ACPI_UINT32_MAX; 844 Info.DisplayType = ACPI_DISPLAY_SUMMARY | ACPI_DISPLAY_SHORT; 845 846 /* Walk the namespace from the root */ 847 848 (void) AcpiWalkNamespace (Type, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX, 849 AcpiDbWalkForSpecificObjects, NULL, (void *) &Info, NULL); 850 851 AcpiOsPrintf ( 852 "\nFound %u objects of type [%s] in the current ACPI Namespace\n", 853 Info.Count, AcpiUtGetTypeName (Type)); 854 855 AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT); 856 return (AE_OK); 857 } 858 859 860 /******************************************************************************* 861 * 862 * FUNCTION: AcpiDbIntegrityWalk 863 * 864 * PARAMETERS: Callback from WalkNamespace 865 * 866 * RETURN: Status 867 * 868 * DESCRIPTION: Examine one NS node for valid values. 869 * 870 ******************************************************************************/ 871 872 static ACPI_STATUS 873 AcpiDbIntegrityWalk ( 874 ACPI_HANDLE ObjHandle, 875 UINT32 NestingLevel, 876 void *Context, 877 void **ReturnValue) 878 { 879 ACPI_INTEGRITY_INFO *Info = (ACPI_INTEGRITY_INFO *) Context; 880 ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle; 881 ACPI_OPERAND_OBJECT *Object; 882 BOOLEAN Alias = TRUE; 883 884 885 Info->Nodes++; 886 887 /* Verify the NS node, and dereference aliases */ 888 889 while (Alias) 890 { 891 if (ACPI_GET_DESCRIPTOR_TYPE (Node) != ACPI_DESC_TYPE_NAMED) 892 { 893 AcpiOsPrintf ( 894 "Invalid Descriptor Type for Node %p [%s] - " 895 "is %2.2X should be %2.2X\n", 896 Node, AcpiUtGetDescriptorName (Node), 897 ACPI_GET_DESCRIPTOR_TYPE (Node), ACPI_DESC_TYPE_NAMED); 898 return (AE_OK); 899 } 900 901 if ((Node->Type == ACPI_TYPE_LOCAL_ALIAS) || 902 (Node->Type == ACPI_TYPE_LOCAL_METHOD_ALIAS)) 903 { 904 Node = (ACPI_NAMESPACE_NODE *) Node->Object; 905 } 906 else 907 { 908 Alias = FALSE; 909 } 910 } 911 912 if (Node->Type > ACPI_TYPE_LOCAL_MAX) 913 { 914 AcpiOsPrintf ("Invalid Object Type for Node %p, Type = %X\n", 915 Node, Node->Type); 916 return (AE_OK); 917 } 918 919 if (!AcpiUtValidNameseg (Node->Name.Ascii)) 920 { 921 AcpiOsPrintf ("Invalid AcpiName for Node %p\n", Node); 922 return (AE_OK); 923 } 924 925 Object = AcpiNsGetAttachedObject (Node); 926 if (Object) 927 { 928 Info->Objects++; 929 if (ACPI_GET_DESCRIPTOR_TYPE (Object) != ACPI_DESC_TYPE_OPERAND) 930 { 931 AcpiOsPrintf ("Invalid Descriptor Type for Object %p [%s]\n", 932 Object, AcpiUtGetDescriptorName (Object)); 933 } 934 } 935 936 return (AE_OK); 937 } 938 939 940 /******************************************************************************* 941 * 942 * FUNCTION: AcpiDbCheckIntegrity 943 * 944 * PARAMETERS: None 945 * 946 * RETURN: None 947 * 948 * DESCRIPTION: Check entire namespace for data structure integrity 949 * 950 ******************************************************************************/ 951 952 void 953 AcpiDbCheckIntegrity ( 954 void) 955 { 956 ACPI_INTEGRITY_INFO Info = {0,0}; 957 958 /* Search all nodes in namespace */ 959 960 (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, 961 ACPI_UINT32_MAX, AcpiDbIntegrityWalk, NULL, (void *) &Info, NULL); 962 963 AcpiOsPrintf ("Verified %u namespace nodes with %u Objects\n", 964 Info.Nodes, Info.Objects); 965 } 966 967 968 /******************************************************************************* 969 * 970 * FUNCTION: AcpiDbWalkForReferences 971 * 972 * PARAMETERS: Callback from WalkNamespace 973 * 974 * RETURN: Status 975 * 976 * DESCRIPTION: Check if this namespace object refers to the target object 977 * that is passed in as the context value. 978 * 979 * Note: Currently doesn't check subobjects within the Node's object 980 * 981 ******************************************************************************/ 982 983 static ACPI_STATUS 984 AcpiDbWalkForReferences ( 985 ACPI_HANDLE ObjHandle, 986 UINT32 NestingLevel, 987 void *Context, 988 void **ReturnValue) 989 { 990 ACPI_OPERAND_OBJECT *ObjDesc = (ACPI_OPERAND_OBJECT *) Context; 991 ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle; 992 993 994 /* Check for match against the namespace node itself */ 995 996 if (Node == (void *) ObjDesc) 997 { 998 AcpiOsPrintf ("Object is a Node [%4.4s]\n", 999 AcpiUtGetNodeName (Node)); 1000 } 1001 1002 /* Check for match against the object attached to the node */ 1003 1004 if (AcpiNsGetAttachedObject (Node) == ObjDesc) 1005 { 1006 AcpiOsPrintf ("Reference at Node->Object %p [%4.4s]\n", 1007 Node, AcpiUtGetNodeName (Node)); 1008 } 1009 1010 return (AE_OK); 1011 } 1012 1013 1014 /******************************************************************************* 1015 * 1016 * FUNCTION: AcpiDbFindReferences 1017 * 1018 * PARAMETERS: ObjectArg - String with hex value of the object 1019 * 1020 * RETURN: None 1021 * 1022 * DESCRIPTION: Search namespace for all references to the input object 1023 * 1024 ******************************************************************************/ 1025 1026 void 1027 AcpiDbFindReferences ( 1028 char *ObjectArg) 1029 { 1030 ACPI_OPERAND_OBJECT *ObjDesc; 1031 ACPI_SIZE Address; 1032 1033 1034 /* Convert string to object pointer */ 1035 1036 Address = strtoul (ObjectArg, NULL, 16); 1037 ObjDesc = ACPI_TO_POINTER (Address); 1038 1039 /* Search all nodes in namespace */ 1040 1041 (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, 1042 ACPI_UINT32_MAX, AcpiDbWalkForReferences, NULL, 1043 (void *) ObjDesc, NULL); 1044 } 1045 1046 1047 /******************************************************************************* 1048 * 1049 * FUNCTION: AcpiDbBusWalk 1050 * 1051 * PARAMETERS: Callback from WalkNamespace 1052 * 1053 * RETURN: Status 1054 * 1055 * DESCRIPTION: Display info about device objects that have a corresponding 1056 * _PRT method. 1057 * 1058 ******************************************************************************/ 1059 1060 static ACPI_STATUS 1061 AcpiDbBusWalk ( 1062 ACPI_HANDLE ObjHandle, 1063 UINT32 NestingLevel, 1064 void *Context, 1065 void **ReturnValue) 1066 { 1067 ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle; 1068 ACPI_STATUS Status; 1069 ACPI_BUFFER Buffer; 1070 ACPI_NAMESPACE_NODE *TempNode; 1071 ACPI_DEVICE_INFO *Info; 1072 UINT32 i; 1073 1074 1075 if ((Node->Type != ACPI_TYPE_DEVICE) && 1076 (Node->Type != ACPI_TYPE_PROCESSOR)) 1077 { 1078 return (AE_OK); 1079 } 1080 1081 /* Exit if there is no _PRT under this device */ 1082 1083 Status = AcpiGetHandle (Node, METHOD_NAME__PRT, 1084 ACPI_CAST_PTR (ACPI_HANDLE, &TempNode)); 1085 if (ACPI_FAILURE (Status)) 1086 { 1087 return (AE_OK); 1088 } 1089 1090 /* Get the full path to this device object */ 1091 1092 Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER; 1093 Status = AcpiNsHandleToPathname (ObjHandle, &Buffer, TRUE); 1094 if (ACPI_FAILURE (Status)) 1095 { 1096 AcpiOsPrintf ("Could Not get pathname for object %p\n", 1097 ObjHandle); 1098 return (AE_OK); 1099 } 1100 1101 Status = AcpiGetObjectInfo (ObjHandle, &Info); 1102 if (ACPI_FAILURE (Status)) 1103 { 1104 return (AE_OK); 1105 } 1106 1107 /* Display the full path */ 1108 1109 AcpiOsPrintf ("%-32s Type %X", (char *) Buffer.Pointer, Node->Type); 1110 ACPI_FREE (Buffer.Pointer); 1111 1112 if (Info->Flags & ACPI_PCI_ROOT_BRIDGE) 1113 { 1114 AcpiOsPrintf (" - Is PCI Root Bridge"); 1115 } 1116 AcpiOsPrintf ("\n"); 1117 1118 /* _PRT info */ 1119 1120 AcpiOsPrintf ("_PRT: %p\n", TempNode); 1121 1122 /* Dump _ADR, _HID, _UID, _CID */ 1123 1124 if (Info->Valid & ACPI_VALID_ADR) 1125 { 1126 AcpiOsPrintf ("_ADR: %8.8X%8.8X\n", 1127 ACPI_FORMAT_UINT64 (Info->Address)); 1128 } 1129 else 1130 { 1131 AcpiOsPrintf ("_ADR: <Not Present>\n"); 1132 } 1133 1134 if (Info->Valid & ACPI_VALID_HID) 1135 { 1136 AcpiOsPrintf ("_HID: %s\n", Info->HardwareId.String); 1137 } 1138 else 1139 { 1140 AcpiOsPrintf ("_HID: <Not Present>\n"); 1141 } 1142 1143 if (Info->Valid & ACPI_VALID_UID) 1144 { 1145 AcpiOsPrintf ("_UID: %s\n", Info->UniqueId.String); 1146 } 1147 else 1148 { 1149 AcpiOsPrintf ("_UID: <Not Present>\n"); 1150 } 1151 1152 if (Info->Valid & ACPI_VALID_CID) 1153 { 1154 for (i = 0; i < Info->CompatibleIdList.Count; i++) 1155 { 1156 AcpiOsPrintf ("_CID: %s\n", 1157 Info->CompatibleIdList.Ids[i].String); 1158 } 1159 } 1160 else 1161 { 1162 AcpiOsPrintf ("_CID: <Not Present>\n"); 1163 } 1164 1165 ACPI_FREE (Info); 1166 return (AE_OK); 1167 } 1168 1169 1170 /******************************************************************************* 1171 * 1172 * FUNCTION: AcpiDbGetBusInfo 1173 * 1174 * PARAMETERS: None 1175 * 1176 * RETURN: None 1177 * 1178 * DESCRIPTION: Display info about system buses. 1179 * 1180 ******************************************************************************/ 1181 1182 void 1183 AcpiDbGetBusInfo ( 1184 void) 1185 { 1186 /* Search all nodes in namespace */ 1187 1188 (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, 1189 ACPI_UINT32_MAX, AcpiDbBusWalk, NULL, NULL, NULL); 1190 } 1191