cs-etm-decoder.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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. #ifndef INCLUDE__CS_ETM_DECODER_H__
  10. #define INCLUDE__CS_ETM_DECODER_H__
  11. #include <linux/types.h>
  12. #include <stdio.h>
  13. struct cs_etm_decoder;
  14. struct cs_etm_buffer {
  15. const unsigned char *buf;
  16. size_t len;
  17. u64 offset;
  18. u64 ref_timestamp;
  19. };
  20. enum cs_etm_sample_type {
  21. CS_ETM_RANGE = 1 << 0,
  22. CS_ETM_TRACE_ON = 1 << 1,
  23. };
  24. struct cs_etm_packet {
  25. enum cs_etm_sample_type sample_type;
  26. u64 start_addr;
  27. u64 end_addr;
  28. u8 last_instr_taken_branch;
  29. u8 exc;
  30. u8 exc_ret;
  31. int cpu;
  32. };
  33. struct cs_etm_queue;
  34. typedef u32 (*cs_etm_mem_cb_type)(struct cs_etm_queue *, u64,
  35. size_t, u8 *);
  36. struct cs_etmv4_trace_params {
  37. u32 reg_idr0;
  38. u32 reg_idr1;
  39. u32 reg_idr2;
  40. u32 reg_idr8;
  41. u32 reg_configr;
  42. u32 reg_traceidr;
  43. };
  44. struct cs_etm_trace_params {
  45. int protocol;
  46. union {
  47. struct cs_etmv4_trace_params etmv4;
  48. };
  49. };
  50. struct cs_etm_decoder_params {
  51. int operation;
  52. void (*packet_printer)(const char *msg);
  53. cs_etm_mem_cb_type mem_acc_cb;
  54. u8 formatted;
  55. u8 fsyncs;
  56. u8 hsyncs;
  57. u8 frame_aligned;
  58. void *data;
  59. };
  60. /*
  61. * The following enums are indexed starting with 1 to align with the
  62. * open source coresight trace decoder library.
  63. */
  64. enum {
  65. CS_ETM_PROTO_ETMV3 = 1,
  66. CS_ETM_PROTO_ETMV4i,
  67. CS_ETM_PROTO_ETMV4d,
  68. };
  69. enum {
  70. CS_ETM_OPERATION_PRINT = 1,
  71. CS_ETM_OPERATION_DECODE,
  72. };
  73. int cs_etm_decoder__process_data_block(struct cs_etm_decoder *decoder,
  74. u64 indx, const u8 *buf,
  75. size_t len, size_t *consumed);
  76. struct cs_etm_decoder *
  77. cs_etm_decoder__new(int num_cpu,
  78. struct cs_etm_decoder_params *d_params,
  79. struct cs_etm_trace_params t_params[]);
  80. void cs_etm_decoder__free(struct cs_etm_decoder *decoder);
  81. int cs_etm_decoder__add_mem_access_cb(struct cs_etm_decoder *decoder,
  82. u64 start, u64 end,
  83. cs_etm_mem_cb_type cb_func);
  84. int cs_etm_decoder__get_packet(struct cs_etm_decoder *decoder,
  85. struct cs_etm_packet *packet);
  86. int cs_etm_decoder__reset(struct cs_etm_decoder *decoder);
  87. #endif /* INCLUDE__CS_ETM_DECODER_H__ */