freertos/xtensa: make vportYIELD_FROM_ISR compatible with version that both takes argument or not

pull/5919/head
Felipe Neves 2020-07-29 15:04:47 -03:00 zatwierdzone przez bot
rodzic 1a1e1911f9
commit 36b2737bb1
4 zmienionych plików z 35 dodań i 11 usunięć

Wyświetl plik

@ -29,9 +29,7 @@ static void software_isr(void *arg) {
xt_set_intclear(1 << SW_ISR_LEVEL_1);
xSemaphoreGiveFromISR(sync, &yield);
if(yield) {
portYIELD_FROM_ISR();
}
portYIELD_FROM_ISR(yield);
cycle_before_exit = portGET_RUN_TIME_COUNTER_VALUE();
}

Wyświetl plik

@ -75,7 +75,7 @@ extern "C" {
#include <stdint.h>
#include <stdlib.h>
#include <stdbool.h>
#include <stdarg.h>
#include <xtensa/hal.h>
#include <xtensa/config/core.h>
#include <xtensa/config/system.h> /* required for XSHAL_CLIB */
@ -321,13 +321,17 @@ static inline void __attribute__((always_inline)) uxPortCompareSet(volatile uint
#define portALT_GET_RUN_TIME_COUNTER_VALUE(x) x = (uint32_t)esp_timer_get_time()
#endif
/* Kernel utilities. */
void vPortYield( void );
void xEvaluateYieldFromISR(int argc, ...);
void _frxt_setup_switch( void );
#define portYIELD() vPortYield()
#define portYIELD_FROM_ISR() {traceISR_EXIT_TO_SCHEDULER(); _frxt_setup_switch();}
//Macro to count number of arguments of a __VA_ARGS__ used to support portYIELD_FROM_ISR with,
//or without arguments.
#define GET_ARGUMENT_COUNT(...) GET_ARGUMENT_COUNT_INNER(0, ##__VA_ARGS__,1,0)
#define GET_ARGUMENT_COUNT_INNER(zero, one, count, ...) count
#define portYIELD() vPortYield()
#define portYIELD_FROM_ISR(...) xEvaluateYieldFromISR(GET_ARGUMENT_COUNT(__VA_ARGS__), ##__VA_ARGS__)
/* Yielding within an API call (when interrupts are off), means the yield should be delayed
until interrupts are re-enabled.

Wyświetl plik

@ -387,6 +387,30 @@ BaseType_t IRAM_ATTR xPortInterruptedFromISRContext(void)
return (port_interruptNesting[xPortGetCoreID()] != 0);
}
void IRAM_ATTR xEvaluateYieldFromISR(int argc, ...)
{
BaseType_t xYield;
va_list ap;
va_start(ap, argc);
if(argc) {
xYield = (BaseType_t)va_arg(ap, int);
va_end(ap);
} else {
//Yield does not exist, it is a empty vPortYieldFromISR macro:
va_end(ap);
traceISR_EXIT_TO_SCHEDULER();
_frxt_setup_switch();
return;
}
//Yield exists, so need evaluate it first then switch:
if(xYield) {
traceISR_EXIT_TO_SCHEDULER();
_frxt_setup_switch();
}
}
void vPortAssertIfInISR(void)
{
configASSERT(xPortInIsrContext());

Wyświetl plik

@ -75,6 +75,4 @@
#define portVALID_STACK_MEM(ptr) esp_ptr_byte_accessible(ptr)
#else
#define portVALID_STACK_MEM(ptr) (esp_ptr_internal(ptr) && esp_ptr_byte_accessible(ptr))
#endif
#endif