cs-etm-decoder.h 2.1 KB

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