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

📄 excreate.c

📁 acpi tools for linux include acpiexec and acpixtract
💻 C
📖 第 1 页 / 共 2 页
字号:
    /* Create the new mutex object */    ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_MUTEX);    if (!ObjDesc)    {        Status = AE_NO_MEMORY;        goto Cleanup;    }    /* Create the actual OS Mutex */    Status = AcpiOsCreateMutex (&ObjDesc->Mutex.OsMutex);    if (ACPI_FAILURE (Status))    {        goto Cleanup;    }    /* Init object and attach to NS node */    ObjDesc->Mutex.SyncLevel = (UINT8) WalkState->Operands[1]->Integer.Value;    ObjDesc->Mutex.Node = (ACPI_NAMESPACE_NODE *) WalkState->Operands[0];    Status = AcpiNsAttachObject (ObjDesc->Mutex.Node, ObjDesc, ACPI_TYPE_MUTEX);Cleanup:    /*     * Remove local reference to the object (on error, will cause deletion     * of both object and semaphore if present.)     */    AcpiUtRemoveReference (ObjDesc);    return_ACPI_STATUS (Status);}/******************************************************************************* * * FUNCTION:    AcpiExCreateRegion * * PARAMETERS:  AmlStart            - Pointer to the region declaration AML *              AmlLength           - Max length of the declaration AML *              RegionSpace         - SpaceID for the region *              WalkState           - Current state * * RETURN:      Status * * DESCRIPTION: Create a new operation region object * ******************************************************************************/ACPI_STATUSAcpiExCreateRegion (    UINT8                   *AmlStart,    UINT32                  AmlLength,    UINT8                   RegionSpace,    ACPI_WALK_STATE         *WalkState){    ACPI_STATUS             Status;    ACPI_OPERAND_OBJECT     *ObjDesc;    ACPI_NAMESPACE_NODE     *Node;    ACPI_OPERAND_OBJECT     *RegionObj2;    ACPI_FUNCTION_TRACE (ExCreateRegion);    /* Get the Namespace Node */    Node = WalkState->Op->Common.Node;    /*     * If the region object is already attached to this node,     * just return     */    if (AcpiNsGetAttachedObject (Node))    {        return_ACPI_STATUS (AE_OK);    }    /*     * Space ID must be one of the predefined IDs, or in the user-defined     * range     */    if ((RegionSpace >= ACPI_NUM_PREDEFINED_REGIONS) &&        (RegionSpace < ACPI_USER_REGION_BEGIN))    {        ACPI_ERROR ((AE_INFO, "Invalid AddressSpace type %X", RegionSpace));        return_ACPI_STATUS (AE_AML_INVALID_SPACE_ID);    }    ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "Region Type - %s (%X)\n",        AcpiUtGetRegionName (RegionSpace), RegionSpace));    /* Create the region descriptor */    ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_REGION);    if (!ObjDesc)    {        Status = AE_NO_MEMORY;        goto Cleanup;    }    /*     * Remember location in AML stream of address & length     * operands since they need to be evaluated at run time.     */    RegionObj2 = ObjDesc->Common.NextObject;    RegionObj2->Extra.AmlStart = AmlStart;    RegionObj2->Extra.AmlLength = AmlLength;    /* Init the region from the operands */    ObjDesc->Region.SpaceId = RegionSpace;    ObjDesc->Region.Address = 0;    ObjDesc->Region.Length = 0;    ObjDesc->Region.Node = Node;    /* Install the new region object in the parent Node */    Status = AcpiNsAttachObject (Node, ObjDesc, ACPI_TYPE_REGION);Cleanup:    /* Remove local reference to the object */    AcpiUtRemoveReference (ObjDesc);    return_ACPI_STATUS (Status);}/******************************************************************************* * * FUNCTION:    AcpiExCreateProcessor * * PARAMETERS:  WalkState           - Current state * * RETURN:      Status * * DESCRIPTION: Create a new processor object and populate the fields * *              Processor (Name[0], CpuID[1], PblockAddr[2], PblockLength[3]) * ******************************************************************************/ACPI_STATUSAcpiExCreateProcessor (    ACPI_WALK_STATE         *WalkState){    ACPI_OPERAND_OBJECT     **Operand = &WalkState->Operands[0];    ACPI_OPERAND_OBJECT     *ObjDesc;    ACPI_STATUS             Status;    ACPI_FUNCTION_TRACE_PTR (ExCreateProcessor, WalkState);    /* Create the processor object */    ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_PROCESSOR);    if (!ObjDesc)    {        return_ACPI_STATUS (AE_NO_MEMORY);    }    /* Initialize the processor object from the operands */    ObjDesc->Processor.ProcId = (UINT8) Operand[1]->Integer.Value;    ObjDesc->Processor.Length = (UINT8) Operand[3]->Integer.Value;    ObjDesc->Processor.Address = (ACPI_IO_ADDRESS) Operand[2]->Integer.Value;    /* Install the processor object in the parent Node */    Status = AcpiNsAttachObject ((ACPI_NAMESPACE_NODE *) Operand[0],                    ObjDesc, ACPI_TYPE_PROCESSOR);    /* Remove local reference to the object */    AcpiUtRemoveReference (ObjDesc);    return_ACPI_STATUS (Status);}/******************************************************************************* * * FUNCTION:    AcpiExCreatePowerResource * * PARAMETERS:  WalkState           - Current state * * RETURN:      Status * * DESCRIPTION: Create a new PowerResource object and populate the fields * *              PowerResource (Name[0], SystemLevel[1], ResourceOrder[2]) * ******************************************************************************/ACPI_STATUSAcpiExCreatePowerResource (    ACPI_WALK_STATE         *WalkState){    ACPI_OPERAND_OBJECT     **Operand = &WalkState->Operands[0];    ACPI_STATUS             Status;    ACPI_OPERAND_OBJECT     *ObjDesc;    ACPI_FUNCTION_TRACE_PTR (ExCreatePowerResource, WalkState);    /* Create the power resource object */    ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_POWER);    if (!ObjDesc)    {        return_ACPI_STATUS (AE_NO_MEMORY);    }    /* Initialize the power object from the operands */    ObjDesc->PowerResource.SystemLevel = (UINT8) Operand[1]->Integer.Value;    ObjDesc->PowerResource.ResourceOrder = (UINT16) Operand[2]->Integer.Value;    /* Install the  power resource object in the parent Node */    Status = AcpiNsAttachObject ((ACPI_NAMESPACE_NODE *) Operand[0],                    ObjDesc, ACPI_TYPE_POWER);    /* Remove local reference to the object */    AcpiUtRemoveReference (ObjDesc);    return_ACPI_STATUS (Status);}#endif/******************************************************************************* * * FUNCTION:    AcpiExCreateMethod * * PARAMETERS:  AmlStart        - First byte of the method's AML *              AmlLength       - AML byte count for this method *              WalkState       - Current state * * RETURN:      Status * * DESCRIPTION: Create a new method object * ******************************************************************************/ACPI_STATUSAcpiExCreateMethod (    UINT8                   *AmlStart,    UINT32                  AmlLength,    ACPI_WALK_STATE         *WalkState){    ACPI_OPERAND_OBJECT     **Operand = &WalkState->Operands[0];    ACPI_OPERAND_OBJECT     *ObjDesc;    ACPI_STATUS             Status;    UINT8                   MethodFlags;    ACPI_FUNCTION_TRACE_PTR (ExCreateMethod, WalkState);    /* Create a new method object */    ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_METHOD);    if (!ObjDesc)    {       Status = AE_NO_MEMORY;       goto Exit;    }    /* Save the method's AML pointer and length  */    ObjDesc->Method.AmlStart = AmlStart;    ObjDesc->Method.AmlLength = AmlLength;    /*     * Disassemble the method flags. Split off the Arg Count     * for efficiency     */    MethodFlags = (UINT8) Operand[1]->Integer.Value;    ObjDesc->Method.MethodFlags = (UINT8) (MethodFlags & ~AML_METHOD_ARG_COUNT);    ObjDesc->Method.ParamCount = (UINT8) (MethodFlags & AML_METHOD_ARG_COUNT);    /*     * Get the SyncLevel. If method is serialized, a mutex will be     * created for this method when it is parsed.     */    if (MethodFlags & AML_METHOD_SERIALIZED)    {        /*         * ACPI 1.0: SyncLevel = 0         * ACPI 2.0: SyncLevel = SyncLevel in method declaration         */        ObjDesc->Method.SyncLevel = (UINT8)            ((MethodFlags & AML_METHOD_SYNCH_LEVEL) >> 4);    }    /* Attach the new object to the method Node */    Status = AcpiNsAttachObject ((ACPI_NAMESPACE_NODE *) Operand[0],                    ObjDesc, ACPI_TYPE_METHOD);    /* Remove local reference to the object */    AcpiUtRemoveReference (ObjDesc);Exit:    /* Remove a reference to the operand */    AcpiUtRemoveReference (Operand[1]);    return_ACPI_STATUS (Status);}

⌨️ 快捷键说明

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