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

📄 aslfold.c

📁 acpi tools for linux include acpiexec and acpixtract
💻 C
📖 第 1 页 / 共 2 页
字号:
        }        if (WalkState->WalkType == ACPI_WALK_CONST_OPTIONAL)        {            /*             * We are looking at at normal expression to see if it can be             * reduced.  It can't.  No error             */            return (AE_TYPE);        }        /*         * This is an expression that MUST reduce to a constant, and it         * can't be reduced.  This is an error         */        if (Op->Asl.CompileFlags & NODE_IS_TARGET)        {            AslError (ASL_ERROR, ASL_MSG_INVALID_TARGET, Op,                Op->Asl.ParseOpName);        }        else        {            AslError (ASL_ERROR, ASL_MSG_INVALID_CONSTANT_OP, Op,                Op->Asl.ParseOpName);        }        return (AE_TYPE);    }    /* Debug output */    DbgPrint (ASL_PARSE_OUTPUT, "TYPE_345");    if (Op->Asl.CompileFlags & NODE_IS_TARGET)    {        DbgPrint (ASL_PARSE_OUTPUT, " TARGET");    }    if (Op->Asl.CompileFlags & NODE_IS_TERM_ARG)    {        DbgPrint (ASL_PARSE_OUTPUT, " TERMARG");    }    DbgPrint (ASL_PARSE_OUTPUT, "\n");    return (AE_OK);}/******************************************************************************* * * FUNCTION:    OpcAmlConstantWalk * * PARAMETERS:  ASL_WALK_CALLBACK * * RETURN:      Status * * DESCRIPTION: Reduce an Op and its subtree to a constant if possible * ******************************************************************************/ACPI_STATUSOpcAmlConstantWalk (    ACPI_PARSE_OBJECT       *Op,    UINT32                  Level,    void                    *Context){    ACPI_WALK_STATE         *WalkState;    ACPI_STATUS             Status = AE_OK;    ACPI_OPERAND_OBJECT     *ObjDesc;    ACPI_PARSE_OBJECT       *RootOp;    ACPI_PARSE_OBJECT       *OriginalParentOp;    UINT8                   WalkType;    /*     * Only interested in subtrees that could possibly contain     * expressions that can be evaluated at this time     */    if ((!(Op->Asl.CompileFlags & NODE_COMPILE_TIME_CONST)) ||          (Op->Asl.CompileFlags & NODE_IS_TARGET))    {        return (AE_OK);    }    /* Set the walk type based on the reduction used for this op */    if (Op->Asl.CompileFlags & NODE_IS_TERM_ARG)    {        /* Op is a TermArg, constant folding is merely optional */        if (!Gbl_FoldConstants)        {            return (AE_CTRL_DEPTH);        }        WalkType = ACPI_WALK_CONST_OPTIONAL;    }    else    {        /* Op is a DataObject, the expression MUST reduced to a constant */        WalkType = ACPI_WALK_CONST_REQUIRED;    }    /* Create a new walk state */    WalkState = AcpiDsCreateWalkState (0, NULL, NULL, NULL);    if (!WalkState)    {        return AE_NO_MEMORY;    }    WalkState->NextOp               = NULL;    WalkState->Params               = NULL;    WalkState->CallerReturnDesc     = &ObjDesc;    WalkState->WalkType             = WalkType;    /*     * Examine the entire subtree -- all nodes must be constants     * or type 3/4/5 opcodes     */    Status = TrWalkParseTree (Op, ASL_WALK_VISIT_DOWNWARD,                OpcAmlCheckForConstant, NULL, WalkState);    /*     * Did we find an entire subtree that contains all constants and type 3/4/5     * opcodes?  (Only AE_OK or AE_TYPE returned from above)     */    if (Status == AE_TYPE)    {        /* Subtree cannot be reduced to a constant */        if (WalkState->WalkType == ACPI_WALK_CONST_OPTIONAL)        {            AcpiDsDeleteWalkState (WalkState);            return (AE_OK);        }        /* Don't descend any further, and use a default "constant" value */        Status = AE_CTRL_DEPTH;    }    else    {        /* Subtree can be reduced */        /* Allocate a new temporary root for this subtree */        RootOp = TrAllocateNode (PARSEOP_INTEGER);        if (!RootOp)        {            return (AE_NO_MEMORY);        }        RootOp->Common.AmlOpcode = AML_INT_EVAL_SUBTREE_OP;        OriginalParentOp = Op->Common.Parent;        Op->Common.Parent = RootOp;        /* Hand off the subtree to the AML interpreter */        Status = TrWalkParseTree (Op, ASL_WALK_VISIT_TWICE,                    OpcAmlEvaluationWalk1, OpcAmlEvaluationWalk2, WalkState);        Op->Common.Parent = OriginalParentOp;        /* TBD: we really *should* release the RootOp node */        if (ACPI_SUCCESS (Status))        {            TotalFolds++;            /* Get the final result */            Status = AcpiDsResultPop (&ObjDesc, WalkState);        }    }    if (ACPI_FAILURE (Status))    {        /* We could not resolve the subtree for some reason */        AslCoreSubsystemError (Op, Status,            "Failure during constant evaluation", FALSE);        AslError (ASL_ERROR, ASL_MSG_CONSTANT_EVALUATION, Op,            Op->Asl.ParseOpName);        /* Set the subtree value to ZERO anyway.  Eliminates further errors */        Op->Asl.ParseOpcode      = PARSEOP_INTEGER;        Op->Common.Value.Integer = 0;        OpcSetOptimalIntegerSize (Op);    }    else    {        AslError (ASL_OPTIMIZATION, ASL_MSG_CONSTANT_FOLDED, Op,            Op->Asl.ParseOpName);        /*         * Because we know we executed type 3/4/5 opcodes above, we know that         * the result must be either an Integer, String, or Buffer.         */        switch (ACPI_GET_OBJECT_TYPE (ObjDesc))        {        case ACPI_TYPE_INTEGER:            Op->Asl.ParseOpcode      = PARSEOP_INTEGER;            Op->Common.Value.Integer = ObjDesc->Integer.Value;            OpcSetOptimalIntegerSize (Op);            DbgPrint (ASL_PARSE_OUTPUT,                "Constant expression reduced to (INTEGER) %8.8X%8.8X\n",                ACPI_FORMAT_UINT64 (ObjDesc->Integer.Value));            break;        case ACPI_TYPE_STRING:            Op->Asl.ParseOpcode     = PARSEOP_STRING_LITERAL;            Op->Common.AmlOpcode    = AML_STRING_OP;            Op->Asl.AmlLength       = ACPI_STRLEN (ObjDesc->String.Pointer) + 1;            Op->Common.Value.String = ObjDesc->String.Pointer;            DbgPrint (ASL_PARSE_OUTPUT,                "Constant expression reduced to (STRING) %s\n",                Op->Common.Value.String);            break;        case ACPI_TYPE_BUFFER:            Op->Asl.ParseOpcode     = PARSEOP_BUFFER;            Op->Common.AmlOpcode    = AML_BUFFER_OP;            Op->Asl.CompileFlags    = NODE_AML_PACKAGE;            UtSetParseOpName (Op);            /* Child node is the buffer length */            RootOp = TrAllocateNode (PARSEOP_INTEGER);            RootOp->Asl.AmlOpcode     = AML_DWORD_OP;            RootOp->Asl.Value.Integer = ObjDesc->Buffer.Length;            RootOp->Asl.Parent        = Op;            (void) OpcSetOptimalIntegerSize (RootOp);            Op->Asl.Child = RootOp;            Op = RootOp;            UtSetParseOpName (Op);            /* Peer to the child is the raw buffer data */            RootOp = TrAllocateNode (PARSEOP_RAW_DATA);            RootOp->Asl.AmlOpcode     = AML_RAW_DATA_BUFFER;            RootOp->Asl.AmlLength     = ObjDesc->Buffer.Length;            RootOp->Asl.Value.String  = (char *) ObjDesc->Buffer.Pointer;            RootOp->Asl.Parent        = Op->Asl.Parent;            Op->Asl.Next = RootOp;            Op = RootOp;            DbgPrint (ASL_PARSE_OUTPUT,                "Constant expression reduced to (BUFFER) length %X\n",                ObjDesc->Buffer.Length);            break;        default:            printf ("Unsupported return type: %s\n",                        AcpiUtGetObjectTypeName (ObjDesc));            break;        }    }    UtSetParseOpName (Op);    Op->Asl.Child = NULL;    AcpiDsDeleteWalkState (WalkState);    return (AE_CTRL_DEPTH);}

⌨️ 快捷键说明

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