xref: /openbmc/linux/drivers/acpi/acpica/dsobject.c (revision 1ac731c529cd4d6adbce134754b51ff7d822b145)
195857638SErik 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  *
6*612c2932SBob Moore  * Copyright (C) 2000 - 2023, Intel Corp.
795b482a8SLen Brown  *
895857638SErik 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 /*******************************************************************************
2295b482a8SLen Brown  *
2395b482a8SLen Brown  * FUNCTION:    acpi_ds_build_internal_object
2495b482a8SLen Brown  *
2595b482a8SLen Brown  * PARAMETERS:  walk_state      - Current walk state
26ba494beeSBob Moore  *              op              - Parser object to be translated
2795b482a8SLen Brown  *              obj_desc_ptr    - Where the ACPI internal object is returned
2895b482a8SLen Brown  *
2995b482a8SLen Brown  * RETURN:      Status
3095b482a8SLen Brown  *
3195b482a8SLen Brown  * DESCRIPTION: Translate a parser Op object to the equivalent namespace object
3295b482a8SLen Brown  *              Simple objects are any objects other than a package object!
3395b482a8SLen Brown  *
3495b482a8SLen Brown  ******************************************************************************/
35a62a7117SBob Moore acpi_status
acpi_ds_build_internal_object(struct acpi_walk_state * walk_state,union acpi_parse_object * op,union acpi_operand_object ** obj_desc_ptr)3695b482a8SLen Brown acpi_ds_build_internal_object(struct acpi_walk_state *walk_state,
3795b482a8SLen Brown 			      union acpi_parse_object *op,
3895b482a8SLen Brown 			      union acpi_operand_object **obj_desc_ptr)
3995b482a8SLen Brown {
4095b482a8SLen Brown 	union acpi_operand_object *obj_desc;
4195b482a8SLen Brown 	acpi_status status;
4295b482a8SLen Brown 
4395b482a8SLen Brown 	ACPI_FUNCTION_TRACE(ds_build_internal_object);
4495b482a8SLen Brown 
4595b482a8SLen Brown 	*obj_desc_ptr = NULL;
4695b482a8SLen Brown 	if (op->common.aml_opcode == AML_INT_NAMEPATH_OP) {
4795b482a8SLen Brown 		/*
4895b482a8SLen Brown 		 * This is a named object reference. If this name was
49a62a7117SBob Moore 		 * previously looked up in the namespace, it was stored in
50a62a7117SBob Moore 		 * this op. Otherwise, go ahead and look it up now
5195b482a8SLen Brown 		 */
5295b482a8SLen Brown 		if (!op->common.node) {
53a62a7117SBob Moore 
54a62a7117SBob Moore 			/* Check if we are resolving a named reference within a package */
55a62a7117SBob Moore 
56a62a7117SBob Moore 			if ((op->common.parent->common.aml_opcode ==
57a62a7117SBob Moore 			     AML_PACKAGE_OP)
58a62a7117SBob Moore 			    || (op->common.parent->common.aml_opcode ==
59a62a7117SBob Moore 				AML_VARIABLE_PACKAGE_OP)) {
60a62a7117SBob Moore 				/*
61a62a7117SBob Moore 				 * We won't resolve package elements here, we will do this
62a62a7117SBob Moore 				 * after all ACPI tables are loaded into the namespace. This
63a62a7117SBob Moore 				 * behavior supports both forward references to named objects
64a62a7117SBob Moore 				 * and external references to objects in other tables.
65a62a7117SBob Moore 				 */
66a62a7117SBob Moore 				goto create_new_object;
67a62a7117SBob Moore 			} else {
6895b482a8SLen Brown 				status = acpi_ns_lookup(walk_state->scope_info,
6995b482a8SLen Brown 							op->common.value.string,
7095b482a8SLen Brown 							ACPI_TYPE_ANY,
7195b482a8SLen Brown 							ACPI_IMODE_EXECUTE,
7295b482a8SLen Brown 							ACPI_NS_SEARCH_PARENT |
73a62a7117SBob Moore 							ACPI_NS_DONT_OPEN_SCOPE,
74a62a7117SBob Moore 							NULL,
75a62a7117SBob Moore 							ACPI_CAST_INDIRECT_PTR
7695b482a8SLen Brown 							(struct
7795b482a8SLen Brown 							 acpi_namespace_node,
78a62a7117SBob Moore 							 &(op->common.node)));
7995b482a8SLen Brown 				if (ACPI_FAILURE(status)) {
8016ccf829SBob Moore 					ACPI_ERROR_NAMESPACE(walk_state->
8116ccf829SBob Moore 							     scope_info,
8216ccf829SBob Moore 							     op->common.value.
83a62a7117SBob Moore 							     string, status);
8495b482a8SLen Brown 					return_ACPI_STATUS(status);
8595b482a8SLen Brown 				}
8695b482a8SLen Brown 			}
8795b482a8SLen Brown 		}
8895b482a8SLen Brown 	}
8995b482a8SLen Brown 
90a62a7117SBob Moore create_new_object:
91a62a7117SBob Moore 
9295b482a8SLen Brown 	/* Create and init a new internal ACPI object */
9395b482a8SLen Brown 
9495b482a8SLen Brown 	obj_desc = acpi_ut_create_internal_object((acpi_ps_get_opcode_info
9595b482a8SLen Brown 						   (op->common.aml_opcode))->
9695b482a8SLen Brown 						  object_type);
9795b482a8SLen Brown 	if (!obj_desc) {
9895b482a8SLen Brown 		return_ACPI_STATUS(AE_NO_MEMORY);
9995b482a8SLen Brown 	}
10095b482a8SLen Brown 
10195b482a8SLen Brown 	status =
10295b482a8SLen Brown 	    acpi_ds_init_object_from_op(walk_state, op, op->common.aml_opcode,
10395b482a8SLen Brown 					&obj_desc);
10495b482a8SLen Brown 	if (ACPI_FAILURE(status)) {
10595b482a8SLen Brown 		acpi_ut_remove_reference(obj_desc);
10695b482a8SLen Brown 		return_ACPI_STATUS(status);
10795b482a8SLen Brown 	}
10895b482a8SLen Brown 
109a62a7117SBob Moore 	/*
110a62a7117SBob Moore 	 * Handling for unresolved package reference elements.
111a62a7117SBob Moore 	 * These are elements that are namepaths.
112a62a7117SBob Moore 	 */
113a62a7117SBob Moore 	if ((op->common.parent->common.aml_opcode == AML_PACKAGE_OP) ||
114a62a7117SBob Moore 	    (op->common.parent->common.aml_opcode == AML_VARIABLE_PACKAGE_OP)) {
115a62a7117SBob Moore 		obj_desc->reference.resolved = TRUE;
116a62a7117SBob Moore 
117a62a7117SBob Moore 		if ((op->common.aml_opcode == AML_INT_NAMEPATH_OP) &&
118a62a7117SBob Moore 		    !obj_desc->reference.node) {
119a62a7117SBob Moore 			/*
120a62a7117SBob Moore 			 * Name was unresolved above.
121a62a7117SBob Moore 			 * Get the prefix node for later lookup
122a62a7117SBob Moore 			 */
123a62a7117SBob Moore 			obj_desc->reference.node =
124a62a7117SBob Moore 			    walk_state->scope_info->scope.node;
125a62a7117SBob Moore 			obj_desc->reference.aml = op->common.aml;
126a62a7117SBob Moore 			obj_desc->reference.resolved = FALSE;
127a62a7117SBob Moore 		}
128a62a7117SBob Moore 	}
129a62a7117SBob Moore 
13095b482a8SLen Brown 	*obj_desc_ptr = obj_desc;
13195b482a8SLen Brown 	return_ACPI_STATUS(status);
13295b482a8SLen Brown }
13395b482a8SLen Brown 
13495b482a8SLen Brown /*******************************************************************************
13595b482a8SLen Brown  *
13695b482a8SLen Brown  * FUNCTION:    acpi_ds_build_internal_buffer_obj
13795b482a8SLen Brown  *
13895b482a8SLen Brown  * PARAMETERS:  walk_state      - Current walk state
139ba494beeSBob Moore  *              op              - Parser object to be translated
14095b482a8SLen Brown  *              buffer_length   - Length of the buffer
14195b482a8SLen Brown  *              obj_desc_ptr    - Where the ACPI internal object is returned
14295b482a8SLen Brown  *
14395b482a8SLen Brown  * RETURN:      Status
14495b482a8SLen Brown  *
14595b482a8SLen Brown  * DESCRIPTION: Translate a parser Op package object to the equivalent
14695b482a8SLen Brown  *              namespace object
14795b482a8SLen Brown  *
14895b482a8SLen Brown  ******************************************************************************/
14995b482a8SLen Brown 
15095b482a8SLen Brown acpi_status
acpi_ds_build_internal_buffer_obj(struct acpi_walk_state * walk_state,union acpi_parse_object * op,u32 buffer_length,union acpi_operand_object ** obj_desc_ptr)15195b482a8SLen Brown acpi_ds_build_internal_buffer_obj(struct acpi_walk_state *walk_state,
15295b482a8SLen Brown 				  union acpi_parse_object *op,
15395b482a8SLen Brown 				  u32 buffer_length,
15495b482a8SLen Brown 				  union acpi_operand_object **obj_desc_ptr)
15595b482a8SLen Brown {
15695b482a8SLen Brown 	union acpi_parse_object *arg;
15795b482a8SLen Brown 	union acpi_operand_object *obj_desc;
15895b482a8SLen Brown 	union acpi_parse_object *byte_list;
15995b482a8SLen Brown 	u32 byte_list_length = 0;
16095b482a8SLen Brown 
16195b482a8SLen Brown 	ACPI_FUNCTION_TRACE(ds_build_internal_buffer_obj);
16295b482a8SLen Brown 
16395b482a8SLen Brown 	/*
16495b482a8SLen Brown 	 * If we are evaluating a Named buffer object "Name (xxxx, Buffer)".
16595b482a8SLen Brown 	 * The buffer object already exists (from the NS node), otherwise it must
16695b482a8SLen Brown 	 * be created.
16795b482a8SLen Brown 	 */
16895b482a8SLen Brown 	obj_desc = *obj_desc_ptr;
16995b482a8SLen Brown 	if (!obj_desc) {
17095b482a8SLen Brown 
17195b482a8SLen Brown 		/* Create a new buffer object */
17295b482a8SLen Brown 
17395b482a8SLen Brown 		obj_desc = acpi_ut_create_internal_object(ACPI_TYPE_BUFFER);
17495b482a8SLen Brown 		*obj_desc_ptr = obj_desc;
17595b482a8SLen Brown 		if (!obj_desc) {
17695b482a8SLen Brown 			return_ACPI_STATUS(AE_NO_MEMORY);
17795b482a8SLen Brown 		}
17895b482a8SLen Brown 	}
17995b482a8SLen Brown 
18095b482a8SLen Brown 	/*
18195b482a8SLen Brown 	 * Second arg is the buffer data (optional) byte_list can be either
18295b482a8SLen Brown 	 * individual bytes or a string initializer. In either case, a
18395b482a8SLen Brown 	 * byte_list appears in the AML.
18495b482a8SLen Brown 	 */
18595b482a8SLen Brown 	arg = op->common.value.arg;	/* skip first arg */
18695b482a8SLen Brown 
18795b482a8SLen Brown 	byte_list = arg->named.next;
18895b482a8SLen Brown 	if (byte_list) {
18995b482a8SLen Brown 		if (byte_list->common.aml_opcode != AML_INT_BYTELIST_OP) {
19095b482a8SLen Brown 			ACPI_ERROR((AE_INFO,
191f6a22b0bSBob Moore 				    "Expecting bytelist, found AML opcode 0x%X in op %p",
19295b482a8SLen Brown 				    byte_list->common.aml_opcode, byte_list));
19395b482a8SLen Brown 
19495b482a8SLen Brown 			acpi_ut_remove_reference(obj_desc);
19595b482a8SLen Brown 			return (AE_TYPE);
19695b482a8SLen Brown 		}
19795b482a8SLen Brown 
19895b482a8SLen Brown 		byte_list_length = (u32) byte_list->common.value.integer;
19995b482a8SLen Brown 	}
20095b482a8SLen Brown 
20195b482a8SLen Brown 	/*
20295b482a8SLen Brown 	 * The buffer length (number of bytes) will be the larger of:
20395b482a8SLen Brown 	 * 1) The specified buffer length and
20495b482a8SLen Brown 	 * 2) The length of the initializer byte list
20595b482a8SLen Brown 	 */
20695b482a8SLen Brown 	obj_desc->buffer.length = buffer_length;
20795b482a8SLen Brown 	if (byte_list_length > buffer_length) {
20895b482a8SLen Brown 		obj_desc->buffer.length = byte_list_length;
20995b482a8SLen Brown 	}
21095b482a8SLen Brown 
21195b482a8SLen Brown 	/* Allocate the buffer */
21295b482a8SLen Brown 
21395b482a8SLen Brown 	if (obj_desc->buffer.length == 0) {
21495b482a8SLen Brown 		obj_desc->buffer.pointer = NULL;
21595b482a8SLen Brown 		ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
21695b482a8SLen Brown 				  "Buffer defined with zero length in AML, creating\n"));
21795b482a8SLen Brown 	} else {
21895b482a8SLen Brown 		obj_desc->buffer.pointer =
21995b482a8SLen Brown 		    ACPI_ALLOCATE_ZEROED(obj_desc->buffer.length);
22095b482a8SLen Brown 		if (!obj_desc->buffer.pointer) {
22195b482a8SLen Brown 			acpi_ut_delete_object_desc(obj_desc);
22295b482a8SLen Brown 			return_ACPI_STATUS(AE_NO_MEMORY);
22395b482a8SLen Brown 		}
22495b482a8SLen Brown 
22595b482a8SLen Brown 		/* Initialize buffer from the byte_list (if present) */
22695b482a8SLen Brown 
22795b482a8SLen Brown 		if (byte_list) {
2284fa4616eSBob Moore 			memcpy(obj_desc->buffer.pointer, byte_list->named.data,
2294fa4616eSBob Moore 			       byte_list_length);
23095b482a8SLen Brown 		}
23195b482a8SLen Brown 	}
23295b482a8SLen Brown 
23395b482a8SLen Brown 	obj_desc->buffer.flags |= AOPOBJ_DATA_VALID;
23495b482a8SLen Brown 	op->common.node = ACPI_CAST_PTR(struct acpi_namespace_node, obj_desc);
23595b482a8SLen Brown 	return_ACPI_STATUS(AE_OK);
23695b482a8SLen Brown }
23795b482a8SLen Brown 
23895b482a8SLen Brown /*******************************************************************************
23995b482a8SLen Brown  *
24095b482a8SLen Brown  * FUNCTION:    acpi_ds_create_node
24195b482a8SLen Brown  *
24295b482a8SLen Brown  * PARAMETERS:  walk_state      - Current walk state
243ba494beeSBob Moore  *              node            - NS Node to be initialized
244ba494beeSBob Moore  *              op              - Parser object to be translated
24595b482a8SLen Brown  *
24695b482a8SLen Brown  * RETURN:      Status
24795b482a8SLen Brown  *
24895b482a8SLen Brown  * DESCRIPTION: Create the object to be associated with a namespace node
24995b482a8SLen Brown  *
25095b482a8SLen Brown  ******************************************************************************/
25195b482a8SLen Brown 
25295b482a8SLen Brown acpi_status
acpi_ds_create_node(struct acpi_walk_state * walk_state,struct acpi_namespace_node * node,union acpi_parse_object * op)25395b482a8SLen Brown acpi_ds_create_node(struct acpi_walk_state *walk_state,
25495b482a8SLen Brown 		    struct acpi_namespace_node *node,
25595b482a8SLen Brown 		    union acpi_parse_object *op)
25695b482a8SLen Brown {
25795b482a8SLen Brown 	acpi_status status;
25895b482a8SLen Brown 	union acpi_operand_object *obj_desc;
25995b482a8SLen Brown 
26095b482a8SLen Brown 	ACPI_FUNCTION_TRACE_PTR(ds_create_node, op);
26195b482a8SLen Brown 
26295b482a8SLen Brown 	/*
26395b482a8SLen Brown 	 * Because of the execution pass through the non-control-method
26495b482a8SLen Brown 	 * parts of the table, we can arrive here twice. Only init
26595b482a8SLen Brown 	 * the named object node the first time through
26695b482a8SLen Brown 	 */
26795b482a8SLen Brown 	if (acpi_ns_get_attached_object(node)) {
26895b482a8SLen Brown 		return_ACPI_STATUS(AE_OK);
26995b482a8SLen Brown 	}
27095b482a8SLen Brown 
27195b482a8SLen Brown 	if (!op->common.value.arg) {
27295b482a8SLen Brown 
27395b482a8SLen Brown 		/* No arguments, there is nothing to do */
27495b482a8SLen Brown 
27595b482a8SLen Brown 		return_ACPI_STATUS(AE_OK);
27695b482a8SLen Brown 	}
27795b482a8SLen Brown 
27895b482a8SLen Brown 	/* Build an internal object for the argument(s) */
27995b482a8SLen Brown 
2801fad8738SBob Moore 	status =
2811fad8738SBob Moore 	    acpi_ds_build_internal_object(walk_state, op->common.value.arg,
28295b482a8SLen Brown 					  &obj_desc);
28395b482a8SLen Brown 	if (ACPI_FAILURE(status)) {
28495b482a8SLen Brown 		return_ACPI_STATUS(status);
28595b482a8SLen Brown 	}
28695b482a8SLen Brown 
28795b482a8SLen Brown 	/* Re-type the object according to its argument */
28895b482a8SLen Brown 
2893371c19cSBob Moore 	node->type = obj_desc->common.type;
29095b482a8SLen Brown 
29195b482a8SLen Brown 	/* Attach obj to node */
29295b482a8SLen Brown 
29395b482a8SLen Brown 	status = acpi_ns_attach_object(node, obj_desc, node->type);
29495b482a8SLen Brown 
29595b482a8SLen Brown 	/* Remove local reference to the object */
29695b482a8SLen Brown 
29795b482a8SLen Brown 	acpi_ut_remove_reference(obj_desc);
29895b482a8SLen Brown 	return_ACPI_STATUS(status);
29995b482a8SLen Brown }
30095b482a8SLen Brown 
30195b482a8SLen Brown /*******************************************************************************
30295b482a8SLen Brown  *
30395b482a8SLen Brown  * FUNCTION:    acpi_ds_init_object_from_op
30495b482a8SLen Brown  *
30595b482a8SLen Brown  * PARAMETERS:  walk_state      - Current walk state
306ba494beeSBob Moore  *              op              - Parser op used to init the internal object
307ba494beeSBob Moore  *              opcode          - AML opcode associated with the object
30895b482a8SLen Brown  *              ret_obj_desc    - Namespace object to be initialized
30995b482a8SLen Brown  *
31095b482a8SLen Brown  * RETURN:      Status
31195b482a8SLen Brown  *
31295b482a8SLen Brown  * DESCRIPTION: Initialize a namespace object from a parser Op and its
31395b482a8SLen Brown  *              associated arguments. The namespace object is a more compact
31495b482a8SLen Brown  *              representation of the Op and its arguments.
31595b482a8SLen Brown  *
31695b482a8SLen Brown  ******************************************************************************/
31795b482a8SLen Brown 
31895b482a8SLen Brown acpi_status
acpi_ds_init_object_from_op(struct acpi_walk_state * walk_state,union acpi_parse_object * op,u16 opcode,union acpi_operand_object ** ret_obj_desc)31995b482a8SLen Brown acpi_ds_init_object_from_op(struct acpi_walk_state *walk_state,
32095b482a8SLen Brown 			    union acpi_parse_object *op,
32195b482a8SLen Brown 			    u16 opcode,
32295b482a8SLen Brown 			    union acpi_operand_object **ret_obj_desc)
32395b482a8SLen Brown {
32495b482a8SLen Brown 	const struct acpi_opcode_info *op_info;
32595b482a8SLen Brown 	union acpi_operand_object *obj_desc;
32695b482a8SLen Brown 	acpi_status status = AE_OK;
32795b482a8SLen Brown 
32895b482a8SLen Brown 	ACPI_FUNCTION_TRACE(ds_init_object_from_op);
32995b482a8SLen Brown 
33095b482a8SLen Brown 	obj_desc = *ret_obj_desc;
33195b482a8SLen Brown 	op_info = acpi_ps_get_opcode_info(opcode);
33295b482a8SLen Brown 	if (op_info->class == AML_CLASS_UNKNOWN) {
33395b482a8SLen Brown 
33495b482a8SLen Brown 		/* Unknown opcode */
33595b482a8SLen Brown 
33695b482a8SLen Brown 		return_ACPI_STATUS(AE_TYPE);
33795b482a8SLen Brown 	}
33895b482a8SLen Brown 
33995b482a8SLen Brown 	/* Perform per-object initialization */
34095b482a8SLen Brown 
3413371c19cSBob Moore 	switch (obj_desc->common.type) {
34295b482a8SLen Brown 	case ACPI_TYPE_BUFFER:
34395b482a8SLen Brown 		/*
34495b482a8SLen Brown 		 * Defer evaluation of Buffer term_arg operand
34595b482a8SLen Brown 		 */
34695b482a8SLen Brown 		obj_desc->buffer.node =
34795b482a8SLen Brown 		    ACPI_CAST_PTR(struct acpi_namespace_node,
34895b482a8SLen Brown 				  walk_state->operands[0]);
34995b482a8SLen Brown 		obj_desc->buffer.aml_start = op->named.data;
35095b482a8SLen Brown 		obj_desc->buffer.aml_length = op->named.length;
35195b482a8SLen Brown 		break;
35295b482a8SLen Brown 
35395b482a8SLen Brown 	case ACPI_TYPE_PACKAGE:
35495b482a8SLen Brown 		/*
355a62a7117SBob Moore 		 * Defer evaluation of Package term_arg operand and all
356a62a7117SBob Moore 		 * package elements. (01/2017): We defer the element
357a62a7117SBob Moore 		 * resolution to allow forward references from the package
358a62a7117SBob Moore 		 * in order to provide compatibility with other ACPI
359a62a7117SBob Moore 		 * implementations.
36095b482a8SLen Brown 		 */
36195b482a8SLen Brown 		obj_desc->package.node =
36295b482a8SLen Brown 		    ACPI_CAST_PTR(struct acpi_namespace_node,
36395b482a8SLen Brown 				  walk_state->operands[0]);
364a62a7117SBob Moore 
365a62a7117SBob Moore 		if (!op->named.data) {
366a62a7117SBob Moore 			return_ACPI_STATUS(AE_OK);
367a62a7117SBob Moore 		}
368a62a7117SBob Moore 
36995b482a8SLen Brown 		obj_desc->package.aml_start = op->named.data;
37095b482a8SLen Brown 		obj_desc->package.aml_length = op->named.length;
37195b482a8SLen Brown 		break;
37295b482a8SLen Brown 
37395b482a8SLen Brown 	case ACPI_TYPE_INTEGER:
37495b482a8SLen Brown 
37595b482a8SLen Brown 		switch (op_info->type) {
37695b482a8SLen Brown 		case AML_TYPE_CONSTANT:
37795b482a8SLen Brown 			/*
37895b482a8SLen Brown 			 * Resolve AML Constants here - AND ONLY HERE!
37995b482a8SLen Brown 			 * All constants are integers.
38095b482a8SLen Brown 			 * We mark the integer with a flag that indicates that it started
38195b482a8SLen Brown 			 * life as a constant -- so that stores to constants will perform
38295b482a8SLen Brown 			 * as expected (noop). zero_op is used as a placeholder for optional
38395b482a8SLen Brown 			 * target operands.
38495b482a8SLen Brown 			 */
38595b482a8SLen Brown 			obj_desc->common.flags = AOPOBJ_AML_CONSTANT;
38695b482a8SLen Brown 
38795b482a8SLen Brown 			switch (opcode) {
38895b482a8SLen Brown 			case AML_ZERO_OP:
38995b482a8SLen Brown 
39095b482a8SLen Brown 				obj_desc->integer.value = 0;
39195b482a8SLen Brown 				break;
39295b482a8SLen Brown 
39395b482a8SLen Brown 			case AML_ONE_OP:
39495b482a8SLen Brown 
39595b482a8SLen Brown 				obj_desc->integer.value = 1;
39695b482a8SLen Brown 				break;
39795b482a8SLen Brown 
39895b482a8SLen Brown 			case AML_ONES_OP:
39995b482a8SLen Brown 
4005df7e6cbSBob Moore 				obj_desc->integer.value = ACPI_UINT64_MAX;
40195b482a8SLen Brown 
40295b482a8SLen Brown 				/* Truncate value if we are executing from a 32-bit ACPI table */
40395b482a8SLen Brown 
404ef42e53fSBob Moore 				(void)acpi_ex_truncate_for32bit_table(obj_desc);
40595b482a8SLen Brown 				break;
40695b482a8SLen Brown 
40795b482a8SLen Brown 			case AML_REVISION_OP:
40895b482a8SLen Brown 
40995b482a8SLen Brown 				obj_desc->integer.value = ACPI_CA_VERSION;
41095b482a8SLen Brown 				break;
41195b482a8SLen Brown 
41295b482a8SLen Brown 			default:
41395b482a8SLen Brown 
41495b482a8SLen Brown 				ACPI_ERROR((AE_INFO,
415f6a22b0bSBob Moore 					    "Unknown constant opcode 0x%X",
41695b482a8SLen Brown 					    opcode));
41795b482a8SLen Brown 				status = AE_AML_OPERAND_TYPE;
41895b482a8SLen Brown 				break;
41995b482a8SLen Brown 			}
42095b482a8SLen Brown 			break;
42195b482a8SLen Brown 
42295b482a8SLen Brown 		case AML_TYPE_LITERAL:
42395b482a8SLen Brown 
42495b482a8SLen Brown 			obj_desc->integer.value = op->common.value.integer;
425ef42e53fSBob Moore 
426ef42e53fSBob Moore 			if (acpi_ex_truncate_for32bit_table(obj_desc)) {
427ef42e53fSBob Moore 
428ef42e53fSBob Moore 				/* Warn if we found a 64-bit constant in a 32-bit table */
429ef42e53fSBob Moore 
430ef42e53fSBob Moore 				ACPI_WARNING((AE_INFO,
431ef42e53fSBob Moore 					      "Truncated 64-bit constant found in 32-bit table: %8.8X%8.8X => %8.8X",
432ef42e53fSBob Moore 					      ACPI_FORMAT_UINT64(op->common.
433ef42e53fSBob Moore 								 value.integer),
434ef42e53fSBob Moore 					      (u32)obj_desc->integer.value));
435ef42e53fSBob Moore 			}
43695b482a8SLen Brown 			break;
43795b482a8SLen Brown 
43895b482a8SLen Brown 		default:
4391d1ea1b7SChao Guan 
440f6a22b0bSBob Moore 			ACPI_ERROR((AE_INFO, "Unknown Integer type 0x%X",
44195b482a8SLen Brown 				    op_info->type));
44295b482a8SLen Brown 			status = AE_AML_OPERAND_TYPE;
44395b482a8SLen Brown 			break;
44495b482a8SLen Brown 		}
44595b482a8SLen Brown 		break;
44695b482a8SLen Brown 
44795b482a8SLen Brown 	case ACPI_TYPE_STRING:
44895b482a8SLen Brown 
44995b482a8SLen Brown 		obj_desc->string.pointer = op->common.value.string;
4504fa4616eSBob Moore 		obj_desc->string.length = (u32)strlen(op->common.value.string);
45195b482a8SLen Brown 
45295b482a8SLen Brown 		/*
45395b482a8SLen Brown 		 * The string is contained in the ACPI table, don't ever try
45495b482a8SLen Brown 		 * to delete it
45595b482a8SLen Brown 		 */
45695b482a8SLen Brown 		obj_desc->common.flags |= AOPOBJ_STATIC_POINTER;
45795b482a8SLen Brown 		break;
45895b482a8SLen Brown 
45995b482a8SLen Brown 	case ACPI_TYPE_METHOD:
46095b482a8SLen Brown 		break;
46195b482a8SLen Brown 
46295b482a8SLen Brown 	case ACPI_TYPE_LOCAL_REFERENCE:
46395b482a8SLen Brown 
46495b482a8SLen Brown 		switch (op_info->type) {
46595b482a8SLen Brown 		case AML_TYPE_LOCAL_VARIABLE:
46695b482a8SLen Brown 
4679ff5a21aSBob Moore 			/* Local ID (0-7) is (AML opcode - base AML_FIRST_LOCAL_OP) */
46895b482a8SLen Brown 
469ba9c3f55SBob Moore 			obj_desc->reference.value =
4709ff5a21aSBob Moore 			    ((u32)opcode) - AML_FIRST_LOCAL_OP;
47195b482a8SLen Brown 			obj_desc->reference.class = ACPI_REFCLASS_LOCAL;
47295b482a8SLen Brown 
47395b482a8SLen Brown 			status =
47495b482a8SLen Brown 			    acpi_ds_method_data_get_node(ACPI_REFCLASS_LOCAL,
47595b482a8SLen Brown 							 obj_desc->reference.
47695b482a8SLen Brown 							 value, walk_state,
47795b482a8SLen Brown 							 ACPI_CAST_INDIRECT_PTR
47895b482a8SLen Brown 							 (struct
47995b482a8SLen Brown 							  acpi_namespace_node,
48095b482a8SLen Brown 							  &obj_desc->reference.
48195b482a8SLen Brown 							  object));
48295b482a8SLen Brown 			break;
48395b482a8SLen Brown 
48495b482a8SLen Brown 		case AML_TYPE_METHOD_ARGUMENT:
48595b482a8SLen Brown 
4869ff5a21aSBob Moore 			/* Arg ID (0-6) is (AML opcode - base AML_FIRST_ARG_OP) */
48795b482a8SLen Brown 
4889ff5a21aSBob Moore 			obj_desc->reference.value =
4899ff5a21aSBob Moore 			    ((u32)opcode) - AML_FIRST_ARG_OP;
49095b482a8SLen Brown 			obj_desc->reference.class = ACPI_REFCLASS_ARG;
49195b482a8SLen Brown 
49295b482a8SLen Brown 			status = acpi_ds_method_data_get_node(ACPI_REFCLASS_ARG,
49395b482a8SLen Brown 							      obj_desc->
49495b482a8SLen Brown 							      reference.value,
49595b482a8SLen Brown 							      walk_state,
49695b482a8SLen Brown 							      ACPI_CAST_INDIRECT_PTR
49795b482a8SLen Brown 							      (struct
49895b482a8SLen Brown 							       acpi_namespace_node,
49995b482a8SLen Brown 							       &obj_desc->
50095b482a8SLen Brown 							       reference.
50195b482a8SLen Brown 							       object));
50295b482a8SLen Brown 			break;
50395b482a8SLen Brown 
50495b482a8SLen Brown 		default:	/* Object name or Debug object */
50595b482a8SLen Brown 
50695b482a8SLen Brown 			switch (op->common.aml_opcode) {
50795b482a8SLen Brown 			case AML_INT_NAMEPATH_OP:
50895b482a8SLen Brown 
50995b482a8SLen Brown 				/* Node was saved in Op */
51095b482a8SLen Brown 
51195b482a8SLen Brown 				obj_desc->reference.node = op->common.node;
512a62a7117SBob Moore 				obj_desc->reference.class = ACPI_REFCLASS_NAME;
513a62a7117SBob Moore 				if (op->common.node) {
51495b482a8SLen Brown 					obj_desc->reference.object =
51595b482a8SLen Brown 					    op->common.node->object;
516a62a7117SBob Moore 				}
51795b482a8SLen Brown 				break;
51895b482a8SLen Brown 
51995b482a8SLen Brown 			case AML_DEBUG_OP:
52095b482a8SLen Brown 
52195b482a8SLen Brown 				obj_desc->reference.class = ACPI_REFCLASS_DEBUG;
52295b482a8SLen Brown 				break;
52395b482a8SLen Brown 
52495b482a8SLen Brown 			default:
52595b482a8SLen Brown 
52695b482a8SLen Brown 				ACPI_ERROR((AE_INFO,
527f6a22b0bSBob Moore 					    "Unimplemented reference type for AML opcode: 0x%4.4X",
52895b482a8SLen Brown 					    opcode));
52995b482a8SLen Brown 				return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
53095b482a8SLen Brown 			}
53195b482a8SLen Brown 			break;
53295b482a8SLen Brown 		}
53395b482a8SLen Brown 		break;
53495b482a8SLen Brown 
53595b482a8SLen Brown 	default:
53695b482a8SLen Brown 
537f6a22b0bSBob Moore 		ACPI_ERROR((AE_INFO, "Unimplemented data type: 0x%X",
5383371c19cSBob Moore 			    obj_desc->common.type));
53995b482a8SLen Brown 
54095b482a8SLen Brown 		status = AE_AML_OPERAND_TYPE;
54195b482a8SLen Brown 		break;
54295b482a8SLen Brown 	}
54395b482a8SLen Brown 
54495b482a8SLen Brown 	return_ACPI_STATUS(status);
54595b482a8SLen Brown }
546