cs-etm.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. /* RB tree for quick conversion between traceID and CPUs */
  50. struct intlist *traceid_list;
  51. #define KiB(x) ((x) * 1024)
  52. #define MiB(x) ((x) * 1024 * 1024)
  53. #define CS_ETM_HEADER_SIZE (CS_HEADER_VERSION_0_MAX * sizeof(u64))
  54. static const u64 __perf_cs_etmv3_magic = 0x3030303030303030ULL;
  55. static const u64 __perf_cs_etmv4_magic = 0x4040404040404040ULL;
  56. #define CS_ETMV3_PRIV_SIZE (CS_ETM_PRIV_MAX * sizeof(u64))
  57. #define CS_ETMV4_PRIV_SIZE (CS_ETMV4_PRIV_MAX * sizeof(u64))
  58. #ifdef HAVE_CSTRACE_SUPPORT
  59. int cs_etm__process_auxtrace_info(union perf_event *event,
  60. struct perf_session *session);
  61. #else
  62. static inline int
  63. cs_etm__process_auxtrace_info(union perf_event *event __maybe_unused,
  64. struct perf_session *session __maybe_unused)
  65. {
  66. return -1;
  67. }
  68. #endif
  69. #endif