Disassembler: Emit descriptions for resource tags (_MIN, etc.)

Add support to emit short commented descriptions for the various
resource tags, when they are referenced by a Create* operator.
This commit is contained in:
Robert Moore 2012-05-31 15:21:56 -07:00
parent 0d7ca2f1bc
commit d4fcca77cc
4 changed files with 117 additions and 19 deletions

View File

@ -145,6 +145,7 @@ AcpiDmGetResourceTag (
static char *
AcpiGetTagPathname (
ACPI_PARSE_OBJECT *Op,
ACPI_NAMESPACE_NODE *BufferNode,
ACPI_NAMESPACE_NODE *ResourceNode,
UINT32 BitIndex);
@ -515,7 +516,6 @@ AcpiDmCheckResourceReference (
ACPI_NAMESPACE_NODE *BufferNode;
ACPI_NAMESPACE_NODE *ResourceNode;
const ACPI_OPCODE_INFO *OpInfo;
char *Pathname;
UINT32 BitIndex;
@ -591,14 +591,7 @@ AcpiDmCheckResourceReference (
/* Translate the Index to a resource tag pathname */
Pathname = AcpiGetTagPathname (BufferNode, ResourceNode, BitIndex);
if (Pathname)
{
/* Complete the conversion of the Index to a symbol */
IndexOp->Common.AmlOpcode = AML_INT_NAMEPATH_OP;
IndexOp->Common.Value.String = Pathname;
}
AcpiGetTagPathname (IndexOp, BufferNode, ResourceNode, BitIndex);
}
@ -669,6 +662,7 @@ AcpiDmGetResourceNode (
static char *
AcpiGetTagPathname (
ACPI_PARSE_OBJECT *IndexOp,
ACPI_NAMESPACE_NODE *BufferNode,
ACPI_NAMESPACE_NODE *ResourceNode,
UINT32 BitIndex)
@ -761,6 +755,15 @@ AcpiGetTagPathname (
AcpiNsInternalizeName (Pathname, &InternalPath);
ACPI_FREE (Pathname);
/* Update the Op with the symbol */
AcpiPsInitOp (IndexOp, AML_INT_NAMEPATH_OP);
IndexOp->Common.Value.String = InternalPath;
/* We will need the tag later. Cheat by putting it in the Node field */
IndexOp->Common.Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, Tag);
return (InternalPath);
}

View File

@ -118,6 +118,7 @@
#include "acparser.h"
#include "amlcode.h"
#include "acdisasm.h"
#include "acnamesp.h"
#ifdef ACPI_DISASSEMBLER
@ -160,6 +161,14 @@ AcpiDmPredefinedDescription (
return;
}
/* Ensure that the comment field is emitted only once */
if (Op->Common.DisasmFlags & ACPI_PARSEOP_PREDEF_CHECKED)
{
return;
}
Op->Common.DisasmFlags |= ACPI_PARSEOP_PREDEF_CHECKED;
/* Predefined name must start with an underscore */
NameString = ACPI_CAST_PTR (char, &Op->Named.Name);
@ -245,14 +254,93 @@ AcpiDmPredefinedDescription (
if (ACPI_COMPARE_NAME (NameString, Info->Name))
{
AcpiOsPrintf (" // %4.4s: %s",
NameString, (char *) Info->Description);
NameString, ACPI_CAST_PTR (char, Info->Description));
return;
}
}
#else
return;
#endif
return;
}
/*******************************************************************************
*
* FUNCTION: AcpiDmFieldPredefinedDescription
*
* PARAMETERS: Op - Parse object
*
* RETURN: None
*
* DESCRIPTION: Emit a description comment for a resource descriptor tag
* (which is a predefined ACPI name.) Used for iASL compiler only.
*
******************************************************************************/
void
AcpiDmFieldPredefinedDescription (
ACPI_PARSE_OBJECT *Op)
{
#ifdef ACPI_ASL_COMPILER
ACPI_PARSE_OBJECT *IndexOp;
char *Tag;
const ACPI_OPCODE_INFO *OpInfo;
const AH_PREDEFINED_NAME *Info;
if (!Op)
{
return;
}
/* Ensure that the comment field is emitted only once */
if (Op->Common.DisasmFlags & ACPI_PARSEOP_PREDEF_CHECKED)
{
return;
}
Op->Common.DisasmFlags |= ACPI_PARSEOP_PREDEF_CHECKED;
/*
* Op must be one of the Create* operators: CreateField, CreateBitField,
* CreateByteField, CreateWordField, CreateDWordField, CreateQWordField
*/
OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);
if (!(OpInfo->Flags & AML_CREATE))
{
return;
}
/* Second argument is the Index argument */
IndexOp = Op->Common.Value.Arg;
IndexOp = IndexOp->Common.Next;
/* Index argument must be a namepath */
if (IndexOp->Common.AmlOpcode != AML_INT_NAMEPATH_OP)
{
return;
}
/* Major cheat: We previously put the Tag ptr in the Node field */
Tag = ACPI_CAST_PTR (char, IndexOp->Common.Node);
/* Match the name in the info table */
for (Info = AslPredefinedInfo; Info->Name; Info++)
{
if (ACPI_COMPARE_NAME (Tag, Info->Name))
{
AcpiOsPrintf (" // %4.4s: %s", Tag,
ACPI_CAST_PTR (char, Info->Description));
return;
}
}
#endif
return;
}

View File

@ -606,7 +606,7 @@ AcpiDmDescendingOp (
AcpiDmMethodFlags (Op);
AcpiOsPrintf (")");
/* Emit description comment for Name() with a predefined ACPI name */
/* Emit description comment for Method() with a predefined ACPI name */
AcpiDmPredefinedDescription (Op);
break;
@ -774,7 +774,6 @@ AcpiDmDescendingOp (
/* Emit description comment for Name() with a predefined ACPI name */
AcpiDmPredefinedDescription (Op->Asl.Parent);
Op->Asl.Parent->Common.DisasmFlags |= ACPI_PARSEOP_PREDEF_CHECKED;
AcpiOsPrintf ("\n");
AcpiDmIndent (Info->Level);
@ -883,13 +882,18 @@ AcpiDmAscendingOp (
AcpiOsPrintf (")");
/* Emit description comment for Name() with a predefined ACPI name */
if ((Op->Common.AmlOpcode == AML_NAME_OP) &&
(!(Op->Common.DisasmFlags & ACPI_PARSEOP_PREDEF_CHECKED)))
if (Op->Common.AmlOpcode == AML_NAME_OP)
{
/* Emit description comment for Name() with a predefined ACPI name */
AcpiDmPredefinedDescription (Op);
}
else
{
/* For Create* operators, attempt to emit resource tag description */
AcpiDmFieldPredefinedDescription (Op);
}
/* Could be a nested operator, check if comma required */
@ -1016,7 +1020,6 @@ AcpiDmAscendingOp (
if (ParentOp && ParentOp->Asl.AmlOpcode == AML_NAME_OP)
{
AcpiDmPredefinedDescription (ParentOp);
ParentOp->Common.DisasmFlags |= ACPI_PARSEOP_PREDEF_CHECKED;
}
}
AcpiOsPrintf ("\n");

View File

@ -594,6 +594,10 @@ void
AcpiDmPredefinedDescription (
ACPI_PARSE_OBJECT *Op);
void
AcpiDmFieldPredefinedDescription (
ACPI_PARSE_OBJECT *Op);
void
AcpiDmFieldFlags (
ACPI_PARSE_OBJECT *Op);