1 // SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0
2 /*******************************************************************************
4 * Module Name: dbtest - Various debug-related tests
6 ******************************************************************************/
15 #define _COMPONENT ACPI_CA_DEBUGGER
16 ACPI_MODULE_NAME("dbtest")
18 /* Local prototypes */
19 static void acpi_db_test_all_objects(void);
22 acpi_db_test_one_object(acpi_handle obj_handle,
23 u32 nesting_level, void *context, void **return_value);
26 acpi_db_test_integer_type(struct acpi_namespace_node *node, u32 bit_length);
29 acpi_db_test_buffer_type(struct acpi_namespace_node *node, u32 bit_length);
32 acpi_db_test_string_type(struct acpi_namespace_node *node, u32 byte_length);
34 static acpi_status acpi_db_test_package_type(struct acpi_namespace_node *node);
37 acpi_db_test_field_unit_type(union acpi_operand_object *obj_desc);
40 acpi_db_read_from_object(struct acpi_namespace_node *node,
41 acpi_object_type expected_type,
42 union acpi_object **value);
45 acpi_db_write_to_object(struct acpi_namespace_node *node,
46 union acpi_object *value);
48 static void acpi_db_evaluate_all_predefined_names(char *count_arg);
51 acpi_db_evaluate_one_predefined_name(acpi_handle obj_handle,
53 void *context, void **return_value);
58 static struct acpi_db_argument_info acpi_db_test_types[] = {
61 {NULL} /* Must be null terminated */
64 #define CMD_TEST_OBJECTS 0
65 #define CMD_TEST_PREDEFINED 1
67 #define BUFFER_FILL_VALUE 0xFF
70 * Support for the special debugger read/write control methods.
71 * These methods are installed into the current namespace and are
72 * used to read and write the various namespace objects. The point
73 * is to force the AML interpreter do all of the work.
75 #define ACPI_DB_READ_METHOD "\\_T98"
76 #define ACPI_DB_WRITE_METHOD "\\_T99"
78 static acpi_handle read_handle = NULL;
79 static acpi_handle write_handle = NULL;
81 /* ASL Definitions of the debugger read/write control methods. AML below. */
84 definition_block("ssdt.aml", "SSDT", 2, "Intel", "DEBUG", 0x00000001)
86 method(_T98, 1, not_serialized) { /* Read */
87 return (de_ref_of(arg0))
91 definition_block("ssdt2.aml", "SSDT", 2, "Intel", "DEBUG", 0x00000001)
93 method(_T99, 2, not_serialized) { /* Write */
99 static unsigned char read_method_code[] = {
100 0x53, 0x53, 0x44, 0x54, 0x2E, 0x00, 0x00, 0x00, /* 00000000 "SSDT...." */
101 0x02, 0xC9, 0x49, 0x6E, 0x74, 0x65, 0x6C, 0x00, /* 00000008 "..Intel." */
102 0x44, 0x45, 0x42, 0x55, 0x47, 0x00, 0x00, 0x00, /* 00000010 "DEBUG..." */
103 0x01, 0x00, 0x00, 0x00, 0x49, 0x4E, 0x54, 0x4C, /* 00000018 "....INTL" */
104 0x18, 0x12, 0x13, 0x20, 0x14, 0x09, 0x5F, 0x54, /* 00000020 "... .._T" */
105 0x39, 0x38, 0x01, 0xA4, 0x83, 0x68 /* 00000028 "98...h" */
108 static unsigned char write_method_code[] = {
109 0x53, 0x53, 0x44, 0x54, 0x2E, 0x00, 0x00, 0x00, /* 00000000 "SSDT...." */
110 0x02, 0x15, 0x49, 0x6E, 0x74, 0x65, 0x6C, 0x00, /* 00000008 "..Intel." */
111 0x44, 0x45, 0x42, 0x55, 0x47, 0x00, 0x00, 0x00, /* 00000010 "DEBUG..." */
112 0x01, 0x00, 0x00, 0x00, 0x49, 0x4E, 0x54, 0x4C, /* 00000018 "....INTL" */
113 0x18, 0x12, 0x13, 0x20, 0x14, 0x09, 0x5F, 0x54, /* 00000020 "... .._T" */
114 0x39, 0x39, 0x02, 0x70, 0x69, 0x68 /* 00000028 "99.pih" */
117 /*******************************************************************************
119 * FUNCTION: acpi_db_execute_test
121 * PARAMETERS: type_arg - Subcommand
125 * DESCRIPTION: Execute various debug tests.
127 * Note: Code is prepared for future expansion of the TEST command.
129 ******************************************************************************/
131 void acpi_db_execute_test(char *type_arg)
135 acpi_ut_strupr(type_arg);
136 temp = acpi_db_match_argument(type_arg, acpi_db_test_types);
137 if (temp == ACPI_TYPE_NOT_FOUND) {
138 acpi_os_printf("Invalid or unsupported argument\n");
143 case CMD_TEST_OBJECTS:
145 acpi_db_test_all_objects();
148 case CMD_TEST_PREDEFINED:
150 acpi_db_evaluate_all_predefined_names(NULL);
158 /*******************************************************************************
160 * FUNCTION: acpi_db_test_all_objects
166 * DESCRIPTION: This test implements the OBJECTS subcommand. It exercises the
167 * namespace by reading/writing/comparing all data objects such
168 * as integers, strings, buffers, fields, buffer fields, etc.
170 ******************************************************************************/
172 static void acpi_db_test_all_objects(void)
176 /* Install the debugger read-object control method if necessary */
179 status = acpi_install_method(read_method_code);
180 if (ACPI_FAILURE(status)) {
182 ("%s, Could not install debugger read method\n",
183 acpi_format_exception(status));
188 acpi_get_handle(NULL, ACPI_DB_READ_METHOD, &read_handle);
189 if (ACPI_FAILURE(status)) {
191 ("Could not obtain handle for debug method %s\n",
192 ACPI_DB_READ_METHOD);
197 /* Install the debugger write-object control method if necessary */
200 status = acpi_install_method(write_method_code);
201 if (ACPI_FAILURE(status)) {
203 ("%s, Could not install debugger write method\n",
204 acpi_format_exception(status));
209 acpi_get_handle(NULL, ACPI_DB_WRITE_METHOD, &write_handle);
210 if (ACPI_FAILURE(status)) {
212 ("Could not obtain handle for debug method %s\n",
213 ACPI_DB_WRITE_METHOD);
218 /* Walk the entire namespace, testing each supported named data object */
220 (void)acpi_walk_namespace(ACPI_TYPE_ANY, ACPI_ROOT_OBJECT,
221 ACPI_UINT32_MAX, acpi_db_test_one_object,
225 /*******************************************************************************
227 * FUNCTION: acpi_db_test_one_object
229 * PARAMETERS: acpi_walk_callback
233 * DESCRIPTION: Test one namespace object. Supported types are Integer,
234 * String, Buffer, Package, buffer_field, and field_unit.
235 * All other object types are simply ignored.
237 ******************************************************************************/
240 acpi_db_test_one_object(acpi_handle obj_handle,
241 u32 nesting_level, void *context, void **return_value)
243 struct acpi_namespace_node *node;
244 union acpi_operand_object *obj_desc;
245 acpi_object_type local_type;
248 acpi_status status = AE_OK;
250 node = ACPI_CAST_PTR(struct acpi_namespace_node, obj_handle);
251 obj_desc = node->object;
254 * For the supported types, get the actual bit length or
255 * byte length. Map the type to one of Integer/String/Buffer.
257 switch (node->type) {
258 case ACPI_TYPE_INTEGER:
260 /* Integer width is either 32 or 64 */
262 local_type = ACPI_TYPE_INTEGER;
263 bit_length = acpi_gbl_integer_bit_width;
266 case ACPI_TYPE_STRING:
268 local_type = ACPI_TYPE_STRING;
269 byte_length = obj_desc->string.length;
272 case ACPI_TYPE_BUFFER:
274 local_type = ACPI_TYPE_BUFFER;
275 byte_length = obj_desc->buffer.length;
276 bit_length = byte_length * 8;
279 case ACPI_TYPE_PACKAGE:
281 local_type = ACPI_TYPE_PACKAGE;
284 case ACPI_TYPE_FIELD_UNIT:
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_FIELD_UNIT;
292 case ACPI_TYPE_BUFFER_FIELD:
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).
298 local_type = ACPI_TYPE_INTEGER;
300 bit_length = obj_desc->common_field.bit_length;
301 byte_length = ACPI_ROUND_BITS_UP_TO_BYTES(bit_length);
302 if (bit_length > acpi_gbl_integer_bit_width) {
303 local_type = ACPI_TYPE_BUFFER;
310 /* Ignore all non-data types - Methods, Devices, Scopes, etc. */
315 /* Emit the common prefix: Type:Name */
317 acpi_os_printf("%14s: %4.4s",
318 acpi_ut_get_type_name(node->type), node->name.ascii);
321 acpi_os_printf(" No attached sub-object, ignoring\n");
325 /* At this point, we have resolved the object to one of the major types */
327 switch (local_type) {
328 case ACPI_TYPE_INTEGER:
330 status = acpi_db_test_integer_type(node, bit_length);
333 case ACPI_TYPE_STRING:
335 status = acpi_db_test_string_type(node, byte_length);
338 case ACPI_TYPE_BUFFER:
340 status = acpi_db_test_buffer_type(node, bit_length);
343 case ACPI_TYPE_PACKAGE:
345 status = acpi_db_test_package_type(node);
348 case ACPI_TYPE_FIELD_UNIT:
350 status = acpi_db_test_field_unit_type(obj_desc);
355 acpi_os_printf(" Ignoring, type not implemented (%2.2X)",
360 /* Exit on error, but don't abort the namespace walk */
362 if (ACPI_FAILURE(status)) {
366 acpi_os_printf("\n");
370 /*******************************************************************************
372 * FUNCTION: acpi_db_test_integer_type
374 * PARAMETERS: node - Parent NS node for the object
375 * bit_length - Actual length of the object. Used for
376 * support of arbitrary length field_unit
377 * and buffer_field objects.
381 * DESCRIPTION: Test read/write for an Integer-valued object. Performs a
382 * write/read/compare of an arbitrary new value, then performs
383 * a write/read/compare of the original value.
385 ******************************************************************************/
388 acpi_db_test_integer_type(struct acpi_namespace_node *node, u32 bit_length)
390 union acpi_object *temp1 = NULL;
391 union acpi_object *temp2 = NULL;
392 union acpi_object *temp3 = NULL;
393 union acpi_object write_value;
397 if (bit_length > 64) {
398 acpi_os_printf(" Invalid length for an Integer: %u",
403 /* Read the original value */
405 status = acpi_db_read_from_object(node, ACPI_TYPE_INTEGER, &temp1);
406 if (ACPI_FAILURE(status)) {
410 acpi_os_printf(ACPI_DEBUG_LENGTH_FORMAT " %8.8X%8.8X",
411 bit_length, ACPI_ROUND_BITS_UP_TO_BYTES(bit_length),
412 ACPI_FORMAT_UINT64(temp1->integer.value));
414 value_to_write = ACPI_UINT64_MAX >> (64 - bit_length);
415 if (temp1->integer.value == value_to_write) {
418 /* Write a new value */
420 write_value.type = ACPI_TYPE_INTEGER;
421 write_value.integer.value = value_to_write;
422 status = acpi_db_write_to_object(node, &write_value);
423 if (ACPI_FAILURE(status)) {
427 /* Ensure that we can read back the new value */
429 status = acpi_db_read_from_object(node, ACPI_TYPE_INTEGER, &temp2);
430 if (ACPI_FAILURE(status)) {
434 if (temp2->integer.value != value_to_write) {
435 acpi_os_printf(" MISMATCH 2: %8.8X%8.8X, expecting %8.8X%8.8X",
436 ACPI_FORMAT_UINT64(temp2->integer.value),
437 ACPI_FORMAT_UINT64(value_to_write));
440 /* Write back the original value */
442 write_value.integer.value = temp1->integer.value;
443 status = acpi_db_write_to_object(node, &write_value);
444 if (ACPI_FAILURE(status)) {
448 /* Ensure that we can read back the original value */
450 status = acpi_db_read_from_object(node, ACPI_TYPE_INTEGER, &temp3);
451 if (ACPI_FAILURE(status)) {
455 if (temp3->integer.value != temp1->integer.value) {
456 acpi_os_printf(" MISMATCH 3: %8.8X%8.8X, expecting %8.8X%8.8X",
457 ACPI_FORMAT_UINT64(temp3->integer.value),
458 ACPI_FORMAT_UINT64(temp1->integer.value));
474 /*******************************************************************************
476 * FUNCTION: acpi_db_test_buffer_type
478 * PARAMETERS: node - Parent NS node for the object
479 * bit_length - Actual length of the object.
483 * DESCRIPTION: Test read/write for an Buffer-valued object. Performs a
484 * write/read/compare of an arbitrary new value, then performs
485 * a write/read/compare of the original value.
487 ******************************************************************************/
490 acpi_db_test_buffer_type(struct acpi_namespace_node *node, u32 bit_length)
492 union acpi_object *temp1 = NULL;
493 union acpi_object *temp2 = NULL;
494 union acpi_object *temp3 = NULL;
496 union acpi_object write_value;
502 byte_length = ACPI_ROUND_BITS_UP_TO_BYTES(bit_length);
503 if (byte_length == 0) {
504 acpi_os_printf(" Ignoring zero length buffer");
508 /* Allocate a local buffer */
510 buffer = ACPI_ALLOCATE_ZEROED(byte_length);
512 return (AE_NO_MEMORY);
515 /* Read the original value */
517 status = acpi_db_read_from_object(node, ACPI_TYPE_BUFFER, &temp1);
518 if (ACPI_FAILURE(status)) {
522 /* Emit a few bytes of the buffer */
524 acpi_os_printf(ACPI_DEBUG_LENGTH_FORMAT, bit_length,
525 temp1->buffer.length);
526 for (i = 0; ((i < 8) && (i < byte_length)); i++) {
527 acpi_os_printf(" %2.2X", temp1->buffer.pointer[i]);
529 acpi_os_printf("... ");
534 * Handle possible extra bits at the end of the buffer. Can
535 * happen for field_units larger than an integer, but the bit
536 * count is not an integral number of bytes. Zero out the
539 memset(buffer, BUFFER_FILL_VALUE, byte_length);
540 extra_bits = bit_length % 8;
542 buffer[byte_length - 1] = ACPI_MASK_BITS_ABOVE(extra_bits);
545 write_value.type = ACPI_TYPE_BUFFER;
546 write_value.buffer.length = byte_length;
547 write_value.buffer.pointer = buffer;
549 status = acpi_db_write_to_object(node, &write_value);
550 if (ACPI_FAILURE(status)) {
554 /* Ensure that we can read back the new value */
556 status = acpi_db_read_from_object(node, ACPI_TYPE_BUFFER, &temp2);
557 if (ACPI_FAILURE(status)) {
561 if (memcmp(temp2->buffer.pointer, buffer, byte_length)) {
562 acpi_os_printf(" MISMATCH 2: New buffer value");
565 /* Write back the original value */
567 write_value.buffer.length = byte_length;
568 write_value.buffer.pointer = temp1->buffer.pointer;
570 status = acpi_db_write_to_object(node, &write_value);
571 if (ACPI_FAILURE(status)) {
575 /* Ensure that we can read back the original value */
577 status = acpi_db_read_from_object(node, ACPI_TYPE_BUFFER, &temp3);
578 if (ACPI_FAILURE(status)) {
582 if (memcmp(temp1->buffer.pointer, temp3->buffer.pointer, byte_length)) {
583 acpi_os_printf(" MISMATCH 3: While restoring original buffer");
600 /*******************************************************************************
602 * FUNCTION: acpi_db_test_string_type
604 * PARAMETERS: node - Parent NS node for the object
605 * byte_length - Actual length of the object.
609 * DESCRIPTION: Test read/write for an String-valued object. Performs a
610 * write/read/compare of an arbitrary new value, then performs
611 * a write/read/compare of the original value.
613 ******************************************************************************/
616 acpi_db_test_string_type(struct acpi_namespace_node *node, u32 byte_length)
618 union acpi_object *temp1 = NULL;
619 union acpi_object *temp2 = NULL;
620 union acpi_object *temp3 = NULL;
621 char *value_to_write = "Test String from AML Debugger";
622 union acpi_object write_value;
625 /* Read the original value */
627 status = acpi_db_read_from_object(node, ACPI_TYPE_STRING, &temp1);
628 if (ACPI_FAILURE(status)) {
632 acpi_os_printf(ACPI_DEBUG_LENGTH_FORMAT " \"%s\"",
633 (temp1->string.length * 8), temp1->string.length,
634 temp1->string.pointer);
636 /* Write a new value */
638 write_value.type = ACPI_TYPE_STRING;
639 write_value.string.length = strlen(value_to_write);
640 write_value.string.pointer = value_to_write;
642 status = acpi_db_write_to_object(node, &write_value);
643 if (ACPI_FAILURE(status)) {
647 /* Ensure that we can read back the new value */
649 status = acpi_db_read_from_object(node, ACPI_TYPE_STRING, &temp2);
650 if (ACPI_FAILURE(status)) {
654 if (strcmp(temp2->string.pointer, value_to_write)) {
655 acpi_os_printf(" MISMATCH 2: %s, expecting %s",
656 temp2->string.pointer, value_to_write);
659 /* Write back the original value */
661 write_value.string.length = strlen(temp1->string.pointer);
662 write_value.string.pointer = temp1->string.pointer;
664 status = acpi_db_write_to_object(node, &write_value);
665 if (ACPI_FAILURE(status)) {
669 /* Ensure that we can read back the original value */
671 status = acpi_db_read_from_object(node, ACPI_TYPE_STRING, &temp3);
672 if (ACPI_FAILURE(status)) {
676 if (strcmp(temp1->string.pointer, temp3->string.pointer)) {
677 acpi_os_printf(" MISMATCH 3: %s, expecting %s",
678 temp3->string.pointer, temp1->string.pointer);
694 /*******************************************************************************
696 * FUNCTION: acpi_db_test_package_type
698 * PARAMETERS: node - Parent NS node for the object
702 * DESCRIPTION: Test read for a Package object.
704 ******************************************************************************/
706 static acpi_status acpi_db_test_package_type(struct acpi_namespace_node *node)
708 union acpi_object *temp1 = NULL;
711 /* Read the original value */
713 status = acpi_db_read_from_object(node, ACPI_TYPE_PACKAGE, &temp1);
714 if (ACPI_FAILURE(status)) {
718 acpi_os_printf(" %.2X Elements", temp1->package.count);
723 /*******************************************************************************
725 * FUNCTION: acpi_db_test_field_unit_type
727 * PARAMETERS: obj_desc - A field unit object
731 * DESCRIPTION: Test read/write on a named field unit.
733 ******************************************************************************/
736 acpi_db_test_field_unit_type(union acpi_operand_object *obj_desc)
738 union acpi_operand_object *region_obj;
741 acpi_status status = AE_OK;
742 union acpi_operand_object *ret_buffer_desc;
744 /* Supported spaces are memory/io/pci_config */
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:
752 /* Need the interpreter to execute */
754 acpi_ut_acquire_mutex(ACPI_MTX_INTERPRETER);
755 acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
757 /* Exercise read-then-write */
760 acpi_ex_read_data_from_field(NULL, obj_desc,
762 if (status == AE_OK) {
763 acpi_ex_write_data_to_field(ret_buffer_desc, obj_desc,
765 acpi_ut_remove_reference(ret_buffer_desc);
768 acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
769 acpi_ut_release_mutex(ACPI_MTX_INTERPRETER);
771 bit_length = obj_desc->common_field.bit_length;
772 byte_length = ACPI_ROUND_BITS_UP_TO_BYTES(bit_length);
774 acpi_os_printf(ACPI_DEBUG_LENGTH_FORMAT " [%s]", bit_length,
776 acpi_ut_get_region_name(region_obj->region.
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);
790 /*******************************************************************************
792 * FUNCTION: acpi_db_read_from_object
794 * PARAMETERS: node - Parent NS node for the object
795 * expected_type - Object type expected from the read
796 * value - Where the value read is returned
800 * DESCRIPTION: Performs a read from the specified object by invoking the
801 * special debugger control method that reads the object. Thus,
802 * the AML interpreter is doing all of the work, increasing the
803 * validity of the test.
805 ******************************************************************************/
808 acpi_db_read_from_object(struct acpi_namespace_node *node,
809 acpi_object_type expected_type,
810 union acpi_object **value)
812 union acpi_object *ret_value;
813 struct acpi_object_list param_objects;
814 union acpi_object params[2];
815 struct acpi_buffer return_obj;
818 params[0].type = ACPI_TYPE_LOCAL_REFERENCE;
819 params[0].reference.actual_type = node->type;
820 params[0].reference.handle = ACPI_CAST_PTR(acpi_handle, node);
822 param_objects.count = 1;
823 param_objects.pointer = params;
825 return_obj.length = ACPI_ALLOCATE_BUFFER;
827 acpi_gbl_method_executing = TRUE;
828 status = acpi_evaluate_object(read_handle, NULL,
829 ¶m_objects, &return_obj);
831 acpi_gbl_method_executing = FALSE;
832 if (ACPI_FAILURE(status)) {
833 acpi_os_printf("Could not read from object, %s",
834 acpi_format_exception(status));
838 ret_value = (union acpi_object *)return_obj.pointer;
840 switch (ret_value->type) {
841 case ACPI_TYPE_INTEGER:
842 case ACPI_TYPE_BUFFER:
843 case ACPI_TYPE_STRING:
844 case ACPI_TYPE_PACKAGE:
846 * Did we receive the type we wanted? Most important for the
847 * Integer/Buffer case (when a field is larger than an Integer,
848 * it should return a Buffer).
850 if (ret_value->type != expected_type) {
852 (" Type mismatch: Expected %s, Received %s",
853 acpi_ut_get_type_name(expected_type),
854 acpi_ut_get_type_name(ret_value->type));
856 acpi_os_free(return_obj.pointer);
865 acpi_os_printf(" Unsupported return object type, %s",
866 acpi_ut_get_type_name(ret_value->type));
868 acpi_os_free(return_obj.pointer);
875 /*******************************************************************************
877 * FUNCTION: acpi_db_write_to_object
879 * PARAMETERS: node - Parent NS node for the object
880 * value - Value to be written
884 * DESCRIPTION: Performs a write to the specified object by invoking the
885 * special debugger control method that writes the object. Thus,
886 * the AML interpreter is doing all of the work, increasing the
887 * validity of the test.
889 ******************************************************************************/
892 acpi_db_write_to_object(struct acpi_namespace_node *node,
893 union acpi_object *value)
895 struct acpi_object_list param_objects;
896 union acpi_object params[2];
899 params[0].type = ACPI_TYPE_LOCAL_REFERENCE;
900 params[0].reference.actual_type = node->type;
901 params[0].reference.handle = ACPI_CAST_PTR(acpi_handle, node);
903 /* Copy the incoming user parameter */
905 memcpy(¶ms[1], value, sizeof(union acpi_object));
907 param_objects.count = 2;
908 param_objects.pointer = params;
910 acpi_gbl_method_executing = TRUE;
911 status = acpi_evaluate_object(write_handle, NULL, ¶m_objects, NULL);
912 acpi_gbl_method_executing = FALSE;
914 if (ACPI_FAILURE(status)) {
915 acpi_os_printf("Could not write to object, %s",
916 acpi_format_exception(status));
922 /*******************************************************************************
924 * FUNCTION: acpi_db_evaluate_all_predefined_names
926 * PARAMETERS: count_arg - Max number of methods to execute
930 * DESCRIPTION: Namespace batch execution. Execute predefined names in the
931 * namespace, up to the max count, if specified.
933 ******************************************************************************/
935 static void acpi_db_evaluate_all_predefined_names(char *count_arg)
937 struct acpi_db_execute_walk info;
940 info.max_count = ACPI_UINT32_MAX;
943 info.max_count = strtoul(count_arg, NULL, 0);
946 /* Search all nodes in namespace */
948 (void)acpi_walk_namespace(ACPI_TYPE_ANY, ACPI_ROOT_OBJECT,
950 acpi_db_evaluate_one_predefined_name, NULL,
951 (void *)&info, NULL);
953 acpi_os_printf("Evaluated %u predefined names in the namespace\n",
957 /*******************************************************************************
959 * FUNCTION: acpi_db_evaluate_one_predefined_name
961 * PARAMETERS: Callback from walk_namespace
965 * DESCRIPTION: Batch execution module. Currently only executes predefined
968 ******************************************************************************/
971 acpi_db_evaluate_one_predefined_name(acpi_handle obj_handle,
973 void *context, void **return_value)
975 struct acpi_namespace_node *node =
976 (struct acpi_namespace_node *)obj_handle;
977 struct acpi_db_execute_walk *info =
978 (struct acpi_db_execute_walk *)context;
980 const union acpi_predefined_info *predefined;
981 struct acpi_device_info *obj_info;
982 struct acpi_object_list param_objects;
983 union acpi_object params[ACPI_METHOD_NUM_ARGS];
984 union acpi_object *this_param;
985 struct acpi_buffer return_obj;
992 /* The name must be a predefined ACPI name */
994 predefined = acpi_ut_match_predefined_method(node->name.ascii);
999 if (node->type == ACPI_TYPE_LOCAL_SCOPE) {
1003 pathname = acpi_ns_get_normalized_pathname(node, TRUE);
1008 /* Get the object info for number of method parameters */
1010 status = acpi_get_object_info(obj_handle, &obj_info);
1011 if (ACPI_FAILURE(status)) {
1012 ACPI_FREE(pathname);
1016 param_objects.count = 0;
1017 param_objects.pointer = NULL;
1019 if (obj_info->type == ACPI_TYPE_METHOD) {
1021 /* Setup default parameters (with proper types) */
1023 arg_type_list = predefined->info.argument_list;
1024 arg_count = METHOD_GET_ARG_COUNT(arg_type_list);
1027 * Setup the ACPI-required number of arguments, regardless of what
1028 * the actual method defines. If there is a difference, then the
1029 * method is wrong and a warning will be issued during execution.
1031 this_param = params;
1032 for (i = 0; i < arg_count; i++) {
1033 arg_type = METHOD_GET_NEXT_TYPE(arg_type_list);
1034 this_param->type = arg_type;
1037 case ACPI_TYPE_INTEGER:
1039 this_param->integer.value = 1;
1042 case ACPI_TYPE_STRING:
1044 this_param->string.pointer =
1045 "This is the default argument string";
1046 this_param->string.length =
1047 strlen(this_param->string.pointer);
1050 case ACPI_TYPE_BUFFER:
1052 this_param->buffer.pointer = (u8 *)params; /* just a garbage buffer */
1053 this_param->buffer.length = 48;
1056 case ACPI_TYPE_PACKAGE:
1058 this_param->package.elements = NULL;
1059 this_param->package.count = 0;
1065 ("%s: Unsupported argument type: %u\n",
1066 pathname, arg_type);
1073 param_objects.count = arg_count;
1074 param_objects.pointer = params;
1077 ACPI_FREE(obj_info);
1078 return_obj.pointer = NULL;
1079 return_obj.length = ACPI_ALLOCATE_BUFFER;
1081 /* Do the actual method execution */
1083 acpi_gbl_method_executing = TRUE;
1085 status = acpi_evaluate_object(node, NULL, ¶m_objects, &return_obj);
1087 acpi_os_printf("%-32s returned %s\n",
1088 pathname, acpi_format_exception(status));
1089 acpi_gbl_method_executing = FALSE;
1090 ACPI_FREE(pathname);
1092 /* Ignore status from method execution */
1096 /* Update count, check if we have executed enough methods */
1099 if (info->count >= info->max_count) {
1100 status = AE_CTRL_TERMINATE;