patch-2.4.10 linux/drivers/acpi/namespace/nsaccess.c

Next file: linux/drivers/acpi/namespace/nsalloc.c
Previous file: linux/drivers/acpi/kdb/kdbm_acpi.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.4.9/linux/drivers/acpi/namespace/nsaccess.c linux/drivers/acpi/namespace/nsaccess.c
@@ -1,7 +1,7 @@
 /*******************************************************************************
  *
  * Module Name: nsaccess - Top-level functions for accessing ACPI namespace
- *              $Revision: 126 $
+ *              $Revision: 133 $
  *
  ******************************************************************************/
 
@@ -49,13 +49,16 @@
  *
  ******************************************************************************/
 
-ACPI_STATUS
+acpi_status
 acpi_ns_root_initialize (void)
 {
-	ACPI_STATUS             status = AE_OK;
-	PREDEFINED_NAMES        *init_val = NULL;
-	ACPI_NAMESPACE_NODE     *new_node;
-	ACPI_OPERAND_OBJECT     *obj_desc;
+	acpi_status             status = AE_OK;
+	const predefined_names  *init_val = NULL;
+	acpi_namespace_node     *new_node;
+	acpi_operand_object     *obj_desc;
+
+
+	FUNCTION_TRACE ("Ns_root_initialize");
 
 
 	acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
@@ -64,7 +67,6 @@
 	 * The global root ptr is initially NULL, so a non-NULL value indicates
 	 * that Acpi_ns_root_initialize() has already been called; just return.
 	 */
-
 	if (acpi_gbl_root_node) {
 		status = AE_OK;
 		goto unlock_and_exit;
@@ -75,30 +77,34 @@
 	 * Tell the rest of the subsystem that the root is initialized
 	 * (This is OK because the namespace is locked)
 	 */
-
 	acpi_gbl_root_node = &acpi_gbl_root_node_struct;
 
 
 	/* Enter the pre-defined names in the name table */
 
+	ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Entering predefined entries into namespace\n"));
+
 	for (init_val = acpi_gbl_pre_defined_names; init_val->name; init_val++) {
 		status = acpi_ns_lookup (NULL, init_val->name, init_val->type,
 				 IMODE_LOAD_PASS2, NS_NO_UPSEARCH,
 				 NULL, &new_node);
 
+		if (ACPI_FAILURE (status) || (!new_node)) /* Must be on same line for code converter */ {
+			ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+				"Could not create predefined name %s, %s\n",
+				init_val->name, acpi_format_exception (status)));
+		}
 
 		/*
 		 * Name entered successfully.
 		 * If entry in Pre_defined_names[] specifies an
 		 * initial value, create the initial value.
 		 */
-
 		if (init_val->val) {
 			/*
 			 * Entry requests an initial value, allocate a
 			 * descriptor for it.
 			 */
-
 			obj_desc = acpi_ut_create_internal_object (init_val->type);
 			if (!obj_desc) {
 				status = AE_NO_MEMORY;
@@ -116,28 +122,18 @@
 			case ACPI_TYPE_INTEGER:
 
 				obj_desc->integer.value =
-						(ACPI_INTEGER) STRTOUL (init_val->val, NULL, 10);
+						(acpi_integer) STRTOUL (init_val->val, NULL, 10);
 				break;
 
 
 			case ACPI_TYPE_STRING:
 
-				obj_desc->string.length = STRLEN (init_val->val);
-
 				/*
-				 * Allocate a buffer for the string.  All
-				 * String.Pointers must be allocated buffers!
-				 * (makes deletion simpler)
+				 * Build an object around the static string
 				 */
-				obj_desc->string.pointer = acpi_ut_allocate (
-						   (obj_desc->string.length + 1));
-				if (!obj_desc->string.pointer) {
-					acpi_ut_remove_reference (obj_desc);
-					status = AE_NO_MEMORY;
-					goto unlock_and_exit;
-				}
-
-				STRCPY (obj_desc->string.pointer, init_val->val);
+				obj_desc->string.length = STRLEN (init_val->val);
+				obj_desc->string.pointer = init_val->val;
+				obj_desc->common.flags |= AOPOBJ_STATIC_POINTER;
 				break;
 
 
@@ -157,11 +153,11 @@
 					if (ACPI_FAILURE (status)) {
 						goto unlock_and_exit;
 					}
+
 					/*
 					 * We just created the mutex for the
 					 * global lock, save it
 					 */
-
 					acpi_gbl_global_lock_semaphore = obj_desc->mutex.semaphore;
 				}
 
@@ -195,7 +191,7 @@
 
 unlock_and_exit:
 	acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
-	return (status);
+	return_ACPI_STATUS (status);
 }
 
 
@@ -222,31 +218,36 @@
  *
  ******************************************************************************/
 
-ACPI_STATUS
+acpi_status
 acpi_ns_lookup (
-	ACPI_GENERIC_STATE      *scope_info,
+	acpi_generic_state      *scope_info,
 	NATIVE_CHAR             *pathname,
-	ACPI_OBJECT_TYPE8       type,
-	OPERATING_MODE          interpreter_mode,
+	acpi_object_type8       type,
+	operating_mode          interpreter_mode,
 	u32                     flags,
-	ACPI_WALK_STATE         *walk_state,
-	ACPI_NAMESPACE_NODE     **return_node)
+	acpi_walk_state         *walk_state,
+	acpi_namespace_node     **return_node)
 {
-	ACPI_STATUS             status;
-	ACPI_NAMESPACE_NODE     *prefix_node;
-	ACPI_NAMESPACE_NODE     *current_node = NULL;
-	ACPI_NAMESPACE_NODE     *scope_to_push = NULL;
-	ACPI_NAMESPACE_NODE     *this_node = NULL;
+	acpi_status             status;
+	acpi_namespace_node     *prefix_node;
+	acpi_namespace_node     *current_node = NULL;
+	acpi_namespace_node     *scope_to_push = NULL;
+	acpi_namespace_node     *this_node = NULL;
 	u32                     num_segments;
-	ACPI_NAME               simple_name;
+	acpi_name               simple_name;
 	u8                      null_name_path = FALSE;
-	ACPI_OBJECT_TYPE8       type_to_check_for;
-	ACPI_OBJECT_TYPE8       this_search_type;
+	acpi_object_type8       type_to_check_for;
+	acpi_object_type8       this_search_type;
 	u32                     local_flags = flags & ~NS_ERROR_IF_FOUND;
 
+	DEBUG_EXEC              (u32 i;)
+
+
+	FUNCTION_TRACE ("Ns_lookup");
+
 
 	if (!return_node) {
-		return (AE_BAD_PARAMETER);
+		return_ACPI_STATUS (AE_BAD_PARAMETER);
 	}
 
 
@@ -263,9 +264,11 @@
 	 * 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 {
@@ -280,7 +283,6 @@
 	 * but the Bank_field_defn may also check for a Field definition as well
 	 * as an Operation_region.
 	 */
-
 	if (INTERNAL_TYPE_FIELD_DEFN == type) {
 		/* Def_field_defn defines fields in a Region */
 
@@ -309,6 +311,8 @@
 		num_segments = 0;
 		this_node = acpi_gbl_root_node;
 
+		ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
+			"Null Pathname (Zero segments),  Flags=%x\n", flags));
 	}
 
 	else {
@@ -330,7 +334,6 @@
 		 *  - A Multi_name_prefix_op, followed by a byte indicating the
 		 *    number of segments and the segments themselves.
 		 */
-
 		if (*pathname == AML_ROOT_PREFIX) {
 			/* Pathname is fully qualified, look in root name table */
 
@@ -340,6 +343,9 @@
 
 			pathname++;
 
+			ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "Searching from root [%p]\n",
+				current_node));
+
 			/* Direct reference to root, "\" */
 
 			if (!(*pathname)) {
@@ -353,11 +359,13 @@
 
 			current_node = prefix_node;
 
+			ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "Searching relative to pfx scope [%p]\n",
+				prefix_node));
+
 			/*
 			 * Handle up-prefix (carat).  More than one prefix
 			 * is supported
 			 */
