patch-2.4.0-test9 linux/drivers/acpi/dispatcher/dsutils.c

Next file: linux/drivers/acpi/dispatcher/dswexec.c
Previous file: linux/drivers/acpi/dispatcher/dsopcode.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/dispatcher/dsutils.c linux/drivers/acpi/dispatcher/dsutils.c
@@ -1,9 +1,9 @@
-
-/******************************************************************************
+/*******************************************************************************
  *
  * Module Name: dsutils - Dispatcher utilities
+ *              $Revision: 44 $
  *
- *****************************************************************************/
+ ******************************************************************************/
 
 /*
  *  Copyright (C) 2000 R. Byron Moore
@@ -25,20 +25,20 @@
 
 
 #include "acpi.h"
-#include "parser.h"
+#include "acparser.h"
 #include "amlcode.h"
-#include "dispatch.h"
-#include "interp.h"
-#include "namesp.h"
-#include "debugger.h"
+#include "acdispat.h"
+#include "acinterp.h"
+#include "acnamesp.h"
+#include "acdebug.h"
 
 #define _COMPONENT          PARSER
-	 MODULE_NAME         ("dsutils");
+	 MODULE_NAME         ("dsutils")
 
 
-/*****************************************************************************
+/*******************************************************************************
  *
- * FUNCTION:    Acpi_ds_delete_result_if_not_used
+ * FUNCTION:    Acpi_ds_is_result_used
  *
  * PARAMETERS:  Op
  *              Result_obj
@@ -46,52 +46,32 @@
  *
  * RETURN:      Status
  *
- * DESCRIPTION: Used after interpretation of an opcode.  If there is an internal
- *              result descriptor, check if the parent opcode will actually use
- *              this result.  If not, delete the result now so that it will
- *              not become orphaned.
+ * DESCRIPTION: Check if a result object will be used by the parent
  *
- ****************************************************************************/
+ ******************************************************************************/
 
