diff options
author | Jung-uk Kim <jkim@FreeBSD.org> | 2012-06-20 17:51:04 +0000 |
---|---|---|
committer | Jung-uk Kim <jkim@FreeBSD.org> | 2012-06-20 17:51:04 +0000 |
commit | 705c538931446b23ef7f028f71c9da55c78bbf23 (patch) | |
tree | f634c2ad6dfa6f49c5aaabc64f8bb79b74dda5a7 /source/components/disassembler | |
parent | fa948a817cf9dae39dc632f9bf48a8af37244a0e (diff) |
Notes
Diffstat (limited to 'source/components/disassembler')
-rw-r--r-- | source/components/disassembler/dmopcode.c | 213 | ||||
-rw-r--r-- | source/components/disassembler/dmwalk.c | 55 |
2 files changed, 260 insertions, 8 deletions
diff --git a/source/components/disassembler/dmopcode.c b/source/components/disassembler/dmopcode.c index 6d2c3e1ecf55..b52bdb28151f 100644 --- a/source/components/disassembler/dmopcode.c +++ b/source/components/disassembler/dmopcode.c @@ -46,6 +46,7 @@ #include "acparser.h" #include "amlcode.h" #include "acdisasm.h" +#include "acnamesp.h" #ifdef ACPI_DISASSEMBLER @@ -61,6 +62,218 @@ AcpiDmMatchKeyword ( /******************************************************************************* * + * FUNCTION: AcpiDmPredefinedDescription + * + * PARAMETERS: Op - Name() parse object + * + * RETURN: None + * + * DESCRIPTION: Emit a description comment for a predefined ACPI name. + * Used for iASL compiler only. + * + ******************************************************************************/ + +void +AcpiDmPredefinedDescription ( + ACPI_PARSE_OBJECT *Op) +{ +#ifdef ACPI_ASL_COMPILER + const AH_PREDEFINED_NAME *Info; + char *NameString; + int LastCharIsDigit; + int LastCharsAreHex; + + + 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; + + /* Predefined name must start with an underscore */ + + NameString = ACPI_CAST_PTR (char, &Op->Named.Name); + if (NameString[0] != '_') + { + return; + } + + /* + * Check for the special ACPI names: + * _ACd, _ALd, _EJd, _Exx, _Lxx, _Qxx, _Wxx, _T_a + * (where d=decimal_digit, x=hex_digit, a=anything) + * + * Convert these to the generic name for table lookup. + * Note: NameString is guaranteed to be upper case here. + */ + LastCharIsDigit = + (ACPI_IS_DIGIT (NameString[3])); /* d */ + LastCharsAreHex = + (ACPI_IS_XDIGIT (NameString[2]) && /* xx */ + ACPI_IS_XDIGIT (NameString[3])); + + switch (NameString[1]) + { + case 'A': + if ((NameString[2] == 'C') && (LastCharIsDigit)) + { + NameString = "_ACx"; + } + else if ((NameString[2] == 'L') && (LastCharIsDigit)) + { + NameString = "_ALx"; + } + break; + + case 'E': + if ((NameString[2] == 'J') && (LastCharIsDigit)) + { + NameString = "_EJx"; + } + else if (LastCharsAreHex) + { + NameString = "_Exx"; + } + break; + + case 'L': + if (LastCharsAreHex) + { + NameString = "_Lxx"; + } + break; + + case 'Q': + if (LastCharsAreHex) + { + NameString = "_Qxx"; + } + break; + + case 'T': + if (NameString[2] == '_') + { + NameString = "_T_x"; + } + break; + + case 'W': + if (LastCharsAreHex) + { + NameString = "_Wxx"; + } + break; + + default: + break; + } + + /* Match the name in the info table */ + + for (Info = AslPredefinedInfo; Info->Name; Info++) + { + if (ACPI_COMPARE_NAME (NameString, Info->Name)) + { + AcpiOsPrintf (" // %4.4s: %s", + NameString, ACPI_CAST_PTR (char, Info->Description)); + 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; +} + + +/******************************************************************************* + * * FUNCTION: AcpiDmMethodFlags * * PARAMETERS: Op - Method Object to be examined diff --git a/source/components/disassembler/dmwalk.c b/source/components/disassembler/dmwalk.c index dd3ee002557b..6a6b95e1f71d 100644 --- a/source/components/disassembler/dmwalk.c +++ b/source/components/disassembler/dmwalk.c @@ -453,7 +453,7 @@ AcpiDmDescendingOp ( * keep track of the current column. */ Info->Count++; - if (Info->Count /*+Info->LastLevel*/ > 10) + if (Info->Count /* +Info->LastLevel */ > 10) { Info->Count = 0; AcpiOsPrintf ("\n"); @@ -533,6 +533,10 @@ AcpiDmDescendingOp ( AcpiDmMethodFlags (Op); AcpiOsPrintf (")"); + + /* Emit description comment for Method() with a predefined ACPI name */ + + AcpiDmPredefinedDescription (Op); break; @@ -603,7 +607,8 @@ AcpiDmDescendingOp ( default: - AcpiOsPrintf ("*** Unhandled named opcode %X\n", Op->Common.AmlOpcode); + AcpiOsPrintf ("*** Unhandled named opcode %X\n", + Op->Common.AmlOpcode); break; } } @@ -644,7 +649,8 @@ AcpiDmDescendingOp ( NextOp = NextOp->Common.Next; Info->Flags = ACPI_PARSEOP_PARAMLIST; - AcpiDmWalkParseTree (NextOp, AcpiDmDescendingOp, AcpiDmAscendingOp, Info); + AcpiDmWalkParseTree (NextOp, AcpiDmDescendingOp, + AcpiDmAscendingOp, Info); Info->Flags = 0; Info->Level = Level; @@ -686,12 +692,18 @@ AcpiDmDescendingOp ( if (Op->Common.DisasmOpcode == ACPI_DASM_RESOURCE) { /* - * We have a resource list. Don't need to output - * the buffer size Op. Open up a new block + * We have a resource list. Don't need to output + * the buffer size Op. Open up a new block */ NextOp->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE; NextOp = NextOp->Common.Next; - AcpiOsPrintf (")\n"); + AcpiOsPrintf (")"); + + /* Emit description comment for Name() with a predefined ACPI name */ + + AcpiDmPredefinedDescription (Op->Asl.Parent); + + AcpiOsPrintf ("\n"); AcpiDmIndent (Info->Level); AcpiOsPrintf ("{\n"); return (AE_OK); @@ -719,7 +731,7 @@ AcpiDmDescendingOp ( case AML_PACKAGE_OP: - /* The next op is the size or predicate parameter */ + /* The next op is the size parameter */ NextOp = AcpiPsGetDepthNext (NULL, Op); if (NextOp) @@ -772,6 +784,7 @@ AcpiDmAscendingOp ( void *Context) { ACPI_OP_WALK_INFO *Info = Context; + ACPI_PARSE_OBJECT *ParentOp; if (Op->Common.DisasmFlags & ACPI_PARSEOP_IGNORE) @@ -797,6 +810,19 @@ AcpiDmAscendingOp ( AcpiOsPrintf (")"); + 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 */ if (!AcpiDmCommaIfListMember (Op)) @@ -911,7 +937,20 @@ AcpiDmAscendingOp ( */ if (Op->Common.Next) { - AcpiOsPrintf (")\n"); + AcpiOsPrintf (")"); + + /* Emit description comment for Name() with a predefined ACPI name */ + + ParentOp = Op->Common.Parent; + if (ParentOp) + { + ParentOp = ParentOp->Common.Parent; + if (ParentOp && ParentOp->Asl.AmlOpcode == AML_NAME_OP) + { + AcpiDmPredefinedDescription (ParentOp); + } + } + AcpiOsPrintf ("\n"); AcpiDmIndent (Level - 1); AcpiOsPrintf ("{\n"); } |