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

📄 uteval.c

📁 acpi tools for linux include acpiexec and acpixtract
💻 C
📖 第 1 页 / 共 2 页
字号:
/******************************************************************************* * * FUNCTION:    AcpiUtCopyIdString * * PARAMETERS:  Destination         - Where to copy the string *              Source              - Source string *              MaxLength           - Length of the destination buffer * * RETURN:      None * * DESCRIPTION: Copies an ID string for the _HID, _CID, and _UID methods. *              Performs removal of a leading asterisk if present -- workaround *              for a known issue on a bunch of machines. * ******************************************************************************/static voidAcpiUtCopyIdString (    char                    *Destination,    char                    *Source,    ACPI_SIZE               MaxLength){    /*     * Workaround for ID strings that have a leading asterisk. This construct     * is not allowed by the ACPI specification  (ID strings must be     * alphanumeric), but enough existing machines have this embedded in their     * ID strings that the following code is useful.     */    if (*Source == '*')    {        Source++;    }    /* Do the actual copy */    ACPI_STRNCPY (Destination, Source, MaxLength);}/******************************************************************************* * * FUNCTION:    AcpiUtExecute_HID * * PARAMETERS:  DeviceNode          - Node for the device *              Hid                 - Where the HID is returned * * RETURN:      Status * * DESCRIPTION: Executes the _HID control method that returns the hardware *              ID of the device. * *              NOTE: Internal function, no parameter validation * ******************************************************************************/ACPI_STATUSAcpiUtExecute_HID (    ACPI_NAMESPACE_NODE     *DeviceNode,    ACPI_DEVICE_ID          *Hid){    ACPI_OPERAND_OBJECT     *ObjDesc;    ACPI_STATUS             Status;    ACPI_FUNCTION_TRACE (UtExecute_HID);    Status = AcpiUtEvaluateObject (DeviceNode, METHOD_NAME__HID,                ACPI_BTYPE_INTEGER | ACPI_BTYPE_STRING, &ObjDesc);    if (ACPI_FAILURE (Status))    {        return_ACPI_STATUS (Status);    }    if (ACPI_GET_OBJECT_TYPE (ObjDesc) == ACPI_TYPE_INTEGER)    {        /* Convert the Numeric HID to string */        AcpiExEisaIdToString ((UINT32) ObjDesc->Integer.Value, Hid->Value);    }    else    {        /* Copy the String HID from the returned object */        AcpiUtCopyIdString (Hid->Value, ObjDesc->String.Pointer,                sizeof (Hid->Value));    }    /* On exit, we must delete the return object */    AcpiUtRemoveReference (ObjDesc);    return_ACPI_STATUS (Status);}/******************************************************************************* * * FUNCTION:    AcpiUtTranslateOneCid * * PARAMETERS:  ObjDesc             - _CID object, must be integer or string *              OneCid              - Where the CID string is returned * * RETURN:      Status * * DESCRIPTION: Return a numeric or string _CID value as a string. *              (Compatible ID) * *              NOTE:  Assumes a maximum _CID string length of *                     ACPI_MAX_CID_LENGTH. * ******************************************************************************/static ACPI_STATUSAcpiUtTranslateOneCid (    ACPI_OPERAND_OBJECT     *ObjDesc,    ACPI_COMPATIBLE_ID      *OneCid){    switch (ACPI_GET_OBJECT_TYPE (ObjDesc))    {    case ACPI_TYPE_INTEGER:        /* Convert the Numeric CID to string */        AcpiExEisaIdToString ((UINT32) ObjDesc->Integer.Value, OneCid->Value);        return (AE_OK);    case ACPI_TYPE_STRING:        if (ObjDesc->String.Length > ACPI_MAX_CID_LENGTH)        {            return (AE_AML_STRING_LIMIT);        }        /* Copy the String CID from the returned object */        AcpiUtCopyIdString (OneCid->Value, ObjDesc->String.Pointer,                ACPI_MAX_CID_LENGTH);        return (AE_OK);    default:        return (AE_TYPE);    }}/******************************************************************************* * * FUNCTION:    AcpiUtExecute_CID * * PARAMETERS:  DeviceNode          - Node for the device *              ReturnCidList       - Where the CID list is returned * * RETURN:      Status * * DESCRIPTION: Executes the _CID control method that returns one or more *              compatible hardware IDs for the device. * *              NOTE: Internal function, no parameter validation * ******************************************************************************/ACPI_STATUSAcpiUtExecute_CID (    ACPI_NAMESPACE_NODE     *DeviceNode,    ACPI_COMPATIBLE_ID_LIST **ReturnCidList){    ACPI_OPERAND_OBJECT     *ObjDesc;    ACPI_STATUS             Status;    UINT32                  Count;    UINT32                  Size;    ACPI_COMPATIBLE_ID_LIST *CidList;    ACPI_NATIVE_UINT        i;    ACPI_FUNCTION_TRACE (UtExecute_CID);    /* Evaluate the _CID method for this device */    Status = AcpiUtEvaluateObject (DeviceNode, METHOD_NAME__CID,                ACPI_BTYPE_INTEGER | ACPI_BTYPE_STRING | ACPI_BTYPE_PACKAGE,                &ObjDesc);    if (ACPI_FAILURE (Status))    {        return_ACPI_STATUS (Status);    }    /* Get the number of _CIDs returned */    Count = 1;    if (ACPI_GET_OBJECT_TYPE (ObjDesc) == ACPI_TYPE_PACKAGE)    {        Count = ObjDesc->Package.Count;    }    /* Allocate a worst-case buffer for the _CIDs */    Size = (((Count - 1) * sizeof (ACPI_COMPATIBLE_ID)) +                           sizeof (ACPI_COMPATIBLE_ID_LIST));    CidList = ACPI_ALLOCATE_ZEROED ((ACPI_SIZE) Size);    if (!CidList)    {        return_ACPI_STATUS (AE_NO_MEMORY);    }    /* Init CID list */    CidList->Count = Count;    CidList->Size  = Size;    /*     *  A _CID can return either a single compatible ID or a package of     *  compatible IDs.  Each compatible ID can be one of the following:     *  1) Integer (32 bit compressed EISA ID) or     *  2) String (PCI ID format, e.g. "PCI\VEN_vvvv&DEV_dddd&SUBSYS_ssssssss")     */    /* The _CID object can be either a single CID or a package (list) of CIDs */    if (ACPI_GET_OBJECT_TYPE (ObjDesc) == ACPI_TYPE_PACKAGE)    {        /* Translate each package element */        for (i = 0; i < Count; i++)        {            Status = AcpiUtTranslateOneCid (ObjDesc->Package.Elements[i],                            &CidList->Id[i]);            if (ACPI_FAILURE (Status))            {                break;            }        }    }    else    {        /* Only one CID, translate to a string */        Status = AcpiUtTranslateOneCid (ObjDesc, CidList->Id);    }    /* Cleanup on error */    if (ACPI_FAILURE (Status))    {        ACPI_FREE (CidList);    }    else    {        *ReturnCidList = CidList;    }    /* On exit, we must delete the _CID return object */    AcpiUtRemoveReference (ObjDesc);    return_ACPI_STATUS (Status);}/******************************************************************************* * * FUNCTION:    AcpiUtExecute_UID * * PARAMETERS:  DeviceNode          - Node for the device *              Uid                 - Where the UID is returned * * RETURN:      Status * * DESCRIPTION: Executes the _UID control method that returns the hardware *              ID of the device. * *              NOTE: Internal function, no parameter validation * ******************************************************************************/ACPI_STATUSAcpiUtExecute_UID (    ACPI_NAMESPACE_NODE     *DeviceNode,    ACPI_DEVICE_ID          *Uid){    ACPI_OPERAND_OBJECT     *ObjDesc;    ACPI_STATUS             Status;    ACPI_FUNCTION_TRACE (UtExecute_UID);    Status = AcpiUtEvaluateObject (DeviceNode, METHOD_NAME__UID,                ACPI_BTYPE_INTEGER | ACPI_BTYPE_STRING, &ObjDesc);    if (ACPI_FAILURE (Status))    {        return_ACPI_STATUS (Status);    }    if (ACPI_GET_OBJECT_TYPE (ObjDesc) == ACPI_TYPE_INTEGER)    {        /* Convert the Numeric UID to string */        AcpiExUnsignedIntegerToString (ObjDesc->Integer.Value, Uid->Value);    }    else    {        /* Copy the String UID from the returned object */        AcpiUtCopyIdString (Uid->Value, ObjDesc->String.Pointer,                sizeof (Uid->Value));    }    /* On exit, we must delete the return object */    AcpiUtRemoveReference (ObjDesc);    return_ACPI_STATUS (Status);}/******************************************************************************* * * FUNCTION:    AcpiUtExecute_STA * * PARAMETERS:  DeviceNode          - Node for the device *              Flags               - Where the status flags are returned * * RETURN:      Status * * DESCRIPTION: Executes _STA for selected device and stores results in *              *Flags. * *              NOTE: Internal function, no parameter validation * ******************************************************************************/ACPI_STATUSAcpiUtExecute_STA (    ACPI_NAMESPACE_NODE     *DeviceNode,    UINT32                  *Flags){    ACPI_OPERAND_OBJECT     *ObjDesc;    ACPI_STATUS             Status;    ACPI_FUNCTION_TRACE (UtExecute_STA);    Status = AcpiUtEvaluateObject (DeviceNode, METHOD_NAME__STA,                ACPI_BTYPE_INTEGER, &ObjDesc);    if (ACPI_FAILURE (Status))    {        if (AE_NOT_FOUND == Status)        {            ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,                "_STA on %4.4s was not found, assuming device is present\n",                AcpiUtGetNodeName (DeviceNode)));            *Flags = ACPI_UINT32_MAX;            Status = AE_OK;        }        return_ACPI_STATUS (Status);    }    /* Extract the status flags */    *Flags = (UINT32) ObjDesc->Integer.Value;    /* On exit, we must delete the return object */    AcpiUtRemoveReference (ObjDesc);    return_ACPI_STATUS (Status);}/******************************************************************************* * * FUNCTION:    AcpiUtExecute_Sxds * * PARAMETERS:  DeviceNode          - Node for the device *              Flags               - Where the status flags are returned * * RETURN:      Status * * DESCRIPTION: Executes _STA for selected device and stores results in *              *Flags. * *              NOTE: Internal function, no parameter validation * ******************************************************************************/ACPI_STATUSAcpiUtExecute_Sxds (    ACPI_NAMESPACE_NODE     *DeviceNode,    UINT8                   *Highest){    ACPI_OPERAND_OBJECT     *ObjDesc;    ACPI_STATUS             Status;    UINT32                  i;    ACPI_FUNCTION_TRACE (UtExecute_Sxds);    for (i = 0; i < 4; i++)    {        Highest[i] = 0xFF;        Status = AcpiUtEvaluateObject (DeviceNode,                    ACPI_CAST_PTR (char, AcpiGbl_HighestDstateNames[i]),                    ACPI_BTYPE_INTEGER, &ObjDesc);        if (ACPI_FAILURE (Status))        {            if (Status != AE_NOT_FOUND)            {                ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,                    "%s on Device %4.4s, %s\n",                    ACPI_CAST_PTR (char, AcpiGbl_HighestDstateNames[i]),                    AcpiUtGetNodeName (DeviceNode),                    AcpiFormatException (Status)));                return_ACPI_STATUS (Status);            }        }        else        {            /* Extract the Dstate value */            Highest[i] = (UINT8) ObjDesc->Integer.Value;            /* Delete the return object */            AcpiUtRemoveReference (ObjDesc);        }    }    return_ACPI_STATUS (AE_OK);}

⌨️ 快捷键说明

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