opnsense-src/source/components/debugger/dbobject.c

581 lines
15 KiB
C
Raw Normal View History

2003-07-13 18:44:13 -04:00
/*******************************************************************************
*
2015-07-20 18:31:50 -04:00
* Module Name: dbobject - ACPI object decode and display
2003-07-13 18:44:13 -04:00
*
******************************************************************************/
2011-01-13 11:12:34 -05:00
/*
2016-01-11 17:10:31 -05:00
* Copyright (C) 2000 - 2016, Intel Corp.
2003-07-13 18:44:13 -04:00
* All rights reserved.
*
2011-01-13 11:12:34 -05:00
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions, and the following disclaimer,
* without modification.
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
* substantially similar to the "NO WARRANTY" disclaimer below
* ("Disclaimer") and any redistribution must be conditioned upon
* including a substantially similar Disclaimer requirement for further
* binary redistribution.
* 3. Neither the names of the above-listed copyright holders nor the names
* of any contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* Alternatively, this software may be distributed under the terms of the
* GNU General Public License ("GPL") version 2 as published by the Free
* Software Foundation.
*
* NO WARRANTY
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGES.
*/
2003-07-13 18:44:13 -04:00
#include "acpi.h"
#include "accommon.h"
#include "acnamesp.h"
2015-07-20 18:31:50 -04:00
#include "acdebug.h"
2003-07-13 18:44:13 -04:00
#define _COMPONENT ACPI_CA_DEBUGGER
2015-07-20 18:31:50 -04:00
ACPI_MODULE_NAME ("dbobject")
2003-07-13 18:44:13 -04:00
2015-08-25 15:41:12 -04:00
/* Local prototypes */
2003-07-13 18:44:13 -04:00
static void
2015-07-20 18:31:50 -04:00
AcpiDbDecodeNode (
ACPI_NAMESPACE_NODE *Node);
/*******************************************************************************
2003-07-13 18:44:13 -04:00
*
2015-07-20 18:31:50 -04:00
* FUNCTION: AcpiDbDumpMethodInfo
2003-07-13 18:44:13 -04:00
*
* PARAMETERS: Status - Method execution status
* WalkState - Current state of the parse tree walk
*
* RETURN: None
*
* DESCRIPTION: Called when a method has been aborted because of an error.
* Dumps the method execution stack, and the method locals/args,
* and disassembles the AML opcode that failed.
*
******************************************************************************/
2003-07-13 18:44:13 -04:00
void
2015-07-20 18:31:50 -04:00
AcpiDbDumpMethodInfo (
2003-07-13 18:44:13 -04:00
ACPI_STATUS Status,
2015-07-20 18:31:50 -04:00
ACPI_WALK_STATE *WalkState)
2003-07-13 18:44:13 -04:00
{
ACPI_THREAD_STATE *Thread;
/* Ignore control codes, they are not errors */
if ((Status & AE_CODE_MASK) == AE_CODE_CONTROL)
{
return;
}
2003-12-08 21:45:16 -05:00
/* We may be executing a deferred opcode */
if (WalkState->DeferredNode)
{
AcpiOsPrintf ("Executing subtree for Buffer/Package/Region\n");
return;
}
/*
* If there is no Thread, we are not actually executing a method.
* This can happen when the iASL compiler calls the interpreter
* to perform constant folding.
*/
Thread = WalkState->Thread;
if (!Thread)
{
return;
}
2003-07-13 18:44:13 -04:00
/* Display the method locals and arguments */
AcpiOsPrintf ("\n");
2015-07-20 18:31:50 -04:00
AcpiDbDecodeLocals (WalkState);
2003-07-13 18:44:13 -04:00
AcpiOsPrintf ("\n");
2015-07-20 18:31:50 -04:00
AcpiDbDecodeArguments (WalkState);
2003-07-13 18:44:13 -04:00
AcpiOsPrintf ("\n");
}
/*******************************************************************************
*
2015-07-20 18:31:50 -04:00
* FUNCTION: AcpiDbDecodeInternalObject
2003-07-13 18:44:13 -04:00
*
* PARAMETERS: ObjDesc - Object to be displayed
*
* RETURN: None
*
2012-10-19 14:47:57 -04:00
* DESCRIPTION: Short display of an internal object. Numbers/Strings/Buffers.
2003-07-13 18:44:13 -04:00
*
******************************************************************************/
void
2015-07-20 18:31:50 -04:00
AcpiDbDecodeInternalObject (
2003-07-13 18:44:13 -04:00
ACPI_OPERAND_OBJECT *ObjDesc)
{
UINT32 i;
if (!ObjDesc)
{
AcpiOsPrintf (" Uninitialized");
return;
}
if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) != ACPI_DESC_TYPE_OPERAND)
{
2015-08-25 15:41:12 -04:00
AcpiOsPrintf (" %p [%s]", ObjDesc,
AcpiUtGetDescriptorName (ObjDesc));
2003-07-13 18:44:13 -04:00
return;
}
AcpiOsPrintf (" %s", AcpiUtGetObjectTypeName (ObjDesc));
switch (ObjDesc->Common.Type)
2003-07-13 18:44:13 -04:00
{
case ACPI_TYPE_INTEGER:
2004-02-28 15:23:30 -05:00
AcpiOsPrintf (" %8.8X%8.8X",
2015-08-25 15:41:12 -04:00
ACPI_FORMAT_UINT64 (ObjDesc->Integer.Value));
2003-07-13 18:44:13 -04:00
break;
case ACPI_TYPE_STRING:
2016-05-27 17:40:35 -04:00
AcpiOsPrintf ("(%u) \"%.60s",
2015-08-25 15:41:12 -04:00
ObjDesc->String.Length, ObjDesc->String.Pointer);
2003-07-13 18:44:13 -04:00
2016-05-27 17:40:35 -04:00
if (ObjDesc->String.Length > 60)
2003-07-13 18:44:13 -04:00
{
AcpiOsPrintf ("...");
}
else
{
AcpiOsPrintf ("\"");
}
break;
case ACPI_TYPE_BUFFER:
2010-05-28 14:46:48 -04:00
AcpiOsPrintf ("(%u)", ObjDesc->Buffer.Length);
2003-07-13 18:44:13 -04:00
for (i = 0; (i < 8) && (i < ObjDesc->Buffer.Length); i++)
{
AcpiOsPrintf (" %2.2X", ObjDesc->Buffer.Pointer[i]);
}
break;
default:
AcpiOsPrintf (" %p", ObjDesc);
break;
}
}
/*******************************************************************************
*
2015-07-20 18:31:50 -04:00
* FUNCTION: AcpiDbDecodeNode
2003-07-13 18:44:13 -04:00
*
* PARAMETERS: Node - Object to be displayed
*
* RETURN: None
*
* DESCRIPTION: Short display of a namespace node
*
******************************************************************************/
static void
2015-07-20 18:31:50 -04:00
AcpiDbDecodeNode (
2003-07-13 18:44:13 -04:00
ACPI_NAMESPACE_NODE *Node)
{
AcpiOsPrintf ("<Node> Name %4.4s",
2015-08-25 15:41:12 -04:00
AcpiUtGetNodeName (Node));
2003-07-13 18:44:13 -04:00
if (Node->Flags & ANOBJ_METHOD_ARG)
{
AcpiOsPrintf (" [Method Arg]");
}
if (Node->Flags & ANOBJ_METHOD_LOCAL)
{
AcpiOsPrintf (" [Method Local]");
}
switch (Node->Type)
{
/* These types have no attached object */
case ACPI_TYPE_DEVICE:
2013-05-17 19:13:40 -04:00
AcpiOsPrintf (" Device");
break;
case ACPI_TYPE_THERMAL:
2013-05-17 19:13:40 -04:00
AcpiOsPrintf (" Thermal Zone");
break;
default:
2013-05-17 19:13:40 -04:00
2015-07-20 18:31:50 -04:00
AcpiDbDecodeInternalObject (AcpiNsGetAttachedObject (Node));
break;
}
2003-07-13 18:44:13 -04:00
}
/*******************************************************************************
*
2015-07-20 18:31:50 -04:00
* FUNCTION: AcpiDbDisplayInternalObject
2003-07-13 18:44:13 -04:00
*
* PARAMETERS: ObjDesc - Object to be displayed
* WalkState - Current walk state
*
* RETURN: None
*
* DESCRIPTION: Short display of an internal object
*
******************************************************************************/
void
2015-07-20 18:31:50 -04:00
AcpiDbDisplayInternalObject (
2003-07-13 18:44:13 -04:00
ACPI_OPERAND_OBJECT *ObjDesc,
ACPI_WALK_STATE *WalkState)
{
UINT8 Type;
AcpiOsPrintf ("%p ", ObjDesc);
if (!ObjDesc)
{
AcpiOsPrintf ("<Null Object>\n");
2003-07-13 18:44:13 -04:00
return;
}
/* Decode the object type */
switch (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc))
{
case ACPI_DESC_TYPE_PARSER:
AcpiOsPrintf ("<Parser> ");
break;
case ACPI_DESC_TYPE_NAMED:
2015-07-20 18:31:50 -04:00
AcpiDbDecodeNode ((ACPI_NAMESPACE_NODE *) ObjDesc);
2003-07-13 18:44:13 -04:00
break;
case ACPI_DESC_TYPE_OPERAND:
Type = ObjDesc->Common.Type;
2003-07-13 18:44:13 -04:00
if (Type > ACPI_TYPE_LOCAL_MAX)
{
AcpiOsPrintf (" Type %X [Invalid Type]", (UINT32) Type);
return;
}
/* Decode the ACPI object type */
switch (ObjDesc->Common.Type)
2003-07-13 18:44:13 -04:00
{
case ACPI_TYPE_LOCAL_REFERENCE:
AcpiOsPrintf ("[%s] ", AcpiUtGetReferenceName (ObjDesc));
/* Decode the refererence */
switch (ObjDesc->Reference.Class)
2003-07-13 18:44:13 -04:00
{
case ACPI_REFCLASS_LOCAL:
2003-07-13 18:44:13 -04:00
AcpiOsPrintf ("%X ", ObjDesc->Reference.Value);
2003-07-13 18:44:13 -04:00
if (WalkState)
{
ObjDesc = WalkState->LocalVariables
2015-08-25 15:41:12 -04:00
[ObjDesc->Reference.Value].Object;
2003-07-13 18:44:13 -04:00
AcpiOsPrintf ("%p", ObjDesc);
2015-07-20 18:31:50 -04:00
AcpiDbDecodeInternalObject (ObjDesc);
2003-07-13 18:44:13 -04:00
}
break;
case ACPI_REFCLASS_ARG:
2003-07-13 18:44:13 -04:00
AcpiOsPrintf ("%X ", ObjDesc->Reference.Value);
2003-07-13 18:44:13 -04:00
if (WalkState)
{
ObjDesc = WalkState->Arguments
2015-08-25 15:41:12 -04:00
[ObjDesc->Reference.Value].Object;
2003-07-13 18:44:13 -04:00
AcpiOsPrintf ("%p", ObjDesc);
2015-07-20 18:31:50 -04:00
AcpiDbDecodeInternalObject (ObjDesc);
2003-07-13 18:44:13 -04:00
}
break;
case ACPI_REFCLASS_INDEX:
2003-07-13 18:44:13 -04:00
2004-02-28 15:23:30 -05:00
switch (ObjDesc->Reference.TargetType)
2003-07-13 18:44:13 -04:00
{
2004-02-28 15:23:30 -05:00
case ACPI_TYPE_BUFFER_FIELD:
2004-02-28 15:23:30 -05:00
AcpiOsPrintf ("%p", ObjDesc->Reference.Object);
2015-07-20 18:31:50 -04:00
AcpiDbDecodeInternalObject (ObjDesc->Reference.Object);
2004-02-28 15:23:30 -05:00
break;
case ACPI_TYPE_PACKAGE:
AcpiOsPrintf ("%p", ObjDesc->Reference.Where);
if (!ObjDesc->Reference.Where)
{
AcpiOsPrintf (" Uninitialized WHERE pointer");
2004-02-28 15:23:30 -05:00
}
else
{
2015-07-20 18:31:50 -04:00
AcpiDbDecodeInternalObject (
*(ObjDesc->Reference.Where));
2004-02-28 15:23:30 -05:00
}
break;
default:
2004-02-28 15:23:30 -05:00
AcpiOsPrintf ("Unknown index target type");
break;
2003-07-13 18:44:13 -04:00
}
break;
case ACPI_REFCLASS_REFOF:
2003-07-13 18:44:13 -04:00
2004-02-28 15:23:30 -05:00
if (!ObjDesc->Reference.Object)
{
2015-08-25 15:41:12 -04:00
AcpiOsPrintf (
"Uninitialized reference subobject pointer");
2004-02-28 15:23:30 -05:00
break;
}
2003-07-13 18:44:13 -04:00
/* Reference can be to a Node or an Operand object */
switch (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc->Reference.Object))
{
case ACPI_DESC_TYPE_NAMED:
2015-08-25 15:41:12 -04:00
2015-07-20 18:31:50 -04:00
AcpiDbDecodeNode (ObjDesc->Reference.Object);
2003-07-13 18:44:13 -04:00
break;
case ACPI_DESC_TYPE_OPERAND:
2015-08-25 15:41:12 -04:00
2015-07-20 18:31:50 -04:00
AcpiDbDecodeInternalObject (ObjDesc->Reference.Object);
2003-07-13 18:44:13 -04:00
break;
default:
break;
}
break;
case ACPI_REFCLASS_NAME:
2015-07-20 18:31:50 -04:00
AcpiDbDecodeNode (ObjDesc->Reference.Node);
break;
2003-07-13 18:44:13 -04:00
case ACPI_REFCLASS_DEBUG:
case ACPI_REFCLASS_TABLE:
AcpiOsPrintf ("\n");
break;
default: /* Unknown reference class */
AcpiOsPrintf ("%2.2X\n", ObjDesc->Reference.Class);
2003-07-13 18:44:13 -04:00
break;
}
break;
default:
2004-02-28 15:23:30 -05:00
AcpiOsPrintf ("<Obj> ");
2015-07-20 18:31:50 -04:00
AcpiDbDecodeInternalObject (ObjDesc);
2003-07-13 18:44:13 -04:00
break;
}
break;
default:
2004-02-28 15:23:30 -05:00
AcpiOsPrintf ("<Not a valid ACPI Object Descriptor> [%s]",
AcpiUtGetDescriptorName (ObjDesc));
2003-07-13 18:44:13 -04:00
break;
}
AcpiOsPrintf ("\n");
}
/*******************************************************************************
*
2015-07-20 18:31:50 -04:00
* FUNCTION: AcpiDbDecodeLocals
2003-07-13 18:44:13 -04:00
*
* PARAMETERS: WalkState - State for current method
2003-07-13 18:44:13 -04:00
*
* RETURN: None
*
* DESCRIPTION: Display all locals for the currently running control method
*
******************************************************************************/
void
2015-07-20 18:31:50 -04:00
AcpiDbDecodeLocals (
2003-07-13 18:44:13 -04:00
ACPI_WALK_STATE *WalkState)
{
UINT32 i;
ACPI_OPERAND_OBJECT *ObjDesc;
ACPI_NAMESPACE_NODE *Node;
2015-09-30 16:13:30 -04:00
BOOLEAN DisplayLocals = FALSE;
2003-07-13 18:44:13 -04:00
ObjDesc = WalkState->MethodDesc;
2003-12-08 21:45:16 -05:00
Node = WalkState->MethodNode;
2015-08-25 15:41:12 -04:00
2003-07-13 18:44:13 -04:00
if (!Node)
{
AcpiOsPrintf (
"No method node (Executing subtree for buffer or opregion)\n");
2003-07-13 18:44:13 -04:00
return;
}
2003-12-08 21:45:16 -05:00
if (Node->Type != ACPI_TYPE_METHOD)
{
AcpiOsPrintf ("Executing subtree for Buffer/Package/Region\n");
return;
}
2015-09-30 16:13:30 -04:00
/* Are any locals actually set? */
2003-07-13 18:44:13 -04:00
for (i = 0; i < ACPI_METHOD_NUM_LOCALS; i++)
{
ObjDesc = WalkState->LocalVariables[i].Object;
2015-09-30 16:13:30 -04:00
if (ObjDesc)
{
DisplayLocals = TRUE;
break;
}
}
/* If any are set, only display the ones that are set */
if (DisplayLocals)
{
AcpiOsPrintf ("\nInitialized Local Variables for method [%4.4s]:\n",
AcpiUtGetNodeName (Node));
for (i = 0; i < ACPI_METHOD_NUM_LOCALS; i++)
{
ObjDesc = WalkState->LocalVariables[i].Object;
if (ObjDesc)
{
AcpiOsPrintf (" Local%X: ", i);
AcpiDbDisplayInternalObject (ObjDesc, WalkState);
}
}
}
else
{
2015-11-25 16:04:42 -05:00
AcpiOsPrintf (
"No Local Variables are initialized for method [%4.4s]\n",
2015-09-30 16:13:30 -04:00
AcpiUtGetNodeName (Node));
2003-07-13 18:44:13 -04:00
}
}
/*******************************************************************************
*
2015-07-20 18:31:50 -04:00
* FUNCTION: AcpiDbDecodeArguments
2003-07-13 18:44:13 -04:00
*
* PARAMETERS: WalkState - State for current method
2003-07-13 18:44:13 -04:00
*
* RETURN: None
*
* DESCRIPTION: Display all arguments for the currently running control method
*
******************************************************************************/
void
2015-07-20 18:31:50 -04:00
AcpiDbDecodeArguments (
2003-07-13 18:44:13 -04:00
ACPI_WALK_STATE *WalkState)
{
UINT32 i;
ACPI_OPERAND_OBJECT *ObjDesc;
ACPI_NAMESPACE_NODE *Node;
2015-09-30 16:13:30 -04:00
BOOLEAN DisplayArgs = FALSE;
2003-07-13 18:44:13 -04:00
2015-09-30 16:13:30 -04:00
Node = WalkState->MethodNode;
2003-07-13 18:44:13 -04:00
ObjDesc = WalkState->MethodDesc;
2015-08-25 15:41:12 -04:00
2003-07-13 18:44:13 -04:00
if (!Node)
{
AcpiOsPrintf (
"No method node (Executing subtree for buffer or opregion)\n");
2003-07-13 18:44:13 -04:00
return;
}
2003-12-08 21:45:16 -05:00
if (Node->Type != ACPI_TYPE_METHOD)
{
AcpiOsPrintf ("Executing subtree for Buffer/Package/Region\n");
return;
}
2015-09-30 16:13:30 -04:00
/* Are any arguments actually set? */
2003-07-13 18:44:13 -04:00
for (i = 0; i < ACPI_METHOD_NUM_ARGS; i++)
{
ObjDesc = WalkState->Arguments[i].Object;
2015-09-30 16:13:30 -04:00
if (ObjDesc)
{
DisplayArgs = TRUE;
break;
}
}
/* If any are set, only display the ones that are set */
if (DisplayArgs)
{
AcpiOsPrintf (
"Initialized Arguments for Method [%4.4s]: "
"(%X arguments defined for method invocation)\n",
AcpiUtGetNodeName (Node), ObjDesc->Method.ParamCount);
for (i = 0; i < ACPI_METHOD_NUM_ARGS; i++)
{
ObjDesc = WalkState->Arguments[i].Object;
if (ObjDesc)
{
AcpiOsPrintf (" Arg%u: ", i);
AcpiDbDisplayInternalObject (ObjDesc, WalkState);
}
}
}
else
{
2015-11-25 16:04:42 -05:00
AcpiOsPrintf (
"No Arguments are initialized for method [%4.4s]\n",
2015-09-30 16:13:30 -04:00
AcpiUtGetNodeName (Node));
2003-07-13 18:44:13 -04:00
}
}