xtensa_perfmon_access.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. /*
  2. * SPDX-FileCopyrightText: 2018-2022 Espressif Systems (Shanghai) CO LTD
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. #ifndef _PERF_MON_ACCESS_H_
  7. #define _PERF_MON_ACCESS_H_
  8. #include <stdint.h>
  9. #include <stdbool.h>
  10. #include "esp_err.h"
  11. #include "esp_log.h"
  12. #ifdef __cplusplus
  13. extern "C"
  14. {
  15. #endif
  16. /**@{*/
  17. /**
  18. * @brief Init Performance Monitoor
  19. *
  20. * Initialize performance monitor register with define values
  21. *
  22. * @param[in] id: performance counter number
  23. * @param[in] select: select value from PMCTRLx register
  24. * @param[in] mask: mask value from PMCTRLx register
  25. * @param[in] kernelcnt: kernelcnt value from PMCTRLx register
  26. * @param[in] tracelevel: tracelevel value from PMCTRLx register
  27. *
  28. * @return
  29. * - ESP_OK on success
  30. * - ESP_ERR_INVALID_ARG if one of the arguments is not correct
  31. */
  32. esp_err_t xtensa_perfmon_init(int id, uint16_t select, uint16_t mask, int kernelcnt, int tracelevel);
  33. /**@}*/
  34. /**@{*/
  35. /**
  36. * @brief Reset PM counter
  37. *
  38. * Reset PM counter. Writes 0 to the PMx register.
  39. *
  40. * @param[in] id: performance counter number
  41. *
  42. * @return
  43. * - ESP_OK on success
  44. * - ESP_ERR_INVALID_ARG if id out of range
  45. */
  46. esp_err_t xtensa_perfmon_reset(int id);
  47. /**@}*/
  48. /**@{*/
  49. /**
  50. * @brief Start PM counters
  51. *
  52. * Start all PM counters synchronously. Write 1 to the PGM register
  53. */
  54. void xtensa_perfmon_start(void);
  55. /**@}*/
  56. /**@{*/
  57. /**
  58. * @brief Stop PM counters
  59. *
  60. * Stop all PM counters synchronously. Write 0 to the PGM register
  61. */
  62. void xtensa_perfmon_stop(void);
  63. /**@}*/
  64. /**@{*/
  65. /**
  66. * @brief Read PM counter
  67. *
  68. * Read value of defined PM counter.
  69. *
  70. * @param[in] id: performance counter number
  71. *
  72. * @return
  73. * - Performance counter value
  74. */
  75. uint32_t xtensa_perfmon_value(int id);
  76. /**@}*/
  77. /**@{*/
  78. /**
  79. * @brief Read PM overflow state
  80. *
  81. * Read overflow value of defined PM counter.
  82. *
  83. * @param[in] id: performance counter number
  84. *
  85. * @return
  86. * - ESP_OK if there is no overflow (overflow = 0)
  87. * - ESP_FAIL if overflow occure (overflow = 1)
  88. */
  89. esp_err_t xtensa_perfmon_overflow(int id);
  90. /**@}*/
  91. /**@{*/
  92. /**
  93. * @brief Dump PM values
  94. *
  95. * Dump all PM register to the console.
  96. *
  97. */
  98. void xtensa_perfmon_dump(void);
  99. /**@}*/
  100. #ifdef __cplusplus
  101. }
  102. #endif
  103. #endif // _PERF_MON_ACCESS_H_