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

📄 nsxfobj.c

📁 这个linux源代码是很全面的~基本完整了~使用c编译的~由于时间问题我没有亲自测试~但就算用来做参考资料也是非常好的
💻 C
📖 第 1 页 / 共 2 页
字号:
/******************************************************************************* * * FUNCTION:    Acpi_get_type * * PARAMETERS:  Handle          - Handle of object whose type is desired *              *Ret_type       - Where the type will be placed * * RETURN:      Status * * DESCRIPTION: This routine returns the type associatd with a particular handle * ******************************************************************************/acpi_statusacpi_get_type (	acpi_handle             handle,	acpi_object_type        *ret_type){	acpi_namespace_node     *node;	/* Parameter Validation */	if (!ret_type) {		return (AE_BAD_PARAMETER);	}	/*	 * Special case for the predefined Root Node	 * (return type ANY)	 */	if (handle == ACPI_ROOT_OBJECT) {		*ret_type = ACPI_TYPE_ANY;		return (AE_OK);	}	acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);	/* Convert and validate the handle */	node = acpi_ns_map_handle_to_node (handle);	if (!node) {		acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);		return (AE_BAD_PARAMETER);	}	*ret_type = node->type;	acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);	return (AE_OK);}/******************************************************************************* * * FUNCTION:    Acpi_get_parent * * PARAMETERS:  Handle          - Handle of object whose parent is desired *              Ret_handle      - Where the parent handle will be placed * * RETURN:      Status * * DESCRIPTION: Returns a handle to the parent of the object represented by *              Handle. * ******************************************************************************/acpi_statusacpi_get_parent (	acpi_handle             handle,	acpi_handle             *ret_handle){	acpi_namespace_node     *node;	acpi_status             status = AE_OK;	if (!ret_handle) {		return (AE_BAD_PARAMETER);	}	/* Special case for the predefined Root Node (no parent) */	if (handle == ACPI_ROOT_OBJECT) {		return (AE_NULL_ENTRY);	}	acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);	/* Convert and validate the handle */	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_object (node));	/* Return exeption if parent is null */	if (!acpi_ns_get_parent_object (node)) {		status = AE_NULL_ENTRY;	}unlock_and_exit:	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;	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.	 */	acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);	status = acpi_ns_walk_namespace ((acpi_object_type8) type, start_object,			  max_depth, NS_WALK_UNLOCK, user_function, context,			  return_value);	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          device_id;	acpi_get_devices_info   *info;	info = context;	acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);	node = acpi_ns_map_handle_to_node (obj_handle);	acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);	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	 */	if (info->hid != NULL) {		status = acpi_ut_execute_HID (node, &device_id);		if (status == AE_NOT_FOUND) {			return (AE_OK);		}		else if (ACPI_FAILURE (status)) {			return (AE_CTRL_DEPTH);		}		if (STRNCMP (device_id.buffer, info->hid, sizeof (device_id.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;	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.	 */	acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);	status = acpi_ns_walk_namespace (ACPI_TYPE_DEVICE,			   ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,			   NS_WALK_UNLOCK,			   acpi_ns_get_device_callback, &info,			   return_value);	acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);	return_ACPI_STATUS (status);}

⌨️ 快捷键说明

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