dbcmds.c revision 67754
1121642Smarcel/******************************************************************************* 2121642Smarcel * 3121642Smarcel * Module Name: dbcmds - debug commands and output routines 4121642Smarcel * $Revision: 41 $ 5121642Smarcel * 6121642Smarcel ******************************************************************************/ 7121642Smarcel 8121642Smarcel/****************************************************************************** 9121642Smarcel * 10121642Smarcel * 1. Copyright Notice 11121642Smarcel * 12121642Smarcel * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights 13121642Smarcel * reserved. 14121642Smarcel * 15121642Smarcel * 2. License 16121642Smarcel * 17121642Smarcel * 2.1. This is your license from Intel Corp. under its intellectual property 18121642Smarcel * rights. You may have additional license terms from the party that provided 19121642Smarcel * you this software, covering your right to use that party's intellectual 20121642Smarcel * property rights. 21121642Smarcel * 22121642Smarcel * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a 23121642Smarcel * copy of the source code appearing in this file ("Covered Code") an 24121642Smarcel * irrevocable, perpetual, worldwide license under Intel's copyrights in the 25121642Smarcel * base code distributed originally by Intel ("Original Intel Code") to copy, 26121642Smarcel * make derivatives, distribute, use and display any portion of the Covered 27121642Smarcel * Code in any form, with the right to sublicense such rights; and 28121642Smarcel * 29121642Smarcel * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent 30121642Smarcel * license (with the right to sublicense), under only those claims of Intel 31121642Smarcel * patents that are infringed by the Original Intel Code, to make, use, sell, 32121642Smarcel * offer to sell, and import the Covered Code and derivative works thereof 33121642Smarcel * solely to the minimum extent necessary to exercise the above copyright 34121642Smarcel * license, and in no event shall the patent license extend to any additions 35121642Smarcel * to or modifications of the Original Intel Code. No other license or right 36121642Smarcel * is granted directly or by implication, estoppel or otherwise; 37121642Smarcel * 38121642Smarcel * The above copyright and patent license is granted only if the following 39121642Smarcel * conditions are met: 40121642Smarcel * 41121642Smarcel * 3. Conditions 42121642Smarcel * 43121642Smarcel * 3.1. Redistribution of Source with Rights to Further Distribute Source. 44121642Smarcel * Redistribution of source code of any substantial portion of the Covered 45121642Smarcel * Code or modification with rights to further distribute source must include 46121642Smarcel * the above Copyright Notice, the above License, this list of Conditions, 47121642Smarcel * and the following Disclaimer and Export Compliance provision. In addition, 48121642Smarcel * Licensee must cause all Covered Code to which Licensee contributes to 49121642Smarcel * contain a file documenting the changes Licensee made to create that Covered 50121642Smarcel * Code and the date of any change. Licensee must include in that file the 51121642Smarcel * documentation of any changes made by any predecessor Licensee. Licensee 52121642Smarcel * must include a prominent statement that the modification is derived, 53121642Smarcel * directly or indirectly, from Original Intel Code. 54121642Smarcel * 55121642Smarcel * 3.2. Redistribution of Source with no Rights to Further Distribute Source. 56121642Smarcel * Redistribution of source code of any substantial portion of the Covered 57121642Smarcel * Code or modification without rights to further distribute source must 58121642Smarcel * include the following Disclaimer and Export Compliance provision in the 59121642Smarcel * documentation and/or other materials provided with distribution. In 60121642Smarcel * addition, Licensee may not authorize further sublicense of source of any 61121642Smarcel * portion of the Covered Code, and must include terms to the effect that the 62121642Smarcel * license from Licensee to its licensee is limited to the intellectual 63121642Smarcel * property embodied in the software Licensee provides to its licensee, and 64121642Smarcel * not to intellectual property embodied in modifications its licensee may 65121642Smarcel * make. 66121642Smarcel * 67121642Smarcel * 3.3. Redistribution of Executable. Redistribution in executable form of any 68121642Smarcel * substantial portion of the Covered Code or modification must reproduce the 69121642Smarcel * above Copyright Notice, and the following Disclaimer and Export Compliance 70121642Smarcel * provision in the documentation and/or other materials provided with the 71121642Smarcel * distribution. 72121642Smarcel * 73121642Smarcel * 3.4. Intel retains all right, title, and interest in and to the Original 74121642Smarcel * Intel Code. 75121642Smarcel * 76121642Smarcel * 3.5. Neither the name Intel nor any other trademark owned or controlled by 77121642Smarcel * Intel shall be used in advertising or otherwise to promote the sale, use or 78121642Smarcel * other dealings in products derived from or relating to the Covered Code 79121642Smarcel * without prior written authorization from Intel. 80121642Smarcel * 81121642Smarcel * 4. Disclaimer and Export Compliance 82121642Smarcel * 83121642Smarcel * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED 84121642Smarcel * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE 85121642Smarcel * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, 86121642Smarcel * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY 87121642Smarcel * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY 88121642Smarcel * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A 89121642Smarcel * PARTICULAR PURPOSE. 90121642Smarcel * 91121642Smarcel * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES 92121642Smarcel * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR 93121642Smarcel * 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 129#ifdef ENABLE_DEBUGGER 130 131#define _COMPONENT DEBUGGER 132 MODULE_NAME ("dbcmds") 133 134 135/* 136 * Arguments for the Objects command 137 * These object types map directly to the ACPI_TYPES 138 */ 139 140ARGUMENT_INFO AcpiDbObjectTypes [] = 141{ 142 {"ANY"}, 143 {"NUMBERS"}, 144 {"STRINGS"}, 145 {"BUFFERS"}, 146 {"PACKAGES"}, 147 {"FIELDS"}, 148 {"DEVICES"}, 149 {"EVENTS"}, 150 {"METHODS"}, 151 {"MUTEXES"}, 152 {"REGIONS"}, 153 {"POWERRESOURCES"}, 154 {"PROCESSORS"}, 155 {"THERMALZONES"}, 156 {"BUFFERFIELDS"}, 157 {"DDBHANDLES"}, 158 {NULL} /* Must be null terminated */ 159}; 160 161 162/******************************************************************************* 163 * 164 * FUNCTION: AcpiDbWalkForReferences 165 * 166 * PARAMETERS: Callback from WalkNamespace 167 * 168 * RETURN: Status 169 * 170 * DESCRIPTION: Check if this namespace object refers to the target object 171 * that is passed in as the context value. 172 * 173 ******************************************************************************/ 174 175ACPI_STATUS 176AcpiDbWalkForReferences ( 177 ACPI_HANDLE ObjHandle, 178 UINT32 NestingLevel, 179 void *Context, 180 void **ReturnValue) 181{ 182 ACPI_OPERAND_OBJECT *ObjDesc = (ACPI_OPERAND_OBJECT *) Context; 183 ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle; 184 185 186 /* Check for match against the namespace node itself */ 187 188 if (Node == (void *) ObjDesc) 189 { 190 AcpiOsPrintf ("Object is a Node [%4.4s]\n", &Node->Name); 191 } 192 193 /* Check for match against the object attached to the node */ 194 195 if (Node->Object == ObjDesc) 196 { 197 AcpiOsPrintf ("Reference at Node->Object %p [%4.4s]\n", Node, &Node->Name); 198 } 199 200 /* Check first child for a match */ 201 /* TBD: [Investigate] probably now obsolete with new datastructure */ 202 203 if (Node->Child == (void *) ObjDesc) 204 { 205 AcpiOsPrintf ("Reference at Node->Child %p [%4.4s]\n", Node, &Node->Name); 206 } 207 208 return (AE_OK); 209} 210 211 212/******************************************************************************* 213 * 214 * FUNCTION: AcpiDbFindReferences 215 * 216 * PARAMETERS: ObjectArg - String with hex value of the object 217 * 218 * RETURN: None 219 * 220 * DESCRIPTION: Search namespace for all references to the input object 221 * 222 ******************************************************************************/ 223 224void 225AcpiDbFindReferences ( 226 NATIVE_CHAR *ObjectArg) 227{ 228 ACPI_OPERAND_OBJECT *ObjDesc; 229 230 231 /* Convert string to object pointer */ 232 233 ObjDesc = (ACPI_OPERAND_OBJECT *) STRTOUL (ObjectArg, NULL, 16); 234 235 /* Search all nodes in namespace */ 236 237 AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX, 238 AcpiDbWalkForReferences, (void *) ObjDesc, NULL); 239} 240 241 242/******************************************************************************* 243 * 244 * FUNCTION: AcpiDbDisplayTableInfo 245 * 246 * PARAMETERS: TableArg - String with name of table to be displayed 247 * 248 * RETURN: None 249 * 250 * DESCRIPTION: Display information about loaded tables. Current 251 * implementation displays all loaded tables. 252 * 253 ******************************************************************************/ 254 255void 256AcpiDbDisplayTableInfo ( 257 NATIVE_CHAR *TableArg) 258{ 259 UINT32 i; 260 261 262 for (i = 0; i < NUM_ACPI_TABLES; i++) 263 { 264 if (AcpiGbl_AcpiTables[i].Pointer) 265 { 266 AcpiOsPrintf ("%s at 0x%p length 0x%X\n", AcpiGbl_AcpiTableData[i].Name, 267 AcpiGbl_AcpiTables[i].Pointer, AcpiGbl_AcpiTables[i].Length); 268 } 269 } 270} 271 272 273/******************************************************************************* 274 * 275 * FUNCTION: AcpiDbUnloadAcpiTable 276 * 277 * PARAMETERS: TableArg - Name of the table to be unloaded 278 * InstanceArg - Which instance of the table to unload (if 279 * there are multiple tables of the same type) 280 * 281 * RETURN: Nonde 282 * 283 * DESCRIPTION: Unload an ACPI table. 284 * Instance is not implemented 285 * 286 ******************************************************************************/ 287 288void 289AcpiDbUnloadAcpiTable ( 290 NATIVE_CHAR *TableArg, 291 NATIVE_CHAR *InstanceArg) 292{ 293 UINT32 i; 294 ACPI_STATUS Status; 295 296 297 /* Search all tables for the target type */ 298 299 for (i = 0; i < NUM_ACPI_TABLES; i++) 300 { 301 if (!STRNCMP (TableArg, AcpiGbl_AcpiTableData[i].Signature, AcpiGbl_AcpiTableData[i].SigLength)) 302 { 303 /* Found the table, unload it */ 304 305 Status = AcpiUnloadTable (i); 306 if (ACPI_SUCCESS (Status)) 307 { 308 AcpiOsPrintf ("[%s] unloaded and uninstalled\n", TableArg); 309 } 310 else 311 { 312 AcpiOsPrintf ("%s, while unloading [%s]\n", AcpiCmFormatException (Status), TableArg); 313 } 314 315 return; 316 } 317 } 318 319 AcpiOsPrintf ("Unknown table type [%s]\n", TableArg); 320} 321 322 323/******************************************************************************* 324 * 325 * FUNCTION: AcpiDbSetMethodBreakpoint 326 * 327 * PARAMETERS: Location - AML offset of breakpoint 328 * WalkState - Current walk info 329 * Op - Current Op (from parse walk) 330 * 331 * RETURN: None 332 * 333 * DESCRIPTION: Set a breakpoint in a control method at the specified 334 * AML offset 335 * 336 ******************************************************************************/ 337 338void 339AcpiDbSetMethodBreakpoint ( 340 NATIVE_CHAR *Location, 341 ACPI_WALK_STATE *WalkState, 342 ACPI_PARSE_OBJECT *Op) 343{ 344 UINT32 Address; 345 346 347 if (!Op) 348 { 349 AcpiOsPrintf ("There is no method currently executing\n"); 350 return; 351 } 352 353 /* Get and verify the breakpoint address */ 354 355 Address = STRTOUL (Location, NULL, 16); 356 if (Address <= Op->AmlOffset) 357 { 358 AcpiOsPrintf ("Breakpoint 0x%X is beyond current address 0x%X\n", Address, Op->AmlOffset); 359 } 360 361 /* Save breakpoint in current walk */ 362 363 WalkState->MethodBreakpoint = Address; 364 AcpiOsPrintf ("Breakpoint set at AML offset 0x%X\n", Address); 365} 366 367 368/******************************************************************************* 369 * 370 * FUNCTION: AcpiDbSetMethodCallBreakpoint 371 * 372 * PARAMETERS: Op - Current Op (from parse walk) 373 * 374 * RETURN: None 375 * 376 * DESCRIPTION: Set a breakpoint in a control method at the specified 377 * AML offset 378 * 379 ******************************************************************************/ 380 381void 382AcpiDbSetMethodCallBreakpoint ( 383 ACPI_PARSE_OBJECT *Op) 384{ 385 386 387 if (!Op) 388 { 389 AcpiOsPrintf ("There is no method currently executing\n"); 390 return; 391 } 392 393 394 AcpiGbl_StepToNextCall = TRUE; 395} 396 397 398/******************************************************************************* 399 * 400 * FUNCTION: AcpiDbDisassembleAml 401 * 402 * PARAMETERS: Statements - Number of statements to disassemble 403 * Op - Current Op (from parse walk) 404 * 405 * RETURN: None 406 * 407 * DESCRIPTION: Display disassembled AML (ASL) starting from Op for the number 408 * of statements specified. 409 * 410 ******************************************************************************/ 411 412void 413AcpiDbDisassembleAml ( 414 NATIVE_CHAR *Statements, 415 ACPI_PARSE_OBJECT *Op) 416{ 417 UINT32 NumStatements = 8; 418 419 420 if (!Op) 421 { 422 AcpiOsPrintf ("There is no method currently executing\n"); 423 return; 424 } 425 426 if (Statements) 427 { 428 NumStatements = STRTOUL (Statements, NULL, 0); 429 } 430 431 432 AcpiDbDisplayOp (NULL, Op, NumStatements); 433} 434 435 436/******************************************************************************* 437 * 438 * FUNCTION: AcpiDbDumpNamespace 439 * 440 * PARAMETERS: StartArg - Node to begin namespace dump 441 * DepthArg - Maximum tree depth to be dumped 442 * 443 * RETURN: None 444 * 445 * DESCRIPTION: Dump entire namespace or a subtree. Each node is displayed 446 * with type and other information. 447 * 448 ******************************************************************************/ 449 450void 451AcpiDbDumpNamespace ( 452 NATIVE_CHAR *StartArg, 453 NATIVE_CHAR *DepthArg) 454{ 455 ACPI_HANDLE SubtreeEntry = AcpiGbl_RootNode; 456 UINT32 MaxDepth = ACPI_UINT32_MAX; 457 458 459 /* No argument given, just start at the root and dump entire namespace */ 460 461 if (StartArg) 462 { 463 /* Check if numeric argument, must be a Node */ 464 465 if ((StartArg[0] >= 0x30) && (StartArg[0] <= 0x39)) 466 { 467 SubtreeEntry = (ACPI_HANDLE) STRTOUL (StartArg, NULL, 16); 468 if (!AcpiOsReadable (SubtreeEntry, sizeof (ACPI_NAMESPACE_NODE))) 469 { 470 AcpiOsPrintf ("Address %p is invalid in this address space\n", SubtreeEntry); 471 return; 472 } 473 474 if (!VALID_DESCRIPTOR_TYPE ((SubtreeEntry), ACPI_DESC_TYPE_NAMED)) 475 { 476 AcpiOsPrintf ("Address %p is not a valid Named object\n", SubtreeEntry); 477 return; 478 } 479 } 480 481 /* Alpha argument */ 482 483 else 484 { 485 /* The parameter is a name string that must be resolved to a Named obj*/ 486 487 SubtreeEntry = AcpiDbLocalNsLookup (StartArg); 488 if (!SubtreeEntry) 489 { 490 SubtreeEntry = AcpiGbl_RootNode; 491 } 492 } 493 494 /* Now we can check for the depth argument */ 495 496 if (DepthArg) 497 { 498 MaxDepth = STRTOUL (DepthArg, NULL, 0); 499 } 500 } 501 502 503 AcpiDbSetOutputDestination (DB_DUPLICATE_OUTPUT); 504 AcpiOsPrintf ("ACPI Namespace (from %p subtree):\n", SubtreeEntry); 505 506 /* Display the subtree */ 507 508 AcpiDbSetOutputDestination (DB_REDIRECTABLE_OUTPUT); 509 AcpiNsDumpObjects (ACPI_TYPE_ANY, MaxDepth, ACPI_UINT32_MAX, SubtreeEntry); 510 AcpiDbSetOutputDestination (DB_CONSOLE_OUTPUT); 511} 512 513 514/******************************************************************************* 515 * 516 * FUNCTION: AcpiDbDumpNamespaceByOwner 517 * 518 * PARAMETERS: OwnerArg - Owner ID whose nodes will be displayed 519 * DepthArg - Maximum tree depth to be dumped 520 * 521 * RETURN: None 522 * 523 * DESCRIPTION: Dump elements of the namespace that are owned by the OwnerId. 524 * 525 ******************************************************************************/ 526 527void 528AcpiDbDumpNamespaceByOwner ( 529 NATIVE_CHAR *OwnerArg, 530 NATIVE_CHAR *DepthArg) 531{ 532 ACPI_HANDLE SubtreeEntry = AcpiGbl_RootNode; 533 UINT32 MaxDepth = ACPI_UINT32_MAX; 534 UINT16 OwnerId; 535 536 537 OwnerId = (UINT16) STRTOUL (OwnerArg, NULL, 0); 538 539 540 /* Now we can check for the depth argument */ 541 542 if (DepthArg) 543 { 544 MaxDepth = STRTOUL (DepthArg, NULL, 0); 545 } 546 547 548 AcpiDbSetOutputDestination (DB_DUPLICATE_OUTPUT); 549 AcpiOsPrintf ("ACPI Namespace by owner 0x%X:\n", OwnerId); 550 551 /* Display the subtree */ 552 553 AcpiDbSetOutputDestination (DB_REDIRECTABLE_OUTPUT); 554 AcpiNsDumpObjects (ACPI_TYPE_ANY, MaxDepth, OwnerId, SubtreeEntry); 555 AcpiDbSetOutputDestination (DB_CONSOLE_OUTPUT); 556} 557 558 559/******************************************************************************* 560 * 561 * FUNCTION: AcpiDbSendNotify 562 * 563 * PARAMETERS: Name - Name of ACPI object to send the notify to 564 * Value - Value of the notify to send. 565 * 566 * RETURN: None 567 * 568 * DESCRIPTION: Send an ACPI notification. The value specified is sent to the 569 * named object as an ACPI notify. 570 * 571 ******************************************************************************/ 572 573void 574AcpiDbSendNotify ( 575 NATIVE_CHAR *Name, 576 UINT32 Value) 577{ 578 ACPI_NAMESPACE_NODE *Node; 579 580 581 /* Translate name to an Named object */ 582 583 Node = AcpiDbLocalNsLookup (Name); 584 if (!Node) 585 { 586 return; 587 } 588 589 /* Decode Named object type */ 590 591 switch (Node->Type) 592 { 593 case ACPI_TYPE_DEVICE: 594 case ACPI_TYPE_THERMAL: 595 596 /* Send the notify */ 597 598 AcpiEvNotifyDispatch (Node, Value); 599 break; 600 601 default: 602 AcpiOsPrintf ("Named object is not a device or a thermal object\n"); 603 break; 604 } 605 606} 607 608 609/******************************************************************************* 610 * 611 * FUNCTION: AcpiDbSetMethodData 612 * 613 * PARAMETERS: TypeArg - L for local, A for argument 614 * IndexArg - which one 615 * ValueArg - Value to set. 616 * 617 * RETURN: None 618 * 619 * DESCRIPTION: Set a local or argument for the running control method. 620 * NOTE: only object supported is Number. 621 * 622 ******************************************************************************/ 623 624void 625AcpiDbSetMethodData ( 626 NATIVE_CHAR *TypeArg, 627 NATIVE_CHAR *IndexArg, 628 NATIVE_CHAR *ValueArg) 629{ 630 NATIVE_CHAR Type; 631 UINT32 Index; 632 UINT32 Value; 633 ACPI_WALK_STATE *WalkState; 634 ACPI_OPERAND_OBJECT *ObjDesc; 635 636 637 /* Validate TypeArg */ 638 639 STRUPR (TypeArg); 640 Type = TypeArg[0]; 641 if ((Type != 'L') && 642 (Type != 'A')) 643 { 644 AcpiOsPrintf ("Invalid SET operand: %s\n", TypeArg); 645 return; 646 } 647 648 /* Get the index and value */ 649 650 Index = STRTOUL (IndexArg, NULL, 16); 651 Value = STRTOUL (ValueArg, NULL, 16); 652 653 WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList); 654 if (!WalkState) 655 { 656 AcpiOsPrintf ("There is no method currently executing\n"); 657 return; 658 } 659 660 661 /* Create and initialize the new object */ 662 663 ObjDesc = AcpiCmCreateInternalObject (ACPI_TYPE_NUMBER); 664 if (!ObjDesc) 665 { 666 AcpiOsPrintf ("Could not create an internal object\n"); 667 return; 668 } 669 670 ObjDesc->Number.Value = Value; 671 672 673 /* Store the new object into the target */ 674 675 switch (Type) 676 { 677 case 'A': 678 679 /* Set a method argument */ 680 681 if (Index > MTH_NUM_ARGS) 682 { 683 AcpiOsPrintf ("Arg%d - Invalid argument name\n", Index); 684 return; 685 } 686 687 AcpiDsMethodDataSetValue (MTH_TYPE_ARG, Index, ObjDesc, WalkState); 688 ObjDesc = WalkState->Arguments[Index].Object; 689 690 AcpiOsPrintf ("Arg%d: ", Index); 691 AcpiDbDisplayInternalObject (ObjDesc, WalkState); 692 break; 693 694 case 'L': 695 696 /* Set a method local */ 697 698 if (Index > MTH_NUM_LOCALS) 699 { 700 AcpiOsPrintf ("Local%d - Invalid local variable name\n", Index); 701 return; 702 } 703 704 AcpiDsMethodDataSetValue (MTH_TYPE_LOCAL, Index, ObjDesc, WalkState); 705 ObjDesc = WalkState->LocalVariables[Index].Object; 706 707 AcpiOsPrintf ("Local%d: ", Index); 708 AcpiDbDisplayInternalObject (ObjDesc, WalkState); 709 break; 710 711 default: 712 break; 713 } 714} 715 716 717/******************************************************************************* 718 * 719 * FUNCTION: AcpiDbWalkForSpecificObjects 720 * 721 * PARAMETERS: Callback from WalkNamespace 722 * 723 * RETURN: Status 724 * 725 * DESCRIPTION: Display short info about objects in the namespace 726 * 727 ******************************************************************************/ 728 729ACPI_STATUS 730AcpiDbWalkForSpecificObjects ( 731 ACPI_HANDLE ObjHandle, 732 UINT32 NestingLevel, 733 void *Context, 734 void **ReturnValue) 735{ 736 ACPI_OPERAND_OBJECT *ObjDesc; 737 ACPI_STATUS Status; 738 UINT32 BufSize; 739 NATIVE_CHAR buffer[64]; 740 741 742 ObjDesc = ((ACPI_NAMESPACE_NODE *)ObjHandle)->Object; 743 744 /* Get and display the full pathname to this object */ 745 746 Status = AcpiNsHandleToPathname (ObjHandle, &BufSize, buffer); 747 748 if (ACPI_FAILURE (Status)) 749 { 750 AcpiOsPrintf ("Could Not get pathname for object %p\n", ObjHandle); 751 return (AE_OK); 752 } 753 754 AcpiOsPrintf ("%32s", buffer); 755 756 757 /* Display short information about the object */ 758 759 if (ObjDesc) 760 { 761 switch (ObjDesc->Common.Type) 762 { 763 case ACPI_TYPE_METHOD: 764 AcpiOsPrintf (" #Args %d Concurrency %d", ObjDesc->Method.ParamCount, ObjDesc->Method.Concurrency); 765 break; 766 767 case ACPI_TYPE_NUMBER: 768 AcpiOsPrintf (" Value 0x%X", ObjDesc->Number.Value); 769 break; 770 771 case ACPI_TYPE_STRING: 772 AcpiOsPrintf (" \"%s\"", ObjDesc->String.Pointer); 773 break; 774 775 case ACPI_TYPE_REGION: 776 AcpiOsPrintf (" SpaceId %d Address %X Length %X", ObjDesc->Region.SpaceId, ObjDesc->Region.Address, ObjDesc->Region.Length); 777 break; 778 779 case ACPI_TYPE_PACKAGE: 780 AcpiOsPrintf (" #Elements %d", ObjDesc->Package.Count); 781 break; 782 783 case ACPI_TYPE_BUFFER: 784 AcpiOsPrintf (" Length %d", ObjDesc->Buffer.Length); 785 break; 786 } 787 } 788 789 AcpiOsPrintf ("\n"); 790 return (AE_OK); 791} 792 793 794/******************************************************************************* 795 * 796 * FUNCTION: AcpiDbDisplayObjects 797 * 798 * PARAMETERS: ObjTypeArg - Type of object to display 799 * DisplayCountArg - Max depth to display 800 * 801 * RETURN: None 802 * 803 * DESCRIPTION: Display objects in the namespace of the requested type 804 * 805 ******************************************************************************/ 806 807ACPI_STATUS 808AcpiDbDisplayObjects ( 809 NATIVE_CHAR *ObjTypeArg, 810 NATIVE_CHAR *DisplayCountArg) 811{ 812 UINT32 DisplayCount; 813 OBJECT_TYPE_INTERNAL Type; 814 815 816 /* Get the object type */ 817 818 STRUPR (ObjTypeArg); 819 Type = AcpiDbMatchArgument (ObjTypeArg, AcpiDbObjectTypes); 820 if (Type == ACPI_TYPE_NOT_FOUND) 821 { 822 AcpiOsPrintf ("Invalid or unsupported argument\n"); 823 return (AE_OK); 824 } 825 826 /* Get the display depth */ 827 828 if (DisplayCountArg) 829 { 830 DisplayCount = STRTOUL (DisplayCountArg, NULL, 0); 831 } 832 833 else 834 { 835 DisplayCount = ACPI_UINT32_MAX; 836 } 837 838 AcpiDbSetOutputDestination (DB_DUPLICATE_OUTPUT); 839 AcpiOsPrintf ("Objects of type [%s] defined in the current ACPI Namespace: \n", AcpiCmGetTypeName (Type)); 840 841 AcpiDbSetOutputDestination (DB_REDIRECTABLE_OUTPUT); 842 843 /* Walk the namespace from the root */ 844 845 AcpiWalkNamespace (Type, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX, 846 AcpiDbWalkForSpecificObjects, (void *) &Type, NULL); 847 848 AcpiDbSetOutputDestination (DB_CONSOLE_OUTPUT); 849 return (AE_OK); 850} 851 852 853/******************************************************************************* 854 * 855 * FUNCTION: AcpiDbWalkAndMatchName 856 * 857 * PARAMETERS: Callback from WalkNamespace 858 * 859 * RETURN: Status 860 * 861 * DESCRIPTION: Find a particular name/names within the namespace. Wildcards 862 * are supported -- '?' matches any character. 863 * 864 ******************************************************************************/ 865 866ACPI_STATUS 867AcpiDbWalkAndMatchName ( 868 ACPI_HANDLE ObjHandle, 869 UINT32 NestingLevel, 870 void *Context, 871 void **ReturnValue) 872{ 873 ACPI_OPERAND_OBJECT *ObjDesc; 874 ACPI_STATUS Status; 875 NATIVE_CHAR *RequestedName = (NATIVE_CHAR *) Context; 876 UINT32 i; 877 UINT32 BufSize; 878 NATIVE_CHAR Buffer[96]; 879 880 881 ObjDesc = ((ACPI_NAMESPACE_NODE *)ObjHandle)->Object; 882 883 884 /* Check for a name match */ 885 886 for (i = 0; i < 4; i++) 887 { 888 /* Wildcard support */ 889 890 if ((RequestedName[i] != '?') && 891 (RequestedName[i] != ((NATIVE_CHAR *) (&((ACPI_NAMESPACE_NODE *) ObjHandle)->Name))[i])) 892 { 893 /* No match, just exit */ 894 895 return (AE_OK); 896 } 897 } 898 899 900 /* Get the full pathname to this object */ 901 902 BufSize = sizeof (Buffer); 903 904 Status = AcpiNsHandleToPathname (ObjHandle, &BufSize, Buffer); 905 if (ACPI_FAILURE (Status)) 906 { 907 AcpiOsPrintf ("Could Not get pathname for object %p\n", ObjHandle); 908 } 909 910 else 911 { 912 AcpiOsPrintf ("%32s (0x%p) - %s\n", Buffer, ObjHandle, 913 AcpiCmGetTypeName (((ACPI_NAMESPACE_NODE *) ObjHandle)->Type)); 914 } 915 916 return (AE_OK); 917} 918 919 920/******************************************************************************* 921 * 922 * FUNCTION: AcpiDbFindNameInNamespace 923 * 924 * PARAMETERS: NameArg - The 4-character ACPI name to find. 925 * wildcards are supported. 926 * 927 * RETURN: None 928 * 929 * DESCRIPTION: Search the namespace for a given name (with wildcards) 930 * 931 ******************************************************************************/ 932 933ACPI_STATUS 934AcpiDbFindNameInNamespace ( 935 NATIVE_CHAR *NameArg) 936{ 937 938 if (STRLEN (NameArg) > 4) 939 { 940 AcpiOsPrintf ("Name must be no longer than 4 characters\n"); 941 return (AE_OK); 942 } 943 944 /* Walk the namespace from the root */ 945 946 AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX, 947 AcpiDbWalkAndMatchName, NameArg, NULL); 948 949 AcpiDbSetOutputDestination (DB_CONSOLE_OUTPUT); 950 return (AE_OK); 951} 952 953 954/******************************************************************************* 955 * 956 * FUNCTION: AcpiDbSetScope 957 * 958 * PARAMETERS: Name - New scope path 959 * 960 * RETURN: Status 961 * 962 * DESCRIPTION: Set the "current scope" as maintained by this utility. 963 * The scope is used as a prefix to ACPI paths. 964 * 965 ******************************************************************************/ 966 967void 968AcpiDbSetScope ( 969 NATIVE_CHAR *Name) 970{ 971 972 if (!Name || Name[0] == 0) 973 { 974 AcpiOsPrintf ("Current scope: %s\n", ScopeBuf); 975 return; 976 } 977 978 AcpiDbPrepNamestring (Name); 979 980 /* TBD: [Future] Validate scope here */ 981 982 if (Name[0] == '\\') 983 { 984 STRCPY (ScopeBuf, Name); 985 STRCAT (ScopeBuf, "\\"); 986 } 987 988 else 989 { 990 STRCAT (ScopeBuf, Name); 991 STRCAT (ScopeBuf, "\\"); 992 } 993 994 AcpiOsPrintf ("New scope: %s\n", ScopeBuf); 995} 996 997#endif /* ENABLE_DEBUGGER */ 998