1
2#include <errno.h>
3#include <libunwind.h>
4#include "perf_regs.h"
5#include "../../util/unwind.h"
6#include "../../util/debug.h"
7
8int libunwind__arch_reg_id(int regnum)
9{
10	switch (regnum) {
11	case UNW_AARCH64_X0:
12		return PERF_REG_ARM64_X0;
13	case UNW_AARCH64_X1:
14		return PERF_REG_ARM64_X1;
15	case UNW_AARCH64_X2:
16		return PERF_REG_ARM64_X2;
17	case UNW_AARCH64_X3:
18		return PERF_REG_ARM64_X3;
19	case UNW_AARCH64_X4:
20		return PERF_REG_ARM64_X4;
21	case UNW_AARCH64_X5:
22		return PERF_REG_ARM64_X5;
23	case UNW_AARCH64_X6:
24		return PERF_REG_ARM64_X6;
25	case UNW_AARCH64_X7:
26		return PERF_REG_ARM64_X7;
27	case UNW_AARCH64_X8:
28		return PERF_REG_ARM64_X8;
29	case UNW_AARCH64_X9:
30		return PERF_REG_ARM64_X9;
31	case UNW_AARCH64_X10:
32		return PERF_REG_ARM64_X10;
33	case UNW_AARCH64_X11:
34		return PERF_REG_ARM64_X11;
35	case UNW_AARCH64_X12:
36		return PERF_REG_ARM64_X12;
37	case UNW_AARCH64_X13:
38		return PERF_REG_ARM64_X13;
39	case UNW_AARCH64_X14:
40		return PERF_REG_ARM64_X14;
41	case UNW_AARCH64_X15:
42		return PERF_REG_ARM64_X15;
43	case UNW_AARCH64_X16:
44		return PERF_REG_ARM64_X16;
45	case UNW_AARCH64_X17:
46		return PERF_REG_ARM64_X17;
47	case UNW_AARCH64_X18:
48		return PERF_REG_ARM64_X18;
49	case UNW_AARCH64_X19:
50		return PERF_REG_ARM64_X19;
51	case UNW_AARCH64_X20:
52		return PERF_REG_ARM64_X20;
53	case UNW_AARCH64_X21:
54		return PERF_REG_ARM64_X21;
55	case UNW_AARCH64_X22:
56		return PERF_REG_ARM64_X22;
57	case UNW_AARCH64_X23:
58		return PERF_REG_ARM64_X23;
59	case UNW_AARCH64_X24:
60		return PERF_REG_ARM64_X24;
61	case UNW_AARCH64_X25:
62		return PERF_REG_ARM64_X25;
63	case UNW_AARCH64_X26:
64		return PERF_REG_ARM64_X26;
65	case UNW_AARCH64_X27:
66		return PERF_REG_ARM64_X27;
67	case UNW_AARCH64_X28:
68		return PERF_REG_ARM64_X28;
69	case UNW_AARCH64_X29:
70		return PERF_REG_ARM64_X29;
71	case UNW_AARCH64_X30:
72		return PERF_REG_ARM64_LR;
73	case UNW_AARCH64_SP:
74		return PERF_REG_ARM64_SP;
75	case UNW_AARCH64_PC:
76		return PERF_REG_ARM64_PC;
77	default:
78		pr_err("unwind: invalid reg id %d\n", regnum);
79		return -EINVAL;
80	}
81
82	return -EINVAL;
83}
84