xref: /openbmc/linux/drivers/acpi/acpica/dsobject.c (revision ba494beeaa69bc0fb01eb89464ad5d57d26e3901)
195b482a8SLen Brown /******************************************************************************
295b482a8SLen Brown  *
395b482a8SLen Brown  * Module Name: dsobject - Dispatcher object management routines
495b482a8SLen Brown  *
595b482a8SLen Brown  *****************************************************************************/
695b482a8SLen Brown 
795b482a8SLen Brown /*
877848130SBob Moore  * Copyright (C) 2000 - 2012, Intel Corp.
995b482a8SLen Brown  * All rights reserved.
1095b482a8SLen Brown  *
1195b482a8SLen Brown  * Redistribution and use in source and binary forms, with or without
1295b482a8SLen Brown  * modification, are permitted provided that the following conditions
1395b482a8SLen Brown  * are met:
1495b482a8SLen Brown  * 1. Redistributions of source code must retain the above copyright
1595b482a8SLen Brown  *    notice, this list of conditions, and the following disclaimer,
1695b482a8SLen Brown  *    without modification.
1795b482a8SLen Brown  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
1895b482a8SLen Brown  *    substantially similar to the "NO WARRANTY" disclaimer below
1995b482a8SLen Brown  *    ("Disclaimer") and any redistribution must be conditioned upon
2095b482a8SLen Brown  *    including a substantially similar Disclaimer requirement for further
2195b482a8SLen Brown  *    binary redistribution.
2295b482a8SLen Brown  * 3. Neither the names of the above-listed copyright holders nor the names
2395b482a8SLen Brown  *    of any contributors may be used to endorse or promote products derived
2495b482a8SLen Brown  *    from this software without specific prior written permission.
2595b482a8SLen Brown  *
2695b482a8SLen Brown  * Alternatively, this software may be distributed under the terms of the
2795b482a8SLen Brown  * GNU General Public License ("GPL") version 2 as published by the Free
2895b482a8SLen Brown  * Software Foundation.
2995b482a8SLen Brown  *
3095b482a8SLen Brown  * NO WARRANTY
3195b482a8SLen Brown  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
3295b482a8SLen Brown  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
3395b482a8SLen Brown  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
3495b482a8SLen Brown  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
3595b482a8SLen Brown  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
3695b482a8SLen Brown  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
3795b482a8SLen Brown  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
3895b482a8SLen Brown  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
3995b482a8SLen Brown  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
4095b482a8SLen Brown  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
4195b482a8SLen Brown  * POSSIBILITY OF SUCH DAMAGES.
4295b482a8SLen Brown  */
4395b482a8SLen Brown 
4495b482a8SLen Brown #include <acpi/acpi.h>
45e2f7a777SLen Brown #include "accommon.h"
46e2f7a777SLen Brown #include "acparser.h"
47e2f7a777SLen Brown #include "amlcode.h"
48e2f7a777SLen Brown #include "acdispat.h"
49e2f7a777SLen Brown #include "acnamesp.h"
50e2f7a777SLen Brown #include "acinterp.h"
5195b482a8SLen Brown 
5295b482a8SLen Brown #define _COMPONENT          ACPI_DISPATCHER
5395b482a8SLen Brown ACPI_MODULE_NAME("dsobject")
5495b482a8SLen Brown 
5595b482a8SLen Brown /* Local prototypes */
5695b482a8SLen Brown static acpi_status
5795b482a8SLen Brown acpi_ds_build_internal_object(struct acpi_walk_state *walk_state,
5895b482a8SLen Brown 			      union acpi_parse_object *op,
5995b482a8SLen Brown 			      union acpi_operand_object **obj_desc_ptr);
6095b482a8SLen Brown 
6195b482a8SLen Brown #ifndef ACPI_NO_METHOD_EXECUTION
6295b482a8SLen Brown /*******************************************************************************
6395b482a8SLen Brown  *
6495b482a8SLen Brown  * FUNCTION:    acpi_ds_build_internal_object
6595b482a8SLen Brown  *
6695b482a8SLen Brown  * PARAMETERS:  walk_state      - Current walk state
67*ba494beeSBob Moore  *              op              - Parser object to be translated
6895b482a8SLen Brown  *              obj_desc_ptr    - Where the ACPI internal object is returned
6995b482a8SLen Brown  *
7095b482a8SLen Brown  * RETURN:      Status
7195b482a8SLen Brown  *
7295b482a8SLen Brown  * DESCRIPTION: Translate a parser Op object to the equivalent namespace object
7395b482a8SLen Brown  *              Simple objects are any objects other than a package object!
7495b482a8SLen Brown  *
7595b482a8SLen Brown  ******************************************************************************/
7695b482a8SLen Brown 
7795b482a8SLen Brown static acpi_status
7895b482a8SLen Brown acpi_ds_build_internal_object(struct acpi_walk_state *walk_state,
7995b482a8SLen Brown 			      union acpi_parse_object *op,
8095b482a8SLen Brown 			      union acpi_operand_object **obj_desc_ptr)
8195b482a8SLen Brown {
8295b482a8SLen Brown 	union acpi_operand_object *obj_desc;
8395b482a8SLen Brown 	acpi_status status;
8409079250SBob Moore 	acpi_object_type type;
8595b482a8SLen Brown 
8695b482a8SLen Brown 	ACPI_FUNCTION_TRACE(ds_build_internal_object);
8795b482a8SLen Brown 
8895b482a8SLen Brown 	*obj_desc_ptr = NULL;
8995b482a8SLen Brown 	if (op->common.aml_opcode == AML_INT_NAMEPATH_OP) {
9095b482a8SLen Brown 		/*
9195b482a8SLen Brown 		 * This is a named object reference. If this name was
9295b482a8SLen Brown 		 * previously looked up in the namespace, it was stored in this op.
9395b482a8SLen Brown 		 * Otherwise, go ahead and look it up now
9495b482a8SLen Brown 		 */
9595b482a8SLen Brown 		if (!op->common.node) {
9695b482a8SLen Brown 			status = acpi_ns_lookup(walk_state->scope_info,
9795b482a8SLen Brown 						op->common.value.string,
9895b482a8SLen Brown 						ACPI_TYPE_ANY,
9995b482a8SLen Brown 						ACPI_IMODE_EXECUTE,
10095b482a8SLen Brown 						ACPI_NS_SEARCH_PARENT |
10195b482a8SLen Brown 						ACPI_NS_DONT_OPEN_SCOPE, NULL,
10295b482a8SLen Brown 						ACPI_CAST_INDIRECT_PTR(struct
10395b482a8SLen Brown 								       acpi_namespace_node,
10495b482a8SLen Brown 								       &(op->
10595b482a8SLen Brown 									 common.
10695b482a8SLen Brown 									 node)));
10795b482a8SLen Brown 			if (ACPI_FAILURE(status)) {
10895b482a8SLen Brown 
10995b482a8SLen Brown 				/* Check if we are resolving a named reference within a package */
11095b482a8SLen Brown 
11195b482a8SLen Brown 				if ((status == AE_NOT_FOUND)
11295b482a8SLen Brown 				    && (acpi_gbl_enable_interpreter_slack)
11395b482a8SLen Brown 				    &&
11495b482a8SLen Brown 				    ((op->common.parent->common.aml_opcode ==
11595b482a8SLen Brown 				      AML_PACKAGE_OP)
11695b482a8SLen Brown 				     || (op->common.parent->common.aml_opcode ==
11795b482a8SLen Brown 					 AML_VAR_PACKAGE_OP))) {
11895b482a8SLen Brown 					/*
11995b482a8SLen Brown 					 * We didn't find the target and we are populating elements
12095b482a8SLen Brown 					 * of a package - ignore if slack enabled. Some ASL code
12195b482a8SLen Brown 					 * contains dangling invalid references in packages and
12295b482a8SLen Brown 					 * expects that no exception will be issued. Leave the
12395b482a8SLen Brown 					 * element as a null element. It cannot be used, but it
12495b482a8SLen Brown 					 * can be overwritten by subsequent ASL code - this is
12595b482a8SLen Brown 					 * typically the case.
12695b482a8SLen Brown 					 */
12795b482a8SLen Brown 					ACPI_DEBUG_PRINT((ACPI_DB_INFO,
12895b482a8SLen Brown 							  "Ignoring unresolved reference in package [%4.4s]\n",
12995b482a8SLen Brown 							  walk_state->
13095b482a8SLen Brown 							  scope_info->scope.
13195b482a8SLen Brown 							  node->name.ascii));
13295b482a8SLen Brown 
13395b482a8SLen Brown 					return_ACPI_STATUS(AE_OK);
13495b482a8SLen Brown 				} else {
13595b482a8SLen Brown 					ACPI_ERROR_NAMESPACE(op->common.value.
13695b482a8SLen Brown 							     string, status);
13795b482a8SLen Brown 				}
13895b482a8SLen Brown 
13995b482a8SLen Brown 				return_ACPI_STATUS(status);
14095b482a8SLen Brown 			}
14195b482a8SLen Brown 		}
14295b482a8SLen Brown 
14395b482a8SLen Brown 		/* Special object resolution for elements of a package */
14495b482a8SLen Brown 
14595b482a8SLen Brown 		if ((op->common.parent->common.aml_opcode == AML_PACKAGE_OP) ||
14695b482a8SLen Brown 		    (op->common.parent->common.aml_opcode ==
14795b482a8SLen Brown 		     AML_VAR_PACKAGE_OP)) {
14895b482a8SLen Brown 			/*
14995b482a8SLen Brown 			 * Attempt to resolve the node to a value before we insert it into
15095b482a8SLen Brown 			 * the package. If this is a reference to a common data type,
15195b482a8SLen Brown 			 * resolve it immediately. According to the ACPI spec, package
15295b482a8SLen Brown 			 * elements can only be "data objects" or method references.
15395b482a8SLen Brown 			 * Attempt to resolve to an Integer, Buffer, String or Package.
15495b482a8SLen Brown 			 * If cannot, return the named reference (for things like Devices,
15595b482a8SLen Brown 			 * Methods, etc.) Buffer Fields and Fields will resolve to simple
15695b482a8SLen Brown 			 * objects (int/buf/str/pkg).
15795b482a8SLen Brown 			 *
15895b482a8SLen Brown 			 * NOTE: References to things like Devices, Methods, Mutexes, etc.
15995b482a8SLen Brown 			 * will remain as named references. This behavior is not described
16095b482a8SLen Brown 			 * in the ACPI spec, but it appears to be an oversight.
16195b482a8SLen Brown 			 */
16295b482a8SLen Brown 			obj_desc =
16395b482a8SLen Brown 			    ACPI_CAST_PTR(union acpi_operand_object,
16495b482a8SLen Brown 					  op->common.node);
16595b482a8SLen Brown 
16695b482a8SLen Brown 			status =
16795b482a8SLen Brown 			    acpi_ex_resolve_node_to_value(ACPI_CAST_INDIRECT_PTR
16895b482a8SLen Brown 							  (struct
16995b482a8SLen Brown 							   acpi_namespace_node,
17095b482a8SLen Brown 							   &obj_desc),
17195b482a8SLen Brown 							  walk_state);
17295b482a8SLen Brown 			if (ACPI_FAILURE(status)) {
17395b482a8SLen Brown 				return_ACPI_STATUS(status);
17495b482a8SLen Brown 			}
17595b482a8SLen Brown 
17609079250SBob Moore 			/*
17709079250SBob Moore 			 * Special handling for Alias objects. We need to setup the type
17809079250SBob Moore 			 * and the Op->Common.Node to point to the Alias target. Note,
17909079250SBob Moore 			 * Alias has at most one level of indirection internally.
18009079250SBob Moore 			 */
18109079250SBob Moore 			type = op->common.node->type;
18209079250SBob Moore 			if (type == ACPI_TYPE_LOCAL_ALIAS) {
18309079250SBob Moore 				type = obj_desc->common.type;
18409079250SBob Moore 				op->common.node =
18509079250SBob Moore 				    ACPI_CAST_PTR(struct acpi_namespace_node,
18609079250SBob Moore 						  op->common.node->object);
18709079250SBob Moore 			}
18809079250SBob Moore 
18909079250SBob Moore 			switch (type) {
19095b482a8SLen Brown 				/*
19195b482a8SLen Brown 				 * For these types, we need the actual node, not the subobject.
19295b482a8SLen Brown 				 * However, the subobject did not get an extra reference count above.
19395b482a8SLen Brown 				 *
19495b482a8SLen Brown 				 * TBD: should ex_resolve_node_to_value be changed to fix this?
19595b482a8SLen Brown 				 */
19695b482a8SLen Brown 			case ACPI_TYPE_DEVICE:
19795b482a8SLen Brown 			case ACPI_TYPE_THERMAL:
19895b482a8SLen Brown 
19995b482a8SLen Brown 				acpi_ut_add_reference(op->common.node->object);
20095b482a8SLen Brown 
20195b482a8SLen Brown 				/*lint -fallthrough */
20295b482a8SLen Brown 				/*
20395b482a8SLen Brown 				 * For these types, we need the actual node, not the subobject.
20495b482a8SLen Brown 				 * The subobject got an extra reference count in ex_resolve_node_to_value.
20595b482a8SLen Brown 				 */
20695b482a8SLen Brown 			case ACPI_TYPE_MUTEX:
20795b482a8SLen Brown 			case ACPI_TYPE_METHOD:
20895b482a8SLen Brown 			case ACPI_TYPE_POWER:
20995b482a8SLen Brown 			case ACPI_TYPE_PROCESSOR:
21095b482a8SLen Brown 			case ACPI_TYPE_EVENT:
21195b482a8SLen Brown 			case ACPI_TYPE_REGION:
21295b482a8SLen Brown 
21395b482a8SLen Brown 				/* We will create a reference object for these types below */
21495b482a8SLen Brown 				break;
21595b482a8SLen Brown 
21695b482a8SLen Brown 			default:
21795b482a8SLen Brown 				/*
21895b482a8SLen Brown 				 * All other types - the node was resolved to an actual
21995b482a8SLen Brown 				 * object, we are done.
22095b482a8SLen Brown 				 */
22195b482a8SLen Brown 				goto exit;
22295b482a8SLen Brown 			}
22395b482a8SLen Brown 		}
22495b482a8SLen Brown 	}
22595b482a8SLen Brown 
22695b482a8SLen Brown 	/* Create and init a new internal ACPI object */
22795b482a8SLen Brown 
22895b482a8SLen Brown 	obj_desc = acpi_ut_create_internal_object((acpi_ps_get_opcode_info
22995b482a8SLen Brown 						   (op->common.aml_opcode))->
23095b482a8SLen Brown 						  object_type);
23195b482a8SLen Brown 	if (!obj_desc) {
23295b482a8SLen Brown 		return_ACPI_STATUS(AE_NO_MEMORY);
23395b482a8SLen Brown 	}
23495b482a8SLen Brown 
23595b482a8SLen Brown 	status =
23695b482a8SLen Brown 	    acpi_ds_init_object_from_op(walk_state, op, op->common.aml_opcode,
23795b482a8SLen Brown 					&obj_desc);
23895b482a8SLen Brown 	if (ACPI_FAILURE(status)) {
23995b482a8SLen Brown 		acpi_ut_remove_reference(obj_desc);
24095b482a8SLen Brown 		return_ACPI_STATUS(status);
24195b482a8SLen Brown 	}
24295b482a8SLen Brown 
24395b482a8SLen Brown       exit:
24495b482a8SLen Brown 	*obj_desc_ptr = obj_desc;
24595b482a8SLen Brown 	return_ACPI_STATUS(status);
24695b482a8SLen Brown }
24795b482a8SLen Brown 
24895b482a8SLen Brown /*******************************************************************************
24995b482a8SLen Brown  *
25095b482a8SLen Brown  * FUNCTION:    acpi_ds_build_internal_buffer_obj
25195b482a8SLen Brown  *
25295b482a8SLen Brown  * PARAMETERS:  walk_state      - Current walk state
253*ba494beeSBob Moore  *              op              - Parser object to be translated
25495b482a8SLen Brown  *              buffer_length   - Length of the buffer
25595b482a8SLen Brown  *              obj_desc_ptr    - Where the ACPI internal object is returned
25695b482a8SLen Brown  *
25795b482a8SLen Brown  * RETURN:      Status
25895b482a8SLen Brown  *
25995b482a8SLen Brown  * DESCRIPTION: Translate a parser Op package object to the equivalent
26095b482a8SLen Brown  *              namespace object
26195b482a8SLen Brown  *
26295b482a8SLen Brown  ******************************************************************************/
26395b482a8SLen Brown 
26495b482a8SLen Brown acpi_status
26595b482a8SLen Brown acpi_ds_build_internal_buffer_obj(struct acpi_walk_state *walk_state,
26695b482a8SLen Brown 				  union acpi_parse_object *op,
26795b482a8SLen Brown 				  u32 buffer_length,
26895b482a8SLen Brown 				  union acpi_operand_object **obj_desc_ptr)
26995b482a8SLen Brown {
27095b482a8SLen Brown 	union acpi_parse_object *arg;
27195b482a8SLen Brown 	union acpi_operand_object *obj_desc;
27295b482a8SLen Brown 	union acpi_parse_object *byte_list;
27395b482a8SLen Brown 	u32 byte_list_length = 0;
27495b482a8SLen Brown 
27595b482a8SLen Brown 	ACPI_FUNCTION_TRACE(ds_build_internal_buffer_obj);
27695b482a8SLen Brown 
27795b482a8SLen Brown 	/*
27895b482a8SLen Brown 	 * If we are evaluating a Named buffer object "Name (xxxx, Buffer)".
27995b482a8SLen Brown 	 * The buffer object already exists (from the NS node), otherwise it must
28095b482a8SLen Brown 	 * be created.
28195b482a8SLen Brown 	 */
28295b482a8SLen Brown 	obj_desc = *obj_desc_ptr;
28395b482a8SLen Brown 	if (!obj_desc) {
28495b482a8SLen Brown 
28595b482a8SLen Brown 		/* Create a new buffer object */
28695b482a8SLen Brown 
28795b482a8SLen Brown 		obj_desc = acpi_ut_create_internal_object(ACPI_TYPE_BUFFER);
28895b482a8SLen Brown 		*obj_desc_ptr = obj_desc;
28995b482a8SLen Brown 		if (!obj_desc) {
29095b482a8SLen Brown 			return_ACPI_STATUS(AE_NO_MEMORY);
29195b482a8SLen Brown 		}
29295b482a8SLen Brown 	}
29395b482a8SLen Brown 
29495b482a8SLen Brown 	/*
29595b482a8SLen Brown 	 * Second arg is the buffer data (optional) byte_list can be either
29695b482a8SLen Brown 	 * individual bytes or a string initializer.  In either case, a
29795b482a8SLen Brown 	 * byte_list appears in the AML.
29895b482a8SLen Brown 	 */
29995b482a8SLen Brown 	arg = op->common.value.arg;	/* skip first arg */
30095b482a8SLen Brown 
30195b482a8SLen Brown 	byte_list = arg->named.next;
30295b482a8SLen Brown 	if (byte_list) {
30395b482a8SLen Brown 		if (byte_list->common.aml_opcode != AML_INT_BYTELIST_OP) {
30495b482a8SLen Brown 			ACPI_ERROR((AE_INFO,
305f6a22b0bSBob Moore 				    "Expecting bytelist, found AML opcode 0x%X in op %p",
30695b482a8SLen Brown 				    byte_list->common.aml_opcode, byte_list));
30795b482a8SLen Brown 
30895b482a8SLen Brown 			acpi_ut_remove_reference(obj_desc);
30995b482a8SLen Brown 			return (AE_TYPE);
31095b482a8SLen Brown 		}
31195b482a8SLen Brown 
31295b482a8SLen Brown 		byte_list_length = (u32) byte_list->common.value.integer;
31395b482a8SLen Brown 	}
31495b482a8SLen Brown 
31595b482a8SLen Brown 	/*
31695b482a8SLen Brown 	 * The buffer length (number of bytes) will be the larger of:
31795b482a8SLen Brown 	 * 1) The specified buffer length and
31895b482a8SLen Brown 	 * 2) The length of the initializer byte list
31995b482a8SLen Brown 	 */
32095b482a8SLen Brown 	obj_desc->buffer.length = buffer_length;
32195b482a8SLen Brown 	if (byte_list_length > buffer_length) {
32295b482a8SLen Brown 		obj_desc->buffer.length = byte_list_length;
32395b482a8SLen Brown 	}
32495b482a8SLen Brown 
32595b482a8SLen Brown 	/* Allocate the buffer */
32695b482a8SLen Brown 
32795b482a8SLen Brown 	if (obj_desc->buffer.length == 0) {
32895b482a8SLen Brown 		obj_desc->buffer.pointer = NULL;
32995b482a8SLen Brown 		ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
33095b482a8SLen Brown 				  "Buffer defined with zero length in AML, creating\n"));
33195b482a8SLen Brown 	} else {
33295b482a8SLen Brown 		obj_desc->buffer.pointer =
33395b482a8SLen Brown 		    ACPI_ALLOCATE_ZEROED(obj_desc->buffer.length);
33495b482a8SLen Brown 		if (!obj_desc->buffer.pointer) {
33595b482a8SLen Brown 			acpi_ut_delete_object_desc(obj_desc);
33695b482a8SLen Brown 			return_ACPI_STATUS(AE_NO_MEMORY);
33795b482a8SLen Brown 		}
33895b482a8SLen Brown 
33995b482a8SLen Brown 		/* Initialize buffer from the byte_list (if present) */
34095b482a8SLen Brown 
34195b482a8SLen Brown 		if (byte_list) {
34295b482a8SLen Brown 			ACPI_MEMCPY(obj_desc->buffer.pointer,
34395b482a8SLen Brown 				    byte_list->named.data, byte_list_length);
34495b482a8SLen Brown 		}
34595b482a8SLen Brown 	}
34695b482a8SLen Brown 
34795b482a8SLen Brown 	obj_desc->buffer.flags |= AOPOBJ_DATA_VALID;
34895b482a8SLen Brown 	op->common.node = ACPI_CAST_PTR(struct acpi_namespace_node, obj_desc);
34995b482a8SLen Brown 	return_ACPI_STATUS(AE_OK);
35095b482a8SLen Brown }
35195b482a8SLen Brown 
35295b482a8SLen Brown /*******************************************************************************
35395b482a8SLen Brown  *
35495b482a8SLen Brown  * FUNCTION:    acpi_ds_build_internal_package_obj
35595b482a8SLen Brown  *
35695b482a8SLen Brown  * PARAMETERS:  walk_state      - Current walk state
357*ba494beeSBob Moore  *              op              - Parser object to be translated
35895b482a8SLen Brown  *              element_count   - Number of elements in the package - this is
35995b482a8SLen Brown  *                                the num_elements argument to Package()
36095b482a8SLen Brown  *              obj_desc_ptr    - Where the ACPI internal object is returned
36195b482a8SLen Brown  *
36295b482a8SLen Brown  * RETURN:      Status
36395b482a8SLen Brown  *
36495b482a8SLen Brown  * DESCRIPTION: Translate a parser Op package object to the equivalent
36595b482a8SLen Brown  *              namespace object
36695b482a8SLen Brown  *
36795b482a8SLen Brown  * NOTE: The number of elements in the package will be always be the num_elements
36895b482a8SLen Brown  * count, regardless of the number of elements in the package list. If
36995b482a8SLen Brown  * num_elements is smaller, only that many package list elements are used.
37095b482a8SLen Brown  * if num_elements is larger, the Package object is padded out with
37195b482a8SLen Brown  * objects of type Uninitialized (as per ACPI spec.)
37295b482a8SLen Brown  *
37395b482a8SLen Brown  * Even though the ASL compilers do not allow num_elements to be smaller
37495b482a8SLen Brown  * than the Package list length (for the fixed length package opcode), some
37595b482a8SLen Brown  * BIOS code modifies the AML on the fly to adjust the num_elements, and
37695b482a8SLen Brown  * this code compensates for that. This also provides compatibility with
37795b482a8SLen Brown  * other AML interpreters.
37895b482a8SLen Brown  *
37995b482a8SLen Brown  ******************************************************************************/
38095b482a8SLen Brown 
38195b482a8SLen Brown acpi_status
38295b482a8SLen Brown acpi_ds_build_internal_package_obj(struct acpi_walk_state *walk_state,
38395b482a8SLen Brown 				   union acpi_parse_object *op,
38495b482a8SLen Brown 				   u32 element_count,
38595b482a8SLen Brown 				   union acpi_operand_object **obj_desc_ptr)
38695b482a8SLen Brown {
38795b482a8SLen Brown 	union acpi_parse_object *arg;
38895b482a8SLen Brown 	union acpi_parse_object *parent;
38995b482a8SLen Brown 	union acpi_operand_object *obj_desc = NULL;
39095b482a8SLen Brown 	acpi_status status = AE_OK;
39195b482a8SLen Brown 	unsigned i;
39295b482a8SLen Brown 	u16 index;
39395b482a8SLen Brown 	u16 reference_count;
39495b482a8SLen Brown 
39595b482a8SLen Brown 	ACPI_FUNCTION_TRACE(ds_build_internal_package_obj);
39695b482a8SLen Brown 
39795b482a8SLen Brown 	/* Find the parent of a possibly nested package */
39895b482a8SLen Brown 
39995b482a8SLen Brown 	parent = op->common.parent;
40095b482a8SLen Brown 	while ((parent->common.aml_opcode == AML_PACKAGE_OP) ||
40195b482a8SLen Brown 	       (parent->common.aml_opcode == AML_VAR_PACKAGE_OP)) {
40295b482a8SLen Brown 		parent = parent->common.parent;
40395b482a8SLen Brown 	}
40495b482a8SLen Brown 
40595b482a8SLen Brown 	/*
40695b482a8SLen Brown 	 * If we are evaluating a Named package object "Name (xxxx, Package)",
40795b482a8SLen Brown 	 * the package object already exists, otherwise it must be created.
40895b482a8SLen Brown 	 */
40995b482a8SLen Brown 	obj_desc = *obj_desc_ptr;
41095b482a8SLen Brown 	if (!obj_desc) {
41195b482a8SLen Brown 		obj_desc = acpi_ut_create_internal_object(ACPI_TYPE_PACKAGE);
41295b482a8SLen Brown 		*obj_desc_ptr = obj_desc;
41395b482a8SLen Brown 		if (!obj_desc) {
41495b482a8SLen Brown 			return_ACPI_STATUS(AE_NO_MEMORY);
41595b482a8SLen Brown 		}
41695b482a8SLen Brown 
41795b482a8SLen Brown 		obj_desc->package.node = parent->common.node;
41895b482a8SLen Brown 	}
41995b482a8SLen Brown 
42095b482a8SLen Brown 	/*
42195b482a8SLen Brown 	 * Allocate the element array (array of pointers to the individual
42295b482a8SLen Brown 	 * objects) based on the num_elements parameter. Add an extra pointer slot
42395b482a8SLen Brown 	 * so that the list is always null terminated.
42495b482a8SLen Brown 	 */
42595b482a8SLen Brown 	obj_desc->package.elements = ACPI_ALLOCATE_ZEROED(((acpi_size)
42695b482a8SLen Brown 							   element_count +
42795b482a8SLen Brown 							   1) * sizeof(void *));
42895b482a8SLen Brown 
42995b482a8SLen Brown 	if (!obj_desc->package.elements) {
43095b482a8SLen Brown 		acpi_ut_delete_object_desc(obj_desc);
43195b482a8SLen Brown 		return_ACPI_STATUS(AE_NO_MEMORY);
43295b482a8SLen Brown 	}
43395b482a8SLen Brown 
43495b482a8SLen Brown 	obj_desc->package.count = element_count;
43595b482a8SLen Brown 
43695b482a8SLen Brown 	/*
43795b482a8SLen Brown 	 * Initialize the elements of the package, up to the num_elements count.
43895b482a8SLen Brown 	 * Package is automatically padded with uninitialized (NULL) elements
43995b482a8SLen Brown 	 * if num_elements is greater than the package list length. Likewise,
44095b482a8SLen Brown 	 * Package is truncated if num_elements is less than the list length.
44195b482a8SLen Brown 	 */
44295b482a8SLen Brown 	arg = op->common.value.arg;
44395b482a8SLen Brown 	arg = arg->common.next;
44495b482a8SLen Brown 	for (i = 0; arg && (i < element_count); i++) {
44595b482a8SLen Brown 		if (arg->common.aml_opcode == AML_INT_RETURN_VALUE_OP) {
44695b482a8SLen Brown 			if (arg->common.node->type == ACPI_TYPE_METHOD) {
44795b482a8SLen Brown 				/*
44895b482a8SLen Brown 				 * A method reference "looks" to the parser to be a method
44995b482a8SLen Brown 				 * invocation, so we special case it here
45095b482a8SLen Brown 				 */
45195b482a8SLen Brown 				arg->common.aml_opcode = AML_INT_NAMEPATH_OP;
45295b482a8SLen Brown 				status =
45395b482a8SLen Brown 				    acpi_ds_build_internal_object(walk_state,
45495b482a8SLen Brown 								  arg,
45595b482a8SLen Brown 								  &obj_desc->
45695b482a8SLen Brown 								  package.
45795b482a8SLen Brown 								  elements[i]);
45895b482a8SLen Brown 			} else {
45995b482a8SLen Brown 				/* This package element is already built, just get it */
46095b482a8SLen Brown 
46195b482a8SLen Brown 				obj_desc->package.elements[i] =
46295b482a8SLen Brown 				    ACPI_CAST_PTR(union acpi_operand_object,
46395b482a8SLen Brown 						  arg->common.node);
46495b482a8SLen Brown 			}
46595b482a8SLen Brown 		} else {
46695b482a8SLen Brown 			status = acpi_ds_build_internal_object(walk_state, arg,
46795b482a8SLen Brown 							       &obj_desc->
46895b482a8SLen Brown 							       package.
46995b482a8SLen Brown 							       elements[i]);
47095b482a8SLen Brown 		}
47195b482a8SLen Brown 
47295b482a8SLen Brown 		if (*obj_desc_ptr) {
47395b482a8SLen Brown 
47495b482a8SLen Brown 			/* Existing package, get existing reference count */
47595b482a8SLen Brown 
47695b482a8SLen Brown 			reference_count =
47795b482a8SLen Brown 			    (*obj_desc_ptr)->common.reference_count;
47895b482a8SLen Brown 			if (reference_count > 1) {
47995b482a8SLen Brown 
48095b482a8SLen Brown 				/* Make new element ref count match original ref count */
48195b482a8SLen Brown 
48295b482a8SLen Brown 				for (index = 0; index < (reference_count - 1);
48395b482a8SLen Brown 				     index++) {
48495b482a8SLen Brown 					acpi_ut_add_reference((obj_desc->
48595b482a8SLen Brown 							       package.
48695b482a8SLen Brown 							       elements[i]));
48795b482a8SLen Brown 				}
48895b482a8SLen Brown 			}
48995b482a8SLen Brown 		}
49095b482a8SLen Brown 
49195b482a8SLen Brown 		arg = arg->common.next;
49295b482a8SLen Brown 	}
49395b482a8SLen Brown 
49495b482a8SLen Brown 	/* Check for match between num_elements and actual length of package_list */
49595b482a8SLen Brown 
49695b482a8SLen Brown 	if (arg) {
49795b482a8SLen Brown 		/*
49895b482a8SLen Brown 		 * num_elements was exhausted, but there are remaining elements in the
499e3fe0913SBob Moore 		 * package_list. Truncate the package to num_elements.
50095b482a8SLen Brown 		 *
50195b482a8SLen Brown 		 * Note: technically, this is an error, from ACPI spec: "It is an error
50295b482a8SLen Brown 		 * for NumElements to be less than the number of elements in the
5037d5d05d0SBob Moore 		 * PackageList". However, we just print a message and
504e3fe0913SBob Moore 		 * no exception is returned. This provides Windows compatibility. Some
505e3fe0913SBob Moore 		 * BIOSs will alter the num_elements on the fly, creating this type
506e3fe0913SBob Moore 		 * of ill-formed package object.
50795b482a8SLen Brown 		 */
50895b482a8SLen Brown 		while (arg) {
509e3fe0913SBob Moore 			/*
510e3fe0913SBob Moore 			 * We must delete any package elements that were created earlier
511e3fe0913SBob Moore 			 * and are not going to be used because of the package truncation.
512e3fe0913SBob Moore 			 */
513e3fe0913SBob Moore 			if (arg->common.node) {
514e3fe0913SBob Moore 				acpi_ut_remove_reference(ACPI_CAST_PTR
515e3fe0913SBob Moore 							 (union
516e3fe0913SBob Moore 							  acpi_operand_object,
517e3fe0913SBob Moore 							  arg->common.node));
518e3fe0913SBob Moore 				arg->common.node = NULL;
519e3fe0913SBob Moore 			}
52095b482a8SLen Brown 
52195b482a8SLen Brown 			/* Find out how many elements there really are */
52295b482a8SLen Brown 
52395b482a8SLen Brown 			i++;
52495b482a8SLen Brown 			arg = arg->common.next;
52595b482a8SLen Brown 		}
52695b482a8SLen Brown 
5277d5d05d0SBob Moore 		ACPI_INFO((AE_INFO,
528f6a22b0bSBob Moore 			   "Actual Package length (%u) is larger than NumElements field (%u), truncated\n",
52995b482a8SLen Brown 			   i, element_count));
53095b482a8SLen Brown 	} else if (i < element_count) {
53195b482a8SLen Brown 		/*
53295b482a8SLen Brown 		 * Arg list (elements) was exhausted, but we did not reach num_elements count.
53395b482a8SLen Brown 		 * Note: this is not an error, the package is padded out with NULLs.
53495b482a8SLen Brown 		 */
53595b482a8SLen Brown 		ACPI_DEBUG_PRINT((ACPI_DB_INFO,
536f6a22b0bSBob Moore 				  "Package List length (%u) smaller than NumElements count (%u), padded with null elements\n",
53795b482a8SLen Brown 				  i, element_count));
53895b482a8SLen Brown 	}
53995b482a8SLen Brown 
54095b482a8SLen Brown 	obj_desc->package.flags |= AOPOBJ_DATA_VALID;
54195b482a8SLen Brown 	op->common.node = ACPI_CAST_PTR(struct acpi_namespace_node, obj_desc);
54295b482a8SLen Brown 	return_ACPI_STATUS(status);
54395b482a8SLen Brown }
54495b482a8SLen Brown 
54595b482a8SLen Brown /*******************************************************************************
54695b482a8SLen Brown  *
54795b482a8SLen Brown  * FUNCTION:    acpi_ds_create_node
54895b482a8SLen Brown  *
54995b482a8SLen Brown  * PARAMETERS:  walk_state      - Current walk state
550*ba494beeSBob Moore  *              node            - NS Node to be initialized
551*ba494beeSBob Moore  *              op              - Parser object to be translated
55295b482a8SLen Brown  *
55395b482a8SLen Brown  * RETURN:      Status
55495b482a8SLen Brown  *
55595b482a8SLen Brown  * DESCRIPTION: Create the object to be associated with a namespace node
55695b482a8SLen Brown  *
55795b482a8SLen Brown  ******************************************************************************/
55895b482a8SLen Brown 
55995b482a8SLen Brown acpi_status
56095b482a8SLen Brown acpi_ds_create_node(struct acpi_walk_state *walk_state,
56195b482a8SLen Brown 		    struct acpi_namespace_node *node,
56295b482a8SLen Brown 		    union acpi_parse_object *op)
56395b482a8SLen Brown {
56495b482a8SLen Brown 	acpi_status status;
56595b482a8SLen Brown 	union acpi_operand_object *obj_desc;
56695b482a8SLen Brown 
56795b482a8SLen Brown 	ACPI_FUNCTION_TRACE_PTR(ds_create_node, op);
56895b482a8SLen Brown 
56995b482a8SLen Brown 	/*
57095b482a8SLen Brown 	 * Because of the execution pass through the non-control-method
57195b482a8SLen Brown 	 * parts of the table, we can arrive here twice.  Only init
57295b482a8SLen Brown 	 * the named object node the first time through
57395b482a8SLen Brown 	 */
57495b482a8SLen Brown 	if (acpi_ns_get_attached_object(node)) {
57595b482a8SLen Brown 		return_ACPI_STATUS(AE_OK);
57695b482a8SLen Brown 	}
57795b482a8SLen Brown 
57895b482a8SLen Brown 	if (!op->common.value.arg) {
57995b482a8SLen Brown 
58095b482a8SLen Brown 		/* No arguments, there is nothing to do */
58195b482a8SLen Brown 
58295b482a8SLen Brown 		return_ACPI_STATUS(AE_OK);
58395b482a8SLen Brown 	}
58495b482a8SLen Brown 
58595b482a8SLen Brown 	/* Build an internal object for the argument(s) */
58695b482a8SLen Brown 
58795b482a8SLen Brown 	status = acpi_ds_build_internal_object(walk_state, op->common.value.arg,
58895b482a8SLen Brown 					       &obj_desc);
58995b482a8SLen Brown 	if (ACPI_FAILURE(status)) {
59095b482a8SLen Brown 		return_ACPI_STATUS(status);
59195b482a8SLen Brown 	}
59295b482a8SLen Brown 
59395b482a8SLen Brown 	/* Re-type the object according to its argument */
59495b482a8SLen Brown 
5953371c19cSBob Moore 	node->type = obj_desc->common.type;
59695b482a8SLen Brown 
59795b482a8SLen Brown 	/* Attach obj to node */
59895b482a8SLen Brown 
59995b482a8SLen Brown 	status = acpi_ns_attach_object(node, obj_desc, node->type);
60095b482a8SLen Brown 
60195b482a8SLen Brown 	/* Remove local reference to the object */
60295b482a8SLen Brown 
60395b482a8SLen Brown 	acpi_ut_remove_reference(obj_desc);
60495b482a8SLen Brown 	return_ACPI_STATUS(status);
60595b482a8SLen Brown }
60695b482a8SLen Brown 
60795b482a8SLen Brown #endif				/* ACPI_NO_METHOD_EXECUTION */
60895b482a8SLen Brown 
60995b482a8SLen Brown /*******************************************************************************
61095b482a8SLen Brown  *
61195b482a8SLen Brown  * FUNCTION:    acpi_ds_init_object_from_op
61295b482a8SLen Brown  *
61395b482a8SLen Brown  * PARAMETERS:  walk_state      - Current walk state
614*ba494beeSBob Moore  *              op              - Parser op used to init the internal object
615*ba494beeSBob Moore  *              opcode          - AML opcode associated with the object
61695b482a8SLen Brown  *              ret_obj_desc    - Namespace object to be initialized
61795b482a8SLen Brown  *
61895b482a8SLen Brown  * RETURN:      Status
61995b482a8SLen Brown  *
62095b482a8SLen Brown  * DESCRIPTION: Initialize a namespace object from a parser Op and its
62195b482a8SLen Brown  *              associated arguments.  The namespace object is a more compact
62295b482a8SLen Brown  *              representation of the Op and its arguments.
62395b482a8SLen Brown  *
62495b482a8SLen Brown  ******************************************************************************/
62595b482a8SLen Brown 
62695b482a8SLen Brown acpi_status
62795b482a8SLen Brown acpi_ds_init_object_from_op(struct acpi_walk_state *walk_state,
62895b482a8SLen Brown 			    union acpi_parse_object *op,
62995b482a8SLen Brown 			    u16 opcode,
63095b482a8SLen Brown 			    union acpi_operand_object **ret_obj_desc)
63195b482a8SLen Brown {
63295b482a8SLen Brown 	const struct acpi_opcode_info *op_info;
63395b482a8SLen Brown 	union acpi_operand_object *obj_desc;
63495b482a8SLen Brown 	acpi_status status = AE_OK;
63595b482a8SLen Brown 
63695b482a8SLen Brown 	ACPI_FUNCTION_TRACE(ds_init_object_from_op);
63795b482a8SLen Brown 
63895b482a8SLen Brown 	obj_desc = *ret_obj_desc;
63995b482a8SLen Brown 	op_info = acpi_ps_get_opcode_info(opcode);
64095b482a8SLen Brown 	if (op_info->class == AML_CLASS_UNKNOWN) {
64195b482a8SLen Brown 
64295b482a8SLen Brown 		/* Unknown opcode */
64395b482a8SLen Brown 
64495b482a8SLen Brown 		return_ACPI_STATUS(AE_TYPE);
64595b482a8SLen Brown 	}
64695b482a8SLen Brown 
64795b482a8SLen Brown 	/* Perform per-object initialization */
64895b482a8SLen Brown 
6493371c19cSBob Moore 	switch (obj_desc->common.type) {
65095b482a8SLen Brown 	case ACPI_TYPE_BUFFER:
65195b482a8SLen Brown 
65295b482a8SLen Brown 		/*
65395b482a8SLen Brown 		 * Defer evaluation of Buffer term_arg operand
65495b482a8SLen Brown 		 */
65595b482a8SLen Brown 		obj_desc->buffer.node =
65695b482a8SLen Brown 		    ACPI_CAST_PTR(struct acpi_namespace_node,
65795b482a8SLen Brown 				  walk_state->operands[0]);
65895b482a8SLen Brown 		obj_desc->buffer.aml_start = op->named.data;
65995b482a8SLen Brown 		obj_desc->buffer.aml_length = op->named.length;
66095b482a8SLen Brown 		break;
66195b482a8SLen Brown 
66295b482a8SLen Brown 	case ACPI_TYPE_PACKAGE:
66395b482a8SLen Brown 
66495b482a8SLen Brown 		/*
66595b482a8SLen Brown 		 * Defer evaluation of Package term_arg operand
66695b482a8SLen Brown 		 */
66795b482a8SLen Brown 		obj_desc->package.node =
66895b482a8SLen Brown 		    ACPI_CAST_PTR(struct acpi_namespace_node,
66995b482a8SLen Brown 				  walk_state->operands[0]);
67095b482a8SLen Brown 		obj_desc->package.aml_start = op->named.data;
67195b482a8SLen Brown 		obj_desc->package.aml_length = op->named.length;
67295b482a8SLen Brown 		break;
67395b482a8SLen Brown 
67495b482a8SLen Brown 	case ACPI_TYPE_INTEGER:
67595b482a8SLen Brown 
67695b482a8SLen Brown 		switch (op_info->type) {
67795b482a8SLen Brown 		case AML_TYPE_CONSTANT:
67895b482a8SLen Brown 			/*
67995b482a8SLen Brown 			 * Resolve AML Constants here - AND ONLY HERE!
68095b482a8SLen Brown 			 * All constants are integers.
68195b482a8SLen Brown 			 * We mark the integer with a flag that indicates that it started
68295b482a8SLen Brown 			 * life as a constant -- so that stores to constants will perform
68395b482a8SLen Brown 			 * as expected (noop). zero_op is used as a placeholder for optional
68495b482a8SLen Brown 			 * target operands.
68595b482a8SLen Brown 			 */
68695b482a8SLen Brown 			obj_desc->common.flags = AOPOBJ_AML_CONSTANT;
68795b482a8SLen Brown 
68895b482a8SLen Brown 			switch (opcode) {
68995b482a8SLen Brown 			case AML_ZERO_OP:
69095b482a8SLen Brown 
69195b482a8SLen Brown 				obj_desc->integer.value = 0;
69295b482a8SLen Brown 				break;
69395b482a8SLen Brown 
69495b482a8SLen Brown 			case AML_ONE_OP:
69595b482a8SLen Brown 
69695b482a8SLen Brown 				obj_desc->integer.value = 1;
69795b482a8SLen Brown 				break;
69895b482a8SLen Brown 
69995b482a8SLen Brown 			case AML_ONES_OP:
70095b482a8SLen Brown 
7015df7e6cbSBob Moore 				obj_desc->integer.value = ACPI_UINT64_MAX;
70295b482a8SLen Brown 
70395b482a8SLen Brown 				/* Truncate value if we are executing from a 32-bit ACPI table */
70495b482a8SLen Brown 
70595b482a8SLen Brown #ifndef ACPI_NO_METHOD_EXECUTION
70695b482a8SLen Brown 				acpi_ex_truncate_for32bit_table(obj_desc);
70795b482a8SLen Brown #endif
70895b482a8SLen Brown 				break;
70995b482a8SLen Brown 
71095b482a8SLen Brown 			case AML_REVISION_OP:
71195b482a8SLen Brown 
71295b482a8SLen Brown 				obj_desc->integer.value = ACPI_CA_VERSION;
71395b482a8SLen Brown 				break;
71495b482a8SLen Brown 
71595b482a8SLen Brown 			default:
71695b482a8SLen Brown 
71795b482a8SLen Brown 				ACPI_ERROR((AE_INFO,
718f6a22b0bSBob Moore 					    "Unknown constant opcode 0x%X",
71995b482a8SLen Brown 					    opcode));
72095b482a8SLen Brown 				status = AE_AML_OPERAND_TYPE;
72195b482a8SLen Brown 				break;
72295b482a8SLen Brown 			}
72395b482a8SLen Brown 			break;
72495b482a8SLen Brown 
72595b482a8SLen Brown 		case AML_TYPE_LITERAL:
72695b482a8SLen Brown 
72795b482a8SLen Brown 			obj_desc->integer.value = op->common.value.integer;
72895b482a8SLen Brown #ifndef ACPI_NO_METHOD_EXECUTION
72995b482a8SLen Brown 			acpi_ex_truncate_for32bit_table(obj_desc);
73095b482a8SLen Brown #endif
73195b482a8SLen Brown 			break;
73295b482a8SLen Brown 
73395b482a8SLen Brown 		default:
734f6a22b0bSBob Moore 			ACPI_ERROR((AE_INFO, "Unknown Integer type 0x%X",
73595b482a8SLen Brown 				    op_info->type));
73695b482a8SLen Brown 			status = AE_AML_OPERAND_TYPE;
73795b482a8SLen Brown 			break;
73895b482a8SLen Brown 		}
73995b482a8SLen Brown 		break;
74095b482a8SLen Brown 
74195b482a8SLen Brown 	case ACPI_TYPE_STRING:
74295b482a8SLen Brown 
74395b482a8SLen Brown 		obj_desc->string.pointer = op->common.value.string;
74495b482a8SLen Brown 		obj_desc->string.length =
74595b482a8SLen Brown 		    (u32) ACPI_STRLEN(op->common.value.string);
74695b482a8SLen Brown 
74795b482a8SLen Brown 		/*
74895b482a8SLen Brown 		 * The string is contained in the ACPI table, don't ever try
74995b482a8SLen Brown 		 * to delete it
75095b482a8SLen Brown 		 */
75195b482a8SLen Brown 		obj_desc->common.flags |= AOPOBJ_STATIC_POINTER;
75295b482a8SLen Brown 		break;
75395b482a8SLen Brown 
75495b482a8SLen Brown 	case ACPI_TYPE_METHOD:
75595b482a8SLen Brown 		break;
75695b482a8SLen Brown 
75795b482a8SLen Brown 	case ACPI_TYPE_LOCAL_REFERENCE:
75895b482a8SLen Brown 
75995b482a8SLen Brown 		switch (op_info->type) {
76095b482a8SLen Brown 		case AML_TYPE_LOCAL_VARIABLE:
76195b482a8SLen Brown 
76295b482a8SLen Brown 			/* Local ID (0-7) is (AML opcode - base AML_LOCAL_OP) */
76395b482a8SLen Brown 
764ba9c3f55SBob Moore 			obj_desc->reference.value =
765ba9c3f55SBob Moore 			    ((u32)opcode) - AML_LOCAL_OP;
76695b482a8SLen Brown 			obj_desc->reference.class = ACPI_REFCLASS_LOCAL;
76795b482a8SLen Brown 
76895b482a8SLen Brown #ifndef ACPI_NO_METHOD_EXECUTION
76995b482a8SLen Brown 			status =
77095b482a8SLen Brown 			    acpi_ds_method_data_get_node(ACPI_REFCLASS_LOCAL,
77195b482a8SLen Brown 							 obj_desc->reference.
77295b482a8SLen Brown 							 value, walk_state,
77395b482a8SLen Brown 							 ACPI_CAST_INDIRECT_PTR
77495b482a8SLen Brown 							 (struct
77595b482a8SLen Brown 							  acpi_namespace_node,
77695b482a8SLen Brown 							  &obj_desc->reference.
77795b482a8SLen Brown 							  object));
77895b482a8SLen Brown #endif
77995b482a8SLen Brown 			break;
78095b482a8SLen Brown 
78195b482a8SLen Brown 		case AML_TYPE_METHOD_ARGUMENT:
78295b482a8SLen Brown 
78395b482a8SLen Brown 			/* Arg ID (0-6) is (AML opcode - base AML_ARG_OP) */
78495b482a8SLen Brown 
785ba9c3f55SBob Moore 			obj_desc->reference.value = ((u32)opcode) - AML_ARG_OP;
78695b482a8SLen Brown 			obj_desc->reference.class = ACPI_REFCLASS_ARG;
78795b482a8SLen Brown 
78895b482a8SLen Brown #ifndef ACPI_NO_METHOD_EXECUTION
78995b482a8SLen Brown 			status = acpi_ds_method_data_get_node(ACPI_REFCLASS_ARG,
79095b482a8SLen Brown 							      obj_desc->
79195b482a8SLen Brown 							      reference.value,
79295b482a8SLen Brown 							      walk_state,
79395b482a8SLen Brown 							      ACPI_CAST_INDIRECT_PTR
79495b482a8SLen Brown 							      (struct
79595b482a8SLen Brown 							       acpi_namespace_node,
79695b482a8SLen Brown 							       &obj_desc->
79795b482a8SLen Brown 							       reference.
79895b482a8SLen Brown 							       object));
79995b482a8SLen Brown #endif
80095b482a8SLen Brown 			break;
80195b482a8SLen Brown 
80295b482a8SLen Brown 		default:	/* Object name or Debug object */
80395b482a8SLen Brown 
80495b482a8SLen Brown 			switch (op->common.aml_opcode) {
80595b482a8SLen Brown 			case AML_INT_NAMEPATH_OP:
80695b482a8SLen Brown 
80795b482a8SLen Brown 				/* Node was saved in Op */
80895b482a8SLen Brown 
80995b482a8SLen Brown 				obj_desc->reference.node = op->common.node;
81095b482a8SLen Brown 				obj_desc->reference.object =
81195b482a8SLen Brown 				    op->common.node->object;
81295b482a8SLen Brown 				obj_desc->reference.class = ACPI_REFCLASS_NAME;
81395b482a8SLen Brown 				break;
81495b482a8SLen Brown 
81595b482a8SLen Brown 			case AML_DEBUG_OP:
81695b482a8SLen Brown 
81795b482a8SLen Brown 				obj_desc->reference.class = ACPI_REFCLASS_DEBUG;
81895b482a8SLen Brown 				break;
81995b482a8SLen Brown 
82095b482a8SLen Brown 			default:
82195b482a8SLen Brown 
82295b482a8SLen Brown 				ACPI_ERROR((AE_INFO,
823f6a22b0bSBob Moore 					    "Unimplemented reference type for AML opcode: 0x%4.4X",
82495b482a8SLen Brown 					    opcode));
82595b482a8SLen Brown 				return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
82695b482a8SLen Brown 			}
82795b482a8SLen Brown 			break;
82895b482a8SLen Brown 		}
82995b482a8SLen Brown 		break;
83095b482a8SLen Brown 
83195b482a8SLen Brown 	default:
83295b482a8SLen Brown 
833f6a22b0bSBob Moore 		ACPI_ERROR((AE_INFO, "Unimplemented data type: 0x%X",
8343371c19cSBob Moore 			    obj_desc->common.type));
83595b482a8SLen Brown 
83695b482a8SLen Brown 		status = AE_AML_OPERAND_TYPE;
83795b482a8SLen Brown 		break;
83895b482a8SLen Brown 	}
83995b482a8SLen Brown 
84095b482a8SLen Brown 	return_ACPI_STATUS(status);
84195b482a8SLen Brown }
842