xref: /openbmc/linux/tools/perf/util/perf_regs.h (revision ff382c1c)
1b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */
22bcd355bSJiri Olsa #ifndef __PERF_REGS_H
32bcd355bSJiri Olsa #define __PERF_REGS_H
42bcd355bSJiri Olsa 
5d944c4eeSBorislav Petkov #include <linux/types.h>
69fb47654SSukadev Bhattiprolu #include <linux/compiler.h>
70c4e774fSJiri Olsa 
80c4e774fSJiri Olsa struct regs_dump;
9c9b951c4SJiri Olsa 
10c5e991eeSStephane Eranian struct sample_reg {
11c5e991eeSStephane Eranian 	const char *name;
12c5e991eeSStephane Eranian 	uint64_t mask;
13c5e991eeSStephane Eranian };
14ffc60350SGerman Gomez 
15ffc60350SGerman Gomez #define SMPL_REG_MASK(b) (1ULL << (b))
16ffc60350SGerman Gomez #define SMPL_REG(n, b) { .name = #n, .mask = SMPL_REG_MASK(b) }
17ffc60350SGerman Gomez #define SMPL_REG2_MASK(b) (3ULL << (b))
18ffc60350SGerman Gomez #define SMPL_REG2(n, b) { .name = #n, .mask = SMPL_REG2_MASK(b) }
19af4aeaddSStephane Eranian #define SMPL_REG_END { .name = NULL }
20c5e991eeSStephane Eranian 
21d451a205SRavi Bangoria enum {
22d451a205SRavi Bangoria 	SDT_ARG_VALID = 0,
23d451a205SRavi Bangoria 	SDT_ARG_SKIP,
24d451a205SRavi Bangoria };
25d451a205SRavi Bangoria 
26d451a205SRavi Bangoria int arch_sdt_arg_parse_op(char *old_op, char **new_op);
27af785e75SKan Liang uint64_t arch__intr_reg_mask(void);
28af785e75SKan Liang uint64_t arch__user_reg_mask(void);
293b1f8311SAlexis Berlemont 
3089fe808aSIngo Molnar #ifdef HAVE_PERF_REGS_SUPPORT
3142466b9fSIan Rogers extern const struct sample_reg sample_reg_masks[];
3242466b9fSIan Rogers 
3383869019SGerman Gomez const char *perf_reg_name(int id, const char *arch);
34c9b951c4SJiri Olsa int perf_reg_value(u64 *valp, struct regs_dump *regs, int id);
3534af56afSLeo Yan uint64_t perf_arch_reg_ip(const char *arch);
3634af56afSLeo Yan uint64_t perf_arch_reg_sp(const char *arch);
375000e7f6SLeo Yan const char *__perf_reg_name_arm64(int id);
3834af56afSLeo Yan uint64_t __perf_reg_ip_arm64(void);
3934af56afSLeo Yan uint64_t __perf_reg_sp_arm64(void);
405000e7f6SLeo Yan const char *__perf_reg_name_arm(int id);
4134af56afSLeo Yan uint64_t __perf_reg_ip_arm(void);
4234af56afSLeo Yan uint64_t __perf_reg_sp_arm(void);
435000e7f6SLeo Yan const char *__perf_reg_name_csky(int id);
4434af56afSLeo Yan uint64_t __perf_reg_ip_csky(void);
4534af56afSLeo Yan uint64_t __perf_reg_sp_csky(void);
465000e7f6SLeo Yan const char *__perf_reg_name_loongarch(int id);
4734af56afSLeo Yan uint64_t __perf_reg_ip_loongarch(void);
4834af56afSLeo Yan uint64_t __perf_reg_sp_loongarch(void);
495000e7f6SLeo Yan const char *__perf_reg_name_mips(int id);
5034af56afSLeo Yan uint64_t __perf_reg_ip_mips(void);
5134af56afSLeo Yan uint64_t __perf_reg_sp_mips(void);
525000e7f6SLeo Yan const char *__perf_reg_name_powerpc(int id);
5334af56afSLeo Yan uint64_t __perf_reg_ip_powerpc(void);
5434af56afSLeo Yan uint64_t __perf_reg_sp_powerpc(void);
555000e7f6SLeo Yan const char *__perf_reg_name_riscv(int id);
5634af56afSLeo Yan uint64_t __perf_reg_ip_riscv(void);
5734af56afSLeo Yan uint64_t __perf_reg_sp_riscv(void);
585000e7f6SLeo Yan const char *__perf_reg_name_s390(int id);
5934af56afSLeo Yan uint64_t __perf_reg_ip_s390(void);
6034af56afSLeo Yan uint64_t __perf_reg_sp_s390(void);
615000e7f6SLeo Yan const char *__perf_reg_name_x86(int id);
6234af56afSLeo Yan uint64_t __perf_reg_ip_x86(void);
6334af56afSLeo Yan uint64_t __perf_reg_sp_x86(void);
6434af56afSLeo Yan 
DWARF_MINIMAL_REGS(const char * arch)6534af56afSLeo Yan static inline uint64_t DWARF_MINIMAL_REGS(const char *arch)
6634af56afSLeo Yan {
6734af56afSLeo Yan 	return (1ULL << perf_arch_reg_ip(arch)) | (1ULL << perf_arch_reg_sp(arch));
6834af56afSLeo Yan }
69c9b951c4SJiri Olsa 
702bcd355bSJiri Olsa #else
712bcd355bSJiri Olsa 
DWARF_MINIMAL_REGS(const char * arch __maybe_unused)7234af56afSLeo Yan static inline uint64_t DWARF_MINIMAL_REGS(const char *arch __maybe_unused)
7334af56afSLeo Yan {
74*856caabfSLeo Yan 	return 0;
7534af56afSLeo Yan }
76d194d8fcSAlexey Budankov 
perf_reg_name(int id __maybe_unused,const char * arch __maybe_unused)7783869019SGerman Gomez static inline const char *perf_reg_name(int id __maybe_unused, const char *arch __maybe_unused)
782bcd355bSJiri Olsa {
795b596e0fSArnaldo Carvalho de Melo 	return "unknown";
802bcd355bSJiri Olsa }
81c9b951c4SJiri Olsa 
perf_reg_value(u64 * valp __maybe_unused,struct regs_dump * regs __maybe_unused,int id __maybe_unused)82c9b951c4SJiri Olsa static inline int perf_reg_value(u64 *valp __maybe_unused,
83c9b951c4SJiri Olsa 				 struct regs_dump *regs __maybe_unused,
84c9b951c4SJiri Olsa 				 int id __maybe_unused)
85c9b951c4SJiri Olsa {
86c9b951c4SJiri Olsa 	return 0;
87c9b951c4SJiri Olsa }
8834af56afSLeo Yan 
perf_arch_reg_ip(const char * arch __maybe_unused)8934af56afSLeo Yan static inline uint64_t perf_arch_reg_ip(const char *arch __maybe_unused)
9034af56afSLeo Yan {
9134af56afSLeo Yan 	return 0;
9234af56afSLeo Yan }
9334af56afSLeo Yan 
perf_arch_reg_sp(const char * arch __maybe_unused)9434af56afSLeo Yan static inline uint64_t perf_arch_reg_sp(const char *arch __maybe_unused)
9534af56afSLeo Yan {
9634af56afSLeo Yan 	return 0;
9734af56afSLeo Yan }
9834af56afSLeo Yan 
9989fe808aSIngo Molnar #endif /* HAVE_PERF_REGS_SUPPORT */
1002bcd355bSJiri Olsa #endif /* __PERF_REGS_H */
101