1 /*******************************************************************************
3 * Module Name: dbcmds - Miscellaneous debug commands and output routines
5 ******************************************************************************/
8 * Copyright (C) 2000 - 2015, Intel Corp.
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
44 #include <contrib/dev/acpica/include/acpi.h>
45 #include <contrib/dev/acpica/include/accommon.h>
46 #include <contrib/dev/acpica/include/acevents.h>
47 #include <contrib/dev/acpica/include/acdebug.h>
48 #include <contrib/dev/acpica/include/acnamesp.h>
49 #include <contrib/dev/acpica/include/acresrc.h>
50 #include <contrib/dev/acpica/include/actables.h>
54 #define _COMPONENT ACPI_CA_DEBUGGER
55 ACPI_MODULE_NAME ("dbcmds")
58 /* Local prototypes */
61 AcpiDmCompareAmlResources (
63 ACPI_RSDESC_SIZE Aml1BufferLength,
65 ACPI_RSDESC_SIZE Aml2BufferLength);
68 AcpiDmTestResourceConversion (
69 ACPI_NAMESPACE_NODE *Node,
73 AcpiDbResourceCallback (
74 ACPI_RESOURCE *Resource,
78 AcpiDbDeviceResources (
79 ACPI_HANDLE ObjHandle,
85 AcpiDbDoOneSleepState (
89 /*******************************************************************************
91 * FUNCTION: AcpiDbConvertToNode
93 * PARAMETERS: InString - String to convert
95 * RETURN: Pointer to a NS node
97 * DESCRIPTION: Convert a string to a valid NS pointer. Handles numeric or
98 * alphanumeric strings.
100 ******************************************************************************/
102 ACPI_NAMESPACE_NODE *
103 AcpiDbConvertToNode (
106 ACPI_NAMESPACE_NODE *Node;
110 if ((*InString >= 0x30) && (*InString <= 0x39))
112 /* Numeric argument, convert */
114 Address = ACPI_STRTOUL (InString, NULL, 16);
115 Node = ACPI_TO_POINTER (Address);
116 if (!AcpiOsReadable (Node, sizeof (ACPI_NAMESPACE_NODE)))
118 AcpiOsPrintf ("Address %p is invalid",
123 /* Make sure pointer is valid NS node */
125 if (ACPI_GET_DESCRIPTOR_TYPE (Node) != ACPI_DESC_TYPE_NAMED)
127 AcpiOsPrintf ("Address %p is not a valid namespace node [%s]\n",
128 Node, AcpiUtGetDescriptorName (Node));
135 * Alpha argument: The parameter is a name string that must be
136 * resolved to a Namespace object.
138 Node = AcpiDbLocalNsLookup (InString);
141 AcpiOsPrintf ("Could not find [%s] in namespace, defaulting to root node\n",
143 Node = AcpiGbl_RootNode;
151 /*******************************************************************************
153 * FUNCTION: AcpiDbSleep
155 * PARAMETERS: ObjectArg - Desired sleep state (0-5). NULL means
156 * invoke all possible sleep states.
160 * DESCRIPTION: Simulate sleep/wake sequences
162 ******************************************************************************/
172 ACPI_FUNCTION_TRACE (AcpiDbSleep);
175 /* Null input (no arguments) means to invoke all sleep states */
179 AcpiOsPrintf ("Invoking all possible sleep states, 0-%d\n",
182 for (i = 0; i <= ACPI_S_STATES_MAX; i++)
184 AcpiDbDoOneSleepState ((UINT8) i);
187 return_ACPI_STATUS (AE_OK);
190 /* Convert argument to binary and invoke the sleep state */
192 SleepState = (UINT8) ACPI_STRTOUL (ObjectArg, NULL, 0);
193 AcpiDbDoOneSleepState (SleepState);
194 return_ACPI_STATUS (AE_OK);
198 /*******************************************************************************
200 * FUNCTION: AcpiDbDoOneSleepState
202 * PARAMETERS: SleepState - Desired sleep state (0-5)
206 * DESCRIPTION: Simulate a sleep/wake sequence
208 ******************************************************************************/
211 AcpiDbDoOneSleepState (
219 /* Validate parameter */
221 if (SleepState > ACPI_S_STATES_MAX)
223 AcpiOsPrintf ("Sleep state %d out of range (%d max)\n",
224 SleepState, ACPI_S_STATES_MAX);
228 AcpiOsPrintf ("\n---- Invoking sleep state S%d (%s):\n",
229 SleepState, AcpiGbl_SleepStateNames[SleepState]);
231 /* Get the values for the sleep type registers (for display only) */
233 Status = AcpiGetSleepTypeData (SleepState, &SleepTypeA, &SleepTypeB);
234 if (ACPI_FAILURE (Status))
236 AcpiOsPrintf ("Could not evaluate [%s] method, %s\n",
237 AcpiGbl_SleepStateNames[SleepState],
238 AcpiFormatException (Status));
243 "Register values for sleep state S%d: Sleep-A: %.2X, Sleep-B: %.2X\n",
244 SleepState, SleepTypeA, SleepTypeB);
246 /* Invoke the various sleep/wake interfaces */
248 AcpiOsPrintf ("**** Sleep: Prepare to sleep (S%d) ****\n",
250 Status = AcpiEnterSleepStatePrep (SleepState);
251 if (ACPI_FAILURE (Status))
256 AcpiOsPrintf ("**** Sleep: Going to sleep (S%d) ****\n",
258 Status = AcpiEnterSleepState (SleepState);
259 if (ACPI_FAILURE (Status))
264 AcpiOsPrintf ("**** Wake: Prepare to return from sleep (S%d) ****\n",
266 Status = AcpiLeaveSleepStatePrep (SleepState);
267 if (ACPI_FAILURE (Status))
272 AcpiOsPrintf ("**** Wake: Return from sleep (S%d) ****\n",
274 Status = AcpiLeaveSleepState (SleepState);
275 if (ACPI_FAILURE (Status))
284 ACPI_EXCEPTION ((AE_INFO, Status, "During invocation of sleep state S%d",
289 /*******************************************************************************
291 * FUNCTION: AcpiDbDisplayLocks
297 * DESCRIPTION: Display information about internal mutexes.
299 ******************************************************************************/
308 for (i = 0; i < ACPI_MAX_MUTEX; i++)
310 AcpiOsPrintf ("%26s : %s\n", AcpiUtGetMutexName (i),
311 AcpiGbl_MutexInfo[i].ThreadId == ACPI_MUTEX_NOT_ACQUIRED
312 ? "Locked" : "Unlocked");
317 /*******************************************************************************
319 * FUNCTION: AcpiDbDisplayTableInfo
321 * PARAMETERS: TableArg - Name of table to be displayed
325 * DESCRIPTION: Display information about loaded tables. Current
326 * implementation displays all loaded tables.
328 ******************************************************************************/
331 AcpiDbDisplayTableInfo (
335 ACPI_TABLE_DESC *TableDesc;
341 AcpiOsPrintf ("Idx ID Status Type TableHeader (Sig, Address, Length)\n");
343 /* Walk the entire root table list */
345 for (i = 0; i < AcpiGbl_RootTableList.CurrentTableCount; i++)
347 TableDesc = &AcpiGbl_RootTableList.Tables[i];
349 /* Index and Table ID */
351 AcpiOsPrintf ("%3u %.2u ", i, TableDesc->OwnerId);
353 /* Decode the table flags */
355 if (!(TableDesc->Flags & ACPI_TABLE_IS_LOADED))
357 AcpiOsPrintf ("NotLoaded ");
361 AcpiOsPrintf (" Loaded ");
364 switch (TableDesc->Flags & ACPI_TABLE_ORIGIN_MASK)
366 case ACPI_TABLE_ORIGIN_EXTERNAL_VIRTUAL:
368 AcpiOsPrintf ("External/virtual ");
371 case ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL:
373 AcpiOsPrintf ("Internal/physical ");
376 case ACPI_TABLE_ORIGIN_INTERNAL_VIRTUAL:
378 AcpiOsPrintf ("Internal/virtual ");
383 AcpiOsPrintf ("INVALID TYPE ");
387 /* Make sure that the table is mapped */
389 Status = AcpiTbValidateTable (TableDesc);
390 if (ACPI_FAILURE (Status))
395 /* Dump the table header */
397 if (TableDesc->Pointer)
399 AcpiTbPrintTableHeader (TableDesc->Address, TableDesc->Pointer);
403 /* If the pointer is null, the table has been unloaded */
405 ACPI_INFO ((AE_INFO, "%4.4s - Table has been unloaded",
406 TableDesc->Signature.Ascii));
412 /*******************************************************************************
414 * FUNCTION: AcpiDbUnloadAcpiTable
416 * PARAMETERS: ObjectName - Namespace pathname for an object that
417 * is owned by the table to be unloaded
421 * DESCRIPTION: Unload an ACPI table, via any namespace node that is owned
424 ******************************************************************************/
427 AcpiDbUnloadAcpiTable (
430 ACPI_NAMESPACE_NODE *Node;
434 /* Translate name to an Named object */
436 Node = AcpiDbConvertToNode (ObjectName);
442 Status = AcpiUnloadParentTable (ACPI_CAST_PTR (ACPI_HANDLE, Node));
443 if (ACPI_SUCCESS (Status))
445 AcpiOsPrintf ("Parent of [%s] (%p) unloaded and uninstalled\n",
450 AcpiOsPrintf ("%s, while unloading parent table of [%s]\n",
451 AcpiFormatException (Status), ObjectName);
456 /*******************************************************************************
458 * FUNCTION: AcpiDbSendNotify
460 * PARAMETERS: Name - Name of ACPI object where to send notify
461 * Value - Value of the notify to send.
465 * DESCRIPTION: Send an ACPI notification. The value specified is sent to the
466 * named object as an ACPI notify.
468 ******************************************************************************/
475 ACPI_NAMESPACE_NODE *Node;
479 /* Translate name to an Named object */
481 Node = AcpiDbConvertToNode (Name);
487 /* Dispatch the notify if legal */
489 if (AcpiEvIsNotifyObject (Node))
491 Status = AcpiEvQueueNotifyRequest (Node, Value);
492 if (ACPI_FAILURE (Status))
494 AcpiOsPrintf ("Could not queue notify\n");
500 "Named object [%4.4s] Type %s, must be Device/Thermal/Processor type\n",
501 AcpiUtGetNodeName (Node), AcpiUtGetTypeName (Node->Type));
506 /*******************************************************************************
508 * FUNCTION: AcpiDbDisplayInterfaces
510 * PARAMETERS: ActionArg - Null, "install", or "remove"
511 * InterfaceNameArg - Name for install/remove options
515 * DESCRIPTION: Display or modify the global _OSI interface list
517 ******************************************************************************/
520 AcpiDbDisplayInterfaces (
522 char *InterfaceNameArg)
524 ACPI_INTERFACE_INFO *NextInterface;
529 /* If no arguments, just display current interface list */
533 (void) AcpiOsAcquireMutex (AcpiGbl_OsiMutex,
536 NextInterface = AcpiGbl_SupportedInterfaces;
537 while (NextInterface)
539 if (!(NextInterface->Flags & ACPI_OSI_INVALID))
541 AcpiOsPrintf ("%s\n", NextInterface->Name);
543 NextInterface = NextInterface->Next;
546 AcpiOsReleaseMutex (AcpiGbl_OsiMutex);
550 /* If ActionArg exists, so must InterfaceNameArg */
552 if (!InterfaceNameArg)
554 AcpiOsPrintf ("Missing Interface Name argument\n");
558 /* Uppercase the action for match below */
560 AcpiUtStrupr (ActionArg);
562 /* Install - install an interface */
564 SubString = ACPI_STRSTR ("INSTALL", ActionArg);
567 Status = AcpiInstallInterface (InterfaceNameArg);
568 if (ACPI_FAILURE (Status))
570 AcpiOsPrintf ("%s, while installing \"%s\"\n",
571 AcpiFormatException (Status), InterfaceNameArg);
576 /* Remove - remove an interface */
578 SubString = ACPI_STRSTR ("REMOVE", ActionArg);
581 Status = AcpiRemoveInterface (InterfaceNameArg);
582 if (ACPI_FAILURE (Status))
584 AcpiOsPrintf ("%s, while removing \"%s\"\n",
585 AcpiFormatException (Status), InterfaceNameArg);
590 /* Invalid ActionArg */
592 AcpiOsPrintf ("Invalid action argument: %s\n", ActionArg);
597 /*******************************************************************************
599 * FUNCTION: AcpiDbDisplayTemplate
601 * PARAMETERS: BufferArg - Buffer name or address
605 * DESCRIPTION: Dump a buffer that contains a resource template
607 ******************************************************************************/
610 AcpiDbDisplayTemplate (
613 ACPI_NAMESPACE_NODE *Node;
615 ACPI_BUFFER ReturnBuffer;
618 /* Translate BufferArg to an Named object */
620 Node = AcpiDbConvertToNode (BufferArg);
621 if (!Node || (Node == AcpiGbl_RootNode))
623 AcpiOsPrintf ("Invalid argument: %s\n", BufferArg);
627 /* We must have a buffer object */
629 if (Node->Type != ACPI_TYPE_BUFFER)
631 AcpiOsPrintf ("Not a Buffer object, cannot be a template: %s\n",
636 ReturnBuffer.Length = ACPI_DEBUG_BUFFER_SIZE;
637 ReturnBuffer.Pointer = AcpiGbl_DbBuffer;
639 /* Attempt to convert the raw buffer to a resource list */
641 Status = AcpiRsCreateResourceList (Node->Object, &ReturnBuffer);
643 AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT);
644 AcpiDbgLevel |= ACPI_LV_RESOURCES;
646 if (ACPI_FAILURE (Status))
648 AcpiOsPrintf ("Could not convert Buffer to a resource list: %s, %s\n",
649 BufferArg, AcpiFormatException (Status));
653 /* Now we can dump the resource list */
655 AcpiRsDumpResourceList (ACPI_CAST_PTR (ACPI_RESOURCE,
656 ReturnBuffer.Pointer));
659 AcpiOsPrintf ("\nRaw data buffer:\n");
660 AcpiUtDebugDumpBuffer ((UINT8 *) Node->Object->Buffer.Pointer,
661 Node->Object->Buffer.Length,
662 DB_BYTE_DISPLAY, ACPI_UINT32_MAX);
664 AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT);
669 /*******************************************************************************
671 * FUNCTION: AcpiDmCompareAmlResources
673 * PARAMETERS: Aml1Buffer - Contains first resource list
674 * Aml1BufferLength - Length of first resource list
675 * Aml2Buffer - Contains second resource list
676 * Aml2BufferLength - Length of second resource list
680 * DESCRIPTION: Compare two AML resource lists, descriptor by descriptor (in
681 * order to isolate a miscompare to an individual resource)
683 ******************************************************************************/
686 AcpiDmCompareAmlResources (
688 ACPI_RSDESC_SIZE Aml1BufferLength,
690 ACPI_RSDESC_SIZE Aml2BufferLength)
696 ACPI_RSDESC_SIZE Aml1Length;
697 ACPI_RSDESC_SIZE Aml2Length;
698 ACPI_RSDESC_SIZE Offset = 0;
704 /* Compare overall buffer sizes (may be different due to size rounding) */
706 if (Aml1BufferLength != Aml2BufferLength)
709 "**** Buffer length mismatch in converted AML: Original %X, New %X ****\n",
710 Aml1BufferLength, Aml2BufferLength);
715 Aml1End = Aml1Buffer + Aml1BufferLength;
716 Aml2End = Aml2Buffer + Aml2BufferLength;
718 /* Walk the descriptor lists, comparing each descriptor */
720 while ((Aml1 < Aml1End) && (Aml2 < Aml2End))
722 /* Get the lengths of each descriptor */
724 Aml1Length = AcpiUtGetDescriptorLength (Aml1);
725 Aml2Length = AcpiUtGetDescriptorLength (Aml2);
726 ResourceType = AcpiUtGetResourceType (Aml1);
728 /* Check for descriptor length match */
730 if (Aml1Length != Aml2Length)
733 "**** Length mismatch in descriptor [%.2X] type %2.2X, Offset %8.8X Len1 %X, Len2 %X ****\n",
734 Count, ResourceType, Offset, Aml1Length, Aml2Length);
737 /* Check for descriptor byte match */
739 else if (ACPI_MEMCMP (Aml1, Aml2, Aml1Length))
742 "**** Data mismatch in descriptor [%.2X] type %2.2X, Offset %8.8X ****\n",
743 Count, ResourceType, Offset);
745 for (i = 0; i < Aml1Length; i++)
747 if (Aml1[i] != Aml2[i])
750 "Mismatch at byte offset %.2X: is %2.2X, should be %2.2X\n",
751 i, Aml2[i], Aml1[i]);
756 /* Exit on EndTag descriptor */
758 if (ResourceType == ACPI_RESOURCE_NAME_END_TAG)
763 /* Point to next descriptor in each buffer */
766 Offset += Aml1Length;
773 /*******************************************************************************
775 * FUNCTION: AcpiDmTestResourceConversion
777 * PARAMETERS: Node - Parent device node
778 * Name - resource method name (_CRS)
782 * DESCRIPTION: Compare the original AML with a conversion of the AML to
783 * internal resource list, then back to AML.
785 ******************************************************************************/
788 AcpiDmTestResourceConversion (
789 ACPI_NAMESPACE_NODE *Node,
793 ACPI_BUFFER ReturnBuffer;
794 ACPI_BUFFER ResourceBuffer;
796 ACPI_OBJECT *OriginalAml;
799 AcpiOsPrintf ("Resource Conversion Comparison:\n");
801 NewAml.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
802 ReturnBuffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
803 ResourceBuffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
805 /* Get the original _CRS AML resource template */
807 Status = AcpiEvaluateObject (Node, Name, NULL, &ReturnBuffer);
808 if (ACPI_FAILURE (Status))
810 AcpiOsPrintf ("Could not obtain %s: %s\n",
811 Name, AcpiFormatException (Status));
815 /* Get the AML resource template, converted to internal resource structs */
817 Status = AcpiGetCurrentResources (Node, &ResourceBuffer);
818 if (ACPI_FAILURE (Status))
820 AcpiOsPrintf ("AcpiGetCurrentResources failed: %s\n",
821 AcpiFormatException (Status));
825 /* Convert internal resource list to external AML resource template */
827 Status = AcpiRsCreateAmlResources (&ResourceBuffer, &NewAml);
828 if (ACPI_FAILURE (Status))
830 AcpiOsPrintf ("AcpiRsCreateAmlResources failed: %s\n",
831 AcpiFormatException (Status));
835 /* Compare original AML to the newly created AML resource list */
837 OriginalAml = ReturnBuffer.Pointer;
839 AcpiDmCompareAmlResources (OriginalAml->Buffer.Pointer,
840 (ACPI_RSDESC_SIZE) OriginalAml->Buffer.Length,
841 NewAml.Pointer, (ACPI_RSDESC_SIZE) NewAml.Length);
843 /* Cleanup and exit */
845 ACPI_FREE (NewAml.Pointer);
847 ACPI_FREE (ResourceBuffer.Pointer);
849 ACPI_FREE (ReturnBuffer.Pointer);
854 /*******************************************************************************
856 * FUNCTION: AcpiDbResourceCallback
858 * PARAMETERS: ACPI_WALK_RESOURCE_CALLBACK
862 * DESCRIPTION: Simple callback to exercise AcpiWalkResources and
863 * AcpiWalkResourceBuffer.
865 ******************************************************************************/
868 AcpiDbResourceCallback (
869 ACPI_RESOURCE *Resource,
877 /*******************************************************************************
879 * FUNCTION: AcpiDbDeviceResources
881 * PARAMETERS: ACPI_WALK_CALLBACK
885 * DESCRIPTION: Display the _PRT/_CRS/_PRS resources for a device object.
887 ******************************************************************************/
890 AcpiDbDeviceResources (
891 ACPI_HANDLE ObjHandle,
896 ACPI_NAMESPACE_NODE *Node;
897 ACPI_NAMESPACE_NODE *PrtNode = NULL;
898 ACPI_NAMESPACE_NODE *CrsNode = NULL;
899 ACPI_NAMESPACE_NODE *PrsNode = NULL;
900 ACPI_NAMESPACE_NODE *AeiNode = NULL;
902 ACPI_BUFFER ReturnBuffer;
906 Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, ObjHandle);
907 ParentPath = AcpiNsGetExternalPathname (Node);
910 return (AE_NO_MEMORY);
913 /* Get handles to the resource methods for this device */
915 (void) AcpiGetHandle (Node, METHOD_NAME__PRT, ACPI_CAST_PTR (ACPI_HANDLE, &PrtNode));
916 (void) AcpiGetHandle (Node, METHOD_NAME__CRS, ACPI_CAST_PTR (ACPI_HANDLE, &CrsNode));
917 (void) AcpiGetHandle (Node, METHOD_NAME__PRS, ACPI_CAST_PTR (ACPI_HANDLE, &PrsNode));
918 (void) AcpiGetHandle (Node, METHOD_NAME__AEI, ACPI_CAST_PTR (ACPI_HANDLE, &AeiNode));
919 if (!PrtNode && !CrsNode && !PrsNode && !AeiNode)
921 goto Cleanup; /* Nothing to do */
924 AcpiOsPrintf ("\nDevice: %s\n", ParentPath);
926 /* Prepare for a return object of arbitrary size */
928 ReturnBuffer.Pointer = AcpiGbl_DbBuffer;
929 ReturnBuffer.Length = ACPI_DEBUG_BUFFER_SIZE;
936 AcpiOsPrintf ("Evaluating _PRT\n");
938 Status = AcpiEvaluateObject (PrtNode, NULL, NULL, &ReturnBuffer);
939 if (ACPI_FAILURE (Status))
941 AcpiOsPrintf ("Could not evaluate _PRT: %s\n",
942 AcpiFormatException (Status));
946 ReturnBuffer.Pointer = AcpiGbl_DbBuffer;
947 ReturnBuffer.Length = ACPI_DEBUG_BUFFER_SIZE;
949 Status = AcpiGetIrqRoutingTable (Node, &ReturnBuffer);
950 if (ACPI_FAILURE (Status))
952 AcpiOsPrintf ("GetIrqRoutingTable failed: %s\n",
953 AcpiFormatException (Status));
957 AcpiRsDumpIrqList (ACPI_CAST_PTR (UINT8, AcpiGbl_DbBuffer));
966 AcpiOsPrintf ("Evaluating _CRS\n");
968 ReturnBuffer.Pointer = AcpiGbl_DbBuffer;
969 ReturnBuffer.Length = ACPI_DEBUG_BUFFER_SIZE;
971 Status = AcpiEvaluateObject (CrsNode, NULL, NULL, &ReturnBuffer);
972 if (ACPI_FAILURE (Status))
974 AcpiOsPrintf ("Could not evaluate _CRS: %s\n",
975 AcpiFormatException (Status));
979 /* This code exercises the AcpiWalkResources interface */
981 Status = AcpiWalkResources (Node, METHOD_NAME__CRS,
982 AcpiDbResourceCallback, NULL);
983 if (ACPI_FAILURE (Status))
985 AcpiOsPrintf ("AcpiWalkResources failed: %s\n",
986 AcpiFormatException (Status));
990 /* Get the _CRS resource list (test ALLOCATE buffer) */
992 ReturnBuffer.Pointer = NULL;
993 ReturnBuffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
995 Status = AcpiGetCurrentResources (Node, &ReturnBuffer);
996 if (ACPI_FAILURE (Status))
998 AcpiOsPrintf ("AcpiGetCurrentResources failed: %s\n",
999 AcpiFormatException (Status));
1003 /* This code exercises the AcpiWalkResourceBuffer interface */
1005 Status = AcpiWalkResourceBuffer (&ReturnBuffer,
1006 AcpiDbResourceCallback, NULL);
1007 if (ACPI_FAILURE (Status))
1009 AcpiOsPrintf ("AcpiWalkResourceBuffer failed: %s\n",
1010 AcpiFormatException (Status));
1014 /* Dump the _CRS resource list */
1016 AcpiRsDumpResourceList (ACPI_CAST_PTR (ACPI_RESOURCE,
1017 ReturnBuffer.Pointer));
1020 * Perform comparison of original AML to newly created AML. This
1021 * tests both the AML->Resource conversion and the Resource->AML
1024 (void) AcpiDmTestResourceConversion (Node, METHOD_NAME__CRS);
1026 /* Execute _SRS with the resource list */
1028 AcpiOsPrintf ("Evaluating _SRS\n");
1030 Status = AcpiSetCurrentResources (Node, &ReturnBuffer);
1031 if (ACPI_FAILURE (Status))
1033 AcpiOsPrintf ("AcpiSetCurrentResources failed: %s\n",
1034 AcpiFormatException (Status));
1039 ACPI_FREE (ReturnBuffer.Pointer);
1048 AcpiOsPrintf ("Evaluating _PRS\n");
1050 ReturnBuffer.Pointer = AcpiGbl_DbBuffer;
1051 ReturnBuffer.Length = ACPI_DEBUG_BUFFER_SIZE;
1053 Status = AcpiEvaluateObject (PrsNode, NULL, NULL, &ReturnBuffer);
1054 if (ACPI_FAILURE (Status))
1056 AcpiOsPrintf ("Could not evaluate _PRS: %s\n",
1057 AcpiFormatException (Status));
1061 ReturnBuffer.Pointer = AcpiGbl_DbBuffer;
1062 ReturnBuffer.Length = ACPI_DEBUG_BUFFER_SIZE;
1064 Status = AcpiGetPossibleResources (Node, &ReturnBuffer);
1065 if (ACPI_FAILURE (Status))
1067 AcpiOsPrintf ("AcpiGetPossibleResources failed: %s\n",
1068 AcpiFormatException (Status));
1072 AcpiRsDumpResourceList (ACPI_CAST_PTR (ACPI_RESOURCE, AcpiGbl_DbBuffer));
1081 AcpiOsPrintf ("Evaluating _AEI\n");
1083 ReturnBuffer.Pointer = AcpiGbl_DbBuffer;
1084 ReturnBuffer.Length = ACPI_DEBUG_BUFFER_SIZE;
1086 Status = AcpiEvaluateObject (AeiNode, NULL, NULL, &ReturnBuffer);
1087 if (ACPI_FAILURE (Status))
1089 AcpiOsPrintf ("Could not evaluate _AEI: %s\n",
1090 AcpiFormatException (Status));
1094 ReturnBuffer.Pointer = AcpiGbl_DbBuffer;
1095 ReturnBuffer.Length = ACPI_DEBUG_BUFFER_SIZE;
1097 Status = AcpiGetEventResources (Node, &ReturnBuffer);
1098 if (ACPI_FAILURE (Status))
1100 AcpiOsPrintf ("AcpiGetEventResources failed: %s\n",
1101 AcpiFormatException (Status));
1105 AcpiRsDumpResourceList (ACPI_CAST_PTR (ACPI_RESOURCE, AcpiGbl_DbBuffer));
1110 ACPI_FREE (ParentPath);
1115 /*******************************************************************************
1117 * FUNCTION: AcpiDbDisplayResources
1119 * PARAMETERS: ObjectArg - String object name or object pointer.
1120 * NULL or "*" means "display resources for
1125 * DESCRIPTION: Display the resource objects associated with a device.
1127 ******************************************************************************/
1130 AcpiDbDisplayResources (
1133 ACPI_NAMESPACE_NODE *Node;
1136 AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT);
1137 AcpiDbgLevel |= ACPI_LV_RESOURCES;
1139 /* Asterisk means "display resources for all devices" */
1141 if (!ObjectArg || (!ACPI_STRCMP (ObjectArg, "*")))
1143 (void) AcpiWalkNamespace (ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
1144 ACPI_UINT32_MAX, AcpiDbDeviceResources, NULL, NULL, NULL);
1148 /* Convert string to object pointer */
1150 Node = AcpiDbConvertToNode (ObjectArg);
1153 if (Node->Type != ACPI_TYPE_DEVICE)
1155 AcpiOsPrintf ("%4.4s: Name is not a device object (%s)\n",
1156 Node->Name.Ascii, AcpiUtGetTypeName (Node->Type));
1160 (void) AcpiDbDeviceResources (Node, 0, NULL, NULL);
1165 AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT);
1169 #if (!ACPI_REDUCED_HARDWARE)
1170 /*******************************************************************************
1172 * FUNCTION: AcpiDbGenerateGpe
1174 * PARAMETERS: GpeArg - Raw GPE number, ascii string
1175 * BlockArg - GPE block number, ascii string
1176 * 0 or 1 for FADT GPE blocks
1180 * DESCRIPTION: Simulate firing of a GPE
1182 ******************************************************************************/
1189 UINT32 BlockNumber = 0;
1191 ACPI_GPE_EVENT_INFO *GpeEventInfo;
1194 GpeNumber = ACPI_STRTOUL (GpeArg, NULL, 0);
1197 * If no block arg, or block arg == 0 or 1, use the FADT-defined
1202 BlockNumber = ACPI_STRTOUL (BlockArg, NULL, 0);
1203 if (BlockNumber == 1)
1209 GpeEventInfo = AcpiEvGetGpeEventInfo (ACPI_TO_POINTER (BlockNumber),
1213 AcpiOsPrintf ("Invalid GPE\n");
1217 (void) AcpiEvGpeDispatch (NULL, GpeEventInfo, GpeNumber);
1224 AcpiEvSciDispatch ();
1227 #endif /* !ACPI_REDUCED_HARDWARE */
1229 #endif /* ACPI_DEBUGGER */