]>
Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | /****************************************************************************** |
2 | * | |
3 | * Module Name: dsobject - Dispatcher object management routines | |
4 | * | |
5 | *****************************************************************************/ | |
6 | ||
7 | /* | |
6c9deb72 | 8 | * Copyright (C) 2000 - 2007, 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 | |
b229cf92 | 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)) { |
52fc0b02 | 106 | |
defba1d8 BM |
107 | /* Check if we are resolving a named reference within a package */ |
108 | ||
109 | if ((status == AE_NOT_FOUND) | |
110 | && (acpi_gbl_enable_interpreter_slack) | |
111 | && | |
112 | ((op->common.parent->common.aml_opcode == | |
113 | AML_PACKAGE_OP) | |
114 | || (op->common.parent->common.aml_opcode == | |
115 | AML_VAR_PACKAGE_OP))) { | |
116 | /* | |
117 | * We didn't find the target and we are populating elements | |
118 | * of a package - ignore if slack enabled. Some ASL code | |
119 | * contains dangling invalid references in packages and | |
120 | * expects that no exception will be issued. Leave the | |
121 | * element as a null element. It cannot be used, but it | |
122 | * can be overwritten by subsequent ASL code - this is | |
123 | * typically the case. | |
124 | */ | |
125 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, | |
126 | "Ignoring unresolved reference in package [%4.4s]\n", | |
127 | walk_state-> | |
128 | scope_info->scope. | |
129 | node->name.ascii)); | |
130 | ||
131 | return_ACPI_STATUS(AE_OK); | |
132 | } else { | |
b8e4d893 BM |
133 | ACPI_ERROR_NAMESPACE(op->common.value. |
134 | string, status); | |
defba1d8 BM |
135 | } |
136 | ||
4be44fcd | 137 | return_ACPI_STATUS(status); |
1da177e4 LT |
138 | } |
139 | } | |
140 | } | |
141 | ||
defba1d8 | 142 | /* Create and init a new internal ACPI object */ |
1da177e4 | 143 | |
4be44fcd LB |
144 | obj_desc = acpi_ut_create_internal_object((acpi_ps_get_opcode_info |
145 | (op->common.aml_opcode))-> | |
146 | object_type); | |
1da177e4 | 147 | if (!obj_desc) { |
4be44fcd | 148 | return_ACPI_STATUS(AE_NO_MEMORY); |
1da177e4 LT |
149 | } |
150 | ||
4be44fcd LB |
151 | status = |
152 | acpi_ds_init_object_from_op(walk_state, op, op->common.aml_opcode, | |
153 | &obj_desc); | |
154 | if (ACPI_FAILURE(status)) { | |
155 | acpi_ut_remove_reference(obj_desc); | |
156 | return_ACPI_STATUS(status); | |
1da177e4 LT |
157 | } |
158 | ||
159 | *obj_desc_ptr = obj_desc; | |
4be44fcd | 160 | return_ACPI_STATUS(AE_OK); |
1da177e4 LT |
161 | } |
162 | ||
44f6c012 | 163 | /******************************************************************************* |
1da177e4 LT |
164 | * |
165 | * FUNCTION: acpi_ds_build_internal_buffer_obj | |
166 | * | |
167 | * PARAMETERS: walk_state - Current walk state | |
168 | * Op - Parser object to be translated | |
169 | * buffer_length - Length of the buffer | |
170 | * obj_desc_ptr - Where the ACPI internal object is returned | |
171 | * | |
172 | * RETURN: Status | |
173 | * | |
174 | * DESCRIPTION: Translate a parser Op package object to the equivalent | |
175 | * namespace object | |
176 | * | |
44f6c012 | 177 | ******************************************************************************/ |
1da177e4 LT |
178 | |
179 | acpi_status | |
4be44fcd LB |
180 | acpi_ds_build_internal_buffer_obj(struct acpi_walk_state *walk_state, |
181 | union acpi_parse_object *op, | |
182 | u32 buffer_length, | |
183 | union acpi_operand_object **obj_desc_ptr) | |
1da177e4 | 184 | { |
4be44fcd LB |
185 | union acpi_parse_object *arg; |
186 | union acpi_operand_object *obj_desc; | |
187 | union acpi_parse_object *byte_list; | |
188 | u32 byte_list_length = 0; | |
1da177e4 | 189 | |
b229cf92 | 190 | ACPI_FUNCTION_TRACE(ds_build_internal_buffer_obj); |
1da177e4 | 191 | |
defba1d8 BM |
192 | /* |
193 | * If we are evaluating a Named buffer object "Name (xxxx, Buffer)". | |
194 | * The buffer object already exists (from the NS node), otherwise it must | |
195 | * be created. | |
196 | */ | |
1da177e4 | 197 | obj_desc = *obj_desc_ptr; |
defba1d8 | 198 | if (!obj_desc) { |
52fc0b02 | 199 | |
1da177e4 LT |
200 | /* Create a new buffer object */ |
201 | ||
4be44fcd | 202 | obj_desc = acpi_ut_create_internal_object(ACPI_TYPE_BUFFER); |
1da177e4 LT |
203 | *obj_desc_ptr = obj_desc; |
204 | if (!obj_desc) { | |
4be44fcd | 205 | return_ACPI_STATUS(AE_NO_MEMORY); |
1da177e4 LT |
206 | } |
207 | } | |
208 | ||
209 | /* | |
210 | * Second arg is the buffer data (optional) byte_list can be either | |
211 | * individual bytes or a string initializer. In either case, a | |
212 | * byte_list appears in the AML. | |
213 | */ | |
4be44fcd | 214 | arg = op->common.value.arg; /* skip first arg */ |
1da177e4 LT |
215 | |
216 | byte_list = arg->named.next; | |
217 | if (byte_list) { | |
218 | if (byte_list->common.aml_opcode != AML_INT_BYTELIST_OP) { | |
b8e4d893 BM |
219 | ACPI_ERROR((AE_INFO, |
220 | "Expecting bytelist, got AML opcode %X in op %p", | |
221 | byte_list->common.aml_opcode, byte_list)); | |
1da177e4 | 222 | |
4be44fcd | 223 | acpi_ut_remove_reference(obj_desc); |
1da177e4 LT |
224 | return (AE_TYPE); |
225 | } | |
226 | ||
227 | byte_list_length = (u32) byte_list->common.value.integer; | |
228 | } | |
229 | ||
230 | /* | |
231 | * The buffer length (number of bytes) will be the larger of: | |
232 | * 1) The specified buffer length and | |
233 | * 2) The length of the initializer byte list | |
234 | */ | |
235 | obj_desc->buffer.length = buffer_length; | |
236 | if (byte_list_length > buffer_length) { | |
237 | obj_desc->buffer.length = byte_list_length; | |
238 | } | |
239 | ||
240 | /* Allocate the buffer */ | |
241 | ||
242 | if (obj_desc->buffer.length == 0) { | |
243 | obj_desc->buffer.pointer = NULL; | |
4be44fcd LB |
244 | ACPI_DEBUG_PRINT((ACPI_DB_EXEC, |
245 | "Buffer defined with zero length in AML, creating\n")); | |
246 | } else { | |
247 | obj_desc->buffer.pointer = | |
8313524a | 248 | ACPI_ALLOCATE_ZEROED(obj_desc->buffer.length); |
1da177e4 | 249 | if (!obj_desc->buffer.pointer) { |
4be44fcd LB |
250 | acpi_ut_delete_object_desc(obj_desc); |
251 | return_ACPI_STATUS(AE_NO_MEMORY); | |
1da177e4 LT |
252 | } |
253 | ||
254 | /* Initialize buffer from the byte_list (if present) */ | |
255 | ||
256 | if (byte_list) { | |
4be44fcd LB |
257 | ACPI_MEMCPY(obj_desc->buffer.pointer, |
258 | byte_list->named.data, byte_list_length); | |
1da177e4 LT |
259 | } |
260 | } | |
261 | ||
262 | obj_desc->buffer.flags |= AOPOBJ_DATA_VALID; | |
8f9337c8 | 263 | op->common.node = ACPI_CAST_PTR(struct acpi_namespace_node, obj_desc); |
4be44fcd | 264 | return_ACPI_STATUS(AE_OK); |
1da177e4 LT |
265 | } |
266 | ||
44f6c012 | 267 | /******************************************************************************* |
1da177e4 LT |
268 | * |
269 | * FUNCTION: acpi_ds_build_internal_package_obj | |
270 | * | |
271 | * PARAMETERS: walk_state - Current walk state | |
272 | * Op - Parser object to be translated | |
8f9337c8 BM |
273 | * element_count - Number of elements in the package - this is |
274 | * the num_elements argument to Package() | |
1da177e4 LT |
275 | * obj_desc_ptr - Where the ACPI internal object is returned |
276 | * | |
277 | * RETURN: Status | |
278 | * | |
279 | * DESCRIPTION: Translate a parser Op package object to the equivalent | |
280 | * namespace object | |
281 | * | |
8f9337c8 BM |
282 | * NOTE: The number of elements in the package will be always be the num_elements |
283 | * count, regardless of the number of elements in the package list. If | |
284 | * num_elements is smaller, only that many package list elements are used. | |
285 | * if num_elements is larger, the Package object is padded out with | |
286 | * objects of type Uninitialized (as per ACPI spec.) | |
287 | * | |
288 | * Even though the ASL compilers do not allow num_elements to be smaller | |
289 | * than the Package list length (for the fixed length package opcode), some | |
290 | * BIOS code modifies the AML on the fly to adjust the num_elements, and | |
291 | * this code compensates for that. This also provides compatibility with | |
292 | * other AML interpreters. | |
293 | * | |
44f6c012 | 294 | ******************************************************************************/ |
1da177e4 LT |
295 | |
296 | acpi_status | |
4be44fcd LB |
297 | acpi_ds_build_internal_package_obj(struct acpi_walk_state *walk_state, |
298 | union acpi_parse_object *op, | |
8f9337c8 | 299 | u32 element_count, |
4be44fcd | 300 | union acpi_operand_object **obj_desc_ptr) |
1da177e4 | 301 | { |
4be44fcd LB |
302 | union acpi_parse_object *arg; |
303 | union acpi_parse_object *parent; | |
304 | union acpi_operand_object *obj_desc = NULL; | |
4be44fcd | 305 | acpi_status status = AE_OK; |
defba1d8 | 306 | acpi_native_uint i; |
1da177e4 | 307 | |
b229cf92 | 308 | ACPI_FUNCTION_TRACE(ds_build_internal_package_obj); |
1da177e4 LT |
309 | |
310 | /* Find the parent of a possibly nested package */ | |
311 | ||
312 | parent = op->common.parent; | |
4be44fcd LB |
313 | while ((parent->common.aml_opcode == AML_PACKAGE_OP) || |
314 | (parent->common.aml_opcode == AML_VAR_PACKAGE_OP)) { | |
1da177e4 LT |
315 | parent = parent->common.parent; |
316 | } | |
317 | ||
defba1d8 BM |
318 | /* |
319 | * If we are evaluating a Named package object "Name (xxxx, Package)", | |
320 | * the package object already exists, otherwise it must be created. | |
321 | */ | |
1da177e4 | 322 | obj_desc = *obj_desc_ptr; |
defba1d8 | 323 | if (!obj_desc) { |
4be44fcd | 324 | obj_desc = acpi_ut_create_internal_object(ACPI_TYPE_PACKAGE); |
1da177e4 LT |
325 | *obj_desc_ptr = obj_desc; |
326 | if (!obj_desc) { | |
4be44fcd | 327 | return_ACPI_STATUS(AE_NO_MEMORY); |
1da177e4 LT |
328 | } |
329 | ||
330 | obj_desc->package.node = parent->common.node; | |
331 | } | |
332 | ||
1da177e4 | 333 | /* |
8f9337c8 BM |
334 | * Allocate the element array (array of pointers to the individual |
335 | * objects) based on the num_elements parameter. Add an extra pointer slot | |
336 | * so that the list is always null terminated. | |
1da177e4 | 337 | */ |
8313524a | 338 | obj_desc->package.elements = ACPI_ALLOCATE_ZEROED(((acpi_size) |
8f9337c8 | 339 | element_count + |
8313524a | 340 | 1) * sizeof(void *)); |
1da177e4 LT |
341 | |
342 | if (!obj_desc->package.elements) { | |
4be44fcd LB |
343 | acpi_ut_delete_object_desc(obj_desc); |
344 | return_ACPI_STATUS(AE_NO_MEMORY); | |
1da177e4 LT |
345 | } |
346 | ||
8f9337c8 BM |
347 | obj_desc->package.count = element_count; |
348 | ||
1da177e4 | 349 | /* |
8f9337c8 BM |
350 | * Initialize the elements of the package, up to the num_elements count. |
351 | * Package is automatically padded with uninitialized (NULL) elements | |
352 | * if num_elements is greater than the package list length. Likewise, | |
353 | * Package is truncated if num_elements is less than the list length. | |
1da177e4 | 354 | */ |
1da177e4 LT |
355 | arg = op->common.value.arg; |
356 | arg = arg->common.next; | |
8f9337c8 | 357 | for (i = 0; arg && (i < element_count); i++) { |
1da177e4 | 358 | if (arg->common.aml_opcode == AML_INT_RETURN_VALUE_OP) { |
52fc0b02 | 359 | |
8f9337c8 | 360 | /* This package element is already built, just get it */ |
1da177e4 | 361 | |
44f6c012 | 362 | obj_desc->package.elements[i] = |
4be44fcd LB |
363 | ACPI_CAST_PTR(union acpi_operand_object, |
364 | arg->common.node); | |
365 | } else { | |
366 | status = acpi_ds_build_internal_object(walk_state, arg, | |
367 | &obj_desc-> | |
368 | package. | |
369 | elements[i]); | |
1da177e4 | 370 | } |
1da177e4 LT |
371 | arg = arg->common.next; |
372 | } | |
373 | ||
8f9337c8 BM |
374 | if (!arg) { |
375 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, | |
376 | "Package List length larger than NumElements count (%X), truncated\n", | |
377 | element_count)); | |
378 | } | |
379 | ||
1da177e4 | 380 | obj_desc->package.flags |= AOPOBJ_DATA_VALID; |
8f9337c8 | 381 | op->common.node = ACPI_CAST_PTR(struct acpi_namespace_node, obj_desc); |
4be44fcd | 382 | return_ACPI_STATUS(status); |
1da177e4 LT |
383 | } |
384 | ||
44f6c012 | 385 | /******************************************************************************* |
1da177e4 LT |
386 | * |
387 | * FUNCTION: acpi_ds_create_node | |
388 | * | |
389 | * PARAMETERS: walk_state - Current walk state | |
390 | * Node - NS Node to be initialized | |
391 | * Op - Parser object to be translated | |
392 | * | |
393 | * RETURN: Status | |
394 | * | |
395 | * DESCRIPTION: Create the object to be associated with a namespace node | |
396 | * | |
44f6c012 | 397 | ******************************************************************************/ |
1da177e4 LT |
398 | |
399 | acpi_status | |
4be44fcd LB |
400 | acpi_ds_create_node(struct acpi_walk_state *walk_state, |
401 | struct acpi_namespace_node *node, | |
402 | union acpi_parse_object *op) | |
1da177e4 | 403 | { |
4be44fcd LB |
404 | acpi_status status; |
405 | union acpi_operand_object *obj_desc; | |
1da177e4 | 406 | |
b229cf92 | 407 | ACPI_FUNCTION_TRACE_PTR(ds_create_node, op); |
1da177e4 LT |
408 | |
409 | /* | |
410 | * Because of the execution pass through the non-control-method | |
411 | * parts of the table, we can arrive here twice. Only init | |
412 | * the named object node the first time through | |
413 | */ | |
4be44fcd LB |
414 | if (acpi_ns_get_attached_object(node)) { |
415 | return_ACPI_STATUS(AE_OK); | |
1da177e4 LT |
416 | } |
417 | ||
418 | if (!op->common.value.arg) { | |
52fc0b02 | 419 | |
1da177e4 LT |
420 | /* No arguments, there is nothing to do */ |
421 | ||
4be44fcd | 422 | return_ACPI_STATUS(AE_OK); |
1da177e4 LT |
423 | } |
424 | ||
425 | /* Build an internal object for the argument(s) */ | |
426 | ||
4be44fcd LB |
427 | status = acpi_ds_build_internal_object(walk_state, op->common.value.arg, |
428 | &obj_desc); | |
429 | if (ACPI_FAILURE(status)) { | |
430 | return_ACPI_STATUS(status); | |
1da177e4 LT |
431 | } |
432 | ||
433 | /* Re-type the object according to its argument */ | |
434 | ||
4be44fcd | 435 | node->type = ACPI_GET_OBJECT_TYPE(obj_desc); |
1da177e4 LT |
436 | |
437 | /* Attach obj to node */ | |
438 | ||
4be44fcd | 439 | status = acpi_ns_attach_object(node, obj_desc, node->type); |
1da177e4 LT |
440 | |
441 | /* Remove local reference to the object */ | |
442 | ||
4be44fcd LB |
443 | acpi_ut_remove_reference(obj_desc); |
444 | return_ACPI_STATUS(status); | |
1da177e4 LT |
445 | } |
446 | ||
4be44fcd | 447 | #endif /* ACPI_NO_METHOD_EXECUTION */ |
1da177e4 | 448 | |
44f6c012 | 449 | /******************************************************************************* |
1da177e4 LT |
450 | * |
451 | * FUNCTION: acpi_ds_init_object_from_op | |
452 | * | |
453 | * PARAMETERS: walk_state - Current walk state | |
454 | * Op - Parser op used to init the internal object | |
455 | * Opcode - AML opcode associated with the object | |
456 | * ret_obj_desc - Namespace object to be initialized | |
457 | * | |
458 | * RETURN: Status | |
459 | * | |
460 | * DESCRIPTION: Initialize a namespace object from a parser Op and its | |
461 | * associated arguments. The namespace object is a more compact | |
462 | * representation of the Op and its arguments. | |
463 | * | |
44f6c012 | 464 | ******************************************************************************/ |
1da177e4 LT |
465 | |
466 | acpi_status | |
4be44fcd LB |
467 | acpi_ds_init_object_from_op(struct acpi_walk_state *walk_state, |
468 | union acpi_parse_object *op, | |
469 | u16 opcode, | |
470 | union acpi_operand_object **ret_obj_desc) | |
1da177e4 | 471 | { |
4be44fcd LB |
472 | const struct acpi_opcode_info *op_info; |
473 | union acpi_operand_object *obj_desc; | |
474 | acpi_status status = AE_OK; | |
1da177e4 | 475 | |
b229cf92 | 476 | ACPI_FUNCTION_TRACE(ds_init_object_from_op); |
1da177e4 LT |
477 | |
478 | obj_desc = *ret_obj_desc; | |
4be44fcd | 479 | op_info = acpi_ps_get_opcode_info(opcode); |
1da177e4 | 480 | if (op_info->class == AML_CLASS_UNKNOWN) { |
52fc0b02 | 481 | |
1da177e4 LT |
482 | /* Unknown opcode */ |
483 | ||
4be44fcd | 484 | return_ACPI_STATUS(AE_TYPE); |
1da177e4 LT |
485 | } |
486 | ||
487 | /* Perform per-object initialization */ | |
488 | ||
4be44fcd | 489 | switch (ACPI_GET_OBJECT_TYPE(obj_desc)) { |
1da177e4 LT |
490 | case ACPI_TYPE_BUFFER: |
491 | ||
492 | /* | |
493 | * Defer evaluation of Buffer term_arg operand | |
494 | */ | |
8f9337c8 BM |
495 | obj_desc->buffer.node = |
496 | ACPI_CAST_PTR(struct acpi_namespace_node, | |
497 | walk_state->operands[0]); | |
1da177e4 LT |
498 | obj_desc->buffer.aml_start = op->named.data; |
499 | obj_desc->buffer.aml_length = op->named.length; | |
500 | break; | |
501 | ||
1da177e4 LT |
502 | case ACPI_TYPE_PACKAGE: |
503 | ||
504 | /* | |
505 | * Defer evaluation of Package term_arg operand | |
506 | */ | |
8f9337c8 BM |
507 | obj_desc->package.node = |
508 | ACPI_CAST_PTR(struct acpi_namespace_node, | |
509 | walk_state->operands[0]); | |
1da177e4 LT |
510 | obj_desc->package.aml_start = op->named.data; |
511 | obj_desc->package.aml_length = op->named.length; | |
512 | break; | |
513 | ||
1da177e4 LT |
514 | case ACPI_TYPE_INTEGER: |
515 | ||
516 | switch (op_info->type) { | |
517 | case AML_TYPE_CONSTANT: | |
518 | /* | |
519 | * Resolve AML Constants here - AND ONLY HERE! | |
520 | * All constants are integers. | |
44f6c012 RM |
521 | * We mark the integer with a flag that indicates that it started |
522 | * life as a constant -- so that stores to constants will perform | |
523 | * as expected (noop). zero_op is used as a placeholder for optional | |
524 | * target operands. | |
1da177e4 LT |
525 | */ |
526 | obj_desc->common.flags = AOPOBJ_AML_CONSTANT; | |
527 | ||
528 | switch (opcode) { | |
529 | case AML_ZERO_OP: | |
530 | ||
531 | obj_desc->integer.value = 0; | |
532 | break; | |
533 | ||
534 | case AML_ONE_OP: | |
535 | ||
536 | obj_desc->integer.value = 1; | |
537 | break; | |
538 | ||
539 | case AML_ONES_OP: | |
540 | ||
541 | obj_desc->integer.value = ACPI_INTEGER_MAX; | |
542 | ||
543 | /* Truncate value if we are executing from a 32-bit ACPI table */ | |
544 | ||
545 | #ifndef ACPI_NO_METHOD_EXECUTION | |
4be44fcd | 546 | acpi_ex_truncate_for32bit_table(obj_desc); |
1da177e4 LT |
547 | #endif |
548 | break; | |
549 | ||
550 | case AML_REVISION_OP: | |
551 | ||
552 | obj_desc->integer.value = ACPI_CA_VERSION; | |
553 | break; | |
554 | ||
555 | default: | |
556 | ||
b8e4d893 BM |
557 | ACPI_ERROR((AE_INFO, |
558 | "Unknown constant opcode %X", | |
559 | opcode)); | |
1da177e4 LT |
560 | status = AE_AML_OPERAND_TYPE; |
561 | break; | |
562 | } | |
563 | break; | |
564 | ||
1da177e4 LT |
565 | case AML_TYPE_LITERAL: |
566 | ||
567 | obj_desc->integer.value = op->common.value.integer; | |
6f42ccf2 | 568 | #ifndef ACPI_NO_METHOD_EXECUTION |
4be44fcd | 569 | acpi_ex_truncate_for32bit_table(obj_desc); |
6f42ccf2 | 570 | #endif |
1da177e4 LT |
571 | break; |
572 | ||
1da177e4 | 573 | default: |
b8e4d893 BM |
574 | ACPI_ERROR((AE_INFO, "Unknown Integer type %X", |
575 | op_info->type)); | |
1da177e4 LT |
576 | status = AE_AML_OPERAND_TYPE; |
577 | break; | |
578 | } | |
579 | break; | |
580 | ||
1da177e4 LT |
581 | case ACPI_TYPE_STRING: |
582 | ||
583 | obj_desc->string.pointer = op->common.value.string; | |
4be44fcd LB |
584 | obj_desc->string.length = |
585 | (u32) ACPI_STRLEN(op->common.value.string); | |
1da177e4 LT |
586 | |
587 | /* | |
588 | * The string is contained in the ACPI table, don't ever try | |
589 | * to delete it | |
590 | */ | |
591 | obj_desc->common.flags |= AOPOBJ_STATIC_POINTER; | |
592 | break; | |
593 | ||
1da177e4 LT |
594 | case ACPI_TYPE_METHOD: |
595 | break; | |
596 | ||
1da177e4 LT |
597 | case ACPI_TYPE_LOCAL_REFERENCE: |
598 | ||
599 | switch (op_info->type) { | |
600 | case AML_TYPE_LOCAL_VARIABLE: | |
601 | ||
602 | /* Split the opcode into a base opcode + offset */ | |
603 | ||
604 | obj_desc->reference.opcode = AML_LOCAL_OP; | |
605 | obj_desc->reference.offset = opcode - AML_LOCAL_OP; | |
606 | ||
607 | #ifndef ACPI_NO_METHOD_EXECUTION | |
4be44fcd LB |
608 | status = acpi_ds_method_data_get_node(AML_LOCAL_OP, |
609 | obj_desc-> | |
610 | reference.offset, | |
611 | walk_state, | |
612 | (struct | |
613 | acpi_namespace_node | |
614 | **)&obj_desc-> | |
615 | reference.object); | |
1da177e4 LT |
616 | #endif |
617 | break; | |
618 | ||
1da177e4 LT |
619 | case AML_TYPE_METHOD_ARGUMENT: |
620 | ||
621 | /* Split the opcode into a base opcode + offset */ | |
622 | ||
623 | obj_desc->reference.opcode = AML_ARG_OP; | |
624 | obj_desc->reference.offset = opcode - AML_ARG_OP; | |
625 | ||
626 | #ifndef ACPI_NO_METHOD_EXECUTION | |
4be44fcd LB |
627 | status = acpi_ds_method_data_get_node(AML_ARG_OP, |
628 | obj_desc-> | |
629 | reference.offset, | |
630 | walk_state, | |
631 | (struct | |
632 | acpi_namespace_node | |
633 | **)&obj_desc-> | |
634 | reference.object); | |
1da177e4 LT |
635 | #endif |
636 | break; | |
637 | ||
4be44fcd | 638 | default: /* Other literals, etc.. */ |
1da177e4 LT |
639 | |
640 | if (op->common.aml_opcode == AML_INT_NAMEPATH_OP) { | |
52fc0b02 | 641 | |
1da177e4 LT |
642 | /* Node was saved in Op */ |
643 | ||
644 | obj_desc->reference.node = op->common.node; | |
645 | } | |
646 | ||
647 | obj_desc->reference.opcode = opcode; | |
648 | break; | |
649 | } | |
650 | break; | |
651 | ||
1da177e4 LT |
652 | default: |
653 | ||
b8e4d893 BM |
654 | ACPI_ERROR((AE_INFO, "Unimplemented data type: %X", |
655 | ACPI_GET_OBJECT_TYPE(obj_desc))); | |
1da177e4 LT |
656 | |
657 | status = AE_AML_OPERAND_TYPE; | |
658 | break; | |
659 | } | |
660 | ||
4be44fcd | 661 | return_ACPI_STATUS(status); |
1da177e4 | 662 | } |