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

📄 exoparg2.c

📁 acpi tools for linux include acpiexec and acpixtract
💻 C
📖 第 1 页 / 共 2 页
字号:
 * * RETURN:      Status * * DESCRIPTION: Execute opcode with two arguments, one target, and a return *              value. * ******************************************************************************/ACPI_STATUSAcpiExOpcode_2A_1T_1R (    ACPI_WALK_STATE         *WalkState){    ACPI_OPERAND_OBJECT     **Operand = &WalkState->Operands[0];    ACPI_OPERAND_OBJECT     *ReturnDesc = NULL;    ACPI_INTEGER            Index;    ACPI_STATUS             Status = AE_OK;    ACPI_SIZE               Length;    ACPI_FUNCTION_TRACE_STR (ExOpcode_2A_1T_1R,        AcpiPsGetOpcodeName (WalkState->Opcode));    /* Execute the opcode */    if (WalkState->OpInfo->Flags & AML_MATH)    {        /* All simple math opcodes (add, etc.) */        ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER);        if (!ReturnDesc)        {            Status = AE_NO_MEMORY;            goto Cleanup;        }        ReturnDesc->Integer.Value = AcpiExDoMathOp (WalkState->Opcode,                                                Operand[0]->Integer.Value,                                                Operand[1]->Integer.Value);        goto StoreResultToTarget;    }    switch (WalkState->Opcode)    {    case AML_MOD_OP: /* Mod (Dividend, Divisor, RemainderResult (ACPI 2.0) */        ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER);        if (!ReturnDesc)        {            Status = AE_NO_MEMORY;            goto Cleanup;        }        /* ReturnDesc will contain the remainder */        Status = AcpiUtDivide (Operand[0]->Integer.Value,                               Operand[1]->Integer.Value,                               NULL,                               &ReturnDesc->Integer.Value);        break;    case AML_CONCAT_OP: /* Concatenate (Data1, Data2, Result) */        Status = AcpiExDoConcatenate (Operand[0], Operand[1],                    &ReturnDesc, WalkState);        break;    case AML_TO_STRING_OP: /* ToString (Buffer, Length, Result) (ACPI 2.0) */        /*         * Input object is guaranteed to be a buffer at this point (it may have         * been converted.)  Copy the raw buffer data to a new object of         * type String.         */        /*         * Get the length of the new string. It is the smallest of:         * 1) Length of the input buffer         * 2) Max length as specified in the ToString operator         * 3) Length of input buffer up to a zero byte (null terminator)         *         * NOTE: A length of zero is ok, and will create a zero-length, null         *       terminated string.         */        Length = 0;        while ((Length < Operand[0]->Buffer.Length) &&               (Length < Operand[1]->Integer.Value) &&               (Operand[0]->Buffer.Pointer[Length]))        {            Length++;        }        /* Allocate a new string object */        ReturnDesc = AcpiUtCreateStringObject (Length);        if (!ReturnDesc)        {            Status = AE_NO_MEMORY;            goto Cleanup;        }        /*         * Copy the raw buffer data with no transform.         * (NULL terminated already)         */        ACPI_MEMCPY (ReturnDesc->String.Pointer,            Operand[0]->Buffer.Pointer, Length);        break;    case AML_CONCAT_RES_OP:        /* ConcatenateResTemplate (Buffer, Buffer, Result) (ACPI 2.0) */        Status = AcpiExConcatTemplate (Operand[0], Operand[1],                    &ReturnDesc, WalkState);        break;    case AML_INDEX_OP:              /* Index (Source Index Result) */        /* Create the internal return object */        ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_LOCAL_REFERENCE);        if (!ReturnDesc)        {            Status = AE_NO_MEMORY;            goto Cleanup;        }        /* Initialize the Index reference object */        Index = Operand[1]->Integer.Value;        ReturnDesc->Reference.Offset = (UINT32) Index;        ReturnDesc->Reference.Opcode = AML_INDEX_OP;        /*         * At this point, the Source operand is a String, Buffer, or Package.         * Verify that the index is within range.         */        switch (ACPI_GET_OBJECT_TYPE (Operand[0]))        {        case ACPI_TYPE_STRING:            if (Index >= Operand[0]->String.Length)            {                Status = AE_AML_STRING_LIMIT;            }            ReturnDesc->Reference.TargetType = ACPI_TYPE_BUFFER_FIELD;            break;        case ACPI_TYPE_BUFFER:            if (Index >= Operand[0]->Buffer.Length)            {                Status = AE_AML_BUFFER_LIMIT;            }            ReturnDesc->Reference.TargetType = ACPI_TYPE_BUFFER_FIELD;            break;        case ACPI_TYPE_PACKAGE:            if (Index >= Operand[0]->Package.Count)            {                Status = AE_AML_PACKAGE_LIMIT;            }            ReturnDesc->Reference.TargetType = ACPI_TYPE_PACKAGE;            ReturnDesc->Reference.Where = &Operand[0]->Package.Elements [Index];            break;        default:            Status = AE_AML_INTERNAL;            goto Cleanup;        }        /* Failure means that the Index was beyond the end of the object */        if (ACPI_FAILURE (Status))        {            ACPI_EXCEPTION ((AE_INFO, Status,                "Index (%X%8.8X) is beyond end of object",                ACPI_FORMAT_UINT64 (Index)));            goto Cleanup;        }        /*         * Save the target object and add a reference to it for the life         * of the index         */        ReturnDesc->Reference.Object = Operand[0];        AcpiUtAddReference (Operand[0]);        /* Store the reference to the Target */        Status = AcpiExStore (ReturnDesc, Operand[2], WalkState);        /* Return the reference */        WalkState->ResultObj = ReturnDesc;        goto Cleanup;    default:        ACPI_ERROR ((AE_INFO, "Unknown AML opcode %X",            WalkState->Opcode));        Status = AE_AML_BAD_OPCODE;        break;    }StoreResultToTarget:    if (ACPI_SUCCESS (Status))    {        /*         * Store the result of the operation (which is now in ReturnDesc) into         * the Target descriptor.         */        Status = AcpiExStore (ReturnDesc, Operand[2], WalkState);        if (ACPI_FAILURE (Status))        {            goto Cleanup;        }        if (!WalkState->ResultObj)        {            WalkState->ResultObj = ReturnDesc;        }    }Cleanup:    /* Delete return object on error */    if (ACPI_FAILURE (Status))    {        AcpiUtRemoveReference (ReturnDesc);        WalkState->ResultObj = NULL;    }    return_ACPI_STATUS (Status);}/******************************************************************************* * * FUNCTION:    AcpiExOpcode_2A_0T_1R * * PARAMETERS:  WalkState           - Current walk state * * RETURN:      Status * * DESCRIPTION: Execute opcode with 2 arguments, no target, and a return value * ******************************************************************************/ACPI_STATUSAcpiExOpcode_2A_0T_1R (    ACPI_WALK_STATE         *WalkState){    ACPI_OPERAND_OBJECT     **Operand = &WalkState->Operands[0];    ACPI_OPERAND_OBJECT     *ReturnDesc = NULL;    ACPI_STATUS             Status = AE_OK;    BOOLEAN                 LogicalResult = FALSE;    ACPI_FUNCTION_TRACE_STR (ExOpcode_2A_0T_1R,        AcpiPsGetOpcodeName (WalkState->Opcode));    /* Create the internal return object */    ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER);    if (!ReturnDesc)    {        Status = AE_NO_MEMORY;        goto Cleanup;    }    /* Execute the Opcode */    if (WalkState->OpInfo->Flags & AML_LOGICAL_NUMERIC)    {        /* LogicalOp  (Operand0, Operand1) */        Status = AcpiExDoLogicalNumericOp (WalkState->Opcode,                        Operand[0]->Integer.Value, Operand[1]->Integer.Value,                        &LogicalResult);        goto StoreLogicalResult;    }    else if (WalkState->OpInfo->Flags & AML_LOGICAL)    {        /* LogicalOp  (Operand0, Operand1) */        Status = AcpiExDoLogicalOp (WalkState->Opcode, Operand[0],                    Operand[1], &LogicalResult);        goto StoreLogicalResult;    }    switch (WalkState->Opcode)    {    case AML_ACQUIRE_OP:            /* Acquire (MutexObject, Timeout) */        Status = AcpiExAcquireMutex (Operand[1], Operand[0], WalkState);        if (Status == AE_TIME)        {            LogicalResult = TRUE;       /* TRUE = Acquire timed out */            Status = AE_OK;        }        break;    case AML_WAIT_OP:               /* Wait (EventObject, Timeout) */        Status = AcpiExSystemWaitEvent (Operand[1], Operand[0]);        if (Status == AE_TIME)        {            LogicalResult = TRUE;       /* TRUE, Wait timed out */            Status = AE_OK;        }        break;    default:        ACPI_ERROR ((AE_INFO, "Unknown AML opcode %X",            WalkState->Opcode));        Status = AE_AML_BAD_OPCODE;        goto Cleanup;    }StoreLogicalResult:    /*     * Set return value to according to LogicalResult. logical TRUE (all ones)     * Default is FALSE (zero)     */    if (LogicalResult)    {        ReturnDesc->Integer.Value = ACPI_INTEGER_MAX;    }Cleanup:    /* Delete return object on error */    if (ACPI_FAILURE (Status))    {        AcpiUtRemoveReference (ReturnDesc);    }    /* Save return object on success */    else    {        WalkState->ResultObj = ReturnDesc;    }    return_ACPI_STATUS (Status);}

⌨️ 快捷键说明

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