ACPI: ACPICA 20060526

Restructured, flattened, and simplified the internal
interfaces for namespace object evaluation - resulting
in smaller code, less CPU stack use, and fewer
interfaces. (With assistance from Mikhail Kouzmich)

Fixed a problem with the CopyObject operator where the
first parameter was not typed correctly for the parser,
interpreter, compiler, and disassembler. Caused various
errors and unexpected behavior.

Fixed a problem where a ShiftLeft or ShiftRight of
more than 64 bits produced incorrect results with some
C compilers. Since the behavior of C compilers when
the shift value is larger than the datatype width is
apparently not well defined, the interpreter now detects
this condition and simply returns zero as expected in all
such cases. (BZ 395)

Fixed problem reports (Valery Podrezov) integrated: -
Update String-to-Integer conversion to match ACPI 3.0A spec
http://bugzilla.kernel.org/show_bug.cgi?id=5329
Allow interpreter to handle nested method declarations
http://bugzilla.kernel.org/show_bug.cgi?id=5361

Fixed problem reports (Fiodor Suietov) integrated: -
acpi_terminate() doesn't free debug memory allocation
list objects (BZ 355) - After Core Subsystem
shutdown, acpi_subsystem_status() returns AE_OK (BZ 356) -
acpi_os_unmap_memory() for RSDP can be invoked inconsistently
(BZ 357) - Resource Manager should return AE_TYPE for
non-device objects (BZ 358) - Incomplete cleanup branch
in AcpiNsEvaluateRelative (BZ 359) - Use acpi_os_free()
instead of ACPI_FREE in acpi_rs_set_srs_method_data (BZ 360)
- Incomplete cleanup branch in acpi_ps_parse_aml (BZ 361) -
Incomplete cleanup branch in acpi_ds_delete_walk_state (BZ 362)
- acpi_get_table_header returns AE_NO_ACPI_TABLES until DSDT
is loaded (BZ 365) - Status of the Global Initialization
Handler call not used (BZ 366) - Incorrect object parameter
to Global Initialization Handler (BZ 367)

Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
diff --git a/drivers/acpi/events/evgpe.c b/drivers/acpi/events/evgpe.c
index aa179dc..23fe53b 100644
--- a/drivers/acpi/events/evgpe.c
+++ b/drivers/acpi/events/evgpe.c
@@ -488,9 +488,9 @@
  *
  * RETURN:      None
  *
- * DESCRIPTION: Perform the actual execution of a GPE control method.  This
- *              function is called from an invocation of acpi_os_exece
- *              (and therefore does NOT execute at interrupt level) so that
+ * DESCRIPTION: Perform the actual execution of a GPE control method. This
+ *              function is called from an invocation of acpi_os_execute and
+ *              therefore does NOT execute at interrupt level - so that
  *              the control method itself is not executed in the context of
  *              an interrupt handler.
  *
@@ -502,7 +502,7 @@
 	u32 gpe_number = 0;
 	acpi_status status;
 	struct acpi_gpe_event_info local_gpe_event_info;
-	struct acpi_parameter_info info;
+	struct acpi_evaluate_info *info;
 
 	ACPI_FUNCTION_TRACE(ev_asynch_execute_gpe_method);
 
