patch-2.4.22 linux-2.4.22/drivers/acpi/dispatcher/dsopcode.c

Next file: linux-2.4.22/drivers/acpi/dispatcher/dsutils.c
Previous file: linux-2.4.22/drivers/acpi/dispatcher/dsobject.c
Back to the patch index
Back to the overall index

diff -urN linux-2.4.21/drivers/acpi/dispatcher/dsopcode.c linux-2.4.22/drivers/acpi/dispatcher/dsopcode.c
@@ -2,126 +2,118 @@
  *
  * Module Name: dsopcode - Dispatcher Op Region support and handling of
  *                         "control" opcodes
- *              $Revision: 56 $
  *
  *****************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ * Copyright (C) 2000 - 2003, R. Byron Moore
+ * All rights reserved.
  *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions, and the following disclaimer,
+ *    without modification.
+ * 2. Redistributions in binary form must reproduce at minimum a disclaimer
+ *    substantially similar to the "NO WARRANTY" disclaimer below
+ *    ("Disclaimer") and any redistribution must be conditioned upon
+ *    including a substantially similar Disclaimer requirement for further
+ *    binary redistribution.
+ * 3. Neither the names of the above-listed copyright holders nor the names
+ *    of any contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * Alternatively, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") version 2 as published by the Free
+ * Software Foundation.
+ *
+ * NO WARRANTY
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGES.
  */
 
 
-#include "acpi.h"
-#include "acparser.h"
-#include "amlcode.h"
-#include "acdispat.h"
-#include "acinterp.h"
-#include "acnamesp.h"
-#include "acevents.h"
-#include "actables.h"
+#include <acpi/acpi.h>
+#include <acpi/acparser.h>
+#include <acpi/amlcode.h>
+#include <acpi/acdispat.h>
+#include <acpi/acinterp.h>
+#include <acpi/acnamesp.h>
+#include <acpi/acevents.h>
 
 #define _COMPONENT          ACPI_DISPATCHER
-	 MODULE_NAME         ("dsopcode")
+	 ACPI_MODULE_NAME    ("dsopcode")
 
 
 /*****************************************************************************
  *
- * FUNCTION:    Acpi_ds_get_buffer_field_arguments
+ * FUNCTION:    acpi_ds_execute_arguments
  *
- * PARAMETERS:  Obj_desc        - A valid Buffer_field object
+ * PARAMETERS:  Node                - Parent NS node
+ *              aml_length          - Length of executable AML
+ *              aml_start           - Pointer to the AML
  *
  * RETURN:      Status.
  *
- * DESCRIPTION: Get Buffer_field Buffer and Index. This implements the late
- *              evaluation of these field attributes.
+ * DESCRIPTION: Late execution of region or field arguments
  *
  ****************************************************************************/
 
 acpi_status
-acpi_ds_get_buffer_field_arguments (
-	acpi_operand_object     *obj_desc)
+acpi_ds_execute_arguments (
+	struct acpi_namespace_node      *node,
+	struct acpi_namespace_node      *scope_node,
+	u32                             aml_length,
+	u8                              *aml_start)
 {
-	acpi_operand_object     *extra_desc;
-	acpi_namespace_node     *node;
-	acpi_parse_object       *op;
-	acpi_parse_object       *field_op;
-	acpi_status             status;
-	acpi_table_desc         *table_desc;
-	acpi_walk_state         *walk_state;
-
+	acpi_status                     status;
+	union acpi_parse_object         *op;
+	struct acpi_walk_state          *walk_state;
+	union acpi_parse_object         *arg;
 
-	FUNCTION_TRACE_PTR ("Ds_get_buffer_field_arguments", obj_desc);
 
-
-	if (obj_desc->common.flags & AOPOBJ_DATA_VALID) {
-		return_ACPI_STATUS (AE_OK);
-	}
-
-
-	/* Get the AML pointer (method object) and Buffer_field node */
-
-	extra_desc = obj_desc->buffer_field.extra;
-	node = obj_desc->buffer_field.node;
-
-	DEBUG_EXEC(acpi_ut_display_init_pathname (node, " [Field]"));
-	ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[%4.4s] Buffer_field JIT Init\n",
-		(char*)&node->name));
+	ACPI_FUNCTION_TRACE ("ds_execute_arguments");
 
 
 	/*
-	 * Allocate a new parser op to be the root of the parsed
-	 * Op_region tree
+	 * Allocate a new parser op to be the root of the parsed tree
 	 */
-	op = acpi_ps_alloc_op (AML_SCOPE_OP);
+	op = acpi_ps_alloc_op (AML_INT_EVAL_SUBTREE_OP);
 	if (!op) {
-		return (AE_NO_MEMORY);
+		return_ACPI_STATUS (AE_NO_MEMORY);
 	}
 
-	/* Save the Node for use in Acpi_ps_parse_aml */
-
-	op->node = acpi_ns_get_parent_object (node);
+	/* Save the Node for use in acpi_ps_parse_aml */
 
-	/* Get a handle to the parent ACPI table */
-
-	status = acpi_tb_handle_to_object (node->owner_id, &table_desc);
-	if (ACPI_FAILURE (status)) {
-		return_ACPI_STATUS (status);
-	}
+	op->common.node = scope_node;
 
 	/* Create and initialize a new parser state */
 
-	walk_state = acpi_ds_create_walk_state (TABLE_ID_DSDT,
-			   NULL, NULL, NULL);
+	walk_state = acpi_ds_create_walk_state (0, NULL, NULL, NULL);
 	if (!walk_state) {
 		return_ACPI_STATUS (AE_NO_MEMORY);
 	}
 
-	status = acpi_ds_init_aml_walk (walk_state, op, NULL, extra_desc->extra.aml_start,
-			  extra_desc->extra.aml_length, NULL, NULL, 1);
+	status = acpi_ds_init_aml_walk (walk_state, op, NULL, aml_start,
+			  aml_length, NULL, NULL, 1);
 	if (ACPI_FAILURE (status)) {
-		/* TBD: delete walk state */
+		acpi_ds_delete_walk_state (walk_state);
 		return_ACPI_STATUS (status);
 	}
 
-	/* TBD: No Walk flags?? */
-
-	walk_state->parse_flags = 0;
+	walk_state->parse_flags = ACPI_PARSE_DEFERRED_OP;
 
-	/* Pass1: Parse the entire Buffer_field declaration */
+	/* Pass1: Parse the entire declaration */
 
 	status = acpi_ps_parse_aml (walk_state);
 	if (ACPI_FAILURE (status)) {
@@ -129,204 +121,250 @@
 		return_ACPI_STATUS (status);
 	}
 
