aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/dispatcher/dswload.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/acpi/dispatcher/dswload.c')
-rw-r--r--drivers/acpi/dispatcher/dswload.c488
1 files changed, 242 insertions, 246 deletions
diff --git a/drivers/acpi/dispatcher/dswload.c b/drivers/acpi/dispatcher/dswload.c
index 9100c0bda470..362bbcfc1718 100644
--- a/drivers/acpi/dispatcher/dswload.c
+++ b/drivers/acpi/dispatcher/dswload.c
@@ -41,7 +41,6 @@
41 * POSSIBILITY OF SUCH DAMAGES. 41 * POSSIBILITY OF SUCH DAMAGES.
42 */ 42 */
43 43
44
45#include <acpi/acpi.h> 44#include <acpi/acpi.h>
46#include <acpi/acparser.h> 45#include <acpi/acparser.h>
47#include <acpi/amlcode.h> 46#include <acpi/amlcode.h>
@@ -55,8 +54,7 @@
55#endif 54#endif
56 55
57#define _COMPONENT ACPI_DISPATCHER 56#define _COMPONENT ACPI_DISPATCHER
58 ACPI_MODULE_NAME ("dswload") 57ACPI_MODULE_NAME("dswload")
59
60 58
61/******************************************************************************* 59/*******************************************************************************
62 * 60 *
@@ -70,32 +68,29 @@
70 * DESCRIPTION: Init walk state callbacks 68 * DESCRIPTION: Init walk state callbacks
71 * 69 *
72 ******************************************************************************/ 70 ******************************************************************************/
73
74acpi_status 71acpi_status
75acpi_ds_init_callbacks ( 72acpi_ds_init_callbacks(struct acpi_walk_state *walk_state, u32 pass_number)
76 struct acpi_walk_state *walk_state,
77 u32 pass_number)
78{ 73{
79 74
80 switch (pass_number) { 75 switch (pass_number) {
81 case 1: 76 case 1:
82 walk_state->parse_flags = ACPI_PARSE_LOAD_PASS1 | 77 walk_state->parse_flags = ACPI_PARSE_LOAD_PASS1 |
83 ACPI_PARSE_DELETE_TREE; 78 ACPI_PARSE_DELETE_TREE;
84 walk_state->descending_callback = acpi_ds_load1_begin_op; 79 walk_state->descending_callback = acpi_ds_load1_begin_op;
85 walk_state->ascending_callback = acpi_ds_load1_end_op; 80 walk_state->ascending_callback = acpi_ds_load1_end_op;
86 break; 81 break;
87 82
88 case 2: 83 case 2:
89 walk_state->parse_flags = ACPI_PARSE_LOAD_PASS1 | 84 walk_state->parse_flags = ACPI_PARSE_LOAD_PASS1 |
90 ACPI_PARSE_DELETE_TREE; 85 ACPI_PARSE_DELETE_TREE;
91 walk_state->descending_callback = acpi_ds_load2_begin_op; 86 walk_state->descending_callback = acpi_ds_load2_begin_op;
92 walk_state->ascending_callback = acpi_ds_load2_end_op; 87 walk_state->ascending_callback = acpi_ds_load2_end_op;
93 break; 88 break;
94 89
95 case 3: 90 case 3:
96#ifndef ACPI_NO_METHOD_EXECUTION 91#ifndef ACPI_NO_METHOD_EXECUTION
97 walk_state->parse_flags |= ACPI_PARSE_EXECUTE | 92 walk_state->parse_flags |= ACPI_PARSE_EXECUTE |
98 ACPI_PARSE_DELETE_TREE; 93 ACPI_PARSE_DELETE_TREE;
99 walk_state->descending_callback = acpi_ds_exec_begin_op; 94 walk_state->descending_callback = acpi_ds_exec_begin_op;
100 walk_state->ascending_callback = acpi_ds_exec_end_op; 95 walk_state->ascending_callback = acpi_ds_exec_end_op;
101#endif 96#endif
@@ -108,7 +103,6 @@ acpi_ds_init_callbacks (
108 return (AE_OK); 103 return (AE_OK);
109} 104}
110 105
111
112/******************************************************************************* 106/*******************************************************************************
113 * 107 *
114 * FUNCTION: acpi_ds_load1_begin_op 108 * FUNCTION: acpi_ds_load1_begin_op
@@ -123,23 +117,21 @@ acpi_ds_init_callbacks (
123 ******************************************************************************/ 117 ******************************************************************************/
124 118
125acpi_status 119acpi_status
126acpi_ds_load1_begin_op ( 120acpi_ds_load1_begin_op(struct acpi_walk_state * walk_state,
127 struct acpi_walk_state *walk_state, 121 union acpi_parse_object ** out_op)
128 union acpi_parse_object **out_op)
129{ 122{
130 union acpi_parse_object *op; 123 union acpi_parse_object *op;
131 struct acpi_namespace_node *node; 124 struct acpi_namespace_node *node;
132 acpi_status status; 125 acpi_status status;
133 acpi_object_type object_type; 126 acpi_object_type object_type;
134 char *path; 127 char *path;
135 u32 flags; 128 u32 flags;
136
137
138 ACPI_FUNCTION_NAME ("ds_load1_begin_op");
139 129
130 ACPI_FUNCTION_NAME("ds_load1_begin_op");
140 131
141 op = walk_state->op; 132 op = walk_state->op;
142 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Op=%p State=%p\n", op, walk_state)); 133 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, "Op=%p State=%p\n", op,
134 walk_state));
143 135
144 /* We are only interested in opcodes that have an associated name */ 136 /* We are only interested in opcodes that have an associated name */
145 137
@@ -157,14 +149,15 @@ acpi_ds_load1_begin_op (
157 } 149 }
158 } 150 }
159 151
160 path = acpi_ps_get_next_namestring (&walk_state->parser_state); 152 path = acpi_ps_get_next_namestring(&walk_state->parser_state);
161 153
162 /* Map the raw opcode into an internal object type */ 154 /* Map the raw opcode into an internal object type */
163 155
164 object_type = walk_state->op_info->object_type; 156 object_type = walk_state->op_info->object_type;
165 157
166 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, 158 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
167 "State=%p Op=%p [%s]\n", walk_state, op, acpi_ut_get_type_name (object_type))); 159 "State=%p Op=%p [%s]\n", walk_state, op,
160 acpi_ut_get_type_name(object_type)));
168 161
169 switch (walk_state->opcode) { 162 switch (walk_state->opcode) {
170 case AML_SCOPE_OP: 163 case AML_SCOPE_OP:
@@ -174,8 +167,10 @@ acpi_ds_load1_begin_op (
174 * that we can actually open the scope to enter new names underneath it. 167 * that we can actually open the scope to enter new names underneath it.
175 * Allow search-to-root for single namesegs. 168 * Allow search-to-root for single namesegs.
176 */ 169 */
177 status = acpi_ns_lookup (walk_state->scope_info, path, object_type, 170 status =
178 ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, walk_state, &(node)); 171 acpi_ns_lookup(walk_state->scope_info, path, object_type,
172 ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT,
173 walk_state, &(node));
179#ifdef ACPI_ASL_COMPILER 174#ifdef ACPI_ASL_COMPILER
180 if (status == AE_NOT_FOUND) { 175 if (status == AE_NOT_FOUND) {
181 /* 176 /*
@@ -183,14 +178,16 @@ acpi_ds_load1_begin_op (
183 * Target of Scope() not found. Generate an External for it, and 178 * Target of Scope() not found. Generate an External for it, and
184 * insert the name into the namespace. 179 * insert the name into the namespace.
185 */ 180 */
186 acpi_dm_add_to_external_list (path); 181 acpi_dm_add_to_external_list(path);
187 status = acpi_ns_lookup (walk_state->scope_info, path, object_type, 182 status =
188 ACPI_IMODE_LOAD_PASS1, ACPI_NS_SEARCH_PARENT, 183 acpi_ns_lookup(walk_state->scope_info, path,
189 walk_state, &(node)); 184 object_type, ACPI_IMODE_LOAD_PASS1,
185 ACPI_NS_SEARCH_PARENT, walk_state,
186 &(node));
190 } 187 }
191#endif 188#endif
192 if (ACPI_FAILURE (status)) { 189 if (ACPI_FAILURE(status)) {
193 ACPI_REPORT_NSERROR (path, status); 190 ACPI_REPORT_NSERROR(path, status);
194 return (status); 191 return (status);
195 } 192 }
196 193
@@ -199,7 +196,7 @@ acpi_ds_load1_begin_op (
199 * one of the opcodes that actually opens a scope 196 * one of the opcodes that actually opens a scope
200 */ 197 */
201 switch (node->type) { 198 switch (node->type) {
202 case ACPI_TYPE_LOCAL_SCOPE: /* Scope */ 199 case ACPI_TYPE_LOCAL_SCOPE: /* Scope */
203 case ACPI_TYPE_DEVICE: 200 case ACPI_TYPE_DEVICE:
204 case ACPI_TYPE_POWER: 201 case ACPI_TYPE_POWER:
205 case ACPI_TYPE_PROCESSOR: 202 case ACPI_TYPE_PROCESSOR:
@@ -223,9 +220,10 @@ acpi_ds_load1_begin_op (
223 * a warning 220 * a warning
224 */ 221 */
225 222
226 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, 223 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
227 "Type override - [%4.4s] had invalid type (%s) for Scope operator, changed to (Scope)\n", 224 "Type override - [%4.4s] had invalid type (%s) for Scope operator, changed to (Scope)\n",
228 path, acpi_ut_get_type_name (node->type))); 225 path,
226 acpi_ut_get_type_name(node->type)));
229 227
230 node->type = ACPI_TYPE_ANY; 228 node->type = ACPI_TYPE_ANY;
231 walk_state->scope_info->common.value = ACPI_TYPE_ANY; 229 walk_state->scope_info->common.value = ACPI_TYPE_ANY;
@@ -235,15 +233,12 @@ acpi_ds_load1_begin_op (
235 233
236 /* All other types are an error */ 234 /* All other types are an error */
237 235
238 ACPI_REPORT_ERROR (( 236 ACPI_REPORT_ERROR(("Invalid type (%s) for target of Scope operator [%4.4s] (Cannot override)\n", acpi_ut_get_type_name(node->type), path));
239 "Invalid type (%s) for target of Scope operator [%4.4s] (Cannot override)\n",
240 acpi_ut_get_type_name (node->type), path));
241 237
242 return (AE_AML_OPERAND_TYPE); 238 return (AE_AML_OPERAND_TYPE);
243 } 239 }
244 break; 240 break;
245 241
246
247 default: 242 default:
248 243
249 /* 244 /*
@@ -272,15 +267,15 @@ acpi_ds_load1_begin_op (
272 267
273 flags = ACPI_NS_NO_UPSEARCH; 268 flags = ACPI_NS_NO_UPSEARCH;
274 if ((walk_state->opcode != AML_SCOPE_OP) && 269 if ((walk_state->opcode != AML_SCOPE_OP) &&
275 (!(walk_state->parse_flags & ACPI_PARSE_DEFERRED_OP))) { 270 (!(walk_state->parse_flags & ACPI_PARSE_DEFERRED_OP))) {
276 flags |= ACPI_NS_ERROR_IF_FOUND; 271 flags |= ACPI_NS_ERROR_IF_FOUND;
277 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "[%s] Cannot already exist\n", 272 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
278 acpi_ut_get_type_name (object_type))); 273 "[%s] Cannot already exist\n",
279 } 274 acpi_ut_get_type_name(object_type)));
280 else { 275 } else {
281 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, 276 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
282 "[%s] Both Find or Create allowed\n", 277 "[%s] Both Find or Create allowed\n",
283 acpi_ut_get_type_name (object_type))); 278 acpi_ut_get_type_name(object_type)));
284 } 279 }
285 280
286 /* 281 /*
@@ -289,22 +284,23 @@ acpi_ds_load1_begin_op (
289 * involve arguments to the opcode must be created as we go back up the 284 * involve arguments to the opcode must be created as we go back up the
290 * parse tree later. 285 * parse tree later.
291 */ 286 */
292 status = acpi_ns_lookup (walk_state->scope_info, path, object_type, 287 status =
293 ACPI_IMODE_LOAD_PASS1, flags, walk_state, &(node)); 288 acpi_ns_lookup(walk_state->scope_info, path, object_type,
294 if (ACPI_FAILURE (status)) { 289 ACPI_IMODE_LOAD_PASS1, flags, walk_state,
295 ACPI_REPORT_NSERROR (path, status); 290 &(node));
291 if (ACPI_FAILURE(status)) {
292 ACPI_REPORT_NSERROR(path, status);
296 return (status); 293 return (status);
297 } 294 }
298 break; 295 break;
299 } 296 }
300 297
301
302 /* Common exit */ 298 /* Common exit */
303 299
304 if (!op) { 300 if (!op) {
305 /* Create a new op */ 301 /* Create a new op */
306 302
307 op = acpi_ps_alloc_op (walk_state->opcode); 303 op = acpi_ps_alloc_op(walk_state->opcode);
308 if (!op) { 304 if (!op) {
309 return (AE_NO_MEMORY); 305 return (AE_NO_MEMORY);
310 } 306 }
@@ -318,19 +314,18 @@ acpi_ds_load1_begin_op (
318 op->named.path = (u8 *) path; 314 op->named.path = (u8 *) path;
319#endif 315#endif
320 316
321
322 /* 317 /*
323 * Put the Node in the "op" object that the parser uses, so we 318 * Put the Node in the "op" object that the parser uses, so we
324 * can get it again quickly when this scope is closed 319 * can get it again quickly when this scope is closed
325 */ 320 */
326 op->common.node = node; 321 op->common.node = node;
327 acpi_ps_append_arg (acpi_ps_get_parent_scope (&walk_state->parser_state), op); 322 acpi_ps_append_arg(acpi_ps_get_parent_scope(&walk_state->parser_state),
323 op);
328 324
329 *out_op = op; 325 *out_op = op;
330 return (status); 326 return (status);
331} 327}
332 328
333
334/******************************************************************************* 329/*******************************************************************************
335 * 330 *
336 * FUNCTION: acpi_ds_load1_end_op 331 * FUNCTION: acpi_ds_load1_end_op
@@ -344,20 +339,17 @@ acpi_ds_load1_begin_op (
344 * 339 *
345 ******************************************************************************/ 340 ******************************************************************************/
346 341
347acpi_status 342acpi_status acpi_ds_load1_end_op(struct acpi_walk_state * walk_state)
348acpi_ds_load1_end_op (
349 struct acpi_walk_state *walk_state)
350{ 343{
351 union acpi_parse_object *op; 344 union acpi_parse_object *op;
352 acpi_object_type object_type; 345 acpi_object_type object_type;
353 acpi_status status = AE_OK; 346 acpi_status status = AE_OK;
354
355
356 ACPI_FUNCTION_NAME ("ds_load1_end_op");
357 347
348 ACPI_FUNCTION_NAME("ds_load1_end_op");
358 349
359 op = walk_state->op; 350 op = walk_state->op;
360 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Op=%p State=%p\n", op, walk_state)); 351 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, "Op=%p State=%p\n", op,
352 walk_state));
361 353
362 /* We are only interested in opcodes that have an associated name */ 354 /* We are only interested in opcodes that have an associated name */
363 355
@@ -371,21 +363,20 @@ acpi_ds_load1_end_op (
371 363
372#ifndef ACPI_NO_METHOD_EXECUTION 364#ifndef ACPI_NO_METHOD_EXECUTION
373 if (walk_state->op_info->flags & AML_FIELD) { 365 if (walk_state->op_info->flags & AML_FIELD) {
374 if (walk_state->opcode == AML_FIELD_OP || 366 if (walk_state->opcode == AML_FIELD_OP ||
375 walk_state->opcode == AML_BANK_FIELD_OP || 367 walk_state->opcode == AML_BANK_FIELD_OP ||
376 walk_state->opcode == AML_INDEX_FIELD_OP) { 368 walk_state->opcode == AML_INDEX_FIELD_OP) {
377 status = acpi_ds_init_field_objects (op, walk_state); 369 status = acpi_ds_init_field_objects(op, walk_state);
378 } 370 }
379 return (status); 371 return (status);
380 } 372 }
381 373
382
383 if (op->common.aml_opcode == AML_REGION_OP) { 374 if (op->common.aml_opcode == AML_REGION_OP) {
384 status = acpi_ex_create_region (op->named.data, op->named.length, 375 status = acpi_ex_create_region(op->named.data, op->named.length,
385 (acpi_adr_space_type) 376 (acpi_adr_space_type)
386 ((op->common.value.arg)->common.value.integer), 377 ((op->common.value.arg)->common.
387 walk_state); 378 value.integer), walk_state);
388 if (ACPI_FAILURE (status)) { 379 if (ACPI_FAILURE(status)) {
389 return (status); 380 return (status);
390 } 381 }
391 } 382 }
@@ -395,8 +386,11 @@ acpi_ds_load1_end_op (
395 /* For Name opcode, get the object type from the argument */ 386 /* For Name opcode, get the object type from the argument */
396 387
397 if (op->common.value.arg) { 388 if (op->common.value.arg) {
398 object_type = (acpi_ps_get_opcode_info ( 389 object_type = (acpi_ps_get_opcode_info((op->common.
399 (op->common.value.arg)->common.aml_opcode))->object_type; 390 value.arg)->
391 common.
392 aml_opcode))->
393 object_type;
400 op->common.node->type = (u8) object_type; 394 op->common.node->type = (u8) object_type;
401 } 395 }
402 } 396 }
@@ -410,23 +404,26 @@ acpi_ds_load1_end_op (
410 * of invocations of the method (need to know the number of 404 * of invocations of the method (need to know the number of
411 * arguments.) 405 * arguments.)
412 */ 406 */
413 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, 407 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
414 "LOADING-Method: State=%p Op=%p named_obj=%p\n", 408 "LOADING-Method: State=%p Op=%p named_obj=%p\n",
415 walk_state, op, op->named.node)); 409 walk_state, op, op->named.node));
416 410
417 if (!acpi_ns_get_attached_object (op->named.node)) { 411 if (!acpi_ns_get_attached_object(op->named.node)) {
418 walk_state->operands[0] = (void *) op->named.node; 412 walk_state->operands[0] = (void *)op->named.node;
419 walk_state->num_operands = 1; 413 walk_state->num_operands = 1;
420 414
421 status = acpi_ds_create_operands (walk_state, op->common.value.arg); 415 status =
422 if (ACPI_SUCCESS (status)) { 416 acpi_ds_create_operands(walk_state,
423 status = acpi_ex_create_method (op->named.data, 417 op->common.value.arg);
424 op->named.length, walk_state); 418 if (ACPI_SUCCESS(status)) {
419 status = acpi_ex_create_method(op->named.data,
420 op->named.length,
421 walk_state);
425 } 422 }
426 walk_state->operands[0] = NULL; 423 walk_state->operands[0] = NULL;
427 walk_state->num_operands = 0; 424 walk_state->num_operands = 0;
428 425
429 if (ACPI_FAILURE (status)) { 426 if (ACPI_FAILURE(status)) {
430 return (status); 427 return (status);
431 } 428 }
432 } 429 }
@@ -434,17 +431,17 @@ acpi_ds_load1_end_op (
434 431
435 /* Pop the scope stack */ 432 /* Pop the scope stack */
436 433
437 if (acpi_ns_opens_scope (object_type)) { 434 if (acpi_ns_opens_scope(object_type)) {
438 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "(%s): Popping scope for Op %p\n", 435 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
439 acpi_ut_get_type_name (object_type), op)); 436 "(%s): Popping scope for Op %p\n",
437 acpi_ut_get_type_name(object_type), op));
440 438
441 status = acpi_ds_scope_stack_pop (walk_state); 439 status = acpi_ds_scope_stack_pop(walk_state);
442 } 440 }
443 441
444 return (status); 442 return (status);
445} 443}
446 444
447
448/******************************************************************************* 445/*******************************************************************************
449 * 446 *
450 * FUNCTION: acpi_ds_load2_begin_op 447 * FUNCTION: acpi_ds_load2_begin_op
@@ -459,50 +456,50 @@ acpi_ds_load1_end_op (
459 ******************************************************************************/ 456 ******************************************************************************/
460 457
461acpi_status 458acpi_status
462acpi_ds_load2_begin_op ( 459acpi_ds_load2_begin_op(struct acpi_walk_state * walk_state,
463 struct acpi_walk_state *walk_state, 460 union acpi_parse_object ** out_op)
464 union acpi_parse_object **out_op)
465{ 461{
466 union acpi_parse_object *op; 462 union acpi_parse_object *op;
467 struct acpi_namespace_node *node; 463 struct acpi_namespace_node *node;
468 acpi_status status; 464 acpi_status status;
469 acpi_object_type object_type; 465 acpi_object_type object_type;
470 char *buffer_ptr; 466 char *buffer_ptr;
471
472
473 ACPI_FUNCTION_TRACE ("ds_load2_begin_op");
474 467
468 ACPI_FUNCTION_TRACE("ds_load2_begin_op");
475 469
476 op = walk_state->op; 470 op = walk_state->op;
477 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Op=%p State=%p\n", op, walk_state)); 471 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, "Op=%p State=%p\n", op,
472 walk_state));
478 473
479 if (op) { 474 if (op) {
480 if ((walk_state->control_state) && 475 if ((walk_state->control_state) &&
481 (walk_state->control_state->common.state == 476 (walk_state->control_state->common.state ==
482 ACPI_CONTROL_CONDITIONAL_EXECUTING)) { 477 ACPI_CONTROL_CONDITIONAL_EXECUTING)) {
483 /* We are executing a while loop outside of a method */ 478 /* We are executing a while loop outside of a method */
484 479
485 status = acpi_ds_exec_begin_op (walk_state, out_op); 480 status = acpi_ds_exec_begin_op(walk_state, out_op);
486 return_ACPI_STATUS (status); 481 return_ACPI_STATUS(status);
487 } 482 }
488 483
489 /* We only care about Namespace opcodes here */ 484 /* We only care about Namespace opcodes here */
490 485
491 if ((!(walk_state->op_info->flags & AML_NSOPCODE) && 486 if ((!(walk_state->op_info->flags & AML_NSOPCODE) &&
492 (walk_state->opcode != AML_INT_NAMEPATH_OP)) || 487 (walk_state->opcode != AML_INT_NAMEPATH_OP)) ||
493 (!(walk_state->op_info->flags & AML_NAMED))) { 488 (!(walk_state->op_info->flags & AML_NAMED))) {
494 if ((walk_state->op_info->class == AML_CLASS_EXECUTE) || 489 if ((walk_state->op_info->class == AML_CLASS_EXECUTE) ||
495 (walk_state->op_info->class == AML_CLASS_CONTROL)) { 490 (walk_state->op_info->class == AML_CLASS_CONTROL)) {
496 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, 491 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
497 "Begin/EXEC: %s (fl %8.8X)\n", walk_state->op_info->name, 492 "Begin/EXEC: %s (fl %8.8X)\n",
498 walk_state->op_info->flags)); 493 walk_state->op_info->name,
494 walk_state->op_info->flags));
499 495
500 /* Executing a type1 or type2 opcode outside of a method */ 496 /* Executing a type1 or type2 opcode outside of a method */
501 497
502 status = acpi_ds_exec_begin_op (walk_state, out_op); 498 status =
503 return_ACPI_STATUS (status); 499 acpi_ds_exec_begin_op(walk_state, out_op);
500 return_ACPI_STATUS(status);
504 } 501 }
505 return_ACPI_STATUS (AE_OK); 502 return_ACPI_STATUS(AE_OK);
506 } 503 }
507 504
508 /* Get the name we are going to enter or lookup in the namespace */ 505 /* Get the name we are going to enter or lookup in the namespace */
@@ -514,28 +511,27 @@ acpi_ds_load2_begin_op (
514 if (!buffer_ptr) { 511 if (!buffer_ptr) {
515 /* No name, just exit */ 512 /* No name, just exit */
516 513
517 return_ACPI_STATUS (AE_OK); 514 return_ACPI_STATUS(AE_OK);
518 } 515 }
519 } 516 } else {
520 else {
521 /* Get name from the op */ 517 /* Get name from the op */
522 518
523 buffer_ptr = (char *) &op->named.name; 519 buffer_ptr = (char *)&op->named.name;
524 } 520 }
525 } 521 } else {
526 else {
527 /* Get the namestring from the raw AML */ 522 /* Get the namestring from the raw AML */
528 523
529 buffer_ptr = acpi_ps_get_next_namestring (&walk_state->parser_state); 524 buffer_ptr =
525 acpi_ps_get_next_namestring(&walk_state->parser_state);
530 } 526 }
531 527
532 /* Map the opcode into an internal object type */ 528 /* Map the opcode into an internal object type */
533 529
534 object_type = walk_state->op_info->object_type; 530 object_type = walk_state->op_info->object_type;
535 531
536 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, 532 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
537 "State=%p Op=%p Type=%X\n", walk_state, op, object_type)); 533 "State=%p Op=%p Type=%X\n", walk_state, op,
538 534 object_type));
539 535
540 switch (walk_state->opcode) { 536 switch (walk_state->opcode) {
541 case AML_FIELD_OP: 537 case AML_FIELD_OP:
@@ -553,9 +549,10 @@ acpi_ds_load2_begin_op (
553 * Don't enter the name into the namespace, but look it up 549 * Don't enter the name into the namespace, but look it up
554 * for use later. 550 * for use later.
555 */ 551 */
556 status = acpi_ns_lookup (walk_state->scope_info, buffer_ptr, object_type, 552 status =
557 ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, 553 acpi_ns_lookup(walk_state->scope_info, buffer_ptr,
558 walk_state, &(node)); 554 object_type, ACPI_IMODE_EXECUTE,
555 ACPI_NS_SEARCH_PARENT, walk_state, &(node));
559 break; 556 break;
560 557
561 case AML_SCOPE_OP: 558 case AML_SCOPE_OP:
@@ -565,28 +562,28 @@ acpi_ds_load2_begin_op (
565 * Don't enter the name into the namespace, but look it up 562 * Don't enter the name into the namespace, but look it up
566 * for use later. 563 * for use later.
567 */ 564 */
568 status = acpi_ns_lookup (walk_state->scope_info, buffer_ptr, object_type, 565 status =
569 ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, 566 acpi_ns_lookup(walk_state->scope_info, buffer_ptr,
570 walk_state, &(node)); 567 object_type, ACPI_IMODE_EXECUTE,
571 if (ACPI_FAILURE (status)) { 568 ACPI_NS_SEARCH_PARENT, walk_state, &(node));
569 if (ACPI_FAILURE(status)) {
572#ifdef ACPI_ASL_COMPILER 570#ifdef ACPI_ASL_COMPILER
573 if (status == AE_NOT_FOUND) { 571 if (status == AE_NOT_FOUND) {
574 status = AE_OK; 572 status = AE_OK;
575 } 573 } else {
576 else { 574 ACPI_REPORT_NSERROR(buffer_ptr, status);
577 ACPI_REPORT_NSERROR (buffer_ptr, status);
578 } 575 }
579#else 576#else
580 ACPI_REPORT_NSERROR (buffer_ptr, status); 577 ACPI_REPORT_NSERROR(buffer_ptr, status);
581#endif 578#endif
582 return_ACPI_STATUS (status); 579 return_ACPI_STATUS(status);
583 } 580 }
584 /* 581 /*
585 * We must check to make sure that the target is 582 * We must check to make sure that the target is
586 * one of the opcodes that actually opens a scope 583 * one of the opcodes that actually opens a scope
587 */ 584 */
588 switch (node->type) { 585 switch (node->type) {
589 case ACPI_TYPE_LOCAL_SCOPE: /* Scope */ 586 case ACPI_TYPE_LOCAL_SCOPE: /* Scope */
590 case ACPI_TYPE_DEVICE: 587 case ACPI_TYPE_DEVICE:
591 case ACPI_TYPE_POWER: 588 case ACPI_TYPE_POWER:
592 case ACPI_TYPE_PROCESSOR: 589 case ACPI_TYPE_PROCESSOR:
@@ -607,9 +604,7 @@ acpi_ds_load2_begin_op (
607 * Scope (DEB) { ... } 604 * Scope (DEB) { ... }
608 */ 605 */
609 606
610 ACPI_REPORT_WARNING (( 607 ACPI_REPORT_WARNING(("Type override - [%4.4s] had invalid type (%s) for Scope operator, changed to (Scope)\n", buffer_ptr, acpi_ut_get_type_name(node->type)));
611 "Type override - [%4.4s] had invalid type (%s) for Scope operator, changed to (Scope)\n",
612 buffer_ptr, acpi_ut_get_type_name (node->type)));
613 608
614 node->type = ACPI_TYPE_ANY; 609 node->type = ACPI_TYPE_ANY;
615 walk_state->scope_info->common.value = ACPI_TYPE_ANY; 610 walk_state->scope_info->common.value = ACPI_TYPE_ANY;
@@ -619,9 +614,7 @@ acpi_ds_load2_begin_op (
619 614
620 /* All other types are an error */ 615 /* All other types are an error */
621 616
622 ACPI_REPORT_ERROR (( 617 ACPI_REPORT_ERROR(("Invalid type (%s) for target of Scope operator [%4.4s]\n", acpi_ut_get_type_name(node->type), buffer_ptr));
623 "Invalid type (%s) for target of Scope operator [%4.4s]\n",
624 acpi_ut_get_type_name (node->type), buffer_ptr));
625 618
626 return (AE_AML_OPERAND_TYPE); 619 return (AE_AML_OPERAND_TYPE);
627 } 620 }
@@ -636,14 +629,16 @@ acpi_ds_load2_begin_op (
636 629
637 node = op->common.node; 630 node = op->common.node;
638 631
639 if (acpi_ns_opens_scope (object_type)) { 632 if (acpi_ns_opens_scope(object_type)) {
640 status = acpi_ds_scope_stack_push (node, object_type, walk_state); 633 status =
641 if (ACPI_FAILURE (status)) { 634 acpi_ds_scope_stack_push(node, object_type,
642 return_ACPI_STATUS (status); 635 walk_state);
636 if (ACPI_FAILURE(status)) {
637 return_ACPI_STATUS(status);
643 } 638 }
644 639
645 } 640 }
646 return_ACPI_STATUS (AE_OK); 641 return_ACPI_STATUS(AE_OK);
647 } 642 }
648 643
649 /* 644 /*
@@ -664,23 +659,24 @@ acpi_ds_load2_begin_op (
664 659
665 /* Add new entry into namespace */ 660 /* Add new entry into namespace */
666 661
667 status = acpi_ns_lookup (walk_state->scope_info, buffer_ptr, object_type, 662 status =
668 ACPI_IMODE_LOAD_PASS2, ACPI_NS_NO_UPSEARCH, 663 acpi_ns_lookup(walk_state->scope_info, buffer_ptr,
669 walk_state, &(node)); 664 object_type, ACPI_IMODE_LOAD_PASS2,
665 ACPI_NS_NO_UPSEARCH, walk_state, &(node));
670 break; 666 break;
671 } 667 }
672 668
673 if (ACPI_FAILURE (status)) { 669 if (ACPI_FAILURE(status)) {
674 ACPI_REPORT_NSERROR (buffer_ptr, status); 670 ACPI_REPORT_NSERROR(buffer_ptr, status);
675 return_ACPI_STATUS (status); 671 return_ACPI_STATUS(status);
676 } 672 }
677 673
678 if (!op) { 674 if (!op) {
679 /* Create a new op */ 675 /* Create a new op */
680 676
681 op = acpi_ps_alloc_op (walk_state->opcode); 677 op = acpi_ps_alloc_op(walk_state->opcode);
682 if (!op) { 678 if (!op) {
683 return_ACPI_STATUS (AE_NO_MEMORY); 679 return_ACPI_STATUS(AE_NO_MEMORY);
684 } 680 }
685 681
686 /* Initialize the new op */ 682 /* Initialize the new op */
@@ -697,10 +693,9 @@ acpi_ds_load2_begin_op (
697 */ 693 */
698 op->common.node = node; 694 op->common.node = node;
699 695
700 return_ACPI_STATUS (status); 696 return_ACPI_STATUS(status);
701} 697}
702 698
703
704/******************************************************************************* 699/*******************************************************************************
705 * 700 *
706 * FUNCTION: acpi_ds_load2_end_op 701 * FUNCTION: acpi_ds_load2_end_op
@@ -714,26 +709,23 @@ acpi_ds_load2_begin_op (
714 * 709 *
715 ******************************************************************************/ 710 ******************************************************************************/
716 711
717acpi_status 712acpi_status acpi_ds_load2_end_op(struct acpi_walk_state *walk_state)
718acpi_ds_load2_end_op (
719 struct acpi_walk_state *walk_state)
720{ 713{
721 union acpi_parse_object *op; 714 union acpi_parse_object *op;
722 acpi_status status = AE_OK; 715 acpi_status status = AE_OK;
723 acpi_object_type object_type; 716 acpi_object_type object_type;
724 struct acpi_namespace_node *node; 717 struct acpi_namespace_node *node;
725 union acpi_parse_object *arg; 718 union acpi_parse_object *arg;
726 struct acpi_namespace_node *new_node; 719 struct acpi_namespace_node *new_node;
727#ifndef ACPI_NO_METHOD_EXECUTION 720#ifndef ACPI_NO_METHOD_EXECUTION
728 u32 i; 721 u32 i;
729#endif 722#endif
730 723
731 724 ACPI_FUNCTION_TRACE("ds_load2_end_op");
732 ACPI_FUNCTION_TRACE ("ds_load2_end_op");
733 725
734 op = walk_state->op; 726 op = walk_state->op;
735 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Opcode [%s] Op %p State %p\n", 727 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, "Opcode [%s] Op %p State %p\n",
736 walk_state->op_info->name, op, walk_state)); 728 walk_state->op_info->name, op, walk_state));
737 729
738 /* Check if opcode had an associated namespace object */ 730 /* Check if opcode had an associated namespace object */
739 731
@@ -742,23 +734,25 @@ acpi_ds_load2_end_op (
742 /* No namespace object. Executable opcode? */ 734 /* No namespace object. Executable opcode? */
743 735
744 if ((walk_state->op_info->class == AML_CLASS_EXECUTE) || 736 if ((walk_state->op_info->class == AML_CLASS_EXECUTE) ||
745 (walk_state->op_info->class == AML_CLASS_CONTROL)) { 737 (walk_state->op_info->class == AML_CLASS_CONTROL)) {
746 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, 738 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
747 "End/EXEC: %s (fl %8.8X)\n", walk_state->op_info->name, 739 "End/EXEC: %s (fl %8.8X)\n",
748 walk_state->op_info->flags)); 740 walk_state->op_info->name,
741 walk_state->op_info->flags));
749 742
750 /* Executing a type1 or type2 opcode outside of a method */ 743 /* Executing a type1 or type2 opcode outside of a method */
751 744
752 status = acpi_ds_exec_end_op (walk_state); 745 status = acpi_ds_exec_end_op(walk_state);
753 return_ACPI_STATUS (status); 746 return_ACPI_STATUS(status);
754 } 747 }
755#endif 748#endif
756 return_ACPI_STATUS (AE_OK); 749 return_ACPI_STATUS(AE_OK);
757 } 750 }
758 751
759 if (op->common.aml_opcode == AML_SCOPE_OP) { 752 if (op->common.aml_opcode == AML_SCOPE_OP) {
760 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, 753 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
761 "Ending scope Op=%p State=%p\n", op, walk_state)); 754 "Ending scope Op=%p State=%p\n", op,
755 walk_state));
762 } 756 }
763 757
764 object_type = walk_state->op_info->object_type; 758 object_type = walk_state->op_info->object_type;
@@ -773,18 +767,19 @@ acpi_ds_load2_end_op (
773 * Put the Node on the object stack (Contains the ACPI Name of 767 * Put the Node on the object stack (Contains the ACPI Name of
774 * this object) 768 * this object)
775 */ 769 */
776 walk_state->operands[0] = (void *) node; 770 walk_state->operands[0] = (void *)node;
777 walk_state->num_operands = 1; 771 walk_state->num_operands = 1;
778 772
779 /* Pop the scope stack */ 773 /* Pop the scope stack */
780 774
781 if (acpi_ns_opens_scope (object_type) && 775 if (acpi_ns_opens_scope(object_type) &&
782 (op->common.aml_opcode != AML_INT_METHODCALL_OP)) { 776 (op->common.aml_opcode != AML_INT_METHODCALL_OP)) {
783 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "(%s) Popping scope for Op %p\n", 777 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
784 acpi_ut_get_type_name (object_type), op)); 778 "(%s) Popping scope for Op %p\n",
779 acpi_ut_get_type_name(object_type), op));
785 780
786 status = acpi_ds_scope_stack_pop (walk_state); 781 status = acpi_ds_scope_stack_pop(walk_state);
787 if (ACPI_FAILURE (status)) { 782 if (ACPI_FAILURE(status)) {
788 goto cleanup; 783 goto cleanup;
789 } 784 }
790 } 785 }
@@ -817,9 +812,10 @@ acpi_ds_load2_end_op (
817 * AML_THERMALZONE 812 * AML_THERMALZONE
818 */ 813 */
819 814
820 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, 815 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
821 "Create-Load [%s] State=%p Op=%p named_obj=%p\n", 816 "Create-Load [%s] State=%p Op=%p named_obj=%p\n",
822 acpi_ps_get_opcode_name (op->common.aml_opcode), walk_state, op, node)); 817 acpi_ps_get_opcode_name(op->common.aml_opcode),
818 walk_state, op, node));
823 819
824 /* Decode the opcode */ 820 /* Decode the opcode */
825 821
@@ -834,27 +830,32 @@ acpi_ds_load2_end_op (
834 * Create the field object, but the field buffer and index must 830 * Create the field object, but the field buffer and index must
835 * be evaluated later during the execution phase 831 * be evaluated later during the execution phase
836 */ 832 */
837 status = acpi_ds_create_buffer_field (op, walk_state); 833 status = acpi_ds_create_buffer_field(op, walk_state);
838 break; 834 break;
839 835
840 836 case AML_TYPE_NAMED_FIELD:
841 case AML_TYPE_NAMED_FIELD:
842 837
843 switch (op->common.aml_opcode) { 838 switch (op->common.aml_opcode) {
844 case AML_INDEX_FIELD_OP: 839 case AML_INDEX_FIELD_OP:
845 840
846 status = acpi_ds_create_index_field (op, (acpi_handle) arg->common.node, 841 status =
847 walk_state); 842 acpi_ds_create_index_field(op,
843 (acpi_handle) arg->
844 common.node, walk_state);
848 break; 845 break;
849 846
850 case AML_BANK_FIELD_OP: 847 case AML_BANK_FIELD_OP:
851 848
852 status = acpi_ds_create_bank_field (op, arg->common.node, walk_state); 849 status =
850 acpi_ds_create_bank_field(op, arg->common.node,
851 walk_state);
853 break; 852 break;
854 853
855 case AML_FIELD_OP: 854 case AML_FIELD_OP:
856 855
857 status = acpi_ds_create_field (op, arg->common.node, walk_state); 856 status =
857 acpi_ds_create_field(op, arg->common.node,
858 walk_state);
858 break; 859 break;
859 860
860 default: 861 default:
@@ -863,43 +864,42 @@ acpi_ds_load2_end_op (
863 } 864 }
864 break; 865 break;
865 866
867 case AML_TYPE_NAMED_SIMPLE:
866 868
867 case AML_TYPE_NAMED_SIMPLE: 869 status = acpi_ds_create_operands(walk_state, arg);
868 870 if (ACPI_FAILURE(status)) {
869 status = acpi_ds_create_operands (walk_state, arg);
870 if (ACPI_FAILURE (status)) {
871 goto cleanup; 871 goto cleanup;
872 } 872 }
873 873
874 switch (op->common.aml_opcode) { 874 switch (op->common.aml_opcode) {
875 case AML_PROCESSOR_OP: 875 case AML_PROCESSOR_OP:
876 876
877 status = acpi_ex_create_processor (walk_state); 877 status = acpi_ex_create_processor(walk_state);
878 break; 878 break;
879 879
880 case AML_POWER_RES_OP: 880 case AML_POWER_RES_OP:
881 881
882 status = acpi_ex_create_power_resource (walk_state); 882 status = acpi_ex_create_power_resource(walk_state);
883 break; 883 break;
884 884
885 case AML_MUTEX_OP: 885 case AML_MUTEX_OP:
886 886
887 status = acpi_ex_create_mutex (walk_state); 887 status = acpi_ex_create_mutex(walk_state);
888 break; 888 break;
889 889
890 case AML_EVENT_OP: 890 case AML_EVENT_OP:
891 891
892 status = acpi_ex_create_event (walk_state); 892 status = acpi_ex_create_event(walk_state);
893 break; 893 break;
894 894
895 case AML_DATA_REGION_OP: 895 case AML_DATA_REGION_OP:
896 896
897 status = acpi_ex_create_table_region (walk_state); 897 status = acpi_ex_create_table_region(walk_state);
898 break; 898 break;
899 899
900 case AML_ALIAS_OP: 900 case AML_ALIAS_OP:
901 901
902 status = acpi_ex_create_alias (walk_state); 902 status = acpi_ex_create_alias(walk_state);
903 break; 903 break;
904 904
905 default: 905 default:
@@ -912,12 +912,12 @@ acpi_ds_load2_end_op (
912 /* Delete operands */ 912 /* Delete operands */
913 913
914 for (i = 1; i < walk_state->num_operands; i++) { 914 for (i = 1; i < walk_state->num_operands; i++) {
915 acpi_ut_remove_reference (walk_state->operands[i]); 915 acpi_ut_remove_reference(walk_state->operands[i]);
916 walk_state->operands[i] = NULL; 916 walk_state->operands[i] = NULL;
917 } 917 }
918 918
919 break; 919 break;
920#endif /* ACPI_NO_METHOD_EXECUTION */ 920#endif /* ACPI_NO_METHOD_EXECUTION */
921 921
922 case AML_TYPE_NAMED_COMPLEX: 922 case AML_TYPE_NAMED_COMPLEX:
923 923
@@ -933,9 +933,10 @@ acpi_ds_load2_end_op (
933 * If we have a valid region, initialize it 933 * If we have a valid region, initialize it
934 * Namespace is NOT locked at this point. 934 * Namespace is NOT locked at this point.
935 */ 935 */
936 status = acpi_ev_initialize_region (acpi_ns_get_attached_object (node), 936 status =
937 FALSE); 937 acpi_ev_initialize_region
938 if (ACPI_FAILURE (status)) { 938 (acpi_ns_get_attached_object(node), FALSE);
939 if (ACPI_FAILURE(status)) {
939 /* 940 /*
940 * If AE_NOT_EXIST is returned, it is not fatal 941 * If AE_NOT_EXIST is returned, it is not fatal
941 * because many regions get created before a handler 942 * because many regions get created before a handler
@@ -947,13 +948,11 @@ acpi_ds_load2_end_op (
947 } 948 }
948 break; 949 break;
949 950
950
951 case AML_NAME_OP: 951 case AML_NAME_OP:
952 952
953 status = acpi_ds_create_node (walk_state, node, op); 953 status = acpi_ds_create_node(walk_state, node, op);
954 break; 954 break;
955#endif /* ACPI_NO_METHOD_EXECUTION */ 955#endif /* ACPI_NO_METHOD_EXECUTION */
956
957 956
958 default: 957 default:
959 /* All NAMED_COMPLEX opcodes must be handled above */ 958 /* All NAMED_COMPLEX opcodes must be handled above */
@@ -962,27 +961,28 @@ acpi_ds_load2_end_op (
962 } 961 }
963 break; 962 break;
964 963
965
966 case AML_CLASS_INTERNAL: 964 case AML_CLASS_INTERNAL:
967 965
968 /* case AML_INT_NAMEPATH_OP: */ 966 /* case AML_INT_NAMEPATH_OP: */
969 break; 967 break;
970 968
971
972 case AML_CLASS_METHOD_CALL: 969 case AML_CLASS_METHOD_CALL:
973 970
974 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, 971 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
975 "RESOLVING-method_call: State=%p Op=%p named_obj=%p\n", 972 "RESOLVING-method_call: State=%p Op=%p named_obj=%p\n",
976 walk_state, op, node)); 973 walk_state, op, node));
977 974
978 /* 975 /*
979 * Lookup the method name and save the Node 976 * Lookup the method name and save the Node
980 */ 977 */
981 status = acpi_ns_lookup (walk_state->scope_info, arg->common.value.string, 978 status =
982 ACPI_TYPE_ANY, ACPI_IMODE_LOAD_PASS2, 979 acpi_ns_lookup(walk_state->scope_info,
983 ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE, 980 arg->common.value.string, ACPI_TYPE_ANY,
984 walk_state, &(new_node)); 981 ACPI_IMODE_LOAD_PASS2,
985 if (ACPI_SUCCESS (status)) { 982 ACPI_NS_SEARCH_PARENT |
983 ACPI_NS_DONT_OPEN_SCOPE, walk_state,
984 &(new_node));
985 if (ACPI_SUCCESS(status)) {
986 986
987 /* 987 /*
988 * Make sure that what we found is indeed a method 988 * Make sure that what we found is indeed a method
@@ -998,24 +998,20 @@ acpi_ds_load2_end_op (
998 * parser uses, so we can get it again at the end of this scope 998 * parser uses, so we can get it again at the end of this scope
999 */ 999 */
1000 op->common.node = new_node; 1000 op->common.node = new_node;
1001 } 1001 } else {
1002 else { 1002 ACPI_REPORT_NSERROR(arg->common.value.string, status);
1003 ACPI_REPORT_NSERROR (arg->common.value.string, status);
1004 } 1003 }
1005 break; 1004 break;
1006 1005
1007
1008 default: 1006 default:
1009 break; 1007 break;
1010 } 1008 }
1011 1009
1012cleanup: 1010 cleanup:
1013 1011
1014 /* Remove the Node pushed at the very beginning */ 1012 /* Remove the Node pushed at the very beginning */
1015 1013
1016 walk_state->operands[0] = NULL; 1014 walk_state->operands[0] = NULL;
1017 walk_state->num_operands = 0; 1015 walk_state->num_operands = 0;
1018 return_ACPI_STATUS (status); 1016 return_ACPI_STATUS(status);
1019} 1017}
1020
1021