On Fri, Sep 22, 2017 at 04:03:24AM -0500, Tor Jeremiassen wrote:
This patch adds functions in to create and destroy instances of the decoder library interface.
This patch contains code contributed by Mike Leach as a separate commit but which had to be adjusted and distrubted 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 | 85 +++++++++++++++++++++++++ tools/perf/util/cs-etm-decoder/cs-etm-decoder.h | 7 ++ 2 files changed, 92 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 d836475..1345eda 100644 --- a/tools/perf/util/cs-etm-decoder/cs-etm-decoder.c +++ b/tools/perf/util/cs-etm-decoder/cs-etm-decoder.c @@ -247,3 +247,88 @@ cs_etm_decoder__create_etmv4i_decoder(struct cs_etm_decoder_params *d_params, return ret; }
+struct cs_etm_decoder * +cs_etm_decoder__new(uint32_t num_cpu, struct cs_etm_decoder_params *d_params,
struct cs_etm_trace_params t_params[])
+{
- struct cs_etm_decoder *decoder;
- ocsd_dcd_tree_src_t format;
- uint32_t flags;
- int ret;
- size_t i;
Moved this to a uint32_t type.
- if ((!t_params) || (!d_params))
return NULL;
- decoder = zalloc(sizeof(*decoder));
- if (!decoder)
return NULL;
- /* init the channel list */
- INIT_LIST_HEAD(&(decoder->channel_list));
- decoder->state.data = d_params->data;
- decoder->prev_return = OCSD_RESP_CONT;
- format = (d_params->formatted ? OCSD_TRC_SRC_FRAME_FORMATTED :
OCSD_TRC_SRC_SINGLE);
- flags = 0;
- flags |= (d_params->fsyncs ? OCSD_DFRMTR_HAS_FSYNCS : 0);
- flags |= (d_params->hsyncs ? OCSD_DFRMTR_HAS_HSYNCS : 0);
- flags |= (d_params->frame_aligned ? OCSD_DFRMTR_FRAME_MEM_ALIGN : 0);
- /* Drivers may add barrier frames when used with perf, set up to
* handle this. Barriers const of FSYNC packet repeated 4 times.
*/
I fixed the multi-line comment.
- flags |= OCSD_DFRMTR_RESET_ON_4X_FSYNC;
- /* Create decode tree for the data source */
- decoder->dcd_tree = ocsd_create_dcd_tree(format, flags);
- if (decoder->dcd_tree == 0)
goto err_free_decoder;
- for (i = 0; i < num_cpu; i++) {
switch (t_params[i].protocol) {
case CS_ETM_PROTO_ETMV4i:
ret = cs_etm_decoder__create_etmv4i_decoder(
d_params,
&t_params[i],
decoder);
if (ret != 0)
goto err_free_decoder_tree;
break;
default:
goto err_free_decoder_tree;
}
- }
- return decoder;
+err_free_decoder_tree:
- ocsd_destroy_dcd_tree(decoder->dcd_tree);
+err_free_decoder:
- free(decoder);
- return NULL;
+}
+void cs_etm_decoder__free(struct cs_etm_decoder *decoder) +{
- struct cs_etm_channel *tmp;
- struct list_head *pos, *q;
- if (!decoder)
return;
- ocsd_destroy_dcd_tree(decoder->dcd_tree);
- decoder->dcd_tree = NULL;
- list_for_each_safe(pos, q, &(decoder->channel_list)) {
tmp = list_entry(pos, struct cs_etm_channel, chan_list);
list_del(pos);
free(tmp);
- }
- free(decoder);
+} 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 38effcb..daaa217 100644 --- a/tools/perf/util/cs-etm-decoder/cs-etm-decoder.h +++ b/tools/perf/util/cs-etm-decoder/cs-etm-decoder.h @@ -115,6 +115,13 @@ cs_etm_decoder__process_data_block(struct cs_etm_decoder *decoder, uint64_t indx, const uint8_t *buf, size_t len, size_t *consumed); +struct cs_etm_decoder * +cs_etm_decoder__new(uint32_t num_cpu,
struct cs_etm_decoder_params *d_params,
struct cs_etm_trace_params t_params[]);
+void cs_etm_decoder__free(struct cs_etm_decoder *decoder);
int cs_etm_decoder__create_etmv4i_decoder(struct cs_etm_decoder_params *d_params, struct cs_etm_trace_params *t_params, -- 2.7.4
CoreSight mailing list CoreSight@lists.linaro.org https://lists.linaro.org/mailman/listinfo/coresight