-	/* Get and init the actual Field_unit Op created above */
-
-	field_op = op->value.arg;
-	op->node = node;
-
+	/* Get and init the Op created above */
 
-	field_op = op->value.arg;
-	field_op->node = node;
+	arg = op->common.value.arg;
+	op->common.node = node;
+	arg->common.node = node;
 	acpi_ps_delete_parse_tree (op);
 
-	/* Evaluate the address and length arguments for the Op_region */
+	/* Evaluate the address and length arguments for the Buffer Field */
 
-	op = acpi_ps_alloc_op (AML_SCOPE_OP);
+	op = acpi_ps_alloc_op (AML_INT_EVAL_SUBTREE_OP);
 	if (!op) {
-		return (AE_NO_MEMORY);
+		return_ACPI_STATUS (AE_NO_MEMORY);
 	}
 
-	op->node = acpi_ns_get_parent_object (node);
+	op->common.node = scope_node;
 
 	/* Create and initialize a new parser state */
 
-	walk_state = acpi_ds_create_walk_state (TABLE_ID_DSDT,
-			   NULL, NULL, NULL);
+	walk_state = acpi_ds_create_walk_state (0, NULL, NULL, NULL);
 	if (!walk_state) {
 		return_ACPI_STATUS (AE_NO_MEMORY);
 	}
 
-	status = acpi_ds_init_aml_walk (walk_state, op, NULL, extra_desc->extra.aml_start,
-			  extra_desc->extra.aml_length, NULL, NULL, 3);
+	status = acpi_ds_init_aml_walk (walk_state, op, NULL, aml_start,
+			  aml_length, NULL, NULL, 3);
 	if (ACPI_FAILURE (status)) {
-		/* TBD: delete walk state */
+		acpi_ds_delete_walk_state (walk_state);
 		return_ACPI_STATUS (status);
 	}
 
 	status = acpi_ps_parse_aml (walk_state);
 	acpi_ps_delete_parse_tree (op);
-
-	/*
-	 * The pseudo-method object is no longer needed since the region is
-	 * now initialized
-	 */
-	acpi_ut_remove_reference (obj_desc->buffer_field.extra);
-	obj_desc->buffer_field.extra = NULL;
-
 	return_ACPI_STATUS (status);
 }
 
 
 /*****************************************************************************
  *
- * FUNCTION:    Acpi_ds_get_region_arguments
+ * FUNCTION:    acpi_ds_get_buffer_field_arguments
  *
- * PARAMETERS:  Obj_desc        - A valid region object
+ * PARAMETERS:  obj_desc        - A valid buffer_field object
  *
  * RETURN:      Status.
  *
- * DESCRIPTION: Get region address and length.  This implements the late
- *              evaluation of these region attributes.
+ * DESCRIPTION: Get buffer_field Buffer and Index. This implements the late
+ *              evaluation of these field attributes.
  *
  ****************************************************************************/
 
 acpi_status
-acpi_ds_get_region_arguments (
-	acpi_operand_object     *obj_desc)
+acpi_ds_get_buffer_field_arguments (
+	union acpi_operand_object       *obj_desc)
 {
-	acpi_operand_object     *extra_desc = NULL;
-	acpi_namespace_node     *node;
-	acpi_parse_object       *op;
-	acpi_parse_object       *region_op;
-	acpi_status             status;
-	acpi_table_desc         *table_desc;
-	acpi_walk_state         *walk_state;
+	union acpi_operand_object       *extra_desc;
+	struct acpi_namespace_node      *node;
+	acpi_status                     status;
 
 
-	FUNCTION_TRACE_PTR ("Ds_get_region_arguments", obj_desc);
+	ACPI_FUNCTION_TRACE_PTR ("ds_get_buffer_field_arguments", obj_desc);
 
 
-	if (obj_desc->region.flags & AOPOBJ_DATA_VALID) {
+	if (obj_desc->common.flags & AOPOBJ_DATA_VALID) {
 		return_ACPI_STATUS (AE_OK);
 	}
 
+	/* Get the AML pointer (method object) and buffer_field node */
 
-	/* Get the AML pointer (method object) and region node */
+	extra_desc = acpi_ns_get_secondary_object (obj_desc);
+	node = obj_desc->buffer_field.node;
 
-	extra_desc = obj_desc->region.extra;
-	node = obj_desc->region.node;
+	ACPI_DEBUG_EXEC(acpi_ut_display_init_pathname (ACPI_TYPE_BUFFER_FIELD, node, NULL));
+	ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[%4.4s] buffer_field JIT Init\n",
+		node->name.ascii));
 
-	DEBUG_EXEC(acpi_ut_display_init_pathname (node, " [Operation Region]"));
+	/* Execute the AML code for the term_arg arguments */
 
-	ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[%4.4s] Op_region Init at AML %p\n",
-		(char*)&node->name, extra_desc->extra.aml_start));
+	status = acpi_ds_execute_arguments (node, acpi_ns_get_parent_node (node),
+			 extra_desc->extra.aml_length, extra_desc->extra.aml_start);
+	return_ACPI_STATUS (status);
+}
 
-	/*
-	 * Allocate a new parser op to be the root of the parsed
-	 * Op_region tree
-	 */
-	op = acpi_ps_alloc_op (AML_SCOPE_OP);
-	if (!op) {
-		return (AE_NO_MEMORY);
-	}
 
-	/* Save the Node for use in Acpi_ps_parse_aml */
+/*****************************************************************************
+ *
+ * FUNCTION:    acpi_ds_get_buffer_arguments
+ *
+ * PARAMETERS:  obj_desc        - A valid Bufferobject
+ *
+ * RETURN:      Status.
+ *
+ * DESCRIPTION: Get Buffer length and initializer byte list.  This implements
+ *              the late evaluation of these attributes.
+ *
+ ****************************************************************************/
 
