1 /*******************************************************************************
3 * Module Name: dbexec - debugger control method execution
5 ******************************************************************************/
8 * Copyright (C) 2000 - 2018, 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>
49 #define _COMPONENT ACPI_CA_DEBUGGER
50 ACPI_MODULE_NAME("dbexec")
52 static struct acpi_db_method_info acpi_gbl_db_method_info
;
54 /* Local prototypes */
57 acpi_db_execute_method(struct acpi_db_method_info
*info
,
58 struct acpi_buffer
*return_obj
);
60 static acpi_status
acpi_db_execute_setup(struct acpi_db_method_info
*info
);
62 static u32
acpi_db_get_outstanding_allocations(void);
64 static void ACPI_SYSTEM_XFACE
acpi_db_method_thread(void *context
);
67 acpi_db_execution_walk(acpi_handle obj_handle
,
68 u32 nesting_level
, void *context
, void **return_value
);
70 static void ACPI_SYSTEM_XFACE
acpi_db_single_execution_thread(void *context
);
72 /*******************************************************************************
74 * FUNCTION: acpi_db_delete_objects
76 * PARAMETERS: count - Count of objects in the list
77 * objects - Array of ACPI_OBJECTs to be deleted
81 * DESCRIPTION: Delete a list of ACPI_OBJECTS. Handles packages and nested
82 * packages via recursion.
84 ******************************************************************************/
86 void acpi_db_delete_objects(u32 count
, union acpi_object
*objects
)
90 for (i
= 0; i
< count
; i
++) {
91 switch (objects
[i
].type
) {
92 case ACPI_TYPE_BUFFER
:
94 ACPI_FREE(objects
[i
].buffer
.pointer
);
97 case ACPI_TYPE_PACKAGE
:
99 /* Recursive call to delete package elements */
101 acpi_db_delete_objects(objects
[i
].package
.count
,
102 objects
[i
].package
.elements
);
104 /* Free the elements array */
106 ACPI_FREE(objects
[i
].package
.elements
);
116 /*******************************************************************************
118 * FUNCTION: acpi_db_execute_method
120 * PARAMETERS: info - Valid info segment
121 * return_obj - Where to put return object
125 * DESCRIPTION: Execute a control method.
127 ******************************************************************************/
130 acpi_db_execute_method(struct acpi_db_method_info
*info
,
131 struct acpi_buffer
*return_obj
)
134 struct acpi_object_list param_objects
;
135 union acpi_object params
[ACPI_DEBUGGER_MAX_ARGS
+ 1];
138 ACPI_FUNCTION_TRACE(db_execute_method
);
140 if (acpi_gbl_db_output_to_file
&& !acpi_dbg_level
) {
141 acpi_os_printf("Warning: debug output is not enabled!\n");
144 param_objects
.count
= 0;
145 param_objects
.pointer
= NULL
;
147 /* Pass through any command-line arguments */
149 if (info
->args
&& info
->args
[0]) {
151 /* Get arguments passed on the command line */
153 for (i
= 0; (info
->args
[i
] && *(info
->args
[i
])); i
++) {
155 /* Convert input string (token) to an actual union acpi_object */
157 status
= acpi_db_convert_to_object(info
->types
[i
],
160 if (ACPI_FAILURE(status
)) {
161 ACPI_EXCEPTION((AE_INFO
, status
,
162 "While parsing method arguments"));
167 param_objects
.count
= i
;
168 param_objects
.pointer
= params
;
171 /* Prepare for a return object of arbitrary size */
173 return_obj
->pointer
= acpi_gbl_db_buffer
;
174 return_obj
->length
= ACPI_DEBUG_BUFFER_SIZE
;
176 /* Do the actual method execution */
178 acpi_gbl_method_executing
= TRUE
;
179 status
= acpi_evaluate_object(NULL
, info
->pathname
,
180 ¶m_objects
, return_obj
);
182 acpi_gbl_cm_single_step
= FALSE
;
183 acpi_gbl_method_executing
= FALSE
;
185 if (ACPI_FAILURE(status
)) {
186 if ((status
== AE_ABORT_METHOD
) || acpi_gbl_abort_method
) {
188 /* Clear the abort and fall back to the debugger prompt */
190 ACPI_EXCEPTION((AE_INFO
, status
,
191 "Aborting top-level method"));
193 acpi_gbl_abort_method
= FALSE
;
198 ACPI_EXCEPTION((AE_INFO
, status
,
199 "while executing %s from debugger",
202 if (status
== AE_BUFFER_OVERFLOW
) {
204 "Possible overflow of internal debugger "
205 "buffer (size 0x%X needed 0x%X)",
206 ACPI_DEBUG_BUFFER_SIZE
,
207 (u32
)return_obj
->length
));
212 acpi_db_delete_objects(param_objects
.count
, params
);
213 return_ACPI_STATUS(status
);
216 /*******************************************************************************
218 * FUNCTION: acpi_db_execute_setup
220 * PARAMETERS: info - Valid method info
224 * DESCRIPTION: Setup info segment prior to method execution
226 ******************************************************************************/
228 static acpi_status
acpi_db_execute_setup(struct acpi_db_method_info
*info
)
232 ACPI_FUNCTION_NAME(db_execute_setup
);
234 /* Concatenate the current scope to the supplied name */
236 info
->pathname
[0] = 0;
237 if ((info
->name
[0] != '\\') && (info
->name
[0] != '/')) {
238 if (acpi_ut_safe_strcat(info
->pathname
, sizeof(info
->pathname
),
239 acpi_gbl_db_scope_buf
)) {
240 status
= AE_BUFFER_OVERFLOW
;
245 if (acpi_ut_safe_strcat(info
->pathname
, sizeof(info
->pathname
),
247 status
= AE_BUFFER_OVERFLOW
;
251 acpi_db_prep_namestring(info
->pathname
);
253 acpi_db_set_output_destination(ACPI_DB_DUPLICATE_OUTPUT
);
254 acpi_os_printf("Evaluating %s\n", info
->pathname
);
256 if (info
->flags
& EX_SINGLE_STEP
) {
257 acpi_gbl_cm_single_step
= TRUE
;
258 acpi_db_set_output_destination(ACPI_DB_CONSOLE_OUTPUT
);
262 /* No single step, allow redirection to a file */
264 acpi_db_set_output_destination(ACPI_DB_REDIRECTABLE_OUTPUT
);
271 ACPI_EXCEPTION((AE_INFO
, status
, "During setup for method execution"));
275 #ifdef ACPI_DBG_TRACK_ALLOCATIONS
276 u32
acpi_db_get_cache_info(struct acpi_memory_list
*cache
)
279 return (cache
->total_allocated
- cache
->total_freed
-
280 cache
->current_depth
);
284 /*******************************************************************************
286 * FUNCTION: acpi_db_get_outstanding_allocations
290 * RETURN: Current global allocation count minus cache entries
292 * DESCRIPTION: Determine the current number of "outstanding" allocations --
293 * those allocations that have not been freed and also are not
294 * in one of the various object caches.
296 ******************************************************************************/
298 static u32
acpi_db_get_outstanding_allocations(void)
302 #ifdef ACPI_DBG_TRACK_ALLOCATIONS
304 outstanding
+= acpi_db_get_cache_info(acpi_gbl_state_cache
);
305 outstanding
+= acpi_db_get_cache_info(acpi_gbl_ps_node_cache
);
306 outstanding
+= acpi_db_get_cache_info(acpi_gbl_ps_node_ext_cache
);
307 outstanding
+= acpi_db_get_cache_info(acpi_gbl_operand_cache
);
310 return (outstanding
);
313 /*******************************************************************************
315 * FUNCTION: acpi_db_execution_walk
317 * PARAMETERS: WALK_CALLBACK
321 * DESCRIPTION: Execute a control method. Name is relative to the current
324 ******************************************************************************/
327 acpi_db_execution_walk(acpi_handle obj_handle
,
328 u32 nesting_level
, void *context
, void **return_value
)
330 union acpi_operand_object
*obj_desc
;
331 struct acpi_namespace_node
*node
=
332 (struct acpi_namespace_node
*)obj_handle
;
333 struct acpi_buffer return_obj
;
336 obj_desc
= acpi_ns_get_attached_object(node
);
337 if (obj_desc
->method
.param_count
) {
341 return_obj
.pointer
= NULL
;
342 return_obj
.length
= ACPI_ALLOCATE_BUFFER
;
344 acpi_ns_print_node_pathname(node
, "Evaluating");
346 /* Do the actual method execution */
348 acpi_os_printf("\n");
349 acpi_gbl_method_executing
= TRUE
;
351 status
= acpi_evaluate_object(node
, NULL
, NULL
, &return_obj
);
353 acpi_os_printf("Evaluation of [%4.4s] returned %s\n",
354 acpi_ut_get_node_name(node
),
355 acpi_format_exception(status
));
357 acpi_gbl_method_executing
= FALSE
;
361 /*******************************************************************************
363 * FUNCTION: acpi_db_execute
365 * PARAMETERS: name - Name of method to execute
366 * args - Parameters to the method
368 * flags - single step/no single step
372 * DESCRIPTION: Execute a control method. Name is relative to the current
375 ******************************************************************************/
378 acpi_db_execute(char *name
, char **args
, acpi_object_type
*types
, u32 flags
)
381 struct acpi_buffer return_obj
;
384 #ifdef ACPI_DEBUG_OUTPUT
385 u32 previous_allocations
;
390 * Allow one execution to be performed by debugger or single step
391 * execution will be dead locked by the interpreter mutexes.
393 if (acpi_gbl_method_executing
) {
394 acpi_os_printf("Only one debugger execution is allowed.\n");
397 #ifdef ACPI_DEBUG_OUTPUT
398 /* Memory allocation tracking */
400 previous_allocations
= acpi_db_get_outstanding_allocations();
404 (void)acpi_walk_namespace(ACPI_TYPE_METHOD
, ACPI_ROOT_OBJECT
,
406 acpi_db_execution_walk
, NULL
, NULL
,
411 name_string
= ACPI_ALLOCATE(strlen(name
) + 1);
416 memset(&acpi_gbl_db_method_info
, 0, sizeof(struct acpi_db_method_info
));
417 strcpy(name_string
, name
);
418 acpi_ut_strupr(name_string
);
420 /* Subcommand to Execute all predefined names in the namespace */
422 if (!strncmp(name_string
, "PREDEF", 6)) {
423 acpi_db_evaluate_predefined_names();
424 ACPI_FREE(name_string
);
428 acpi_gbl_db_method_info
.name
= name_string
;
429 acpi_gbl_db_method_info
.args
= args
;
430 acpi_gbl_db_method_info
.types
= types
;
431 acpi_gbl_db_method_info
.flags
= flags
;
433 return_obj
.pointer
= NULL
;
434 return_obj
.length
= ACPI_ALLOCATE_BUFFER
;
436 status
= acpi_db_execute_setup(&acpi_gbl_db_method_info
);
437 if (ACPI_FAILURE(status
)) {
438 ACPI_FREE(name_string
);
442 /* Get the NS node, determines existence also */
444 status
= acpi_get_handle(NULL
, acpi_gbl_db_method_info
.pathname
,
445 &acpi_gbl_db_method_info
.method
);
446 if (ACPI_SUCCESS(status
)) {
447 status
= acpi_db_execute_method(&acpi_gbl_db_method_info
,
450 ACPI_FREE(name_string
);
453 * Allow any handlers in separate threads to complete.
454 * (Such as Notify handlers invoked from AML executed above).
456 acpi_os_sleep((u64
)10);
458 #ifdef ACPI_DEBUG_OUTPUT
460 /* Memory allocation tracking */
463 acpi_db_get_outstanding_allocations() - previous_allocations
;
465 acpi_db_set_output_destination(ACPI_DB_DUPLICATE_OUTPUT
);
467 if (allocations
> 0) {
469 ("0x%X Outstanding allocations after evaluation of %s\n",
470 allocations
, acpi_gbl_db_method_info
.pathname
);
474 if (ACPI_FAILURE(status
)) {
475 acpi_os_printf("Evaluation of %s failed with status %s\n",
476 acpi_gbl_db_method_info
.pathname
,
477 acpi_format_exception(status
));
479 /* Display a return object, if any */
481 if (return_obj
.length
) {
482 acpi_os_printf("Evaluation of %s returned object %p, "
483 "external buffer length %X\n",
484 acpi_gbl_db_method_info
.pathname
,
486 (u32
)return_obj
.length
);
488 acpi_db_dump_external_object(return_obj
.pointer
, 1);
490 /* Dump a _PLD buffer if present */
492 if (ACPI_COMPARE_NAME
494 (struct acpi_namespace_node
,
495 acpi_gbl_db_method_info
.method
)->name
.ascii
),
497 acpi_db_dump_pld_buffer(return_obj
.pointer
);
501 ("No object was returned from evaluation of %s\n",
502 acpi_gbl_db_method_info
.pathname
);
506 acpi_db_set_output_destination(ACPI_DB_CONSOLE_OUTPUT
);
509 /*******************************************************************************
511 * FUNCTION: acpi_db_method_thread
513 * PARAMETERS: context - Execution info segment
517 * DESCRIPTION: Debugger execute thread. Waits for a command line, then
518 * simply dispatches it.
520 ******************************************************************************/
522 static void ACPI_SYSTEM_XFACE
acpi_db_method_thread(void *context
)
525 struct acpi_db_method_info
*info
= context
;
526 struct acpi_db_method_info local_info
;
529 struct acpi_buffer return_obj
;
532 * acpi_gbl_db_method_info.Arguments will be passed as method arguments.
533 * Prevent acpi_gbl_db_method_info from being modified by multiple threads
536 * Note: The arguments we are passing are used by the ASL test suite
537 * (aslts). Do not change them without updating the tests.
539 (void)acpi_os_wait_semaphore(info
->info_gate
, 1, ACPI_WAIT_FOREVER
);
541 if (info
->init_args
) {
542 acpi_db_uint32_to_hex_string(info
->num_created
,
543 info
->index_of_thread_str
);
544 acpi_db_uint32_to_hex_string((u32
)acpi_os_get_thread_id(),
545 info
->id_of_thread_str
);
548 if (info
->threads
&& (info
->num_created
< info
->num_threads
)) {
549 info
->threads
[info
->num_created
++] = acpi_os_get_thread_id();
553 local_info
.args
= local_info
.arguments
;
554 local_info
.arguments
[0] = local_info
.num_threads_str
;
555 local_info
.arguments
[1] = local_info
.id_of_thread_str
;
556 local_info
.arguments
[2] = local_info
.index_of_thread_str
;
557 local_info
.arguments
[3] = NULL
;
559 local_info
.types
= local_info
.arg_types
;
561 (void)acpi_os_signal_semaphore(info
->info_gate
, 1);
563 for (i
= 0; i
< info
->num_loops
; i
++) {
564 status
= acpi_db_execute_method(&local_info
, &return_obj
);
565 if (ACPI_FAILURE(status
)) {
567 ("%s During evaluation of %s at iteration %X\n",
568 acpi_format_exception(status
), info
->pathname
, i
);
569 if (status
== AE_ABORT_METHOD
) {
574 if ((i
% 100) == 0) {
575 acpi_os_printf("%u loops, Thread 0x%x\n",
576 i
, acpi_os_get_thread_id());
579 if (return_obj
.length
) {
581 ("Evaluation of %s returned object %p Buflen %X\n",
582 info
->pathname
, return_obj
.pointer
,
583 (u32
)return_obj
.length
);
584 acpi_db_dump_external_object(return_obj
.pointer
, 1);
589 /* Signal our completion */
592 (void)acpi_os_wait_semaphore(info
->thread_complete_gate
,
593 1, ACPI_WAIT_FOREVER
);
594 info
->num_completed
++;
596 if (info
->num_completed
== info
->num_threads
) {
598 /* Do signal for main thread once only */
602 (void)acpi_os_signal_semaphore(info
->thread_complete_gate
, 1);
605 status
= acpi_os_signal_semaphore(info
->main_thread_gate
, 1);
606 if (ACPI_FAILURE(status
)) {
608 ("Could not signal debugger thread sync semaphore, %s\n",
609 acpi_format_exception(status
));
614 /*******************************************************************************
616 * FUNCTION: acpi_db_single_execution_thread
618 * PARAMETERS: context - Method info struct
622 * DESCRIPTION: Create one thread and execute a method
624 ******************************************************************************/
626 static void ACPI_SYSTEM_XFACE
acpi_db_single_execution_thread(void *context
)
628 struct acpi_db_method_info
*info
= context
;
630 struct acpi_buffer return_obj
;
632 acpi_os_printf("\n");
634 status
= acpi_db_execute_method(info
, &return_obj
);
635 if (ACPI_FAILURE(status
)) {
636 acpi_os_printf("%s During evaluation of %s\n",
637 acpi_format_exception(status
), info
->pathname
);
641 /* Display a return object, if any */
643 if (return_obj
.length
) {
644 acpi_os_printf("Evaluation of %s returned object %p, "
645 "external buffer length %X\n",
646 acpi_gbl_db_method_info
.pathname
,
647 return_obj
.pointer
, (u32
)return_obj
.length
);
649 acpi_db_dump_external_object(return_obj
.pointer
, 1);
652 acpi_os_printf("\nBackground thread completed\n%c ",
653 ACPI_DEBUGGER_COMMAND_PROMPT
);
656 /*******************************************************************************
658 * FUNCTION: acpi_db_create_execution_thread
660 * PARAMETERS: method_name_arg - Control method to execute
661 * arguments - Array of arguments to the method
662 * types - Corresponding array of object types
666 * DESCRIPTION: Create a single thread to evaluate a namespace object. Handles
667 * arguments passed on command line for control methods.
669 ******************************************************************************/
672 acpi_db_create_execution_thread(char *method_name_arg
,
673 char **arguments
, acpi_object_type
*types
)
678 memset(&acpi_gbl_db_method_info
, 0, sizeof(struct acpi_db_method_info
));
679 acpi_gbl_db_method_info
.name
= method_name_arg
;
680 acpi_gbl_db_method_info
.init_args
= 1;
681 acpi_gbl_db_method_info
.args
= acpi_gbl_db_method_info
.arguments
;
682 acpi_gbl_db_method_info
.types
= acpi_gbl_db_method_info
.arg_types
;
684 /* Setup method arguments, up to 7 (0-6) */
686 for (i
= 0; (i
< ACPI_METHOD_NUM_ARGS
) && *arguments
; i
++) {
687 acpi_gbl_db_method_info
.arguments
[i
] = *arguments
;
690 acpi_gbl_db_method_info
.arg_types
[i
] = *types
;
694 status
= acpi_db_execute_setup(&acpi_gbl_db_method_info
);
695 if (ACPI_FAILURE(status
)) {
699 /* Get the NS node, determines existence also */
701 status
= acpi_get_handle(NULL
, acpi_gbl_db_method_info
.pathname
,
702 &acpi_gbl_db_method_info
.method
);
703 if (ACPI_FAILURE(status
)) {
704 acpi_os_printf("%s Could not get handle for %s\n",
705 acpi_format_exception(status
),
706 acpi_gbl_db_method_info
.pathname
);
710 status
= acpi_os_execute(OSL_DEBUGGER_EXEC_THREAD
,
711 acpi_db_single_execution_thread
,
712 &acpi_gbl_db_method_info
);
713 if (ACPI_FAILURE(status
)) {
717 acpi_os_printf("\nBackground thread started\n");
720 /*******************************************************************************
722 * FUNCTION: acpi_db_create_execution_threads
724 * PARAMETERS: num_threads_arg - Number of threads to create
725 * num_loops_arg - Loop count for the thread(s)
726 * method_name_arg - Control method to execute
730 * DESCRIPTION: Create threads to execute method(s)
732 ******************************************************************************/
735 acpi_db_create_execution_threads(char *num_threads_arg
,
736 char *num_loops_arg
, char *method_name_arg
)
743 acpi_mutex main_thread_gate
;
744 acpi_mutex thread_complete_gate
;
745 acpi_mutex info_gate
;
747 /* Get the arguments */
749 num_threads
= strtoul(num_threads_arg
, NULL
, 0);
750 num_loops
= strtoul(num_loops_arg
, NULL
, 0);
752 if (!num_threads
|| !num_loops
) {
753 acpi_os_printf("Bad argument: Threads %X, Loops %X\n",
754 num_threads
, num_loops
);
759 * Create the semaphore for synchronization of
760 * the created threads with the main thread.
762 status
= acpi_os_create_semaphore(1, 0, &main_thread_gate
);
763 if (ACPI_FAILURE(status
)) {
764 acpi_os_printf("Could not create semaphore for "
765 "synchronization with the main thread, %s\n",
766 acpi_format_exception(status
));
771 * Create the semaphore for synchronization
772 * between the created threads.
774 status
= acpi_os_create_semaphore(1, 1, &thread_complete_gate
);
775 if (ACPI_FAILURE(status
)) {
776 acpi_os_printf("Could not create semaphore for "
777 "synchronization between the created threads, %s\n",
778 acpi_format_exception(status
));
780 (void)acpi_os_delete_semaphore(main_thread_gate
);
784 status
= acpi_os_create_semaphore(1, 1, &info_gate
);
785 if (ACPI_FAILURE(status
)) {
786 acpi_os_printf("Could not create semaphore for "
787 "synchronization of AcpiGbl_DbMethodInfo, %s\n",
788 acpi_format_exception(status
));
790 (void)acpi_os_delete_semaphore(thread_complete_gate
);
791 (void)acpi_os_delete_semaphore(main_thread_gate
);
795 memset(&acpi_gbl_db_method_info
, 0, sizeof(struct acpi_db_method_info
));
797 /* Array to store IDs of threads */
799 acpi_gbl_db_method_info
.num_threads
= num_threads
;
800 size
= sizeof(acpi_thread_id
) * acpi_gbl_db_method_info
.num_threads
;
802 acpi_gbl_db_method_info
.threads
= acpi_os_allocate(size
);
803 if (acpi_gbl_db_method_info
.threads
== NULL
) {
804 acpi_os_printf("No memory for thread IDs array\n");
805 (void)acpi_os_delete_semaphore(main_thread_gate
);
806 (void)acpi_os_delete_semaphore(thread_complete_gate
);
807 (void)acpi_os_delete_semaphore(info_gate
);
810 memset(acpi_gbl_db_method_info
.threads
, 0, size
);
812 /* Setup the context to be passed to each thread */
814 acpi_gbl_db_method_info
.name
= method_name_arg
;
815 acpi_gbl_db_method_info
.flags
= 0;
816 acpi_gbl_db_method_info
.num_loops
= num_loops
;
817 acpi_gbl_db_method_info
.main_thread_gate
= main_thread_gate
;
818 acpi_gbl_db_method_info
.thread_complete_gate
= thread_complete_gate
;
819 acpi_gbl_db_method_info
.info_gate
= info_gate
;
821 /* Init arguments to be passed to method */
823 acpi_gbl_db_method_info
.init_args
= 1;
824 acpi_gbl_db_method_info
.args
= acpi_gbl_db_method_info
.arguments
;
825 acpi_gbl_db_method_info
.arguments
[0] =
826 acpi_gbl_db_method_info
.num_threads_str
;
827 acpi_gbl_db_method_info
.arguments
[1] =
828 acpi_gbl_db_method_info
.id_of_thread_str
;
829 acpi_gbl_db_method_info
.arguments
[2] =
830 acpi_gbl_db_method_info
.index_of_thread_str
;
831 acpi_gbl_db_method_info
.arguments
[3] = NULL
;
833 acpi_gbl_db_method_info
.types
= acpi_gbl_db_method_info
.arg_types
;
834 acpi_gbl_db_method_info
.arg_types
[0] = ACPI_TYPE_INTEGER
;
835 acpi_gbl_db_method_info
.arg_types
[1] = ACPI_TYPE_INTEGER
;
836 acpi_gbl_db_method_info
.arg_types
[2] = ACPI_TYPE_INTEGER
;
838 acpi_db_uint32_to_hex_string(num_threads
,
839 acpi_gbl_db_method_info
.num_threads_str
);
841 status
= acpi_db_execute_setup(&acpi_gbl_db_method_info
);
842 if (ACPI_FAILURE(status
)) {
843 goto cleanup_and_exit
;
846 /* Get the NS node, determines existence also */
848 status
= acpi_get_handle(NULL
, acpi_gbl_db_method_info
.pathname
,
849 &acpi_gbl_db_method_info
.method
);
850 if (ACPI_FAILURE(status
)) {
851 acpi_os_printf("%s Could not get handle for %s\n",
852 acpi_format_exception(status
),
853 acpi_gbl_db_method_info
.pathname
);
854 goto cleanup_and_exit
;
857 /* Create the threads */
859 acpi_os_printf("Creating %X threads to execute %X times each\n",
860 num_threads
, num_loops
);
862 for (i
= 0; i
< (num_threads
); i
++) {
864 acpi_os_execute(OSL_DEBUGGER_EXEC_THREAD
,
865 acpi_db_method_thread
,
866 &acpi_gbl_db_method_info
);
867 if (ACPI_FAILURE(status
)) {
872 /* Wait for all threads to complete */
874 (void)acpi_os_wait_semaphore(main_thread_gate
, 1, ACPI_WAIT_FOREVER
);
876 acpi_db_set_output_destination(ACPI_DB_DUPLICATE_OUTPUT
);
877 acpi_os_printf("All threads (%X) have completed\n", num_threads
);
878 acpi_db_set_output_destination(ACPI_DB_CONSOLE_OUTPUT
);
882 /* Cleanup and exit */
884 (void)acpi_os_delete_semaphore(main_thread_gate
);
885 (void)acpi_os_delete_semaphore(thread_complete_gate
);
886 (void)acpi_os_delete_semaphore(info_gate
);
888 acpi_os_free(acpi_gbl_db_method_info
.threads
);
889 acpi_gbl_db_method_info
.threads
= NULL
;