feat(freertos): Add configuration to speed up task switch

The global heap is 74332 bytes when connect to AP and get IP by DHCP.
This commit is contained in:
Dong Heng
2018-11-28 16:16:10 +08:00
parent 72eea96f4a
commit 6fd342dd0f
7 changed files with 40 additions and 9 deletions

View File

@ -45,5 +45,14 @@ config FREERTOS_TIMER_STACKSIZE
default 2048
help
The size of the stack used by the timer in FreeRTOS.
config TASK_SWITCH_FASTER
bool "Task switch faster"
default y
help
Enable this option, linking task switch function and its father functions to IRAM
to speed up task switch. It is specific for faster I/O application and so on.
But it may cost more 1KB IRAM, so user global heap may decrease 1KB.
endmenu

View File

@ -71,7 +71,7 @@ void vListInitialiseItem( ListItem_t * const pxItem )
}
/*-----------------------------------------------------------*/
void vListInsertEnd( List_t * const pxList, ListItem_t * const pxNewListItem )
void TASK_SW_ATTR vListInsertEnd( List_t * const pxList, ListItem_t * const pxNewListItem )
{
ListItem_t * const pxIndex = pxList->pxIndex;
@ -167,7 +167,7 @@ const TickType_t xValueOfInsertion = pxNewListItem->xItemValue;
}
/*-----------------------------------------------------------*/
UBaseType_t uxListRemove( ListItem_t * const pxItemToRemove )
UBaseType_t TASK_SW_ATTR uxListRemove( ListItem_t * const pxItemToRemove )
{
/* The list item knows which list it is in. Obtain the list from the list
item. */

View File

@ -2611,7 +2611,7 @@ implementations require configUSE_TICKLESS_IDLE to be set to a value other than
#endif /* INCLUDE_xTaskAbortDelay */
/*----------------------------------------------------------*/
BaseType_t xTaskIncrementTick( void )
BaseType_t TASK_SW_ATTR xTaskIncrementTick( void )
{
TCB_t * pxTCB;
TickType_t xItemValue;
@ -2873,7 +2873,7 @@ BaseType_t xSwitchRequired = pdFALSE;
#endif /* configUSE_APPLICATION_TASK_TAG */
/*-----------------------------------------------------------*/
void vTaskSwitchContext( void )
void TASK_SW_ATTR vTaskSwitchContext( void )
{
if( uxSchedulerSuspended != ( UBaseType_t ) pdFALSE )
{

View File

@ -127,5 +127,11 @@ NVIC value of 255. */
/* add this to dump task stack information */
#define configRECORD_STACK_HIGH_ADDRESS 1
#ifdef CONFIG_TASK_SWITCH_FASTER
#define TASK_SW_ATTR IRAM_ATTR
#else
#define TASK_SW_ATTR
#endif
#endif /* FREERTOS_CONFIG_H */

View File

@ -59,8 +59,12 @@ vPortYield:
call0 _xt_int_enter
call0 vPortEnterCritical
#ifndef CONFIG_TASK_SWITCH_FASTER
movi a0, vTaskSwitchContext
callx0 a0
callx0 a0
#else
call0 vTaskSwitchContext
#endif
call0 vPortExitCritical
call0 _xt_int_exit
@ -239,8 +243,12 @@ _xt_timer_int:
/* Call the uCOS-II tick handler. */
#ifdef __XTENSA_CALL0_ABI__ /* OSTimeTick() */
#ifndef CONFIG_TASK_SWITCH_FASTER
movi a0, xPortSysTickHandle
callx0 a0
#else
call0 xPortSysTickHandle
#endif
#else
call4 xTaskIncrementTick
#endif
@ -281,8 +289,12 @@ _xt_timer_int1:
#endif
/* Call the uCOS-II tick handler. */
#ifndef CONFIG_TASK_SWITCH_FASTER
movi a0, vTaskSwitchContext
callx0 a0
#else
call0 vTaskSwitchContext
#endif
#ifdef __XTENSA_CALL0_ABI__
/* Restore a2 and a3. */

View File

@ -118,7 +118,7 @@ void IRAM_ATTR HDL_MAC_SIG_IN_LV1_ISR(void)
extern portBASE_TYPE MacIsrSigPostDefHdl(void);
void SoftIsrHdl(void* arg)
void TASK_SW_ATTR SoftIsrHdl(void* arg)
{
ETS_NMI_LOCK();
@ -137,7 +137,7 @@ void SoftIsrHdl(void* arg)
ETS_NMI_UNLOCK();
}
void xPortSysTickHandle(void)
void TASK_SW_ATTR xPortSysTickHandle(void)
{
if (xTaskIncrementTick() != pdFALSE) {
vTaskSwitchContext();
@ -284,7 +284,7 @@ void _xt_isr_attach(uint8_t i, _xt_isr func, void* arg)
isr[i].arg = arg;
}
uint16_t _xt_isr_handler(uint16_t i)
uint16_t TASK_SW_ATTR _xt_isr_handler(uint16_t i)
{
uint8_t index;

View File

@ -927,8 +927,12 @@ _xt_user_entry1:
s32i a1, a0, 0
mov a1, a0
#ifndef CONFIG_TASK_SWITCH_FASTER
movi a0, _xt_isr_handler
callx0 a0
#else
call0 _xt_isr_handler
#endif
movi a0, _chip_interrupt_tmp
l32i a1, a0, 0