Loading...
1/* SPDX-License-Identifier: GPL-2.0 */
2/*
3 * Copyright(C) 2015 Linaro Limited. All rights reserved.
4 * Author: Mathieu Poirier <mathieu.poirier@linaro.org>
5 */
6
7#ifndef INCLUDE__UTIL_PERF_CS_ETM_H__
8#define INCLUDE__UTIL_PERF_CS_ETM_H__
9
10#include "util/event.h"
11#include "util/session.h"
12
13/* Versionning header in case things need tro change in the future. That way
14 * decoding of old snapshot is still possible.
15 */
16enum {
17 /* Starting with 0x0 */
18 CS_HEADER_VERSION_0,
19 /* PMU->type (32 bit), total # of CPUs (32 bit) */
20 CS_PMU_TYPE_CPUS,
21 CS_ETM_SNAPSHOT,
22 CS_HEADER_VERSION_0_MAX,
23};
24
25/* Beginning of header common to both ETMv3 and V4 */
26enum {
27 CS_ETM_MAGIC,
28 CS_ETM_CPU,
29};
30
31/* ETMv3/PTM metadata */
32enum {
33 /* Dynamic, configurable parameters */
34 CS_ETM_ETMCR = CS_ETM_CPU + 1,
35 CS_ETM_ETMTRACEIDR,
36 /* RO, taken from sysFS */
37 CS_ETM_ETMCCER,
38 CS_ETM_ETMIDR,
39 CS_ETM_PRIV_MAX,
40};
41
42/* ETMv4 metadata */
43enum {
44 /* Dynamic, configurable parameters */
45 CS_ETMV4_TRCCONFIGR = CS_ETM_CPU + 1,
46 CS_ETMV4_TRCTRACEIDR,
47 /* RO, taken from sysFS */
48 CS_ETMV4_TRCIDR0,
49 CS_ETMV4_TRCIDR1,
50 CS_ETMV4_TRCIDR2,
51 CS_ETMV4_TRCIDR8,
52 CS_ETMV4_TRCAUTHSTATUS,
53 CS_ETMV4_PRIV_MAX,
54};
55
56/* RB tree for quick conversion between traceID and CPUs */
57struct intlist *traceid_list;
58
59#define KiB(x) ((x) * 1024)
60#define MiB(x) ((x) * 1024 * 1024)
61
62#define CS_ETM_HEADER_SIZE (CS_HEADER_VERSION_0_MAX * sizeof(u64))
63
64static const u64 __perf_cs_etmv3_magic = 0x3030303030303030ULL;
65static const u64 __perf_cs_etmv4_magic = 0x4040404040404040ULL;
66#define CS_ETMV3_PRIV_SIZE (CS_ETM_PRIV_MAX * sizeof(u64))
67#define CS_ETMV4_PRIV_SIZE (CS_ETMV4_PRIV_MAX * sizeof(u64))
68
69#ifdef HAVE_CSTRACE_SUPPORT
70int cs_etm__process_auxtrace_info(union perf_event *event,
71 struct perf_session *session);
72#else
73static inline int
74cs_etm__process_auxtrace_info(union perf_event *event __maybe_unused,
75 struct perf_session *session __maybe_unused)
76{
77 return -1;
78}
79#endif
80
81#endif
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/* Versionning header in case things need tro change in the future. That way
22 * decoding of old snapshot is still possible.
23 */
24enum {
25 /* Starting with 0x0 */
26 CS_HEADER_VERSION_0,
27 /* PMU->type (32 bit), total # of CPUs (32 bit) */
28 CS_PMU_TYPE_CPUS,
29 CS_ETM_SNAPSHOT,
30 CS_HEADER_VERSION_0_MAX,
31};
32
33/* Beginning of header common to both ETMv3 and V4 */
34enum {
35 CS_ETM_MAGIC,
36 CS_ETM_CPU,
37};
38
39/* ETMv3/PTM metadata */
40enum {
41 /* Dynamic, configurable parameters */
42 CS_ETM_ETMCR = CS_ETM_CPU + 1,
43 CS_ETM_ETMTRACEIDR,
44 /* RO, taken from sysFS */
45 CS_ETM_ETMCCER,
46 CS_ETM_ETMIDR,
47 CS_ETM_PRIV_MAX,
48};
49
50/* ETMv4 metadata */
51enum {
52 /* Dynamic, configurable parameters */
53 CS_ETMV4_TRCCONFIGR = CS_ETM_CPU + 1,
54 CS_ETMV4_TRCTRACEIDR,
55 /* RO, taken from sysFS */
56 CS_ETMV4_TRCIDR0,
57 CS_ETMV4_TRCIDR1,
58 CS_ETMV4_TRCIDR2,
59 CS_ETMV4_TRCIDR8,
60 CS_ETMV4_TRCAUTHSTATUS,
61 CS_ETMV4_PRIV_MAX,
62};
63
64#define KiB(x) ((x) * 1024)
65#define MiB(x) ((x) * 1024 * 1024)
66
67#define CS_ETM_HEADER_SIZE (CS_HEADER_VERSION_0_MAX * sizeof(u64))
68
69static const u64 __perf_cs_etmv3_magic = 0x3030303030303030ULL;
70static const u64 __perf_cs_etmv4_magic = 0x4040404040404040ULL;
71#define CS_ETMV3_PRIV_SIZE (CS_ETM_PRIV_MAX * sizeof(u64))
72#define CS_ETMV4_PRIV_SIZE (CS_ETMV4_PRIV_MAX * sizeof(u64))
73
74#endif