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

📄 adwalk.c

📁 acpi tools for linux include acpiexec and acpixtract
💻 C
📖 第 1 页 / 共 2 页
字号:
    ACPI_PARSE_OBJECT       *NextOp;    ACPI_PARSE_OBJECT       *ParentOp;    UINT32                  ArgCount;    if (!Op)    {        return (AE_OK);    }    OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);    switch (Op->Common.AmlOpcode)    {#ifdef ACPI_UNDER_DEVELOPMENT    case AML_ADD_OP:        ChildOp = Op->Common.Value.Arg;        if ((ChildOp->Common.AmlOpcode == AML_INT_NAMEPATH_OP) &&            !ChildOp->Common.Node)        {            AcpiNsExternalizeName (ACPI_UINT32_MAX, ChildOp->Common.Value.String,                            NULL, &Path);            AcpiOsPrintf ("/* %-16s A-NAMEPATH: %s  */\n", Op->Common.AmlOpName, Path);            ACPI_FREE (Path);            NextOp = Op->Common.Next;            if (!NextOp)            {                /* This NamePath has no args, assume it is an integer */                AcpiDmAddToExternalList (ChildOp->Common.Value.String, ACPI_TYPE_INTEGER, 0);                return (AE_OK);            }            ArgCount = AcpiDmInspectPossibleArgs (3, 1, NextOp);            AcpiOsPrintf ("/* A-CHILDREN: %d Actual %d */\n", ArgCount, AcpiDmCountChildren (Op));            if (ArgCount < 1)            {                /* One Arg means this is just a Store(Name,Target) */                AcpiDmAddToExternalList (ChildOp->Common.Value.String, ACPI_TYPE_INTEGER, 0);                return (AE_OK);            }            AcpiDmAddToExternalList (ChildOp->Common.Value.String, ACPI_TYPE_METHOD, ArgCount);        }        break;#endif    case AML_STORE_OP:        ChildOp = Op->Common.Value.Arg;        if ((ChildOp->Common.AmlOpcode == AML_INT_NAMEPATH_OP) &&            !ChildOp->Common.Node)        {            NextOp = Op->Common.Next;            if (!NextOp)            {                /* This NamePath has no args, assume it is an integer */                AcpiDmAddToExternalList (ChildOp->Common.Value.String, ACPI_TYPE_INTEGER, 0);                return (AE_OK);            }            ArgCount = AcpiDmInspectPossibleArgs (2, 1, NextOp);            if (ArgCount <= 1)            {                /* One Arg means this is just a Store(Name,Target) */                AcpiDmAddToExternalList (ChildOp->Common.Value.String, ACPI_TYPE_INTEGER, 0);                return (AE_OK);            }            AcpiDmAddToExternalList (ChildOp->Common.Value.String, ACPI_TYPE_METHOD, ArgCount);        }        break;    case AML_INT_NAMEPATH_OP:        /* Must examine parent to see if this namepath is an argument */        ParentOp = Op->Common.Parent;        OpInfo = AcpiPsGetOpcodeInfo (ParentOp->Common.AmlOpcode);        if ((OpInfo->Class != AML_CLASS_EXECUTE) &&            (OpInfo->Class != AML_CLASS_CREATE) &&            (ParentOp->Common.AmlOpcode != AML_INT_METHODCALL_OP) &&            !Op->Common.Node)        {            ArgCount = AcpiDmInspectPossibleArgs (0, 0, Op->Common.Next);            /*             * Check if namepath is a predicate for if/while or lone parameter to             * a return.             */            if (ArgCount == 0)            {                if (((ParentOp->Common.AmlOpcode == AML_IF_OP) ||                     (ParentOp->Common.AmlOpcode == AML_WHILE_OP) ||                     (ParentOp->Common.AmlOpcode == AML_RETURN_OP)) &&                     /* And namepath is the first argument */                     (ParentOp->Common.Value.Arg == Op))                {                    AcpiDmAddToExternalList (Op->Common.Value.String, ACPI_TYPE_INTEGER, 0);                    break;                }            }            /*             * This is a standalone namestring (not a parameter to another             * operator) - it *must* be a method invocation, nothing else is             * grammatically possible.             */            AcpiDmAddToExternalList (Op->Common.Value.String, ACPI_TYPE_METHOD, ArgCount);        }        break;    }    return (AE_OK);}/******************************************************************************* * * FUNCTION:    AcpiDmLoadDescendingOp * * PARAMETERS:  ASL_WALK_CALLBACK * * RETURN:      Status * * DESCRIPTION: Descending handler for namespace control method object load * ******************************************************************************/static ACPI_STATUSAcpiDmLoadDescendingOp (    ACPI_PARSE_OBJECT       *Op,    UINT32                  Level,    void                    *Context){    ACPI_OP_WALK_INFO       *Info = Context;    const ACPI_OPCODE_INFO  *OpInfo;    ACPI_WALK_STATE         *WalkState;    ACPI_OBJECT_TYPE        ObjectType;    ACPI_STATUS             Status;    char                    *Path = NULL;    ACPI_PARSE_OBJECT       *NextOp;    ACPI_NAMESPACE_NODE     *Node;    WalkState = Info->WalkState;    OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);    ObjectType = OpInfo->ObjectType;    ObjectType = AslMapNamedOpcodeToDataType (Op->Asl.AmlOpcode);    /* Only interested in operators that create new names */    if (!(OpInfo->Flags & AML_NAMED) &&        !(OpInfo->Flags & AML_CREATE))    {        goto Exit;    }    /* Get the NamePath from the appropriate place */    if (OpInfo->Flags & AML_NAMED)    {        /* For all named operators, get the new name */        Path = (char *) Op->Named.Path;    }    else if (OpInfo->Flags & AML_CREATE)    {        /* New name is the last child */        NextOp = Op->Common.Value.Arg;        while (NextOp->Common.Next)        {            NextOp = NextOp->Common.Next;        }        Path = NextOp->Common.Value.String;    }    if (!Path)    {        goto Exit;    }    /* Insert the name into the namespace */    Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ObjectType,                ACPI_IMODE_LOAD_PASS2, ACPI_NS_DONT_OPEN_SCOPE,                WalkState, &Node);    Op->Common.Node = Node;Exit:    if (AcpiNsOpensScope (ObjectType))    {        if (Op->Common.Node)        {            Status = AcpiDsScopeStackPush (Op->Common.Node, ObjectType, WalkState);            if (ACPI_FAILURE (Status))            {                return (Status);            }        }    }    return (AE_OK);}/******************************************************************************* * * FUNCTION:    AcpiDmXrefDescendingOp * * PARAMETERS:  ASL_WALK_CALLBACK * * RETURN:      Status * * DESCRIPTION: Descending handler for namespace cross reference * ******************************************************************************/static ACPI_STATUSAcpiDmXrefDescendingOp (    ACPI_PARSE_OBJECT       *Op,    UINT32                  Level,    void                    *Context){    ACPI_OP_WALK_INFO       *Info = Context;    const ACPI_OPCODE_INFO  *OpInfo;    ACPI_WALK_STATE         *WalkState;    ACPI_OBJECT_TYPE        ObjectType;    ACPI_STATUS             Status;    char                    *Path = NULL;    ACPI_PARSE_OBJECT       *NextOp;    ACPI_NAMESPACE_NODE     *Node;    WalkState = Info->WalkState;    OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);    ObjectType = OpInfo->ObjectType;    ObjectType = AslMapNamedOpcodeToDataType (Op->Asl.AmlOpcode);    if ((!(OpInfo->Flags & AML_NAMED)) &&        (!(OpInfo->Flags & AML_CREATE)) &&        (Op->Common.AmlOpcode != AML_INT_NAMEPATH_OP))    {        goto Exit;    }    /* Get the NamePath from the appropriate place */    if (OpInfo->Flags & AML_NAMED)    {        if ((Op->Common.AmlOpcode == AML_ALIAS_OP) ||            (Op->Common.AmlOpcode == AML_SCOPE_OP))        {            /*             * Only these two operators refer to an existing name,             * first argument             */            Path = (char *) Op->Named.Path;        }    }    else if (OpInfo->Flags & AML_CREATE)    {        /* Referenced Buffer Name is the first child */        NextOp = Op->Common.Value.Arg;        if (NextOp->Common.AmlOpcode == AML_INT_NAMEPATH_OP)        {            Path = NextOp->Common.Value.String;        }    }    else    {        Path = Op->Common.Value.String;    }    if (!Path)    {        goto Exit;    }    /*     * Lookup the name in the namespace.  Name must exist at this point, or it     * is an invalid reference.     *     * The namespace is also used as a lookup table for references to resource     * descriptors and the fields within them.     */    Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ACPI_TYPE_ANY,                ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE,                WalkState, &Node);    if (ACPI_FAILURE (Status))    {        if (Status == AE_NOT_FOUND)        {            AcpiDmAddToExternalList (Path, (UINT8) ObjectType, 0);            /*             * We could install this into the namespace, but we catch duplicate             * externals when they are added to the list.             */#if 0            Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ACPI_TYPE_ANY,                       ACPI_IMODE_LOAD_PASS1, ACPI_NS_DONT_OPEN_SCOPE,                       WalkState, &Node);#endif        }    }    else    {        Op->Common.Node = Node;    }Exit:    /* Open new scope if necessary */    if (AcpiNsOpensScope (ObjectType))    {        if (Op->Common.Node)        {            Status = AcpiDsScopeStackPush (Op->Common.Node, ObjectType, WalkState);            if (ACPI_FAILURE (Status))            {                return (Status);            }        }    }    return (AE_OK);}/******************************************************************************* * * FUNCTION:    AcpiDmResourceDescendingOp * * PARAMETERS:  ASL_WALK_CALLBACK * * RETURN:      None * * DESCRIPTION: Process one parse op during symbolic resource index conversion. * ******************************************************************************/static ACPI_STATUSAcpiDmResourceDescendingOp (    ACPI_PARSE_OBJECT       *Op,    UINT32                  Level,    void                    *Context){    ACPI_OP_WALK_INFO       *Info = Context;    const ACPI_OPCODE_INFO  *OpInfo;    ACPI_WALK_STATE         *WalkState;    ACPI_OBJECT_TYPE        ObjectType;    ACPI_STATUS             Status;    WalkState = Info->WalkState;    OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);    /* Open new scope if necessary */    ObjectType = OpInfo->ObjectType;    if (AcpiNsOpensScope (ObjectType))    {        if (Op->Common.Node)        {            Status = AcpiDsScopeStackPush (Op->Common.Node, ObjectType, WalkState);            if (ACPI_FAILURE (Status))            {                return (Status);            }        }    }    /*     * Check if this operator contains a reference to a resource descriptor.     * If so, convert the reference into a symbolic reference.     */    AcpiDmCheckResourceReference (Op, WalkState);    return (AE_OK);}/******************************************************************************* * * FUNCTION:    AcpiDmCommonAscendingOp * * PARAMETERS:  ASL_WALK_CALLBACK * * RETURN:      None * * DESCRIPTION: Ascending handler for combined parse/namespace walks. Closes *              scope if necessary. * ******************************************************************************/static ACPI_STATUSAcpiDmCommonAscendingOp (    ACPI_PARSE_OBJECT       *Op,    UINT32                  Level,    void                    *Context){    ACPI_OP_WALK_INFO       *Info = Context;    const ACPI_OPCODE_INFO  *OpInfo;    ACPI_OBJECT_TYPE        ObjectType;    /* Close scope if necessary */    OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);    ObjectType = OpInfo->ObjectType;    ObjectType = AslMapNamedOpcodeToDataType (Op->Asl.AmlOpcode);    if (AcpiNsOpensScope (ObjectType))    {        (void) AcpiDsScopeStackPop (Info->WalkState);    }    return (AE_OK);}/******************************************************************************* * * FUNCTION:    AcpiDmInspectPossibleArgs * * PARAMETERS:  CurrentOpArgCount   - Which arg of the current op was the *                                    possible method invocation found *              TargetCount         - Number of targets (0,1,2) for this op *              Op                  - Parse op * * RETURN:      Status * * DESCRIPTION: Examine following args and next ops for possible arguments *              for an unrecognized method invocation. * ******************************************************************************/static UINT32AcpiDmInspectPossibleArgs (    UINT32                  CurrentOpArgCount,    UINT32                  TargetCount,    ACPI_PARSE_OBJECT       *Op){    const ACPI_OPCODE_INFO  *OpInfo;    UINT32                  i;    UINT32                  Last = 0;    UINT32                  Lookahead;    Lookahead = (ACPI_METHOD_NUM_ARGS + TargetCount) - CurrentOpArgCount;    /* Lookahead for the maximum number of possible arguments */    for (i = 0; i < Lookahead; i++)    {        if (!Op)        {            break;        }        OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);        /*         * Any one of these operators is "very probably" not a method arg         */        if ((Op->Common.AmlOpcode == AML_STORE_OP) ||            (Op->Common.AmlOpcode == AML_NOTIFY_OP))        {            break;        }        if ((OpInfo->Class != AML_CLASS_EXECUTE) &&            (OpInfo->Class != AML_CLASS_CONTROL))        {            Last = i+1;        }        Op = Op->Common.Next;    }    return (Last);}

⌨️ 快捷键说明

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