dbcmds.c revision 87031
1/******************************************************************************* 2 * 3 * Module Name: dbcmds - debug commands and output routines 4 * $Revision: 67 $ 5 * 6 ******************************************************************************/ 7 8/****************************************************************************** 9 * 10 * 1. Copyright Notice 11 * 12 * Some or all of this work - Copyright (c) 1999, 2000, 2001, 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. 21 * 22 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a 23 * copy of the source code appearing in this file ("Covered Code") an 24 * irrevocable, perpetual, worldwide license under Intel's copyrights in the 25 * base code distributed originally by Intel ("Original Intel Code") to copy, 26 * make derivatives, distribute, use and display any portion of the Covered 27 * Code in any form, with the right to sublicense such rights; and 28 * 29 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent 30 * license (with the right to sublicense), under only those claims of Intel 31 * patents that are infringed by the Original Intel Code, to make, use, sell, 32 * offer to sell, and import the Covered Code and derivative works thereof 33 * solely to the minimum extent necessary to exercise the above copyright 34 * license, and in no event shall the patent license extend to any additions 35 * to or modifications of the Original Intel Code. No other license or right 36 * is granted directly or by implication, estoppel or otherwise; 37 * 38 * The above copyright and patent license is granted only if the following 39 * conditions are met: 40 * 41 * 3. Conditions 42 * 43 * 3.1. Redistribution of Source with Rights to Further Distribute Source. 44 * Redistribution of source code of any substantial portion of the Covered 45 * Code or modification with rights to further distribute source must include 46 * the above Copyright Notice, the above License, this list of Conditions, 47 * and the following Disclaimer and Export Compliance provision. In addition, 48 * Licensee must cause all Covered Code to which Licensee contributes to 49 * contain a file documenting the changes Licensee made to create that Covered 50 * Code and the date of any change. Licensee must include in that file the 51 * documentation of any changes made by any predecessor Licensee. Licensee 52 * must include a prominent statement that the modification is derived, 53 * directly or indirectly, from Original Intel Code. 54 * 55 * 3.2. Redistribution of Source with no Rights to Further Distribute Source. 56 * Redistribution of source code of any substantial portion of the Covered 57 * Code or modification without rights to further distribute source must 58 * include the following Disclaimer and Export Compliance provision in the 59 * documentation and/or other materials provided with distribution. In 60 * addition, Licensee may not authorize further sublicense of source of any 61 * portion of the Covered Code, and must include terms to the effect that the 62 * license from Licensee to its licensee is limited to the intellectual 63 * property embodied in the software Licensee provides to its licensee, and 64 * not to intellectual property embodied in modifications its licensee may 65 * make. 66 * 67 * 3.3. Redistribution of Executable. Redistribution in executable form of any 68 * substantial portion of the Covered Code or modification must reproduce the 69 * above Copyright Notice, and the following Disclaimer and Export Compliance 70 * provision in the documentation and/or other materials provided with the 71 * distribution. 72 * 73 * 3.4. Intel retains all right, title, and interest in and to the Original 74 * Intel Code. 75 * 76 * 3.5. Neither the name Intel nor any other trademark owned or controlled by 77 * Intel shall be used in advertising or otherwise to promote the sale, use or 78 * other dealings in products derived from or relating to the Covered Code 79 * without prior written authorization from Intel. 80 * 81 * 4. Disclaimer and Export Compliance 82 * 83 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED 84 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE 85 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, 86 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY 87 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY 88 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A 89 * PARTICULAR PURPOSE. 90 * 91 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES 92 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR 93 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, 94 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY 95 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL 96 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS 97 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY 98 * LIMITED REMEDY. 99 * 100 * 4.3. Licensee shall not export, either directly or indirectly, any of this 101 * software or system incorporating such software without first obtaining any 102 * required license or other approval from the U. S. Department of Commerce or 103 * any other agency or department of the United States Government. In the 104 * event Licensee exports any such software from the United States or 105 * re-exports any such software from a foreign destination, Licensee shall 106 * ensure that the distribution and export/re-export of the software is in 107 * compliance with all laws, regulations, orders, or other restrictions of the 108 * U.S. Export Administration Regulations. Licensee agrees that neither it nor 109 * any of its subsidiaries will export/re-export any technical data, process, 110 * software, or service, directly or indirectly, to any country for which the 111 * United States government or any agency thereof requires an export license, 112 * other governmental approval, or letter of assurance, without first obtaining 113 * such license, approval or letter. 114 * 115 *****************************************************************************/ 116 117 118#include "acpi.h" 119#include "acparser.h" 120#include "acdispat.h" 121#include "amlcode.h" 122#include "acnamesp.h" 123#include "acparser.h" 124#include "acevents.h" 125#include "acinterp.h" 126#include "acdebug.h" 127#include "actables.h" 128#include "acresrc.h" 129 130#ifdef ENABLE_DEBUGGER 131 132#define _COMPONENT ACPI_DEBUGGER 133 MODULE_NAME ("dbcmds") 134 135 136/* 137 * Arguments for the Objects command 138 * These object types map directly to the ACPI_TYPES 139 */ 140 141ARGUMENT_INFO AcpiDbObjectTypes [] = 142{ 143 {"ANY"}, 144 {"NUMBERS"}, 145 {"STRINGS"}, 146 {"BUFFERS"}, 147 {"PACKAGES"}, 148 {"FIELDS"}, 149 {"DEVICES"}, 150 {"EVENTS"}, 151 {"METHODS"}, 152 {"MUTEXES"}, 153 {"REGIONS"}, 154 {"POWERRESOURCES"}, 155 {"PROCESSORS"}, 156 {"THERMALZONES"}, 157 {"BUFFERFIELDS"}, 158 {"DDBHANDLES"}, 159 {NULL} /* Must be null terminated */ 160}; 161 162 163/******************************************************************************* 164 * 165 * FUNCTION: AcpiDbWalkForReferences 166 * 167 * PARAMETERS: Callback from WalkNamespace 168 * 169 * RETURN: Status 170 * 171 * DESCRIPTION: Check if this namespace object refers to the target object 172 * that is passed in as the context value. 173 * 174 ******************************************************************************/ 175 176ACPI_STATUS 177AcpiDbWalkForReferences ( 178 ACPI_HANDLE ObjHandle, 179 UINT32 NestingLevel, 180 void *Context, 181 void **ReturnValue) 182{ 183 ACPI_OPERAND_OBJECT *ObjDesc = (ACPI_OPERAND_OBJECT *) Context; 184 ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle; 185 186 187 /* Check for match against the namespace node itself */ 188 189 if (Node == (void *) ObjDesc) 190 { 191 AcpiOsPrintf ("Object is a Node [%4.4s]\n", &Node->Name); 192 } 193 194 /* Check for match against the object attached to the node */ 195 196 if (AcpiNsGetAttachedObject (Node) == ObjDesc) 197 { 198 AcpiOsPrintf ("Reference at Node->Object %p [%4.4s]\n", Node, &Node->Name); 199 } 200 201 /* Check first child for a match */ 202 /* TBD: [Investigate] probably now obsolete with new datastructure */ 203 204 if (Node->Child == (void *) ObjDesc) 205 { 206 AcpiOsPrintf ("Reference at Node->Child %p [%4.4s]\n", Node, &Node->Name); 207 } 208 209 return (AE_OK); 210} 211 212 213/******************************************************************************* 214 * 215 * FUNCTION: AcpiDbFindReferences 216 * 217 * PARAMETERS: ObjectArg - String with hex value of the object 218 * 219 * RETURN: None 220 * 221 * DESCRIPTION: Search namespace for all references to the input object 222 * 223 ******************************************************************************/ 224 225void 226AcpiDbFindReferences ( 227 NATIVE_CHAR *ObjectArg) 228{ 229 ACPI_OPERAND_OBJECT *ObjDesc; 230 231 232 /* Convert string to object pointer */ 233 234 ObjDesc = (ACPI_OPERAND_OBJECT *) STRTOUL (ObjectArg, NULL, 16); 235 236 /* Search all nodes in namespace */ 237 238 AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX, 239 AcpiDbWalkForReferences, (void *) ObjDesc, NULL); 240} 241 242 243/******************************************************************************* 244 * 245 * FUNCTION: AcpiDbDisplayLocks 246 * 247 * PARAMETERS: None 248 * 249 * RETURN: None 250 * 251 * DESCRIPTION: Display information about internal mutexes. 252 * 253 ******************************************************************************/ 254 255void 256AcpiDbDisplayLocks (void) 257{ 258 UINT32 i; 259 260 261 for (i = 0; i < MAX_MTX; i++) 262 { 263 AcpiOsPrintf ("%26s : %s\n", AcpiUtGetMutexName (i), 264 AcpiGbl_AcpiMutexInfo[i].OwnerId == ACPI_MUTEX_NOT_ACQUIRED 265 ? "Locked" : "Unlocked"); 266 } 267} 268 269 270/******************************************************************************* 271 * 272 * FUNCTION: AcpiDbDisplayTableInfo 273 * 274 * PARAMETERS: TableArg - String with name of table to be displayed 275 * 276 * RETURN: None 277 * 278 * DESCRIPTION: Display information about loaded tables. Current 279 * implementation displays all loaded tables. 280 * 281 ******************************************************************************/ 282 283void 284AcpiDbDisplayTableInfo ( 285 NATIVE_CHAR *TableArg) 286{ 287 UINT32 i; 288 289 290 for (i = 0; i < NUM_ACPI_TABLES; i++) 291 { 292 if (AcpiGbl_AcpiTables[i].Pointer) 293 { 294 AcpiOsPrintf ("%s at %p length %X\n", AcpiGbl_AcpiTableData[i].Name, 295 AcpiGbl_AcpiTables[i].Pointer, AcpiGbl_AcpiTables[i].Length); 296 } 297 } 298} 299 300 301/******************************************************************************* 302 * 303 * FUNCTION: AcpiDbUnloadAcpiTable 304 * 305 * PARAMETERS: TableArg - Name of the table to be unloaded 306 * InstanceArg - Which instance of the table to unload (if 307 * there are multiple tables of the same type) 308 * 309 * RETURN: Nonde 310 * 311 * DESCRIPTION: Unload an ACPI table. 312 * Instance is not implemented 313 * 314 ******************************************************************************/ 315 316void 317AcpiDbUnloadAcpiTable ( 318 NATIVE_CHAR *TableArg, 319 NATIVE_CHAR *InstanceArg) 320{ 321 UINT32 i; 322 ACPI_STATUS Status; 323 324 325 /* Search all tables for the target type */ 326 327 for (i = 0; i < NUM_ACPI_TABLES; i++) 328 { 329 if (!STRNCMP (TableArg, AcpiGbl_AcpiTableData[i].Signature, 330 AcpiGbl_AcpiTableData[i].SigLength)) 331 { 332 /* Found the table, unload it */ 333 334 Status = AcpiUnloadTable (i); 335 if (ACPI_SUCCESS (Status)) 336 { 337 AcpiOsPrintf ("[%s] unloaded and uninstalled\n", TableArg); 338 } 339 else 340 { 341 AcpiOsPrintf ("%s, while unloading [%s]\n", 342 AcpiFormatException (Status), TableArg); 343 } 344 345 return; 346 } 347 } 348 349 AcpiOsPrintf ("Unknown table type [%s]\n", TableArg); 350} 351 352 353/******************************************************************************* 354 * 355 * FUNCTION: AcpiDbSetMethodBreakpoint 356 * 357 * PARAMETERS: Location - AML offset of breakpoint 358 * WalkState - Current walk info 359 * Op - Current Op (from parse walk) 360 * 361 * RETURN: None 362 * 363 * DESCRIPTION: Set a breakpoint in a control method at the specified 364 * AML offset 365 * 366 ******************************************************************************/ 367 368void 369AcpiDbSetMethodBreakpoint ( 370 NATIVE_CHAR *Location, 371 ACPI_WALK_STATE *WalkState, 372 ACPI_PARSE_OBJECT *Op) 373{ 374 UINT32 Address; 375 376 377 if (!Op) 378 { 379 AcpiOsPrintf ("There is no method currently executing\n"); 380 return; 381 } 382 383 /* Get and verify the breakpoint address */ 384 385 Address = STRTOUL (Location, NULL, 16); 386 if (Address <= Op->AmlOffset) 387 { 388 AcpiOsPrintf ("Breakpoint %X is beyond current address %X\n", Address, Op->AmlOffset); 389 } 390 391 /* Save breakpoint in current walk */ 392 393 WalkState->MethodBreakpoint = Address; 394 AcpiOsPrintf ("Breakpoint set at AML offset %X\n", Address); 395} 396 397 398/******************************************************************************* 399 * 400 * FUNCTION: AcpiDbSetMethodCallBreakpoint 401 * 402 * PARAMETERS: Op - Current Op (from parse walk) 403 * 404 * RETURN: None 405 * 406 * DESCRIPTION: Set a breakpoint in a control method at the specified 407 * AML offset 408 * 409 ******************************************************************************/ 410 411void 412AcpiDbSetMethodCallBreakpoint ( 413 ACPI_PARSE_OBJECT *Op) 414{ 415 416 417 if (!Op) 418 { 419 AcpiOsPrintf ("There is no method currently executing\n"); 420 return; 421 } 422 423 424 AcpiGbl_StepToNextCall = TRUE; 425} 426 427 428/******************************************************************************* 429 * 430 * FUNCTION: AcpiDbDisassembleAml 431 * 432 * PARAMETERS: Statements - Number of statements to disassemble 433 * Op - Current Op (from parse walk) 434 * 435 * RETURN: None 436 * 437 * DESCRIPTION: Display disassembled AML (ASL) starting from Op for the number 438 * of statements specified. 439 * 440 ******************************************************************************/ 441 442void 443AcpiDbDisassembleAml ( 444 NATIVE_CHAR *Statements, 445 ACPI_PARSE_OBJECT *Op) 446{ 447 UINT32 NumStatements = 8; 448 449 450 if (!Op) 451 { 452 AcpiOsPrintf ("There is no method currently executing\n"); 453 return; 454 } 455 456 if (Statements) 457 { 458 NumStatements = STRTOUL (Statements, NULL, 0); 459 } 460 461 462 AcpiDbDisplayOp (NULL, Op, NumStatements); 463} 464 465 466/******************************************************************************* 467 * 468 * FUNCTION: AcpiDbDumpNamespace 469 * 470 * PARAMETERS: StartArg - Node to begin namespace dump 471 * DepthArg - Maximum tree depth to be dumped 472 * 473 * RETURN: None 474 * 475 * DESCRIPTION: Dump entire namespace or a subtree. Each node is displayed 476 * with type and other information. 477 * 478 ******************************************************************************/ 479 480void 481AcpiDbDumpNamespace ( 482 NATIVE_CHAR *StartArg, 483 NATIVE_CHAR *DepthArg) 484{ 485 ACPI_HANDLE SubtreeEntry = AcpiGbl_RootNode; 486 UINT32 MaxDepth = ACPI_UINT32_MAX; 487 488 489 /* No argument given, just start at the root and dump entire namespace */ 490 491 if (StartArg) 492 { 493 /* Check if numeric argument, must be a Node */ 494 495 if ((StartArg[0] >= 0x30) && (StartArg[0] <= 0x39)) 496 { 497 SubtreeEntry = (ACPI_HANDLE) STRTOUL (StartArg, NULL, 16); 498 if (!AcpiOsReadable (SubtreeEntry, sizeof (ACPI_NAMESPACE_NODE))) 499 { 500 AcpiOsPrintf ("Address %p is invalid in this address space\n", SubtreeEntry); 501 return; 502 } 503 504 if (!VALID_DESCRIPTOR_TYPE ((SubtreeEntry), ACPI_DESC_TYPE_NAMED)) 505 { 506 AcpiOsPrintf ("Address %p is not a valid Named object\n", SubtreeEntry); 507 return; 508 } 509 } 510 511 /* Alpha argument */ 512 513 else 514 { 515 /* The parameter is a name string that must be resolved to a Named obj*/ 516 517 SubtreeEntry = AcpiDbLocalNsLookup (StartArg); 518 if (!SubtreeEntry) 519 { 520 SubtreeEntry = AcpiGbl_RootNode; 521 } 522 } 523 524 /* Now we can check for the depth argument */ 525 526 if (DepthArg) 527 { 528 MaxDepth = STRTOUL (DepthArg, NULL, 0); 529 } 530 } 531 532 533 AcpiDbSetOutputDestination (DB_DUPLICATE_OUTPUT); 534 AcpiOsPrintf ("ACPI Namespace (from %p subtree):\n", SubtreeEntry); 535 536 /* Display the subtree */ 537 538 AcpiDbSetOutputDestination (DB_REDIRECTABLE_OUTPUT); 539 AcpiNsDumpObjects (ACPI_TYPE_ANY, ACPI_DISPLAY_SUMMARY, MaxDepth, ACPI_UINT32_MAX, SubtreeEntry); 540 AcpiDbSetOutputDestination (DB_CONSOLE_OUTPUT); 541} 542 543 544/******************************************************************************* 545 * 546 * FUNCTION: AcpiDbDumpNamespaceByOwner 547 * 548 * PARAMETERS: OwnerArg - Owner ID whose nodes will be displayed 549 * DepthArg - Maximum tree depth to be dumped 550 * 551 * RETURN: None 552 * 553 * DESCRIPTION: Dump elements of the namespace that are owned by the OwnerId. 554 * 555 ******************************************************************************/ 556 557void 558AcpiDbDumpNamespaceByOwner ( 559 NATIVE_CHAR *OwnerArg, 560 NATIVE_CHAR *DepthArg) 561{ 562 ACPI_HANDLE SubtreeEntry = AcpiGbl_RootNode; 563 UINT32 MaxDepth = ACPI_UINT32_MAX; 564 UINT16 OwnerId; 565 566 567 OwnerId = (UINT16) STRTOUL (OwnerArg, NULL, 0); 568 569 570 /* Now we can check for the depth argument */ 571 572 if (DepthArg) 573 { 574 MaxDepth = STRTOUL (DepthArg, NULL, 0); 575 } 576 577 578 AcpiDbSetOutputDestination (DB_DUPLICATE_OUTPUT); 579 AcpiOsPrintf ("ACPI Namespace by owner %X:\n", OwnerId); 580 581 /* Display the subtree */ 582 583 AcpiDbSetOutputDestination (DB_REDIRECTABLE_OUTPUT); 584 AcpiNsDumpObjects (ACPI_TYPE_ANY, ACPI_DISPLAY_SUMMARY, MaxDepth, OwnerId, SubtreeEntry); 585 AcpiDbSetOutputDestination (DB_CONSOLE_OUTPUT); 586} 587 588 589/******************************************************************************* 590 * 591 * FUNCTION: AcpiDbSendNotify 592 * 593 * PARAMETERS: Name - Name of ACPI object to send the notify to 594 * Value - Value of the notify to send. 595 * 596 * RETURN: None 597 * 598 * DESCRIPTION: Send an ACPI notification. The value specified is sent to the 599 * named object as an ACPI notify. 600 * 601 ******************************************************************************/ 602 603void 604AcpiDbSendNotify ( 605 NATIVE_CHAR *Name, 606 UINT32 Value) 607{ 608 ACPI_NAMESPACE_NODE *Node; 609 610 611 /* Translate name to an Named object */ 612 613 Node = AcpiDbLocalNsLookup (Name); 614 if (!Node) 615 { 616 return; 617 } 618 619 /* Decode Named object type */ 620 621 switch (Node->Type) 622 { 623 case ACPI_TYPE_DEVICE: 624 case ACPI_TYPE_THERMAL: 625 626 /* Send the notify */ 627 628 AcpiEvQueueNotifyRequest (Node, Value); 629 break; 630 631 default: 632 AcpiOsPrintf ("Named object is not a device or a thermal object\n"); 633 break; 634 } 635 636} 637 638 639/******************************************************************************* 640 * 641 * FUNCTION: AcpiDbSetMethodData 642 * 643 * PARAMETERS: TypeArg - L for local, A for argument 644 * IndexArg - which one 645 * ValueArg - Value to set. 646 * 647 * RETURN: None 648 * 649 * DESCRIPTION: Set a local or argument for the running control method. 650 * NOTE: only object supported is Number. 651 * 652 ******************************************************************************/ 653 654void 655AcpiDbSetMethodData ( 656 NATIVE_CHAR *TypeArg, 657 NATIVE_CHAR *IndexArg, 658 NATIVE_CHAR *ValueArg) 659{ 660 NATIVE_CHAR Type; 661 UINT32 Index; 662 UINT32 Value; 663 ACPI_WALK_STATE *WalkState; 664 ACPI_OPERAND_OBJECT *ObjDesc; 665 666 667 /* Validate TypeArg */ 668 669 STRUPR (TypeArg); 670 Type = TypeArg[0]; 671 if ((Type != 'L') && 672 (Type != 'A')) 673 { 674 AcpiOsPrintf ("Invalid SET operand: %s\n", TypeArg); 675 return; 676 } 677 678 /* Get the index and value */ 679 680 Index = STRTOUL (IndexArg, NULL, 16); 681 Value = STRTOUL (ValueArg, NULL, 16); 682 683 WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList); 684 if (!WalkState) 685 { 686 AcpiOsPrintf ("There is no method currently executing\n"); 687 return; 688 } 689 690 691 /* Create and initialize the new object */ 692 693 ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER); 694 if (!ObjDesc) 695 { 696 AcpiOsPrintf ("Could not create an internal object\n"); 697 return; 698 } 699 700 ObjDesc->Integer.Value = Value; 701 702 703 /* Store the new object into the target */ 704 705 switch (Type) 706 { 707 case 'A': 708 709 /* Set a method argument */ 710 711 if (Index > MTH_NUM_ARGS) 712 { 713 AcpiOsPrintf ("Arg%d - Invalid argument name\n", Index); 714 return; 715 } 716 717 AcpiDsStoreObjectToLocal (AML_ARG_OP, Index, ObjDesc, WalkState); 718 ObjDesc = WalkState->Arguments[Index].Object; 719 720 AcpiOsPrintf ("Arg%d: ", Index); 721 AcpiDbDisplayInternalObject (ObjDesc, WalkState); 722 break; 723 724 case 'L': 725 726 /* Set a method local */ 727 728 if (Index > MTH_NUM_LOCALS) 729 { 730 AcpiOsPrintf ("Local%d - Invalid local variable name\n", Index); 731 return; 732 } 733 734 AcpiDsStoreObjectToLocal (AML_LOCAL_OP, Index, ObjDesc, WalkState); 735 ObjDesc = WalkState->LocalVariables[Index].Object; 736 737 AcpiOsPrintf ("Local%d: ", Index); 738 AcpiDbDisplayInternalObject (ObjDesc, WalkState); 739 break; 740 741 default: 742 break; 743 } 744} 745 746 747/******************************************************************************* 748 * 749 * FUNCTION: AcpiDbWalkForSpecificObjects 750 * 751 * PARAMETERS: Callback from WalkNamespace 752 * 753 * RETURN: Status 754 * 755 * DESCRIPTION: Display short info about objects in the namespace 756 * 757 ******************************************************************************/ 758 759ACPI_STATUS 760AcpiDbWalkForSpecificObjects ( 761 ACPI_HANDLE ObjHandle, 762 UINT32 NestingLevel, 763 void *Context, 764 void **ReturnValue) 765{ 766 ACPI_OPERAND_OBJECT *ObjDesc; 767 ACPI_STATUS Status; 768 UINT32 BufSize; 769 NATIVE_CHAR Buffer[64]; 770 771 772 ObjDesc = AcpiNsGetAttachedObject ((ACPI_NAMESPACE_NODE *) ObjHandle); 773 BufSize = sizeof (Buffer) / sizeof (*Buffer); 774 775 /* Get and display the full pathname to this object */ 776 777 Status = AcpiNsHandleToPathname (ObjHandle, &BufSize, Buffer); 778 779 if (ACPI_FAILURE (Status)) 780 { 781 AcpiOsPrintf ("Could Not get pathname for object %p\n", ObjHandle); 782 return (AE_OK); 783 } 784 785 AcpiOsPrintf ("%32s", Buffer); 786 787 788 /* Display short information about the object */ 789 790 if (ObjDesc) 791 { 792 switch (ObjDesc->Common.Type) 793 { 794 case ACPI_TYPE_METHOD: 795 AcpiOsPrintf (" #Args %d Concurrency %X", ObjDesc->Method.ParamCount, ObjDesc->Method.Concurrency); 796 break; 797 798 case ACPI_TYPE_INTEGER: 799 AcpiOsPrintf (" Value %X", ObjDesc->Integer.Value); 800 break; 801 802 case ACPI_TYPE_STRING: 803 AcpiOsPrintf (" \"%s\"", ObjDesc->String.Pointer); 804 break; 805 806 case ACPI_TYPE_REGION: 807 AcpiOsPrintf (" SpaceId %X Address %X Length %X", ObjDesc->Region.SpaceId, ObjDesc->Region.Address, ObjDesc->Region.Length); 808 break; 809 810 case ACPI_TYPE_PACKAGE: 811 AcpiOsPrintf (" #Elements %X", ObjDesc->Package.Count); 812 break; 813 814 case ACPI_TYPE_BUFFER: 815 AcpiOsPrintf (" Length %X", ObjDesc->Buffer.Length); 816 break; 817 } 818 } 819 820 AcpiOsPrintf ("\n"); 821 return (AE_OK); 822} 823 824 825/******************************************************************************* 826 * 827 * FUNCTION: AcpiDbDisplayObjects 828 * 829 * PARAMETERS: ObjTypeArg - Type of object to display 830 * DisplayCountArg - Max depth to display 831 * 832 * RETURN: None 833 * 834 * DESCRIPTION: Display objects in the namespace of the requested type 835 * 836 ******************************************************************************/ 837 838ACPI_STATUS 839AcpiDbDisplayObjects ( 840 NATIVE_CHAR *ObjTypeArg, 841 NATIVE_CHAR *DisplayCountArg) 842{ 843 ACPI_OBJECT_TYPE8 Type; 844 845 846 /* Get the object type */ 847 848 Type = AcpiDbMatchArgument (ObjTypeArg, AcpiDbObjectTypes); 849 if (Type == ACPI_TYPE_NOT_FOUND) 850 { 851 AcpiOsPrintf ("Invalid or unsupported argument\n"); 852 return (AE_OK); 853 } 854 855 AcpiDbSetOutputDestination (DB_DUPLICATE_OUTPUT); 856 AcpiOsPrintf ("Objects of type [%s] defined in the current ACPI Namespace: \n", AcpiUtGetTypeName (Type)); 857 858 AcpiDbSetOutputDestination (DB_REDIRECTABLE_OUTPUT); 859 860 /* Walk the namespace from the root */ 861 862 AcpiWalkNamespace (Type, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX, 863 AcpiDbWalkForSpecificObjects, (void *) &Type, NULL); 864 865 AcpiDbSetOutputDestination (DB_CONSOLE_OUTPUT); 866 return (AE_OK); 867} 868 869 870/******************************************************************************* 871 * 872 * FUNCTION: AcpiDbWalkAndMatchName 873 * 874 * PARAMETERS: Callback from WalkNamespace 875 * 876 * RETURN: Status 877 * 878 * DESCRIPTION: Find a particular name/names within the namespace. Wildcards 879 * are supported -- '?' matches any character. 880 * 881 ******************************************************************************/ 882 883ACPI_STATUS 884AcpiDbWalkAndMatchName ( 885 ACPI_HANDLE ObjHandle, 886 UINT32 NestingLevel, 887 void *Context, 888 void **ReturnValue) 889{ 890 ACPI_STATUS Status; 891 NATIVE_CHAR *RequestedName = (NATIVE_CHAR *) Context; 892 UINT32 i; 893 UINT32 BufSize; 894 NATIVE_CHAR Buffer[96]; 895 896 897 /* Check for a name match */ 898 899 for (i = 0; i < 4; i++) 900 { 901 /* Wildcard support */ 902 903 if ((RequestedName[i] != '?') && 904 (RequestedName[i] != ((NATIVE_CHAR *) (&((ACPI_NAMESPACE_NODE *) ObjHandle)->Name))[i])) 905 { 906 /* No match, just exit */ 907 908 return (AE_OK); 909 } 910 } 911 912 913 /* Get the full pathname to this object */ 914 915 BufSize = sizeof (Buffer) / sizeof (*Buffer); 916 917 Status = AcpiNsHandleToPathname (ObjHandle, &BufSize, Buffer); 918 if (ACPI_FAILURE (Status)) 919 { 920 AcpiOsPrintf ("Could Not get pathname for object %p\n", ObjHandle); 921 } 922 923 else 924 { 925 AcpiOsPrintf ("%32s (%p) - %s\n", Buffer, ObjHandle, 926 AcpiUtGetTypeName (((ACPI_NAMESPACE_NODE *) ObjHandle)->Type)); 927 } 928 929 return (AE_OK); 930} 931 932 933/******************************************************************************* 934 * 935 * FUNCTION: AcpiDbFindNameInNamespace 936 * 937 * PARAMETERS: NameArg - The 4-character ACPI name to find. 938 * wildcards are supported. 939 * 940 * RETURN: None 941 * 942 * DESCRIPTION: Search the namespace for a given name (with wildcards) 943 * 944 ******************************************************************************/ 945 946ACPI_STATUS 947AcpiDbFindNameInNamespace ( 948 NATIVE_CHAR *NameArg) 949{ 950 951 if (STRLEN (NameArg) > 4) 952 { 953 AcpiOsPrintf ("Name must be no longer than 4 characters\n"); 954 return (AE_OK); 955 } 956 957 /* Walk the namespace from the root */ 958 959 AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX, 960 AcpiDbWalkAndMatchName, NameArg, NULL); 961 962 AcpiDbSetOutputDestination (DB_CONSOLE_OUTPUT); 963 return (AE_OK); 964} 965 966 967/******************************************************************************* 968 * 969 * FUNCTION: AcpiDbSetScope 970 * 971 * PARAMETERS: Name - New scope path 972 * 973 * RETURN: Status 974 * 975 * DESCRIPTION: Set the "current scope" as maintained by this utility. 976 * The scope is used as a prefix to ACPI paths. 977 * 978 ******************************************************************************/ 979 980void 981AcpiDbSetScope ( 982 NATIVE_CHAR *Name) 983{ 984 985 if (!Name || Name[0] == 0) 986 { 987 AcpiOsPrintf ("Current scope: %s\n", AcpiGbl_DbScopeBuf); 988 return; 989 } 990 991 AcpiDbPrepNamestring (Name); 992 993 /* TBD: [Future] Validate scope here */ 994 995 if (Name[0] == '\\') 996 { 997 STRCPY (AcpiGbl_DbScopeBuf, Name); 998 STRCAT (AcpiGbl_DbScopeBuf, "\\"); 999 } 1000 1001 else 1002 { 1003 STRCAT (AcpiGbl_DbScopeBuf, Name); 1004 STRCAT (AcpiGbl_DbScopeBuf, "\\"); 1005 } 1006 1007 AcpiOsPrintf ("New scope: %s\n", AcpiGbl_DbScopeBuf); 1008} 1009 1010 1011/******************************************************************************* 1012 * 1013 * FUNCTION: AcpiDbDisplayResources 1014 * 1015 * PARAMETERS: ObjectArg - String with hex value of the object 1016 * 1017 * RETURN: None 1018 * 1019 * DESCRIPTION: 1020 * 1021 ******************************************************************************/ 1022 1023void 1024AcpiDbDisplayResources ( 1025 NATIVE_CHAR *ObjectArg) 1026{ 1027#ifndef _IA16 1028 ACPI_OPERAND_OBJECT *ObjDesc; 1029 ACPI_STATUS Status; 1030 ACPI_BUFFER ReturnObj; 1031 1032 1033 AcpiDbSetOutputDestination (DB_REDIRECTABLE_OUTPUT); 1034 1035 /* Convert string to object pointer */ 1036 1037 ObjDesc = (ACPI_OPERAND_OBJECT *) STRTOUL (ObjectArg, NULL, 16); 1038 1039 /* Prepare for a return object of arbitrary size */ 1040 1041 ReturnObj.Pointer = AcpiGbl_DbBuffer; 1042 ReturnObj.Length = ACPI_DEBUG_BUFFER_SIZE; 1043 1044 1045 /* _PRT */ 1046 1047 AcpiOsPrintf ("Evaluating _PRT\n"); 1048 1049 Status = AcpiEvaluateObject (ObjDesc, "_PRT", NULL, &ReturnObj); 1050 if (ACPI_FAILURE (Status)) 1051 { 1052 AcpiOsPrintf ("Could not obtain _PRT: %s\n", AcpiFormatException (Status)); 1053 goto GetCrs; 1054 } 1055 1056 ReturnObj.Pointer = AcpiGbl_DbBuffer; 1057 ReturnObj.Length = ACPI_DEBUG_BUFFER_SIZE; 1058 1059 Status = AcpiGetIrqRoutingTable (ObjDesc, &ReturnObj); 1060 if (ACPI_FAILURE (Status)) 1061 { 1062 AcpiOsPrintf ("GetIrqRoutingTable failed: %s\n", AcpiFormatException (Status)); 1063 } 1064 1065 else 1066 { 1067 AcpiRsDumpIrqList ((UINT8 *) AcpiGbl_DbBuffer); 1068 } 1069 1070 1071 /* _CRS */ 1072 1073GetCrs: 1074 AcpiOsPrintf ("Evaluating _CRS\n"); 1075 1076 ReturnObj.Pointer = AcpiGbl_DbBuffer; 1077 ReturnObj.Length = ACPI_DEBUG_BUFFER_SIZE; 1078 1079 Status = AcpiEvaluateObject (ObjDesc, "_CRS", NULL, &ReturnObj); 1080 if (ACPI_FAILURE (Status)) 1081 { 1082 AcpiOsPrintf ("Could not obtain _CRS: %s\n", AcpiFormatException (Status)); 1083 goto GetPrs; 1084 } 1085 1086 ReturnObj.Pointer = AcpiGbl_DbBuffer; 1087 ReturnObj.Length = ACPI_DEBUG_BUFFER_SIZE; 1088 1089 Status = AcpiGetCurrentResources (ObjDesc, &ReturnObj); 1090 if (ACPI_FAILURE (Status)) 1091 { 1092 AcpiOsPrintf ("AcpiGetCurrentResources failed: %s\n", AcpiFormatException (Status)); 1093 } 1094 1095 else 1096 { 1097 AcpiRsDumpResourceList ((ACPI_RESOURCE *) AcpiGbl_DbBuffer); 1098 } 1099 1100 1101 /* _PRS */ 1102 1103GetPrs: 1104 AcpiOsPrintf ("Evaluating _PRS\n"); 1105 1106 ReturnObj.Pointer = AcpiGbl_DbBuffer; 1107 ReturnObj.Length = ACPI_DEBUG_BUFFER_SIZE; 1108 1109 Status = AcpiEvaluateObject (ObjDesc, "_PRS", NULL, &ReturnObj); 1110 if (ACPI_FAILURE (Status)) 1111 { 1112 AcpiOsPrintf ("Could not obtain _PRS: %s\n", AcpiFormatException (Status)); 1113 goto Cleanup; 1114 } 1115 1116 ReturnObj.Pointer = AcpiGbl_DbBuffer; 1117 ReturnObj.Length = ACPI_DEBUG_BUFFER_SIZE; 1118 1119 Status = AcpiGetPossibleResources (ObjDesc, &ReturnObj); 1120 if (ACPI_FAILURE (Status)) 1121 { 1122 AcpiOsPrintf ("AcpiGetPossibleResources failed: %s\n", AcpiFormatException (Status)); 1123 } 1124 1125 else 1126 { 1127 AcpiRsDumpResourceList ((ACPI_RESOURCE *) AcpiGbl_DbBuffer); 1128 } 1129 1130 1131Cleanup: 1132 1133 AcpiDbSetOutputDestination (DB_CONSOLE_OUTPUT); 1134 return; 1135#endif 1136 1137} 1138 1139 1140#endif /* ENABLE_DEBUGGER */ 1141