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

📄 nsxfeval.c

📁 acpi tools for linux include acpiexec and acpixtract
💻 C
📖 第 1 页 / 共 2 页
字号:
 * * FUNCTION:    AcpiWalkNamespace * * PARAMETERS:  Type                - ACPI_OBJECT_TYPE to search for *              StartObject         - Handle in namespace where search begins *              MaxDepth            - Depth to which search is to reach *              UserFunction        - Called when an object of "Type" is found *              Context             - Passed to user function *              ReturnValue         - Location where return value of *                                    UserFunction is put if terminated early * * RETURNS      Return value from the UserFunction if terminated early. *              Otherwise, returns NULL. * * DESCRIPTION: Performs a modified depth-first walk of the namespace tree, *              starting (and ending) at the object specified by StartHandle. *              The UserFunction is called whenever an object that matches *              the type parameter is found.  If the user function returns *              a non-zero value, the search is terminated immediately and this *              value is returned to the caller. * *              The point of this procedure is to provide a generic namespace *              walk routine that can be called from multiple places to *              provide multiple services;  the User Function can be tailored *              to each task, whether it is a print function, a compare *              function, etc. * ******************************************************************************/ACPI_STATUSAcpiWalkNamespace (    ACPI_OBJECT_TYPE        Type,    ACPI_HANDLE             StartObject,    UINT32                  MaxDepth,    ACPI_WALK_CALLBACK      UserFunction,    void                    *Context,    void                    **ReturnValue){    ACPI_STATUS             Status;    ACPI_FUNCTION_TRACE (AcpiWalkNamespace);    /* Parameter validation */    if ((Type > ACPI_TYPE_LOCAL_MAX) ||        (!MaxDepth)                  ||        (!UserFunction))    {        return_ACPI_STATUS (AE_BAD_PARAMETER);    }    /*     * Lock the namespace around the walk.     * The namespace will be unlocked/locked around each call     * to the user function - since this function     * must be allowed to make Acpi calls itself.     */    Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);    if (ACPI_FAILURE (Status))    {        return_ACPI_STATUS (Status);    }    Status = AcpiNsWalkNamespace (Type, StartObject, MaxDepth,                    ACPI_NS_WALK_UNLOCK,                    UserFunction, Context, ReturnValue);    (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);    return_ACPI_STATUS (Status);}ACPI_EXPORT_SYMBOL (AcpiWalkNamespace)/******************************************************************************* * * FUNCTION:    AcpiNsGetDeviceCallback * * PARAMETERS:  Callback from AcpiGetDevice * * RETURN:      Status * * DESCRIPTION: Takes callbacks from WalkNamespace and filters out all non- *              present devices, or if they specified a HID, it filters based *              on that. * ******************************************************************************/static ACPI_STATUSAcpiNsGetDeviceCallback (    ACPI_HANDLE             ObjHandle,    UINT32                  NestingLevel,    void                    *Context,    void                    **ReturnValue){    ACPI_GET_DEVICES_INFO   *Info = Context;    ACPI_STATUS             Status;    ACPI_NAMESPACE_NODE     *Node;    UINT32                  Flags;    ACPI_DEVICE_ID          Hid;    ACPI_COMPATIBLE_ID_LIST *Cid;    ACPI_NATIVE_UINT        i;    BOOLEAN                 Found;    Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);    if (ACPI_FAILURE (Status))    {        return (Status);    }    Node = AcpiNsMapHandleToNode (ObjHandle);    Status = AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);    if (ACPI_FAILURE (Status))    {        return (Status);    }    if (!Node)    {        return (AE_BAD_PARAMETER);    }    /* Run _STA to determine if device is present */    Status = AcpiUtExecute_STA (Node, &Flags);    if (ACPI_FAILURE (Status))    {        return (AE_CTRL_DEPTH);    }    if (!(Flags & ACPI_STA_DEVICE_PRESENT) &&        !(Flags & ACPI_STA_DEVICE_FUNCTIONING))    {        /*         * Don't examine the children of the device only when the         * device is neither present nor functional. See ACPI spec,         * description of _STA for more information.         */        return (AE_CTRL_DEPTH);    }    /* Filter based on device HID & CID */    if (Info->Hid != NULL)    {        Status = AcpiUtExecute_HID (Node, &Hid);        if (Status == AE_NOT_FOUND)        {            return (AE_OK);        }        else if (ACPI_FAILURE (Status))        {            return (AE_CTRL_DEPTH);        }        if (ACPI_STRNCMP (Hid.Value, Info->Hid, sizeof (Hid.Value)) != 0)        {            /*             * HID does not match, attempt match within the             * list of Compatible IDs (CIDs)             */            Status = AcpiUtExecute_CID (Node, &Cid);            if (Status == AE_NOT_FOUND)            {                return (AE_OK);            }            else if (ACPI_FAILURE (Status))            {                return (AE_CTRL_DEPTH);            }            /* Walk the CID list */            Found = FALSE;            for (i = 0; i < Cid->Count; i++)            {                if (ACPI_STRNCMP (Cid->Id[i].Value, Info->Hid,                        sizeof (ACPI_COMPATIBLE_ID)) == 0)                {                    /* Found a matching CID */                    Found = TRUE;                    break;                }            }            ACPI_FREE (Cid);            if (!Found)            {                return (AE_OK);            }        }    }    /* We have a valid device, invoke the user function */    Status = Info->UserFunction (ObjHandle, NestingLevel, Info->Context,                ReturnValue);    return (Status);}/******************************************************************************* * * FUNCTION:    AcpiGetDevices * * PARAMETERS:  HID                 - HID to search for. Can be NULL. *              UserFunction        - Called when a matching object is found *              Context             - Passed to user function *              ReturnValue         - Location where return value of *                                    UserFunction is put if terminated early * * RETURNS      Return value from the UserFunction if terminated early. *              Otherwise, returns NULL. * * DESCRIPTION: Performs a modified depth-first walk of the namespace tree, *              starting (and ending) at the object specified by StartHandle. *              The UserFunction is called whenever an object of type *              Device is found.  If the user function returns *              a non-zero value, the search is terminated immediately and this *              value is returned to the caller. * *              This is a wrapper for WalkNamespace, but the callback performs *              additional filtering. Please see AcpiNsGetDeviceCallback. * ******************************************************************************/ACPI_STATUSAcpiGetDevices (    char                    *HID,    ACPI_WALK_CALLBACK      UserFunction,    void                    *Context,    void                    **ReturnValue){    ACPI_STATUS             Status;    ACPI_GET_DEVICES_INFO   Info;    ACPI_FUNCTION_TRACE (AcpiGetDevices);    /* Parameter validation */    if (!UserFunction)    {        return_ACPI_STATUS (AE_BAD_PARAMETER);    }    /*     * We're going to call their callback from OUR callback, so we need     * to know what it is, and their context parameter.     */    Info.Hid          = HID;    Info.Context      = Context;    Info.UserFunction = UserFunction;    /*     * Lock the namespace around the walk.     * The namespace will be unlocked/locked around each call     * to the user function - since this function     * must be allowed to make Acpi calls itself.     */    Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);    if (ACPI_FAILURE (Status))    {        return_ACPI_STATUS (Status);    }    Status = AcpiNsWalkNamespace (ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,                ACPI_UINT32_MAX, ACPI_NS_WALK_UNLOCK,                AcpiNsGetDeviceCallback, &Info, ReturnValue);    (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);    return_ACPI_STATUS (Status);}ACPI_EXPORT_SYMBOL (AcpiGetDevices)/******************************************************************************* * * FUNCTION:    AcpiAttachData * * PARAMETERS:  ObjHandle           - Namespace node *              Handler             - Handler for this attachment *              Data                - Pointer to data to be attached * * RETURN:      Status * * DESCRIPTION: Attach arbitrary data and handler to a namespace node. * ******************************************************************************/ACPI_STATUSAcpiAttachData (    ACPI_HANDLE             ObjHandle,    ACPI_OBJECT_HANDLER     Handler,    void                    *Data){    ACPI_NAMESPACE_NODE     *Node;    ACPI_STATUS             Status;    /* Parameter validation */    if (!ObjHandle  ||        !Handler    ||        !Data)    {        return (AE_BAD_PARAMETER);    }    Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);    if (ACPI_FAILURE (Status))    {        return (Status);    }    /* Convert and validate the handle */    Node = AcpiNsMapHandleToNode (ObjHandle);    if (!Node)    {        Status = AE_BAD_PARAMETER;        goto UnlockAndExit;    }    Status = AcpiNsAttachData (Node, Handler, Data);UnlockAndExit:    (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);    return (Status);}ACPI_EXPORT_SYMBOL (AcpiAttachData)/******************************************************************************* * * FUNCTION:    AcpiDetachData * * PARAMETERS:  ObjHandle           - Namespace node handle *              Handler             - Handler used in call to AcpiAttachData * * RETURN:      Status * * DESCRIPTION: Remove data that was previously attached to a node. * ******************************************************************************/ACPI_STATUSAcpiDetachData (    ACPI_HANDLE             ObjHandle,    ACPI_OBJECT_HANDLER     Handler){    ACPI_NAMESPACE_NODE     *Node;    ACPI_STATUS             Status;    /* Parameter validation */    if (!ObjHandle  ||        !Handler)    {        return (AE_BAD_PARAMETER);    }    Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);    if (ACPI_FAILURE (Status))    {        return (Status);    }    /* Convert and validate the handle */    Node = AcpiNsMapHandleToNode (ObjHandle);    if (!Node)    {        Status = AE_BAD_PARAMETER;        goto UnlockAndExit;    }    Status = AcpiNsDetachData (Node, Handler);UnlockAndExit:    (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);    return (Status);}ACPI_EXPORT_SYMBOL (AcpiDetachData)/******************************************************************************* * * FUNCTION:    AcpiGetData * * PARAMETERS:  ObjHandle           - Namespace node *              Handler             - Handler used in call to AttachData *              Data                - Where the data is returned * * RETURN:      Status * * DESCRIPTION: Retrieve data that was previously attached to a namespace node. * ******************************************************************************/ACPI_STATUSAcpiGetData (    ACPI_HANDLE             ObjHandle,    ACPI_OBJECT_HANDLER     Handler,    void                    **Data){    ACPI_NAMESPACE_NODE     *Node;    ACPI_STATUS             Status;    /* Parameter validation */    if (!ObjHandle  ||        !Handler    ||        !Data)    {        return (AE_BAD_PARAMETER);    }    Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);    if (ACPI_FAILURE (Status))    {        return (Status);    }    /* Convert and validate the handle */    Node = AcpiNsMapHandleToNode (ObjHandle);    if (!Node)    {        Status = AE_BAD_PARAMETER;        goto UnlockAndExit;    }    Status = AcpiNsGetAttachedData (Node, Handler, Data);UnlockAndExit:    (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);    return (Status);}ACPI_EXPORT_SYMBOL (AcpiGetData)

⌨️ 快捷键说明

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