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/d7b44738 Signed-off-by: Bob Moore <robert.moore@intel.com> Signed-off-by: Erik Schmauss <erik.schmauss@intel.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
This commit is contained in:
parent
d41bf52e38
commit
060c859d79
@ -222,6 +222,10 @@ ACPI_DBR_DEPENDENT_RETURN_VOID(void
|
||||
void
|
||||
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
|
||||
acpi_db_create_execution_threads(char *num_threads_arg,
|
||||
char *num_loops_arg, char *method_name_arg);
|
||||
|
@ -1218,16 +1218,17 @@ struct acpi_db_method_info {
|
||||
acpi_object_type *types;
|
||||
|
||||
/*
|
||||
* Arguments to be passed to method for the command
|
||||
* Threads -
|
||||
* the Number of threads, ID of current thread and
|
||||
* Index of current thread inside all them created.
|
||||
* Arguments to be passed to method for the commands Threads and
|
||||
* Background. Note, ACPI specifies a maximum of 7 arguments (0 - 6).
|
||||
*
|
||||
* For the Threads command, the Number of threads, ID of current
|
||||
* thread and Index of current thread inside all them created.
|
||||
*/
|
||||
char init_args;
|
||||
#ifdef ACPI_DEBUGGER
|
||||
acpi_object_type arg_types[4];
|
||||
acpi_object_type arg_types[ACPI_METHOD_NUM_ARGS];
|
||||
#endif
|
||||
char *arguments[4];
|
||||
char *arguments[ACPI_METHOD_NUM_ARGS];
|
||||
char num_threads_str[11];
|
||||
char id_of_thread_str[11];
|
||||
char index_of_thread_str[11];
|
||||
|
@ -67,6 +67,8 @@ static acpi_status
|
||||
acpi_db_execution_walk(acpi_handle obj_handle,
|
||||
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
|
||||
@ -229,7 +231,7 @@ static acpi_status acpi_db_execute_setup(struct acpi_db_method_info *info)
|
||||
|
||||
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;
|
||||
if ((info->name[0] != '\\') && (info->name[0] != '/')) {
|
||||
@ -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
|
||||
|
@ -136,6 +136,7 @@ enum acpi_ex_debugger_commands {
|
||||
CMD_UNLOAD,
|
||||
|
||||
CMD_TERMINATE,
|
||||
CMD_BACKGROUND,
|
||||
CMD_THREADS,
|
||||
|
||||
CMD_TEST,
|
||||
@ -212,6 +213,7 @@ static const struct acpi_db_command_info acpi_gbl_db_commands[] = {
|
||||
{"UNLOAD", 1},
|
||||
|
||||
{"TERMINATE", 0},
|
||||
{"BACKGROUND", 1},
|
||||
{"THREADS", 3},
|
||||
|
||||
{"TEST", 1},
|
||||
@ -222,36 +224,12 @@ static const struct acpi_db_command_info acpi_gbl_db_commands[] = {
|
||||
/*
|
||||
* Help for all debugger commands. First argument is the number of lines
|
||||
* 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[] = {
|
||||
{0, "\nGeneral-Purpose Commands:", "\n"},
|
||||
{1, " Allocations", "Display list of current memory allocations\n"},
|
||||
{2, " Dump <Address>|<Namepath>", "\n"},
|
||||
{0, " [Byte|Word|Dword|Qword]",
|
||||
"Display ACPI objects or memory\n"},
|
||||
{1, " Handlers", "Info about global handlers\n"},
|
||||
{1, " Help [Command]", "This help screen or individual command\n"},
|
||||
{1, " History", "Display command history buffer\n"},
|
||||
{1, " Level <DebugLevel>] [console]",
|
||||
"Get/Set debug level for file or console\n"},
|
||||
{1, " Locks", "Current status of internal mutexes\n"},
|
||||
{1, " Osi [Install|Remove <name>]",
|
||||
"Display or modify global _OSI list\n"},
|
||||
{1, " Quit or Exit", "Exit this command\n"},
|
||||
{8, " Stats <SubCommand>",
|
||||
"Display namespace and memory statistics\n"},
|
||||
{1, " Allocations", "Display list of current memory allocations\n"},
|
||||
{1, " Memory", "Dump internal memory lists\n"},
|
||||
{1, " Misc", "Namespace search and mutex stats\n"},
|
||||
{1, " Objects", "Summary of namespace objects\n"},
|
||||
{1, " Sizes", "Sizes for each of the internal objects\n"},
|
||||
{1, " Stack", "Display CPU stack usage\n"},
|
||||
{1, " Tables", "Info about current ACPI table(s)\n"},
|
||||
{1, " Tables", "Display info about loaded ACPI tables\n"},
|
||||
{1, " ! <CommandNumber>", "Execute command from history buffer\n"},
|
||||
{1, " !!", "Execute last command again\n"},
|
||||
|
||||
{0, "\nNamespace Access 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)",
|
||||
@ -275,19 +253,74 @@ static const struct acpi_db_command_help acpi_gbl_db_command_help[] = {
|
||||
{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 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"},
|
||||
{2, " Dump <Address>|<Namepath>", "\n"},
|
||||
{0, " [Byte|Word|Dword|Qword]",
|
||||
"Display ACPI objects or memory\n"},
|
||||
{1, " Handlers", "Info about global handlers\n"},
|
||||
{1, " Help [Command]", "This help screen or individual command\n"},
|
||||
{1, " History", "Display command history buffer\n"},
|
||||
{1, " Level <DebugLevel>] [console]",
|
||||
"Get/Set debug level for file or console\n"},
|
||||
{1, " Locks", "Current status of internal mutexes\n"},
|
||||
{1, " Osi [Install|Remove <name>]",
|
||||
"Display or modify global _OSI list\n"},
|
||||
{1, " Quit or Exit", "Exit this command\n"},
|
||||
{8, " Stats <SubCommand>",
|
||||
"Display namespace and memory statistics\n"},
|
||||
{1, " Allocations", "Display list of current memory allocations\n"},
|
||||
{1, " Memory", "Dump internal memory lists\n"},
|
||||
{1, " Misc", "Namespace search and mutex stats\n"},
|
||||
{1, " Objects", "Summary of namespace objects\n"},
|
||||
{1, " Sizes", "Sizes for each of the internal objects\n"},
|
||||
{1, " Stack", "Display CPU stack usage\n"},
|
||||
{1, " Tables", "Info about current ACPI table(s)\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, " !!", "Execute last command again\n"},
|
||||
|
||||
{0, "\nMethod and Namespace Debugging:", "\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"},
|
||||
{3, " Test <TestName>", "Invoke a debug test\n"},
|
||||
{1, " Objects", "Read/write/compare all namespace data objects\n"},
|
||||
{1, " Predefined",
|
||||
"Validate all ACPI predefined names (_STA, etc.)\n"},
|
||||
{1, " Execute predefined",
|
||||
"Execute all predefined (public) methods\n"},
|
||||
|
||||
{0, "\nControl Method Single-Step Execution:", "\n"},
|
||||
{1, " Arguments (or Args)", "Display method arguments\n"},
|
||||
{1, " Breakpoint <AmlOffset>", "Set an AML execution breakpoint\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, " Information", "Display info about the current method\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[] = {
|
||||
{1, " Results", "Display method result stack\n"},
|
||||
{1, " Set <A|L> <#> <Value>", "Set method data (Arguments/Locals)\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, " <Enter>", "Single step next AML opcode (over calls)\n"},
|
||||
|
||||
#ifdef ACPI_APPLICATION
|
||||
{0, "\nHardware Simulation Commands:", "\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"},
|
||||
{0, "\nFile Operations:", "\n"},
|
||||
{1, " Close", "Close debug output 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, " Unload <Namepath>",
|
||||
"Unload an ACPI table via namespace object\n"},
|
||||
|
||||
{0, "\nUser Space Commands:", "\n"},
|
||||
{1, " Terminate", "Delete namespace and all internal objects\n"},
|
||||
{1, " Thread <Threads><Loops><NamePath>",
|
||||
"Spawn threads to execute method(s)\n"},
|
||||
|
||||
{0, "\nDebug Test Commands:", "\n"},
|
||||
{3, " Test <TestName>", "Invoke a debug test\n"},
|
||||
{1, " Objects", "Read/write/compare all namespace data objects\n"},
|
||||
{1, " Predefined",
|
||||
"Execute all ACPI predefined names (_STA, etc.)\n"},
|
||||
{0, "\nHardware Simulation:", "\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"},
|
||||
#endif
|
||||
{0, NULL, NULL}
|
||||
};
|
||||
@ -442,11 +458,15 @@ static void acpi_db_display_help(char *command)
|
||||
|
||||
/* No argument to help, display help for all commands */
|
||||
|
||||
acpi_os_printf("\nSummary of AML Debugger Commands\n\n");
|
||||
|
||||
while (next->invocation) {
|
||||
acpi_os_printf("%-38s%s", next->invocation,
|
||||
next->description);
|
||||
next++;
|
||||
}
|
||||
acpi_os_printf("\n");
|
||||
|
||||
} else {
|
||||
/* Display help for all commands that match the subtring */
|
||||
|
||||
@ -1087,6 +1107,13 @@ acpi_db_command_dispatch(char *input_buffer,
|
||||
/* acpi_initialize (NULL); */
|
||||
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:
|
||||
|
||||
acpi_db_create_execution_threads(acpi_gbl_db_args[1],
|
||||
|
Loading…
Reference in New Issue
Block a user