18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-or-later 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * Copyright 2016 Chandan Kumar, IBM Corporation. 48c2ecf20Sopenharmony_ci */ 58c2ecf20Sopenharmony_ci 68c2ecf20Sopenharmony_ci#include <errno.h> 78c2ecf20Sopenharmony_ci#include <libunwind.h> 88c2ecf20Sopenharmony_ci#include <asm/perf_regs.h> 98c2ecf20Sopenharmony_ci#include "../../util/unwind.h" 108c2ecf20Sopenharmony_ci#include "../../util/debug.h" 118c2ecf20Sopenharmony_ci 128c2ecf20Sopenharmony_ciint libunwind__arch_reg_id(int regnum) 138c2ecf20Sopenharmony_ci{ 148c2ecf20Sopenharmony_ci switch (regnum) { 158c2ecf20Sopenharmony_ci case UNW_PPC64_R0: 168c2ecf20Sopenharmony_ci return PERF_REG_POWERPC_R0; 178c2ecf20Sopenharmony_ci case UNW_PPC64_R1: 188c2ecf20Sopenharmony_ci return PERF_REG_POWERPC_R1; 198c2ecf20Sopenharmony_ci case UNW_PPC64_R2: 208c2ecf20Sopenharmony_ci return PERF_REG_POWERPC_R2; 218c2ecf20Sopenharmony_ci case UNW_PPC64_R3: 228c2ecf20Sopenharmony_ci return PERF_REG_POWERPC_R3; 238c2ecf20Sopenharmony_ci case UNW_PPC64_R4: 248c2ecf20Sopenharmony_ci return PERF_REG_POWERPC_R4; 258c2ecf20Sopenharmony_ci case UNW_PPC64_R5: 268c2ecf20Sopenharmony_ci return PERF_REG_POWERPC_R5; 278c2ecf20Sopenharmony_ci case UNW_PPC64_R6: 288c2ecf20Sopenharmony_ci return PERF_REG_POWERPC_R6; 298c2ecf20Sopenharmony_ci case UNW_PPC64_R7: 308c2ecf20Sopenharmony_ci return PERF_REG_POWERPC_R7; 318c2ecf20Sopenharmony_ci case UNW_PPC64_R8: 328c2ecf20Sopenharmony_ci return PERF_REG_POWERPC_R8; 338c2ecf20Sopenharmony_ci case UNW_PPC64_R9: 348c2ecf20Sopenharmony_ci return PERF_REG_POWERPC_R9; 358c2ecf20Sopenharmony_ci case UNW_PPC64_R10: 368c2ecf20Sopenharmony_ci return PERF_REG_POWERPC_R10; 378c2ecf20Sopenharmony_ci case UNW_PPC64_R11: 388c2ecf20Sopenharmony_ci return PERF_REG_POWERPC_R11; 398c2ecf20Sopenharmony_ci case UNW_PPC64_R12: 408c2ecf20Sopenharmony_ci return PERF_REG_POWERPC_R12; 418c2ecf20Sopenharmony_ci case UNW_PPC64_R13: 428c2ecf20Sopenharmony_ci return PERF_REG_POWERPC_R13; 438c2ecf20Sopenharmony_ci case UNW_PPC64_R14: 448c2ecf20Sopenharmony_ci return PERF_REG_POWERPC_R14; 458c2ecf20Sopenharmony_ci case UNW_PPC64_R15: 468c2ecf20Sopenharmony_ci return PERF_REG_POWERPC_R15; 478c2ecf20Sopenharmony_ci case UNW_PPC64_R16: 488c2ecf20Sopenharmony_ci return PERF_REG_POWERPC_R16; 498c2ecf20Sopenharmony_ci case UNW_PPC64_R17: 508c2ecf20Sopenharmony_ci return PERF_REG_POWERPC_R17; 518c2ecf20Sopenharmony_ci case UNW_PPC64_R18: 528c2ecf20Sopenharmony_ci return PERF_REG_POWERPC_R18; 538c2ecf20Sopenharmony_ci case UNW_PPC64_R19: 548c2ecf20Sopenharmony_ci return PERF_REG_POWERPC_R19; 558c2ecf20Sopenharmony_ci case UNW_PPC64_R20: 568c2ecf20Sopenharmony_ci return PERF_REG_POWERPC_R20; 578c2ecf20Sopenharmony_ci case UNW_PPC64_R21: 588c2ecf20Sopenharmony_ci return PERF_REG_POWERPC_R21; 598c2ecf20Sopenharmony_ci case UNW_PPC64_R22: 608c2ecf20Sopenharmony_ci return PERF_REG_POWERPC_R22; 618c2ecf20Sopenharmony_ci case UNW_PPC64_R23: 628c2ecf20Sopenharmony_ci return PERF_REG_POWERPC_R23; 638c2ecf20Sopenharmony_ci case UNW_PPC64_R24: 648c2ecf20Sopenharmony_ci return PERF_REG_POWERPC_R24; 658c2ecf20Sopenharmony_ci case UNW_PPC64_R25: 668c2ecf20Sopenharmony_ci return PERF_REG_POWERPC_R25; 678c2ecf20Sopenharmony_ci case UNW_PPC64_R26: 688c2ecf20Sopenharmony_ci return PERF_REG_POWERPC_R26; 698c2ecf20Sopenharmony_ci case UNW_PPC64_R27: 708c2ecf20Sopenharmony_ci return PERF_REG_POWERPC_R27; 718c2ecf20Sopenharmony_ci case UNW_PPC64_R28: 728c2ecf20Sopenharmony_ci return PERF_REG_POWERPC_R28; 738c2ecf20Sopenharmony_ci case UNW_PPC64_R29: 748c2ecf20Sopenharmony_ci return PERF_REG_POWERPC_R29; 758c2ecf20Sopenharmony_ci case UNW_PPC64_R30: 768c2ecf20Sopenharmony_ci return PERF_REG_POWERPC_R30; 778c2ecf20Sopenharmony_ci case UNW_PPC64_R31: 788c2ecf20Sopenharmony_ci return PERF_REG_POWERPC_R31; 798c2ecf20Sopenharmony_ci case UNW_PPC64_LR: 808c2ecf20Sopenharmony_ci return PERF_REG_POWERPC_LINK; 818c2ecf20Sopenharmony_ci case UNW_PPC64_CTR: 828c2ecf20Sopenharmony_ci return PERF_REG_POWERPC_CTR; 838c2ecf20Sopenharmony_ci case UNW_PPC64_XER: 848c2ecf20Sopenharmony_ci return PERF_REG_POWERPC_XER; 858c2ecf20Sopenharmony_ci case UNW_PPC64_NIP: 868c2ecf20Sopenharmony_ci return PERF_REG_POWERPC_NIP; 878c2ecf20Sopenharmony_ci default: 888c2ecf20Sopenharmony_ci pr_err("unwind: invalid reg id %d\n", regnum); 898c2ecf20Sopenharmony_ci return -EINVAL; 908c2ecf20Sopenharmony_ci } 918c2ecf20Sopenharmony_ci return -EINVAL; 928c2ecf20Sopenharmony_ci} 93