On Fri, Sep 22, 2017 at 04:03:23AM -0500, Tor Jeremiassen wrote:
The decoder library can be configured to do full trace decoding or just parse the compressed trace stream to generate string representation of the individual trace packets that can be printed.
This patch adds code to the decoder library interface that generates basic configuration for ETMv4 trace decoding and configures the trace decoder library to perform basic packet printing for ETMv4, using a callback function registered from the coresight ETM code.
This patch contains code contributed by Mike Leach as a separate commit which had to be adjusted and distributed across several patches.
Cc: Mike Leach mike.leach@linaro.org Signed-off-by: Tor Jeremiassen tor@ti.com
tools/perf/util/cs-etm-decoder/cs-etm-decoder.c | 118 ++++++++++++++++++++++++ tools/perf/util/cs-etm-decoder/cs-etm-decoder.h | 5 + 2 files changed, 123 insertions(+)
diff --git a/tools/perf/util/cs-etm-decoder/cs-etm-decoder.c b/tools/perf/util/cs-etm-decoder/cs-etm-decoder.c index 9d601df..d836475 100644 --- a/tools/perf/util/cs-etm-decoder/cs-etm-decoder.c +++ b/tools/perf/util/cs-etm-decoder/cs-etm-decoder.c @@ -114,6 +114,67 @@ cs_etm_decoder__process_data_block(struct cs_etm_decoder *decoder, return &decoder->state; } +static void cs_etm_decoder__gen_etmv4_config(struct cs_etm_trace_params *params,
ocsd_etmv4_cfg *config)
+{
- config->reg_configr = params->reg_configr;
- config->reg_traceidr = params->reg_traceidr;
- config->reg_idr0 = params->reg_idr0;
- config->reg_idr1 = params->reg_idr1;
- config->reg_idr2 = params->reg_idr2;
- config->reg_idr8 = params->reg_idr8;
- config->reg_idr9 = 0;
- config->reg_idr10 = 0;
- config->reg_idr11 = 0;
- config->reg_idr12 = 0;
- config->reg_idr13 = 0;
- config->arch_ver = ARCH_V8;
- config->core_prof = profile_CortexA;
+}
+static ocsd_datapath_resp_t +cs_etm_decoder__etmv4i_packet_printer(const void *context,
const ocsd_datapath_op_t op,
const ocsd_trc_index_t indx,
const ocsd_etmv4_i_pkt *pkt)
+{
- const size_t PACKET_STR_LEN = 1024;
- ocsd_datapath_resp_t ret = OCSD_RESP_CONT;
- char packet_str[PACKET_STR_LEN];
- size_t offset;
- struct cs_etm_channel *channel = (struct cs_etm_channel *) context;
- struct cs_etm_decoder *decoder = channel->decoder;
- sprintf(packet_str, "%ld: id[%02X] ", (long int) indx, channel->cs_id);
- offset = strlen(packet_str);
- switch (op) {
- case OCSD_OP_DATA:
if (ocsd_pkt_str(OCSD_PROTOCOL_ETMV4I,
(void *)pkt, packet_str + offset,
PACKET_STR_LEN - offset) != OCSD_OK)
ret = OCSD_RESP_FATAL_INVALID_PARAM;
break;
- case OCSD_OP_EOT:
sprintf(packet_str, "**** END OF TRACE id[%02X] ****\n",
channel->cs_id);
break;
- case OCSD_OP_FLUSH:
sprintf(packet_str, "**** FLUSH DECODER id[%02X] ****\n",
channel->cs_id);
break;
- case OCSD_OP_RESET:
sprintf(packet_str, "**** RESET DECODER ****\n");
break;
- default:
break;
- }
- decoder->packet_printer(packet_str);
- return ret;
+}
struct cs_etm_channel *cs_etm_decoder__create_channel_item( struct cs_etm_decoder *decoder, uint8_t cs_id) @@ -129,3 +190,60 @@ struct cs_etm_channel *cs_etm_decoder__create_channel_item( list_add(&(chan->chan_list), &(decoder->channel_list)); return chan; }
+static int cs_etm_decoder__create_etmv4i_packet_printer(
struct cs_etm_decoder_params *d_params,
struct cs_etm_trace_params *t_params,
struct cs_etm_decoder *decoder)
+{
- ocsd_etmv4_cfg trace_config;
- int ret = 0;
- unsigned char CSID; /* CSID extracted from the config data */
- struct cs_etm_channel *channel;
- if (!d_params->packet_printer)
return -CS_ETM_ERR_PARAM;
- cs_etm_decoder__gen_etmv4_config(t_params, &trace_config);
- decoder->packet_printer = d_params->packet_printer;
- ret = ocsd_dt_create_decoder(decoder->dcd_tree,
OCSD_BUILTIN_DCD_ETMV4I,
OCSD_CREATE_FLG_PACKET_PROC,
(void *)&trace_config, &CSID);
- if (ret != 0)
return -CS_ETM_ERR_DECODER;
- channel = cs_etm_decoder__create_channel_item(decoder, CSID);
- if (!channel)
return -CS_ETM_ERR_DECODER;
- ret = ocsd_dt_attach_packet_callback(decoder->dcd_tree,
CSID, OCSD_C_API_CB_PKT_SINK,
cs_etm_decoder__etmv4i_packet_printer,
channel);
- if (ret != 0)
return -CS_ETM_ERR_DECODER;
- return 0;
+}
+int +cs_etm_decoder__create_etmv4i_decoder(struct cs_etm_decoder_params *d_params,
struct cs_etm_trace_params *t_params,
struct cs_etm_decoder *decoder)
+{
- int ret;
- if (d_params->operation == CS_ETM_OPERATION_PRINT)
ret = cs_etm_decoder__create_etmv4i_packet_printer(d_params,
t_params,
decoder);
- else
ret = -CS_ETM_ERR_PARAM;
- return ret;
+} diff --git a/tools/perf/util/cs-etm-decoder/cs-etm-decoder.h b/tools/perf/util/cs-etm-decoder/cs-etm-decoder.h index ab9880c..38effcb 100644 --- a/tools/perf/util/cs-etm-decoder/cs-etm-decoder.h +++ b/tools/perf/util/cs-etm-decoder/cs-etm-decoder.h @@ -114,4 +114,9 @@ const struct cs_etm_state * cs_etm_decoder__process_data_block(struct cs_etm_decoder *decoder, uint64_t indx, const uint8_t *buf, size_t len, size_t *consumed);
+int +cs_etm_decoder__create_etmv4i_decoder(struct cs_etm_decoder_params *d_params,
struct cs_etm_trace_params *t_params,
struct cs_etm_decoder *decoder);
#endif /* INCLUDE__CS_ETM_DECODER_H__ */
Other than making this patch apply because of previous modifications, nothing in this one changed.
-- 2.7.4
CoreSight mailing list CoreSight@lists.linaro.org https://lists.linaro.org/mailman/listinfo/coresight