-	op->node = acpi_ns_get_parent_object (node);
+acpi_status
+acpi_ds_get_buffer_arguments (
+	union acpi_operand_object       *obj_desc)
+{
+	struct acpi_namespace_node      *node;
+	acpi_status                     status;
 
-	/* Get a handle to the parent ACPI table */
 
-	status = acpi_tb_handle_to_object (node->owner_id, &table_desc);
-	if (ACPI_FAILURE (status)) {
-		return_ACPI_STATUS (status);
-	}
+	ACPI_FUNCTION_TRACE_PTR ("ds_get_buffer_arguments", obj_desc);
 
-	/* Create and initialize a new parser state */
 
-	walk_state = acpi_ds_create_walk_state (TABLE_ID_DSDT,
-			   op, NULL, NULL);
-	if (!walk_state) {
-		return_ACPI_STATUS (AE_NO_MEMORY);
+	if (obj_desc->common.flags & AOPOBJ_DATA_VALID) {
+		return_ACPI_STATUS (AE_OK);
 	}
 
-	status = acpi_ds_init_aml_walk (walk_state, op, NULL, extra_desc->extra.aml_start,
-			  extra_desc->extra.aml_length, NULL, NULL, 1);
-	if (ACPI_FAILURE (status)) {
-		/* TBD: delete walk state */
-		return_ACPI_STATUS (status);
+	/* Get the Buffer node */
+
+	node = obj_desc->buffer.node;
+	if (!node) {
+		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+				"No pointer back to NS node in buffer %p\n", obj_desc));
+		return_ACPI_STATUS (AE_AML_INTERNAL);
 	}
 
-	/* TBD: No Walk flags?? */
+	ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Buffer JIT Init\n"));
 
-	walk_state->parse_flags = 0;
+	/* Execute the AML code for the term_arg arguments */
 
-	/* Parse the entire Op_region declaration, creating a parse tree */
+	status = acpi_ds_execute_arguments (node, node,
+			 obj_desc->buffer.aml_length, obj_desc->buffer.aml_start);
+	return_ACPI_STATUS (status);
+}
 
-	status = acpi_ps_parse_aml (walk_state);
-	if (ACPI_FAILURE (status)) {
-		acpi_ps_delete_parse_tree (op);
-		return_ACPI_STATUS (status);
-	}
 
-	/* Get and init the actual Region_op created above */
+/*****************************************************************************
+ *
+ * FUNCTION:    acpi_ds_get_package_arguments
+ *
+ * PARAMETERS:  obj_desc        - A valid Packageobject
+ *
+ * RETURN:      Status.
+ *
+ * DESCRIPTION: Get Package length and initializer byte list.  This implements
+ *              the late evaluation of these attributes.
+ *
+ ****************************************************************************/
 
-	region_op = op->value.arg;
-	op->node = node;
+acpi_status
+acpi_ds_get_package_arguments (
+	union acpi_operand_object       *obj_desc)
+{
+	struct acpi_namespace_node      *node;
+	acpi_status                     status;
 
 
-	region_op = op->value.arg;
-	region_op->node = node;
-	acpi_ps_delete_parse_tree (op);
+	ACPI_FUNCTION_TRACE_PTR ("ds_get_package_arguments", obj_desc);
 
-	/* Evaluate the address and length arguments for the Op_region */
 
-	op = acpi_ps_alloc_op (AML_SCOPE_OP);
-	if (!op) {
-		return (AE_NO_MEMORY);
+	if (obj_desc->common.flags & AOPOBJ_DATA_VALID) {
+		return_ACPI_STATUS (AE_OK);
 	}
 
-	op->node = acpi_ns_get_parent_object (node);
+	/* Get the Package node */
 
-	/* Create and initialize a new parser state */
+	node = obj_desc->package.node;
+	if (!node) {
+		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+				"No pointer back to NS node in package %p\n", obj_desc));
+		return_ACPI_STATUS (AE_AML_INTERNAL);
+	}
 
-	walk_state = acpi_ds_create_walk_state (TABLE_ID_DSDT,
-			   op, NULL, NULL);
-	if (!walk_state) {
-		return_ACPI_STATUS (AE_NO_MEMORY);
+	ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Package JIT Init\n"));
+
+	/* Execute the AML code for the term_arg arguments */
+
+	status = acpi_ds_execute_arguments (node, node,
+			 obj_desc->package.aml_length, obj_desc->package.aml_start);
+	return_ACPI_STATUS (status);
+}
+
+
+/*****************************************************************************
+ *
+ * FUNCTION:    acpi_ds_get_region_arguments
+ *
+ * PARAMETERS:  obj_desc        - A valid region object
+ *
+ * RETURN:      Status.
+ *
+ * DESCRIPTION: Get region address and length.  This implements the late
+ *              evaluation of these region attributes.
+ *
+ ****************************************************************************/
+
+acpi_status
+acpi_ds_get_region_arguments (
+	union acpi_operand_object       *obj_desc)
+{
+	struct acpi_namespace_node      *node;
+	acpi_status                     status;
+	union acpi_operand_object       *extra_desc;
+
+
+	ACPI_FUNCTION_TRACE_PTR ("ds_get_region_arguments", obj_desc);
+
+
+	if (obj_desc->region.flags & AOPOBJ_DATA_VALID) {
+		return_ACPI_STATUS (AE_OK);
 	}
 
-	status = acpi_ds_init_aml_walk (walk_state, op, NULL, extra_desc->extra.aml_start,
-			  extra_desc->extra.aml_length, NULL, NULL, 3);
-	if (ACPI_FAILURE (status)) {
-		/* TBD: delete walk state */
-		return_ACPI_STATUS (status);
+	extra_desc = acpi_ns_get_secondary_object (obj_desc);
+	if (!extra_desc) {
+		return_ACPI_STATUS (AE_NOT_EXIST);
 	}
 
-	status = acpi_ps_parse_aml (walk_state);
-	acpi_ps_delete_parse_tree (op);
+	/* Get the Region node */
+
+	node = obj_desc->region.node;
 
+	ACPI_DEBUG_EXEC(acpi_ut_display_init_pathname (ACPI_TYPE_REGION, node, NULL));
+
+	ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[%4.4s] op_region Init at AML %p\n",
+		node->name.ascii, extra_desc->extra.aml_start));
+
+
+	status = acpi_ds_execute_arguments (node, acpi_ns_get_parent_node (node),
+			 extra_desc->extra.aml_length, extra_desc->extra.aml_start);
 	return_ACPI_STATUS (status);
 }
 
 
 /*****************************************************************************
  *
- * FUNCTION:    Acpi_ds_initialize_region
+ * FUNCTION:    acpi_ds_initialize_region
  *
  * PARAMETERS:  Op              - A valid region Op object
  *
  * RETURN:      Status
  *
- * DESCRIPTION:
+ * DESCRIPTION: Front end to ev_initialize_region
  *
  ****************************************************************************/
 
 acpi_status
 acpi_ds_initialize_region (
-	acpi_handle             obj_handle)
+	acpi_handle                     obj_handle)
 {
-	acpi_operand_object     *obj_desc;
-	acpi_status             status;
+	union acpi_operand_object       *obj_desc;
+	acpi_status                     status;
 
 
 	obj_desc = acpi_ns_get_attached_object (obj_handle);
@@ -334,301 +372,276 @@
 	/* Namespace is NOT locked */
 
 	status = acpi_ev_initialize_region (obj_desc, FALSE);
-
 	return (status);
 }
 
 
 /*****************************************************************************
  *
- * FUNCTION:    Acpi_ds_eval_buffer_field_operands
+ * FUNCTION:    acpi_ds_init_buffer_field
  *
- * PARAMETERS:  Op              - A valid Buffer_field Op object
+ * PARAMETERS:  aml_opcode      - create_xxx_field
+ *              obj_desc        - buffer_field object
+ *              buffer_desc     - Host Buffer
+ *              offset_desc     - Offset into buffer
+ *              Length          - Length of field (CREATE_FIELD_OP only)
+ *              Result          - Where to store the result
  *
  * RETURN:      Status
  *
- * DESCRIPTION: Get Buffer_field Buffer and Index
- *              Called from Acpi_ds_exec_end_op during Buffer_field parse tree walk
- *
- * ACPI SPECIFICATION REFERENCES:
- *  Each of the Buffer Field opcodes is defined as specified in in-line
- *  comments below. For each one, use the following definitions.
- *
- *  Def_bit_field   :=  Bit_field_op    Src_buf Bit_idx Destination
- *  Def_byte_field  :=  Byte_field_op   Src_buf Byte_idx Destination
- *  Def_create_field := Create_field_op Src_buf Bit_idx Num_bits Name_string
- *  Def_dWord_field :=  DWord_field_op  Src_buf Byte_idx Destination
- *  Def_word_field  :=  Word_field_op   Src_buf Byte_idx Destination
- *  Bit_index       :=  Term_arg=>Integer
- *  Byte_index      :=  Term_arg=>Integer
- *  Destination     :=  Name_string
- *  Num_bits        :=  Term_arg=>Integer
- *  Source_buf      :=  Term_arg=>Buffer
+ * DESCRIPTION: Perform actual initialization of a buffer field
  *
  ****************************************************************************/
 
 acpi_status
