xtensa_perfmon_apis.h 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. // Copyright 2018-2019 Espressif Systems (Shanghai) PTE LTD
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. #ifndef _xtensa_perfmon_apis_H_
  15. #define _xtensa_perfmon_apis_H_
  16. #include "xtensa_perfmon_access.h"
  17. #include "xtensa_perfmon_masks.h"
  18. #ifdef __cplusplus
  19. extern "C"
  20. {
  21. #endif
  22. /**
  23. * @brief Performance monitor configuration structure
  24. *
  25. * Structure to configure performance counter to measure dedicated function
  26. */
  27. typedef struct xtensa_perfmon_config {
  28. int repeat_count; /*!< how much times function will be called before the calback will be repeated */
  29. float max_deviation; /*!< Difference between min and max counter number 0..1, 0 - no difference, 1 - not used */
  30. void *call_params; /*!< This pointer will be passed to the call_function as a parameter */
  31. void (*call_function)(void *params); /*!< pointer to the function that have to be called */
  32. void (*callback)(void *params, uint32_t select, uint32_t mask, uint32_t value); /*!< pointer to the function that will be called with result parameters */
  33. void *callback_params; /*!< parameter that will be passed to the callback */
  34. int tracelevel; /*!< trace level for all counters.
  35. In case of negative value, the filter will be ignored.
  36. If it's >=0, then the perfmon will count only when interrupt level > tracelevel. It's useful to monitor interrupts. */
  37. uint32_t counters_size;/*!< amount of counter in the list */
  38. const uint32_t *select_mask; /*!< list of the select/mask parameters */
  39. } xtensa_perfmon_config_t;
  40. /**
  41. * @brief Execute PM
  42. *
  43. * Execute performance counter for dedicated function with defined parameters
  44. *
  45. * @param[in] config: pointer to the configuration structure
  46. *
  47. * @return
  48. * - ESP_OK if no errors
  49. * - ESP_ERR_INVALID_ARG if one of the required parameters not defined
  50. * - ESP_FAIL - counter overflow
  51. */
  52. esp_err_t xtensa_perfmon_exec(const xtensa_perfmon_config_t *config);
  53. /**
  54. * @brief Dump PM results
  55. *
  56. * Callback to dump perfmon result to a FILE* stream specified in
  57. * perfmon_config_t::callback_params. If callback_params is set to NULL, will print to stdout
  58. *
  59. * @param[in] params: used parameters passed from configuration (callback_params).
  60. * This parameter expected as FILE* hanle, where data will be stored.
  61. * If this parameter NULL, then data will be stored to the stdout.
  62. * @param[in] select: select value for current counter
  63. * @param[in] mask: mask value for current counter
  64. * @param[in] value: counter value for current counter
  65. *
  66. */
  67. void xtensa_perfmon_view_cb(void *params, uint32_t select, uint32_t mask, uint32_t value);
  68. #ifdef __cplusplus
  69. }
  70. #endif
  71. #endif // _xtensa_perfmon_apis_H_