1 /*******************************************************************************
3 * Module Name: dmobject - ACPI object decode and display
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.
44 #include <contrib/dev/acpica/include/acpi.h>
45 #include <contrib/dev/acpica/include/accommon.h>
46 #include <contrib/dev/acpica/include/acnamesp.h>
47 #include <contrib/dev/acpica/include/acdisasm.h>
50 #ifdef ACPI_DISASSEMBLER
52 #define _COMPONENT ACPI_CA_DEBUGGER
53 ACPI_MODULE_NAME ("dmnames")
55 /* Local prototypes */
59 ACPI_NAMESPACE_NODE *Node);
62 /*******************************************************************************
64 * FUNCTION: AcpiDmDumpMethodInfo
66 * PARAMETERS: Status - Method execution status
67 * WalkState - Current state of the parse tree walk
68 * Op - Executing parse op
72 * DESCRIPTION: Called when a method has been aborted because of an error.
73 * Dumps the method execution stack, and the method locals/args,
74 * and disassembles the AML opcode that failed.
76 ******************************************************************************/
79 AcpiDmDumpMethodInfo (
81 ACPI_WALK_STATE *WalkState,
82 ACPI_PARSE_OBJECT *Op)
84 ACPI_PARSE_OBJECT *Next;
85 ACPI_THREAD_STATE *Thread;
86 ACPI_WALK_STATE *NextWalkState;
87 ACPI_NAMESPACE_NODE *PreviousMethod = NULL;
90 /* Ignore control codes, they are not errors */
92 if ((Status & AE_CODE_MASK) == AE_CODE_CONTROL)
97 /* We may be executing a deferred opcode */
99 if (WalkState->DeferredNode)
101 AcpiOsPrintf ("Executing subtree for Buffer/Package/Region\n");
106 * If there is no Thread, we are not actually executing a method.
107 * This can happen when the iASL compiler calls the interpreter
108 * to perform constant folding.
110 Thread = WalkState->Thread;
116 /* Display exception and method name */
118 AcpiOsPrintf ("\n**** Exception %s during execution of method ",
119 AcpiFormatException (Status));
120 AcpiNsPrintNodePathname (WalkState->MethodNode, NULL);
122 /* Display stack of executing methods */
124 AcpiOsPrintf ("\n\nMethod Execution Stack:\n");
125 NextWalkState = Thread->WalkStateList;
127 /* Walk list of linked walk states */
129 while (NextWalkState)
131 AcpiOsPrintf (" Method [%4.4s] executing: ",
132 AcpiUtGetNodeName (NextWalkState->MethodNode));
134 /* First method is the currently executing method */
136 if (NextWalkState == WalkState)
140 /* Display currently executing ASL statement */
142 Next = Op->Common.Next;
143 Op->Common.Next = NULL;
145 AcpiDmDisassemble (NextWalkState, Op, ACPI_UINT32_MAX);
146 Op->Common.Next = Next;
152 * This method has called another method
153 * NOTE: the method call parse subtree is already deleted at this
154 * point, so we cannot disassemble the method invocation.
156 AcpiOsPrintf ("Call to method ");
157 AcpiNsPrintNodePathname (PreviousMethod, NULL);
160 PreviousMethod = NextWalkState->MethodNode;
161 NextWalkState = NextWalkState->Next;
165 /* Display the method locals and arguments */
168 AcpiDmDisplayLocals (WalkState);
170 AcpiDmDisplayArguments (WalkState);
175 /*******************************************************************************
177 * FUNCTION: AcpiDmDecodeInternalObject
179 * PARAMETERS: ObjDesc - Object to be displayed
183 * DESCRIPTION: Short display of an internal object. Numbers/Strings/Buffers.
185 ******************************************************************************/
188 AcpiDmDecodeInternalObject (
189 ACPI_OPERAND_OBJECT *ObjDesc)
196 AcpiOsPrintf (" Uninitialized");
200 if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) != ACPI_DESC_TYPE_OPERAND)
202 AcpiOsPrintf (" %p [%s]", ObjDesc, AcpiUtGetDescriptorName (ObjDesc));
206 AcpiOsPrintf (" %s", AcpiUtGetObjectTypeName (ObjDesc));
208 switch (ObjDesc->Common.Type)
210 case ACPI_TYPE_INTEGER:
212 AcpiOsPrintf (" %8.8X%8.8X",
213 ACPI_FORMAT_UINT64 (ObjDesc->Integer.Value));
216 case ACPI_TYPE_STRING:
218 AcpiOsPrintf ("(%u) \"%.24s",
219 ObjDesc->String.Length, ObjDesc->String.Pointer);
221 if (ObjDesc->String.Length > 24)
223 AcpiOsPrintf ("...");
231 case ACPI_TYPE_BUFFER:
233 AcpiOsPrintf ("(%u)", ObjDesc->Buffer.Length);
234 for (i = 0; (i < 8) && (i < ObjDesc->Buffer.Length); i++)
236 AcpiOsPrintf (" %2.2X", ObjDesc->Buffer.Pointer[i]);
242 AcpiOsPrintf (" %p", ObjDesc);
248 /*******************************************************************************
250 * FUNCTION: AcpiDmDecodeNode
252 * PARAMETERS: Node - Object to be displayed
256 * DESCRIPTION: Short display of a namespace node
258 ******************************************************************************/
262 ACPI_NAMESPACE_NODE *Node)
265 AcpiOsPrintf ("<Node> Name %4.4s",
266 AcpiUtGetNodeName (Node));
268 if (Node->Flags & ANOBJ_METHOD_ARG)
270 AcpiOsPrintf (" [Method Arg]");
272 if (Node->Flags & ANOBJ_METHOD_LOCAL)
274 AcpiOsPrintf (" [Method Local]");
279 /* These types have no attached object */
281 case ACPI_TYPE_DEVICE:
283 AcpiOsPrintf (" Device");
286 case ACPI_TYPE_THERMAL:
288 AcpiOsPrintf (" Thermal Zone");
293 AcpiDmDecodeInternalObject (AcpiNsGetAttachedObject (Node));
299 /*******************************************************************************
301 * FUNCTION: AcpiDmDisplayInternalObject
303 * PARAMETERS: ObjDesc - Object to be displayed
304 * WalkState - Current walk state
308 * DESCRIPTION: Short display of an internal object
310 ******************************************************************************/
313 AcpiDmDisplayInternalObject (
314 ACPI_OPERAND_OBJECT *ObjDesc,
315 ACPI_WALK_STATE *WalkState)
320 AcpiOsPrintf ("%p ", ObjDesc);
324 AcpiOsPrintf ("<Null Object>\n");
328 /* Decode the object type */
330 switch (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc))
332 case ACPI_DESC_TYPE_PARSER:
334 AcpiOsPrintf ("<Parser> ");
337 case ACPI_DESC_TYPE_NAMED:
339 AcpiDmDecodeNode ((ACPI_NAMESPACE_NODE *) ObjDesc);
342 case ACPI_DESC_TYPE_OPERAND:
344 Type = ObjDesc->Common.Type;
345 if (Type > ACPI_TYPE_LOCAL_MAX)
347 AcpiOsPrintf (" Type %X [Invalid Type]", (UINT32) Type);
351 /* Decode the ACPI object type */
353 switch (ObjDesc->Common.Type)
355 case ACPI_TYPE_LOCAL_REFERENCE:
357 AcpiOsPrintf ("[%s] ", AcpiUtGetReferenceName (ObjDesc));
359 /* Decode the refererence */
361 switch (ObjDesc->Reference.Class)
363 case ACPI_REFCLASS_LOCAL:
365 AcpiOsPrintf ("%X ", ObjDesc->Reference.Value);
368 ObjDesc = WalkState->LocalVariables
369 [ObjDesc->Reference.Value].Object;
370 AcpiOsPrintf ("%p", ObjDesc);
371 AcpiDmDecodeInternalObject (ObjDesc);
375 case ACPI_REFCLASS_ARG:
377 AcpiOsPrintf ("%X ", ObjDesc->Reference.Value);
380 ObjDesc = WalkState->Arguments
381 [ObjDesc->Reference.Value].Object;
382 AcpiOsPrintf ("%p", ObjDesc);
383 AcpiDmDecodeInternalObject (ObjDesc);
387 case ACPI_REFCLASS_INDEX:
389 switch (ObjDesc->Reference.TargetType)
391 case ACPI_TYPE_BUFFER_FIELD:
393 AcpiOsPrintf ("%p", ObjDesc->Reference.Object);
394 AcpiDmDecodeInternalObject (ObjDesc->Reference.Object);
397 case ACPI_TYPE_PACKAGE:
399 AcpiOsPrintf ("%p", ObjDesc->Reference.Where);
400 if (!ObjDesc->Reference.Where)
402 AcpiOsPrintf (" Uninitialized WHERE pointer");
406 AcpiDmDecodeInternalObject (
407 *(ObjDesc->Reference.Where));
413 AcpiOsPrintf ("Unknown index target type");
418 case ACPI_REFCLASS_REFOF:
420 if (!ObjDesc->Reference.Object)
422 AcpiOsPrintf ("Uninitialized reference subobject pointer");
426 /* Reference can be to a Node or an Operand object */
428 switch (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc->Reference.Object))
430 case ACPI_DESC_TYPE_NAMED:
431 AcpiDmDecodeNode (ObjDesc->Reference.Object);
434 case ACPI_DESC_TYPE_OPERAND:
435 AcpiDmDecodeInternalObject (ObjDesc->Reference.Object);
443 case ACPI_REFCLASS_NAME:
445 AcpiDmDecodeNode (ObjDesc->Reference.Node);
448 case ACPI_REFCLASS_DEBUG:
449 case ACPI_REFCLASS_TABLE:
454 default: /* Unknown reference class */
456 AcpiOsPrintf ("%2.2X\n", ObjDesc->Reference.Class);
463 AcpiOsPrintf ("<Obj> ");
464 AcpiDmDecodeInternalObject (ObjDesc);
471 AcpiOsPrintf ("<Not a valid ACPI Object Descriptor> [%s]",
472 AcpiUtGetDescriptorName (ObjDesc));
480 /*******************************************************************************
482 * FUNCTION: AcpiDmDisplayLocals
484 * PARAMETERS: WalkState - State for current method
488 * DESCRIPTION: Display all locals for the currently running control method
490 ******************************************************************************/
493 AcpiDmDisplayLocals (
494 ACPI_WALK_STATE *WalkState)
497 ACPI_OPERAND_OBJECT *ObjDesc;
498 ACPI_NAMESPACE_NODE *Node;
501 ObjDesc = WalkState->MethodDesc;
502 Node = WalkState->MethodNode;
506 "No method node (Executing subtree for buffer or opregion)\n");
510 if (Node->Type != ACPI_TYPE_METHOD)
512 AcpiOsPrintf ("Executing subtree for Buffer/Package/Region\n");
516 AcpiOsPrintf ("Local Variables for method [%4.4s]:\n",
517 AcpiUtGetNodeName (Node));
519 for (i = 0; i < ACPI_METHOD_NUM_LOCALS; i++)
521 ObjDesc = WalkState->LocalVariables[i].Object;
522 AcpiOsPrintf (" Local%X: ", i);
523 AcpiDmDisplayInternalObject (ObjDesc, WalkState);
528 /*******************************************************************************
530 * FUNCTION: AcpiDmDisplayArguments
532 * PARAMETERS: WalkState - State for current method
536 * DESCRIPTION: Display all arguments for the currently running control method
538 ******************************************************************************/
541 AcpiDmDisplayArguments (
542 ACPI_WALK_STATE *WalkState)
545 ACPI_OPERAND_OBJECT *ObjDesc;
546 ACPI_NAMESPACE_NODE *Node;
549 ObjDesc = WalkState->MethodDesc;
550 Node = WalkState->MethodNode;
554 "No method node (Executing subtree for buffer or opregion)\n");
558 if (Node->Type != ACPI_TYPE_METHOD)
560 AcpiOsPrintf ("Executing subtree for Buffer/Package/Region\n");
565 "Arguments for Method [%4.4s]: (%X arguments defined, max concurrency = %X)\n",
566 AcpiUtGetNodeName (Node), ObjDesc->Method.ParamCount, ObjDesc->Method.SyncLevel);
568 for (i = 0; i < ACPI_METHOD_NUM_ARGS; i++)
570 ObjDesc = WalkState->Arguments[i].Object;
571 AcpiOsPrintf (" Arg%u: ", i);
572 AcpiDmDisplayInternalObject (ObjDesc, WalkState);