Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | /****************************************************************************** |
2 | * | |
3 | * Module Name: dsobject - Dispatcher object management routines | |
4 | * | |
5 | *****************************************************************************/ | |
6 | ||
7 | /* | |
4a90c7e8 | 8 | * Copyright (C) 2000 - 2006, R. Byron Moore |
1da177e4 LT |
9 | * All rights reserved. |
10 | * | |
11 | * Redistribution and use in source and binary forms, with or without | |
12 | * modification, are permitted provided that the following conditions | |
13 | * are met: | |
14 | * 1. Redistributions of source code must retain the above copyright | |
15 | * notice, this list of conditions, and the following disclaimer, | |
16 | * without modification. | |
17 | * 2. Redistributions in binary form must reproduce at minimum a disclaimer | |
18 | * substantially similar to the "NO WARRANTY" disclaimer below | |
19 | * ("Disclaimer") and any redistribution must be conditioned upon | |
20 | * including a substantially similar Disclaimer requirement for further | |
21 | * binary redistribution. | |
22 | * 3. Neither the names of the above-listed copyright holders nor the names | |
23 | * of any contributors may be used to endorse or promote products derived | |
24 | * from this software without specific prior written permission. | |
25 | * | |
26 | * Alternatively, this software may be distributed under the terms of the | |
27 | * GNU General Public License ("GPL") version 2 as published by the Free | |
28 | * Software Foundation. | |
29 | * | |
30 | * NO WARRANTY | |
31 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
32 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
33 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR | |
34 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
35 | * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
36 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
37 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
38 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | |
39 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING | |
40 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
41 | * POSSIBILITY OF SUCH DAMAGES. | |
42 | */ | |
43 | ||
1da177e4 LT |
44 | #include <acpi/acpi.h> |
45 | #include <acpi/acparser.h> | |
46 | #include <acpi/amlcode.h> | |
47 | #include <acpi/acdispat.h> | |
48 | #include <acpi/acnamesp.h> | |
49 | #include <acpi/acinterp.h> | |
50 | ||
51 | #define _COMPONENT ACPI_DISPATCHER | |
4be44fcd | 52 | ACPI_MODULE_NAME("dsobject") |
1da177e4 | 53 | |
defba1d8 | 54 | /* Local prototypes */ |
44f6c012 | 55 | static acpi_status |
4be44fcd LB |
56 | acpi_ds_build_internal_object(struct acpi_walk_state *walk_state, |
57 | union acpi_parse_object *op, | |
58 | union acpi_operand_object **obj_desc_ptr); | |
1da177e4 LT |
59 | |
60 | #ifndef ACPI_NO_METHOD_EXECUTION | |
44f6c012 | 61 | /******************************************************************************* |
1da177e4 LT |
62 | * |
63 | * FUNCTION: acpi_ds_build_internal_object | |
64 | * | |
65 | * PARAMETERS: walk_state - Current walk state | |
66 | * Op - Parser object to be translated | |
67 | * obj_desc_ptr - Where the ACPI internal object is returned | |
68 | * | |
69 | * RETURN: Status | |
70 | * | |
71 | * DESCRIPTION: Translate a parser Op object to the equivalent namespace object | |
72 | * Simple objects are any objects other than a package object! | |
73 | * | |
44f6c012 | 74 | ******************************************************************************/ |
1da177e4 | 75 | |
44f6c012 | 76 | static acpi_status |
4be44fcd LB |
77 | acpi_ds_build_internal_object(struct acpi_walk_state *walk_state, |
78 | union acpi_parse_object *op, | |
79 | union acpi_operand_object **obj_desc_ptr) | |
1da177e4 | 80 | { |
4be44fcd LB |
81 | union acpi_operand_object *obj_desc; |
82 | acpi_status status; | |
1da177e4 | 83 | |
4be44fcd | 84 | ACPI_FUNCTION_TRACE("ds_build_internal_object"); |
1da177e4 LT |
85 | |
86 | *obj_desc_ptr = NULL; | |
87 | if (op->common.aml_opcode == AML_INT_NAMEPATH_OP) { | |
88 | /* | |
defba1d8 | 89 | * This is a named object reference. If this name was |
1da177e4 LT |
90 | * previously looked up in the namespace, it was stored in this op. |
91 | * Otherwise, go ahead and look it up now | |
92 | */ | |
93 | if (!op->common.node) { | |
4be44fcd LB |
94 | status = acpi_ns_lookup(walk_state->scope_info, |
95 | op->common.value.string, | |
96 | ACPI_TYPE_ANY, | |
97 | ACPI_IMODE_EXECUTE, | |
98 | ACPI_NS_SEARCH_PARENT | | |
99 | ACPI_NS_DONT_OPEN_SCOPE, NULL, | |
defba1d8 BM |
100 | ACPI_CAST_INDIRECT_PTR(struct |
101 | acpi_namespace_node, | |
102 | &(op-> | |
103 | common. | |
104 | node))); | |
4be44fcd | 105 | if (ACPI_FAILURE(status)) { |
defba1d8 BM |
106 | /* Check if we are resolving a named reference within a package */ |
107 | ||
108 | if ((status == AE_NOT_FOUND) | |
109 | && (acpi_gbl_enable_interpreter_slack) | |
110 | && | |
111 | ((op->common.parent->common.aml_opcode == | |
112 | AML_PACKAGE_OP) | |
113 | || (op->common.parent->common.aml_opcode == | |
114 | AML_VAR_PACKAGE_OP))) { | |
115 | /* | |
116 | * We didn't find the target and we are populating elements | |
117 | * of a package - ignore if slack enabled. Some ASL code | |
118 | * contains dangling invalid references in packages and | |
119 | * expects that no exception will be issued. Leave the | |
120 | * element as a null element. It cannot be used, but it | |
121 | * can be overwritten by subsequent ASL code - this is | |
122 | * typically the case. | |
123 | */ | |
124 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, | |
125 | "Ignoring unresolved reference in package [%4.4s]\n", | |
126 | walk_state-> | |
127 | scope_info->scope. | |
128 | node->name.ascii)); | |
129 | ||
130 | return_ACPI_STATUS(AE_OK); | |
131 | } else { | |
b8e4d893 BM |
132 | ACPI_ERROR_NAMESPACE(op->common.value. |
133 | string, status); | |
defba1d8 BM |
134 | } |
135 | ||
4be44fcd | 136 | return_ACPI_STATUS(status); |
1da177e4 LT |
137 | } |
138 | } | |
139 | } | |
140 | ||
defba1d8 | 141 | /* Create and init a new internal ACPI object */ |
1da177e4 | 142 | |
4be44fcd LB |
143 | obj_desc = acpi_ut_create_internal_object((acpi_ps_get_opcode_info |
144 | (op->common.aml_opcode))-> | |
145 | object_type); | |
1da177e4 | 146 | if (!obj_desc) { |
4be44fcd | 147 | return_ACPI_STATUS(AE_NO_MEMORY); |
1da177e4 LT |
148 | } |
149 | ||
4be44fcd LB |
150 | status = |
151 | acpi_ds_init_object_from_op(walk_state, op, op->common.aml_opcode, | |
152 | &obj_desc); | |
153 | if (ACPI_FAILURE(status)) { | |
154 | acpi_ut_remove_reference(obj_desc); | |
155 | return_ACPI_STATUS(status); | |
1da177e4 LT |
156 | } |
157 | ||
158 | *obj_desc_ptr = obj_desc; | |
4be44fcd | 159 | return_ACPI_STATUS(AE_OK); |
1da177e4 LT |
160 | } |
161 | ||
44f6c012 | 162 | /******************************************************************************* |
1da177e4 LT |
163 | * |
164 | * FUNCTION: acpi_ds_build_internal_buffer_obj | |
165 | * | |
166 | * PARAMETERS: walk_state - Current walk state | |
167 | * Op - Parser object to be translated | |
168 | * buffer_length - Length of the buffer | |
169 | * obj_desc_ptr - Where the ACPI internal object is returned | |
170 | * | |
171 | * RETURN: Status | |
172 | * | |
173 | * DESCRIPTION: Translate a parser Op package object to the equivalent | |
174 | * namespace object | |
175 | * | |
44f6c012 | 176 | ******************************************************************************/ |
1da177e4 LT |
177 | |
178 | acpi_status | |
4be44fcd LB |
179 | acpi_ds_build_internal_buffer_obj(struct acpi_walk_state *walk_state, |
180 | union acpi_parse_object *op, | |
181 | u32 buffer_length, | |
182 | union acpi_operand_object **obj_desc_ptr) | |
1da177e4 | 183 | { |
4be44fcd LB |
184 | union acpi_parse_object *arg; |
185 | union acpi_operand_object *obj_desc; | |
186 | union acpi_parse_object *byte_list; | |
187 | u32 byte_list_length = 0; | |
1da177e4 | 188 | |
4be44fcd | 189 | ACPI_FUNCTION_TRACE("ds_build_internal_buffer_obj"); |
1da177e4 | 190 | |
defba1d8 BM |
191 | /* |
192 | * If we are evaluating a Named buffer object "Name (xxxx, Buffer)". | |
193 | * The buffer object already exists (from the NS node), otherwise it must | |
194 | * be created. | |
195 | */ | |
1da177e4 | 196 | obj_desc = *obj_desc_ptr; |
defba1d8 | 197 | if (!obj_desc) { |
1da177e4 LT |
198 | /* Create a new buffer object */ |
199 | ||
4be44fcd | 200 | obj_desc = acpi_ut_create_internal_object(ACPI_TYPE_BUFFER); |
1da177e4 LT |
201 | *obj_desc_ptr = obj_desc; |
202 | if (!obj_desc) { | |
4be44fcd | 203 | return_ACPI_STATUS(AE_NO_MEMORY); |
1da177e4 LT |
204 | } |
205 | } | |
206 | ||
207 | /* | |
208 | * Second arg is the buffer data (optional) byte_list can be either | |
209 | * individual bytes or a string initializer. In either case, a | |
210 | * byte_list appears in the AML. | |
211 | */ | |
4be44fcd | 212 | arg = op->common.value.arg; /* skip first arg */ |
1da177e4 LT |
213 | |
214 | byte_list = arg->named.next; | |
215 | if (byte_list) { | |
216 | if (byte_list->common.aml_opcode != AML_INT_BYTELIST_OP) { | |
b8e4d893 BM |
217 | ACPI_ERROR((AE_INFO, |
218 | "Expecting bytelist, got AML opcode %X in op %p", | |
219 | byte_list->common.aml_opcode, byte_list)); | |
1da177e4 | 220 | |
4be44fcd | 221 | acpi_ut_remove_reference(obj_desc); |
1da177e4 LT |
222 | return (AE_TYPE); |
223 | } | |
224 | ||
225 | byte_list_length = (u32) byte_list->common.value.integer; | |
226 | } | |
227 | ||
228 | /* | |
229 | * The buffer length (number of bytes) will be the larger of: | |
230 | * 1) The specified buffer length and | |
231 | * 2) The length of the initializer byte list | |
232 | */ | |
233 | obj_desc->buffer.length = buffer_length; | |
234 | if (byte_list_length > buffer_length) { | |
235 | obj_desc->buffer.length = byte_list_length; | |
236 | } | |
237 | ||
238 | /* Allocate the buffer */ | |
239 | ||
240 | if (obj_desc->buffer.length == 0) { | |
241 | obj_desc->buffer.pointer = NULL; | |
4be44fcd LB |
242 | ACPI_DEBUG_PRINT((ACPI_DB_EXEC, |
243 | "Buffer defined with zero length in AML, creating\n")); | |
244 | } else { | |
245 | obj_desc->buffer.pointer = | |
246 | ACPI_MEM_CALLOCATE(obj_desc->buffer.length); | |
1da177e4 | 247 | if (!obj_desc->buffer.pointer) { |
4be44fcd LB |
248 | acpi_ut_delete_object_desc(obj_desc); |
249 | return_ACPI_STATUS(AE_NO_MEMORY); | |
1da177e4 LT |
250 | } |
251 | ||
252 | /* Initialize buffer from the byte_list (if present) */ | |
253 | ||
254 | if (byte_list) { | |
4be44fcd LB |
255 | ACPI_MEMCPY(obj_desc->buffer.pointer, |
256 | byte_list->named.data, byte_list_length); | |
1da177e4 LT |
257 | } |
258 | } | |
259 | ||
260 | obj_desc->buffer.flags |= AOPOBJ_DATA_VALID; | |
4be44fcd LB |
261 | op->common.node = (struct acpi_namespace_node *)obj_desc; |
262 | return_ACPI_STATUS(AE_OK); | |
1da177e4 LT |
263 | } |
264 | ||
44f6c012 | 265 | /******************************************************************************* |
1da177e4 LT |
266 | * |
267 | * FUNCTION: acpi_ds_build_internal_package_obj | |
268 | * | |
269 | * PARAMETERS: walk_state - Current walk state | |
270 | * Op - Parser object to be translated | |
271 | * package_length - Number of elements in the package | |
272 | * obj_desc_ptr - Where the ACPI internal object is returned | |
273 | * | |
274 | * RETURN: Status | |
275 | * | |
276 | * DESCRIPTION: Translate a parser Op package object to the equivalent | |
277 | * namespace object | |
278 | * | |
44f6c012 | 279 | ******************************************************************************/ |
1da177e4 LT |
280 | |
281 | acpi_status | |
4be44fcd LB |
282 | acpi_ds_build_internal_package_obj(struct acpi_walk_state *walk_state, |
283 | union acpi_parse_object *op, | |
284 | u32 package_length, | |
285 | union acpi_operand_object **obj_desc_ptr) | |
1da177e4 | 286 | { |
4be44fcd LB |
287 | union acpi_parse_object *arg; |
288 | union acpi_parse_object *parent; | |
289 | union acpi_operand_object *obj_desc = NULL; | |
290 | u32 package_list_length; | |
291 | acpi_status status = AE_OK; | |
defba1d8 | 292 | acpi_native_uint i; |
1da177e4 | 293 | |
4be44fcd | 294 | ACPI_FUNCTION_TRACE("ds_build_internal_package_obj"); |
1da177e4 LT |
295 | |
296 | /* Find the parent of a possibly nested package */ | |
297 | ||
298 | parent = op->common.parent; | |
4be44fcd LB |
299 | while ((parent->common.aml_opcode == AML_PACKAGE_OP) || |
300 | (parent->common.aml_opcode == AML_VAR_PACKAGE_OP)) { | |
1da177e4 LT |
301 | parent = parent->common.parent; |
302 | } | |
303 | ||
defba1d8 BM |
304 | /* |
305 | * If we are evaluating a Named package object "Name (xxxx, Package)", | |
306 | * the package object already exists, otherwise it must be created. | |
307 | */ | |
1da177e4 | 308 | obj_desc = *obj_desc_ptr; |
defba1d8 | 309 | if (!obj_desc) { |
4be44fcd | 310 | obj_desc = acpi_ut_create_internal_object(ACPI_TYPE_PACKAGE); |
1da177e4 LT |
311 | *obj_desc_ptr = obj_desc; |
312 | if (!obj_desc) { | |
4be44fcd | 313 | return_ACPI_STATUS(AE_NO_MEMORY); |
1da177e4 LT |
314 | } |
315 | ||
316 | obj_desc->package.node = parent->common.node; | |
317 | } | |
318 | ||
319 | obj_desc->package.count = package_length; | |
320 | ||
321 | /* Count the number of items in the package list */ | |
322 | ||
1da177e4 LT |
323 | arg = op->common.value.arg; |
324 | arg = arg->common.next; | |
defba1d8 | 325 | for (package_list_length = 0; arg; package_list_length++) { |
1da177e4 LT |
326 | arg = arg->common.next; |
327 | } | |
328 | ||
329 | /* | |
330 | * The package length (number of elements) will be the greater | |
331 | * of the specified length and the length of the initializer list | |
332 | */ | |
333 | if (package_list_length > package_length) { | |
334 | obj_desc->package.count = package_list_length; | |
335 | } | |
336 | ||
337 | /* | |
338 | * Allocate the pointer array (array of pointers to the | |
339 | * individual objects). Add an extra pointer slot so | |
340 | * that the list is always null terminated. | |
341 | */ | |
4be44fcd LB |
342 | obj_desc->package.elements = ACPI_MEM_CALLOCATE(((acpi_size) obj_desc-> |
343 | package.count + | |
344 | 1) * sizeof(void *)); | |
1da177e4 LT |
345 | |
346 | if (!obj_desc->package.elements) { | |
4be44fcd LB |
347 | acpi_ut_delete_object_desc(obj_desc); |
348 | return_ACPI_STATUS(AE_NO_MEMORY); | |
1da177e4 LT |
349 | } |
350 | ||
351 | /* | |
defba1d8 | 352 | * Initialize all elements of the package |
1da177e4 | 353 | */ |
1da177e4 LT |
354 | arg = op->common.value.arg; |
355 | arg = arg->common.next; | |
defba1d8 | 356 | for (i = 0; arg; i++) { |
1da177e4 LT |
357 | if (arg->common.aml_opcode == AML_INT_RETURN_VALUE_OP) { |
358 | /* Object (package or buffer) is already built */ | |
359 | ||
44f6c012 | 360 | obj_desc->package.elements[i] = |
4be44fcd LB |
361 | ACPI_CAST_PTR(union acpi_operand_object, |
362 | arg->common.node); | |
363 | } else { | |
364 | status = acpi_ds_build_internal_object(walk_state, arg, | |
365 | &obj_desc-> | |
366 | package. | |
367 | elements[i]); | |
1da177e4 | 368 | } |
1da177e4 LT |
369 | arg = arg->common.next; |
370 | } | |
371 | ||
372 | obj_desc->package.flags |= AOPOBJ_DATA_VALID; | |
4be44fcd LB |
373 | op->common.node = (struct acpi_namespace_node *)obj_desc; |
374 | return_ACPI_STATUS(status); | |
1da177e4 LT |
375 | } |
376 | ||
44f6c012 | 377 | /******************************************************************************* |
1da177e4 LT |
378 | * |
379 | * FUNCTION: acpi_ds_create_node | |
380 | * | |
381 | * PARAMETERS: walk_state - Current walk state | |
382 | * Node - NS Node to be initialized | |
383 | * Op - Parser object to be translated | |
384 | * | |
385 | * RETURN: Status | |
386 | * | |
387 | * DESCRIPTION: Create the object to be associated with a namespace node | |
388 | * | |
44f6c012 | 389 | ******************************************************************************/ |
1da177e4 LT |
390 | |
391 | acpi_status | |
4be44fcd LB |
392 | acpi_ds_create_node(struct acpi_walk_state *walk_state, |
393 | struct acpi_namespace_node *node, | |
394 | union acpi_parse_object *op) | |
1da177e4 | 395 | { |
4be44fcd LB |
396 | acpi_status status; |
397 | union acpi_operand_object *obj_desc; | |
1da177e4 | 398 | |
4be44fcd | 399 | ACPI_FUNCTION_TRACE_PTR("ds_create_node", op); |
1da177e4 LT |
400 | |
401 | /* | |
402 | * Because of the execution pass through the non-control-method | |
403 | * parts of the table, we can arrive here twice. Only init | |
404 | * the named object node the first time through | |
405 | */ | |
4be44fcd LB |
406 | if (acpi_ns_get_attached_object(node)) { |
407 | return_ACPI_STATUS(AE_OK); | |
1da177e4 LT |
408 | } |
409 | ||
410 | if (!op->common.value.arg) { | |
411 | /* No arguments, there is nothing to do */ | |
412 | ||
4be44fcd | 413 | return_ACPI_STATUS(AE_OK); |
1da177e4 LT |
414 | } |
415 | ||
416 | /* Build an internal object for the argument(s) */ | |
417 | ||
4be44fcd LB |
418 | status = acpi_ds_build_internal_object(walk_state, op->common.value.arg, |
419 | &obj_desc); | |
420 | if (ACPI_FAILURE(status)) { | |
421 | return_ACPI_STATUS(status); | |
1da177e4 LT |
422 | } |
423 | ||
424 | /* Re-type the object according to its argument */ | |
425 | ||
4be44fcd | 426 | node->type = ACPI_GET_OBJECT_TYPE(obj_desc); |
1da177e4 LT |
427 | |
428 | /* Attach obj to node */ | |
429 | ||
4be44fcd | 430 | status = acpi_ns_attach_object(node, obj_desc, node->type); |
1da177e4 LT |
431 | |
432 | /* Remove local reference to the object */ | |
433 | ||
4be44fcd LB |
434 | acpi_ut_remove_reference(obj_desc); |
435 | return_ACPI_STATUS(status); | |
1da177e4 LT |
436 | } |
437 | ||
4be44fcd | 438 | #endif /* ACPI_NO_METHOD_EXECUTION */ |
1da177e4 | 439 | |
44f6c012 | 440 | /******************************************************************************* |
1da177e4 LT |
441 | * |
442 | * FUNCTION: acpi_ds_init_object_from_op | |
443 | * | |
444 | * PARAMETERS: walk_state - Current walk state | |
445 | * Op - Parser op used to init the internal object | |
446 | * Opcode - AML opcode associated with the object | |
447 | * ret_obj_desc - Namespace object to be initialized | |
448 | * | |
449 | * RETURN: Status | |
450 | * | |
451 | * DESCRIPTION: Initialize a namespace object from a parser Op and its | |
452 | * associated arguments. The namespace object is a more compact | |
453 | * representation of the Op and its arguments. | |
454 | * | |
44f6c012 | 455 | ******************************************************************************/ |
1da177e4 LT |
456 | |
457 | acpi_status | |
4be44fcd LB |
458 | acpi_ds_init_object_from_op(struct acpi_walk_state *walk_state, |
459 | union acpi_parse_object *op, | |
460 | u16 opcode, | |
461 | union acpi_operand_object **ret_obj_desc) | |
1da177e4 | 462 | { |
4be44fcd LB |
463 | const struct acpi_opcode_info *op_info; |
464 | union acpi_operand_object *obj_desc; | |
465 | acpi_status status = AE_OK; | |
1da177e4 | 466 | |
4be44fcd | 467 | ACPI_FUNCTION_TRACE("ds_init_object_from_op"); |
1da177e4 LT |
468 | |
469 | obj_desc = *ret_obj_desc; | |
4be44fcd | 470 | op_info = acpi_ps_get_opcode_info(opcode); |
1da177e4 LT |
471 | if (op_info->class == AML_CLASS_UNKNOWN) { |
472 | /* Unknown opcode */ | |
473 | ||
4be44fcd | 474 | return_ACPI_STATUS(AE_TYPE); |
1da177e4 LT |
475 | } |
476 | ||
477 | /* Perform per-object initialization */ | |
478 | ||
4be44fcd | 479 | switch (ACPI_GET_OBJECT_TYPE(obj_desc)) { |
1da177e4 LT |
480 | case ACPI_TYPE_BUFFER: |
481 | ||
482 | /* | |
483 | * Defer evaluation of Buffer term_arg operand | |
484 | */ | |
4be44fcd LB |
485 | obj_desc->buffer.node = (struct acpi_namespace_node *) |
486 | walk_state->operands[0]; | |
1da177e4 LT |
487 | obj_desc->buffer.aml_start = op->named.data; |
488 | obj_desc->buffer.aml_length = op->named.length; | |
489 | break; | |
490 | ||
1da177e4 LT |
491 | case ACPI_TYPE_PACKAGE: |
492 | ||
493 | /* | |
494 | * Defer evaluation of Package term_arg operand | |
495 | */ | |
4be44fcd LB |
496 | obj_desc->package.node = (struct acpi_namespace_node *) |
497 | walk_state->operands[0]; | |
1da177e4 LT |
498 | obj_desc->package.aml_start = op->named.data; |
499 | obj_desc->package.aml_length = op->named.length; | |
500 | break; | |
501 | ||
1da177e4 LT |
502 | case ACPI_TYPE_INTEGER: |
503 | ||
504 | switch (op_info->type) { | |
505 | case AML_TYPE_CONSTANT: | |
506 | /* | |
507 | * Resolve AML Constants here - AND ONLY HERE! | |
508 | * All constants are integers. | |
44f6c012 RM |
509 | * We mark the integer with a flag that indicates that it started |
510 | * life as a constant -- so that stores to constants will perform | |
511 | * as expected (noop). zero_op is used as a placeholder for optional | |
512 | * target operands. | |
1da177e4 LT |
513 | */ |
514 | obj_desc->common.flags = AOPOBJ_AML_CONSTANT; | |
515 | ||
516 | switch (opcode) { | |
517 | case AML_ZERO_OP: | |
518 | ||
519 | obj_desc->integer.value = 0; | |
520 | break; | |
521 | ||
522 | case AML_ONE_OP: | |
523 | ||
524 | obj_desc->integer.value = 1; | |
525 | break; | |
526 | ||
527 | case AML_ONES_OP: | |
528 | ||
529 | obj_desc->integer.value = ACPI_INTEGER_MAX; | |
530 | ||
531 | /* Truncate value if we are executing from a 32-bit ACPI table */ | |
532 | ||
533 | #ifndef ACPI_NO_METHOD_EXECUTION | |
4be44fcd | 534 | acpi_ex_truncate_for32bit_table(obj_desc); |
1da177e4 LT |
535 | #endif |
536 | break; | |
537 | ||
538 | case AML_REVISION_OP: | |
539 | ||
540 | obj_desc->integer.value = ACPI_CA_VERSION; | |
541 | break; | |
542 | ||
543 | default: | |
544 | ||
b8e4d893 BM |
545 | ACPI_ERROR((AE_INFO, |
546 | "Unknown constant opcode %X", | |
547 | opcode)); | |
1da177e4 LT |
548 | status = AE_AML_OPERAND_TYPE; |
549 | break; | |
550 | } | |
551 | break; | |
552 | ||
1da177e4 LT |
553 | case AML_TYPE_LITERAL: |
554 | ||
555 | obj_desc->integer.value = op->common.value.integer; | |
6f42ccf2 | 556 | #ifndef ACPI_NO_METHOD_EXECUTION |
4be44fcd | 557 | acpi_ex_truncate_for32bit_table(obj_desc); |
6f42ccf2 | 558 | #endif |
1da177e4 LT |
559 | break; |
560 | ||
1da177e4 | 561 | default: |
b8e4d893 BM |
562 | ACPI_ERROR((AE_INFO, "Unknown Integer type %X", |
563 | op_info->type)); | |
1da177e4 LT |
564 | status = AE_AML_OPERAND_TYPE; |
565 | break; | |
566 | } | |
567 | break; | |
568 | ||
1da177e4 LT |
569 | case ACPI_TYPE_STRING: |
570 | ||
571 | obj_desc->string.pointer = op->common.value.string; | |
4be44fcd LB |
572 | obj_desc->string.length = |
573 | (u32) ACPI_STRLEN(op->common.value.string); | |
1da177e4 LT |
574 | |
575 | /* | |
576 | * The string is contained in the ACPI table, don't ever try | |
577 | * to delete it | |
578 | */ | |
579 | obj_desc->common.flags |= AOPOBJ_STATIC_POINTER; | |
580 | break; | |
581 | ||
1da177e4 LT |
582 | case ACPI_TYPE_METHOD: |
583 | break; | |
584 | ||
1da177e4 LT |
585 | case ACPI_TYPE_LOCAL_REFERENCE: |
586 | ||
587 | switch (op_info->type) { | |
588 | case AML_TYPE_LOCAL_VARIABLE: | |
589 | ||
590 | /* Split the opcode into a base opcode + offset */ | |
591 | ||
592 | obj_desc->reference.opcode = AML_LOCAL_OP; | |
593 | obj_desc->reference.offset = opcode - AML_LOCAL_OP; | |
594 | ||
595 | #ifndef ACPI_NO_METHOD_EXECUTION | |
4be44fcd LB |
596 | status = acpi_ds_method_data_get_node(AML_LOCAL_OP, |
597 | obj_desc-> | |
598 | reference.offset, | |
599 | walk_state, | |
600 | (struct | |
601 | acpi_namespace_node | |
602 | **)&obj_desc-> | |
603 | reference.object); | |
1da177e4 LT |
604 | #endif |
605 | break; | |
606 | ||
1da177e4 LT |
607 | case AML_TYPE_METHOD_ARGUMENT: |
608 | ||
609 | /* Split the opcode into a base opcode + offset */ | |
610 | ||
611 | obj_desc->reference.opcode = AML_ARG_OP; | |
612 | obj_desc->reference.offset = opcode - AML_ARG_OP; | |
613 | ||
614 | #ifndef ACPI_NO_METHOD_EXECUTION | |
4be44fcd LB |
615 | status = acpi_ds_method_data_get_node(AML_ARG_OP, |
616 | obj_desc-> | |
617 | reference.offset, | |
618 | walk_state, | |
619 | (struct | |
620 | acpi_namespace_node | |
621 | **)&obj_desc-> | |
622 | reference.object); | |
1da177e4 LT |
623 | #endif |
624 | break; | |
625 | ||
4be44fcd | 626 | default: /* Other literals, etc.. */ |
1da177e4 LT |
627 | |
628 | if (op->common.aml_opcode == AML_INT_NAMEPATH_OP) { | |
629 | /* Node was saved in Op */ | |
630 | ||
631 | obj_desc->reference.node = op->common.node; | |
632 | } | |
633 | ||
634 | obj_desc->reference.opcode = opcode; | |
635 | break; | |
636 | } | |
637 | break; | |
638 | ||
1da177e4 LT |
639 | default: |
640 | ||
b8e4d893 BM |
641 | ACPI_ERROR((AE_INFO, "Unimplemented data type: %X", |
642 | ACPI_GET_OBJECT_TYPE(obj_desc))); | |
1da177e4 LT |
643 | |
644 | status = AE_AML_OPERAND_TYPE; | |
645 | break; | |
646 | } | |
647 | ||
4be44fcd | 648 | return_ACPI_STATUS(status); |
1da177e4 | 649 | } |