Skip to content

Commit 6218ab3

Browse files
acpibobrafaeljw
authored andcommitted
ACPICA: Debugger: Add a new command: "ALL <NameSeg>"
This command will execute/evaluate all objects with a match to the <NameSeg> argument. ACPICA commit a1a32ec054f067d1617067e2bafb0a27a8728e07 Link: acpica/acpica@a1a32ec0 Signed-off-by: Bob Moore <robert.moore@intel.com> Signed-off-by: Erik Kaneda <erik.kaneda@intel.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent ef3efb4 commit 6218ab3

4 files changed

Lines changed: 188 additions & 34 deletions

File tree

drivers/acpi/acpica/acdebug.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,14 @@ struct acpi_db_argument_info {
3737
struct acpi_db_execute_walk {
3838
u32 count;
3939
u32 max_count;
40+
char name_seg[ACPI_NAMESEG_SIZE + 1];
4041
};
4142

4243
#define PARAM_LIST(pl) pl
4344

4445
#define EX_NO_SINGLE_STEP 1
4546
#define EX_SINGLE_STEP 2
47+
#define EX_ALL 4
4648

4749
/*
4850
* dbxface - external debugger interfaces
@@ -124,6 +126,8 @@ void acpi_db_disassemble_aml(char *statements, union acpi_parse_object *op);
124126

125127
void acpi_db_evaluate_predefined_names(void);
126128

129+
void acpi_db_evaluate_all(char *name_seg);
130+
127131
/*
128132
* dbnames - namespace commands
129133
*/

drivers/acpi/acpica/dbexec.c

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@ void acpi_db_delete_objects(u32 count, union acpi_object *objects)
8686
*
8787
* RETURN: Status
8888
*
89-
* DESCRIPTION: Execute a control method.
89+
* DESCRIPTION: Execute a control method. Used to evaluate objects via the
90+
* "EXECUTE" or "EVALUATE" commands.
9091
*
9192
******************************************************************************/
9293

@@ -314,11 +315,12 @@ acpi_db_execution_walk(acpi_handle obj_handle,
314315

315316
status = acpi_evaluate_object(node, NULL, NULL, &return_obj);
316317

318+
acpi_gbl_method_executing = FALSE;
319+
317320
acpi_os_printf("Evaluation of [%4.4s] returned %s\n",
318321
acpi_ut_get_node_name(node),
319322
acpi_format_exception(status));
320323

321-
acpi_gbl_method_executing = FALSE;
322324
return (AE_OK);
323325
}
324326

@@ -334,7 +336,8 @@ acpi_db_execution_walk(acpi_handle obj_handle,
334336
* RETURN: None
335337
*
336338
* DESCRIPTION: Execute a control method. Name is relative to the current
337-
* scope.
339+
* scope. Function used for the "EXECUTE", "EVALUATE", and
340+
* "ALL" commands
338341
*
339342
******************************************************************************/
340343

@@ -372,6 +375,12 @@ acpi_db_execute(char *name, char **args, acpi_object_type *types, u32 flags)
372375
return;
373376
}
374377

378+
if ((flags & EX_ALL) && (strlen(name) > 4)) {
379+
acpi_os_printf("Input name (%s) must be a 4-char NameSeg\n",
380+
name);
381+
return;
382+
}
383+
375384
name_string = ACPI_ALLOCATE(strlen(name) + 1);
376385
if (!name_string) {
377386
return;
@@ -389,13 +398,24 @@ acpi_db_execute(char *name, char **args, acpi_object_type *types, u32 flags)
389398
return;
390399
}
391400

392-
acpi_gbl_db_method_info.name = name_string;
393-
acpi_gbl_db_method_info.args = args;
394-
acpi_gbl_db_method_info.types = types;
395-
acpi_gbl_db_method_info.flags = flags;
401+
/* Command (ALL <nameseg>) to execute all methods of a particular name */
396402

397-
return_obj.pointer = NULL;
398-
return_obj.length = ACPI_ALLOCATE_BUFFER;
403+
else if (flags & EX_ALL) {
404+
acpi_gbl_db_method_info.name = name_string;
405+
return_obj.pointer = NULL;
406+
return_obj.length = ACPI_ALLOCATE_BUFFER;
407+
acpi_db_evaluate_all(name_string);
408+
ACPI_FREE(name_string);
409+
return;
410+
} else {
411+
acpi_gbl_db_method_info.name = name_string;
412+
acpi_gbl_db_method_info.args = args;
413+
acpi_gbl_db_method_info.types = types;
414+
acpi_gbl_db_method_info.flags = flags;
415+
416+
return_obj.pointer = NULL;
417+
return_obj.length = ACPI_ALLOCATE_BUFFER;
418+
}
399419

400420
status = acpi_db_execute_setup(&acpi_gbl_db_method_info);
401421
if (ACPI_FAILURE(status)) {
@@ -450,6 +470,7 @@ acpi_db_execute(char *name, char **args, acpi_object_type *types, u32 flags)
450470
(u32)return_obj.length);
451471

452472
acpi_db_dump_external_object(return_obj.pointer, 1);
473+
acpi_os_printf("\n");
453474

454475
/* Dump a _PLD buffer if present */
455476

drivers/acpi/acpica/dbinput.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ acpi_db_match_command_help(const char *command,
3737
enum acpi_ex_debugger_commands {
3838
CMD_NOT_FOUND = 0,
3939
CMD_NULL,
40+
CMD_ALL,
4041
CMD_ALLOCATIONS,
4142
CMD_ARGS,
4243
CMD_ARGUMENTS,
@@ -115,6 +116,7 @@ enum acpi_ex_debugger_commands {
115116
static const struct acpi_db_command_info acpi_gbl_db_commands[] = {
116117
{"<NOT FOUND>", 0},
117118
{"<NULL>", 0},
119+
{"ALL", 1},
118120
{"ALLOCATIONS", 0},
119121
{"ARGS", 0},
120122
{"ARGUMENTS", 0},
@@ -222,6 +224,7 @@ static const struct acpi_db_command_help acpi_gbl_db_command_help[] = {
222224
{1, " Type <Object>", "Display object type\n"},
223225

224226
{0, "\nControl Method Execution:", "\n"},
227+
{1, " All <NameSeg>", "Evaluate all objects named NameSeg\n"},
225228
{1, " Evaluate <Namepath> [Arguments]",
226229
"Evaluate object or control method\n"},
227230
{1, " Execute <Namepath> [Arguments]", "Synonym for Evaluate\n"},
@@ -740,6 +743,15 @@ acpi_db_command_dispatch(char *input_buffer,
740743
}
741744
break;
742745

746+
case CMD_ALL:
747+
748+
acpi_os_printf("Executing all objects with NameSeg: %s\n",
749+
acpi_gbl_db_args[1]);
750+
acpi_db_execute(acpi_gbl_db_args[1], &acpi_gbl_db_args[2],
751+
&acpi_gbl_db_arg_types[2],
752+
EX_NO_SINGLE_STEP | EX_ALL);
753+
break;
754+
743755
case CMD_ALLOCATIONS:
744756

745757
#ifdef ACPI_DBG_TRACK_ALLOCATIONS

drivers/acpi/acpica/dbmethod.c

Lines changed: 142 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ static acpi_status
2121
acpi_db_walk_for_execute(acpi_handle obj_handle,
2222
u32 nesting_level, void *context, void **return_value);
2323

24+
static acpi_status acpi_db_evaluate_object(struct acpi_namespace_node *node);
25+
2426
/*******************************************************************************
2527
*
2628
* FUNCTION: acpi_db_set_method_breakpoint
@@ -346,42 +348,26 @@ acpi_status acpi_db_disassemble_method(char *name)
346348

347349
/*******************************************************************************
348350
*
349-
* FUNCTION: acpi_db_walk_for_execute
351+
* FUNCTION: acpi_db_evaluate_object
350352
*
351-
* PARAMETERS: Callback from walk_namespace
353+
* PARAMETERS: node - Namespace node for the object
352354
*
353355
* RETURN: Status
354356
*
355-
* DESCRIPTION: Batch execution module. Currently only executes predefined
356-
* ACPI names.
357+
* DESCRIPTION: Main execution function for the Evaluate/Execute/All debugger
358+
* commands.
357359
*
358360
******************************************************************************/
359361

360-
static acpi_status
361-
acpi_db_walk_for_execute(acpi_handle obj_handle,
362-
u32 nesting_level, void *context, void **return_value)
362+
static acpi_status acpi_db_evaluate_object(struct acpi_namespace_node *node)
363363
{
364-
struct acpi_namespace_node *node =
365-
(struct acpi_namespace_node *)obj_handle;
366-
struct acpi_db_execute_walk *info =
367-
(struct acpi_db_execute_walk *)context;
368-
struct acpi_buffer return_obj;
369-
acpi_status status;
370364
char *pathname;
371365
u32 i;
372366
struct acpi_device_info *obj_info;
373367
struct acpi_object_list param_objects;
374368
union acpi_object params[ACPI_METHOD_NUM_ARGS];
375-
const union acpi_predefined_info *predefined;
376-
377-
predefined = acpi_ut_match_predefined_method(node->name.ascii);
378-
if (!predefined) {
379-
return (AE_OK);
380-
}
381-
382-
if (node->type == ACPI_TYPE_LOCAL_SCOPE) {
383-
return (AE_OK);
384-
}
369+
struct acpi_buffer return_obj;
370+
acpi_status status;
385371

386372
pathname = acpi_ns_get_external_pathname(node);
387373
if (!pathname) {
@@ -390,7 +376,7 @@ acpi_db_walk_for_execute(acpi_handle obj_handle,
390376

391377
/* Get the object info for number of method parameters */
392378

393-
status = acpi_get_object_info(obj_handle, &obj_info);
379+
status = acpi_get_object_info(node, &obj_info);
394380
if (ACPI_FAILURE(status)) {
395381
ACPI_FREE(pathname);
396382
return (status);
@@ -421,14 +407,67 @@ acpi_db_walk_for_execute(acpi_handle obj_handle,
421407
acpi_gbl_method_executing = TRUE;
422408

423409
status = acpi_evaluate_object(node, NULL, &param_objects, &return_obj);
410+
acpi_gbl_method_executing = FALSE;
424411

425412
acpi_os_printf("%-32s returned %s\n", pathname,
426413
acpi_format_exception(status));
427-
acpi_gbl_method_executing = FALSE;
414+
if (return_obj.length) {
415+
acpi_os_printf("Evaluation of %s returned object %p, "
416+
"external buffer length %X\n",
417+
pathname, return_obj.pointer,
418+
(u32)return_obj.length);
419+
420+
acpi_db_dump_external_object(return_obj.pointer, 1);
421+
acpi_os_printf("\n");
422+
}
423+
428424
ACPI_FREE(pathname);
429425

430426
/* Ignore status from method execution */
431427

428+
return (AE_OK);
429+
430+
/* Update count, check if we have executed enough methods */
431+
432+
}
433+
434+
/*******************************************************************************
435+
*
436+
* FUNCTION: acpi_db_walk_for_execute
437+
*
438+
* PARAMETERS: Callback from walk_namespace
439+
*
440+
* RETURN: Status
441+
*
442+
* DESCRIPTION: Batch execution function. Evaluates all "predefined" objects --
443+
* the nameseg begins with an underscore.
444+
*
445+
******************************************************************************/
446+
447+
static acpi_status
448+
acpi_db_walk_for_execute(acpi_handle obj_handle,
449+
u32 nesting_level, void *context, void **return_value)
450+
{
451+
struct acpi_namespace_node *node =
452+
(struct acpi_namespace_node *)obj_handle;
453+
struct acpi_db_execute_walk *info =
454+
(struct acpi_db_execute_walk *)context;
455+
acpi_status status;
456+
const union acpi_predefined_info *predefined;
457+
458+
predefined = acpi_ut_match_predefined_method(node->name.ascii);
459+
if (!predefined) {
460+
return (AE_OK);
461+
}
462+
463+
if (node->type == ACPI_TYPE_LOCAL_SCOPE) {
464+
return (AE_OK);
465+
}
466+
467+
acpi_db_evaluate_object(node);
468+
469+
/* Ignore status from object evaluation */
470+
432471
status = AE_OK;
433472

434473
/* Update count, check if we have executed enough methods */
@@ -441,6 +480,52 @@ acpi_db_walk_for_execute(acpi_handle obj_handle,
441480
return (status);
442481
}
443482

483+
/*******************************************************************************
484+
*
485+
* FUNCTION: acpi_db_walk_for_execute_all
486+
*
487+
* PARAMETERS: Callback from walk_namespace
488+
*
489+
* RETURN: Status
490+
*
491+
* DESCRIPTION: Batch execution function. Evaluates all objects whose path ends
492+
* with the nameseg "Info->NameSeg". Used for the "ALL" command.
493+
*
494+
******************************************************************************/
495+
496+
static acpi_status
497+
acpi_db_walk_for_execute_all(acpi_handle obj_handle,
498+
u32 nesting_level,
499+
void *context, void **return_value)
500+
{
501+
struct acpi_namespace_node *node =
502+
(struct acpi_namespace_node *)obj_handle;
503+
struct acpi_db_execute_walk *info =
504+
(struct acpi_db_execute_walk *)context;
505+
acpi_status status;
506+
507+
if (!ACPI_COMPARE_NAMESEG(node->name.ascii, info->name_seg)) {
508+
return (AE_OK);
509+
}
510+
511+
if (node->type == ACPI_TYPE_LOCAL_SCOPE) {
512+
return (AE_OK);
513+
}
514+
515+
/* Now evaluate the input object (node) */
516+
517+
acpi_db_evaluate_object(node);
518+
519+
/* Ignore status from method execution */
520+
521+
status = AE_OK;
522+
523+
/* Update count of executed methods/objects */
524+
525+
info->count++;
526+
return (status);
527+
}
528+
444529
/*******************************************************************************
445530
*
446531
* FUNCTION: acpi_db_evaluate_predefined_names
@@ -470,3 +555,35 @@ void acpi_db_evaluate_predefined_names(void)
470555
acpi_os_printf("Evaluated %u predefined names in the namespace\n",
471556
info.count);
472557
}
558+
559+
/*******************************************************************************
560+
*
561+
* FUNCTION: acpi_db_evaluate_all
562+
*
563+
* PARAMETERS: none_acpi_gbl_db_method_info
564+
*
565+
* RETURN: None
566+
*
567+
* DESCRIPTION: Namespace batch execution. Implements the "ALL" command.
568+
* Execute all namepaths whose final nameseg matches the
569+
* input nameseg.
570+
*
571+
******************************************************************************/
572+
573+
void acpi_db_evaluate_all(char *name_seg)
574+
{
575+
struct acpi_db_execute_walk info;
576+
577+
info.count = 0;
578+
info.max_count = ACPI_UINT32_MAX;
579+
ACPI_COPY_NAMESEG(info.name_seg, name_seg);
580+
info.name_seg[ACPI_NAMESEG_SIZE] = 0;
581+
582+
/* Search all nodes in namespace */
583+
584+
(void)acpi_walk_namespace(ACPI_TYPE_ANY, ACPI_ROOT_OBJECT,
585+
ACPI_UINT32_MAX, acpi_db_walk_for_execute_all,
586+
NULL, (void *)&info, NULL);
587+
588+
acpi_os_printf("Evaluated %u names in the namespace\n", info.count);
589+
}

0 commit comments

Comments
 (0)