Skip to content

Commit 5fd0332

Browse files
Erik Schmaussrafaeljw
authored andcommitted
ACPICA: debugger: add command to dump all fields of particular subtype
In acpiexec, this can be invoked by typing "fields" followed by a number representing the address space ID of that field. Signed-off-by: Erik Schmauss <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent efcf945 commit 5fd0332

File tree

4 files changed

+141
-0
lines changed

4 files changed

+141
-0
lines changed

drivers/acpi/acpica/acdebug.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,8 @@ void acpi_db_find_references(char *object_arg);
148148

149149
void acpi_db_get_bus_info(void);
150150

151+
acpi_status acpi_db_display_fields(u32 address_space_id);
152+
151153
/*
152154
* dbdisply - debug display commands
153155
*/

drivers/acpi/acpica/acstruct.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,16 @@ struct acpi_device_walk_info {
192192
u32 num_INI;
193193
};
194194

195+
/* Info used by Acpi acpi_db_display_fields */
196+
197+
struct acpi_region_walk_info {
198+
u32 debug_level;
199+
u32 count;
200+
acpi_owner_id owner_id;
201+
u8 display_type;
202+
u32 address_space_id;
203+
};
204+
195205
/* TBD: [Restructure] Merge with struct above */
196206

197207
struct acpi_walk_info {

drivers/acpi/acpica/dbinput.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ enum acpi_ex_debugger_commands {
5050
CMD_EVALUATE,
5151
CMD_EXECUTE,
5252
CMD_EXIT,
53+
CMD_FIELDS,
5354
CMD_FIND,
5455
CMD_GO,
5556
CMD_HANDLERS,
@@ -127,6 +128,7 @@ static const struct acpi_db_command_info acpi_gbl_db_commands[] = {
127128
{"EVALUATE", 1},
128129
{"EXECUTE", 1},
129130
{"EXIT", 0},
131+
{"FIELDS", 1},
130132
{"FIND", 1},
131133
{"GO", 0},
132134
{"HANDLERS", 0},
@@ -200,6 +202,8 @@ static const struct acpi_db_command_help acpi_gbl_db_command_help[] = {
200202
"Find ACPI name(s) with wildcards\n"},
201203
{1, " Integrity", "Validate namespace integrity\n"},
202204
{1, " Methods", "Display list of loaded control methods\n"},
205+
{1, " Fields <AddressSpaceId>",
206+
"Display list of loaded field units by space ID\n"},
203207
{1, " Namespace [Object] [Depth]",
204208
"Display loaded namespace tree/subtree\n"},
205209
{1, " Notify <Object> <Value>", "Send a notification on Object\n"},
@@ -674,6 +678,7 @@ acpi_db_command_dispatch(char *input_buffer,
674678
union acpi_parse_object *op)
675679
{
676680
u32 temp;
681+
u64 temp64;
677682
u32 command_index;
678683
u32 param_count;
679684
char *command_line;
@@ -789,6 +794,21 @@ acpi_db_command_dispatch(char *input_buffer,
789794
status = acpi_db_find_name_in_namespace(acpi_gbl_db_args[1]);
790795
break;
791796

797+
case CMD_FIELDS:
798+
799+
status = acpi_ut_strtoul64(acpi_gbl_db_args[1], &temp64);
800+
801+
if (ACPI_FAILURE(status)
802+
|| temp64 >= ACPI_NUM_PREDEFINED_REGIONS) {
803+
acpi_os_printf
804+
("Invalid adress space ID: must be between 0 and %u inclusive\n",
805+
ACPI_NUM_PREDEFINED_REGIONS - 1);
806+
return (AE_OK);
807+
}
808+
809+
status = acpi_db_display_fields((u32)temp64);
810+
break;
811+
792812
case CMD_GO:
793813

794814
acpi_gbl_cm_single_step = FALSE;

drivers/acpi/acpica/dbnames.c

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include "acnamesp.h"
1111
#include "acdebug.h"
1212
#include "acpredef.h"
13+
#include "acinterp.h"
1314

1415
#define _COMPONENT ACPI_CA_DEBUGGER
1516
ACPI_MODULE_NAME("dbnames")
@@ -502,6 +503,81 @@ acpi_db_walk_for_object_counts(acpi_handle obj_handle,
502503
return (AE_OK);
503504
}
504505

506+
/*******************************************************************************
507+
*
508+
* FUNCTION: acpi_db_walk_for_fields
509+
*
510+
* PARAMETERS: Callback from walk_namespace
511+
*
512+
* RETURN: Status
513+
*
514+
* DESCRIPTION: Display short info about objects in the namespace
515+
*
516+
******************************************************************************/
517+
518+
static acpi_status
519+
acpi_db_walk_for_fields(acpi_handle obj_handle,
520+
u32 nesting_level, void *context, void **return_value)
521+
{
522+
union acpi_object *ret_value;
523+
struct acpi_region_walk_info *info =
524+
(struct acpi_region_walk_info *)context;
525+
struct acpi_buffer buffer;
526+
acpi_status status;
527+
struct acpi_namespace_node *node = acpi_ns_validate_handle(obj_handle);
528+
529+
if (!node) {
530+
return (AE_OK);
531+
}
532+
if (node->object->field.region_obj->region.space_id !=
533+
info->address_space_id) {
534+
return (AE_OK);
535+
}
536+
537+
info->count++;
538+
539+
/* Get and display the full pathname to this object */
540+
541+
buffer.length = ACPI_ALLOCATE_LOCAL_BUFFER;
542+
status = acpi_ns_handle_to_pathname(obj_handle, &buffer, TRUE);
543+
if (ACPI_FAILURE(status)) {
544+
acpi_os_printf("Could Not get pathname for object %p\n",
545+
obj_handle);
546+
return (AE_OK);
547+
}
548+
549+
acpi_os_printf("%s ", (char *)buffer.pointer);
550+
ACPI_FREE(buffer.pointer);
551+
552+
buffer.length = ACPI_ALLOCATE_LOCAL_BUFFER;
553+
acpi_evaluate_object(obj_handle, NULL, NULL, &buffer);
554+
555+
ret_value = (union acpi_object *)buffer.pointer;
556+
switch (ret_value->type) {
557+
case ACPI_TYPE_INTEGER:
558+
559+
acpi_os_printf("%8.8X%8.8X",
560+
ACPI_FORMAT_UINT64(ret_value->integer.value));
561+
break;
562+
563+
case ACPI_TYPE_BUFFER:
564+
565+
acpi_ut_dump_buffer(ret_value->buffer.pointer,
566+
ret_value->buffer.length,
567+
DB_DISPLAY_DATA_ONLY | DB_BYTE_DISPLAY, 0);
568+
break;
569+
570+
default:
571+
572+
break;
573+
}
574+
acpi_os_printf("\n");
575+
576+
ACPI_FREE(buffer.pointer);
577+
578+
return (AE_OK);
579+
}
580+
505581
/*******************************************************************************
506582
*
507583
* FUNCTION: acpi_db_walk_for_specific_objects
@@ -628,6 +704,39 @@ acpi_status acpi_db_display_objects(char *obj_type_arg, char *display_count_arg)
628704
return (AE_OK);
629705
}
630706

707+
/*******************************************************************************
708+
*
709+
* FUNCTION: acpi_db_display_fields
710+
*
711+
* PARAMETERS: obj_type_arg - Type of object to display
712+
* display_count_arg - Max depth to display
713+
*
714+
* RETURN: None
715+
*
716+
* DESCRIPTION: Display objects in the namespace of the requested type
717+
*
718+
******************************************************************************/
719+
720+
acpi_status acpi_db_display_fields(u32 address_space_id)
721+
{
722+
struct acpi_region_walk_info info;
723+
724+
info.count = 0;
725+
info.owner_id = ACPI_OWNER_ID_MAX;
726+
info.debug_level = ACPI_UINT32_MAX;
727+
info.display_type = ACPI_DISPLAY_SUMMARY | ACPI_DISPLAY_SHORT;
728+
info.address_space_id = address_space_id;
729+
730+
/* Walk the namespace from the root */
731+
732+
(void)acpi_walk_namespace(ACPI_TYPE_LOCAL_REGION_FIELD,
733+
ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
734+
acpi_db_walk_for_fields, NULL, (void *)&info,
735+
NULL);
736+
737+
return (AE_OK);
738+
}
739+
631740
/*******************************************************************************
632741
*
633742
* FUNCTION: acpi_db_integrity_walk

0 commit comments

Comments
 (0)