blob: ac0bfb1b16fe0c9ef6098beac99a4c0e0db4f20e [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/******************************************************************************
2 *
3 * Module Name: dsopcode - Dispatcher Op Region support and handling of
4 * "control" opcodes
5 *
6 *****************************************************************************/
7
8/*
Len Brown75a44ce2008-04-23 23:00:13 -04009 * Copyright (C) 2000 - 2008, Intel Corp.
Linus Torvalds1da177e2005-04-16 15:20:36 -070010 * All rights reserved.
11 *
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
14 * are met:
15 * 1. Redistributions of source code must retain the above copyright
16 * notice, this list of conditions, and the following disclaimer,
17 * without modification.
18 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
19 * substantially similar to the "NO WARRANTY" disclaimer below
20 * ("Disclaimer") and any redistribution must be conditioned upon
21 * including a substantially similar Disclaimer requirement for further
22 * binary redistribution.
23 * 3. Neither the names of the above-listed copyright holders nor the names
24 * of any contributors may be used to endorse or promote products derived
25 * from this software without specific prior written permission.
26 *
27 * Alternatively, this software may be distributed under the terms of the
28 * GNU General Public License ("GPL") version 2 as published by the Free
29 * Software Foundation.
30 *
31 * NO WARRANTY
32 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
33 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
34 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
35 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
36 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
37 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
38 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
39 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
40 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
41 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
42 * POSSIBILITY OF SUCH DAMAGES.
43 */
44
Linus Torvalds1da177e2005-04-16 15:20:36 -070045#include <acpi/acpi.h>
46#include <acpi/acparser.h>
47#include <acpi/amlcode.h>
48#include <acpi/acdispat.h>
49#include <acpi/acinterp.h>
50#include <acpi/acnamesp.h>
51#include <acpi/acevents.h>
Lin Ming941f48b2008-04-10 19:06:41 +040052#include <acpi/actables.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070053
54#define _COMPONENT ACPI_DISPATCHER
Len Brown4be44fc2005-08-05 00:44:28 -040055ACPI_MODULE_NAME("dsopcode")
Linus Torvalds1da177e2005-04-16 15:20:36 -070056
Robert Moore44f6c012005-04-18 22:49:35 -040057/* Local prototypes */
Len Brown4be44fc2005-08-05 00:44:28 -040058static acpi_status
59acpi_ds_execute_arguments(struct acpi_namespace_node *node,
60 struct acpi_namespace_node *scope_node,
61 u32 aml_length, u8 * aml_start);
Linus Torvalds1da177e2005-04-16 15:20:36 -070062
Robert Moore44f6c012005-04-18 22:49:35 -040063static acpi_status
Len Brown4be44fc2005-08-05 00:44:28 -040064acpi_ds_init_buffer_field(u16 aml_opcode,
65 union acpi_operand_object *obj_desc,
66 union acpi_operand_object *buffer_desc,
67 union acpi_operand_object *offset_desc,
68 union acpi_operand_object *length_desc,
69 union acpi_operand_object *result_desc);
Robert Moore44f6c012005-04-18 22:49:35 -040070
71/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -070072 *
73 * FUNCTION: acpi_ds_execute_arguments
74 *
Robert Moore44f6c012005-04-18 22:49:35 -040075 * PARAMETERS: Node - Object NS node
76 * scope_node - Parent NS node
Linus Torvalds1da177e2005-04-16 15:20:36 -070077 * aml_length - Length of executable AML
78 * aml_start - Pointer to the AML
79 *
80 * RETURN: Status.
81 *
82 * DESCRIPTION: Late (deferred) execution of region or field arguments
83 *
Robert Moore44f6c012005-04-18 22:49:35 -040084 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -070085
Robert Moore44f6c012005-04-18 22:49:35 -040086static acpi_status
Len Brown4be44fc2005-08-05 00:44:28 -040087acpi_ds_execute_arguments(struct acpi_namespace_node *node,
88 struct acpi_namespace_node *scope_node,
89 u32 aml_length, u8 * aml_start)
Linus Torvalds1da177e2005-04-16 15:20:36 -070090{
Len Brown4be44fc2005-08-05 00:44:28 -040091 acpi_status status;
92 union acpi_parse_object *op;
93 struct acpi_walk_state *walk_state;
Linus Torvalds1da177e2005-04-16 15:20:36 -070094
Bob Mooreb229cf92006-04-21 17:15:00 -040095 ACPI_FUNCTION_TRACE(ds_execute_arguments);
Linus Torvalds1da177e2005-04-16 15:20:36 -070096
97 /*
98 * Allocate a new parser op to be the root of the parsed tree
99 */
Len Brown4be44fc2005-08-05 00:44:28 -0400100 op = acpi_ps_alloc_op(AML_INT_EVAL_SUBTREE_OP);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700101 if (!op) {
Len Brown4be44fc2005-08-05 00:44:28 -0400102 return_ACPI_STATUS(AE_NO_MEMORY);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700103 }
104
105 /* Save the Node for use in acpi_ps_parse_aml */
106
107 op->common.node = scope_node;
108
109 /* Create and initialize a new parser state */
110
Len Brown4be44fc2005-08-05 00:44:28 -0400111 walk_state = acpi_ds_create_walk_state(0, NULL, NULL, NULL);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700112 if (!walk_state) {
Robert Moore88ac00f2005-05-26 00:00:00 -0400113 status = AE_NO_MEMORY;
114 goto cleanup;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700115 }
116
Len Brown4be44fc2005-08-05 00:44:28 -0400117 status = acpi_ds_init_aml_walk(walk_state, op, NULL, aml_start,
Bob Mooreec3153f2007-02-02 19:48:21 +0300118 aml_length, NULL, ACPI_IMODE_LOAD_PASS1);
Len Brown4be44fc2005-08-05 00:44:28 -0400119 if (ACPI_FAILURE(status)) {
120 acpi_ds_delete_walk_state(walk_state);
Robert Moore88ac00f2005-05-26 00:00:00 -0400121 goto cleanup;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700122 }
123
124 /* Mark this parse as a deferred opcode */
125
126 walk_state->parse_flags = ACPI_PARSE_DEFERRED_OP;
127 walk_state->deferred_node = node;
128
129 /* Pass1: Parse the entire declaration */
130
Len Brown4be44fc2005-08-05 00:44:28 -0400131 status = acpi_ps_parse_aml(walk_state);
132 if (ACPI_FAILURE(status)) {
Robert Moore88ac00f2005-05-26 00:00:00 -0400133 goto cleanup;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700134 }
135
136 /* Get and init the Op created above */
137
138 op->common.node = node;
Len Brown4be44fc2005-08-05 00:44:28 -0400139 acpi_ps_delete_parse_tree(op);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700140
141 /* Evaluate the deferred arguments */
142
Len Brown4be44fc2005-08-05 00:44:28 -0400143 op = acpi_ps_alloc_op(AML_INT_EVAL_SUBTREE_OP);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700144 if (!op) {
Len Brown4be44fc2005-08-05 00:44:28 -0400145 return_ACPI_STATUS(AE_NO_MEMORY);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700146 }
147
148 op->common.node = scope_node;
149
150 /* Create and initialize a new parser state */
151
Len Brown4be44fc2005-08-05 00:44:28 -0400152 walk_state = acpi_ds_create_walk_state(0, NULL, NULL, NULL);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700153 if (!walk_state) {
Robert Moore88ac00f2005-05-26 00:00:00 -0400154 status = AE_NO_MEMORY;
155 goto cleanup;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700156 }
157
158 /* Execute the opcode and arguments */
159
Len Brown4be44fc2005-08-05 00:44:28 -0400160 status = acpi_ds_init_aml_walk(walk_state, op, NULL, aml_start,
Bob Mooreec3153f2007-02-02 19:48:21 +0300161 aml_length, NULL, ACPI_IMODE_EXECUTE);
Len Brown4be44fc2005-08-05 00:44:28 -0400162 if (ACPI_FAILURE(status)) {
163 acpi_ds_delete_walk_state(walk_state);
Robert Moore88ac00f2005-05-26 00:00:00 -0400164 goto cleanup;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700165 }
166
167 /* Mark this execution as a deferred opcode */
168
169 walk_state->deferred_node = node;
Len Brown4be44fc2005-08-05 00:44:28 -0400170 status = acpi_ps_parse_aml(walk_state);
Robert Moore88ac00f2005-05-26 00:00:00 -0400171
Len Brown4be44fc2005-08-05 00:44:28 -0400172 cleanup:
173 acpi_ps_delete_parse_tree(op);
174 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700175}
176
Robert Moore44f6c012005-04-18 22:49:35 -0400177/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700178 *
179 * FUNCTION: acpi_ds_get_buffer_field_arguments
180 *
181 * PARAMETERS: obj_desc - A valid buffer_field object
182 *
183 * RETURN: Status.
184 *
185 * DESCRIPTION: Get buffer_field Buffer and Index. This implements the late
186 * evaluation of these field attributes.
187 *
Robert Moore44f6c012005-04-18 22:49:35 -0400188 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700189
190acpi_status
Len Brown4be44fc2005-08-05 00:44:28 -0400191acpi_ds_get_buffer_field_arguments(union acpi_operand_object *obj_desc)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700192{
Len Brown4be44fc2005-08-05 00:44:28 -0400193 union acpi_operand_object *extra_desc;
194 struct acpi_namespace_node *node;
195 acpi_status status;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700196
Bob Mooreb229cf92006-04-21 17:15:00 -0400197 ACPI_FUNCTION_TRACE_PTR(ds_get_buffer_field_arguments, obj_desc);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700198
199 if (obj_desc->common.flags & AOPOBJ_DATA_VALID) {
Len Brown4be44fc2005-08-05 00:44:28 -0400200 return_ACPI_STATUS(AE_OK);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700201 }
202
203 /* Get the AML pointer (method object) and buffer_field node */
204
Len Brown4be44fc2005-08-05 00:44:28 -0400205 extra_desc = acpi_ns_get_secondary_object(obj_desc);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700206 node = obj_desc->buffer_field.node;
207
Len Brown4be44fc2005-08-05 00:44:28 -0400208 ACPI_DEBUG_EXEC(acpi_ut_display_init_pathname
209 (ACPI_TYPE_BUFFER_FIELD, node, NULL));
Bob Mooreb229cf92006-04-21 17:15:00 -0400210 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "[%4.4s] BufferField Arg Init\n",
Len Brown4be44fc2005-08-05 00:44:28 -0400211 acpi_ut_get_node_name(node)));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700212
213 /* Execute the AML code for the term_arg arguments */
214
Len Brown4be44fc2005-08-05 00:44:28 -0400215 status = acpi_ds_execute_arguments(node, acpi_ns_get_parent_node(node),
216 extra_desc->extra.aml_length,
217 extra_desc->extra.aml_start);
218 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700219}
220
Robert Moore44f6c012005-04-18 22:49:35 -0400221/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700222 *
Lin Mingef805d92008-04-10 19:06:41 +0400223 * FUNCTION: acpi_ds_get_bank_field_arguments
224 *
225 * PARAMETERS: obj_desc - A valid bank_field object
226 *
227 * RETURN: Status.
228 *
229 * DESCRIPTION: Get bank_field bank_value. This implements the late
230 * evaluation of these field attributes.
231 *
232 ******************************************************************************/
233
234acpi_status
235acpi_ds_get_bank_field_arguments(union acpi_operand_object *obj_desc)
236{
237 union acpi_operand_object *extra_desc;
238 struct acpi_namespace_node *node;
239 acpi_status status;
240
241 ACPI_FUNCTION_TRACE_PTR(ds_get_bank_field_arguments, obj_desc);
242
243 if (obj_desc->common.flags & AOPOBJ_DATA_VALID) {
244 return_ACPI_STATUS(AE_OK);
245 }
246
247 /* Get the AML pointer (method object) and bank_field node */
248
249 extra_desc = acpi_ns_get_secondary_object(obj_desc);
250 node = obj_desc->bank_field.node;
251
252 ACPI_DEBUG_EXEC(acpi_ut_display_init_pathname
253 (ACPI_TYPE_LOCAL_BANK_FIELD, node, NULL));
254 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "[%4.4s] BankField Arg Init\n",
255 acpi_ut_get_node_name(node)));
256
257 /* Execute the AML code for the term_arg arguments */
258
259 status = acpi_ds_execute_arguments(node, acpi_ns_get_parent_node(node),
260 extra_desc->extra.aml_length,
261 extra_desc->extra.aml_start);
262 return_ACPI_STATUS(status);
263}
264
265/*******************************************************************************
266 *
Linus Torvalds1da177e2005-04-16 15:20:36 -0700267 * FUNCTION: acpi_ds_get_buffer_arguments
268 *
269 * PARAMETERS: obj_desc - A valid Buffer object
270 *
271 * RETURN: Status.
272 *
273 * DESCRIPTION: Get Buffer length and initializer byte list. This implements
274 * the late evaluation of these attributes.
275 *
Robert Moore44f6c012005-04-18 22:49:35 -0400276 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700277
Len Brown4be44fc2005-08-05 00:44:28 -0400278acpi_status acpi_ds_get_buffer_arguments(union acpi_operand_object *obj_desc)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700279{
Len Brown4be44fc2005-08-05 00:44:28 -0400280 struct acpi_namespace_node *node;
281 acpi_status status;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700282
Bob Mooreb229cf92006-04-21 17:15:00 -0400283 ACPI_FUNCTION_TRACE_PTR(ds_get_buffer_arguments, obj_desc);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700284
285 if (obj_desc->common.flags & AOPOBJ_DATA_VALID) {
Len Brown4be44fc2005-08-05 00:44:28 -0400286 return_ACPI_STATUS(AE_OK);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700287 }
288
289 /* Get the Buffer node */
290
291 node = obj_desc->buffer.node;
292 if (!node) {
Bob Mooreb8e4d892006-01-27 16:43:00 -0500293 ACPI_ERROR((AE_INFO,
294 "No pointer back to NS node in buffer obj %p",
295 obj_desc));
Len Brown4be44fc2005-08-05 00:44:28 -0400296 return_ACPI_STATUS(AE_AML_INTERNAL);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700297 }
298
Len Brown4be44fc2005-08-05 00:44:28 -0400299 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Buffer Arg Init\n"));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700300
301 /* Execute the AML code for the term_arg arguments */
302
Len Brown4be44fc2005-08-05 00:44:28 -0400303 status = acpi_ds_execute_arguments(node, node,
304 obj_desc->buffer.aml_length,
305 obj_desc->buffer.aml_start);
306 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700307}
308
Robert Moore44f6c012005-04-18 22:49:35 -0400309/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700310 *
311 * FUNCTION: acpi_ds_get_package_arguments
312 *
313 * PARAMETERS: obj_desc - A valid Package object
314 *
315 * RETURN: Status.
316 *
317 * DESCRIPTION: Get Package length and initializer byte list. This implements
318 * the late evaluation of these attributes.
319 *
Robert Moore44f6c012005-04-18 22:49:35 -0400320 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700321
Len Brown4be44fc2005-08-05 00:44:28 -0400322acpi_status acpi_ds_get_package_arguments(union acpi_operand_object *obj_desc)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700323{
Len Brown4be44fc2005-08-05 00:44:28 -0400324 struct acpi_namespace_node *node;
325 acpi_status status;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700326
Bob Mooreb229cf92006-04-21 17:15:00 -0400327 ACPI_FUNCTION_TRACE_PTR(ds_get_package_arguments, obj_desc);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700328
329 if (obj_desc->common.flags & AOPOBJ_DATA_VALID) {
Len Brown4be44fc2005-08-05 00:44:28 -0400330 return_ACPI_STATUS(AE_OK);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700331 }
332
333 /* Get the Package node */
334
335 node = obj_desc->package.node;
336 if (!node) {
Bob Mooreb8e4d892006-01-27 16:43:00 -0500337 ACPI_ERROR((AE_INFO,
338 "No pointer back to NS node in package %p",
339 obj_desc));
Len Brown4be44fc2005-08-05 00:44:28 -0400340 return_ACPI_STATUS(AE_AML_INTERNAL);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700341 }
342
Len Brown4be44fc2005-08-05 00:44:28 -0400343 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Package Arg Init\n"));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700344
345 /* Execute the AML code for the term_arg arguments */
346
Len Brown4be44fc2005-08-05 00:44:28 -0400347 status = acpi_ds_execute_arguments(node, node,
348 obj_desc->package.aml_length,
349 obj_desc->package.aml_start);
350 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700351}
352
Linus Torvalds1da177e2005-04-16 15:20:36 -0700353/*****************************************************************************
354 *
355 * FUNCTION: acpi_ds_get_region_arguments
356 *
357 * PARAMETERS: obj_desc - A valid region object
358 *
359 * RETURN: Status.
360 *
361 * DESCRIPTION: Get region address and length. This implements the late
362 * evaluation of these region attributes.
363 *
364 ****************************************************************************/
365
Len Brown4be44fc2005-08-05 00:44:28 -0400366acpi_status acpi_ds_get_region_arguments(union acpi_operand_object *obj_desc)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700367{
Len Brown4be44fc2005-08-05 00:44:28 -0400368 struct acpi_namespace_node *node;
369 acpi_status status;
370 union acpi_operand_object *extra_desc;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700371
Bob Mooreb229cf92006-04-21 17:15:00 -0400372 ACPI_FUNCTION_TRACE_PTR(ds_get_region_arguments, obj_desc);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700373
374 if (obj_desc->region.flags & AOPOBJ_DATA_VALID) {
Len Brown4be44fc2005-08-05 00:44:28 -0400375 return_ACPI_STATUS(AE_OK);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700376 }
377
Len Brown4be44fc2005-08-05 00:44:28 -0400378 extra_desc = acpi_ns_get_secondary_object(obj_desc);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700379 if (!extra_desc) {
Len Brown4be44fc2005-08-05 00:44:28 -0400380 return_ACPI_STATUS(AE_NOT_EXIST);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700381 }
382
383 /* Get the Region node */
384
385 node = obj_desc->region.node;
386
Len Brown4be44fc2005-08-05 00:44:28 -0400387 ACPI_DEBUG_EXEC(acpi_ut_display_init_pathname
388 (ACPI_TYPE_REGION, node, NULL));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700389
Bob Mooreb229cf92006-04-21 17:15:00 -0400390 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "[%4.4s] OpRegion Arg Init at AML %p\n",
Len Brown4be44fc2005-08-05 00:44:28 -0400391 acpi_ut_get_node_name(node),
392 extra_desc->extra.aml_start));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700393
394 /* Execute the argument AML */
395
Len Brown4be44fc2005-08-05 00:44:28 -0400396 status = acpi_ds_execute_arguments(node, acpi_ns_get_parent_node(node),
397 extra_desc->extra.aml_length,
398 extra_desc->extra.aml_start);
Bob Mooreb229cf92006-04-21 17:15:00 -0400399 if (ACPI_FAILURE(status)) {
400 return_ACPI_STATUS(status);
401 }
402
403 /* Validate the region address/length via the host OS */
404
405 status = acpi_os_validate_address(obj_desc->region.space_id,
406 obj_desc->region.address,
Thomas Renningerdf92e692008-02-04 23:31:22 -0800407 (acpi_size) obj_desc->region.length,
408 acpi_ut_get_node_name(node));
409
Bob Mooreb229cf92006-04-21 17:15:00 -0400410 if (ACPI_FAILURE(status)) {
411 /*
412 * Invalid address/length. We will emit an error message and mark
413 * the region as invalid, so that it will cause an additional error if
414 * it is ever used. Then return AE_OK.
415 */
416 ACPI_EXCEPTION((AE_INFO, status,
417 "During address validation of OpRegion [%4.4s]",
418 node->name.ascii));
419 obj_desc->common.flags |= AOPOBJ_INVALID;
420 status = AE_OK;
421 }
422
Len Brown4be44fc2005-08-05 00:44:28 -0400423 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700424}
425
Robert Moore44f6c012005-04-18 22:49:35 -0400426/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700427 *
428 * FUNCTION: acpi_ds_initialize_region
429 *
Robert Moore44f6c012005-04-18 22:49:35 -0400430 * PARAMETERS: obj_handle - Region namespace node
Linus Torvalds1da177e2005-04-16 15:20:36 -0700431 *
432 * RETURN: Status
433 *
434 * DESCRIPTION: Front end to ev_initialize_region
435 *
Robert Moore44f6c012005-04-18 22:49:35 -0400436 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700437
Len Brown4be44fc2005-08-05 00:44:28 -0400438acpi_status acpi_ds_initialize_region(acpi_handle obj_handle)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700439{
Len Brown4be44fc2005-08-05 00:44:28 -0400440 union acpi_operand_object *obj_desc;
441 acpi_status status;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700442
Len Brown4be44fc2005-08-05 00:44:28 -0400443 obj_desc = acpi_ns_get_attached_object(obj_handle);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700444
445 /* Namespace is NOT locked */
446
Len Brown4be44fc2005-08-05 00:44:28 -0400447 status = acpi_ev_initialize_region(obj_desc, FALSE);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700448 return (status);
449}
450
Robert Moore44f6c012005-04-18 22:49:35 -0400451/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700452 *
453 * FUNCTION: acpi_ds_init_buffer_field
454 *
455 * PARAMETERS: aml_opcode - create_xxx_field
456 * obj_desc - buffer_field object
457 * buffer_desc - Host Buffer
458 * offset_desc - Offset into buffer
Robert Moore44f6c012005-04-18 22:49:35 -0400459 * length_desc - Length of field (CREATE_FIELD_OP only)
460 * result_desc - Where to store the result
Linus Torvalds1da177e2005-04-16 15:20:36 -0700461 *
462 * RETURN: Status
463 *
464 * DESCRIPTION: Perform actual initialization of a buffer field
465 *
Robert Moore44f6c012005-04-18 22:49:35 -0400466 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700467
Robert Moore44f6c012005-04-18 22:49:35 -0400468static acpi_status
Len Brown4be44fc2005-08-05 00:44:28 -0400469acpi_ds_init_buffer_field(u16 aml_opcode,
470 union acpi_operand_object *obj_desc,
471 union acpi_operand_object *buffer_desc,
472 union acpi_operand_object *offset_desc,
473 union acpi_operand_object *length_desc,
474 union acpi_operand_object *result_desc)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700475{
Len Brown4be44fc2005-08-05 00:44:28 -0400476 u32 offset;
477 u32 bit_offset;
478 u32 bit_count;
479 u8 field_flags;
480 acpi_status status;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700481
Bob Mooreb229cf92006-04-21 17:15:00 -0400482 ACPI_FUNCTION_TRACE_PTR(ds_init_buffer_field, obj_desc);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700483
484 /* Host object must be a Buffer */
485
Len Brown4be44fc2005-08-05 00:44:28 -0400486 if (ACPI_GET_OBJECT_TYPE(buffer_desc) != ACPI_TYPE_BUFFER) {
Bob Mooreb8e4d892006-01-27 16:43:00 -0500487 ACPI_ERROR((AE_INFO,
488 "Target of Create Field is not a Buffer object - %s",
489 acpi_ut_get_object_type_name(buffer_desc)));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700490
491 status = AE_AML_OPERAND_TYPE;
492 goto cleanup;
493 }
494
495 /*
496 * The last parameter to all of these opcodes (result_desc) started
497 * out as a name_string, and should therefore now be a NS node
498 * after resolution in acpi_ex_resolve_operands().
499 */
Len Brown4be44fc2005-08-05 00:44:28 -0400500 if (ACPI_GET_DESCRIPTOR_TYPE(result_desc) != ACPI_DESC_TYPE_NAMED) {
Bob Mooreb8e4d892006-01-27 16:43:00 -0500501 ACPI_ERROR((AE_INFO,
502 "(%s) destination not a NS Node [%s]",
503 acpi_ps_get_opcode_name(aml_opcode),
504 acpi_ut_get_descriptor_name(result_desc)));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700505
506 status = AE_AML_OPERAND_TYPE;
507 goto cleanup;
508 }
509
510 offset = (u32) offset_desc->integer.value;
511
512 /*
513 * Setup the Bit offsets and counts, according to the opcode
514 */
515 switch (aml_opcode) {
516 case AML_CREATE_FIELD_OP:
517
518 /* Offset is in bits, count is in bits */
519
Robert Moore44f6c012005-04-18 22:49:35 -0400520 field_flags = AML_FIELD_ACCESS_BYTE;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700521 bit_offset = offset;
Len Brown4be44fc2005-08-05 00:44:28 -0400522 bit_count = (u32) length_desc->integer.value;
Robert Moore44f6c012005-04-18 22:49:35 -0400523
524 /* Must have a valid (>0) bit count */
525
526 if (bit_count == 0) {
Bob Mooreb8e4d892006-01-27 16:43:00 -0500527 ACPI_ERROR((AE_INFO,
Bob Mooreb229cf92006-04-21 17:15:00 -0400528 "Attempt to CreateField of length zero"));
Robert Moore44f6c012005-04-18 22:49:35 -0400529 status = AE_AML_OPERAND_VALUE;
530 goto cleanup;
531 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700532 break;
533
534 case AML_CREATE_BIT_FIELD_OP:
535
536 /* Offset is in bits, Field is one bit */
537
538 bit_offset = offset;
Len Brown4be44fc2005-08-05 00:44:28 -0400539 bit_count = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700540 field_flags = AML_FIELD_ACCESS_BYTE;
541 break;
542
543 case AML_CREATE_BYTE_FIELD_OP:
544
545 /* Offset is in bytes, field is one byte */
546
547 bit_offset = 8 * offset;
Len Brown4be44fc2005-08-05 00:44:28 -0400548 bit_count = 8;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700549 field_flags = AML_FIELD_ACCESS_BYTE;
550 break;
551
552 case AML_CREATE_WORD_FIELD_OP:
553
554 /* Offset is in bytes, field is one word */
555
556 bit_offset = 8 * offset;
Len Brown4be44fc2005-08-05 00:44:28 -0400557 bit_count = 16;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700558 field_flags = AML_FIELD_ACCESS_WORD;
559 break;
560
561 case AML_CREATE_DWORD_FIELD_OP:
562
563 /* Offset is in bytes, field is one dword */
564
565 bit_offset = 8 * offset;
Len Brown4be44fc2005-08-05 00:44:28 -0400566 bit_count = 32;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700567 field_flags = AML_FIELD_ACCESS_DWORD;
568 break;
569
570 case AML_CREATE_QWORD_FIELD_OP:
571
572 /* Offset is in bytes, field is one qword */
573
574 bit_offset = 8 * offset;
Len Brown4be44fc2005-08-05 00:44:28 -0400575 bit_count = 64;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700576 field_flags = AML_FIELD_ACCESS_QWORD;
577 break;
578
579 default:
580
Bob Mooreb8e4d892006-01-27 16:43:00 -0500581 ACPI_ERROR((AE_INFO,
582 "Unknown field creation opcode %02x", aml_opcode));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700583 status = AE_AML_BAD_OPCODE;
584 goto cleanup;
585 }
586
587 /* Entire field must fit within the current length of the buffer */
588
Len Brown4be44fc2005-08-05 00:44:28 -0400589 if ((bit_offset + bit_count) > (8 * (u32) buffer_desc->buffer.length)) {
Bob Mooreb8e4d892006-01-27 16:43:00 -0500590 ACPI_ERROR((AE_INFO,
591 "Field [%4.4s] at %d exceeds Buffer [%4.4s] size %d (bits)",
592 acpi_ut_get_node_name(result_desc),
593 bit_offset + bit_count,
594 acpi_ut_get_node_name(buffer_desc->buffer.node),
595 8 * (u32) buffer_desc->buffer.length));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700596 status = AE_AML_BUFFER_LIMIT;
597 goto cleanup;
598 }
599
600 /*
601 * Initialize areas of the field object that are common to all fields
Robert Moore44f6c012005-04-18 22:49:35 -0400602 * For field_flags, use LOCK_RULE = 0 (NO_LOCK),
603 * UPDATE_RULE = 0 (UPDATE_PRESERVE)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700604 */
Len Brown4be44fc2005-08-05 00:44:28 -0400605 status = acpi_ex_prep_common_field_object(obj_desc, field_flags, 0,
606 bit_offset, bit_count);
607 if (ACPI_FAILURE(status)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700608 goto cleanup;
609 }
610
611 obj_desc->buffer_field.buffer_obj = buffer_desc;
612
613 /* Reference count for buffer_desc inherits obj_desc count */
614
Robert Moore44f6c012005-04-18 22:49:35 -0400615 buffer_desc->common.reference_count = (u16)
Len Brown4be44fc2005-08-05 00:44:28 -0400616 (buffer_desc->common.reference_count +
617 obj_desc->common.reference_count);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700618
Len Brown4be44fc2005-08-05 00:44:28 -0400619 cleanup:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700620
621 /* Always delete the operands */
622
Len Brown4be44fc2005-08-05 00:44:28 -0400623 acpi_ut_remove_reference(offset_desc);
624 acpi_ut_remove_reference(buffer_desc);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700625
626 if (aml_opcode == AML_CREATE_FIELD_OP) {
Len Brown4be44fc2005-08-05 00:44:28 -0400627 acpi_ut_remove_reference(length_desc);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700628 }
629
630 /* On failure, delete the result descriptor */
631
Len Brown4be44fc2005-08-05 00:44:28 -0400632 if (ACPI_FAILURE(status)) {
633 acpi_ut_remove_reference(result_desc); /* Result descriptor */
634 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700635 /* Now the address and length are valid for this buffer_field */
636
637 obj_desc->buffer_field.flags |= AOPOBJ_DATA_VALID;
638 }
639
Len Brown4be44fc2005-08-05 00:44:28 -0400640 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700641}
642
Robert Moore44f6c012005-04-18 22:49:35 -0400643/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700644 *
645 * FUNCTION: acpi_ds_eval_buffer_field_operands
646 *
647 * PARAMETERS: walk_state - Current walk
648 * Op - A valid buffer_field Op object
649 *
650 * RETURN: Status
651 *
652 * DESCRIPTION: Get buffer_field Buffer and Index
653 * Called from acpi_ds_exec_end_op during buffer_field parse tree walk
654 *
Robert Moore44f6c012005-04-18 22:49:35 -0400655 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700656
657acpi_status
Len Brown4be44fc2005-08-05 00:44:28 -0400658acpi_ds_eval_buffer_field_operands(struct acpi_walk_state *walk_state,
659 union acpi_parse_object *op)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700660{
Len Brown4be44fc2005-08-05 00:44:28 -0400661 acpi_status status;
662 union acpi_operand_object *obj_desc;
663 struct acpi_namespace_node *node;
664 union acpi_parse_object *next_op;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700665
Bob Mooreb229cf92006-04-21 17:15:00 -0400666 ACPI_FUNCTION_TRACE_PTR(ds_eval_buffer_field_operands, op);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700667
668 /*
669 * This is where we evaluate the address and length fields of the
670 * create_xxx_field declaration
671 */
Len Brown4be44fc2005-08-05 00:44:28 -0400672 node = op->common.node;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700673
674 /* next_op points to the op that holds the Buffer */
675
676 next_op = op->common.value.arg;
677
678 /* Evaluate/create the address and length operands */
679
Len Brown4be44fc2005-08-05 00:44:28 -0400680 status = acpi_ds_create_operands(walk_state, next_op);
681 if (ACPI_FAILURE(status)) {
682 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700683 }
684
Len Brown4be44fc2005-08-05 00:44:28 -0400685 obj_desc = acpi_ns_get_attached_object(node);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700686 if (!obj_desc) {
Len Brown4be44fc2005-08-05 00:44:28 -0400687 return_ACPI_STATUS(AE_NOT_EXIST);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700688 }
689
690 /* Resolve the operands */
691
Len Brown4be44fc2005-08-05 00:44:28 -0400692 status = acpi_ex_resolve_operands(op->common.aml_opcode,
693 ACPI_WALK_OPERANDS, walk_state);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700694
Len Brown4be44fc2005-08-05 00:44:28 -0400695 ACPI_DUMP_OPERANDS(ACPI_WALK_OPERANDS, ACPI_IMODE_EXECUTE,
696 acpi_ps_get_opcode_name(op->common.aml_opcode),
697 walk_state->num_operands,
Bob Mooreb229cf92006-04-21 17:15:00 -0400698 "after AcpiExResolveOperands");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700699
Len Brown4be44fc2005-08-05 00:44:28 -0400700 if (ACPI_FAILURE(status)) {
Bob Mooreb8e4d892006-01-27 16:43:00 -0500701 ACPI_ERROR((AE_INFO, "(%s) bad operand(s) (%X)",
702 acpi_ps_get_opcode_name(op->common.aml_opcode),
703 status));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700704
Len Brown4be44fc2005-08-05 00:44:28 -0400705 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700706 }
707
708 /* Initialize the Buffer Field */
709
710 if (op->common.aml_opcode == AML_CREATE_FIELD_OP) {
Bob Moore52fc0b02006-10-02 00:00:00 -0400711
Linus Torvalds1da177e2005-04-16 15:20:36 -0700712 /* NOTE: Slightly different operands for this opcode */
713
Len Brown4be44fc2005-08-05 00:44:28 -0400714 status =
715 acpi_ds_init_buffer_field(op->common.aml_opcode, obj_desc,
716 walk_state->operands[0],
717 walk_state->operands[1],
718 walk_state->operands[2],
719 walk_state->operands[3]);
720 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700721 /* All other, create_xxx_field opcodes */
722
Len Brown4be44fc2005-08-05 00:44:28 -0400723 status =
724 acpi_ds_init_buffer_field(op->common.aml_opcode, obj_desc,
725 walk_state->operands[0],
726 walk_state->operands[1], NULL,
727 walk_state->operands[2]);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700728 }
729
Len Brown4be44fc2005-08-05 00:44:28 -0400730 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700731}
732
Robert Moore44f6c012005-04-18 22:49:35 -0400733/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700734 *
735 * FUNCTION: acpi_ds_eval_region_operands
736 *
737 * PARAMETERS: walk_state - Current walk
738 * Op - A valid region Op object
739 *
740 * RETURN: Status
741 *
742 * DESCRIPTION: Get region address and length
743 * Called from acpi_ds_exec_end_op during op_region parse tree walk
744 *
Robert Moore44f6c012005-04-18 22:49:35 -0400745 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700746
747acpi_status
Len Brown4be44fc2005-08-05 00:44:28 -0400748acpi_ds_eval_region_operands(struct acpi_walk_state *walk_state,
749 union acpi_parse_object *op)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700750{
Len Brown4be44fc2005-08-05 00:44:28 -0400751 acpi_status status;
752 union acpi_operand_object *obj_desc;
753 union acpi_operand_object *operand_desc;
754 struct acpi_namespace_node *node;
755 union acpi_parse_object *next_op;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700756
Bob Mooreb229cf92006-04-21 17:15:00 -0400757 ACPI_FUNCTION_TRACE_PTR(ds_eval_region_operands, op);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700758
759 /*
Robert Moore44f6c012005-04-18 22:49:35 -0400760 * This is where we evaluate the address and length fields of the
761 * op_region declaration
Linus Torvalds1da177e2005-04-16 15:20:36 -0700762 */
Len Brown4be44fc2005-08-05 00:44:28 -0400763 node = op->common.node;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700764
765 /* next_op points to the op that holds the space_iD */
766
767 next_op = op->common.value.arg;
768
769 /* next_op points to address op */
770
771 next_op = next_op->common.next;
772
773 /* Evaluate/create the address and length operands */
774
Len Brown4be44fc2005-08-05 00:44:28 -0400775 status = acpi_ds_create_operands(walk_state, next_op);
776 if (ACPI_FAILURE(status)) {
777 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700778 }
779
780 /* Resolve the length and address operands to numbers */
781
Len Brown4be44fc2005-08-05 00:44:28 -0400782 status = acpi_ex_resolve_operands(op->common.aml_opcode,
783 ACPI_WALK_OPERANDS, walk_state);
784 if (ACPI_FAILURE(status)) {
785 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700786 }
787
Len Brown4be44fc2005-08-05 00:44:28 -0400788 ACPI_DUMP_OPERANDS(ACPI_WALK_OPERANDS, ACPI_IMODE_EXECUTE,
789 acpi_ps_get_opcode_name(op->common.aml_opcode),
Bob Mooreb229cf92006-04-21 17:15:00 -0400790 1, "after AcpiExResolveOperands");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700791
Len Brown4be44fc2005-08-05 00:44:28 -0400792 obj_desc = acpi_ns_get_attached_object(node);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700793 if (!obj_desc) {
Len Brown4be44fc2005-08-05 00:44:28 -0400794 return_ACPI_STATUS(AE_NOT_EXIST);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700795 }
796
797 /*
798 * Get the length operand and save it
799 * (at Top of stack)
800 */
801 operand_desc = walk_state->operands[walk_state->num_operands - 1];
802
803 obj_desc->region.length = (u32) operand_desc->integer.value;
Len Brown4be44fc2005-08-05 00:44:28 -0400804 acpi_ut_remove_reference(operand_desc);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700805
806 /*
807 * Get the address and save it
808 * (at top of stack - 1)
809 */
810 operand_desc = walk_state->operands[walk_state->num_operands - 2];
811
Robert Moore44f6c012005-04-18 22:49:35 -0400812 obj_desc->region.address = (acpi_physical_address)
Len Brown4be44fc2005-08-05 00:44:28 -0400813 operand_desc->integer.value;
814 acpi_ut_remove_reference(operand_desc);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700815
Bob Mooreb229cf92006-04-21 17:15:00 -0400816 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "RgnObj %p Addr %8.8X%8.8X Len %X\n",
Len Brown4be44fc2005-08-05 00:44:28 -0400817 obj_desc,
Bob Mooreb7f9f042008-04-10 19:06:40 +0400818 ACPI_FORMAT_NATIVE_UINT(obj_desc->region.address),
Len Brown4be44fc2005-08-05 00:44:28 -0400819 obj_desc->region.length));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700820
821 /* Now the address and length are valid for this opregion */
822
823 obj_desc->region.flags |= AOPOBJ_DATA_VALID;
824
Len Brown4be44fc2005-08-05 00:44:28 -0400825 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700826}
827
Robert Moore44f6c012005-04-18 22:49:35 -0400828/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700829 *
Lin Ming941f48b2008-04-10 19:06:41 +0400830 * FUNCTION: acpi_ds_eval_table_region_operands
831 *
832 * PARAMETERS: walk_state - Current walk
833 * Op - A valid region Op object
834 *
835 * RETURN: Status
836 *
837 * DESCRIPTION: Get region address and length
838 * Called from acpi_ds_exec_end_op during data_table_region parse tree walk
839 *
840 ******************************************************************************/
841
842acpi_status
843acpi_ds_eval_table_region_operands(struct acpi_walk_state *walk_state,
844 union acpi_parse_object *op)
845{
846 acpi_status status;
847 union acpi_operand_object *obj_desc;
848 union acpi_operand_object **operand;
849 struct acpi_namespace_node *node;
850 union acpi_parse_object *next_op;
Bob Moore67a119f2008-06-10 13:42:13 +0800851 u32 table_index;
Lin Ming941f48b2008-04-10 19:06:41 +0400852 struct acpi_table_header *table;
853
854 ACPI_FUNCTION_TRACE_PTR(ds_eval_table_region_operands, op);
855
856 /*
857 * This is where we evaluate the signature_string and oem_iDString
858 * and oem_table_iDString of the data_table_region declaration
859 */
860 node = op->common.node;
861
862 /* next_op points to signature_string op */
863
864 next_op = op->common.value.arg;
865
866 /*
867 * Evaluate/create the signature_string and oem_iDString
868 * and oem_table_iDString operands
869 */
870 status = acpi_ds_create_operands(walk_state, next_op);
871 if (ACPI_FAILURE(status)) {
872 return_ACPI_STATUS(status);
873 }
874
875 /*
876 * Resolve the signature_string and oem_iDString
877 * and oem_table_iDString operands
878 */
879 status = acpi_ex_resolve_operands(op->common.aml_opcode,
880 ACPI_WALK_OPERANDS, walk_state);
881 if (ACPI_FAILURE(status)) {
882 return_ACPI_STATUS(status);
883 }
884
885 ACPI_DUMP_OPERANDS(ACPI_WALK_OPERANDS, ACPI_IMODE_EXECUTE,
886 acpi_ps_get_opcode_name(op->common.aml_opcode),
887 1, "after AcpiExResolveOperands");
888
889 operand = &walk_state->operands[0];
890
891 /* Find the ACPI table */
892
893 status = acpi_tb_find_table(operand[0]->string.pointer,
894 operand[1]->string.pointer,
895 operand[2]->string.pointer, &table_index);
896 if (ACPI_FAILURE(status)) {
897 return_ACPI_STATUS(status);
898 }
899
900 acpi_ut_remove_reference(operand[0]);
901 acpi_ut_remove_reference(operand[1]);
902 acpi_ut_remove_reference(operand[2]);
903
904 status = acpi_get_table_by_index(table_index, &table);
905 if (ACPI_FAILURE(status)) {
906 return_ACPI_STATUS(status);
907 }
908
909 obj_desc = acpi_ns_get_attached_object(node);
910 if (!obj_desc) {
911 return_ACPI_STATUS(AE_NOT_EXIST);
912 }
913
914 obj_desc->region.address =
915 (acpi_physical_address) ACPI_TO_INTEGER(table);
916 obj_desc->region.length = table->length;
917
918 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "RgnObj %p Addr %8.8X%8.8X Len %X\n",
919 obj_desc,
920 ACPI_FORMAT_NATIVE_UINT(obj_desc->region.address),
921 obj_desc->region.length));
922
923 /* Now the address and length are valid for this opregion */
924
925 obj_desc->region.flags |= AOPOBJ_DATA_VALID;
926
927 return_ACPI_STATUS(status);
928}
929
930/*******************************************************************************
931 *
Linus Torvalds1da177e2005-04-16 15:20:36 -0700932 * FUNCTION: acpi_ds_eval_data_object_operands
933 *
934 * PARAMETERS: walk_state - Current walk
935 * Op - A valid data_object Op object
936 * obj_desc - data_object
937 *
938 * RETURN: Status
939 *
940 * DESCRIPTION: Get the operands and complete the following data object types:
941 * Buffer, Package.
942 *
Robert Moore44f6c012005-04-18 22:49:35 -0400943 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700944
945acpi_status
Len Brown4be44fc2005-08-05 00:44:28 -0400946acpi_ds_eval_data_object_operands(struct acpi_walk_state *walk_state,
947 union acpi_parse_object *op,
948 union acpi_operand_object *obj_desc)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700949{
Len Brown4be44fc2005-08-05 00:44:28 -0400950 acpi_status status;
951 union acpi_operand_object *arg_desc;
952 u32 length;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700953
Bob Mooreb229cf92006-04-21 17:15:00 -0400954 ACPI_FUNCTION_TRACE(ds_eval_data_object_operands);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700955
956 /* The first operand (for all of these data objects) is the length */
957
Bob Moore773069d2008-04-10 19:06:36 +0400958 /*
959 * Set proper index into operand stack for acpi_ds_obj_stack_push
960 * invoked inside acpi_ds_create_operand.
961 */
962 walk_state->operand_index = walk_state->num_operands;
963
Len Brown4be44fc2005-08-05 00:44:28 -0400964 status = acpi_ds_create_operand(walk_state, op->common.value.arg, 1);
965 if (ACPI_FAILURE(status)) {
966 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700967 }
968
Len Brown4be44fc2005-08-05 00:44:28 -0400969 status = acpi_ex_resolve_operands(walk_state->opcode,
970 &(walk_state->
971 operands[walk_state->num_operands -
972 1]), walk_state);
973 if (ACPI_FAILURE(status)) {
974 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700975 }
976
977 /* Extract length operand */
978
Len Brown4be44fc2005-08-05 00:44:28 -0400979 arg_desc = walk_state->operands[walk_state->num_operands - 1];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700980 length = (u32) arg_desc->integer.value;
981
982 /* Cleanup for length operand */
983
Len Brown4be44fc2005-08-05 00:44:28 -0400984 status = acpi_ds_obj_stack_pop(1, walk_state);
985 if (ACPI_FAILURE(status)) {
986 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700987 }
988
Len Brown4be44fc2005-08-05 00:44:28 -0400989 acpi_ut_remove_reference(arg_desc);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700990
991 /*
992 * Create the actual data object
993 */
994 switch (op->common.aml_opcode) {
995 case AML_BUFFER_OP:
996
Len Brown4be44fc2005-08-05 00:44:28 -0400997 status =
998 acpi_ds_build_internal_buffer_obj(walk_state, op, length,
999 &obj_desc);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001000 break;
1001
1002 case AML_PACKAGE_OP:
1003 case AML_VAR_PACKAGE_OP:
1004
Len Brown4be44fc2005-08-05 00:44:28 -04001005 status =
1006 acpi_ds_build_internal_package_obj(walk_state, op, length,
1007 &obj_desc);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001008 break;
1009
1010 default:
Len Brown4be44fc2005-08-05 00:44:28 -04001011 return_ACPI_STATUS(AE_AML_BAD_OPCODE);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001012 }
1013
Len Brown4be44fc2005-08-05 00:44:28 -04001014 if (ACPI_SUCCESS(status)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001015 /*
Robert Moore44f6c012005-04-18 22:49:35 -04001016 * Return the object in the walk_state, unless the parent is a package -
Linus Torvalds1da177e2005-04-16 15:20:36 -07001017 * in this case, the return object will be stored in the parse tree
1018 * for the package.
1019 */
1020 if ((!op->common.parent) ||
Len Brown4be44fc2005-08-05 00:44:28 -04001021 ((op->common.parent->common.aml_opcode != AML_PACKAGE_OP) &&
1022 (op->common.parent->common.aml_opcode !=
1023 AML_VAR_PACKAGE_OP)
Len Brownfd350942007-05-09 23:34:35 -04001024 && (op->common.parent->common.aml_opcode != AML_NAME_OP))) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001025 walk_state->result_obj = obj_desc;
1026 }
1027 }
1028
Len Brown4be44fc2005-08-05 00:44:28 -04001029 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001030}
1031
Linus Torvalds1da177e2005-04-16 15:20:36 -07001032/*******************************************************************************
1033 *
Lin Mingef805d92008-04-10 19:06:41 +04001034 * FUNCTION: acpi_ds_eval_bank_field_operands
1035 *
1036 * PARAMETERS: walk_state - Current walk
1037 * Op - A valid bank_field Op object
1038 *
1039 * RETURN: Status
1040 *
1041 * DESCRIPTION: Get bank_field bank_value
1042 * Called from acpi_ds_exec_end_op during bank_field parse tree walk
1043 *
1044 ******************************************************************************/
1045
1046acpi_status
1047acpi_ds_eval_bank_field_operands(struct acpi_walk_state *walk_state,
1048 union acpi_parse_object *op)
1049{
1050 acpi_status status;
1051 union acpi_operand_object *obj_desc;
1052 union acpi_operand_object *operand_desc;
1053 struct acpi_namespace_node *node;
1054 union acpi_parse_object *next_op;
1055 union acpi_parse_object *arg;
1056
1057 ACPI_FUNCTION_TRACE_PTR(ds_eval_bank_field_operands, op);
1058
1059 /*
1060 * This is where we evaluate the bank_value field of the
1061 * bank_field declaration
1062 */
1063
1064 /* next_op points to the op that holds the Region */
1065
1066 next_op = op->common.value.arg;
1067
1068 /* next_op points to the op that holds the Bank Register */
1069
1070 next_op = next_op->common.next;
1071
1072 /* next_op points to the op that holds the Bank Value */
1073
1074 next_op = next_op->common.next;
1075
1076 /*
1077 * Set proper index into operand stack for acpi_ds_obj_stack_push
1078 * invoked inside acpi_ds_create_operand.
1079 *
1080 * We use walk_state->Operands[0] to store the evaluated bank_value
1081 */
1082 walk_state->operand_index = 0;
1083
1084 status = acpi_ds_create_operand(walk_state, next_op, 0);
1085 if (ACPI_FAILURE(status)) {
1086 return_ACPI_STATUS(status);
1087 }
1088
1089 status = acpi_ex_resolve_to_value(&walk_state->operands[0], walk_state);
1090 if (ACPI_FAILURE(status)) {
1091 return_ACPI_STATUS(status);
1092 }
1093
1094 ACPI_DUMP_OPERANDS(ACPI_WALK_OPERANDS, ACPI_IMODE_EXECUTE,
1095 acpi_ps_get_opcode_name(op->common.aml_opcode),
1096 1, "after AcpiExResolveOperands");
1097
1098 /*
1099 * Get the bank_value operand and save it
1100 * (at Top of stack)
1101 */
1102 operand_desc = walk_state->operands[0];
1103
1104 /* Arg points to the start Bank Field */
1105
1106 arg = acpi_ps_get_arg(op, 4);
1107 while (arg) {
1108
1109 /* Ignore OFFSET and ACCESSAS terms here */
1110
1111 if (arg->common.aml_opcode == AML_INT_NAMEDFIELD_OP) {
1112 node = arg->common.node;
1113
1114 obj_desc = acpi_ns_get_attached_object(node);
1115 if (!obj_desc) {
1116 return_ACPI_STATUS(AE_NOT_EXIST);
1117 }
1118
1119 obj_desc->bank_field.value =
1120 (u32) operand_desc->integer.value;
1121 }
1122
1123 /* Move to next field in the list */
1124
1125 arg = arg->common.next;
1126 }
1127
1128 acpi_ut_remove_reference(operand_desc);
1129 return_ACPI_STATUS(status);
1130}
1131
1132/*******************************************************************************
1133 *
Linus Torvalds1da177e2005-04-16 15:20:36 -07001134 * FUNCTION: acpi_ds_exec_begin_control_op
1135 *
1136 * PARAMETERS: walk_list - The list that owns the walk stack
1137 * Op - The control Op
1138 *
1139 * RETURN: Status
1140 *
1141 * DESCRIPTION: Handles all control ops encountered during control method
1142 * execution.
1143 *
1144 ******************************************************************************/
1145
1146acpi_status
Len Brown4be44fc2005-08-05 00:44:28 -04001147acpi_ds_exec_begin_control_op(struct acpi_walk_state *walk_state,
1148 union acpi_parse_object *op)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001149{
Len Brown4be44fc2005-08-05 00:44:28 -04001150 acpi_status status = AE_OK;
1151 union acpi_generic_state *control_state;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001152
Bob Mooreb229cf92006-04-21 17:15:00 -04001153 ACPI_FUNCTION_NAME(ds_exec_begin_control_op);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001154
Len Brown4be44fc2005-08-05 00:44:28 -04001155 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, "Op=%p Opcode=%2.2X State=%p\n", op,
1156 op->common.aml_opcode, walk_state));
Linus Torvalds1da177e2005-04-16 15:20:36 -07001157
1158 switch (op->common.aml_opcode) {
1159 case AML_IF_OP:
1160 case AML_WHILE_OP:
1161
1162 /*
1163 * IF/WHILE: Create a new control state to manage these
1164 * constructs. We need to manage these as a stack, in order
1165 * to handle nesting.
1166 */
Len Brown4be44fc2005-08-05 00:44:28 -04001167 control_state = acpi_ut_create_control_state();
Linus Torvalds1da177e2005-04-16 15:20:36 -07001168 if (!control_state) {
1169 status = AE_NO_MEMORY;
1170 break;
1171 }
1172 /*
1173 * Save a pointer to the predicate for multiple executions
1174 * of a loop
1175 */
Len Brown4be44fc2005-08-05 00:44:28 -04001176 control_state->control.aml_predicate_start =
1177 walk_state->parser_state.aml - 1;
1178 control_state->control.package_end =
1179 walk_state->parser_state.pkg_end;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001180 control_state->control.opcode = op->common.aml_opcode;
1181
Linus Torvalds1da177e2005-04-16 15:20:36 -07001182 /* Push the control state on this walk's control stack */
1183
Len Brown4be44fc2005-08-05 00:44:28 -04001184 acpi_ut_push_generic_state(&walk_state->control_state,
1185 control_state);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001186 break;
1187
1188 case AML_ELSE_OP:
1189
1190 /* Predicate is in the state object */
1191 /* If predicate is true, the IF was executed, ignore ELSE part */
1192
1193 if (walk_state->last_predicate) {
1194 status = AE_CTRL_TRUE;
1195 }
1196
1197 break;
1198
1199 case AML_RETURN_OP:
1200
1201 break;
1202
1203 default:
1204 break;
1205 }
1206
1207 return (status);
1208}
1209
Linus Torvalds1da177e2005-04-16 15:20:36 -07001210/*******************************************************************************
1211 *
1212 * FUNCTION: acpi_ds_exec_end_control_op
1213 *
1214 * PARAMETERS: walk_list - The list that owns the walk stack
1215 * Op - The control Op
1216 *
1217 * RETURN: Status
1218 *
1219 * DESCRIPTION: Handles all control ops encountered during control method
1220 * execution.
1221 *
1222 ******************************************************************************/
1223
1224acpi_status
Len Brown4be44fc2005-08-05 00:44:28 -04001225acpi_ds_exec_end_control_op(struct acpi_walk_state * walk_state,
1226 union acpi_parse_object * op)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001227{
Len Brown4be44fc2005-08-05 00:44:28 -04001228 acpi_status status = AE_OK;
1229 union acpi_generic_state *control_state;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001230
Bob Mooreb229cf92006-04-21 17:15:00 -04001231 ACPI_FUNCTION_NAME(ds_exec_end_control_op);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001232
1233 switch (op->common.aml_opcode) {
1234 case AML_IF_OP:
1235
Len Brown4be44fc2005-08-05 00:44:28 -04001236 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, "[IF_OP] Op=%p\n", op));
Linus Torvalds1da177e2005-04-16 15:20:36 -07001237
1238 /*
1239 * Save the result of the predicate in case there is an
1240 * ELSE to come
1241 */
1242 walk_state->last_predicate =
Len Brown4be44fc2005-08-05 00:44:28 -04001243 (u8) walk_state->control_state->common.value;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001244
1245 /*
1246 * Pop the control state that was created at the start
1247 * of the IF and free it
1248 */
Len Brown4be44fc2005-08-05 00:44:28 -04001249 control_state =
1250 acpi_ut_pop_generic_state(&walk_state->control_state);
1251 acpi_ut_delete_generic_state(control_state);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001252 break;
1253
Linus Torvalds1da177e2005-04-16 15:20:36 -07001254 case AML_ELSE_OP:
1255
1256 break;
1257
Linus Torvalds1da177e2005-04-16 15:20:36 -07001258 case AML_WHILE_OP:
1259
Len Brown4be44fc2005-08-05 00:44:28 -04001260 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, "[WHILE_OP] Op=%p\n", op));
Linus Torvalds1da177e2005-04-16 15:20:36 -07001261
1262 if (walk_state->control_state->common.value) {
Bob Moore52fc0b02006-10-02 00:00:00 -04001263
Linus Torvalds1da177e2005-04-16 15:20:36 -07001264 /* Predicate was true, go back and evaluate it again! */
1265
1266 status = AE_CTRL_PENDING;
1267 }
1268
Len Brown4be44fc2005-08-05 00:44:28 -04001269 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
1270 "[WHILE_OP] termination! Op=%p\n", op));
Linus Torvalds1da177e2005-04-16 15:20:36 -07001271
1272 /* Pop this control state and free it */
1273
Len Brown4be44fc2005-08-05 00:44:28 -04001274 control_state =
1275 acpi_ut_pop_generic_state(&walk_state->control_state);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001276
Len Brown4be44fc2005-08-05 00:44:28 -04001277 walk_state->aml_last_while =
1278 control_state->control.aml_predicate_start;
1279 acpi_ut_delete_generic_state(control_state);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001280 break;
1281
Linus Torvalds1da177e2005-04-16 15:20:36 -07001282 case AML_RETURN_OP:
1283
Len Brown4be44fc2005-08-05 00:44:28 -04001284 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
1285 "[RETURN_OP] Op=%p Arg=%p\n", op,
1286 op->common.value.arg));
Linus Torvalds1da177e2005-04-16 15:20:36 -07001287
1288 /*
1289 * One optional operand -- the return value
1290 * It can be either an immediate operand or a result that
1291 * has been bubbled up the tree
1292 */
1293 if (op->common.value.arg) {
Bob Moore52fc0b02006-10-02 00:00:00 -04001294
Linus Torvalds1da177e2005-04-16 15:20:36 -07001295 /* Since we have a real Return(), delete any implicit return */
1296
Len Brown4be44fc2005-08-05 00:44:28 -04001297 acpi_ds_clear_implicit_return(walk_state);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001298
1299 /* Return statement has an immediate operand */
1300
Len Brown4be44fc2005-08-05 00:44:28 -04001301 status =
1302 acpi_ds_create_operands(walk_state,
1303 op->common.value.arg);
1304 if (ACPI_FAILURE(status)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001305 return (status);
1306 }
1307
1308 /*
1309 * If value being returned is a Reference (such as
1310 * an arg or local), resolve it now because it may
1311 * cease to exist at the end of the method.
1312 */
Len Brown4be44fc2005-08-05 00:44:28 -04001313 status =
1314 acpi_ex_resolve_to_value(&walk_state->operands[0],
1315 walk_state);
1316 if (ACPI_FAILURE(status)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001317 return (status);
1318 }
1319
1320 /*
1321 * Get the return value and save as the last result
1322 * value. This is the only place where walk_state->return_desc
1323 * is set to anything other than zero!
1324 */
1325 walk_state->return_desc = walk_state->operands[0];
Bob Moore773069d2008-04-10 19:06:36 +04001326 } else if (walk_state->result_count) {
Bob Moore52fc0b02006-10-02 00:00:00 -04001327
Linus Torvalds1da177e2005-04-16 15:20:36 -07001328 /* Since we have a real Return(), delete any implicit return */
1329
Len Brown4be44fc2005-08-05 00:44:28 -04001330 acpi_ds_clear_implicit_return(walk_state);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001331
1332 /*
1333 * The return value has come from a previous calculation.
1334 *
1335 * If value being returned is a Reference (such as
1336 * an arg or local), resolve it now because it may
1337 * cease to exist at the end of the method.
1338 *
1339 * Allow references created by the Index operator to return unchanged.
1340 */
Len Brown4be44fc2005-08-05 00:44:28 -04001341 if ((ACPI_GET_DESCRIPTOR_TYPE
1342 (walk_state->results->results.obj_desc[0]) ==
1343 ACPI_DESC_TYPE_OPERAND)
1344 &&
1345 (ACPI_GET_OBJECT_TYPE
1346 (walk_state->results->results.obj_desc[0]) ==
1347 ACPI_TYPE_LOCAL_REFERENCE)
1348 && ((walk_state->results->results.obj_desc[0])->
1349 reference.opcode != AML_INDEX_OP)) {
1350 status =
1351 acpi_ex_resolve_to_value(&walk_state->
1352 results->results.
1353 obj_desc[0],
1354 walk_state);
1355 if (ACPI_FAILURE(status)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001356 return (status);
1357 }
1358 }
1359
Len Brown4be44fc2005-08-05 00:44:28 -04001360 walk_state->return_desc =
1361 walk_state->results->results.obj_desc[0];
1362 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001363 /* No return operand */
1364
1365 if (walk_state->num_operands) {
Len Brown4be44fc2005-08-05 00:44:28 -04001366 acpi_ut_remove_reference(walk_state->
1367 operands[0]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001368 }
1369
Len Brown4be44fc2005-08-05 00:44:28 -04001370 walk_state->operands[0] = NULL;
1371 walk_state->num_operands = 0;
1372 walk_state->return_desc = NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001373 }
1374
Len Brown4be44fc2005-08-05 00:44:28 -04001375 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
Bob Mooreb229cf92006-04-21 17:15:00 -04001376 "Completed RETURN_OP State=%p, RetVal=%p\n",
Len Brown4be44fc2005-08-05 00:44:28 -04001377 walk_state, walk_state->return_desc));
Linus Torvalds1da177e2005-04-16 15:20:36 -07001378
1379 /* End the control method execution right now */
1380
1381 status = AE_CTRL_TERMINATE;
1382 break;
1383
Linus Torvalds1da177e2005-04-16 15:20:36 -07001384 case AML_NOOP_OP:
1385
1386 /* Just do nothing! */
1387 break;
1388
Linus Torvalds1da177e2005-04-16 15:20:36 -07001389 case AML_BREAK_POINT_OP:
1390
1391 /* Call up to the OS service layer to handle this */
1392
Len Brown4be44fc2005-08-05 00:44:28 -04001393 status =
1394 acpi_os_signal(ACPI_SIGNAL_BREAKPOINT,
1395 "Executed AML Breakpoint opcode");
Linus Torvalds1da177e2005-04-16 15:20:36 -07001396
1397 /* If and when it returns, all done. */
1398
1399 break;
1400
Linus Torvalds1da177e2005-04-16 15:20:36 -07001401 case AML_BREAK_OP:
Len Brown4be44fc2005-08-05 00:44:28 -04001402 case AML_CONTINUE_OP: /* ACPI 2.0 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001403
1404 /* Pop and delete control states until we find a while */
1405
1406 while (walk_state->control_state &&
Len Brown4be44fc2005-08-05 00:44:28 -04001407 (walk_state->control_state->control.opcode !=
1408 AML_WHILE_OP)) {
1409 control_state =
1410 acpi_ut_pop_generic_state(&walk_state->
1411 control_state);
1412 acpi_ut_delete_generic_state(control_state);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001413 }
1414
1415 /* No while found? */
1416
1417 if (!walk_state->control_state) {
1418 return (AE_AML_NO_WHILE);
1419 }
1420
1421 /* Was: walk_state->aml_last_while = walk_state->control_state->Control.aml_predicate_start; */
1422
Len Brown4be44fc2005-08-05 00:44:28 -04001423 walk_state->aml_last_while =
1424 walk_state->control_state->control.package_end;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001425
1426 /* Return status depending on opcode */
1427
1428 if (op->common.aml_opcode == AML_BREAK_OP) {
1429 status = AE_CTRL_BREAK;
Len Brown4be44fc2005-08-05 00:44:28 -04001430 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001431 status = AE_CTRL_CONTINUE;
1432 }
1433 break;
1434
Linus Torvalds1da177e2005-04-16 15:20:36 -07001435 default:
1436
Bob Mooreb8e4d892006-01-27 16:43:00 -05001437 ACPI_ERROR((AE_INFO, "Unknown control opcode=%X Op=%p",
1438 op->common.aml_opcode, op));
Linus Torvalds1da177e2005-04-16 15:20:36 -07001439
1440 status = AE_AML_BAD_OPCODE;
1441 break;
1442 }
1443
1444 return (status);
1445}