18c2ecf20Sopenharmony_ci#include <linux/kernel.h> 28c2ecf20Sopenharmony_ci#include <elfutils/libdwfl.h> 38c2ecf20Sopenharmony_ci#include "../../util/unwind-libdw.h" 48c2ecf20Sopenharmony_ci#include "../../util/perf_regs.h" 58c2ecf20Sopenharmony_ci#include "../../util/event.h" 68c2ecf20Sopenharmony_ci#include "dwarf-regs-table.h" 78c2ecf20Sopenharmony_ci 88c2ecf20Sopenharmony_ci 98c2ecf20Sopenharmony_cibool libdw__arch_set_initial_registers(Dwfl_Thread *thread, void *arg) 108c2ecf20Sopenharmony_ci{ 118c2ecf20Sopenharmony_ci struct unwind_info *ui = arg; 128c2ecf20Sopenharmony_ci struct regs_dump *user_regs = &ui->sample->user_regs; 138c2ecf20Sopenharmony_ci Dwarf_Word dwarf_regs[ARRAY_SIZE(s390_dwarf_regs)]; 148c2ecf20Sopenharmony_ci 158c2ecf20Sopenharmony_ci#define REG(r) ({ \ 168c2ecf20Sopenharmony_ci Dwarf_Word val = 0; \ 178c2ecf20Sopenharmony_ci perf_reg_value(&val, user_regs, PERF_REG_S390_##r); \ 188c2ecf20Sopenharmony_ci val; \ 198c2ecf20Sopenharmony_ci}) 208c2ecf20Sopenharmony_ci /* 218c2ecf20Sopenharmony_ci * For DWARF register mapping details, 228c2ecf20Sopenharmony_ci * see also perf/arch/s390/include/dwarf-regs-table.h 238c2ecf20Sopenharmony_ci */ 248c2ecf20Sopenharmony_ci dwarf_regs[0] = REG(R0); 258c2ecf20Sopenharmony_ci dwarf_regs[1] = REG(R1); 268c2ecf20Sopenharmony_ci dwarf_regs[2] = REG(R2); 278c2ecf20Sopenharmony_ci dwarf_regs[3] = REG(R3); 288c2ecf20Sopenharmony_ci dwarf_regs[4] = REG(R4); 298c2ecf20Sopenharmony_ci dwarf_regs[5] = REG(R5); 308c2ecf20Sopenharmony_ci dwarf_regs[6] = REG(R6); 318c2ecf20Sopenharmony_ci dwarf_regs[7] = REG(R7); 328c2ecf20Sopenharmony_ci dwarf_regs[8] = REG(R8); 338c2ecf20Sopenharmony_ci dwarf_regs[9] = REG(R9); 348c2ecf20Sopenharmony_ci dwarf_regs[10] = REG(R10); 358c2ecf20Sopenharmony_ci dwarf_regs[11] = REG(R11); 368c2ecf20Sopenharmony_ci dwarf_regs[12] = REG(R12); 378c2ecf20Sopenharmony_ci dwarf_regs[13] = REG(R13); 388c2ecf20Sopenharmony_ci dwarf_regs[14] = REG(R14); 398c2ecf20Sopenharmony_ci dwarf_regs[15] = REG(R15); 408c2ecf20Sopenharmony_ci 418c2ecf20Sopenharmony_ci dwarf_regs[16] = REG(FP0); 428c2ecf20Sopenharmony_ci dwarf_regs[17] = REG(FP2); 438c2ecf20Sopenharmony_ci dwarf_regs[18] = REG(FP4); 448c2ecf20Sopenharmony_ci dwarf_regs[19] = REG(FP6); 458c2ecf20Sopenharmony_ci dwarf_regs[20] = REG(FP1); 468c2ecf20Sopenharmony_ci dwarf_regs[21] = REG(FP3); 478c2ecf20Sopenharmony_ci dwarf_regs[22] = REG(FP5); 488c2ecf20Sopenharmony_ci dwarf_regs[23] = REG(FP7); 498c2ecf20Sopenharmony_ci dwarf_regs[24] = REG(FP8); 508c2ecf20Sopenharmony_ci dwarf_regs[25] = REG(FP10); 518c2ecf20Sopenharmony_ci dwarf_regs[26] = REG(FP12); 528c2ecf20Sopenharmony_ci dwarf_regs[27] = REG(FP14); 538c2ecf20Sopenharmony_ci dwarf_regs[28] = REG(FP9); 548c2ecf20Sopenharmony_ci dwarf_regs[29] = REG(FP11); 558c2ecf20Sopenharmony_ci dwarf_regs[30] = REG(FP13); 568c2ecf20Sopenharmony_ci dwarf_regs[31] = REG(FP15); 578c2ecf20Sopenharmony_ci 588c2ecf20Sopenharmony_ci dwarf_regs[64] = REG(MASK); 598c2ecf20Sopenharmony_ci dwarf_regs[65] = REG(PC); 608c2ecf20Sopenharmony_ci 618c2ecf20Sopenharmony_ci dwfl_thread_state_register_pc(thread, dwarf_regs[65]); 628c2ecf20Sopenharmony_ci return dwfl_thread_state_registers(thread, 0, 32, dwarf_regs); 638c2ecf20Sopenharmony_ci} 64