Commit 060c859d authored by Bob Moore's avatar Bob Moore Committed by Rafael J. Wysocki

ACPICA: Debugger: add "background" command for method execution

ACPICA commit d7b44738a48caa9f669b8dbf0024d456711aec31

Allows a single task to execute in the background, while control
returns to the debugger prompt.

Also, cleanup the debugger help screen.

Link: https://github.com/acpica/acpica/commit/d7b44738Signed-off-by: default avatarBob Moore <robert.moore@intel.com>
Signed-off-by: default avatarErik Schmauss <erik.schmauss@intel.com>
Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
parent d41bf52e
...@@ -222,6 +222,10 @@ ACPI_DBR_DEPENDENT_RETURN_VOID(void ...@@ -222,6 +222,10 @@ ACPI_DBR_DEPENDENT_RETURN_VOID(void
void void
acpi_db_execute(char *name, char **args, acpi_object_type *types, u32 flags); acpi_db_execute(char *name, char **args, acpi_object_type *types, u32 flags);
void
acpi_db_create_execution_thread(char *method_name_arg,
char **arguments, acpi_object_type *types);
void void
acpi_db_create_execution_threads(char *num_threads_arg, acpi_db_create_execution_threads(char *num_threads_arg,
char *num_loops_arg, char *method_name_arg); char *num_loops_arg, char *method_name_arg);
......
...@@ -1218,16 +1218,17 @@ struct acpi_db_method_info { ...@@ -1218,16 +1218,17 @@ struct acpi_db_method_info {
acpi_object_type *types; acpi_object_type *types;
/* /*
* Arguments to be passed to method for the command * Arguments to be passed to method for the commands Threads and
* Threads - * Background. Note, ACPI specifies a maximum of 7 arguments (0 - 6).
* the Number of threads, ID of current thread and *
* Index of current thread inside all them created. * For the Threads command, the Number of threads, ID of current
* thread and Index of current thread inside all them created.
*/ */
char init_args; char init_args;
#ifdef ACPI_DEBUGGER #ifdef ACPI_DEBUGGER
acpi_object_type arg_types[4]; acpi_object_type arg_types[ACPI_METHOD_NUM_ARGS];
#endif #endif
char *arguments[4]; char *arguments[ACPI_METHOD_NUM_ARGS];
char num_threads_str[11]; char num_threads_str[11];
char id_of_thread_str[11]; char id_of_thread_str[11];
char index_of_thread_str[11]; char index_of_thread_str[11];
......
...@@ -67,6 +67,8 @@ static acpi_status ...@@ -67,6 +67,8 @@ static acpi_status
acpi_db_execution_walk(acpi_handle obj_handle, acpi_db_execution_walk(acpi_handle obj_handle,
u32 nesting_level, void *context, void **return_value); u32 nesting_level, void *context, void **return_value);
static void ACPI_SYSTEM_XFACE acpi_db_single_execution_thread(void *context);
/******************************************************************************* /*******************************************************************************
* *
* FUNCTION: acpi_db_delete_objects * FUNCTION: acpi_db_delete_objects
...@@ -229,7 +231,7 @@ static acpi_status acpi_db_execute_setup(struct acpi_db_method_info *info) ...@@ -229,7 +231,7 @@ static acpi_status acpi_db_execute_setup(struct acpi_db_method_info *info)
ACPI_FUNCTION_NAME(db_execute_setup); ACPI_FUNCTION_NAME(db_execute_setup);
/* Catenate the current scope to the supplied name */ /* Concatenate the current scope to the supplied name */
info->pathname[0] = 0; info->pathname[0] = 0;
if ((info->name[0] != '\\') && (info->name[0] != '/')) { if ((info->name[0] != '\\') && (info->name[0] != '/')) {
...@@ -609,6 +611,112 @@ static void ACPI_SYSTEM_XFACE acpi_db_method_thread(void *context) ...@@ -609,6 +611,112 @@ static void ACPI_SYSTEM_XFACE acpi_db_method_thread(void *context)
} }
} }
/*******************************************************************************
*
* FUNCTION: acpi_db_single_execution_thread
*
* PARAMETERS: context - Method info struct
*
* RETURN: None
*
* DESCRIPTION: Create one thread and execute a method
*
******************************************************************************/
static void ACPI_SYSTEM_XFACE acpi_db_single_execution_thread(void *context)
{
struct acpi_db_method_info *info = context;
acpi_status status;
struct acpi_buffer return_obj;
acpi_os_printf("\n");
status = acpi_db_execute_method(info, &return_obj);
if (ACPI_FAILURE(status)) {
acpi_os_printf("%s During evaluation of %s\n",
acpi_format_exception(status), info->pathname);
return;
}
/* Display a return object, if any */
if (return_obj.length) {
acpi_os_printf("Evaluation of %s returned object %p, "
"external buffer length %X\n",
acpi_gbl_db_method_info.pathname,
return_obj.pointer, (u32)return_obj.length);
acpi_db_dump_external_object(return_obj.pointer, 1);
}
acpi_os_printf("\nBackground thread completed\n%c ",
ACPI_DEBUGGER_COMMAND_PROMPT);
}
/*******************************************************************************
*
* FUNCTION: acpi_db_create_execution_thread
*
* PARAMETERS: method_name_arg - Control method to execute
* arguments - Array of arguments to the method
* types - Corresponding array of object types
*
* RETURN: None
*
* DESCRIPTION: Create a single thread to evaluate a namespace object. Handles
* arguments passed on command line for control methods.
*
******************************************************************************/
void
acpi_db_create_execution_thread(char *method_name_arg,
char **arguments, acpi_object_type *types)
{
acpi_status status;
u32 i;
memset(&acpi_gbl_db_method_info, 0, sizeof(struct acpi_db_method_info));
acpi_gbl_db_method_info.name = method_name_arg;
acpi_gbl_db_method_info.init_args = 1;
acpi_gbl_db_method_info.args = acpi_gbl_db_method_info.arguments;
acpi_gbl_db_method_info.types = acpi_gbl_db_method_info.arg_types;
/* Setup method arguments, up to 7 (0-6) */
for (i = 0; (i < ACPI_METHOD_NUM_ARGS) && *arguments; i++) {
acpi_gbl_db_method_info.arguments[i] = *arguments;
arguments++;
acpi_gbl_db_method_info.arg_types[i] = *types;
types++;
}
status = acpi_db_execute_setup(&acpi_gbl_db_method_info);
if (ACPI_FAILURE(status)) {
return;
}
/* Get the NS node, determines existence also */
status = acpi_get_handle(NULL, acpi_gbl_db_method_info.pathname,
&acpi_gbl_db_method_info.method);
if (ACPI_FAILURE(status)) {
acpi_os_printf("%s Could not get handle for %s\n",
acpi_format_exception(status),
acpi_gbl_db_method_info.pathname);
return;
}
status = acpi_os_execute(OSL_DEBUGGER_EXEC_THREAD,
acpi_db_single_execution_thread,
&acpi_gbl_db_method_info);
if (ACPI_FAILURE(status)) {
return;
}
acpi_os_printf("\nBackground thread started\n");
}
/******************************************************************************* /*******************************************************************************
* *
* FUNCTION: acpi_db_create_execution_threads * FUNCTION: acpi_db_create_execution_threads
......
...@@ -136,6 +136,7 @@ enum acpi_ex_debugger_commands { ...@@ -136,6 +136,7 @@ enum acpi_ex_debugger_commands {
CMD_UNLOAD, CMD_UNLOAD,
CMD_TERMINATE, CMD_TERMINATE,
CMD_BACKGROUND,
CMD_THREADS, CMD_THREADS,
CMD_TEST, CMD_TEST,
...@@ -212,6 +213,7 @@ static const struct acpi_db_command_info acpi_gbl_db_commands[] = { ...@@ -212,6 +213,7 @@ static const struct acpi_db_command_info acpi_gbl_db_commands[] = {
{"UNLOAD", 1}, {"UNLOAD", 1},
{"TERMINATE", 0}, {"TERMINATE", 0},
{"BACKGROUND", 1},
{"THREADS", 3}, {"THREADS", 3},
{"TEST", 1}, {"TEST", 1},
...@@ -222,9 +224,56 @@ static const struct acpi_db_command_info acpi_gbl_db_commands[] = { ...@@ -222,9 +224,56 @@ static const struct acpi_db_command_info acpi_gbl_db_commands[] = {
/* /*
* Help for all debugger commands. First argument is the number of lines * Help for all debugger commands. First argument is the number of lines
* of help to output for the command. * of help to output for the command.
*
* Note: Some commands are not supported by the kernel-level version of
* the debugger.
*/ */
static const struct acpi_db_command_help acpi_gbl_db_command_help[] = { static const struct acpi_db_command_help acpi_gbl_db_command_help[] = {
{0, "\nGeneral-Purpose Commands:", "\n"}, {0, "\nNamespace Access:", "\n"},
{1, " Businfo", "Display system bus info\n"},
{1, " Disassemble <Method>", "Disassemble a control method\n"},
{1, " Find <AcpiName> (? is wildcard)",
"Find ACPI name(s) with wildcards\n"},
{1, " Integrity", "Validate namespace integrity\n"},
{1, " Methods", "Display list of loaded control methods\n"},
{1, " Namespace [Object] [Depth]",
"Display loaded namespace tree/subtree\n"},
{1, " Notify <Object> <Value>", "Send a notification on Object\n"},
{1, " Objects [ObjectType]",
"Display summary of all objects or just given type\n"},
{1, " Owner <OwnerId> [Depth]",
"Display loaded namespace by object owner\n"},
{1, " Paths", "Display full pathnames of namespace objects\n"},
{1, " Predefined", "Check all predefined names\n"},
{1, " Prefix [<Namepath>]", "Set or Get current execution prefix\n"},
{1, " References <Addr>", "Find all references to object at addr\n"},
{1, " Resources [DeviceName]",
"Display Device resources (no arg = all devices)\n"},
{1, " Set N <NamedObject> <Value>", "Set value for named integer\n"},
{1, " Template <Object>", "Format/dump a Buffer/ResourceTemplate\n"},
{1, " Type <Object>", "Display object type\n"},
{0, "\nControl Method Execution:", "\n"},
{1, " Evaluate <Namepath> [Arguments]",
"Evaluate object or control method\n"},
{1, " Execute <Namepath> [Arguments]", "Synonym for Evaluate\n"},
#ifdef ACPI_APPLICATION
{1, " Background <Namepath> [Arguments]",
"Evaluate object/method in a separate thread\n"},
{1, " Thread <Threads><Loops><NamePath>",
"Spawn threads to execute method(s)\n"},
#endif
{1, " Debug <Namepath> [Arguments]", "Single-Step a control method\n"},
{7, " [Arguments] formats:", "Control method argument formats\n"},
{1, " Hex Integer", "Integer\n"},
{1, " \"Ascii String\"", "String\n"},
{1, " (Hex Byte List)", "Buffer\n"},
{1, " (01 42 7A BF)", "Buffer example (4 bytes)\n"},
{1, " [Package Element List]", "Package\n"},
{1, " [0x01 0x1234 \"string\"]",
"Package example (3 elements)\n"},
{0, "\nMiscellaneous:", "\n"},
{1, " Allocations", "Display list of current memory allocations\n"}, {1, " Allocations", "Display list of current memory allocations\n"},
{2, " Dump <Address>|<Namepath>", "\n"}, {2, " Dump <Address>|<Namepath>", "\n"},
{0, " [Byte|Word|Dword|Qword]", {0, " [Byte|Word|Dword|Qword]",
...@@ -248,46 +297,30 @@ static const struct acpi_db_command_help acpi_gbl_db_command_help[] = { ...@@ -248,46 +297,30 @@ static const struct acpi_db_command_help acpi_gbl_db_command_help[] = {
{1, " Stack", "Display CPU stack usage\n"}, {1, " Stack", "Display CPU stack usage\n"},
{1, " Tables", "Info about current ACPI table(s)\n"}, {1, " Tables", "Info about current ACPI table(s)\n"},
{1, " Tables", "Display info about loaded ACPI tables\n"}, {1, " Tables", "Display info about loaded ACPI tables\n"},
#ifdef ACPI_APPLICATION
{1, " Terminate", "Delete namespace and all internal objects\n"},
#endif
{1, " ! <CommandNumber>", "Execute command from history buffer\n"}, {1, " ! <CommandNumber>", "Execute command from history buffer\n"},
{1, " !!", "Execute last command again\n"}, {1, " !!", "Execute last command again\n"},
{0, "\nNamespace Access Commands:", "\n"}, {0, "\nMethod and Namespace Debugging:", "\n"},
{1, " Businfo", "Display system bus info\n"}, {5, " Trace <State> [<Namepath>] [Once]",
{1, " Disassemble <Method>", "Disassemble a control method\n"}, "Trace control method execution\n"},
{1, " Find <AcpiName> (? is wildcard)", {1, " Enable", "Enable all messages\n"},
"Find ACPI name(s) with wildcards\n"}, {1, " Disable", "Disable tracing\n"},
{1, " Integrity", "Validate namespace integrity\n"}, {1, " Method", "Enable method execution messages\n"},
{1, " Methods", "Display list of loaded control methods\n"}, {1, " Opcode", "Enable opcode execution messages\n"},
{1, " Namespace [Object] [Depth]", {3, " Test <TestName>", "Invoke a debug test\n"},
"Display loaded namespace tree/subtree\n"}, {1, " Objects", "Read/write/compare all namespace data objects\n"},
{1, " Notify <Object> <Value>", "Send a notification on Object\n"}, {1, " Predefined",
{1, " Objects [ObjectType]", "Validate all ACPI predefined names (_STA, etc.)\n"},
"Display summary of all objects or just given type\n"}, {1, " Execute predefined",
{1, " Owner <OwnerId> [Depth]", "Execute all predefined (public) methods\n"},
"Display loaded namespace by object owner\n"},
{1, " Paths", "Display full pathnames of namespace objects\n"},
{1, " Predefined", "Check all predefined names\n"},
{1, " Prefix [<Namepath>]", "Set or Get current execution prefix\n"},
{1, " References <Addr>", "Find all references to object at addr\n"},
{1, " Resources [DeviceName]",
"Display Device resources (no arg = all devices)\n"},
{1, " Set N <NamedObject> <Value>", "Set value for named integer\n"},
{1, " Template <Object>", "Format/dump a Buffer/ResourceTemplate\n"},
{1, " Type <Object>", "Display object type\n"},
{0, "\nControl Method Execution Commands:", "\n"}, {0, "\nControl Method Single-Step Execution:", "\n"},
{1, " Arguments (or Args)", "Display method arguments\n"}, {1, " Arguments (or Args)", "Display method arguments\n"},
{1, " Breakpoint <AmlOffset>", "Set an AML execution breakpoint\n"}, {1, " Breakpoint <AmlOffset>", "Set an AML execution breakpoint\n"},
{1, " Call", "Run to next control method invocation\n"}, {1, " Call", "Run to next control method invocation\n"},
{1, " Debug <Namepath> [Arguments]", "Single Step a control method\n"},
{6, " Evaluate", "Synonym for Execute\n"},
{5, " Execute <Namepath> [Arguments]", "Execute control method\n"},
{1, " Hex Integer", "Integer method argument\n"},
{1, " \"Ascii String\"", "String method argument\n"},
{1, " (Hex Byte List)", "Buffer method argument\n"},
{1, " [Package Element List]", "Package method argument\n"},
{5, " Execute predefined",
"Execute all predefined (public) methods\n"},
{1, " Go", "Allow method to run to completion\n"}, {1, " Go", "Allow method to run to completion\n"},
{1, " Information", "Display info about the current method\n"}, {1, " Information", "Display info about the current method\n"},
{1, " Into", "Step into (not over) a method call\n"}, {1, " Into", "Step into (not over) a method call\n"},
...@@ -296,41 +329,24 @@ static const struct acpi_db_command_help acpi_gbl_db_command_help[] = { ...@@ -296,41 +329,24 @@ static const struct acpi_db_command_help acpi_gbl_db_command_help[] = {
{1, " Results", "Display method result stack\n"}, {1, " Results", "Display method result stack\n"},
{1, " Set <A|L> <#> <Value>", "Set method data (Arguments/Locals)\n"}, {1, " Set <A|L> <#> <Value>", "Set method data (Arguments/Locals)\n"},
{1, " Stop", "Terminate control method\n"}, {1, " Stop", "Terminate control method\n"},
{5, " Trace <State> [<Namepath>] [Once]",
"Trace control method execution\n"},
{1, " Enable", "Enable all messages\n"},
{1, " Disable", "Disable tracing\n"},
{1, " Method", "Enable method execution messages\n"},
{1, " Opcode", "Enable opcode execution messages\n"},
{1, " Tree", "Display control method calling tree\n"}, {1, " Tree", "Display control method calling tree\n"},
{1, " <Enter>", "Single step next AML opcode (over calls)\n"}, {1, " <Enter>", "Single step next AML opcode (over calls)\n"},
#ifdef ACPI_APPLICATION #ifdef ACPI_APPLICATION
{0, "\nHardware Simulation Commands:", "\n"}, {0, "\nFile Operations:", "\n"},
{1, " EnableAcpi", "Enable ACPI (hardware) mode\n"},
{1, " Event <F|G> <Value>", "Generate AcpiEvent (Fixed/GPE)\n"},
{1, " Gpe <GpeNum> [GpeBlockDevice]", "Simulate a GPE\n"},
{1, " Gpes", "Display info on all GPE devices\n"},
{1, " Sci", "Generate an SCI\n"},
{1, " Sleep [SleepState]", "Simulate sleep/wake sequence(s) (0-5)\n"},
{0, "\nFile I/O Commands:", "\n"},
{1, " Close", "Close debug output file\n"}, {1, " Close", "Close debug output file\n"},
{1, " Load <Input Filename>", "Load ACPI table from a file\n"}, {1, " Load <Input Filename>", "Load ACPI table from a file\n"},
{1, " Open <Output Filename>", "Open a file for debug output\n"}, {1, " Open <Output Filename>", "Open a file for debug output\n"},
{1, " Unload <Namepath>", {1, " Unload <Namepath>",
"Unload an ACPI table via namespace object\n"}, "Unload an ACPI table via namespace object\n"},
{0, "\nUser Space Commands:", "\n"}, {0, "\nHardware Simulation:", "\n"},
{1, " Terminate", "Delete namespace and all internal objects\n"}, {1, " EnableAcpi", "Enable ACPI (hardware) mode\n"},
{1, " Thread <Threads><Loops><NamePath>", {1, " Event <F|G> <Value>", "Generate AcpiEvent (Fixed/GPE)\n"},
"Spawn threads to execute method(s)\n"}, {1, " Gpe <GpeNum> [GpeBlockDevice]", "Simulate a GPE\n"},
{1, " Gpes", "Display info on all GPE devices\n"},
{0, "\nDebug Test Commands:", "\n"}, {1, " Sci", "Generate an SCI\n"},
{3, " Test <TestName>", "Invoke a debug test\n"}, {1, " Sleep [SleepState]", "Simulate sleep/wake sequence(s) (0-5)\n"},
{1, " Objects", "Read/write/compare all namespace data objects\n"},
{1, " Predefined",
"Execute all ACPI predefined names (_STA, etc.)\n"},
#endif #endif
{0, NULL, NULL} {0, NULL, NULL}
}; };
...@@ -442,11 +458,15 @@ static void acpi_db_display_help(char *command) ...@@ -442,11 +458,15 @@ static void acpi_db_display_help(char *command)
/* No argument to help, display help for all commands */ /* No argument to help, display help for all commands */
acpi_os_printf("\nSummary of AML Debugger Commands\n\n");
while (next->invocation) { while (next->invocation) {
acpi_os_printf("%-38s%s", next->invocation, acpi_os_printf("%-38s%s", next->invocation,
next->description); next->description);
next++; next++;
} }
acpi_os_printf("\n");
} else { } else {
/* Display help for all commands that match the subtring */ /* Display help for all commands that match the subtring */
...@@ -1087,6 +1107,13 @@ acpi_db_command_dispatch(char *input_buffer, ...@@ -1087,6 +1107,13 @@ acpi_db_command_dispatch(char *input_buffer,
/* acpi_initialize (NULL); */ /* acpi_initialize (NULL); */
break; break;
case CMD_BACKGROUND:
acpi_db_create_execution_thread(acpi_gbl_db_args[1],
&acpi_gbl_db_args[2],
&acpi_gbl_db_arg_types[2]);
break;
case CMD_THREADS: case CMD_THREADS:
acpi_db_create_execution_threads(acpi_gbl_db_args[1], acpi_db_create_execution_threads(acpi_gbl_db_args[1],
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment