1 /* 2 * SPDX-License-Identifier: GPL-2.0 3 * 4 * Copyright(C) 2015-2018 Linaro Limited. 5 * 6 * Author: Tor Jeremiassen <tor@ti.com> 7 * Author: Mathieu Poirier <mathieu.poirier@linaro.org> 8 */ 9 10 #ifndef INCLUDE__CS_ETM_DECODER_H__ 11 #define INCLUDE__CS_ETM_DECODER_H__ 12 13 #include <linux/types.h> 14 #include <stdio.h> 15 16 struct cs_etm_decoder; 17 struct cs_etm_packet; 18 struct cs_etm_packet_queue; 19 20 struct cs_etm_queue; 21 22 typedef u32 (*cs_etm_mem_cb_type)(struct cs_etm_queue *, u8, u64, size_t, u8 *); 23 24 struct cs_etmv3_trace_params { 25 u32 reg_ctrl; 26 u32 reg_trc_id; 27 u32 reg_ccer; 28 u32 reg_idr; 29 }; 30 31 struct cs_etmv4_trace_params { 32 u32 reg_idr0; 33 u32 reg_idr1; 34 u32 reg_idr2; 35 u32 reg_idr8; 36 u32 reg_configr; 37 u32 reg_traceidr; 38 }; 39 40 struct cs_ete_trace_params { 41 u32 reg_idr0; 42 u32 reg_idr1; 43 u32 reg_idr2; 44 u32 reg_idr8; 45 u32 reg_configr; 46 u32 reg_traceidr; 47 u32 reg_devarch; 48 }; 49 50 struct cs_etm_trace_params { 51 int protocol; 52 union { 53 struct cs_etmv3_trace_params etmv3; 54 struct cs_etmv4_trace_params etmv4; 55 struct cs_ete_trace_params ete; 56 }; 57 }; 58 59 struct cs_etm_decoder_params { 60 int operation; 61 void (*packet_printer)(const char *msg); 62 cs_etm_mem_cb_type mem_acc_cb; 63 u8 formatted; 64 u8 fsyncs; 65 u8 hsyncs; 66 u8 frame_aligned; 67 void *data; 68 }; 69 70 /* 71 * The following enums are indexed starting with 1 to align with the 72 * open source coresight trace decoder library. 73 */ 74 enum { 75 CS_ETM_PROTO_ETMV3 = 1, 76 CS_ETM_PROTO_ETMV4i, 77 CS_ETM_PROTO_ETMV4d, 78 CS_ETM_PROTO_PTM, 79 CS_ETM_PROTO_ETE 80 }; 81 82 enum cs_etm_decoder_operation { 83 CS_ETM_OPERATION_PRINT = 1, 84 CS_ETM_OPERATION_DECODE, 85 CS_ETM_OPERATION_MAX, 86 }; 87 88 int cs_etm_decoder__process_data_block(struct cs_etm_decoder *decoder, 89 u64 indx, const u8 *buf, 90 size_t len, size_t *consumed); 91 92 struct cs_etm_decoder * 93 cs_etm_decoder__new(int num_cpu, 94 struct cs_etm_decoder_params *d_params, 95 struct cs_etm_trace_params t_params[]); 96 97 void cs_etm_decoder__free(struct cs_etm_decoder *decoder); 98 99 int cs_etm_decoder__add_mem_access_cb(struct cs_etm_decoder *decoder, 100 u64 start, u64 end, 101 cs_etm_mem_cb_type cb_func); 102 103 int cs_etm_decoder__get_packet(struct cs_etm_packet_queue *packet_queue, 104 struct cs_etm_packet *packet); 105 106 int cs_etm_decoder__reset(struct cs_etm_decoder *decoder); 107 const char *cs_etm_decoder__get_name(struct cs_etm_decoder *decoder); 108 109 #endif /* INCLUDE__CS_ETM_DECODER_H__ */ 110