forked from thesofproject/sof
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtrace.h
More file actions
162 lines (130 loc) · 5.2 KB
/
trace.h
File metadata and controls
162 lines (130 loc) · 5.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
/* SPDX-License-Identifier: BSD-3-Clause
*
* Copyright(c) 2016 Intel Corporation. All rights reserved.
*
* Author: Liam Girdwood <liam.r.girdwood@linux.intel.com>
* Keyon Jie <yang.jie@linux.intel.com>
* Artur Kloniecki <arturx.kloniecki@linux.intel.com>
* Karol Trzcinski <karolx.trzcinski@linux.intel.com>
*/
#ifndef __SOF_TRACE_TRACE_H__
#define __SOF_TRACE_TRACE_H__
#ifndef RELATIVE_FILE
#error "This file requires RELATIVE_FILE to be defined. " \
"Add it to CMake's target with sof_append_relative_path_definitions."
#endif
#include <rtos/sof.h>
#include <stdbool.h>
#include <stdint.h>
#include <string.h>
#ifdef __ZEPHYR__
#include <zephyr/kernel.h>
#include <zephyr/logging/log.h>
#endif
#if !CONFIG_LIBRARY
#include <platform/trace/trace.h>
#endif
#include <sof/common.h>
#include <sof/trace/preproc.h>
#include <sof/trace/trace-boot.h>
/* Silences compiler warnings about unused variables */
#define trace_unused(class, ctx, id_1, id_2, format, ...) \
SOF_TRACE_UNUSED(ctx, id_1, id_2, ##__VA_ARGS__)
#if defined(__ZEPHYR__) && defined(CONFIG_ZEPHYR_LOG)
#define tr_err(ctx, fmt, ...) LOG_ERR(fmt, ##__VA_ARGS__)
#define tr_warn(ctx, fmt, ...) LOG_WRN(fmt, ##__VA_ARGS__)
#define tr_info(ctx, fmt, ...) LOG_INF(fmt, ##__VA_ARGS__)
#define tr_dbg(ctx, fmt, ...) LOG_DBG(fmt, ##__VA_ARGS__)
#elif CONFIG_TRACE
#include "trace-soflogger.h"
#else
#define tr_err(ctx, fmt, ...) \
trace_unused(_TRACE_INV_CLASS, ctx, _TRACE_INV_ID, _TRACE_INV_ID, fmt, ##__VA_ARGS__)
#define tr_warn(ctx, fmt, ...) \
trace_unused(_TRACE_INV_CLASS, ctx, _TRACE_INV_ID, _TRACE_INV_ID, fmt, ##__VA_ARGS__)
#define tr_info(ctx, fmt, ...) \
trace_unused(_TRACE_INV_CLASS, ctx, _TRACE_INV_ID, _TRACE_INV_ID, fmt, ##__VA_ARGS__)
#define tr_dbg(ctx, fmt, ...) \
trace_unused(_TRACE_INV_CLASS, ctx, _TRACE_INV_ID, _TRACE_INV_ID, fmt, ##__VA_ARGS__)
#endif
#ifndef CONFIG_TRACE
struct trace_filter;
struct sof;
#define trace_event_with_ids(class, ctx, id_1, id_2, format, ...) \
trace_unused(class, ctx, id_1, id_2, format, ##__VA_ARGS__)
#define trace_event_atomic_with_ids(class, ctx, id_1, id_2, format, ...) \
trace_unused(class, ctx, id_1, id_2, format, ##__VA_ARGS__)
#define trace_warn_with_ids(class, ctx, id_1, id_2, format, ...) \
trace_unused(class, ctx, id_1, id_2, format, ##__VA_ARGS__)
#define trace_warn_atomic_with_ids(class, ctx, id_1, id_2, format, ...) \
trace_unused(class, ctx, id_1, id_2, format, ##__VA_ARGS__)
#define tracev_event_with_ids(class, ctx, id_1, id_2, format, ...) \
trace_unused(class, ctx, id_1, id_2, format, ##__VA_ARGS__)
#define trace_point(x) do {} while (0)
static inline void trace_flush_dma_to_mbox(void) { }
static inline void trace_on(void) { }
static inline void trace_off(void) { }
static inline void trace_init(struct sof *sof) { }
static inline int trace_filter_update(const struct trace_filter *filter)
{ return 0; }
#define trace_error_with_ids(class, ctx, id_1, id_2, format, ...) \
trace_unused(class, ctx, id_1, id_2, format, ##__VA_ARGS__)
#define trace_error_atomic_with_ids(class, ctx, id_1, id_2, format, ...) \
trace_unused(class, ctx, id_1, id_2, format, ##__VA_ARGS__)
#define trace_dev_err(get_ctx_m, get_id_m, get_subid_m, dev, fmt, ...) \
trace_event_with_ids(_TRACE_INV_CLASS, get_ctx_m(dev), \
get_id_m(dev), get_subid_m(dev), \
fmt, ##__VA_ARGS__)
#define trace_dev_warn(get_ctx_m, get_id_m, get_subid_m, dev, fmt, ...) \
trace_event_with_ids(_TRACE_INV_CLASS, get_ctx_m(dev), \
get_id_m(dev), get_subid_m(dev), \
fmt, ##__VA_ARGS__)
#define trace_dev_info(get_ctx_m, get_id_m, get_subid_m, dev, fmt, ...) \
trace_event_with_ids(_TRACE_INV_CLASS, get_ctx_m(dev), \
get_id_m(dev), get_subid_m(dev), \
fmt, ##__VA_ARGS__)
#define trace_dev_dbg(get_ctx_m, get_id_m, get_subid_m, dev, fmt, ...) \
trace_event_with_ids(_TRACE_INV_CLASS, get_ctx_m(dev), \
get_id_m(dev), get_subid_m(dev), \
fmt, ##__VA_ARGS__)
static inline void mtrace_printf(int log_level, const char *format_str, ...)
{
};
#endif /* !CONFIG_TRACE */
/** Default value when there is no specific pipeline, dev, dai, etc. */
#define _TRACE_INV_ID -1
/** This has been replaced in commits 6ce635aa82 and earlier by the
* DECLARE_TR_CTX, tr_ctx and component UUID system below
*/
#define _TRACE_INV_CLASS TRACE_CLASS_DEPRECATED
/**
* Trace context.
*/
struct tr_ctx {
const struct sof_uuid_entry *uuid_p; /**< UUID pointer, use SOF_UUID() to init */
uint32_t level; /**< Default log level */
};
#if defined(UNIT_TEST) || !defined(CONFIG_TRACE)
#define TRACE_CONTEXT_SECTION
#else
#define TRACE_CONTEXT_SECTION __section(".trace_ctx")
#endif
/**
* Declares trace context.
* @param ctx_name (Symbol) name.
* @param uuid UUID pointer, use SOF_UUID() to inititalize.
* @param default_log_level Default log level.
*/
#define DECLARE_TR_CTX(ctx_name, uuid, default_log_level) \
struct tr_ctx ctx_name TRACE_CONTEXT_SECTION = { \
.uuid_p = uuid, \
.level = default_log_level, \
}
/* Only define these two macros for XTOS to avoid the collision with
* zephyr/include/zephyr/logging/log.h
*/
#ifndef __ZEPHYR__
#define LOG_MODULE_REGISTER(ctx, level)
#define LOG_MODULE_DECLARE(ctx, level)
#endif
#endif /* __SOF_TRACE_TRACE_H__ */