blob: 6b8eb13e14e4d5897fca71c41634a07cc9ec5d16 [file] [log] [blame]
Jiri Olsac9b951c2014-01-07 13:47:29 +01001#include <errno.h>
2#include "perf_regs.h"
Jiri Olsa0c4e7742014-04-17 19:39:10 +02003#include "event.h"
Jiri Olsac9b951c2014-01-07 13:47:29 +01004
Stephane Eranianaf4aead2015-09-01 11:30:14 +02005const struct sample_reg __weak sample_reg_masks[] = {
6 SMPL_REG_END
7};
8
Sukadev Bhattiprolu9fb47652015-09-24 17:53:49 -04009#ifdef HAVE_PERF_REGS_SUPPORT
Jiri Olsac9b951c2014-01-07 13:47:29 +010010int perf_reg_value(u64 *valp, struct regs_dump *regs, int id)
11{
12 int i, idx = 0;
13 u64 mask = regs->mask;
14
Jiri Olsa0c4e7742014-04-17 19:39:10 +020015 if (regs->cache_mask & (1 << id))
16 goto out;
17
Jiri Olsac9b951c2014-01-07 13:47:29 +010018 if (!(mask & (1 << id)))
19 return -EINVAL;
20
21 for (i = 0; i < id; i++) {
22 if (mask & (1 << i))
23 idx++;
24 }
25
Jiri Olsa0c4e7742014-04-17 19:39:10 +020026 regs->cache_mask |= (1 << id);
27 regs->cache_regs[id] = regs->regs[idx];
28
29out:
30 *valp = regs->cache_regs[id];
Jiri Olsac9b951c2014-01-07 13:47:29 +010031 return 0;
32}
Sukadev Bhattiprolu9fb47652015-09-24 17:53:49 -040033#endif