18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
28c2ecf20Sopenharmony_ci#ifndef ARCH_PERF_REGS_H
38c2ecf20Sopenharmony_ci#define ARCH_PERF_REGS_H
48c2ecf20Sopenharmony_ci
58c2ecf20Sopenharmony_ci#include <stdlib.h>
68c2ecf20Sopenharmony_ci#include <linux/types.h>
78c2ecf20Sopenharmony_ci#include <asm/perf_regs.h>
88c2ecf20Sopenharmony_ci
98c2ecf20Sopenharmony_civoid perf_regs_load(u64 *regs);
108c2ecf20Sopenharmony_ci
118c2ecf20Sopenharmony_ci#define PERF_REGS_MASK  ((1ULL << PERF_REG_POWERPC_MAX) - 1)
128c2ecf20Sopenharmony_ci#define PERF_REGS_MAX   PERF_REG_POWERPC_MAX
138c2ecf20Sopenharmony_ci#ifdef __powerpc64__
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_POWERPC_NIP
208c2ecf20Sopenharmony_ci#define PERF_REG_SP     PERF_REG_POWERPC_R1
218c2ecf20Sopenharmony_ci
228c2ecf20Sopenharmony_cistatic const char *reg_names[] = {
238c2ecf20Sopenharmony_ci	[PERF_REG_POWERPC_R0] = "r0",
248c2ecf20Sopenharmony_ci	[PERF_REG_POWERPC_R1] = "r1",
258c2ecf20Sopenharmony_ci	[PERF_REG_POWERPC_R2] = "r2",
268c2ecf20Sopenharmony_ci	[PERF_REG_POWERPC_R3] = "r3",
278c2ecf20Sopenharmony_ci	[PERF_REG_POWERPC_R4] = "r4",
288c2ecf20Sopenharmony_ci	[PERF_REG_POWERPC_R5] = "r5",
298c2ecf20Sopenharmony_ci	[PERF_REG_POWERPC_R6] = "r6",
308c2ecf20Sopenharmony_ci	[PERF_REG_POWERPC_R7] = "r7",
318c2ecf20Sopenharmony_ci	[PERF_REG_POWERPC_R8] = "r8",
328c2ecf20Sopenharmony_ci	[PERF_REG_POWERPC_R9] = "r9",
338c2ecf20Sopenharmony_ci	[PERF_REG_POWERPC_R10] = "r10",
348c2ecf20Sopenharmony_ci	[PERF_REG_POWERPC_R11] = "r11",
358c2ecf20Sopenharmony_ci	[PERF_REG_POWERPC_R12] = "r12",
368c2ecf20Sopenharmony_ci	[PERF_REG_POWERPC_R13] = "r13",
378c2ecf20Sopenharmony_ci	[PERF_REG_POWERPC_R14] = "r14",
388c2ecf20Sopenharmony_ci	[PERF_REG_POWERPC_R15] = "r15",
398c2ecf20Sopenharmony_ci	[PERF_REG_POWERPC_R16] = "r16",
408c2ecf20Sopenharmony_ci	[PERF_REG_POWERPC_R17] = "r17",
418c2ecf20Sopenharmony_ci	[PERF_REG_POWERPC_R18] = "r18",
428c2ecf20Sopenharmony_ci	[PERF_REG_POWERPC_R19] = "r19",
438c2ecf20Sopenharmony_ci	[PERF_REG_POWERPC_R20] = "r20",
448c2ecf20Sopenharmony_ci	[PERF_REG_POWERPC_R21] = "r21",
458c2ecf20Sopenharmony_ci	[PERF_REG_POWERPC_R22] = "r22",
468c2ecf20Sopenharmony_ci	[PERF_REG_POWERPC_R23] = "r23",
478c2ecf20Sopenharmony_ci	[PERF_REG_POWERPC_R24] = "r24",
488c2ecf20Sopenharmony_ci	[PERF_REG_POWERPC_R25] = "r25",
498c2ecf20Sopenharmony_ci	[PERF_REG_POWERPC_R26] = "r26",
508c2ecf20Sopenharmony_ci	[PERF_REG_POWERPC_R27] = "r27",
518c2ecf20Sopenharmony_ci	[PERF_REG_POWERPC_R28] = "r28",
528c2ecf20Sopenharmony_ci	[PERF_REG_POWERPC_R29] = "r29",
538c2ecf20Sopenharmony_ci	[PERF_REG_POWERPC_R30] = "r30",
548c2ecf20Sopenharmony_ci	[PERF_REG_POWERPC_R31] = "r31",
558c2ecf20Sopenharmony_ci	[PERF_REG_POWERPC_NIP] = "nip",
568c2ecf20Sopenharmony_ci	[PERF_REG_POWERPC_MSR] = "msr",
578c2ecf20Sopenharmony_ci	[PERF_REG_POWERPC_ORIG_R3] = "orig_r3",
588c2ecf20Sopenharmony_ci	[PERF_REG_POWERPC_CTR] = "ctr",
598c2ecf20Sopenharmony_ci	[PERF_REG_POWERPC_LINK] = "link",
608c2ecf20Sopenharmony_ci	[PERF_REG_POWERPC_XER] = "xer",
618c2ecf20Sopenharmony_ci	[PERF_REG_POWERPC_CCR] = "ccr",
628c2ecf20Sopenharmony_ci	[PERF_REG_POWERPC_SOFTE] = "softe",
638c2ecf20Sopenharmony_ci	[PERF_REG_POWERPC_TRAP] = "trap",
648c2ecf20Sopenharmony_ci	[PERF_REG_POWERPC_DAR] = "dar",
658c2ecf20Sopenharmony_ci	[PERF_REG_POWERPC_DSISR] = "dsisr",
668c2ecf20Sopenharmony_ci	[PERF_REG_POWERPC_SIER] = "sier",
678c2ecf20Sopenharmony_ci	[PERF_REG_POWERPC_MMCRA] = "mmcra",
688c2ecf20Sopenharmony_ci	[PERF_REG_POWERPC_MMCR0] = "mmcr0",
698c2ecf20Sopenharmony_ci	[PERF_REG_POWERPC_MMCR1] = "mmcr1",
708c2ecf20Sopenharmony_ci	[PERF_REG_POWERPC_MMCR2] = "mmcr2",
718c2ecf20Sopenharmony_ci	[PERF_REG_POWERPC_MMCR3] = "mmcr3",
728c2ecf20Sopenharmony_ci	[PERF_REG_POWERPC_SIER2] = "sier2",
738c2ecf20Sopenharmony_ci	[PERF_REG_POWERPC_SIER3] = "sier3",
748c2ecf20Sopenharmony_ci};
758c2ecf20Sopenharmony_ci
768c2ecf20Sopenharmony_cistatic inline const char *__perf_reg_name(int id)
778c2ecf20Sopenharmony_ci{
788c2ecf20Sopenharmony_ci	return reg_names[id];
798c2ecf20Sopenharmony_ci}
808c2ecf20Sopenharmony_ci#endif /* ARCH_PERF_REGS_H */
81