1 /******************************************************************************* 2 * 3 * Module Name: dbcmds - Miscellaneous debug commands and output routines 4 * 5 ******************************************************************************/ 6 7 /****************************************************************************** 8 * 9 * 1. Copyright Notice 10 * 11 * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. 12 * All rights reserved. 13 * 14 * 2. License 15 * 16 * 2.1. This is your license from Intel Corp. under its intellectual property 17 * rights. You may have additional license terms from the party that provided 18 * you this software, covering your right to use that party's intellectual 19 * property rights. 20 * 21 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a 22 * copy of the source code appearing in this file ("Covered Code") an 23 * irrevocable, perpetual, worldwide license under Intel's copyrights in the 24 * base code distributed originally by Intel ("Original Intel Code") to copy, 25 * make derivatives, distribute, use and display any portion of the Covered 26 * Code in any form, with the right to sublicense such rights; and 27 * 28 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent 29 * license (with the right to sublicense), under only those claims of Intel 30 * patents that are infringed by the Original Intel Code, to make, use, sell, 31 * offer to sell, and import the Covered Code and derivative works thereof 32 * solely to the minimum extent necessary to exercise the above copyright 33 * license, and in no event shall the patent license extend to any additions 34 * to or modifications of the Original Intel Code. No other license or right 35 * is granted directly or by implication, estoppel or otherwise; 36 * 37 * The above copyright and patent license is granted only if the following 38 * conditions are met: 39 * 40 * 3. Conditions 41 * 42 * 3.1. Redistribution of Source with Rights to Further Distribute Source. 43 * Redistribution of source code of any substantial portion of the Covered 44 * Code or modification with rights to further distribute source must include 45 * the above Copyright Notice, the above License, this list of Conditions, 46 * and the following Disclaimer and Export Compliance provision. In addition, 47 * Licensee must cause all Covered Code to which Licensee contributes to 48 * contain a file documenting the changes Licensee made to create that Covered 49 * Code and the date of any change. Licensee must include in that file the 50 * documentation of any changes made by any predecessor Licensee. Licensee 51 * must include a prominent statement that the modification is derived, 52 * directly or indirectly, from Original Intel Code. 53 * 54 * 3.2. Redistribution of Source with no Rights to Further Distribute Source. 55 * Redistribution of source code of any substantial portion of the Covered 56 * Code or modification without rights to further distribute source must 57 * include the following Disclaimer and Export Compliance provision in the 58 * documentation and/or other materials provided with distribution. In 59 * addition, Licensee may not authorize further sublicense of source of any 60 * portion of the Covered Code, and must include terms to the effect that the 61 * license from Licensee to its licensee is limited to the intellectual 62 * property embodied in the software Licensee provides to its licensee, and 63 * not to intellectual property embodied in modifications its licensee may 64 * make. 65 * 66 * 3.3. Redistribution of Executable. Redistribution in executable form of any 67 * substantial portion of the Covered Code or modification must reproduce the 68 * above Copyright Notice, and the following Disclaimer and Export Compliance 69 * provision in the documentation and/or other materials provided with the 70 * distribution. 71 * 72 * 3.4. Intel retains all right, title, and interest in and to the Original 73 * Intel Code. 74 * 75 * 3.5. Neither the name Intel nor any other trademark owned or controlled by 76 * Intel shall be used in advertising or otherwise to promote the sale, use or 77 * other dealings in products derived from or relating to the Covered Code 78 * without prior written authorization from Intel. 79 * 80 * 4. Disclaimer and Export Compliance 81 * 82 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED 83 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE 84 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, 85 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY 86 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY 87 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A 88 * PARTICULAR PURPOSE. 89 * 90 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES 91 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR 92 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, 93 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY 94 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL 95 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS 96 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY 97 * LIMITED REMEDY. 98 * 99 * 4.3. Licensee shall not export, either directly or indirectly, any of this 100 * software or system incorporating such software without first obtaining any 101 * required license or other approval from the U. S. Department of Commerce or 102 * any other agency or department of the United States Government. In the 103 * event Licensee exports any such software from the United States or 104 * re-exports any such software from a foreign destination, Licensee shall 105 * ensure that the distribution and export/re-export of the software is in 106 * compliance with all laws, regulations, orders, or other restrictions of the 107 * U.S. Export Administration Regulations. Licensee agrees that neither it nor 108 * any of its subsidiaries will export/re-export any technical data, process, 109 * software, or service, directly or indirectly, to any country for which the 110 * United States government or any agency thereof requires an export license, 111 * other governmental approval, or letter of assurance, without first obtaining 112 * such license, approval or letter. 113 * 114 ***************************************************************************** 115 * 116 * Alternatively, you may choose to be licensed under the terms of the 117 * following license: 118 * 119 * Redistribution and use in source and binary forms, with or without 120 * modification, are permitted provided that the following conditions 121 * are met: 122 * 1. Redistributions of source code must retain the above copyright 123 * notice, this list of conditions, and the following disclaimer, 124 * without modification. 125 * 2. Redistributions in binary form must reproduce at minimum a disclaimer 126 * substantially similar to the "NO WARRANTY" disclaimer below 127 * ("Disclaimer") and any redistribution must be conditioned upon 128 * including a substantially similar Disclaimer requirement for further 129 * binary redistribution. 130 * 3. Neither the names of the above-listed copyright holders nor the names 131 * of any contributors may be used to endorse or promote products derived 132 * from this software without specific prior written permission. 133 * 134 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 135 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 136 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 137 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 138 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 139 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 140 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 141 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 142 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 143 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 144 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 145 * 146 * Alternatively, you may choose to be licensed under the terms of the 147 * GNU General Public License ("GPL") version 2 as published by the Free 148 * Software Foundation. 149 * 150 *****************************************************************************/ 151 152 #include "acpi.h" 153 #include "accommon.h" 154 #include "acevents.h" 155 #include "acdebug.h" 156 #include "acnamesp.h" 157 #include "acresrc.h" 158 #include "actables.h" 159 #ifndef _KERNEL 160 #include "limits.h" 161 #endif 162 163 #define _COMPONENT ACPI_CA_DEBUGGER 164 ACPI_MODULE_NAME ("dbcmds") 165 166 167 /* Local prototypes */ 168 169 static void 170 AcpiDmCompareAmlResources ( 171 UINT8 *Aml1Buffer, 172 ACPI_RSDESC_SIZE Aml1BufferLength, 173 UINT8 *Aml2Buffer, 174 ACPI_RSDESC_SIZE Aml2BufferLength); 175 176 static ACPI_STATUS 177 AcpiDmTestResourceConversion ( 178 ACPI_NAMESPACE_NODE *Node, 179 char *Name); 180 181 static ACPI_STATUS 182 AcpiDbResourceCallback ( 183 ACPI_RESOURCE *Resource, 184 void *Context); 185 186 static ACPI_STATUS 187 AcpiDbDeviceResources ( 188 ACPI_HANDLE ObjHandle, 189 UINT32 NestingLevel, 190 void *Context, 191 void **ReturnValue); 192 193 static void 194 AcpiDbDoOneSleepState ( 195 UINT8 SleepState); 196 197 198 static char *AcpiDbTraceMethodName = NULL; 199 200 201 /******************************************************************************* 202 * 203 * FUNCTION: AcpiDbConvertToNode 204 * 205 * PARAMETERS: InString - String to convert 206 * 207 * RETURN: Pointer to a NS node 208 * 209 * DESCRIPTION: Convert a string to a valid NS pointer. Handles numeric or 210 * alphanumeric strings. 211 * 212 ******************************************************************************/ 213 214 ACPI_NAMESPACE_NODE * 215 AcpiDbConvertToNode ( 216 char *InString) 217 { 218 ACPI_NAMESPACE_NODE *Node; 219 ACPI_SIZE Address; 220 221 222 if ((*InString >= 0x30) && (*InString <= 0x39)) 223 { 224 /* Numeric argument, convert */ 225 226 Address = strtoul (InString, NULL, 16); 227 Node = ACPI_TO_POINTER (Address); 228 if (!AcpiOsReadable (Node, sizeof (ACPI_NAMESPACE_NODE))) 229 { 230 AcpiOsPrintf ("Address %p is invalid", Node); 231 return (NULL); 232 } 233 234 /* Make sure pointer is valid NS node */ 235 236 if (ACPI_GET_DESCRIPTOR_TYPE (Node) != ACPI_DESC_TYPE_NAMED) 237 { 238 AcpiOsPrintf ("Address %p is not a valid namespace node [%s]\n", 239 Node, AcpiUtGetDescriptorName (Node)); 240 return (NULL); 241 } 242 } 243 else 244 { 245 /* 246 * Alpha argument: The parameter is a name string that must be 247 * resolved to a Namespace object. 248 */ 249 Node = AcpiDbLocalNsLookup (InString); 250 if (!Node) 251 { 252 AcpiOsPrintf ( 253 "Could not find [%s] in namespace, defaulting to root node\n", 254 InString); 255 Node = AcpiGbl_RootNode; 256 } 257 } 258 259 return (Node); 260 } 261 262 263 /******************************************************************************* 264 * 265 * FUNCTION: AcpiDbSleep 266 * 267 * PARAMETERS: ObjectArg - Desired sleep state (0-5). NULL means 268 * invoke all possible sleep states. 269 * 270 * RETURN: Status 271 * 272 * DESCRIPTION: Simulate sleep/wake sequences 273 * 274 ******************************************************************************/ 275 276 ACPI_STATUS 277 AcpiDbSleep ( 278 char *ObjectArg) 279 { 280 UINT8 SleepState; 281 UINT32 i; 282 283 284 ACPI_FUNCTION_TRACE (AcpiDbSleep); 285 286 287 /* Null input (no arguments) means to invoke all sleep states */ 288 289 if (!ObjectArg) 290 { 291 AcpiOsPrintf ("Invoking all possible sleep states, 0-%d\n", 292 ACPI_S_STATES_MAX); 293 294 for (i = 0; i <= ACPI_S_STATES_MAX; i++) 295 { 296 AcpiDbDoOneSleepState ((UINT8) i); 297 } 298 299 return_ACPI_STATUS (AE_OK); 300 } 301 302 /* Convert argument to binary and invoke the sleep state */ 303 304 SleepState = (UINT8) strtoul (ObjectArg, NULL, 0); 305 AcpiDbDoOneSleepState (SleepState); 306 return_ACPI_STATUS (AE_OK); 307 } 308 309 310 /******************************************************************************* 311 * 312 * FUNCTION: AcpiDbDoOneSleepState 313 * 314 * PARAMETERS: SleepState - Desired sleep state (0-5) 315 * 316 * RETURN: None 317 * 318 * DESCRIPTION: Simulate a sleep/wake sequence 319 * 320 ******************************************************************************/ 321 322 static void 323 AcpiDbDoOneSleepState ( 324 UINT8 SleepState) 325 { 326 ACPI_STATUS Status; 327 UINT8 SleepTypeA; 328 UINT8 SleepTypeB; 329 330 331 /* Validate parameter */ 332 333 if (SleepState > ACPI_S_STATES_MAX) 334 { 335 AcpiOsPrintf ("Sleep state %d out of range (%d max)\n", 336 SleepState, ACPI_S_STATES_MAX); 337 return; 338 } 339 340 AcpiOsPrintf ("\n---- Invoking sleep state S%d (%s):\n", 341 SleepState, AcpiGbl_SleepStateNames[SleepState]); 342 343 /* Get the values for the sleep type registers (for display only) */ 344 345 Status = AcpiGetSleepTypeData (SleepState, &SleepTypeA, &SleepTypeB); 346 if (ACPI_FAILURE (Status)) 347 { 348 AcpiOsPrintf ("Could not evaluate [%s] method, %s\n", 349 AcpiGbl_SleepStateNames[SleepState], 350 AcpiFormatException (Status)); 351 return; 352 } 353 354 AcpiOsPrintf ( 355 "Register values for sleep state S%d: Sleep-A: %.2X, Sleep-B: %.2X\n", 356 SleepState, SleepTypeA, SleepTypeB); 357 358 /* Invoke the various sleep/wake interfaces */ 359 360 AcpiOsPrintf ("**** Sleep: Prepare to sleep (S%d) ****\n", 361 SleepState); 362 Status = AcpiEnterSleepStatePrep (SleepState); 363 if (ACPI_FAILURE (Status)) 364 { 365 goto ErrorExit; 366 } 367 368 AcpiOsPrintf ("**** Sleep: Going to sleep (S%d) ****\n", 369 SleepState); 370 Status = AcpiEnterSleepState (SleepState); 371 if (ACPI_FAILURE (Status)) 372 { 373 goto ErrorExit; 374 } 375 376 AcpiOsPrintf ("**** Wake: Prepare to return from sleep (S%d) ****\n", 377 SleepState); 378 Status = AcpiLeaveSleepStatePrep (SleepState); 379 if (ACPI_FAILURE (Status)) 380 { 381 goto ErrorExit; 382 } 383 384 AcpiOsPrintf ("**** Wake: Return from sleep (S%d) ****\n", 385 SleepState); 386 Status = AcpiLeaveSleepState (SleepState); 387 if (ACPI_FAILURE (Status)) 388 { 389 goto ErrorExit; 390 } 391 392 return; 393 394 395 ErrorExit: 396 ACPI_EXCEPTION ((AE_INFO, Status, "During invocation of sleep state S%d", 397 SleepState)); 398 } 399 400 401 /******************************************************************************* 402 * 403 * FUNCTION: AcpiDbDisplayLocks 404 * 405 * PARAMETERS: None 406 * 407 * RETURN: None 408 * 409 * DESCRIPTION: Display information about internal mutexes. 410 * 411 ******************************************************************************/ 412 413 void 414 AcpiDbDisplayLocks ( 415 void) 416 { 417 UINT32 i; 418 419 420 for (i = 0; i < ACPI_MAX_MUTEX; i++) 421 { 422 AcpiOsPrintf ("%26s : %s\n", AcpiUtGetMutexName (i), 423 AcpiGbl_MutexInfo[i].ThreadId == ACPI_MUTEX_NOT_ACQUIRED 424 ? "Locked" : "Unlocked"); 425 } 426 } 427 428 429 /******************************************************************************* 430 * 431 * FUNCTION: AcpiDbDisplayTableInfo 432 * 433 * PARAMETERS: TableArg - Name of table to be displayed 434 * 435 * RETURN: None 436 * 437 * DESCRIPTION: Display information about loaded tables. Current 438 * implementation displays all loaded tables. 439 * 440 ******************************************************************************/ 441 442 void 443 AcpiDbDisplayTableInfo ( 444 char *TableArg) 445 { 446 UINT32 i; 447 ACPI_TABLE_DESC *TableDesc; 448 ACPI_STATUS Status; 449 450 451 /* Header */ 452 453 AcpiOsPrintf ("Idx ID Status Type " 454 "TableHeader (Sig, Address, Length, Misc)\n"); 455 456 /* Walk the entire root table list */ 457 458 for (i = 0; i < AcpiGbl_RootTableList.CurrentTableCount; i++) 459 { 460 TableDesc = &AcpiGbl_RootTableList.Tables[i]; 461 462 /* Index and Table ID */ 463 464 AcpiOsPrintf ("%3u %.2u ", i, TableDesc->OwnerId); 465 466 /* Decode the table flags */ 467 468 if (!(TableDesc->Flags & ACPI_TABLE_IS_LOADED)) 469 { 470 AcpiOsPrintf ("NotLoaded "); 471 } 472 else 473 { 474 AcpiOsPrintf (" Loaded "); 475 } 476 477 switch (TableDesc->Flags & ACPI_TABLE_ORIGIN_MASK) 478 { 479 case ACPI_TABLE_ORIGIN_EXTERNAL_VIRTUAL: 480 481 AcpiOsPrintf ("External/virtual "); 482 break; 483 484 case ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL: 485 486 AcpiOsPrintf ("Internal/physical "); 487 break; 488 489 case ACPI_TABLE_ORIGIN_INTERNAL_VIRTUAL: 490 491 AcpiOsPrintf ("Internal/virtual "); 492 break; 493 494 default: 495 496 AcpiOsPrintf ("INVALID TYPE "); 497 break; 498 } 499 500 /* Make sure that the table is mapped */ 501 502 Status = AcpiTbValidateTable (TableDesc); 503 if (ACPI_FAILURE (Status)) 504 { 505 return; 506 } 507 508 /* Dump the table header */ 509 510 if (TableDesc->Pointer) 511 { 512 AcpiTbPrintTableHeader (TableDesc->Address, TableDesc->Pointer); 513 } 514 else 515 { 516 /* If the pointer is null, the table has been unloaded */ 517 518 ACPI_INFO (("%4.4s - Table has been unloaded", 519 TableDesc->Signature.Ascii)); 520 } 521 } 522 } 523 524 525 /******************************************************************************* 526 * 527 * FUNCTION: AcpiDbUnloadAcpiTable 528 * 529 * PARAMETERS: ObjectName - Namespace pathname for an object that 530 * is owned by the table to be unloaded 531 * 532 * RETURN: None 533 * 534 * DESCRIPTION: Unload an ACPI table, via any namespace node that is owned 535 * by the table. 536 * 537 ******************************************************************************/ 538 539 void 540 AcpiDbUnloadAcpiTable ( 541 char *ObjectName) 542 { 543 ACPI_NAMESPACE_NODE *Node; 544 ACPI_STATUS Status; 545 546 547 /* Translate name to an Named object */ 548 549 Node = AcpiDbConvertToNode (ObjectName); 550 if (!Node) 551 { 552 return; 553 } 554 555 Status = AcpiUnloadParentTable (ACPI_CAST_PTR (ACPI_HANDLE, Node)); 556 if (ACPI_SUCCESS (Status)) 557 { 558 AcpiOsPrintf ("Parent of [%s] (%p) unloaded and uninstalled\n", 559 ObjectName, Node); 560 } 561 else 562 { 563 AcpiOsPrintf ("%s, while unloading parent table of [%s]\n", 564 AcpiFormatException (Status), ObjectName); 565 } 566 } 567 568 569 /******************************************************************************* 570 * 571 * FUNCTION: AcpiDbSendNotify 572 * 573 * PARAMETERS: Name - Name of ACPI object where to send notify 574 * Value - Value of the notify to send. 575 * 576 * RETURN: None 577 * 578 * DESCRIPTION: Send an ACPI notification. The value specified is sent to the 579 * named object as an ACPI notify. 580 * 581 ******************************************************************************/ 582 583 void 584 AcpiDbSendNotify ( 585 char *Name, 586 UINT32 Value) 587 { 588 ACPI_NAMESPACE_NODE *Node; 589 ACPI_STATUS Status; 590 591 592 /* Translate name to an Named object */ 593 594 Node = AcpiDbConvertToNode (Name); 595 if (!Node) 596 { 597 return; 598 } 599 600 /* Dispatch the notify if legal */ 601 602 if (AcpiEvIsNotifyObject (Node)) 603 { 604 Status = AcpiEvQueueNotifyRequest (Node, Value); 605 if (ACPI_FAILURE (Status)) 606 { 607 AcpiOsPrintf ("Could not queue notify\n"); 608 } 609 } 610 else 611 { 612 AcpiOsPrintf ( 613 "Named object [%4.4s] Type %s, " 614 "must be Device/Thermal/Processor type\n", 615 AcpiUtGetNodeName (Node), AcpiUtGetTypeName (Node->Type)); 616 } 617 } 618 619 620 /******************************************************************************* 621 * 622 * FUNCTION: AcpiDbDisplayInterfaces 623 * 624 * PARAMETERS: ActionArg - Null, "install", or "remove" 625 * InterfaceNameArg - Name for install/remove options 626 * 627 * RETURN: None 628 * 629 * DESCRIPTION: Display or modify the global _OSI interface list 630 * 631 ******************************************************************************/ 632 633 void 634 AcpiDbDisplayInterfaces ( 635 char *ActionArg, 636 char *InterfaceNameArg) 637 { 638 ACPI_INTERFACE_INFO *NextInterface; 639 char *SubString; 640 ACPI_STATUS Status; 641 642 643 /* If no arguments, just display current interface list */ 644 645 if (!ActionArg) 646 { 647 (void) AcpiOsAcquireMutex (AcpiGbl_OsiMutex, ACPI_WAIT_FOREVER); 648 649 NextInterface = AcpiGbl_SupportedInterfaces; 650 while (NextInterface) 651 { 652 if (!(NextInterface->Flags & ACPI_OSI_INVALID)) 653 { 654 AcpiOsPrintf ("%s\n", NextInterface->Name); 655 } 656 657 NextInterface = NextInterface->Next; 658 } 659 660 AcpiOsReleaseMutex (AcpiGbl_OsiMutex); 661 return; 662 } 663 664 /* If ActionArg exists, so must InterfaceNameArg */ 665 666 if (!InterfaceNameArg) 667 { 668 AcpiOsPrintf ("Missing Interface Name argument\n"); 669 return; 670 } 671 672 /* Uppercase the action for match below */ 673 674 AcpiUtStrupr (ActionArg); 675 676 /* Install - install an interface */ 677 678 SubString = strstr ("INSTALL", ActionArg); 679 if (SubString) 680 { 681 Status = AcpiInstallInterface (InterfaceNameArg); 682 if (ACPI_FAILURE (Status)) 683 { 684 AcpiOsPrintf ("%s, while installing \"%s\"\n", 685 AcpiFormatException (Status), InterfaceNameArg); 686 } 687 return; 688 } 689 690 /* Remove - remove an interface */ 691 692 SubString = strstr ("REMOVE", ActionArg); 693 if (SubString) 694 { 695 Status = AcpiRemoveInterface (InterfaceNameArg); 696 if (ACPI_FAILURE (Status)) 697 { 698 AcpiOsPrintf ("%s, while removing \"%s\"\n", 699 AcpiFormatException (Status), InterfaceNameArg); 700 } 701 return; 702 } 703 704 /* Invalid ActionArg */ 705 706 AcpiOsPrintf ("Invalid action argument: %s\n", ActionArg); 707 return; 708 } 709 710 711 /******************************************************************************* 712 * 713 * FUNCTION: AcpiDbDisplayTemplate 714 * 715 * PARAMETERS: BufferArg - Buffer name or address 716 * 717 * RETURN: None 718 * 719 * DESCRIPTION: Dump a buffer that contains a resource template 720 * 721 ******************************************************************************/ 722 723 void 724 AcpiDbDisplayTemplate ( 725 char *BufferArg) 726 { 727 ACPI_NAMESPACE_NODE *Node; 728 ACPI_STATUS Status; 729 ACPI_BUFFER ReturnBuffer; 730 731 732 /* Translate BufferArg to an Named object */ 733 734 Node = AcpiDbConvertToNode (BufferArg); 735 if (!Node || (Node == AcpiGbl_RootNode)) 736 { 737 AcpiOsPrintf ("Invalid argument: %s\n", BufferArg); 738 return; 739 } 740 741 /* We must have a buffer object */ 742 743 if (Node->Type != ACPI_TYPE_BUFFER) 744 { 745 AcpiOsPrintf ("Not a Buffer object, cannot be a template: %s\n", 746 BufferArg); 747 return; 748 } 749 750 ReturnBuffer.Length = ACPI_DEBUG_BUFFER_SIZE; 751 ReturnBuffer.Pointer = AcpiGbl_DbBuffer; 752 753 /* Attempt to convert the raw buffer to a resource list */ 754 755 Status = AcpiRsCreateResourceList (Node->Object, &ReturnBuffer); 756 757 AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT); 758 AcpiDbgLevel |= ACPI_LV_RESOURCES; 759 760 if (ACPI_FAILURE (Status)) 761 { 762 AcpiOsPrintf ( 763 "Could not convert Buffer to a resource list: %s, %s\n", 764 BufferArg, AcpiFormatException (Status)); 765 goto DumpBuffer; 766 } 767 768 /* Now we can dump the resource list */ 769 770 AcpiRsDumpResourceList (ACPI_CAST_PTR (ACPI_RESOURCE, 771 ReturnBuffer.Pointer)); 772 773 DumpBuffer: 774 AcpiOsPrintf ("\nRaw data buffer:\n"); 775 AcpiUtDebugDumpBuffer ((UINT8 *) Node->Object->Buffer.Pointer, 776 Node->Object->Buffer.Length, 777 DB_BYTE_DISPLAY, ACPI_UINT32_MAX); 778 779 AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT); 780 return; 781 } 782 783 784 /******************************************************************************* 785 * 786 * FUNCTION: AcpiDmCompareAmlResources 787 * 788 * PARAMETERS: Aml1Buffer - Contains first resource list 789 * Aml1BufferLength - Length of first resource list 790 * Aml2Buffer - Contains second resource list 791 * Aml2BufferLength - Length of second resource list 792 * 793 * RETURN: None 794 * 795 * DESCRIPTION: Compare two AML resource lists, descriptor by descriptor (in 796 * order to isolate a miscompare to an individual resource) 797 * 798 ******************************************************************************/ 799 800 static void 801 AcpiDmCompareAmlResources ( 802 UINT8 *Aml1Buffer, 803 ACPI_RSDESC_SIZE Aml1BufferLength, 804 UINT8 *Aml2Buffer, 805 ACPI_RSDESC_SIZE Aml2BufferLength) 806 { 807 UINT8 *Aml1; 808 UINT8 *Aml2; 809 UINT8 *Aml1End; 810 UINT8 *Aml2End; 811 ACPI_RSDESC_SIZE Aml1Length; 812 ACPI_RSDESC_SIZE Aml2Length; 813 ACPI_RSDESC_SIZE Offset = 0; 814 UINT8 ResourceType; 815 UINT32 Count = 0; 816 UINT32 i; 817 818 819 /* Compare overall buffer sizes (may be different due to size rounding) */ 820 821 if (Aml1BufferLength != Aml2BufferLength) 822 { 823 AcpiOsPrintf ( 824 "**** Buffer length mismatch in converted " 825 "AML: Original %X, New %X ****\n", 826 Aml1BufferLength, Aml2BufferLength); 827 } 828 829 Aml1 = Aml1Buffer; 830 Aml2 = Aml2Buffer; 831 Aml1End = Aml1Buffer + Aml1BufferLength; 832 Aml2End = Aml2Buffer + Aml2BufferLength; 833 834 /* Walk the descriptor lists, comparing each descriptor */ 835 836 while ((Aml1 < Aml1End) && (Aml2 < Aml2End)) 837 { 838 /* Get the lengths of each descriptor */ 839 840 Aml1Length = AcpiUtGetDescriptorLength (Aml1); 841 Aml2Length = AcpiUtGetDescriptorLength (Aml2); 842 ResourceType = AcpiUtGetResourceType (Aml1); 843 844 /* Check for descriptor length match */ 845 846 if (Aml1Length != Aml2Length) 847 { 848 AcpiOsPrintf ( 849 "**** Length mismatch in descriptor [%.2X] type %2.2X, " 850 "Offset %8.8X Len1 %X, Len2 %X ****\n", 851 Count, ResourceType, Offset, Aml1Length, Aml2Length); 852 } 853 854 /* Check for descriptor byte match */ 855 856 else if (memcmp (Aml1, Aml2, Aml1Length)) 857 { 858 AcpiOsPrintf ( 859 "**** Data mismatch in descriptor [%.2X] type %2.2X, " 860 "Offset %8.8X ****\n", 861 Count, ResourceType, Offset); 862 863 for (i = 0; i < Aml1Length; i++) 864 { 865 if (Aml1[i] != Aml2[i]) 866 { 867 AcpiOsPrintf ( 868 "Mismatch at byte offset %.2X: is %2.2X, " 869 "should be %2.2X\n", 870 i, Aml2[i], Aml1[i]); 871 } 872 } 873 } 874 875 /* Exit on EndTag descriptor */ 876 877 if (ResourceType == ACPI_RESOURCE_NAME_END_TAG) 878 { 879 return; 880 } 881 882 /* Point to next descriptor in each buffer */ 883 884 Count++; 885 Offset += Aml1Length; 886 Aml1 += Aml1Length; 887 Aml2 += Aml2Length; 888 } 889 } 890 891 892 /******************************************************************************* 893 * 894 * FUNCTION: AcpiDmTestResourceConversion 895 * 896 * PARAMETERS: Node - Parent device node 897 * Name - resource method name (_CRS) 898 * 899 * RETURN: Status 900 * 901 * DESCRIPTION: Compare the original AML with a conversion of the AML to 902 * internal resource list, then back to AML. 903 * 904 ******************************************************************************/ 905 906 static ACPI_STATUS 907 AcpiDmTestResourceConversion ( 908 ACPI_NAMESPACE_NODE *Node, 909 char *Name) 910 { 911 ACPI_STATUS Status; 912 ACPI_BUFFER ReturnBuffer; 913 ACPI_BUFFER ResourceBuffer; 914 ACPI_BUFFER NewAml; 915 ACPI_OBJECT *OriginalAml; 916 917 918 AcpiOsPrintf ("Resource Conversion Comparison:\n"); 919 920 NewAml.Length = ACPI_ALLOCATE_LOCAL_BUFFER; 921 ReturnBuffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER; 922 ResourceBuffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER; 923 924 /* Get the original _CRS AML resource template */ 925 926 Status = AcpiEvaluateObject (Node, Name, NULL, &ReturnBuffer); 927 if (ACPI_FAILURE (Status)) 928 { 929 AcpiOsPrintf ("Could not obtain %s: %s\n", 930 Name, AcpiFormatException (Status)); 931 return (Status); 932 } 933 934 /* Get the AML resource template, converted to internal resource structs */ 935 936 Status = AcpiGetCurrentResources (Node, &ResourceBuffer); 937 if (ACPI_FAILURE (Status)) 938 { 939 AcpiOsPrintf ("AcpiGetCurrentResources failed: %s\n", 940 AcpiFormatException (Status)); 941 goto Exit1; 942 } 943 944 /* Convert internal resource list to external AML resource template */ 945 946 Status = AcpiRsCreateAmlResources (&ResourceBuffer, &NewAml); 947 if (ACPI_FAILURE (Status)) 948 { 949 AcpiOsPrintf ("AcpiRsCreateAmlResources failed: %s\n", 950 AcpiFormatException (Status)); 951 goto Exit2; 952 } 953 954 /* Compare original AML to the newly created AML resource list */ 955 956 OriginalAml = ReturnBuffer.Pointer; 957 958 AcpiDmCompareAmlResources (OriginalAml->Buffer.Pointer, 959 (ACPI_RSDESC_SIZE) OriginalAml->Buffer.Length, 960 NewAml.Pointer, (ACPI_RSDESC_SIZE) NewAml.Length); 961 962 /* Cleanup and exit */ 963 964 ACPI_FREE (NewAml.Pointer); 965 Exit2: 966 ACPI_FREE (ResourceBuffer.Pointer); 967 Exit1: 968 ACPI_FREE (ReturnBuffer.Pointer); 969 return (Status); 970 } 971 972 973 /******************************************************************************* 974 * 975 * FUNCTION: AcpiDbResourceCallback 976 * 977 * PARAMETERS: ACPI_WALK_RESOURCE_CALLBACK 978 * 979 * RETURN: Status 980 * 981 * DESCRIPTION: Simple callback to exercise AcpiWalkResources and 982 * AcpiWalkResourceBuffer. 983 * 984 ******************************************************************************/ 985 986 static ACPI_STATUS 987 AcpiDbResourceCallback ( 988 ACPI_RESOURCE *Resource, 989 void *Context) 990 { 991 992 return (AE_OK); 993 } 994 995 996 /******************************************************************************* 997 * 998 * FUNCTION: AcpiDbDeviceResources 999 * 1000 * PARAMETERS: ACPI_WALK_CALLBACK 1001 * 1002 * RETURN: Status 1003 * 1004 * DESCRIPTION: Display the _PRT/_CRS/_PRS resources for a device object. 1005 * 1006 ******************************************************************************/ 1007 1008 static ACPI_STATUS 1009 AcpiDbDeviceResources ( 1010 ACPI_HANDLE ObjHandle, 1011 UINT32 NestingLevel, 1012 void *Context, 1013 void **ReturnValue) 1014 { 1015 ACPI_NAMESPACE_NODE *Node; 1016 ACPI_NAMESPACE_NODE *PrtNode = NULL; 1017 ACPI_NAMESPACE_NODE *CrsNode = NULL; 1018 ACPI_NAMESPACE_NODE *PrsNode = NULL; 1019 ACPI_NAMESPACE_NODE *AeiNode = NULL; 1020 char *ParentPath; 1021 ACPI_BUFFER ReturnBuffer; 1022 ACPI_STATUS Status; 1023 1024 1025 Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, ObjHandle); 1026 ParentPath = AcpiNsGetNormalizedPathname (Node, TRUE); 1027 if (!ParentPath) 1028 { 1029 return (AE_NO_MEMORY); 1030 } 1031 1032 /* Get handles to the resource methods for this device */ 1033 1034 (void) AcpiGetHandle (Node, METHOD_NAME__PRT, 1035 ACPI_CAST_PTR (ACPI_HANDLE, &PrtNode)); 1036 (void) AcpiGetHandle (Node, METHOD_NAME__CRS, 1037 ACPI_CAST_PTR (ACPI_HANDLE, &CrsNode)); 1038 (void) AcpiGetHandle (Node, METHOD_NAME__PRS, 1039 ACPI_CAST_PTR (ACPI_HANDLE, &PrsNode)); 1040 (void) AcpiGetHandle (Node, METHOD_NAME__AEI, 1041 ACPI_CAST_PTR (ACPI_HANDLE, &AeiNode)); 1042 1043 if (!PrtNode && !CrsNode && !PrsNode && !AeiNode) 1044 { 1045 goto Cleanup; /* Nothing to do */ 1046 } 1047 1048 AcpiOsPrintf ("\nDevice: %s\n", ParentPath); 1049 1050 /* Prepare for a return object of arbitrary size */ 1051 1052 ReturnBuffer.Pointer = AcpiGbl_DbBuffer; 1053 ReturnBuffer.Length = ACPI_DEBUG_BUFFER_SIZE; 1054 1055 1056 /* _PRT */ 1057 1058 if (PrtNode) 1059 { 1060 AcpiOsPrintf ("Evaluating _PRT\n"); 1061 1062 Status = AcpiEvaluateObject (PrtNode, NULL, NULL, &ReturnBuffer); 1063 if (ACPI_FAILURE (Status)) 1064 { 1065 AcpiOsPrintf ("Could not evaluate _PRT: %s\n", 1066 AcpiFormatException (Status)); 1067 goto GetCrs; 1068 } 1069 1070 ReturnBuffer.Pointer = AcpiGbl_DbBuffer; 1071 ReturnBuffer.Length = ACPI_DEBUG_BUFFER_SIZE; 1072 1073 Status = AcpiGetIrqRoutingTable (Node, &ReturnBuffer); 1074 if (ACPI_FAILURE (Status)) 1075 { 1076 AcpiOsPrintf ("GetIrqRoutingTable failed: %s\n", 1077 AcpiFormatException (Status)); 1078 goto GetCrs; 1079 } 1080 1081 AcpiRsDumpIrqList (ACPI_CAST_PTR (UINT8, AcpiGbl_DbBuffer)); 1082 } 1083 1084 1085 /* _CRS */ 1086 1087 GetCrs: 1088 if (CrsNode) 1089 { 1090 AcpiOsPrintf ("Evaluating _CRS\n"); 1091 1092 ReturnBuffer.Pointer = AcpiGbl_DbBuffer; 1093 ReturnBuffer.Length = ACPI_DEBUG_BUFFER_SIZE; 1094 1095 Status = AcpiEvaluateObject (CrsNode, NULL, NULL, &ReturnBuffer); 1096 if (ACPI_FAILURE (Status)) 1097 { 1098 AcpiOsPrintf ("Could not evaluate _CRS: %s\n", 1099 AcpiFormatException (Status)); 1100 goto GetPrs; 1101 } 1102 1103 /* This code exercises the AcpiWalkResources interface */ 1104 1105 Status = AcpiWalkResources (Node, METHOD_NAME__CRS, 1106 AcpiDbResourceCallback, NULL); 1107 if (ACPI_FAILURE (Status)) 1108 { 1109 AcpiOsPrintf ("AcpiWalkResources failed: %s\n", 1110 AcpiFormatException (Status)); 1111 goto GetPrs; 1112 } 1113 1114 /* Get the _CRS resource list (test ALLOCATE buffer) */ 1115 1116 ReturnBuffer.Pointer = NULL; 1117 ReturnBuffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER; 1118 1119 Status = AcpiGetCurrentResources (Node, &ReturnBuffer); 1120 if (ACPI_FAILURE (Status)) 1121 { 1122 AcpiOsPrintf ("AcpiGetCurrentResources failed: %s\n", 1123 AcpiFormatException (Status)); 1124 goto GetPrs; 1125 } 1126 1127 /* This code exercises the AcpiWalkResourceBuffer interface */ 1128 1129 Status = AcpiWalkResourceBuffer (&ReturnBuffer, 1130 AcpiDbResourceCallback, NULL); 1131 if (ACPI_FAILURE (Status)) 1132 { 1133 AcpiOsPrintf ("AcpiWalkResourceBuffer failed: %s\n", 1134 AcpiFormatException (Status)); 1135 goto EndCrs; 1136 } 1137 1138 /* Dump the _CRS resource list */ 1139 1140 AcpiRsDumpResourceList (ACPI_CAST_PTR (ACPI_RESOURCE, 1141 ReturnBuffer.Pointer)); 1142 1143 /* 1144 * Perform comparison of original AML to newly created AML. This 1145 * tests both the AML->Resource conversion and the Resource->AML 1146 * conversion. 1147 */ 1148 (void) AcpiDmTestResourceConversion (Node, __UNCONST(METHOD_NAME__CRS)); 1149 1150 /* Execute _SRS with the resource list */ 1151 1152 AcpiOsPrintf ("Evaluating _SRS\n"); 1153 1154 Status = AcpiSetCurrentResources (Node, &ReturnBuffer); 1155 if (ACPI_FAILURE (Status)) 1156 { 1157 AcpiOsPrintf ("AcpiSetCurrentResources failed: %s\n", 1158 AcpiFormatException (Status)); 1159 goto EndCrs; 1160 } 1161 1162 EndCrs: 1163 ACPI_FREE (ReturnBuffer.Pointer); 1164 } 1165 1166 1167 /* _PRS */ 1168 1169 GetPrs: 1170 if (PrsNode) 1171 { 1172 AcpiOsPrintf ("Evaluating _PRS\n"); 1173 1174 ReturnBuffer.Pointer = AcpiGbl_DbBuffer; 1175 ReturnBuffer.Length = ACPI_DEBUG_BUFFER_SIZE; 1176 1177 Status = AcpiEvaluateObject (PrsNode, NULL, NULL, &ReturnBuffer); 1178 if (ACPI_FAILURE (Status)) 1179 { 1180 AcpiOsPrintf ("Could not evaluate _PRS: %s\n", 1181 AcpiFormatException (Status)); 1182 goto GetAei; 1183 } 1184 1185 ReturnBuffer.Pointer = AcpiGbl_DbBuffer; 1186 ReturnBuffer.Length = ACPI_DEBUG_BUFFER_SIZE; 1187 1188 Status = AcpiGetPossibleResources (Node, &ReturnBuffer); 1189 if (ACPI_FAILURE (Status)) 1190 { 1191 AcpiOsPrintf ("AcpiGetPossibleResources failed: %s\n", 1192 AcpiFormatException (Status)); 1193 goto GetAei; 1194 } 1195 1196 AcpiRsDumpResourceList (ACPI_CAST_PTR ( 1197 ACPI_RESOURCE, AcpiGbl_DbBuffer)); 1198 } 1199 1200 1201 /* _AEI */ 1202 1203 GetAei: 1204 if (AeiNode) 1205 { 1206 AcpiOsPrintf ("Evaluating _AEI\n"); 1207 1208 ReturnBuffer.Pointer = AcpiGbl_DbBuffer; 1209 ReturnBuffer.Length = ACPI_DEBUG_BUFFER_SIZE; 1210 1211 Status = AcpiEvaluateObject (AeiNode, NULL, NULL, &ReturnBuffer); 1212 if (ACPI_FAILURE (Status)) 1213 { 1214 AcpiOsPrintf ("Could not evaluate _AEI: %s\n", 1215 AcpiFormatException (Status)); 1216 goto Cleanup; 1217 } 1218 1219 ReturnBuffer.Pointer = AcpiGbl_DbBuffer; 1220 ReturnBuffer.Length = ACPI_DEBUG_BUFFER_SIZE; 1221 1222 Status = AcpiGetEventResources (Node, &ReturnBuffer); 1223 if (ACPI_FAILURE (Status)) 1224 { 1225 AcpiOsPrintf ("AcpiGetEventResources failed: %s\n", 1226 AcpiFormatException (Status)); 1227 goto Cleanup; 1228 } 1229 1230 AcpiRsDumpResourceList (ACPI_CAST_PTR ( 1231 ACPI_RESOURCE, AcpiGbl_DbBuffer)); 1232 } 1233 1234 1235 Cleanup: 1236 ACPI_FREE (ParentPath); 1237 return (AE_OK); 1238 } 1239 1240 1241 /******************************************************************************* 1242 * 1243 * FUNCTION: AcpiDbDisplayResources 1244 * 1245 * PARAMETERS: ObjectArg - String object name or object pointer. 1246 * NULL or "*" means "display resources for 1247 * all devices" 1248 * 1249 * RETURN: None 1250 * 1251 * DESCRIPTION: Display the resource objects associated with a device. 1252 * 1253 ******************************************************************************/ 1254 1255 void 1256 AcpiDbDisplayResources ( 1257 char *ObjectArg) 1258 { 1259 ACPI_NAMESPACE_NODE *Node; 1260 1261 1262 AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT); 1263 AcpiDbgLevel |= ACPI_LV_RESOURCES; 1264 1265 /* Asterisk means "display resources for all devices" */ 1266 1267 if (!ObjectArg || (!strcmp (ObjectArg, "*"))) 1268 { 1269 (void) AcpiWalkNamespace (ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, 1270 ACPI_UINT32_MAX, AcpiDbDeviceResources, NULL, NULL, NULL); 1271 } 1272 else 1273 { 1274 /* Convert string to object pointer */ 1275 1276 Node = AcpiDbConvertToNode (ObjectArg); 1277 if (Node) 1278 { 1279 if (Node->Type != ACPI_TYPE_DEVICE) 1280 { 1281 AcpiOsPrintf ( 1282 "%4.4s: Name is not a device object (%s)\n", 1283 Node->Name.Ascii, AcpiUtGetTypeName (Node->Type)); 1284 } 1285 else 1286 { 1287 (void) AcpiDbDeviceResources (Node, 0, NULL, NULL); 1288 } 1289 } 1290 } 1291 1292 AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT); 1293 } 1294 1295 1296 /******************************************************************************* 1297 * 1298 * FUNCTION: AcpiDbGenerateGed 1299 * 1300 * PARAMETERS: GedArg - Raw GED number, ascii string 1301 * 1302 * RETURN: None 1303 * 1304 * DESCRIPTION: Simulate firing of a GED 1305 * 1306 ******************************************************************************/ 1307 1308 void 1309 AcpiDbGenerateInterrupt ( 1310 char *GsivArg) 1311 { 1312 UINT32 GsivNumber; 1313 ACPI_GED_HANDLER_INFO *GedInfo = AcpiGbl_GedHandlerList; 1314 1315 if (!GedInfo) { 1316 AcpiOsPrintf ("No GED handling present\n"); 1317 } 1318 1319 GsivNumber = strtoul (GsivArg, NULL, 0); 1320 1321 while (GedInfo) { 1322 1323 if (GedInfo->IntId == GsivNumber) { 1324 ACPI_OBJECT_LIST ArgList; 1325 ACPI_OBJECT Arg0; 1326 ACPI_HANDLE EvtHandle = GedInfo->EvtMethod; 1327 ACPI_STATUS Status; 1328 1329 AcpiOsPrintf ("Evaluate GED _EVT (GSIV=%d)\n", GsivNumber); 1330 1331 if (!EvtHandle) { 1332 AcpiOsPrintf ("Undefined _EVT method\n"); 1333 return; 1334 } 1335 1336 Arg0.Integer.Type = ACPI_TYPE_INTEGER; 1337 Arg0.Integer.Value = GsivNumber; 1338 1339 ArgList.Count = 1; 1340 ArgList.Pointer = &Arg0; 1341 1342 Status = AcpiEvaluateObject (EvtHandle, NULL, &ArgList, NULL); 1343 if (ACPI_FAILURE (Status)) 1344 { 1345 AcpiOsPrintf ("Could not evaluate _EVT\n"); 1346 return; 1347 } 1348 1349 } 1350 GedInfo = GedInfo->Next; 1351 } 1352 } 1353 1354 #if (!ACPI_REDUCED_HARDWARE) 1355 /******************************************************************************* 1356 * 1357 * FUNCTION: AcpiDbGenerateGpe 1358 * 1359 * PARAMETERS: GpeArg - Raw GPE number, ascii string 1360 * BlockArg - GPE block number, ascii string 1361 * 0 or 1 for FADT GPE blocks 1362 * 1363 * RETURN: None 1364 * 1365 * DESCRIPTION: Simulate firing of a GPE 1366 * 1367 ******************************************************************************/ 1368 1369 void 1370 AcpiDbGenerateGpe ( 1371 char *GpeArg, 1372 char *BlockArg) 1373 { 1374 UINT32 BlockNumber = 0; 1375 UINT32 GpeNumber; 1376 ACPI_GPE_EVENT_INFO *GpeEventInfo; 1377 1378 1379 GpeNumber = strtoul (GpeArg, NULL, 0); 1380 1381 /* 1382 * If no block arg, or block arg == 0 or 1, use the FADT-defined 1383 * GPE blocks. 1384 */ 1385 if (BlockArg) 1386 { 1387 BlockNumber = strtoul (BlockArg, NULL, 0); 1388 if (BlockNumber == 1) 1389 { 1390 BlockNumber = 0; 1391 } 1392 } 1393 1394 GpeEventInfo = AcpiEvGetGpeEventInfo ( 1395 ACPI_TO_POINTER (BlockNumber), GpeNumber); 1396 if (!GpeEventInfo) 1397 { 1398 AcpiOsPrintf ("Invalid GPE\n"); 1399 return; 1400 } 1401 1402 (void) AcpiEvGpeDispatch (NULL, GpeEventInfo, GpeNumber); 1403 } 1404 1405 1406 /******************************************************************************* 1407 * 1408 * FUNCTION: AcpiDbGenerateSci 1409 * 1410 * PARAMETERS: None 1411 * 1412 * RETURN: None 1413 * 1414 * DESCRIPTION: Simulate an SCI -- just call the SCI dispatch. 1415 * 1416 ******************************************************************************/ 1417 1418 void 1419 AcpiDbGenerateSci ( 1420 void) 1421 { 1422 AcpiEvSciDispatch (); 1423 } 1424 1425 #endif /* !ACPI_REDUCED_HARDWARE */ 1426 1427 1428 /******************************************************************************* 1429 * 1430 * FUNCTION: AcpiDbTrace 1431 * 1432 * PARAMETERS: EnableArg - ENABLE/AML to enable tracer 1433 * DISABLE to disable tracer 1434 * MethodArg - Method to trace 1435 * OnceArg - Whether trace once 1436 * 1437 * RETURN: None 1438 * 1439 * DESCRIPTION: Control method tracing facility 1440 * 1441 ******************************************************************************/ 1442 1443 void 1444 AcpiDbTrace ( 1445 char *EnableArg, 1446 char *MethodArg, 1447 char *OnceArg) 1448 { 1449 UINT32 DebugLevel = 0; 1450 UINT32 DebugLayer = 0; 1451 UINT32 Flags = 0; 1452 1453 1454 AcpiUtStrupr (EnableArg); 1455 AcpiUtStrupr (OnceArg); 1456 1457 if (MethodArg) 1458 { 1459 if (AcpiDbTraceMethodName) 1460 { 1461 ACPI_FREE (AcpiDbTraceMethodName); 1462 AcpiDbTraceMethodName = NULL; 1463 } 1464 1465 AcpiDbTraceMethodName = ACPI_ALLOCATE (strlen (MethodArg) + 1); 1466 if (!AcpiDbTraceMethodName) 1467 { 1468 AcpiOsPrintf ("Failed to allocate method name (%s)\n", 1469 MethodArg); 1470 return; 1471 } 1472 1473 strcpy (AcpiDbTraceMethodName, MethodArg); 1474 } 1475 1476 if (!strcmp (EnableArg, "ENABLE") || 1477 !strcmp (EnableArg, "METHOD") || 1478 !strcmp (EnableArg, "OPCODE")) 1479 { 1480 if (!strcmp (EnableArg, "ENABLE")) 1481 { 1482 /* Inherit current console settings */ 1483 1484 DebugLevel = AcpiGbl_DbConsoleDebugLevel; 1485 DebugLayer = AcpiDbgLayer; 1486 } 1487 else 1488 { 1489 /* Restrict console output to trace points only */ 1490 1491 DebugLevel = ACPI_LV_TRACE_POINT; 1492 DebugLayer = ACPI_EXECUTER; 1493 } 1494 1495 Flags = ACPI_TRACE_ENABLED; 1496 1497 if (!strcmp (EnableArg, "OPCODE")) 1498 { 1499 Flags |= ACPI_TRACE_OPCODE; 1500 } 1501 1502 if (OnceArg && !strcmp (OnceArg, "ONCE")) 1503 { 1504 Flags |= ACPI_TRACE_ONESHOT; 1505 } 1506 } 1507 1508 (void) AcpiDebugTrace (AcpiDbTraceMethodName, 1509 DebugLevel, DebugLayer, Flags); 1510 } 1511