-void
-acpi_ds_delete_result_if_not_used (
-	ACPI_GENERIC_OP         *op,
-	ACPI_OBJECT_INTERNAL    *result_obj,
-	ACPI_WALK_STATE         *walk_state)
+u8
+acpi_ds_is_result_used (
+	ACPI_PARSE_OBJECT       *op)
 {
-	ACPI_OP_INFO            *parent_info;
-	ACPI_OBJECT_INTERNAL    *obj_desc;
-	ACPI_STATUS             status;
+	ACPI_OPCODE_INFO        *parent_info;
+
 
+	/* Must have both an Op and a Result Object */
 
 	if (!op) {
-		return;
+		return (TRUE);
 	}
 
-	if (!result_obj) {
-		return;
-	}
 
+	/*
+	 * If there is no parent, the result can't possibly be used!
+	 * (An executing method typically has no parent, since each
+	 * method is parsed separately)  However, a method that is
+	 * invoked from another method has a parent.
+	 */
 	if (!op->parent) {
-		/*
-		 * If there is no parent, the result can't possibly be used!
-		 * (An executing method typically has no parent, since each
-		 * method is parsed separately
-		 */
-
-		/*
-		 * Must pop the result stack (Obj_desc should be equal
-		 *  to Result_obj)
-		 */
-
-		status = acpi_ds_result_stack_pop (&obj_desc, walk_state);
-		if (ACPI_FAILURE (status)) {
-			return;
-		}
-
-		acpi_cm_remove_reference (result_obj);
-
-		return;
+		return (FALSE);
 	}
 
 
@@ -100,15 +80,15 @@
 	 */
 
 	parent_info = acpi_ps_get_opcode_info (op->parent->opcode);
-	if (!parent_info) {
-		return;
+	if (ACPI_GET_OP_TYPE (parent_info) != ACPI_OP_TYPE_OPCODE) {
+		return (FALSE);
 	}
 
 
 	/* Never delete the return value associated with a return opcode */
 
 	if (op->parent->opcode == AML_RETURN_OP) {
-		return;
+		return (TRUE);
 	}
 
 
@@ -119,26 +99,15 @@
 	 * as an operand later.
 	 */
 
-	switch (parent_info->flags & OP_INFO_TYPE)
+	switch (ACPI_GET_OP_CLASS (parent_info))
 	{
 	/*
-	 * In these cases, the parent will never use the return object,
-	 * so delete it here and now.
+	 * In these cases, the parent will never use the return object
 	 */
 	case OPTYPE_CONTROL:        /* IF, ELSE, WHILE only */
 	case OPTYPE_NAMED_OBJECT:   /* Scope, method, etc. */
 
-		/*
-		 * Must pop the result stack (Obj_desc should be equal
-		 * to Result_obj)
-		 */
-
-		status = acpi_ds_result_stack_pop (&obj_desc, walk_state);
-		if (ACPI_FAILURE (status)) {
-			return;
-		}
-
-		acpi_cm_remove_reference (result_obj);
+		return (FALSE);
 		break;
 
 	/*
@@ -149,11 +118,63 @@
 		break;
 	}
 
+	return (TRUE);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    Acpi_ds_delete_result_if_not_used
+ *
+ * PARAMETERS:  Op
+ *              Result_obj
+ *              Walk_state
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Used after interpretation of an opcode.  If there is an internal
+ *              result descriptor, check if the parent opcode will actually use
+ *              this result.  If not, delete the result now so that it will
+ *              not become orphaned.
+ *
+ ******************************************************************************/
+
+void
+acpi_ds_delete_result_if_not_used (
+	ACPI_PARSE_OBJECT       *op,
+	ACPI_OPERAND_OBJECT     *result_obj,
+	ACPI_WALK_STATE         *walk_state)
+{
+	ACPI_OPERAND_OBJECT     *obj_desc;
+	ACPI_STATUS             status;
+
+
+	if (!op) {
+		return;
+	}
+
+	if (!result_obj) {
+		return;
+	}
+
+
+	if (!acpi_ds_is_result_used (op)) {
+		/*
+		 * Must pop the result stack (Obj_desc should be equal
+		 *  to Result_obj)
+		 */
+
+		status = acpi_ds_result_stack_pop (&obj_desc, walk_state);
+		if (ACPI_SUCCESS (status)) {
+			acpi_cm_remove_reference (result_obj);
+		}
+	}
+
 	return;
 }
 
 
-/*****************************************************************************
+/*******************************************************************************
  *
  * FUNCTION:    Acpi_ds_create_operand
  *
@@ -167,19 +188,19 @@
  *              looking up a name or entering a new name into the internal
  *              namespace.
  *
- ****************************************************************************/
+ ******************************************************************************/
 
 ACPI_STATUS
 acpi_ds_create_operand (
 	ACPI_WALK_STATE         *walk_state,
-	ACPI_GENERIC_OP         *arg)
+	ACPI_PARSE_OBJECT       *arg)
 {
 	ACPI_STATUS             status = AE_OK;
-	char                    *name_string;
+	NATIVE_CHAR             *name_string;
 	u32                     name_length;
 	OBJECT_TYPE_INTERNAL    data_type;
-	ACPI_OBJECT_INTERNAL    *obj_desc;
-	ACPI_GENERIC_OP         *parent_op;
+	ACPI_OPERAND_OBJECT     *obj_desc;
+	ACPI_PARSE_OBJECT       *parent_op;
 	u16                     opcode;
 	u32                     flags;
 	OPERATING_MODE          interpreter_mode;
@@ -214,7 +235,7 @@
 		 */
 
 		parent_op = arg->parent;
-		if ((acpi_ps_is_named_object_op (parent_op->opcode)) &&
+		if ((acpi_ps_is_node_op (parent_op->opcode)) &&
 			(parent_op->opcode != AML_METHODCALL_OP) &&
 			(parent_op->opcode != AML_NAMEPATH_OP))
 		{
@@ -233,7 +254,7 @@
 				 ACPI_TYPE_ANY, interpreter_mode,
 				 NS_SEARCH_PARENT | NS_DONT_OPEN_SCOPE,
 				 walk_state,
-				 (ACPI_NAMED_OBJECT**) &obj_desc);
+				 (ACPI_NAMESPACE_NODE **) &obj_desc);
 
 		/* Free the namestring created above */
 
@@ -252,7 +273,7 @@
 				 * indicate this to the interpreter, set the
 				 * object to the root
 				 */
-				obj_desc = (ACPI_OBJECT_INTERNAL *) acpi_gbl_root_object;
+				obj_desc = (ACPI_OPERAND_OBJECT *) acpi_gbl_root_node;
 				status = AE_OK;
 			}
 
@@ -277,6 +298,7 @@
 		if (ACPI_FAILURE (status)) {
 			return (status);
 		}
+		DEBUGGER_EXEC (acpi_db_display_argument_object (obj_desc, walk_state));
 	}
 
 
@@ -311,6 +333,8 @@
 		}
 
 		if (flags & OP_HAS_RETURN_VALUE) {
+			DEBUGGER_EXEC (acpi_db_display_argument_object (walk_state->operands [walk_state->num_operands - 1], walk_state));
+
 			/*
 			 * Use value that was already previously returned
 			 * by the evaluation of this argument
@@ -338,9 +362,9 @@
 			/* Initialize the new object */
 
 			status = acpi_ds_init_object_from_op (walk_state, arg,
-					 opcode, obj_desc);
+					 opcode, &obj_desc);
 			if (ACPI_FAILURE (status)) {
-				acpi_cm_free (obj_desc);
+				acpi_cm_delete_object_desc (obj_desc);
 				return (status);
 			}
 	   }
