1 /*******************************************************************************
3 * Module Name: dbcmds - Miscellaneous debug commands and output routines
5 ******************************************************************************/
8 * Copyright (C) 2000 - 2014, 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.
55 #define _COMPONENT ACPI_CA_DEBUGGER
56 ACPI_MODULE_NAME ("dbcmds")
59 /* Local prototypes */
62 AcpiDmCompareAmlResources (
64 ACPI_RSDESC_SIZE Aml1BufferLength,
66 ACPI_RSDESC_SIZE Aml2BufferLength);
69 AcpiDmTestResourceConversion (
70 ACPI_NAMESPACE_NODE *Node,
74 AcpiDbResourceCallback (
75 ACPI_RESOURCE *Resource,
79 AcpiDbDeviceResources (
80 ACPI_HANDLE ObjHandle,
86 AcpiDbDoOneSleepState (
90 /*******************************************************************************
92 * FUNCTION: AcpiDbConvertToNode
94 * PARAMETERS: InString - String to convert
96 * RETURN: Pointer to a NS node
98 * DESCRIPTION: Convert a string to a valid NS pointer. Handles numeric or
99 * alphanumeric strings.
101 ******************************************************************************/
103 ACPI_NAMESPACE_NODE *
104 AcpiDbConvertToNode (
107 ACPI_NAMESPACE_NODE *Node;
111 if ((*InString >= 0x30) && (*InString <= 0x39))
113 /* Numeric argument, convert */
115 Address = ACPI_STRTOUL (InString, NULL, 16);
116 Node = ACPI_TO_POINTER (Address);
117 if (!AcpiOsReadable (Node, sizeof (ACPI_NAMESPACE_NODE)))
119 AcpiOsPrintf ("Address %p is invalid",
124 /* Make sure pointer is valid NS node */
126 if (ACPI_GET_DESCRIPTOR_TYPE (Node) != ACPI_DESC_TYPE_NAMED)
128 AcpiOsPrintf ("Address %p is not a valid namespace node [%s]\n",
129 Node, AcpiUtGetDescriptorName (Node));
136 * Alpha argument: The parameter is a name string that must be
137 * resolved to a Namespace object.
139 Node = AcpiDbLocalNsLookup (InString);
142 AcpiOsPrintf ("Could not find [%s] in namespace, defaulting to root node\n",
144 Node = AcpiGbl_RootNode;
152 /*******************************************************************************
154 * FUNCTION: AcpiDbSleep
156 * PARAMETERS: ObjectArg - Desired sleep state (0-5). NULL means
157 * invoke all possible sleep states.
161 * DESCRIPTION: Simulate sleep/wake sequences
163 ******************************************************************************/
173 ACPI_FUNCTION_TRACE (AcpiDbSleep);
176 /* Null input (no arguments) means to invoke all sleep states */
180 AcpiOsPrintf ("Invoking all possible sleep states, 0-%d\n",
183 for (i = 0; i <= ACPI_S_STATES_MAX; i++)
185 AcpiDbDoOneSleepState ((UINT8) i);
188 return_ACPI_STATUS (AE_OK);
191 /* Convert argument to binary and invoke the sleep state */
193 SleepState = (UINT8) ACPI_STRTOUL (ObjectArg, NULL, 0);
194 AcpiDbDoOneSleepState (SleepState);
195 return_ACPI_STATUS (AE_OK);
199 /*******************************************************************************
201 * FUNCTION: AcpiDbDoOneSleepState
203 * PARAMETERS: SleepState - Desired sleep state (0-5)
207 * DESCRIPTION: Simulate a sleep/wake sequence
209 ******************************************************************************/
212 AcpiDbDoOneSleepState (
220 /* Validate parameter */
222 if (SleepState > ACPI_S_STATES_MAX)
224 AcpiOsPrintf ("Sleep state %d out of range (%d max)\n",
225 SleepState, ACPI_S_STATES_MAX);
229 AcpiOsPrintf ("\n---- Invoking sleep state S%d (%s):\n",
230 SleepState, AcpiGbl_SleepStateNames[SleepState]);
232 /* Get the values for the sleep type registers (for display only) */
234 Status = AcpiGetSleepTypeData (SleepState, &SleepTypeA, &SleepTypeB);
235 if (ACPI_FAILURE (Status))
237 AcpiOsPrintf ("Could not evaluate [%s] method, %s\n",
238 AcpiGbl_SleepStateNames[SleepState],
239 AcpiFormatException (Status));
244 "Register values for sleep state S%d: Sleep-A: %.2X, Sleep-B: %.2X\n",
245 SleepState, SleepTypeA, SleepTypeB);
247 /* Invoke the various sleep/wake interfaces */
249 AcpiOsPrintf ("**** Sleep: Prepare to sleep (S%d) ****\n",
251 Status = AcpiEnterSleepStatePrep (SleepState);
252 if (ACPI_FAILURE (Status))
257 AcpiOsPrintf ("**** Sleep: Going to sleep (S%d) ****\n",
259 Status = AcpiEnterSleepState (SleepState);
260 if (ACPI_FAILURE (Status))
265 AcpiOsPrintf ("**** Wake: Prepare to return from sleep (S%d) ****\n",
267 Status = AcpiLeaveSleepStatePrep (SleepState);
268 if (ACPI_FAILURE (Status))
273 AcpiOsPrintf ("**** Wake: Return from sleep (S%d) ****\n",
275 Status = AcpiLeaveSleepState (SleepState);
276 if (ACPI_FAILURE (Status))
285 ACPI_EXCEPTION ((AE_INFO, Status, "During invocation of sleep state S%d",
290 /*******************************************************************************
292 * FUNCTION: AcpiDbDisplayLocks
298 * DESCRIPTION: Display information about internal mutexes.
300 ******************************************************************************/
309 for (i = 0; i < ACPI_MAX_MUTEX; i++)
311 AcpiOsPrintf ("%26s : %s\n", AcpiUtGetMutexName (i),
312 AcpiGbl_MutexInfo[i].ThreadId == ACPI_MUTEX_NOT_ACQUIRED
313 ? "Locked" : "Unlocked");
318 /*******************************************************************************
320 * FUNCTION: AcpiDbDisplayTableInfo
322 * PARAMETERS: TableArg - Name of table to be displayed
326 * DESCRIPTION: Display information about loaded tables. Current
327 * implementation displays all loaded tables.
329 ******************************************************************************/
332 AcpiDbDisplayTableInfo (
336 ACPI_TABLE_DESC *TableDesc;
342 AcpiOsPrintf ("Idx ID Status Type TableHeader (Sig, Address, Length)\n");
344 /* Walk the entire root table list */
346 for (i = 0; i < AcpiGbl_RootTableList.CurrentTableCount; i++)
348 TableDesc = &AcpiGbl_RootTableList.Tables[i];
350 /* Index and Table ID */
352 AcpiOsPrintf ("%3u %.2u ", i, TableDesc->OwnerId);
354 /* Decode the table flags */
356 if (!(TableDesc->Flags & ACPI_TABLE_IS_LOADED))
358 AcpiOsPrintf ("NotLoaded ");
362 AcpiOsPrintf (" Loaded ");
365 switch (TableDesc->Flags & ACPI_TABLE_ORIGIN_MASK)
367 case ACPI_TABLE_ORIGIN_EXTERNAL_VIRTUAL:
369 AcpiOsPrintf ("External/virtual ");
372 case ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL:
374 AcpiOsPrintf ("Internal/physical ");
377 case ACPI_TABLE_ORIGIN_INTERNAL_VIRTUAL:
379 AcpiOsPrintf ("Internal/virtual ");
384 AcpiOsPrintf ("INVALID TYPE ");
388 /* Make sure that the table is mapped */
390 Status = AcpiTbValidateTable (TableDesc);
391 if (ACPI_FAILURE (Status))
396 /* Dump the table header */
398 if (TableDesc->Pointer)
400 AcpiTbPrintTableHeader (TableDesc->Address, TableDesc->Pointer);
404 /* If the pointer is null, the table has been unloaded */
406 ACPI_INFO ((AE_INFO, "%4.4s - Table has been unloaded",
407 TableDesc->Signature.Ascii));
413 /*******************************************************************************
415 * FUNCTION: AcpiDbUnloadAcpiTable
417 * PARAMETERS: ObjectName - Namespace pathname for an object that
418 * is owned by the table to be unloaded
422 * DESCRIPTION: Unload an ACPI table, via any namespace node that is owned
425 ******************************************************************************/
428 AcpiDbUnloadAcpiTable (
431 ACPI_NAMESPACE_NODE *Node;
435 /* Translate name to an Named object */
437 Node = AcpiDbConvertToNode (ObjectName);
443 Status = AcpiUnloadParentTable (ACPI_CAST_PTR (ACPI_HANDLE, Node));
444 if (ACPI_SUCCESS (Status))
446 AcpiOsPrintf ("Parent of [%s] (%p) unloaded and uninstalled\n",
451 AcpiOsPrintf ("%s, while unloading parent table of [%s]\n",
452 AcpiFormatException (Status), ObjectName);
457 /*******************************************************************************
459 * FUNCTION: AcpiDbSendNotify
461 * PARAMETERS: Name - Name of ACPI object where to send notify
462 * Value - Value of the notify to send.
466 * DESCRIPTION: Send an ACPI notification. The value specified is sent to the
467 * named object as an ACPI notify.
469 ******************************************************************************/
476 ACPI_NAMESPACE_NODE *Node;
480 /* Translate name to an Named object */
482 Node = AcpiDbConvertToNode (Name);
488 /* Dispatch the notify if legal */
490 if (AcpiEvIsNotifyObject (Node))
492 Status = AcpiEvQueueNotifyRequest (Node, Value);
493 if (ACPI_FAILURE (Status))
495 AcpiOsPrintf ("Could not queue notify\n");
501 "Named object [%4.4s] Type %s, must be Device/Thermal/Processor type\n",
502 AcpiUtGetNodeName (Node), AcpiUtGetTypeName (Node->Type));
507 /*******************************************************************************
509 * FUNCTION: AcpiDbDisplayInterfaces
511 * PARAMETERS: ActionArg - Null, "install", or "remove"
512 * InterfaceNameArg - Name for install/remove options
516 * DESCRIPTION: Display or modify the global _OSI interface list
518 ******************************************************************************/
521 AcpiDbDisplayInterfaces (
523 char *InterfaceNameArg)
525 ACPI_INTERFACE_INFO *NextInterface;
530 /* If no arguments, just display current interface list */
534 (void) AcpiOsAcquireMutex (AcpiGbl_OsiMutex,
537 NextInterface = AcpiGbl_SupportedInterfaces;
538 while (NextInterface)
540 if (!(NextInterface->Flags & ACPI_OSI_INVALID))
542 AcpiOsPrintf ("%s\n", NextInterface->Name);
544 NextInterface = NextInterface->Next;
547 AcpiOsReleaseMutex (AcpiGbl_OsiMutex);
551 /* If ActionArg exists, so must InterfaceNameArg */
553 if (!InterfaceNameArg)
555 AcpiOsPrintf ("Missing Interface Name argument\n");
559 /* Uppercase the action for match below */
561 AcpiUtStrupr (ActionArg);
563 /* Install - install an interface */
565 SubString = ACPI_STRSTR ("INSTALL", ActionArg);
568 Status = AcpiInstallInterface (InterfaceNameArg);
569 if (ACPI_FAILURE (Status))
571 AcpiOsPrintf ("%s, while installing \"%s\"\n",
572 AcpiFormatException (Status), InterfaceNameArg);
577 /* Remove - remove an interface */
579 SubString = ACPI_STRSTR ("REMOVE", ActionArg);
582 Status = AcpiRemoveInterface (InterfaceNameArg);
583 if (ACPI_FAILURE (Status))
585 AcpiOsPrintf ("%s, while removing \"%s\"\n",
586 AcpiFormatException (Status), InterfaceNameArg);
591 /* Invalid ActionArg */
593 AcpiOsPrintf ("Invalid action argument: %s\n", ActionArg);
598 /*******************************************************************************
600 * FUNCTION: AcpiDbDisplayTemplate
602 * PARAMETERS: BufferArg - Buffer name or address
606 * DESCRIPTION: Dump a buffer that contains a resource template
608 ******************************************************************************/
611 AcpiDbDisplayTemplate (
614 ACPI_NAMESPACE_NODE *Node;
616 ACPI_BUFFER ReturnBuffer;
619 /* Translate BufferArg to an Named object */
621 Node = AcpiDbConvertToNode (BufferArg);
622 if (!Node || (Node == AcpiGbl_RootNode))
624 AcpiOsPrintf ("Invalid argument: %s\n", BufferArg);
628 /* We must have a buffer object */
630 if (Node->Type != ACPI_TYPE_BUFFER)
632 AcpiOsPrintf ("Not a Buffer object, cannot be a template: %s\n",
637 ReturnBuffer.Length = ACPI_DEBUG_BUFFER_SIZE;
638 ReturnBuffer.Pointer = AcpiGbl_DbBuffer;
640 /* Attempt to convert the raw buffer to a resource list */
642 Status = AcpiRsCreateResourceList (Node->Object, &ReturnBuffer);
644 AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT);
645 AcpiDbgLevel |= ACPI_LV_RESOURCES;
647 if (ACPI_FAILURE (Status))
649 AcpiOsPrintf ("Could not convert Buffer to a resource list: %s, %s\n",
650 BufferArg, AcpiFormatException (Status));
654 /* Now we can dump the resource list */
656 AcpiRsDumpResourceList (ACPI_CAST_PTR (ACPI_RESOURCE,
657 ReturnBuffer.Pointer));
660 AcpiOsPrintf ("\nRaw data buffer:\n");
661 AcpiUtDebugDumpBuffer ((UINT8 *) Node->Object->Buffer.Pointer,
662 Node->Object->Buffer.Length,
663 DB_BYTE_DISPLAY, ACPI_UINT32_MAX);
665 AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT);
670 /*******************************************************************************
672 * FUNCTION: AcpiDmCompareAmlResources
674 * PARAMETERS: Aml1Buffer - Contains first resource list
675 * Aml1BufferLength - Length of first resource list
676 * Aml2Buffer - Contains second resource list
677 * Aml2BufferLength - Length of second resource list
681 * DESCRIPTION: Compare two AML resource lists, descriptor by descriptor (in
682 * order to isolate a miscompare to an individual resource)
684 ******************************************************************************/
687 AcpiDmCompareAmlResources (
689 ACPI_RSDESC_SIZE Aml1BufferLength,
691 ACPI_RSDESC_SIZE Aml2BufferLength)
697 ACPI_RSDESC_SIZE Aml1Length;
698 ACPI_RSDESC_SIZE Aml2Length;
699 ACPI_RSDESC_SIZE Offset = 0;
705 /* Compare overall buffer sizes (may be different due to size rounding) */
707 if (Aml1BufferLength != Aml2BufferLength)
710 "**** Buffer length mismatch in converted AML: Original %X, New %X ****\n",
711 Aml1BufferLength, Aml2BufferLength);
716 Aml1End = Aml1Buffer + Aml1BufferLength;
717 Aml2End = Aml2Buffer + Aml2BufferLength;
719 /* Walk the descriptor lists, comparing each descriptor */
721 while ((Aml1 < Aml1End) && (Aml2 < Aml2End))
723 /* Get the lengths of each descriptor */
725 Aml1Length = AcpiUtGetDescriptorLength (Aml1);
726 Aml2Length = AcpiUtGetDescriptorLength (Aml2);
727 ResourceType = AcpiUtGetResourceType (Aml1);
729 /* Check for descriptor length match */
731 if (Aml1Length != Aml2Length)
734 "**** Length mismatch in descriptor [%.2X] type %2.2X, Offset %8.8X Len1 %X, Len2 %X ****\n",
735 Count, ResourceType, Offset, Aml1Length, Aml2Length);
738 /* Check for descriptor byte match */
740 else if (ACPI_MEMCMP (Aml1, Aml2, Aml1Length))
743 "**** Data mismatch in descriptor [%.2X] type %2.2X, Offset %8.8X ****\n",
744 Count, ResourceType, Offset);
746 for (i = 0; i < Aml1Length; i++)
748 if (Aml1[i] != Aml2[i])
751 "Mismatch at byte offset %.2X: is %2.2X, should be %2.2X\n",
752 i, Aml2[i], Aml1[i]);
757 /* Exit on EndTag descriptor */
759 if (ResourceType == ACPI_RESOURCE_NAME_END_TAG)
764 /* Point to next descriptor in each buffer */
767 Offset += Aml1Length;
774 /*******************************************************************************
776 * FUNCTION: AcpiDmTestResourceConversion
778 * PARAMETERS: Node - Parent device node
779 * Name - resource method name (_CRS)
783 * DESCRIPTION: Compare the original AML with a conversion of the AML to
784 * internal resource list, then back to AML.
786 ******************************************************************************/
789 AcpiDmTestResourceConversion (
790 ACPI_NAMESPACE_NODE *Node,
794 ACPI_BUFFER ReturnBuffer;
795 ACPI_BUFFER ResourceBuffer;
797 ACPI_OBJECT *OriginalAml;
800 AcpiOsPrintf ("Resource Conversion Comparison:\n");
802 NewAml.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
803 ReturnBuffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
804 ResourceBuffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
806 /* Get the original _CRS AML resource template */
808 Status = AcpiEvaluateObject (Node, Name, NULL, &ReturnBuffer);
809 if (ACPI_FAILURE (Status))
811 AcpiOsPrintf ("Could not obtain %s: %s\n",
812 Name, AcpiFormatException (Status));
816 /* Get the AML resource template, converted to internal resource structs */
818 Status = AcpiGetCurrentResources (Node, &ResourceBuffer);
819 if (ACPI_FAILURE (Status))
821 AcpiOsPrintf ("AcpiGetCurrentResources failed: %s\n",
822 AcpiFormatException (Status));
826 /* Convert internal resource list to external AML resource template */
828 Status = AcpiRsCreateAmlResources (&ResourceBuffer, &NewAml);
829 if (ACPI_FAILURE (Status))
831 AcpiOsPrintf ("AcpiRsCreateAmlResources failed: %s\n",
832 AcpiFormatException (Status));
836 /* Compare original AML to the newly created AML resource list */
838 OriginalAml = ReturnBuffer.Pointer;
840 AcpiDmCompareAmlResources (OriginalAml->Buffer.Pointer,
841 (ACPI_RSDESC_SIZE) OriginalAml->Buffer.Length,
842 NewAml.Pointer, (ACPI_RSDESC_SIZE) NewAml.Length);
844 /* Cleanup and exit */
846 ACPI_FREE (NewAml.Pointer);
848 ACPI_FREE (ResourceBuffer.Pointer);
850 ACPI_FREE (ReturnBuffer.Pointer);
855 /*******************************************************************************
857 * FUNCTION: AcpiDbResourceCallback
859 * PARAMETERS: ACPI_WALK_RESOURCE_CALLBACK
863 * DESCRIPTION: Simple callback to exercise AcpiWalkResources and
864 * AcpiWalkResourceBuffer.
866 ******************************************************************************/
869 AcpiDbResourceCallback (
870 ACPI_RESOURCE *Resource,
878 /*******************************************************************************
880 * FUNCTION: AcpiDbDeviceResources
882 * PARAMETERS: ACPI_WALK_CALLBACK
886 * DESCRIPTION: Display the _PRT/_CRS/_PRS resources for a device object.
888 ******************************************************************************/
891 AcpiDbDeviceResources (
892 ACPI_HANDLE ObjHandle,
897 ACPI_NAMESPACE_NODE *Node;
898 ACPI_NAMESPACE_NODE *PrtNode = NULL;
899 ACPI_NAMESPACE_NODE *CrsNode = NULL;
900 ACPI_NAMESPACE_NODE *PrsNode = NULL;
901 ACPI_NAMESPACE_NODE *AeiNode = NULL;
903 ACPI_BUFFER ReturnBuffer;
907 Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, ObjHandle);
908 ParentPath = AcpiNsGetExternalPathname (Node);
911 return (AE_NO_MEMORY);
914 /* Get handles to the resource methods for this device */
916 (void) AcpiGetHandle (Node, METHOD_NAME__PRT, ACPI_CAST_PTR (ACPI_HANDLE, &PrtNode));
917 (void) AcpiGetHandle (Node, METHOD_NAME__CRS, ACPI_CAST_PTR (ACPI_HANDLE, &CrsNode));
918 (void) AcpiGetHandle (Node, METHOD_NAME__PRS, ACPI_CAST_PTR (ACPI_HANDLE, &PrsNode));
919 (void) AcpiGetHandle (Node, METHOD_NAME__AEI, ACPI_CAST_PTR (ACPI_HANDLE, &AeiNode));
920 if (!PrtNode && !CrsNode && !PrsNode && !AeiNode)
922 goto Cleanup; /* Nothing to do */
925 AcpiOsPrintf ("\nDevice: %s\n", ParentPath);
927 /* Prepare for a return object of arbitrary size */
929 ReturnBuffer.Pointer = AcpiGbl_DbBuffer;
930 ReturnBuffer.Length = ACPI_DEBUG_BUFFER_SIZE;
937 AcpiOsPrintf ("Evaluating _PRT\n");
939 Status = AcpiEvaluateObject (PrtNode, NULL, NULL, &ReturnBuffer);
940 if (ACPI_FAILURE (Status))
942 AcpiOsPrintf ("Could not evaluate _PRT: %s\n",
943 AcpiFormatException (Status));
947 ReturnBuffer.Pointer = AcpiGbl_DbBuffer;
948 ReturnBuffer.Length = ACPI_DEBUG_BUFFER_SIZE;
950 Status = AcpiGetIrqRoutingTable (Node, &ReturnBuffer);
951 if (ACPI_FAILURE (Status))
953 AcpiOsPrintf ("GetIrqRoutingTable failed: %s\n",
954 AcpiFormatException (Status));
958 AcpiRsDumpIrqList (ACPI_CAST_PTR (UINT8, AcpiGbl_DbBuffer));
967 AcpiOsPrintf ("Evaluating _CRS\n");
969 ReturnBuffer.Pointer = AcpiGbl_DbBuffer;
970 ReturnBuffer.Length = ACPI_DEBUG_BUFFER_SIZE;
972 Status = AcpiEvaluateObject (CrsNode, NULL, NULL, &ReturnBuffer);
973 if (ACPI_FAILURE (Status))
975 AcpiOsPrintf ("Could not evaluate _CRS: %s\n",
976 AcpiFormatException (Status));
980 /* This code exercises the AcpiWalkResources interface */
982 Status = AcpiWalkResources (Node, METHOD_NAME__CRS,
983 AcpiDbResourceCallback, NULL);
984 if (ACPI_FAILURE (Status))
986 AcpiOsPrintf ("AcpiWalkResources failed: %s\n",
987 AcpiFormatException (Status));
991 /* Get the _CRS resource list (test ALLOCATE buffer) */
993 ReturnBuffer.Pointer = NULL;
994 ReturnBuffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
996 Status = AcpiGetCurrentResources (Node, &ReturnBuffer);
997 if (ACPI_FAILURE (Status))
999 AcpiOsPrintf ("AcpiGetCurrentResources failed: %s\n",
1000 AcpiFormatException (Status));
1004 /* This code exercises the AcpiWalkResourceBuffer interface */
1006 Status = AcpiWalkResourceBuffer (&ReturnBuffer,
1007 AcpiDbResourceCallback, NULL);
1008 if (ACPI_FAILURE (Status))
1010 AcpiOsPrintf ("AcpiWalkResourceBuffer failed: %s\n",
1011 AcpiFormatException (Status));
1015 /* Dump the _CRS resource list */
1017 AcpiRsDumpResourceList (ACPI_CAST_PTR (ACPI_RESOURCE,
1018 ReturnBuffer.Pointer));
1021 * Perform comparison of original AML to newly created AML. This
1022 * tests both the AML->Resource conversion and the Resource->AML
1025 (void) AcpiDmTestResourceConversion (Node, METHOD_NAME__CRS);
1027 /* Execute _SRS with the resource list */
1029 AcpiOsPrintf ("Evaluating _SRS\n");
1031 Status = AcpiSetCurrentResources (Node, &ReturnBuffer);
1032 if (ACPI_FAILURE (Status))
1034 AcpiOsPrintf ("AcpiSetCurrentResources failed: %s\n",
1035 AcpiFormatException (Status));
1040 ACPI_FREE (ReturnBuffer.Pointer);
1049 AcpiOsPrintf ("Evaluating _PRS\n");
1051 ReturnBuffer.Pointer = AcpiGbl_DbBuffer;
1052 ReturnBuffer.Length = ACPI_DEBUG_BUFFER_SIZE;
1054 Status = AcpiEvaluateObject (PrsNode, NULL, NULL, &ReturnBuffer);
1055 if (ACPI_FAILURE (Status))
1057 AcpiOsPrintf ("Could not evaluate _PRS: %s\n",
1058 AcpiFormatException (Status));
1062 ReturnBuffer.Pointer = AcpiGbl_DbBuffer;
1063 ReturnBuffer.Length = ACPI_DEBUG_BUFFER_SIZE;
1065 Status = AcpiGetPossibleResources (Node, &ReturnBuffer);
1066 if (ACPI_FAILURE (Status))
1068 AcpiOsPrintf ("AcpiGetPossibleResources failed: %s\n",
1069 AcpiFormatException (Status));
1073 AcpiRsDumpResourceList (ACPI_CAST_PTR (ACPI_RESOURCE, AcpiGbl_DbBuffer));
1082 AcpiOsPrintf ("Evaluating _AEI\n");
1084 ReturnBuffer.Pointer = AcpiGbl_DbBuffer;
1085 ReturnBuffer.Length = ACPI_DEBUG_BUFFER_SIZE;
1087 Status = AcpiEvaluateObject (AeiNode, NULL, NULL, &ReturnBuffer);
1088 if (ACPI_FAILURE (Status))
1090 AcpiOsPrintf ("Could not evaluate _AEI: %s\n",
1091 AcpiFormatException (Status));
1095 ReturnBuffer.Pointer = AcpiGbl_DbBuffer;
1096 ReturnBuffer.Length = ACPI_DEBUG_BUFFER_SIZE;
1098 Status = AcpiGetEventResources (Node, &ReturnBuffer);
1099 if (ACPI_FAILURE (Status))
1101 AcpiOsPrintf ("AcpiGetEventResources failed: %s\n",
1102 AcpiFormatException (Status));
1106 AcpiRsDumpResourceList (ACPI_CAST_PTR (ACPI_RESOURCE, AcpiGbl_DbBuffer));
1111 ACPI_FREE (ParentPath);
1116 /*******************************************************************************
1118 * FUNCTION: AcpiDbDisplayResources
1120 * PARAMETERS: ObjectArg - String object name or object pointer.
1121 * NULL or "*" means "display resources for
1126 * DESCRIPTION: Display the resource objects associated with a device.
1128 ******************************************************************************/
1131 AcpiDbDisplayResources (
1134 ACPI_NAMESPACE_NODE *Node;
1137 AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT);
1138 AcpiDbgLevel |= ACPI_LV_RESOURCES;
1140 /* Asterisk means "display resources for all devices" */
1142 if (!ObjectArg || (!ACPI_STRCMP (ObjectArg, "*")))
1144 (void) AcpiWalkNamespace (ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
1145 ACPI_UINT32_MAX, AcpiDbDeviceResources, NULL, NULL, NULL);
1149 /* Convert string to object pointer */
1151 Node = AcpiDbConvertToNode (ObjectArg);
1154 if (Node->Type != ACPI_TYPE_DEVICE)
1156 AcpiOsPrintf ("%4.4s: Name is not a device object (%s)\n",
1157 Node->Name.Ascii, AcpiUtGetTypeName (Node->Type));
1161 (void) AcpiDbDeviceResources (Node, 0, NULL, NULL);
1166 AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT);
1170 #if (!ACPI_REDUCED_HARDWARE)
1171 /*******************************************************************************
1173 * FUNCTION: AcpiDbGenerateGpe
1175 * PARAMETERS: GpeArg - Raw GPE number, ascii string
1176 * BlockArg - GPE block number, ascii string
1177 * 0 or 1 for FADT GPE blocks
1181 * DESCRIPTION: Simulate firing of a GPE
1183 ******************************************************************************/
1190 UINT32 BlockNumber = 0;
1192 ACPI_GPE_EVENT_INFO *GpeEventInfo;
1195 GpeNumber = ACPI_STRTOUL (GpeArg, NULL, 0);
1198 * If no block arg, or block arg == 0 or 1, use the FADT-defined
1203 BlockNumber = ACPI_STRTOUL (BlockArg, NULL, 0);
1204 if (BlockNumber == 1)
1210 GpeEventInfo = AcpiEvGetGpeEventInfo (ACPI_TO_POINTER (BlockNumber),
1214 AcpiOsPrintf ("Invalid GPE\n");
1218 (void) AcpiEvGpeDispatch (NULL, GpeEventInfo, GpeNumber);
1225 AcpiEvSciDispatch ();
1228 #endif /* !ACPI_REDUCED_HARDWARE */
1230 #endif /* ACPI_DEBUGGER */