-acpi_ds_eval_buffer_field_operands (
-	acpi_walk_state         *walk_state,
-	acpi_parse_object       *op)
+acpi_ds_init_buffer_field (
+	u16                             aml_opcode,
+	union acpi_operand_object       *obj_desc,
+	union acpi_operand_object       *buffer_desc,
+	union acpi_operand_object       *offset_desc,
+	union acpi_operand_object       *length_desc,
+	union acpi_operand_object       *result_desc)
 {
-	acpi_status             status;
-	acpi_operand_object     *obj_desc;
-	acpi_namespace_node     *node;
-	acpi_parse_object       *next_op;
-	u32                     offset;
-	u32                     bit_offset;
-	u32                     bit_count;
-	u8                      field_flags;
-	acpi_operand_object     *res_desc = NULL;
-	acpi_operand_object     *cnt_desc = NULL;
-	acpi_operand_object     *off_desc = NULL;
-	acpi_operand_object     *src_desc = NULL;
-
-
-	FUNCTION_TRACE_PTR ("Ds_eval_buffer_field_operands", op);
-
-
-	/*
-	 * This is where we evaluate the address and length fields of the
-	 * Create_xxx_field declaration
-	 */
-	node =  op->node;
-
-	/* Next_op points to the op that holds the Buffer */
-
-	next_op = op->value.arg;
-
-	/* Acpi_evaluate/create the address and length operands */
-
-	status = acpi_ds_create_operands (walk_state, next_op);
-	if (ACPI_FAILURE (status)) {
-		return_ACPI_STATUS (status);
-	}
+	u32                             offset;
+	u32                             bit_offset;
+	u32                             bit_count;
+	u8                              field_flags;
+	acpi_status                     status;
 
-	obj_desc = acpi_ns_get_attached_object (node);
-	if (!obj_desc) {
-		return_ACPI_STATUS (AE_NOT_EXIST);
-	}
 
+	ACPI_FUNCTION_TRACE_PTR ("ds_init_buffer_field", obj_desc);
 
-	/* Resolve the operands */
 
-	status = acpi_ex_resolve_operands (op->opcode, WALK_OPERANDS, walk_state);
-	DUMP_OPERANDS (WALK_OPERANDS, IMODE_EXECUTE, acpi_ps_get_opcode_name (op->opcode),
-			  walk_state->num_operands, "after Acpi_ex_resolve_operands");
+	/* Host object must be a Buffer */
 
-	if (ACPI_FAILURE (status)) {
-		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "(%s) bad operand(s) (%X)\n",
-			acpi_ps_get_opcode_name (op->opcode), status));
+	if (ACPI_GET_OBJECT_TYPE (buffer_desc) != ACPI_TYPE_BUFFER) {
+		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+			"Target of Create Field is not a Buffer object - %s\n",
+			acpi_ut_get_object_type_name (buffer_desc)));
 
+		status = AE_AML_OPERAND_TYPE;
 		goto cleanup;
 	}
 
-	/* Get the operands */
-
-	if (AML_CREATE_FIELD_OP == op->opcode) {
-		res_desc = walk_state->operands[3];
-		cnt_desc = walk_state->operands[2];
-	}
-	else {
-		res_desc = walk_state->operands[2];
-	}
-
-	off_desc = walk_state->operands[1];
-	src_desc = walk_state->operands[0];
-
-
-	offset = (u32) off_desc->integer.value;
-
 	/*
-	 * If Res_desc is a Name, it will be a direct name pointer after
-	 * Acpi_ex_resolve_operands()
+	 * The last parameter to all of these opcodes (result_desc) started
+	 * out as a name_string, and should therefore now be a NS node
+	 * after resolution in acpi_ex_resolve_operands().
 	 */
-	if (!VALID_DESCRIPTOR_TYPE (res_desc, ACPI_DESC_TYPE_NAMED)) {
-		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "(%s) destination must be a Node\n",
-			acpi_ps_get_opcode_name (op->opcode)));
+	if (ACPI_GET_DESCRIPTOR_TYPE (result_desc) != ACPI_DESC_TYPE_NAMED) {
+		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "(%s) destination must be a NS Node\n",
+			acpi_ps_get_opcode_name (aml_opcode)));
 
 		status = AE_AML_OPERAND_TYPE;
 		goto cleanup;
 	}
 
+	offset = (u32) offset_desc->integer.value;
+
 	/*
 	 * Setup the Bit offsets and counts, according to the opcode
 	 */
