Commit bab04824 authored by Lv Zheng's avatar Lv Zheng Committed by Rafael J. Wysocki

ACPICA: Executer: Add OSL trace hook support

ACPICA commit e8e4a9b19d0b72a7b165398bdc961fc2f6f502ec

This patch adds OSL trace hook support.

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

Link: https://github.com/acpica/acpica/commit/e8e4a9b1Signed-off-by: default avatarLv Zheng <lv.zheng@intel.com>
Signed-off-by: default avatarBob Moore <robert.moore@intel.com>
Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
parent ab6c5733
...@@ -149,6 +149,10 @@ void ...@@ -149,6 +149,10 @@ void
acpi_ex_stop_trace_opcode(union acpi_parse_object *op, acpi_ex_stop_trace_opcode(union acpi_parse_object *op,
struct acpi_walk_state *walk_state); struct acpi_walk_state *walk_state);
void
acpi_ex_trace_point(acpi_trace_event_type type,
u8 begin, u8 *aml, char *pathname);
/* /*
* exfield - ACPI AML (p-code) execution - field manipulation * exfield - ACPI AML (p-code) execution - field manipulation
*/ */
......
...@@ -52,6 +52,12 @@ ACPI_MODULE_NAME("exdebug") ...@@ -52,6 +52,12 @@ ACPI_MODULE_NAME("exdebug")
static union acpi_operand_object *acpi_gbl_trace_method_object = NULL; static union acpi_operand_object *acpi_gbl_trace_method_object = NULL;
/* Local prototypes */
#ifdef ACPI_DEBUG_OUTPUT
static const char *acpi_ex_get_trace_event_name(acpi_trace_event_type type);
#endif
#ifndef ACPI_NO_ERROR_MESSAGES #ifndef ACPI_NO_ERROR_MESSAGES
/******************************************************************************* /*******************************************************************************
* *
...@@ -363,6 +369,78 @@ static u8 acpi_ex_interpreter_trace_enabled(char *name) ...@@ -363,6 +369,78 @@ static u8 acpi_ex_interpreter_trace_enabled(char *name)
return (TRUE); return (TRUE);
} }
/*******************************************************************************
*
* FUNCTION: acpi_ex_get_trace_event_name
*
* 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 *acpi_ex_get_trace_event_name(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: acpi_ex_trace_point
*
* 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
acpi_ex_trace_point(acpi_trace_event_type type,
u8 begin, u8 *aml, char *pathname)
{
ACPI_FUNCTION_NAME(ex_trace_point);
if (pathname) {
ACPI_DEBUG_PRINT((ACPI_DB_TRACE_POINT,
"%s %s [0x%p:%s] execution.\n",
acpi_ex_get_trace_event_name(type),
begin ? "Begin" : "End", aml, pathname));
} else {
ACPI_DEBUG_PRINT((ACPI_DB_TRACE_POINT,
"%s %s [0x%p] execution.\n",
acpi_ex_get_trace_event_name(type),
begin ? "Begin" : "End", aml));
}
}
/******************************************************************************* /*******************************************************************************
* *
* FUNCTION: acpi_ex_start_trace_method * FUNCTION: acpi_ex_start_trace_method
...@@ -417,16 +495,9 @@ acpi_ex_start_trace_method(struct acpi_namespace_node *method_node, ...@@ -417,16 +495,9 @@ acpi_ex_start_trace_method(struct acpi_namespace_node *method_node,
exit: exit:
if (enabled) { if (enabled) {
if (pathname) { ACPI_TRACE_POINT(ACPI_TRACE_AML_METHOD, TRUE,
ACPI_DEBUG_PRINT((ACPI_DB_TRACE_POINT, obj_desc ? obj_desc->method.aml_start : NULL,
"Begin method [0x%p:%s] execution.\n", pathname);
obj_desc->method.aml_start,
pathname));
} else {
ACPI_DEBUG_PRINT((ACPI_DB_TRACE_POINT,
"Begin method [0x%p] execution.\n",
obj_desc->method.aml_start));
}
} }
if (pathname) { if (pathname) {
ACPI_FREE(pathname); ACPI_FREE(pathname);
...@@ -473,16 +544,9 @@ acpi_ex_stop_trace_method(struct acpi_namespace_node *method_node, ...@@ -473,16 +544,9 @@ acpi_ex_stop_trace_method(struct acpi_namespace_node *method_node,
(void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
if (enabled) { if (enabled) {
if (pathname) { ACPI_TRACE_POINT(ACPI_TRACE_AML_METHOD, FALSE,
ACPI_DEBUG_PRINT((ACPI_DB_TRACE_POINT, obj_desc ? obj_desc->method.aml_start : NULL,
"End method [0x%p:%s] execution.\n", pathname);
obj_desc->method.aml_start,
pathname));
} else {
ACPI_DEBUG_PRINT((ACPI_DB_TRACE_POINT,
"End method [0x%p] execution.\n",
obj_desc->method.aml_start));
}
} }
status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE); status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
...@@ -535,20 +599,8 @@ acpi_ex_start_trace_opcode(union acpi_parse_object *op, ...@@ -535,20 +599,8 @@ acpi_ex_start_trace_opcode(union acpi_parse_object *op,
ACPI_FUNCTION_NAME(ex_start_trace_opcode); ACPI_FUNCTION_NAME(ex_start_trace_opcode);
if (acpi_ex_interpreter_trace_enabled(NULL)) { if (acpi_ex_interpreter_trace_enabled(NULL)) {
if (walk_state->op_info) { ACPI_TRACE_POINT(ACPI_TRACE_AML_OPCODE, TRUE,
ACPI_DEBUG_PRINT((ACPI_DB_TRACE_POINT, op->common.aml, op->common.aml_op_name);
"Begin opcode: %s[0x%p] Class=0x%02x, Type=0x%02x, Flags=0x%04x.\n",
op->common.aml_op_name,
op->common.aml,
walk_state->op_info->class,
walk_state->op_info->type,
walk_state->op_info->flags));
} else {
ACPI_DEBUG_PRINT((ACPI_DB_TRACE_POINT,
"Begin opcode: %s[0x%p].\n",
op->common.aml_op_name,
op->common.aml));
}
} }
} }
...@@ -574,8 +626,7 @@ acpi_ex_stop_trace_opcode(union acpi_parse_object *op, ...@@ -574,8 +626,7 @@ acpi_ex_stop_trace_opcode(union acpi_parse_object *op,
ACPI_FUNCTION_NAME(ex_stop_trace_opcode); ACPI_FUNCTION_NAME(ex_stop_trace_opcode);
if (acpi_ex_interpreter_trace_enabled(NULL)) { if (acpi_ex_interpreter_trace_enabled(NULL)) {
ACPI_DEBUG_PRINT((ACPI_DB_TRACE_POINT, ACPI_TRACE_POINT(ACPI_TRACE_AML_OPCODE, FALSE,
"End opcode: %s[0x%p].\n", op->common.aml, op->common.aml_op_name);
op->common.aml_op_name, op->common.aml));
} }
} }
...@@ -45,6 +45,7 @@ ...@@ -45,6 +45,7 @@
#include <acpi/acpi.h> #include <acpi/acpi.h>
#include "accommon.h" #include "accommon.h"
#include "acinterp.h"
#define _COMPONENT ACPI_UTILITIES #define _COMPONENT ACPI_UTILITIES
ACPI_MODULE_NAME("utdebug") ACPI_MODULE_NAME("utdebug")
...@@ -560,8 +561,37 @@ acpi_ut_ptr_exit(u32 line_number, ...@@ -560,8 +561,37 @@ acpi_ut_ptr_exit(u32 line_number,
} }
} }
/*******************************************************************************
*
* FUNCTION: acpi_trace_point
*
* 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
acpi_trace_point(acpi_trace_event_type type, u8 begin, u8 *aml, char *pathname)
{
ACPI_FUNCTION_ENTRY();
acpi_ex_trace_point(type, begin, aml, pathname);
#ifdef ACPI_USE_SYSTEM_TRACER
acpi_os_trace_point(type, begin, aml, pathname);
#endif #endif
}
ACPI_EXPORT_SYMBOL(acpi_trace_point)
#endif
#ifdef ACPI_APPLICATION #ifdef ACPI_APPLICATION
/******************************************************************************* /*******************************************************************************
* *
...@@ -575,7 +605,6 @@ acpi_ut_ptr_exit(u32 line_number, ...@@ -575,7 +605,6 @@ acpi_ut_ptr_exit(u32 line_number,
* DESCRIPTION: Print error message to the console, used by applications. * DESCRIPTION: Print error message to the console, used by applications.
* *
******************************************************************************/ ******************************************************************************/
void ACPI_INTERNAL_VAR_XFACE acpi_log_error(const char *format, ...) void ACPI_INTERNAL_VAR_XFACE acpi_log_error(const char *format, ...)
{ {
va_list args; va_list args;
......
...@@ -447,6 +447,8 @@ ...@@ -447,6 +447,8 @@
#define ACPI_DUMP_PATHNAME(a, b, c, d) acpi_ns_dump_pathname(a, b, c, d) #define ACPI_DUMP_PATHNAME(a, b, c, d) acpi_ns_dump_pathname(a, b, c, d)
#define ACPI_DUMP_BUFFER(a, b) acpi_ut_debug_dump_buffer((u8 *) a, b, DB_BYTE_DISPLAY, _COMPONENT) #define ACPI_DUMP_BUFFER(a, b) acpi_ut_debug_dump_buffer((u8 *) a, b, DB_BYTE_DISPLAY, _COMPONENT)
#define ACPI_TRACE_POINT(a, b, c, d) acpi_trace_point (a, b, c, d)
#else /* ACPI_DEBUG_OUTPUT */ #else /* ACPI_DEBUG_OUTPUT */
/* /*
* This is the non-debug case -- make everything go away, * This is the non-debug case -- make everything go away,
...@@ -468,6 +470,7 @@ ...@@ -468,6 +470,7 @@
#define ACPI_DUMP_PATHNAME(a, b, c, d) #define ACPI_DUMP_PATHNAME(a, b, c, d)
#define ACPI_DUMP_BUFFER(a, b) #define ACPI_DUMP_BUFFER(a, b)
#define ACPI_IS_DEBUG_ENABLED(level, component) 0 #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 */ /* Return macros must have a return statement at the minimum */
......
...@@ -430,4 +430,10 @@ long acpi_os_get_file_offset(ACPI_FILE file); ...@@ -430,4 +430,10 @@ long acpi_os_get_file_offset(ACPI_FILE file);
acpi_status acpi_os_set_file_offset(ACPI_FILE file, long offset, u8 from); acpi_status acpi_os_set_file_offset(ACPI_FILE file, long offset, u8 from);
#endif #endif
#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_trace_point
void
acpi_os_trace_point(acpi_trace_event_type type,
u8 begin, u8 *aml, char *pathname);
#endif
#endif /* __ACPIOSXF_H__ */ #endif /* __ACPIOSXF_H__ */
...@@ -909,6 +909,11 @@ ACPI_DBG_DEPENDENT_RETURN_VOID(ACPI_PRINTF_LIKE(6) ...@@ -909,6 +909,11 @@ ACPI_DBG_DEPENDENT_RETURN_VOID(ACPI_PRINTF_LIKE(6)
const char *module_name, const char *module_name,
u32 component_id, u32 component_id,
const char *format, ...)) const char *format, ...))
ACPI_DBG_DEPENDENT_RETURN_VOID(void
acpi_trace_point(acpi_trace_event_type type,
u8 begin,
u8 *aml, char *pathname))
ACPI_APP_DEPENDENT_RETURN_VOID(ACPI_PRINTF_LIKE(1) ACPI_APP_DEPENDENT_RETURN_VOID(ACPI_PRINTF_LIKE(1)
void ACPI_INTERNAL_VAR_XFACE void ACPI_INTERNAL_VAR_XFACE
acpi_log_error(const char *format, ...)) acpi_log_error(const char *format, ...))
......
...@@ -1247,6 +1247,14 @@ struct acpi_memory_list { ...@@ -1247,6 +1247,14 @@ struct acpi_memory_list {
#endif #endif
}; };
/* 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 */ /* Definitions of _OSI support */
#define ACPI_VENDOR_STRINGS 0x01 #define ACPI_VENDOR_STRINGS 0x01
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment