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

📄 exstore.c

📁 acpi tools for linux include acpiexec and acpixtract
💻 C
📖 第 1 页 / 共 2 页
字号:
    default:        /* Destination is not a Reference object */        ACPI_ERROR ((AE_INFO,            "Target is not a Reference or Constant object - %s [%p]",            AcpiUtGetObjectTypeName (DestDesc), DestDesc));        ACPI_DUMP_STACK_ENTRY (SourceDesc);        ACPI_DUMP_STACK_ENTRY (DestDesc);        ACPI_DUMP_OPERANDS (&DestDesc, ACPI_IMODE_EXECUTE, "ExStore",                        2, "Target is not a Reference or Constant object");        return_ACPI_STATUS (AE_AML_OPERAND_TYPE);    }    /*     * Examine the Reference opcode.  These cases are handled:     *     * 1) Store to Name (Change the object associated with a name)     * 2) Store to an indexed area of a Buffer or Package     * 3) Store to a Method Local or Arg     * 4) Store to the debug object     */    switch (RefDesc->Reference.Opcode)    {    case AML_REF_OF_OP:        /* Storing an object into a Name "container" */        Status = AcpiExStoreObjectToNode (SourceDesc,                    RefDesc->Reference.Object,                    WalkState, ACPI_IMPLICIT_CONVERSION);        break;    case AML_INDEX_OP:        /* Storing to an Index (pointer into a packager or buffer) */        Status = AcpiExStoreObjectToIndex (SourceDesc, RefDesc, WalkState);        break;    case AML_LOCAL_OP:    case AML_ARG_OP:        /* Store to a method local/arg  */        Status = AcpiDsStoreObjectToLocal (RefDesc->Reference.Opcode,                    RefDesc->Reference.Offset, SourceDesc, WalkState);        break;    case AML_DEBUG_OP:        /*         * Storing to the Debug object causes the value stored to be         * displayed and otherwise has no effect -- see ACPI Specification         */        ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,            "**** Write to Debug Object: Object %p %s ****:\n\n",            SourceDesc, AcpiUtGetObjectTypeName (SourceDesc)));        AcpiExDoDebugObject (SourceDesc, 0, 0);        break;    default:        ACPI_ERROR ((AE_INFO, "Unknown Reference opcode %X",            RefDesc->Reference.Opcode));        ACPI_DUMP_ENTRY (RefDesc, ACPI_LV_ERROR);        Status = AE_AML_INTERNAL;        break;    }    return_ACPI_STATUS (Status);}/******************************************************************************* * * FUNCTION:    AcpiExStoreObjectToIndex * * PARAMETERS:  *SourceDesc             - Value to be stored *              *DestDesc               - Named object to receive the value *              WalkState               - Current walk state * * RETURN:      Status * * DESCRIPTION: Store the object to indexed Buffer or Package element * ******************************************************************************/static ACPI_STATUSAcpiExStoreObjectToIndex (    ACPI_OPERAND_OBJECT     *SourceDesc,    ACPI_OPERAND_OBJECT     *IndexDesc,    ACPI_WALK_STATE         *WalkState){    ACPI_STATUS             Status = AE_OK;    ACPI_OPERAND_OBJECT     *ObjDesc;    ACPI_OPERAND_OBJECT     *NewDesc;    UINT8                   Value = 0;    UINT32                  i;    ACPI_FUNCTION_TRACE (ExStoreObjectToIndex);    /*     * Destination must be a reference pointer, and     * must point to either a buffer or a package     */    switch (IndexDesc->Reference.TargetType)    {    case ACPI_TYPE_PACKAGE:        /*         * Storing to a package element. Copy the object and replace         * any existing object with the new object. No implicit         * conversion is performed.         *         * The object at *(IndexDesc->Reference.Where) is the         * element within the package that is to be modified.         * The parent package object is at IndexDesc->Reference.Object         */        ObjDesc = *(IndexDesc->Reference.Where);        if (ACPI_GET_OBJECT_TYPE (SourceDesc) == ACPI_TYPE_LOCAL_REFERENCE &&            SourceDesc->Reference.Opcode == AML_LOAD_OP)        {            /* This is a DDBHandle, just add a reference to it */            AcpiUtAddReference (SourceDesc);            NewDesc = SourceDesc;        }        else        {            /* Normal object, copy it */            Status = AcpiUtCopyIobjectToIobject (SourceDesc, &NewDesc, WalkState);            if (ACPI_FAILURE (Status))            {                return_ACPI_STATUS (Status);            }        }        if (ObjDesc)        {            /* Decrement reference count by the ref count of the parent package */            for (i = 0;                 i < ((ACPI_OPERAND_OBJECT *)                        IndexDesc->Reference.Object)->Common.ReferenceCount;                 i++)            {                AcpiUtRemoveReference (ObjDesc);            }        }        *(IndexDesc->Reference.Where) = NewDesc;        /* Increment ref count by the ref count of the parent package-1 */        for (i = 1;             i < ((ACPI_OPERAND_OBJECT *)                    IndexDesc->Reference.Object)->Common.ReferenceCount;             i++)        {            AcpiUtAddReference (NewDesc);        }        break;    case ACPI_TYPE_BUFFER_FIELD:        /*         * Store into a Buffer or String (not actually a real BufferField)         * at a location defined by an Index.         *         * The first 8-bit element of the source object is written to the         * 8-bit Buffer location defined by the Index destination object,         * according to the ACPI 2.0 specification.         */        /*         * Make sure the target is a Buffer or String. An error should         * not happen here, since the ReferenceObject was constructed         * by the INDEX_OP code.         */        ObjDesc = IndexDesc->Reference.Object;        if ((ACPI_GET_OBJECT_TYPE (ObjDesc) != ACPI_TYPE_BUFFER) &&            (ACPI_GET_OBJECT_TYPE (ObjDesc) != ACPI_TYPE_STRING))        {            return_ACPI_STATUS (AE_AML_OPERAND_TYPE);        }        /*         * The assignment of the individual elements will be slightly         * different for each source type.         */        switch (ACPI_GET_OBJECT_TYPE (SourceDesc))        {        case ACPI_TYPE_INTEGER:            /* Use the least-significant byte of the integer */            Value = (UINT8) (SourceDesc->Integer.Value);            break;        case ACPI_TYPE_BUFFER:        case ACPI_TYPE_STRING:            /* Note: Takes advantage of common string/buffer fields */            Value = SourceDesc->Buffer.Pointer[0];            break;        default:            /* All other types are invalid */            ACPI_ERROR ((AE_INFO,                "Source must be Integer/Buffer/String type, not %s",                AcpiUtGetObjectTypeName (SourceDesc)));            return_ACPI_STATUS (AE_AML_OPERAND_TYPE);        }        /* Store the source value into the target buffer byte */        ObjDesc->Buffer.Pointer[IndexDesc->Reference.Offset] = Value;        break;    default:        ACPI_ERROR ((AE_INFO,            "Target is not a Package or BufferField"));        Status = AE_AML_OPERAND_TYPE;        break;    }    return_ACPI_STATUS (Status);}/******************************************************************************* * * FUNCTION:    AcpiExStoreObjectToNode * * PARAMETERS:  SourceDesc              - Value to be stored *              Node                    - Named object to receive the value *              WalkState               - Current walk state *              ImplicitConversion      - Perform implicit conversion (yes/no) * * RETURN:      Status * * DESCRIPTION: Store the object to the named object. * *              The Assignment of an object to a named object is handled here *              The value passed in will replace the current value (if any) *              with the input value. * *              When storing into an object the data is converted to the *              target object type then stored in the object.  This means *              that the target object type (for an initialized target) will *              not be changed by a store operation. * *              Assumes parameters are already validated. * ******************************************************************************/ACPI_STATUSAcpiExStoreObjectToNode (    ACPI_OPERAND_OBJECT     *SourceDesc,    ACPI_NAMESPACE_NODE     *Node,    ACPI_WALK_STATE         *WalkState,    UINT8                   ImplicitConversion){    ACPI_STATUS             Status = AE_OK;    ACPI_OPERAND_OBJECT     *TargetDesc;    ACPI_OPERAND_OBJECT     *NewDesc;    ACPI_OBJECT_TYPE        TargetType;    ACPI_FUNCTION_TRACE_PTR (ExStoreObjectToNode, SourceDesc);    /* Get current type of the node, and object attached to Node */    TargetType = AcpiNsGetType (Node);    TargetDesc = AcpiNsGetAttachedObject (Node);    ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Storing %p(%s) into node %p(%s)\n",        SourceDesc, AcpiUtGetObjectTypeName (SourceDesc),              Node, AcpiUtGetTypeName (TargetType)));    /*     * Resolve the source object to an actual value     * (If it is a reference object)     */    Status = AcpiExResolveObject (&SourceDesc, TargetType, WalkState);    if (ACPI_FAILURE (Status))    {        return_ACPI_STATUS (Status);    }    /* If no implicit conversion, drop into the default case below */    if ((!ImplicitConversion) ||           ((WalkState->Opcode == AML_COPY_OP) &&           (TargetType != ACPI_TYPE_LOCAL_REGION_FIELD) &&           (TargetType != ACPI_TYPE_LOCAL_BANK_FIELD) &&           (TargetType != ACPI_TYPE_LOCAL_INDEX_FIELD)))    {        /*         * Force execution of default (no implicit conversion). Note:         * CopyObject does not perform an implicit conversion, as per the ACPI         * spec -- except in case of region/bank/index fields -- because these         * objects must retain their original type permanently.         */        TargetType = ACPI_TYPE_ANY;    }    /* Do the actual store operation */    switch (TargetType)    {    case ACPI_TYPE_BUFFER_FIELD:    case ACPI_TYPE_LOCAL_REGION_FIELD:    case ACPI_TYPE_LOCAL_BANK_FIELD:    case ACPI_TYPE_LOCAL_INDEX_FIELD:        /* For fields, copy the source data to the target field. */        Status = AcpiExWriteDataToField (SourceDesc, TargetDesc,                    &WalkState->ResultObj);        break;    case ACPI_TYPE_INTEGER:    case ACPI_TYPE_STRING:    case ACPI_TYPE_BUFFER:        /*         * These target types are all of type Integer/String/Buffer, and         * therefore support implicit conversion before the store.         *         * Copy and/or convert the source object to a new target object         */        Status = AcpiExStoreObjectToObject (SourceDesc, TargetDesc,                    &NewDesc, WalkState);        if (ACPI_FAILURE (Status))        {            return_ACPI_STATUS (Status);        }        if (NewDesc != TargetDesc)        {            /*             * Store the new NewDesc as the new value of the Name, and set             * the Name's type to that of the value being stored in it.             * SourceDesc reference count is incremented by AttachObject.             *             * Note: This may change the type of the node if an explicit store             * has been performed such that the node/object type has been             * changed.             */            Status = AcpiNsAttachObject (Node, NewDesc, NewDesc->Common.Type);            ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,                "Store %s into %s via Convert/Attach\n",                AcpiUtGetObjectTypeName (SourceDesc),                AcpiUtGetObjectTypeName (NewDesc)));        }        break;    default:        ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,            "Storing %s (%p) directly into node (%p) with no implicit conversion\n",            AcpiUtGetObjectTypeName (SourceDesc), SourceDesc, Node));        /* No conversions for all other types.  Just attach the source object */        Status = AcpiNsAttachObject (Node, SourceDesc,                    ACPI_GET_OBJECT_TYPE (SourceDesc));        break;    }    return_ACPI_STATUS (Status);}

⌨️ 快捷键说明

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