]> asedeno.scripts.mit.edu Git - linux.git/blob - tools/perf/util/cs-etm.h
perf tools: Add processing of coresight metadata
[linux.git] / tools / perf / util / cs-etm.h
1 /*
2  * Copyright(C) 2015 Linaro Limited. All rights reserved.
3  * Author: Mathieu Poirier <mathieu.poirier@linaro.org>
4  *
5  * This program is free software; you can redistribute it and/or modify it
6  * under the terms of the GNU General Public License version 2 as published by
7  * the Free Software Foundation.
8  *
9  * This program is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
12  * more details.
13  *
14  * You should have received a copy of the GNU General Public License along with
15  * this program.  If not, see <http://www.gnu.org/licenses/>.
16  */
17
18 #ifndef INCLUDE__UTIL_PERF_CS_ETM_H__
19 #define INCLUDE__UTIL_PERF_CS_ETM_H__
20
21 #include "util/event.h"
22 #include "util/session.h"
23
24 /* Versionning header in case things need tro change in the future.  That way
25  * decoding of old snapshot is still possible.
26  */
27 enum {
28         /* Starting with 0x0 */
29         CS_HEADER_VERSION_0,
30         /* PMU->type (32 bit), total # of CPUs (32 bit) */
31         CS_PMU_TYPE_CPUS,
32         CS_ETM_SNAPSHOT,
33         CS_HEADER_VERSION_0_MAX,
34 };
35
36 /* Beginning of header common to both ETMv3 and V4 */
37 enum {
38         CS_ETM_MAGIC,
39         CS_ETM_CPU,
40 };
41
42 /* ETMv3/PTM metadata */
43 enum {
44         /* Dynamic, configurable parameters */
45         CS_ETM_ETMCR = CS_ETM_CPU + 1,
46         CS_ETM_ETMTRACEIDR,
47         /* RO, taken from sysFS */
48         CS_ETM_ETMCCER,
49         CS_ETM_ETMIDR,
50         CS_ETM_PRIV_MAX,
51 };
52
53 /* ETMv4 metadata */
54 enum {
55         /* Dynamic, configurable parameters */
56         CS_ETMV4_TRCCONFIGR = CS_ETM_CPU + 1,
57         CS_ETMV4_TRCTRACEIDR,
58         /* RO, taken from sysFS */
59         CS_ETMV4_TRCIDR0,
60         CS_ETMV4_TRCIDR1,
61         CS_ETMV4_TRCIDR2,
62         CS_ETMV4_TRCIDR8,
63         CS_ETMV4_TRCAUTHSTATUS,
64         CS_ETMV4_PRIV_MAX,
65 };
66
67 /* RB tree for quick conversion between traceID and CPUs */
68 struct intlist *traceid_list;
69
70 #define KiB(x) ((x) * 1024)
71 #define MiB(x) ((x) * 1024 * 1024)
72
73 #define CS_ETM_HEADER_SIZE (CS_HEADER_VERSION_0_MAX * sizeof(u64))
74
75 static const u64 __perf_cs_etmv3_magic   = 0x3030303030303030ULL;
76 static const u64 __perf_cs_etmv4_magic   = 0x4040404040404040ULL;
77 #define CS_ETMV3_PRIV_SIZE (CS_ETM_PRIV_MAX * sizeof(u64))
78 #define CS_ETMV4_PRIV_SIZE (CS_ETMV4_PRIV_MAX * sizeof(u64))
79
80 #ifdef HAVE_CSTRACE_SUPPORT
81 int cs_etm__process_auxtrace_info(union perf_event *event,
82                                   struct perf_session *session);
83 #else
84 static inline int
85 cs_etm__process_auxtrace_info(union perf_event *event __maybe_unused,
86                               struct perf_session *session __maybe_unused)
87 {
88         return -1;
89 }
90 #endif
91
92 #endif