Skip to content

Commit

Permalink
Executer: Add OSL trace hook support.
Browse files Browse the repository at this point in the history
This patch adds OSL trace hook support.

OSPMs are encouraged to use AcpiOsTracePoint() with
ACPI_USE_SYSTEM_TRACER defined to implement platform specific trace
facility. Lv Zheng.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
  • Loading branch information
Lv Zheng committed Jun 10, 2015
1 parent 07fffd0 commit e8e4a9b
Show file tree
Hide file tree
Showing 8 changed files with 176 additions and 36 deletions.
136 changes: 100 additions & 36 deletions source/components/executer/exdebug.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,14 @@

static ACPI_OPERAND_OBJECT *AcpiGbl_TraceMethodObject = NULL;

/* Local prototypes */

#ifdef ACPI_DEBUG_OUTPUT
static const char *
AcpiExGetTraceEventName (
ACPI_TRACE_EVENT_TYPE Type);
#endif


#ifndef ACPI_NO_ERROR_MESSAGES
/*******************************************************************************
Expand Down Expand Up @@ -449,6 +457,90 @@ AcpiExInterpreterTraceEnabled (
}


/*******************************************************************************
*
* FUNCTION: AcpiExGetTraceEventName
*
* PARAMETERS: Type - Trace event type
*
* RETURN: Trace event name.
*
* DESCRIPTION: Used to obtain the full trace event name.
*
******************************************************************************/

#ifdef ACPI_DEBUG_OUTPUT

static const char *
AcpiExGetTraceEventName (
ACPI_TRACE_EVENT_TYPE Type)
{
switch (Type)
{
case ACPI_TRACE_AML_METHOD:

return "Method";

case ACPI_TRACE_AML_OPCODE:

return "Opcode";

case ACPI_TRACE_AML_REGION:

return "Region";

default:

return "";
}
}

#endif


/*******************************************************************************
*
* FUNCTION: AcpiExTracePoint
*
* PARAMETERS: Type - Trace event type
* Begin - TRUE if before execution
* Aml - Executed AML address
* Pathname - Object path
*
* RETURN: None
*
* DESCRIPTION: Internal interpreter execution trace.
*
******************************************************************************/

void
AcpiExTracePoint (
ACPI_TRACE_EVENT_TYPE Type,
BOOLEAN Begin,
UINT8 *Aml,
char *Pathname)
{

ACPI_FUNCTION_NAME (ExTracePoint);


if (Pathname)
{
ACPI_DEBUG_PRINT ((ACPI_DB_TRACE_POINT,
"%s %s [0x%p:%s] execution.\n",
AcpiExGetTraceEventName (Type), Begin ? "Begin" : "End",
Aml, Pathname));
}
else
{
ACPI_DEBUG_PRINT ((ACPI_DB_TRACE_POINT,
"%s %s [0x%p] execution.\n",
AcpiExGetTraceEventName (Type), Begin ? "Begin" : "End",
Aml));
}
}


/*******************************************************************************
*
* FUNCTION: AcpiExStartTraceMethod
Expand Down Expand Up @@ -512,17 +604,10 @@ AcpiExStartTraceMethod (
Exit:
if (Enabled)
{
ACPI_TRACE_POINT (ACPI_TRACE_AML_METHOD, TRUE,
ObjDesc ? ObjDesc->Method.AmlStart : NULL, Pathname);
if (Pathname)
{
ACPI_DEBUG_PRINT ((ACPI_DB_TRACE_POINT,
"Begin method [0x%p:%s] execution.\n",
ObjDesc->Method.AmlStart, Pathname));
}
else
{
ACPI_DEBUG_PRINT ((ACPI_DB_TRACE_POINT,
"Begin method [0x%p] execution.\n",
ObjDesc->Method.AmlStart));
}
}
if (Pathname)
Expand Down Expand Up @@ -578,17 +663,10 @@ AcpiExStopTraceMethod (

if (Enabled)
{
ACPI_TRACE_POINT (ACPI_TRACE_AML_METHOD, FALSE,
ObjDesc ? ObjDesc->Method.AmlStart : NULL, Pathname);
if (Pathname)
{
ACPI_DEBUG_PRINT ((ACPI_DB_TRACE_POINT,
"End method [0x%p:%s] execution.\n",
ObjDesc->Method.AmlStart, Pathname));
}
else
{
ACPI_DEBUG_PRINT ((ACPI_DB_TRACE_POINT,
"End method [0x%p] execution.\n",
ObjDesc->Method.AmlStart));
}
}

Expand Down Expand Up @@ -649,21 +727,8 @@ AcpiExStartTraceOpcode (

if (AcpiExInterpreterTraceEnabled (NULL))
{
if (WalkState->OpInfo)
{
ACPI_DEBUG_PRINT ((ACPI_DB_TRACE_POINT,
"Begin opcode: %s[0x%p] Class=0x%02x, Type=0x%02x, Flags=0x%04x.\n",
Op->Common.AmlOpName, Op->Common.Aml,
WalkState->OpInfo->Class,
WalkState->OpInfo->Type,
WalkState->OpInfo->Flags));
}
else
{
ACPI_DEBUG_PRINT ((ACPI_DB_TRACE_POINT,
"Begin opcode: %s[0x%p].\n",
Op->Common.AmlOpName, Op->Common.Aml));
}
ACPI_TRACE_POINT (ACPI_TRACE_AML_OPCODE, TRUE,
Op->Common.Aml, Op->Common.AmlOpName);
}
}

Expand Down Expand Up @@ -693,8 +758,7 @@ AcpiExStopTraceOpcode (

if (AcpiExInterpreterTraceEnabled (NULL))
{
ACPI_DEBUG_PRINT ((ACPI_DB_TRACE_POINT,
"End opcode: %s[0x%p].\n",
Op->Common.AmlOpName, Op->Common.Aml));
ACPI_TRACE_POINT (ACPI_TRACE_AML_OPCODE, FALSE,
Op->Common.Aml, Op->Common.AmlOpName);
}
}
37 changes: 37 additions & 0 deletions source/components/utilities/utdebug.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@

#include "acpi.h"
#include "accommon.h"
#include "acinterp.h"

#define _COMPONENT ACPI_UTILITIES
ACPI_MODULE_NAME ("utdebug")
Expand Down Expand Up @@ -706,6 +707,42 @@ AcpiUtPtrExit (
}
}


/*******************************************************************************
*
* FUNCTION: AcpiTracePoint
*
* PARAMETERS: Type - Trace event type
* Begin - TRUE if before execution
* Aml - Executed AML address
* Pathname - Object path
* Pointer - Pointer to the related object
*
* RETURN: None
*
* DESCRIPTION: Interpreter execution trace.
*
******************************************************************************/

