Jiri Olsa | c9b951c | 2014-01-07 13:47:29 +0100 | [diff] [blame] | 1 | #include <errno.h> |
| 2 | #include "perf_regs.h" |
Jiri Olsa | 0c4e774 | 2014-04-17 19:39:10 +0200 | [diff] [blame] | 3 | #include "event.h" |
Jiri Olsa | c9b951c | 2014-01-07 13:47:29 +0100 | [diff] [blame] | 4 | |
Stephane Eranian | af4aead | 2015-09-01 11:30:14 +0200 | [diff] [blame^] | 5 | const struct sample_reg __weak sample_reg_masks[] = { |
| 6 | SMPL_REG_END |
| 7 | }; |
| 8 | |
Jiri Olsa | c9b951c | 2014-01-07 13:47:29 +0100 | [diff] [blame] | 9 | int perf_reg_value(u64 *valp, struct regs_dump *regs, int id) |
| 10 | { |
| 11 | int i, idx = 0; |
| 12 | u64 mask = regs->mask; |
| 13 | |
Jiri Olsa | 0c4e774 | 2014-04-17 19:39:10 +0200 | [diff] [blame] | 14 | if (regs->cache_mask & (1 << id)) |
| 15 | goto out; |
| 16 | |
Jiri Olsa | c9b951c | 2014-01-07 13:47:29 +0100 | [diff] [blame] | 17 | if (!(mask & (1 << id))) |
| 18 | return -EINVAL; |
| 19 | |
| 20 | for (i = 0; i < id; i++) { |
| 21 | if (mask & (1 << i)) |
| 22 | idx++; |
| 23 | } |
| 24 | |
Jiri Olsa | 0c4e774 | 2014-04-17 19:39:10 +0200 | [diff] [blame] | 25 | regs->cache_mask |= (1 << id); |
| 26 | regs->cache_regs[id] = regs->regs[idx]; |
| 27 | |
| 28 | out: |
| 29 | *valp = regs->cache_regs[id]; |
Jiri Olsa | c9b951c | 2014-01-07 13:47:29 +0100 | [diff] [blame] | 30 | return 0; |
| 31 | } |