1 /*******************************************************************************
3 * Module Name: dbtest - Various debug-related tests
5 ******************************************************************************/
8 * Copyright (C) 2000 - 2016, Intel Corp.
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
44 #include <acpi/acpi.h>
50 #define _COMPONENT ACPI_CA_DEBUGGER
51 ACPI_MODULE_NAME("dbtest")
53 /* Local prototypes */
54 static void acpi_db_test_all_objects(void);
57 acpi_db_test_one_object(acpi_handle obj_handle
,
58 u32 nesting_level
, void *context
, void **return_value
);
61 acpi_db_test_integer_type(struct acpi_namespace_node
*node
, u32 bit_length
);
64 acpi_db_test_buffer_type(struct acpi_namespace_node
*node
, u32 bit_length
);
67 acpi_db_test_string_type(struct acpi_namespace_node
*node
, u32 byte_length
);
70 acpi_db_read_from_object(struct acpi_namespace_node
*node
,
71 acpi_object_type expected_type
,
72 union acpi_object
**value
);
75 acpi_db_write_to_object(struct acpi_namespace_node
*node
,
76 union acpi_object
*value
);
78 static void acpi_db_evaluate_all_predefined_names(char *count_arg
);
81 acpi_db_evaluate_one_predefined_name(acpi_handle obj_handle
,
83 void *context
, void **return_value
);
88 static struct acpi_db_argument_info acpi_db_test_types
[] = {
91 {NULL
} /* Must be null terminated */
94 #define CMD_TEST_OBJECTS 0
95 #define CMD_TEST_PREDEFINED 1
97 #define BUFFER_FILL_VALUE 0xFF
100 * Support for the special debugger read/write control methods.
101 * These methods are installed into the current namespace and are
102 * used to read and write the various namespace objects. The point
103 * is to force the AML interpreter do all of the work.
105 #define ACPI_DB_READ_METHOD "\\_T98"
106 #define ACPI_DB_WRITE_METHOD "\\_T99"
108 static acpi_handle read_handle
= NULL
;
109 static acpi_handle write_handle
= NULL
;
111 /* ASL Definitions of the debugger read/write control methods */
114 definition_block("ssdt.aml", "SSDT", 2, "Intel", "DEBUG", 0x00000001)
116 method(_T98
, 1, not_serialized
) { /* Read */
117 return (de_ref_of(arg0
))
121 definition_block("ssdt2.aml", "SSDT", 2, "Intel", "DEBUG", 0x00000001)
123 method(_T99
, 2, not_serialized
) { /* Write */
129 static unsigned char read_method_code
[] = {
130 0x53, 0x53, 0x44, 0x54, 0x2E, 0x00, 0x00, 0x00, /* 00000000 "SSDT...." */
131 0x02, 0xC9, 0x49, 0x6E, 0x74, 0x65, 0x6C, 0x00, /* 00000008 "..Intel." */
132 0x44, 0x45, 0x42, 0x55, 0x47, 0x00, 0x00, 0x00, /* 00000010 "DEBUG..." */
133 0x01, 0x00, 0x00, 0x00, 0x49, 0x4E, 0x54, 0x4C, /* 00000018 "....INTL" */
134 0x18, 0x12, 0x13, 0x20, 0x14, 0x09, 0x5F, 0x54, /* 00000020 "... .._T" */
135 0x39, 0x38, 0x01, 0xA4, 0x83, 0x68 /* 00000028 "98...h" */
138 static unsigned char write_method_code
[] = {
139 0x53, 0x53, 0x44, 0x54, 0x2E, 0x00, 0x00, 0x00, /* 00000000 "SSDT...." */
140 0x02, 0x15, 0x49, 0x6E, 0x74, 0x65, 0x6C, 0x00, /* 00000008 "..Intel." */
141 0x44, 0x45, 0x42, 0x55, 0x47, 0x00, 0x00, 0x00, /* 00000010 "DEBUG..." */
142 0x01, 0x00, 0x00, 0x00, 0x49, 0x4E, 0x54, 0x4C, /* 00000018 "....INTL" */
143 0x18, 0x12, 0x13, 0x20, 0x14, 0x09, 0x5F, 0x54, /* 00000020 "... .._T" */
144 0x39, 0x39, 0x02, 0x70, 0x69, 0x68 /* 00000028 "99.pih" */
147 /*******************************************************************************
149 * FUNCTION: acpi_db_execute_test
151 * PARAMETERS: type_arg - Subcommand
155 * DESCRIPTION: Execute various debug tests.
157 * Note: Code is prepared for future expansion of the TEST command.
159 ******************************************************************************/
161 void acpi_db_execute_test(char *type_arg
)
165 acpi_ut_strupr(type_arg
);
166 temp
= acpi_db_match_argument(type_arg
, acpi_db_test_types
);
167 if (temp
== ACPI_TYPE_NOT_FOUND
) {
168 acpi_os_printf("Invalid or unsupported argument\n");
173 case CMD_TEST_OBJECTS
:
175 acpi_db_test_all_objects();
178 case CMD_TEST_PREDEFINED
:
180 acpi_db_evaluate_all_predefined_names(NULL
);
188 /*******************************************************************************
190 * FUNCTION: acpi_db_test_all_objects
196 * DESCRIPTION: This test implements the OBJECTS subcommand. It exercises the
197 * namespace by reading/writing/comparing all data objects such
198 * as integers, strings, buffers, fields, buffer fields, etc.
200 ******************************************************************************/
202 static void acpi_db_test_all_objects(void)
206 /* Install the debugger read-object control method if necessary */
209 status
= acpi_install_method(read_method_code
);
210 if (ACPI_FAILURE(status
)) {
212 ("%s, Could not install debugger read method\n",
213 acpi_format_exception(status
));
218 acpi_get_handle(NULL
, ACPI_DB_READ_METHOD
, &read_handle
);
219 if (ACPI_FAILURE(status
)) {
221 ("Could not obtain handle for debug method %s\n",
222 ACPI_DB_READ_METHOD
);
227 /* Install the debugger write-object control method if necessary */
230 status
= acpi_install_method(write_method_code
);
231 if (ACPI_FAILURE(status
)) {
233 ("%s, Could not install debugger write method\n",
234 acpi_format_exception(status
));
239 acpi_get_handle(NULL
, ACPI_DB_WRITE_METHOD
, &write_handle
);
240 if (ACPI_FAILURE(status
)) {
242 ("Could not obtain handle for debug method %s\n",
243 ACPI_DB_WRITE_METHOD
);
248 /* Walk the entire namespace, testing each supported named data object */
250 (void)acpi_walk_namespace(ACPI_TYPE_ANY
, ACPI_ROOT_OBJECT
,
251 ACPI_UINT32_MAX
, acpi_db_test_one_object
,
255 /*******************************************************************************
257 * FUNCTION: acpi_db_test_one_object
259 * PARAMETERS: acpi_walk_callback
263 * DESCRIPTION: Test one namespace object. Supported types are Integer,
264 * String, Buffer, buffer_field, and field_unit. All other object
265 * types are simply ignored.
267 * Note: Support for Packages is not implemented.
269 ******************************************************************************/
272 acpi_db_test_one_object(acpi_handle obj_handle
,
273 u32 nesting_level
, void *context
, void **return_value
)
275 struct acpi_namespace_node
*node
;
276 union acpi_operand_object
*obj_desc
;
277 union acpi_operand_object
*region_obj
;
278 acpi_object_type local_type
;
281 acpi_status status
= AE_OK
;
283 node
= ACPI_CAST_PTR(struct acpi_namespace_node
, obj_handle
);
284 obj_desc
= node
->object
;
287 * For the supported types, get the actual bit length or
288 * byte length. Map the type to one of Integer/String/Buffer.
290 switch (node
->type
) {
291 case ACPI_TYPE_INTEGER
:
293 /* Integer width is either 32 or 64 */
295 local_type
= ACPI_TYPE_INTEGER
;
296 bit_length
= acpi_gbl_integer_bit_width
;
299 case ACPI_TYPE_STRING
:
301 local_type
= ACPI_TYPE_STRING
;
302 byte_length
= obj_desc
->string
.length
;
305 case ACPI_TYPE_BUFFER
:
307 local_type
= ACPI_TYPE_BUFFER
;
308 byte_length
= obj_desc
->buffer
.length
;
309 bit_length
= byte_length
* 8;
312 case ACPI_TYPE_FIELD_UNIT
:
313 case ACPI_TYPE_BUFFER_FIELD
:
314 case ACPI_TYPE_LOCAL_REGION_FIELD
:
315 case ACPI_TYPE_LOCAL_INDEX_FIELD
:
316 case ACPI_TYPE_LOCAL_BANK_FIELD
:
318 local_type
= ACPI_TYPE_INTEGER
;
321 * Returned object will be a Buffer if the field length
322 * is larger than the size of an Integer (32 or 64 bits
323 * depending on the DSDT version).
325 bit_length
= obj_desc
->common_field
.bit_length
;
326 byte_length
= ACPI_ROUND_BITS_UP_TO_BYTES(bit_length
);
327 if (bit_length
> acpi_gbl_integer_bit_width
) {
328 local_type
= ACPI_TYPE_BUFFER
;
335 /* Ignore all other types */
340 /* Emit the common prefix: Type:Name */
342 acpi_os_printf("%14s: %4.4s",
343 acpi_ut_get_type_name(node
->type
), node
->name
.ascii
);
345 acpi_os_printf(" Ignoring, no attached object\n");
350 * Check for unsupported region types. Note: acpi_exec simulates
351 * access to system_memory, system_IO, PCI_Config, and EC.
353 switch (node
->type
) {
354 case ACPI_TYPE_LOCAL_REGION_FIELD
:
356 region_obj
= obj_desc
->field
.region_obj
;
357 switch (region_obj
->region
.space_id
) {
358 case ACPI_ADR_SPACE_SYSTEM_MEMORY
:
359 case ACPI_ADR_SPACE_SYSTEM_IO
:
360 case ACPI_ADR_SPACE_PCI_CONFIG
:
361 case ACPI_ADR_SPACE_EC
:
368 (" %s space is not supported [%4.4s]\n",
369 acpi_ut_get_region_name(region_obj
->region
.
371 region_obj
->region
.node
->name
.ascii
);
380 /* At this point, we have resolved the object to one of the major types */
382 switch (local_type
) {
383 case ACPI_TYPE_INTEGER
:
385 status
= acpi_db_test_integer_type(node
, bit_length
);
388 case ACPI_TYPE_STRING
:
390 status
= acpi_db_test_string_type(node
, byte_length
);
393 case ACPI_TYPE_BUFFER
:
395 status
= acpi_db_test_buffer_type(node
, bit_length
);
400 acpi_os_printf(" Ignoring, type not implemented (%2.2X)",
405 switch (node
->type
) {
406 case ACPI_TYPE_LOCAL_REGION_FIELD
:
408 region_obj
= obj_desc
->field
.region_obj
;
409 acpi_os_printf(" (%s)",
410 acpi_ut_get_region_name(region_obj
->region
.
418 acpi_os_printf("\n");
422 /*******************************************************************************
424 * FUNCTION: acpi_db_test_integer_type
426 * PARAMETERS: node - Parent NS node for the object
427 * bit_length - Actual length of the object. Used for
428 * support of arbitrary length field_unit
429 * and buffer_field objects.
433 * DESCRIPTION: Test read/write for an Integer-valued object. Performs a
434 * write/read/compare of an arbitrary new value, then performs
435 * a write/read/compare of the original value.
437 ******************************************************************************/
440 acpi_db_test_integer_type(struct acpi_namespace_node
*node
, u32 bit_length
)
442 union acpi_object
*temp1
= NULL
;
443 union acpi_object
*temp2
= NULL
;
444 union acpi_object
*temp3
= NULL
;
445 union acpi_object write_value
;
449 if (bit_length
> 64) {
450 acpi_os_printf(" Invalid length for an Integer: %u",
455 /* Read the original value */
457 status
= acpi_db_read_from_object(node
, ACPI_TYPE_INTEGER
, &temp1
);
458 if (ACPI_FAILURE(status
)) {
462 acpi_os_printf(" (%4.4X/%3.3X) %8.8X%8.8X",
463 bit_length
, ACPI_ROUND_BITS_UP_TO_BYTES(bit_length
),
464 ACPI_FORMAT_UINT64(temp1
->integer
.value
));
466 value_to_write
= ACPI_UINT64_MAX
>> (64 - bit_length
);
467 if (temp1
->integer
.value
== value_to_write
) {
471 /* Write a new value */
473 write_value
.type
= ACPI_TYPE_INTEGER
;
474 write_value
.integer
.value
= value_to_write
;
475 status
= acpi_db_write_to_object(node
, &write_value
);
476 if (ACPI_FAILURE(status
)) {
480 /* Ensure that we can read back the new value */
482 status
= acpi_db_read_from_object(node
, ACPI_TYPE_INTEGER
, &temp2
);
483 if (ACPI_FAILURE(status
)) {
487 if (temp2
->integer
.value
!= value_to_write
) {
488 acpi_os_printf(" MISMATCH 2: %8.8X%8.8X, expecting %8.8X%8.8X",
489 ACPI_FORMAT_UINT64(temp2
->integer
.value
),
490 ACPI_FORMAT_UINT64(value_to_write
));
493 /* Write back the original value */
495 write_value
.integer
.value
= temp1
->integer
.value
;
496 status
= acpi_db_write_to_object(node
, &write_value
);
497 if (ACPI_FAILURE(status
)) {
501 /* Ensure that we can read back the original value */
503 status
= acpi_db_read_from_object(node
, ACPI_TYPE_INTEGER
, &temp3
);
504 if (ACPI_FAILURE(status
)) {
508 if (temp3
->integer
.value
!= temp1
->integer
.value
) {
509 acpi_os_printf(" MISMATCH 3: %8.8X%8.8X, expecting %8.8X%8.8X",
510 ACPI_FORMAT_UINT64(temp3
->integer
.value
),
511 ACPI_FORMAT_UINT64(temp1
->integer
.value
));
527 /*******************************************************************************
529 * FUNCTION: acpi_db_test_buffer_type
531 * PARAMETERS: node - Parent NS node for the object
532 * bit_length - Actual length of the object.
536 * DESCRIPTION: Test read/write for an Buffer-valued object. Performs a
537 * write/read/compare of an arbitrary new value, then performs
538 * a write/read/compare of the original value.
540 ******************************************************************************/
543 acpi_db_test_buffer_type(struct acpi_namespace_node
*node
, u32 bit_length
)
545 union acpi_object
*temp1
= NULL
;
546 union acpi_object
*temp2
= NULL
;
547 union acpi_object
*temp3
= NULL
;
549 union acpi_object write_value
;
555 byte_length
= ACPI_ROUND_BITS_UP_TO_BYTES(bit_length
);
556 if (byte_length
== 0) {
557 acpi_os_printf(" Ignoring zero length buffer");
561 /* Allocate a local buffer */
563 buffer
= ACPI_ALLOCATE_ZEROED(byte_length
);
565 return (AE_NO_MEMORY
);
568 /* Read the original value */
570 status
= acpi_db_read_from_object(node
, ACPI_TYPE_BUFFER
, &temp1
);
571 if (ACPI_FAILURE(status
)) {
575 /* Emit a few bytes of the buffer */
577 acpi_os_printf(" (%4.4X/%3.3X)", bit_length
, temp1
->buffer
.length
);
578 for (i
= 0; ((i
< 4) && (i
< byte_length
)); i
++) {
579 acpi_os_printf(" %2.2X", temp1
->buffer
.pointer
[i
]);
581 acpi_os_printf("... ");
586 * Handle possible extra bits at the end of the buffer. Can
587 * happen for field_units larger than an integer, but the bit
588 * count is not an integral number of bytes. Zero out the
591 memset(buffer
, BUFFER_FILL_VALUE
, byte_length
);
592 extra_bits
= bit_length
% 8;
594 buffer
[byte_length
- 1] = ACPI_MASK_BITS_ABOVE(extra_bits
);
597 write_value
.type
= ACPI_TYPE_BUFFER
;
598 write_value
.buffer
.length
= byte_length
;
599 write_value
.buffer
.pointer
= buffer
;
601 status
= acpi_db_write_to_object(node
, &write_value
);
602 if (ACPI_FAILURE(status
)) {
606 /* Ensure that we can read back the new value */
608 status
= acpi_db_read_from_object(node
, ACPI_TYPE_BUFFER
, &temp2
);
609 if (ACPI_FAILURE(status
)) {
613 if (memcmp(temp2
->buffer
.pointer
, buffer
, byte_length
)) {
614 acpi_os_printf(" MISMATCH 2: New buffer value");
617 /* Write back the original value */
619 write_value
.buffer
.length
= byte_length
;
620 write_value
.buffer
.pointer
= temp1
->buffer
.pointer
;
622 status
= acpi_db_write_to_object(node
, &write_value
);
623 if (ACPI_FAILURE(status
)) {
627 /* Ensure that we can read back the original value */
629 status
= acpi_db_read_from_object(node
, ACPI_TYPE_BUFFER
, &temp3
);
630 if (ACPI_FAILURE(status
)) {
634 if (memcmp(temp1
->buffer
.pointer
, temp3
->buffer
.pointer
, byte_length
)) {
635 acpi_os_printf(" MISMATCH 3: While restoring original buffer");
652 /*******************************************************************************
654 * FUNCTION: acpi_db_test_string_type
656 * PARAMETERS: node - Parent NS node for the object
657 * byte_length - Actual length of the object.
661 * DESCRIPTION: Test read/write for an String-valued object. Performs a
662 * write/read/compare of an arbitrary new value, then performs
663 * a write/read/compare of the original value.
665 ******************************************************************************/
668 acpi_db_test_string_type(struct acpi_namespace_node
*node
, u32 byte_length
)
670 union acpi_object
*temp1
= NULL
;
671 union acpi_object
*temp2
= NULL
;
672 union acpi_object
*temp3
= NULL
;
673 char *value_to_write
= "Test String from AML Debugger";
674 union acpi_object write_value
;
677 /* Read the original value */
679 status
= acpi_db_read_from_object(node
, ACPI_TYPE_STRING
, &temp1
);
680 if (ACPI_FAILURE(status
)) {
684 acpi_os_printf(" (%4.4X/%3.3X) \"%s\"", (temp1
->string
.length
* 8),
685 temp1
->string
.length
, temp1
->string
.pointer
);
687 /* Write a new value */
689 write_value
.type
= ACPI_TYPE_STRING
;
690 write_value
.string
.length
= strlen(value_to_write
);
691 write_value
.string
.pointer
= value_to_write
;
693 status
= acpi_db_write_to_object(node
, &write_value
);
694 if (ACPI_FAILURE(status
)) {
698 /* Ensure that we can read back the new value */
700 status
= acpi_db_read_from_object(node
, ACPI_TYPE_STRING
, &temp2
);
701 if (ACPI_FAILURE(status
)) {
705 if (strcmp(temp2
->string
.pointer
, value_to_write
)) {
706 acpi_os_printf(" MISMATCH 2: %s, expecting %s",
707 temp2
->string
.pointer
, value_to_write
);
710 /* Write back the original value */
712 write_value
.string
.length
= strlen(temp1
->string
.pointer
);
713 write_value
.string
.pointer
= temp1
->string
.pointer
;
715 status
= acpi_db_write_to_object(node
, &write_value
);
716 if (ACPI_FAILURE(status
)) {
720 /* Ensure that we can read back the original value */
722 status
= acpi_db_read_from_object(node
, ACPI_TYPE_STRING
, &temp3
);
723 if (ACPI_FAILURE(status
)) {
727 if (strcmp(temp1
->string
.pointer
, temp3
->string
.pointer
)) {
728 acpi_os_printf(" MISMATCH 3: %s, expecting %s",
729 temp3
->string
.pointer
, temp1
->string
.pointer
);
745 /*******************************************************************************
747 * FUNCTION: acpi_db_read_from_object
749 * PARAMETERS: node - Parent NS node for the object
750 * expected_type - Object type expected from the read
751 * value - Where the value read is returned
755 * DESCRIPTION: Performs a read from the specified object by invoking the
756 * special debugger control method that reads the object. Thus,
757 * the AML interpreter is doing all of the work, increasing the
758 * validity of the test.
760 ******************************************************************************/
763 acpi_db_read_from_object(struct acpi_namespace_node
*node
,
764 acpi_object_type expected_type
,
765 union acpi_object
**value
)
767 union acpi_object
*ret_value
;
768 struct acpi_object_list param_objects
;
769 union acpi_object params
[2];
770 struct acpi_buffer return_obj
;
773 params
[0].type
= ACPI_TYPE_LOCAL_REFERENCE
;
774 params
[0].reference
.actual_type
= node
->type
;
775 params
[0].reference
.handle
= ACPI_CAST_PTR(acpi_handle
, node
);
777 param_objects
.count
= 1;
778 param_objects
.pointer
= params
;
780 return_obj
.length
= ACPI_ALLOCATE_BUFFER
;
782 acpi_gbl_method_executing
= TRUE
;
783 status
= acpi_evaluate_object(read_handle
, NULL
,
784 ¶m_objects
, &return_obj
);
785 acpi_gbl_method_executing
= FALSE
;
787 if (ACPI_FAILURE(status
)) {
788 acpi_os_printf("Could not read from object, %s",
789 acpi_format_exception(status
));
793 ret_value
= (union acpi_object
*)return_obj
.pointer
;
795 switch (ret_value
->type
) {
796 case ACPI_TYPE_INTEGER
:
797 case ACPI_TYPE_BUFFER
:
798 case ACPI_TYPE_STRING
:
800 * Did we receive the type we wanted? Most important for the
801 * Integer/Buffer case (when a field is larger than an Integer,
802 * it should return a Buffer).
804 if (ret_value
->type
!= expected_type
) {
806 (" Type mismatch: Expected %s, Received %s",
807 acpi_ut_get_type_name(expected_type
),
808 acpi_ut_get_type_name(ret_value
->type
));
818 acpi_os_printf(" Unsupported return object type, %s",
819 acpi_ut_get_type_name(ret_value
->type
));
821 acpi_os_free(return_obj
.pointer
);
828 /*******************************************************************************
830 * FUNCTION: acpi_db_write_to_object
832 * PARAMETERS: node - Parent NS node for the object
833 * value - Value to be written
837 * DESCRIPTION: Performs a write to the specified object by invoking the
838 * special debugger control method that writes the object. Thus,
839 * the AML interpreter is doing all of the work, increasing the
840 * validity of the test.
842 ******************************************************************************/
845 acpi_db_write_to_object(struct acpi_namespace_node
*node
,
846 union acpi_object
*value
)
848 struct acpi_object_list param_objects
;
849 union acpi_object params
[2];
852 params
[0].type
= ACPI_TYPE_LOCAL_REFERENCE
;
853 params
[0].reference
.actual_type
= node
->type
;
854 params
[0].reference
.handle
= ACPI_CAST_PTR(acpi_handle
, node
);
856 /* Copy the incoming user parameter */
858 memcpy(¶ms
[1], value
, sizeof(union acpi_object
));
860 param_objects
.count
= 2;
861 param_objects
.pointer
= params
;
863 acpi_gbl_method_executing
= TRUE
;
864 status
= acpi_evaluate_object(write_handle
, NULL
, ¶m_objects
, NULL
);
865 acpi_gbl_method_executing
= FALSE
;
867 if (ACPI_FAILURE(status
)) {
868 acpi_os_printf("Could not write to object, %s",
869 acpi_format_exception(status
));
875 /*******************************************************************************
877 * FUNCTION: acpi_db_evaluate_all_predefined_names
879 * PARAMETERS: count_arg - Max number of methods to execute
883 * DESCRIPTION: Namespace batch execution. Execute predefined names in the
884 * namespace, up to the max count, if specified.
886 ******************************************************************************/
888 static void acpi_db_evaluate_all_predefined_names(char *count_arg
)
890 struct acpi_db_execute_walk info
;
893 info
.max_count
= ACPI_UINT32_MAX
;
896 info
.max_count
= strtoul(count_arg
, NULL
, 0);
899 /* Search all nodes in namespace */
901 (void)acpi_walk_namespace(ACPI_TYPE_ANY
, ACPI_ROOT_OBJECT
,
903 acpi_db_evaluate_one_predefined_name
, NULL
,
904 (void *)&info
, NULL
);
906 acpi_os_printf("Evaluated %u predefined names in the namespace\n",
910 /*******************************************************************************
912 * FUNCTION: acpi_db_evaluate_one_predefined_name
914 * PARAMETERS: Callback from walk_namespace
918 * DESCRIPTION: Batch execution module. Currently only executes predefined
921 ******************************************************************************/
924 acpi_db_evaluate_one_predefined_name(acpi_handle obj_handle
,
926 void *context
, void **return_value
)
928 struct acpi_namespace_node
*node
=
929 (struct acpi_namespace_node
*)obj_handle
;
930 struct acpi_db_execute_walk
*info
=
931 (struct acpi_db_execute_walk
*)context
;
933 const union acpi_predefined_info
*predefined
;
934 struct acpi_device_info
*obj_info
;
935 struct acpi_object_list param_objects
;
936 union acpi_object params
[ACPI_METHOD_NUM_ARGS
];
937 union acpi_object
*this_param
;
938 struct acpi_buffer return_obj
;
945 /* The name must be a predefined ACPI name */
947 predefined
= acpi_ut_match_predefined_method(node
->name
.ascii
);
952 if (node
->type
== ACPI_TYPE_LOCAL_SCOPE
) {
956 pathname
= acpi_ns_get_normalized_pathname(node
, TRUE
);
961 /* Get the object info for number of method parameters */
963 status
= acpi_get_object_info(obj_handle
, &obj_info
);
964 if (ACPI_FAILURE(status
)) {
969 param_objects
.count
= 0;
970 param_objects
.pointer
= NULL
;
972 if (obj_info
->type
== ACPI_TYPE_METHOD
) {
974 /* Setup default parameters (with proper types) */
976 arg_type_list
= predefined
->info
.argument_list
;
977 arg_count
= METHOD_GET_ARG_COUNT(arg_type_list
);
980 * Setup the ACPI-required number of arguments, regardless of what
981 * the actual method defines. If there is a difference, then the
982 * method is wrong and a warning will be issued during execution.
985 for (i
= 0; i
< arg_count
; i
++) {
986 arg_type
= METHOD_GET_NEXT_TYPE(arg_type_list
);
987 this_param
->type
= arg_type
;
990 case ACPI_TYPE_INTEGER
:
992 this_param
->integer
.value
= 1;
995 case ACPI_TYPE_STRING
:
997 this_param
->string
.pointer
=
998 "This is the default argument string";
999 this_param
->string
.length
=
1000 strlen(this_param
->string
.pointer
);
1003 case ACPI_TYPE_BUFFER
:
1005 this_param
->buffer
.pointer
= (u8
*)params
; /* just a garbage buffer */
1006 this_param
->buffer
.length
= 48;
1009 case ACPI_TYPE_PACKAGE
:
1011 this_param
->package
.elements
= NULL
;
1012 this_param
->package
.count
= 0;
1018 ("%s: Unsupported argument type: %u\n",
1019 pathname
, arg_type
);
1026 param_objects
.count
= arg_count
;
1027 param_objects
.pointer
= params
;
1030 ACPI_FREE(obj_info
);
1031 return_obj
.pointer
= NULL
;
1032 return_obj
.length
= ACPI_ALLOCATE_BUFFER
;
1034 /* Do the actual method execution */
1036 acpi_gbl_method_executing
= TRUE
;
1038 status
= acpi_evaluate_object(node
, NULL
, ¶m_objects
, &return_obj
);
1040 acpi_os_printf("%-32s returned %s\n",
1041 pathname
, acpi_format_exception(status
));
1042 acpi_gbl_method_executing
= FALSE
;
1043 ACPI_FREE(pathname
);
1045 /* Ignore status from method execution */
1049 /* Update count, check if we have executed enough methods */
1052 if (info
->count
>= info
->max_count
) {
1053 status
= AE_CTRL_TERMINATE
;