esp_ipc_isr.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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. /**
  13. * @brief IPC ISR Callback
  14. *
  15. * A callback of this type should be provided as an argument when calling esp_ipc_isr_asm_call() or
  16. * esp_ipc_isr_asm_call_blocking().
  17. */
  18. typedef void (*esp_ipc_isr_func_t)(void* arg);
  19. /**
  20. * @brief Initialize the IPC ISR feature
  21. *
  22. * This function initializes the IPC ISR feature and must be called before any other esp_ipc_isr...() functions.
  23. * The IPC ISR feature allows for callbacks (written in assembly) to be run on a particular CPU in the context of a
  24. * High Priority Interrupt.
  25. *
  26. * - This function will register a High Priority Interrupt on each CPU. The priority of the interrupts is dependent on
  27. * the CONFIG_ESP_SYSTEM_CHECK_INT_LEVEL option.
  28. * - Callbacks written in assembly can then run in context of the registered High Priority Interrupts
  29. * - Callbacks can be executed by calling esp_ipc_isr_asm_call() or esp_ipc_isr_asm_call_blocking()
  30. */
  31. void esp_ipc_isr_init(void);
  32. /**
  33. * @brief Execute an assembly callback on the other CPU
  34. *
  35. * Execute a given callback on the other CPU in the context of a High Priority Interrupt.
  36. *
  37. * - This function will busy-wait in a critical section until the other CPU has started execution of the callback
  38. * - The callback must be written in assembly, is invoked using a CALLX0 instruction, and has a2, a3, a4 as scratch
  39. * registers. See docs for more details
  40. *
  41. * @note This function is not available in single-core mode.
  42. *
  43. * @param[in] func Pointer to a function of type void func(void* arg) to be executed
  44. * @param[in] arg Arbitrary argument of type void* to be passed into the function
  45. */
  46. void esp_ipc_isr_asm_call(esp_ipc_isr_func_t func, void* arg);
  47. /**
  48. * @brief Execute an assembly callback on the other CPU and busy-wait until it completes
  49. *
  50. * This function is identical to esp_ipc_isr_asm_call() except that this function will busy-wait until the execution of
  51. * the callback completes.
  52. *
  53. * @note This function is not available in single-core mode.
  54. *
  55. * @param[in] func Pointer to a function of type void func(void* arg) to be executed
  56. * @param[in] arg Arbitrary argument of type void* to be passed into the function
  57. */
  58. void esp_ipc_isr_asm_call_blocking(esp_ipc_isr_func_t func, void* arg);
  59. /**
  60. * @brief Stall the other CPU
  61. *
  62. * This function will stall the other CPU. The other CPU is stalled by busy-waiting in the context of a High Priority
  63. * Interrupt. The other CPU will not be resumed until esp_ipc_isr_release_other_cpu() is called.
  64. *
  65. * - This function is internally implemented using IPC ISR
  66. * - This function is used for DPORT workaround.
  67. * - If the stall feature is paused using esp_ipc_isr_stall_pause(), this function will have no effect
  68. *
  69. * @note This function is not available in single-core mode.
  70. */
  71. void esp_ipc_isr_stall_other_cpu(void);
  72. /**
  73. * @brief Release the other CPU
  74. *
  75. * This function will release the other CPU that was previously stalled from calling esp_ipc_isr_stall_other_cpu()
  76. *
  77. * - This function is used for DPORT workaround.
  78. * - If the stall feature is paused using esp_ipc_isr_stall_pause(), this function will have no effect
  79. *
  80. * @note This function is not available in single-core mode.
  81. */
  82. void esp_ipc_isr_release_other_cpu(void);
  83. /**
  84. * @brief Puase the CPU stall feature
  85. *
  86. * This function will pause the CPU stall feature. Once paused, calls to esp_ipc_isr_stall_other_cpu() and
  87. * esp_ipc_isr_release_other_cpu() will have no effect. If a IPC ISR call is already in progress, this function will
  88. * busy-wait until the call completes before pausing the CPU stall feature.
  89. */
  90. void esp_ipc_isr_stall_pause(void);
  91. /**
  92. * @brief Abort a CPU stall
  93. *
  94. * This function will abort any stalling routine of the other CPU due to a pervious call to
  95. * esp_ipc_isr_stall_other_cpu(). This function aborts the stall in a non-recoverable manner, thus should only be called
  96. * in case of a panic().
  97. *
  98. * - This function is used in panic handling code
  99. */
  100. void esp_ipc_isr_stall_abort(void);
  101. /**
  102. * @brief Resume the CPU stall feature
  103. *
  104. * This function will resume the CPU stall feature that was previously paused by calling esp_ipc_isr_stall_pause(). Once
  105. * resumed, calls to esp_ipc_isr_stall_other_cpu() and esp_ipc_isr_release_other_cpu() will have effect again.
  106. */
  107. void esp_ipc_isr_stall_resume(void);
  108. #else // CONFIG_ESP_IPC_ISR_ENABLE
  109. #define esp_ipc_isr_stall_other_cpu()
  110. #define esp_ipc_isr_release_other_cpu()
  111. #define esp_ipc_isr_stall_pause()
  112. #define esp_ipc_isr_stall_abort()
  113. #define esp_ipc_isr_stall_resume()
  114. #endif // CONFIG_ESP_IPC_ISR_ENABLE
  115. #ifdef __cplusplus
  116. }
  117. #endif