| .. | .. |
|---|
| 10 | 10 | #include "acdebug.h" |
|---|
| 11 | 11 | #include "acnamesp.h" |
|---|
| 12 | 12 | #include "acpredef.h" |
|---|
| 13 | +#include "acinterp.h" |
|---|
| 13 | 14 | |
|---|
| 14 | 15 | #define _COMPONENT ACPI_CA_DEBUGGER |
|---|
| 15 | 16 | ACPI_MODULE_NAME("dbtest") |
|---|
| .. | .. |
|---|
| 31 | 32 | acpi_db_test_string_type(struct acpi_namespace_node *node, u32 byte_length); |
|---|
| 32 | 33 | |
|---|
| 33 | 34 | static acpi_status acpi_db_test_package_type(struct acpi_namespace_node *node); |
|---|
| 35 | + |
|---|
| 36 | +static acpi_status |
|---|
| 37 | +acpi_db_test_field_unit_type(union acpi_operand_object *obj_desc); |
|---|
| 34 | 38 | |
|---|
| 35 | 39 | static acpi_status |
|---|
| 36 | 40 | acpi_db_read_from_object(struct acpi_namespace_node *node, |
|---|
| .. | .. |
|---|
| 74 | 78 | static acpi_handle read_handle = NULL; |
|---|
| 75 | 79 | static acpi_handle write_handle = NULL; |
|---|
| 76 | 80 | |
|---|
| 77 | | -/* ASL Definitions of the debugger read/write control methods */ |
|---|
| 81 | +/* ASL Definitions of the debugger read/write control methods. AML below. */ |
|---|
| 78 | 82 | |
|---|
| 79 | 83 | #if 0 |
|---|
| 80 | 84 | definition_block("ssdt.aml", "SSDT", 2, "Intel", "DEBUG", 0x00000001) |
|---|
| .. | .. |
|---|
| 227 | 231 | * RETURN: Status |
|---|
| 228 | 232 | * |
|---|
| 229 | 233 | * DESCRIPTION: Test one namespace object. Supported types are Integer, |
|---|
| 230 | | - * String, Buffer, buffer_field, and field_unit. All other object |
|---|
| 231 | | - * types are simply ignored. |
|---|
| 232 | | - * |
|---|
| 233 | | - * Note: Support for Packages is not implemented. |
|---|
| 234 | + * String, Buffer, Package, buffer_field, and field_unit. |
|---|
| 235 | + * All other object types are simply ignored. |
|---|
| 234 | 236 | * |
|---|
| 235 | 237 | ******************************************************************************/ |
|---|
| 236 | 238 | |
|---|
| .. | .. |
|---|
| 240 | 242 | { |
|---|
| 241 | 243 | struct acpi_namespace_node *node; |
|---|
| 242 | 244 | union acpi_operand_object *obj_desc; |
|---|
| 243 | | - union acpi_operand_object *region_obj; |
|---|
| 244 | 245 | acpi_object_type local_type; |
|---|
| 245 | 246 | u32 bit_length = 0; |
|---|
| 246 | 247 | u32 byte_length = 0; |
|---|
| .. | .. |
|---|
| 281 | 282 | break; |
|---|
| 282 | 283 | |
|---|
| 283 | 284 | case ACPI_TYPE_FIELD_UNIT: |
|---|
| 284 | | - case ACPI_TYPE_BUFFER_FIELD: |
|---|
| 285 | 285 | case ACPI_TYPE_LOCAL_REGION_FIELD: |
|---|
| 286 | 286 | case ACPI_TYPE_LOCAL_INDEX_FIELD: |
|---|
| 287 | 287 | case ACPI_TYPE_LOCAL_BANK_FIELD: |
|---|
| 288 | 288 | |
|---|
| 289 | + local_type = ACPI_TYPE_FIELD_UNIT; |
|---|
| 290 | + break; |
|---|
| 291 | + |
|---|
| 292 | + case ACPI_TYPE_BUFFER_FIELD: |
|---|
| 293 | + /* |
|---|
| 294 | + * The returned object will be a Buffer if the field length |
|---|
| 295 | + * is larger than the size of an Integer (32 or 64 bits |
|---|
| 296 | + * depending on the DSDT version). |
|---|
| 297 | + */ |
|---|
| 289 | 298 | local_type = ACPI_TYPE_INTEGER; |
|---|
| 290 | 299 | if (obj_desc) { |
|---|
| 291 | | - /* |
|---|
| 292 | | - * Returned object will be a Buffer if the field length |
|---|
| 293 | | - * is larger than the size of an Integer (32 or 64 bits |
|---|
| 294 | | - * depending on the DSDT version). |
|---|
| 295 | | - */ |
|---|
| 296 | 300 | bit_length = obj_desc->common_field.bit_length; |
|---|
| 297 | 301 | byte_length = ACPI_ROUND_BITS_UP_TO_BYTES(bit_length); |
|---|
| 298 | 302 | if (bit_length > acpi_gbl_integer_bit_width) { |
|---|
| .. | .. |
|---|
| 303 | 307 | |
|---|
| 304 | 308 | default: |
|---|
| 305 | 309 | |
|---|
| 306 | | - /* Ignore all other types */ |
|---|
| 310 | + /* Ignore all non-data types - Methods, Devices, Scopes, etc. */ |
|---|
| 307 | 311 | |
|---|
| 308 | 312 | return (AE_OK); |
|---|
| 309 | 313 | } |
|---|
| .. | .. |
|---|
| 314 | 318 | acpi_ut_get_type_name(node->type), node->name.ascii); |
|---|
| 315 | 319 | |
|---|
| 316 | 320 | if (!obj_desc) { |
|---|
| 317 | | - acpi_os_printf(" Ignoring, no attached object\n"); |
|---|
| 321 | + acpi_os_printf(" No attached sub-object, ignoring\n"); |
|---|
| 318 | 322 | return (AE_OK); |
|---|
| 319 | | - } |
|---|
| 320 | | - |
|---|
| 321 | | - /* |
|---|
| 322 | | - * Check for unsupported region types. Note: acpi_exec simulates |
|---|
| 323 | | - * access to system_memory, system_IO, PCI_Config, and EC. |
|---|
| 324 | | - */ |
|---|
| 325 | | - switch (node->type) { |
|---|
| 326 | | - case ACPI_TYPE_LOCAL_REGION_FIELD: |
|---|
| 327 | | - |
|---|
| 328 | | - region_obj = obj_desc->field.region_obj; |
|---|
| 329 | | - switch (region_obj->region.space_id) { |
|---|
| 330 | | - case ACPI_ADR_SPACE_SYSTEM_MEMORY: |
|---|
| 331 | | - case ACPI_ADR_SPACE_SYSTEM_IO: |
|---|
| 332 | | - case ACPI_ADR_SPACE_PCI_CONFIG: |
|---|
| 333 | | - |
|---|
| 334 | | - break; |
|---|
| 335 | | - |
|---|
| 336 | | - default: |
|---|
| 337 | | - |
|---|
| 338 | | - acpi_os_printf |
|---|
| 339 | | - (" %s space is not supported in this command [%4.4s]\n", |
|---|
| 340 | | - acpi_ut_get_region_name(region_obj->region. |
|---|
| 341 | | - space_id), |
|---|
| 342 | | - region_obj->region.node->name.ascii); |
|---|
| 343 | | - return (AE_OK); |
|---|
| 344 | | - } |
|---|
| 345 | | - break; |
|---|
| 346 | | - |
|---|
| 347 | | - default: |
|---|
| 348 | | - break; |
|---|
| 349 | 323 | } |
|---|
| 350 | 324 | |
|---|
| 351 | 325 | /* At this point, we have resolved the object to one of the major types */ |
|---|
| .. | .. |
|---|
| 371 | 345 | status = acpi_db_test_package_type(node); |
|---|
| 372 | 346 | break; |
|---|
| 373 | 347 | |
|---|
| 348 | + case ACPI_TYPE_FIELD_UNIT: |
|---|
| 349 | + |
|---|
| 350 | + status = acpi_db_test_field_unit_type(obj_desc); |
|---|
| 351 | + break; |
|---|
| 352 | + |
|---|
| 374 | 353 | default: |
|---|
| 375 | 354 | |
|---|
| 376 | 355 | acpi_os_printf(" Ignoring, type not implemented (%2.2X)", |
|---|
| .. | .. |
|---|
| 382 | 361 | |
|---|
| 383 | 362 | if (ACPI_FAILURE(status)) { |
|---|
| 384 | 363 | status = AE_OK; |
|---|
| 385 | | - goto exit; |
|---|
| 386 | 364 | } |
|---|
| 387 | 365 | |
|---|
| 388 | | - switch (node->type) { |
|---|
| 389 | | - case ACPI_TYPE_LOCAL_REGION_FIELD: |
|---|
| 390 | | - |
|---|
| 391 | | - region_obj = obj_desc->field.region_obj; |
|---|
| 392 | | - acpi_os_printf(" (%s)", |
|---|
| 393 | | - acpi_ut_get_region_name(region_obj->region. |
|---|
| 394 | | - space_id)); |
|---|
| 395 | | - |
|---|
| 396 | | - break; |
|---|
| 397 | | - |
|---|
| 398 | | - default: |
|---|
| 399 | | - break; |
|---|
| 400 | | - } |
|---|
| 401 | | - |
|---|
| 402 | | -exit: |
|---|
| 403 | 366 | acpi_os_printf("\n"); |
|---|
| 404 | 367 | return (status); |
|---|
| 405 | 368 | } |
|---|
| .. | .. |
|---|
| 444 | 407 | return (status); |
|---|
| 445 | 408 | } |
|---|
| 446 | 409 | |
|---|
| 447 | | - acpi_os_printf(" (%4.4X/%3.3X) %8.8X%8.8X", |
|---|
| 410 | + acpi_os_printf(ACPI_DEBUG_LENGTH_FORMAT " %8.8X%8.8X", |
|---|
| 448 | 411 | bit_length, ACPI_ROUND_BITS_UP_TO_BYTES(bit_length), |
|---|
| 449 | 412 | ACPI_FORMAT_UINT64(temp1->integer.value)); |
|---|
| 450 | 413 | |
|---|
| .. | .. |
|---|
| 558 | 521 | |
|---|
| 559 | 522 | /* Emit a few bytes of the buffer */ |
|---|
| 560 | 523 | |
|---|
| 561 | | - acpi_os_printf(" (%4.4X/%3.3X)", bit_length, temp1->buffer.length); |
|---|
| 562 | | - for (i = 0; ((i < 4) && (i < byte_length)); i++) { |
|---|
| 524 | + acpi_os_printf(ACPI_DEBUG_LENGTH_FORMAT, bit_length, |
|---|
| 525 | + temp1->buffer.length); |
|---|
| 526 | + for (i = 0; ((i < 8) && (i < byte_length)); i++) { |
|---|
| 563 | 527 | acpi_os_printf(" %2.2X", temp1->buffer.pointer[i]); |
|---|
| 564 | 528 | } |
|---|
| 565 | 529 | acpi_os_printf("... "); |
|---|
| .. | .. |
|---|
| 665 | 629 | return (status); |
|---|
| 666 | 630 | } |
|---|
| 667 | 631 | |
|---|
| 668 | | - acpi_os_printf(" (%4.4X/%3.3X) \"%s\"", (temp1->string.length * 8), |
|---|
| 669 | | - temp1->string.length, temp1->string.pointer); |
|---|
| 632 | + acpi_os_printf(ACPI_DEBUG_LENGTH_FORMAT " \"%s\"", |
|---|
| 633 | + (temp1->string.length * 8), temp1->string.length, |
|---|
| 634 | + temp1->string.pointer); |
|---|
| 670 | 635 | |
|---|
| 671 | 636 | /* Write a new value */ |
|---|
| 672 | 637 | |
|---|
| .. | .. |
|---|
| 750 | 715 | return (status); |
|---|
| 751 | 716 | } |
|---|
| 752 | 717 | |
|---|
| 753 | | - acpi_os_printf(" %8.8X Elements", temp1->package.count); |
|---|
| 718 | + acpi_os_printf(" %.2X Elements", temp1->package.count); |
|---|
| 754 | 719 | acpi_os_free(temp1); |
|---|
| 755 | 720 | return (status); |
|---|
| 756 | 721 | } |
|---|
| 757 | 722 | |
|---|
| 758 | 723 | /******************************************************************************* |
|---|
| 759 | 724 | * |
|---|
| 725 | + * FUNCTION: acpi_db_test_field_unit_type |
|---|
| 726 | + * |
|---|
| 727 | + * PARAMETERS: obj_desc - A field unit object |
|---|
| 728 | + * |
|---|
| 729 | + * RETURN: Status |
|---|
| 730 | + * |
|---|
| 731 | + * DESCRIPTION: Test read/write on a named field unit. |
|---|
| 732 | + * |
|---|
| 733 | + ******************************************************************************/ |
|---|
| 734 | + |
|---|
| 735 | +static acpi_status |
|---|
| 736 | +acpi_db_test_field_unit_type(union acpi_operand_object *obj_desc) |
|---|
| 737 | +{ |
|---|
| 738 | + union acpi_operand_object *region_obj; |
|---|
| 739 | + u32 bit_length = 0; |
|---|
| 740 | + u32 byte_length = 0; |
|---|
| 741 | + acpi_status status = AE_OK; |
|---|
| 742 | + union acpi_operand_object *ret_buffer_desc; |
|---|
| 743 | + |
|---|
| 744 | + /* Supported spaces are memory/io/pci_config */ |
|---|
| 745 | + |
|---|
| 746 | + region_obj = obj_desc->field.region_obj; |
|---|
| 747 | + switch (region_obj->region.space_id) { |
|---|
| 748 | + case ACPI_ADR_SPACE_SYSTEM_MEMORY: |
|---|
| 749 | + case ACPI_ADR_SPACE_SYSTEM_IO: |
|---|
| 750 | + case ACPI_ADR_SPACE_PCI_CONFIG: |
|---|
| 751 | + |
|---|
| 752 | + /* Need the interpreter to execute */ |
|---|
| 753 | + |
|---|
| 754 | + acpi_ut_acquire_mutex(ACPI_MTX_INTERPRETER); |
|---|
| 755 | + acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE); |
|---|
| 756 | + |
|---|
| 757 | + /* Exercise read-then-write */ |
|---|
| 758 | + |
|---|
| 759 | + status = |
|---|
| 760 | + acpi_ex_read_data_from_field(NULL, obj_desc, |
|---|
| 761 | + &ret_buffer_desc); |
|---|
| 762 | + if (status == AE_OK) { |
|---|
| 763 | + acpi_ex_write_data_to_field(ret_buffer_desc, obj_desc, |
|---|
| 764 | + NULL); |
|---|
| 765 | + acpi_ut_remove_reference(ret_buffer_desc); |
|---|
| 766 | + } |
|---|
| 767 | + |
|---|
| 768 | + acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); |
|---|
| 769 | + acpi_ut_release_mutex(ACPI_MTX_INTERPRETER); |
|---|
| 770 | + |
|---|
| 771 | + bit_length = obj_desc->common_field.bit_length; |
|---|
| 772 | + byte_length = ACPI_ROUND_BITS_UP_TO_BYTES(bit_length); |
|---|
| 773 | + |
|---|
| 774 | + acpi_os_printf(ACPI_DEBUG_LENGTH_FORMAT " [%s]", bit_length, |
|---|
| 775 | + byte_length, |
|---|
| 776 | + acpi_ut_get_region_name(region_obj->region. |
|---|
| 777 | + space_id)); |
|---|
| 778 | + return (status); |
|---|
| 779 | + |
|---|
| 780 | + default: |
|---|
| 781 | + |
|---|
| 782 | + acpi_os_printf |
|---|
| 783 | + (" %s address space is not supported in this command [%4.4s]", |
|---|
| 784 | + acpi_ut_get_region_name(region_obj->region.space_id), |
|---|
| 785 | + region_obj->region.node->name.ascii); |
|---|
| 786 | + return (AE_OK); |
|---|
| 787 | + } |
|---|
| 788 | +} |
|---|
| 789 | + |
|---|
| 790 | +/******************************************************************************* |
|---|
| 791 | + * |
|---|
| 760 | 792 | * FUNCTION: acpi_db_read_from_object |
|---|
| 761 | 793 | * |
|---|
| 762 | 794 | * PARAMETERS: node - Parent NS node for the object |
|---|