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