1 /*******************************************************************************
3 * Module Name: dbcmds - Miscellaneous debug commands and output routines
5 ******************************************************************************/
8 * Copyright (C) 2000 - 2016, 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.
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 static char *AcpiDbTraceMethodName = NULL;
92 /*******************************************************************************
94 * FUNCTION: AcpiDbConvertToNode
96 * PARAMETERS: InString - String to convert
98 * RETURN: Pointer to a NS node
100 * DESCRIPTION: Convert a string to a valid NS pointer. Handles numeric or
101 * alphanumeric strings.
103 ******************************************************************************/
105 ACPI_NAMESPACE_NODE *
106 AcpiDbConvertToNode (
109 ACPI_NAMESPACE_NODE *Node;
113 if ((*InString >= 0x30) && (*InString <= 0x39))
115 /* Numeric argument, convert */
117 Address = strtoul (InString, NULL, 16);
118 Node = ACPI_TO_POINTER (Address);
119 if (!AcpiOsReadable (Node, sizeof (ACPI_NAMESPACE_NODE)))
121 AcpiOsPrintf ("Address %p is invalid", Node);
125 /* Make sure pointer is valid NS node */
127 if (ACPI_GET_DESCRIPTOR_TYPE (Node) != ACPI_DESC_TYPE_NAMED)
129 AcpiOsPrintf ("Address %p is not a valid namespace node [%s]\n",
130 Node, AcpiUtGetDescriptorName (Node));
137 * Alpha argument: The parameter is a name string that must be
138 * resolved to a Namespace object.
140 Node = AcpiDbLocalNsLookup (InString);
144 "Could not find [%s] in namespace, defaulting to root node\n",
146 Node = AcpiGbl_RootNode;
154 /*******************************************************************************
156 * FUNCTION: AcpiDbSleep
158 * PARAMETERS: ObjectArg - Desired sleep state (0-5). NULL means
159 * invoke all possible sleep states.
163 * DESCRIPTION: Simulate sleep/wake sequences
165 ******************************************************************************/
175 ACPI_FUNCTION_TRACE (AcpiDbSleep);
178 /* Null input (no arguments) means to invoke all sleep states */
182 AcpiOsPrintf ("Invoking all possible sleep states, 0-%d\n",
185 for (i = 0; i <= ACPI_S_STATES_MAX; i++)
187 AcpiDbDoOneSleepState ((UINT8) i);
190 return_ACPI_STATUS (AE_OK);
193 /* Convert argument to binary and invoke the sleep state */
195 SleepState = (UINT8) strtoul (ObjectArg, NULL, 0);
196 AcpiDbDoOneSleepState (SleepState);
197 return_ACPI_STATUS (AE_OK);
201 /*******************************************************************************
203 * FUNCTION: AcpiDbDoOneSleepState
205 * PARAMETERS: SleepState - Desired sleep state (0-5)
209 * DESCRIPTION: Simulate a sleep/wake sequence
211 ******************************************************************************/
214 AcpiDbDoOneSleepState (
222 /* Validate parameter */
224 if (SleepState > ACPI_S_STATES_MAX)
226 AcpiOsPrintf ("Sleep state %d out of range (%d max)\n",
227 SleepState, ACPI_S_STATES_MAX);
231 AcpiOsPrintf ("\n---- Invoking sleep state S%d (%s):\n",
232 SleepState, AcpiGbl_SleepStateNames[SleepState]);
234 /* Get the values for the sleep type registers (for display only) */
236 Status = AcpiGetSleepTypeData (SleepState, &SleepTypeA, &SleepTypeB);
237 if (ACPI_FAILURE (Status))
239 AcpiOsPrintf ("Could not evaluate [%s] method, %s\n",
240 AcpiGbl_SleepStateNames[SleepState],
241 AcpiFormatException (Status));
246 "Register values for sleep state S%d: Sleep-A: %.2X, Sleep-B: %.2X\n",
247 SleepState, SleepTypeA, SleepTypeB);
249 /* Invoke the various sleep/wake interfaces */
251 AcpiOsPrintf ("**** Sleep: Prepare to sleep (S%d) ****\n",
253 Status = AcpiEnterSleepStatePrep (SleepState);
254 if (ACPI_FAILURE (Status))
259 AcpiOsPrintf ("**** Sleep: Going to sleep (S%d) ****\n",
261 Status = AcpiEnterSleepState (SleepState);
262 if (ACPI_FAILURE (Status))
267 AcpiOsPrintf ("**** Wake: Prepare to return from sleep (S%d) ****\n",
269 Status = AcpiLeaveSleepStatePrep (SleepState);
270 if (ACPI_FAILURE (Status))
275 AcpiOsPrintf ("**** Wake: Return from sleep (S%d) ****\n",
277 Status = AcpiLeaveSleepState (SleepState);
278 if (ACPI_FAILURE (Status))
287 ACPI_EXCEPTION ((AE_INFO, Status, "During invocation of sleep state S%d",
292 /*******************************************************************************
294 * FUNCTION: AcpiDbDisplayLocks
300 * DESCRIPTION: Display information about internal mutexes.
302 ******************************************************************************/
311 for (i = 0; i < ACPI_MAX_MUTEX; i++)
313 AcpiOsPrintf ("%26s : %s\n", AcpiUtGetMutexName (i),
314 AcpiGbl_MutexInfo[i].ThreadId == ACPI_MUTEX_NOT_ACQUIRED
315 ? "Locked" : "Unlocked");
320 /*******************************************************************************
322 * FUNCTION: AcpiDbDisplayTableInfo
324 * PARAMETERS: TableArg - Name of table to be displayed
328 * DESCRIPTION: Display information about loaded tables. Current
329 * implementation displays all loaded tables.
331 ******************************************************************************/
334 AcpiDbDisplayTableInfo (
338 ACPI_TABLE_DESC *TableDesc;
344 AcpiOsPrintf ("Idx ID Status Type "
345 "TableHeader (Sig, Address, Length, Misc)\n");
347 /* Walk the entire root table list */
349 for (i = 0; i < AcpiGbl_RootTableList.CurrentTableCount; i++)
351 TableDesc = &AcpiGbl_RootTableList.Tables[i];
353 /* Index and Table ID */
355 AcpiOsPrintf ("%3u %.2u ", i, TableDesc->OwnerId);
357 /* Decode the table flags */
359 if (!(TableDesc->Flags & ACPI_TABLE_IS_LOADED))
361 AcpiOsPrintf ("NotLoaded ");
365 AcpiOsPrintf (" Loaded ");
368 switch (TableDesc->Flags & ACPI_TABLE_ORIGIN_MASK)
370 case ACPI_TABLE_ORIGIN_EXTERNAL_VIRTUAL:
372 AcpiOsPrintf ("External/virtual ");
375 case ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL:
377 AcpiOsPrintf ("Internal/physical ");
380 case ACPI_TABLE_ORIGIN_INTERNAL_VIRTUAL:
382 AcpiOsPrintf ("Internal/virtual ");
387 AcpiOsPrintf ("INVALID TYPE ");
391 /* Make sure that the table is mapped */
393 Status = AcpiTbValidateTable (TableDesc);
394 if (ACPI_FAILURE (Status))
399 /* Dump the table header */
401 if (TableDesc->Pointer)
403 AcpiTbPrintTableHeader (TableDesc->Address, TableDesc->Pointer);
407 /* If the pointer is null, the table has been unloaded */
409 ACPI_INFO ((AE_INFO, "%4.4s - Table has been unloaded",
410 TableDesc->Signature.Ascii));
416 /*******************************************************************************
418 * FUNCTION: AcpiDbUnloadAcpiTable
420 * PARAMETERS: ObjectName - Namespace pathname for an object that
421 * is owned by the table to be unloaded
425 * DESCRIPTION: Unload an ACPI table, via any namespace node that is owned
428 ******************************************************************************/
431 AcpiDbUnloadAcpiTable (
434 ACPI_NAMESPACE_NODE *Node;
438 /* Translate name to an Named object */
440 Node = AcpiDbConvertToNode (ObjectName);
446 Status = AcpiUnloadParentTable (ACPI_CAST_PTR (ACPI_HANDLE, Node));
447 if (ACPI_SUCCESS (Status))
449 AcpiOsPrintf ("Parent of [%s] (%p) unloaded and uninstalled\n",
454 AcpiOsPrintf ("%s, while unloading parent table of [%s]\n",
455 AcpiFormatException (Status), ObjectName);
460 /*******************************************************************************
462 * FUNCTION: AcpiDbSendNotify
464 * PARAMETERS: Name - Name of ACPI object where to send notify
465 * Value - Value of the notify to send.
469 * DESCRIPTION: Send an ACPI notification. The value specified is sent to the
470 * named object as an ACPI notify.
472 ******************************************************************************/
479 ACPI_NAMESPACE_NODE *Node;
483 /* Translate name to an Named object */
485 Node = AcpiDbConvertToNode (Name);
491 /* Dispatch the notify if legal */
493 if (AcpiEvIsNotifyObject (Node))
495 Status = AcpiEvQueueNotifyRequest (Node, Value);
496 if (ACPI_FAILURE (Status))
498 AcpiOsPrintf ("Could not queue notify\n");
504 "Named object [%4.4s] Type %s, "
505 "must be Device/Thermal/Processor type\n",
506 AcpiUtGetNodeName (Node), AcpiUtGetTypeName (Node->Type));
511 /*******************************************************************************
513 * FUNCTION: AcpiDbDisplayInterfaces
515 * PARAMETERS: ActionArg - Null, "install", or "remove"
516 * InterfaceNameArg - Name for install/remove options
520 * DESCRIPTION: Display or modify the global _OSI interface list
522 ******************************************************************************/
525 AcpiDbDisplayInterfaces (
527 char *InterfaceNameArg)
529 ACPI_INTERFACE_INFO *NextInterface;
534 /* If no arguments, just display current interface list */
538 (void) AcpiOsAcquireMutex (AcpiGbl_OsiMutex, ACPI_WAIT_FOREVER);
540 NextInterface = AcpiGbl_SupportedInterfaces;
541 while (NextInterface)
543 if (!(NextInterface->Flags & ACPI_OSI_INVALID))
545 AcpiOsPrintf ("%s\n", NextInterface->Name);
548 NextInterface = NextInterface->Next;
551 AcpiOsReleaseMutex (AcpiGbl_OsiMutex);
555 /* If ActionArg exists, so must InterfaceNameArg */
557 if (!InterfaceNameArg)
559 AcpiOsPrintf ("Missing Interface Name argument\n");
563 /* Uppercase the action for match below */
565 AcpiUtStrupr (ActionArg);
567 /* Install - install an interface */
569 SubString = strstr ("INSTALL", ActionArg);
572 Status = AcpiInstallInterface (InterfaceNameArg);
573 if (ACPI_FAILURE (Status))
575 AcpiOsPrintf ("%s, while installing \"%s\"\n",
576 AcpiFormatException (Status), InterfaceNameArg);
581 /* Remove - remove an interface */
583 SubString = strstr ("REMOVE", ActionArg);
586 Status = AcpiRemoveInterface (InterfaceNameArg);
587 if (ACPI_FAILURE (Status))
589 AcpiOsPrintf ("%s, while removing \"%s\"\n",
590 AcpiFormatException (Status), InterfaceNameArg);
595 /* Invalid ActionArg */
597 AcpiOsPrintf ("Invalid action argument: %s\n", ActionArg);
602 /*******************************************************************************
604 * FUNCTION: AcpiDbDisplayTemplate
606 * PARAMETERS: BufferArg - Buffer name or address
610 * DESCRIPTION: Dump a buffer that contains a resource template
612 ******************************************************************************/
615 AcpiDbDisplayTemplate (
618 ACPI_NAMESPACE_NODE *Node;
620 ACPI_BUFFER ReturnBuffer;
623 /* Translate BufferArg to an Named object */
625 Node = AcpiDbConvertToNode (BufferArg);
626 if (!Node || (Node == AcpiGbl_RootNode))
628 AcpiOsPrintf ("Invalid argument: %s\n", BufferArg);
632 /* We must have a buffer object */
634 if (Node->Type != ACPI_TYPE_BUFFER)
636 AcpiOsPrintf ("Not a Buffer object, cannot be a template: %s\n",
641 ReturnBuffer.Length = ACPI_DEBUG_BUFFER_SIZE;
642 ReturnBuffer.Pointer = AcpiGbl_DbBuffer;
644 /* Attempt to convert the raw buffer to a resource list */
646 Status = AcpiRsCreateResourceList (Node->Object, &ReturnBuffer);
648 AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT);
649 AcpiDbgLevel |= ACPI_LV_RESOURCES;
651 if (ACPI_FAILURE (Status))
654 "Could not convert Buffer to a resource list: %s, %s\n",
655 BufferArg, AcpiFormatException (Status));
659 /* Now we can dump the resource list */
661 AcpiRsDumpResourceList (ACPI_CAST_PTR (ACPI_RESOURCE,
662 ReturnBuffer.Pointer));
665 AcpiOsPrintf ("\nRaw data buffer:\n");
666 AcpiUtDebugDumpBuffer ((UINT8 *) Node->Object->Buffer.Pointer,
667 Node->Object->Buffer.Length,
668 DB_BYTE_DISPLAY, ACPI_UINT32_MAX);
670 AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT);
675 /*******************************************************************************
677 * FUNCTION: AcpiDmCompareAmlResources
679 * PARAMETERS: Aml1Buffer - Contains first resource list
680 * Aml1BufferLength - Length of first resource list
681 * Aml2Buffer - Contains second resource list
682 * Aml2BufferLength - Length of second resource list
686 * DESCRIPTION: Compare two AML resource lists, descriptor by descriptor (in
687 * order to isolate a miscompare to an individual resource)
689 ******************************************************************************/
692 AcpiDmCompareAmlResources (
694 ACPI_RSDESC_SIZE Aml1BufferLength,
696 ACPI_RSDESC_SIZE Aml2BufferLength)
702 ACPI_RSDESC_SIZE Aml1Length;
703 ACPI_RSDESC_SIZE Aml2Length;
704 ACPI_RSDESC_SIZE Offset = 0;
710 /* Compare overall buffer sizes (may be different due to size rounding) */
712 if (Aml1BufferLength != Aml2BufferLength)
715 "**** Buffer length mismatch in converted "
716 "AML: Original %X, New %X ****\n",
717 Aml1BufferLength, Aml2BufferLength);
722 Aml1End = Aml1Buffer + Aml1BufferLength;
723 Aml2End = Aml2Buffer + Aml2BufferLength;
725 /* Walk the descriptor lists, comparing each descriptor */
727 while ((Aml1 < Aml1End) && (Aml2 < Aml2End))
729 /* Get the lengths of each descriptor */
731 Aml1Length = AcpiUtGetDescriptorLength (Aml1);
732 Aml2Length = AcpiUtGetDescriptorLength (Aml2);
733 ResourceType = AcpiUtGetResourceType (Aml1);
735 /* Check for descriptor length match */
737 if (Aml1Length != Aml2Length)
740 "**** Length mismatch in descriptor [%.2X] type %2.2X, "
741 "Offset %8.8X Len1 %X, Len2 %X ****\n",
742 Count, ResourceType, Offset, Aml1Length, Aml2Length);
745 /* Check for descriptor byte match */
747 else if (memcmp (Aml1, Aml2, Aml1Length))
750 "**** Data mismatch in descriptor [%.2X] type %2.2X, "
751 "Offset %8.8X ****\n",
752 Count, ResourceType, Offset);
754 for (i = 0; i < Aml1Length; i++)
756 if (Aml1[i] != Aml2[i])
759 "Mismatch at byte offset %.2X: is %2.2X, "
761 i, Aml2[i], Aml1[i]);
766 /* Exit on EndTag descriptor */
768 if (ResourceType == ACPI_RESOURCE_NAME_END_TAG)
773 /* Point to next descriptor in each buffer */
776 Offset += Aml1Length;
783 /*******************************************************************************
785 * FUNCTION: AcpiDmTestResourceConversion
787 * PARAMETERS: Node - Parent device node
788 * Name - resource method name (_CRS)
792 * DESCRIPTION: Compare the original AML with a conversion of the AML to
793 * internal resource list, then back to AML.
795 ******************************************************************************/
798 AcpiDmTestResourceConversion (
799 ACPI_NAMESPACE_NODE *Node,
803 ACPI_BUFFER ReturnBuffer;
804 ACPI_BUFFER ResourceBuffer;
806 ACPI_OBJECT *OriginalAml;
809 AcpiOsPrintf ("Resource Conversion Comparison:\n");
811 NewAml.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
812 ReturnBuffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
813 ResourceBuffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
815 /* Get the original _CRS AML resource template */
817 Status = AcpiEvaluateObject (Node, Name, NULL, &ReturnBuffer);
818 if (ACPI_FAILURE (Status))
820 AcpiOsPrintf ("Could not obtain %s: %s\n",
821 Name, AcpiFormatException (Status));
825 /* Get the AML resource template, converted to internal resource structs */
827 Status = AcpiGetCurrentResources (Node, &ResourceBuffer);
828 if (ACPI_FAILURE (Status))
830 AcpiOsPrintf ("AcpiGetCurrentResources failed: %s\n",
831 AcpiFormatException (Status));
835 /* Convert internal resource list to external AML resource template */
837 Status = AcpiRsCreateAmlResources (&ResourceBuffer, &NewAml);
838 if (ACPI_FAILURE (Status))
840 AcpiOsPrintf ("AcpiRsCreateAmlResources failed: %s\n",
841 AcpiFormatException (Status));
845 /* Compare original AML to the newly created AML resource list */
847 OriginalAml = ReturnBuffer.Pointer;
849 AcpiDmCompareAmlResources (OriginalAml->Buffer.Pointer,
850 (ACPI_RSDESC_SIZE) OriginalAml->Buffer.Length,
851 NewAml.Pointer, (ACPI_RSDESC_SIZE) NewAml.Length);
853 /* Cleanup and exit */
855 ACPI_FREE (NewAml.Pointer);
857 ACPI_FREE (ResourceBuffer.Pointer);
859 ACPI_FREE (ReturnBuffer.Pointer);
864 /*******************************************************************************
866 * FUNCTION: AcpiDbResourceCallback
868 * PARAMETERS: ACPI_WALK_RESOURCE_CALLBACK
872 * DESCRIPTION: Simple callback to exercise AcpiWalkResources and
873 * AcpiWalkResourceBuffer.
875 ******************************************************************************/
878 AcpiDbResourceCallback (
879 ACPI_RESOURCE *Resource,
887 /*******************************************************************************
889 * FUNCTION: AcpiDbDeviceResources
891 * PARAMETERS: ACPI_WALK_CALLBACK
895 * DESCRIPTION: Display the _PRT/_CRS/_PRS resources for a device object.
897 ******************************************************************************/
900 AcpiDbDeviceResources (
901 ACPI_HANDLE ObjHandle,
906 ACPI_NAMESPACE_NODE *Node;
907 ACPI_NAMESPACE_NODE *PrtNode = NULL;
908 ACPI_NAMESPACE_NODE *CrsNode = NULL;
909 ACPI_NAMESPACE_NODE *PrsNode = NULL;
910 ACPI_NAMESPACE_NODE *AeiNode = NULL;
912 ACPI_BUFFER ReturnBuffer;
916 Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, ObjHandle);
917 ParentPath = AcpiNsGetNormalizedPathname (Node, TRUE);
920 return (AE_NO_MEMORY);
923 /* Get handles to the resource methods for this device */
925 (void) AcpiGetHandle (Node, METHOD_NAME__PRT,
926 ACPI_CAST_PTR (ACPI_HANDLE, &PrtNode));
927 (void) AcpiGetHandle (Node, METHOD_NAME__CRS,
928 ACPI_CAST_PTR (ACPI_HANDLE, &CrsNode));
929 (void) AcpiGetHandle (Node, METHOD_NAME__PRS,
930 ACPI_CAST_PTR (ACPI_HANDLE, &PrsNode));
931 (void) AcpiGetHandle (Node, METHOD_NAME__AEI,
932 ACPI_CAST_PTR (ACPI_HANDLE, &AeiNode));
934 if (!PrtNode && !CrsNode && !PrsNode && !AeiNode)
936 goto Cleanup; /* Nothing to do */
939 AcpiOsPrintf ("\nDevice: %s\n", ParentPath);
941 /* Prepare for a return object of arbitrary size */
943 ReturnBuffer.Pointer = AcpiGbl_DbBuffer;
944 ReturnBuffer.Length = ACPI_DEBUG_BUFFER_SIZE;
951 AcpiOsPrintf ("Evaluating _PRT\n");
953 Status = AcpiEvaluateObject (PrtNode, NULL, NULL, &ReturnBuffer);
954 if (ACPI_FAILURE (Status))
956 AcpiOsPrintf ("Could not evaluate _PRT: %s\n",
957 AcpiFormatException (Status));
961 ReturnBuffer.Pointer = AcpiGbl_DbBuffer;
962 ReturnBuffer.Length = ACPI_DEBUG_BUFFER_SIZE;
964 Status = AcpiGetIrqRoutingTable (Node, &ReturnBuffer);
965 if (ACPI_FAILURE (Status))
967 AcpiOsPrintf ("GetIrqRoutingTable failed: %s\n",
968 AcpiFormatException (Status));
972 AcpiRsDumpIrqList (ACPI_CAST_PTR (UINT8, AcpiGbl_DbBuffer));
981 AcpiOsPrintf ("Evaluating _CRS\n");
983 ReturnBuffer.Pointer = AcpiGbl_DbBuffer;
984 ReturnBuffer.Length = ACPI_DEBUG_BUFFER_SIZE;
986 Status = AcpiEvaluateObject (CrsNode, NULL, NULL, &ReturnBuffer);
987 if (ACPI_FAILURE (Status))
989 AcpiOsPrintf ("Could not evaluate _CRS: %s\n",
990 AcpiFormatException (Status));
994 /* This code exercises the AcpiWalkResources interface */
996 Status = AcpiWalkResources (Node, METHOD_NAME__CRS,
997 AcpiDbResourceCallback, NULL);
998 if (ACPI_FAILURE (Status))
1000 AcpiOsPrintf ("AcpiWalkResources failed: %s\n",
1001 AcpiFormatException (Status));
1005 /* Get the _CRS resource list (test ALLOCATE buffer) */
1007 ReturnBuffer.Pointer = NULL;
1008 ReturnBuffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
1010 Status = AcpiGetCurrentResources (Node, &ReturnBuffer);
1011 if (ACPI_FAILURE (Status))
1013 AcpiOsPrintf ("AcpiGetCurrentResources failed: %s\n",
1014 AcpiFormatException (Status));
1018 /* This code exercises the AcpiWalkResourceBuffer interface */
1020 Status = AcpiWalkResourceBuffer (&ReturnBuffer,
1021 AcpiDbResourceCallback, NULL);
1022 if (ACPI_FAILURE (Status))
1024 AcpiOsPrintf ("AcpiWalkResourceBuffer failed: %s\n",
1025 AcpiFormatException (Status));
1029 /* Dump the _CRS resource list */
1031 AcpiRsDumpResourceList (ACPI_CAST_PTR (ACPI_RESOURCE,
1032 ReturnBuffer.Pointer));
1035 * Perform comparison of original AML to newly created AML. This
1036 * tests both the AML->Resource conversion and the Resource->AML
1039 (void) AcpiDmTestResourceConversion (Node, METHOD_NAME__CRS);
1041 /* Execute _SRS with the resource list */
1043 AcpiOsPrintf ("Evaluating _SRS\n");
1045 Status = AcpiSetCurrentResources (Node, &ReturnBuffer);
1046 if (ACPI_FAILURE (Status))
1048 AcpiOsPrintf ("AcpiSetCurrentResources failed: %s\n",
1049 AcpiFormatException (Status));
1054 ACPI_FREE (ReturnBuffer.Pointer);
1063 AcpiOsPrintf ("Evaluating _PRS\n");
1065 ReturnBuffer.Pointer = AcpiGbl_DbBuffer;
1066 ReturnBuffer.Length = ACPI_DEBUG_BUFFER_SIZE;
1068 Status = AcpiEvaluateObject (PrsNode, NULL, NULL, &ReturnBuffer);
1069 if (ACPI_FAILURE (Status))
1071 AcpiOsPrintf ("Could not evaluate _PRS: %s\n",
1072 AcpiFormatException (Status));
1076 ReturnBuffer.Pointer = AcpiGbl_DbBuffer;
1077 ReturnBuffer.Length = ACPI_DEBUG_BUFFER_SIZE;
1079 Status = AcpiGetPossibleResources (Node, &ReturnBuffer);
1080 if (ACPI_FAILURE (Status))
1082 AcpiOsPrintf ("AcpiGetPossibleResources failed: %s\n",
1083 AcpiFormatException (Status));
1087 AcpiRsDumpResourceList (ACPI_CAST_PTR (
1088 ACPI_RESOURCE, AcpiGbl_DbBuffer));
1097 AcpiOsPrintf ("Evaluating _AEI\n");
1099 ReturnBuffer.Pointer = AcpiGbl_DbBuffer;
1100 ReturnBuffer.Length = ACPI_DEBUG_BUFFER_SIZE;
1102 Status = AcpiEvaluateObject (AeiNode, NULL, NULL, &ReturnBuffer);
1103 if (ACPI_FAILURE (Status))
1105 AcpiOsPrintf ("Could not evaluate _AEI: %s\n",
1106 AcpiFormatException (Status));
1110 ReturnBuffer.Pointer = AcpiGbl_DbBuffer;
1111 ReturnBuffer.Length = ACPI_DEBUG_BUFFER_SIZE;
1113 Status = AcpiGetEventResources (Node, &ReturnBuffer);
1114 if (ACPI_FAILURE (Status))
1116 AcpiOsPrintf ("AcpiGetEventResources failed: %s\n",
1117 AcpiFormatException (Status));
1121 AcpiRsDumpResourceList (ACPI_CAST_PTR (
1122 ACPI_RESOURCE, AcpiGbl_DbBuffer));
1127 ACPI_FREE (ParentPath);
1132 /*******************************************************************************
1134 * FUNCTION: AcpiDbDisplayResources
1136 * PARAMETERS: ObjectArg - String object name or object pointer.
1137 * NULL or "*" means "display resources for
1142 * DESCRIPTION: Display the resource objects associated with a device.
1144 ******************************************************************************/
1147 AcpiDbDisplayResources (
1150 ACPI_NAMESPACE_NODE *Node;
1153 AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT);
1154 AcpiDbgLevel |= ACPI_LV_RESOURCES;
1156 /* Asterisk means "display resources for all devices" */
1158 if (!ObjectArg || (!strcmp (ObjectArg, "*")))
1160 (void) AcpiWalkNamespace (ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
1161 ACPI_UINT32_MAX, AcpiDbDeviceResources, NULL, NULL, NULL);
1165 /* Convert string to object pointer */
1167 Node = AcpiDbConvertToNode (ObjectArg);
1170 if (Node->Type != ACPI_TYPE_DEVICE)
1173 "%4.4s: Name is not a device object (%s)\n",
1174 Node->Name.Ascii, AcpiUtGetTypeName (Node->Type));
1178 (void) AcpiDbDeviceResources (Node, 0, NULL, NULL);
1183 AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT);
1187 #if (!ACPI_REDUCED_HARDWARE)
1188 /*******************************************************************************
1190 * FUNCTION: AcpiDbGenerateGpe
1192 * PARAMETERS: GpeArg - Raw GPE number, ascii string
1193 * BlockArg - GPE block number, ascii string
1194 * 0 or 1 for FADT GPE blocks
1198 * DESCRIPTION: Simulate firing of a GPE
1200 ******************************************************************************/
1207 UINT32 BlockNumber = 0;
1209 ACPI_GPE_EVENT_INFO *GpeEventInfo;
1212 GpeNumber = strtoul (GpeArg, NULL, 0);
1215 * If no block arg, or block arg == 0 or 1, use the FADT-defined
1220 BlockNumber = strtoul (BlockArg, NULL, 0);
1221 if (BlockNumber == 1)
1227 GpeEventInfo = AcpiEvGetGpeEventInfo (
1228 ACPI_TO_POINTER (BlockNumber), GpeNumber);
1231 AcpiOsPrintf ("Invalid GPE\n");
1235 (void) AcpiEvGpeDispatch (NULL, GpeEventInfo, GpeNumber);
1239 /*******************************************************************************
1241 * FUNCTION: AcpiDbGenerateSci
1247 * DESCRIPTION: Simulate an SCI -- just call the SCI dispatch.
1249 ******************************************************************************/
1255 AcpiEvSciDispatch ();
1258 #endif /* !ACPI_REDUCED_HARDWARE */
1261 /*******************************************************************************
1263 * FUNCTION: AcpiDbTrace
1265 * PARAMETERS: EnableArg - ENABLE/AML to enable tracer
1266 * DISABLE to disable tracer
1267 * MethodArg - Method to trace
1268 * OnceArg - Whether trace once
1272 * DESCRIPTION: Control method tracing facility
1274 ******************************************************************************/
1282 UINT32 DebugLevel = 0;
1283 UINT32 DebugLayer = 0;
1287 AcpiUtStrupr (EnableArg);
1288 AcpiUtStrupr (OnceArg);
1292 if (AcpiDbTraceMethodName)
1294 ACPI_FREE (AcpiDbTraceMethodName);
1295 AcpiDbTraceMethodName = NULL;
1298 AcpiDbTraceMethodName = ACPI_ALLOCATE (strlen (MethodArg) + 1);
1299 if (!AcpiDbTraceMethodName)
1301 AcpiOsPrintf ("Failed to allocate method name (%s)\n",
1306 strcpy (AcpiDbTraceMethodName, MethodArg);
1309 if (!strcmp (EnableArg, "ENABLE") ||
1310 !strcmp (EnableArg, "METHOD") ||
1311 !strcmp (EnableArg, "OPCODE"))
1313 if (!strcmp (EnableArg, "ENABLE"))
1315 /* Inherit current console settings */
1317 DebugLevel = AcpiGbl_DbConsoleDebugLevel;
1318 DebugLayer = AcpiDbgLayer;
1322 /* Restrict console output to trace points only */
1324 DebugLevel = ACPI_LV_TRACE_POINT;
1325 DebugLayer = ACPI_EXECUTER;
1328 Flags = ACPI_TRACE_ENABLED;
1330 if (!strcmp (EnableArg, "OPCODE"))
1332 Flags |= ACPI_TRACE_OPCODE;
1335 if (OnceArg && !strcmp (OnceArg, "ONCE"))
1337 Flags |= ACPI_TRACE_ONESHOT;
1341 (void) AcpiDebugTrace (AcpiDbTraceMethodName,
1342 DebugLevel, DebugLayer, Flags);
1345 #endif /* ACPI_DEBUGGER */