patch-2.4.10 linux/drivers/acpi/events/evregion.c

Next file: linux/drivers/acpi/events/evrgnini.c
Previous file: linux/drivers/acpi/events/evmisc.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.4.9/linux/drivers/acpi/events/evregion.c linux/drivers/acpi/events/evregion.c
@@ -1,7 +1,7 @@
 /******************************************************************************
  *
  * Module Name: evregion - ACPI Address_space (Op_region) handler dispatch
- *              $Revision: 103 $
+ *              $Revision: 110 $
  *
  *****************************************************************************/
 
@@ -46,11 +46,14 @@
  *
  ******************************************************************************/
 
-ACPI_STATUS
+acpi_status
 acpi_ev_install_default_address_space_handlers (
 	void)
 {
-	ACPI_STATUS             status;
+	acpi_status             status;
+
+
+	FUNCTION_TRACE ("Ev_install_default_address_space_handlers");
 
 
 	/*
@@ -68,13 +71,12 @@
 	 * NOTE: We ignore AE_EXIST because this means that a handler has
 	 * already been installed (via Acpi_install_address_space_handler)
 	 */
-
 	status = acpi_install_address_space_handler (acpi_gbl_root_node,
 			   ACPI_ADR_SPACE_SYSTEM_MEMORY,
 			   ACPI_DEFAULT_HANDLER, NULL, NULL);
 	if ((ACPI_FAILURE (status)) &&
 		(status != AE_EXIST)) {
-		return (status);
+		return_ACPI_STATUS (status);
 	}
 
 	status = acpi_install_address_space_handler (acpi_gbl_root_node,
@@ -82,7 +84,7 @@
 			   ACPI_DEFAULT_HANDLER, NULL, NULL);
 	if ((ACPI_FAILURE (status)) &&
 		(status != AE_EXIST)) {
-		return (status);
+		return_ACPI_STATUS (status);
 	}
 
 	status = acpi_install_address_space_handler (acpi_gbl_root_node,
@@ -90,11 +92,11 @@
 			   ACPI_DEFAULT_HANDLER, NULL, NULL);
 	if ((ACPI_FAILURE (status)) &&
 		(status != AE_EXIST)) {
-		return (status);
+		return_ACPI_STATUS (status);
 	}
 
 
-	return (AE_OK);
+	return_ACPI_STATUS (AE_OK);
 }
 
 
@@ -113,19 +115,20 @@
  *
  ******************************************************************************/
 
-static ACPI_STATUS
+static acpi_status
 acpi_ev_execute_reg_method (
-	ACPI_OPERAND_OBJECT    *region_obj,
+	acpi_operand_object    *region_obj,
 	u32                     function)
 {
-	ACPI_OPERAND_OBJECT    *params[3];
-	ACPI_OPERAND_OBJECT     space_id_desc;
-	ACPI_OPERAND_OBJECT     function_desc;
-	ACPI_STATUS             status;
+	acpi_operand_object    *params[3];
+	acpi_status             status;
+
+
+	FUNCTION_TRACE ("Ev_execute_reg_method");
 
 
 	if (region_obj->region.extra->extra.method_REG == NULL) {
-		return (AE_OK);
+		return_ACPI_STATUS (AE_OK);
 	}
 
 	/*
@@ -137,31 +140,36 @@
 	 *          0 for disconnecting the handler
 	 *          Passed as a parameter
 	 */
+	params[0] = acpi_ut_create_internal_object (ACPI_TYPE_INTEGER);
+	if (!params[0]) {
+		return_ACPI_STATUS (AE_NO_MEMORY);
+	}
 
-	acpi_ut_init_static_object (&space_id_desc);
-	acpi_ut_init_static_object (&function_desc);
+	params[1] = acpi_ut_create_internal_object (ACPI_TYPE_INTEGER);
+	if (!params[1]) {
+		acpi_ut_remove_reference (params[0]);
+		return_ACPI_STATUS (AE_NO_MEMORY);
+	}
 
-	/*
-	 *  Method requires two parameters.
-	 */
-	params [0] = &space_id_desc;
-	params [1] = &function_desc;
-	params [2] = NULL;
+	params[2] = NULL;
 
 	/*
 	 *  Set up the parameter objects
 	 */
-	space_id_desc.common.type  = ACPI_TYPE_INTEGER;
-	space_id_desc.integer.value = region_obj->region.space_id;
-
-	function_desc.common.type  = ACPI_TYPE_INTEGER;
-	function_desc.integer.value = function;
+	params[0]->integer.value  = region_obj->region.space_id;
+	params[1]->integer.value = function;
 
 	/*
 	 *  Execute the method, no return value
 	 */
+	DEBUG_EXEC(acpi_ut_display_init_pathname (region_obj->region.extra->extra.method_REG, " [Method]"));
 	status = acpi_ns_evaluate_by_handle (region_obj->region.extra->extra.method_REG, params, NULL);
-	return (status);
+
+
+	acpi_ut_remove_reference (params[0]);
+	acpi_ut_remove_reference (params[1]);
+
+	return_ACPI_STATUS (status);
 }
 
 
