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;
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",
126 /* Make sure pointer is valid NS node */
128 if (ACPI_GET_DESCRIPTOR_TYPE (Node) != ACPI_DESC_TYPE_NAMED)
130 AcpiOsPrintf ("Address %p is not a valid namespace node [%s]\n",
131 Node, AcpiUtGetDescriptorName (Node));
138 * Alpha argument: The parameter is a name string that must be
139 * resolved to a Namespace object.
141 Node = AcpiDbLocalNsLookup (InString);
145 "Could not find [%s] in namespace, defaulting to root node\n",
147 Node = AcpiGbl_RootNode;
155 /*******************************************************************************
157 * FUNCTION: AcpiDbSleep
159 * PARAMETERS: ObjectArg - Desired sleep state (0-5). NULL means
160 * invoke all possible sleep states.
164 * DESCRIPTION: Simulate sleep/wake sequences
166 ******************************************************************************/
176 ACPI_FUNCTION_TRACE (AcpiDbSleep);
179 /* Null input (no arguments) means to invoke all sleep states */
183 AcpiOsPrintf ("Invoking all possible sleep states, 0-%d\n",
186 for (i = 0; i <= ACPI_S_STATES_MAX; i++)
188 AcpiDbDoOneSleepState ((UINT8) i);
191 return_ACPI_STATUS (AE_OK);
194 /* Convert argument to binary and invoke the sleep state */
196 SleepState = (UINT8) strtoul (ObjectArg, NULL, 0);
197 AcpiDbDoOneSleepState (SleepState);
198 return_ACPI_STATUS (AE_OK);
202 /*******************************************************************************
204 * FUNCTION: AcpiDbDoOneSleepState
206 * PARAMETERS: SleepState - Desired sleep state (0-5)
210 * DESCRIPTION: Simulate a sleep/wake sequence
212 ******************************************************************************/
215 AcpiDbDoOneSleepState (
223 /* Validate parameter */
225 if (SleepState > ACPI_S_STATES_MAX)
227 AcpiOsPrintf ("Sleep state %d out of range (%d max)\n",
228 SleepState, ACPI_S_STATES_MAX);
232 AcpiOsPrintf ("\n---- Invoking sleep state S%d (%s):\n",
233 SleepState, AcpiGbl_SleepStateNames[SleepState]);
235 /* Get the values for the sleep type registers (for display only) */
237 Status = AcpiGetSleepTypeData (SleepState, &SleepTypeA, &SleepTypeB);
238 if (ACPI_FAILURE (Status))
240 AcpiOsPrintf ("Could not evaluate [%s] method, %s\n",
241 AcpiGbl_SleepStateNames[SleepState],
242 AcpiFormatException (Status));
247 "Register values for sleep state S%d: Sleep-A: %.2X, Sleep-B: %.2X\n",
248 SleepState, SleepTypeA, SleepTypeB);
250 /* Invoke the various sleep/wake interfaces */
252 AcpiOsPrintf ("**** Sleep: Prepare to sleep (S%d) ****\n",
254 Status = AcpiEnterSleepStatePrep (SleepState);
255 if (ACPI_FAILURE (Status))
260 AcpiOsPrintf ("**** Sleep: Going to sleep (S%d) ****\n",
262 Status = AcpiEnterSleepState (SleepState);
263 if (ACPI_FAILURE (Status))
268 AcpiOsPrintf ("**** Wake: Prepare to return from sleep (S%d) ****\n",
270 Status = AcpiLeaveSleepStatePrep (SleepState);
271 if (ACPI_FAILURE (Status))
276 AcpiOsPrintf ("**** Wake: Return from sleep (S%d) ****\n",
278 Status = AcpiLeaveSleepState (SleepState);
279 if (ACPI_FAILURE (Status))
288 ACPI_EXCEPTION ((AE_INFO, Status, "During invocation of sleep state S%d",
293 /*******************************************************************************
295 * FUNCTION: AcpiDbDisplayLocks
301 * DESCRIPTION: Display information about internal mutexes.
303 ******************************************************************************/
312 for (i = 0; i < ACPI_MAX_MUTEX; i++)
314 AcpiOsPrintf ("%26s : %s\n", AcpiUtGetMutexName (i),
315 AcpiGbl_MutexInfo[i].ThreadId == ACPI_MUTEX_NOT_ACQUIRED
316 ? "Locked" : "Unlocked");
321 /*******************************************************************************
323 * FUNCTION: AcpiDbDisplayTableInfo
325 * PARAMETERS: TableArg - Name of table to be displayed
329 * DESCRIPTION: Display information about loaded tables. Current
330 * implementation displays all loaded tables.
332 ******************************************************************************/
335 AcpiDbDisplayTableInfo (
339 ACPI_TABLE_DESC *TableDesc;
345 AcpiOsPrintf ("Idx ID Status Type "
346 "TableHeader (Sig, Address, Length, Misc)\n");
348 /* Walk the entire root table list */
350 for (i = 0; i < AcpiGbl_RootTableList.CurrentTableCount; i++)
352 TableDesc = &AcpiGbl_RootTableList.Tables[i];
354 /* Index and Table ID */
356 AcpiOsPrintf ("%3u %.2u ", i, TableDesc->OwnerId);
358 /* Decode the table flags */
360 if (!(TableDesc->Flags & ACPI_TABLE_IS_LOADED))
362 AcpiOsPrintf ("NotLoaded ");
366 AcpiOsPrintf (" Loaded ");
369 switch (TableDesc->Flags & ACPI_TABLE_ORIGIN_MASK)
371 case ACPI_TABLE_ORIGIN_EXTERNAL_VIRTUAL:
373 AcpiOsPrintf ("External/virtual ");
376 case ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL:
378 AcpiOsPrintf ("Internal/physical ");
381 case ACPI_TABLE_ORIGIN_INTERNAL_VIRTUAL:
383 AcpiOsPrintf ("Internal/virtual ");
388 AcpiOsPrintf ("INVALID TYPE ");
392 /* Make sure that the table is mapped */
394 Status = AcpiTbValidateTable (TableDesc);
395 if (ACPI_FAILURE (Status))
400 /* Dump the table header */
402 if (TableDesc->Pointer)
404 AcpiTbPrintTableHeader (TableDesc->Address, TableDesc->Pointer);
408 /* If the pointer is null, the table has been unloaded */
410 ACPI_INFO ((AE_INFO, "%4.4s - Table has been unloaded",
411 TableDesc->Signature.Ascii));
417 /*******************************************************************************
419 * FUNCTION: AcpiDbUnloadAcpiTable
421 * PARAMETERS: ObjectName - Namespace pathname for an object that
422 * is owned by the table to be unloaded
426 * DESCRIPTION: Unload an ACPI table, via any namespace node that is owned
429 ******************************************************************************/
432 AcpiDbUnloadAcpiTable (
435 ACPI_NAMESPACE_NODE *Node;
439 /* Translate name to an Named object */
441 Node = AcpiDbConvertToNode (ObjectName);
447 Status = AcpiUnloadParentTable (ACPI_CAST_PTR (ACPI_HANDLE, Node));
448 if (ACPI_SUCCESS (Status))
450 AcpiOsPrintf ("Parent of [%s] (%p) unloaded and uninstalled\n",
455 AcpiOsPrintf ("%s, while unloading parent table of [%s]\n",
456 AcpiFormatException (Status), ObjectName);
461 /*******************************************************************************
463 * FUNCTION: AcpiDbSendNotify
465 * PARAMETERS: Name - Name of ACPI object where to send notify
466 * Value - Value of the notify to send.
470 * DESCRIPTION: Send an ACPI notification. The value specified is sent to the
471 * named object as an ACPI notify.
473 ******************************************************************************/
480 ACPI_NAMESPACE_NODE *Node;
484 /* Translate name to an Named object */
486 Node = AcpiDbConvertToNode (Name);
492 /* Dispatch the notify if legal */
494 if (AcpiEvIsNotifyObject (Node))
496 Status = AcpiEvQueueNotifyRequest (Node, Value);
497 if (ACPI_FAILURE (Status))
499 AcpiOsPrintf ("Could not queue notify\n");
505 "Named object [%4.4s] Type %s, "
506 "must be Device/Thermal/Processor type\n",
507 AcpiUtGetNodeName (Node), AcpiUtGetTypeName (Node->Type));
512 /*******************************************************************************
514 * FUNCTION: AcpiDbDisplayInterfaces
516 * PARAMETERS: ActionArg - Null, "install", or "remove"
517 * InterfaceNameArg - Name for install/remove options
521 * DESCRIPTION: Display or modify the global _OSI interface list
523 ******************************************************************************/
526 AcpiDbDisplayInterfaces (
528 char *InterfaceNameArg)
530 ACPI_INTERFACE_INFO *NextInterface;
535 /* If no arguments, just display current interface list */
539 (void) AcpiOsAcquireMutex (AcpiGbl_OsiMutex, ACPI_WAIT_FOREVER);
541 NextInterface = AcpiGbl_SupportedInterfaces;
542 while (NextInterface)
544 if (!(NextInterface->Flags & ACPI_OSI_INVALID))
546 AcpiOsPrintf ("%s\n", NextInterface->Name);
549 NextInterface = NextInterface->Next;
552 AcpiOsReleaseMutex (AcpiGbl_OsiMutex);
556 /* If ActionArg exists, so must InterfaceNameArg */
558 if (!InterfaceNameArg)
560 AcpiOsPrintf ("Missing Interface Name argument\n");
564 /* Uppercase the action for match below */
566 AcpiUtStrupr (ActionArg);
568 /* Install - install an interface */
570 SubString = strstr ("INSTALL", ActionArg);
573 Status = AcpiInstallInterface (InterfaceNameArg);
574 if (ACPI_FAILURE (Status))
576 AcpiOsPrintf ("%s, while installing \"%s\"\n",
577 AcpiFormatException (Status), InterfaceNameArg);
582 /* Remove - remove an interface */
584 SubString = strstr ("REMOVE", ActionArg);
587 Status = AcpiRemoveInterface (InterfaceNameArg);
588 if (ACPI_FAILURE (Status))
590 AcpiOsPrintf ("%s, while removing \"%s\"\n",
591 AcpiFormatException (Status), InterfaceNameArg);
596 /* Invalid ActionArg */
598 AcpiOsPrintf ("Invalid action argument: %s\n", ActionArg);
603 /*******************************************************************************
605 * FUNCTION: AcpiDbDisplayTemplate
607 * PARAMETERS: BufferArg - Buffer name or address
611 * DESCRIPTION: Dump a buffer that contains a resource template
613 ******************************************************************************/
616 AcpiDbDisplayTemplate (
619 ACPI_NAMESPACE_NODE *Node;
621 ACPI_BUFFER ReturnBuffer;
624 /* Translate BufferArg to an Named object */
626 Node = AcpiDbConvertToNode (BufferArg);
627 if (!Node || (Node == AcpiGbl_RootNode))
629 AcpiOsPrintf ("Invalid argument: %s\n", BufferArg);
633 /* We must have a buffer object */
635 if (Node->Type != ACPI_TYPE_BUFFER)
637 AcpiOsPrintf ("Not a Buffer object, cannot be a template: %s\n",
642 ReturnBuffer.Length = ACPI_DEBUG_BUFFER_SIZE;
643 ReturnBuffer.Pointer = AcpiGbl_DbBuffer;
645 /* Attempt to convert the raw buffer to a resource list */
647 Status = AcpiRsCreateResourceList (Node->Object, &ReturnBuffer);
649 AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT);
650 AcpiDbgLevel |= ACPI_LV_RESOURCES;
652 if (ACPI_FAILURE (Status))
655 "Could not convert Buffer to a resource list: %s, %s\n",
656 BufferArg, AcpiFormatException (Status));
660 /* Now we can dump the resource list */
662 AcpiRsDumpResourceList (ACPI_CAST_PTR (ACPI_RESOURCE,
663 ReturnBuffer.Pointer));
666 AcpiOsPrintf ("\nRaw data buffer:\n");
667 AcpiUtDebugDumpBuffer ((UINT8 *) Node->Object->Buffer.Pointer,
668 Node->Object->Buffer.Length,
669 DB_BYTE_DISPLAY, ACPI_UINT32_MAX);
671 AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT);
676 /*******************************************************************************
678 * FUNCTION: AcpiDmCompareAmlResources
680 * PARAMETERS: Aml1Buffer - Contains first resource list
681 * Aml1BufferLength - Length of first resource list
682 * Aml2Buffer - Contains second resource list
683 * Aml2BufferLength - Length of second resource list
687 * DESCRIPTION: Compare two AML resource lists, descriptor by descriptor (in
688 * order to isolate a miscompare to an individual resource)
690 ******************************************************************************/
693 AcpiDmCompareAmlResources (
695 ACPI_RSDESC_SIZE Aml1BufferLength,
697 ACPI_RSDESC_SIZE Aml2BufferLength)
703 ACPI_RSDESC_SIZE Aml1Length;
704 ACPI_RSDESC_SIZE Aml2Length;
705 ACPI_RSDESC_SIZE Offset = 0;
711 /* Compare overall buffer sizes (may be different due to size rounding) */
713 if (Aml1BufferLength != Aml2BufferLength)
716 "**** Buffer length mismatch in converted "
717 "AML: Original %X, New %X ****\n",
718 Aml1BufferLength, Aml2BufferLength);
723 Aml1End = Aml1Buffer + Aml1BufferLength;
724 Aml2End = Aml2Buffer + Aml2BufferLength;
726 /* Walk the descriptor lists, comparing each descriptor */
728 while ((Aml1 < Aml1End) && (Aml2 < Aml2End))
730 /* Get the lengths of each descriptor */
732 Aml1Length = AcpiUtGetDescriptorLength (Aml1);
733 Aml2Length = AcpiUtGetDescriptorLength (Aml2);
734 ResourceType = AcpiUtGetResourceType (Aml1);
736 /* Check for descriptor length match */
738 if (Aml1Length != Aml2Length)
741 "**** Length mismatch in descriptor [%.2X] type %2.2X, "
742 "Offset %8.8X Len1 %X, Len2 %X ****\n",
743 Count, ResourceType, Offset, Aml1Length, Aml2Length);
746 /* Check for descriptor byte match */
748 else if (memcmp (Aml1, Aml2, Aml1Length))
751 "**** Data mismatch in descriptor [%.2X] type %2.2X, "
752 "Offset %8.8X ****\n",
753 Count, ResourceType, Offset);
755 for (i = 0; i < Aml1Length; i++)
757 if (Aml1[i] != Aml2[i])
760 "Mismatch at byte offset %.2X: is %2.2X, "
762 i, Aml2[i], Aml1[i]);
767 /* Exit on EndTag descriptor */
769 if (ResourceType == ACPI_RESOURCE_NAME_END_TAG)
774 /* Point to next descriptor in each buffer */
777 Offset += Aml1Length;
784 /*******************************************************************************
786 * FUNCTION: AcpiDmTestResourceConversion
788 * PARAMETERS: Node - Parent device node
789 * Name - resource method name (_CRS)
793 * DESCRIPTION: Compare the original AML with a conversion of the AML to
794 * internal resource list, then back to AML.
796 ******************************************************************************/
799 AcpiDmTestResourceConversion (
800 ACPI_NAMESPACE_NODE *Node,
804 ACPI_BUFFER ReturnBuffer;
805 ACPI_BUFFER ResourceBuffer;
807 ACPI_OBJECT *OriginalAml;
810 AcpiOsPrintf ("Resource Conversion Comparison:\n");
812 NewAml.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
813 ReturnBuffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
814 ResourceBuffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
816 /* Get the original _CRS AML resource template */
818 Status = AcpiEvaluateObject (Node, Name, NULL, &ReturnBuffer);
819 if (ACPI_FAILURE (Status))
821 AcpiOsPrintf ("Could not obtain %s: %s\n",
822 Name, AcpiFormatException (Status));
826 /* Get the AML resource template, converted to internal resource structs */
828 Status = AcpiGetCurrentResources (Node, &ResourceBuffer);
829 if (ACPI_FAILURE (Status))
831 AcpiOsPrintf ("AcpiGetCurrentResources failed: %s\n",
832 AcpiFormatException (Status));
836 /* Convert internal resource list to external AML resource template */
838 Status = AcpiRsCreateAmlResources (&ResourceBuffer, &NewAml);
839 if (ACPI_FAILURE (Status))
841 AcpiOsPrintf ("AcpiRsCreateAmlResources failed: %s\n",
842 AcpiFormatException (Status));
846 /* Compare original AML to the newly created AML resource list */
848 OriginalAml = ReturnBuffer.Pointer;
850 AcpiDmCompareAmlResources (OriginalAml->Buffer.Pointer,
851 (ACPI_RSDESC_SIZE) OriginalAml->Buffer.Length,
852 NewAml.Pointer, (ACPI_RSDESC_SIZE) NewAml.Length);
854 /* Cleanup and exit */
856 ACPI_FREE (NewAml.Pointer);
858 ACPI_FREE (ResourceBuffer.Pointer);
860 ACPI_FREE (ReturnBuffer.Pointer);
865 /*******************************************************************************
867 * FUNCTION: AcpiDbResourceCallback
869 * PARAMETERS: ACPI_WALK_RESOURCE_CALLBACK
873 * DESCRIPTION: Simple callback to exercise AcpiWalkResources and
874 * AcpiWalkResourceBuffer.
876 ******************************************************************************/
879 AcpiDbResourceCallback (
880 ACPI_RESOURCE *Resource,
888 /*******************************************************************************
890 * FUNCTION: AcpiDbDeviceResources
892 * PARAMETERS: ACPI_WALK_CALLBACK
896 * DESCRIPTION: Display the _PRT/_CRS/_PRS resources for a device object.
898 ******************************************************************************/
901 AcpiDbDeviceResources (
902 ACPI_HANDLE ObjHandle,
907 ACPI_NAMESPACE_NODE *Node;
908 ACPI_NAMESPACE_NODE *PrtNode = NULL;
909 ACPI_NAMESPACE_NODE *CrsNode = NULL;
910 ACPI_NAMESPACE_NODE *PrsNode = NULL;
911 ACPI_NAMESPACE_NODE *AeiNode = NULL;
913 ACPI_BUFFER ReturnBuffer;
917 Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, ObjHandle);
918 ParentPath = AcpiNsGetExternalPathname (Node);
921 return (AE_NO_MEMORY);
924 /* Get handles to the resource methods for this device */
926 (void) AcpiGetHandle (Node, METHOD_NAME__PRT,
927 ACPI_CAST_PTR (ACPI_HANDLE, &PrtNode));
928 (void) AcpiGetHandle (Node, METHOD_NAME__CRS,
929 ACPI_CAST_PTR (ACPI_HANDLE, &CrsNode));
930 (void) AcpiGetHandle (Node, METHOD_NAME__PRS,
931 ACPI_CAST_PTR (ACPI_HANDLE, &PrsNode));
932 (void) AcpiGetHandle (Node, METHOD_NAME__AEI,
933 ACPI_CAST_PTR (ACPI_HANDLE, &AeiNode));
935 if (!PrtNode && !CrsNode && !PrsNode && !AeiNode)
937 goto Cleanup; /* Nothing to do */
940 AcpiOsPrintf ("\nDevice: %s\n", ParentPath);
942 /* Prepare for a return object of arbitrary size */
944 ReturnBuffer.Pointer = AcpiGbl_DbBuffer;
945 ReturnBuffer.Length = ACPI_DEBUG_BUFFER_SIZE;
952 AcpiOsPrintf ("Evaluating _PRT\n");
954 Status = AcpiEvaluateObject (PrtNode, NULL, NULL, &ReturnBuffer);
955 if (ACPI_FAILURE (Status))
957 AcpiOsPrintf ("Could not evaluate _PRT: %s\n",
958 AcpiFormatException (Status));
962 ReturnBuffer.Pointer = AcpiGbl_DbBuffer;
963 ReturnBuffer.Length = ACPI_DEBUG_BUFFER_SIZE;
965 Status = AcpiGetIrqRoutingTable (Node, &ReturnBuffer);
966 if (ACPI_FAILURE (Status))
968 AcpiOsPrintf ("GetIrqRoutingTable failed: %s\n",
969 AcpiFormatException (Status));
973 AcpiRsDumpIrqList (ACPI_CAST_PTR (UINT8, AcpiGbl_DbBuffer));
982 AcpiOsPrintf ("Evaluating _CRS\n");
984 ReturnBuffer.Pointer = AcpiGbl_DbBuffer;
985 ReturnBuffer.Length = ACPI_DEBUG_BUFFER_SIZE;
987 Status = AcpiEvaluateObject (CrsNode, NULL, NULL, &ReturnBuffer);
988 if (ACPI_FAILURE (Status))
990 AcpiOsPrintf ("Could not evaluate _CRS: %s\n",
991 AcpiFormatException (Status));
995 /* This code exercises the AcpiWalkResources interface */
997 Status = AcpiWalkResources (Node, METHOD_NAME__CRS,
998 AcpiDbResourceCallback, NULL);
999 if (ACPI_FAILURE (Status))
1001 AcpiOsPrintf ("AcpiWalkResources failed: %s\n",
1002 AcpiFormatException (Status));
1006 /* Get the _CRS resource list (test ALLOCATE buffer) */
1008 ReturnBuffer.Pointer = NULL;
1009 ReturnBuffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
1011 Status = AcpiGetCurrentResources (Node, &ReturnBuffer);
1012 if (ACPI_FAILURE (Status))
1014 AcpiOsPrintf ("AcpiGetCurrentResources failed: %s\n",
1015 AcpiFormatException (Status));
1019 /* This code exercises the AcpiWalkResourceBuffer interface */
1021 Status = AcpiWalkResourceBuffer (&ReturnBuffer,
1022 AcpiDbResourceCallback, NULL);
1023 if (ACPI_FAILURE (Status))
1025 AcpiOsPrintf ("AcpiWalkResourceBuffer failed: %s\n",
1026 AcpiFormatException (Status));
1030 /* Dump the _CRS resource list */
1032 AcpiRsDumpResourceList (ACPI_CAST_PTR (ACPI_RESOURCE,
1033 ReturnBuffer.Pointer));
1036 * Perform comparison of original AML to newly created AML. This
1037 * tests both the AML->Resource conversion and the Resource->AML
1040 (void) AcpiDmTestResourceConversion (Node, METHOD_NAME__CRS);
1042 /* Execute _SRS with the resource list */
1044 AcpiOsPrintf ("Evaluating _SRS\n");
1046 Status = AcpiSetCurrentResources (Node, &ReturnBuffer);
1047 if (ACPI_FAILURE (Status))
1049 AcpiOsPrintf ("AcpiSetCurrentResources failed: %s\n",
1050 AcpiFormatException (Status));
1055 ACPI_FREE (ReturnBuffer.Pointer);
1064 AcpiOsPrintf ("Evaluating _PRS\n");
1066 ReturnBuffer.Pointer = AcpiGbl_DbBuffer;
1067 ReturnBuffer.Length = ACPI_DEBUG_BUFFER_SIZE;
1069 Status = AcpiEvaluateObject (PrsNode, NULL, NULL, &ReturnBuffer);
1070 if (ACPI_FAILURE (Status))
1072 AcpiOsPrintf ("Could not evaluate _PRS: %s\n",
1073 AcpiFormatException (Status));
1077 ReturnBuffer.Pointer = AcpiGbl_DbBuffer;
1078 ReturnBuffer.Length = ACPI_DEBUG_BUFFER_SIZE;
1080 Status = AcpiGetPossibleResources (Node, &ReturnBuffer);
1081 if (ACPI_FAILURE (Status))
1083 AcpiOsPrintf ("AcpiGetPossibleResources failed: %s\n",
1084 AcpiFormatException (Status));
1088 AcpiRsDumpResourceList (ACPI_CAST_PTR (
1089 ACPI_RESOURCE, AcpiGbl_DbBuffer));
1098 AcpiOsPrintf ("Evaluating _AEI\n");
1100 ReturnBuffer.Pointer = AcpiGbl_DbBuffer;
1101 ReturnBuffer.Length = ACPI_DEBUG_BUFFER_SIZE;
1103 Status = AcpiEvaluateObject (AeiNode, NULL, NULL, &ReturnBuffer);
1104 if (ACPI_FAILURE (Status))
1106 AcpiOsPrintf ("Could not evaluate _AEI: %s\n",
1107 AcpiFormatException (Status));
1111 ReturnBuffer.Pointer = AcpiGbl_DbBuffer;
1112 ReturnBuffer.Length = ACPI_DEBUG_BUFFER_SIZE;
1114 Status = AcpiGetEventResources (Node, &ReturnBuffer);
1115 if (ACPI_FAILURE (Status))
1117 AcpiOsPrintf ("AcpiGetEventResources failed: %s\n",
1118 AcpiFormatException (Status));
1122 AcpiRsDumpResourceList (ACPI_CAST_PTR (
1123 ACPI_RESOURCE, AcpiGbl_DbBuffer));
1128 ACPI_FREE (ParentPath);
1133 /*******************************************************************************
1135 * FUNCTION: AcpiDbDisplayResources
1137 * PARAMETERS: ObjectArg - String object name or object pointer.
1138 * NULL or "*" means "display resources for
1143 * DESCRIPTION: Display the resource objects associated with a device.
1145 ******************************************************************************/
1148 AcpiDbDisplayResources (
1151 ACPI_NAMESPACE_NODE *Node;
1154 AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT);
1155 AcpiDbgLevel |= ACPI_LV_RESOURCES;
1157 /* Asterisk means "display resources for all devices" */
1159 if (!ObjectArg || (!strcmp (ObjectArg, "*")))
1161 (void) AcpiWalkNamespace (ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
1162 ACPI_UINT32_MAX, AcpiDbDeviceResources, NULL, NULL, NULL);
1166 /* Convert string to object pointer */
1168 Node = AcpiDbConvertToNode (ObjectArg);
1171 if (Node->Type != ACPI_TYPE_DEVICE)
1174 "%4.4s: Name is not a device object (%s)\n",
1175 Node->Name.Ascii, AcpiUtGetTypeName (Node->Type));
1179 (void) AcpiDbDeviceResources (Node, 0, NULL, NULL);
1184 AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT);
1188 #if (!ACPI_REDUCED_HARDWARE)
1189 /*******************************************************************************
1191 * FUNCTION: AcpiDbGenerateGpe
1193 * PARAMETERS: GpeArg - Raw GPE number, ascii string
1194 * BlockArg - GPE block number, ascii string
1195 * 0 or 1 for FADT GPE blocks
1199 * DESCRIPTION: Simulate firing of a GPE
1201 ******************************************************************************/
1208 UINT32 BlockNumber = 0;
1210 ACPI_GPE_EVENT_INFO *GpeEventInfo;
1213 GpeNumber = strtoul (GpeArg, NULL, 0);
1216 * If no block arg, or block arg == 0 or 1, use the FADT-defined
1221 BlockNumber = strtoul (BlockArg, NULL, 0);
1222 if (BlockNumber == 1)
1228 GpeEventInfo = AcpiEvGetGpeEventInfo (ACPI_TO_POINTER (BlockNumber),
1232 AcpiOsPrintf ("Invalid GPE\n");
1236 (void) AcpiEvGpeDispatch (NULL, GpeEventInfo, GpeNumber);
1240 /*******************************************************************************
1242 * FUNCTION: AcpiDbGenerateSci
1248 * DESCRIPTION: Simulate an SCI -- just call the SCI dispatch.
1250 ******************************************************************************/
1256 AcpiEvSciDispatch ();
1259 #endif /* !ACPI_REDUCED_HARDWARE */
1262 /*******************************************************************************
1264 * FUNCTION: AcpiDbTrace
1266 * PARAMETERS: EnableArg - ENABLE/AML to enable tracer
1267 * DISABLE to disable tracer
1268 * MethodArg - Method to trace
1269 * OnceArg - Whether trace once
1273 * DESCRIPTION: Control method tracing facility
1275 ******************************************************************************/
1283 UINT32 DebugLevel = 0;
1284 UINT32 DebugLayer = 0;
1290 AcpiUtStrupr (EnableArg);
1295 AcpiUtStrupr (OnceArg);
1300 if (AcpiDbTraceMethodName)
1302 ACPI_FREE (AcpiDbTraceMethodName);
1303 AcpiDbTraceMethodName = NULL;
1306 AcpiDbTraceMethodName = ACPI_ALLOCATE (strlen (MethodArg) + 1);
1307 if (!AcpiDbTraceMethodName)
1309 AcpiOsPrintf ("Failed to allocate method name (%s)\n",
1314 strcpy (AcpiDbTraceMethodName, MethodArg);
1317 if (!strcmp (EnableArg, "ENABLE") ||
1318 !strcmp (EnableArg, "METHOD") ||
1319 !strcmp (EnableArg, "OPCODE"))
1321 if (!strcmp (EnableArg, "ENABLE"))
1323 /* Inherit current console settings */
1325 DebugLevel = AcpiGbl_DbConsoleDebugLevel;
1326 DebugLayer = AcpiDbgLayer;
1330 /* Restrict console output to trace points only */
1332 DebugLevel = ACPI_LV_TRACE_POINT;
1333 DebugLayer = ACPI_EXECUTER;
1336 Flags = ACPI_TRACE_ENABLED;
1338 if (!strcmp (EnableArg, "OPCODE"))
1340 Flags |= ACPI_TRACE_OPCODE;
1343 if (OnceArg && !strcmp (OnceArg, "ONCE"))
1345 Flags |= ACPI_TRACE_ONESHOT;
1349 (void) AcpiDebugTrace (AcpiDbTraceMethodName,
1350 DebugLevel, DebugLayer, Flags);
1353 #endif /* ACPI_DEBUGGER */