esp_ipc_isr.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. /*
  2. * SPDX-FileCopyrightText: 2015-2022 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 Execute an assembly callback on the other CPU
  21. *
  22. * Execute a given callback on the other CPU in the context of a High Priority Interrupt.
  23. *
  24. * - This function will busy-wait in a critical section until the other CPU has started execution of the callback
  25. * - The callback must be written in assembly, is invoked using a CALLX0 instruction, and has a2, a3, a4 as scratch
  26. * registers. See docs for more details
  27. *
  28. * @note This function is not available in single-core mode.
  29. *
  30. * @param[in] func Pointer to a function of type void func(void* arg) to be executed
  31. * @param[in] arg Arbitrary argument of type void* to be passed into the function
  32. */
  33. void esp_ipc_isr_asm_call(esp_ipc_isr_func_t func, void* arg);
  34. /**
  35. * @brief Execute an assembly callback on the other CPU and busy-wait until it completes
  36. *
  37. * This function is identical to esp_ipc_isr_asm_call() except that this function will busy-wait until the execution of
  38. * the callback completes.
  39. *
  40. * @note This function is not available in single-core mode.
  41. *
  42. * @param[in] func Pointer to a function of type void func(void* arg) to be executed
  43. * @param[in] arg Arbitrary argument of type void* to be passed into the function
  44. */
  45. void esp_ipc_isr_asm_call_blocking(esp_ipc_isr_func_t func, void* arg);
  46. /**
  47. * @brief Stall the other CPU
  48. *
  49. * This function will stall the other CPU. The other CPU is stalled by busy-waiting in the context of a High Priority
  50. * Interrupt. The other CPU will not be resumed until esp_ipc_isr_release_other_cpu() is called.
  51. *
  52. * - This function is internally implemented using IPC ISR
  53. * - This function is used for DPORT workaround.
  54. * - If the stall feature is paused using esp_ipc_isr_stall_pause(), this function will have no effect
  55. *
  56. * @note This function is not available in single-core mode.
  57. * @note It is the caller's responsibility to avoid deadlocking on spinlocks
  58. */
  59. void esp_ipc_isr_stall_other_cpu(void);
  60. /**
  61. * @brief Release the other CPU
  62. *
  63. * This function will release the other CPU that was previously stalled from calling esp_ipc_isr_stall_other_cpu()
  64. *
  65. * - This function is used for DPORT workaround.
  66. * - If the stall feature is paused using esp_ipc_isr_stall_pause(), this function will have no effect
  67. *
  68. * @note This function is not available in single-core mode.
  69. */
  70. void esp_ipc_isr_release_other_cpu(void);
  71. /**
  72. * @brief Puase the CPU stall feature
  73. *
  74. * This function will pause the CPU stall feature. Once paused, calls to esp_ipc_isr_stall_other_cpu() and
  75. * esp_ipc_isr_release_other_cpu() will have no effect. If a IPC ISR call is already in progress, this function will
  76. * busy-wait until the call completes before pausing the CPU stall feature.
  77. */
  78. void esp_ipc_isr_stall_pause(void);
  79. /**
  80. * @brief Abort a CPU stall
  81. *
  82. * This function will abort any stalling routine of the other CPU due to a pervious call to
  83. * esp_ipc_isr_stall_other_cpu(). This function aborts the stall in a non-recoverable manner, thus should only be called
  84. * in case of a panic().
  85. *
  86. * - This function is used in panic handling code
  87. */
  88. void esp_ipc_isr_stall_abort(void);
  89. /**
  90. * @brief Resume the CPU stall feature
  91. *
  92. * This function will resume the CPU stall feature that was previously paused by calling esp_ipc_isr_stall_pause(). Once
  93. * resumed, calls to esp_ipc_isr_stall_other_cpu() and esp_ipc_isr_release_other_cpu() will have effect again.
  94. */
  95. void esp_ipc_isr_stall_resume(void);
  96. #else // CONFIG_ESP_IPC_ISR_ENABLE
  97. #define esp_ipc_isr_stall_other_cpu()
  98. #define esp_ipc_isr_release_other_cpu()
  99. #define esp_ipc_isr_stall_pause()
  100. #define esp_ipc_isr_stall_abort()
  101. #define esp_ipc_isr_stall_resume()
  102. #endif // CONFIG_ESP_IPC_ISR_ENABLE
  103. #ifdef __cplusplus
  104. }
  105. #endif