@@ -183,27 +191,33 @@
  *
  ******************************************************************************/
 
-ACPI_STATUS
+acpi_status
 acpi_ev_address_space_dispatch (
-	ACPI_OPERAND_OBJECT     *region_obj,
+	acpi_operand_object     *region_obj,
 	u32                     function,
 	ACPI_PHYSICAL_ADDRESS   address,
 	u32                     bit_width,
 	u32                     *value)
 {
-	ACPI_STATUS             status;
+	acpi_status             status;
 	ACPI_ADR_SPACE_HANDLER  handler;
 	ACPI_ADR_SPACE_SETUP    region_setup;
-	ACPI_OPERAND_OBJECT     *handler_desc;
+	acpi_operand_object     *handler_desc;
 	void                    *region_context = NULL;
 
 
+	FUNCTION_TRACE ("Ev_address_space_dispatch");
+
+
 	/*
 	 * Ensure that there is a handler associated with this region
 	 */
 	handler_desc = region_obj->region.addr_handler;
 	if (!handler_desc) {
-		return(AE_NOT_EXIST);
+		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "no handler for region(%p) [%s]\n",
+			region_obj, acpi_ut_get_region_name (region_obj->region.space_id)));
+
+		return_ACPI_STATUS(AE_NOT_EXIST);
 	}
 
 	/*
@@ -219,7 +233,9 @@
 			/*
 			 *  Bad news, no init routine and not init'd
 			 */
-			return (AE_UNKNOWN_STATUS);
+			ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No init routine for region(%p) [%s]\n",
+				region_obj, acpi_ut_get_region_name (region_obj->region.space_id)));
+			return_ACPI_STATUS (AE_UNKNOWN_STATUS);
 		}
 
 		/*
@@ -239,7 +255,10 @@
 		 *  Init routine may fail
 		 */
 		if (ACPI_FAILURE (status)) {
-			return(status);
+			ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Region Init: %s [%s]\n",
+				acpi_format_exception (status),
+				acpi_ut_get_region_name (region_obj->region.space_id)));
+			return_ACPI_STATUS(status);
 		}
 
 		region_obj->region.flags |= AOPOBJ_INITIALIZED;
@@ -256,6 +275,11 @@
 	 */
 	handler = handler_desc->addr_handler.handler;
 
+	ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION,
+		"Addrhandler %p (%p), Address %8.8lX%8.8lX\n",
+		&region_obj->region.addr_handler->addr_handler, handler, HIDWORD(address),
+		LODWORD(address)));
+
 	if (!(handler_desc->addr_handler.flags & ADDR_HANDLER_DEFAULT_INSTALLED)) {
 		/*
 		 *  For handlers other than the default (supplied) handlers, we must
@@ -272,15 +296,21 @@
 			 handler_desc->addr_handler.context,
 			 region_obj->region.extra->extra.region_context);
 
+	if (ACPI_FAILURE (status)) {
+		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Region handler: %s [%s]\n",
+			acpi_format_exception (status),
+			acpi_ut_get_region_name (region_obj->region.space_id)));
+	}
 
 	if (!(handler_desc->addr_handler.flags & ADDR_HANDLER_DEFAULT_INSTALLED)) {
-		/* We just returned from a non-default handler, we must re-enter the
-		interpreter */
-
+		/*
+		 * We just returned from a non-default handler, we must re-enter the
+		 * interpreter
+		 */
 		acpi_ex_enter_interpreter ();
 	}
 
-	return (status);
+	return_ACPI_STATUS (status);
 }
 
 /*******************************************************************************
@@ -299,15 +329,18 @@
 
 void
 acpi_ev_disassociate_region_from_handler(
-	ACPI_OPERAND_OBJECT     *region_obj,
+	acpi_operand_object     *region_obj,
 	u8                      acpi_ns_is_locked)
 {
-	ACPI_OPERAND_OBJECT     *handler_obj;
-	ACPI_OPERAND_OBJECT     *obj_desc;
-	ACPI_OPERAND_OBJECT     **last_obj_ptr;
+	acpi_operand_object     *handler_obj;
+	acpi_operand_object     *obj_desc;
+	acpi_operand_object     **last_obj_ptr;
 	ACPI_ADR_SPACE_SETUP    region_setup;
 	void                    *region_context;
-	ACPI_STATUS             status;
+	acpi_status             status;
+
+
+	FUNCTION_TRACE ("Ev_disassociate_region_from_handler");
 
 
 	region_context = region_obj->region.extra->extra.region_context;
@@ -315,20 +348,18 @@
 	/*
 	 *  Get the address handler from the region object
 	 */
-
 	handler_obj = region_obj->region.addr_handler;
 	if (!handler_obj) {
 		/*
 		 *  This region has no handler, all done
 		 */
-		return;
+		return_VOID;
 	}
 
 
 	/*
 	 *  Find this region in the handler's list
 	 */
-
 	obj_desc = handler_obj->addr_handler.region_list;
 	last_obj_ptr = &handler_obj->addr_handler.region_list;
 
