1 /* SPDX-License-Identifier: BSD-3-Clause
2  *
3  * Copyright(c) 2018 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  */
8 
9 /**
10  * \file include/ipc/trace.h
11  * \brief IPC definitions
12  * \author Liam Girdwood <liam.r.girdwood@linux.intel.com>
13  * \author Keyon Jie <yang.jie@linux.intel.com>
14  * \author Karol Trzcinski <karolx.trzcinski@linux.intel.com>
15  */
16 
17 #ifndef __IPC_TRACE_H__
18 #define __IPC_TRACE_H__
19 
20 #include <ipc/header.h>
21 #include <ipc/stream.h>
22 #include <stdint.h>
23 
24 /*
25  * DMA for Trace
26  */
27 
28 #define SOF_TRACE_FILENAME_SIZE		32
29 
30 /* DMA for Trace params info - SOF_IPC_TRACE_DMA_PARAMS */
31 /* Deprecated - use sof_ipc_dma_trace_params_ext */
32 struct sof_ipc_dma_trace_params {
33 	struct sof_ipc_cmd_hdr hdr;
34 	struct sof_ipc_host_buffer buffer;
35 	uint32_t stream_tag;
36 } __attribute__((packed, aligned(4)));
37 
38 /* DMA for Trace params info - SOF_IPC_TRACE_DMA_PARAMS_EXT */
39 struct sof_ipc_dma_trace_params_ext {
40 	struct sof_ipc_cmd_hdr hdr;
41 	struct sof_ipc_host_buffer buffer;
42 	uint32_t stream_tag;
43 	uint64_t timestamp_ns; /* in nanosecnd */
44 	uint32_t reserved[8];
45 } __attribute__((packed, aligned(4)));
46 
47 /* DMA for Trace params info - SOF_IPC_TRACE_DMA_POSITION */
48 struct sof_ipc_dma_trace_posn {
49 	struct sof_ipc_reply rhdr;
50 	uint32_t host_offset;	/* Offset of DMA host buffer */
51 	uint32_t overflow;	/* overflow bytes if any */
52 	uint32_t messages;	/* total trace messages */
53 } __attribute__((packed, aligned(4)));
54 
55 /* Values used in sof_ipc_trace_filter_elem */
56 
57 /* bits 6..0 */
58 #define SOF_IPC_TRACE_FILTER_ELEM_SET_LEVEL	0x01	/**< trace level for selected components */
59 #define SOF_IPC_TRACE_FILTER_ELEM_BY_UUID	0x02	/**< filter by uuid key */
60 #define SOF_IPC_TRACE_FILTER_ELEM_BY_COMP	0x03	/**< filter by component id */
61 #define SOF_IPC_TRACE_FILTER_ELEM_BY_PIPE	0x04	/**< filter by pipeline */
62 #define SOF_IPC_TRACE_FILTER_ELEM_TYPE_MASK	0x7F	/**< filter element type mask */
63 
64 /* bit 7 */
65 #define SOF_IPC_TRACE_FILTER_ELEM_FIN	0x80	/**< mark last filter in set */
66 
67 /* bits 31..8: Unused */
68 
69 /** part of sof_ipc_trace_filter, ABI3.17 */
70 struct sof_ipc_trace_filter_elem {
71 	int32_t key;		/**< SOF_IPC_TRACE_FILTER_ELEM_ {LEVEL, UUID, COMP, PIPE} */
72 	int32_t value;		/**< element value */
73 } __attribute__((packed, aligned(4)));
74 
75 /** Runtime tracing filtration data - SOF_IPC_TRACE_FILTER_UPDATE, ABI3.17 */
76 struct sof_ipc_trace_filter {
77 	struct sof_ipc_cmd_hdr hdr;	/**< IPC command header */
78 	uint32_t elem_cnt;		/**< number of entries in elems[] array */
79 	uint32_t reserved[8];		/**< reserved for future usage */
80 	/** variable size array with new filtering settings */
81 	struct sof_ipc_trace_filter_elem elems[];
82 } __attribute__((packed, aligned(4)));
83 
84 /*
85  * Commom debug
86  */
87 
88 /*
89  * SOF panic codes
90  */
91 #define SOF_IPC_PANIC_MAGIC			0x0dead000
92 #define SOF_IPC_PANIC_MAGIC_MASK		0x0ffff000
93 #define SOF_IPC_PANIC_CODE_MASK			0x00000fff
94 
95 #define SOF_IPC_PANIC_MEM			(SOF_IPC_PANIC_MAGIC | 0x0)
96 #define SOF_IPC_PANIC_WORK			(SOF_IPC_PANIC_MAGIC | 0x1)
97 #define SOF_IPC_PANIC_IPC			(SOF_IPC_PANIC_MAGIC | 0x2)
98 #define SOF_IPC_PANIC_ARCH			(SOF_IPC_PANIC_MAGIC | 0x3)
99 #define SOF_IPC_PANIC_PLATFORM			(SOF_IPC_PANIC_MAGIC | 0x4)
100 #define SOF_IPC_PANIC_TASK			(SOF_IPC_PANIC_MAGIC | 0x5)
101 #define SOF_IPC_PANIC_EXCEPTION			(SOF_IPC_PANIC_MAGIC | 0x6)
102 #define SOF_IPC_PANIC_DEADLOCK			(SOF_IPC_PANIC_MAGIC | 0x7)
103 #define SOF_IPC_PANIC_STACK			(SOF_IPC_PANIC_MAGIC | 0x8)
104 #define SOF_IPC_PANIC_IDLE			(SOF_IPC_PANIC_MAGIC | 0x9)
105 #define SOF_IPC_PANIC_WFI			(SOF_IPC_PANIC_MAGIC | 0xa)
106 #define SOF_IPC_PANIC_ASSERT			(SOF_IPC_PANIC_MAGIC | 0xb)
107 
108 /* panic info include filename and line number
109  * filename array will not include null terminator if fully filled
110  */
111 struct sof_ipc_panic_info {
112 	struct sof_ipc_hdr hdr;
113 	uint32_t code;			/* SOF_IPC_PANIC_ */
114 	char filename[SOF_TRACE_FILENAME_SIZE];
115 	uint32_t linenum;
116 } __attribute__((packed, aligned(4)));
117 
118 #endif /* __IPC_TRACE_H__ */
119