nsxfobj.c
来自「是关于linux2.5.1的完全源码」· C语言 代码 · 共 836 行 · 第 1/2 页
C
836 行
node = acpi_ns_map_handle_to_node (handle); if (!node) { status = AE_BAD_PARAMETER; goto unlock_and_exit; } /* Get the parent entry */ *ret_handle = acpi_ns_convert_entry_to_handle (acpi_ns_get_parent_node (node)); /* Return exeption if parent is null */ if (!acpi_ns_get_parent_node (node)) { status = AE_NULL_ENTRY; }unlock_and_exit: (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); return (status);}/******************************************************************************* * * FUNCTION: Acpi_walk_namespace * * PARAMETERS: Type - acpi_object_type to search for * Start_object - Handle in namespace where search begins * Max_depth - Depth to which search is to reach * User_function - Called when an object of "Type" is found * Context - Passed to user function * Return_value - Location where return value of * User_function is put if terminated early * * RETURNS Return value from the User_function 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 Start_handle. * The User_function 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_statusacpi_walk_namespace ( acpi_object_type type, acpi_handle start_object, u32 max_depth, acpi_walk_callback user_function, void *context, void **return_value){ acpi_status status; ACPI_FUNCTION_TRACE ("Acpi_walk_namespace"); /* Parameter validation */ if ((type > ACPI_TYPE_MAX) || (!max_depth) || (!user_function)) { 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 = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE); if (ACPI_FAILURE (status)) { return_ACPI_STATUS (status); } status = acpi_ns_walk_namespace (type, start_object, max_depth, ACPI_NS_WALK_UNLOCK, user_function, context, return_value); (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); return_ACPI_STATUS (status);}/******************************************************************************* * * FUNCTION: Acpi_ns_get_device_callback * * PARAMETERS: Callback from Acpi_get_device * * RETURN: Status * * DESCRIPTION: Takes callbacks from Walk_namespace and filters out all non- * present devices, or if they specified a HID, it filters based * on that. * ******************************************************************************/static acpi_statusacpi_ns_get_device_callback ( acpi_handle obj_handle, u32 nesting_level, void *context, void **return_value){ acpi_status status; acpi_namespace_node *node; u32 flags; acpi_device_id hid; acpi_device_id cid; acpi_get_devices_info *info; info = context; status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE); if (ACPI_FAILURE (status)) { return (status); } node = acpi_ns_map_handle_to_node (obj_handle); status = acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); if (ACPI_FAILURE (status)) { return (status); } if (!node) { return (AE_BAD_PARAMETER); } /* * Run _STA to determine if device is present */ status = acpi_ut_execute_STA (node, &flags); if (ACPI_FAILURE (status)) { return (AE_CTRL_DEPTH); } if (!(flags & 0x01)) { /* Don't return at the device or children of the device if not there */ return (AE_CTRL_DEPTH); } /* * Filter based on device HID & CID */ if (info->hid != NULL) { status = acpi_ut_execute_HID (node, &hid); if (status == AE_NOT_FOUND) { return (AE_OK); } else if (ACPI_FAILURE (status)) { return (AE_CTRL_DEPTH); } if (ACPI_STRNCMP (hid.buffer, info->hid, sizeof (hid.buffer)) != 0) { status = acpi_ut_execute_CID (node, &cid); if (status == AE_NOT_FOUND) { return (AE_OK); } else if (ACPI_FAILURE (status)) { return (AE_CTRL_DEPTH); } /* TBD: Handle CID packages */ if (ACPI_STRNCMP (cid.buffer, info->hid, sizeof (cid.buffer)) != 0) { return (AE_OK); } } } info->user_function (obj_handle, nesting_level, info->context, return_value); return (AE_OK);}/******************************************************************************* * * FUNCTION: Acpi_get_devices * * PARAMETERS: HID - HID to search for. Can be NULL. * User_function - Called when a matching object is found * Context - Passed to user function * Return_value - Location where return value of * User_function is put if terminated early * * RETURNS Return value from the User_function 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 Start_handle. * The User_function 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. * * This is a wrapper for Walk_namespace, but the callback performs * additional filtering. Please see Acpi_get_device_callback. * ******************************************************************************/acpi_statusacpi_get_devices ( NATIVE_CHAR *HID, acpi_walk_callback user_function, void *context, void **return_value){ acpi_status status; acpi_get_devices_info info; ACPI_FUNCTION_TRACE ("Acpi_get_devices"); /* Parameter validation */ if (!user_function) { 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.context = context; info.user_function = user_function; info.hid = HID; /* * 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 = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE); if (ACPI_FAILURE (status)) { return_ACPI_STATUS (status); } status = acpi_ns_walk_namespace (ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX, ACPI_NS_WALK_UNLOCK, acpi_ns_get_device_callback, &info, return_value); (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); return_ACPI_STATUS (status);}/******************************************************************************* * * FUNCTION: Acpi_attach_data * * PARAMETERS: * * RETURN: Status * * DESCRIPTION: * ******************************************************************************/acpi_statusacpi_attach_data ( acpi_handle obj_handle, ACPI_OBJECT_HANDLER handler, void *data){ acpi_namespace_node *node; acpi_status status; /* Parameter validation */ if (!obj_handle || !handler || !data) { return (AE_BAD_PARAMETER); } status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE); if (ACPI_FAILURE (status)) { return (status); } /* Convert and validate the handle */ node = acpi_ns_map_handle_to_node (obj_handle); if (!node) { status = AE_BAD_PARAMETER; goto unlock_and_exit; } status = acpi_ns_attach_data (node, handler, data);unlock_and_exit: (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); return (status);}/******************************************************************************* * * FUNCTION: Acpi_detach_data * * PARAMETERS: * * RETURN: Status * * DESCRIPTION: * ******************************************************************************/acpi_statusacpi_detach_data ( acpi_handle obj_handle, ACPI_OBJECT_HANDLER handler){ acpi_namespace_node *node; acpi_status status; /* Parameter validation */ if (!obj_handle || !handler) { return (AE_BAD_PARAMETER); } status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE); if (ACPI_FAILURE (status)) { return (status); } /* Convert and validate the handle */ node = acpi_ns_map_handle_to_node (obj_handle); if (!node) { status = AE_BAD_PARAMETER; goto unlock_and_exit; } status = acpi_ns_detach_data (node, handler);unlock_and_exit: (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); return (status);}/******************************************************************************* * * FUNCTION: Acpi_get_data * * PARAMETERS: * * RETURN: Status * * DESCRIPTION: * ******************************************************************************/acpi_statusacpi_get_data ( acpi_handle obj_handle, ACPI_OBJECT_HANDLER handler, void **data){ acpi_namespace_node *node; acpi_status status; /* Parameter validation */ if (!obj_handle || !handler || !data) { return (AE_BAD_PARAMETER); } status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE); if (ACPI_FAILURE (status)) { return (status); } /* Convert and validate the handle */ node = acpi_ns_map_handle_to_node (obj_handle); if (!node) { status = AE_BAD_PARAMETER; goto unlock_and_exit; } status = acpi_ns_get_attached_data (node, handler, data);unlock_and_exit: (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); return (status);}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?