162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 262306a36Sopenharmony_ci#ifndef __PERF_REGS_H 362306a36Sopenharmony_ci#define __PERF_REGS_H 462306a36Sopenharmony_ci 562306a36Sopenharmony_ci#include <linux/types.h> 662306a36Sopenharmony_ci#include <linux/compiler.h> 762306a36Sopenharmony_ci 862306a36Sopenharmony_cistruct regs_dump; 962306a36Sopenharmony_ci 1062306a36Sopenharmony_cistruct sample_reg { 1162306a36Sopenharmony_ci const char *name; 1262306a36Sopenharmony_ci uint64_t mask; 1362306a36Sopenharmony_ci}; 1462306a36Sopenharmony_ci 1562306a36Sopenharmony_ci#define SMPL_REG_MASK(b) (1ULL << (b)) 1662306a36Sopenharmony_ci#define SMPL_REG(n, b) { .name = #n, .mask = SMPL_REG_MASK(b) } 1762306a36Sopenharmony_ci#define SMPL_REG2_MASK(b) (3ULL << (b)) 1862306a36Sopenharmony_ci#define SMPL_REG2(n, b) { .name = #n, .mask = SMPL_REG2_MASK(b) } 1962306a36Sopenharmony_ci#define SMPL_REG_END { .name = NULL } 2062306a36Sopenharmony_ci 2162306a36Sopenharmony_cienum { 2262306a36Sopenharmony_ci SDT_ARG_VALID = 0, 2362306a36Sopenharmony_ci SDT_ARG_SKIP, 2462306a36Sopenharmony_ci}; 2562306a36Sopenharmony_ci 2662306a36Sopenharmony_ciint arch_sdt_arg_parse_op(char *old_op, char **new_op); 2762306a36Sopenharmony_ciuint64_t arch__intr_reg_mask(void); 2862306a36Sopenharmony_ciuint64_t arch__user_reg_mask(void); 2962306a36Sopenharmony_ci 3062306a36Sopenharmony_ci#ifdef HAVE_PERF_REGS_SUPPORT 3162306a36Sopenharmony_ciextern const struct sample_reg sample_reg_masks[]; 3262306a36Sopenharmony_ci 3362306a36Sopenharmony_ciconst char *perf_reg_name(int id, const char *arch); 3462306a36Sopenharmony_ciint perf_reg_value(u64 *valp, struct regs_dump *regs, int id); 3562306a36Sopenharmony_ciuint64_t perf_arch_reg_ip(const char *arch); 3662306a36Sopenharmony_ciuint64_t perf_arch_reg_sp(const char *arch); 3762306a36Sopenharmony_ciconst char *__perf_reg_name_arm64(int id); 3862306a36Sopenharmony_ciuint64_t __perf_reg_ip_arm64(void); 3962306a36Sopenharmony_ciuint64_t __perf_reg_sp_arm64(void); 4062306a36Sopenharmony_ciconst char *__perf_reg_name_arm(int id); 4162306a36Sopenharmony_ciuint64_t __perf_reg_ip_arm(void); 4262306a36Sopenharmony_ciuint64_t __perf_reg_sp_arm(void); 4362306a36Sopenharmony_ciconst char *__perf_reg_name_csky(int id); 4462306a36Sopenharmony_ciuint64_t __perf_reg_ip_csky(void); 4562306a36Sopenharmony_ciuint64_t __perf_reg_sp_csky(void); 4662306a36Sopenharmony_ciconst char *__perf_reg_name_loongarch(int id); 4762306a36Sopenharmony_ciuint64_t __perf_reg_ip_loongarch(void); 4862306a36Sopenharmony_ciuint64_t __perf_reg_sp_loongarch(void); 4962306a36Sopenharmony_ciconst char *__perf_reg_name_mips(int id); 5062306a36Sopenharmony_ciuint64_t __perf_reg_ip_mips(void); 5162306a36Sopenharmony_ciuint64_t __perf_reg_sp_mips(void); 5262306a36Sopenharmony_ciconst char *__perf_reg_name_powerpc(int id); 5362306a36Sopenharmony_ciuint64_t __perf_reg_ip_powerpc(void); 5462306a36Sopenharmony_ciuint64_t __perf_reg_sp_powerpc(void); 5562306a36Sopenharmony_ciconst char *__perf_reg_name_riscv(int id); 5662306a36Sopenharmony_ciuint64_t __perf_reg_ip_riscv(void); 5762306a36Sopenharmony_ciuint64_t __perf_reg_sp_riscv(void); 5862306a36Sopenharmony_ciconst char *__perf_reg_name_s390(int id); 5962306a36Sopenharmony_ciuint64_t __perf_reg_ip_s390(void); 6062306a36Sopenharmony_ciuint64_t __perf_reg_sp_s390(void); 6162306a36Sopenharmony_ciconst char *__perf_reg_name_x86(int id); 6262306a36Sopenharmony_ciuint64_t __perf_reg_ip_x86(void); 6362306a36Sopenharmony_ciuint64_t __perf_reg_sp_x86(void); 6462306a36Sopenharmony_ci 6562306a36Sopenharmony_cistatic inline uint64_t DWARF_MINIMAL_REGS(const char *arch) 6662306a36Sopenharmony_ci{ 6762306a36Sopenharmony_ci return (1ULL << perf_arch_reg_ip(arch)) | (1ULL << perf_arch_reg_sp(arch)); 6862306a36Sopenharmony_ci} 6962306a36Sopenharmony_ci 7062306a36Sopenharmony_ci#else 7162306a36Sopenharmony_ci 7262306a36Sopenharmony_cistatic inline uint64_t DWARF_MINIMAL_REGS(const char *arch __maybe_unused) 7362306a36Sopenharmony_ci{ 7462306a36Sopenharmony_ci return 0; 7562306a36Sopenharmony_ci} 7662306a36Sopenharmony_ci 7762306a36Sopenharmony_cistatic inline const char *perf_reg_name(int id __maybe_unused, const char *arch __maybe_unused) 7862306a36Sopenharmony_ci{ 7962306a36Sopenharmony_ci return "unknown"; 8062306a36Sopenharmony_ci} 8162306a36Sopenharmony_ci 8262306a36Sopenharmony_cistatic inline int perf_reg_value(u64 *valp __maybe_unused, 8362306a36Sopenharmony_ci struct regs_dump *regs __maybe_unused, 8462306a36Sopenharmony_ci int id __maybe_unused) 8562306a36Sopenharmony_ci{ 8662306a36Sopenharmony_ci return 0; 8762306a36Sopenharmony_ci} 8862306a36Sopenharmony_ci 8962306a36Sopenharmony_cistatic inline uint64_t perf_arch_reg_ip(const char *arch __maybe_unused) 9062306a36Sopenharmony_ci{ 9162306a36Sopenharmony_ci return 0; 9262306a36Sopenharmony_ci} 9362306a36Sopenharmony_ci 9462306a36Sopenharmony_cistatic inline uint64_t perf_arch_reg_sp(const char *arch __maybe_unused) 9562306a36Sopenharmony_ci{ 9662306a36Sopenharmony_ci return 0; 9762306a36Sopenharmony_ci} 9862306a36Sopenharmony_ci 9962306a36Sopenharmony_ci#endif /* HAVE_PERF_REGS_SUPPORT */ 10062306a36Sopenharmony_ci#endif /* __PERF_REGS_H */ 101