@@ -540,16 +540,29 @@
 	 */
 	if ((local_gpe_event_info.flags & ACPI_GPE_DISPATCH_MASK) ==
 	    ACPI_GPE_DISPATCH_METHOD) {
-		/*
-		 * Invoke the GPE Method (_Lxx, _Exx) i.e., evaluate the _Lxx/_Exx
-		 * control method that corresponds to this GPE
-		 */
-		info.node = local_gpe_event_info.dispatch.method_node;
-		info.parameters =
-		    ACPI_CAST_PTR(union acpi_operand_object *, gpe_event_info);
-		info.parameter_type = ACPI_PARAM_GPE;
 
-		status = acpi_ns_evaluate_by_handle(&info);
+		/* Allocate the evaluation information block */
+
+		info = ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_evaluate_info));
+		if (!info) {
+			status = AE_NO_MEMORY;
+		} else {
+			/*
+			 * Invoke the GPE Method (_Lxx, _Exx) i.e., evaluate the _Lxx/_Exx
+			 * control method that corresponds to this GPE
+			 */
+			info->prefix_node =
+			    local_gpe_event_info.dispatch.method_node;
+			info->parameters =
+			    ACPI_CAST_PTR(union acpi_operand_object *,
+					  gpe_event_info);
+			info->parameter_type = ACPI_PARAM_GPE;
+			info->flags = ACPI_IGNORE_RETURN_VALUE;
+
+			status = acpi_ns_evaluate(info);
+			ACPI_FREE(info);
+		}
+
 		if (ACPI_FAILURE(status)) {
 			ACPI_EXCEPTION((AE_INFO, status,
 					"While evaluating method [%4.4s] for GPE[%2X]",
diff --git a/drivers/acpi/events/evmisc.c b/drivers/acpi/events/evmisc.c
index 24e0b8d..6eef4ef 100644
--- a/drivers/acpi/events/evmisc.c
+++ b/drivers/acpi/events/evmisc.c
@@ -49,12 +49,13 @@
 #define _COMPONENT          ACPI_EVENTS
 ACPI_MODULE_NAME("evmisc")
 
+/* Names for Notify() values, used for debug output */
 #ifdef ACPI_DEBUG_OUTPUT
 static const char *acpi_notify_value_names[] = {
 	"Bus Check",
 	"Device Check",
 	"Device Wake",
-	"Eject request",
+	"Eject Request",
 	"Device Check Light",
 	"Frequency Mismatch",
 	"Bus Mode Mismatch",
@@ -191,8 +192,9 @@
 		notify_info->notify.value = (u16) notify_value;
 		notify_info->notify.handler_obj = handler_obj;
 
-		status = acpi_os_execute(OSL_NOTIFY_HANDLER,
-					 acpi_ev_notify_dispatch, notify_info);
+		status =
+		    acpi_os_execute(OSL_NOTIFY_HANDLER, acpi_ev_notify_dispatch,
+				    notify_info);
 		if (ACPI_FAILURE(status)) {
 			acpi_ut_delete_generic_state(notify_info);
 		}
@@ -345,8 +347,9 @@
 
 		/* Run the Global Lock thread which will signal all waiting threads */
 
-		status = acpi_os_execute(OSL_GLOBAL_LOCK_HANDLER,
-					 acpi_ev_global_lock_thread, context);
+		status =
+		    acpi_os_execute(OSL_GLOBAL_LOCK_HANDLER,
+				    acpi_ev_global_lock_thread, context);
 		if (ACPI_FAILURE(status)) {
 			ACPI_EXCEPTION((AE_INFO, status,
 					"Could not queue Global Lock thread"));
@@ -462,8 +465,9 @@
 	 * Acquire the global lock semaphore first.
 	 * Since this wait will block, we must release the interpreter
 	 */
-	status = acpi_ex_system_wait_semaphore(acpi_gbl_global_lock_semaphore,
-					       timeout);
+	status =
+	    acpi_ex_system_wait_semaphore(acpi_gbl_global_lock_semaphore,
+					  timeout);
 	return_ACPI_STATUS(status);
 }
 
diff --git a/drivers/acpi/events/evregion.c b/drivers/acpi/events/evregion.c
index edf9d2e..094a17e 100644
--- a/drivers/acpi/events/evregion.c
+++ b/drivers/acpi/events/evregion.c
@@ -193,8 +193,8 @@
 acpi_status
 acpi_ev_execute_reg_method(union acpi_operand_object *region_obj, u32 function)
 {
-	struct acpi_parameter_info info;
-	union acpi_operand_object *params[3];
+	struct acpi_evaluate_info *info;
+	union acpi_operand_object *args[3];
 	union acpi_operand_object *region_obj2;
 	acpi_status status;
 
@@ -209,47 +209,60 @@
 		return_ACPI_STATUS(AE_OK);
 	}
 
-	/*
-	 * The _REG method has two arguments:
-	 *
-	 * Arg0, Integer: Operation region space ID
-	 *          Same value as region_obj->Region.space_id
-	 * Arg1, Integer: connection status
-	 *          1 for connecting the handler,
-	 *          0 for disconnecting the handler
-	 *          Passed as a parameter
-	 */
-	params[0] = acpi_ut_create_internal_object(ACPI_TYPE_INTEGER);
-	if (!params[0]) {
+	/* Allocate and initialize the evaluation information block */
+
+	info = ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_evaluate_info));
+	if (!info) {
 		return_ACPI_STATUS(AE_NO_MEMORY);
 	}
 
-	params[1] = acpi_ut_create_internal_object(ACPI_TYPE_INTEGER);
-	if (!params[1]) {
+	info->prefix_node = region_obj2->extra.method_REG;
+	info->pathname = NULL;
+	info->parameters = args;
+	info->parameter_type = ACPI_PARAM_ARGS;
+	info->flags = ACPI_IGNORE_RETURN_VALUE;
+
+	/*
+	 * The _REG method has two arguments:
+	 *
+	 * Arg0 - Integer:
+	 *  Operation region space ID Same value as region_obj->Region.space_id
+	 *
+	 * Arg1 - Integer:
+	 *  connection status 1 for connecting the handler, 0 for disconnecting
+	 *  the handler (Passed as a parameter)
+	 */
+	args[0] = acpi_ut_create_internal_object(ACPI_TYPE_INTEGER);
+	if (!args[0]) {
 		status = AE_NO_MEMORY;
-		goto cleanup;
+		goto cleanup1;
+	}
+
+	args[1] = acpi_ut_create_internal_object(ACPI_TYPE_INTEGER);
+	if (!args[1]) {
+		status = AE_NO_MEMORY;
+		goto cleanup2;
 	}
 
 	/* Setup the parameter objects */
 
-	params[0]->integer.value = region_obj->region.space_id;
-	params[1]->integer.value = function;
-	params[2] = NULL;
-
-	info.node = region_obj2->extra.method_REG;
-	info.parameters = params;
-	info.parameter_type = ACPI_PARAM_ARGS;
+	args[0]->integer.value = region_obj->region.space_id;
+	args[1]->integer.value = function;
+	args[2] = NULL;
 
 	/* Execute the method, no return value */
 
 	ACPI_DEBUG_EXEC(acpi_ut_display_init_pathname
-			(ACPI_TYPE_METHOD, info.node, NULL));
-	status = acpi_ns_evaluate_by_handle(&info);
+			(ACPI_TYPE_METHOD, info->prefix_node, NULL));
 
-	acpi_ut_remove_reference(params[1]);
+	status = acpi_ns_evaluate(info);
+	acpi_ut_remove_reference(args[1]);
 
-      cleanup:
-	acpi_ut_remove_reference(params[0]);
+      cleanup2:
+	acpi_ut_remove_reference(args[0]);
+
+      cleanup1:
+	ACPI_FREE(info);
 	return_ACPI_STATUS(status);
 }
 
diff --git a/drivers/acpi/events/evrgnini.c b/drivers/acpi/events/evrgnini.c
index 1cecd57..5b3c7a8 100644
--- a/drivers/acpi/events/evrgnini.c
+++ b/drivers/acpi/events/evrgnini.c
@@ -475,8 +475,9 @@
 
 	/* Find any "_REG" method associated with this region definition */
 
-	status = acpi_ns_search_node(*reg_name_ptr, node,
-				     ACPI_TYPE_METHOD, &method_node);
+	status =
+	    acpi_ns_search_one_scope(*reg_name_ptr, node, ACPI_TYPE_METHOD,
+				     &method_node);
 	if (ACPI_SUCCESS(status)) {
 		/*
 		 * The _REG method is optional and there can be only one per region