blob: 6992c8d5ab431db04d6987e1faa6afe6c1147e53 [file] [log] [blame]
Erik Schmauss95857632018-03-14 16:13:07 -07001// SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0
Linus Torvalds1da177e2005-04-16 15:20:36 -07002/******************************************************************************
3 *
4 * Module Name: dsobject - Dispatcher object management routines
5 *
Bob Mooreda6f8322018-01-04 10:06:38 -08006 * Copyright (C) 2000 - 2018, Intel Corp.
Linus Torvalds1da177e2005-04-16 15:20:36 -07007 *
Erik Schmauss95857632018-03-14 16:13:07 -07008 *****************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -07009
Linus Torvalds1da177e2005-04-16 15:20:36 -070010#include <acpi/acpi.h>
Len Browne2f7a772009-01-09 00:30:03 -050011#include "accommon.h"
12#include "acparser.h"
13#include "amlcode.h"
14#include "acdispat.h"
15#include "acnamesp.h"
16#include "acinterp.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070017
18#define _COMPONENT ACPI_DISPATCHER
Len Brown4be44fc2005-08-05 00:44:28 -040019ACPI_MODULE_NAME("dsobject")
Linus Torvalds1da177e2005-04-16 15:20:36 -070020
Linus Torvalds1da177e2005-04-16 15:20:36 -070021#ifndef ACPI_NO_METHOD_EXECUTION
Robert Moore44f6c012005-04-18 22:49:35 -040022/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -070023 *
24 * FUNCTION: acpi_ds_build_internal_object
25 *
26 * PARAMETERS: walk_state - Current walk state
Bob Mooreba494be2012-07-12 09:40:10 +080027 * op - Parser object to be translated
Linus Torvalds1da177e2005-04-16 15:20:36 -070028 * obj_desc_ptr - Where the ACPI internal object is returned
29 *
30 * RETURN: Status
31 *
32 * DESCRIPTION: Translate a parser Op object to the equivalent namespace object
33 * Simple objects are any objects other than a package object!
34 *
Robert Moore44f6c012005-04-18 22:49:35 -040035 ******************************************************************************/
Bob Moorea62a7112017-08-03 14:27:22 +080036acpi_status
Len Brown4be44fc2005-08-05 00:44:28 -040037acpi_ds_build_internal_object(struct acpi_walk_state *walk_state,
38 union acpi_parse_object *op,
39 union acpi_operand_object **obj_desc_ptr)
Linus Torvalds1da177e2005-04-16 15:20:36 -070040{
Len Brown4be44fc2005-08-05 00:44:28 -040041 union acpi_operand_object *obj_desc;
42 acpi_status status;
Linus Torvalds1da177e2005-04-16 15:20:36 -070043
Bob Mooreb229cf92006-04-21 17:15:00 -040044 ACPI_FUNCTION_TRACE(ds_build_internal_object);
Linus Torvalds1da177e2005-04-16 15:20:36 -070045
46 *obj_desc_ptr = NULL;
47 if (op->common.aml_opcode == AML_INT_NAMEPATH_OP) {
48 /*
Bob Mooredefba1d2005-12-16 17:05:00 -050049 * This is a named object reference. If this name was
Bob Moorea62a7112017-08-03 14:27:22 +080050 * previously looked up in the namespace, it was stored in
51 * this op. Otherwise, go ahead and look it up now
Linus Torvalds1da177e2005-04-16 15:20:36 -070052 */
53 if (!op->common.node) {
Bob Moore52fc0b02006-10-02 00:00:00 -040054
Bob Moorea62a7112017-08-03 14:27:22 +080055 /* Check if we are resolving a named reference within a package */
Bob Mooredefba1d2005-12-16 17:05:00 -050056
Bob Moorea62a7112017-08-03 14:27:22 +080057 if ((op->common.parent->common.aml_opcode ==
58 AML_PACKAGE_OP)
59 || (op->common.parent->common.aml_opcode ==
60 AML_VARIABLE_PACKAGE_OP)) {
61 /*
62 * We won't resolve package elements here, we will do this
63 * after all ACPI tables are loaded into the namespace. This
64 * behavior supports both forward references to named objects
65 * and external references to objects in other tables.
66 */
67 goto create_new_object;
68 } else {
69 status = acpi_ns_lookup(walk_state->scope_info,
70 op->common.value.string,
71 ACPI_TYPE_ANY,
72 ACPI_IMODE_EXECUTE,
73 ACPI_NS_SEARCH_PARENT |
74 ACPI_NS_DONT_OPEN_SCOPE,
75 NULL,
76 ACPI_CAST_INDIRECT_PTR
77 (struct
78 acpi_namespace_node,
79 &(op->common.node)));
80 if (ACPI_FAILURE(status)) {
Bob Moore16ccf822017-11-17 15:42:22 -080081 ACPI_ERROR_NAMESPACE(walk_state->
82 scope_info,
83 op->common.value.
Bob Mooreb8e4d892006-01-27 16:43:00 -050084 string, status);
Bob Moorea62a7112017-08-03 14:27:22 +080085 return_ACPI_STATUS(status);
Bob Mooredefba1d2005-12-16 17:05:00 -050086 }
Bob Moore152c3002007-10-17 16:10:18 -040087 }
88 }
Linus Torvalds1da177e2005-04-16 15:20:36 -070089 }
90
Bob Moorea62a7112017-08-03 14:27:22 +080091create_new_object:
92
Bob Mooredefba1d2005-12-16 17:05:00 -050093 /* Create and init a new internal ACPI object */
Linus Torvalds1da177e2005-04-16 15:20:36 -070094
Len Brown4be44fc2005-08-05 00:44:28 -040095 obj_desc = acpi_ut_create_internal_object((acpi_ps_get_opcode_info
96 (op->common.aml_opcode))->
97 object_type);
Linus Torvalds1da177e2005-04-16 15:20:36 -070098 if (!obj_desc) {
Len Brown4be44fc2005-08-05 00:44:28 -040099 return_ACPI_STATUS(AE_NO_MEMORY);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700100 }
101
Len Brown4be44fc2005-08-05 00:44:28 -0400102 status =
103 acpi_ds_init_object_from_op(walk_state, op, op->common.aml_opcode,
104 &obj_desc);
105 if (ACPI_FAILURE(status)) {
106 acpi_ut_remove_reference(obj_desc);
107 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700108 }
109
Bob Moorea62a7112017-08-03 14:27:22 +0800110 /*
111 * Handling for unresolved package reference elements.
112 * These are elements that are namepaths.
113 */
114 if ((op->common.parent->common.aml_opcode == AML_PACKAGE_OP) ||
115 (op->common.parent->common.aml_opcode == AML_VARIABLE_PACKAGE_OP)) {
116 obj_desc->reference.resolved = TRUE;
117
118 if ((op->common.aml_opcode == AML_INT_NAMEPATH_OP) &&
119 !obj_desc->reference.node) {
120 /*
121 * Name was unresolved above.
122 * Get the prefix node for later lookup
123 */
124 obj_desc->reference.node =
125 walk_state->scope_info->scope.node;
126 obj_desc->reference.aml = op->common.aml;
127 obj_desc->reference.resolved = FALSE;
128 }
129 }
130
Linus Torvalds1da177e2005-04-16 15:20:36 -0700131 *obj_desc_ptr = obj_desc;
Bob Moore9e41d932008-04-10 19:06:39 +0400132 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700133}
134
Robert Moore44f6c012005-04-18 22:49:35 -0400135/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700136 *
137 * FUNCTION: acpi_ds_build_internal_buffer_obj
138 *
139 * PARAMETERS: walk_state - Current walk state
Bob Mooreba494be2012-07-12 09:40:10 +0800140 * op - Parser object to be translated
Linus Torvalds1da177e2005-04-16 15:20:36 -0700141 * buffer_length - Length of the buffer
142 * obj_desc_ptr - Where the ACPI internal object is returned
143 *
144 * RETURN: Status
145 *
146 * DESCRIPTION: Translate a parser Op package object to the equivalent
147 * namespace object
148 *
Robert Moore44f6c012005-04-18 22:49:35 -0400149 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700150
151acpi_status
Len Brown4be44fc2005-08-05 00:44:28 -0400152acpi_ds_build_internal_buffer_obj(struct acpi_walk_state *walk_state,
153 union acpi_parse_object *op,
154 u32 buffer_length,
155 union acpi_operand_object **obj_desc_ptr)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700156{
Len Brown4be44fc2005-08-05 00:44:28 -0400157 union acpi_parse_object *arg;
158 union acpi_operand_object *obj_desc;
159 union acpi_parse_object *byte_list;
160 u32 byte_list_length = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700161
Bob Mooreb229cf92006-04-21 17:15:00 -0400162 ACPI_FUNCTION_TRACE(ds_build_internal_buffer_obj);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700163
Bob Mooredefba1d2005-12-16 17:05:00 -0500164 /*
165 * If we are evaluating a Named buffer object "Name (xxxx, Buffer)".
166 * The buffer object already exists (from the NS node), otherwise it must
167 * be created.
168 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700169 obj_desc = *obj_desc_ptr;
Bob Mooredefba1d2005-12-16 17:05:00 -0500170 if (!obj_desc) {
Bob Moore52fc0b02006-10-02 00:00:00 -0400171
Linus Torvalds1da177e2005-04-16 15:20:36 -0700172 /* Create a new buffer object */
173
Len Brown4be44fc2005-08-05 00:44:28 -0400174 obj_desc = acpi_ut_create_internal_object(ACPI_TYPE_BUFFER);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700175 *obj_desc_ptr = obj_desc;
176 if (!obj_desc) {
Len Brown4be44fc2005-08-05 00:44:28 -0400177 return_ACPI_STATUS(AE_NO_MEMORY);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700178 }
179 }
180
181 /*
182 * Second arg is the buffer data (optional) byte_list can be either
Bob Moore73a30902012-10-31 02:26:55 +0000183 * individual bytes or a string initializer. In either case, a
Linus Torvalds1da177e2005-04-16 15:20:36 -0700184 * byte_list appears in the AML.
185 */
Len Brown4be44fc2005-08-05 00:44:28 -0400186 arg = op->common.value.arg; /* skip first arg */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700187
188 byte_list = arg->named.next;
189 if (byte_list) {
190 if (byte_list->common.aml_opcode != AML_INT_BYTELIST_OP) {
Bob Mooreb8e4d892006-01-27 16:43:00 -0500191 ACPI_ERROR((AE_INFO,
Bob Mooref6a22b02010-03-05 17:56:40 +0800192 "Expecting bytelist, found AML opcode 0x%X in op %p",
Bob Mooreb8e4d892006-01-27 16:43:00 -0500193 byte_list->common.aml_opcode, byte_list));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700194
Len Brown4be44fc2005-08-05 00:44:28 -0400195 acpi_ut_remove_reference(obj_desc);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700196 return (AE_TYPE);
197 }
198
199 byte_list_length = (u32) byte_list->common.value.integer;
200 }
201
202 /*
203 * The buffer length (number of bytes) will be the larger of:
204 * 1) The specified buffer length and
205 * 2) The length of the initializer byte list
206 */
207 obj_desc->buffer.length = buffer_length;
208 if (byte_list_length > buffer_length) {
209 obj_desc->buffer.length = byte_list_length;
210 }
211
212 /* Allocate the buffer */
213
214 if (obj_desc->buffer.length == 0) {
215 obj_desc->buffer.pointer = NULL;
Len Brown4be44fc2005-08-05 00:44:28 -0400216 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
217 "Buffer defined with zero length in AML, creating\n"));
218 } else {
219 obj_desc->buffer.pointer =
Bob Moore83135242006-10-03 00:00:00 -0400220 ACPI_ALLOCATE_ZEROED(obj_desc->buffer.length);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700221 if (!obj_desc->buffer.pointer) {
Len Brown4be44fc2005-08-05 00:44:28 -0400222 acpi_ut_delete_object_desc(obj_desc);
223 return_ACPI_STATUS(AE_NO_MEMORY);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700224 }
225
226 /* Initialize buffer from the byte_list (if present) */
227
228 if (byte_list) {
Bob Moore4fa46162015-07-01 14:45:11 +0800229 memcpy(obj_desc->buffer.pointer, byte_list->named.data,
230 byte_list_length);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700231 }
232 }
233
234 obj_desc->buffer.flags |= AOPOBJ_DATA_VALID;
Bob Moore8f9337c2007-02-02 19:48:18 +0300235 op->common.node = ACPI_CAST_PTR(struct acpi_namespace_node, obj_desc);
Len Brown4be44fc2005-08-05 00:44:28 -0400236 return_ACPI_STATUS(AE_OK);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700237}
238
Robert Moore44f6c012005-04-18 22:49:35 -0400239/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700240 *
Linus Torvalds1da177e2005-04-16 15:20:36 -0700241 * FUNCTION: acpi_ds_create_node
242 *
243 * PARAMETERS: walk_state - Current walk state
Bob Mooreba494be2012-07-12 09:40:10 +0800244 * node - NS Node to be initialized
245 * op - Parser object to be translated
Linus Torvalds1da177e2005-04-16 15:20:36 -0700246 *
247 * RETURN: Status
248 *
249 * DESCRIPTION: Create the object to be associated with a namespace node
250 *
Robert Moore44f6c012005-04-18 22:49:35 -0400251 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700252
253acpi_status
Len Brown4be44fc2005-08-05 00:44:28 -0400254acpi_ds_create_node(struct acpi_walk_state *walk_state,
255 struct acpi_namespace_node *node,
256 union acpi_parse_object *op)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700257{
Len Brown4be44fc2005-08-05 00:44:28 -0400258 acpi_status status;
259 union acpi_operand_object *obj_desc;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700260
Bob Mooreb229cf92006-04-21 17:15:00 -0400261 ACPI_FUNCTION_TRACE_PTR(ds_create_node, op);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700262
263 /*
264 * Because of the execution pass through the non-control-method
Bob Moore73a30902012-10-31 02:26:55 +0000265 * parts of the table, we can arrive here twice. Only init
Linus Torvalds1da177e2005-04-16 15:20:36 -0700266 * the named object node the first time through
267 */
Len Brown4be44fc2005-08-05 00:44:28 -0400268 if (acpi_ns_get_attached_object(node)) {
269 return_ACPI_STATUS(AE_OK);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700270 }
271
272 if (!op->common.value.arg) {
Bob Moore52fc0b02006-10-02 00:00:00 -0400273
Linus Torvalds1da177e2005-04-16 15:20:36 -0700274 /* No arguments, there is nothing to do */
275
Len Brown4be44fc2005-08-05 00:44:28 -0400276 return_ACPI_STATUS(AE_OK);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700277 }
278
279 /* Build an internal object for the argument(s) */
280
Bob Moore1fad8732015-12-29 13:54:36 +0800281 status =
282 acpi_ds_build_internal_object(walk_state, op->common.value.arg,
283 &obj_desc);
Len Brown4be44fc2005-08-05 00:44:28 -0400284 if (ACPI_FAILURE(status)) {
285 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700286 }
287
288 /* Re-type the object according to its argument */
289
Bob Moore3371c192009-02-18 14:44:03 +0800290 node->type = obj_desc->common.type;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700291
292 /* Attach obj to node */
293
Len Brown4be44fc2005-08-05 00:44:28 -0400294 status = acpi_ns_attach_object(node, obj_desc, node->type);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700295
296 /* Remove local reference to the object */
297
Len Brown4be44fc2005-08-05 00:44:28 -0400298 acpi_ut_remove_reference(obj_desc);
299 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700300}
301
Len Brown4be44fc2005-08-05 00:44:28 -0400302#endif /* ACPI_NO_METHOD_EXECUTION */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700303
Robert Moore44f6c012005-04-18 22:49:35 -0400304/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700305 *
306 * FUNCTION: acpi_ds_init_object_from_op
307 *
308 * PARAMETERS: walk_state - Current walk state
Bob Mooreba494be2012-07-12 09:40:10 +0800309 * op - Parser op used to init the internal object
310 * opcode - AML opcode associated with the object
Linus Torvalds1da177e2005-04-16 15:20:36 -0700311 * ret_obj_desc - Namespace object to be initialized
312 *
313 * RETURN: Status
314 *
315 * DESCRIPTION: Initialize a namespace object from a parser Op and its
Bob Moore73a30902012-10-31 02:26:55 +0000316 * associated arguments. The namespace object is a more compact
Linus Torvalds1da177e2005-04-16 15:20:36 -0700317 * representation of the Op and its arguments.
318 *
Robert Moore44f6c012005-04-18 22:49:35 -0400319 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700320
321acpi_status
Len Brown4be44fc2005-08-05 00:44:28 -0400322acpi_ds_init_object_from_op(struct acpi_walk_state *walk_state,
323 union acpi_parse_object *op,
324 u16 opcode,
325 union acpi_operand_object **ret_obj_desc)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700326{
Len Brown4be44fc2005-08-05 00:44:28 -0400327 const struct acpi_opcode_info *op_info;
328 union acpi_operand_object *obj_desc;
329 acpi_status status = AE_OK;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700330
Bob Mooreb229cf92006-04-21 17:15:00 -0400331 ACPI_FUNCTION_TRACE(ds_init_object_from_op);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700332
333 obj_desc = *ret_obj_desc;
Len Brown4be44fc2005-08-05 00:44:28 -0400334 op_info = acpi_ps_get_opcode_info(opcode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700335 if (op_info->class == AML_CLASS_UNKNOWN) {
Bob Moore52fc0b02006-10-02 00:00:00 -0400336
Linus Torvalds1da177e2005-04-16 15:20:36 -0700337 /* Unknown opcode */
338
Len Brown4be44fc2005-08-05 00:44:28 -0400339 return_ACPI_STATUS(AE_TYPE);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700340 }
341
342 /* Perform per-object initialization */
343
Bob Moore3371c192009-02-18 14:44:03 +0800344 switch (obj_desc->common.type) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700345 case ACPI_TYPE_BUFFER:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700346 /*
347 * Defer evaluation of Buffer term_arg operand
348 */
Bob Moore8f9337c2007-02-02 19:48:18 +0300349 obj_desc->buffer.node =
350 ACPI_CAST_PTR(struct acpi_namespace_node,
351 walk_state->operands[0]);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700352 obj_desc->buffer.aml_start = op->named.data;
353 obj_desc->buffer.aml_length = op->named.length;
354 break;
355
Linus Torvalds1da177e2005-04-16 15:20:36 -0700356 case ACPI_TYPE_PACKAGE:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700357 /*
Bob Moorea62a7112017-08-03 14:27:22 +0800358 * Defer evaluation of Package term_arg operand and all
359 * package elements. (01/2017): We defer the element
360 * resolution to allow forward references from the package
361 * in order to provide compatibility with other ACPI
362 * implementations.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700363 */
Bob Moore8f9337c2007-02-02 19:48:18 +0300364 obj_desc->package.node =
365 ACPI_CAST_PTR(struct acpi_namespace_node,
366 walk_state->operands[0]);
Bob Moorea62a7112017-08-03 14:27:22 +0800367
368 if (!op->named.data) {
369 return_ACPI_STATUS(AE_OK);
370 }
371
Linus Torvalds1da177e2005-04-16 15:20:36 -0700372 obj_desc->package.aml_start = op->named.data;
373 obj_desc->package.aml_length = op->named.length;
374 break;
375
Linus Torvalds1da177e2005-04-16 15:20:36 -0700376 case ACPI_TYPE_INTEGER:
377
378 switch (op_info->type) {
379 case AML_TYPE_CONSTANT:
380 /*
381 * Resolve AML Constants here - AND ONLY HERE!
382 * All constants are integers.
Robert Moore44f6c012005-04-18 22:49:35 -0400383 * We mark the integer with a flag that indicates that it started
384 * life as a constant -- so that stores to constants will perform
385 * as expected (noop). zero_op is used as a placeholder for optional
386 * target operands.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700387 */
388 obj_desc->common.flags = AOPOBJ_AML_CONSTANT;
389
390 switch (opcode) {
391 case AML_ZERO_OP:
392
393 obj_desc->integer.value = 0;
394 break;
395
396 case AML_ONE_OP:
397
398 obj_desc->integer.value = 1;
399 break;
400
401 case AML_ONES_OP:
402
Bob Moore5df7e6c2010-01-21 10:06:32 +0800403 obj_desc->integer.value = ACPI_UINT64_MAX;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700404
405 /* Truncate value if we are executing from a 32-bit ACPI table */
406
407#ifndef ACPI_NO_METHOD_EXECUTION
Bob Mooreef42e532012-12-31 00:07:18 +0000408 (void)acpi_ex_truncate_for32bit_table(obj_desc);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700409#endif
410 break;
411
412 case AML_REVISION_OP:
413
414 obj_desc->integer.value = ACPI_CA_VERSION;
415 break;
416
417 default:
418
Bob Mooreb8e4d892006-01-27 16:43:00 -0500419 ACPI_ERROR((AE_INFO,
Bob Mooref6a22b02010-03-05 17:56:40 +0800420 "Unknown constant opcode 0x%X",
Bob Mooreb8e4d892006-01-27 16:43:00 -0500421 opcode));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700422 status = AE_AML_OPERAND_TYPE;
423 break;
424 }
425 break;
426
Linus Torvalds1da177e2005-04-16 15:20:36 -0700427 case AML_TYPE_LITERAL:
428
429 obj_desc->integer.value = op->common.value.integer;
Bob Mooreef42e532012-12-31 00:07:18 +0000430
Robert Moore6f42ccf2005-05-13 00:00:00 -0400431#ifndef ACPI_NO_METHOD_EXECUTION
Bob Mooreef42e532012-12-31 00:07:18 +0000432 if (acpi_ex_truncate_for32bit_table(obj_desc)) {
433
434 /* Warn if we found a 64-bit constant in a 32-bit table */
435
436 ACPI_WARNING((AE_INFO,
437 "Truncated 64-bit constant found in 32-bit table: %8.8X%8.8X => %8.8X",
438 ACPI_FORMAT_UINT64(op->common.
439 value.integer),
440 (u32)obj_desc->integer.value));
441 }
Robert Moore6f42ccf2005-05-13 00:00:00 -0400442#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700443 break;
444
Linus Torvalds1da177e2005-04-16 15:20:36 -0700445 default:
Chao Guan1d1ea1b2013-06-08 00:58:14 +0000446
Bob Mooref6a22b02010-03-05 17:56:40 +0800447 ACPI_ERROR((AE_INFO, "Unknown Integer type 0x%X",
Bob Mooreb8e4d892006-01-27 16:43:00 -0500448 op_info->type));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700449 status = AE_AML_OPERAND_TYPE;
450 break;
451 }
452 break;
453
Linus Torvalds1da177e2005-04-16 15:20:36 -0700454 case ACPI_TYPE_STRING:
455
456 obj_desc->string.pointer = op->common.value.string;
Bob Moore4fa46162015-07-01 14:45:11 +0800457 obj_desc->string.length = (u32)strlen(op->common.value.string);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700458
459 /*
460 * The string is contained in the ACPI table, don't ever try
461 * to delete it
462 */
463 obj_desc->common.flags |= AOPOBJ_STATIC_POINTER;
464 break;
465
Linus Torvalds1da177e2005-04-16 15:20:36 -0700466 case ACPI_TYPE_METHOD:
467 break;
468
Linus Torvalds1da177e2005-04-16 15:20:36 -0700469 case ACPI_TYPE_LOCAL_REFERENCE:
470
471 switch (op_info->type) {
472 case AML_TYPE_LOCAL_VARIABLE:
473
Bob Moore9ff5a21a2017-04-26 16:18:40 +0800474 /* Local ID (0-7) is (AML opcode - base AML_FIRST_LOCAL_OP) */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700475
Bob Mooreba9c3f52009-04-22 13:13:48 +0800476 obj_desc->reference.value =
Bob Moore9ff5a21a2017-04-26 16:18:40 +0800477 ((u32)opcode) - AML_FIRST_LOCAL_OP;
Bob Moore1044f1f2008-09-27 11:08:41 +0800478 obj_desc->reference.class = ACPI_REFCLASS_LOCAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700479
480#ifndef ACPI_NO_METHOD_EXECUTION
Bob Moore1044f1f2008-09-27 11:08:41 +0800481 status =
482 acpi_ds_method_data_get_node(ACPI_REFCLASS_LOCAL,
483 obj_desc->reference.
484 value, walk_state,
485 ACPI_CAST_INDIRECT_PTR
486 (struct
487 acpi_namespace_node,
488 &obj_desc->reference.
489 object));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700490#endif
491 break;
492
Linus Torvalds1da177e2005-04-16 15:20:36 -0700493 case AML_TYPE_METHOD_ARGUMENT:
494
Bob Moore9ff5a21a2017-04-26 16:18:40 +0800495 /* Arg ID (0-6) is (AML opcode - base AML_FIRST_ARG_OP) */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700496
Bob Moore9ff5a21a2017-04-26 16:18:40 +0800497 obj_desc->reference.value =
498 ((u32)opcode) - AML_FIRST_ARG_OP;
Bob Moore1044f1f2008-09-27 11:08:41 +0800499 obj_desc->reference.class = ACPI_REFCLASS_ARG;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700500
501#ifndef ACPI_NO_METHOD_EXECUTION
Bob Moore1044f1f2008-09-27 11:08:41 +0800502 status = acpi_ds_method_data_get_node(ACPI_REFCLASS_ARG,
Len Brown4be44fc2005-08-05 00:44:28 -0400503 obj_desc->
Bob Moore1044f1f2008-09-27 11:08:41 +0800504 reference.value,
Len Brown4be44fc2005-08-05 00:44:28 -0400505 walk_state,
Bob Moore57e664c2008-09-27 10:40:39 +0800506 ACPI_CAST_INDIRECT_PTR
Len Brown4be44fc2005-08-05 00:44:28 -0400507 (struct
Bob Moore57e664c2008-09-27 10:40:39 +0800508 acpi_namespace_node,
509 &obj_desc->
510 reference.
511 object));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700512#endif
513 break;
514
Bob Moore1044f1f2008-09-27 11:08:41 +0800515 default: /* Object name or Debug object */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700516
Bob Moore1044f1f2008-09-27 11:08:41 +0800517 switch (op->common.aml_opcode) {
518 case AML_INT_NAMEPATH_OP:
Bob Moore52fc0b02006-10-02 00:00:00 -0400519
Linus Torvalds1da177e2005-04-16 15:20:36 -0700520 /* Node was saved in Op */
521
522 obj_desc->reference.node = op->common.node;
Bob Moore1044f1f2008-09-27 11:08:41 +0800523 obj_desc->reference.class = ACPI_REFCLASS_NAME;
Bob Moorea62a7112017-08-03 14:27:22 +0800524 if (op->common.node) {
525 obj_desc->reference.object =
526 op->common.node->object;
527 }
Bob Moore1044f1f2008-09-27 11:08:41 +0800528 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700529
Bob Moore1044f1f2008-09-27 11:08:41 +0800530 case AML_DEBUG_OP:
531
532 obj_desc->reference.class = ACPI_REFCLASS_DEBUG;
533 break;
534
535 default:
536
537 ACPI_ERROR((AE_INFO,
Bob Mooref6a22b02010-03-05 17:56:40 +0800538 "Unimplemented reference type for AML opcode: 0x%4.4X",
Bob Moore1044f1f2008-09-27 11:08:41 +0800539 opcode));
540 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
541 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700542 break;
543 }
544 break;
545
Linus Torvalds1da177e2005-04-16 15:20:36 -0700546 default:
547
Bob Mooref6a22b02010-03-05 17:56:40 +0800548 ACPI_ERROR((AE_INFO, "Unimplemented data type: 0x%X",
Bob Moore3371c192009-02-18 14:44:03 +0800549 obj_desc->common.type));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700550
551 status = AE_AML_OPERAND_TYPE;
552 break;
553 }
554
Len Brown4be44fc2005-08-05 00:44:28 -0400555 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700556}