Skip to content

Commit

Permalink
debugger: add command to dump all fields of a particular subtype
Browse files Browse the repository at this point in the history
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 <erik.schmauss@intel.com>
  • Loading branch information
Erik Schmauss committed Oct 9, 2019
1 parent fb18935 commit 85cbe5e
Show file tree
Hide file tree
Showing 4 changed files with 153 additions and 0 deletions.
19 changes: 19 additions & 0 deletions source/components/debugger/dbinput.c
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ enum AcpiExDebuggerCommands
CMD_EVALUATE,
CMD_EXECUTE,
CMD_EXIT,
CMD_FIELDS,
CMD_FIND,
CMD_GO,
CMD_HANDLERS,
Expand Down Expand Up @@ -287,6 +288,7 @@ static const ACPI_DB_COMMAND_INFO AcpiGbl_DbCommands[] =
{"EVALUATE", 1},
{"EXECUTE", 1},
{"EXIT", 0},
{"FIELDS", 1},
{"FIND", 1},
{"GO", 0},
{"HANDLERS", 0},
Expand Down Expand Up @@ -360,6 +362,7 @@ static const ACPI_DB_COMMAND_HELP AcpiGbl_DbCommandHelp[] =
{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, " Fields <AddressSpaceId>", "Display list of loaded field units by space ID\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"},
Expand Down Expand Up @@ -877,6 +880,7 @@ AcpiDbCommandDispatch (
ACPI_PARSE_OBJECT *Op)
{
UINT32 Temp;
UINT64 Temp64;
UINT32 CommandIndex;
UINT32 ParamCount;
char *CommandLine;
Expand Down Expand Up @@ -992,6 +996,21 @@ AcpiDbCommandDispatch (
Status = AcpiDbFindNameInNamespace (AcpiGbl_DbArgs[1]);
break;

case CMD_FIELDS:

Status = AcpiUtStrtoul64 (AcpiGbl_DbArgs[1], &Temp64);

if (ACPI_FAILURE (Status) || Temp64 >= ACPI_NUM_PREDEFINED_REGIONS)
{
AcpiOsPrintf (
"Invalid adress space ID: must be between 0 and %u inclusive\n",
ACPI_NUM_PREDEFINED_REGIONS - 1);
return (AE_OK);
}

Status = AcpiDbDisplayFields ((UINT32) Temp64);
break;

case CMD_GO:

AcpiGbl_CmSingleStep = FALSE;
Expand Down
117 changes: 117 additions & 0 deletions source/components/debugger/dbnames.c
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@
#include "acnamesp.h"
#include "acdebug.h"
#include "acpredef.h"
#include "acinterp.h"


#define _COMPONENT ACPI_CA_DEBUGGER
Expand Down Expand Up @@ -722,6 +723,86 @@ AcpiDbWalkForObjectCounts (
}


/*******************************************************************************
*
* FUNCTION: AcpiDbWalkForFields
*
* PARAMETERS: Callback from WalkNamespace
*
* RETURN: Status
*
* DESCRIPTION: Display short info about objects in the namespace
*
******************************************************************************/

static ACPI_STATUS
AcpiDbWalkForFields (
ACPI_HANDLE ObjHandle,
UINT32 NestingLevel,
void *Context,
void **ReturnValue)
{
ACPI_OBJECT *RetValue;
ACPI_REGION_WALK_INFO *Info = (ACPI_REGION_WALK_INFO *) Context;
ACPI_BUFFER Buffer;
ACPI_STATUS Status;
ACPI_NAMESPACE_NODE *Node = AcpiNsValidateHandle (ObjHandle);


if (!Node)
{
return (AE_OK);
}
if (Node->Object->Field.RegionObj->Region.SpaceId != Info->AddressSpaceId)
{
return (AE_OK);
}

Info->Count++;

/* Get and display the full pathname to this object */

Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
Status = AcpiNsHandleToPathname (ObjHandle, &Buffer, TRUE);
if (ACPI_FAILURE (Status))
{
AcpiOsPrintf ("Could Not get pathname for object %p\n", ObjHandle);
return (AE_OK);
}

AcpiOsPrintf ("%s ", (char *) Buffer.Pointer);
ACPI_FREE (Buffer.Pointer);

Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
AcpiEvaluateObject (ObjHandle, NULL, NULL, &Buffer);

RetValue = (ACPI_OBJECT *) Buffer.Pointer;
switch (RetValue->Type)
{
case ACPI_TYPE_INTEGER:

AcpiOsPrintf ("%lx", RetValue->Integer.Value);
break;

case ACPI_TYPE_BUFFER:

AcpiUtDumpBuffer (RetValue->Buffer.Pointer,
RetValue->Buffer.Length, DB_DISPLAY_DATA_ONLY | DB_BYTE_DISPLAY, 0);
break;

default:

break;
}
AcpiOsPrintf ("\n");

ACPI_FREE (Buffer.Pointer);

return (AE_OK);
}



/*******************************************************************************
*
* FUNCTION: AcpiDbWalkForSpecificObjects
Expand Down Expand Up @@ -857,6 +938,42 @@ AcpiDbDisplayObjects (
}


/*******************************************************************************
*
* FUNCTION: AcpiDbDisplayFields
*
* PARAMETERS: ObjTypeArg - Type of object to display
* DisplayCountArg - Max depth to display
*
* RETURN: None
*
* DESCRIPTION: Display objects in the namespace of the requested type
*
******************************************************************************/

ACPI_STATUS
AcpiDbDisplayFields (
UINT32 AddressSpaceId)
{
ACPI_REGION_WALK_INFO Info;


Info.Count = 0;
Info.OwnerId = ACPI_OWNER_ID_MAX;
Info.DebugLevel = ACPI_UINT32_MAX;
Info.DisplayType = ACPI_DISPLAY_SUMMARY | ACPI_DISPLAY_SHORT;
Info.AddressSpaceId = AddressSpaceId;

/* Walk the namespace from the root */

(void) AcpiWalkNamespace (ACPI_TYPE_LOCAL_REGION_FIELD, ACPI_ROOT_OBJECT,
ACPI_UINT32_MAX, AcpiDbWalkForFields, NULL,
(void *) &Info, NULL);

return (AE_OK);
}


/*******************************************************************************
*
* FUNCTION: AcpiDbIntegrityWalk
Expand Down
4 changes: 4 additions & 0 deletions source/include/acdebug.h
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,10 @@ void
AcpiDbGetBusInfo (
void);

ACPI_STATUS
AcpiDbDisplayFields (
UINT32 AddressSpaceId);


/*
* dbdisply - debug display commands
Expand Down
13 changes: 13 additions & 0 deletions source/include/acstruct.h
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,19 @@ typedef struct acpi_device_walk_info
} ACPI_DEVICE_WALK_INFO;


/* Info used by Acpi AcpiDbDisplayFields */

typedef struct acpi_region_walk_info
{
UINT32 DebugLevel;
UINT32 Count;
ACPI_OWNER_ID OwnerId;
UINT8 DisplayType;
UINT32 AddressSpaceId;

} ACPI_REGION_WALK_INFO;


/* TBD: [Restructure] Merge with struct above */

typedef struct acpi_walk_info
Expand Down

0 comments on commit 85cbe5e

Please sign in to comment.