-	switch (op->opcode) {
-
-	/* Def_create_field */
-
+	switch (aml_opcode) {
 	case AML_CREATE_FIELD_OP:
 
 		/* Offset is in bits, count is in bits */
 
-		bit_offset  = offset;
-		bit_count   = (u32) cnt_desc->integer.value;
-		field_flags = ACCESS_BYTE_ACC;
+		bit_offset = offset;
+		bit_count  = (u32) length_desc->integer.value;
+		field_flags = AML_FIELD_ACCESS_BYTE;
 		break;
 
-
-	/* Def_create_bit_field */
-
 	case AML_CREATE_BIT_FIELD_OP:
 
 		/* Offset is in bits, Field is one bit */
 
-		bit_offset  = offset;
-		bit_count   = 1;
-		field_flags = ACCESS_BYTE_ACC;
+		bit_offset = offset;
+		bit_count  = 1;
+		field_flags = AML_FIELD_ACCESS_BYTE;
 		break;
 
-
-	/* Def_create_byte_field */
-
 	case AML_CREATE_BYTE_FIELD_OP:
 
 		/* Offset is in bytes, field is one byte */
 
-		bit_offset  = 8 * offset;
-		bit_count   = 8;
-		field_flags = ACCESS_BYTE_ACC;
+		bit_offset = 8 * offset;
+		bit_count  = 8;
+		field_flags = AML_FIELD_ACCESS_BYTE;
 		break;
 
-
-	/* Def_create_word_field */
-
 	case AML_CREATE_WORD_FIELD_OP:
 
 		/* Offset is in bytes, field is one word */
 
-		bit_offset  = 8 * offset;
-		bit_count   = 16;
-		field_flags = ACCESS_WORD_ACC;
+		bit_offset = 8 * offset;
+		bit_count  = 16;
+		field_flags = AML_FIELD_ACCESS_WORD;
 		break;
 
-
-	/* Def_create_dWord_field */
-
 	case AML_CREATE_DWORD_FIELD_OP:
 
 		/* Offset is in bytes, field is one dword */
 
-		bit_offset  = 8 * offset;
-		bit_count   = 32;
-		field_flags = ACCESS_DWORD_ACC;
+		bit_offset = 8 * offset;
+		bit_count  = 32;
+		field_flags = AML_FIELD_ACCESS_DWORD;
 		break;
 
-
-	/* Def_create_qWord_field */
-
 	case AML_CREATE_QWORD_FIELD_OP:
 
 		/* Offset is in bytes, field is one qword */
 
-		bit_offset  = 8 * offset;
-		bit_count   = 64;
-		field_flags = ACCESS_QWORD_ACC;
+		bit_offset = 8 * offset;
+		bit_count  = 64;
+		field_flags = AML_FIELD_ACCESS_QWORD;
 		break;
 
-
 	default:
 
 		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
-			"Internal error - unknown field creation opcode %02x\n",
-			op->opcode));
+			"Unknown field creation opcode %02x\n",
+			aml_opcode));
 		status = AE_AML_BAD_OPCODE;
 		goto cleanup;
 	}
 
 
+	/* Entire field must fit within the current length of the buffer */
+
+	if ((bit_offset + bit_count) >
+		(8 * (u32) buffer_desc->buffer.length)) {
+		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+			"Field size %d exceeds Buffer size %d (bits)\n",
+			 bit_offset + bit_count, 8 * (u32) buffer_desc->buffer.length));
+		status = AE_AML_BUFFER_LIMIT;
+		goto cleanup;
+	}
+
 	/*
-	 * Setup field according to the object type
+	 * Initialize areas of the field object that are common to all fields
+	 * For field_flags, use LOCK_RULE = 0 (NO_LOCK), UPDATE_RULE = 0 (UPDATE_PRESERVE)
 	 */
-	switch (src_desc->common.type) {
+	status = acpi_ex_prep_common_field_object (obj_desc, field_flags, 0,
+			  bit_offset, bit_count);
+	if (ACPI_FAILURE (status)) {
+		goto cleanup;
+	}
 
-	/* Source_buff :=  Term_arg=>Buffer */
+	obj_desc->buffer_field.buffer_obj = buffer_desc;
 
-	case ACPI_TYPE_BUFFER:
+	/* Reference count for buffer_desc inherits obj_desc count */
 
-		if ((bit_offset + bit_count) >
-			(8 * (u32) src_desc->buffer.length)) {
-			ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
-				"Field size %d exceeds Buffer size %d (bits)\n",
-				 bit_offset + bit_count, 8 * (u32) src_desc->buffer.length));
-			status = AE_AML_BUFFER_LIMIT;
-			goto cleanup;
-		}
+	buffer_desc->common.reference_count = (u16) (buffer_desc->common.reference_count +
+			  obj_desc->common.reference_count);
 
 
-		/*
-		 * Initialize areas of the field object that are common to all fields
-		 * For Field_flags, use LOCK_RULE = 0 (NO_LOCK), UPDATE_RULE = 0 (UPDATE_PRESERVE)
-		 */
-		status = acpi_ex_prep_common_field_object (obj_desc, field_flags,
-				  bit_offset, bit_count);
-		if (ACPI_FAILURE (status)) {
-			return_ACPI_STATUS (status);
-		}
+cleanup:
 
-		obj_desc->buffer_field.buffer_obj = src_desc;
+	/* Always delete the operands */
 
-		/* Reference count for Src_desc inherits Obj_desc count */
+	acpi_ut_remove_reference (offset_desc);
+	acpi_ut_remove_reference (buffer_desc);
 
-		src_desc->common.reference_count = (u16) (src_desc->common.reference_count +
-				  obj_desc->common.reference_count);
+	if (aml_opcode == AML_CREATE_FIELD_OP) {
+		acpi_ut_remove_reference (length_desc);
+	}
 
-		break;
+	/* On failure, delete the result descriptor */
 
+	if (ACPI_FAILURE (status)) {
+		acpi_ut_remove_reference (result_desc); /* Result descriptor */
+	}
+	else {
+		/* Now the address and length are valid for this buffer_field */
 
-	/* Improper object type */
+		obj_desc->buffer_field.flags |= AOPOBJ_DATA_VALID;
+	}
 
-	default:
+	return_ACPI_STATUS (status);
+}
 
-		if ((src_desc->common.type > (u8) INTERNAL_TYPE_REFERENCE) || !acpi_ut_valid_object_type (src_desc->common.type)) /* TBD: This line MUST be a single line until Acpi_src can handle it (block deletion) */ {
-			ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
-				"Tried to create field in invalid object type %X\n",
-				src_desc->common.type));
-		}
 
-		else {
-			ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
-				"Tried to create field in improper object type - %s\n",
-				acpi_ut_get_type_name (src_desc->common.type)));
-		}
+/*****************************************************************************
+ *
+ * FUNCTION:    acpi_ds_eval_buffer_field_operands
+ *
+ * PARAMETERS:  walk_state      - Current walk
+ *              Op              - A valid buffer_field Op object
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Get buffer_field Buffer and Index
+ *              Called from acpi_ds_exec_end_op during buffer_field parse tree walk
+ *
+ ****************************************************************************/
 
