blob: c4023f22f287dd7fb6cdf4a395af2f0d631665fb [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
Naveen N. Raof4782202016-04-28 15:01:10 +053015 if (regs->cache_mask & (1ULL << id))
Jiri Olsa0c4e7742014-04-17 19:39:10 +020016 goto out;
17
Naveen N. Raof4782202016-04-28 15:01:10 +053018 if (!(mask & (1ULL << id)))
Jiri Olsac9b951c2014-01-07 13:47:29 +010019 return -EINVAL;
20
21 for (i = 0; i < id; i++) {
Naveen N. Raof4782202016-04-28 15:01:10 +053022 if (mask & (1ULL << i))
Jiri Olsac9b951c2014-01-07 13:47:29 +010023 idx++;
24 }
25
Naveen N. Raof4782202016-04-28 15:01:10 +053026 regs->cache_mask |= (1ULL << id);
Jiri Olsa0c4e7742014-04-17 19:39:10 +020027 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