1 /*******************************************************************************
3 * Module Name: dbobject - ACPI object decode and display
5 ******************************************************************************/
8 * Copyright (C) 2000 - 2017, 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/acdebug.h>
50 #define _COMPONENT ACPI_CA_DEBUGGER
51 ACPI_MODULE_NAME ("dbobject")
54 /* Local prototypes */
58 ACPI_NAMESPACE_NODE *Node);
61 /*******************************************************************************
63 * FUNCTION: AcpiDbDumpMethodInfo
65 * PARAMETERS: Status - Method execution status
66 * WalkState - Current state of the parse tree walk
70 * DESCRIPTION: Called when a method has been aborted because of an error.
71 * Dumps the method execution stack, and the method locals/args,
72 * and disassembles the AML opcode that failed.
74 ******************************************************************************/
77 AcpiDbDumpMethodInfo (
79 ACPI_WALK_STATE *WalkState)
81 ACPI_THREAD_STATE *Thread;
84 /* Ignore control codes, they are not errors */
86 if ((Status & AE_CODE_MASK) == AE_CODE_CONTROL)
91 /* We may be executing a deferred opcode */
93 if (WalkState->DeferredNode)
95 AcpiOsPrintf ("Executing subtree for Buffer/Package/Region\n");
100 * If there is no Thread, we are not actually executing a method.
101 * This can happen when the iASL compiler calls the interpreter
102 * to perform constant folding.
104 Thread = WalkState->Thread;
110 /* Display the method locals and arguments */
113 AcpiDbDecodeLocals (WalkState);
115 AcpiDbDecodeArguments (WalkState);
120 /*******************************************************************************
122 * FUNCTION: AcpiDbDecodeInternalObject
124 * PARAMETERS: ObjDesc - Object to be displayed
128 * DESCRIPTION: Short display of an internal object. Numbers/Strings/Buffers.
130 ******************************************************************************/
133 AcpiDbDecodeInternalObject (
134 ACPI_OPERAND_OBJECT *ObjDesc)
141 AcpiOsPrintf (" Uninitialized");
145 if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) != ACPI_DESC_TYPE_OPERAND)
147 AcpiOsPrintf (" %p [%s]", ObjDesc,
148 AcpiUtGetDescriptorName (ObjDesc));
152 AcpiOsPrintf (" %s", AcpiUtGetObjectTypeName (ObjDesc));
154 switch (ObjDesc->Common.Type)
156 case ACPI_TYPE_INTEGER:
158 AcpiOsPrintf (" %8.8X%8.8X",
159 ACPI_FORMAT_UINT64 (ObjDesc->Integer.Value));
162 case ACPI_TYPE_STRING:
164 AcpiOsPrintf ("(%u) \"%.60s",
165 ObjDesc->String.Length, ObjDesc->String.Pointer);
167 if (ObjDesc->String.Length > 60)
169 AcpiOsPrintf ("...");
177 case ACPI_TYPE_BUFFER:
179 AcpiOsPrintf ("(%u)", ObjDesc->Buffer.Length);
180 for (i = 0; (i < 8) && (i < ObjDesc->Buffer.Length); i++)
182 AcpiOsPrintf (" %2.2X", ObjDesc->Buffer.Pointer[i]);
188 AcpiOsPrintf (" %p", ObjDesc);
194 /*******************************************************************************
196 * FUNCTION: AcpiDbDecodeNode
198 * PARAMETERS: Node - Object to be displayed
202 * DESCRIPTION: Short display of a namespace node
204 ******************************************************************************/
208 ACPI_NAMESPACE_NODE *Node)
211 AcpiOsPrintf ("<Node> Name %4.4s",
212 AcpiUtGetNodeName (Node));
214 if (Node->Flags & ANOBJ_METHOD_ARG)
216 AcpiOsPrintf (" [Method Arg]");
218 if (Node->Flags & ANOBJ_METHOD_LOCAL)
220 AcpiOsPrintf (" [Method Local]");
225 /* These types have no attached object */
227 case ACPI_TYPE_DEVICE:
229 AcpiOsPrintf (" Device");
232 case ACPI_TYPE_THERMAL:
234 AcpiOsPrintf (" Thermal Zone");
239 AcpiDbDecodeInternalObject (AcpiNsGetAttachedObject (Node));
245 /*******************************************************************************
247 * FUNCTION: AcpiDbDisplayInternalObject
249 * PARAMETERS: ObjDesc - Object to be displayed
250 * WalkState - Current walk state
254 * DESCRIPTION: Short display of an internal object
256 ******************************************************************************/
259 AcpiDbDisplayInternalObject (
260 ACPI_OPERAND_OBJECT *ObjDesc,
261 ACPI_WALK_STATE *WalkState)
266 AcpiOsPrintf ("%p ", ObjDesc);
270 AcpiOsPrintf ("<Null Object>\n");
274 /* Decode the object type */
276 switch (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc))
278 case ACPI_DESC_TYPE_PARSER:
280 AcpiOsPrintf ("<Parser> ");
283 case ACPI_DESC_TYPE_NAMED:
285 AcpiDbDecodeNode ((ACPI_NAMESPACE_NODE *) ObjDesc);
288 case ACPI_DESC_TYPE_OPERAND:
290 Type = ObjDesc->Common.Type;
291 if (Type > ACPI_TYPE_LOCAL_MAX)
293 AcpiOsPrintf (" Type %X [Invalid Type]", (UINT32) Type);
297 /* Decode the ACPI object type */
299 switch (ObjDesc->Common.Type)
301 case ACPI_TYPE_LOCAL_REFERENCE:
303 AcpiOsPrintf ("[%s] ", AcpiUtGetReferenceName (ObjDesc));
305 /* Decode the refererence */
307 switch (ObjDesc->Reference.Class)
309 case ACPI_REFCLASS_LOCAL:
311 AcpiOsPrintf ("%X ", ObjDesc->Reference.Value);
314 ObjDesc = WalkState->LocalVariables
315 [ObjDesc->Reference.Value].Object;
316 AcpiOsPrintf ("%p", ObjDesc);
317 AcpiDbDecodeInternalObject (ObjDesc);
321 case ACPI_REFCLASS_ARG:
323 AcpiOsPrintf ("%X ", ObjDesc->Reference.Value);
326 ObjDesc = WalkState->Arguments
327 [ObjDesc->Reference.Value].Object;
328 AcpiOsPrintf ("%p", ObjDesc);
329 AcpiDbDecodeInternalObject (ObjDesc);
333 case ACPI_REFCLASS_INDEX:
335 switch (ObjDesc->Reference.TargetType)
337 case ACPI_TYPE_BUFFER_FIELD:
339 AcpiOsPrintf ("%p", ObjDesc->Reference.Object);
340 AcpiDbDecodeInternalObject (ObjDesc->Reference.Object);
343 case ACPI_TYPE_PACKAGE:
345 AcpiOsPrintf ("%p", ObjDesc->Reference.Where);
346 if (!ObjDesc->Reference.Where)
348 AcpiOsPrintf (" Uninitialized WHERE pointer");
352 AcpiDbDecodeInternalObject (
353 *(ObjDesc->Reference.Where));
359 AcpiOsPrintf ("Unknown index target type");
364 case ACPI_REFCLASS_REFOF:
366 if (!ObjDesc->Reference.Object)
369 "Uninitialized reference subobject pointer");
373 /* Reference can be to a Node or an Operand object */
375 switch (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc->Reference.Object))
377 case ACPI_DESC_TYPE_NAMED:
379 AcpiDbDecodeNode (ObjDesc->Reference.Object);
382 case ACPI_DESC_TYPE_OPERAND:
384 AcpiDbDecodeInternalObject (ObjDesc->Reference.Object);
392 case ACPI_REFCLASS_NAME:
394 AcpiDbDecodeNode (ObjDesc->Reference.Node);
397 case ACPI_REFCLASS_DEBUG:
398 case ACPI_REFCLASS_TABLE:
403 default: /* Unknown reference class */
405 AcpiOsPrintf ("%2.2X\n", ObjDesc->Reference.Class);
412 AcpiOsPrintf ("<Obj> ");
413 AcpiDbDecodeInternalObject (ObjDesc);
420 AcpiOsPrintf ("<Not a valid ACPI Object Descriptor> [%s]",
421 AcpiUtGetDescriptorName (ObjDesc));
429 /*******************************************************************************
431 * FUNCTION: AcpiDbDecodeLocals
433 * PARAMETERS: WalkState - State for current method
437 * DESCRIPTION: Display all locals for the currently running control method
439 ******************************************************************************/
443 ACPI_WALK_STATE *WalkState)
446 ACPI_OPERAND_OBJECT *ObjDesc;
447 ACPI_NAMESPACE_NODE *Node;
448 BOOLEAN DisplayLocals = FALSE;
451 ObjDesc = WalkState->MethodDesc;
452 Node = WalkState->MethodNode;
457 "No method node (Executing subtree for buffer or opregion)\n");
461 if (Node->Type != ACPI_TYPE_METHOD)
463 AcpiOsPrintf ("Executing subtree for Buffer/Package/Region\n");
467 /* Are any locals actually set? */
469 for (i = 0; i < ACPI_METHOD_NUM_LOCALS; i++)
471 ObjDesc = WalkState->LocalVariables[i].Object;
474 DisplayLocals = TRUE;
479 /* If any are set, only display the ones that are set */
483 AcpiOsPrintf ("\nInitialized Local Variables for method [%4.4s]:\n",
484 AcpiUtGetNodeName (Node));
486 for (i = 0; i < ACPI_METHOD_NUM_LOCALS; i++)
488 ObjDesc = WalkState->LocalVariables[i].Object;
491 AcpiOsPrintf (" Local%X: ", i);
492 AcpiDbDisplayInternalObject (ObjDesc, WalkState);
499 "No Local Variables are initialized for method [%4.4s]\n",
500 AcpiUtGetNodeName (Node));
505 /*******************************************************************************
507 * FUNCTION: AcpiDbDecodeArguments
509 * PARAMETERS: WalkState - State for current method
513 * DESCRIPTION: Display all arguments for the currently running control method
515 ******************************************************************************/
518 AcpiDbDecodeArguments (
519 ACPI_WALK_STATE *WalkState)
522 ACPI_OPERAND_OBJECT *ObjDesc;
523 ACPI_NAMESPACE_NODE *Node;
524 BOOLEAN DisplayArgs = FALSE;
527 Node = WalkState->MethodNode;
528 ObjDesc = WalkState->MethodDesc;
533 "No method node (Executing subtree for buffer or opregion)\n");
537 if (Node->Type != ACPI_TYPE_METHOD)
539 AcpiOsPrintf ("Executing subtree for Buffer/Package/Region\n");
543 /* Are any arguments actually set? */
545 for (i = 0; i < ACPI_METHOD_NUM_ARGS; i++)
547 ObjDesc = WalkState->Arguments[i].Object;
555 /* If any are set, only display the ones that are set */
560 "Initialized Arguments for Method [%4.4s]: "
561 "(%X arguments defined for method invocation)\n",
562 AcpiUtGetNodeName (Node), ObjDesc->Method.ParamCount);
564 for (i = 0; i < ACPI_METHOD_NUM_ARGS; i++)
566 ObjDesc = WalkState->Arguments[i].Object;
569 AcpiOsPrintf (" Arg%u: ", i);
570 AcpiDbDisplayInternalObject (ObjDesc, WalkState);
577 "No Arguments are initialized for method [%4.4s]\n",
578 AcpiUtGetNodeName (Node));