diff --git a/cpu/esp_common/vendor/xtensa/xtensa_api.h b/cpu/esp_common/vendor/xtensa/xtensa_api.h index 025b3d1676..b84fefca2c 100644 --- a/cpu/esp_common/vendor/xtensa/xtensa_api.h +++ b/cpu/esp_common/vendor/xtensa/xtensa_api.h @@ -28,8 +28,9 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #ifndef XTENSA_API_H #define XTENSA_API_H -#include +#include +#include #include "xtensa_context.h" #ifdef __cplusplus @@ -120,6 +121,25 @@ static inline void xt_set_intclear(unsigned int arg) xthal_set_intclear(arg); } +/* +------------------------------------------------------------------------------- + Call this function to get handler's argument for the specified interrupt. + + n - Interrupt number. +------------------------------------------------------------------------------- +*/ +extern void * xt_get_interrupt_handler_arg(int n); + +/* +------------------------------------------------------------------------------- + Call this function to check if the specified interrupt is free to use. + + intr - Interrupt number. + cpu - cpu number. +------------------------------------------------------------------------------- +*/ +bool xt_int_has_handler(int intr, int cpu); + #ifdef __cplusplus } #endif diff --git a/cpu/esp_common/vendor/xtensa/xtensa_intr.c b/cpu/esp_common/vendor/xtensa/xtensa_intr.c index 38021012f8..f9c964ff84 100644 --- a/cpu/esp_common/vendor/xtensa/xtensa_intr.c +++ b/cpu/esp_common/vendor/xtensa/xtensa_intr.c @@ -95,7 +95,6 @@ void xt_unhandled_interrupt(void * arg) exit(-1); } - /* This function registers a handler for the specified interrupt. The "arg" parameter specifies the argument to be passed to the handler when it is @@ -127,5 +126,29 @@ xt_handler xt_set_interrupt_handler(int n, xt_handler f, void * arg) return ((old == &xt_unhandled_interrupt) ? 0 : old); } +bool xt_int_has_handler(int intr, int cpu) +{ + /* TODO multiple cores */ + (void)cpu; + return (_xt_interrupt_table[intr].handler != xt_unhandled_interrupt); +} + +#if CONFIG_APPTRACE_SV_ENABLE +void * xt_get_interrupt_handler_arg(int n) +{ + /* TODO multiple cores */ + xt_handler_table_entry * entry; + + if( n < 0 || n >= XCHAL_NUM_INTERRUPTS ) + return 0; /* invalid interrupt number */ + + /* Convert exception number to _xt_exception_table name */ + n = n * portNUM_PROCESSORS + xPortGetCoreID(); + + entry = _xt_interrupt_table + n; + return entry->arg; +} +#endif + #endif /* XCHAL_HAVE_INTERRUPTS */