1 /* SPDX-License-Identifier: GPL-2.0 */ 2 /* 3 * arm_spe_decoder.h: Arm Statistical Profiling Extensions support 4 * Copyright (c) 2019-2020, Arm Ltd. 5 */ 6 7 #ifndef INCLUDE__ARM_SPE_DECODER_H__ 8 #define INCLUDE__ARM_SPE_DECODER_H__ 9 10 #include <stdbool.h> 11 #include <stddef.h> 12 #include <stdint.h> 13 14 #include "arm-spe-pkt-decoder.h" 15 16 enum arm_spe_sample_type { 17 ARM_SPE_L1D_ACCESS = 1 << 0, 18 ARM_SPE_L1D_MISS = 1 << 1, 19 ARM_SPE_LLC_ACCESS = 1 << 2, 20 ARM_SPE_LLC_MISS = 1 << 3, 21 ARM_SPE_TLB_ACCESS = 1 << 4, 22 ARM_SPE_TLB_MISS = 1 << 5, 23 ARM_SPE_BRANCH_MISS = 1 << 6, 24 ARM_SPE_REMOTE_ACCESS = 1 << 7, 25 }; 26 27 enum arm_spe_op_type { 28 ARM_SPE_LD = 1 << 0, 29 ARM_SPE_ST = 1 << 1, 30 }; 31 32 struct arm_spe_record { 33 enum arm_spe_sample_type type; 34 int err; 35 u32 op; 36 u64 from_ip; 37 u64 to_ip; 38 u64 timestamp; 39 u64 virt_addr; 40 u64 phys_addr; 41 }; 42 43 struct arm_spe_insn; 44 45 struct arm_spe_buffer { 46 const unsigned char *buf; 47 size_t len; 48 u64 offset; 49 u64 trace_nr; 50 }; 51 52 struct arm_spe_params { 53 int (*get_trace)(struct arm_spe_buffer *buffer, void *data); 54 void *data; 55 }; 56 57 struct arm_spe_decoder { 58 int (*get_trace)(struct arm_spe_buffer *buffer, void *data); 59 void *data; 60 struct arm_spe_record record; 61 62 const unsigned char *buf; 63 size_t len; 64 65 struct arm_spe_pkt packet; 66 }; 67 68 struct arm_spe_decoder *arm_spe_decoder_new(struct arm_spe_params *params); 69 void arm_spe_decoder_free(struct arm_spe_decoder *decoder); 70 71 int arm_spe_decode(struct arm_spe_decoder *decoder); 72 73 #endif 74