cs-etm.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Copyright(C) 2015 Linaro Limited. All rights reserved.
  4. * Author: Mathieu Poirier <mathieu.poirier@linaro.org>
  5. */
  6. #ifndef INCLUDE__UTIL_PERF_CS_ETM_H__
  7. #define INCLUDE__UTIL_PERF_CS_ETM_H__
  8. #include "util/event.h"
  9. #include "util/session.h"
  10. /* Versionning header in case things need tro change in the future. That way
  11. * decoding of old snapshot is still possible.
  12. */
  13. enum {
  14. /* Starting with 0x0 */
  15. CS_HEADER_VERSION_0,
  16. /* PMU->type (32 bit), total # of CPUs (32 bit) */
  17. CS_PMU_TYPE_CPUS,
  18. CS_ETM_SNAPSHOT,
  19. CS_HEADER_VERSION_0_MAX,
  20. };
  21. /* Beginning of header common to both ETMv3 and V4 */
  22. enum {
  23. CS_ETM_MAGIC,
  24. CS_ETM_CPU,
  25. };
  26. /* ETMv3/PTM metadata */
  27. enum {
  28. /* Dynamic, configurable parameters */
  29. CS_ETM_ETMCR = CS_ETM_CPU + 1,
  30. CS_ETM_ETMTRACEIDR,
  31. /* RO, taken from sysFS */
  32. CS_ETM_ETMCCER,
  33. CS_ETM_ETMIDR,
  34. CS_ETM_PRIV_MAX,
  35. };
  36. /* ETMv4 metadata */
  37. enum {
  38. /* Dynamic, configurable parameters */
  39. CS_ETMV4_TRCCONFIGR = CS_ETM_CPU + 1,
  40. CS_ETMV4_TRCTRACEIDR,
  41. /* RO, taken from sysFS */
  42. CS_ETMV4_TRCIDR0,
  43. CS_ETMV4_TRCIDR1,
  44. CS_ETMV4_TRCIDR2,
  45. CS_ETMV4_TRCIDR8,
  46. CS_ETMV4_TRCAUTHSTATUS,
  47. CS_ETMV4_PRIV_MAX,
  48. };
  49. #define KiB(x) ((x) * 1024)
  50. #define MiB(x) ((x) * 1024 * 1024)
  51. #define CS_ETM_HEADER_SIZE (CS_HEADER_VERSION_0_MAX * sizeof(u64))
  52. static const u64 __perf_cs_etmv3_magic = 0x3030303030303030ULL;
  53. static const u64 __perf_cs_etmv4_magic = 0x4040404040404040ULL;
  54. #define CS_ETMV3_PRIV_SIZE (CS_ETM_PRIV_MAX * sizeof(u64))
  55. #define CS_ETMV4_PRIV_SIZE (CS_ETMV4_PRIV_MAX * sizeof(u64))
  56. #ifdef HAVE_CSTRACE_SUPPORT
  57. int cs_etm__process_auxtrace_info(union perf_event *event,
  58. struct perf_session *session);
  59. int cs_etm__get_cpu(u8 trace_chan_id, int *cpu);
  60. #else
  61. static inline int
  62. cs_etm__process_auxtrace_info(union perf_event *event __maybe_unused,
  63. struct perf_session *session __maybe_unused)
  64. {
  65. return -1;
  66. }
  67. static inline int cs_etm__get_cpu(u8 trace_chan_id __maybe_unused,
  68. int *cpu __maybe_unused)
  69. {
  70. return -1;
  71. }
  72. #endif
  73. #endif