Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
| 2 | #include <errno.h> |
| 3 | #include "perf_regs.h" |
| 4 | #include "event.h" |
| 5 | |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 6 | int __weak arch_sdt_arg_parse_op(char *old_op __maybe_unused, |
| 7 | char **new_op __maybe_unused) |
| 8 | { |
| 9 | return SDT_ARG_SKIP; |
| 10 | } |
| 11 | |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 12 | uint64_t __weak arch__intr_reg_mask(void) |
| 13 | { |
| 14 | return PERF_REGS_MASK; |
| 15 | } |
| 16 | |
| 17 | uint64_t __weak arch__user_reg_mask(void) |
| 18 | { |
| 19 | return PERF_REGS_MASK; |
| 20 | } |
| 21 | |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 22 | #ifdef HAVE_PERF_REGS_SUPPORT |
| 23 | int perf_reg_value(u64 *valp, struct regs_dump *regs, int id) |
| 24 | { |
| 25 | int i, idx = 0; |
| 26 | u64 mask = regs->mask; |
| 27 | |
| 28 | if (regs->cache_mask & (1ULL << id)) |
| 29 | goto out; |
| 30 | |
| 31 | if (!(mask & (1ULL << id))) |
| 32 | return -EINVAL; |
| 33 | |
| 34 | for (i = 0; i < id; i++) { |
| 35 | if (mask & (1ULL << i)) |
| 36 | idx++; |
| 37 | } |
| 38 | |
| 39 | regs->cache_mask |= (1ULL << id); |
| 40 | regs->cache_regs[id] = regs->regs[idx]; |
| 41 | |
| 42 | out: |
| 43 | *valp = regs->cache_regs[id]; |
| 44 | return 0; |
| 45 | } |
| 46 | #endif |