1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Copyright(C) 2015 Linaro Limited. All rights reserved.
4 * Author: Mathieu Poirier <mathieu.poirier@linaro.org>
7 #ifndef INCLUDE__UTIL_PERF_CS_ETM_H__
8 #define INCLUDE__UTIL_PERF_CS_ETM_H__
10 #include "util/event.h"
11 #include "util/session.h"
13 /* Versionning header in case things need tro change in the future. That way
14 * decoding of old snapshot is still possible.
17 /* Starting with 0x0 */
19 /* PMU->type (32 bit), total # of CPUs (32 bit) */
22 CS_HEADER_VERSION_0_MAX
,
25 /* Beginning of header common to both ETMv3 and V4 */
31 /* ETMv3/PTM metadata */
33 /* Dynamic, configurable parameters */
34 CS_ETM_ETMCR
= CS_ETM_CPU
+ 1,
36 /* RO, taken from sysFS */
44 /* Dynamic, configurable parameters */
45 CS_ETMV4_TRCCONFIGR
= CS_ETM_CPU
+ 1,
47 /* RO, taken from sysFS */
52 CS_ETMV4_TRCAUTHSTATUS
,
57 * ETMv3 exception encoding number:
58 * See Embedded Trace Macrocell spcification (ARM IHI 0014Q)
59 * table 7-12 Encoding of Exception[3:0] for non-ARMv7-M processors.
62 CS_ETMV3_EXC_NONE
= 0,
63 CS_ETMV3_EXC_DEBUG_HALT
= 1,
66 CS_ETMV3_EXC_ASYNC_DATA_ABORT
= 4,
67 CS_ETMV3_EXC_JAZELLE_THUMBEE
= 5,
68 CS_ETMV3_EXC_PE_RESET
= 8,
69 CS_ETMV3_EXC_UNDEFINED_INSTR
= 9,
70 CS_ETMV3_EXC_SVC
= 10,
71 CS_ETMV3_EXC_PREFETCH_ABORT
= 11,
72 CS_ETMV3_EXC_DATA_FAULT
= 12,
73 CS_ETMV3_EXC_GENERIC
= 13,
74 CS_ETMV3_EXC_IRQ
= 14,
75 CS_ETMV3_EXC_FIQ
= 15,
79 * ETMv4 exception encoding number:
80 * See ARM Embedded Trace Macrocell Architecture Specification (ARM IHI 0064D)
81 * table 6-12 Possible values for the TYPE field in an Exception instruction
82 * trace packet, for ARMv7-A/R and ARMv8-A/R PEs.
85 CS_ETMV4_EXC_RESET
= 0,
86 CS_ETMV4_EXC_DEBUG_HALT
= 1,
87 CS_ETMV4_EXC_CALL
= 2,
88 CS_ETMV4_EXC_TRAP
= 3,
89 CS_ETMV4_EXC_SYSTEM_ERROR
= 4,
90 CS_ETMV4_EXC_INST_DEBUG
= 6,
91 CS_ETMV4_EXC_DATA_DEBUG
= 7,
92 CS_ETMV4_EXC_ALIGNMENT
= 10,
93 CS_ETMV4_EXC_INST_FAULT
= 11,
94 CS_ETMV4_EXC_DATA_FAULT
= 12,
95 CS_ETMV4_EXC_IRQ
= 14,
96 CS_ETMV4_EXC_FIQ
= 15,
97 CS_ETMV4_EXC_END
= 31,
100 /* RB tree for quick conversion between traceID and metadata pointers */
101 struct intlist
*traceid_list
;
103 #define KiB(x) ((x) * 1024)
104 #define MiB(x) ((x) * 1024 * 1024)
106 #define CS_ETM_HEADER_SIZE (CS_HEADER_VERSION_0_MAX * sizeof(u64))
108 #define __perf_cs_etmv3_magic 0x3030303030303030ULL
109 #define __perf_cs_etmv4_magic 0x4040404040404040ULL
110 #define CS_ETMV3_PRIV_SIZE (CS_ETM_PRIV_MAX * sizeof(u64))
111 #define CS_ETMV4_PRIV_SIZE (CS_ETMV4_PRIV_MAX * sizeof(u64))
113 #ifdef HAVE_CSTRACE_SUPPORT
114 int cs_etm__process_auxtrace_info(union perf_event
*event
,
115 struct perf_session
*session
);
116 int cs_etm__get_cpu(u8 trace_chan_id
, int *cpu
);
119 cs_etm__process_auxtrace_info(union perf_event
*event __maybe_unused
,
120 struct perf_session
*session __maybe_unused
)
125 static inline int cs_etm__get_cpu(u8 trace_chan_id __maybe_unused
,
126 int *cpu __maybe_unused
)