-
 			while (*pathname == AML_PARENT_PREFIX) {
 				/* Point to segment part or next Parent_prefix */
 
@@ -371,7 +379,7 @@
 
 					REPORT_ERROR (
 						("Too many parent prefixes (^) - reached root\n"));
-					return (AE_NOT_FOUND);
+					return_ACPI_STATUS (AE_NOT_FOUND);
 				}
 
 				current_node = this_node;
@@ -383,7 +391,6 @@
 		 * Examine the name prefix opcode, if any,
 		 * to determine the number of segments
 		 */
-
 		if (*pathname == AML_DUAL_NAME_PREFIX) {
 			num_segments = 2;
 
@@ -391,6 +398,8 @@
 
 			pathname++;
 
+			ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
+				"Dual Pathname (2 segments, Flags=%X)\n", flags));
 		}
 
 		else if (*pathname == AML_MULTI_NAME_PREFIX_OP) {
@@ -400,6 +409,9 @@
 
 			pathname++;
 
+			ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
+				"Multi Pathname (%d Segments, Flags=%X) \n",
+				num_segments, flags));
 		}
 
 		else {
@@ -409,8 +421,23 @@
 			 */
 			num_segments = 1;
 
+			ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
+				"Simple Pathname (1 segment, Flags=%X)\n", flags));
 		}
 
