1 #include <errno.h> 2 #include "perf_regs.h" 3 #include "event.h" 4 5 int perf_reg_value(u64 *valp, struct regs_dump *regs, int id) 6 { 7 int i, idx = 0; 8 u64 mask = regs->mask; 9 10 if (regs->cache_mask & (1 << id)) 11 goto out; 12 13 if (!(mask & (1 << id))) 14 return -EINVAL; 15 16 for (i = 0; i < id; i++) { 17 if (mask & (1 << i)) 18 idx++; 19 } 20 21 regs->cache_mask |= (1 << id); 22 regs->cache_regs[id] = regs->regs[idx]; 23 24 out: 25 *valp = regs->cache_regs[id]; 26 return 0; 27 } 28