-		status = AE_AML_OPERAND_TYPE;
-		goto cleanup;
-	}
+acpi_status
+acpi_ds_eval_buffer_field_operands (
+	struct acpi_walk_state          *walk_state,
+	union acpi_parse_object         *op)
+{
+	acpi_status                     status;
+	union acpi_operand_object       *obj_desc;
+	struct acpi_namespace_node      *node;
+	union acpi_parse_object         *next_op;
 
 
-	if (AML_CREATE_FIELD_OP == op->opcode) {
-		/* Delete object descriptor unique to Create_field */
+	ACPI_FUNCTION_TRACE_PTR ("ds_eval_buffer_field_operands", op);
 
-		acpi_ut_remove_reference (cnt_desc);
-		cnt_desc = NULL;
-	}
 
+	/*
+	 * This is where we evaluate the address and length fields of the
+	 * create_xxx_field declaration
+	 */
+	node =  op->common.node;
+
+	/* next_op points to the op that holds the Buffer */
 
-cleanup:
+	next_op = op->common.value.arg;
 
-	/* Always delete the operands */
+	/* Evaluate/create the address and length operands */
 
-	acpi_ut_remove_reference (off_desc);
-	acpi_ut_remove_reference (src_desc);
+	status = acpi_ds_create_operands (walk_state, next_op);
+	if (ACPI_FAILURE (status)) {
+		return_ACPI_STATUS (status);
+	}
 
-	if (AML_CREATE_FIELD_OP == op->opcode) {
-		acpi_ut_remove_reference (cnt_desc);
+	obj_desc = acpi_ns_get_attached_object (node);
+	if (!obj_desc) {
+		return_ACPI_STATUS (AE_NOT_EXIST);
 	}
 
-	/* On failure, delete the result descriptor */
+	/* Resolve the operands */
+
+	status = acpi_ex_resolve_operands (op->common.aml_opcode,
+			  ACPI_WALK_OPERANDS, walk_state);
+
+	ACPI_DUMP_OPERANDS (ACPI_WALK_OPERANDS, ACPI_IMODE_EXECUTE,
+			  acpi_ps_get_opcode_name (op->common.aml_opcode),
+			  walk_state->num_operands, "after acpi_ex_resolve_operands");
 
 	if (ACPI_FAILURE (status)) {
-		acpi_ut_remove_reference (res_desc); /* Result descriptor */
+		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "(%s) bad operand(s) (%X)\n",
+			acpi_ps_get_opcode_name (op->common.aml_opcode), status));
+
+		return_ACPI_STATUS (status);
 	}
 
+	/* Initialize the Buffer Field */
+
+	if (op->common.aml_opcode == AML_CREATE_FIELD_OP) {
+		/* NOTE: Slightly different operands for this opcode */
+
+		status = acpi_ds_init_buffer_field (op->common.aml_opcode, obj_desc,
+				 walk_state->operands[0], walk_state->operands[1],
+				 walk_state->operands[2], walk_state->operands[3]);
+	}
 	else {
-		/* Now the address and length are valid for this Buffer_field */
+		/* All other, create_xxx_field opcodes */
 
-		obj_desc->buffer_field.flags |= AOPOBJ_DATA_VALID;
+		status = acpi_ds_init_buffer_field (op->common.aml_opcode, obj_desc,
+				 walk_state->operands[0], walk_state->operands[1],
+						  NULL, walk_state->operands[2]);
 	}
 
 	return_ACPI_STATUS (status);
@@ -637,46 +650,47 @@
 
 /*****************************************************************************
  *
- * FUNCTION:    Acpi_ds_eval_region_operands
+ * FUNCTION:    acpi_ds_eval_region_operands
  *
- * PARAMETERS:  Op              - A valid region Op object
+ * PARAMETERS:  walk_state      - Current walk
+ *              Op              - A valid region Op object
  *
  * RETURN:      Status
  *
  * DESCRIPTION: Get region address and length
- *              Called from Acpi_ds_exec_end_op during Op_region parse tree walk
+ *              Called from acpi_ds_exec_end_op during op_region parse tree walk
  *
  ****************************************************************************/
 
 acpi_status
 acpi_ds_eval_region_operands (
-	acpi_walk_state         *walk_state,
-	acpi_parse_object       *op)
+	struct acpi_walk_state          *walk_state,
+	union acpi_parse_object         *op)
 {
-	acpi_status             status;
-	acpi_operand_object     *obj_desc;
-	acpi_operand_object     *operand_desc;
-	acpi_namespace_node     *node;
-	acpi_parse_object       *next_op;
+	acpi_status                     status;
+	union acpi_operand_object       *obj_desc;
+	union acpi_operand_object       *operand_desc;
+	struct acpi_namespace_node      *node;
+	union acpi_parse_object         *next_op;
 
 
-	FUNCTION_TRACE_PTR ("Ds_eval_region_operands", op);
+	ACPI_FUNCTION_TRACE_PTR ("ds_eval_region_operands", op);
 
 
 	/*
-	 * This is where we evaluate the address and length fields of the Op_region declaration
+	 * This is where we evaluate the address and length fields of the op_region declaration
 	 */
-	node =  op->node;
+	node =  op->common.node;
 
-	/* Next_op points to the op that holds the Space_iD */
+	/* next_op points to the op that holds the space_iD */
 
-	next_op = op->value.arg;
+	next_op = op->common.value.arg;
 
-	/* Next_op points to address op */
+	/* next_op points to address op */
 
-	next_op = next_op->next;
+	next_op = next_op->common.next;
 
-	/* Acpi_evaluate/create the address and length operands */
+	/* Evaluate/create the address and length operands */
 
 	status = acpi_ds_create_operands (walk_state, next_op);
 	if (ACPI_FAILURE (status)) {
@@ -685,15 +699,14 @@
 
 	/* Resolve the length and address operands to numbers */
 
-	status = acpi_ex_resolve_operands (op->opcode, WALK_OPERANDS, walk_state);
+	status = acpi_ex_resolve_operands (op->common.aml_opcode, ACPI_WALK_OPERANDS, walk_state);
 	if (ACPI_FAILURE (status)) {
 		return_ACPI_STATUS (status);
 	}
 
-	DUMP_OPERANDS (WALK_OPERANDS, IMODE_EXECUTE,
-			  acpi_ps_get_opcode_name (op->opcode),
-			  1, "after Acpi_ex_resolve_operands");
-
+	ACPI_DUMP_OPERANDS (ACPI_WALK_OPERANDS, ACPI_IMODE_EXECUTE,
+			  acpi_ps_get_opcode_name (op->common.aml_opcode),
+			  1, "after acpi_ex_resolve_operands");
 
 	obj_desc = acpi_ns_get_attached_object (node);
 	if (!obj_desc) {
@@ -715,12 +728,12 @@
 	 */
 	operand_desc = walk_state->operands[walk_state->num_operands - 2];
 
-	obj_desc->region.address = (ACPI_PHYSICAL_ADDRESS) operand_desc->integer.value;
+	obj_desc->region.address = (acpi_physical_address) operand_desc->integer.value;
 	acpi_ut_remove_reference (operand_desc);
 
-
-	ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Rgn_obj %p Addr %8.8X%8.8X Len %X\n",
-		obj_desc, HIDWORD(obj_desc->region.address), LODWORD(obj_desc->region.address),
+	ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "rgn_obj %p Addr %8.8X%8.8X Len %X\n",
+		obj_desc,
+		ACPI_HIDWORD (obj_desc->region.address), ACPI_LODWORD (obj_desc->region.address),
 		obj_desc->region.length));
 
 	/* Now the address and length are valid for this opregion */
@@ -731,11 +744,106 @@
 }
 
 
