xref: /openbmc/linux/drivers/acpi/acpica/dsobject.c (revision 95857638889aeea1b10a16b55041adf3e3ab84c4)
1*95857638SErik Schmauss // SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0
295b482a8SLen Brown /******************************************************************************
395b482a8SLen Brown  *
495b482a8SLen Brown  * Module Name: dsobject - Dispatcher object management routines
595b482a8SLen Brown  *
6da6f8320SBob Moore  * Copyright (C) 2000 - 2018, Intel Corp.
795b482a8SLen Brown  *
8*95857638SErik Schmauss  *****************************************************************************/
995b482a8SLen Brown 
1095b482a8SLen Brown #include <acpi/acpi.h>
11e2f7a777SLen Brown #include "accommon.h"
12e2f7a777SLen Brown #include "acparser.h"
13e2f7a777SLen Brown #include "amlcode.h"
14e2f7a777SLen Brown #include "acdispat.h"
15e2f7a777SLen Brown #include "acnamesp.h"
16e2f7a777SLen Brown #include "acinterp.h"
1795b482a8SLen Brown 
1895b482a8SLen Brown #define _COMPONENT          ACPI_DISPATCHER
1995b482a8SLen Brown ACPI_MODULE_NAME("dsobject")
2095b482a8SLen Brown 
2195b482a8SLen Brown #ifndef ACPI_NO_METHOD_EXECUTION
2295b482a8SLen Brown /*******************************************************************************
2395b482a8SLen Brown  *
2495b482a8SLen Brown  * FUNCTION:    acpi_ds_build_internal_object
2595b482a8SLen Brown  *
2695b482a8SLen Brown  * PARAMETERS:  walk_state      - Current walk state
27ba494beeSBob Moore  *              op              - Parser object to be translated
2895b482a8SLen Brown  *              obj_desc_ptr    - Where the ACPI internal object is returned
2995b482a8SLen Brown  *
3095b482a8SLen Brown  * RETURN:      Status
3195b482a8SLen Brown  *
3295b482a8SLen Brown  * DESCRIPTION: Translate a parser Op object to the equivalent namespace object
3395b482a8SLen Brown  *              Simple objects are any objects other than a package object!
3495b482a8SLen Brown  *
3595b482a8SLen Brown  ******************************************************************************/
36a62a7117SBob Moore acpi_status
3795b482a8SLen Brown acpi_ds_build_internal_object(struct acpi_walk_state *walk_state,
3895b482a8SLen Brown 			      union acpi_parse_object *op,
3995b482a8SLen Brown 			      union acpi_operand_object **obj_desc_ptr)
4095b482a8SLen Brown {
4195b482a8SLen Brown 	union acpi_operand_object *obj_desc;
4295b482a8SLen Brown 	acpi_status status;
4395b482a8SLen Brown 
4495b482a8SLen Brown 	ACPI_FUNCTION_TRACE(ds_build_internal_object);
4595b482a8SLen Brown 
4695b482a8SLen Brown 	*obj_desc_ptr = NULL;
4795b482a8SLen Brown 	if (op->common.aml_opcode == AML_INT_NAMEPATH_OP) {
4895b482a8SLen Brown 		/*
4995b482a8SLen Brown 		 * This is a named object reference. If this name was
50a62a7117SBob Moore 		 * previously looked up in the namespace, it was stored in
51a62a7117SBob Moore 		 * this op. Otherwise, go ahead and look it up now
5295b482a8SLen Brown 		 */
5395b482a8SLen Brown 		if (!op->common.node) {
54a62a7117SBob Moore 
55a62a7117SBob Moore 			/* Check if we are resolving a named reference within a package */
56a62a7117SBob Moore 
57a62a7117SBob Moore 			if ((op->common.parent->common.aml_opcode ==
58a62a7117SBob Moore 			     AML_PACKAGE_OP)
59a62a7117SBob Moore 			    || (op->common.parent->common.aml_opcode ==
60a62a7117SBob Moore 				AML_VARIABLE_PACKAGE_OP)) {
61a62a7117SBob Moore 				/*
62a62a7117SBob Moore 				 * We won't resolve package elements here, we will do this
63a62a7117SBob Moore 				 * after all ACPI tables are loaded into the namespace. This
64a62a7117SBob Moore 				 * behavior supports both forward references to named objects
65a62a7117SBob Moore 				 * and external references to objects in other tables.
66a62a7117SBob Moore 				 */
67a62a7117SBob Moore 				goto create_new_object;
68a62a7117SBob Moore 			} else {
6995b482a8SLen Brown 				status = acpi_ns_lookup(walk_state->scope_info,
7095b482a8SLen Brown 							op->common.value.string,
7195b482a8SLen Brown 							ACPI_TYPE_ANY,
7295b482a8SLen Brown 							ACPI_IMODE_EXECUTE,
7395b482a8SLen Brown 							ACPI_NS_SEARCH_PARENT |
74a62a7117SBob Moore 							ACPI_NS_DONT_OPEN_SCOPE,
75a62a7117SBob Moore 							NULL,
76a62a7117SBob Moore 							ACPI_CAST_INDIRECT_PTR
7795b482a8SLen Brown 							(struct
7895b482a8SLen Brown 							 acpi_namespace_node,
79a62a7117SBob Moore 							 &(op->common.node)));
8095b482a8SLen Brown 				if (ACPI_FAILURE(status)) {
8116ccf829SBob Moore 					ACPI_ERROR_NAMESPACE(walk_state->
8216ccf829SBob Moore 							     scope_info,
8316ccf829SBob Moore 							     op->common.value.
84a62a7117SBob Moore 							     string, status);
8595b482a8SLen Brown 					return_ACPI_STATUS(status);
8695b482a8SLen Brown 				}
8795b482a8SLen Brown 			}
8895b482a8SLen Brown 		}
8995b482a8SLen Brown 	}
9095b482a8SLen Brown 
91a62a7117SBob Moore create_new_object:
92a62a7117SBob Moore 
9395b482a8SLen Brown 	/* Create and init a new internal ACPI object */
9495b482a8SLen Brown 
9595b482a8SLen Brown 	obj_desc = acpi_ut_create_internal_object((acpi_ps_get_opcode_info
9695b482a8SLen Brown 						   (op->common.aml_opcode))->
9795b482a8SLen Brown 						  object_type);
9895b482a8SLen Brown 	if (!obj_desc) {
9995b482a8SLen Brown 		return_ACPI_STATUS(AE_NO_MEMORY);
10095b482a8SLen Brown 	}
10195b482a8SLen Brown 
10295b482a8SLen Brown 	status =
10395b482a8SLen Brown 	    acpi_ds_init_object_from_op(walk_state, op, op->common.aml_opcode,
10495b482a8SLen Brown 					&obj_desc);
10595b482a8SLen Brown 	if (ACPI_FAILURE(status)) {
10695b482a8SLen Brown 		acpi_ut_remove_reference(obj_desc);
10795b482a8SLen Brown 		return_ACPI_STATUS(status);
10895b482a8SLen Brown 	}
10995b482a8SLen Brown 
110a62a7117SBob Moore 	/*
111a62a7117SBob Moore 	 * Handling for unresolved package reference elements.
112a62a7117SBob Moore 	 * These are elements that are namepaths.
113a62a7117SBob Moore 	 */
114a62a7117SBob Moore 	if ((op->common.parent->common.aml_opcode == AML_PACKAGE_OP) ||
115a62a7117SBob Moore 	    (op->common.parent->common.aml_opcode == AML_VARIABLE_PACKAGE_OP)) {
116a62a7117SBob Moore 		obj_desc->reference.resolved = TRUE;
117a62a7117SBob Moore 
118a62a7117SBob Moore 		if ((op->common.aml_opcode == AML_INT_NAMEPATH_OP) &&
119a62a7117SBob Moore 		    !obj_desc->reference.node) {
120a62a7117SBob Moore 			/*
121a62a7117SBob Moore 			 * Name was unresolved above.
122a62a7117SBob Moore 			 * Get the prefix node for later lookup
123a62a7117SBob Moore 			 */
124a62a7117SBob Moore 			obj_desc->reference.node =
125a62a7117SBob Moore 			    walk_state->scope_info->scope.node;
126a62a7117SBob Moore 			obj_desc->reference.aml = op->common.aml;
127a62a7117SBob Moore 			obj_desc->reference.resolved = FALSE;
128a62a7117SBob Moore 		}
129a62a7117SBob Moore 	}
130a62a7117SBob Moore 
13195b482a8SLen Brown 	*obj_desc_ptr = obj_desc;
13295b482a8SLen Brown 	return_ACPI_STATUS(status);
13395b482a8SLen Brown }
13495b482a8SLen Brown 
13595b482a8SLen Brown /*******************************************************************************
13695b482a8SLen Brown  *
13795b482a8SLen Brown  * FUNCTION:    acpi_ds_build_internal_buffer_obj
13895b482a8SLen Brown  *
13995b482a8SLen Brown  * PARAMETERS:  walk_state      - Current walk state
140ba494beeSBob Moore  *              op              - Parser object to be translated
14195b482a8SLen Brown  *              buffer_length   - Length of the buffer
14295b482a8SLen Brown  *              obj_desc_ptr    - Where the ACPI internal object is returned
14395b482a8SLen Brown  *
14495b482a8SLen Brown  * RETURN:      Status
14595b482a8SLen Brown  *
14695b482a8SLen Brown  * DESCRIPTION: Translate a parser Op package object to the equivalent
14795b482a8SLen Brown  *              namespace object
14895b482a8SLen Brown  *
14995b482a8SLen Brown  ******************************************************************************/
15095b482a8SLen Brown 
15195b482a8SLen Brown acpi_status
15295b482a8SLen Brown acpi_ds_build_internal_buffer_obj(struct acpi_walk_state *walk_state,
15395b482a8SLen Brown 				  union acpi_parse_object *op,
15495b482a8SLen Brown 				  u32 buffer_length,
15595b482a8SLen Brown 				  union acpi_operand_object **obj_desc_ptr)
15695b482a8SLen Brown {
15795b482a8SLen Brown 	union acpi_parse_object *arg;
15895b482a8SLen Brown 	union acpi_operand_object *obj_desc;
15995b482a8SLen Brown 	union acpi_parse_object *byte_list;
16095b482a8SLen Brown 	u32 byte_list_length = 0;
16195b482a8SLen Brown 
16295b482a8SLen Brown 	ACPI_FUNCTION_TRACE(ds_build_internal_buffer_obj);
16395b482a8SLen Brown 
16495b482a8SLen Brown 	/*
16595b482a8SLen Brown 	 * If we are evaluating a Named buffer object "Name (xxxx, Buffer)".
16695b482a8SLen Brown 	 * The buffer object already exists (from the NS node), otherwise it must
16795b482a8SLen Brown 	 * be created.
16895b482a8SLen Brown 	 */
16995b482a8SLen Brown 	obj_desc = *obj_desc_ptr;
17095b482a8SLen Brown 	if (!obj_desc) {
17195b482a8SLen Brown 
17295b482a8SLen Brown 		/* Create a new buffer object */
17395b482a8SLen Brown 
17495b482a8SLen Brown 		obj_desc = acpi_ut_create_internal_object(ACPI_TYPE_BUFFER);
17595b482a8SLen Brown 		*obj_desc_ptr = obj_desc;
17695b482a8SLen Brown 		if (!obj_desc) {
17795b482a8SLen Brown 			return_ACPI_STATUS(AE_NO_MEMORY);
17895b482a8SLen Brown 		}
17995b482a8SLen Brown 	}
18095b482a8SLen Brown 
18195b482a8SLen Brown 	/*
18295b482a8SLen Brown 	 * Second arg is the buffer data (optional) byte_list can be either
18395b482a8SLen Brown 	 * individual bytes or a string initializer. In either case, a
18495b482a8SLen Brown 	 * byte_list appears in the AML.
18595b482a8SLen Brown 	 */
18695b482a8SLen Brown 	arg = op->common.value.arg;	/* skip first arg */
18795b482a8SLen Brown 
18895b482a8SLen Brown 	byte_list = arg->named.next;
18995b482a8SLen Brown 	if (byte_list) {
19095b482a8SLen Brown 		if (byte_list->common.aml_opcode != AML_INT_BYTELIST_OP) {
19195b482a8SLen Brown 			ACPI_ERROR((AE_INFO,
192f6a22b0bSBob Moore 				    "Expecting bytelist, found AML opcode 0x%X in op %p",
19395b482a8SLen Brown 				    byte_list->common.aml_opcode, byte_list));
19495b482a8SLen Brown 
19595b482a8SLen Brown 			acpi_ut_remove_reference(obj_desc);
19695b482a8SLen Brown 			return (AE_TYPE);
19795b482a8SLen Brown 		}
19895b482a8SLen Brown 
19995b482a8SLen Brown 		byte_list_length = (u32) byte_list->common.value.integer;
20095b482a8SLen Brown 	}
20195b482a8SLen Brown 
20295b482a8SLen Brown 	/*
20395b482a8SLen Brown 	 * The buffer length (number of bytes) will be the larger of:
20495b482a8SLen Brown 	 * 1) The specified buffer length and
20595b482a8SLen Brown 	 * 2) The length of the initializer byte list
20695b482a8SLen Brown 	 */
20795b482a8SLen Brown 	obj_desc->buffer.length = buffer_length;
20895b482a8SLen Brown 	if (byte_list_length > buffer_length) {
20995b482a8SLen Brown 		obj_desc->buffer.length = byte_list_length;
21095b482a8SLen Brown 	}
21195b482a8SLen Brown 
21295b482a8SLen Brown 	/* Allocate the buffer */
21395b482a8SLen Brown 
21495b482a8SLen Brown 	if (obj_desc->buffer.length == 0) {
21595b482a8SLen Brown 		obj_desc->buffer.pointer = NULL;
21695b482a8SLen Brown 		ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
21795b482a8SLen Brown 				  "Buffer defined with zero length in AML, creating\n"));
21895b482a8SLen Brown 	} else {
21995b482a8SLen Brown 		obj_desc->buffer.pointer =
22095b482a8SLen Brown 		    ACPI_ALLOCATE_ZEROED(obj_desc->buffer.length);
22195b482a8SLen Brown 		if (!obj_desc->buffer.pointer) {
22295b482a8SLen Brown 			acpi_ut_delete_object_desc(obj_desc);
22395b482a8SLen Brown 			return_ACPI_STATUS(AE_NO_MEMORY);
22495b482a8SLen Brown 		}
22595b482a8SLen Brown 
22695b482a8SLen Brown 		/* Initialize buffer from the byte_list (if present) */
22795b482a8SLen Brown 
22895b482a8SLen Brown 		if (byte_list) {
2294fa4616eSBob Moore 			memcpy(obj_desc->buffer.pointer, byte_list->named.data,
2304fa4616eSBob Moore 			       byte_list_length);
23195b482a8SLen Brown 		}
23295b482a8SLen Brown 	}
23395b482a8SLen Brown 
23495b482a8SLen Brown 	obj_desc->buffer.flags |= AOPOBJ_DATA_VALID;
23595b482a8SLen Brown 	op->common.node = ACPI_CAST_PTR(struct acpi_namespace_node, obj_desc);
23695b482a8SLen Brown 	return_ACPI_STATUS(AE_OK);
23795b482a8SLen Brown }
23895b482a8SLen Brown 
23995b482a8SLen Brown /*******************************************************************************
24095b482a8SLen Brown  *
24195b482a8SLen Brown  * FUNCTION:    acpi_ds_create_node
24295b482a8SLen Brown  *
24395b482a8SLen Brown  * PARAMETERS:  walk_state      - Current walk state
244ba494beeSBob Moore  *              node            - NS Node to be initialized
245ba494beeSBob Moore  *              op              - Parser object to be translated
24695b482a8SLen Brown  *
24795b482a8SLen Brown  * RETURN:      Status
24895b482a8SLen Brown  *
24995b482a8SLen Brown  * DESCRIPTION: Create the object to be associated with a namespace node
25095b482a8SLen Brown  *
25195b482a8SLen Brown  ******************************************************************************/
25295b482a8SLen Brown 
25395b482a8SLen Brown acpi_status
25495b482a8SLen Brown acpi_ds_create_node(struct acpi_walk_state *walk_state,
25595b482a8SLen Brown 		    struct acpi_namespace_node *node,
25695b482a8SLen Brown 		    union acpi_parse_object *op)
25795b482a8SLen Brown {
25895b482a8SLen Brown 	acpi_status status;
25995b482a8SLen Brown 	union acpi_operand_object *obj_desc;
26095b482a8SLen Brown 
26195b482a8SLen Brown 	ACPI_FUNCTION_TRACE_PTR(ds_create_node, op);
26295b482a8SLen Brown 
26395b482a8SLen Brown 	/*
26495b482a8SLen Brown 	 * Because of the execution pass through the non-control-method
26595b482a8SLen Brown 	 * parts of the table, we can arrive here twice. Only init
26695b482a8SLen Brown 	 * the named object node the first time through
26795b482a8SLen Brown 	 */
26895b482a8SLen Brown 	if (acpi_ns_get_attached_object(node)) {
26995b482a8SLen Brown 		return_ACPI_STATUS(AE_OK);
27095b482a8SLen Brown 	}
27195b482a8SLen Brown 
27295b482a8SLen Brown 	if (!op->common.value.arg) {
27395b482a8SLen Brown 
27495b482a8SLen Brown 		/* No arguments, there is nothing to do */
27595b482a8SLen Brown 
27695b482a8SLen Brown 		return_ACPI_STATUS(AE_OK);
27795b482a8SLen Brown 	}
27895b482a8SLen Brown 
27995b482a8SLen Brown 	/* Build an internal object for the argument(s) */
28095b482a8SLen Brown 
2811fad8738SBob Moore 	status =
2821fad8738SBob Moore 	    acpi_ds_build_internal_object(walk_state, op->common.value.arg,
28395b482a8SLen Brown 					  &obj_desc);
28495b482a8SLen Brown 	if (ACPI_FAILURE(status)) {
28595b482a8SLen Brown 		return_ACPI_STATUS(status);
28695b482a8SLen Brown 	}
28795b482a8SLen Brown 
28895b482a8SLen Brown 	/* Re-type the object according to its argument */
28995b482a8SLen Brown 
2903371c19cSBob Moore 	node->type = obj_desc->common.type;
29195b482a8SLen Brown 
29295b482a8SLen Brown 	/* Attach obj to node */
29395b482a8SLen Brown 
29495b482a8SLen Brown 	status = acpi_ns_attach_object(node, obj_desc, node->type);
29595b482a8SLen Brown 
29695b482a8SLen Brown 	/* Remove local reference to the object */
29795b482a8SLen Brown 
29895b482a8SLen Brown 	acpi_ut_remove_reference(obj_desc);
29995b482a8SLen Brown 	return_ACPI_STATUS(status);
30095b482a8SLen Brown }
30195b482a8SLen Brown 
30295b482a8SLen Brown #endif				/* ACPI_NO_METHOD_EXECUTION */
30395b482a8SLen Brown 
30495b482a8SLen Brown /*******************************************************************************
30595b482a8SLen Brown  *
30695b482a8SLen Brown  * FUNCTION:    acpi_ds_init_object_from_op
30795b482a8SLen Brown  *
30895b482a8SLen Brown  * PARAMETERS:  walk_state      - Current walk state
309ba494beeSBob Moore  *              op              - Parser op used to init the internal object
310ba494beeSBob Moore  *              opcode          - AML opcode associated with the object
31195b482a8SLen Brown  *              ret_obj_desc    - Namespace object to be initialized
31295b482a8SLen Brown  *
31395b482a8SLen Brown  * RETURN:      Status
31495b482a8SLen Brown  *
31595b482a8SLen Brown  * DESCRIPTION: Initialize a namespace object from a parser Op and its
31695b482a8SLen Brown  *              associated arguments. The namespace object is a more compact
31795b482a8SLen Brown  *              representation of the Op and its arguments.
31895b482a8SLen Brown  *
31995b482a8SLen Brown  ******************************************************************************/
32095b482a8SLen Brown 
32195b482a8SLen Brown acpi_status
32295b482a8SLen Brown acpi_ds_init_object_from_op(struct acpi_walk_state *walk_state,
32395b482a8SLen Brown 			    union acpi_parse_object *op,
32495b482a8SLen Brown 			    u16 opcode,
32595b482a8SLen Brown 			    union acpi_operand_object **ret_obj_desc)
32695b482a8SLen Brown {
32795b482a8SLen Brown 	const struct acpi_opcode_info *op_info;
32895b482a8SLen Brown 	union acpi_operand_object *obj_desc;
32995b482a8SLen Brown 	acpi_status status = AE_OK;
33095b482a8SLen Brown 
33195b482a8SLen Brown 	ACPI_FUNCTION_TRACE(ds_init_object_from_op);
33295b482a8SLen Brown 
33395b482a8SLen Brown 	obj_desc = *ret_obj_desc;
33495b482a8SLen Brown 	op_info = acpi_ps_get_opcode_info(opcode);
33595b482a8SLen Brown 	if (op_info->class == AML_CLASS_UNKNOWN) {
33695b482a8SLen Brown 
33795b482a8SLen Brown 		/* Unknown opcode */
33895b482a8SLen Brown 
33995b482a8SLen Brown 		return_ACPI_STATUS(AE_TYPE);
34095b482a8SLen Brown 	}
34195b482a8SLen Brown 
34295b482a8SLen Brown 	/* Perform per-object initialization */
34395b482a8SLen Brown 
3443371c19cSBob Moore 	switch (obj_desc->common.type) {
34595b482a8SLen Brown 	case ACPI_TYPE_BUFFER:
34695b482a8SLen Brown 		/*
34795b482a8SLen Brown 		 * Defer evaluation of Buffer term_arg operand
34895b482a8SLen Brown 		 */
34995b482a8SLen Brown 		obj_desc->buffer.node =
35095b482a8SLen Brown 		    ACPI_CAST_PTR(struct acpi_namespace_node,
35195b482a8SLen Brown 				  walk_state->operands[0]);
35295b482a8SLen Brown 		obj_desc->buffer.aml_start = op->named.data;
35395b482a8SLen Brown 		obj_desc->buffer.aml_length = op->named.length;
35495b482a8SLen Brown 		break;
35595b482a8SLen Brown 
35695b482a8SLen Brown 	case ACPI_TYPE_PACKAGE:
35795b482a8SLen Brown 		/*
358a62a7117SBob Moore 		 * Defer evaluation of Package term_arg operand and all
359a62a7117SBob Moore 		 * package elements. (01/2017): We defer the element
360a62a7117SBob Moore 		 * resolution to allow forward references from the package
361a62a7117SBob Moore 		 * in order to provide compatibility with other ACPI
362a62a7117SBob Moore 		 * implementations.
36395b482a8SLen Brown 		 */
36495b482a8SLen Brown 		obj_desc->package.node =
36595b482a8SLen Brown 		    ACPI_CAST_PTR(struct acpi_namespace_node,
36695b482a8SLen Brown 				  walk_state->operands[0]);
367a62a7117SBob Moore 
368a62a7117SBob Moore 		if (!op->named.data) {
369a62a7117SBob Moore 			return_ACPI_STATUS(AE_OK);
370a62a7117SBob Moore 		}
371a62a7117SBob Moore 
37295b482a8SLen Brown 		obj_desc->package.aml_start = op->named.data;
37395b482a8SLen Brown 		obj_desc->package.aml_length = op->named.length;
37495b482a8SLen Brown 		break;
37595b482a8SLen Brown 
37695b482a8SLen Brown 	case ACPI_TYPE_INTEGER:
37795b482a8SLen Brown 
37895b482a8SLen Brown 		switch (op_info->type) {
37995b482a8SLen Brown 		case AML_TYPE_CONSTANT:
38095b482a8SLen Brown 			/*
38195b482a8SLen Brown 			 * Resolve AML Constants here - AND ONLY HERE!
38295b482a8SLen Brown 			 * All constants are integers.
38395b482a8SLen Brown 			 * We mark the integer with a flag that indicates that it started
38495b482a8SLen Brown 			 * life as a constant -- so that stores to constants will perform
38595b482a8SLen Brown 			 * as expected (noop). zero_op is used as a placeholder for optional
38695b482a8SLen Brown 			 * target operands.
38795b482a8SLen Brown 			 */
38895b482a8SLen Brown 			obj_desc->common.flags = AOPOBJ_AML_CONSTANT;
38995b482a8SLen Brown 
39095b482a8SLen Brown 			switch (opcode) {
39195b482a8SLen Brown 			case AML_ZERO_OP:
39295b482a8SLen Brown 
39395b482a8SLen Brown 				obj_desc->integer.value = 0;
39495b482a8SLen Brown 				break;
39595b482a8SLen Brown 
39695b482a8SLen Brown 			case AML_ONE_OP:
39795b482a8SLen Brown 
39895b482a8SLen Brown 				obj_desc->integer.value = 1;
39995b482a8SLen Brown 				break;
40095b482a8SLen Brown 
40195b482a8SLen Brown 			case AML_ONES_OP:
40295b482a8SLen Brown 
4035df7e6cbSBob Moore 				obj_desc->integer.value = ACPI_UINT64_MAX;
40495b482a8SLen Brown 
40595b482a8SLen Brown 				/* Truncate value if we are executing from a 32-bit ACPI table */
40695b482a8SLen Brown 
40795b482a8SLen Brown #ifndef ACPI_NO_METHOD_EXECUTION
408ef42e53fSBob Moore 				(void)acpi_ex_truncate_for32bit_table(obj_desc);
40995b482a8SLen Brown #endif
41095b482a8SLen Brown 				break;
41195b482a8SLen Brown 
41295b482a8SLen Brown 			case AML_REVISION_OP:
41395b482a8SLen Brown 
41495b482a8SLen Brown 				obj_desc->integer.value = ACPI_CA_VERSION;
41595b482a8SLen Brown 				break;
41695b482a8SLen Brown 
41795b482a8SLen Brown 			default:
41895b482a8SLen Brown 
41995b482a8SLen Brown 				ACPI_ERROR((AE_INFO,
420f6a22b0bSBob Moore 					    "Unknown constant opcode 0x%X",
42195b482a8SLen Brown 					    opcode));
42295b482a8SLen Brown 				status = AE_AML_OPERAND_TYPE;
42395b482a8SLen Brown 				break;
42495b482a8SLen Brown 			}
42595b482a8SLen Brown 			break;
42695b482a8SLen Brown 
42795b482a8SLen Brown 		case AML_TYPE_LITERAL:
42895b482a8SLen Brown 
42995b482a8SLen Brown 			obj_desc->integer.value = op->common.value.integer;
430ef42e53fSBob Moore 
43195b482a8SLen Brown #ifndef ACPI_NO_METHOD_EXECUTION
432ef42e53fSBob Moore 			if (acpi_ex_truncate_for32bit_table(obj_desc)) {
433ef42e53fSBob Moore 
434ef42e53fSBob Moore 				/* Warn if we found a 64-bit constant in a 32-bit table */
435ef42e53fSBob Moore 
436ef42e53fSBob Moore 				ACPI_WARNING((AE_INFO,
437ef42e53fSBob Moore 					      "Truncated 64-bit constant found in 32-bit table: %8.8X%8.8X => %8.8X",
438ef42e53fSBob Moore 					      ACPI_FORMAT_UINT64(op->common.
439ef42e53fSBob Moore 								 value.integer),
440ef42e53fSBob Moore 					      (u32)obj_desc->integer.value));
441ef42e53fSBob Moore 			}
44295b482a8SLen Brown #endif
44395b482a8SLen Brown 			break;
44495b482a8SLen Brown 
44595b482a8SLen Brown 		default:
4461d1ea1b7SChao Guan 
447f6a22b0bSBob Moore 			ACPI_ERROR((AE_INFO, "Unknown Integer type 0x%X",
44895b482a8SLen Brown 				    op_info->type));
44995b482a8SLen Brown 			status = AE_AML_OPERAND_TYPE;
45095b482a8SLen Brown 			break;
45195b482a8SLen Brown 		}
45295b482a8SLen Brown 		break;
45395b482a8SLen Brown 
45495b482a8SLen Brown 	case ACPI_TYPE_STRING:
45595b482a8SLen Brown 
45695b482a8SLen Brown 		obj_desc->string.pointer = op->common.value.string;
4574fa4616eSBob Moore 		obj_desc->string.length = (u32)strlen(op->common.value.string);
45895b482a8SLen Brown 
45995b482a8SLen Brown 		/*
46095b482a8SLen Brown 		 * The string is contained in the ACPI table, don't ever try
46195b482a8SLen Brown 		 * to delete it
46295b482a8SLen Brown 		 */
46395b482a8SLen Brown 		obj_desc->common.flags |= AOPOBJ_STATIC_POINTER;
46495b482a8SLen Brown 		break;
46595b482a8SLen Brown 
46695b482a8SLen Brown 	case ACPI_TYPE_METHOD:
46795b482a8SLen Brown 		break;
46895b482a8SLen Brown 
46995b482a8SLen Brown 	case ACPI_TYPE_LOCAL_REFERENCE:
47095b482a8SLen Brown 
47195b482a8SLen Brown 		switch (op_info->type) {
47295b482a8SLen Brown 		case AML_TYPE_LOCAL_VARIABLE:
47395b482a8SLen Brown 
4749ff5a21aSBob Moore 			/* Local ID (0-7) is (AML opcode - base AML_FIRST_LOCAL_OP) */
47595b482a8SLen Brown 
476ba9c3f55SBob Moore 			obj_desc->reference.value =
4779ff5a21aSBob Moore 			    ((u32)opcode) - AML_FIRST_LOCAL_OP;
47895b482a8SLen Brown 			obj_desc->reference.class = ACPI_REFCLASS_LOCAL;
47995b482a8SLen Brown 
48095b482a8SLen Brown #ifndef ACPI_NO_METHOD_EXECUTION
48195b482a8SLen Brown 			status =
48295b482a8SLen Brown 			    acpi_ds_method_data_get_node(ACPI_REFCLASS_LOCAL,
48395b482a8SLen Brown 							 obj_desc->reference.
48495b482a8SLen Brown 							 value, walk_state,
48595b482a8SLen Brown 							 ACPI_CAST_INDIRECT_PTR
48695b482a8SLen Brown 							 (struct
48795b482a8SLen Brown 							  acpi_namespace_node,
48895b482a8SLen Brown 							  &obj_desc->reference.
48995b482a8SLen Brown 							  object));
49095b482a8SLen Brown #endif
49195b482a8SLen Brown 			break;
49295b482a8SLen Brown 
49395b482a8SLen Brown 		case AML_TYPE_METHOD_ARGUMENT:
49495b482a8SLen Brown 
4959ff5a21aSBob Moore 			/* Arg ID (0-6) is (AML opcode - base AML_FIRST_ARG_OP) */
49695b482a8SLen Brown 
4979ff5a21aSBob Moore 			obj_desc->reference.value =
4989ff5a21aSBob Moore 			    ((u32)opcode) - AML_FIRST_ARG_OP;
49995b482a8SLen Brown 			obj_desc->reference.class = ACPI_REFCLASS_ARG;
50095b482a8SLen Brown 
50195b482a8SLen Brown #ifndef ACPI_NO_METHOD_EXECUTION
50295b482a8SLen Brown 			status = acpi_ds_method_data_get_node(ACPI_REFCLASS_ARG,
50395b482a8SLen Brown 							      obj_desc->
50495b482a8SLen Brown 							      reference.value,
50595b482a8SLen Brown 							      walk_state,
50695b482a8SLen Brown 							      ACPI_CAST_INDIRECT_PTR
50795b482a8SLen Brown 							      (struct
50895b482a8SLen Brown 							       acpi_namespace_node,
50995b482a8SLen Brown 							       &obj_desc->
51095b482a8SLen Brown 							       reference.
51195b482a8SLen Brown 							       object));
51295b482a8SLen Brown #endif
51395b482a8SLen Brown 			break;
51495b482a8SLen Brown 
51595b482a8SLen Brown 		default:	/* Object name or Debug object */
51695b482a8SLen Brown 
51795b482a8SLen Brown 			switch (op->common.aml_opcode) {
51895b482a8SLen Brown 			case AML_INT_NAMEPATH_OP:
51995b482a8SLen Brown 
52095b482a8SLen Brown 				/* Node was saved in Op */
52195b482a8SLen Brown 
52295b482a8SLen Brown 				obj_desc->reference.node = op->common.node;
523a62a7117SBob Moore 				obj_desc->reference.class = ACPI_REFCLASS_NAME;
524a62a7117SBob Moore 				if (op->common.node) {
52595b482a8SLen Brown 					obj_desc->reference.object =
52695b482a8SLen Brown 					    op->common.node->object;
527a62a7117SBob Moore 				}
52895b482a8SLen Brown 				break;
52995b482a8SLen Brown 
53095b482a8SLen Brown 			case AML_DEBUG_OP:
53195b482a8SLen Brown 
53295b482a8SLen Brown 				obj_desc->reference.class = ACPI_REFCLASS_DEBUG;
53395b482a8SLen Brown 				break;
53495b482a8SLen Brown 
53595b482a8SLen Brown 			default:
53695b482a8SLen Brown 
53795b482a8SLen Brown 				ACPI_ERROR((AE_INFO,
538f6a22b0bSBob Moore 					    "Unimplemented reference type for AML opcode: 0x%4.4X",
53995b482a8SLen Brown 					    opcode));
54095b482a8SLen Brown 				return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
54195b482a8SLen Brown 			}
54295b482a8SLen Brown 			break;
54395b482a8SLen Brown 		}
54495b482a8SLen Brown 		break;
54595b482a8SLen Brown 
54695b482a8SLen Brown 	default:
54795b482a8SLen Brown 
548f6a22b0bSBob Moore 		ACPI_ERROR((AE_INFO, "Unimplemented data type: 0x%X",
5493371c19cSBob Moore 			    obj_desc->common.type));
55095b482a8SLen Brown 
55195b482a8SLen Brown 		status = AE_AML_OPERAND_TYPE;
55295b482a8SLen Brown 		break;
55395b482a8SLen Brown 	}
55495b482a8SLen Brown 
55595b482a8SLen Brown 	return_ACPI_STATUS(status);
55695b482a8SLen Brown }
557