dbcmds.c revision 131440
1/******************************************************************************* 2 * 3 * Module Name: dbcmds - debug commands and output routines 4 * $Revision: 113 $ 5 * 6 ******************************************************************************/ 7 8/****************************************************************************** 9 * 10 * 1. Copyright Notice 11 * 12 * Some or all of this work - Copyright (c) 1999 - 2004, 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 "acdispat.h" 120#include "amlcode.h" 121#include "acnamesp.h" 122#include "acevents.h" 123#include "acdebug.h" 124#include "acresrc.h" 125#include "acdisasm.h" 126 127#ifdef ACPI_DEBUGGER 128 129#define _COMPONENT ACPI_CA_DEBUGGER 130 ACPI_MODULE_NAME ("dbcmds") 131 132 133/* 134 * Arguments for the Objects command 135 * These object types map directly to the ACPI_TYPES 136 */ 137 138static ARGUMENT_INFO AcpiDbObjectTypes [] = 139{ 140 {"ANY"}, 141 {"NUMBERS"}, 142 {"STRINGS"}, 143 {"BUFFERS"}, 144 {"PACKAGES"}, 145 {"FIELDS"}, 146 {"DEVICES"}, 147 {"EVENTS"}, 148 {"METHODS"}, 149 {"MUTEXES"}, 150 {"REGIONS"}, 151 {"POWERRESOURCES"}, 152 {"PROCESSORS"}, 153 {"THERMALZONES"}, 154 {"BUFFERFIELDS"}, 155 {"DDBHANDLES"}, 156 {NULL} /* Must be null terminated */ 157}; 158 159 160ACPI_STATUS 161AcpiDbSleep ( 162 char *ObjectArg) 163{ 164#if ACPI_MACHINE_WIDTH == 16 165 return (AE_OK); 166#else 167 ACPI_STATUS Status; 168 UINT8 SleepState; 169 170 171 SleepState = (UINT8) ACPI_STRTOUL (ObjectArg, NULL, 0); 172 173 AcpiOsPrintf ("**** Prepare to sleep ****\n"); 174 Status = AcpiEnterSleepStatePrep (SleepState); 175 if (ACPI_FAILURE (Status)) 176 { 177 return (Status); 178 } 179 180 AcpiOsPrintf ("**** Going to sleep ****\n"); 181 Status = AcpiEnterSleepState (SleepState); 182 if (ACPI_FAILURE (Status)) 183 { 184 return (Status); 185 } 186 187 AcpiOsPrintf ("**** returning from sleep ****\n"); 188 Status = AcpiLeaveSleepState (SleepState); 189 190 return (Status); 191#endif 192} 193 194 195/******************************************************************************* 196 * 197 * FUNCTION: AcpiDbWalkForReferences 198 * 199 * PARAMETERS: Callback from WalkNamespace 200 * 201 * RETURN: Status 202 * 203 * DESCRIPTION: Check if this namespace object refers to the target object 204 * that is passed in as the context value. 205 * 206 * Note: Currently doesn't check subobjects within the Node's object 207 * 208 ******************************************************************************/ 209 210ACPI_STATUS 211AcpiDbWalkForReferences ( 212 ACPI_HANDLE ObjHandle, 213 UINT32 NestingLevel, 214 void *Context, 215 void **ReturnValue) 216{ 217 ACPI_OPERAND_OBJECT *ObjDesc = (ACPI_OPERAND_OBJECT *) Context; 218 ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle; 219 220 221 /* Check for match against the namespace node itself */ 222 223 if (Node == (void *) ObjDesc) 224 { 225 AcpiOsPrintf ("Object is a Node [%4.4s]\n", 226 AcpiUtGetNodeName (Node)); 227 } 228 229 /* Check for match against the object attached to the node */ 230 231 if (AcpiNsGetAttachedObject (Node) == ObjDesc) 232 { 233 AcpiOsPrintf ("Reference at Node->Object %p [%4.4s]\n", 234 Node, AcpiUtGetNodeName (Node)); 235 } 236 237 return (AE_OK); 238} 239 240 241/******************************************************************************* 242 * 243 * FUNCTION: AcpiDbFindReferences 244 * 245 * PARAMETERS: ObjectArg - String with hex value of the object 246 * 247 * RETURN: None 248 * 249 * DESCRIPTION: Search namespace for all references to the input object 250 * 251 ******************************************************************************/ 252 253void 254AcpiDbFindReferences ( 255 char *ObjectArg) 256{ 257 ACPI_OPERAND_OBJECT *ObjDesc; 258 259 260 /* Convert string to object pointer */ 261 262 ObjDesc = ACPI_TO_POINTER (ACPI_STRTOUL (ObjectArg, NULL, 16)); 263 264 /* Search all nodes in namespace */ 265 266 (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX, 267 AcpiDbWalkForReferences, (void *) ObjDesc, NULL); 268} 269 270 271/******************************************************************************* 272 * 273 * FUNCTION: AcpiDbDisplayLocks 274 * 275 * PARAMETERS: None 276 * 277 * RETURN: None 278 * 279 * DESCRIPTION: Display information about internal mutexes. 280 * 281 ******************************************************************************/ 282 283void 284AcpiDbDisplayLocks (void) 285{ 286 UINT32 i; 287 288 289 for (i = 0; i < MAX_MUTEX; i++) 290 { 291 AcpiOsPrintf ("%26s : %s\n", AcpiUtGetMutexName (i), 292 AcpiGbl_MutexInfo[i].OwnerId == ACPI_MUTEX_NOT_ACQUIRED 293 ? "Locked" : "Unlocked"); 294 } 295} 296 297 298/******************************************************************************* 299 * 300 * FUNCTION: AcpiDbDisplayTableInfo 301 * 302 * PARAMETERS: TableArg - String with name of table to be displayed 303 * 304 * RETURN: None 305 * 306 * DESCRIPTION: Display information about loaded tables. Current 307 * implementation displays all loaded tables. 308 * 309 ******************************************************************************/ 310 311void 312AcpiDbDisplayTableInfo ( 313 char *TableArg) 314{ 315 UINT32 i; 316 ACPI_TABLE_DESC *TableDesc; 317 318 319 for (i = 0; i < NUM_ACPI_TABLE_TYPES; i++) 320 { 321 TableDesc = AcpiGbl_TableLists[i].Next; 322 while (TableDesc) 323 { 324 AcpiOsPrintf ( "%s at %p length %.5X", 325 AcpiGbl_TableData[i].Name, TableDesc->Pointer, 326 (UINT32) TableDesc->Length); 327 328 if (i != ACPI_TABLE_FACS) 329 { 330 AcpiOsPrintf (" OemID=%6s TableId=%8s OemRevision=%8.8X", 331 TableDesc->Pointer->OemId, 332 TableDesc->Pointer->OemTableId, 333 TableDesc->Pointer->OemRevision); 334 } 335 AcpiOsPrintf ("\n"); 336 337 TableDesc = TableDesc->Next; 338 } 339 } 340} 341 342 343/******************************************************************************* 344 * 345 * FUNCTION: AcpiDbUnloadAcpiTable 346 * 347 * PARAMETERS: TableArg - Name of the table to be unloaded 348 * InstanceArg - Which instance of the table to unload (if 349 * there are multiple tables of the same type) 350 * 351 * RETURN: Nonde 352 * 353 * DESCRIPTION: Unload an ACPI table. 354 * Instance is not implemented 355 * 356 ******************************************************************************/ 357 358void 359AcpiDbUnloadAcpiTable ( 360 char *TableArg, 361 char *InstanceArg) 362{ 363 UINT32 i; 364 ACPI_STATUS Status; 365 366 367 /* Search all tables for the target type */ 368 369 for (i = 0; i < NUM_ACPI_TABLE_TYPES; i++) 370 { 371 if (!ACPI_STRNCMP (TableArg, AcpiGbl_TableData[i].Signature, 372 AcpiGbl_TableData[i].SigLength)) 373 { 374 /* Found the table, unload it */ 375 376 Status = AcpiUnloadTable (i); 377 if (ACPI_SUCCESS (Status)) 378 { 379 AcpiOsPrintf ("[%s] unloaded and uninstalled\n", TableArg); 380 } 381 else 382 { 383 AcpiOsPrintf ("%s, while unloading [%s]\n", 384 AcpiFormatException (Status), TableArg); 385 } 386 387 return; 388 } 389 } 390 391 AcpiOsPrintf ("Unknown table type [%s]\n", TableArg); 392} 393 394 395/******************************************************************************* 396 * 397 * FUNCTION: AcpiDbSetMethodBreakpoint 398 * 399 * PARAMETERS: Location - AML offset of breakpoint 400 * WalkState - Current walk info 401 * Op - Current Op (from parse walk) 402 * 403 * RETURN: None 404 * 405 * DESCRIPTION: Set a breakpoint in a control method at the specified 406 * AML offset 407 * 408 ******************************************************************************/ 409 410void 411AcpiDbSetMethodBreakpoint ( 412 char *Location, 413 ACPI_WALK_STATE *WalkState, 414 ACPI_PARSE_OBJECT *Op) 415{ 416 UINT32 Address; 417 418 419 if (!Op) 420 { 421 AcpiOsPrintf ("There is no method currently executing\n"); 422 return; 423 } 424 425 /* Get and verify the breakpoint address */ 426 427 Address = ACPI_STRTOUL (Location, NULL, 16); 428 if (Address <= Op->Common.AmlOffset) 429 { 430 AcpiOsPrintf ("Breakpoint %X is beyond current address %X\n", Address, Op->Common.AmlOffset); 431 } 432 433 /* Save breakpoint in current walk */ 434 435 WalkState->UserBreakpoint = Address; 436 AcpiOsPrintf ("Breakpoint set at AML offset %X\n", Address); 437} 438 439 440/******************************************************************************* 441 * 442 * FUNCTION: AcpiDbSetMethodCallBreakpoint 443 * 444 * PARAMETERS: Op - Current Op (from parse walk) 445 * 446 * RETURN: None 447 * 448 * DESCRIPTION: Set a breakpoint in a control method at the specified 449 * AML offset 450 * 451 ******************************************************************************/ 452 453void 454AcpiDbSetMethodCallBreakpoint ( 455 ACPI_PARSE_OBJECT *Op) 456{ 457 458 459 if (!Op) 460 { 461 AcpiOsPrintf ("There is no method currently executing\n"); 462 return; 463 } 464 465 AcpiGbl_StepToNextCall = TRUE; 466} 467 468 469/******************************************************************************* 470 * 471 * FUNCTION: AcpiDbDisassembleAml 472 * 473 * PARAMETERS: Statements - Number of statements to disassemble 474 * Op - Current Op (from parse walk) 475 * 476 * RETURN: None 477 * 478 * DESCRIPTION: Display disassembled AML (ASL) starting from Op for the number 479 * of statements specified. 480 * 481 ******************************************************************************/ 482 483void 484AcpiDbDisassembleAml ( 485 char *Statements, 486 ACPI_PARSE_OBJECT *Op) 487{ 488 UINT32 NumStatements = 8; 489 490 491 if (!Op) 492 { 493 AcpiOsPrintf ("There is no method currently executing\n"); 494 return; 495 } 496 497 if (Statements) 498 { 499 NumStatements = ACPI_STRTOUL (Statements, NULL, 0); 500 } 501 502 AcpiDmDisassemble (NULL, Op, NumStatements); 503} 504 505 506/******************************************************************************* 507 * 508 * FUNCTION: AcpiDbDumpNamespace 509 * 510 * PARAMETERS: StartArg - Node to begin namespace dump 511 * DepthArg - Maximum tree depth to be dumped 512 * 513 * RETURN: None 514 * 515 * DESCRIPTION: Dump entire namespace or a subtree. Each node is displayed 516 * with type and other information. 517 * 518 ******************************************************************************/ 519 520void 521AcpiDbDumpNamespace ( 522 char *StartArg, 523 char *DepthArg) 524{ 525 ACPI_HANDLE SubtreeEntry = AcpiGbl_RootNode; 526 UINT32 MaxDepth = ACPI_UINT32_MAX; 527 528 529 /* No argument given, just start at the root and dump entire namespace */ 530 531 if (StartArg) 532 { 533 /* Check if numeric argument, must be a Node */ 534 535 if ((StartArg[0] >= 0x30) && (StartArg[0] <= 0x39)) 536 { 537 SubtreeEntry = ACPI_TO_POINTER (ACPI_STRTOUL (StartArg, NULL, 16)); 538 if (!AcpiOsReadable (SubtreeEntry, sizeof (ACPI_NAMESPACE_NODE))) 539 { 540 AcpiOsPrintf ("Address %p is invalid in this address space\n", SubtreeEntry); 541 return; 542 } 543 544 if (ACPI_GET_DESCRIPTOR_TYPE (SubtreeEntry) != ACPI_DESC_TYPE_NAMED) 545 { 546 AcpiOsPrintf ("Address %p is not a valid NS node [%s]\n", 547 SubtreeEntry, AcpiUtGetDescriptorName (SubtreeEntry)); 548 return; 549 } 550 } 551 else 552 { 553 /* Alpha argument */ 554 /* The parameter is a name string that must be resolved to a Named obj*/ 555 556 SubtreeEntry = AcpiDbLocalNsLookup (StartArg); 557 if (!SubtreeEntry) 558 { 559 SubtreeEntry = AcpiGbl_RootNode; 560 } 561 } 562 563 /* Now we can check for the depth argument */ 564 565 if (DepthArg) 566 { 567 MaxDepth = ACPI_STRTOUL (DepthArg, NULL, 0); 568 } 569 } 570 571 AcpiDbSetOutputDestination (ACPI_DB_DUPLICATE_OUTPUT); 572 AcpiOsPrintf ("ACPI Namespace (from %p subtree):\n", SubtreeEntry); 573 574 /* Display the subtree */ 575 576 AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT); 577 AcpiNsDumpObjects (ACPI_TYPE_ANY, ACPI_DISPLAY_SUMMARY, MaxDepth, ACPI_UINT32_MAX, SubtreeEntry); 578 AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT); 579} 580 581 582/******************************************************************************* 583 * 584 * FUNCTION: AcpiDbDumpNamespaceByOwner 585 * 586 * PARAMETERS: OwnerArg - Owner ID whose nodes will be displayed 587 * DepthArg - Maximum tree depth to be dumped 588 * 589 * RETURN: None 590 * 591 * DESCRIPTION: Dump elements of the namespace that are owned by the OwnerId. 592 * 593 ******************************************************************************/ 594 595void 596AcpiDbDumpNamespaceByOwner ( 597 char *OwnerArg, 598 char *DepthArg) 599{ 600 ACPI_HANDLE SubtreeEntry = AcpiGbl_RootNode; 601 UINT32 MaxDepth = ACPI_UINT32_MAX; 602 UINT16 OwnerId; 603 604 605 OwnerId = (UINT16) ACPI_STRTOUL (OwnerArg, NULL, 0); 606 607 /* Now we can check for the depth argument */ 608 609 if (DepthArg) 610 { 611 MaxDepth = ACPI_STRTOUL (DepthArg, NULL, 0); 612 } 613 614 AcpiDbSetOutputDestination (ACPI_DB_DUPLICATE_OUTPUT); 615 AcpiOsPrintf ("ACPI Namespace by owner %X:\n", OwnerId); 616 617 /* Display the subtree */ 618 619 AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT); 620 AcpiNsDumpObjects (ACPI_TYPE_ANY, ACPI_DISPLAY_SUMMARY, MaxDepth, OwnerId, SubtreeEntry); 621 AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT); 622} 623 624 625/******************************************************************************* 626 * 627 * FUNCTION: AcpiDbSendNotify 628 * 629 * PARAMETERS: Name - Name of ACPI object to send the notify to 630 * Value - Value of the notify to send. 631 * 632 * RETURN: None 633 * 634 * DESCRIPTION: Send an ACPI notification. The value specified is sent to the 635 * named object as an ACPI notify. 636 * 637 ******************************************************************************/ 638 639void 640AcpiDbSendNotify ( 641 char *Name, 642 UINT32 Value) 643{ 644 ACPI_NAMESPACE_NODE *Node; 645 ACPI_STATUS Status; 646 647 648 /* Translate name to an Named object */ 649 650 Node = AcpiDbLocalNsLookup (Name); 651 if (!Node) 652 { 653 return; 654 } 655 656 /* Decode Named object type */ 657 658 switch (Node->Type) 659 { 660 case ACPI_TYPE_DEVICE: 661 case ACPI_TYPE_THERMAL: 662 663 /* Send the notify */ 664 665 Status = AcpiEvQueueNotifyRequest (Node, Value); 666 if (ACPI_FAILURE (Status)) 667 { 668 AcpiOsPrintf ("Could not queue notify\n"); 669 } 670 break; 671 672 default: 673 AcpiOsPrintf ("Named object is not a device or a thermal object\n"); 674 break; 675 } 676} 677 678 679/******************************************************************************* 680 * 681 * FUNCTION: AcpiDbSetMethodData 682 * 683 * PARAMETERS: TypeArg - L for local, A for argument 684 * IndexArg - which one 685 * ValueArg - Value to set. 686 * 687 * RETURN: None 688 * 689 * DESCRIPTION: Set a local or argument for the running control method. 690 * NOTE: only object supported is Number. 691 * 692 ******************************************************************************/ 693 694void 695AcpiDbSetMethodData ( 696 char *TypeArg, 697 char *IndexArg, 698 char *ValueArg) 699{ 700 char Type; 701 UINT32 Index; 702 UINT32 Value; 703 ACPI_WALK_STATE *WalkState; 704 ACPI_OPERAND_OBJECT *ObjDesc; 705 ACPI_STATUS Status; 706 707 708 /* Validate TypeArg */ 709 710 ACPI_STRUPR (TypeArg); 711 Type = TypeArg[0]; 712 if ((Type != 'L') && 713 (Type != 'A')) 714 { 715 AcpiOsPrintf ("Invalid SET operand: %s\n", TypeArg); 716 return; 717 } 718 719 /* Get the index and value */ 720 721 Index = ACPI_STRTOUL (IndexArg, NULL, 16); 722 Value = ACPI_STRTOUL (ValueArg, NULL, 16); 723 724 WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList); 725 if (!WalkState) 726 { 727 AcpiOsPrintf ("There is no method currently executing\n"); 728 return; 729 } 730 731 /* Create and initialize the new object */ 732 733 ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER); 734 if (!ObjDesc) 735 { 736 AcpiOsPrintf ("Could not create an internal object\n"); 737 return; 738 } 739 740 ObjDesc->Integer.Value = Value; 741 742 /* Store the new object into the target */ 743 744 switch (Type) 745 { 746 case 'A': 747 748 /* Set a method argument */ 749 750 if (Index > ACPI_METHOD_MAX_ARG) 751 { 752 AcpiOsPrintf ("Arg%d - Invalid argument name\n", Index); 753 return; 754 } 755 756 Status = AcpiDsStoreObjectToLocal (AML_ARG_OP, Index, ObjDesc, WalkState); 757 if (ACPI_FAILURE (Status)) 758 { 759 return; 760 } 761 762 ObjDesc = WalkState->Arguments[Index].Object; 763 764 AcpiOsPrintf ("Arg%d: ", Index); 765 AcpiDmDisplayInternalObject (ObjDesc, WalkState); 766 break; 767 768 case 'L': 769 770 /* Set a method local */ 771 772 if (Index > ACPI_METHOD_MAX_LOCAL) 773 { 774 AcpiOsPrintf ("Local%d - Invalid local variable name\n", Index); 775 return; 776 } 777 778 Status = AcpiDsStoreObjectToLocal (AML_LOCAL_OP, Index, ObjDesc, WalkState); 779 if (ACPI_FAILURE (Status)) 780 { 781 return; 782 } 783 784 ObjDesc = WalkState->LocalVariables[Index].Object; 785 786 AcpiOsPrintf ("Local%d: ", Index); 787 AcpiDmDisplayInternalObject (ObjDesc, WalkState); 788 break; 789 790 default: 791 break; 792 } 793} 794 795 796/******************************************************************************* 797 * 798 * FUNCTION: AcpiDbWalkForSpecificObjects 799 * 800 * PARAMETERS: Callback from WalkNamespace 801 * 802 * RETURN: Status 803 * 804 * DESCRIPTION: Display short info about objects in the namespace 805 * 806 ******************************************************************************/ 807 808ACPI_STATUS 809AcpiDbWalkForSpecificObjects ( 810 ACPI_HANDLE ObjHandle, 811 UINT32 NestingLevel, 812 void *Context, 813 void **ReturnValue) 814{ 815 ACPI_OPERAND_OBJECT *ObjDesc; 816 ACPI_STATUS Status; 817 ACPI_BUFFER Buffer; 818 819 820 ObjDesc = AcpiNsGetAttachedObject ((ACPI_NAMESPACE_NODE *) ObjHandle); 821 822 /* Get and display the full pathname to this object */ 823 824 Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER; 825 Status = AcpiNsHandleToPathname (ObjHandle, &Buffer); 826 if (ACPI_FAILURE (Status)) 827 { 828 AcpiOsPrintf ("Could Not get pathname for object %p\n", ObjHandle); 829 return (AE_OK); 830 } 831 832 AcpiOsPrintf ("%32s", (char *) Buffer.Pointer); 833 ACPI_MEM_FREE (Buffer.Pointer); 834 835 /* Display short information about the object */ 836 837 if (ObjDesc) 838 { 839 switch (ACPI_GET_OBJECT_TYPE (ObjDesc)) 840 { 841 case ACPI_TYPE_METHOD: 842 AcpiOsPrintf (" #Args %d Concurrency %X", 843 ObjDesc->Method.ParamCount, ObjDesc->Method.Concurrency); 844 break; 845 846 case ACPI_TYPE_INTEGER: 847 AcpiOsPrintf (" Value %8.8X%8.8X", 848 ACPI_FORMAT_UINT64 (ObjDesc->Integer.Value)); 849 break; 850 851 case ACPI_TYPE_STRING: 852 AcpiOsPrintf (" \"%s\"", ObjDesc->String.Pointer); 853 break; 854 855 case ACPI_TYPE_REGION: 856 AcpiOsPrintf (" SpaceId %X Length %X Address %8.8X%8.8X", 857 ObjDesc->Region.SpaceId, 858 ObjDesc->Region.Length, 859 ACPI_FORMAT_UINT64 (ObjDesc->Region.Address)); 860 break; 861 862 case ACPI_TYPE_PACKAGE: 863 AcpiOsPrintf (" #Elements %X", ObjDesc->Package.Count); 864 break; 865 866 case ACPI_TYPE_BUFFER: 867 AcpiOsPrintf (" Length %X", ObjDesc->Buffer.Length); 868 break; 869 870 default: 871 /* Ignore other object types */ 872 break; 873 } 874 } 875 876 AcpiOsPrintf ("\n"); 877 return (AE_OK); 878} 879 880 881/******************************************************************************* 882 * 883 * FUNCTION: AcpiDbDisplayObjects 884 * 885 * PARAMETERS: ObjTypeArg - Type of object to display 886 * DisplayCountArg - Max depth to display 887 * 888 * RETURN: None 889 * 890 * DESCRIPTION: Display objects in the namespace of the requested type 891 * 892 ******************************************************************************/ 893 894ACPI_STATUS 895AcpiDbDisplayObjects ( 896 char *ObjTypeArg, 897 char *DisplayCountArg) 898{ 899 ACPI_OBJECT_TYPE Type; 900 901 902 /* Get the object type */ 903 904 Type = AcpiDbMatchArgument (ObjTypeArg, AcpiDbObjectTypes); 905 if (Type == ACPI_TYPE_NOT_FOUND) 906 { 907 AcpiOsPrintf ("Invalid or unsupported argument\n"); 908 return (AE_OK); 909 } 910 911 AcpiDbSetOutputDestination (ACPI_DB_DUPLICATE_OUTPUT); 912 AcpiOsPrintf ("Objects of type [%s] defined in the current ACPI Namespace: \n", 913 AcpiUtGetTypeName (Type)); 914 915 AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT); 916 917 /* Walk the namespace from the root */ 918 919 (void) AcpiWalkNamespace (Type, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX, 920 AcpiDbWalkForSpecificObjects, (void *) &Type, NULL); 921 922 AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT); 923 return (AE_OK); 924} 925 926 927/******************************************************************************* 928 * 929 * FUNCTION: AcpiDbWalkAndMatchName 930 * 931 * PARAMETERS: Callback from WalkNamespace 932 * 933 * RETURN: Status 934 * 935 * DESCRIPTION: Find a particular name/names within the namespace. Wildcards 936 * are supported -- '?' matches any character. 937 * 938 ******************************************************************************/ 939 940ACPI_STATUS 941AcpiDbWalkAndMatchName ( 942 ACPI_HANDLE ObjHandle, 943 UINT32 NestingLevel, 944 void *Context, 945 void **ReturnValue) 946{ 947 ACPI_STATUS Status; 948 char *RequestedName = (char *) Context; 949 UINT32 i; 950 ACPI_BUFFER Buffer; 951 952 953 /* Check for a name match */ 954 955 for (i = 0; i < 4; i++) 956 { 957 /* Wildcard support */ 958 959 if ((RequestedName[i] != '?') && 960 (RequestedName[i] != ((ACPI_NAMESPACE_NODE *) ObjHandle)->Name.Ascii[i])) 961 { 962 /* No match, just exit */ 963 964 return (AE_OK); 965 } 966 } 967 968 /* Get the full pathname to this object */ 969 970 Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER; 971 Status = AcpiNsHandleToPathname (ObjHandle, &Buffer); 972 if (ACPI_FAILURE (Status)) 973 { 974 AcpiOsPrintf ("Could Not get pathname for object %p\n", ObjHandle); 975 } 976 else 977 { 978 AcpiOsPrintf ("%32s (%p) - %s\n", (char *) Buffer.Pointer, ObjHandle, 979 AcpiUtGetTypeName (((ACPI_NAMESPACE_NODE *) ObjHandle)->Type)); 980 ACPI_MEM_FREE (Buffer.Pointer); 981 } 982 983 return (AE_OK); 984} 985 986 987/******************************************************************************* 988 * 989 * FUNCTION: AcpiDbFindNameInNamespace 990 * 991 * PARAMETERS: NameArg - The 4-character ACPI name to find. 992 * wildcards are supported. 993 * 994 * RETURN: None 995 * 996 * DESCRIPTION: Search the namespace for a given name (with wildcards) 997 * 998 ******************************************************************************/ 999 1000ACPI_STATUS 1001AcpiDbFindNameInNamespace ( 1002 char *NameArg) 1003{ 1004 1005 if (ACPI_STRLEN (NameArg) > 4) 1006 { 1007 AcpiOsPrintf ("Name must be no longer than 4 characters\n"); 1008 return (AE_OK); 1009 } 1010 1011 /* Walk the namespace from the root */ 1012 1013 (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX, 1014 AcpiDbWalkAndMatchName, NameArg, NULL); 1015 1016 AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT); 1017 return (AE_OK); 1018} 1019 1020 1021/******************************************************************************* 1022 * 1023 * FUNCTION: AcpiDbSetScope 1024 * 1025 * PARAMETERS: Name - New scope path 1026 * 1027 * RETURN: Status 1028 * 1029 * DESCRIPTION: Set the "current scope" as maintained by this utility. 1030 * The scope is used as a prefix to ACPI paths. 1031 * 1032 ******************************************************************************/ 1033 1034void 1035AcpiDbSetScope ( 1036 char *Name) 1037{ 1038 ACPI_STATUS Status; 1039 ACPI_NAMESPACE_NODE *Node; 1040 1041 1042 if (!Name || Name[0] == 0) 1043 { 1044 AcpiOsPrintf ("Current scope: %s\n", AcpiGbl_DbScopeBuf); 1045 return; 1046 } 1047 1048 AcpiDbPrepNamestring (Name); 1049 1050 if (Name[0] == '\\') 1051 { 1052 /* Validate new scope from the root */ 1053 1054 Status = AcpiNsGetNodeByPath (Name, AcpiGbl_RootNode, ACPI_NS_NO_UPSEARCH, &Node); 1055 if (ACPI_FAILURE (Status)) 1056 { 1057 goto ErrorExit; 1058 } 1059 1060 ACPI_STRCPY (AcpiGbl_DbScopeBuf, Name); 1061 ACPI_STRCAT (AcpiGbl_DbScopeBuf, "\\"); 1062 } 1063 else 1064 { 1065 /* Validate new scope relative to old scope */ 1066 1067 Status = AcpiNsGetNodeByPath (Name, AcpiGbl_DbScopeNode, ACPI_NS_NO_UPSEARCH, &Node); 1068 if (ACPI_FAILURE (Status)) 1069 { 1070 goto ErrorExit; 1071 } 1072 1073 ACPI_STRCAT (AcpiGbl_DbScopeBuf, Name); 1074 ACPI_STRCAT (AcpiGbl_DbScopeBuf, "\\"); 1075 } 1076 1077 AcpiGbl_DbScopeNode = Node; 1078 AcpiOsPrintf ("New scope: %s\n", AcpiGbl_DbScopeBuf); 1079 return; 1080 1081ErrorExit: 1082 1083 AcpiOsPrintf ("Could not attach scope: %s, %s\n", Name, AcpiFormatException (Status)); 1084} 1085 1086 1087/******************************************************************************* 1088 * 1089 * FUNCTION: AcpiDbDisplayResources 1090 * 1091 * PARAMETERS: ObjectArg - String with hex value of the object 1092 * 1093 * RETURN: None 1094 * 1095 * DESCRIPTION: Display the resource objects associated with a device. 1096 * 1097 ******************************************************************************/ 1098 1099void 1100AcpiDbDisplayResources ( 1101 char *ObjectArg) 1102{ 1103#if ACPI_MACHINE_WIDTH != 16 1104 1105 ACPI_OPERAND_OBJECT *ObjDesc; 1106 ACPI_STATUS Status; 1107 ACPI_BUFFER ReturnObj; 1108 1109 1110 AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT); 1111 AcpiDbgLevel |= ACPI_LV_RESOURCES; 1112 1113 /* Convert string to object pointer */ 1114 1115 ObjDesc = ACPI_TO_POINTER (ACPI_STRTOUL (ObjectArg, NULL, 16)); 1116 1117 /* Prepare for a return object of arbitrary size */ 1118 1119 ReturnObj.Pointer = AcpiGbl_DbBuffer; 1120 ReturnObj.Length = ACPI_DEBUG_BUFFER_SIZE; 1121 1122 /* _PRT */ 1123 1124 AcpiOsPrintf ("Evaluating _PRT\n"); 1125 1126 Status = AcpiEvaluateObject (ObjDesc, "_PRT", NULL, &ReturnObj); 1127 if (ACPI_FAILURE (Status)) 1128 { 1129 AcpiOsPrintf ("Could not obtain _PRT: %s\n", AcpiFormatException (Status)); 1130 goto GetCrs; 1131 } 1132 1133 ReturnObj.Pointer = AcpiGbl_DbBuffer; 1134 ReturnObj.Length = ACPI_DEBUG_BUFFER_SIZE; 1135 1136 Status = AcpiGetIrqRoutingTable (ObjDesc, &ReturnObj); 1137 if (ACPI_FAILURE (Status)) 1138 { 1139 AcpiOsPrintf ("GetIrqRoutingTable failed: %s\n", AcpiFormatException (Status)); 1140 } 1141 else 1142 { 1143 AcpiRsDumpIrqList ((UINT8 *) AcpiGbl_DbBuffer); 1144 } 1145 1146 1147 /* _CRS */ 1148 1149GetCrs: 1150 AcpiOsPrintf ("Evaluating _CRS\n"); 1151 1152 ReturnObj.Pointer = AcpiGbl_DbBuffer; 1153 ReturnObj.Length = ACPI_DEBUG_BUFFER_SIZE; 1154 1155 Status = AcpiEvaluateObject (ObjDesc, "_CRS", NULL, &ReturnObj); 1156 if (ACPI_FAILURE (Status)) 1157 { 1158 AcpiOsPrintf ("Could not obtain _CRS: %s\n", AcpiFormatException (Status)); 1159 goto GetPrs; 1160 } 1161 1162 ReturnObj.Pointer = AcpiGbl_DbBuffer; 1163 ReturnObj.Length = ACPI_DEBUG_BUFFER_SIZE; 1164 1165 Status = AcpiGetCurrentResources (ObjDesc, &ReturnObj); 1166 if (ACPI_FAILURE (Status)) 1167 { 1168 AcpiOsPrintf ("AcpiGetCurrentResources failed: %s\n", AcpiFormatException (Status)); 1169 goto GetPrs; 1170 } 1171 else 1172 { 1173 AcpiRsDumpResourceList (ACPI_CAST_PTR (ACPI_RESOURCE, AcpiGbl_DbBuffer)); 1174 } 1175 1176 Status = AcpiSetCurrentResources (ObjDesc, &ReturnObj); 1177 if (ACPI_FAILURE (Status)) 1178 { 1179 AcpiOsPrintf ("AcpiSetCurrentResources failed: %s\n", AcpiFormatException (Status)); 1180 goto GetPrs; 1181 } 1182 1183 1184 /* _PRS */ 1185 1186GetPrs: 1187 AcpiOsPrintf ("Evaluating _PRS\n"); 1188 1189 ReturnObj.Pointer = AcpiGbl_DbBuffer; 1190 ReturnObj.Length = ACPI_DEBUG_BUFFER_SIZE; 1191 1192 Status = AcpiEvaluateObject (ObjDesc, "_PRS", NULL, &ReturnObj); 1193 if (ACPI_FAILURE (Status)) 1194 { 1195 AcpiOsPrintf ("Could not obtain _PRS: %s\n", AcpiFormatException (Status)); 1196 goto Cleanup; 1197 } 1198 1199 ReturnObj.Pointer = AcpiGbl_DbBuffer; 1200 ReturnObj.Length = ACPI_DEBUG_BUFFER_SIZE; 1201 1202 Status = AcpiGetPossibleResources (ObjDesc, &ReturnObj); 1203 if (ACPI_FAILURE (Status)) 1204 { 1205 AcpiOsPrintf ("AcpiGetPossibleResources failed: %s\n", AcpiFormatException (Status)); 1206 } 1207 else 1208 { 1209 AcpiRsDumpResourceList (ACPI_CAST_PTR (ACPI_RESOURCE, AcpiGbl_DbBuffer)); 1210 } 1211 1212Cleanup: 1213 1214 AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT); 1215 return; 1216#endif 1217} 1218 1219 1220/******************************************************************************* 1221 * 1222 * FUNCTION: AcpiDbIntegrityWalk 1223 * 1224 * PARAMETERS: Callback from WalkNamespace 1225 * 1226 * RETURN: Status 1227 * 1228 * DESCRIPTION: Examine one NS node for valid values. 1229 * 1230 ******************************************************************************/ 1231 1232ACPI_STATUS 1233AcpiDbIntegrityWalk ( 1234 ACPI_HANDLE ObjHandle, 1235 UINT32 NestingLevel, 1236 void *Context, 1237 void **ReturnValue) 1238{ 1239 ACPI_INTEGRITY_INFO *Info = (ACPI_INTEGRITY_INFO *) Context; 1240 ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle; 1241 ACPI_OPERAND_OBJECT *Object; 1242 1243 1244 Info->Nodes++; 1245 if (ACPI_GET_DESCRIPTOR_TYPE (Node) != ACPI_DESC_TYPE_NAMED) 1246 { 1247 AcpiOsPrintf ("Invalid Descriptor Type for Node %p [%s]\n", 1248 Node, AcpiUtGetDescriptorName (Node)); 1249 } 1250 1251 if (Node->Type > ACPI_TYPE_LOCAL_MAX) 1252 { 1253 AcpiOsPrintf ("Invalid Object Type for Node %p, Type = %X\n", 1254 Node, Node->Type); 1255 } 1256 1257 if (!AcpiUtValidAcpiName (Node->Name.Integer)) 1258 { 1259 AcpiOsPrintf ("Invalid AcpiName for Node %p\n", Node); 1260 } 1261 1262 Object = AcpiNsGetAttachedObject (Node); 1263 if (Object) 1264 { 1265 Info->Objects++; 1266 if (ACPI_GET_DESCRIPTOR_TYPE (Object) != ACPI_DESC_TYPE_OPERAND) 1267 { 1268 AcpiOsPrintf ("Invalid Descriptor Type for Object %p [%s]\n", 1269 Object, AcpiUtGetDescriptorName (Object)); 1270 } 1271 } 1272 1273 return (AE_OK); 1274} 1275 1276 1277/******************************************************************************* 1278 * 1279 * FUNCTION: AcpiDbCheckIntegrity 1280 * 1281 * PARAMETERS: None 1282 * 1283 * RETURN: None 1284 * 1285 * DESCRIPTION: Check entire namespace for data structure integrity 1286 * 1287 ******************************************************************************/ 1288 1289void 1290AcpiDbCheckIntegrity (void) 1291{ 1292 ACPI_INTEGRITY_INFO Info = {0,0}; 1293 1294 /* Search all nodes in namespace */ 1295 1296 (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX, 1297 AcpiDbIntegrityWalk, (void *) &Info, NULL); 1298 1299 AcpiOsPrintf ("Verified %d namespace nodes with %d Objects\n", Info.Nodes, Info.Objects); 1300} 1301 1302 1303/******************************************************************************* 1304 * 1305 * FUNCTION: AcpiDbGenerateGpe 1306 * 1307 * PARAMETERS: None 1308 * 1309 * RETURN: None 1310 * 1311 * DESCRIPTION: Generate a GPE 1312 * 1313 ******************************************************************************/ 1314 1315void 1316AcpiDbGenerateGpe ( 1317 char *GpeArg, 1318 char *BlockArg) 1319{ 1320 UINT32 BlockNumber; 1321 UINT32 GpeNumber; 1322 ACPI_GPE_EVENT_INFO *GpeEventInfo; 1323 1324 1325 GpeNumber = ACPI_STRTOUL (GpeArg, NULL, 0); 1326 BlockNumber = ACPI_STRTOUL (BlockArg, NULL, 0); 1327 1328 1329 GpeEventInfo = AcpiEvGetGpeEventInfo (ACPI_TO_POINTER (BlockNumber), GpeNumber); 1330 if (!GpeEventInfo) 1331 { 1332 AcpiOsPrintf ("Invalid GPE\n"); 1333 return; 1334 } 1335 1336 (void) AcpiEvGpeDispatch (GpeEventInfo, GpeNumber); 1337} 1338 1339#endif /* ACPI_DEBUGGER */ 1340