Merge branch 'feature/speed_up_freertos_interrupt_active_event' into 'master'

feat(freertos): speed up CPU hardware interrupt active event

See merge request sdk/ESP8266_RTOS_SDK!1305
This commit is contained in:
Dong Heng
2020-02-25 10:16:07 +08:00
6 changed files with 18 additions and 15 deletions

View File

@ -43,7 +43,6 @@ static const char *I2S_TAG = "i2s";
return (ret_val); \ return (ret_val); \
} }
#define portYIELD_FROM_ISR() taskYIELD()
#define dma_intr_enable() _xt_isr_unmask(1 << ETS_SLC_INUM) #define dma_intr_enable() _xt_isr_unmask(1 << ETS_SLC_INUM)
#define dma_intr_disable() _xt_isr_mask(1 << ETS_SLC_INUM) #define dma_intr_disable() _xt_isr_mask(1 << ETS_SLC_INUM)
#define dma_intr_register(a, b) _xt_isr_attach(ETS_SLC_INUM, (a), (b)) #define dma_intr_register(a, b) _xt_isr_attach(ETS_SLC_INUM, (a), (b))

View File

@ -41,8 +41,6 @@
} \ } \
} while(0) } while(0)
#define portYIELD_FROM_ISR() taskYIELD()
#ifndef CONFIG_ESP8266_HSPI_HIGH_THROUGHPUT #ifndef CONFIG_ESP8266_HSPI_HIGH_THROUGHPUT
#define ENTER_CRITICAL_HIGH_THROUGHPUT() ENTER_CRITICAL() #define ENTER_CRITICAL_HIGH_THROUGHPUT() ENTER_CRITICAL()
#define EXIT_CRITICAL_HIGH_THROUGHPUT() EXIT_CRITICAL() #define EXIT_CRITICAL_HIGH_THROUGHPUT() EXIT_CRITICAL()

View File

@ -35,8 +35,6 @@
#include "driver/uart.h" #include "driver/uart.h"
#include "driver/uart_select.h" #include "driver/uart_select.h"
#define portYIELD_FROM_ISR() taskYIELD()
#define UART_ENTER_CRITICAL() portENTER_CRITICAL() #define UART_ENTER_CRITICAL() portENTER_CRITICAL()
#define UART_EXIT_CRITICAL() portEXIT_CRITICAL() #define UART_EXIT_CRITICAL() portEXIT_CRITICAL()

View File

@ -111,6 +111,7 @@ extern void vTaskSwitchContext( void ); \
} \ } \
} }
void portYIELD_FROM_ISR(void);
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/
extern unsigned cpu_sr; extern unsigned cpu_sr;

View File

@ -53,7 +53,6 @@
#define PORT_ASSERT(x) do { if (!(x)) {ets_printf("%s %u\n", "rtos_port", __LINE__); while(1){}; }} while (0) #define PORT_ASSERT(x) do { if (!(x)) {ets_printf("%s %u\n", "rtos_port", __LINE__); while(1){}; }} while (0)
extern uint8_t NMIIrqIsOn; extern uint8_t NMIIrqIsOn;
static int SWReq = 0;
uint32_t cpu_sr; uint32_t cpu_sr;
@ -68,9 +67,15 @@ uint64_t g_esp_os_ticks;
uint64_t g_esp_os_us; uint64_t g_esp_os_us;
uint64_t g_esp_os_cpu_clk; uint64_t g_esp_os_cpu_clk;
static uint32_t s_switch_ctx_flag;
void vPortEnterCritical(void); void vPortEnterCritical(void);
void vPortExitCritical(void); void vPortExitCritical(void);
void IRAM_ATTR portYIELD_FROM_ISR(void)
{
s_switch_ctx_flag = 1;
}
uint8_t *__cpu_init_stk(uint8_t *stack_top, void (*_entry)(void *), void *param, void (*_exit)(void)) uint8_t *__cpu_init_stk(uint8_t *stack_top, void (*_entry)(void *), void *param, void (*_exit)(void))
{ {
@ -112,7 +117,7 @@ void IRAM_ATTR PendSV(int req)
{ {
if (req == 1) { if (req == 1) {
vPortEnterCritical(); vPortEnterCritical();
SWReq = 1; s_switch_ctx_flag = 1;
xthal_set_intset(1 << ETS_SOFT_INUM); xthal_set_intset(1 << ETS_SOFT_INUM);
vPortExitCritical(); vPortExitCritical();
} else if (req == 2) { } else if (req == 2) {
@ -120,13 +125,12 @@ void IRAM_ATTR PendSV(int req)
} }
} }
void TASK_SW_ATTR SoftIsrHdl(void* arg) void IRAM_ATTR SoftIsrHdl(void* arg)
{ {
extern int MacIsrSigPostDefHdl(void); extern int MacIsrSigPostDefHdl(void);
if (MacIsrSigPostDefHdl() || (SWReq == 1)) { if (MacIsrSigPostDefHdl()) {
vTaskSwitchContext(); portYIELD_FROM_ISR();
SWReq = 0;
} }
} }
@ -165,7 +169,7 @@ void IRAM_ATTR xPortSysTickHandle(void *p)
g_esp_os_ticks++; g_esp_os_ticks++;
if (xTaskIncrementTick() != pdFALSE) { if (xTaskIncrementTick() != pdFALSE) {
vTaskSwitchContext(); portYIELD_FROM_ISR();
} }
} }
@ -259,7 +263,7 @@ void IRAM_ATTR vPortExitCritical(void)
void show_critical_info(void) void show_critical_info(void)
{ {
ets_printf("ShowCritical:%u\n", uxCriticalNesting); ets_printf("ShowCritical:%u\n", uxCriticalNesting);
ets_printf("SWReq:%u\n", SWReq); ets_printf("s_switch_ctx_flag:%u\n", s_switch_ctx_flag);
} }
#ifdef ESP_DPORT_CLOSE_NMI #ifdef ESP_DPORT_CLOSE_NMI
@ -345,6 +349,11 @@ void IRAM_ATTR _xt_isr_handler(void)
mask &= ~bit; mask &= ~bit;
} }
} while (soc_get_int_mask()); } while (soc_get_int_mask());
if (s_switch_ctx_flag) {
vTaskSwitchContext();
s_switch_ctx_flag = 0;
}
} }
int xPortInIsrContext(void) int xPortInIsrContext(void)

View File

@ -20,8 +20,6 @@
#include "semphr.h" #include "semphr.h"
#include "task.h" #include "task.h"
#define portYIELD_FROM_ISR portYIELD
/* Initialize the given lock by allocating a new mutex semaphore /* Initialize the given lock by allocating a new mutex semaphore
as the _lock_t value. as the _lock_t value.