Sound Open Firmware
Loading...
Searching...
No Matches
trace.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: BSD-3-Clause
2 *
3 * Copyright(c) 2016 Intel Corporation. All rights reserved.
4 *
5 * Author: Liam Girdwood <liam.r.girdwood@linux.intel.com>
6 * Keyon Jie <yang.jie@linux.intel.com>
7 * Artur Kloniecki <arturx.kloniecki@linux.intel.com>
8 * Karol Trzcinski <karolx.trzcinski@linux.intel.com>
9 */
10
11#ifndef __SOF_TRACE_TRACE_H__
12#define __SOF_TRACE_TRACE_H__
13
14#ifndef RELATIVE_FILE
15#error "This file requires RELATIVE_FILE to be defined. " \
16 "Add it to CMake's target with sof_append_relative_path_definitions."
17#endif
18
19#include <rtos/sof.h>
20#include <stdbool.h>
21#include <stdint.h>
22#include <string.h>
23
24#ifdef __ZEPHYR__
25#include <zephyr/kernel.h>
26#endif
27#include <zephyr/logging/log.h>
28
29#include <sof/common.h>
30
31#if CONFIG_ZEPHYR_LOG || CONFIG_LIBRARY || CONFIG_ARCH_POSIX_LIBFUZZER
32#include <sof/lib/uuid.h>
33#endif
34#include <sof/trace/preproc.h>
36
37/* Silences compiler warnings about unused variables */
38#define trace_unused(class, ctx, id_1, id_2, format, ...) \
39 SOF_TRACE_UNUSED(ctx, id_1, id_2, ##__VA_ARGS__)
40
41#if defined(__ZEPHYR__) && defined(CONFIG_ZEPHYR_LOG)
42
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__)
47
48#elif CONFIG_TRACE
49
50#include "trace-soflogger.h"
51
52#else
53
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__)
62
63#endif
64
65#ifndef CONFIG_TRACE
66
67struct trace_filter;
68struct sof;
69
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__)
74
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__)
79
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__)
82
83#define trace_point(x) do {} while (0)
84
85static inline void trace_flush_dma_to_mbox(void) { }
86static inline void trace_on(void) { }
87static inline void trace_off(void) { }
88static inline void trace_init(struct sof *sof) { }
89static inline int trace_filter_update(const struct trace_filter *filter)
90 { return 0; }
91
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__)
96
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), \
100 fmt, ##__VA_ARGS__)
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), \
104 fmt, ##__VA_ARGS__)
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), \
108 fmt, ##__VA_ARGS__)
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), \
112 fmt, ##__VA_ARGS__)
113
114static inline void mtrace_printf(int log_level, const char *format_str, ...)
115{
116};
117
118#endif /* !CONFIG_TRACE */
119
121#define _TRACE_INV_ID -1
122
126#define _TRACE_INV_CLASS TRACE_CLASS_DEPRECATED
127
131struct sof_uuid_entry;
132struct tr_ctx {
133 const struct sof_uuid_entry *uuid_p;
134 uint32_t level;
135};
136
137#if defined(UNIT_TEST) || !defined(CONFIG_TRACE)
138#define TRACE_CONTEXT_SECTION
139#else
140#define TRACE_CONTEXT_SECTION __section(".trace_ctx")
141#endif
142
149#define DECLARE_TR_CTX(ctx_name, uuid, default_log_level) \
150 struct tr_ctx ctx_name TRACE_CONTEXT_SECTION = { \
151 .uuid_p = uuid, \
152 .level = default_log_level, \
153 }
154
155#endif /* __SOF_TRACE_TRACE_H__ */
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
Definition trace.h:132
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