aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/dispatcher/dswload.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@g5.osdl.org>2006-02-02 01:06:15 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2006-02-02 01:06:15 -0500
commit59ed2f59e4ea6a32f9591e378da7935f713a7000 (patch)
treea1276a611dbb1bc44685ef8af363e99603e60047 /drivers/acpi/dispatcher/dswload.c
parent9ad11ab48b1ad618bf47076e9e579f267f5306c2 (diff)
parentb8e4d89357fc434618a59c1047cac72641191805 (diff)
Merge branch 'release' of git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux-acpi-2.6
Diffstat (limited to 'drivers/acpi/dispatcher/dswload.c')
-rw-r--r--drivers/acpi/dispatcher/dswload.c270
1 files changed, 193 insertions, 77 deletions
diff --git a/drivers/acpi/dispatcher/dswload.c b/drivers/acpi/dispatcher/dswload.c
index 411731261c29..d3d24da31c81 100644
--- a/drivers/acpi/dispatcher/dswload.c
+++ b/drivers/acpi/dispatcher/dswload.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -127,7 +127,7 @@ acpi_ds_load1_begin_op(struct acpi_walk_state * walk_state,
127 char *path; 127 char *path;
128 u32 flags; 128 u32 flags;
129 129
130 ACPI_FUNCTION_NAME("ds_load1_begin_op"); 130 ACPI_FUNCTION_TRACE("ds_load1_begin_op");
131 131
132 op = walk_state->op; 132 op = walk_state->op;
133 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, "Op=%p State=%p\n", op, 133 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, "Op=%p State=%p\n", op,
@@ -138,14 +138,14 @@ acpi_ds_load1_begin_op(struct acpi_walk_state * walk_state,
138 if (op) { 138 if (op) {
139 if (!(walk_state->op_info->flags & AML_NAMED)) { 139 if (!(walk_state->op_info->flags & AML_NAMED)) {
140 *out_op = op; 140 *out_op = op;
141 return (AE_OK); 141 return_ACPI_STATUS(AE_OK);
142 } 142 }
143 143
144 /* Check if this object has already been installed in the namespace */ 144 /* Check if this object has already been installed in the namespace */
145 145
146 if (op->common.node) { 146 if (op->common.node) {
147 *out_op = op; 147 *out_op = op;
148 return (AE_OK); 148 return_ACPI_STATUS(AE_OK);
149 } 149 }
150 } 150 }
151 151
@@ -187,8 +187,8 @@ acpi_ds_load1_begin_op(struct acpi_walk_state * walk_state,
187 } 187 }
188#endif 188#endif
189 if (ACPI_FAILURE(status)) { 189 if (ACPI_FAILURE(status)) {
190 ACPI_REPORT_NSERROR(path, status); 190 ACPI_ERROR_NAMESPACE(path, status);
191 return (status); 191 return_ACPI_STATUS(status);
192 } 192 }
193 193
194 /* 194 /*
@@ -233,9 +233,11 @@ acpi_ds_load1_begin_op(struct acpi_walk_state * walk_state,
233 233
234 /* All other types are an error */ 234 /* All other types are an error */
235 235
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)); 236 ACPI_ERROR((AE_INFO,
237 "Invalid type (%s) for target of Scope operator [%4.4s] (Cannot override)",
238 acpi_ut_get_type_name(node->type), path));
237 239
238 return (AE_AML_OPERAND_TYPE); 240 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
239 } 241 }
240 break; 242 break;
241 243
@@ -257,6 +259,7 @@ acpi_ds_load1_begin_op(struct acpi_walk_state * walk_state,
257 * buffer_field, or Package), the name of the object is already 259 * buffer_field, or Package), the name of the object is already
258 * in the namespace. 260 * in the namespace.
259 */ 261 */
262
260 if (walk_state->deferred_node) { 263 if (walk_state->deferred_node) {
261 /* This name is already in the namespace, get the node */ 264 /* This name is already in the namespace, get the node */
262 265
@@ -265,6 +268,16 @@ acpi_ds_load1_begin_op(struct acpi_walk_state * walk_state,
265 break; 268 break;
266 } 269 }
267 270
271 /*
272 * If we are executing a method, do not create any namespace objects
273 * during the load phase, only during execution.
274 */
275 if (walk_state->method_node) {
276 node = NULL;
277 status = AE_OK;
278 break;
279 }
280
268 flags = ACPI_NS_NO_UPSEARCH; 281 flags = ACPI_NS_NO_UPSEARCH;
269 if ((walk_state->opcode != AML_SCOPE_OP) && 282 if ((walk_state->opcode != AML_SCOPE_OP) &&
270 (!(walk_state->parse_flags & ACPI_PARSE_DEFERRED_OP))) { 283 (!(walk_state->parse_flags & ACPI_PARSE_DEFERRED_OP))) {
@@ -289,8 +302,8 @@ acpi_ds_load1_begin_op(struct acpi_walk_state * walk_state,
289 ACPI_IMODE_LOAD_PASS1, flags, walk_state, 302 ACPI_IMODE_LOAD_PASS1, flags, walk_state,
290 &(node)); 303 &(node));
291 if (ACPI_FAILURE(status)) { 304 if (ACPI_FAILURE(status)) {
292 ACPI_REPORT_NSERROR(path, status); 305 ACPI_ERROR_NAMESPACE(path, status);
293 return (status); 306 return_ACPI_STATUS(status);
294 } 307 }
295 break; 308 break;
296 } 309 }
@@ -302,28 +315,29 @@ acpi_ds_load1_begin_op(struct acpi_walk_state * walk_state,
302 315
303 op = acpi_ps_alloc_op(walk_state->opcode); 316 op = acpi_ps_alloc_op(walk_state->opcode);
304 if (!op) { 317 if (!op) {
305 return (AE_NO_MEMORY); 318 return_ACPI_STATUS(AE_NO_MEMORY);
306 } 319 }
307 } 320 }
308 321
309 /* Initialize */ 322 /* Initialize the op */
310
311 op->named.name = node->name.integer;
312 323
313#if (defined (ACPI_NO_METHOD_EXECUTION) || defined (ACPI_CONSTANT_EVAL_ONLY)) 324#if (defined (ACPI_NO_METHOD_EXECUTION) || defined (ACPI_CONSTANT_EVAL_ONLY))
314 op->named.path = (u8 *) path; 325 op->named.path = ACPI_CAST_PTR(u8, path);
315#endif 326#endif
316 327
317 /* 328 if (node) {
318 * Put the Node in the "op" object that the parser uses, so we 329 /*
319 * can get it again quickly when this scope is closed 330 * Put the Node in the "op" object that the parser uses, so we
320 */ 331 * can get it again quickly when this scope is closed
321 op->common.node = node; 332 */
333 op->common.node = node;
334 op->named.name = node->name.integer;
335 }
336
322 acpi_ps_append_arg(acpi_ps_get_parent_scope(&walk_state->parser_state), 337 acpi_ps_append_arg(acpi_ps_get_parent_scope(&walk_state->parser_state),
323 op); 338 op);
324
325 *out_op = op; 339 *out_op = op;
326 return (status); 340 return_ACPI_STATUS(status);
327} 341}
328 342
329/******************************************************************************* 343/*******************************************************************************
@@ -339,13 +353,13 @@ acpi_ds_load1_begin_op(struct acpi_walk_state * walk_state,
339 * 353 *
340 ******************************************************************************/ 354 ******************************************************************************/
341 355
342acpi_status acpi_ds_load1_end_op(struct acpi_walk_state * walk_state) 356acpi_status acpi_ds_load1_end_op(struct acpi_walk_state *walk_state)
343{ 357{
344 union acpi_parse_object *op; 358 union acpi_parse_object *op;
345 acpi_object_type object_type; 359 acpi_object_type object_type;
346 acpi_status status = AE_OK; 360 acpi_status status = AE_OK;
347 361
348 ACPI_FUNCTION_NAME("ds_load1_end_op"); 362 ACPI_FUNCTION_TRACE("ds_load1_end_op");
349 363
350 op = walk_state->op; 364 op = walk_state->op;
351 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, "Op=%p State=%p\n", op, 365 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, "Op=%p State=%p\n", op,
@@ -354,7 +368,7 @@ acpi_status acpi_ds_load1_end_op(struct acpi_walk_state * walk_state)
354 /* We are only interested in opcodes that have an associated name */ 368 /* We are only interested in opcodes that have an associated name */
355 369
356 if (!(walk_state->op_info->flags & (AML_NAMED | AML_FIELD))) { 370 if (!(walk_state->op_info->flags & (AML_NAMED | AML_FIELD))) {
357 return (AE_OK); 371 return_ACPI_STATUS(AE_OK);
358 } 372 }
359 373
360 /* Get the object type to determine if we should pop the scope */ 374 /* Get the object type to determine if we should pop the scope */
@@ -363,21 +377,37 @@ acpi_status acpi_ds_load1_end_op(struct acpi_walk_state * walk_state)
363 377
364#ifndef ACPI_NO_METHOD_EXECUTION 378#ifndef ACPI_NO_METHOD_EXECUTION
365 if (walk_state->op_info->flags & AML_FIELD) { 379 if (walk_state->op_info->flags & AML_FIELD) {
366 if (walk_state->opcode == AML_FIELD_OP || 380 /*
367 walk_state->opcode == AML_BANK_FIELD_OP || 381 * If we are executing a method, do not create any namespace objects
368 walk_state->opcode == AML_INDEX_FIELD_OP) { 382 * during the load phase, only during execution.
369 status = acpi_ds_init_field_objects(op, walk_state); 383 */
384 if (!walk_state->method_node) {
385 if (walk_state->opcode == AML_FIELD_OP ||
386 walk_state->opcode == AML_BANK_FIELD_OP ||
387 walk_state->opcode == AML_INDEX_FIELD_OP) {
388 status =
389 acpi_ds_init_field_objects(op, walk_state);
390 }
370 } 391 }
371 return (status); 392 return_ACPI_STATUS(status);
372 } 393 }
373 394
374 if (op->common.aml_opcode == AML_REGION_OP) { 395 /*
375 status = acpi_ex_create_region(op->named.data, op->named.length, 396 * If we are executing a method, do not create any namespace objects
376 (acpi_adr_space_type) 397 * during the load phase, only during execution.
377 ((op->common.value.arg)->common. 398 */
378 value.integer), walk_state); 399 if (!walk_state->method_node) {
379 if (ACPI_FAILURE(status)) { 400 if (op->common.aml_opcode == AML_REGION_OP) {
380 return (status); 401 status =
402 acpi_ex_create_region(op->named.data,
403 op->named.length,
404 (acpi_adr_space_type)
405 ((op->common.value.arg)->
406 common.value.integer),
407 walk_state);
408 if (ACPI_FAILURE(status)) {
409 return_ACPI_STATUS(status);
410 }
381 } 411 }
382 } 412 }
383#endif 413#endif
@@ -391,47 +421,63 @@ acpi_status acpi_ds_load1_end_op(struct acpi_walk_state * walk_state)
391 common. 421 common.
392 aml_opcode))-> 422 aml_opcode))->
393 object_type; 423 object_type;
394 op->common.node->type = (u8) object_type; 424
425 /* Set node type if we have a namespace node */
426
427 if (op->common.node) {
428 op->common.node->type = (u8) object_type;
429 }
395 } 430 }
396 } 431 }
397 432
398 if (op->common.aml_opcode == AML_METHOD_OP) { 433 /*
399 /* 434 * If we are executing a method, do not create any namespace objects
400 * method_op pkg_length name_string method_flags term_list 435 * during the load phase, only during execution.
401 * 436 */
402 * Note: We must create the method node/object pair as soon as we 437 if (!walk_state->method_node) {
403 * see the method declaration. This allows later pass1 parsing 438 if (op->common.aml_opcode == AML_METHOD_OP) {
404 * of invocations of the method (need to know the number of 439 /*
405 * arguments.) 440 * method_op pkg_length name_string method_flags term_list
406 */ 441 *
407 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, 442 * Note: We must create the method node/object pair as soon as we
408 "LOADING-Method: State=%p Op=%p named_obj=%p\n", 443 * see the method declaration. This allows later pass1 parsing
409 walk_state, op, op->named.node)); 444 * of invocations of the method (need to know the number of
445 * arguments.)
446 */
447 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
448 "LOADING-Method: State=%p Op=%p named_obj=%p\n",
449 walk_state, op, op->named.node));
410 450
411 if (!acpi_ns_get_attached_object(op->named.node)) { 451 if (!acpi_ns_get_attached_object(op->named.node)) {
412 walk_state->operands[0] = (void *)op->named.node; 452 walk_state->operands[0] =
413 walk_state->num_operands = 1; 453 ACPI_CAST_PTR(void, op->named.node);
454 walk_state->num_operands = 1;
414 455
415 status = 456 status =
416 acpi_ds_create_operands(walk_state, 457 acpi_ds_create_operands(walk_state,
417 op->common.value.arg); 458 op->common.value.
418 if (ACPI_SUCCESS(status)) { 459 arg);
419 status = acpi_ex_create_method(op->named.data, 460 if (ACPI_SUCCESS(status)) {
420 op->named.length, 461 status =
421 walk_state); 462 acpi_ex_create_method(op->named.
422 } 463 data,
423 walk_state->operands[0] = NULL; 464 op->named.
424 walk_state->num_operands = 0; 465 length,
466 walk_state);
467 }
468 walk_state->operands[0] = NULL;
469 walk_state->num_operands = 0;
425 470
426 if (ACPI_FAILURE(status)) { 471 if (ACPI_FAILURE(status)) {
427 return (status); 472 return_ACPI_STATUS(status);
473 }
428 } 474 }
429 } 475 }
430 } 476 }
431 477
432 /* Pop the scope stack */ 478 /* Pop the scope stack (only if loading a table) */
433 479
434 if (acpi_ns_opens_scope(object_type)) { 480 if (!walk_state->method_node && acpi_ns_opens_scope(object_type)) {
435 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, 481 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
436 "(%s): Popping scope for Op %p\n", 482 "(%s): Popping scope for Op %p\n",
437 acpi_ut_get_type_name(object_type), op)); 483 acpi_ut_get_type_name(object_type), op));
@@ -439,7 +485,7 @@ acpi_status acpi_ds_load1_end_op(struct acpi_walk_state * walk_state)
439 status = acpi_ds_scope_stack_pop(walk_state); 485 status = acpi_ds_scope_stack_pop(walk_state);
440 } 486 }
441 487
442 return (status); 488 return_ACPI_STATUS(status);
443} 489}
444 490
445/******************************************************************************* 491/*******************************************************************************
@@ -456,8 +502,8 @@ acpi_status acpi_ds_load1_end_op(struct acpi_walk_state * walk_state)
456 ******************************************************************************/ 502 ******************************************************************************/
457 503
458acpi_status 504acpi_status
459acpi_ds_load2_begin_op(struct acpi_walk_state * walk_state, 505acpi_ds_load2_begin_op(struct acpi_walk_state *walk_state,
460 union acpi_parse_object ** out_op) 506 union acpi_parse_object **out_op)
461{ 507{
462 union acpi_parse_object *op; 508 union acpi_parse_object *op;
463 struct acpi_namespace_node *node; 509 struct acpi_namespace_node *node;
@@ -574,10 +620,10 @@ acpi_ds_load2_begin_op(struct acpi_walk_state * walk_state,
574 if (status == AE_NOT_FOUND) { 620 if (status == AE_NOT_FOUND) {
575 status = AE_OK; 621 status = AE_OK;
576 } else { 622 } else {
577 ACPI_REPORT_NSERROR(buffer_ptr, status); 623 ACPI_ERROR_NAMESPACE(buffer_ptr, status);
578 } 624 }
579#else 625#else
580 ACPI_REPORT_NSERROR(buffer_ptr, status); 626 ACPI_ERROR_NAMESPACE(buffer_ptr, status);
581#endif 627#endif
582 return_ACPI_STATUS(status); 628 return_ACPI_STATUS(status);
583 } 629 }
@@ -607,7 +653,10 @@ acpi_ds_load2_begin_op(struct acpi_walk_state * walk_state,
607 * Scope (DEB) { ... } 653 * Scope (DEB) { ... }
608 */ 654 */
609 655
610 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))); 656 ACPI_WARNING((AE_INFO,
657 "Type override - [%4.4s] had invalid type (%s) for Scope operator, changed to (Scope)",
658 buffer_ptr,
659 acpi_ut_get_type_name(node->type)));
611 660
612 node->type = ACPI_TYPE_ANY; 661 node->type = ACPI_TYPE_ANY;
613 walk_state->scope_info->common.value = ACPI_TYPE_ANY; 662 walk_state->scope_info->common.value = ACPI_TYPE_ANY;
@@ -617,7 +666,10 @@ acpi_ds_load2_begin_op(struct acpi_walk_state * walk_state,
617 666
618 /* All other types are an error */ 667 /* All other types are an error */
619 668
620 ACPI_REPORT_ERROR(("Invalid type (%s) for target of Scope operator [%4.4s]\n", acpi_ut_get_type_name(node->type), buffer_ptr)); 669 ACPI_ERROR((AE_INFO,
670 "Invalid type (%s) for target of Scope operator [%4.4s]",
671 acpi_ut_get_type_name(node->type),
672 buffer_ptr));
621 673
622 return (AE_AML_OPERAND_TYPE); 674 return (AE_AML_OPERAND_TYPE);
623 } 675 }
@@ -670,7 +722,7 @@ acpi_ds_load2_begin_op(struct acpi_walk_state * walk_state,
670 } 722 }
671 723
672 if (ACPI_FAILURE(status)) { 724 if (ACPI_FAILURE(status)) {
673 ACPI_REPORT_NSERROR(buffer_ptr, status); 725 ACPI_ERROR_NAMESPACE(buffer_ptr, status);
674 return_ACPI_STATUS(status); 726 return_ACPI_STATUS(status);
675 } 727 }
676 728
@@ -840,6 +892,13 @@ acpi_status acpi_ds_load2_end_op(struct acpi_walk_state *walk_state)
840 892
841 case AML_TYPE_NAMED_FIELD: 893 case AML_TYPE_NAMED_FIELD:
842 894
895 /*
896 * If we are executing a method, initialize the field
897 */
898 if (walk_state->method_node) {
899 status = acpi_ds_init_field_objects(op, walk_state);
900 }
901
843 switch (op->common.aml_opcode) { 902 switch (op->common.aml_opcode) {
844 case AML_INDEX_FIELD_OP: 903 case AML_INDEX_FIELD_OP:
845 904
@@ -929,6 +988,24 @@ acpi_status acpi_ds_load2_end_op(struct acpi_walk_state *walk_state)
929 switch (op->common.aml_opcode) { 988 switch (op->common.aml_opcode) {
930#ifndef ACPI_NO_METHOD_EXECUTION 989#ifndef ACPI_NO_METHOD_EXECUTION
931 case AML_REGION_OP: 990 case AML_REGION_OP:
991
992 /*
993 * If we are executing a method, initialize the region
994 */
995 if (walk_state->method_node) {
996 status =
997 acpi_ex_create_region(op->named.data,
998 op->named.length,
999 (acpi_adr_space_type)
1000 ((op->common.value.
1001 arg)->common.value.
1002 integer),
1003 walk_state);
1004 if (ACPI_FAILURE(status)) {
1005 return (status);
1006 }
1007 }
1008
932 /* 1009 /*
933 * The op_region is not fully parsed at this time. Only valid 1010 * The op_region is not fully parsed at this time. Only valid
934 * argument is the space_id. (We must save the address of the 1011 * argument is the space_id. (We must save the address of the
@@ -957,11 +1034,50 @@ acpi_status acpi_ds_load2_end_op(struct acpi_walk_state *walk_state)
957 1034
958 status = acpi_ds_create_node(walk_state, node, op); 1035 status = acpi_ds_create_node(walk_state, node, op);
959 break; 1036 break;
1037
1038 case AML_METHOD_OP:
1039 /*
1040 * method_op pkg_length name_string method_flags term_list
1041 *
1042 * Note: We must create the method node/object pair as soon as we
1043 * see the method declaration. This allows later pass1 parsing
1044 * of invocations of the method (need to know the number of
1045 * arguments.)
1046 */
1047 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
1048 "LOADING-Method: State=%p Op=%p named_obj=%p\n",
1049 walk_state, op, op->named.node));
1050
1051 if (!acpi_ns_get_attached_object(op->named.node)) {
1052 walk_state->operands[0] =
1053 ACPI_CAST_PTR(void, op->named.node);
1054 walk_state->num_operands = 1;
1055
1056 status =
1057 acpi_ds_create_operands(walk_state,
1058 op->common.value.
1059 arg);
1060 if (ACPI_SUCCESS(status)) {
1061 status =
1062 acpi_ex_create_method(op->named.
1063 data,
1064 op->named.
1065 length,
1066 walk_state);
1067 }
1068 walk_state->operands[0] = NULL;
1069 walk_state->num_operands = 0;
1070
1071 if (ACPI_FAILURE(status)) {
1072 return_ACPI_STATUS(status);
1073 }
1074 }
1075 break;
1076
960#endif /* ACPI_NO_METHOD_EXECUTION */ 1077#endif /* ACPI_NO_METHOD_EXECUTION */
961 1078
962 default: 1079 default:
963 /* All NAMED_COMPLEX opcodes must be handled above */ 1080 /* All NAMED_COMPLEX opcodes must be handled above */
964 /* Note: Method objects were already created in Pass 1 */
965 break; 1081 break;
966 } 1082 }
967 break; 1083 break;
@@ -1004,7 +1120,7 @@ acpi_status acpi_ds_load2_end_op(struct acpi_walk_state *walk_state)
1004 */ 1120 */
1005 op->common.node = new_node; 1121 op->common.node = new_node;
1006 } else { 1122 } else {
1007 ACPI_REPORT_NSERROR(arg->common.value.string, status); 1123 ACPI_ERROR_NAMESPACE(arg->common.value.string, status);
1008 } 1124 }
1009 break; 1125 break;
1010 1126