aboutsummaryrefslogtreecommitdiff
path: root/sys/arm64/spe/arm_spe.h
blob: 5dba20673a77368470f1c29a210a411c77fad607 (plain) (blame)
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
/*-
 * SPDX-License-Identifier: BSD-2-Clause
 *
 * Copyright (c) 2024 Arm Ltd
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 */

#ifndef _ARM64_ARM_SPE_H_
#define _ARM64_ARM_SPE_H_

/* kqueue events */
#define ARM_SPE_KQ_BUF		138
#define ARM_SPE_KQ_SHUTDOWN	139
#define ARM_SPE_KQ_SIGNAL	140

/* spe_backend_read() u64 data encoding */
#define KQ_BUF_POS_SHIFT	0
#define KQ_BUF_POS		(1 << KQ_BUF_POS_SHIFT)
#define KQ_PARTREC_SHIFT	1
#define KQ_PARTREC		(1 << KQ_PARTREC_SHIFT)
#define KQ_FINAL_BUF_SHIFT	2
#define KQ_FINAL_BUF		(1 << KQ_FINAL_BUF_SHIFT)

enum arm_spe_ctx_field {
	ARM_SPE_CTX_NONE,
	ARM_SPE_CTX_PID,
	ARM_SPE_CTX_CPU_ID
};

enum arm_spe_profiling_level {
	ARM_SPE_KERNEL_AND_USER,
	ARM_SPE_KERNEL_ONLY,
	ARM_SPE_USER_ONLY
};
struct arm_spe_config {
	/* Minimum interval is IMP DEF up to maximum 24 bit value */
	uint32_t interval;

	/* Profile kernel (EL1), userspace (EL0) or both */
	enum arm_spe_profiling_level level;

	/*
	 * Configure context field in SPE records to store either the
	 * current PID, the CPU ID or neither
	 *
	 * In PID mode, kernel threads without a process context are
	 * logged as PID 0
	 */
	enum arm_spe_ctx_field ctx_field;
};

struct arm_spe_svc_buf {
	uint32_t ident;
	uint8_t buf_idx : 1;
};

#endif /* _ARM64_ARM_SPE_H_ */