コード例 #1
0
ファイル: asllisting.c プロジェクト: cailianchun/acpica
static ACPI_STATUS
LsTreeWriteWalk (
    ACPI_PARSE_OBJECT       *Op,
    UINT32                  Level,
    void                    *Context)
{

    /* Debug output */

    DbgPrint (ASL_TREE_OUTPUT,
        "%5.5d [%2d]", Op->Asl.LogicalLineNumber, Level);

    UtPrintFormattedName (Op->Asl.ParseOpcode, Level);

    if (Op->Asl.ParseOpcode == PARSEOP_NAMESEG)
    {
        DbgPrint (ASL_TREE_OUTPUT,
            "%10.4s      ", Op->Asl.Value.Name);
    }
    else if ((Op->Asl.ParseOpcode == PARSEOP_NAMESTRING) ||
        (Op->Asl.ParseOpcode == PARSEOP_METHODCALL))
    {
        DbgPrint (ASL_TREE_OUTPUT,
            "%10.32s      ", Op->Asl.Value.String);
    }
    else if (Op->Asl.ParseOpcode == PARSEOP_INCLUDE)
    {
        DbgPrint (ASL_TREE_OUTPUT,
            "Open: %s\n", Op->Asl.Value.String);
        return (AE_OK);
    }
    else if (Op->Asl.ParseOpcode == PARSEOP_INCLUDE_END)
    {
        DbgPrint (ASL_TREE_OUTPUT,
            "Close: %s\n", Op->Asl.Filename);
        return (AE_OK);
    }
    else
    {
        DbgPrint (ASL_TREE_OUTPUT, "                ");
    }

    DbgPrint (ASL_TREE_OUTPUT, "    (%.4X) Flags %8.8X",
        Op->Asl.ParseOpcode, Op->Asl.CompileFlags);
    TrPrintNodeCompileFlags (Op->Asl.CompileFlags);
    DbgPrint (ASL_TREE_OUTPUT, "\n");
    return (AE_OK);
}
コード例 #2
0
ファイル: asltree.c プロジェクト: d3c0n808/Intel-iasl
ACPI_PARSE_OBJECT *
TrSetNodeFlags (
    ACPI_PARSE_OBJECT       *Op,
    UINT32                  Flags)
{

    if (!Op)
    {
        return (NULL);
    }

    DbgPrint (ASL_PARSE_OUTPUT,
        "\nSetNodeFlags: %s Op %p, %8.8X", Op->Asl.ParseOpName, Op, Flags);

    TrPrintNodeCompileFlags (Flags);
    DbgPrint (ASL_PARSE_OUTPUT, "\n\n");

    Op->Asl.CompileFlags |= Flags;
    return (Op);
}
コード例 #3
0
ファイル: asllisting.c プロジェクト: Raphine/Raph_Kernel
static ACPI_STATUS
LsTreeWriteWalk (
    ACPI_PARSE_OBJECT       *Op,
    UINT32                  Level,
    void                    *Context)
{

    /* Dump ParseOp name and possible value */

    switch (Op->Asl.ParseOpcode)
    {
        case PARSEOP_NAMESEG:
        case PARSEOP_NAMESTRING:
        case PARSEOP_METHODCALL:
        case PARSEOP_STRING_LITERAL:

        UtDumpStringOp (Op, Level);
        break;

    case PARSEOP_BYTECONST:

        UtDumpIntegerOp (Op, Level, 2);
        break;

    case PARSEOP_WORDCONST:
    case PARSEOP_PACKAGE_LENGTH:

        UtDumpIntegerOp (Op, Level, 4);
        break;

    case PARSEOP_DWORDCONST:
    case PARSEOP_EISAID:

        UtDumpIntegerOp (Op, Level, 8);
        break;

    case PARSEOP_QWORDCONST:
    case PARSEOP_INTEGER:
    case PARSEOP_ONE:
    case PARSEOP_ZERO:
    case PARSEOP_ONES:

        UtDumpIntegerOp (Op, Level, 16);
        break;

    case PARSEOP_INCLUDE:

        DbgPrint (ASL_TREE_OUTPUT,
            "Open: %s\n", Op->Asl.Value.String);
        return (AE_OK);

    case PARSEOP_INCLUDE_END:

        DbgPrint (ASL_TREE_OUTPUT,
            "Close: %s\n", Op->Asl.Filename);
        return (AE_OK);

    default:

        UtDumpBasicOp (Op, Level);
        break;
    }

    /* Dump the remaining data */

    DbgPrint (ASL_TREE_OUTPUT, ASL_PARSE_TREE_DEBUG1,
        Op->Asl.ParseOpcode, Op->Asl.CompileFlags,
        Op->Asl.LineNumber, Op->Asl.EndLine,
        Op->Asl.LogicalLineNumber, Op->Asl.EndLogicalLine);

    TrPrintNodeCompileFlags (Op->Asl.CompileFlags);
    DbgPrint (ASL_TREE_OUTPUT, "\n");
    return (AE_OK);
}
コード例 #4
0
ファイル: aslfold.c プロジェクト: olsner/acpica
static ACPI_STATUS
OpcAmlCheckForConstant (
    ACPI_PARSE_OBJECT       *Op,
    UINT32                  Level,
    void                    *Context)
{
    ACPI_WALK_STATE         *WalkState = Context;
    ACPI_STATUS             Status = AE_OK;
    ACPI_PARSE_OBJECT       *NextOp;
    const ACPI_OPCODE_INFO  *OpInfo;


    WalkState->Op = Op;
    WalkState->Opcode = Op->Common.AmlOpcode;
    WalkState->OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);

    DbgPrint (ASL_PARSE_OUTPUT, "[%.4d] Opcode: %12.12s ",
        Op->Asl.LogicalLineNumber, Op->Asl.ParseOpName);

    /*
     * These opcodes do not appear in the OpcodeInfo table, but
     * they represent constants, so abort the constant walk now.
     */
    if ((WalkState->Opcode == AML_RAW_DATA_BYTE) ||
        (WalkState->Opcode == AML_RAW_DATA_WORD) ||
        (WalkState->Opcode == AML_RAW_DATA_DWORD) ||
        (WalkState->Opcode == AML_RAW_DATA_QWORD))
    {
        DbgPrint (ASL_PARSE_OUTPUT, "RAW DATA");
        Status = AE_TYPE;
        goto CleanupAndExit;
    }

    /*
     * Search upwards for a possible Name() operator. This is done
     * because a type 3/4/5 opcode within a Name() expression
     * MUST be reduced to a simple constant.
     */
    NextOp = Op->Asl.Parent;
    while (NextOp)
    {
        /* Finished if we find a Name() opcode */

        if (NextOp->Asl.AmlOpcode == AML_NAME_OP)
        {
            break;
        }

        /*
         * Any "deferred" opcodes contain one or more TermArg parameters,
         * and thus are not required to be folded to constants at compile
         * time. This affects things like Buffer() and Package() objects.
         * We just ignore them here. However, any sub-expressions can and
         * will still be typechecked. Note: These are called the
         * "deferred" opcodes in the AML interpreter.
         */
        OpInfo = AcpiPsGetOpcodeInfo (NextOp->Common.AmlOpcode);
        if (OpInfo->Flags & AML_DEFER)
        {
            NextOp = NULL;
            break;
        }

        NextOp = NextOp->Asl.Parent;
    }

    /* Type 3/4/5 opcodes have the AML_CONSTANT flag set */

    if (!(WalkState->OpInfo->Flags & AML_CONSTANT))
    {
        /*
         * From the ACPI specification:
         *
         * "The Type 3/4/5 opcodes return a value and can be used in an
         * expression that evaluates to a constant. These opcodes may be
         * evaluated at ASL compile-time. To ensure that these opcodes
         * will evaluate to a constant, the following rules apply: The
         * term cannot have a destination (target) operand, and must have
         * either a Type3Opcode, Type4Opcode, Type5Opcode, ConstExprTerm,
         * Integer, BufferTerm, Package, or String for all arguments."
         */

        /*
         * The value (second) operand for the Name() operator MUST
         * reduce to a single constant, as per the ACPI specification
         * (the operand is a DataObject). This also implies that there
         * can be no target operand. Name() is the only ASL operator
         * with a "DataObject" as an operand and is thus special-
         * cased here.
         */
        if (NextOp) /* Inspect a Name() operator */
        {
            /* Error if there is a target operand */

            if (Op->Asl.CompileFlags & NODE_IS_TARGET)
            {
                AslError (ASL_ERROR, ASL_MSG_INVALID_TARGET, Op, NULL);
                Status = AE_TYPE;
            }

            /* Error if expression cannot be reduced (folded) */

            if (!(NextOp->Asl.CompileFlags & NODE_COULD_NOT_REDUCE))
            {
                /* Ensure only one error message per statement */

                NextOp->Asl.CompileFlags |= NODE_COULD_NOT_REDUCE;
                DbgPrint (ASL_PARSE_OUTPUT,
                    "**** Could not reduce operands for NAME opcode ****\n");

                AslError (ASL_ERROR, ASL_MSG_CONSTANT_REQUIRED, Op,
                    "Constant is required for Name operator");
                Status = AE_TYPE;
            }
        }

        if (ACPI_FAILURE (Status))
        {
            goto CleanupAndExit;
        }

        /* This is not a 3/4/5 opcode, but maybe can convert to STORE */

        if (Op->Asl.CompileFlags & NODE_IS_TARGET)
        {
            DbgPrint (ASL_PARSE_OUTPUT,
                "**** Valid Target, transform to Store ****\n");
            return (AE_CTRL_RETURN_VALUE);
        }

        /* Expression cannot be reduced */

        DbgPrint (ASL_PARSE_OUTPUT,
            "**** Not a Type 3/4/5 opcode or cannot reduce/fold (%s) ****\n",
             Op->Asl.ParseOpName);

        Status = AE_TYPE;
        goto CleanupAndExit;
    }

    /*
     * TBD: Ignore buffer constants for now. The problem is that these
     * constants have been transformed into RAW_DATA at this point, from
     * the parse tree transform process which currently happens before
     * the constant folding process. We may need to defer this transform
     * for buffer until after the constant folding.
     */
    if (WalkState->Opcode == AML_BUFFER_OP)
    {
        DbgPrint (ASL_PARSE_OUTPUT,
            "\nBuffer constant reduction is not supported yet\n");

        if (NextOp) /* Found a Name() operator, error */
        {
            AslError (ASL_ERROR, ASL_MSG_UNSUPPORTED, Op,
                "Buffer expression cannot be reduced");
        }

        Status = AE_TYPE;
        goto CleanupAndExit;
    }

    /* Debug output */

    DbgPrint (ASL_PARSE_OUTPUT, "TYPE_345");

    if (Op->Asl.CompileFlags & NODE_IS_TARGET)
    {
        if (Op->Asl.ParseOpcode == PARSEOP_ZERO)
        {
            DbgPrint (ASL_PARSE_OUTPUT, "%-16s", " NULL TARGET");
        }
        else
        {
            DbgPrint (ASL_PARSE_OUTPUT, "%-16s", " VALID TARGET");
        }
    }

    if (Op->Asl.CompileFlags & NODE_IS_TERM_ARG)
    {
        DbgPrint (ASL_PARSE_OUTPUT, "%-16s", " TERMARG");
    }

