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

📄 nsaccess.c

📁 linux-2.6.15.6
💻 C
📖 第 1 页 / 共 2 页
字号:
	*return_node = ACPI_ENTRY_NOT_FOUND;	if (!acpi_gbl_root_node) {		return_ACPI_STATUS(AE_NO_NAMESPACE);	}	/*	 * Get the prefix scope.	 * A null scope means use the root scope	 */	if ((!scope_info) || (!scope_info->scope.node)) {		ACPI_DEBUG_PRINT((ACPI_DB_NAMES,				  "Null scope prefix, using root node (%p)\n",				  acpi_gbl_root_node));		prefix_node = acpi_gbl_root_node;	} else {		prefix_node = scope_info->scope.node;		if (ACPI_GET_DESCRIPTOR_TYPE(prefix_node) !=		    ACPI_DESC_TYPE_NAMED) {			ACPI_REPORT_ERROR(("ns_lookup: %p is not a namespace node [%s]\n", prefix_node, acpi_ut_get_descriptor_name(prefix_node)));			return_ACPI_STATUS(AE_AML_INTERNAL);		}		/*		 * This node might not be a actual "scope" node (such as a		 * Device/Method, etc.)  It could be a Package or other object node.		 * Backup up the tree to find the containing scope node.		 */		while (!acpi_ns_opens_scope(prefix_node->type) &&		       prefix_node->type != ACPI_TYPE_ANY) {			prefix_node = acpi_ns_get_parent_node(prefix_node);		}	}	/* Save type   TBD: may be no longer necessary */	type_to_check_for = type;	/*	 * Begin examination of the actual pathname	 */	if (!pathname) {		/* A Null name_path is allowed and refers to the root */		num_segments = 0;		this_node = acpi_gbl_root_node;		path = "";		ACPI_DEBUG_PRINT((ACPI_DB_NAMES,				  "Null Pathname (Zero segments), Flags=%X\n",				  flags));	} else {		/*		 * Name pointer is valid (and must be in internal name format)		 *		 * Check for scope prefixes:		 *		 * As represented in the AML stream, a namepath consists of an		 * optional scope prefix followed by a name segment part.		 *		 * If present, the scope prefix is either a Root Prefix (in		 * which case the name is fully qualified), or one or more		 * Parent Prefixes (in which case the name's scope is relative		 * to the current scope).		 */		if (*path == (u8) AML_ROOT_PREFIX) {			/* Pathname is fully qualified, start from the root */			this_node = acpi_gbl_root_node;			search_parent_flag = ACPI_NS_NO_UPSEARCH;			/* Point to name segment part */			path++;			ACPI_DEBUG_PRINT((ACPI_DB_NAMES,					  "Path is absolute from root [%p]\n",					  this_node));		} else {			/* Pathname is relative to current scope, start there */			ACPI_DEBUG_PRINT((ACPI_DB_NAMES,					  "Searching relative to prefix scope [%4.4s] (%p)\n",					  acpi_ut_get_node_name(prefix_node),					  prefix_node));			/*			 * Handle multiple Parent Prefixes (carat) by just getting			 * the parent node for each prefix instance.			 */			this_node = prefix_node;			num_carats = 0;			while (*path == (u8) AML_PARENT_PREFIX) {				/* Name is fully qualified, no search rules apply */				search_parent_flag = ACPI_NS_NO_UPSEARCH;				/*				 * Point past this prefix to the name segment				 * part or the next Parent Prefix				 */				path++;				/* Backup to the parent node */				num_carats++;				this_node = acpi_ns_get_parent_node(this_node);				if (!this_node) {					/* Current scope has no parent scope */					ACPI_REPORT_ERROR(("ACPI path has too many parent prefixes (^) - reached beyond root node\n"));					return_ACPI_STATUS(AE_NOT_FOUND);				}			}			if (search_parent_flag == ACPI_NS_NO_UPSEARCH) {				ACPI_DEBUG_PRINT((ACPI_DB_NAMES,						  "Search scope is [%4.4s], path has %d carat(s)\n",						  acpi_ut_get_node_name						  (this_node), num_carats));			}		}		/*		 * Determine the number of ACPI name segments in this pathname.		 *		 * The segment part consists of either:		 *  - A Null name segment (0)		 *  - A dual_name_prefix followed by two 4-byte name segments		 *  - A multi_name_prefix followed by a byte indicating the		 *      number of segments and the segments themselves.		 *  - A single 4-byte name segment		 *		 * Examine the name prefix opcode, if any, to determine the number of		 * segments.		 */		switch (*path) {		case 0:			/*			 * Null name after a root or parent prefixes. We already			 * have the correct target node and there are no name segments.			 */			num_segments = 0;			type = this_node->type;			ACPI_DEBUG_PRINT((ACPI_DB_NAMES,					  "Prefix-only Pathname (Zero name segments), Flags=%X\n",					  flags));			break;		case AML_DUAL_NAME_PREFIX:			/* More than one name_seg, search rules do not apply */			search_parent_flag = ACPI_NS_NO_UPSEARCH;			/* Two segments, point to first name segment */			num_segments = 2;			path++;			ACPI_DEBUG_PRINT((ACPI_DB_NAMES,					  "Dual Pathname (2 segments, Flags=%X)\n",					  flags));			break;		case AML_MULTI_NAME_PREFIX_OP:			/* More than one name_seg, search rules do not apply */			search_parent_flag = ACPI_NS_NO_UPSEARCH;			/* Extract segment count, point to first name segment */			path++;			num_segments = (u32) (u8) * path;			path++;			ACPI_DEBUG_PRINT((ACPI_DB_NAMES,					  "Multi Pathname (%d Segments, Flags=%X) \n",					  num_segments, flags));			break;		default:			/*			 * Not a Null name, no Dual or Multi prefix, hence there is			 * only one name segment and Pathname is already pointing to it.			 */			num_segments = 1;			ACPI_DEBUG_PRINT((ACPI_DB_NAMES,					  "Simple Pathname (1 segment, Flags=%X)\n",					  flags));			break;		}		ACPI_DEBUG_EXEC(acpi_ns_print_pathname(num_segments, path));	}	/*	 * Search namespace for each segment of the name.  Loop through and	 * verify (or add to the namespace) each name segment.	 *	 * The object type is significant only at the last name	 * segment.  (We don't care about the types along the path, only	 * the type of the final target object.)	 */	this_search_type = ACPI_TYPE_ANY;	current_node = this_node;	while (num_segments && current_node) {		num_segments--;		if (!num_segments) {			/*			 * This is the last segment, enable typechecking			 */			this_search_type = type;			/*			 * Only allow automatic parent search (search rules) if the caller			 * requested it AND we have a single, non-fully-qualified name_seg			 */			if ((search_parent_flag != ACPI_NS_NO_UPSEARCH) &&			    (flags & ACPI_NS_SEARCH_PARENT)) {				local_flags |= ACPI_NS_SEARCH_PARENT;			}			/* Set error flag according to caller */			if (flags & ACPI_NS_ERROR_IF_FOUND) {				local_flags |= ACPI_NS_ERROR_IF_FOUND;			}		}		/* Extract one ACPI name from the front of the pathname */		ACPI_MOVE_32_TO_32(&simple_name, path);		/* Try to find the single (4 character) ACPI name */		status =		    acpi_ns_search_and_enter(simple_name, walk_state,					     current_node, interpreter_mode,					     this_search_type, local_flags,					     &this_node);		if (ACPI_FAILURE(status)) {			if (status == AE_NOT_FOUND) {				/* Name not found in ACPI namespace */				ACPI_DEBUG_PRINT((ACPI_DB_NAMES,						  "Name [%4.4s] not found in scope [%4.4s] %p\n",						  (char *)&simple_name,						  (char *)&current_node->name,						  current_node));			}			*return_node = this_node;			return_ACPI_STATUS(status);		}		/*		 * Sanity typecheck of the target object:		 *		 * If 1) This is the last segment (num_segments == 0)		 *    2) And we are looking for a specific type		 *       (Not checking for TYPE_ANY)		 *    3) Which is not an alias		 *    4) Which is not a local type (TYPE_SCOPE)		 *    5) And the type of target object is known (not TYPE_ANY)		 *    6) And target object does not match what we are looking for		 *		 * Then we have a type mismatch.  Just warn and ignore it.		 */		if ((num_segments == 0) &&		    (type_to_check_for != ACPI_TYPE_ANY) &&		    (type_to_check_for != ACPI_TYPE_LOCAL_ALIAS) &&		    (type_to_check_for != ACPI_TYPE_LOCAL_METHOD_ALIAS) &&		    (type_to_check_for != ACPI_TYPE_LOCAL_SCOPE) &&		    (this_node->type != ACPI_TYPE_ANY) &&		    (this_node->type != type_to_check_for)) {			/* Complain about a type mismatch */			ACPI_REPORT_WARNING(("ns_lookup: Type mismatch on %4.4s (%s), searching for (%s)\n", (char *)&simple_name, acpi_ut_get_type_name(this_node->type), acpi_ut_get_type_name(type_to_check_for)));		}		/*		 * If this is the last name segment and we are not looking for a		 * specific type, but the type of found object is known, use that type		 * to see if it opens a scope.		 */		if ((num_segments == 0) && (type == ACPI_TYPE_ANY)) {			type = this_node->type;		}		/* Point to next name segment and make this node current */		path += ACPI_NAME_SIZE;		current_node = this_node;	}	/*	 * Always check if we need to open a new scope	 */	if (!(flags & ACPI_NS_DONT_OPEN_SCOPE) && (walk_state)) {		/*		 * If entry is a type which opens a scope, push the new scope on the		 * scope stack.		 */		if (acpi_ns_opens_scope(type)) {			status =			    acpi_ds_scope_stack_push(this_node, type,						     walk_state);			if (ACPI_FAILURE(status)) {				return_ACPI_STATUS(status);			}		}	}	*return_node = this_node;	return_ACPI_STATUS(AE_OK);}

⌨️ 快捷键说明

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