1 // SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0
2 /*******************************************************************************
4 * Module Name: dbtest - Various debug-related tests
6 ******************************************************************************/
14 #define _COMPONENT ACPI_CA_DEBUGGER
15 ACPI_MODULE_NAME("dbtest")
17 /* Local prototypes */
18 static void acpi_db_test_all_objects(void);
21 acpi_db_test_one_object(acpi_handle obj_handle
,
22 u32 nesting_level
, void *context
, void **return_value
);
25 acpi_db_test_integer_type(struct acpi_namespace_node
*node
, u32 bit_length
);
28 acpi_db_test_buffer_type(struct acpi_namespace_node
*node
, u32 bit_length
);
31 acpi_db_test_string_type(struct acpi_namespace_node
*node
, u32 byte_length
);
33 static acpi_status
acpi_db_test_package_type(struct acpi_namespace_node
*node
);
36 acpi_db_read_from_object(struct acpi_namespace_node
*node
,
37 acpi_object_type expected_type
,
38 union acpi_object
**value
);
41 acpi_db_write_to_object(struct acpi_namespace_node
*node
,
42 union acpi_object
*value
);
44 static void acpi_db_evaluate_all_predefined_names(char *count_arg
);
47 acpi_db_evaluate_one_predefined_name(acpi_handle obj_handle
,
49 void *context
, void **return_value
);
54 static struct acpi_db_argument_info acpi_db_test_types
[] = {
57 {NULL
} /* Must be null terminated */
60 #define CMD_TEST_OBJECTS 0
61 #define CMD_TEST_PREDEFINED 1
63 #define BUFFER_FILL_VALUE 0xFF
66 * Support for the special debugger read/write control methods.
67 * These methods are installed into the current namespace and are
68 * used to read and write the various namespace objects. The point
69 * is to force the AML interpreter do all of the work.
71 #define ACPI_DB_READ_METHOD "\\_T98"
72 #define ACPI_DB_WRITE_METHOD "\\_T99"
74 static acpi_handle read_handle
= NULL
;
75 static acpi_handle write_handle
= NULL
;
77 /* ASL Definitions of the debugger read/write control methods */
80 definition_block("ssdt.aml", "SSDT", 2, "Intel", "DEBUG", 0x00000001)
82 method(_T98
, 1, not_serialized
) { /* Read */
83 return (de_ref_of(arg0
))
87 definition_block("ssdt2.aml", "SSDT", 2, "Intel", "DEBUG", 0x00000001)
89 method(_T99
, 2, not_serialized
) { /* Write */
95 static unsigned char read_method_code
[] = {
96 0x53, 0x53, 0x44, 0x54, 0x2E, 0x00, 0x00, 0x00, /* 00000000 "SSDT...." */
97 0x02, 0xC9, 0x49, 0x6E, 0x74, 0x65, 0x6C, 0x00, /* 00000008 "..Intel." */
98 0x44, 0x45, 0x42, 0x55, 0x47, 0x00, 0x00, 0x00, /* 00000010 "DEBUG..." */
99 0x01, 0x00, 0x00, 0x00, 0x49, 0x4E, 0x54, 0x4C, /* 00000018 "....INTL" */
100 0x18, 0x12, 0x13, 0x20, 0x14, 0x09, 0x5F, 0x54, /* 00000020 "... .._T" */
101 0x39, 0x38, 0x01, 0xA4, 0x83, 0x68 /* 00000028 "98...h" */
104 static unsigned char write_method_code
[] = {
105 0x53, 0x53, 0x44, 0x54, 0x2E, 0x00, 0x00, 0x00, /* 00000000 "SSDT...." */
106 0x02, 0x15, 0x49, 0x6E, 0x74, 0x65, 0x6C, 0x00, /* 00000008 "..Intel." */
107 0x44, 0x45, 0x42, 0x55, 0x47, 0x00, 0x00, 0x00, /* 00000010 "DEBUG..." */
108 0x01, 0x00, 0x00, 0x00, 0x49, 0x4E, 0x54, 0x4C, /* 00000018 "....INTL" */
109 0x18, 0x12, 0x13, 0x20, 0x14, 0x09, 0x5F, 0x54, /* 00000020 "... .._T" */
110 0x39, 0x39, 0x02, 0x70, 0x69, 0x68 /* 00000028 "99.pih" */
113 /*******************************************************************************
115 * FUNCTION: acpi_db_execute_test
117 * PARAMETERS: type_arg - Subcommand
121 * DESCRIPTION: Execute various debug tests.
123 * Note: Code is prepared for future expansion of the TEST command.
125 ******************************************************************************/
127 void acpi_db_execute_test(char *type_arg
)
131 acpi_ut_strupr(type_arg
);
132 temp
= acpi_db_match_argument(type_arg
, acpi_db_test_types
);
133 if (temp
== ACPI_TYPE_NOT_FOUND
) {
134 acpi_os_printf("Invalid or unsupported argument\n");
139 case CMD_TEST_OBJECTS
:
141 acpi_db_test_all_objects();
144 case CMD_TEST_PREDEFINED
:
146 acpi_db_evaluate_all_predefined_names(NULL
);
154 /*******************************************************************************
156 * FUNCTION: acpi_db_test_all_objects
162 * DESCRIPTION: This test implements the OBJECTS subcommand. It exercises the
163 * namespace by reading/writing/comparing all data objects such
164 * as integers, strings, buffers, fields, buffer fields, etc.
166 ******************************************************************************/
168 static void acpi_db_test_all_objects(void)
172 /* Install the debugger read-object control method if necessary */
175 status
= acpi_install_method(read_method_code
);
176 if (ACPI_FAILURE(status
)) {
178 ("%s, Could not install debugger read method\n",
179 acpi_format_exception(status
));
184 acpi_get_handle(NULL
, ACPI_DB_READ_METHOD
, &read_handle
);
185 if (ACPI_FAILURE(status
)) {
187 ("Could not obtain handle for debug method %s\n",
188 ACPI_DB_READ_METHOD
);
193 /* Install the debugger write-object control method if necessary */
196 status
= acpi_install_method(write_method_code
);
197 if (ACPI_FAILURE(status
)) {
199 ("%s, Could not install debugger write method\n",
200 acpi_format_exception(status
));
205 acpi_get_handle(NULL
, ACPI_DB_WRITE_METHOD
, &write_handle
);
206 if (ACPI_FAILURE(status
)) {
208 ("Could not obtain handle for debug method %s\n",
209 ACPI_DB_WRITE_METHOD
);
214 /* Walk the entire namespace, testing each supported named data object */
216 (void)acpi_walk_namespace(ACPI_TYPE_ANY
, ACPI_ROOT_OBJECT
,
217 ACPI_UINT32_MAX
, acpi_db_test_one_object
,
221 /*******************************************************************************
223 * FUNCTION: acpi_db_test_one_object
225 * PARAMETERS: acpi_walk_callback
229 * 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.
233 * Note: Support for Packages is not implemented.
235 ******************************************************************************/
238 acpi_db_test_one_object(acpi_handle obj_handle
,
239 u32 nesting_level
, void *context
, void **return_value
)
241 struct acpi_namespace_node
*node
;
242 union acpi_operand_object
*obj_desc
;
243 union acpi_operand_object
*region_obj
;
244 acpi_object_type local_type
;
247 acpi_status status
= AE_OK
;
249 node
= ACPI_CAST_PTR(struct acpi_namespace_node
, obj_handle
);
250 obj_desc
= node
->object
;
253 * For the supported types, get the actual bit length or
254 * byte length. Map the type to one of Integer/String/Buffer.
256 switch (node
->type
) {
257 case ACPI_TYPE_INTEGER
:
259 /* Integer width is either 32 or 64 */
261 local_type
= ACPI_TYPE_INTEGER
;
262 bit_length
= acpi_gbl_integer_bit_width
;
265 case ACPI_TYPE_STRING
:
267 local_type
= ACPI_TYPE_STRING
;
268 byte_length
= obj_desc
->string
.length
;
271 case ACPI_TYPE_BUFFER
:
273 local_type
= ACPI_TYPE_BUFFER
;
274 byte_length
= obj_desc
->buffer
.length
;
275 bit_length
= byte_length
* 8;
278 case ACPI_TYPE_PACKAGE
:
280 local_type
= ACPI_TYPE_PACKAGE
;
283 case ACPI_TYPE_FIELD_UNIT
:
284 case ACPI_TYPE_BUFFER_FIELD
:
285 case ACPI_TYPE_LOCAL_REGION_FIELD
:
286 case ACPI_TYPE_LOCAL_INDEX_FIELD
:
287 case ACPI_TYPE_LOCAL_BANK_FIELD
:
289 local_type
= ACPI_TYPE_INTEGER
;
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).
296 bit_length
= obj_desc
->common_field
.bit_length
;
297 byte_length
= ACPI_ROUND_BITS_UP_TO_BYTES(bit_length
);
298 if (bit_length
> acpi_gbl_integer_bit_width
) {
299 local_type
= ACPI_TYPE_BUFFER
;
306 /* Ignore all other types */
311 /* Emit the common prefix: Type:Name */
313 acpi_os_printf("%14s: %4.4s",
314 acpi_ut_get_type_name(node
->type
), node
->name
.ascii
);
317 acpi_os_printf(" Ignoring, no attached object\n");
322 * Check for unsupported region types. Note: acpi_exec simulates
323 * access to system_memory, system_IO, PCI_Config, and EC.
325 switch (node
->type
) {
326 case ACPI_TYPE_LOCAL_REGION_FIELD
:
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
:
339 (" %s space is not supported in this command [%4.4s]\n",
340 acpi_ut_get_region_name(region_obj
->region
.
342 region_obj
->region
.node
->name
.ascii
);
351 /* At this point, we have resolved the object to one of the major types */
353 switch (local_type
) {
354 case ACPI_TYPE_INTEGER
:
356 status
= acpi_db_test_integer_type(node
, bit_length
);
359 case ACPI_TYPE_STRING
:
361 status
= acpi_db_test_string_type(node
, byte_length
);
364 case ACPI_TYPE_BUFFER
:
366 status
= acpi_db_test_buffer_type(node
, bit_length
);
369 case ACPI_TYPE_PACKAGE
:
371 status
= acpi_db_test_package_type(node
);
376 acpi_os_printf(" Ignoring, type not implemented (%2.2X)",
381 /* Exit on error, but don't abort the namespace walk */
383 if (ACPI_FAILURE(status
)) {
388 switch (node
->type
) {
389 case ACPI_TYPE_LOCAL_REGION_FIELD
:
391 region_obj
= obj_desc
->field
.region_obj
;
392 acpi_os_printf(" (%s)",
393 acpi_ut_get_region_name(region_obj
->region
.
403 acpi_os_printf("\n");
407 /*******************************************************************************
409 * FUNCTION: acpi_db_test_integer_type
411 * PARAMETERS: node - Parent NS node for the object
412 * bit_length - Actual length of the object. Used for
413 * support of arbitrary length field_unit
414 * and buffer_field objects.
418 * DESCRIPTION: Test read/write for an Integer-valued object. Performs a
419 * write/read/compare of an arbitrary new value, then performs
420 * a write/read/compare of the original value.
422 ******************************************************************************/
425 acpi_db_test_integer_type(struct acpi_namespace_node
*node
, u32 bit_length
)
427 union acpi_object
*temp1
= NULL
;
428 union acpi_object
*temp2
= NULL
;
429 union acpi_object
*temp3
= NULL
;
430 union acpi_object write_value
;
434 if (bit_length
> 64) {
435 acpi_os_printf(" Invalid length for an Integer: %u",
440 /* Read the original value */
442 status
= acpi_db_read_from_object(node
, ACPI_TYPE_INTEGER
, &temp1
);
443 if (ACPI_FAILURE(status
)) {
447 acpi_os_printf(" (%4.4X/%3.3X) %8.8X%8.8X",
448 bit_length
, ACPI_ROUND_BITS_UP_TO_BYTES(bit_length
),
449 ACPI_FORMAT_UINT64(temp1
->integer
.value
));
451 value_to_write
= ACPI_UINT64_MAX
>> (64 - bit_length
);
452 if (temp1
->integer
.value
== value_to_write
) {
455 /* Write a new value */
457 write_value
.type
= ACPI_TYPE_INTEGER
;
458 write_value
.integer
.value
= value_to_write
;
459 status
= acpi_db_write_to_object(node
, &write_value
);
460 if (ACPI_FAILURE(status
)) {
464 /* Ensure that we can read back the new value */
466 status
= acpi_db_read_from_object(node
, ACPI_TYPE_INTEGER
, &temp2
);
467 if (ACPI_FAILURE(status
)) {
471 if (temp2
->integer
.value
!= value_to_write
) {
472 acpi_os_printf(" MISMATCH 2: %8.8X%8.8X, expecting %8.8X%8.8X",
473 ACPI_FORMAT_UINT64(temp2
->integer
.value
),
474 ACPI_FORMAT_UINT64(value_to_write
));
477 /* Write back the original value */
479 write_value
.integer
.value
= temp1
->integer
.value
;
480 status
= acpi_db_write_to_object(node
, &write_value
);
481 if (ACPI_FAILURE(status
)) {
485 /* Ensure that we can read back the original value */
487 status
= acpi_db_read_from_object(node
, ACPI_TYPE_INTEGER
, &temp3
);
488 if (ACPI_FAILURE(status
)) {
492 if (temp3
->integer
.value
!= temp1
->integer
.value
) {
493 acpi_os_printf(" MISMATCH 3: %8.8X%8.8X, expecting %8.8X%8.8X",
494 ACPI_FORMAT_UINT64(temp3
->integer
.value
),
495 ACPI_FORMAT_UINT64(temp1
->integer
.value
));
511 /*******************************************************************************
513 * FUNCTION: acpi_db_test_buffer_type
515 * PARAMETERS: node - Parent NS node for the object
516 * bit_length - Actual length of the object.
520 * DESCRIPTION: Test read/write for an Buffer-valued object. Performs a
521 * write/read/compare of an arbitrary new value, then performs
522 * a write/read/compare of the original value.
524 ******************************************************************************/
527 acpi_db_test_buffer_type(struct acpi_namespace_node
*node
, u32 bit_length
)
529 union acpi_object
*temp1
= NULL
;
530 union acpi_object
*temp2
= NULL
;
531 union acpi_object
*temp3
= NULL
;
533 union acpi_object write_value
;
539 byte_length
= ACPI_ROUND_BITS_UP_TO_BYTES(bit_length
);
540 if (byte_length
== 0) {
541 acpi_os_printf(" Ignoring zero length buffer");
545 /* Allocate a local buffer */
547 buffer
= ACPI_ALLOCATE_ZEROED(byte_length
);
549 return (AE_NO_MEMORY
);
552 /* Read the original value */
554 status
= acpi_db_read_from_object(node
, ACPI_TYPE_BUFFER
, &temp1
);
555 if (ACPI_FAILURE(status
)) {
559 /* Emit a few bytes of the buffer */
561 acpi_os_printf(" (%4.4X/%3.3X)", bit_length
, temp1
->buffer
.length
);
562 for (i
= 0; ((i
< 4) && (i
< byte_length
)); i
++) {
563 acpi_os_printf(" %2.2X", temp1
->buffer
.pointer
[i
]);
565 acpi_os_printf("... ");
570 * Handle possible extra bits at the end of the buffer. Can
571 * happen for field_units larger than an integer, but the bit
572 * count is not an integral number of bytes. Zero out the
575 memset(buffer
, BUFFER_FILL_VALUE
, byte_length
);
576 extra_bits
= bit_length
% 8;
578 buffer
[byte_length
- 1] = ACPI_MASK_BITS_ABOVE(extra_bits
);
581 write_value
.type
= ACPI_TYPE_BUFFER
;
582 write_value
.buffer
.length
= byte_length
;
583 write_value
.buffer
.pointer
= buffer
;
585 status
= acpi_db_write_to_object(node
, &write_value
);
586 if (ACPI_FAILURE(status
)) {
590 /* Ensure that we can read back the new value */
592 status
= acpi_db_read_from_object(node
, ACPI_TYPE_BUFFER
, &temp2
);
593 if (ACPI_FAILURE(status
)) {
597 if (memcmp(temp2
->buffer
.pointer
, buffer
, byte_length
)) {
598 acpi_os_printf(" MISMATCH 2: New buffer value");
601 /* Write back the original value */
603 write_value
.buffer
.length
= byte_length
;
604 write_value
.buffer
.pointer
= temp1
->buffer
.pointer
;
606 status
= acpi_db_write_to_object(node
, &write_value
);
607 if (ACPI_FAILURE(status
)) {
611 /* Ensure that we can read back the original value */
613 status
= acpi_db_read_from_object(node
, ACPI_TYPE_BUFFER
, &temp3
);
614 if (ACPI_FAILURE(status
)) {
618 if (memcmp(temp1
->buffer
.pointer
, temp3
->buffer
.pointer
, byte_length
)) {
619 acpi_os_printf(" MISMATCH 3: While restoring original buffer");
636 /*******************************************************************************
638 * FUNCTION: acpi_db_test_string_type
640 * PARAMETERS: node - Parent NS node for the object
641 * byte_length - Actual length of the object.
645 * DESCRIPTION: Test read/write for an String-valued object. Performs a
646 * write/read/compare of an arbitrary new value, then performs
647 * a write/read/compare of the original value.
649 ******************************************************************************/
652 acpi_db_test_string_type(struct acpi_namespace_node
*node
, u32 byte_length
)
654 union acpi_object
*temp1
= NULL
;
655 union acpi_object
*temp2
= NULL
;
656 union acpi_object
*temp3
= NULL
;
657 char *value_to_write
= "Test String from AML Debugger";
658 union acpi_object write_value
;
661 /* Read the original value */
663 status
= acpi_db_read_from_object(node
, ACPI_TYPE_STRING
, &temp1
);
664 if (ACPI_FAILURE(status
)) {
668 acpi_os_printf(" (%4.4X/%3.3X) \"%s\"", (temp1
->string
.length
* 8),
669 temp1
->string
.length
, temp1
->string
.pointer
);
671 /* Write a new value */
673 write_value
.type
= ACPI_TYPE_STRING
;
674 write_value
.string
.length
= strlen(value_to_write
);
675 write_value
.string
.pointer
= value_to_write
;
677 status
= acpi_db_write_to_object(node
, &write_value
);
678 if (ACPI_FAILURE(status
)) {
682 /* Ensure that we can read back the new value */
684 status
= acpi_db_read_from_object(node
, ACPI_TYPE_STRING
, &temp2
);
685 if (ACPI_FAILURE(status
)) {
689 if (strcmp(temp2
->string
.pointer
, value_to_write
)) {
690 acpi_os_printf(" MISMATCH 2: %s, expecting %s",
691 temp2
->string
.pointer
, value_to_write
);
694 /* Write back the original value */
696 write_value
.string
.length
= strlen(temp1
->string
.pointer
);
697 write_value
.string
.pointer
= temp1
->string
.pointer
;
699 status
= acpi_db_write_to_object(node
, &write_value
);
700 if (ACPI_FAILURE(status
)) {
704 /* Ensure that we can read back the original value */
706 status
= acpi_db_read_from_object(node
, ACPI_TYPE_STRING
, &temp3
);
707 if (ACPI_FAILURE(status
)) {
711 if (strcmp(temp1
->string
.pointer
, temp3
->string
.pointer
)) {
712 acpi_os_printf(" MISMATCH 3: %s, expecting %s",
713 temp3
->string
.pointer
, temp1
->string
.pointer
);
729 /*******************************************************************************
731 * FUNCTION: acpi_db_test_package_type
733 * PARAMETERS: node - Parent NS node for the object
737 * DESCRIPTION: Test read for a Package object.
739 ******************************************************************************/
741 static acpi_status
acpi_db_test_package_type(struct acpi_namespace_node
*node
)
743 union acpi_object
*temp1
= NULL
;
746 /* Read the original value */
748 status
= acpi_db_read_from_object(node
, ACPI_TYPE_PACKAGE
, &temp1
);
749 if (ACPI_FAILURE(status
)) {
753 acpi_os_printf(" %8.8X Elements", temp1
->package
.count
);
758 /*******************************************************************************
760 * FUNCTION: acpi_db_read_from_object
762 * PARAMETERS: node - Parent NS node for the object
763 * expected_type - Object type expected from the read
764 * value - Where the value read is returned
768 * DESCRIPTION: Performs a read from the specified object by invoking the
769 * special debugger control method that reads the object. Thus,
770 * the AML interpreter is doing all of the work, increasing the
771 * validity of the test.
773 ******************************************************************************/
776 acpi_db_read_from_object(struct acpi_namespace_node
*node
,
777 acpi_object_type expected_type
,
778 union acpi_object
**value
)
780 union acpi_object
*ret_value
;
781 struct acpi_object_list param_objects
;
782 union acpi_object params
[2];
783 struct acpi_buffer return_obj
;
786 params
[0].type
= ACPI_TYPE_LOCAL_REFERENCE
;
787 params
[0].reference
.actual_type
= node
->type
;
788 params
[0].reference
.handle
= ACPI_CAST_PTR(acpi_handle
, node
);
790 param_objects
.count
= 1;
791 param_objects
.pointer
= params
;
793 return_obj
.length
= ACPI_ALLOCATE_BUFFER
;
795 acpi_gbl_method_executing
= TRUE
;
796 status
= acpi_evaluate_object(read_handle
, NULL
,
797 ¶m_objects
, &return_obj
);
799 acpi_gbl_method_executing
= FALSE
;
800 if (ACPI_FAILURE(status
)) {
801 acpi_os_printf("Could not read from object, %s",
802 acpi_format_exception(status
));
806 ret_value
= (union acpi_object
*)return_obj
.pointer
;
808 switch (ret_value
->type
) {
809 case ACPI_TYPE_INTEGER
:
810 case ACPI_TYPE_BUFFER
:
811 case ACPI_TYPE_STRING
:
812 case ACPI_TYPE_PACKAGE
:
814 * Did we receive the type we wanted? Most important for the
815 * Integer/Buffer case (when a field is larger than an Integer,
816 * it should return a Buffer).
818 if (ret_value
->type
!= expected_type
) {
820 (" Type mismatch: Expected %s, Received %s",
821 acpi_ut_get_type_name(expected_type
),
822 acpi_ut_get_type_name(ret_value
->type
));
824 acpi_os_free(return_obj
.pointer
);
833 acpi_os_printf(" Unsupported return object type, %s",
834 acpi_ut_get_type_name(ret_value
->type
));
836 acpi_os_free(return_obj
.pointer
);
843 /*******************************************************************************
845 * FUNCTION: acpi_db_write_to_object
847 * PARAMETERS: node - Parent NS node for the object
848 * value - Value to be written
852 * DESCRIPTION: Performs a write to the specified object by invoking the
853 * special debugger control method that writes the object. Thus,
854 * the AML interpreter is doing all of the work, increasing the
855 * validity of the test.
857 ******************************************************************************/
860 acpi_db_write_to_object(struct acpi_namespace_node
*node
,
861 union acpi_object
*value
)
863 struct acpi_object_list param_objects
;
864 union acpi_object params
[2];
867 params
[0].type
= ACPI_TYPE_LOCAL_REFERENCE
;
868 params
[0].reference
.actual_type
= node
->type
;
869 params
[0].reference
.handle
= ACPI_CAST_PTR(acpi_handle
, node
);
871 /* Copy the incoming user parameter */
873 memcpy(¶ms
[1], value
, sizeof(union acpi_object
));
875 param_objects
.count
= 2;
876 param_objects
.pointer
= params
;
878 acpi_gbl_method_executing
= TRUE
;
879 status
= acpi_evaluate_object(write_handle
, NULL
, ¶m_objects
, NULL
);
880 acpi_gbl_method_executing
= FALSE
;
882 if (ACPI_FAILURE(status
)) {
883 acpi_os_printf("Could not write to object, %s",
884 acpi_format_exception(status
));
890 /*******************************************************************************
892 * FUNCTION: acpi_db_evaluate_all_predefined_names
894 * PARAMETERS: count_arg - Max number of methods to execute
898 * DESCRIPTION: Namespace batch execution. Execute predefined names in the
899 * namespace, up to the max count, if specified.
901 ******************************************************************************/
903 static void acpi_db_evaluate_all_predefined_names(char *count_arg
)
905 struct acpi_db_execute_walk info
;
908 info
.max_count
= ACPI_UINT32_MAX
;
911 info
.max_count
= strtoul(count_arg
, NULL
, 0);
914 /* Search all nodes in namespace */
916 (void)acpi_walk_namespace(ACPI_TYPE_ANY
, ACPI_ROOT_OBJECT
,
918 acpi_db_evaluate_one_predefined_name
, NULL
,
919 (void *)&info
, NULL
);
921 acpi_os_printf("Evaluated %u predefined names in the namespace\n",
925 /*******************************************************************************
927 * FUNCTION: acpi_db_evaluate_one_predefined_name
929 * PARAMETERS: Callback from walk_namespace
933 * DESCRIPTION: Batch execution module. Currently only executes predefined
936 ******************************************************************************/
939 acpi_db_evaluate_one_predefined_name(acpi_handle obj_handle
,
941 void *context
, void **return_value
)
943 struct acpi_namespace_node
*node
=
944 (struct acpi_namespace_node
*)obj_handle
;
945 struct acpi_db_execute_walk
*info
=
946 (struct acpi_db_execute_walk
*)context
;
948 const union acpi_predefined_info
*predefined
;
949 struct acpi_device_info
*obj_info
;
950 struct acpi_object_list param_objects
;
951 union acpi_object params
[ACPI_METHOD_NUM_ARGS
];
952 union acpi_object
*this_param
;
953 struct acpi_buffer return_obj
;
960 /* The name must be a predefined ACPI name */
962 predefined
= acpi_ut_match_predefined_method(node
->name
.ascii
);
967 if (node
->type
== ACPI_TYPE_LOCAL_SCOPE
) {
971 pathname
= acpi_ns_get_normalized_pathname(node
, TRUE
);
976 /* Get the object info for number of method parameters */
978 status
= acpi_get_object_info(obj_handle
, &obj_info
);
979 if (ACPI_FAILURE(status
)) {
984 param_objects
.count
= 0;
985 param_objects
.pointer
= NULL
;
987 if (obj_info
->type
== ACPI_TYPE_METHOD
) {
989 /* Setup default parameters (with proper types) */
991 arg_type_list
= predefined
->info
.argument_list
;
992 arg_count
= METHOD_GET_ARG_COUNT(arg_type_list
);
995 * Setup the ACPI-required number of arguments, regardless of what
996 * the actual method defines. If there is a difference, then the
997 * method is wrong and a warning will be issued during execution.
1000 for (i
= 0; i
< arg_count
; i
++) {
1001 arg_type
= METHOD_GET_NEXT_TYPE(arg_type_list
);
1002 this_param
->type
= arg_type
;
1005 case ACPI_TYPE_INTEGER
:
1007 this_param
->integer
.value
= 1;
1010 case ACPI_TYPE_STRING
:
1012 this_param
->string
.pointer
=
1013 "This is the default argument string";
1014 this_param
->string
.length
=
1015 strlen(this_param
->string
.pointer
);
1018 case ACPI_TYPE_BUFFER
:
1020 this_param
->buffer
.pointer
= (u8
*)params
; /* just a garbage buffer */
1021 this_param
->buffer
.length
= 48;
1024 case ACPI_TYPE_PACKAGE
:
1026 this_param
->package
.elements
= NULL
;
1027 this_param
->package
.count
= 0;
1033 ("%s: Unsupported argument type: %u\n",
1034 pathname
, arg_type
);
1041 param_objects
.count
= arg_count
;
1042 param_objects
.pointer
= params
;
1045 ACPI_FREE(obj_info
);
1046 return_obj
.pointer
= NULL
;
1047 return_obj
.length
= ACPI_ALLOCATE_BUFFER
;
1049 /* Do the actual method execution */
1051 acpi_gbl_method_executing
= TRUE
;
1053 status
= acpi_evaluate_object(node
, NULL
, ¶m_objects
, &return_obj
);
1055 acpi_os_printf("%-32s returned %s\n",
1056 pathname
, acpi_format_exception(status
));
1057 acpi_gbl_method_executing
= FALSE
;
1058 ACPI_FREE(pathname
);
1060 /* Ignore status from method execution */
1064 /* Update count, check if we have executed enough methods */
1067 if (info
->count
>= info
->max_count
) {
1068 status
= AE_CTRL_TERMINATE
;