11#ifndef __SOF_TRACE_TRACE_H__
12#define __SOF_TRACE_TRACE_H__
15#error "This file requires RELATIVE_FILE to be defined. " \
16 "Add it to CMake's target with sof_append_relative_path_definitions."
25#include <zephyr/kernel.h>
27#include <zephyr/logging/log.h>
31#if CONFIG_ZEPHYR_LOG || CONFIG_LIBRARY || CONFIG_ARCH_POSIX_LIBFUZZER
38#define trace_unused(class, ctx, id_1, id_2, format, ...) \
39 SOF_TRACE_UNUSED(ctx, id_1, id_2, ##__VA_ARGS__)
41#if defined(__ZEPHYR__) && defined(CONFIG_ZEPHYR_LOG)
43#define tr_err(ctx, fmt, ...) LOG_ERR(fmt, ##__VA_ARGS__)
44#define tr_warn(ctx, fmt, ...) LOG_WRN(fmt, ##__VA_ARGS__)
45#define tr_info(ctx, fmt, ...) LOG_INF(fmt, ##__VA_ARGS__)
46#define tr_dbg(ctx, fmt, ...) LOG_DBG(fmt, ##__VA_ARGS__)
54#define tr_err(ctx, fmt, ...) \
55 trace_unused(_TRACE_INV_CLASS, ctx, _TRACE_INV_ID, _TRACE_INV_ID, fmt, ##__VA_ARGS__)
56#define tr_warn(ctx, fmt, ...) \
57 trace_unused(_TRACE_INV_CLASS, ctx, _TRACE_INV_ID, _TRACE_INV_ID, fmt, ##__VA_ARGS__)
58#define tr_info(ctx, fmt, ...) \
59 trace_unused(_TRACE_INV_CLASS, ctx, _TRACE_INV_ID, _TRACE_INV_ID, fmt, ##__VA_ARGS__)
60#define tr_dbg(ctx, fmt, ...) \
61 trace_unused(_TRACE_INV_CLASS, ctx, _TRACE_INV_ID, _TRACE_INV_ID, fmt, ##__VA_ARGS__)
70#define trace_event_with_ids(class, ctx, id_1, id_2, format, ...) \
71 trace_unused(class, ctx, id_1, id_2, format, ##__VA_ARGS__)
72#define trace_event_atomic_with_ids(class, ctx, id_1, id_2, format, ...) \
73 trace_unused(class, ctx, id_1, id_2, format, ##__VA_ARGS__)
75#define trace_warn_with_ids(class, ctx, id_1, id_2, format, ...) \
76 trace_unused(class, ctx, id_1, id_2, format, ##__VA_ARGS__)
77#define trace_warn_atomic_with_ids(class, ctx, id_1, id_2, format, ...) \
78 trace_unused(class, ctx, id_1, id_2, format, ##__VA_ARGS__)
80#define tracev_event_with_ids(class, ctx, id_1, id_2, format, ...) \
81 trace_unused(class, ctx, id_1, id_2, format, ##__VA_ARGS__)
83#define trace_point(x) do {} while (0)
92#define trace_error_with_ids(class, ctx, id_1, id_2, format, ...) \
93 trace_unused(class, ctx, id_1, id_2, format, ##__VA_ARGS__)
94#define trace_error_atomic_with_ids(class, ctx, id_1, id_2, format, ...) \
95 trace_unused(class, ctx, id_1, id_2, format, ##__VA_ARGS__)
97#define trace_dev_err(get_ctx_m, get_id_m, get_subid_m, dev, fmt, ...) \
98 trace_event_with_ids(_TRACE_INV_CLASS, get_ctx_m(dev), \
99 get_id_m(dev), get_subid_m(dev), \
101#define trace_dev_warn(get_ctx_m, get_id_m, get_subid_m, dev, fmt, ...) \
102 trace_event_with_ids(_TRACE_INV_CLASS, get_ctx_m(dev), \
103 get_id_m(dev), get_subid_m(dev), \
105#define trace_dev_info(get_ctx_m, get_id_m, get_subid_m, dev, fmt, ...) \
106 trace_event_with_ids(_TRACE_INV_CLASS, get_ctx_m(dev), \
107 get_id_m(dev), get_subid_m(dev), \
109#define trace_dev_dbg(get_ctx_m, get_id_m, get_subid_m, dev, fmt, ...) \
110 trace_event_with_ids(_TRACE_INV_CLASS, get_ctx_m(dev), \
111 get_id_m(dev), get_subid_m(dev), \
114static inline void mtrace_printf(
int log_level,
const char *format_str, ...)
121#define _TRACE_INV_ID -1
126#define _TRACE_INV_CLASS TRACE_CLASS_DEPRECATED
137#if defined(UNIT_TEST) || !defined(CONFIG_TRACE)
138#define TRACE_CONTEXT_SECTION
140#define TRACE_CONTEXT_SECTION __section(".trace_ctx")
149#define DECLARE_TR_CTX(ctx_name, uuid, default_log_level) \
150 struct tr_ctx ctx_name TRACE_CONTEXT_SECTION = { \
152 .level = default_log_level, \
void trace_flush_dma_to_mbox(void)
Flush buffered trace data from DMA buffer to Mailbox Window.
void trace_init(struct sof *sof)
Initialize the trace subsystem and allocate global trace buffers.
int trace_filter_update(const struct trace_filter *elem)
Update runtime trace filtering configuration from IPC payload.
void trace_off(void)
Globally pause trace event logging.
void trace_on(void)
Globally resume trace event logging.
Sound Open Firmware global runtime context.
Connects UUID with component description.
Definition uuid.h:77
General firmware context.
Definition sof.h:50
uint32_t level
Default log level.
Definition trace.h:134
const struct sof_uuid_entry * uuid_p
UUID pointer, use SOF_UUID() to init.
Definition trace.h:133
Runtime trace filter criteria for components and pipelines.
Definition trace-soflogger.h:31
Early bootloader, architecture, and peripheral initialization trace checkpoint codes.
Dictionary-based trace logging engine, log filtering, and mailbox trace fallback.
#define mtrace_printf(log_level, format_str,...)
Direct, low-level access to mbox / shared memory logging when DMA tracing is either not initialized y...
Definition trace-soflogger.h:464