+/*****************************************************************************
+ *
+ * FUNCTION:    acpi_ds_eval_data_object_operands
+ *
+ * PARAMETERS:  walk_state      - Current walk
+ *              Op              - A valid data_object Op object
+ *              obj_desc        - data_object
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Get the operands and complete the following data objec types:
+ *              Buffer
+ *              Package
+ *
+ ****************************************************************************/
+
+acpi_status
+acpi_ds_eval_data_object_operands (
+	struct acpi_walk_state          *walk_state,
+	union acpi_parse_object         *op,
+	union acpi_operand_object       *obj_desc)
+{
+	acpi_status                     status;
+	union acpi_operand_object       *arg_desc;
+	u32                             length;
+
+
+	ACPI_FUNCTION_TRACE ("ds_eval_data_object_operands");
+
+
+	/* The first operand (for all of these data objects) is the length */
+
+	status = acpi_ds_create_operand (walk_state, op->common.value.arg, 1);
+	if (ACPI_FAILURE (status)) {
+		return_ACPI_STATUS (status);
+	}
+
+	status = acpi_ex_resolve_operands (walk_state->opcode,
+			  &(walk_state->operands [walk_state->num_operands -1]),
+			  walk_state);
+	if (ACPI_FAILURE (status)) {
+		return_ACPI_STATUS (status);
+	}
+
+	/* Extract length operand */
+
+	arg_desc = walk_state->operands [walk_state->num_operands - 1];
+	length = (u32) arg_desc->integer.value;
+
+	/* Cleanup for length operand */
+
+	status = acpi_ds_obj_stack_pop (1, walk_state);
+	if (ACPI_FAILURE (status)) {
+		return_ACPI_STATUS (status);
+	}
+
+	acpi_ut_remove_reference (arg_desc);
+
+	/*
+	 * Create the actual data object
+	 */
+	switch (op->common.aml_opcode) {
+	case AML_BUFFER_OP:
+
+		status = acpi_ds_build_internal_buffer_obj (walk_state, op, length, &obj_desc);
+		break;
+
+	case AML_PACKAGE_OP:
+	case AML_VAR_PACKAGE_OP:
+
+		status = acpi_ds_build_internal_package_obj (walk_state, op, length, &obj_desc);
+		break;
+
+	default:
+		return_ACPI_STATUS (AE_AML_BAD_OPCODE);
+	}
+
+	if (ACPI_SUCCESS (status)) {
+		/*
+		 * Return the object in the walk_state, unless the parent is a package --
+		 * in this case, the return object will be stored in the parse tree
+		 * for the package.
+		 */
+		if ((!op->common.parent) ||
+			((op->common.parent->common.aml_opcode != AML_PACKAGE_OP) &&
+			 (op->common.parent->common.aml_opcode != AML_VAR_PACKAGE_OP) &&
+			 (op->common.parent->common.aml_opcode != AML_NAME_OP))) {
+			walk_state->result_obj = obj_desc;
+		}
+	}
+
+	return_ACPI_STATUS (status);
+}
+
+
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ds_exec_begin_control_op
+ * FUNCTION:    acpi_ds_exec_begin_control_op
  *
- * PARAMETERS:  Walk_list       - The list that owns the walk stack
+ * PARAMETERS:  walk_list       - The list that owns the walk stack
  *              Op              - The control Op
  *
  * RETURN:      Status
@@ -747,20 +855,20 @@
 
 acpi_status
 acpi_ds_exec_begin_control_op (
-	acpi_walk_state         *walk_state,
-	acpi_parse_object       *op)
+	struct acpi_walk_state          *walk_state,
+	union acpi_parse_object         *op)
 {
-	acpi_status             status = AE_OK;
-	acpi_generic_state      *control_state;
+	acpi_status                     status = AE_OK;
+	union acpi_generic_state        *control_state;
 
 
-	PROC_NAME ("Ds_exec_begin_control_op");
+	ACPI_FUNCTION_NAME ("ds_exec_begin_control_op");
 
 
 	ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Op=%p Opcode=%2.2X State=%p\n", op,
-		op->opcode, walk_state));
+		op->common.aml_opcode, walk_state));
 
-	switch (op->opcode) {
+	switch (op->common.aml_opcode) {
 	case AML_IF_OP:
 	case AML_WHILE_OP:
 
@@ -774,19 +882,19 @@
 			status = AE_NO_MEMORY;
 			break;
 		}
-
-		acpi_ut_push_generic_state (&walk_state->control_state, control_state);
-
 		/*
 		 * Save a pointer to the predicate for multiple executions
 		 * of a loop
 		 */
-		walk_state->control_state->control.aml_predicate_start =
-				 walk_state->parser_state.aml - 1;
-				 /* TBD: can this be removed? */
-				 /*Acpi_ps_pkg_length_encoding_size (GET8 (Walk_state->Parser_state->Aml));*/
-		break;
+		control_state->control.aml_predicate_start = walk_state->parser_state.aml - 1;
+		control_state->control.package_end = walk_state->parser_state.pkg_end;
+		control_state->control.opcode = op->common.aml_opcode;
+
 
+		/* Push the control state on this walk's control stack */
+
+		acpi_ut_push_generic_state (&walk_state->control_state, control_state);
+		break;
 
 	case AML_ELSE_OP:
 
@@ -799,12 +907,10 @@
 
 		break;
 
-
 	case AML_RETURN_OP:
 
 		break;
 
-
 	default:
 		break;
 	}
@@ -815,9 +921,9 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ds_exec_end_control_op
+ * FUNCTION:    acpi_ds_exec_end_control_op
  *
- * PARAMETERS:  Walk_list       - The list that owns the walk stack
+ * PARAMETERS:  walk_list       - The list that owns the walk stack
  *              Op              - The control Op
  *
  * RETURN:      Status
@@ -825,22 +931,21 @@
  * DESCRIPTION: Handles all control ops encountered during control method
  *              execution.
  *
- *
  ******************************************************************************/
 
 acpi_status
 acpi_ds_exec_end_control_op (
-	acpi_walk_state         *walk_state,
-	acpi_parse_object       *op)
+	struct acpi_walk_state          *walk_state,
+	union acpi_parse_object         *op)
 {
-	acpi_status             status = AE_OK;
-	acpi_generic_state      *control_state;
+	acpi_status                     status = AE_OK;
+	union acpi_generic_state        *control_state;
 
 
-	PROC_NAME ("Ds_exec_end_control_op");
+	ACPI_FUNCTION_NAME ("ds_exec_end_control_op");
 
 
-	switch (op->opcode) {
+	switch (op->common.aml_opcode) {
 	case AML_IF_OP:
 
 		ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "[IF_OP] Op=%p\n", op));
@@ -890,17 +995,17 @@
 	case AML_RETURN_OP:
 
 		ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
-			"[RETURN_OP] Op=%p Arg=%p\n",op, op->value.arg));
+			"[RETURN_OP] Op=%p Arg=%p\n",op, op->common.value.arg));
 
 		/*
 		 * One optional operand -- the return value
 		 * It can be either an immediate operand or a result that
 		 * has been bubbled up the tree
 		 */
-		if (op->value.arg) {
+		if (op->common.value.arg) {
 			/* Return statement has an immediate operand */
 
-			status = acpi_ds_create_operands (walk_state, op->value.arg);
+			status = acpi_ds_create_operands (walk_state, op->common.value.arg);
 			if (ACPI_FAILURE (status)) {
 				return (status);
 			}
@@ -917,12 +1022,11 @@
 
 			/*
 			 * Get the return value and save as the last result
-			 * value.  This is the only place where Walk_state->Return_desc
+			 * value.  This is the only place where walk_state->return_desc
 			 * is set to anything other than zero!
 			 */
 			walk_state->return_desc = walk_state->operands[0];
 		}
-
 		else if ((walk_state->results) &&
 				 (walk_state->results->results.num_results > 0)) {
 			/*
@@ -934,18 +1038,17 @@
 			 *
 			 * Allow references created by the Index operator to return unchanged.
 			 */
-			if (VALID_DESCRIPTOR_TYPE (walk_state->results->results.obj_desc [0], ACPI_DESC_TYPE_INTERNAL) &&
-				((walk_state->results->results.obj_desc [0])->common.type == INTERNAL_TYPE_REFERENCE) &&
+			if ((ACPI_GET_DESCRIPTOR_TYPE (walk_state->results->results.obj_desc[0]) == ACPI_DESC_TYPE_OPERAND) &&
+				(ACPI_GET_OBJECT_TYPE (walk_state->results->results.obj_desc [0]) == ACPI_TYPE_LOCAL_REFERENCE) &&
 				((walk_state->results->results.obj_desc [0])->reference.opcode != AML_INDEX_OP)) {
-					status = acpi_ex_resolve_to_value (&walk_state->results->results.obj_desc [0], walk_state);
-					if (ACPI_FAILURE (status)) {
-						return (status);
-					}
+				status = acpi_ex_resolve_to_value (&walk_state->results->results.obj_desc [0], walk_state);
+				if (ACPI_FAILURE (status)) {
+					return (status);
+				}
 			}
 
 			walk_state->return_desc = walk_state->results->results.obj_desc [0];
 		}
-
 		else {
 			/* No return operand */
 
@@ -960,7 +1063,7 @@
 
 
 		ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
-			"Completed RETURN_OP State=%p, Ret_val=%p\n",
+			"Completed RETURN_OP State=%p, ret_val=%p\n",
 			walk_state, walk_state->return_desc));
 
 		/* End the control method execution right now */
@@ -979,7 +1082,7 @@
 
 		/* Call up to the OS service layer to handle this */
 
-		acpi_os_signal (ACPI_SIGNAL_BREAKPOINT, "Executed AML Breakpoint opcode");
+		status = acpi_os_signal (ACPI_SIGNAL_BREAKPOINT, "Executed AML Breakpoint opcode");
 
 		/* If and when it returns, all done. */
 
@@ -987,43 +1090,47 @@
 
 
 	case AML_BREAK_OP:
+	case AML_CONTINUE_OP: /* ACPI 2.0 */
 
-		ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
-			"Break to end of current package, Op=%p\n", op));
 
-		/* TBD: update behavior for ACPI 2.0 */
+		/* Pop and delete control states until we find a while */
 
-		/*
-		 * As per the ACPI specification:
-		 *      "The break operation causes the current package
-		 *          execution to complete"
-		 *      "Break -- Stop executing the current code package
-		 *          at this point"
-		 *
-		 * Returning AE_FALSE here will cause termination of
-		 * the current package, and execution will continue one
-		 * level up, starting with the completion of the parent Op.
-		 */
-		status = AE_CTRL_FALSE;
-		break;
+		while (walk_state->control_state &&
+				(walk_state->control_state->control.opcode != AML_WHILE_OP)) {
+			control_state = acpi_ut_pop_generic_state (&walk_state->control_state);
+			acpi_ut_delete_generic_state (control_state);
+		}
 
+		/* No while found? */
 
-	case AML_CONTINUE_OP: /* ACPI 2.0 */
+		if (!walk_state->control_state) {
+			return (AE_AML_NO_WHILE);
+		}
+
+		/* Was: walk_state->aml_last_while = walk_state->control_state->Control.aml_predicate_start; */
+
+		walk_state->aml_last_while = walk_state->control_state->control.package_end;
 
-		status = AE_NOT_IMPLEMENTED;
+		/* Return status depending on opcode */
+
+		if (op->common.aml_opcode == AML_BREAK_OP) {
+			status = AE_CTRL_BREAK;
+		}
+		else {
+			status = AE_CTRL_CONTINUE;
+		}
 		break;
 
 
 	default:
 
 		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown control opcode=%X Op=%p\n",
-			op->opcode, op));
+			op->common.aml_opcode, op));
 
 		status = AE_AML_BAD_OPCODE;
 		break;
 	}
 
-
 	return (status);
 }
 

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