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

📄 nsutils.c

📁 这个linux源代码是很全面的~基本完整了~使用c编译的~由于时间问题我没有亲自测试~但就算用来做参考资料也是非常好的
💻 C
📖 第 1 页 / 共 2 页
字号:
			names_count = 2;			break;		/* Null_name */		case 0:			names_index = 0;			names_count = 0;			break;		/* one 4-byte name */		default:			names_index = prefix_length;			names_count = 1;			break;		}	}	/*	 * Calculate the length of Converted_name, which equals the length	 * of the prefix, length of all object names, length of any required	 * punctuation ('.') between object names, plus the NULL terminator.	 */	*converted_name_length = prefix_length + (4 * names_count) +			   ((names_count > 0) ? (names_count - 1) : 0) + 1;	/*	 * Check to see if we're still in bounds.  If not, there's a problem	 * with Internal_name (invalid format).	 */	if (*converted_name_length > internal_name_length) {		REPORT_ERROR (("Ns_externalize_name: Invalid internal name\n"));		return_ACPI_STATUS (AE_BAD_PATHNAME);	}	/*	 * Build Converted_name...	 */	(*converted_name) = ACPI_MEM_CALLOCATE (*converted_name_length);	if (!(*converted_name)) {		return_ACPI_STATUS (AE_NO_MEMORY);	}	j = 0;	for (i = 0; i < prefix_length; i++) {		(*converted_name)[j++] = internal_name[i];	}	if (names_count > 0) {		for (i = 0; i < names_count; i++) {			if (i > 0) {				(*converted_name)[j++] = '.';			}			(*converted_name)[j++] = internal_name[names_index++];			(*converted_name)[j++] = internal_name[names_index++];			(*converted_name)[j++] = internal_name[names_index++];			(*converted_name)[j++] = internal_name[names_index++];		}	}	return_ACPI_STATUS (AE_OK);}/******************************************************************************* * * FUNCTION:    Acpi_ns_map_handle_to_node * * PARAMETERS:  Handle          - Handle to be converted to an Node * * RETURN:      A Name table entry pointer * * DESCRIPTION: Convert a namespace handle to a real Node * ******************************************************************************/acpi_namespace_node *acpi_ns_map_handle_to_node (	acpi_handle             handle){	FUNCTION_ENTRY ();	/*	 * Simple implementation for now;	 * TBD: [Future] Real integer handles allow for more verification	 * and keep all pointers within this subsystem!	 */	if (!handle) {		return (NULL);	}	if (handle == ACPI_ROOT_OBJECT) {		return (acpi_gbl_root_node);	}	/* We can at least attempt to verify the handle */	if (!VALID_DESCRIPTOR_TYPE (handle, ACPI_DESC_TYPE_NAMED)) {		return (NULL);	}	return ((acpi_namespace_node *) handle);}/******************************************************************************* * * FUNCTION:    Acpi_ns_convert_entry_to_handle * * PARAMETERS:  Node          - Node to be converted to a Handle * * RETURN:      An USER acpi_handle * * DESCRIPTION: Convert a real Node to a namespace handle * ******************************************************************************/acpi_handleacpi_ns_convert_entry_to_handle (	acpi_namespace_node         *node){	/*	 * Simple implementation for now;	 * TBD: [Future] Real integer handles allow for more verification	 * and keep all pointers within this subsystem!	 */	return ((acpi_handle) node);/* ---------------------------------------------------	if (!Node)	{		return (NULL);	}	if (Node == Acpi_gbl_Root_node)	{		return (ACPI_ROOT_OBJECT);	}	return ((acpi_handle) Node);------------------------------------------------------*/}/******************************************************************************* * * FUNCTION:    Acpi_ns_terminate * * PARAMETERS:  none * * RETURN:      none * * DESCRIPTION: free memory allocated for table storage. * ******************************************************************************/voidacpi_ns_terminate (void){	acpi_operand_object     *obj_desc;	acpi_namespace_node     *this_node;	FUNCTION_TRACE ("Ns_terminate");	this_node = acpi_gbl_root_node;	/*	 * 1) Free the entire namespace -- all objects, tables, and stacks	 *	 * Delete all objects linked to the root	 * (additional table descriptors)	 */	acpi_ns_delete_namespace_subtree (this_node);	/* Detach any object(s) attached to the root */	obj_desc = acpi_ns_get_attached_object (this_node);	if (obj_desc) {		acpi_ns_detach_object (this_node);		acpi_ut_remove_reference (obj_desc);	}	acpi_ns_delete_children (this_node);	ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Namespace freed\n"));	/*	 * 2) Now we can delete the ACPI tables	 */	acpi_tb_delete_acpi_tables ();	ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "ACPI Tables freed\n"));	return_VOID;}/******************************************************************************* * * FUNCTION:    Acpi_ns_opens_scope * * PARAMETERS:  Type        - A valid namespace type * * RETURN:      NEWSCOPE if the passed type "opens a name scope" according *              to the ACPI specification, else 0 * ******************************************************************************/u32acpi_ns_opens_scope (	acpi_object_type8       type){	FUNCTION_TRACE_U32 ("Ns_opens_scope", type);	if (!acpi_ut_valid_object_type (type)) {		/* type code out of range  */		REPORT_WARNING (("Ns_opens_scope: Invalid Object Type\n"));		return_VALUE (NSP_NORMAL);	}	return_VALUE (((u32) acpi_gbl_ns_properties[type]) & NSP_NEWSCOPE);}/******************************************************************************* * * FUNCTION:    Acpi_ns_get_node * * PARAMETERS:  *Pathname   - Name to be found, in external (ASL) format. The *                            \ (backslash) and ^ (carat) prefixes, and the *                            . (period) to separate segments are supported. *              Start_node  - Root of subtree to be searched, or NS_ALL for the *                            root of the name space.  If Name is fully *                            qualified (first s8 is '\'), the passed value *                            of Scope will not be accessed. *              Return_node - Where the Node is returned * * DESCRIPTION: Look up a name relative to a given scope and return the *              corresponding Node.  NOTE: Scope can be null. * * MUTEX:       Locks namespace * ******************************************************************************/acpi_statusacpi_ns_get_node (	NATIVE_CHAR             *pathname,	acpi_namespace_node     *start_node,	acpi_namespace_node     **return_node){	acpi_generic_state      scope_info;	acpi_status             status;	NATIVE_CHAR             *internal_path = NULL;	FUNCTION_TRACE_PTR ("Ns_get_node", pathname);	/* Ensure that the namespace has been initialized */	if (!acpi_gbl_root_node) {		return_ACPI_STATUS (AE_NO_NAMESPACE);	}	if (!pathname) {		return_ACPI_STATUS (AE_BAD_PARAMETER);	}	/* Convert path to internal representation */	status = acpi_ns_internalize_name (pathname, &internal_path);	if (ACPI_FAILURE (status)) {		return_ACPI_STATUS (status);	}	acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);	/* Setup lookup scope (search starting point) */	scope_info.scope.node = start_node;	/* Lookup the name in the namespace */	status = acpi_ns_lookup (&scope_info, internal_path,			 ACPI_TYPE_ANY, IMODE_EXECUTE,			 NS_NO_UPSEARCH | NS_DONT_OPEN_SCOPE,			 NULL, return_node);	if (ACPI_FAILURE (status)) {		ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "%s, %s\n",				internal_path, acpi_format_exception (status)));	}	acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);	/* Cleanup */	ACPI_MEM_FREE (internal_path);	return_ACPI_STATUS (status);}/******************************************************************************* * * FUNCTION:    Acpi_ns_find_parent_name * * PARAMETERS:  *Child_node            - Named Obj whose name is to be found * * RETURN:      The ACPI name * * DESCRIPTION: Search for the given obj in its parent scope and return the *              name segment, or "????" if the parent name can't be found *              (which "should not happen"). * ******************************************************************************/acpi_nameacpi_ns_find_parent_name (	acpi_namespace_node     *child_node){	acpi_namespace_node     *parent_node;	FUNCTION_TRACE ("Ns_find_parent_name");	if (child_node) {		/* Valid entry.  Get the parent Node */		parent_node = acpi_ns_get_parent_object (child_node);		if (parent_node) {			ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Parent of %p [%4.4s] is %p [%4.4s]\n",				child_node, (char*)&child_node->name, parent_node, (char*)&parent_node->name));			if (parent_node->name) {				return_VALUE (parent_node->name);			}		}		ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "unable to find parent of %p (%4.4s)\n",			child_node, (char*)&child_node->name));	}	return_VALUE (ACPI_UNKNOWN_NAME);}#if defined(ACPI_DEBUG) || defined(ENABLE_DEBUGGER)/******************************************************************************* * * FUNCTION:    Acpi_ns_exist_downstream_sibling * * PARAMETERS:  *Node          - pointer to first Node to examine * * RETURN:      TRUE if sibling is found, FALSE otherwise * * DESCRIPTION: Searches remainder of scope being processed to determine *              whether there is a downstream sibling to the current *              object.  This function is used to determine what type of *              line drawing character to use when displaying namespace *              trees. * ******************************************************************************/u8acpi_ns_exist_downstream_sibling (	acpi_namespace_node     *node){	if (!node) {		return (FALSE);	}	if (node->name) {		return (TRUE);	}	return (FALSE);}#endif /* ACPI_DEBUG *//******************************************************************************* * * FUNCTION:    Acpi_ns_get_parent_object * * PARAMETERS:  Node       - Current table entry * * RETURN:      Parent entry of the given entry * * DESCRIPTION: Obtain the parent entry for a given entry in the namespace. * ******************************************************************************/acpi_namespace_node *acpi_ns_get_parent_object (	acpi_namespace_node     *node){	FUNCTION_ENTRY ();	if (!node) {		return (NULL);	}	/*	 * Walk to the end of this peer list.	 * The last entry is marked with a flag and the peer	 * pointer is really a pointer back to the parent.	 * This saves putting a parent back pointer in each and	 * every named object!	 */	while (!(node->flags & ANOBJ_END_OF_PEER_LIST)) {		node = node->peer;	}	return (node->peer);}/******************************************************************************* * * FUNCTION:    Acpi_ns_get_next_valid_node * * PARAMETERS:  Node       - Current table entry * * RETURN:      Next valid Node in the linked node list.  NULL if no more valid *              nodess * * DESCRIPTION: Find the next valid node within a name table. *              Useful for implementing NULL-end-of-list loops. * ******************************************************************************/acpi_namespace_node *acpi_ns_get_next_valid_node (	acpi_namespace_node     *node){	/* If we are at the end of this peer list, return NULL */	if (node->flags & ANOBJ_END_OF_PEER_LIST) {		return NULL;	}	/* Otherwise just return the next peer */	return (node->peer);}

⌨️ 快捷键说明

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