@@ -337,6 +368,9 @@
 		 *  See if this is the one
 		 */
 		if (obj_desc == region_obj) {
+			ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION,
+				"Removing Region %p from address handler %p\n",
+				region_obj, handler_obj));
 			/*
 			 *  This is it, remove it from the handler's list
 			 */
@@ -366,6 +400,11 @@
 			/*
 			 *  Init routine may fail, Just ignore errors
 			 */
+			if (ACPI_FAILURE (status)) {
+				ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "%s from region init, [%s]\n",
+					acpi_format_exception (status),
+					acpi_ut_get_region_name (region_obj->region.space_id)));
+			}
 
 			region_obj->region.flags &= ~(AOPOBJ_INITIALIZED);
 
@@ -379,11 +418,9 @@
 			 *  If the region is on the handler's list
 			 *  this better be the region's handler
 			 */
-			ACPI_ASSERT (region_obj->region.addr_handler == handler_obj);
-
 			region_obj->region.addr_handler = NULL;
 
-			return;
+			return_VOID;
 
 		} /* found the right handler */
 
@@ -397,7 +434,11 @@
 	/*
 	 *  If we get here, the region was not in the handler's region list
 	 */
-	return;
+	ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION,
+		"Cannot remove region %p from address handler %p\n",
+		region_obj, handler_obj));
+
+	return_VOID;
 }
 
 
@@ -416,34 +457,32 @@
  *
  ******************************************************************************/
 
-ACPI_STATUS
+acpi_status
 acpi_ev_associate_region_and_handler (
-	ACPI_OPERAND_OBJECT     *handler_obj,
-	ACPI_OPERAND_OBJECT     *region_obj,
+	acpi_operand_object     *handler_obj,
+	acpi_operand_object     *region_obj,
 	u8                      acpi_ns_is_locked)
 {
-	ACPI_STATUS     status;
+	acpi_status     status;
 
 
-	ACPI_ASSERT (region_obj->region.space_id == handler_obj->addr_handler.space_id);
-	ACPI_ASSERT (region_obj->region.addr_handler == 0);
+	FUNCTION_TRACE ("Ev_associate_region_and_handler");
+
+
+	ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION,
+		"Adding Region %p to address handler %p [%s]\n",
+		region_obj, handler_obj, acpi_ut_get_region_name (region_obj->region.space_id)));
+
 
 	/*
 	 *  Link this region to the front of the handler's list
 	 */
-
 	region_obj->region.next = handler_obj->addr_handler.region_list;
 	handler_obj->addr_handler.region_list = region_obj;
 
 	/*
 	 *  set the region's handler
 	 */
-
-/*
-	Handler_obj->Common.Reference_count =
-			  (u16) (Handler_obj->Common.Reference_count +
-			  Region_obj->Common.Reference_count - 1);
-*/
 	region_obj->region.addr_handler = handler_obj;
 
 	/*
@@ -459,7 +498,7 @@
 		acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
 	}
 
-	return (status);
+	return_ACPI_STATUS (status);
 }
 
 
@@ -482,24 +521,24 @@
  *
  ******************************************************************************/
 
-ACPI_STATUS
+acpi_status
 acpi_ev_addr_handler_helper (
-	ACPI_HANDLE             obj_handle,
+	acpi_handle             obj_handle,
 	u32                     level,
 	void                    *context,
 	void                    **return_value)
 {
-	ACPI_OPERAND_OBJECT     *handler_obj;
-	ACPI_OPERAND_OBJECT     *tmp_obj;
-	ACPI_OPERAND_OBJECT     *obj_desc;
-	ACPI_NAMESPACE_NODE     *node;
-	ACPI_STATUS             status;
+	acpi_operand_object     *handler_obj;
+	acpi_operand_object     *tmp_obj;
+	acpi_operand_object     *obj_desc;
+	acpi_namespace_node     *node;
+	acpi_status             status;
 
 
 	PROC_NAME ("Ev_addr_handler_helper");
 
 
-	handler_obj = (ACPI_OPERAND_OBJECT *) context;
+	handler_obj = (acpi_operand_object *) context;
 
 	/* Parameter validation */
 
@@ -518,7 +557,6 @@
 	 *  We only care about regions.and objects
 	 *  that can have address handlers
 	 */
-
 	if ((node->type != ACPI_TYPE_DEVICE) &&
 		(node->type != ACPI_TYPE_REGION) &&
 		(node != acpi_gbl_root_node)) {
@@ -551,6 +589,11 @@
 				/*
 				 *  It's for the same address space
 				 */
+				ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION,
+					"Found handler for region [%s] in device %p(%p) handler %p\n",
+					acpi_ut_get_region_name (handler_obj->addr_handler.space_id),
+					obj_desc, tmp_obj, handler_obj));
+
 				/*
 				 *  Since the object we found it on was a device, then it
 				 *  means that someone has already installed a handler for
@@ -578,8 +621,6 @@
 	/*
 	 *  Only here if it was a region
 	 */
-	ACPI_ASSERT (obj_desc->common.type == ACPI_TYPE_REGION);
-
 	if (obj_desc->region.space_id != handler_obj->addr_handler.space_id) {
 		/*
 		 *  This region is for a different address space

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