@@ -352,13 +376,14 @@
 			return (status);
 		}
 
+		DEBUGGER_EXEC (acpi_db_display_argument_object (obj_desc, walk_state));
 	}
 
 	return (AE_OK);
 }
 
 
-/*****************************************************************************
+/*******************************************************************************
  *
  * FUNCTION:    Acpi_ds_create_operands
  *
@@ -370,15 +395,15 @@
  *              namespace objects and place those argument object on the object
  *              stack in preparation for evaluation by the interpreter.
  *
- ****************************************************************************/
+ ******************************************************************************/
 
 ACPI_STATUS
 acpi_ds_create_operands (
 	ACPI_WALK_STATE         *walk_state,
-	ACPI_GENERIC_OP         *first_arg)
+	ACPI_PARSE_OBJECT       *first_arg)
 {
 	ACPI_STATUS             status = AE_OK;
-	ACPI_GENERIC_OP         *arg;
+	ACPI_PARSE_OBJECT       *arg;
 	u32                     args_pushed = 0;
 
 
@@ -416,7 +441,7 @@
 }
 
 
-/*****************************************************************************
+/*******************************************************************************
  *
  * FUNCTION:    Acpi_ds_resolve_operands
  *
@@ -428,7 +453,7 @@
  *              arguments to a control method invocation (a call from one
  *              method to another.)
  *
- ****************************************************************************/
+ ******************************************************************************/
 
 ACPI_STATUS
 acpi_ds_resolve_operands (
@@ -449,7 +474,7 @@
 	 */
 
 	for (i = 0; i < walk_state->num_operands; i++) {
-		status = acpi_aml_resolve_to_value (&walk_state->operands[i]);
+		status = acpi_aml_resolve_to_value (&walk_state->operands[i], walk_state);
 		if (ACPI_FAILURE (status)) {
 			break;
 		}
@@ -459,7 +484,7 @@
 }
 
 
-/*****************************************************************************
+/*******************************************************************************
  *
  * FUNCTION:    Acpi_ds_map_opcode_to_data_type
  *
@@ -472,7 +497,7 @@
  *              if any.  If the opcode returns a value as part of the
  *              intepreter execution, a flag is returned in Out_flags.
  *
- ****************************************************************************/
+ ******************************************************************************/
 
 OBJECT_TYPE_INTERNAL
 acpi_ds_map_opcode_to_data_type (
@@ -480,18 +505,18 @@
 	u32                     *out_flags)
 {
 	OBJECT_TYPE_INTERNAL    data_type = INTERNAL_TYPE_INVALID;
-	ACPI_OP_INFO            *op_info;
+	ACPI_OPCODE_INFO        *op_info;
 	u32                     flags = 0;
 
 
 	op_info = acpi_ps_get_opcode_info (opcode);
-	if (!op_info) {
+	if (ACPI_GET_OP_TYPE (op_info) != ACPI_OP_TYPE_OPCODE) {
 		/* Unknown opcode */
 
-		return data_type;
+		return (data_type);
 	}
 
-	switch (op_info->flags & OP_INFO_TYPE)
+	switch (ACPI_GET_OP_CLASS (op_info))
 	{
 
 	case OPTYPE_LITERAL:
@@ -552,6 +577,7 @@
 	case OPTYPE_DYADIC2_s:
 	case OPTYPE_INDEX:
 	case OPTYPE_MATCH:
+	case OPTYPE_RETURN:
 
 		flags = OP_HAS_RETURN_VALUE;
 		data_type = ACPI_TYPE_ANY;
@@ -592,11 +618,11 @@
 		*out_flags = flags;
 	}
 
-	return data_type;
+	return (data_type);
 }
 
 
-/*****************************************************************************
+/*******************************************************************************
  *
  * FUNCTION:    Acpi_ds_map_named_opcode_to_data_type
  *
@@ -607,7 +633,7 @@
  * DESCRIPTION: Convert a raw Named AML opcode to the associated data type.
  *              Named opcodes are a subsystem of the AML opcodes.
  *
- ****************************************************************************/
+ ******************************************************************************/
 
 OBJECT_TYPE_INTERNAL
 acpi_ds_map_named_opcode_to_data_type (
@@ -688,7 +714,7 @@
 
 	}
 
-	return data_type;
+	return (data_type);
 }
 
 

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