xref: /openbmc/linux/tools/perf/util/perf_regs.c (revision 4da722ca)
1 #include <errno.h>
2 #include "perf_regs.h"
3 #include "event.h"
4 
5 const struct sample_reg __weak sample_reg_masks[] = {
6 	SMPL_REG_END
7 };
8 
9 int __weak arch_sdt_arg_parse_op(char *old_op __maybe_unused,
10 				 char **new_op __maybe_unused)
11 {
12 	return SDT_ARG_SKIP;
13 }
14 
15 #ifdef HAVE_PERF_REGS_SUPPORT
16 int perf_reg_value(u64 *valp, struct regs_dump *regs, int id)
17 {
18 	int i, idx = 0;
19 	u64 mask = regs->mask;
20 
21 	if (regs->cache_mask & (1ULL << id))
22 		goto out;
23 
24 	if (!(mask & (1ULL << id)))
25 		return -EINVAL;
26 
27 	for (i = 0; i < id; i++) {
28 		if (mask & (1ULL << i))
29 			idx++;
30 	}
31 
32 	regs->cache_mask |= (1ULL << id);
33 	regs->cache_regs[id] = regs->regs[idx];
34 
35 out:
36 	*valp = regs->cache_regs[id];
37 	return 0;
38 }
39 #endif
40