| .. | .. |
|---|
| 21 | 21 | acpi_db_walk_for_execute(acpi_handle obj_handle, |
|---|
| 22 | 22 | u32 nesting_level, void *context, void **return_value); |
|---|
| 23 | 23 | |
|---|
| 24 | +static acpi_status acpi_db_evaluate_object(struct acpi_namespace_node *node); |
|---|
| 25 | + |
|---|
| 24 | 26 | /******************************************************************************* |
|---|
| 25 | 27 | * |
|---|
| 26 | 28 | * FUNCTION: acpi_db_set_method_breakpoint |
|---|
| .. | .. |
|---|
| 302 | 304 | } |
|---|
| 303 | 305 | |
|---|
| 304 | 306 | status = acpi_ut_allocate_owner_id(&obj_desc->method.owner_id); |
|---|
| 307 | + if (ACPI_FAILURE(status)) { |
|---|
| 308 | + return (status); |
|---|
| 309 | + } |
|---|
| 310 | + |
|---|
| 305 | 311 | walk_state->owner_id = obj_desc->method.owner_id; |
|---|
| 306 | 312 | |
|---|
| 307 | 313 | /* Push start scope on scope stack and make it current */ |
|---|
| .. | .. |
|---|
| 317 | 323 | walk_state->parse_flags |= ACPI_PARSE_DISASSEMBLE; |
|---|
| 318 | 324 | |
|---|
| 319 | 325 | status = acpi_ps_parse_aml(walk_state); |
|---|
| 326 | + if (ACPI_FAILURE(status)) { |
|---|
| 327 | + return (status); |
|---|
| 328 | + } |
|---|
| 329 | + |
|---|
| 320 | 330 | (void)acpi_dm_parse_deferred_ops(op); |
|---|
| 321 | 331 | |
|---|
| 322 | 332 | /* Now we can disassemble the method */ |
|---|
| .. | .. |
|---|
| 338 | 348 | |
|---|
| 339 | 349 | /******************************************************************************* |
|---|
| 340 | 350 | * |
|---|
| 341 | | - * FUNCTION: acpi_db_walk_for_execute |
|---|
| 351 | + * FUNCTION: acpi_db_evaluate_object |
|---|
| 342 | 352 | * |
|---|
| 343 | | - * PARAMETERS: Callback from walk_namespace |
|---|
| 353 | + * PARAMETERS: node - Namespace node for the object |
|---|
| 344 | 354 | * |
|---|
| 345 | 355 | * RETURN: Status |
|---|
| 346 | 356 | * |
|---|
| 347 | | - * DESCRIPTION: Batch execution module. Currently only executes predefined |
|---|
| 348 | | - * ACPI names. |
|---|
| 357 | + * DESCRIPTION: Main execution function for the Evaluate/Execute/All debugger |
|---|
| 358 | + * commands. |
|---|
| 349 | 359 | * |
|---|
| 350 | 360 | ******************************************************************************/ |
|---|
| 351 | 361 | |
|---|
| 352 | | -static acpi_status |
|---|
| 353 | | -acpi_db_walk_for_execute(acpi_handle obj_handle, |
|---|
| 354 | | - u32 nesting_level, void *context, void **return_value) |
|---|
| 362 | +static acpi_status acpi_db_evaluate_object(struct acpi_namespace_node *node) |
|---|
| 355 | 363 | { |
|---|
| 356 | | - struct acpi_namespace_node *node = |
|---|
| 357 | | - (struct acpi_namespace_node *)obj_handle; |
|---|
| 358 | | - struct acpi_db_execute_walk *info = |
|---|
| 359 | | - (struct acpi_db_execute_walk *)context; |
|---|
| 360 | | - struct acpi_buffer return_obj; |
|---|
| 361 | | - acpi_status status; |
|---|
| 362 | 364 | char *pathname; |
|---|
| 363 | 365 | u32 i; |
|---|
| 364 | 366 | struct acpi_device_info *obj_info; |
|---|
| 365 | 367 | struct acpi_object_list param_objects; |
|---|
| 366 | 368 | union acpi_object params[ACPI_METHOD_NUM_ARGS]; |
|---|
| 367 | | - const union acpi_predefined_info *predefined; |
|---|
| 368 | | - |
|---|
| 369 | | - predefined = acpi_ut_match_predefined_method(node->name.ascii); |
|---|
| 370 | | - if (!predefined) { |
|---|
| 371 | | - return (AE_OK); |
|---|
| 372 | | - } |
|---|
| 373 | | - |
|---|
| 374 | | - if (node->type == ACPI_TYPE_LOCAL_SCOPE) { |
|---|
| 375 | | - return (AE_OK); |
|---|
| 376 | | - } |
|---|
| 369 | + struct acpi_buffer return_obj; |
|---|
| 370 | + acpi_status status; |
|---|
| 377 | 371 | |
|---|
| 378 | 372 | pathname = acpi_ns_get_external_pathname(node); |
|---|
| 379 | 373 | if (!pathname) { |
|---|
| .. | .. |
|---|
| 382 | 376 | |
|---|
| 383 | 377 | /* Get the object info for number of method parameters */ |
|---|
| 384 | 378 | |
|---|
| 385 | | - status = acpi_get_object_info(obj_handle, &obj_info); |
|---|
| 379 | + status = acpi_get_object_info(node, &obj_info); |
|---|
| 386 | 380 | if (ACPI_FAILURE(status)) { |
|---|
| 387 | 381 | ACPI_FREE(pathname); |
|---|
| 388 | 382 | return (status); |
|---|
| .. | .. |
|---|
| 413 | 407 | acpi_gbl_method_executing = TRUE; |
|---|
| 414 | 408 | |
|---|
| 415 | 409 | status = acpi_evaluate_object(node, NULL, ¶m_objects, &return_obj); |
|---|
| 410 | + acpi_gbl_method_executing = FALSE; |
|---|
| 416 | 411 | |
|---|
| 417 | 412 | acpi_os_printf("%-32s returned %s\n", pathname, |
|---|
| 418 | 413 | acpi_format_exception(status)); |
|---|
| 419 | | - acpi_gbl_method_executing = FALSE; |
|---|
| 414 | + if (return_obj.length) { |
|---|
| 415 | + acpi_os_printf("Evaluation of %s returned object %p, " |
|---|
| 416 | + "external buffer length %X\n", |
|---|
| 417 | + pathname, return_obj.pointer, |
|---|
| 418 | + (u32)return_obj.length); |
|---|
| 419 | + |
|---|
| 420 | + acpi_db_dump_external_object(return_obj.pointer, 1); |
|---|
| 421 | + acpi_os_printf("\n"); |
|---|
| 422 | + } |
|---|
| 423 | + |
|---|
| 420 | 424 | ACPI_FREE(pathname); |
|---|
| 421 | 425 | |
|---|
| 422 | 426 | /* Ignore status from method execution */ |
|---|
| 427 | + |
|---|
| 428 | + return (AE_OK); |
|---|
| 429 | + |
|---|
| 430 | + /* Update count, check if we have executed enough methods */ |
|---|
| 431 | + |
|---|
| 432 | +} |
|---|
| 433 | + |
|---|
| 434 | +/******************************************************************************* |
|---|
| 435 | + * |
|---|
| 436 | + * FUNCTION: acpi_db_walk_for_execute |
|---|
| 437 | + * |
|---|
| 438 | + * PARAMETERS: Callback from walk_namespace |
|---|
| 439 | + * |
|---|
| 440 | + * RETURN: Status |
|---|
| 441 | + * |
|---|
| 442 | + * DESCRIPTION: Batch execution function. Evaluates all "predefined" objects -- |
|---|
| 443 | + * the nameseg begins with an underscore. |
|---|
| 444 | + * |
|---|
| 445 | + ******************************************************************************/ |
|---|
| 446 | + |
|---|
| 447 | +static acpi_status |
|---|
| 448 | +acpi_db_walk_for_execute(acpi_handle obj_handle, |
|---|
| 449 | + u32 nesting_level, void *context, void **return_value) |
|---|
| 450 | +{ |
|---|
| 451 | + struct acpi_namespace_node *node = |
|---|
| 452 | + (struct acpi_namespace_node *)obj_handle; |
|---|
| 453 | + struct acpi_db_execute_walk *info = |
|---|
| 454 | + (struct acpi_db_execute_walk *)context; |
|---|
| 455 | + acpi_status status; |
|---|
| 456 | + const union acpi_predefined_info *predefined; |
|---|
| 457 | + |
|---|
| 458 | + predefined = acpi_ut_match_predefined_method(node->name.ascii); |
|---|
| 459 | + if (!predefined) { |
|---|
| 460 | + return (AE_OK); |
|---|
| 461 | + } |
|---|
| 462 | + |
|---|
| 463 | + if (node->type == ACPI_TYPE_LOCAL_SCOPE) { |
|---|
| 464 | + return (AE_OK); |
|---|
| 465 | + } |
|---|
| 466 | + |
|---|
| 467 | + acpi_db_evaluate_object(node); |
|---|
| 468 | + |
|---|
| 469 | + /* Ignore status from object evaluation */ |
|---|
| 423 | 470 | |
|---|
| 424 | 471 | status = AE_OK; |
|---|
| 425 | 472 | |
|---|
| .. | .. |
|---|
| 430 | 477 | status = AE_CTRL_TERMINATE; |
|---|
| 431 | 478 | } |
|---|
| 432 | 479 | |
|---|
| 480 | + return (status); |
|---|
| 481 | +} |
|---|
| 482 | + |
|---|
| 483 | +/******************************************************************************* |
|---|
| 484 | + * |
|---|
| 485 | + * FUNCTION: acpi_db_walk_for_execute_all |
|---|
| 486 | + * |
|---|
| 487 | + * PARAMETERS: Callback from walk_namespace |
|---|
| 488 | + * |
|---|
| 489 | + * RETURN: Status |
|---|
| 490 | + * |
|---|
| 491 | + * DESCRIPTION: Batch execution function. Evaluates all objects whose path ends |
|---|
| 492 | + * with the nameseg "Info->NameSeg". Used for the "ALL" command. |
|---|
| 493 | + * |
|---|
| 494 | + ******************************************************************************/ |
|---|
| 495 | + |
|---|
| 496 | +static acpi_status |
|---|
| 497 | +acpi_db_walk_for_execute_all(acpi_handle obj_handle, |
|---|
| 498 | + u32 nesting_level, |
|---|
| 499 | + void *context, void **return_value) |
|---|
| 500 | +{ |
|---|
| 501 | + struct acpi_namespace_node *node = |
|---|
| 502 | + (struct acpi_namespace_node *)obj_handle; |
|---|
| 503 | + struct acpi_db_execute_walk *info = |
|---|
| 504 | + (struct acpi_db_execute_walk *)context; |
|---|
| 505 | + acpi_status status; |
|---|
| 506 | + |
|---|
| 507 | + if (!ACPI_COMPARE_NAMESEG(node->name.ascii, info->name_seg)) { |
|---|
| 508 | + return (AE_OK); |
|---|
| 509 | + } |
|---|
| 510 | + |
|---|
| 511 | + if (node->type == ACPI_TYPE_LOCAL_SCOPE) { |
|---|
| 512 | + return (AE_OK); |
|---|
| 513 | + } |
|---|
| 514 | + |
|---|
| 515 | + /* Now evaluate the input object (node) */ |
|---|
| 516 | + |
|---|
| 517 | + acpi_db_evaluate_object(node); |
|---|
| 518 | + |
|---|
| 519 | + /* Ignore status from method execution */ |
|---|
| 520 | + |
|---|
| 521 | + status = AE_OK; |
|---|
| 522 | + |
|---|
| 523 | + /* Update count of executed methods/objects */ |
|---|
| 524 | + |
|---|
| 525 | + info->count++; |
|---|
| 433 | 526 | return (status); |
|---|
| 434 | 527 | } |
|---|
| 435 | 528 | |
|---|
| .. | .. |
|---|
| 462 | 555 | acpi_os_printf("Evaluated %u predefined names in the namespace\n", |
|---|
| 463 | 556 | info.count); |
|---|
| 464 | 557 | } |
|---|
| 558 | + |
|---|
| 559 | +/******************************************************************************* |
|---|
| 560 | + * |
|---|
| 561 | + * FUNCTION: acpi_db_evaluate_all |
|---|
| 562 | + * |
|---|
| 563 | + * PARAMETERS: none_acpi_gbl_db_method_info |
|---|
| 564 | + * |
|---|
| 565 | + * RETURN: None |
|---|
| 566 | + * |
|---|
| 567 | + * DESCRIPTION: Namespace batch execution. Implements the "ALL" command. |
|---|
| 568 | + * Execute all namepaths whose final nameseg matches the |
|---|
| 569 | + * input nameseg. |
|---|
| 570 | + * |
|---|
| 571 | + ******************************************************************************/ |
|---|
| 572 | + |
|---|
| 573 | +void acpi_db_evaluate_all(char *name_seg) |
|---|
| 574 | +{ |
|---|
| 575 | + struct acpi_db_execute_walk info; |
|---|
| 576 | + |
|---|
| 577 | + info.count = 0; |
|---|
| 578 | + info.max_count = ACPI_UINT32_MAX; |
|---|
| 579 | + ACPI_COPY_NAMESEG(info.name_seg, name_seg); |
|---|
| 580 | + info.name_seg[ACPI_NAMESEG_SIZE] = 0; |
|---|
| 581 | + |
|---|
| 582 | + /* Search all nodes in namespace */ |
|---|
| 583 | + |
|---|
| 584 | + (void)acpi_walk_namespace(ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, |
|---|
| 585 | + ACPI_UINT32_MAX, acpi_db_walk_for_execute_all, |
|---|
| 586 | + NULL, (void *)&info, NULL); |
|---|
| 587 | + |
|---|
| 588 | + acpi_os_printf("Evaluated %u names in the namespace\n", info.count); |
|---|
| 589 | +} |
|---|