1 /*
2  * SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 #ifndef __ESP_CROSSCORE_INT_H
7 #define __ESP_CROSSCORE_INT_H
8 
9 #include "sdkconfig.h"
10 
11 #ifdef __cplusplus
12 extern "C" {
13 #endif
14 
15 /**
16  * Initialize the crosscore interrupt system for this CPU.
17  * This needs to be called once on every CPU that is used
18  * by FreeRTOS.
19  *
20  * If multicore FreeRTOS support is enabled, this will be
21  * called automatically by the startup code and should not
22  * be called manually.
23  */
24 void esp_crosscore_int_init(void);
25 
26 
27 /**
28  * Send an interrupt to a CPU indicating it should yield its
29  * currently running task in favour of a higher-priority task
30  * that presumably just woke up.
31  *
32  * This is used internally by FreeRTOS in multicore mode
33  * and should not be called by the user.
34  *
35  * @param core_id Core that should do the yielding
36  */
37 void esp_crosscore_int_send_yield(int core_id);
38 
39 
40 /**
41  * Send an interrupt to a CPU indicating it should update its
42  * CCOMPARE1 value due to a frequency switch.
43  *
44  * This is used internally when dynamic frequency switching is
45  * enabled, and should not be called from application code.
46  *
47  * @param core_id Core that should update its CCOMPARE1 value
48  */
49 void esp_crosscore_int_send_freq_switch(int core_id);
50 
51 void esp_crosscore_int_send_gdb_call(int core_id);
52 
53 #if !CONFIG_IDF_TARGET_ESP32C3 && !CONFIG_IDF_TARGET_ESP32C2 && !CONFIG_IDF_TARGET_ESP32C6 && !CONFIG_IDF_TARGET_ESP32H2
54 /**
55  * Send an interrupt to a CPU indicating it should print its current backtrace
56  *
57  * This is used internally by the Task Watchdog to dump the backtrace of the
58  * opposite core and should not be called from application code.
59  *
60  * @param core_id Core that should print its backtrace
61  */
62 void esp_crosscore_int_send_print_backtrace(int core_id);
63 
64 #if CONFIG_ESP_TASK_WDT_EN
65 /**
66  * Send an interrupt to a CPU indicating it call `task_wdt_timeout_abort_xtensa`.
67  * This will make the CPU abort, using the interrupted task frame.
68  *
69  * This is used internally by the Task Watchdog when it should abort after a task,
70  * running on the other core than the one running the TWDT ISR, failed to reset
71  * its timer.
72  *
73  * @param core_id Core that should abort
74  */
75 void esp_crosscore_int_send_twdt_abort(int core_id);
76 
77 #endif // CONFIG_ESP_TASK_WDT_EN
78 #endif // !CONFIG_IDF_TARGET_ESP32C3 && !CONFIG_IDF_TARGET_ESP32C2 && !CONFIG_IDF_TARGET_ESP32C6
79 
80 #ifdef __cplusplus
81 }
82 #endif
83 
84 #endif
85