blob: 53a7e416f33ee5e3943ea81429cfb00b26d199e2 [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/*
Bob Moorea8357b02010-01-22 19:07:36 +08009 * Copyright (C) 2000 - 2010, 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>
Len Browne2f7a772009-01-09 00:30:03 -050046#include "accommon.h"
47#include "acparser.h"
48#include "amlcode.h"
49#include "acdispat.h"
50#include "acinterp.h"
51#include "acnamesp.h"
52#include "acevents.h"
53#include "actables.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070054
55#define _COMPONENT ACPI_DISPATCHER
Len Brown4be44fc2005-08-05 00:44:28 -040056ACPI_MODULE_NAME("dsopcode")
Linus Torvalds1da177e2005-04-16 15:20:36 -070057
Robert Moore44f6c012005-04-18 22:49:35 -040058/* Local prototypes */
Len Brown4be44fc2005-08-05 00:44:28 -040059static acpi_status
60acpi_ds_execute_arguments(struct acpi_namespace_node *node,
61 struct acpi_namespace_node *scope_node,
62 u32 aml_length, u8 * aml_start);
Linus Torvalds1da177e2005-04-16 15:20:36 -070063
Robert Moore44f6c012005-04-18 22:49:35 -040064static acpi_status
Len Brown4be44fc2005-08-05 00:44:28 -040065acpi_ds_init_buffer_field(u16 aml_opcode,
66 union acpi_operand_object *obj_desc,
67 union acpi_operand_object *buffer_desc,
68 union acpi_operand_object *offset_desc,
69 union acpi_operand_object *length_desc,
70 union acpi_operand_object *result_desc);
Robert Moore44f6c012005-04-18 22:49:35 -040071
72/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -070073 *
74 * FUNCTION: acpi_ds_execute_arguments
75 *
Robert Moore44f6c012005-04-18 22:49:35 -040076 * PARAMETERS: Node - Object NS node
77 * scope_node - Parent NS node
Linus Torvalds1da177e2005-04-16 15:20:36 -070078 * aml_length - Length of executable AML
79 * aml_start - Pointer to the AML
80 *
81 * RETURN: Status.
82 *
83 * DESCRIPTION: Late (deferred) execution of region or field arguments
84 *
Robert Moore44f6c012005-04-18 22:49:35 -040085 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -070086
Robert Moore44f6c012005-04-18 22:49:35 -040087static acpi_status
Len Brown4be44fc2005-08-05 00:44:28 -040088acpi_ds_execute_arguments(struct acpi_namespace_node *node,
89 struct acpi_namespace_node *scope_node,
90 u32 aml_length, u8 * aml_start)
Linus Torvalds1da177e2005-04-16 15:20:36 -070091{
Len Brown4be44fc2005-08-05 00:44:28 -040092 acpi_status status;
93 union acpi_parse_object *op;
94 struct acpi_walk_state *walk_state;
Linus Torvalds1da177e2005-04-16 15:20:36 -070095
Bob Mooreb229cf92006-04-21 17:15:00 -040096 ACPI_FUNCTION_TRACE(ds_execute_arguments);
Linus Torvalds1da177e2005-04-16 15:20:36 -070097
98 /*
99 * Allocate a new parser op to be the root of the parsed tree
100 */
Len Brown4be44fc2005-08-05 00:44:28 -0400101 op = acpi_ps_alloc_op(AML_INT_EVAL_SUBTREE_OP);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700102 if (!op) {
Len Brown4be44fc2005-08-05 00:44:28 -0400103 return_ACPI_STATUS(AE_NO_MEMORY);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700104 }
105
106 /* Save the Node for use in acpi_ps_parse_aml */
107
108 op->common.node = scope_node;
109
110 /* Create and initialize a new parser state */
111
Len Brown4be44fc2005-08-05 00:44:28 -0400112 walk_state = acpi_ds_create_walk_state(0, NULL, NULL, NULL);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700113 if (!walk_state) {
Robert Moore88ac00f2005-05-26 00:00:00 -0400114 status = AE_NO_MEMORY;
115 goto cleanup;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700116 }
117
Len Brown4be44fc2005-08-05 00:44:28 -0400118 status = acpi_ds_init_aml_walk(walk_state, op, NULL, aml_start,
Bob Mooreec3153f2007-02-02 19:48:21 +0300119 aml_length, NULL, ACPI_IMODE_LOAD_PASS1);
Len Brown4be44fc2005-08-05 00:44:28 -0400120 if (ACPI_FAILURE(status)) {
121 acpi_ds_delete_walk_state(walk_state);
Robert Moore88ac00f2005-05-26 00:00:00 -0400122 goto cleanup;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700123 }
124
125 /* Mark this parse as a deferred opcode */
126
127 walk_state->parse_flags = ACPI_PARSE_DEFERRED_OP;
128 walk_state->deferred_node = node;
129
130 /* Pass1: Parse the entire declaration */
131
Len Brown4be44fc2005-08-05 00:44:28 -0400132 status = acpi_ps_parse_aml(walk_state);
133 if (ACPI_FAILURE(status)) {
Robert Moore88ac00f2005-05-26 00:00:00 -0400134 goto cleanup;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700135 }
136
137 /* Get and init the Op created above */
138
139 op->common.node = node;
Len Brown4be44fc2005-08-05 00:44:28 -0400140 acpi_ps_delete_parse_tree(op);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700141
142 /* Evaluate the deferred arguments */
143
Len Brown4be44fc2005-08-05 00:44:28 -0400144 op = acpi_ps_alloc_op(AML_INT_EVAL_SUBTREE_OP);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700145 if (!op) {
Len Brown4be44fc2005-08-05 00:44:28 -0400146 return_ACPI_STATUS(AE_NO_MEMORY);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700147 }
148
149 op->common.node = scope_node;
150
151 /* Create and initialize a new parser state */
152
Len Brown4be44fc2005-08-05 00:44:28 -0400153 walk_state = acpi_ds_create_walk_state(0, NULL, NULL, NULL);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700154 if (!walk_state) {
Robert Moore88ac00f2005-05-26 00:00:00 -0400155 status = AE_NO_MEMORY;
156 goto cleanup;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700157 }
158
159 /* Execute the opcode and arguments */
160
Len Brown4be44fc2005-08-05 00:44:28 -0400161 status = acpi_ds_init_aml_walk(walk_state, op, NULL, aml_start,
Bob Mooreec3153f2007-02-02 19:48:21 +0300162 aml_length, NULL, ACPI_IMODE_EXECUTE);
Len Brown4be44fc2005-08-05 00:44:28 -0400163 if (ACPI_FAILURE(status)) {
164 acpi_ds_delete_walk_state(walk_state);
Robert Moore88ac00f2005-05-26 00:00:00 -0400165 goto cleanup;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700166 }
167
168 /* Mark this execution as a deferred opcode */
169
170 walk_state->deferred_node = node;
Len Brown4be44fc2005-08-05 00:44:28 -0400171 status = acpi_ps_parse_aml(walk_state);
Robert Moore88ac00f2005-05-26 00:00:00 -0400172
Len Brown4be44fc2005-08-05 00:44:28 -0400173 cleanup:
174 acpi_ps_delete_parse_tree(op);
175 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700176}
177
Robert Moore44f6c012005-04-18 22:49:35 -0400178/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700179 *
180 * FUNCTION: acpi_ds_get_buffer_field_arguments
181 *
182 * PARAMETERS: obj_desc - A valid buffer_field object
183 *
184 * RETURN: Status.
185 *
186 * DESCRIPTION: Get buffer_field Buffer and Index. This implements the late
187 * evaluation of these field attributes.
188 *
Robert Moore44f6c012005-04-18 22:49:35 -0400189 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700190
191acpi_status
Len Brown4be44fc2005-08-05 00:44:28 -0400192acpi_ds_get_buffer_field_arguments(union acpi_operand_object *obj_desc)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700193{
Len Brown4be44fc2005-08-05 00:44:28 -0400194 union acpi_operand_object *extra_desc;
195 struct acpi_namespace_node *node;
196 acpi_status status;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700197
Bob Mooreb229cf92006-04-21 17:15:00 -0400198 ACPI_FUNCTION_TRACE_PTR(ds_get_buffer_field_arguments, obj_desc);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700199
200 if (obj_desc->common.flags & AOPOBJ_DATA_VALID) {
Len Brown4be44fc2005-08-05 00:44:28 -0400201 return_ACPI_STATUS(AE_OK);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700202 }
203
204 /* Get the AML pointer (method object) and buffer_field node */
205
Len Brown4be44fc2005-08-05 00:44:28 -0400206 extra_desc = acpi_ns_get_secondary_object(obj_desc);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700207 node = obj_desc->buffer_field.node;
208
Len Brown4be44fc2005-08-05 00:44:28 -0400209 ACPI_DEBUG_EXEC(acpi_ut_display_init_pathname
210 (ACPI_TYPE_BUFFER_FIELD, node, NULL));
Bob Mooreb229cf92006-04-21 17:15:00 -0400211 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "[%4.4s] BufferField Arg Init\n",
Len Brown4be44fc2005-08-05 00:44:28 -0400212 acpi_ut_get_node_name(node)));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700213
214 /* Execute the AML code for the term_arg arguments */
215
Len Brown4be44fc2005-08-05 00:44:28 -0400216 status = acpi_ds_execute_arguments(node, acpi_ns_get_parent_node(node),
217 extra_desc->extra.aml_length,
218 extra_desc->extra.aml_start);
219 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700220}
221
Robert Moore44f6c012005-04-18 22:49:35 -0400222/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700223 *
Lin Mingef805d92008-04-10 19:06:41 +0400224 * FUNCTION: acpi_ds_get_bank_field_arguments
225 *
226 * PARAMETERS: obj_desc - A valid bank_field object
227 *
228 * RETURN: Status.
229 *
230 * DESCRIPTION: Get bank_field bank_value. This implements the late
231 * evaluation of these field attributes.
232 *
233 ******************************************************************************/
234
235acpi_status
236acpi_ds_get_bank_field_arguments(union acpi_operand_object *obj_desc)
237{
238 union acpi_operand_object *extra_desc;
239 struct acpi_namespace_node *node;
240 acpi_status status;
241
242 ACPI_FUNCTION_TRACE_PTR(ds_get_bank_field_arguments, obj_desc);
243
244 if (obj_desc->common.flags & AOPOBJ_DATA_VALID) {
245 return_ACPI_STATUS(AE_OK);
246 }
247
248 /* Get the AML pointer (method object) and bank_field node */
249
250 extra_desc = acpi_ns_get_secondary_object(obj_desc);
251 node = obj_desc->bank_field.node;
252
253 ACPI_DEBUG_EXEC(acpi_ut_display_init_pathname
254 (ACPI_TYPE_LOCAL_BANK_FIELD, node, NULL));
255 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "[%4.4s] BankField Arg Init\n",
256 acpi_ut_get_node_name(node)));
257
258 /* Execute the AML code for the term_arg arguments */
259
260 status = acpi_ds_execute_arguments(node, acpi_ns_get_parent_node(node),
261 extra_desc->extra.aml_length,
262 extra_desc->extra.aml_start);
263 return_ACPI_STATUS(status);
264}
265
266/*******************************************************************************
267 *
Linus Torvalds1da177e2005-04-16 15:20:36 -0700268 * FUNCTION: acpi_ds_get_buffer_arguments
269 *
270 * PARAMETERS: obj_desc - A valid Buffer object
271 *
272 * RETURN: Status.
273 *
274 * DESCRIPTION: Get Buffer length and initializer byte list. This implements
275 * the late evaluation of these attributes.
276 *
Robert Moore44f6c012005-04-18 22:49:35 -0400277 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700278
Len Brown4be44fc2005-08-05 00:44:28 -0400279acpi_status acpi_ds_get_buffer_arguments(union acpi_operand_object *obj_desc)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700280{
Len Brown4be44fc2005-08-05 00:44:28 -0400281 struct acpi_namespace_node *node;
282 acpi_status status;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700283
Bob Mooreb229cf92006-04-21 17:15:00 -0400284 ACPI_FUNCTION_TRACE_PTR(ds_get_buffer_arguments, obj_desc);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700285
286 if (obj_desc->common.flags & AOPOBJ_DATA_VALID) {
Len Brown4be44fc2005-08-05 00:44:28 -0400287 return_ACPI_STATUS(AE_OK);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700288 }
289
290 /* Get the Buffer node */
291
292 node = obj_desc->buffer.node;
293 if (!node) {
Bob Mooreb8e4d892006-01-27 16:43:00 -0500294 ACPI_ERROR((AE_INFO,
Bob Mooref6a22b02010-03-05 17:56:40 +0800295 "No pointer back to namespace node in buffer object %p",
Bob Mooreb8e4d892006-01-27 16:43:00 -0500296 obj_desc));
Len Brown4be44fc2005-08-05 00:44:28 -0400297 return_ACPI_STATUS(AE_AML_INTERNAL);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700298 }
299
Len Brown4be44fc2005-08-05 00:44:28 -0400300 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Buffer Arg Init\n"));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700301
302 /* Execute the AML code for the term_arg arguments */
303
Len Brown4be44fc2005-08-05 00:44:28 -0400304 status = acpi_ds_execute_arguments(node, node,
305 obj_desc->buffer.aml_length,
306 obj_desc->buffer.aml_start);
307 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700308}
309
Robert Moore44f6c012005-04-18 22:49:35 -0400310/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700311 *
312 * FUNCTION: acpi_ds_get_package_arguments
313 *
314 * PARAMETERS: obj_desc - A valid Package object
315 *
316 * RETURN: Status.
317 *
318 * DESCRIPTION: Get Package length and initializer byte list. This implements
319 * the late evaluation of these attributes.
320 *
Robert Moore44f6c012005-04-18 22:49:35 -0400321 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700322
Len Brown4be44fc2005-08-05 00:44:28 -0400323acpi_status acpi_ds_get_package_arguments(union acpi_operand_object *obj_desc)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700324{
Len Brown4be44fc2005-08-05 00:44:28 -0400325 struct acpi_namespace_node *node;
326 acpi_status status;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700327
Bob Mooreb229cf92006-04-21 17:15:00 -0400328 ACPI_FUNCTION_TRACE_PTR(ds_get_package_arguments, obj_desc);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700329
330 if (obj_desc->common.flags & AOPOBJ_DATA_VALID) {
Len Brown4be44fc2005-08-05 00:44:28 -0400331 return_ACPI_STATUS(AE_OK);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700332 }
333
334 /* Get the Package node */
335
336 node = obj_desc->package.node;
337 if (!node) {
Bob Mooreb8e4d892006-01-27 16:43:00 -0500338 ACPI_ERROR((AE_INFO,
Bob Mooref6a22b02010-03-05 17:56:40 +0800339 "No pointer back to namespace node in package %p",
Bob Mooreb8e4d892006-01-27 16:43:00 -0500340 obj_desc));
Len Brown4be44fc2005-08-05 00:44:28 -0400341 return_ACPI_STATUS(AE_AML_INTERNAL);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700342 }
343
Len Brown4be44fc2005-08-05 00:44:28 -0400344 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Package Arg Init\n"));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700345
346 /* Execute the AML code for the term_arg arguments */
347
Len Brown4be44fc2005-08-05 00:44:28 -0400348 status = acpi_ds_execute_arguments(node, node,
349 obj_desc->package.aml_length,
350 obj_desc->package.aml_start);
351 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700352}
353
Linus Torvalds1da177e2005-04-16 15:20:36 -0700354/*****************************************************************************
355 *
356 * FUNCTION: acpi_ds_get_region_arguments
357 *
358 * PARAMETERS: obj_desc - A valid region object
359 *
360 * RETURN: Status.
361 *
362 * DESCRIPTION: Get region address and length. This implements the late
363 * evaluation of these region attributes.
364 *
365 ****************************************************************************/
366
Len Brown4be44fc2005-08-05 00:44:28 -0400367acpi_status acpi_ds_get_region_arguments(union acpi_operand_object *obj_desc)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700368{
Len Brown4be44fc2005-08-05 00:44:28 -0400369 struct acpi_namespace_node *node;
370 acpi_status status;
371 union acpi_operand_object *extra_desc;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700372
Bob Mooreb229cf92006-04-21 17:15:00 -0400373 ACPI_FUNCTION_TRACE_PTR(ds_get_region_arguments, obj_desc);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700374
375 if (obj_desc->region.flags & AOPOBJ_DATA_VALID) {
Len Brown4be44fc2005-08-05 00:44:28 -0400376 return_ACPI_STATUS(AE_OK);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700377 }
378
Len Brown4be44fc2005-08-05 00:44:28 -0400379 extra_desc = acpi_ns_get_secondary_object(obj_desc);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700380 if (!extra_desc) {
Len Brown4be44fc2005-08-05 00:44:28 -0400381 return_ACPI_STATUS(AE_NOT_EXIST);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700382 }
383
384 /* Get the Region node */
385
386 node = obj_desc->region.node;
387
Len Brown4be44fc2005-08-05 00:44:28 -0400388 ACPI_DEBUG_EXEC(acpi_ut_display_init_pathname
389 (ACPI_TYPE_REGION, node, NULL));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700390
Bob Mooreb229cf92006-04-21 17:15:00 -0400391 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "[%4.4s] OpRegion Arg Init at AML %p\n",
Len Brown4be44fc2005-08-05 00:44:28 -0400392 acpi_ut_get_node_name(node),
393 extra_desc->extra.aml_start));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700394
395 /* Execute the argument AML */
396
Len Brown4be44fc2005-08-05 00:44:28 -0400397 status = acpi_ds_execute_arguments(node, acpi_ns_get_parent_node(node),
398 extra_desc->extra.aml_length,
399 extra_desc->extra.aml_start);
Len Brown7cb7f452009-07-27 18:42:38 -0400400 if (ACPI_FAILURE(status)) {
401 return_ACPI_STATUS(status);
402 }
403
404 /* Validate the region address/length via the host OS */
405
406 status = acpi_os_validate_address(obj_desc->region.space_id,
407 obj_desc->region.address,
408 (acpi_size) obj_desc->region.length,
409 acpi_ut_get_node_name(node));
410
411 if (ACPI_FAILURE(status)) {
412 /*
413 * Invalid address/length. We will emit an error message and mark
414 * the region as invalid, so that it will cause an additional error if
415 * it is ever used. Then return AE_OK.
416 */
417 ACPI_EXCEPTION((AE_INFO, status,
418 "During address validation of OpRegion [%4.4s]",
419 node->name.ascii));
420 obj_desc->common.flags |= AOPOBJ_INVALID;
421 status = AE_OK;
422 }
423
Len Brown4be44fc2005-08-05 00:44:28 -0400424 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700425}
426
Robert Moore44f6c012005-04-18 22:49:35 -0400427/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700428 *
429 * FUNCTION: acpi_ds_initialize_region
430 *
Robert Moore44f6c012005-04-18 22:49:35 -0400431 * PARAMETERS: obj_handle - Region namespace node
Linus Torvalds1da177e2005-04-16 15:20:36 -0700432 *
433 * RETURN: Status
434 *
435 * DESCRIPTION: Front end to ev_initialize_region
436 *
Robert Moore44f6c012005-04-18 22:49:35 -0400437 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700438
Len Brown4be44fc2005-08-05 00:44:28 -0400439acpi_status acpi_ds_initialize_region(acpi_handle obj_handle)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700440{
Len Brown4be44fc2005-08-05 00:44:28 -0400441 union acpi_operand_object *obj_desc;
442 acpi_status status;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700443
Len Brown4be44fc2005-08-05 00:44:28 -0400444 obj_desc = acpi_ns_get_attached_object(obj_handle);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700445
446 /* Namespace is NOT locked */
447
Len Brown4be44fc2005-08-05 00:44:28 -0400448 status = acpi_ev_initialize_region(obj_desc, FALSE);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700449 return (status);
450}
451
Robert Moore44f6c012005-04-18 22:49:35 -0400452/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700453 *
454 * FUNCTION: acpi_ds_init_buffer_field
455 *
456 * PARAMETERS: aml_opcode - create_xxx_field
457 * obj_desc - buffer_field object
458 * buffer_desc - Host Buffer
459 * offset_desc - Offset into buffer
Robert Moore44f6c012005-04-18 22:49:35 -0400460 * length_desc - Length of field (CREATE_FIELD_OP only)
461 * result_desc - Where to store the result
Linus Torvalds1da177e2005-04-16 15:20:36 -0700462 *
463 * RETURN: Status
464 *
465 * DESCRIPTION: Perform actual initialization of a buffer field
466 *
Robert Moore44f6c012005-04-18 22:49:35 -0400467 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700468
Robert Moore44f6c012005-04-18 22:49:35 -0400469static acpi_status
Len Brown4be44fc2005-08-05 00:44:28 -0400470acpi_ds_init_buffer_field(u16 aml_opcode,
471 union acpi_operand_object *obj_desc,
472 union acpi_operand_object *buffer_desc,
473 union acpi_operand_object *offset_desc,
474 union acpi_operand_object *length_desc,
475 union acpi_operand_object *result_desc)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700476{
Len Brown4be44fc2005-08-05 00:44:28 -0400477 u32 offset;
478 u32 bit_offset;
479 u32 bit_count;
480 u8 field_flags;
481 acpi_status status;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700482
Bob Mooreb229cf92006-04-21 17:15:00 -0400483 ACPI_FUNCTION_TRACE_PTR(ds_init_buffer_field, obj_desc);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700484
485 /* Host object must be a Buffer */
486
Bob Moore3371c192009-02-18 14:44:03 +0800487 if (buffer_desc->common.type != ACPI_TYPE_BUFFER) {
Bob Mooreb8e4d892006-01-27 16:43:00 -0500488 ACPI_ERROR((AE_INFO,
489 "Target of Create Field is not a Buffer object - %s",
490 acpi_ut_get_object_type_name(buffer_desc)));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700491
492 status = AE_AML_OPERAND_TYPE;
493 goto cleanup;
494 }
495
496 /*
497 * The last parameter to all of these opcodes (result_desc) started
498 * out as a name_string, and should therefore now be a NS node
499 * after resolution in acpi_ex_resolve_operands().
500 */
Len Brown4be44fc2005-08-05 00:44:28 -0400501 if (ACPI_GET_DESCRIPTOR_TYPE(result_desc) != ACPI_DESC_TYPE_NAMED) {
Bob Mooreb8e4d892006-01-27 16:43:00 -0500502 ACPI_ERROR((AE_INFO,
503 "(%s) destination not a NS Node [%s]",
504 acpi_ps_get_opcode_name(aml_opcode),
505 acpi_ut_get_descriptor_name(result_desc)));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700506
507 status = AE_AML_OPERAND_TYPE;
508 goto cleanup;
509 }
510
511 offset = (u32) offset_desc->integer.value;
512
513 /*
514 * Setup the Bit offsets and counts, according to the opcode
515 */
516 switch (aml_opcode) {
517 case AML_CREATE_FIELD_OP:
518
519 /* Offset is in bits, count is in bits */
520
Robert Moore44f6c012005-04-18 22:49:35 -0400521 field_flags = AML_FIELD_ACCESS_BYTE;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700522 bit_offset = offset;
Len Brown4be44fc2005-08-05 00:44:28 -0400523 bit_count = (u32) length_desc->integer.value;
Robert Moore44f6c012005-04-18 22:49:35 -0400524
525 /* Must have a valid (>0) bit count */
526
527 if (bit_count == 0) {
Bob Mooreb8e4d892006-01-27 16:43:00 -0500528 ACPI_ERROR((AE_INFO,
Bob Mooreb229cf92006-04-21 17:15:00 -0400529 "Attempt to CreateField of length zero"));
Robert Moore44f6c012005-04-18 22:49:35 -0400530 status = AE_AML_OPERAND_VALUE;
531 goto cleanup;
532 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700533 break;
534
535 case AML_CREATE_BIT_FIELD_OP:
536
537 /* Offset is in bits, Field is one bit */
538
539 bit_offset = offset;
Len Brown4be44fc2005-08-05 00:44:28 -0400540 bit_count = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700541 field_flags = AML_FIELD_ACCESS_BYTE;
542 break;
543
544 case AML_CREATE_BYTE_FIELD_OP:
545
546 /* Offset is in bytes, field is one byte */
547
548 bit_offset = 8 * offset;
Len Brown4be44fc2005-08-05 00:44:28 -0400549 bit_count = 8;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700550 field_flags = AML_FIELD_ACCESS_BYTE;
551 break;
552
553 case AML_CREATE_WORD_FIELD_OP:
554
555 /* Offset is in bytes, field is one word */
556
557 bit_offset = 8 * offset;
Len Brown4be44fc2005-08-05 00:44:28 -0400558 bit_count = 16;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700559 field_flags = AML_FIELD_ACCESS_WORD;
560 break;
561
562 case AML_CREATE_DWORD_FIELD_OP:
563
564 /* Offset is in bytes, field is one dword */
565
566 bit_offset = 8 * offset;
Len Brown4be44fc2005-08-05 00:44:28 -0400567 bit_count = 32;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700568 field_flags = AML_FIELD_ACCESS_DWORD;
569 break;
570
571 case AML_CREATE_QWORD_FIELD_OP:
572
573 /* Offset is in bytes, field is one qword */
574
575 bit_offset = 8 * offset;
Len Brown4be44fc2005-08-05 00:44:28 -0400576 bit_count = 64;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700577 field_flags = AML_FIELD_ACCESS_QWORD;
578 break;
579
580 default:
581
Bob Mooreb8e4d892006-01-27 16:43:00 -0500582 ACPI_ERROR((AE_INFO,
Bob Mooref6a22b02010-03-05 17:56:40 +0800583 "Unknown field creation opcode 0x%02X",
584 aml_opcode));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700585 status = AE_AML_BAD_OPCODE;
586 goto cleanup;
587 }
588
589 /* Entire field must fit within the current length of the buffer */
590
Len Brown4be44fc2005-08-05 00:44:28 -0400591 if ((bit_offset + bit_count) > (8 * (u32) buffer_desc->buffer.length)) {
Bob Mooreb8e4d892006-01-27 16:43:00 -0500592 ACPI_ERROR((AE_INFO,
Bob Mooref6a22b02010-03-05 17:56:40 +0800593 "Field [%4.4s] at %u exceeds Buffer [%4.4s] size %u (bits)",
Bob Mooreb8e4d892006-01-27 16:43:00 -0500594 acpi_ut_get_node_name(result_desc),
595 bit_offset + bit_count,
596 acpi_ut_get_node_name(buffer_desc->buffer.node),
597 8 * (u32) buffer_desc->buffer.length));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700598 status = AE_AML_BUFFER_LIMIT;
599 goto cleanup;
600 }
601
602 /*
603 * Initialize areas of the field object that are common to all fields
Robert Moore44f6c012005-04-18 22:49:35 -0400604 * For field_flags, use LOCK_RULE = 0 (NO_LOCK),
605 * UPDATE_RULE = 0 (UPDATE_PRESERVE)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700606 */
Len Brown4be44fc2005-08-05 00:44:28 -0400607 status = acpi_ex_prep_common_field_object(obj_desc, field_flags, 0,
608 bit_offset, bit_count);
609 if (ACPI_FAILURE(status)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700610 goto cleanup;
611 }
612
613 obj_desc->buffer_field.buffer_obj = buffer_desc;
614
615 /* Reference count for buffer_desc inherits obj_desc count */
616
Robert Moore44f6c012005-04-18 22:49:35 -0400617 buffer_desc->common.reference_count = (u16)
Len Brown4be44fc2005-08-05 00:44:28 -0400618 (buffer_desc->common.reference_count +
619 obj_desc->common.reference_count);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700620
Len Brown4be44fc2005-08-05 00:44:28 -0400621 cleanup:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700622
623 /* Always delete the operands */
624
Len Brown4be44fc2005-08-05 00:44:28 -0400625 acpi_ut_remove_reference(offset_desc);
626 acpi_ut_remove_reference(buffer_desc);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700627
628 if (aml_opcode == AML_CREATE_FIELD_OP) {
Len Brown4be44fc2005-08-05 00:44:28 -0400629 acpi_ut_remove_reference(length_desc);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700630 }
631
632 /* On failure, delete the result descriptor */
633
Len Brown4be44fc2005-08-05 00:44:28 -0400634 if (ACPI_FAILURE(status)) {
635 acpi_ut_remove_reference(result_desc); /* Result descriptor */
636 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700637 /* Now the address and length are valid for this buffer_field */
638
639 obj_desc->buffer_field.flags |= AOPOBJ_DATA_VALID;
640 }
641
Len Brown4be44fc2005-08-05 00:44:28 -0400642 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700643}
644
Robert Moore44f6c012005-04-18 22:49:35 -0400645/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700646 *
647 * FUNCTION: acpi_ds_eval_buffer_field_operands
648 *
649 * PARAMETERS: walk_state - Current walk
650 * Op - A valid buffer_field Op object
651 *
652 * RETURN: Status
653 *
654 * DESCRIPTION: Get buffer_field Buffer and Index
655 * Called from acpi_ds_exec_end_op during buffer_field parse tree walk
656 *
Robert Moore44f6c012005-04-18 22:49:35 -0400657 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700658
659acpi_status
Len Brown4be44fc2005-08-05 00:44:28 -0400660acpi_ds_eval_buffer_field_operands(struct acpi_walk_state *walk_state,
661 union acpi_parse_object *op)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700662{
Len Brown4be44fc2005-08-05 00:44:28 -0400663 acpi_status status;
664 union acpi_operand_object *obj_desc;
665 struct acpi_namespace_node *node;
666 union acpi_parse_object *next_op;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700667
Bob Mooreb229cf92006-04-21 17:15:00 -0400668 ACPI_FUNCTION_TRACE_PTR(ds_eval_buffer_field_operands, op);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700669
670 /*
671 * This is where we evaluate the address and length fields of the
672 * create_xxx_field declaration
673 */
Len Brown4be44fc2005-08-05 00:44:28 -0400674 node = op->common.node;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700675
676 /* next_op points to the op that holds the Buffer */
677
678 next_op = op->common.value.arg;
679
680 /* Evaluate/create the address and length operands */
681
Len Brown4be44fc2005-08-05 00:44:28 -0400682 status = acpi_ds_create_operands(walk_state, next_op);
683 if (ACPI_FAILURE(status)) {
684 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700685 }
686
Len Brown4be44fc2005-08-05 00:44:28 -0400687 obj_desc = acpi_ns_get_attached_object(node);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700688 if (!obj_desc) {
Len Brown4be44fc2005-08-05 00:44:28 -0400689 return_ACPI_STATUS(AE_NOT_EXIST);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700690 }
691
692 /* Resolve the operands */
693
Len Brown4be44fc2005-08-05 00:44:28 -0400694 status = acpi_ex_resolve_operands(op->common.aml_opcode,
695 ACPI_WALK_OPERANDS, walk_state);
Len Brown4be44fc2005-08-05 00:44:28 -0400696 if (ACPI_FAILURE(status)) {
Bob Mooref6a22b02010-03-05 17:56:40 +0800697 ACPI_ERROR((AE_INFO, "(%s) bad operand(s), status 0x%X",
Bob Mooreb8e4d892006-01-27 16:43:00 -0500698 acpi_ps_get_opcode_name(op->common.aml_opcode),
699 status));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700700
Len Brown4be44fc2005-08-05 00:44:28 -0400701 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700702 }
703
704 /* Initialize the Buffer Field */
705
706 if (op->common.aml_opcode == AML_CREATE_FIELD_OP) {
Bob Moore52fc0b02006-10-02 00:00:00 -0400707
Linus Torvalds1da177e2005-04-16 15:20:36 -0700708 /* NOTE: Slightly different operands for this opcode */
709
Len Brown4be44fc2005-08-05 00:44:28 -0400710 status =
711 acpi_ds_init_buffer_field(op->common.aml_opcode, obj_desc,
712 walk_state->operands[0],
713 walk_state->operands[1],
714 walk_state->operands[2],
715 walk_state->operands[3]);
716 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700717 /* All other, create_xxx_field opcodes */
718
Len Brown4be44fc2005-08-05 00:44:28 -0400719 status =
720 acpi_ds_init_buffer_field(op->common.aml_opcode, obj_desc,
721 walk_state->operands[0],
722 walk_state->operands[1], NULL,
723 walk_state->operands[2]);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700724 }
725
Len Brown4be44fc2005-08-05 00:44:28 -0400726 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700727}
728
Robert Moore44f6c012005-04-18 22:49:35 -0400729/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700730 *
731 * FUNCTION: acpi_ds_eval_region_operands
732 *
733 * PARAMETERS: walk_state - Current walk
734 * Op - A valid region Op object
735 *
736 * RETURN: Status
737 *
738 * DESCRIPTION: Get region address and length
739 * Called from acpi_ds_exec_end_op during op_region parse tree walk
740 *
Robert Moore44f6c012005-04-18 22:49:35 -0400741 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700742
743acpi_status
Len Brown4be44fc2005-08-05 00:44:28 -0400744acpi_ds_eval_region_operands(struct acpi_walk_state *walk_state,
745 union acpi_parse_object *op)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700746{
Len Brown4be44fc2005-08-05 00:44:28 -0400747 acpi_status status;
748 union acpi_operand_object *obj_desc;
749 union acpi_operand_object *operand_desc;
750 struct acpi_namespace_node *node;
751 union acpi_parse_object *next_op;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700752
Bob Mooreb229cf92006-04-21 17:15:00 -0400753 ACPI_FUNCTION_TRACE_PTR(ds_eval_region_operands, op);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700754
755 /*
Robert Moore44f6c012005-04-18 22:49:35 -0400756 * This is where we evaluate the address and length fields of the
757 * op_region declaration
Linus Torvalds1da177e2005-04-16 15:20:36 -0700758 */
Len Brown4be44fc2005-08-05 00:44:28 -0400759 node = op->common.node;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700760
761 /* next_op points to the op that holds the space_iD */
762
763 next_op = op->common.value.arg;
764
765 /* next_op points to address op */
766
767 next_op = next_op->common.next;
768
769 /* Evaluate/create the address and length operands */
770
Len Brown4be44fc2005-08-05 00:44:28 -0400771 status = acpi_ds_create_operands(walk_state, next_op);
772 if (ACPI_FAILURE(status)) {
773 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700774 }
775
776 /* Resolve the length and address operands to numbers */
777
Len Brown4be44fc2005-08-05 00:44:28 -0400778 status = acpi_ex_resolve_operands(op->common.aml_opcode,
779 ACPI_WALK_OPERANDS, walk_state);
780 if (ACPI_FAILURE(status)) {
781 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700782 }
783
Len Brown4be44fc2005-08-05 00:44:28 -0400784 obj_desc = acpi_ns_get_attached_object(node);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700785 if (!obj_desc) {
Len Brown4be44fc2005-08-05 00:44:28 -0400786 return_ACPI_STATUS(AE_NOT_EXIST);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700787 }
788
789 /*
790 * Get the length operand and save it
791 * (at Top of stack)
792 */
793 operand_desc = walk_state->operands[walk_state->num_operands - 1];
794
795 obj_desc->region.length = (u32) operand_desc->integer.value;
Len Brown4be44fc2005-08-05 00:44:28 -0400796 acpi_ut_remove_reference(operand_desc);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700797
798 /*
799 * Get the address and save it
800 * (at top of stack - 1)
801 */
802 operand_desc = walk_state->operands[walk_state->num_operands - 2];
803
Robert Moore44f6c012005-04-18 22:49:35 -0400804 obj_desc->region.address = (acpi_physical_address)
Len Brown4be44fc2005-08-05 00:44:28 -0400805 operand_desc->integer.value;
806 acpi_ut_remove_reference(operand_desc);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700807
Bob Mooreb229cf92006-04-21 17:15:00 -0400808 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "RgnObj %p Addr %8.8X%8.8X Len %X\n",
Len Brown4be44fc2005-08-05 00:44:28 -0400809 obj_desc,
Bob Mooreb7f9f042008-04-10 19:06:40 +0400810 ACPI_FORMAT_NATIVE_UINT(obj_desc->region.address),
Len Brown4be44fc2005-08-05 00:44:28 -0400811 obj_desc->region.length));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700812
813 /* Now the address and length are valid for this opregion */
814
815 obj_desc->region.flags |= AOPOBJ_DATA_VALID;
816
Len Brown4be44fc2005-08-05 00:44:28 -0400817 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700818}
819
Robert Moore44f6c012005-04-18 22:49:35 -0400820/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700821 *
Lin Ming941f48b2008-04-10 19:06:41 +0400822 * FUNCTION: acpi_ds_eval_table_region_operands
823 *
824 * PARAMETERS: walk_state - Current walk
825 * Op - A valid region Op object
826 *
827 * RETURN: Status
828 *
829 * DESCRIPTION: Get region address and length
830 * Called from acpi_ds_exec_end_op during data_table_region parse tree walk
831 *
832 ******************************************************************************/
833
834acpi_status
835acpi_ds_eval_table_region_operands(struct acpi_walk_state *walk_state,
836 union acpi_parse_object *op)
837{
838 acpi_status status;
839 union acpi_operand_object *obj_desc;
840 union acpi_operand_object **operand;
841 struct acpi_namespace_node *node;
842 union acpi_parse_object *next_op;
Bob Moore67a119f2008-06-10 13:42:13 +0800843 u32 table_index;
Lin Ming941f48b2008-04-10 19:06:41 +0400844 struct acpi_table_header *table;
845
846 ACPI_FUNCTION_TRACE_PTR(ds_eval_table_region_operands, op);
847
848 /*
849 * This is where we evaluate the signature_string and oem_iDString
850 * and oem_table_iDString of the data_table_region declaration
851 */
852 node = op->common.node;
853
854 /* next_op points to signature_string op */
855
856 next_op = op->common.value.arg;
857
858 /*
859 * Evaluate/create the signature_string and oem_iDString
860 * and oem_table_iDString operands
861 */
862 status = acpi_ds_create_operands(walk_state, next_op);
863 if (ACPI_FAILURE(status)) {
864 return_ACPI_STATUS(status);
865 }
866
867 /*
868 * Resolve the signature_string and oem_iDString
869 * and oem_table_iDString operands
870 */
871 status = acpi_ex_resolve_operands(op->common.aml_opcode,
872 ACPI_WALK_OPERANDS, walk_state);
873 if (ACPI_FAILURE(status)) {
874 return_ACPI_STATUS(status);
875 }
876
Lin Ming941f48b2008-04-10 19:06:41 +0400877 operand = &walk_state->operands[0];
878
879 /* Find the ACPI table */
880
881 status = acpi_tb_find_table(operand[0]->string.pointer,
882 operand[1]->string.pointer,
883 operand[2]->string.pointer, &table_index);
884 if (ACPI_FAILURE(status)) {
885 return_ACPI_STATUS(status);
886 }
887
888 acpi_ut_remove_reference(operand[0]);
889 acpi_ut_remove_reference(operand[1]);
890 acpi_ut_remove_reference(operand[2]);
891
892 status = acpi_get_table_by_index(table_index, &table);
893 if (ACPI_FAILURE(status)) {
894 return_ACPI_STATUS(status);
895 }
896
897 obj_desc = acpi_ns_get_attached_object(node);
898 if (!obj_desc) {
899 return_ACPI_STATUS(AE_NOT_EXIST);
900 }
901
902 obj_desc->region.address =
903 (acpi_physical_address) ACPI_TO_INTEGER(table);
904 obj_desc->region.length = table->length;
905
906 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "RgnObj %p Addr %8.8X%8.8X Len %X\n",
907 obj_desc,
908 ACPI_FORMAT_NATIVE_UINT(obj_desc->region.address),
909 obj_desc->region.length));
910
911 /* Now the address and length are valid for this opregion */
912
913 obj_desc->region.flags |= AOPOBJ_DATA_VALID;
914
915 return_ACPI_STATUS(status);
916}
917
918/*******************************************************************************
919 *
Linus Torvalds1da177e2005-04-16 15:20:36 -0700920 * FUNCTION: acpi_ds_eval_data_object_operands
921 *
922 * PARAMETERS: walk_state - Current walk
923 * Op - A valid data_object Op object
924 * obj_desc - data_object
925 *
926 * RETURN: Status
927 *
928 * DESCRIPTION: Get the operands and complete the following data object types:
929 * Buffer, Package.
930 *
Robert Moore44f6c012005-04-18 22:49:35 -0400931 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700932
933acpi_status
Len Brown4be44fc2005-08-05 00:44:28 -0400934acpi_ds_eval_data_object_operands(struct acpi_walk_state *walk_state,
935 union acpi_parse_object *op,
936 union acpi_operand_object *obj_desc)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700937{
Len Brown4be44fc2005-08-05 00:44:28 -0400938 acpi_status status;
939 union acpi_operand_object *arg_desc;
940 u32 length;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700941
Bob Mooreb229cf92006-04-21 17:15:00 -0400942 ACPI_FUNCTION_TRACE(ds_eval_data_object_operands);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700943
944 /* The first operand (for all of these data objects) is the length */
945
Bob Moore773069d2008-04-10 19:06:36 +0400946 /*
947 * Set proper index into operand stack for acpi_ds_obj_stack_push
948 * invoked inside acpi_ds_create_operand.
949 */
950 walk_state->operand_index = walk_state->num_operands;
951
Len Brown4be44fc2005-08-05 00:44:28 -0400952 status = acpi_ds_create_operand(walk_state, op->common.value.arg, 1);
953 if (ACPI_FAILURE(status)) {
954 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700955 }
956
Len Brown4be44fc2005-08-05 00:44:28 -0400957 status = acpi_ex_resolve_operands(walk_state->opcode,
958 &(walk_state->
959 operands[walk_state->num_operands -
960 1]), walk_state);
961 if (ACPI_FAILURE(status)) {
962 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700963 }
964
965 /* Extract length operand */
966
Len Brown4be44fc2005-08-05 00:44:28 -0400967 arg_desc = walk_state->operands[walk_state->num_operands - 1];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700968 length = (u32) arg_desc->integer.value;
969
970 /* Cleanup for length operand */
971
Len Brown4be44fc2005-08-05 00:44:28 -0400972 status = acpi_ds_obj_stack_pop(1, walk_state);
973 if (ACPI_FAILURE(status)) {
974 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700975 }
976
Len Brown4be44fc2005-08-05 00:44:28 -0400977 acpi_ut_remove_reference(arg_desc);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700978
979 /*
980 * Create the actual data object
981 */
982 switch (op->common.aml_opcode) {
983 case AML_BUFFER_OP:
984
Len Brown4be44fc2005-08-05 00:44:28 -0400985 status =
986 acpi_ds_build_internal_buffer_obj(walk_state, op, length,
987 &obj_desc);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700988 break;
989
990 case AML_PACKAGE_OP:
991 case AML_VAR_PACKAGE_OP:
992
Len Brown4be44fc2005-08-05 00:44:28 -0400993 status =
994 acpi_ds_build_internal_package_obj(walk_state, op, length,
995 &obj_desc);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700996 break;
997
998 default:
Len Brown4be44fc2005-08-05 00:44:28 -0400999 return_ACPI_STATUS(AE_AML_BAD_OPCODE);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001000 }
1001
Len Brown4be44fc2005-08-05 00:44:28 -04001002 if (ACPI_SUCCESS(status)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001003 /*
Robert Moore44f6c012005-04-18 22:49:35 -04001004 * Return the object in the walk_state, unless the parent is a package -
Linus Torvalds1da177e2005-04-16 15:20:36 -07001005 * in this case, the return object will be stored in the parse tree
1006 * for the package.
1007 */
1008 if ((!op->common.parent) ||
Len Brown4be44fc2005-08-05 00:44:28 -04001009 ((op->common.parent->common.aml_opcode != AML_PACKAGE_OP) &&
1010 (op->common.parent->common.aml_opcode !=
1011 AML_VAR_PACKAGE_OP)
Len Brownfd350942007-05-09 23:34:35 -04001012 && (op->common.parent->common.aml_opcode != AML_NAME_OP))) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001013 walk_state->result_obj = obj_desc;
1014 }
1015 }
1016
Len Brown4be44fc2005-08-05 00:44:28 -04001017 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001018}
1019
Linus Torvalds1da177e2005-04-16 15:20:36 -07001020/*******************************************************************************
1021 *
Lin Mingef805d92008-04-10 19:06:41 +04001022 * FUNCTION: acpi_ds_eval_bank_field_operands
1023 *
1024 * PARAMETERS: walk_state - Current walk
1025 * Op - A valid bank_field Op object
1026 *
1027 * RETURN: Status
1028 *
1029 * DESCRIPTION: Get bank_field bank_value
1030 * Called from acpi_ds_exec_end_op during bank_field parse tree walk
1031 *
1032 ******************************************************************************/
1033
1034acpi_status
1035acpi_ds_eval_bank_field_operands(struct acpi_walk_state *walk_state,
1036 union acpi_parse_object *op)
1037{
1038 acpi_status status;
1039 union acpi_operand_object *obj_desc;
1040 union acpi_operand_object *operand_desc;
1041 struct acpi_namespace_node *node;
1042 union acpi_parse_object *next_op;
1043 union acpi_parse_object *arg;
1044
1045 ACPI_FUNCTION_TRACE_PTR(ds_eval_bank_field_operands, op);
1046
1047 /*
1048 * This is where we evaluate the bank_value field of the
1049 * bank_field declaration
1050 */
1051
1052 /* next_op points to the op that holds the Region */
1053
1054 next_op = op->common.value.arg;
1055
1056 /* next_op points to the op that holds the Bank Register */
1057
1058 next_op = next_op->common.next;
1059
1060 /* next_op points to the op that holds the Bank Value */
1061
1062 next_op = next_op->common.next;
1063
1064 /*
1065 * Set proper index into operand stack for acpi_ds_obj_stack_push
1066 * invoked inside acpi_ds_create_operand.
1067 *
1068 * We use walk_state->Operands[0] to store the evaluated bank_value
1069 */
1070 walk_state->operand_index = 0;
1071
1072 status = acpi_ds_create_operand(walk_state, next_op, 0);
1073 if (ACPI_FAILURE(status)) {
1074 return_ACPI_STATUS(status);
1075 }
1076
1077 status = acpi_ex_resolve_to_value(&walk_state->operands[0], walk_state);
1078 if (ACPI_FAILURE(status)) {
1079 return_ACPI_STATUS(status);
1080 }
1081
Bob Moore71d993e2008-06-10 14:25:05 +08001082 ACPI_DUMP_OPERANDS(ACPI_WALK_OPERANDS,
1083 acpi_ps_get_opcode_name(op->common.aml_opcode), 1);
Lin Mingef805d92008-04-10 19:06:41 +04001084 /*
1085 * Get the bank_value operand and save it
1086 * (at Top of stack)
1087 */
1088 operand_desc = walk_state->operands[0];
1089
1090 /* Arg points to the start Bank Field */
1091
1092 arg = acpi_ps_get_arg(op, 4);
1093 while (arg) {
1094
1095 /* Ignore OFFSET and ACCESSAS terms here */
1096
1097 if (arg->common.aml_opcode == AML_INT_NAMEDFIELD_OP) {
1098 node = arg->common.node;
1099
1100 obj_desc = acpi_ns_get_attached_object(node);
1101 if (!obj_desc) {
1102 return_ACPI_STATUS(AE_NOT_EXIST);
1103 }
1104
1105 obj_desc->bank_field.value =
1106 (u32) operand_desc->integer.value;
1107 }
1108
1109 /* Move to next field in the list */
1110
1111 arg = arg->common.next;
1112 }
1113
1114 acpi_ut_remove_reference(operand_desc);
1115 return_ACPI_STATUS(status);
1116}
1117
1118/*******************************************************************************
1119 *
Linus Torvalds1da177e2005-04-16 15:20:36 -07001120 * FUNCTION: acpi_ds_exec_begin_control_op
1121 *
1122 * PARAMETERS: walk_list - The list that owns the walk stack
1123 * Op - The control Op
1124 *
1125 * RETURN: Status
1126 *
1127 * DESCRIPTION: Handles all control ops encountered during control method
1128 * execution.
1129 *
1130 ******************************************************************************/
1131
1132acpi_status
Len Brown4be44fc2005-08-05 00:44:28 -04001133acpi_ds_exec_begin_control_op(struct acpi_walk_state *walk_state,
1134 union acpi_parse_object *op)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001135{
Len Brown4be44fc2005-08-05 00:44:28 -04001136 acpi_status status = AE_OK;
1137 union acpi_generic_state *control_state;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001138
Bob Mooreb229cf92006-04-21 17:15:00 -04001139 ACPI_FUNCTION_NAME(ds_exec_begin_control_op);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001140
Len Brown4be44fc2005-08-05 00:44:28 -04001141 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, "Op=%p Opcode=%2.2X State=%p\n", op,
1142 op->common.aml_opcode, walk_state));
Linus Torvalds1da177e2005-04-16 15:20:36 -07001143
1144 switch (op->common.aml_opcode) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001145 case AML_WHILE_OP:
1146
1147 /*
Bob Moore96411a62008-11-12 15:02:00 +08001148 * If this is an additional iteration of a while loop, continue.
1149 * There is no need to allocate a new control state.
1150 */
1151 if (walk_state->control_state) {
1152 if (walk_state->control_state->control.aml_predicate_start
1153 == (walk_state->parser_state.aml - 1)) {
1154
1155 /* Reset the state to start-of-loop */
1156
1157 walk_state->control_state->common.state =
1158 ACPI_CONTROL_CONDITIONAL_EXECUTING;
1159 break;
1160 }
1161 }
1162
1163 /*lint -fallthrough */
1164
1165 case AML_IF_OP:
1166
1167 /*
Linus Torvalds1da177e2005-04-16 15:20:36 -07001168 * IF/WHILE: Create a new control state to manage these
1169 * constructs. We need to manage these as a stack, in order
1170 * to handle nesting.
1171 */
Len Brown4be44fc2005-08-05 00:44:28 -04001172 control_state = acpi_ut_create_control_state();
Linus Torvalds1da177e2005-04-16 15:20:36 -07001173 if (!control_state) {
1174 status = AE_NO_MEMORY;
1175 break;
1176 }
1177 /*
1178 * Save a pointer to the predicate for multiple executions
1179 * of a loop
1180 */
Len Brown4be44fc2005-08-05 00:44:28 -04001181 control_state->control.aml_predicate_start =
1182 walk_state->parser_state.aml - 1;
1183 control_state->control.package_end =
1184 walk_state->parser_state.pkg_end;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001185 control_state->control.opcode = op->common.aml_opcode;
1186
Linus Torvalds1da177e2005-04-16 15:20:36 -07001187 /* Push the control state on this walk's control stack */
1188
Len Brown4be44fc2005-08-05 00:44:28 -04001189 acpi_ut_push_generic_state(&walk_state->control_state,
1190 control_state);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001191 break;
1192
1193 case AML_ELSE_OP:
1194
1195 /* Predicate is in the state object */
1196 /* If predicate is true, the IF was executed, ignore ELSE part */
1197
1198 if (walk_state->last_predicate) {
1199 status = AE_CTRL_TRUE;
1200 }
1201
1202 break;
1203
1204 case AML_RETURN_OP:
1205
1206 break;
1207
1208 default:
1209 break;
1210 }
1211
1212 return (status);
1213}
1214
Linus Torvalds1da177e2005-04-16 15:20:36 -07001215/*******************************************************************************
1216 *
1217 * FUNCTION: acpi_ds_exec_end_control_op
1218 *
1219 * PARAMETERS: walk_list - The list that owns the walk stack
1220 * Op - The control Op
1221 *
1222 * RETURN: Status
1223 *
1224 * DESCRIPTION: Handles all control ops encountered during control method
1225 * execution.
1226 *
1227 ******************************************************************************/
1228
1229acpi_status
Len Brown4be44fc2005-08-05 00:44:28 -04001230acpi_ds_exec_end_control_op(struct acpi_walk_state * walk_state,
1231 union acpi_parse_object * op)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001232{
Len Brown4be44fc2005-08-05 00:44:28 -04001233 acpi_status status = AE_OK;
1234 union acpi_generic_state *control_state;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001235
Bob Mooreb229cf92006-04-21 17:15:00 -04001236 ACPI_FUNCTION_NAME(ds_exec_end_control_op);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001237
1238 switch (op->common.aml_opcode) {
1239 case AML_IF_OP:
1240
Len Brown4be44fc2005-08-05 00:44:28 -04001241 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, "[IF_OP] Op=%p\n", op));
Linus Torvalds1da177e2005-04-16 15:20:36 -07001242
1243 /*
1244 * Save the result of the predicate in case there is an
1245 * ELSE to come
1246 */
1247 walk_state->last_predicate =
Len Brown4be44fc2005-08-05 00:44:28 -04001248 (u8) walk_state->control_state->common.value;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001249
1250 /*
1251 * Pop the control state that was created at the start
1252 * of the IF and free it
1253 */
Len Brown4be44fc2005-08-05 00:44:28 -04001254 control_state =
1255 acpi_ut_pop_generic_state(&walk_state->control_state);
1256 acpi_ut_delete_generic_state(control_state);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001257 break;
1258
Linus Torvalds1da177e2005-04-16 15:20:36 -07001259 case AML_ELSE_OP:
1260
1261 break;
1262
Linus Torvalds1da177e2005-04-16 15:20:36 -07001263 case AML_WHILE_OP:
1264
Len Brown4be44fc2005-08-05 00:44:28 -04001265 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, "[WHILE_OP] Op=%p\n", op));
Linus Torvalds1da177e2005-04-16 15:20:36 -07001266
Bob Moorefc374452008-11-12 15:15:29 +08001267 control_state = walk_state->control_state;
1268 if (control_state->common.value) {
Bob Moore52fc0b02006-10-02 00:00:00 -04001269
Bob Moorefc374452008-11-12 15:15:29 +08001270 /* Predicate was true, the body of the loop was just executed */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001271
Bob Moorefc374452008-11-12 15:15:29 +08001272 /*
1273 * This loop counter mechanism allows the interpreter to escape
1274 * possibly infinite loops. This can occur in poorly written AML
1275 * when the hardware does not respond within a while loop and the
1276 * loop does not implement a timeout.
1277 */
1278 control_state->control.loop_count++;
1279 if (control_state->control.loop_count >
1280 ACPI_MAX_LOOP_ITERATIONS) {
1281 status = AE_AML_INFINITE_LOOP;
1282 break;
1283 }
1284
1285 /*
1286 * Go back and evaluate the predicate and maybe execute the loop
1287 * another time
1288 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001289 status = AE_CTRL_PENDING;
Bob Moore96411a62008-11-12 15:02:00 +08001290 walk_state->aml_last_while =
Bob Moorefc374452008-11-12 15:15:29 +08001291 control_state->control.aml_predicate_start;
Bob Moore96411a62008-11-12 15:02:00 +08001292 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001293 }
1294
Bob Moore96411a62008-11-12 15:02:00 +08001295 /* Predicate was false, terminate this while loop */
1296
Len Brown4be44fc2005-08-05 00:44:28 -04001297 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
1298 "[WHILE_OP] termination! Op=%p\n", op));
Linus Torvalds1da177e2005-04-16 15:20:36 -07001299
1300 /* Pop this control state and free it */
1301
Len Brown4be44fc2005-08-05 00:44:28 -04001302 control_state =
1303 acpi_ut_pop_generic_state(&walk_state->control_state);
Len Brown4be44fc2005-08-05 00:44:28 -04001304 acpi_ut_delete_generic_state(control_state);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001305 break;
1306
Linus Torvalds1da177e2005-04-16 15:20:36 -07001307 case AML_RETURN_OP:
1308
Len Brown4be44fc2005-08-05 00:44:28 -04001309 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
1310 "[RETURN_OP] Op=%p Arg=%p\n", op,
1311 op->common.value.arg));
Linus Torvalds1da177e2005-04-16 15:20:36 -07001312
1313 /*
1314 * One optional operand -- the return value
1315 * It can be either an immediate operand or a result that
1316 * has been bubbled up the tree
1317 */
1318 if (op->common.value.arg) {
Bob Moore52fc0b02006-10-02 00:00:00 -04001319
Linus Torvalds1da177e2005-04-16 15:20:36 -07001320 /* Since we have a real Return(), delete any implicit return */
1321
Len Brown4be44fc2005-08-05 00:44:28 -04001322 acpi_ds_clear_implicit_return(walk_state);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001323
1324 /* Return statement has an immediate operand */
1325
Len Brown4be44fc2005-08-05 00:44:28 -04001326 status =
1327 acpi_ds_create_operands(walk_state,
1328 op->common.value.arg);
1329 if (ACPI_FAILURE(status)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001330 return (status);
1331 }
1332
1333 /*
1334 * If value being returned is a Reference (such as
1335 * an arg or local), resolve it now because it may
1336 * cease to exist at the end of the method.
1337 */
Len Brown4be44fc2005-08-05 00:44:28 -04001338 status =
1339 acpi_ex_resolve_to_value(&walk_state->operands[0],
1340 walk_state);
1341 if (ACPI_FAILURE(status)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001342 return (status);
1343 }
1344
1345 /*
1346 * Get the return value and save as the last result
1347 * value. This is the only place where walk_state->return_desc
1348 * is set to anything other than zero!
1349 */
1350 walk_state->return_desc = walk_state->operands[0];
Bob Moore773069d2008-04-10 19:06:36 +04001351 } else if (walk_state->result_count) {
Bob Moore52fc0b02006-10-02 00:00:00 -04001352
Linus Torvalds1da177e2005-04-16 15:20:36 -07001353 /* Since we have a real Return(), delete any implicit return */
1354
Len Brown4be44fc2005-08-05 00:44:28 -04001355 acpi_ds_clear_implicit_return(walk_state);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001356
1357 /*
1358 * The return value has come from a previous calculation.
1359 *
1360 * If value being returned is a Reference (such as
1361 * an arg or local), resolve it now because it may
1362 * cease to exist at the end of the method.
1363 *
1364 * Allow references created by the Index operator to return unchanged.
1365 */
Len Brown4be44fc2005-08-05 00:44:28 -04001366 if ((ACPI_GET_DESCRIPTOR_TYPE
1367 (walk_state->results->results.obj_desc[0]) ==
1368 ACPI_DESC_TYPE_OPERAND)
Bob Moore3371c192009-02-18 14:44:03 +08001369 && ((walk_state->results->results.obj_desc[0])->
1370 common.type == ACPI_TYPE_LOCAL_REFERENCE)
Len Brown4be44fc2005-08-05 00:44:28 -04001371 && ((walk_state->results->results.obj_desc[0])->
Bob Moore1044f1f2008-09-27 11:08:41 +08001372 reference.class != ACPI_REFCLASS_INDEX)) {
Len Brown4be44fc2005-08-05 00:44:28 -04001373 status =
1374 acpi_ex_resolve_to_value(&walk_state->
1375 results->results.
1376 obj_desc[0],
1377 walk_state);
1378 if (ACPI_FAILURE(status)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001379 return (status);
1380 }
1381 }
1382
Len Brown4be44fc2005-08-05 00:44:28 -04001383 walk_state->return_desc =
1384 walk_state->results->results.obj_desc[0];
1385 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001386 /* No return operand */
1387
1388 if (walk_state->num_operands) {
Len Brown4be44fc2005-08-05 00:44:28 -04001389 acpi_ut_remove_reference(walk_state->
1390 operands[0]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001391 }
1392
Len Brown4be44fc2005-08-05 00:44:28 -04001393 walk_state->operands[0] = NULL;
1394 walk_state->num_operands = 0;
1395 walk_state->return_desc = NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001396 }
1397
Len Brown4be44fc2005-08-05 00:44:28 -04001398 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
Bob Mooreb229cf92006-04-21 17:15:00 -04001399 "Completed RETURN_OP State=%p, RetVal=%p\n",
Len Brown4be44fc2005-08-05 00:44:28 -04001400 walk_state, walk_state->return_desc));
Linus Torvalds1da177e2005-04-16 15:20:36 -07001401
1402 /* End the control method execution right now */
1403
1404 status = AE_CTRL_TERMINATE;
1405 break;
1406
Linus Torvalds1da177e2005-04-16 15:20:36 -07001407 case AML_NOOP_OP:
1408
1409 /* Just do nothing! */
1410 break;
1411
Linus Torvalds1da177e2005-04-16 15:20:36 -07001412 case AML_BREAK_POINT_OP:
1413
Bob Moore2b09ce92009-04-22 13:22:38 +08001414 /*
1415 * Set the single-step flag. This will cause the debugger (if present)
1416 * to break to the console within the AML debugger at the start of the
1417 * next AML instruction.
1418 */
1419 ACPI_DEBUGGER_EXEC(acpi_gbl_cm_single_step = TRUE);
1420 ACPI_DEBUGGER_EXEC(acpi_os_printf
1421 ("**break** Executed AML BreakPoint opcode\n"));
Linus Torvalds1da177e2005-04-16 15:20:36 -07001422
Bob Moore2b09ce92009-04-22 13:22:38 +08001423 /* Call to the OSL in case OS wants a piece of the action */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001424
Bob Moore2b09ce92009-04-22 13:22:38 +08001425 status = acpi_os_signal(ACPI_SIGNAL_BREAKPOINT,
1426 "Executed AML Breakpoint opcode");
Linus Torvalds1da177e2005-04-16 15:20:36 -07001427 break;
1428
Linus Torvalds1da177e2005-04-16 15:20:36 -07001429 case AML_BREAK_OP:
Len Brown4be44fc2005-08-05 00:44:28 -04001430 case AML_CONTINUE_OP: /* ACPI 2.0 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001431
1432 /* Pop and delete control states until we find a while */
1433
1434 while (walk_state->control_state &&
Len Brown4be44fc2005-08-05 00:44:28 -04001435 (walk_state->control_state->control.opcode !=
1436 AML_WHILE_OP)) {
1437 control_state =
1438 acpi_ut_pop_generic_state(&walk_state->
1439 control_state);
1440 acpi_ut_delete_generic_state(control_state);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001441 }
1442
1443 /* No while found? */
1444
1445 if (!walk_state->control_state) {
1446 return (AE_AML_NO_WHILE);
1447 }
1448
1449 /* Was: walk_state->aml_last_while = walk_state->control_state->Control.aml_predicate_start; */
1450
Len Brown4be44fc2005-08-05 00:44:28 -04001451 walk_state->aml_last_while =
1452 walk_state->control_state->control.package_end;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001453
1454 /* Return status depending on opcode */
1455
1456 if (op->common.aml_opcode == AML_BREAK_OP) {
1457 status = AE_CTRL_BREAK;
Len Brown4be44fc2005-08-05 00:44:28 -04001458 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001459 status = AE_CTRL_CONTINUE;
1460 }
1461 break;
1462
Linus Torvalds1da177e2005-04-16 15:20:36 -07001463 default:
1464
Bob Mooref6a22b02010-03-05 17:56:40 +08001465 ACPI_ERROR((AE_INFO, "Unknown control opcode=0x%X Op=%p",
Bob Mooreb8e4d892006-01-27 16:43:00 -05001466 op->common.aml_opcode, op));
Linus Torvalds1da177e2005-04-16 15:20:36 -07001467
1468 status = AE_AML_BAD_OPCODE;
1469 break;
1470 }
1471
1472 return (status);
1473}