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.
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;
91 /*******************************************************************************
93 * FUNCTION: AcpiDbConvertToNode
95 * PARAMETERS: InString - String to convert
97 * RETURN: Pointer to a NS node
99 * DESCRIPTION: Convert a string to a valid NS pointer. Handles numeric or
100 * alphanumeric strings.
102 ******************************************************************************/
104 ACPI_NAMESPACE_NODE *
105 AcpiDbConvertToNode (
108 ACPI_NAMESPACE_NODE *Node;
112 if ((*InString >= 0x30) && (*InString <= 0x39))
114 /* Numeric argument, convert */
116 Address = strtoul (InString, NULL, 16);
117 Node = ACPI_TO_POINTER (Address);
118 if (!AcpiOsReadable (Node, sizeof (ACPI_NAMESPACE_NODE)))
120 AcpiOsPrintf ("Address %p is invalid",
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);
143 AcpiOsPrintf ("Could not find [%s] in namespace, defaulting to root node\n",
145 Node = AcpiGbl_RootNode;
153 /*******************************************************************************
155 * FUNCTION: AcpiDbSleep
157 * PARAMETERS: ObjectArg - Desired sleep state (0-5). NULL means
158 * invoke all possible sleep states.
162 * DESCRIPTION: Simulate sleep/wake sequences
164 ******************************************************************************/
174 ACPI_FUNCTION_TRACE (AcpiDbSleep);
177 /* Null input (no arguments) means to invoke all sleep states */
181 AcpiOsPrintf ("Invoking all possible sleep states, 0-%d\n",
184 for (i = 0; i <= ACPI_S_STATES_MAX; i++)
186 AcpiDbDoOneSleepState ((UINT8) i);
189 return_ACPI_STATUS (AE_OK);
192 /* Convert argument to binary and invoke the sleep state */
194 SleepState = (UINT8) strtoul (ObjectArg, NULL, 0);
195 AcpiDbDoOneSleepState (SleepState);
196 return_ACPI_STATUS (AE_OK);
200 /*******************************************************************************
202 * FUNCTION: AcpiDbDoOneSleepState
204 * PARAMETERS: SleepState - Desired sleep state (0-5)
208 * DESCRIPTION: Simulate a sleep/wake sequence
210 ******************************************************************************/
213 AcpiDbDoOneSleepState (
221 /* Validate parameter */
223 if (SleepState > ACPI_S_STATES_MAX)
225 AcpiOsPrintf ("Sleep state %d out of range (%d max)\n",
226 SleepState, ACPI_S_STATES_MAX);
230 AcpiOsPrintf ("\n---- Invoking sleep state S%d (%s):\n",
231 SleepState, AcpiGbl_SleepStateNames[SleepState]);
233 /* Get the values for the sleep type registers (for display only) */
235 Status = AcpiGetSleepTypeData (SleepState, &SleepTypeA, &SleepTypeB);
236 if (ACPI_FAILURE (Status))
238 AcpiOsPrintf ("Could not evaluate [%s] method, %s\n",
239 AcpiGbl_SleepStateNames[SleepState],
240 AcpiFormatException (Status));
245 "Register values for sleep state S%d: Sleep-A: %.2X, Sleep-B: %.2X\n",
246 SleepState, SleepTypeA, SleepTypeB);
248 /* Invoke the various sleep/wake interfaces */
250 AcpiOsPrintf ("**** Sleep: Prepare to sleep (S%d) ****\n",
252 Status = AcpiEnterSleepStatePrep (SleepState);
253 if (ACPI_FAILURE (Status))
258 AcpiOsPrintf ("**** Sleep: Going to sleep (S%d) ****\n",
260 Status = AcpiEnterSleepState (SleepState);
261 if (ACPI_FAILURE (Status))
266 AcpiOsPrintf ("**** Wake: Prepare to return from sleep (S%d) ****\n",
268 Status = AcpiLeaveSleepStatePrep (SleepState);
269 if (ACPI_FAILURE (Status))
274 AcpiOsPrintf ("**** Wake: Return from sleep (S%d) ****\n",
276 Status = AcpiLeaveSleepState (SleepState);
277 if (ACPI_FAILURE (Status))
286 ACPI_EXCEPTION ((AE_INFO, Status, "During invocation of sleep state S%d",
291 /*******************************************************************************
293 * FUNCTION: AcpiDbDisplayLocks
299 * DESCRIPTION: Display information about internal mutexes.
301 ******************************************************************************/
310 for (i = 0; i < ACPI_MAX_MUTEX; i++)
312 AcpiOsPrintf ("%26s : %s\n", AcpiUtGetMutexName (i),
313 AcpiGbl_MutexInfo[i].ThreadId == ACPI_MUTEX_NOT_ACQUIRED
314 ? "Locked" : "Unlocked");
319 /*******************************************************************************
321 * FUNCTION: AcpiDbDisplayTableInfo
323 * PARAMETERS: TableArg - Name of table to be displayed
327 * DESCRIPTION: Display information about loaded tables. Current
328 * implementation displays all loaded tables.
330 ******************************************************************************/
333 AcpiDbDisplayTableInfo (
337 ACPI_TABLE_DESC *TableDesc;
343 AcpiOsPrintf ("Idx ID Status Type TableHeader (Sig, Address, Length)\n");
345 /* Walk the entire root table list */
347 for (i = 0; i < AcpiGbl_RootTableList.CurrentTableCount; i++)
349 TableDesc = &AcpiGbl_RootTableList.Tables[i];
351 /* Index and Table ID */
353 AcpiOsPrintf ("%3u %.2u ", i, TableDesc->OwnerId);
355 /* Decode the table flags */
357 if (!(TableDesc->Flags & ACPI_TABLE_IS_LOADED))
359 AcpiOsPrintf ("NotLoaded ");
363 AcpiOsPrintf (" Loaded ");
366 switch (TableDesc->Flags & ACPI_TABLE_ORIGIN_MASK)
368 case ACPI_TABLE_ORIGIN_EXTERNAL_VIRTUAL:
370 AcpiOsPrintf ("External/virtual ");
373 case ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL:
375 AcpiOsPrintf ("Internal/physical ");
378 case ACPI_TABLE_ORIGIN_INTERNAL_VIRTUAL:
380 AcpiOsPrintf ("Internal/virtual ");
385 AcpiOsPrintf ("INVALID TYPE ");
389 /* Make sure that the table is mapped */
391 Status = AcpiTbValidateTable (TableDesc);
392 if (ACPI_FAILURE (Status))
397 /* Dump the table header */
399 if (TableDesc->Pointer)
401 AcpiTbPrintTableHeader (TableDesc->Address, TableDesc->Pointer);
405 /* If the pointer is null, the table has been unloaded */
407 ACPI_INFO ((AE_INFO, "%4.4s - Table has been unloaded",
408 TableDesc->Signature.Ascii));
414 /*******************************************************************************
416 * FUNCTION: AcpiDbUnloadAcpiTable
418 * PARAMETERS: ObjectName - Namespace pathname for an object that
419 * is owned by the table to be unloaded
423 * DESCRIPTION: Unload an ACPI table, via any namespace node that is owned
426 ******************************************************************************/
429 AcpiDbUnloadAcpiTable (
432 ACPI_NAMESPACE_NODE *Node;
436 /* Translate name to an Named object */
438 Node = AcpiDbConvertToNode (ObjectName);
444 Status = AcpiUnloadParentTable (ACPI_CAST_PTR (ACPI_HANDLE, Node));
445 if (ACPI_SUCCESS (Status))
447 AcpiOsPrintf ("Parent of [%s] (%p) unloaded and uninstalled\n",
452 AcpiOsPrintf ("%s, while unloading parent table of [%s]\n",
453 AcpiFormatException (Status), ObjectName);
458 /*******************************************************************************
460 * FUNCTION: AcpiDbSendNotify
462 * PARAMETERS: Name - Name of ACPI object where to send notify
463 * Value - Value of the notify to send.
467 * DESCRIPTION: Send an ACPI notification. The value specified is sent to the
468 * named object as an ACPI notify.
470 ******************************************************************************/
477 ACPI_NAMESPACE_NODE *Node;
481 /* Translate name to an Named object */
483 Node = AcpiDbConvertToNode (Name);
489 /* Dispatch the notify if legal */
491 if (AcpiEvIsNotifyObject (Node))
493 Status = AcpiEvQueueNotifyRequest (Node, Value);
494 if (ACPI_FAILURE (Status))
496 AcpiOsPrintf ("Could not queue notify\n");
502 "Named object [%4.4s] Type %s, must be Device/Thermal/Processor type\n",
503 AcpiUtGetNodeName (Node), AcpiUtGetTypeName (Node->Type));
508 /*******************************************************************************
510 * FUNCTION: AcpiDbDisplayInterfaces
512 * PARAMETERS: ActionArg - Null, "install", or "remove"
513 * InterfaceNameArg - Name for install/remove options
517 * DESCRIPTION: Display or modify the global _OSI interface list
519 ******************************************************************************/
522 AcpiDbDisplayInterfaces (
524 char *InterfaceNameArg)
526 ACPI_INTERFACE_INFO *NextInterface;
531 /* If no arguments, just display current interface list */
535 (void) AcpiOsAcquireMutex (AcpiGbl_OsiMutex,
538 NextInterface = AcpiGbl_SupportedInterfaces;
539 while (NextInterface)
541 if (!(NextInterface->Flags & ACPI_OSI_INVALID))
543 AcpiOsPrintf ("%s\n", NextInterface->Name);
545 NextInterface = NextInterface->Next;
548 AcpiOsReleaseMutex (AcpiGbl_OsiMutex);
552 /* If ActionArg exists, so must InterfaceNameArg */
554 if (!InterfaceNameArg)
556 AcpiOsPrintf ("Missing Interface Name argument\n");
560 /* Uppercase the action for match below */
562 AcpiUtStrupr (ActionArg);
564 /* Install - install an interface */
566 SubString = strstr ("INSTALL", ActionArg);
569 Status = AcpiInstallInterface (InterfaceNameArg);
570 if (ACPI_FAILURE (Status))
572 AcpiOsPrintf ("%s, while installing \"%s\"\n",
573 AcpiFormatException (Status), InterfaceNameArg);
578 /* Remove - remove an interface */
580 SubString = strstr ("REMOVE", ActionArg);
583 Status = AcpiRemoveInterface (InterfaceNameArg);
584 if (ACPI_FAILURE (Status))
586 AcpiOsPrintf ("%s, while removing \"%s\"\n",
587 AcpiFormatException (Status), InterfaceNameArg);
592 /* Invalid ActionArg */
594 AcpiOsPrintf ("Invalid action argument: %s\n", ActionArg);
599 /*******************************************************************************
601 * FUNCTION: AcpiDbDisplayTemplate
603 * PARAMETERS: BufferArg - Buffer name or address
607 * DESCRIPTION: Dump a buffer that contains a resource template
609 ******************************************************************************/
612 AcpiDbDisplayTemplate (
615 ACPI_NAMESPACE_NODE *Node;
617 ACPI_BUFFER ReturnBuffer;
620 /* Translate BufferArg to an Named object */
622 Node = AcpiDbConvertToNode (BufferArg);
623 if (!Node || (Node == AcpiGbl_RootNode))
625 AcpiOsPrintf ("Invalid argument: %s\n", BufferArg);
629 /* We must have a buffer object */
631 if (Node->Type != ACPI_TYPE_BUFFER)
633 AcpiOsPrintf ("Not a Buffer object, cannot be a template: %s\n",
638 ReturnBuffer.Length = ACPI_DEBUG_BUFFER_SIZE;
639 ReturnBuffer.Pointer = AcpiGbl_DbBuffer;
641 /* Attempt to convert the raw buffer to a resource list */
643 Status = AcpiRsCreateResourceList (Node->Object, &ReturnBuffer);
645 AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT);
646 AcpiDbgLevel |= ACPI_LV_RESOURCES;
648 if (ACPI_FAILURE (Status))
650 AcpiOsPrintf ("Could not convert Buffer to a resource list: %s, %s\n",
651 BufferArg, AcpiFormatException (Status));
655 /* Now we can dump the resource list */
657 AcpiRsDumpResourceList (ACPI_CAST_PTR (ACPI_RESOURCE,
658 ReturnBuffer.Pointer));
661 AcpiOsPrintf ("\nRaw data buffer:\n");
662 AcpiUtDebugDumpBuffer ((UINT8 *) Node->Object->Buffer.Pointer,
663 Node->Object->Buffer.Length,
664 DB_BYTE_DISPLAY, ACPI_UINT32_MAX);
666 AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT);
671 /*******************************************************************************
673 * FUNCTION: AcpiDmCompareAmlResources
675 * PARAMETERS: Aml1Buffer - Contains first resource list
676 * Aml1BufferLength - Length of first resource list
677 * Aml2Buffer - Contains second resource list
678 * Aml2BufferLength - Length of second resource list
682 * DESCRIPTION: Compare two AML resource lists, descriptor by descriptor (in
683 * order to isolate a miscompare to an individual resource)
685 ******************************************************************************/
688 AcpiDmCompareAmlResources (
690 ACPI_RSDESC_SIZE Aml1BufferLength,
692 ACPI_RSDESC_SIZE Aml2BufferLength)
698 ACPI_RSDESC_SIZE Aml1Length;
699 ACPI_RSDESC_SIZE Aml2Length;
700 ACPI_RSDESC_SIZE Offset = 0;
706 /* Compare overall buffer sizes (may be different due to size rounding) */
708 if (Aml1BufferLength != Aml2BufferLength)
711 "**** Buffer length mismatch in converted AML: Original %X, New %X ****\n",
712 Aml1BufferLength, Aml2BufferLength);
717 Aml1End = Aml1Buffer + Aml1BufferLength;
718 Aml2End = Aml2Buffer + Aml2BufferLength;
720 /* Walk the descriptor lists, comparing each descriptor */
722 while ((Aml1 < Aml1End) && (Aml2 < Aml2End))
724 /* Get the lengths of each descriptor */
726 Aml1Length = AcpiUtGetDescriptorLength (Aml1);
727 Aml2Length = AcpiUtGetDescriptorLength (Aml2);
728 ResourceType = AcpiUtGetResourceType (Aml1);
730 /* Check for descriptor length match */
732 if (Aml1Length != Aml2Length)
735 "**** Length mismatch in descriptor [%.2X] type %2.2X, Offset %8.8X Len1 %X, Len2 %X ****\n",
736 Count, ResourceType, Offset, Aml1Length, Aml2Length);
739 /* Check for descriptor byte match */
741 else if (memcmp (Aml1, Aml2, Aml1Length))
744 "**** Data mismatch in descriptor [%.2X] type %2.2X, Offset %8.8X ****\n",
745 Count, ResourceType, Offset);
747 for (i = 0; i < Aml1Length; i++)
749 if (Aml1[i] != Aml2[i])
752 "Mismatch at byte offset %.2X: is %2.2X, should be %2.2X\n",
753 i, Aml2[i], Aml1[i]);
758 /* Exit on EndTag descriptor */
760 if (ResourceType == ACPI_RESOURCE_NAME_END_TAG)
765 /* Point to next descriptor in each buffer */
768 Offset += Aml1Length;
775 /*******************************************************************************
777 * FUNCTION: AcpiDmTestResourceConversion
779 * PARAMETERS: Node - Parent device node
780 * Name - resource method name (_CRS)
784 * DESCRIPTION: Compare the original AML with a conversion of the AML to
785 * internal resource list, then back to AML.
787 ******************************************************************************/
790 AcpiDmTestResourceConversion (
791 ACPI_NAMESPACE_NODE *Node,
795 ACPI_BUFFER ReturnBuffer;
796 ACPI_BUFFER ResourceBuffer;
798 ACPI_OBJECT *OriginalAml;
801 AcpiOsPrintf ("Resource Conversion Comparison:\n");
803 NewAml.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
804 ReturnBuffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
805 ResourceBuffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
807 /* Get the original _CRS AML resource template */
809 Status = AcpiEvaluateObject (Node, Name, NULL, &ReturnBuffer);
810 if (ACPI_FAILURE (Status))
812 AcpiOsPrintf ("Could not obtain %s: %s\n",
813 Name, AcpiFormatException (Status));
817 /* Get the AML resource template, converted to internal resource structs */
819 Status = AcpiGetCurrentResources (Node, &ResourceBuffer);
820 if (ACPI_FAILURE (Status))
822 AcpiOsPrintf ("AcpiGetCurrentResources failed: %s\n",
823 AcpiFormatException (Status));
827 /* Convert internal resource list to external AML resource template */
829 Status = AcpiRsCreateAmlResources (&ResourceBuffer, &NewAml);
830 if (ACPI_FAILURE (Status))
832 AcpiOsPrintf ("AcpiRsCreateAmlResources failed: %s\n",
833 AcpiFormatException (Status));
837 /* Compare original AML to the newly created AML resource list */
839 OriginalAml = ReturnBuffer.Pointer;
841 AcpiDmCompareAmlResources (OriginalAml->Buffer.Pointer,
842 (ACPI_RSDESC_SIZE) OriginalAml->Buffer.Length,
843 NewAml.Pointer, (ACPI_RSDESC_SIZE) NewAml.Length);
845 /* Cleanup and exit */
847 ACPI_FREE (NewAml.Pointer);
849 ACPI_FREE (ResourceBuffer.Pointer);
851 ACPI_FREE (ReturnBuffer.Pointer);
856 /*******************************************************************************
858 * FUNCTION: AcpiDbResourceCallback
860 * PARAMETERS: ACPI_WALK_RESOURCE_CALLBACK
864 * DESCRIPTION: Simple callback to exercise AcpiWalkResources and
865 * AcpiWalkResourceBuffer.
867 ******************************************************************************/
870 AcpiDbResourceCallback (
871 ACPI_RESOURCE *Resource,
879 /*******************************************************************************
881 * FUNCTION: AcpiDbDeviceResources
883 * PARAMETERS: ACPI_WALK_CALLBACK
887 * DESCRIPTION: Display the _PRT/_CRS/_PRS resources for a device object.
889 ******************************************************************************/
892 AcpiDbDeviceResources (
893 ACPI_HANDLE ObjHandle,
898 ACPI_NAMESPACE_NODE *Node;
899 ACPI_NAMESPACE_NODE *PrtNode = NULL;
900 ACPI_NAMESPACE_NODE *CrsNode = NULL;
901 ACPI_NAMESPACE_NODE *PrsNode = NULL;
902 ACPI_NAMESPACE_NODE *AeiNode = NULL;
904 ACPI_BUFFER ReturnBuffer;
908 Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, ObjHandle);
909 ParentPath = AcpiNsGetExternalPathname (Node);
912 return (AE_NO_MEMORY);
915 /* Get handles to the resource methods for this device */
917 (void) AcpiGetHandle (Node, METHOD_NAME__PRT, ACPI_CAST_PTR (ACPI_HANDLE, &PrtNode));
918 (void) AcpiGetHandle (Node, METHOD_NAME__CRS, ACPI_CAST_PTR (ACPI_HANDLE, &CrsNode));
919 (void) AcpiGetHandle (Node, METHOD_NAME__PRS, ACPI_CAST_PTR (ACPI_HANDLE, &PrsNode));
920 (void) AcpiGetHandle (Node, METHOD_NAME__AEI, ACPI_CAST_PTR (ACPI_HANDLE, &AeiNode));
921 if (!PrtNode && !CrsNode && !PrsNode && !AeiNode)
923 goto Cleanup; /* Nothing to do */
926 AcpiOsPrintf ("\nDevice: %s\n", ParentPath);
928 /* Prepare for a return object of arbitrary size */
930 ReturnBuffer.Pointer = AcpiGbl_DbBuffer;
931 ReturnBuffer.Length = ACPI_DEBUG_BUFFER_SIZE;
938 AcpiOsPrintf ("Evaluating _PRT\n");
940 Status = AcpiEvaluateObject (PrtNode, NULL, NULL, &ReturnBuffer);
941 if (ACPI_FAILURE (Status))
943 AcpiOsPrintf ("Could not evaluate _PRT: %s\n",
944 AcpiFormatException (Status));
948 ReturnBuffer.Pointer = AcpiGbl_DbBuffer;
949 ReturnBuffer.Length = ACPI_DEBUG_BUFFER_SIZE;
951 Status = AcpiGetIrqRoutingTable (Node, &ReturnBuffer);
952 if (ACPI_FAILURE (Status))
954 AcpiOsPrintf ("GetIrqRoutingTable failed: %s\n",
955 AcpiFormatException (Status));
959 AcpiRsDumpIrqList (ACPI_CAST_PTR (UINT8, AcpiGbl_DbBuffer));
968 AcpiOsPrintf ("Evaluating _CRS\n");
970 ReturnBuffer.Pointer = AcpiGbl_DbBuffer;
971 ReturnBuffer.Length = ACPI_DEBUG_BUFFER_SIZE;
973 Status = AcpiEvaluateObject (CrsNode, NULL, NULL, &ReturnBuffer);
974 if (ACPI_FAILURE (Status))
976 AcpiOsPrintf ("Could not evaluate _CRS: %s\n",
977 AcpiFormatException (Status));
981 /* This code exercises the AcpiWalkResources interface */
983 Status = AcpiWalkResources (Node, METHOD_NAME__CRS,
984 AcpiDbResourceCallback, NULL);
985 if (ACPI_FAILURE (Status))
987 AcpiOsPrintf ("AcpiWalkResources failed: %s\n",
988 AcpiFormatException (Status));
992 /* Get the _CRS resource list (test ALLOCATE buffer) */
994 ReturnBuffer.Pointer = NULL;
995 ReturnBuffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
997 Status = AcpiGetCurrentResources (Node, &ReturnBuffer);
998 if (ACPI_FAILURE (Status))
1000 AcpiOsPrintf ("AcpiGetCurrentResources failed: %s\n",
1001 AcpiFormatException (Status));
1005 /* This code exercises the AcpiWalkResourceBuffer interface */
1007 Status = AcpiWalkResourceBuffer (&ReturnBuffer,
1008 AcpiDbResourceCallback, NULL);
1009 if (ACPI_FAILURE (Status))
1011 AcpiOsPrintf ("AcpiWalkResourceBuffer failed: %s\n",
1012 AcpiFormatException (Status));
1016 /* Dump the _CRS resource list */
1018 AcpiRsDumpResourceList (ACPI_CAST_PTR (ACPI_RESOURCE,
1019 ReturnBuffer.Pointer));
1022 * Perform comparison of original AML to newly created AML. This
1023 * tests both the AML->Resource conversion and the Resource->AML
1026 (void) AcpiDmTestResourceConversion (Node, METHOD_NAME__CRS);
1028 /* Execute _SRS with the resource list */
1030 AcpiOsPrintf ("Evaluating _SRS\n");
1032 Status = AcpiSetCurrentResources (Node, &ReturnBuffer);
1033 if (ACPI_FAILURE (Status))
1035 AcpiOsPrintf ("AcpiSetCurrentResources failed: %s\n",
1036 AcpiFormatException (Status));
1041 ACPI_FREE (ReturnBuffer.Pointer);
1050 AcpiOsPrintf ("Evaluating _PRS\n");
1052 ReturnBuffer.Pointer = AcpiGbl_DbBuffer;
1053 ReturnBuffer.Length = ACPI_DEBUG_BUFFER_SIZE;
1055 Status = AcpiEvaluateObject (PrsNode, NULL, NULL, &ReturnBuffer);
1056 if (ACPI_FAILURE (Status))
1058 AcpiOsPrintf ("Could not evaluate _PRS: %s\n",
1059 AcpiFormatException (Status));
1063 ReturnBuffer.Pointer = AcpiGbl_DbBuffer;
1064 ReturnBuffer.Length = ACPI_DEBUG_BUFFER_SIZE;
1066 Status = AcpiGetPossibleResources (Node, &ReturnBuffer);
1067 if (ACPI_FAILURE (Status))
1069 AcpiOsPrintf ("AcpiGetPossibleResources failed: %s\n",
1070 AcpiFormatException (Status));
1074 AcpiRsDumpResourceList (ACPI_CAST_PTR (ACPI_RESOURCE, AcpiGbl_DbBuffer));
1083 AcpiOsPrintf ("Evaluating _AEI\n");
1085 ReturnBuffer.Pointer = AcpiGbl_DbBuffer;
1086 ReturnBuffer.Length = ACPI_DEBUG_BUFFER_SIZE;
1088 Status = AcpiEvaluateObject (AeiNode, NULL, NULL, &ReturnBuffer);
1089 if (ACPI_FAILURE (Status))
1091 AcpiOsPrintf ("Could not evaluate _AEI: %s\n",
1092 AcpiFormatException (Status));
1096 ReturnBuffer.Pointer = AcpiGbl_DbBuffer;
1097 ReturnBuffer.Length = ACPI_DEBUG_BUFFER_SIZE;
1099 Status = AcpiGetEventResources (Node, &ReturnBuffer);
1100 if (ACPI_FAILURE (Status))
1102 AcpiOsPrintf ("AcpiGetEventResources failed: %s\n",
1103 AcpiFormatException (Status));
1107 AcpiRsDumpResourceList (ACPI_CAST_PTR (ACPI_RESOURCE, AcpiGbl_DbBuffer));
1112 ACPI_FREE (ParentPath);
1117 /*******************************************************************************
1119 * FUNCTION: AcpiDbDisplayResources
1121 * PARAMETERS: ObjectArg - String object name or object pointer.
1122 * NULL or "*" means "display resources for
1127 * DESCRIPTION: Display the resource objects associated with a device.
1129 ******************************************************************************/
1132 AcpiDbDisplayResources (
1135 ACPI_NAMESPACE_NODE *Node;
1138 AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT);
1139 AcpiDbgLevel |= ACPI_LV_RESOURCES;
1141 /* Asterisk means "display resources for all devices" */
1143 if (!ObjectArg || (!strcmp (ObjectArg, "*")))
1145 (void) AcpiWalkNamespace (ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
1146 ACPI_UINT32_MAX, AcpiDbDeviceResources, NULL, NULL, NULL);
1150 /* Convert string to object pointer */
1152 Node = AcpiDbConvertToNode (ObjectArg);
1155 if (Node->Type != ACPI_TYPE_DEVICE)
1157 AcpiOsPrintf ("%4.4s: Name is not a device object (%s)\n",
1158 Node->Name.Ascii, AcpiUtGetTypeName (Node->Type));
1162 (void) AcpiDbDeviceResources (Node, 0, NULL, NULL);
1167 AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT);
1171 #if (!ACPI_REDUCED_HARDWARE)
1172 /*******************************************************************************
1174 * FUNCTION: AcpiDbGenerateGpe
1176 * PARAMETERS: GpeArg - Raw GPE number, ascii string
1177 * BlockArg - GPE block number, ascii string
1178 * 0 or 1 for FADT GPE blocks
1182 * DESCRIPTION: Simulate firing of a GPE
1184 ******************************************************************************/
1191 UINT32 BlockNumber = 0;
1193 ACPI_GPE_EVENT_INFO *GpeEventInfo;
1196 GpeNumber = strtoul (GpeArg, NULL, 0);
1199 * If no block arg, or block arg == 0 or 1, use the FADT-defined
1204 BlockNumber = strtoul (BlockArg, NULL, 0);
1205 if (BlockNumber == 1)
1211 GpeEventInfo = AcpiEvGetGpeEventInfo (ACPI_TO_POINTER (BlockNumber),
1215 AcpiOsPrintf ("Invalid GPE\n");
1219 (void) AcpiEvGpeDispatch (NULL, GpeEventInfo, GpeNumber);
1226 AcpiEvSciDispatch ();
1229 #endif /* !ACPI_REDUCED_HARDWARE */
1232 /*******************************************************************************
1234 * FUNCTION: AcpiDbTrace
1236 * PARAMETERS: EnableArg - ENABLE/AML to enable tracer
1237 * DISABLE to disable tracer
1238 * MethodArg - Method to trace
1239 * OnceArg - Whether trace once
1243 * DESCRIPTION: Control method tracing facility
1245 ******************************************************************************/
1253 UINT32 DebugLevel = 0;
1254 UINT32 DebugLayer = 0;
1260 AcpiUtStrupr (EnableArg);
1264 AcpiUtStrupr (OnceArg);
1268 if (AcpiDbTraceMethodName)
1270 ACPI_FREE (AcpiDbTraceMethodName);
1271 AcpiDbTraceMethodName = NULL;
1273 AcpiDbTraceMethodName = ACPI_ALLOCATE (strlen (MethodArg) + 1);
1274 if (!AcpiDbTraceMethodName)
1276 AcpiOsPrintf ("Failed to allocate method name (%s)\n", MethodArg);
1279 strcpy (AcpiDbTraceMethodName, MethodArg);
1281 if (!strcmp (EnableArg, "ENABLE") ||
1282 !strcmp (EnableArg, "METHOD") ||
1283 !strcmp (EnableArg, "OPCODE"))
1285 if (!strcmp (EnableArg, "ENABLE"))
1287 /* Inherit current console settings */
1289 DebugLevel = AcpiGbl_DbConsoleDebugLevel;
1290 DebugLayer = AcpiDbgLayer;
1294 /* Restrict console output to trace points only */
1296 DebugLevel = ACPI_LV_TRACE_POINT;
1297 DebugLayer = ACPI_EXECUTER;
1300 Flags = ACPI_TRACE_ENABLED;
1301 if (!strcmp (EnableArg, "OPCODE"))
1303 Flags |= ACPI_TRACE_OPCODE;
1305 if (OnceArg && !strcmp (OnceArg, "ONCE"))
1307 Flags |= ACPI_TRACE_ONESHOT;
1311 (void) AcpiDebugTrace (AcpiDbTraceMethodName,
1312 DebugLevel, DebugLayer, Flags);
1315 #endif /* ACPI_DEBUGGER */