No empty .Rs/.Re
[netbsd-mini2440.git] / sys / external / intel-public / acpica / dist / debugger / dbcmds.c
blob0f9698567305993a31cefd70097dc997a363dac9
1 /*******************************************************************************
3 * Module Name: dbcmds - debug commands and output routines
5 ******************************************************************************/
7 /******************************************************************************
9 * 1. Copyright Notice
11 * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp.
12 * All rights reserved.
14 * 2. License
16 * 2.1. This is your license from Intel Corp. under its intellectual property
17 * rights. You may have additional license terms from the party that provided
18 * you this software, covering your right to use that party's intellectual
19 * property rights.
21 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
22 * copy of the source code appearing in this file ("Covered Code") an
23 * irrevocable, perpetual, worldwide license under Intel's copyrights in the
24 * base code distributed originally by Intel ("Original Intel Code") to copy,
25 * make derivatives, distribute, use and display any portion of the Covered
26 * Code in any form, with the right to sublicense such rights; and
28 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
29 * license (with the right to sublicense), under only those claims of Intel
30 * patents that are infringed by the Original Intel Code, to make, use, sell,
31 * offer to sell, and import the Covered Code and derivative works thereof
32 * solely to the minimum extent necessary to exercise the above copyright
33 * license, and in no event shall the patent license extend to any additions
34 * to or modifications of the Original Intel Code. No other license or right
35 * is granted directly or by implication, estoppel or otherwise;
37 * The above copyright and patent license is granted only if the following
38 * conditions are met:
40 * 3. Conditions
42 * 3.1. Redistribution of Source with Rights to Further Distribute Source.
43 * Redistribution of source code of any substantial portion of the Covered
44 * Code or modification with rights to further distribute source must include
45 * the above Copyright Notice, the above License, this list of Conditions,
46 * and the following Disclaimer and Export Compliance provision. In addition,
47 * Licensee must cause all Covered Code to which Licensee contributes to
48 * contain a file documenting the changes Licensee made to create that Covered
49 * Code and the date of any change. Licensee must include in that file the
50 * documentation of any changes made by any predecessor Licensee. Licensee
51 * must include a prominent statement that the modification is derived,
52 * directly or indirectly, from Original Intel Code.
54 * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
55 * Redistribution of source code of any substantial portion of the Covered
56 * Code or modification without rights to further distribute source must
57 * include the following Disclaimer and Export Compliance provision in the
58 * documentation and/or other materials provided with distribution. In
59 * addition, Licensee may not authorize further sublicense of source of any
60 * portion of the Covered Code, and must include terms to the effect that the
61 * license from Licensee to its licensee is limited to the intellectual
62 * property embodied in the software Licensee provides to its licensee, and
63 * not to intellectual property embodied in modifications its licensee may
64 * make.
66 * 3.3. Redistribution of Executable. Redistribution in executable form of any
67 * substantial portion of the Covered Code or modification must reproduce the
68 * above Copyright Notice, and the following Disclaimer and Export Compliance
69 * provision in the documentation and/or other materials provided with the
70 * distribution.
72 * 3.4. Intel retains all right, title, and interest in and to the Original
73 * Intel Code.
75 * 3.5. Neither the name Intel nor any other trademark owned or controlled by
76 * Intel shall be used in advertising or otherwise to promote the sale, use or
77 * other dealings in products derived from or relating to the Covered Code
78 * without prior written authorization from Intel.
80 * 4. Disclaimer and Export Compliance
82 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
83 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
84 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
85 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
86 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
87 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
88 * PARTICULAR PURPOSE.
90 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
91 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
92 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
93 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
94 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
95 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
96 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
97 * LIMITED REMEDY.
99 * 4.3. Licensee shall not export, either directly or indirectly, any of this
100 * software or system incorporating such software without first obtaining any
101 * required license or other approval from the U. S. Department of Commerce or
102 * any other agency or department of the United States Government. In the
103 * event Licensee exports any such software from the United States or
104 * re-exports any such software from a foreign destination, Licensee shall
105 * ensure that the distribution and export/re-export of the software is in
106 * compliance with all laws, regulations, orders, or other restrictions of the
107 * U.S. Export Administration Regulations. Licensee agrees that neither it nor
108 * any of its subsidiaries will export/re-export any technical data, process,
109 * software, or service, directly or indirectly, to any country for which the
110 * United States government or any agency thereof requires an export license,
111 * other governmental approval, or letter of assurance, without first obtaining
112 * such license, approval or letter.
114 *****************************************************************************/
117 #include "acpi.h"
118 #include "accommon.h"
119 #include "acdispat.h"
120 #include "acnamesp.h"
121 #include "acevents.h"
122 #include "acdebug.h"
123 #include "acresrc.h"
124 #include "acdisasm.h"
125 #include "actables.h"
126 #include "acparser.h"
128 #ifdef ACPI_DEBUGGER
130 #define _COMPONENT ACPI_CA_DEBUGGER
131 ACPI_MODULE_NAME ("dbcmds")
133 /* Local prototypes */
135 static ACPI_STATUS
136 AcpiDbIntegrityWalk (
137 ACPI_HANDLE ObjHandle,
138 UINT32 NestingLevel,
139 void *Context,
140 void **ReturnValue);
142 static ACPI_STATUS
143 AcpiDbWalkAndMatchName (
144 ACPI_HANDLE ObjHandle,
145 UINT32 NestingLevel,
146 void *Context,
147 void **ReturnValue);
149 static ACPI_STATUS
150 AcpiDbWalkForReferences (
151 ACPI_HANDLE ObjHandle,
152 UINT32 NestingLevel,
153 void *Context,
154 void **ReturnValue);
156 static ACPI_STATUS
157 AcpiDbWalkForSpecificObjects (
158 ACPI_HANDLE ObjHandle,
159 UINT32 NestingLevel,
160 void *Context,
161 void **ReturnValue);
163 static ACPI_NAMESPACE_NODE *
164 AcpiDbConvertToNode (
165 char *InString);
167 static void
168 AcpiDmCompareAmlResources (
169 UINT8 *Aml1Buffer,
170 ACPI_RSDESC_SIZE Aml1BufferLength,
171 UINT8 *Aml2Buffer,
172 ACPI_RSDESC_SIZE Aml2BufferLength);
174 static ACPI_STATUS
175 AcpiDmTestResourceConversion (
176 ACPI_NAMESPACE_NODE *Node,
177 char *Name);
181 * Arguments for the Objects command
182 * These object types map directly to the ACPI_TYPES
184 static ARGUMENT_INFO AcpiDbObjectTypes [] =
186 {"ANY"},
187 {"INTEGERS"},
188 {"STRINGS"},
189 {"BUFFERS"},
190 {"PACKAGES"},
191 {"FIELDS"},
192 {"DEVICES"},
193 {"EVENTS"},
194 {"METHODS"},
195 {"MUTEXES"},
196 {"REGIONS"},
197 {"POWERRESOURCES"},
198 {"PROCESSORS"},
199 {"THERMALZONES"},
200 {"BUFFERFIELDS"},
201 {"DDBHANDLES"},
202 {"DEBUG"},
203 {"REGIONFIELDS"},
204 {"BANKFIELDS"},
205 {"INDEXFIELDS"},
206 {"REFERENCES"},
207 {"ALIAS"},
208 {NULL} /* Must be null terminated */
212 /*******************************************************************************
214 * FUNCTION: AcpiDbConvertToNode
216 * PARAMETERS: InString - String to convert
218 * RETURN: Pointer to a NS node
220 * DESCRIPTION: Convert a string to a valid NS pointer. Handles numeric or
221 * alpha strings.
223 ******************************************************************************/
225 static ACPI_NAMESPACE_NODE *
226 AcpiDbConvertToNode (
227 char *InString)
229 ACPI_NAMESPACE_NODE *Node;
232 if ((*InString >= 0x30) && (*InString <= 0x39))
234 /* Numeric argument, convert */
236 Node = ACPI_TO_POINTER (ACPI_STRTOUL (InString, NULL, 16));
237 if (!AcpiOsReadable (Node, sizeof (ACPI_NAMESPACE_NODE)))
239 AcpiOsPrintf ("Address %p is invalid in this address space\n",
240 Node);
241 return (NULL);
244 /* Make sure pointer is valid NS node */
246 if (ACPI_GET_DESCRIPTOR_TYPE (Node) != ACPI_DESC_TYPE_NAMED)
248 AcpiOsPrintf ("Address %p is not a valid NS node [%s]\n",
249 Node, AcpiUtGetDescriptorName (Node));
250 return (NULL);
253 else
255 /* Alpha argument */
256 /* The parameter is a name string that must be resolved to a
257 * Named obj
259 Node = AcpiDbLocalNsLookup (InString);
260 if (!Node)
262 Node = AcpiGbl_RootNode;
266 return (Node);
270 /*******************************************************************************
272 * FUNCTION: AcpiDbSleep
274 * PARAMETERS: ObjectArg - Desired sleep state (0-5)
276 * RETURN: Status
278 * DESCRIPTION: Simulate a sleep/wake sequence
280 ******************************************************************************/
282 ACPI_STATUS
283 AcpiDbSleep (
284 char *ObjectArg)
286 ACPI_STATUS Status;
287 UINT8 SleepState;
290 SleepState = (UINT8) ACPI_STRTOUL (ObjectArg, NULL, 0);
292 AcpiOsPrintf ("**** Prepare to sleep ****\n");
293 Status = AcpiEnterSleepStatePrep (SleepState);
294 if (ACPI_FAILURE (Status))
296 return (Status);
299 AcpiOsPrintf ("**** Going to sleep ****\n");
300 Status = AcpiEnterSleepState (SleepState);
301 if (ACPI_FAILURE (Status))
303 return (Status);
306 AcpiOsPrintf ("**** returning from sleep ****\n");
307 Status = AcpiLeaveSleepState (SleepState);
309 return (Status);
313 /*******************************************************************************
315 * FUNCTION: AcpiDbWalkForReferences
317 * PARAMETERS: Callback from WalkNamespace
319 * RETURN: Status
321 * DESCRIPTION: Check if this namespace object refers to the target object
322 * that is passed in as the context value.
324 * Note: Currently doesn't check subobjects within the Node's object
326 ******************************************************************************/
328 static ACPI_STATUS
329 AcpiDbWalkForReferences (
330 ACPI_HANDLE ObjHandle,
331 UINT32 NestingLevel,
332 void *Context,
333 void **ReturnValue)
335 ACPI_OPERAND_OBJECT *ObjDesc = (ACPI_OPERAND_OBJECT *) Context;
336 ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle;
339 /* Check for match against the namespace node itself */
341 if (Node == (void *) ObjDesc)
343 AcpiOsPrintf ("Object is a Node [%4.4s]\n",
344 AcpiUtGetNodeName (Node));
347 /* Check for match against the object attached to the node */
349 if (AcpiNsGetAttachedObject (Node) == ObjDesc)
351 AcpiOsPrintf ("Reference at Node->Object %p [%4.4s]\n",
352 Node, AcpiUtGetNodeName (Node));
355 return (AE_OK);
359 /*******************************************************************************
361 * FUNCTION: AcpiDbFindReferences
363 * PARAMETERS: ObjectArg - String with hex value of the object
365 * RETURN: None
367 * DESCRIPTION: Search namespace for all references to the input object
369 ******************************************************************************/
371 void
372 AcpiDbFindReferences (
373 char *ObjectArg)
375 ACPI_OPERAND_OBJECT *ObjDesc;
378 /* Convert string to object pointer */
380 ObjDesc = ACPI_TO_POINTER (ACPI_STRTOUL (ObjectArg, NULL, 16));
382 /* Search all nodes in namespace */
384 (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
385 AcpiDbWalkForReferences, (void *) ObjDesc, NULL);
389 /*******************************************************************************
391 * FUNCTION: AcpiDbWalkForPredefinedNames
393 * PARAMETERS: Callback from WalkNamespace
395 * RETURN: Status
397 * DESCRIPTION: Detect and display predefined ACPI names (names that start with
398 * an underscore)
400 ******************************************************************************/
402 static ACPI_STATUS
403 AcpiDbWalkForPredefinedNames (
404 ACPI_HANDLE ObjHandle,
405 UINT32 NestingLevel,
406 void *Context,
407 void **ReturnValue)
409 ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle;
410 UINT32 *Count = (UINT32 *) Context;
411 const ACPI_PREDEFINED_INFO *Predefined;
412 const ACPI_PREDEFINED_INFO *Package = NULL;
413 char *Pathname;
416 Predefined = AcpiNsCheckForPredefinedName (Node);
417 if (!Predefined)
419 return (AE_OK);
422 Pathname = AcpiNsGetExternalPathname (Node);
423 if (!Pathname)
425 return (AE_OK);
428 /* If method returns a package, the info is in the next table entry */
430 if (Predefined->Info.ExpectedBtypes & ACPI_BTYPE_PACKAGE)
432 Package = Predefined + 1;
435 AcpiOsPrintf ("%-32s arg %X ret %2.2X", Pathname,
436 Predefined->Info.ParamCount, Predefined->Info.ExpectedBtypes);
438 if (Package)
440 AcpiOsPrintf (" PkgType %2.2X ObjType %2.2X Count %2.2X",
441 Package->RetInfo.Type, Package->RetInfo.ObjectType1,
442 Package->RetInfo.Count1);
445 AcpiOsPrintf("\n");
447 AcpiNsCheckParameterCount (Pathname, Node, ACPI_UINT32_MAX, Predefined);
448 ACPI_FREE (Pathname);
449 (*Count)++;
451 return (AE_OK);
455 /*******************************************************************************
457 * FUNCTION: AcpiDbCheckPredefinedNames
459 * PARAMETERS: None
461 * RETURN: None
463 * DESCRIPTION: Validate all predefined names in the namespace
465 ******************************************************************************/
467 void
468 AcpiDbCheckPredefinedNames (
469 void)
471 UINT32 Count = 0;
474 /* Search all nodes in namespace */
476 (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
477 AcpiDbWalkForPredefinedNames, (void *) &Count, NULL);
479 AcpiOsPrintf ("Found %d predefined names in the namespace\n", Count);
483 /*******************************************************************************
485 * FUNCTION: AcpiDbWalkForExecute
487 * PARAMETERS: Callback from WalkNamespace
489 * RETURN: Status
491 * DESCRIPTION: Batch execution module. Currently only executes predefined
492 * ACPI names.
494 ******************************************************************************/
496 static ACPI_STATUS
497 AcpiDbWalkForExecute (
498 ACPI_HANDLE ObjHandle,
499 UINT32 NestingLevel,
500 void *Context,
501 void **ReturnValue)
503 ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle;
504 UINT32 *Count = (UINT32 *) Context;
505 ACPI_BUFFER ReturnObj;
506 ACPI_STATUS Status;
507 char *Pathname;
508 UINT32 i;
509 ACPI_DEVICE_INFO *ObjInfo;
510 ACPI_OBJECT_LIST ParamObjects;
511 ACPI_OBJECT Params[ACPI_METHOD_NUM_ARGS];
512 const ACPI_PREDEFINED_INFO *Predefined;
515 Predefined = AcpiNsCheckForPredefinedName (Node);
516 if (!Predefined)
518 return (AE_OK);
521 if (Node->Type == ACPI_TYPE_LOCAL_SCOPE)
523 return (AE_OK);
526 Pathname = AcpiNsGetExternalPathname (Node);
527 if (!Pathname)
529 return (AE_OK);
532 /* Get the object info for number of method parameters */
534 Status = AcpiGetObjectInfo (ObjHandle, &ObjInfo);
535 if (ACPI_FAILURE (Status))
537 return (Status);
540 ParamObjects.Pointer = NULL;
541 ParamObjects.Count = 0;
543 if (ObjInfo->Type == ACPI_TYPE_METHOD)
546 /* Setup default parameters */
548 for (i = 0; i < ObjInfo->ParamCount; i++)
550 Params[i].Type = ACPI_TYPE_INTEGER;
551 Params[i].Integer.Value = 1;
554 ParamObjects.Pointer = Params;
555 ParamObjects.Count = ObjInfo->ParamCount;
558 ACPI_FREE (ObjInfo);
560 ReturnObj.Pointer = NULL;
561 ReturnObj.Length = ACPI_ALLOCATE_BUFFER;
564 /* Do the actual method execution */
566 AcpiGbl_MethodExecuting = TRUE;
568 Status = AcpiEvaluateObject (Node, NULL, &ParamObjects, &ReturnObj);
570 AcpiOsPrintf ("%-32s returned %s\n", Pathname, AcpiFormatException (Status));
571 AcpiGbl_MethodExecuting = FALSE;
573 ACPI_FREE (Pathname);
574 (*Count)++;
576 return (AE_OK);
580 /*******************************************************************************
582 * FUNCTION: AcpiDbBatchExecute
584 * PARAMETERS: None
586 * RETURN: None
588 * DESCRIPTION: Namespace batch execution.
590 ******************************************************************************/
592 void
593 AcpiDbBatchExecute (
594 void)
596 UINT32 Count = 0;
599 /* Search all nodes in namespace */
601 (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
602 AcpiDbWalkForExecute, (void *) &Count, NULL);
604 AcpiOsPrintf ("Executed %d predefined names in the namespace\n", Count);
608 /*******************************************************************************
610 * FUNCTION: AcpiDbDisplayLocks
612 * PARAMETERS: None
614 * RETURN: None
616 * DESCRIPTION: Display information about internal mutexes.
618 ******************************************************************************/
620 void
621 AcpiDbDisplayLocks (
622 void)
624 UINT32 i;
627 for (i = 0; i < ACPI_MAX_MUTEX; i++)
629 AcpiOsPrintf ("%26s : %s\n", AcpiUtGetMutexName (i),
630 AcpiGbl_MutexInfo[i].ThreadId == ACPI_MUTEX_NOT_ACQUIRED
631 ? "Locked" : "Unlocked");
636 /*******************************************************************************
638 * FUNCTION: AcpiDbDisplayTableInfo
640 * PARAMETERS: TableArg - String with name of table to be displayed
642 * RETURN: None
644 * DESCRIPTION: Display information about loaded tables. Current
645 * implementation displays all loaded tables.
647 ******************************************************************************/
649 void
650 AcpiDbDisplayTableInfo (
651 char *TableArg)
653 UINT32 i;
654 ACPI_TABLE_DESC *TableDesc;
655 ACPI_STATUS Status;
658 /* Walk the entire root table list */
660 for (i = 0; i < AcpiGbl_RootTableList.Count; i++)
662 TableDesc = &AcpiGbl_RootTableList.Tables[i];
663 AcpiOsPrintf ("%d ", i);
665 /* Make sure that the table is mapped */
667 Status = AcpiTbVerifyTable (TableDesc);
668 if (ACPI_FAILURE (Status))
670 return;
673 /* Dump the table header */
675 if (TableDesc->Pointer)
677 AcpiTbPrintTableHeader (TableDesc->Address, TableDesc->Pointer);
679 else
681 /* If the pointer is null, the table has been unloaded */
683 ACPI_INFO ((AE_INFO, "%4.4s - Table has been unloaded",
684 TableDesc->Signature.Ascii));
690 /*******************************************************************************
692 * FUNCTION: AcpiDbUnloadAcpiTable
694 * PARAMETERS: TableArg - Name of the table to be unloaded
695 * InstanceArg - Which instance of the table to unload (if
696 * there are multiple tables of the same type)
698 * RETURN: Nonde
700 * DESCRIPTION: Unload an ACPI table.
701 * Instance is not implemented
703 ******************************************************************************/
705 void
706 AcpiDbUnloadAcpiTable (
707 char *TableArg,
708 char *InstanceArg)
710 /* TBD: Need to reimplement for new data structures */
712 #if 0
713 UINT32 i;
714 ACPI_STATUS Status;
717 /* Search all tables for the target type */
719 for (i = 0; i < (ACPI_TABLE_ID_MAX+1); i++)
721 if (!ACPI_STRNCMP (TableArg, AcpiGbl_TableData[i].Signature,
722 AcpiGbl_TableData[i].SigLength))
724 /* Found the table, unload it */
726 Status = AcpiUnloadTable (i);
727 if (ACPI_SUCCESS (Status))
729 AcpiOsPrintf ("[%s] unloaded and uninstalled\n", TableArg);
731 else
733 AcpiOsPrintf ("%s, while unloading [%s]\n",
734 AcpiFormatException (Status), TableArg);
737 return;
741 AcpiOsPrintf ("Unknown table type [%s]\n", TableArg);
742 #endif
746 /*******************************************************************************
748 * FUNCTION: AcpiDbSetMethodBreakpoint
750 * PARAMETERS: Location - AML offset of breakpoint
751 * WalkState - Current walk info
752 * Op - Current Op (from parse walk)
754 * RETURN: None
756 * DESCRIPTION: Set a breakpoint in a control method at the specified
757 * AML offset
759 ******************************************************************************/
761 void
762 AcpiDbSetMethodBreakpoint (
763 char *Location,
764 ACPI_WALK_STATE *WalkState,
765 ACPI_PARSE_OBJECT *Op)
767 UINT32 Address;
770 if (!Op)
772 AcpiOsPrintf ("There is no method currently executing\n");
773 return;
776 /* Get and verify the breakpoint address */
778 Address = ACPI_STRTOUL (Location, NULL, 16);
779 if (Address <= Op->Common.AmlOffset)
781 AcpiOsPrintf ("Breakpoint %X is beyond current address %X\n",
782 Address, Op->Common.AmlOffset);
785 /* Save breakpoint in current walk */
787 WalkState->UserBreakpoint = Address;
788 AcpiOsPrintf ("Breakpoint set at AML offset %X\n", Address);
792 /*******************************************************************************
794 * FUNCTION: AcpiDbSetMethodCallBreakpoint
796 * PARAMETERS: Op - Current Op (from parse walk)
798 * RETURN: None
800 * DESCRIPTION: Set a breakpoint in a control method at the specified
801 * AML offset
803 ******************************************************************************/
805 void
806 AcpiDbSetMethodCallBreakpoint (
807 ACPI_PARSE_OBJECT *Op)
811 if (!Op)
813 AcpiOsPrintf ("There is no method currently executing\n");
814 return;
817 AcpiGbl_StepToNextCall = TRUE;
821 /*******************************************************************************
823 * FUNCTION: AcpiDbDisassembleAml
825 * PARAMETERS: Statements - Number of statements to disassemble
826 * Op - Current Op (from parse walk)
828 * RETURN: None
830 * DESCRIPTION: Display disassembled AML (ASL) starting from Op for the number
831 * of statements specified.
833 ******************************************************************************/
835 void
836 AcpiDbDisassembleAml (
837 char *Statements,
838 ACPI_PARSE_OBJECT *Op)
840 UINT32 NumStatements = 8;
843 if (!Op)
845 AcpiOsPrintf ("There is no method currently executing\n");
846 return;
849 if (Statements)
851 NumStatements = ACPI_STRTOUL (Statements, NULL, 0);
854 AcpiDmDisassemble (NULL, Op, NumStatements);
858 /*******************************************************************************
860 * FUNCTION: AcpiDbDisassembleMethod
862 * PARAMETERS: Name - Name of control method
864 * RETURN: None
866 * DESCRIPTION: Display disassembled AML (ASL) starting from Op for the number
867 * of statements specified.
869 ******************************************************************************/
871 ACPI_STATUS
872 AcpiDbDisassembleMethod (
873 char *Name)
875 ACPI_STATUS Status;
876 ACPI_PARSE_OBJECT *Op;
877 ACPI_WALK_STATE *WalkState;
878 ACPI_OPERAND_OBJECT *ObjDesc;
879 ACPI_NAMESPACE_NODE *Method;
882 Method = AcpiDbConvertToNode (Name);
883 if (!Method)
885 return (AE_BAD_PARAMETER);
888 ObjDesc = Method->Object;
890 Op = AcpiPsCreateScopeOp ();
891 if (!Op)
893 return (AE_NO_MEMORY);
896 /* Create and initialize a new walk state */
898 WalkState = AcpiDsCreateWalkState (0, Op, NULL, NULL);
899 if (!WalkState)
901 return (AE_NO_MEMORY);
904 Status = AcpiDsInitAmlWalk (WalkState, Op, NULL,
905 ObjDesc->Method.AmlStart,
906 ObjDesc->Method.AmlLength, NULL, ACPI_IMODE_LOAD_PASS1);
907 if (ACPI_FAILURE (Status))
909 return (Status);
912 /* Parse the AML */
914 WalkState->ParseFlags &= ~ACPI_PARSE_DELETE_TREE;
915 WalkState->ParseFlags |= ACPI_PARSE_DISASSEMBLE;
916 Status = AcpiPsParseAml (WalkState);
918 AcpiDmDisassemble (NULL, Op, 0);
919 AcpiPsDeleteParseTree (Op);
920 return (AE_OK);
924 /*******************************************************************************
926 * FUNCTION: AcpiDbDumpNamespace
928 * PARAMETERS: StartArg - Node to begin namespace dump
929 * DepthArg - Maximum tree depth to be dumped
931 * RETURN: None
933 * DESCRIPTION: Dump entire namespace or a subtree. Each node is displayed
934 * with type and other information.
936 ******************************************************************************/
938 void
939 AcpiDbDumpNamespace (
940 char *StartArg,
941 char *DepthArg)
943 ACPI_HANDLE SubtreeEntry = AcpiGbl_RootNode;
944 UINT32 MaxDepth = ACPI_UINT32_MAX;
947 /* No argument given, just start at the root and dump entire namespace */
949 if (StartArg)
951 SubtreeEntry = AcpiDbConvertToNode (StartArg);
952 if (!SubtreeEntry)
954 return;
957 /* Now we can check for the depth argument */
959 if (DepthArg)
961 MaxDepth = ACPI_STRTOUL (DepthArg, NULL, 0);
965 AcpiDbSetOutputDestination (ACPI_DB_DUPLICATE_OUTPUT);
966 AcpiOsPrintf ("ACPI Namespace (from %4.4s (%p) subtree):\n",
967 ((ACPI_NAMESPACE_NODE *) SubtreeEntry)->Name.Ascii, SubtreeEntry);
969 /* Display the subtree */
971 AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT);
972 AcpiNsDumpObjects (ACPI_TYPE_ANY, ACPI_DISPLAY_SUMMARY, MaxDepth,
973 ACPI_OWNER_ID_MAX, SubtreeEntry);
974 AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT);
978 /*******************************************************************************
980 * FUNCTION: AcpiDbDumpNamespaceByOwner
982 * PARAMETERS: OwnerArg - Owner ID whose nodes will be displayed
983 * DepthArg - Maximum tree depth to be dumped
985 * RETURN: None
987 * DESCRIPTION: Dump elements of the namespace that are owned by the OwnerId.
989 ******************************************************************************/
991 void
992 AcpiDbDumpNamespaceByOwner (
993 char *OwnerArg,
994 char *DepthArg)
996 ACPI_HANDLE SubtreeEntry = AcpiGbl_RootNode;
997 UINT32 MaxDepth = ACPI_UINT32_MAX;
998 ACPI_OWNER_ID OwnerId;
1001 OwnerId = (ACPI_OWNER_ID) ACPI_STRTOUL (OwnerArg, NULL, 0);
1003 /* Now we can check for the depth argument */
1005 if (DepthArg)
1007 MaxDepth = ACPI_STRTOUL (DepthArg, NULL, 0);
1010 AcpiDbSetOutputDestination (ACPI_DB_DUPLICATE_OUTPUT);
1011 AcpiOsPrintf ("ACPI Namespace by owner %X:\n", OwnerId);
1013 /* Display the subtree */
1015 AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT);
1016 AcpiNsDumpObjects (ACPI_TYPE_ANY, ACPI_DISPLAY_SUMMARY, MaxDepth, OwnerId,
1017 SubtreeEntry);
1018 AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT);
1022 /*******************************************************************************
1024 * FUNCTION: AcpiDbSendNotify
1026 * PARAMETERS: Name - Name of ACPI object to send the notify to
1027 * Value - Value of the notify to send.
1029 * RETURN: None
1031 * DESCRIPTION: Send an ACPI notification. The value specified is sent to the
1032 * named object as an ACPI notify.
1034 ******************************************************************************/
1036 void
1037 AcpiDbSendNotify (
1038 char *Name,
1039 UINT32 Value)
1041 ACPI_NAMESPACE_NODE *Node;
1042 ACPI_STATUS Status;
1045 /* Translate name to an Named object */
1047 Node = AcpiDbConvertToNode (Name);
1048 if (!Node)
1050 return;
1053 /* Decode Named object type */
1055 switch (Node->Type)
1057 case ACPI_TYPE_DEVICE:
1058 case ACPI_TYPE_THERMAL:
1060 /* Send the notify */
1062 Status = AcpiEvQueueNotifyRequest (Node, Value);
1063 if (ACPI_FAILURE (Status))
1065 AcpiOsPrintf ("Could not queue notify\n");
1067 break;
1069 default:
1070 AcpiOsPrintf ("Named object is not a device or a thermal object\n");
1071 break;
1076 /*******************************************************************************
1078 * FUNCTION: AcpiDbSetMethodData
1080 * PARAMETERS: TypeArg - L for local, A for argument
1081 * IndexArg - which one
1082 * ValueArg - Value to set.
1084 * RETURN: None
1086 * DESCRIPTION: Set a local or argument for the running control method.
1087 * NOTE: only object supported is Number.
1089 ******************************************************************************/
1091 void
1092 AcpiDbSetMethodData (
1093 char *TypeArg,
1094 char *IndexArg,
1095 char *ValueArg)
1097 char Type;
1098 UINT32 Index;
1099 UINT32 Value;
1100 ACPI_WALK_STATE *WalkState;
1101 ACPI_OPERAND_OBJECT *ObjDesc;
1102 ACPI_STATUS Status;
1103 ACPI_NAMESPACE_NODE *Node;
1106 /* Validate TypeArg */
1108 AcpiUtStrupr (TypeArg);
1109 Type = TypeArg[0];
1110 if ((Type != 'L') &&
1111 (Type != 'A') &&
1112 (Type != 'N'))
1114 AcpiOsPrintf ("Invalid SET operand: %s\n", TypeArg);
1115 return;
1118 Value = ACPI_STRTOUL (ValueArg, NULL, 16);
1120 if (Type == 'N')
1122 Node = AcpiDbConvertToNode (IndexArg);
1123 if (Node->Type != ACPI_TYPE_INTEGER)
1125 AcpiOsPrintf ("Can only set Integer nodes\n");
1126 return;
1128 ObjDesc = Node->Object;
1129 ObjDesc->Integer.Value = Value;
1130 return;
1133 /* Get the index and value */
1135 Index = ACPI_STRTOUL (IndexArg, NULL, 16);
1137 WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList);
1138 if (!WalkState)
1140 AcpiOsPrintf ("There is no method currently executing\n");
1141 return;
1144 /* Create and initialize the new object */
1146 ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER);
1147 if (!ObjDesc)
1149 AcpiOsPrintf ("Could not create an internal object\n");
1150 return;
1153 ObjDesc->Integer.Value = Value;
1155 /* Store the new object into the target */
1157 switch (Type)
1159 case 'A':
1161 /* Set a method argument */
1163 if (Index > ACPI_METHOD_MAX_ARG)
1165 AcpiOsPrintf ("Arg%d - Invalid argument name\n", Index);
1166 goto Cleanup;
1169 Status = AcpiDsStoreObjectToLocal (ACPI_REFCLASS_ARG, Index, ObjDesc,
1170 WalkState);
1171 if (ACPI_FAILURE (Status))
1173 goto Cleanup;
1176 ObjDesc = WalkState->Arguments[Index].Object;
1178 AcpiOsPrintf ("Arg%d: ", Index);
1179 AcpiDmDisplayInternalObject (ObjDesc, WalkState);
1180 break;
1182 case 'L':
1184 /* Set a method local */
1186 if (Index > ACPI_METHOD_MAX_LOCAL)
1188 AcpiOsPrintf ("Local%d - Invalid local variable name\n", Index);
1189 goto Cleanup;
1192 Status = AcpiDsStoreObjectToLocal (ACPI_REFCLASS_LOCAL, Index, ObjDesc,
1193 WalkState);
1194 if (ACPI_FAILURE (Status))
1196 goto Cleanup;
1199 ObjDesc = WalkState->LocalVariables[Index].Object;
1201 AcpiOsPrintf ("Local%d: ", Index);
1202 AcpiDmDisplayInternalObject (ObjDesc, WalkState);
1203 break;
1205 default:
1206 break;
1209 Cleanup:
1210 AcpiUtRemoveReference (ObjDesc);
1214 /*******************************************************************************
1216 * FUNCTION: AcpiDbWalkForSpecificObjects
1218 * PARAMETERS: Callback from WalkNamespace
1220 * RETURN: Status
1222 * DESCRIPTION: Display short info about objects in the namespace
1224 ******************************************************************************/
1226 static ACPI_STATUS
1227 AcpiDbWalkForSpecificObjects (
1228 ACPI_HANDLE ObjHandle,
1229 UINT32 NestingLevel,
1230 void *Context,
1231 void **ReturnValue)
1233 ACPI_WALK_INFO *Info = (ACPI_WALK_INFO *) Context;
1234 ACPI_BUFFER Buffer;
1235 ACPI_STATUS Status;
1238 Info->Count++;
1240 /* Get and display the full pathname to this object */
1242 Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
1243 Status = AcpiNsHandleToPathname (ObjHandle, &Buffer);
1244 if (ACPI_FAILURE (Status))
1246 AcpiOsPrintf ("Could Not get pathname for object %p\n", ObjHandle);
1247 return (AE_OK);
1250 AcpiOsPrintf ("%32s", (char *) Buffer.Pointer);
1251 ACPI_FREE (Buffer.Pointer);
1253 /* Dump short info about the object */
1255 (void) AcpiNsDumpOneObject (ObjHandle, NestingLevel, Info, NULL);
1256 return (AE_OK);
1260 /*******************************************************************************
1262 * FUNCTION: AcpiDbDisplayObjects
1264 * PARAMETERS: ObjTypeArg - Type of object to display
1265 * DisplayCountArg - Max depth to display
1267 * RETURN: None
1269 * DESCRIPTION: Display objects in the namespace of the requested type
1271 ******************************************************************************/
1273 ACPI_STATUS
1274 AcpiDbDisplayObjects (
1275 char *ObjTypeArg,
1276 char *DisplayCountArg)
1278 ACPI_WALK_INFO Info;
1279 ACPI_OBJECT_TYPE Type;
1282 /* Get the object type */
1284 Type = AcpiDbMatchArgument (ObjTypeArg, AcpiDbObjectTypes);
1285 if (Type == ACPI_TYPE_NOT_FOUND)
1287 AcpiOsPrintf ("Invalid or unsupported argument\n");
1288 return (AE_OK);
1291 AcpiDbSetOutputDestination (ACPI_DB_DUPLICATE_OUTPUT);
1292 AcpiOsPrintf (
1293 "Objects of type [%s] defined in the current ACPI Namespace:\n",
1294 AcpiUtGetTypeName (Type));
1296 AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT);
1298 Info.Count = 0;
1299 Info.OwnerId = ACPI_OWNER_ID_MAX;
1300 Info.DebugLevel = ACPI_UINT32_MAX;
1301 Info.DisplayType = ACPI_DISPLAY_SUMMARY | ACPI_DISPLAY_SHORT;
1303 /* Walk the namespace from the root */
1305 (void) AcpiWalkNamespace (Type, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
1306 AcpiDbWalkForSpecificObjects, (void *) &Info, NULL);
1308 AcpiOsPrintf (
1309 "\nFound %u objects of type [%s] in the current ACPI Namespace\n",
1310 Info.Count, AcpiUtGetTypeName (Type));
1312 AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT);
1313 return (AE_OK);
1317 /*******************************************************************************
1319 * FUNCTION: AcpiDbWalkAndMatchName
1321 * PARAMETERS: Callback from WalkNamespace
1323 * RETURN: Status
1325 * DESCRIPTION: Find a particular name/names within the namespace. Wildcards
1326 * are supported -- '?' matches any character.
1328 ******************************************************************************/
1330 static ACPI_STATUS
1331 AcpiDbWalkAndMatchName (
1332 ACPI_HANDLE ObjHandle,
1333 UINT32 NestingLevel,
1334 void *Context,
1335 void **ReturnValue)
1337 ACPI_STATUS Status;
1338 char *RequestedName = (char *) Context;
1339 UINT32 i;
1340 ACPI_BUFFER Buffer;
1341 ACPI_WALK_INFO Info;
1344 /* Check for a name match */
1346 for (i = 0; i < 4; i++)
1348 /* Wildcard support */
1350 if ((RequestedName[i] != '?') &&
1351 (RequestedName[i] != ((ACPI_NAMESPACE_NODE *) ObjHandle)->Name.Ascii[i]))
1353 /* No match, just exit */
1355 return (AE_OK);
1359 /* Get the full pathname to this object */
1361 Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
1362 Status = AcpiNsHandleToPathname (ObjHandle, &Buffer);
1363 if (ACPI_FAILURE (Status))
1365 AcpiOsPrintf ("Could Not get pathname for object %p\n", ObjHandle);
1367 else
1369 Info.OwnerId = ACPI_OWNER_ID_MAX;
1370 Info.DebugLevel = ACPI_UINT32_MAX;
1371 Info.DisplayType = ACPI_DISPLAY_SUMMARY | ACPI_DISPLAY_SHORT;
1373 AcpiOsPrintf ("%32s", (char *) Buffer.Pointer);
1374 (void) AcpiNsDumpOneObject (ObjHandle, NestingLevel, &Info, NULL);
1375 ACPI_FREE (Buffer.Pointer);
1378 return (AE_OK);
1382 /*******************************************************************************
1384 * FUNCTION: AcpiDbFindNameInNamespace
1386 * PARAMETERS: NameArg - The 4-character ACPI name to find.
1387 * wildcards are supported.
1389 * RETURN: None
1391 * DESCRIPTION: Search the namespace for a given name (with wildcards)
1393 ******************************************************************************/
1395 ACPI_STATUS
1396 AcpiDbFindNameInNamespace (
1397 char *NameArg)
1399 char AcpiName[5] = "____";
1400 char *AcpiNamePtr = AcpiName;
1403 if (ACPI_STRLEN (NameArg) > 4)
1405 AcpiOsPrintf ("Name must be no longer than 4 characters\n");
1406 return (AE_OK);
1409 /* Pad out name with underscores as necessary to create a 4-char name */
1411 AcpiUtStrupr (NameArg);
1412 while (*NameArg)
1414 *AcpiNamePtr = *NameArg;
1415 AcpiNamePtr++;
1416 NameArg++;
1419 /* Walk the namespace from the root */
1421 (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
1422 AcpiDbWalkAndMatchName, AcpiName, NULL);
1424 AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT);
1425 return (AE_OK);
1429 /*******************************************************************************
1431 * FUNCTION: AcpiDbSetScope
1433 * PARAMETERS: Name - New scope path
1435 * RETURN: Status
1437 * DESCRIPTION: Set the "current scope" as maintained by this utility.
1438 * The scope is used as a prefix to ACPI paths.
1440 ******************************************************************************/
1442 void
1443 AcpiDbSetScope (
1444 char *Name)
1446 ACPI_STATUS Status;
1447 ACPI_NAMESPACE_NODE *Node;
1450 if (!Name || Name[0] == 0)
1452 AcpiOsPrintf ("Current scope: %s\n", AcpiGbl_DbScopeBuf);
1453 return;
1456 AcpiDbPrepNamestring (Name);
1458 if (Name[0] == '\\')
1460 /* Validate new scope from the root */
1462 Status = AcpiNsGetNode (AcpiGbl_RootNode, Name, ACPI_NS_NO_UPSEARCH,
1463 &Node);
1464 if (ACPI_FAILURE (Status))
1466 goto ErrorExit;
1469 ACPI_STRCPY (AcpiGbl_DbScopeBuf, Name);
1470 ACPI_STRCAT (AcpiGbl_DbScopeBuf, "\\");
1472 else
1474 /* Validate new scope relative to old scope */
1476 Status = AcpiNsGetNode (AcpiGbl_DbScopeNode, Name, ACPI_NS_NO_UPSEARCH,
1477 &Node);
1478 if (ACPI_FAILURE (Status))
1480 goto ErrorExit;
1483 ACPI_STRCAT (AcpiGbl_DbScopeBuf, Name);
1484 ACPI_STRCAT (AcpiGbl_DbScopeBuf, "\\");
1487 AcpiGbl_DbScopeNode = Node;
1488 AcpiOsPrintf ("New scope: %s\n", AcpiGbl_DbScopeBuf);
1489 return;
1491 ErrorExit:
1493 AcpiOsPrintf ("Could not attach scope: %s, %s\n",
1494 Name, AcpiFormatException (Status));
1498 /*******************************************************************************
1500 * FUNCTION: AcpiDmCompareAmlResources
1502 * PARAMETERS: Aml1Buffer - Contains first resource list
1503 * Aml1BufferLength - Length of first resource list
1504 * Aml2Buffer - Contains second resource list
1505 * Aml2BufferLength - Length of second resource list
1507 * RETURN: None
1509 * DESCRIPTION: Compare two AML resource lists, descriptor by descriptor (in
1510 * order to isolate a miscompare to an individual resource)
1512 ******************************************************************************/
1514 static void
1515 AcpiDmCompareAmlResources (
1516 UINT8 *Aml1Buffer,
1517 ACPI_RSDESC_SIZE Aml1BufferLength,
1518 UINT8 *Aml2Buffer,
1519 ACPI_RSDESC_SIZE Aml2BufferLength)
1521 UINT8 *Aml1;
1522 UINT8 *Aml2;
1523 ACPI_RSDESC_SIZE Aml1Length;
1524 ACPI_RSDESC_SIZE Aml2Length;
1525 ACPI_RSDESC_SIZE Offset = 0;
1526 UINT8 ResourceType;
1527 UINT32 Count = 0;
1530 /* Compare overall buffer sizes (may be different due to size rounding) */
1532 if (Aml1BufferLength != Aml2BufferLength)
1534 AcpiOsPrintf (
1535 "**** Buffer length mismatch in converted AML: original %X new %X ****\n",
1536 Aml1BufferLength, Aml2BufferLength);
1539 Aml1 = Aml1Buffer;
1540 Aml2 = Aml2Buffer;
1542 /* Walk the descriptor lists, comparing each descriptor */
1544 while (Aml1 < (Aml1Buffer + Aml1BufferLength))
1546 /* Get the lengths of each descriptor */
1548 Aml1Length = AcpiUtGetDescriptorLength (Aml1);
1549 Aml2Length = AcpiUtGetDescriptorLength (Aml2);
1550 ResourceType = AcpiUtGetResourceType (Aml1);
1552 /* Check for descriptor length match */
1554 if (Aml1Length != Aml2Length)
1556 AcpiOsPrintf (
1557 "**** Length mismatch in descriptor [%.2X] type %2.2X, Offset %8.8X L1 %X L2 %X ****\n",
1558 Count, ResourceType, Offset, Aml1Length, Aml2Length);
1561 /* Check for descriptor byte match */
1563 else if (ACPI_MEMCMP (Aml1, Aml2, Aml1Length))
1565 AcpiOsPrintf (
1566 "**** Data mismatch in descriptor [%.2X] type %2.2X, Offset %8.8X ****\n",
1567 Count, ResourceType, Offset);
1570 /* Exit on EndTag descriptor */
1572 if (ResourceType == ACPI_RESOURCE_NAME_END_TAG)
1574 return;
1577 /* Point to next descriptor in each buffer */
1579 Count++;
1580 Offset += Aml1Length;
1581 Aml1 += Aml1Length;
1582 Aml2 += Aml2Length;
1587 /*******************************************************************************
1589 * FUNCTION: AcpiDmTestResourceConversion
1591 * PARAMETERS: Node - Parent device node
1592 * Name - resource method name (_CRS)
1594 * RETURN: Status
1596 * DESCRIPTION: Compare the original AML with a conversion of the AML to
1597 * internal resource list, then back to AML.
1599 ******************************************************************************/
1601 static ACPI_STATUS
1602 AcpiDmTestResourceConversion (
1603 ACPI_NAMESPACE_NODE *Node,
1604 char *Name)
1606 ACPI_STATUS Status;
1607 ACPI_BUFFER ReturnObj;
1608 ACPI_BUFFER ResourceObj;
1609 ACPI_BUFFER NewAml;
1610 ACPI_OBJECT *OriginalAml;
1613 AcpiOsPrintf ("Resource Conversion Comparison:\n");
1615 NewAml.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
1616 ReturnObj.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
1617 ResourceObj.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
1619 /* Get the original _CRS AML resource template */
1621 Status = AcpiEvaluateObject (Node, Name, NULL, &ReturnObj);
1622 if (ACPI_FAILURE (Status))
1624 AcpiOsPrintf ("Could not obtain %s: %s\n",
1625 Name, AcpiFormatException (Status));
1626 return (Status);
1629 /* Get the AML resource template, converted to internal resource structs */
1631 Status = AcpiGetCurrentResources (Node, &ResourceObj);
1632 if (ACPI_FAILURE (Status))
1634 AcpiOsPrintf ("AcpiGetCurrentResources failed: %s\n",
1635 AcpiFormatException (Status));
1636 goto Exit1;
1639 /* Convert internal resource list to external AML resource template */
1641 Status = AcpiRsCreateAmlResources (ResourceObj.Pointer, &NewAml);
1642 if (ACPI_FAILURE (Status))
1644 AcpiOsPrintf ("AcpiRsCreateAmlResources failed: %s\n",
1645 AcpiFormatException (Status));
1646 goto Exit2;
1649 /* Compare original AML to the newly created AML resource list */
1651 OriginalAml = ReturnObj.Pointer;
1653 AcpiDmCompareAmlResources (
1654 OriginalAml->Buffer.Pointer, (ACPI_RSDESC_SIZE) OriginalAml->Buffer.Length,
1655 NewAml.Pointer, (ACPI_RSDESC_SIZE) NewAml.Length);
1657 /* Cleanup and exit */
1659 ACPI_FREE (NewAml.Pointer);
1660 Exit2:
1661 ACPI_FREE (ResourceObj.Pointer);
1662 Exit1:
1663 ACPI_FREE (ReturnObj.Pointer);
1664 return (Status);
1668 /*******************************************************************************
1670 * FUNCTION: AcpiDbDisplayResources
1672 * PARAMETERS: ObjectArg - String with hex value of the object
1674 * RETURN: None
1676 * DESCRIPTION: Display the resource objects associated with a device.
1678 ******************************************************************************/
1680 void
1681 AcpiDbDisplayResources (
1682 char *ObjectArg)
1684 ACPI_NAMESPACE_NODE *Node;
1685 ACPI_STATUS Status;
1686 ACPI_BUFFER ReturnObj;
1689 AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT);
1690 AcpiDbgLevel |= ACPI_LV_RESOURCES;
1692 /* Convert string to object pointer */
1694 Node = AcpiDbConvertToNode (ObjectArg);
1695 if (!Node)
1697 return;
1700 /* Prepare for a return object of arbitrary size */
1702 ReturnObj.Pointer = AcpiGbl_DbBuffer;
1703 ReturnObj.Length = ACPI_DEBUG_BUFFER_SIZE;
1705 /* _PRT */
1707 AcpiOsPrintf ("Evaluating _PRT\n");
1709 /* Check if _PRT exists */
1711 Status = AcpiEvaluateObject (Node, METHOD_NAME__PRT, NULL, &ReturnObj);
1712 if (ACPI_FAILURE (Status))
1714 AcpiOsPrintf ("Could not obtain _PRT: %s\n",
1715 AcpiFormatException (Status));
1716 goto GetCrs;
1719 ReturnObj.Pointer = AcpiGbl_DbBuffer;
1720 ReturnObj.Length = ACPI_DEBUG_BUFFER_SIZE;
1722 Status = AcpiGetIrqRoutingTable (Node, &ReturnObj);
1723 if (ACPI_FAILURE (Status))
1725 AcpiOsPrintf ("GetIrqRoutingTable failed: %s\n",
1726 AcpiFormatException (Status));
1727 goto GetCrs;
1730 AcpiRsDumpIrqList (ACPI_CAST_PTR (UINT8, AcpiGbl_DbBuffer));
1733 /* _CRS */
1735 GetCrs:
1736 AcpiOsPrintf ("Evaluating _CRS\n");
1738 ReturnObj.Pointer = AcpiGbl_DbBuffer;
1739 ReturnObj.Length = ACPI_DEBUG_BUFFER_SIZE;
1741 /* Check if _CRS exists */
1743 Status = AcpiEvaluateObject (Node, METHOD_NAME__CRS, NULL, &ReturnObj);
1744 if (ACPI_FAILURE (Status))
1746 AcpiOsPrintf ("Could not obtain _CRS: %s\n",
1747 AcpiFormatException (Status));
1748 goto GetPrs;
1751 /* Get the _CRS resource list */
1753 ReturnObj.Pointer = AcpiGbl_DbBuffer;
1754 ReturnObj.Length = ACPI_DEBUG_BUFFER_SIZE;
1756 Status = AcpiGetCurrentResources (Node, &ReturnObj);
1757 if (ACPI_FAILURE (Status))
1759 AcpiOsPrintf ("AcpiGetCurrentResources failed: %s\n",
1760 AcpiFormatException (Status));
1761 goto GetPrs;
1764 /* Dump the _CRS resource list */
1766 AcpiRsDumpResourceList (ACPI_CAST_PTR (ACPI_RESOURCE,
1767 ReturnObj.Pointer));
1770 * Perform comparison of original AML to newly created AML. This tests both
1771 * the AML->Resource conversion and the Resource->Aml conversion.
1773 Status = AcpiDmTestResourceConversion (Node, __UNCONST(METHOD_NAME__CRS));
1775 /* Execute _SRS with the resource list */
1777 Status = AcpiSetCurrentResources (Node, &ReturnObj);
1778 if (ACPI_FAILURE (Status))
1780 AcpiOsPrintf ("AcpiSetCurrentResources failed: %s\n",
1781 AcpiFormatException (Status));
1782 goto GetPrs;
1786 /* _PRS */
1788 GetPrs:
1789 AcpiOsPrintf ("Evaluating _PRS\n");
1791 ReturnObj.Pointer = AcpiGbl_DbBuffer;
1792 ReturnObj.Length = ACPI_DEBUG_BUFFER_SIZE;
1794 /* Check if _PRS exists */
1796 Status = AcpiEvaluateObject (Node, METHOD_NAME__PRS, NULL, &ReturnObj);
1797 if (ACPI_FAILURE (Status))
1799 AcpiOsPrintf ("Could not obtain _PRS: %s\n",
1800 AcpiFormatException (Status));
1801 goto Cleanup;
1804 ReturnObj.Pointer = AcpiGbl_DbBuffer;
1805 ReturnObj.Length = ACPI_DEBUG_BUFFER_SIZE;
1807 Status = AcpiGetPossibleResources (Node, &ReturnObj);
1808 if (ACPI_FAILURE (Status))
1810 AcpiOsPrintf ("AcpiGetPossibleResources failed: %s\n",
1811 AcpiFormatException (Status));
1812 goto Cleanup;
1815 AcpiRsDumpResourceList (ACPI_CAST_PTR (ACPI_RESOURCE, AcpiGbl_DbBuffer));
1817 Cleanup:
1819 AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT);
1820 return;
1824 /*******************************************************************************
1826 * FUNCTION: AcpiDbIntegrityWalk
1828 * PARAMETERS: Callback from WalkNamespace
1830 * RETURN: Status
1832 * DESCRIPTION: Examine one NS node for valid values.
1834 ******************************************************************************/
1836 static ACPI_STATUS
1837 AcpiDbIntegrityWalk (
1838 ACPI_HANDLE ObjHandle,
1839 UINT32 NestingLevel,
1840 void *Context,
1841 void **ReturnValue)
1843 ACPI_INTEGRITY_INFO *Info = (ACPI_INTEGRITY_INFO *) Context;
1844 ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle;
1845 ACPI_OPERAND_OBJECT *Object;
1846 BOOLEAN Alias = TRUE;
1849 Info->Nodes++;
1851 /* Verify the NS node, and dereference aliases */
1853 while (Alias)
1855 if (ACPI_GET_DESCRIPTOR_TYPE (Node) != ACPI_DESC_TYPE_NAMED)
1857 AcpiOsPrintf ("Invalid Descriptor Type for Node %p [%s] - is %2.2X should be %2.2X\n",
1858 Node, AcpiUtGetDescriptorName (Node), ACPI_GET_DESCRIPTOR_TYPE (Node),
1859 ACPI_DESC_TYPE_NAMED);
1860 return (AE_OK);
1863 if ((Node->Type == ACPI_TYPE_LOCAL_ALIAS) ||
1864 (Node->Type == ACPI_TYPE_LOCAL_METHOD_ALIAS))
1866 Node = (ACPI_NAMESPACE_NODE *) Node->Object;
1868 else
1870 Alias = FALSE;
1874 if (Node->Type > ACPI_TYPE_LOCAL_MAX)
1876 AcpiOsPrintf ("Invalid Object Type for Node %p, Type = %X\n",
1877 Node, Node->Type);
1878 return (AE_OK);
1881 if (!AcpiUtValidAcpiName (Node->Name.Integer))
1883 AcpiOsPrintf ("Invalid AcpiName for Node %p\n", Node);
1884 return (AE_OK);
1887 Object = AcpiNsGetAttachedObject (Node);
1888 if (Object)
1890 Info->Objects++;
1891 if (ACPI_GET_DESCRIPTOR_TYPE (Object) != ACPI_DESC_TYPE_OPERAND)
1893 AcpiOsPrintf ("Invalid Descriptor Type for Object %p [%s]\n",
1894 Object, AcpiUtGetDescriptorName (Object));
1898 return (AE_OK);
1902 /*******************************************************************************
1904 * FUNCTION: AcpiDbCheckIntegrity
1906 * PARAMETERS: None
1908 * RETURN: None
1910 * DESCRIPTION: Check entire namespace for data structure integrity
1912 ******************************************************************************/
1914 void
1915 AcpiDbCheckIntegrity (
1916 void)
1918 ACPI_INTEGRITY_INFO Info = {0,0};
1920 /* Search all nodes in namespace */
1922 (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
1923 AcpiDbIntegrityWalk, (void *) &Info, NULL);
1925 AcpiOsPrintf ("Verified %d namespace nodes with %d Objects\n",
1926 Info.Nodes, Info.Objects);
1930 /*******************************************************************************
1932 * FUNCTION: AcpiDbGenerateGpe
1934 * PARAMETERS: GpeArg - Raw GPE number, ascii string
1935 * BlockArg - GPE block number, ascii string
1936 * 0 or 1 for FADT GPE blocks
1938 * RETURN: None
1940 * DESCRIPTION: Generate a GPE
1942 ******************************************************************************/
1944 void
1945 AcpiDbGenerateGpe (
1946 char *GpeArg,
1947 char *BlockArg)
1949 UINT32 BlockNumber;
1950 UINT32 GpeNumber;
1951 ACPI_GPE_EVENT_INFO *GpeEventInfo;
1954 GpeNumber = ACPI_STRTOUL (GpeArg, NULL, 0);
1955 BlockNumber = ACPI_STRTOUL (BlockArg, NULL, 0);
1958 GpeEventInfo = AcpiEvGetGpeEventInfo (ACPI_TO_POINTER (BlockNumber),
1959 GpeNumber);
1960 if (!GpeEventInfo)
1962 AcpiOsPrintf ("Invalid GPE\n");
1963 return;
1966 (void) AcpiEvGpeDispatch (GpeEventInfo, GpeNumber);
1970 /*******************************************************************************
1972 * FUNCTION: AcpiDbBusWalk
1974 * PARAMETERS: Callback from WalkNamespace
1976 * RETURN: Status
1978 * DESCRIPTION: Display info about device objects that have a corresponding
1979 * _PRT method.
1981 ******************************************************************************/
1983 static ACPI_STATUS
1984 AcpiDbBusWalk (
1985 ACPI_HANDLE ObjHandle,
1986 UINT32 NestingLevel,
1987 void *Context,
1988 void **ReturnValue)
1990 ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle;
1991 ACPI_STATUS Status;
1992 ACPI_BUFFER Buffer;
1993 ACPI_NAMESPACE_NODE *TempNode;
1994 ACPI_DEVICE_INFO *Info;
1995 UINT32 i;
1998 if ((Node->Type != ACPI_TYPE_DEVICE) &&
1999 (Node->Type != ACPI_TYPE_PROCESSOR))
2001 return (AE_OK);
2004 /* Exit if there is no _PRT under this device */
2006 Status = AcpiGetHandle (Node, METHOD_NAME__PRT,
2007 ACPI_CAST_PTR (ACPI_HANDLE, &TempNode));
2008 if (ACPI_FAILURE (Status))
2010 return (AE_OK);
2013 /* Get the full path to this device object */
2015 Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
2016 Status = AcpiNsHandleToPathname (ObjHandle, &Buffer);
2017 if (ACPI_FAILURE (Status))
2019 AcpiOsPrintf ("Could Not get pathname for object %p\n", ObjHandle);
2020 return (AE_OK);
2023 Status = AcpiGetObjectInfo (ObjHandle, &Info);
2024 if (ACPI_FAILURE (Status))
2026 return (AE_OK);
2029 /* Display the full path */
2031 AcpiOsPrintf ("%-32s Type %X", (char *) Buffer.Pointer, Node->Type);
2032 ACPI_FREE (Buffer.Pointer);
2034 if (Info->Flags & ACPI_PCI_ROOT_BRIDGE)
2036 AcpiOsPrintf (" - Is PCI Root Bridge");
2038 AcpiOsPrintf ("\n");
2040 /* _PRT info */
2042 AcpiOsPrintf ("_PRT: %p\n", TempNode);
2044 /* Dump _ADR, _HID, _UID, _CID */
2046 if (Info->Valid & ACPI_VALID_ADR)
2048 AcpiOsPrintf ("_ADR: %8.8X%8.8X\n", ACPI_FORMAT_UINT64 (Info->Address));
2050 else
2052 AcpiOsPrintf ("_ADR: <Not Present>\n");
2055 if (Info->Valid & ACPI_VALID_HID)
2057 AcpiOsPrintf ("_HID: %s\n", Info->HardwareId.String);
2059 else
2061 AcpiOsPrintf ("_HID: <Not Present>\n");
2064 if (Info->Valid & ACPI_VALID_UID)
2066 AcpiOsPrintf ("_UID: %s\n", Info->UniqueId.String);
2068 else
2070 AcpiOsPrintf ("_UID: <Not Present>\n");
2073 if (Info->Valid & ACPI_VALID_CID)
2075 for (i = 0; i < Info->CompatibleIdList.Count; i++)
2077 AcpiOsPrintf ("_CID: %s\n",
2078 Info->CompatibleIdList.Ids[i].String);
2081 else
2083 AcpiOsPrintf ("_CID: <Not Present>\n");
2086 ACPI_FREE (Info);
2087 return (AE_OK);
2091 /*******************************************************************************
2093 * FUNCTION: AcpiDbGetBusInfo
2095 * PARAMETERS: None
2097 * RETURN: None
2099 * DESCRIPTION: Display info about system busses.
2101 ******************************************************************************/
2103 void
2104 AcpiDbGetBusInfo (
2105 void)
2107 /* Search all nodes in namespace */
2109 (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
2110 AcpiDbBusWalk, NULL, NULL);
2113 #endif /* ACPI_DEBUGGER */