aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/dispatcher/dsopcode.c
diff options
context:
space:
mode:
authorLen Brown <len.brown@intel.com>2005-08-05 00:44:28 -0400
committerLen Brown <len.brown@intel.com>2005-08-05 00:45:14 -0400
commit4be44fcd3bf648b782f4460fd06dfae6c42ded4b (patch)
tree5b5b7d296ea58786f53b95e5eac9565ff66890b0 /drivers/acpi/dispatcher/dsopcode.c
parentc65ade4dc8b486e8c8b9b0a6399789a5428e2039 (diff)
[ACPI] Lindent all ACPI files
Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'drivers/acpi/dispatcher/dsopcode.c')
-rw-r--r--drivers/acpi/dispatcher/dsopcode.c710
1 files changed, 344 insertions, 366 deletions
diff --git a/drivers/acpi/dispatcher/dsopcode.c b/drivers/acpi/dispatcher/dsopcode.c
index 750bdb1ac344..939d167bf87b 100644
--- a/drivers/acpi/dispatcher/dsopcode.c
+++ b/drivers/acpi/dispatcher/dsopcode.c
@@ -42,7 +42,6 @@
42 * POSSIBILITY OF SUCH DAMAGES. 42 * POSSIBILITY OF SUCH DAMAGES.
43 */ 43 */
44 44
45
46#include <acpi/acpi.h> 45#include <acpi/acpi.h>
47#include <acpi/acparser.h> 46#include <acpi/acparser.h>
48#include <acpi/amlcode.h> 47#include <acpi/amlcode.h>
@@ -52,26 +51,21 @@
52#include <acpi/acevents.h> 51#include <acpi/acevents.h>
53 52
54#define _COMPONENT ACPI_DISPATCHER 53#define _COMPONENT ACPI_DISPATCHER
55 ACPI_MODULE_NAME ("dsopcode") 54ACPI_MODULE_NAME("dsopcode")
56 55
57/* Local prototypes */ 56/* Local prototypes */
58
59static acpi_status 57static acpi_status
60acpi_ds_execute_arguments ( 58acpi_ds_execute_arguments(struct acpi_namespace_node *node,
61 struct acpi_namespace_node *node, 59 struct acpi_namespace_node *scope_node,
62 struct acpi_namespace_node *scope_node, 60 u32 aml_length, u8 * aml_start);
63 u32 aml_length,
64 u8 *aml_start);
65 61
66static acpi_status 62static acpi_status
67acpi_ds_init_buffer_field ( 63acpi_ds_init_buffer_field(u16 aml_opcode,
68 u16 aml_opcode, 64 union acpi_operand_object *obj_desc,
69 union acpi_operand_object *obj_desc, 65 union acpi_operand_object *buffer_desc,
70 union acpi_operand_object *buffer_desc, 66 union acpi_operand_object *offset_desc,
71 union acpi_operand_object *offset_desc, 67 union acpi_operand_object *length_desc,
72 union acpi_operand_object *length_desc, 68 union acpi_operand_object *result_desc);
73 union acpi_operand_object *result_desc);
74
75 69
76/******************************************************************************* 70/*******************************************************************************
77 * 71 *
@@ -89,26 +83,22 @@ acpi_ds_init_buffer_field (
89 ******************************************************************************/ 83 ******************************************************************************/
90 84
91static acpi_status 85static acpi_status
92acpi_ds_execute_arguments ( 86acpi_ds_execute_arguments(struct acpi_namespace_node *node,
93 struct acpi_namespace_node *node, 87 struct acpi_namespace_node *scope_node,
94 struct acpi_namespace_node *scope_node, 88 u32 aml_length, u8 * aml_start)
95 u32 aml_length,
96 u8 *aml_start)
97{ 89{
98 acpi_status status; 90 acpi_status status;
99 union acpi_parse_object *op; 91 union acpi_parse_object *op;
100 struct acpi_walk_state *walk_state; 92 struct acpi_walk_state *walk_state;
101
102
103 ACPI_FUNCTION_TRACE ("ds_execute_arguments");
104 93
94 ACPI_FUNCTION_TRACE("ds_execute_arguments");
105 95
106 /* 96 /*
107 * Allocate a new parser op to be the root of the parsed tree 97 * Allocate a new parser op to be the root of the parsed tree
108 */ 98 */
109 op = acpi_ps_alloc_op (AML_INT_EVAL_SUBTREE_OP); 99 op = acpi_ps_alloc_op(AML_INT_EVAL_SUBTREE_OP);
110 if (!op) { 100 if (!op) {
111 return_ACPI_STATUS (AE_NO_MEMORY); 101 return_ACPI_STATUS(AE_NO_MEMORY);
112 } 102 }
113 103
114 /* Save the Node for use in acpi_ps_parse_aml */ 104 /* Save the Node for use in acpi_ps_parse_aml */
@@ -117,16 +107,16 @@ acpi_ds_execute_arguments (
117 107
118 /* Create and initialize a new parser state */ 108 /* Create and initialize a new parser state */
119 109
120 walk_state = acpi_ds_create_walk_state (0, NULL, NULL, NULL); 110 walk_state = acpi_ds_create_walk_state(0, NULL, NULL, NULL);
121 if (!walk_state) { 111 if (!walk_state) {
122 status = AE_NO_MEMORY; 112 status = AE_NO_MEMORY;
123 goto cleanup; 113 goto cleanup;
124 } 114 }
125 115
126 status = acpi_ds_init_aml_walk (walk_state, op, NULL, aml_start, 116 status = acpi_ds_init_aml_walk(walk_state, op, NULL, aml_start,
127 aml_length, NULL, 1); 117 aml_length, NULL, 1);
128 if (ACPI_FAILURE (status)) { 118 if (ACPI_FAILURE(status)) {
129 acpi_ds_delete_walk_state (walk_state); 119 acpi_ds_delete_walk_state(walk_state);
130 goto cleanup; 120 goto cleanup;
131 } 121 }
132 122
@@ -137,28 +127,28 @@ acpi_ds_execute_arguments (
137 127
138 /* Pass1: Parse the entire declaration */ 128 /* Pass1: Parse the entire declaration */
139 129
140 status = acpi_ps_parse_aml (walk_state); 130 status = acpi_ps_parse_aml(walk_state);
141 if (ACPI_FAILURE (status)) { 131 if (ACPI_FAILURE(status)) {
142 goto cleanup; 132 goto cleanup;
143 } 133 }
144 134
145 /* Get and init the Op created above */ 135 /* Get and init the Op created above */
146 136
147 op->common.node = node; 137 op->common.node = node;
148 acpi_ps_delete_parse_tree (op); 138 acpi_ps_delete_parse_tree(op);
149 139
150 /* Evaluate the deferred arguments */ 140 /* Evaluate the deferred arguments */
151 141
152 op = acpi_ps_alloc_op (AML_INT_EVAL_SUBTREE_OP); 142 op = acpi_ps_alloc_op(AML_INT_EVAL_SUBTREE_OP);
153 if (!op) { 143 if (!op) {
154 return_ACPI_STATUS (AE_NO_MEMORY); 144 return_ACPI_STATUS(AE_NO_MEMORY);
155 } 145 }
156 146
157 op->common.node = scope_node; 147 op->common.node = scope_node;
158 148
159 /* Create and initialize a new parser state */ 149 /* Create and initialize a new parser state */
160 150
161 walk_state = acpi_ds_create_walk_state (0, NULL, NULL, NULL); 151 walk_state = acpi_ds_create_walk_state(0, NULL, NULL, NULL);
162 if (!walk_state) { 152 if (!walk_state) {
163 status = AE_NO_MEMORY; 153 status = AE_NO_MEMORY;
164 goto cleanup; 154 goto cleanup;
@@ -166,24 +156,23 @@ acpi_ds_execute_arguments (
166 156
167 /* Execute the opcode and arguments */ 157 /* Execute the opcode and arguments */
168 158
169 status = acpi_ds_init_aml_walk (walk_state, op, NULL, aml_start, 159 status = acpi_ds_init_aml_walk(walk_state, op, NULL, aml_start,
170 aml_length, NULL, 3); 160 aml_length, NULL, 3);
171 if (ACPI_FAILURE (status)) { 161 if (ACPI_FAILURE(status)) {
172 acpi_ds_delete_walk_state (walk_state); 162 acpi_ds_delete_walk_state(walk_state);
173 goto cleanup; 163 goto cleanup;
174 } 164 }
175 165
176 /* Mark this execution as a deferred opcode */ 166 /* Mark this execution as a deferred opcode */
177 167
178 walk_state->deferred_node = node; 168 walk_state->deferred_node = node;
179 status = acpi_ps_parse_aml (walk_state); 169 status = acpi_ps_parse_aml(walk_state);
180 170
181cleanup: 171 cleanup:
182 acpi_ps_delete_parse_tree (op); 172 acpi_ps_delete_parse_tree(op);
183 return_ACPI_STATUS (status); 173 return_ACPI_STATUS(status);
184} 174}
185 175
186
187/******************************************************************************* 176/*******************************************************************************
188 * 177 *
189 * FUNCTION: acpi_ds_get_buffer_field_arguments 178 * FUNCTION: acpi_ds_get_buffer_field_arguments
@@ -198,38 +187,36 @@ cleanup:
198 ******************************************************************************/ 187 ******************************************************************************/
199 188
200acpi_status 189acpi_status
201acpi_ds_get_buffer_field_arguments ( 190acpi_ds_get_buffer_field_arguments(union acpi_operand_object *obj_desc)
202 union acpi_operand_object *obj_desc)
203{ 191{
204 union acpi_operand_object *extra_desc; 192 union acpi_operand_object *extra_desc;
205 struct acpi_namespace_node *node; 193 struct acpi_namespace_node *node;
206 acpi_status status; 194 acpi_status status;
207
208
209 ACPI_FUNCTION_TRACE_PTR ("ds_get_buffer_field_arguments", obj_desc);
210 195
196 ACPI_FUNCTION_TRACE_PTR("ds_get_buffer_field_arguments", obj_desc);
211 197
212 if (obj_desc->common.flags & AOPOBJ_DATA_VALID) { 198 if (obj_desc->common.flags & AOPOBJ_DATA_VALID) {
213 return_ACPI_STATUS (AE_OK); 199 return_ACPI_STATUS(AE_OK);
214 } 200 }
215 201
216 /* Get the AML pointer (method object) and buffer_field node */ 202 /* Get the AML pointer (method object) and buffer_field node */
217 203
218 extra_desc = acpi_ns_get_secondary_object (obj_desc); 204 extra_desc = acpi_ns_get_secondary_object(obj_desc);
219 node = obj_desc->buffer_field.node; 205 node = obj_desc->buffer_field.node;
220 206
221 ACPI_DEBUG_EXEC(acpi_ut_display_init_pathname (ACPI_TYPE_BUFFER_FIELD, node, NULL)); 207 ACPI_DEBUG_EXEC(acpi_ut_display_init_pathname
222 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[%4.4s] buffer_field Arg Init\n", 208 (ACPI_TYPE_BUFFER_FIELD, node, NULL));
223 acpi_ut_get_node_name (node))); 209 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "[%4.4s] buffer_field Arg Init\n",
210 acpi_ut_get_node_name(node)));
224 211
225 /* Execute the AML code for the term_arg arguments */ 212 /* Execute the AML code for the term_arg arguments */
226 213
227 status = acpi_ds_execute_arguments (node, acpi_ns_get_parent_node (node), 214 status = acpi_ds_execute_arguments(node, acpi_ns_get_parent_node(node),
228 extra_desc->extra.aml_length, extra_desc->extra.aml_start); 215 extra_desc->extra.aml_length,
229 return_ACPI_STATUS (status); 216 extra_desc->extra.aml_start);
217 return_ACPI_STATUS(status);
230} 218}
231 219
232
233/******************************************************************************* 220/*******************************************************************************
234 * 221 *
235 * FUNCTION: acpi_ds_get_buffer_arguments 222 * FUNCTION: acpi_ds_get_buffer_arguments
@@ -243,40 +230,35 @@ acpi_ds_get_buffer_field_arguments (
243 * 230 *
244 ******************************************************************************/ 231 ******************************************************************************/
245 232
246acpi_status 233acpi_status acpi_ds_get_buffer_arguments(union acpi_operand_object *obj_desc)
247acpi_ds_get_buffer_arguments (
248 union acpi_operand_object *obj_desc)
249{ 234{
250 struct acpi_namespace_node *node; 235 struct acpi_namespace_node *node;
251 acpi_status status; 236 acpi_status status;
252
253
254 ACPI_FUNCTION_TRACE_PTR ("ds_get_buffer_arguments", obj_desc);
255 237
238 ACPI_FUNCTION_TRACE_PTR("ds_get_buffer_arguments", obj_desc);
256 239
257 if (obj_desc->common.flags & AOPOBJ_DATA_VALID) { 240 if (obj_desc->common.flags & AOPOBJ_DATA_VALID) {
258 return_ACPI_STATUS (AE_OK); 241 return_ACPI_STATUS(AE_OK);
259 } 242 }
260 243
261 /* Get the Buffer node */ 244 /* Get the Buffer node */
262 245
263 node = obj_desc->buffer.node; 246 node = obj_desc->buffer.node;
264 if (!node) { 247 if (!node) {
265 ACPI_REPORT_ERROR (( 248 ACPI_REPORT_ERROR(("No pointer back to NS node in buffer obj %p\n", obj_desc));
266 "No pointer back to NS node in buffer obj %p\n", obj_desc)); 249 return_ACPI_STATUS(AE_AML_INTERNAL);
267 return_ACPI_STATUS (AE_AML_INTERNAL);
268 } 250 }
269 251
270 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Buffer Arg Init\n")); 252 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Buffer Arg Init\n"));
271 253
272 /* Execute the AML code for the term_arg arguments */ 254 /* Execute the AML code for the term_arg arguments */
273 255
274 status = acpi_ds_execute_arguments (node, node, 256 status = acpi_ds_execute_arguments(node, node,
275 obj_desc->buffer.aml_length, obj_desc->buffer.aml_start); 257 obj_desc->buffer.aml_length,
276 return_ACPI_STATUS (status); 258 obj_desc->buffer.aml_start);
259 return_ACPI_STATUS(status);
277} 260}
278 261
279
280/******************************************************************************* 262/*******************************************************************************
281 * 263 *
282 * FUNCTION: acpi_ds_get_package_arguments 264 * FUNCTION: acpi_ds_get_package_arguments
@@ -290,40 +272,36 @@ acpi_ds_get_buffer_arguments (
290 * 272 *
291 ******************************************************************************/ 273 ******************************************************************************/
292 274
293acpi_status 275acpi_status acpi_ds_get_package_arguments(union acpi_operand_object *obj_desc)
294acpi_ds_get_package_arguments (
295 union acpi_operand_object *obj_desc)
296{ 276{
297 struct acpi_namespace_node *node; 277 struct acpi_namespace_node *node;
298 acpi_status status; 278 acpi_status status;
299
300
301 ACPI_FUNCTION_TRACE_PTR ("ds_get_package_arguments", obj_desc);
302 279
280 ACPI_FUNCTION_TRACE_PTR("ds_get_package_arguments", obj_desc);
303 281
304 if (obj_desc->common.flags & AOPOBJ_DATA_VALID) { 282 if (obj_desc->common.flags & AOPOBJ_DATA_VALID) {
305 return_ACPI_STATUS (AE_OK); 283 return_ACPI_STATUS(AE_OK);
306 } 284 }
307 285
308 /* Get the Package node */ 286 /* Get the Package node */
309 287
310 node = obj_desc->package.node; 288 node = obj_desc->package.node;
311 if (!node) { 289 if (!node) {
312 ACPI_REPORT_ERROR (( 290 ACPI_REPORT_ERROR(("No pointer back to NS node in package %p\n",
313 "No pointer back to NS node in package %p\n", obj_desc)); 291 obj_desc));
314 return_ACPI_STATUS (AE_AML_INTERNAL); 292 return_ACPI_STATUS(AE_AML_INTERNAL);
315 } 293 }
316 294
317 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Package Arg Init\n")); 295 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Package Arg Init\n"));
318 296
319 /* Execute the AML code for the term_arg arguments */ 297 /* Execute the AML code for the term_arg arguments */
320 298
321 status = acpi_ds_execute_arguments (node, node, 299 status = acpi_ds_execute_arguments(node, node,
322 obj_desc->package.aml_length, obj_desc->package.aml_start); 300 obj_desc->package.aml_length,
323 return_ACPI_STATUS (status); 301 obj_desc->package.aml_start);
302 return_ACPI_STATUS(status);
324} 303}
325 304
326
327/***************************************************************************** 305/*****************************************************************************
328 * 306 *
329 * FUNCTION: acpi_ds_get_region_arguments 307 * FUNCTION: acpi_ds_get_region_arguments
@@ -337,44 +315,43 @@ acpi_ds_get_package_arguments (
337 * 315 *
338 ****************************************************************************/ 316 ****************************************************************************/
339 317
340acpi_status 318acpi_status acpi_ds_get_region_arguments(union acpi_operand_object *obj_desc)
341acpi_ds_get_region_arguments (
342 union acpi_operand_object *obj_desc)
343{ 319{
344 struct acpi_namespace_node *node; 320 struct acpi_namespace_node *node;
345 acpi_status status; 321 acpi_status status;
346 union acpi_operand_object *extra_desc; 322 union acpi_operand_object *extra_desc;
347
348
349 ACPI_FUNCTION_TRACE_PTR ("ds_get_region_arguments", obj_desc);
350 323
324 ACPI_FUNCTION_TRACE_PTR("ds_get_region_arguments", obj_desc);
351 325
352 if (obj_desc->region.flags & AOPOBJ_DATA_VALID) { 326 if (obj_desc->region.flags & AOPOBJ_DATA_VALID) {
353 return_ACPI_STATUS (AE_OK); 327 return_ACPI_STATUS(AE_OK);
354 } 328 }
355 329
356 extra_desc = acpi_ns_get_secondary_object (obj_desc); 330 extra_desc = acpi_ns_get_secondary_object(obj_desc);
357 if (!extra_desc) { 331 if (!extra_desc) {
358 return_ACPI_STATUS (AE_NOT_EXIST); 332 return_ACPI_STATUS(AE_NOT_EXIST);
359 } 333 }
360 334
361 /* Get the Region node */ 335 /* Get the Region node */
362 336
363 node = obj_desc->region.node; 337 node = obj_desc->region.node;
364 338
365 ACPI_DEBUG_EXEC (acpi_ut_display_init_pathname (ACPI_TYPE_REGION, node, NULL)); 339 ACPI_DEBUG_EXEC(acpi_ut_display_init_pathname
340 (ACPI_TYPE_REGION, node, NULL));
366 341
367 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[%4.4s] op_region Arg Init at AML %p\n", 342 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
368 acpi_ut_get_node_name (node), extra_desc->extra.aml_start)); 343 "[%4.4s] op_region Arg Init at AML %p\n",
344 acpi_ut_get_node_name(node),
345 extra_desc->extra.aml_start));
369 346
370 /* Execute the argument AML */ 347 /* Execute the argument AML */
371 348
372 status = acpi_ds_execute_arguments (node, acpi_ns_get_parent_node (node), 349 status = acpi_ds_execute_arguments(node, acpi_ns_get_parent_node(node),
373 extra_desc->extra.aml_length, extra_desc->extra.aml_start); 350 extra_desc->extra.aml_length,
374 return_ACPI_STATUS (status); 351 extra_desc->extra.aml_start);
352 return_ACPI_STATUS(status);
375} 353}
376 354
377
378/******************************************************************************* 355/*******************************************************************************
379 * 356 *
380 * FUNCTION: acpi_ds_initialize_region 357 * FUNCTION: acpi_ds_initialize_region
@@ -387,23 +364,19 @@ acpi_ds_get_region_arguments (
387 * 364 *
388 ******************************************************************************/ 365 ******************************************************************************/
389 366
390acpi_status 367acpi_status acpi_ds_initialize_region(acpi_handle obj_handle)
391acpi_ds_initialize_region (
392 acpi_handle obj_handle)
393{ 368{
394 union acpi_operand_object *obj_desc; 369 union acpi_operand_object *obj_desc;
395 acpi_status status; 370 acpi_status status;
396 371
397 372 obj_desc = acpi_ns_get_attached_object(obj_handle);
398 obj_desc = acpi_ns_get_attached_object (obj_handle);
399 373
400 /* Namespace is NOT locked */ 374 /* Namespace is NOT locked */
401 375
402 status = acpi_ev_initialize_region (obj_desc, FALSE); 376 status = acpi_ev_initialize_region(obj_desc, FALSE);
403 return (status); 377 return (status);
404} 378}
405 379
406
407/******************************************************************************* 380/*******************************************************************************
408 * 381 *
409 * FUNCTION: acpi_ds_init_buffer_field 382 * FUNCTION: acpi_ds_init_buffer_field
@@ -422,30 +395,27 @@ acpi_ds_initialize_region (
422 ******************************************************************************/ 395 ******************************************************************************/
423 396
424static acpi_status 397static acpi_status
425acpi_ds_init_buffer_field ( 398acpi_ds_init_buffer_field(u16 aml_opcode,
426 u16 aml_opcode, 399 union acpi_operand_object *obj_desc,
427 union acpi_operand_object *obj_desc, 400 union acpi_operand_object *buffer_desc,
428 union acpi_operand_object *buffer_desc, 401 union acpi_operand_object *offset_desc,
429 union acpi_operand_object *offset_desc, 402 union acpi_operand_object *length_desc,
430 union acpi_operand_object *length_desc, 403 union acpi_operand_object *result_desc)
431 union acpi_operand_object *result_desc)
432{ 404{
433 u32 offset; 405 u32 offset;
434 u32 bit_offset; 406 u32 bit_offset;
435 u32 bit_count; 407 u32 bit_count;
436 u8 field_flags; 408 u8 field_flags;
437 acpi_status status; 409 acpi_status status;
438
439
440 ACPI_FUNCTION_TRACE_PTR ("ds_init_buffer_field", obj_desc);
441 410
411 ACPI_FUNCTION_TRACE_PTR("ds_init_buffer_field", obj_desc);
442 412
443 /* Host object must be a Buffer */ 413 /* Host object must be a Buffer */
444 414
445 if (ACPI_GET_OBJECT_TYPE (buffer_desc) != ACPI_TYPE_BUFFER) { 415 if (ACPI_GET_OBJECT_TYPE(buffer_desc) != ACPI_TYPE_BUFFER) {
446 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 416 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
447 "Target of Create Field is not a Buffer object - %s\n", 417 "Target of Create Field is not a Buffer object - %s\n",
448 acpi_ut_get_object_type_name (buffer_desc))); 418 acpi_ut_get_object_type_name(buffer_desc)));
449 419
450 status = AE_AML_OPERAND_TYPE; 420 status = AE_AML_OPERAND_TYPE;
451 goto cleanup; 421 goto cleanup;
@@ -456,11 +426,11 @@ acpi_ds_init_buffer_field (
456 * out as a name_string, and should therefore now be a NS node 426 * out as a name_string, and should therefore now be a NS node
457 * after resolution in acpi_ex_resolve_operands(). 427 * after resolution in acpi_ex_resolve_operands().
458 */ 428 */
459 if (ACPI_GET_DESCRIPTOR_TYPE (result_desc) != ACPI_DESC_TYPE_NAMED) { 429 if (ACPI_GET_DESCRIPTOR_TYPE(result_desc) != ACPI_DESC_TYPE_NAMED) {
460 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 430 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
461 "(%s) destination not a NS Node [%s]\n", 431 "(%s) destination not a NS Node [%s]\n",
462 acpi_ps_get_opcode_name (aml_opcode), 432 acpi_ps_get_opcode_name(aml_opcode),
463 acpi_ut_get_descriptor_name (result_desc))); 433 acpi_ut_get_descriptor_name(result_desc)));
464 434
465 status = AE_AML_OPERAND_TYPE; 435 status = AE_AML_OPERAND_TYPE;
466 goto cleanup; 436 goto cleanup;
@@ -478,13 +448,13 @@ acpi_ds_init_buffer_field (
478 448
479 field_flags = AML_FIELD_ACCESS_BYTE; 449 field_flags = AML_FIELD_ACCESS_BYTE;
480 bit_offset = offset; 450 bit_offset = offset;
481 bit_count = (u32) length_desc->integer.value; 451 bit_count = (u32) length_desc->integer.value;
482 452
483 /* Must have a valid (>0) bit count */ 453 /* Must have a valid (>0) bit count */
484 454
485 if (bit_count == 0) { 455 if (bit_count == 0) {
486 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 456 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
487 "Attempt to create_field of length 0\n")); 457 "Attempt to create_field of length 0\n"));
488 status = AE_AML_OPERAND_VALUE; 458 status = AE_AML_OPERAND_VALUE;
489 goto cleanup; 459 goto cleanup;
490 } 460 }
@@ -495,7 +465,7 @@ acpi_ds_init_buffer_field (
495 /* Offset is in bits, Field is one bit */ 465 /* Offset is in bits, Field is one bit */
496 466
497 bit_offset = offset; 467 bit_offset = offset;
498 bit_count = 1; 468 bit_count = 1;
499 field_flags = AML_FIELD_ACCESS_BYTE; 469 field_flags = AML_FIELD_ACCESS_BYTE;
500 break; 470 break;
501 471
@@ -504,7 +474,7 @@ acpi_ds_init_buffer_field (
504 /* Offset is in bytes, field is one byte */ 474 /* Offset is in bytes, field is one byte */
505 475
506 bit_offset = 8 * offset; 476 bit_offset = 8 * offset;
507 bit_count = 8; 477 bit_count = 8;
508 field_flags = AML_FIELD_ACCESS_BYTE; 478 field_flags = AML_FIELD_ACCESS_BYTE;
509 break; 479 break;
510 480
@@ -513,7 +483,7 @@ acpi_ds_init_buffer_field (
513 /* Offset is in bytes, field is one word */ 483 /* Offset is in bytes, field is one word */
514 484
515 bit_offset = 8 * offset; 485 bit_offset = 8 * offset;
516 bit_count = 16; 486 bit_count = 16;
517 field_flags = AML_FIELD_ACCESS_WORD; 487 field_flags = AML_FIELD_ACCESS_WORD;
518 break; 488 break;
519 489
@@ -522,7 +492,7 @@ acpi_ds_init_buffer_field (
522 /* Offset is in bytes, field is one dword */ 492 /* Offset is in bytes, field is one dword */
523 493
524 bit_offset = 8 * offset; 494 bit_offset = 8 * offset;
525 bit_count = 32; 495 bit_count = 32;
526 field_flags = AML_FIELD_ACCESS_DWORD; 496 field_flags = AML_FIELD_ACCESS_DWORD;
527 break; 497 break;
528 498
@@ -531,29 +501,29 @@ acpi_ds_init_buffer_field (
531 /* Offset is in bytes, field is one qword */ 501 /* Offset is in bytes, field is one qword */
532 502
533 bit_offset = 8 * offset; 503 bit_offset = 8 * offset;
534 bit_count = 64; 504 bit_count = 64;
535 field_flags = AML_FIELD_ACCESS_QWORD; 505 field_flags = AML_FIELD_ACCESS_QWORD;
536 break; 506 break;
537 507
538 default: 508 default:
539 509
540 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 510 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
541 "Unknown field creation opcode %02x\n", 511 "Unknown field creation opcode %02x\n",
542 aml_opcode)); 512 aml_opcode));
543 status = AE_AML_BAD_OPCODE; 513 status = AE_AML_BAD_OPCODE;
544 goto cleanup; 514 goto cleanup;
545 } 515 }
546 516
547 /* Entire field must fit within the current length of the buffer */ 517 /* Entire field must fit within the current length of the buffer */
548 518
549 if ((bit_offset + bit_count) > 519 if ((bit_offset + bit_count) > (8 * (u32) buffer_desc->buffer.length)) {
550 (8 * (u32) buffer_desc->buffer.length)) { 520 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
551 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 521 "Field [%4.4s] size %d exceeds Buffer [%4.4s] size %d (bits)\n",
552 "Field [%4.4s] size %d exceeds Buffer [%4.4s] size %d (bits)\n", 522 acpi_ut_get_node_name(result_desc),
553 acpi_ut_get_node_name (result_desc), 523 bit_offset + bit_count,
554 bit_offset + bit_count, 524 acpi_ut_get_node_name(buffer_desc->buffer.
555 acpi_ut_get_node_name (buffer_desc->buffer.node), 525 node),
556 8 * (u32) buffer_desc->buffer.length)); 526 8 * (u32) buffer_desc->buffer.length));
557 status = AE_AML_BUFFER_LIMIT; 527 status = AE_AML_BUFFER_LIMIT;
558 goto cleanup; 528 goto cleanup;
559 } 529 }
@@ -563,9 +533,9 @@ acpi_ds_init_buffer_field (
563 * For field_flags, use LOCK_RULE = 0 (NO_LOCK), 533 * For field_flags, use LOCK_RULE = 0 (NO_LOCK),
564 * UPDATE_RULE = 0 (UPDATE_PRESERVE) 534 * UPDATE_RULE = 0 (UPDATE_PRESERVE)
565 */ 535 */
566 status = acpi_ex_prep_common_field_object (obj_desc, field_flags, 0, 536 status = acpi_ex_prep_common_field_object(obj_desc, field_flags, 0,
567 bit_offset, bit_count); 537 bit_offset, bit_count);
568 if (ACPI_FAILURE (status)) { 538 if (ACPI_FAILURE(status)) {
569 goto cleanup; 539 goto cleanup;
570 } 540 }
571 541
@@ -574,35 +544,33 @@ acpi_ds_init_buffer_field (
574 /* Reference count for buffer_desc inherits obj_desc count */ 544 /* Reference count for buffer_desc inherits obj_desc count */
575 545
576 buffer_desc->common.reference_count = (u16) 546 buffer_desc->common.reference_count = (u16)
577 (buffer_desc->common.reference_count + obj_desc->common.reference_count); 547 (buffer_desc->common.reference_count +
548 obj_desc->common.reference_count);
578 549
579 550 cleanup:
580cleanup:
581 551
582 /* Always delete the operands */ 552 /* Always delete the operands */
583 553
584 acpi_ut_remove_reference (offset_desc); 554 acpi_ut_remove_reference(offset_desc);
585 acpi_ut_remove_reference (buffer_desc); 555 acpi_ut_remove_reference(buffer_desc);
586 556
587 if (aml_opcode == AML_CREATE_FIELD_OP) { 557 if (aml_opcode == AML_CREATE_FIELD_OP) {
588 acpi_ut_remove_reference (length_desc); 558 acpi_ut_remove_reference(length_desc);
589 } 559 }
590 560
591 /* On failure, delete the result descriptor */ 561 /* On failure, delete the result descriptor */
592 562
593 if (ACPI_FAILURE (status)) { 563 if (ACPI_FAILURE(status)) {
594 acpi_ut_remove_reference (result_desc); /* Result descriptor */ 564 acpi_ut_remove_reference(result_desc); /* Result descriptor */
595 } 565 } else {
596 else {
597 /* Now the address and length are valid for this buffer_field */ 566 /* Now the address and length are valid for this buffer_field */
598 567
599 obj_desc->buffer_field.flags |= AOPOBJ_DATA_VALID; 568 obj_desc->buffer_field.flags |= AOPOBJ_DATA_VALID;
600 } 569 }
601 570
602 return_ACPI_STATUS (status); 571 return_ACPI_STATUS(status);
603} 572}
604 573
605
606/******************************************************************************* 574/*******************************************************************************
607 * 575 *
608 * FUNCTION: acpi_ds_eval_buffer_field_operands 576 * FUNCTION: acpi_ds_eval_buffer_field_operands
@@ -618,24 +586,21 @@ cleanup:
618 ******************************************************************************/ 586 ******************************************************************************/
619 587
620acpi_status 588acpi_status
621acpi_ds_eval_buffer_field_operands ( 589acpi_ds_eval_buffer_field_operands(struct acpi_walk_state *walk_state,
622 struct acpi_walk_state *walk_state, 590 union acpi_parse_object *op)
623 union acpi_parse_object *op)
624{ 591{
625 acpi_status status; 592 acpi_status status;
626 union acpi_operand_object *obj_desc; 593 union acpi_operand_object *obj_desc;
627 struct acpi_namespace_node *node; 594 struct acpi_namespace_node *node;
628 union acpi_parse_object *next_op; 595 union acpi_parse_object *next_op;
629
630
631 ACPI_FUNCTION_TRACE_PTR ("ds_eval_buffer_field_operands", op);
632 596
597 ACPI_FUNCTION_TRACE_PTR("ds_eval_buffer_field_operands", op);
633 598
634 /* 599 /*
635 * This is where we evaluate the address and length fields of the 600 * This is where we evaluate the address and length fields of the
636 * create_xxx_field declaration 601 * create_xxx_field declaration
637 */ 602 */
638 node = op->common.node; 603 node = op->common.node;
639 604
640 /* next_op points to the op that holds the Buffer */ 605 /* next_op points to the op that holds the Buffer */
641 606
@@ -643,30 +608,32 @@ acpi_ds_eval_buffer_field_operands (
643 608
644 /* Evaluate/create the address and length operands */ 609 /* Evaluate/create the address and length operands */
645 610
646 status = acpi_ds_create_operands (walk_state, next_op); 611 status = acpi_ds_create_operands(walk_state, next_op);
647 if (ACPI_FAILURE (status)) { 612 if (ACPI_FAILURE(status)) {
648 return_ACPI_STATUS (status); 613 return_ACPI_STATUS(status);
649 } 614 }
650 615
651 obj_desc = acpi_ns_get_attached_object (node); 616 obj_desc = acpi_ns_get_attached_object(node);
652 if (!obj_desc) { 617 if (!obj_desc) {
653 return_ACPI_STATUS (AE_NOT_EXIST); 618 return_ACPI_STATUS(AE_NOT_EXIST);
654 } 619 }
655 620
656 /* Resolve the operands */ 621 /* Resolve the operands */
657 622
658 status = acpi_ex_resolve_operands (op->common.aml_opcode, 623 status = acpi_ex_resolve_operands(op->common.aml_opcode,
659 ACPI_WALK_OPERANDS, walk_state); 624 ACPI_WALK_OPERANDS, walk_state);
660 625
661 ACPI_DUMP_OPERANDS (ACPI_WALK_OPERANDS, ACPI_IMODE_EXECUTE, 626 ACPI_DUMP_OPERANDS(ACPI_WALK_OPERANDS, ACPI_IMODE_EXECUTE,
662 acpi_ps_get_opcode_name (op->common.aml_opcode), 627 acpi_ps_get_opcode_name(op->common.aml_opcode),
663 walk_state->num_operands, "after acpi_ex_resolve_operands"); 628 walk_state->num_operands,
629 "after acpi_ex_resolve_operands");
664 630
665 if (ACPI_FAILURE (status)) { 631 if (ACPI_FAILURE(status)) {
666 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "(%s) bad operand(s) (%X)\n", 632 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "(%s) bad operand(s) (%X)\n",
667 acpi_ps_get_opcode_name (op->common.aml_opcode), status)); 633 acpi_ps_get_opcode_name(op->common.
634 aml_opcode), status));
668 635
669 return_ACPI_STATUS (status); 636 return_ACPI_STATUS(status);
670 } 637 }
671 638
672 /* Initialize the Buffer Field */ 639 /* Initialize the Buffer Field */
@@ -674,22 +641,25 @@ acpi_ds_eval_buffer_field_operands (
674 if (op->common.aml_opcode == AML_CREATE_FIELD_OP) { 641 if (op->common.aml_opcode == AML_CREATE_FIELD_OP) {
675 /* NOTE: Slightly different operands for this opcode */ 642 /* NOTE: Slightly different operands for this opcode */
676 643
677 status = acpi_ds_init_buffer_field (op->common.aml_opcode, obj_desc, 644 status =
678 walk_state->operands[0], walk_state->operands[1], 645 acpi_ds_init_buffer_field(op->common.aml_opcode, obj_desc,
679 walk_state->operands[2], walk_state->operands[3]); 646 walk_state->operands[0],
680 } 647 walk_state->operands[1],
681 else { 648 walk_state->operands[2],
649 walk_state->operands[3]);
650 } else {
682 /* All other, create_xxx_field opcodes */ 651 /* All other, create_xxx_field opcodes */
683 652
684 status = acpi_ds_init_buffer_field (op->common.aml_opcode, obj_desc, 653 status =
685 walk_state->operands[0], walk_state->operands[1], 654 acpi_ds_init_buffer_field(op->common.aml_opcode, obj_desc,
686 NULL, walk_state->operands[2]); 655 walk_state->operands[0],
656 walk_state->operands[1], NULL,
657 walk_state->operands[2]);
687 } 658 }
688 659
689 return_ACPI_STATUS (status); 660 return_ACPI_STATUS(status);
690} 661}
691 662
692
693/******************************************************************************* 663/*******************************************************************************
694 * 664 *
695 * FUNCTION: acpi_ds_eval_region_operands 665 * FUNCTION: acpi_ds_eval_region_operands
@@ -705,25 +675,22 @@ acpi_ds_eval_buffer_field_operands (
705 ******************************************************************************/ 675 ******************************************************************************/
706 676
707acpi_status 677acpi_status
708acpi_ds_eval_region_operands ( 678acpi_ds_eval_region_operands(struct acpi_walk_state *walk_state,
709 struct acpi_walk_state *walk_state, 679 union acpi_parse_object *op)
710 union acpi_parse_object *op)
711{ 680{
712 acpi_status status; 681 acpi_status status;
713 union acpi_operand_object *obj_desc; 682 union acpi_operand_object *obj_desc;
714 union acpi_operand_object *operand_desc; 683 union acpi_operand_object *operand_desc;
715 struct acpi_namespace_node *node; 684 struct acpi_namespace_node *node;
716 union acpi_parse_object *next_op; 685 union acpi_parse_object *next_op;
717
718
719 ACPI_FUNCTION_TRACE_PTR ("ds_eval_region_operands", op);
720 686
687 ACPI_FUNCTION_TRACE_PTR("ds_eval_region_operands", op);
721 688
722 /* 689 /*
723 * This is where we evaluate the address and length fields of the 690 * This is where we evaluate the address and length fields of the
724 * op_region declaration 691 * op_region declaration
725 */ 692 */
726 node = op->common.node; 693 node = op->common.node;
727 694
728 /* next_op points to the op that holds the space_iD */ 695 /* next_op points to the op that holds the space_iD */
729 696
@@ -735,26 +702,26 @@ acpi_ds_eval_region_operands (
735 702
736 /* Evaluate/create the address and length operands */ 703 /* Evaluate/create the address and length operands */
737 704
738 status = acpi_ds_create_operands (walk_state, next_op); 705 status = acpi_ds_create_operands(walk_state, next_op);
739 if (ACPI_FAILURE (status)) { 706 if (ACPI_FAILURE(status)) {
740 return_ACPI_STATUS (status); 707 return_ACPI_STATUS(status);
741 } 708 }
742 709
743 /* Resolve the length and address operands to numbers */ 710 /* Resolve the length and address operands to numbers */
744 711
745 status = acpi_ex_resolve_operands (op->common.aml_opcode, 712 status = acpi_ex_resolve_operands(op->common.aml_opcode,
746 ACPI_WALK_OPERANDS, walk_state); 713 ACPI_WALK_OPERANDS, walk_state);
747 if (ACPI_FAILURE (status)) { 714 if (ACPI_FAILURE(status)) {
748 return_ACPI_STATUS (status); 715 return_ACPI_STATUS(status);
749 } 716 }
750 717
751 ACPI_DUMP_OPERANDS (ACPI_WALK_OPERANDS, ACPI_IMODE_EXECUTE, 718 ACPI_DUMP_OPERANDS(ACPI_WALK_OPERANDS, ACPI_IMODE_EXECUTE,
752 acpi_ps_get_opcode_name (op->common.aml_opcode), 719 acpi_ps_get_opcode_name(op->common.aml_opcode),
753 1, "after acpi_ex_resolve_operands"); 720 1, "after acpi_ex_resolve_operands");
754 721
755 obj_desc = acpi_ns_get_attached_object (node); 722 obj_desc = acpi_ns_get_attached_object(node);
756 if (!obj_desc) { 723 if (!obj_desc) {
757 return_ACPI_STATUS (AE_NOT_EXIST); 724 return_ACPI_STATUS(AE_NOT_EXIST);
758 } 725 }
759 726
760 /* 727 /*
@@ -764,7 +731,7 @@ acpi_ds_eval_region_operands (
764 operand_desc = walk_state->operands[walk_state->num_operands - 1]; 731 operand_desc = walk_state->operands[walk_state->num_operands - 1];
765 732
766 obj_desc->region.length = (u32) operand_desc->integer.value; 733 obj_desc->region.length = (u32) operand_desc->integer.value;
767 acpi_ut_remove_reference (operand_desc); 734 acpi_ut_remove_reference(operand_desc);
768 735
769 /* 736 /*
770 * Get the address and save it 737 * Get the address and save it
@@ -773,22 +740,21 @@ acpi_ds_eval_region_operands (
773 operand_desc = walk_state->operands[walk_state->num_operands - 2]; 740 operand_desc = walk_state->operands[walk_state->num_operands - 2];
774 741
775 obj_desc->region.address = (acpi_physical_address) 742 obj_desc->region.address = (acpi_physical_address)
776 operand_desc->integer.value; 743 operand_desc->integer.value;
777 acpi_ut_remove_reference (operand_desc); 744 acpi_ut_remove_reference(operand_desc);
778 745
779 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "rgn_obj %p Addr %8.8X%8.8X Len %X\n", 746 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "rgn_obj %p Addr %8.8X%8.8X Len %X\n",
780 obj_desc, 747 obj_desc,
781 ACPI_FORMAT_UINT64 (obj_desc->region.address), 748 ACPI_FORMAT_UINT64(obj_desc->region.address),
782 obj_desc->region.length)); 749 obj_desc->region.length));
783 750
784 /* Now the address and length are valid for this opregion */ 751 /* Now the address and length are valid for this opregion */
785 752
786 obj_desc->region.flags |= AOPOBJ_DATA_VALID; 753 obj_desc->region.flags |= AOPOBJ_DATA_VALID;
787 754
788 return_ACPI_STATUS (status); 755 return_ACPI_STATUS(status);
789} 756}
790 757
791
792/******************************************************************************* 758/*******************************************************************************
793 * 759 *
794 * FUNCTION: acpi_ds_eval_data_object_operands 760 * FUNCTION: acpi_ds_eval_data_object_operands
@@ -805,46 +771,44 @@ acpi_ds_eval_region_operands (
805 ******************************************************************************/ 771 ******************************************************************************/
806 772
807acpi_status 773acpi_status
808acpi_ds_eval_data_object_operands ( 774acpi_ds_eval_data_object_operands(struct acpi_walk_state *walk_state,
809 struct acpi_walk_state *walk_state, 775 union acpi_parse_object *op,
810 union acpi_parse_object *op, 776 union acpi_operand_object *obj_desc)
811 union acpi_operand_object *obj_desc)
812{ 777{
813 acpi_status status; 778 acpi_status status;
814 union acpi_operand_object *arg_desc; 779 union acpi_operand_object *arg_desc;
815 u32 length; 780 u32 length;
816
817
818 ACPI_FUNCTION_TRACE ("ds_eval_data_object_operands");
819 781
782 ACPI_FUNCTION_TRACE("ds_eval_data_object_operands");
820 783
821 /* The first operand (for all of these data objects) is the length */ 784 /* The first operand (for all of these data objects) is the length */
822 785
823 status = acpi_ds_create_operand (walk_state, op->common.value.arg, 1); 786 status = acpi_ds_create_operand(walk_state, op->common.value.arg, 1);
824 if (ACPI_FAILURE (status)) { 787 if (ACPI_FAILURE(status)) {
825 return_ACPI_STATUS (status); 788 return_ACPI_STATUS(status);
826 } 789 }
827 790
828 status = acpi_ex_resolve_operands (walk_state->opcode, 791 status = acpi_ex_resolve_operands(walk_state->opcode,
829 &(walk_state->operands [walk_state->num_operands -1]), 792 &(walk_state->
830 walk_state); 793 operands[walk_state->num_operands -
831 if (ACPI_FAILURE (status)) { 794 1]), walk_state);
832 return_ACPI_STATUS (status); 795 if (ACPI_FAILURE(status)) {
796 return_ACPI_STATUS(status);
833 } 797 }
834 798
835 /* Extract length operand */ 799 /* Extract length operand */
836 800
837 arg_desc = walk_state->operands [walk_state->num_operands - 1]; 801 arg_desc = walk_state->operands[walk_state->num_operands - 1];
838 length = (u32) arg_desc->integer.value; 802 length = (u32) arg_desc->integer.value;
839 803
840 /* Cleanup for length operand */ 804 /* Cleanup for length operand */
841 805
842 status = acpi_ds_obj_stack_pop (1, walk_state); 806 status = acpi_ds_obj_stack_pop(1, walk_state);
843 if (ACPI_FAILURE (status)) { 807 if (ACPI_FAILURE(status)) {
844 return_ACPI_STATUS (status); 808 return_ACPI_STATUS(status);
845 } 809 }
846 810
847 acpi_ut_remove_reference (arg_desc); 811 acpi_ut_remove_reference(arg_desc);
848 812
849 /* 813 /*
850 * Create the actual data object 814 * Create the actual data object
@@ -852,37 +816,42 @@ acpi_ds_eval_data_object_operands (
852 switch (op->common.aml_opcode) { 816 switch (op->common.aml_opcode) {
853 case AML_BUFFER_OP: 817 case AML_BUFFER_OP:
854 818
855 status = acpi_ds_build_internal_buffer_obj (walk_state, op, length, &obj_desc); 819 status =
820 acpi_ds_build_internal_buffer_obj(walk_state, op, length,
821 &obj_desc);
856 break; 822 break;
857 823
858 case AML_PACKAGE_OP: 824 case AML_PACKAGE_OP:
859 case AML_VAR_PACKAGE_OP: 825 case AML_VAR_PACKAGE_OP:
860 826
861 status = acpi_ds_build_internal_package_obj (walk_state, op, length, &obj_desc); 827 status =
828 acpi_ds_build_internal_package_obj(walk_state, op, length,
829 &obj_desc);
862 break; 830 break;
863 831
864 default: 832 default:
865 return_ACPI_STATUS (AE_AML_BAD_OPCODE); 833 return_ACPI_STATUS(AE_AML_BAD_OPCODE);
866 } 834 }
867 835
868 if (ACPI_SUCCESS (status)) { 836 if (ACPI_SUCCESS(status)) {
869 /* 837 /*
870 * Return the object in the walk_state, unless the parent is a package - 838 * Return the object in the walk_state, unless the parent is a package -
871 * in this case, the return object will be stored in the parse tree 839 * in this case, the return object will be stored in the parse tree
872 * for the package. 840 * for the package.
873 */ 841 */
874 if ((!op->common.parent) || 842 if ((!op->common.parent) ||
875 ((op->common.parent->common.aml_opcode != AML_PACKAGE_OP) && 843 ((op->common.parent->common.aml_opcode != AML_PACKAGE_OP) &&
876 (op->common.parent->common.aml_opcode != AML_VAR_PACKAGE_OP) && 844 (op->common.parent->common.aml_opcode !=
877 (op->common.parent->common.aml_opcode != AML_NAME_OP))) { 845 AML_VAR_PACKAGE_OP)
846 && (op->common.parent->common.aml_opcode !=
847 AML_NAME_OP))) {
878 walk_state->result_obj = obj_desc; 848 walk_state->result_obj = obj_desc;
879 } 849 }
880 } 850 }
881 851
882 return_ACPI_STATUS (status); 852 return_ACPI_STATUS(status);
883} 853}
884 854
885
886/******************************************************************************* 855/*******************************************************************************
887 * 856 *
888 * FUNCTION: acpi_ds_exec_begin_control_op 857 * FUNCTION: acpi_ds_exec_begin_control_op
@@ -898,19 +867,16 @@ acpi_ds_eval_data_object_operands (
898 ******************************************************************************/ 867 ******************************************************************************/
899 868
900acpi_status 869acpi_status
901acpi_ds_exec_begin_control_op ( 870acpi_ds_exec_begin_control_op(struct acpi_walk_state *walk_state,
902 struct acpi_walk_state *walk_state, 871 union acpi_parse_object *op)
903 union acpi_parse_object *op)
904{ 872{
905 acpi_status status = AE_OK; 873 acpi_status status = AE_OK;
906 union acpi_generic_state *control_state; 874 union acpi_generic_state *control_state;
907
908
909 ACPI_FUNCTION_NAME ("ds_exec_begin_control_op");
910 875
876 ACPI_FUNCTION_NAME("ds_exec_begin_control_op");
911 877
912 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Op=%p Opcode=%2.2X State=%p\n", op, 878 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, "Op=%p Opcode=%2.2X State=%p\n", op,
913 op->common.aml_opcode, walk_state)); 879 op->common.aml_opcode, walk_state));
914 880
915 switch (op->common.aml_opcode) { 881 switch (op->common.aml_opcode) {
916 case AML_IF_OP: 882 case AML_IF_OP:
@@ -921,7 +887,7 @@ acpi_ds_exec_begin_control_op (
921 * constructs. We need to manage these as a stack, in order 887 * constructs. We need to manage these as a stack, in order
922 * to handle nesting. 888 * to handle nesting.
923 */ 889 */
924 control_state = acpi_ut_create_control_state (); 890 control_state = acpi_ut_create_control_state();
925 if (!control_state) { 891 if (!control_state) {
926 status = AE_NO_MEMORY; 892 status = AE_NO_MEMORY;
927 break; 893 break;
@@ -930,14 +896,16 @@ acpi_ds_exec_begin_control_op (
930 * Save a pointer to the predicate for multiple executions 896 * Save a pointer to the predicate for multiple executions
931 * of a loop 897 * of a loop
932 */ 898 */
933 control_state->control.aml_predicate_start = walk_state->parser_state.aml - 1; 899 control_state->control.aml_predicate_start =
934 control_state->control.package_end = walk_state->parser_state.pkg_end; 900 walk_state->parser_state.aml - 1;
901 control_state->control.package_end =
902 walk_state->parser_state.pkg_end;
935 control_state->control.opcode = op->common.aml_opcode; 903 control_state->control.opcode = op->common.aml_opcode;
936 904
937
938 /* Push the control state on this walk's control stack */ 905 /* Push the control state on this walk's control stack */
939 906
940 acpi_ut_push_generic_state (&walk_state->control_state, control_state); 907 acpi_ut_push_generic_state(&walk_state->control_state,
908 control_state);
941 break; 909 break;
942 910
943 case AML_ELSE_OP: 911 case AML_ELSE_OP:
@@ -962,7 +930,6 @@ acpi_ds_exec_begin_control_op (
962 return (status); 930 return (status);
963} 931}
964 932
965
966/******************************************************************************* 933/*******************************************************************************
967 * 934 *
968 * FUNCTION: acpi_ds_exec_end_control_op 935 * FUNCTION: acpi_ds_exec_end_control_op
@@ -978,46 +945,42 @@ acpi_ds_exec_begin_control_op (
978 ******************************************************************************/ 945 ******************************************************************************/
979 946
980acpi_status 947acpi_status
981acpi_ds_exec_end_control_op ( 948acpi_ds_exec_end_control_op(struct acpi_walk_state * walk_state,
982 struct acpi_walk_state *walk_state, 949 union acpi_parse_object * op)
983 union acpi_parse_object *op)
984{ 950{
985 acpi_status status = AE_OK; 951 acpi_status status = AE_OK;
986 union acpi_generic_state *control_state; 952 union acpi_generic_state *control_state;
987
988
989 ACPI_FUNCTION_NAME ("ds_exec_end_control_op");
990 953
954 ACPI_FUNCTION_NAME("ds_exec_end_control_op");
991 955
992 switch (op->common.aml_opcode) { 956 switch (op->common.aml_opcode) {
993 case AML_IF_OP: 957 case AML_IF_OP:
994 958
995 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "[IF_OP] Op=%p\n", op)); 959 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, "[IF_OP] Op=%p\n", op));
996 960
997 /* 961 /*
998 * Save the result of the predicate in case there is an 962 * Save the result of the predicate in case there is an
999 * ELSE to come 963 * ELSE to come
1000 */ 964 */
1001 walk_state->last_predicate = 965 walk_state->last_predicate =
1002 (u8) walk_state->control_state->common.value; 966 (u8) walk_state->control_state->common.value;
1003 967
1004 /* 968 /*
1005 * Pop the control state that was created at the start 969 * Pop the control state that was created at the start
1006 * of the IF and free it 970 * of the IF and free it
1007 */ 971 */
1008 control_state = acpi_ut_pop_generic_state (&walk_state->control_state); 972 control_state =
1009 acpi_ut_delete_generic_state (control_state); 973 acpi_ut_pop_generic_state(&walk_state->control_state);
974 acpi_ut_delete_generic_state(control_state);
1010 break; 975 break;
1011 976
1012
1013 case AML_ELSE_OP: 977 case AML_ELSE_OP:
1014 978
1015 break; 979 break;
1016 980
1017
1018 case AML_WHILE_OP: 981 case AML_WHILE_OP:
1019 982
1020 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "[WHILE_OP] Op=%p\n", op)); 983 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, "[WHILE_OP] Op=%p\n", op));
1021 984
1022 if (walk_state->control_state->common.value) { 985 if (walk_state->control_state->common.value) {
1023 /* Predicate was true, go back and evaluate it again! */ 986 /* Predicate was true, go back and evaluate it again! */
@@ -1025,22 +988,24 @@ acpi_ds_exec_end_control_op (
1025 status = AE_CTRL_PENDING; 988 status = AE_CTRL_PENDING;
1026 } 989 }
1027 990
1028 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, 991 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
1029 "[WHILE_OP] termination! Op=%p\n",op)); 992 "[WHILE_OP] termination! Op=%p\n", op));
1030 993
1031 /* Pop this control state and free it */ 994 /* Pop this control state and free it */
1032 995
1033 control_state = acpi_ut_pop_generic_state (&walk_state->control_state); 996 control_state =
997 acpi_ut_pop_generic_state(&walk_state->control_state);
1034 998
1035 walk_state->aml_last_while = control_state->control.aml_predicate_start; 999 walk_state->aml_last_while =
1036 acpi_ut_delete_generic_state (control_state); 1000 control_state->control.aml_predicate_start;
1001 acpi_ut_delete_generic_state(control_state);
1037 break; 1002 break;
1038 1003
1039
1040 case AML_RETURN_OP: 1004 case AML_RETURN_OP:
1041 1005
1042 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, 1006 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
1043 "[RETURN_OP] Op=%p Arg=%p\n",op, op->common.value.arg)); 1007 "[RETURN_OP] Op=%p Arg=%p\n", op,
1008 op->common.value.arg));
1044 1009
1045 /* 1010 /*
1046 * One optional operand -- the return value 1011 * One optional operand -- the return value
@@ -1050,12 +1015,14 @@ acpi_ds_exec_end_control_op (
1050 if (op->common.value.arg) { 1015 if (op->common.value.arg) {
1051 /* Since we have a real Return(), delete any implicit return */ 1016 /* Since we have a real Return(), delete any implicit return */
1052 1017
1053 acpi_ds_clear_implicit_return (walk_state); 1018 acpi_ds_clear_implicit_return(walk_state);
1054 1019
1055 /* Return statement has an immediate operand */ 1020 /* Return statement has an immediate operand */
1056 1021
1057 status = acpi_ds_create_operands (walk_state, op->common.value.arg); 1022 status =
1058 if (ACPI_FAILURE (status)) { 1023 acpi_ds_create_operands(walk_state,
1024 op->common.value.arg);
1025 if (ACPI_FAILURE(status)) {
1059 return (status); 1026 return (status);
1060 } 1027 }
1061 1028
@@ -1064,8 +1031,10 @@ acpi_ds_exec_end_control_op (
1064 * an arg or local), resolve it now because it may 1031 * an arg or local), resolve it now because it may
1065 * cease to exist at the end of the method. 1032 * cease to exist at the end of the method.
1066 */ 1033 */
1067 status = acpi_ex_resolve_to_value (&walk_state->operands [0], walk_state); 1034 status =
1068 if (ACPI_FAILURE (status)) { 1035 acpi_ex_resolve_to_value(&walk_state->operands[0],
1036 walk_state);
1037 if (ACPI_FAILURE(status)) {
1069 return (status); 1038 return (status);
1070 } 1039 }
1071 1040
@@ -1075,12 +1044,11 @@ acpi_ds_exec_end_control_op (
1075 * is set to anything other than zero! 1044 * is set to anything other than zero!
1076 */ 1045 */
1077 walk_state->return_desc = walk_state->operands[0]; 1046 walk_state->return_desc = walk_state->operands[0];
1078 } 1047 } else if ((walk_state->results) &&
1079 else if ((walk_state->results) && 1048 (walk_state->results->results.num_results > 0)) {
1080 (walk_state->results->results.num_results > 0)) {
1081 /* Since we have a real Return(), delete any implicit return */ 1049 /* Since we have a real Return(), delete any implicit return */
1082 1050
1083 acpi_ds_clear_implicit_return (walk_state); 1051 acpi_ds_clear_implicit_return(walk_state);
1084 1052
1085 /* 1053 /*
1086 * The return value has come from a previous calculation. 1054 * The return value has come from a previous calculation.
@@ -1091,67 +1059,78 @@ acpi_ds_exec_end_control_op (
1091 * 1059 *
1092 * Allow references created by the Index operator to return unchanged. 1060 * Allow references created by the Index operator to return unchanged.
1093 */ 1061 */
1094 if ((ACPI_GET_DESCRIPTOR_TYPE (walk_state->results->results.obj_desc[0]) == ACPI_DESC_TYPE_OPERAND) && 1062 if ((ACPI_GET_DESCRIPTOR_TYPE
1095 (ACPI_GET_OBJECT_TYPE (walk_state->results->results.obj_desc [0]) == ACPI_TYPE_LOCAL_REFERENCE) && 1063 (walk_state->results->results.obj_desc[0]) ==
1096 ((walk_state->results->results.obj_desc [0])->reference.opcode != AML_INDEX_OP)) { 1064 ACPI_DESC_TYPE_OPERAND)
1097 status = acpi_ex_resolve_to_value (&walk_state->results->results.obj_desc [0], walk_state); 1065 &&
1098 if (ACPI_FAILURE (status)) { 1066 (ACPI_GET_OBJECT_TYPE
1067 (walk_state->results->results.obj_desc[0]) ==
1068 ACPI_TYPE_LOCAL_REFERENCE)
1069 && ((walk_state->results->results.obj_desc[0])->
1070 reference.opcode != AML_INDEX_OP)) {
1071 status =
1072 acpi_ex_resolve_to_value(&walk_state->
1073 results->results.
1074 obj_desc[0],
1075 walk_state);
1076 if (ACPI_FAILURE(status)) {
1099 return (status); 1077 return (status);
1100 } 1078 }
1101 } 1079 }
1102 1080
1103 walk_state->return_desc = walk_state->results->results.obj_desc [0]; 1081 walk_state->return_desc =
1104 } 1082 walk_state->results->results.obj_desc[0];
1105 else { 1083 } else {
1106 /* No return operand */ 1084 /* No return operand */
1107 1085
1108 if (walk_state->num_operands) { 1086 if (walk_state->num_operands) {
1109 acpi_ut_remove_reference (walk_state->operands [0]); 1087 acpi_ut_remove_reference(walk_state->
1088 operands[0]);
1110 } 1089 }
1111 1090
1112 walk_state->operands [0] = NULL; 1091 walk_state->operands[0] = NULL;
1113 walk_state->num_operands = 0; 1092 walk_state->num_operands = 0;
1114 walk_state->return_desc = NULL; 1093 walk_state->return_desc = NULL;
1115 } 1094 }
1116 1095
1117 1096 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
1118 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, 1097 "Completed RETURN_OP State=%p, ret_val=%p\n",
1119 "Completed RETURN_OP State=%p, ret_val=%p\n", 1098 walk_state, walk_state->return_desc));
1120 walk_state, walk_state->return_desc));
1121 1099
1122 /* End the control method execution right now */ 1100 /* End the control method execution right now */
1123 1101
1124 status = AE_CTRL_TERMINATE; 1102 status = AE_CTRL_TERMINATE;
1125 break; 1103 break;
1126 1104
1127
1128 case AML_NOOP_OP: 1105 case AML_NOOP_OP:
1129 1106
1130 /* Just do nothing! */ 1107 /* Just do nothing! */
1131 break; 1108 break;
1132 1109
1133
1134 case AML_BREAK_POINT_OP: 1110 case AML_BREAK_POINT_OP:
1135 1111
1136 /* Call up to the OS service layer to handle this */ 1112 /* Call up to the OS service layer to handle this */
1137 1113
1138 status = acpi_os_signal (ACPI_SIGNAL_BREAKPOINT, "Executed AML Breakpoint opcode"); 1114 status =
1115 acpi_os_signal(ACPI_SIGNAL_BREAKPOINT,
1116 "Executed AML Breakpoint opcode");
1139 1117
1140 /* If and when it returns, all done. */ 1118 /* If and when it returns, all done. */
1141 1119
1142 break; 1120 break;
1143 1121
1144
1145 case AML_BREAK_OP: 1122 case AML_BREAK_OP:
1146 case AML_CONTINUE_OP: /* ACPI 2.0 */ 1123 case AML_CONTINUE_OP: /* ACPI 2.0 */
1147
1148 1124
1149 /* Pop and delete control states until we find a while */ 1125 /* Pop and delete control states until we find a while */
1150 1126
1151 while (walk_state->control_state && 1127 while (walk_state->control_state &&
1152 (walk_state->control_state->control.opcode != AML_WHILE_OP)) { 1128 (walk_state->control_state->control.opcode !=
1153 control_state = acpi_ut_pop_generic_state (&walk_state->control_state); 1129 AML_WHILE_OP)) {
1154 acpi_ut_delete_generic_state (control_state); 1130 control_state =
1131 acpi_ut_pop_generic_state(&walk_state->
1132 control_state);
1133 acpi_ut_delete_generic_state(control_state);
1155 } 1134 }
1156 1135
1157 /* No while found? */ 1136 /* No while found? */
@@ -1162,23 +1141,23 @@ acpi_ds_exec_end_control_op (
1162 1141
1163 /* Was: walk_state->aml_last_while = walk_state->control_state->Control.aml_predicate_start; */ 1142 /* Was: walk_state->aml_last_while = walk_state->control_state->Control.aml_predicate_start; */
1164 1143
1165 walk_state->aml_last_while = walk_state->control_state->control.package_end; 1144 walk_state->aml_last_while =
1145 walk_state->control_state->control.package_end;
1166 1146
1167 /* Return status depending on opcode */ 1147 /* Return status depending on opcode */
1168 1148
1169 if (op->common.aml_opcode == AML_BREAK_OP) { 1149 if (op->common.aml_opcode == AML_BREAK_OP) {
1170 status = AE_CTRL_BREAK; 1150 status = AE_CTRL_BREAK;
1171 } 1151 } else {
1172 else {
1173 status = AE_CTRL_CONTINUE; 1152 status = AE_CTRL_CONTINUE;
1174 } 1153 }
1175 break; 1154 break;
1176 1155
1177
1178 default: 1156 default:
1179 1157
1180 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown control opcode=%X Op=%p\n", 1158 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
1181 op->common.aml_opcode, op)); 1159 "Unknown control opcode=%X Op=%p\n",
1160 op->common.aml_opcode, op));
1182 1161
1183 status = AE_AML_BAD_OPCODE; 1162 status = AE_AML_BAD_OPCODE;
1184 break; 1163 break;
@@ -1186,4 +1165,3 @@ acpi_ds_exec_end_control_op (
1186 1165
1187 return (status); 1166 return (status);
1188} 1167}
1189