xtensa_perfmon_apis.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*
  2. * SPDX-FileCopyrightText: 2018-2022 Espressif Systems (Shanghai) CO LTD
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. #ifndef _xtensa_perfmon_apis_H_
  7. #define _xtensa_perfmon_apis_H_
  8. #include "xtensa_perfmon_access.h"
  9. #include "xtensa_perfmon_masks.h"
  10. #ifdef __cplusplus
  11. extern "C"
  12. {
  13. #endif
  14. /**
  15. * @brief Performance monitor configuration structure
  16. *
  17. * Structure to configure performance counter to measure dedicated function
  18. */
  19. typedef struct xtensa_perfmon_config {
  20. int repeat_count; /*!< how much times function will be called before the calback will be repeated */
  21. float max_deviation; /*!< Difference between min and max counter number 0..1, 0 - no difference, 1 - not used */
  22. void *call_params; /*!< This pointer will be passed to the call_function as a parameter */
  23. void (*call_function)(void *params); /*!< pointer to the function that have to be called */
  24. void (*callback)(void *params, uint32_t select, uint32_t mask, uint32_t value); /*!< pointer to the function that will be called with result parameters */
  25. void *callback_params; /*!< parameter that will be passed to the callback */
  26. int tracelevel; /*!< trace level for all counters.
  27. In case of negative value, the filter will be ignored.
  28. If it's >=0, then the perfmon will count only when interrupt level > tracelevel. It's useful to monitor interrupts. */
  29. uint32_t counters_size;/*!< amount of counter in the list */
  30. const uint32_t *select_mask; /*!< list of the select/mask parameters */
  31. } xtensa_perfmon_config_t;
  32. /**
  33. * @brief Execute PM
  34. *
  35. * Execute performance counter for dedicated function with defined parameters
  36. *
  37. * @param[in] config: pointer to the configuration structure
  38. *
  39. * @return
  40. * - ESP_OK if no errors
  41. * - ESP_ERR_INVALID_ARG if one of the required parameters not defined
  42. * - ESP_FAIL - counter overflow
  43. */
  44. esp_err_t xtensa_perfmon_exec(const xtensa_perfmon_config_t *config);
  45. /**
  46. * @brief Dump PM results
  47. *
  48. * Callback to dump perfmon result to a FILE* stream specified in
  49. * perfmon_config_t::callback_params. If callback_params is set to NULL, will print to stdout
  50. *
  51. * @param[in] params: used parameters passed from configuration (callback_params).
  52. * This parameter expected as FILE* hanle, where data will be stored.
  53. * If this parameter NULL, then data will be stored to the stdout.
  54. * @param[in] select: select value for current counter
  55. * @param[in] mask: mask value for current counter
  56. * @param[in] value: counter value for current counter
  57. *
  58. */
  59. void xtensa_perfmon_view_cb(void *params, uint32_t select, uint32_t mask, uint32_t value);
  60. #ifdef __cplusplus
  61. }
  62. #endif
  63. #endif // _xtensa_perfmon_apis_H_