⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dmwalk.c

📁 acpi tools for linux include acpiexec and acpixtract
💻 C
📖 第 1 页 / 共 2 页
字号:
                    }                    if (AcpiGbl_ExternalList->Type == ACPI_TYPE_METHOD)                    {                        AcpiOsPrintf (")    // %d Arguments\n", AcpiGbl_ExternalList->Value);                    }                    else                    {                        AcpiOsPrintf (")\n");                    }                    NextExternal = AcpiGbl_ExternalList->Next;                    ACPI_FREE (AcpiGbl_ExternalList->Path);                    ACPI_FREE (AcpiGbl_ExternalList);                    AcpiGbl_ExternalList = NextExternal;                }                AcpiOsPrintf ("\n");            }            return (AE_OK);        }    }    else if ((AcpiDmBlockType (Op->Common.Parent) & BLOCK_BRACE) &&             (!(Op->Common.DisasmFlags & ACPI_PARSEOP_PARAMLIST)) &&             (Op->Common.AmlOpcode != AML_INT_BYTELIST_OP))    {            /*             * This is a first-level element of a term list,             * indent a new line             */            AcpiDmIndent (Level);            Info->LastLevel = Level;            Info->Count = 0;    }    /*     * This is an inexpensive mechanism to try and keep lines from getting     * too long. When the limit is hit, start a new line at the previous     * indent plus one. A better but more expensive mechanism would be to     * keep track of the current column.     */    Info->Count++;    if (Info->Count /*+Info->LastLevel*/ > 10)    {        Info->Count = 0;        AcpiOsPrintf ("\n");        AcpiDmIndent (Info->LastLevel + 1);    }    /* Print the opcode name */    AcpiDmDisassembleOneOp (NULL, Info, Op);    if (Op->Common.DisasmOpcode == ACPI_DASM_LNOT_PREFIX)    {        return (AE_OK);    }    if ((Op->Common.AmlOpcode == AML_NAME_OP) ||        (Op->Common.AmlOpcode == AML_RETURN_OP))    {        Info->Level--;    }    /* Start the opcode argument list if necessary */    OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);    if ((OpInfo->Flags & AML_HAS_ARGS) ||        (Op->Common.AmlOpcode == AML_EVENT_OP))    {        /* This opcode has an argument list */        if (AcpiDmBlockType (Op) & BLOCK_PAREN)        {            AcpiOsPrintf (" (");        }        /* If this is a named opcode, print the associated name value */        if (OpInfo->Flags & AML_NAMED)        {            switch (Op->Common.AmlOpcode)            {            case AML_ALIAS_OP:                NextOp = AcpiPsGetDepthNext (NULL, Op);                NextOp->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE;                AcpiDmNamestring (NextOp->Common.Value.Name);                AcpiOsPrintf (", ");                /*lint -fallthrough */            default:                Name = AcpiPsGetName (Op);                if (Op->Named.Path)                {                    AcpiDmNamestring ((char *) Op->Named.Path);                }                else                {                    AcpiDmDumpName ((char *) &Name);                }                if (Op->Common.AmlOpcode != AML_INT_NAMEDFIELD_OP)                {                    if (AcpiGbl_DbOpt_verbose)                    {                        (void) AcpiPsDisplayObjectPathname (NULL, Op);                    }                }                break;            }            switch (Op->Common.AmlOpcode)            {            case AML_METHOD_OP:                AcpiDmMethodFlags (Op);                AcpiOsPrintf (")");                break;            case AML_NAME_OP:                /* Check for _HID and related EISAID() */                AcpiDmIsEisaId (Op);                AcpiOsPrintf (", ");                break;            case AML_REGION_OP:                AcpiDmRegionFlags (Op);                break;            case AML_POWER_RES_OP:                /* Mark the next two Ops as part of the parameter list */                AcpiOsPrintf (", ");                NextOp = AcpiPsGetDepthNext (NULL, Op);                NextOp->Common.DisasmFlags |= ACPI_PARSEOP_PARAMLIST;                NextOp = NextOp->Common.Next;                NextOp->Common.DisasmFlags |= ACPI_PARSEOP_PARAMLIST;                return (AE_OK);            case AML_PROCESSOR_OP:                /* Mark the next three Ops as part of the parameter list */                AcpiOsPrintf (", ");                NextOp = AcpiPsGetDepthNext (NULL, Op);                NextOp->Common.DisasmFlags |= ACPI_PARSEOP_PARAMLIST;                NextOp = NextOp->Common.Next;                NextOp->Common.DisasmFlags |= ACPI_PARSEOP_PARAMLIST;                NextOp = NextOp->Common.Next;                NextOp->Common.DisasmFlags |= ACPI_PARSEOP_PARAMLIST;                return (AE_OK);            case AML_MUTEX_OP:            case AML_DATA_REGION_OP:                AcpiOsPrintf (", ");                return (AE_OK);            case AML_EVENT_OP:            case AML_ALIAS_OP:                return (AE_OK);            case AML_SCOPE_OP:            case AML_DEVICE_OP:            case AML_THERMAL_ZONE_OP:                AcpiOsPrintf (")");                break;            default:                AcpiOsPrintf ("*** Unhandled named opcode %X\n", Op->Common.AmlOpcode);                break;            }        }        else switch (Op->Common.AmlOpcode)        {        case AML_FIELD_OP:        case AML_BANK_FIELD_OP:        case AML_INDEX_FIELD_OP:            Info->BitOffset = 0;            /* Name of the parent OperationRegion */            NextOp = AcpiPsGetDepthNext (NULL, Op);            AcpiDmNamestring (NextOp->Common.Value.Name);            AcpiOsPrintf (", ");            NextOp->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE;            switch (Op->Common.AmlOpcode)            {            case AML_BANK_FIELD_OP:                /* Namestring - Bank Name */                NextOp = AcpiPsGetDepthNext (NULL, NextOp);                AcpiDmNamestring (NextOp->Common.Value.Name);                NextOp->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE;                AcpiOsPrintf (", ");                /*                 * Bank Value. This is a TermArg in the middle of the parameter                 * list, must handle it here.                 *                 * Disassemble the TermArg parse tree. ACPI_PARSEOP_PARAMLIST                 * eliminates newline in the output.                 */                NextOp = NextOp->Common.Next;                Info->Flags = ACPI_PARSEOP_PARAMLIST;                AcpiDmWalkParseTree (NextOp, AcpiDmDescendingOp, AcpiDmAscendingOp, Info);                Info->Flags = 0;                Info->Level = Level;                NextOp->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE;                AcpiOsPrintf (", ");                break;            case AML_INDEX_FIELD_OP:                /* Namestring - Data Name */                NextOp = AcpiPsGetDepthNext (NULL, NextOp);                AcpiDmNamestring (NextOp->Common.Value.Name);                AcpiOsPrintf (", ");                NextOp->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE;                break;            default:                break;            }            AcpiDmFieldFlags (NextOp);            break;        case AML_BUFFER_OP:            /* The next op is the size parameter */            NextOp = AcpiPsGetDepthNext (NULL, Op);            if (!NextOp)            {                /* Single-step support */                return (AE_OK);            }            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                 */                NextOp->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE;                NextOp = NextOp->Common.Next;                AcpiOsPrintf (")\n");                AcpiDmIndent (Info->Level);                AcpiOsPrintf ("{\n");                return (AE_OK);            }            /* Normal Buffer, mark size as in the parameter list */            NextOp->Common.DisasmFlags |= ACPI_PARSEOP_PARAMLIST;            return (AE_OK);        case AML_VAR_PACKAGE_OP:        case AML_IF_OP:        case AML_WHILE_OP:            /* The next op is the size or predicate parameter */            NextOp = AcpiPsGetDepthNext (NULL, Op);            if (NextOp)            {                NextOp->Common.DisasmFlags |= ACPI_PARSEOP_PARAMLIST;            }            return (AE_OK);        case AML_PACKAGE_OP:            /* The next op is the size or predicate parameter */            NextOp = AcpiPsGetDepthNext (NULL, Op);            if (NextOp)            {                NextOp->Common.DisasmFlags |= ACPI_PARSEOP_PARAMLIST;            }            return (AE_OK);        case AML_MATCH_OP:            AcpiDmMatchOp (Op);            break;        default:            break;        }        if (AcpiDmBlockType (Op) & BLOCK_BRACE)        {            AcpiOsPrintf ("\n");            AcpiDmIndent (Level);            AcpiOsPrintf ("{\n");        }    }    return (AE_OK);}/******************************************************************************* * * FUNCTION:    AcpiDmAscendingOp * * PARAMETERS:  ASL_WALK_CALLBACK * * RETURN:      Status * * DESCRIPTION: Second visitation of a parse object, during ascent of parse *              tree.  Close out any parameter lists and complete the opcode. * ******************************************************************************/static ACPI_STATUSAcpiDmAscendingOp (    ACPI_PARSE_OBJECT       *Op,    UINT32                  Level,    void                    *Context){    ACPI_OP_WALK_INFO       *Info = Context;    if (Op->Common.DisasmFlags & ACPI_PARSEOP_IGNORE)    {        /* Ignore this op -- it was handled elsewhere */        return (AE_OK);    }    if ((Level == 0) && (Op->Common.AmlOpcode == AML_SCOPE_OP))    {        /* Indicates the end of the current descriptor block (table) */        AcpiOsPrintf ("}\n\n");        return (AE_OK);    }    switch (AcpiDmBlockType (Op))    {    case BLOCK_PAREN:        /* Completed an op that has arguments, add closing paren */        AcpiOsPrintf (")");        /* Could be a nested operator, check if comma required */        if (!AcpiDmCommaIfListMember (Op))        {            if ((AcpiDmBlockType (Op->Common.Parent) & BLOCK_BRACE) &&                     (!(Op->Common.DisasmFlags & ACPI_PARSEOP_PARAMLIST)) &&                     (Op->Common.AmlOpcode != AML_INT_BYTELIST_OP))            {                /*                 * This is a first-level element of a term list                 * start a new line                 */                if (!(Info->Flags & ACPI_PARSEOP_PARAMLIST))                {                    AcpiOsPrintf ("\n");                }            }        }        break;    case BLOCK_BRACE:    case (BLOCK_BRACE | BLOCK_PAREN):        /* Completed an op that has a term list, add closing brace */        if (Op->Common.DisasmFlags & ACPI_PARSEOP_EMPTY_TERMLIST)        {            AcpiOsPrintf ("}");        }        else        {            AcpiDmIndent (Level);            AcpiOsPrintf ("}");        }        AcpiDmCommaIfListMember (Op);        if (AcpiDmBlockType (Op->Common.Parent) != BLOCK_PAREN)        {            AcpiOsPrintf ("\n");            if (!(Op->Common.DisasmFlags & ACPI_PARSEOP_EMPTY_TERMLIST))            {                if ((Op->Common.AmlOpcode == AML_IF_OP)  &&                    (Op->Common.Next) &&                    (Op->Common.Next->Common.AmlOpcode == AML_ELSE_OP))                {                    break;                }                if ((AcpiDmBlockType (Op->Common.Parent) & BLOCK_BRACE) &&                    (!Op->Common.Next))                {                    break;                }                AcpiOsPrintf ("\n");            }        }        break;    case BLOCK_NONE:    default:        /* Could be a nested operator, check if comma required */        if (!AcpiDmCommaIfListMember (Op))        {            if ((AcpiDmBlockType (Op->Common.Parent) & BLOCK_BRACE) &&                     (!(Op->Common.DisasmFlags & ACPI_PARSEOP_PARAMLIST)) &&                     (Op->Common.AmlOpcode != AML_INT_BYTELIST_OP))            {                /*                 * This is a first-level element of a term list                 * start a new line                 */                AcpiOsPrintf ("\n");            }        }        else if (Op->Common.Parent)        {            switch (Op->Common.Parent->Common.AmlOpcode)            {            case AML_PACKAGE_OP:            case AML_VAR_PACKAGE_OP:                if (!(Op->Common.DisasmFlags & ACPI_PARSEOP_PARAMLIST))                {                    AcpiOsPrintf ("\n");                }                break;            default:                break;            }        }        break;    }    if (Op->Common.DisasmFlags & ACPI_PARSEOP_PARAMLIST)    {        if ((Op->Common.Next) &&            (Op->Common.Next->Common.DisasmFlags & ACPI_PARSEOP_PARAMLIST))        {            return (AE_OK);        }        /*         * Just completed a parameter node for something like "Buffer (param)".         * Close the paren and open up the term list block with a brace         */        if (Op->Common.Next)        {            AcpiOsPrintf (")\n");            AcpiDmIndent (Level - 1);            AcpiOsPrintf ("{\n");        }        else        {            Op->Common.Parent->Common.DisasmFlags |=                                    ACPI_PARSEOP_EMPTY_TERMLIST;            AcpiOsPrintf (") {");        }    }    if ((Op->Common.AmlOpcode == AML_NAME_OP) ||        (Op->Common.AmlOpcode == AML_RETURN_OP))    {        Info->Level++;    }    return (AE_OK);}#endif  /* ACPI_DISASSEMBLER */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -