162306a36Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-or-later 262306a36Sopenharmony_ci/* 362306a36Sopenharmony_ci * Copyright 2016 Chandan Kumar, IBM Corporation. 462306a36Sopenharmony_ci */ 562306a36Sopenharmony_ci 662306a36Sopenharmony_ci#include <errno.h> 762306a36Sopenharmony_ci#include <libunwind.h> 862306a36Sopenharmony_ci#include <asm/perf_regs.h> 962306a36Sopenharmony_ci#include "../../util/unwind.h" 1062306a36Sopenharmony_ci#include "../../util/debug.h" 1162306a36Sopenharmony_ci 1262306a36Sopenharmony_ciint libunwind__arch_reg_id(int regnum) 1362306a36Sopenharmony_ci{ 1462306a36Sopenharmony_ci switch (regnum) { 1562306a36Sopenharmony_ci case UNW_PPC64_R0: 1662306a36Sopenharmony_ci return PERF_REG_POWERPC_R0; 1762306a36Sopenharmony_ci case UNW_PPC64_R1: 1862306a36Sopenharmony_ci return PERF_REG_POWERPC_R1; 1962306a36Sopenharmony_ci case UNW_PPC64_R2: 2062306a36Sopenharmony_ci return PERF_REG_POWERPC_R2; 2162306a36Sopenharmony_ci case UNW_PPC64_R3: 2262306a36Sopenharmony_ci return PERF_REG_POWERPC_R3; 2362306a36Sopenharmony_ci case UNW_PPC64_R4: 2462306a36Sopenharmony_ci return PERF_REG_POWERPC_R4; 2562306a36Sopenharmony_ci case UNW_PPC64_R5: 2662306a36Sopenharmony_ci return PERF_REG_POWERPC_R5; 2762306a36Sopenharmony_ci case UNW_PPC64_R6: 2862306a36Sopenharmony_ci return PERF_REG_POWERPC_R6; 2962306a36Sopenharmony_ci case UNW_PPC64_R7: 3062306a36Sopenharmony_ci return PERF_REG_POWERPC_R7; 3162306a36Sopenharmony_ci case UNW_PPC64_R8: 3262306a36Sopenharmony_ci return PERF_REG_POWERPC_R8; 3362306a36Sopenharmony_ci case UNW_PPC64_R9: 3462306a36Sopenharmony_ci return PERF_REG_POWERPC_R9; 3562306a36Sopenharmony_ci case UNW_PPC64_R10: 3662306a36Sopenharmony_ci return PERF_REG_POWERPC_R10; 3762306a36Sopenharmony_ci case UNW_PPC64_R11: 3862306a36Sopenharmony_ci return PERF_REG_POWERPC_R11; 3962306a36Sopenharmony_ci case UNW_PPC64_R12: 4062306a36Sopenharmony_ci return PERF_REG_POWERPC_R12; 4162306a36Sopenharmony_ci case UNW_PPC64_R13: 4262306a36Sopenharmony_ci return PERF_REG_POWERPC_R13; 4362306a36Sopenharmony_ci case UNW_PPC64_R14: 4462306a36Sopenharmony_ci return PERF_REG_POWERPC_R14; 4562306a36Sopenharmony_ci case UNW_PPC64_R15: 4662306a36Sopenharmony_ci return PERF_REG_POWERPC_R15; 4762306a36Sopenharmony_ci case UNW_PPC64_R16: 4862306a36Sopenharmony_ci return PERF_REG_POWERPC_R16; 4962306a36Sopenharmony_ci case UNW_PPC64_R17: 5062306a36Sopenharmony_ci return PERF_REG_POWERPC_R17; 5162306a36Sopenharmony_ci case UNW_PPC64_R18: 5262306a36Sopenharmony_ci return PERF_REG_POWERPC_R18; 5362306a36Sopenharmony_ci case UNW_PPC64_R19: 5462306a36Sopenharmony_ci return PERF_REG_POWERPC_R19; 5562306a36Sopenharmony_ci case UNW_PPC64_R20: 5662306a36Sopenharmony_ci return PERF_REG_POWERPC_R20; 5762306a36Sopenharmony_ci case UNW_PPC64_R21: 5862306a36Sopenharmony_ci return PERF_REG_POWERPC_R21; 5962306a36Sopenharmony_ci case UNW_PPC64_R22: 6062306a36Sopenharmony_ci return PERF_REG_POWERPC_R22; 6162306a36Sopenharmony_ci case UNW_PPC64_R23: 6262306a36Sopenharmony_ci return PERF_REG_POWERPC_R23; 6362306a36Sopenharmony_ci case UNW_PPC64_R24: 6462306a36Sopenharmony_ci return PERF_REG_POWERPC_R24; 6562306a36Sopenharmony_ci case UNW_PPC64_R25: 6662306a36Sopenharmony_ci return PERF_REG_POWERPC_R25; 6762306a36Sopenharmony_ci case UNW_PPC64_R26: 6862306a36Sopenharmony_ci return PERF_REG_POWERPC_R26; 6962306a36Sopenharmony_ci case UNW_PPC64_R27: 7062306a36Sopenharmony_ci return PERF_REG_POWERPC_R27; 7162306a36Sopenharmony_ci case UNW_PPC64_R28: 7262306a36Sopenharmony_ci return PERF_REG_POWERPC_R28; 7362306a36Sopenharmony_ci case UNW_PPC64_R29: 7462306a36Sopenharmony_ci return PERF_REG_POWERPC_R29; 7562306a36Sopenharmony_ci case UNW_PPC64_R30: 7662306a36Sopenharmony_ci return PERF_REG_POWERPC_R30; 7762306a36Sopenharmony_ci case UNW_PPC64_R31: 7862306a36Sopenharmony_ci return PERF_REG_POWERPC_R31; 7962306a36Sopenharmony_ci case UNW_PPC64_LR: 8062306a36Sopenharmony_ci return PERF_REG_POWERPC_LINK; 8162306a36Sopenharmony_ci case UNW_PPC64_CTR: 8262306a36Sopenharmony_ci return PERF_REG_POWERPC_CTR; 8362306a36Sopenharmony_ci case UNW_PPC64_XER: 8462306a36Sopenharmony_ci return PERF_REG_POWERPC_XER; 8562306a36Sopenharmony_ci case UNW_PPC64_NIP: 8662306a36Sopenharmony_ci return PERF_REG_POWERPC_NIP; 8762306a36Sopenharmony_ci default: 8862306a36Sopenharmony_ci pr_err("unwind: invalid reg id %d\n", regnum); 8962306a36Sopenharmony_ci return -EINVAL; 9062306a36Sopenharmony_ci } 9162306a36Sopenharmony_ci return -EINVAL; 9262306a36Sopenharmony_ci} 93