+#ifdef ACPI_DEBUG
+
+		/* TBD: [Restructure] Make this a procedure */
+
+		/* Debug only: print the entire name that we are about to lookup */
+
+		ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "["));
+
+		for (i = 0; i < num_segments; i++) {
+			ACPI_DEBUG_PRINT_RAW ((ACPI_DB_NAMES, "%4.4s/", &pathname[i * 4]));
+		}
+		ACPI_DEBUG_PRINT_RAW ((ACPI_DB_NAMES, "]\n"));
+#endif
 	}
 
 
@@ -418,8 +445,6 @@
 	 * Search namespace for each segment of the name.
 	 * Loop through and verify/add each name segment.
 	 */
-
-
 	while (num_segments-- && current_node) {
 		/*
 		 * Search for the current name segment under the current
@@ -448,9 +473,12 @@
 			if (status == AE_NOT_FOUND) {
 				/* Name not found in ACPI namespace  */
 
+				ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
+					"Name [%4.4s] not found in scope %X\n",
+					&simple_name, current_node));
 			}
 
-			return (status);
+			return_ACPI_STATUS (status);
 		}
 
 
@@ -487,7 +515,6 @@
 		 * specific type, but the type of found object is known, use that type
 		 * to see if it opens a scope.
 		 */
-
 		if ((0 == num_segments) && (ACPI_TYPE_ANY == type)) {
 			type = this_node->type;
 		}
@@ -498,7 +525,8 @@
 			 * More segments or the type implies enclosed scope,
 			 * and the next scope has not been allocated.
 			 */
-
+			ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Load mode=%X  This_node=%X\n",
+				interpreter_mode, this_node));
 		}
 
 		current_node = this_node;
@@ -512,7 +540,6 @@
 	/*
 	 * Always check if we need to open a new scope
 	 */
-
 check_for_new_scope_and_exit:
 
 	if (!(flags & NS_DONT_OPEN_SCOPE) && (walk_state)) {
@@ -520,7 +547,6 @@
 		 * If entry is a type which opens a scope,
 		 * push the new scope on the scope stack.
 		 */
-
 		if (acpi_ns_opens_scope (type_to_check_for)) {
 			/*  8-12-98 ASL Grammar Update supports null Name_path  */
 
@@ -536,13 +562,14 @@
 			status = acpi_ds_scope_stack_push (scope_to_push, type,
 					   walk_state);
 			if (ACPI_FAILURE (status)) {
-				return (status);
+				return_ACPI_STATUS (status);
 			}
 
+			ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Set global scope to %p\n", scope_to_push));
 		}
 	}
 
 	*return_node = this_node;
-	return (AE_OK);
+	return_ACPI_STATUS (AE_OK);
 }
 

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)