18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 28c2ecf20Sopenharmony_ci/* Copyright (C) 2019 Hangzhou C-SKY Microsystems co.,ltd. */ 38c2ecf20Sopenharmony_ci 48c2ecf20Sopenharmony_ci#ifndef ARCH_PERF_REGS_H 58c2ecf20Sopenharmony_ci#define ARCH_PERF_REGS_H 68c2ecf20Sopenharmony_ci 78c2ecf20Sopenharmony_ci#include <stdlib.h> 88c2ecf20Sopenharmony_ci#include <linux/types.h> 98c2ecf20Sopenharmony_ci#include <asm/perf_regs.h> 108c2ecf20Sopenharmony_ci 118c2ecf20Sopenharmony_ci#define PERF_REGS_MASK ((1ULL << PERF_REG_RISCV_MAX) - 1) 128c2ecf20Sopenharmony_ci#define PERF_REGS_MAX PERF_REG_RISCV_MAX 138c2ecf20Sopenharmony_ci#if __riscv_xlen == 64 148c2ecf20Sopenharmony_ci#define PERF_SAMPLE_REGS_ABI PERF_SAMPLE_REGS_ABI_64 158c2ecf20Sopenharmony_ci#else 168c2ecf20Sopenharmony_ci#define PERF_SAMPLE_REGS_ABI PERF_SAMPLE_REGS_ABI_32 178c2ecf20Sopenharmony_ci#endif 188c2ecf20Sopenharmony_ci 198c2ecf20Sopenharmony_ci#define PERF_REG_IP PERF_REG_RISCV_PC 208c2ecf20Sopenharmony_ci#define PERF_REG_SP PERF_REG_RISCV_SP 218c2ecf20Sopenharmony_ci 228c2ecf20Sopenharmony_cistatic inline const char *__perf_reg_name(int id) 238c2ecf20Sopenharmony_ci{ 248c2ecf20Sopenharmony_ci switch (id) { 258c2ecf20Sopenharmony_ci case PERF_REG_RISCV_PC: 268c2ecf20Sopenharmony_ci return "pc"; 278c2ecf20Sopenharmony_ci case PERF_REG_RISCV_RA: 288c2ecf20Sopenharmony_ci return "ra"; 298c2ecf20Sopenharmony_ci case PERF_REG_RISCV_SP: 308c2ecf20Sopenharmony_ci return "sp"; 318c2ecf20Sopenharmony_ci case PERF_REG_RISCV_GP: 328c2ecf20Sopenharmony_ci return "gp"; 338c2ecf20Sopenharmony_ci case PERF_REG_RISCV_TP: 348c2ecf20Sopenharmony_ci return "tp"; 358c2ecf20Sopenharmony_ci case PERF_REG_RISCV_T0: 368c2ecf20Sopenharmony_ci return "t0"; 378c2ecf20Sopenharmony_ci case PERF_REG_RISCV_T1: 388c2ecf20Sopenharmony_ci return "t1"; 398c2ecf20Sopenharmony_ci case PERF_REG_RISCV_T2: 408c2ecf20Sopenharmony_ci return "t2"; 418c2ecf20Sopenharmony_ci case PERF_REG_RISCV_S0: 428c2ecf20Sopenharmony_ci return "s0"; 438c2ecf20Sopenharmony_ci case PERF_REG_RISCV_S1: 448c2ecf20Sopenharmony_ci return "s1"; 458c2ecf20Sopenharmony_ci case PERF_REG_RISCV_A0: 468c2ecf20Sopenharmony_ci return "a0"; 478c2ecf20Sopenharmony_ci case PERF_REG_RISCV_A1: 488c2ecf20Sopenharmony_ci return "a1"; 498c2ecf20Sopenharmony_ci case PERF_REG_RISCV_A2: 508c2ecf20Sopenharmony_ci return "a2"; 518c2ecf20Sopenharmony_ci case PERF_REG_RISCV_A3: 528c2ecf20Sopenharmony_ci return "a3"; 538c2ecf20Sopenharmony_ci case PERF_REG_RISCV_A4: 548c2ecf20Sopenharmony_ci return "a4"; 558c2ecf20Sopenharmony_ci case PERF_REG_RISCV_A5: 568c2ecf20Sopenharmony_ci return "a5"; 578c2ecf20Sopenharmony_ci case PERF_REG_RISCV_A6: 588c2ecf20Sopenharmony_ci return "a6"; 598c2ecf20Sopenharmony_ci case PERF_REG_RISCV_A7: 608c2ecf20Sopenharmony_ci return "a7"; 618c2ecf20Sopenharmony_ci case PERF_REG_RISCV_S2: 628c2ecf20Sopenharmony_ci return "s2"; 638c2ecf20Sopenharmony_ci case PERF_REG_RISCV_S3: 648c2ecf20Sopenharmony_ci return "s3"; 658c2ecf20Sopenharmony_ci case PERF_REG_RISCV_S4: 668c2ecf20Sopenharmony_ci return "s4"; 678c2ecf20Sopenharmony_ci case PERF_REG_RISCV_S5: 688c2ecf20Sopenharmony_ci return "s5"; 698c2ecf20Sopenharmony_ci case PERF_REG_RISCV_S6: 708c2ecf20Sopenharmony_ci return "s6"; 718c2ecf20Sopenharmony_ci case PERF_REG_RISCV_S7: 728c2ecf20Sopenharmony_ci return "s7"; 738c2ecf20Sopenharmony_ci case PERF_REG_RISCV_S8: 748c2ecf20Sopenharmony_ci return "s8"; 758c2ecf20Sopenharmony_ci case PERF_REG_RISCV_S9: 768c2ecf20Sopenharmony_ci return "s9"; 778c2ecf20Sopenharmony_ci case PERF_REG_RISCV_S10: 788c2ecf20Sopenharmony_ci return "s10"; 798c2ecf20Sopenharmony_ci case PERF_REG_RISCV_S11: 808c2ecf20Sopenharmony_ci return "s11"; 818c2ecf20Sopenharmony_ci case PERF_REG_RISCV_T3: 828c2ecf20Sopenharmony_ci return "t3"; 838c2ecf20Sopenharmony_ci case PERF_REG_RISCV_T4: 848c2ecf20Sopenharmony_ci return "t4"; 858c2ecf20Sopenharmony_ci case PERF_REG_RISCV_T5: 868c2ecf20Sopenharmony_ci return "t5"; 878c2ecf20Sopenharmony_ci case PERF_REG_RISCV_T6: 888c2ecf20Sopenharmony_ci return "t6"; 898c2ecf20Sopenharmony_ci default: 908c2ecf20Sopenharmony_ci return NULL; 918c2ecf20Sopenharmony_ci } 928c2ecf20Sopenharmony_ci 938c2ecf20Sopenharmony_ci return NULL; 948c2ecf20Sopenharmony_ci} 958c2ecf20Sopenharmony_ci 968c2ecf20Sopenharmony_ci#endif /* ARCH_PERF_REGS_H */ 97