1 /*******************************************************************************
3 * Module Name: dbobject - 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.
48 #ifdef ACPI_DISASSEMBLER
55 #define _COMPONENT ACPI_CA_DEBUGGER
56 ACPI_MODULE_NAME ("dbobject")
58 /* Local prototypes */
62 ACPI_NAMESPACE_NODE *Node);
65 /*******************************************************************************
67 * FUNCTION: AcpiDbDumpMethodInfo
69 * PARAMETERS: Status - Method execution status
70 * WalkState - Current state of the parse tree walk
74 * DESCRIPTION: Called when a method has been aborted because of an error.
75 * Dumps the method execution stack, and the method locals/args,
76 * and disassembles the AML opcode that failed.
78 ******************************************************************************/
81 AcpiDbDumpMethodInfo (
83 ACPI_WALK_STATE *WalkState)
85 ACPI_THREAD_STATE *Thread;
88 /* Ignore control codes, they are not errors */
90 if ((Status & AE_CODE_MASK) == AE_CODE_CONTROL)
95 /* We may be executing a deferred opcode */
97 if (WalkState->DeferredNode)
99 AcpiOsPrintf ("Executing subtree for Buffer/Package/Region\n");
104 * If there is no Thread, we are not actually executing a method.
105 * This can happen when the iASL compiler calls the interpreter
106 * to perform constant folding.
108 Thread = WalkState->Thread;
114 /* Display the method locals and arguments */
117 AcpiDbDecodeLocals (WalkState);
119 AcpiDbDecodeArguments (WalkState);
124 /*******************************************************************************
126 * FUNCTION: AcpiDbDecodeInternalObject
128 * PARAMETERS: ObjDesc - Object to be displayed
132 * DESCRIPTION: Short display of an internal object. Numbers/Strings/Buffers.
134 ******************************************************************************/
137 AcpiDbDecodeInternalObject (
138 ACPI_OPERAND_OBJECT *ObjDesc)
145 AcpiOsPrintf (" Uninitialized");
149 if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) != ACPI_DESC_TYPE_OPERAND)
151 AcpiOsPrintf (" %p [%s]", ObjDesc, AcpiUtGetDescriptorName (ObjDesc));
155 AcpiOsPrintf (" %s", AcpiUtGetObjectTypeName (ObjDesc));
157 switch (ObjDesc->Common.Type)
159 case ACPI_TYPE_INTEGER:
161 AcpiOsPrintf (" %8.8X%8.8X",
162 ACPI_FORMAT_UINT64 (ObjDesc->Integer.Value));
165 case ACPI_TYPE_STRING:
167 AcpiOsPrintf ("(%u) \"%.24s",
168 ObjDesc->String.Length, ObjDesc->String.Pointer);
170 if (ObjDesc->String.Length > 24)
172 AcpiOsPrintf ("...");
180 case ACPI_TYPE_BUFFER:
182 AcpiOsPrintf ("(%u)", ObjDesc->Buffer.Length);
183 for (i = 0; (i < 8) && (i < ObjDesc->Buffer.Length); i++)
185 AcpiOsPrintf (" %2.2X", ObjDesc->Buffer.Pointer[i]);
191 AcpiOsPrintf (" %p", ObjDesc);
197 /*******************************************************************************
199 * FUNCTION: AcpiDbDecodeNode
201 * PARAMETERS: Node - Object to be displayed
205 * DESCRIPTION: Short display of a namespace node
207 ******************************************************************************/
211 ACPI_NAMESPACE_NODE *Node)
214 AcpiOsPrintf ("<Node> Name %4.4s",
215 AcpiUtGetNodeName (Node));
217 if (Node->Flags & ANOBJ_METHOD_ARG)
219 AcpiOsPrintf (" [Method Arg]");
221 if (Node->Flags & ANOBJ_METHOD_LOCAL)
223 AcpiOsPrintf (" [Method Local]");
228 /* These types have no attached object */
230 case ACPI_TYPE_DEVICE:
232 AcpiOsPrintf (" Device");
235 case ACPI_TYPE_THERMAL:
237 AcpiOsPrintf (" Thermal Zone");
242 AcpiDbDecodeInternalObject (AcpiNsGetAttachedObject (Node));
248 /*******************************************************************************
250 * FUNCTION: AcpiDbDisplayInternalObject
252 * PARAMETERS: ObjDesc - Object to be displayed
253 * WalkState - Current walk state
257 * DESCRIPTION: Short display of an internal object
259 ******************************************************************************/
262 AcpiDbDisplayInternalObject (
263 ACPI_OPERAND_OBJECT *ObjDesc,
264 ACPI_WALK_STATE *WalkState)
269 AcpiOsPrintf ("%p ", ObjDesc);
273 AcpiOsPrintf ("<Null Object>\n");
277 /* Decode the object type */
279 switch (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc))
281 case ACPI_DESC_TYPE_PARSER:
283 AcpiOsPrintf ("<Parser> ");
286 case ACPI_DESC_TYPE_NAMED:
288 AcpiDbDecodeNode ((ACPI_NAMESPACE_NODE *) ObjDesc);
291 case ACPI_DESC_TYPE_OPERAND:
293 Type = ObjDesc->Common.Type;
294 if (Type > ACPI_TYPE_LOCAL_MAX)
296 AcpiOsPrintf (" Type %X [Invalid Type]", (UINT32) Type);
300 /* Decode the ACPI object type */
302 switch (ObjDesc->Common.Type)
304 case ACPI_TYPE_LOCAL_REFERENCE:
306 AcpiOsPrintf ("[%s] ", AcpiUtGetReferenceName (ObjDesc));
308 /* Decode the refererence */
310 switch (ObjDesc->Reference.Class)
312 case ACPI_REFCLASS_LOCAL:
314 AcpiOsPrintf ("%X ", ObjDesc->Reference.Value);
317 ObjDesc = WalkState->LocalVariables
318 [ObjDesc->Reference.Value].Object;
319 AcpiOsPrintf ("%p", ObjDesc);
320 AcpiDbDecodeInternalObject (ObjDesc);
324 case ACPI_REFCLASS_ARG:
326 AcpiOsPrintf ("%X ", ObjDesc->Reference.Value);
329 ObjDesc = WalkState->Arguments
330 [ObjDesc->Reference.Value].Object;
331 AcpiOsPrintf ("%p", ObjDesc);
332 AcpiDbDecodeInternalObject (ObjDesc);
336 case ACPI_REFCLASS_INDEX:
338 switch (ObjDesc->Reference.TargetType)
340 case ACPI_TYPE_BUFFER_FIELD:
342 AcpiOsPrintf ("%p", ObjDesc->Reference.Object);
343 AcpiDbDecodeInternalObject (ObjDesc->Reference.Object);
346 case ACPI_TYPE_PACKAGE:
348 AcpiOsPrintf ("%p", ObjDesc->Reference.Where);
349 if (!ObjDesc->Reference.Where)
351 AcpiOsPrintf (" Uninitialized WHERE pointer");
355 AcpiDbDecodeInternalObject (
356 *(ObjDesc->Reference.Where));
362 AcpiOsPrintf ("Unknown index target type");
367 case ACPI_REFCLASS_REFOF:
369 if (!ObjDesc->Reference.Object)
371 AcpiOsPrintf ("Uninitialized reference subobject pointer");
375 /* Reference can be to a Node or an Operand object */
377 switch (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc->Reference.Object))
379 case ACPI_DESC_TYPE_NAMED:
380 AcpiDbDecodeNode (ObjDesc->Reference.Object);
383 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;
450 ObjDesc = WalkState->MethodDesc;
451 Node = WalkState->MethodNode;
455 "No method node (Executing subtree for buffer or opregion)\n");
459 if (Node->Type != ACPI_TYPE_METHOD)
461 AcpiOsPrintf ("Executing subtree for Buffer/Package/Region\n");
465 AcpiOsPrintf ("Local Variables for method [%4.4s]:\n",
466 AcpiUtGetNodeName (Node));
468 for (i = 0; i < ACPI_METHOD_NUM_LOCALS; i++)
470 ObjDesc = WalkState->LocalVariables[i].Object;
471 AcpiOsPrintf (" Local%X: ", i);
472 AcpiDbDisplayInternalObject (ObjDesc, WalkState);
477 /*******************************************************************************
479 * FUNCTION: AcpiDbDecodeArguments
481 * PARAMETERS: WalkState - State for current method
485 * DESCRIPTION: Display all arguments for the currently running control method
487 ******************************************************************************/
490 AcpiDbDecodeArguments (
491 ACPI_WALK_STATE *WalkState)
494 ACPI_OPERAND_OBJECT *ObjDesc;
495 ACPI_NAMESPACE_NODE *Node;
498 ObjDesc = WalkState->MethodDesc;
499 Node = WalkState->MethodNode;
503 "No method node (Executing subtree for buffer or opregion)\n");
507 if (Node->Type != ACPI_TYPE_METHOD)
509 AcpiOsPrintf ("Executing subtree for Buffer/Package/Region\n");
514 "Arguments for Method [%4.4s]: (%X arguments defined, max concurrency = %X)\n",
515 AcpiUtGetNodeName (Node), ObjDesc->Method.ParamCount, ObjDesc->Method.SyncLevel);
517 for (i = 0; i < ACPI_METHOD_NUM_ARGS; i++)
519 ObjDesc = WalkState->Arguments[i].Object;
520 AcpiOsPrintf (" Arg%u: ", i);
521 AcpiDbDisplayInternalObject (ObjDesc, WalkState);