void
AcpiTracePoint (
ACPI_TRACE_EVENT_TYPE Type,
BOOLEAN Begin,
UINT8 *Aml,
char *Pathname)
{

ACPI_FUNCTION_ENTRY ();

AcpiExTracePoint (Type, Begin, Aml, Pathname);

#ifdef ACPI_USE_SYSTEM_TRACER
AcpiOsTracePoint (Type, Begin, Aml, Pathname);
#endif
}

ACPI_EXPORT_SYMBOL (AcpiTracePoint)

#endif


Expand Down
7 changes: 7 additions & 0 deletions source/include/acinterp.h
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,13 @@ AcpiExStopTraceOpcode (
ACPI_PARSE_OBJECT *Op,
ACPI_WALK_STATE *WalkState);

void
AcpiExTracePoint (
ACPI_TRACE_EVENT_TYPE Type,
BOOLEAN Begin,
UINT8 *Aml,
char *Pathname);


/*
* exfield - ACPI AML (p-code) execution - field manipulation
Expand Down
3 changes: 3 additions & 0 deletions source/include/acoutput.h
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,8 @@
#define ACPI_DUMP_PATHNAME(a, b, c, d) AcpiNsDumpPathname(a, b, c, d)
#define ACPI_DUMP_BUFFER(a, b) AcpiUtDebugDumpBuffer((UINT8 *) a, b, DB_BYTE_DISPLAY, _COMPONENT)

#define ACPI_TRACE_POINT(a, b, c, d) AcpiTracePoint (a, b, c, d)

#else /* ACPI_DEBUG_OUTPUT */
/*
* This is the non-debug case -- make everything go away,
Expand All @@ -548,6 +550,7 @@
#define ACPI_DUMP_PATHNAME(a, b, c, d)
#define ACPI_DUMP_BUFFER(a, b)
#define ACPI_IS_DEBUG_ENABLED(Level, Component) 0
#define ACPI_TRACE_POINT(a, b, c, d)

/* Return macros must have a return statement at the minimum */

Expand Down
9 changes: 9 additions & 0 deletions source/include/acpiosxf.h
Original file line number Diff line number Diff line change
Expand Up @@ -671,5 +671,14 @@ AcpiOsSetFileOffset (
UINT8 From);
#endif

#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsTracePoint
void
AcpiOsTracePoint (
ACPI_TRACE_EVENT_TYPE Type,
BOOLEAN Begin,
UINT8 *Aml,
char *Pathname);
#endif


#endif /* __ACPIOSXF_H__ */
8 changes: 8 additions & 0 deletions source/include/acpixf.h
Original file line number Diff line number Diff line change
Expand Up @@ -1265,6 +1265,14 @@ AcpiDebugPrintRaw (
const char *Format,
...))

ACPI_DBG_DEPENDENT_RETURN_VOID (
void
AcpiTracePoint (
ACPI_TRACE_EVENT_TYPE Type,
BOOLEAN Begin,
UINT8 *Aml,
char *Pathname))

ACPI_APP_DEPENDENT_RETURN_VOID (
ACPI_PRINTF_LIKE(1)
void ACPI_INTERNAL_VAR_XFACE
Expand Down
11 changes: 11 additions & 0 deletions source/include/actypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -1421,6 +1421,17 @@ typedef struct acpi_memory_list
} ACPI_MEMORY_LIST;


/* Definitions of trace event types */

typedef enum
{
ACPI_TRACE_AML_METHOD,
ACPI_TRACE_AML_OPCODE,
ACPI_TRACE_AML_REGION

} ACPI_TRACE_EVENT_TYPE;


/* Definitions of _OSI support */

#define ACPI_VENDOR_STRINGS 0x01
Expand Down
1 change: 1 addition & 0 deletions source/tools/acpisrc/astable.c
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,7 @@ ACPI_TYPED_IDENTIFIER_TABLE AcpiIdentifiers[] = {
{"ACPI_TAG_INFO", SRC_TYPE_STRUCT},
{"ACPI_THREAD_ID", SRC_TYPE_SIMPLE},
{"ACPI_THREAD_STATE", SRC_TYPE_STRUCT},
{"ACPI_TRACE_EVENT_TYPE", SRC_TYPE_SIMPLE},
{"ACPI_TYPED_IDENTIFIER_TABLE", SRC_TYPE_STRUCT},
{"ACPI_UINTPTR_T", SRC_TYPE_SIMPLE},
{"ACPI_UPDATE_STATE", SRC_TYPE_STRUCT},
Expand Down

0 comments on commit e8e4a9b

Please sign in to comment.