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