CleanupAndExit:

    /* Dump the node compile flags also */

    TrPrintNodeCompileFlags (Op->Asl.CompileFlags);
    DbgPrint (ASL_PARSE_OUTPUT, "\n");
    return (Status);
}
コード例 #5
0
ファイル: aslfold.c プロジェクト: alexandermerritt/dragonfly
static ACPI_STATUS
OpcAmlCheckForConstant (
    ACPI_PARSE_OBJECT       *Op,
    UINT32                  Level,
    void                    *Context)
{
    ACPI_WALK_STATE         *WalkState = Context;
    ACPI_STATUS             Status = AE_OK;


    WalkState->Op = Op;
    WalkState->Opcode = Op->Common.AmlOpcode;
    WalkState->OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);

    DbgPrint (ASL_PARSE_OUTPUT, "[%.4d] Opcode: %12.12s ",
        Op->Asl.LogicalLineNumber, Op->Asl.ParseOpName);

    /*
     * TBD: Ignore buffer constants for now. The problem is that these
     * constants have been transformed into RAW_DATA at this point, from
     * the parse tree transform process which currently happens before
     * the constant folding process. We may need to defer this transform
     * for buffer until after the constant folding.
     */
    if (WalkState->Opcode == AML_BUFFER_OP)
    {
        Status = AE_TYPE;
        goto CleanupAndExit;
    }

    /*
     * These opcodes do not appear in the OpcodeInfo table, but
     * they represent constants, so abort the constant walk now.
     */
    if ((WalkState->Opcode == AML_RAW_DATA_BYTE) ||
        (WalkState->Opcode == AML_RAW_DATA_WORD) ||
        (WalkState->Opcode == AML_RAW_DATA_DWORD) ||
        (WalkState->Opcode == AML_RAW_DATA_QWORD))
    {
        DbgPrint (ASL_PARSE_OUTPUT, "RAW DATA");
        Status = AE_TYPE;
        goto CleanupAndExit;
    }

    /* Type 3/4/5 opcodes have the AML_CONSTANT flag set */

    if (!(WalkState->OpInfo->Flags & AML_CONSTANT))
    {
        /* Not 3/4/5 opcode, but maybe can convert to STORE */

        if (Op->Asl.CompileFlags & NODE_IS_TARGET)
        {
            DbgPrint (ASL_PARSE_OUTPUT,
                "**** Valid Target, transform to Store ****\n");
            return (AE_CTRL_RETURN_VALUE);
        }

        /* Expression cannot be reduced */

        DbgPrint (ASL_PARSE_OUTPUT,
            "**** Not a Type 3/4/5 opcode (%s) ****",
             Op->Asl.ParseOpName);

        Status = AE_TYPE;
        goto CleanupAndExit;
    }

    /* Debug output */

    DbgPrint (ASL_PARSE_OUTPUT, "TYPE_345");

    if (Op->Asl.CompileFlags & NODE_IS_TARGET)
    {
        if (Op->Asl.ParseOpcode == PARSEOP_ZERO)
        {
            DbgPrint (ASL_PARSE_OUTPUT, "%-16s", " NULL TARGET");
        }
        else
        {
            DbgPrint (ASL_PARSE_OUTPUT, "%-16s", " VALID TARGET");
        }
    }
    if (Op->Asl.CompileFlags & NODE_IS_TERM_ARG)
    {
        DbgPrint (ASL_PARSE_OUTPUT, "%-16s", " TERMARG");
    }

CleanupAndExit:

    /* Dump the node compile flags also */

    TrPrintNodeCompileFlags (Op->Asl.CompileFlags);
    DbgPrint (ASL_PARSE_OUTPUT, "\n");
    return (Status);
}