esp_ipc_isr.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. /*
  2. * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. #pragma once
  7. #include "sdkconfig.h"
  8. #ifdef __cplusplus
  9. extern "C" {
  10. #endif
  11. #ifdef CONFIG_ESP_IPC_ISR_ENABLE
  12. /** @cond */
  13. typedef void (*esp_ipc_isr_func_t)(void* arg);
  14. /** @endcond */
  15. /**
  16. * @brief Initialize inter-processor call module which based on #4 high-interrupt.
  17. *
  18. * This function is called on CPU start and should not be called from the application.
  19. *
  20. * This function starts two tasks, one on each CPU. These tasks register
  21. * #4 High-interrupt and after that, the tasks are deleted.
  22. * The next API functions work with this functionality:
  23. * esp_ipc_isr_asm_call
  24. * esp_ipc_isr_asm_call_blocking
  25. * They allow to run an asm function on other CPU.
  26. */
  27. void esp_ipc_isr_init(void);
  28. /**
  29. * @brief Execute an asm function on the other CPU (uses the #4 high-priority interrupt)
  30. *
  31. * @note In single-core mode, it is not available.
  32. * This function calls the #4 high-priority interrupt on the other CPU.
  33. * The given function is called in the context of the interrupt by CALLX0 command and
  34. * operates with registers a2, a3, a4.
  35. *
  36. * @param[in] func Pointer to a function of type void func(void* arg) to be executed
  37. * @param[in] arg Arbitrary argument of type void* to be passed into the function
  38. */
  39. void esp_ipc_isr_asm_call(esp_ipc_isr_func_t func, void* arg);
  40. /**
  41. * @brief Execute an asm function on the other CPU and blocks until it completes (uses the #4 high-priority interrupt)
  42. *
  43. * @note In single-core mode, it is not available.
  44. * This function calls the #4 high-priority interrupt on the other CPU.
  45. * The given function is called in the context of the interrupt by CALLX0 command.
  46. *
  47. * @param[in] func Pointer to a function of type void func(void* arg) to be executed
  48. * @param[in] arg Arbitrary argument of type void* to be passed into the function
  49. */
  50. void esp_ipc_isr_asm_call_blocking(esp_ipc_isr_func_t func, void* arg);
  51. /**
  52. * @brief Stall the other CPU and the current CPU disables interrupts with level 3 and lower.
  53. *
  54. * @note In single-core mode, it is not available.
  55. * This function calls the #4 high-priority interrupt on the other CPU.
  56. * The esp_ipc_isr_finish_cmd() function is called on the other CPU in the context of the #4 high-priority interrupt.
  57. * The esp_ipc_isr_finish_cmd is called by CALLX0 command.
  58. * It is waiting for the end command. The command will be sent by esp_ipc_isr_release_other_cpu().
  59. * This function is used for DPORT workaround.
  60. *
  61. * This function blocks other CPU until the release call esp_ipc_isr_release_other_cpu().
  62. *
  63. * This fucntion is used for the DPORT workaround: stall other cpu that this cpu is pending to access dport register start.
  64. */
  65. void esp_ipc_isr_stall_other_cpu(void);
  66. /**
  67. * @brief Release the other CPU
  68. *
  69. * @note In single-core mode, it is not available.
  70. * This function will send the end command to release the stall other CPU.
  71. * This function is used for DPORT workaround: stall other cpu that this cpu is pending to access dport register end.
  72. *
  73. */
  74. void esp_ipc_isr_release_other_cpu(void);
  75. /**
  76. * @brief Pause stall the other CPU
  77. */
  78. void esp_ipc_isr_stall_pause(void);
  79. /**
  80. * @brief Abort stall the other CPU
  81. *
  82. * This routine does not stop the stall routines in any way that is recoverable.
  83. * Please only call in case of panic().
  84. * Used in panic code: the enter_critical stuff may be messed up so we just stop everything without checking the mux.
  85. */
  86. void esp_ipc_isr_stall_abort(void);
  87. /**
  88. * @brief Resume stall the other CPU
  89. */
  90. void esp_ipc_isr_stall_resume(void);
  91. #else // not CONFIG_ESP_IPC_ISR_ENABLE
  92. #define esp_ipc_isr_stall_other_cpu()
  93. #define esp_ipc_isr_release_other_cpu()
  94. #define esp_ipc_isr_stall_pause()
  95. #define esp_ipc_isr_stall_abort()
  96. #define esp_ipc_isr_stall_resume()
  97. #endif // CONFIG_ESP_IPC_ISR_ENABLE
  98. #ifdef __cplusplus
  99. }
  100. #endif