From d67265f034c92f1609c15ec2dc69ec5d63cd0c7f Mon Sep 17 00:00:00 2001 From: dongheng Date: Wed, 6 Mar 2019 10:24:03 +0800 Subject: [PATCH 1/2] feat(freertos): Link SoftIsrHdl and its sub functions to IRAM --- components/esp8266/source/esp_wifi_os_adapter.c | 6 +++--- components/freertos/freertos/list.c | 4 ++-- components/freertos/freertos/queue.c | 6 +++--- components/freertos/freertos/tasks.c | 8 ++++---- components/freertos/port/esp8266/port.c | 4 ++-- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/components/esp8266/source/esp_wifi_os_adapter.c b/components/esp8266/source/esp_wifi_os_adapter.c index 519dc899..25aecacd 100644 --- a/components/esp8266/source/esp_wifi_os_adapter.c +++ b/components/esp8266/source/esp_wifi_os_adapter.c @@ -50,7 +50,7 @@ static void task_yield_wrapper(void) portYIELD(); } -static void task_yield_from_isr_wrapper(void) +static void IRAM_ATTR task_yield_from_isr_wrapper(void) { portYIELD(); } @@ -206,7 +206,7 @@ static bool queue_send_wrapper(void *queue, void *item, uint32_t block_time_tick return ret == pdPASS ? true : false; } -static bool queue_send_from_isr_wrapper(void *queue, void *item, int *hptw) +static bool IRAM_ATTR queue_send_from_isr_wrapper(void *queue, void *item, int *hptw) { signed portBASE_TYPE ret; @@ -342,7 +342,7 @@ void *osi_task_top_sp(void) return pxCurrentTCB[0]; } -const wifi_osi_funcs_t s_wifi_osi_funcs = { +wifi_osi_funcs_t s_wifi_osi_funcs = { .version = ESP_WIFI_OS_ADAPTER_VERSION, .task_create = task_create_wrapper, diff --git a/components/freertos/freertos/list.c b/components/freertos/freertos/list.c index 758523a3..bfc2f87a 100644 --- a/components/freertos/freertos/list.c +++ b/components/freertos/freertos/list.c @@ -71,7 +71,7 @@ void vListInitialiseItem( ListItem_t * const pxItem ) } /*-----------------------------------------------------------*/ -void vListInsertEnd( List_t * const pxList, ListItem_t * const pxNewListItem ) +void IRAM_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 IRAM_ATTR uxListRemove( ListItem_t * const pxItemToRemove ) { /* The list item knows which list it is in. Obtain the list from the list item. */ diff --git a/components/freertos/freertos/queue.c b/components/freertos/freertos/queue.c index c37d285f..463a33a2 100644 --- a/components/freertos/freertos/queue.c +++ b/components/freertos/freertos/queue.c @@ -920,7 +920,7 @@ Queue_t * const pxQueue = ( Queue_t * ) xQueue; } /*-----------------------------------------------------------*/ -BaseType_t xQueueGenericSendFromISR( QueueHandle_t xQueue, const void * const pvItemToQueue, BaseType_t * const pxHigherPriorityTaskWoken, const BaseType_t xCopyPosition ) +BaseType_t IRAM_ATTR xQueueGenericSendFromISR( QueueHandle_t xQueue, const void * const pvItemToQueue, BaseType_t * const pxHigherPriorityTaskWoken, const BaseType_t xCopyPosition ) { BaseType_t xReturn; UBaseType_t uxSavedInterruptStatus; @@ -2037,7 +2037,7 @@ Queue_t * const pxQueue = ( Queue_t * ) xQueue; #endif /* configUSE_MUTEXES */ /*-----------------------------------------------------------*/ -static BaseType_t prvCopyDataToQueue( Queue_t * const pxQueue, const void *pvItemToQueue, const BaseType_t xPosition ) +static BaseType_t IRAM_ATTR prvCopyDataToQueue( Queue_t * const pxQueue, const void *pvItemToQueue, const BaseType_t xPosition ) { BaseType_t xReturn = pdFALSE; UBaseType_t uxMessagesWaiting; @@ -2843,7 +2843,7 @@ BaseType_t xReturn; #if ( configUSE_QUEUE_SETS == 1 ) - static BaseType_t prvNotifyQueueSetContainer( const Queue_t * const pxQueue, const BaseType_t xCopyPosition ) + static BaseType_t IRAM_ATTR prvNotifyQueueSetContainer( const Queue_t * const pxQueue, const BaseType_t xCopyPosition ) { Queue_t *pxQueueSetContainer = pxQueue->pxQueueSetContainer; BaseType_t xReturn = pdFALSE; diff --git a/components/freertos/freertos/tasks.c b/components/freertos/freertos/tasks.c index 4c3cf1d8..1cd9c9f4 100644 --- a/components/freertos/freertos/tasks.c +++ b/components/freertos/freertos/tasks.c @@ -2873,7 +2873,7 @@ BaseType_t xSwitchRequired = pdFALSE; #endif /* configUSE_APPLICATION_TASK_TAG */ /*-----------------------------------------------------------*/ -void vTaskSwitchContext( void ) +void IRAM_ATTR vTaskSwitchContext( void ) { if( uxSchedulerSuspended != ( UBaseType_t ) pdFALSE ) { @@ -3006,7 +3006,7 @@ void vTaskPlaceOnUnorderedEventList( List_t * pxEventList, const TickType_t xIte #endif /* configUSE_TIMERS */ /*-----------------------------------------------------------*/ -BaseType_t xTaskRemoveFromEventList( const List_t * const pxEventList ) +BaseType_t IRAM_ATTR xTaskRemoveFromEventList( const List_t * const pxEventList ) { TCB_t *pxUnblockedTCB; BaseType_t xReturn; @@ -3781,7 +3781,7 @@ static void prvCheckTasksWaitingTermination( void ) #endif /* INCLUDE_vTaskDelete */ /*-----------------------------------------------------------*/ -static void prvResetNextTaskUnblockTime( void ) +static void IRAM_ATTR prvResetNextTaskUnblockTime( void ) { TCB_t *pxTCB; @@ -3939,7 +3939,7 @@ TCB_t *pxTCB; #if ( configUSE_MUTEXES == 1 ) - BaseType_t xTaskPriorityDisinherit( TaskHandle_t const pxMutexHolder ) + BaseType_t IRAM_ATTR xTaskPriorityDisinherit( TaskHandle_t const pxMutexHolder ) { TCB_t * const pxTCB = ( TCB_t * ) pxMutexHolder; BaseType_t xReturn = pdFALSE; diff --git a/components/freertos/port/esp8266/port.c b/components/freertos/port/esp8266/port.c index 70e077c4..f03b2e9e 100644 --- a/components/freertos/port/esp8266/port.c +++ b/components/freertos/port/esp8266/port.c @@ -118,7 +118,7 @@ void IRAM_ATTR HDL_MAC_SIG_IN_LV1_ISR(void) extern portBASE_TYPE MacIsrSigPostDefHdl(void); -void SoftIsrHdl(void* arg) +void IRAM_ATTR SoftIsrHdl(void* arg) { ETS_NMI_LOCK(); @@ -130,7 +130,7 @@ void SoftIsrHdl(void* arg) } if (xHigherPriorityTaskWoken || (SWReq == 1)) { - _xt_timer_int1(); + _xt_timer_int1(); // call vTaskSwitchContext SWReq = 0; } From 1c975959fb8dff563a82409152f50f54eff03f76 Mon Sep 17 00:00:00 2001 From: dongheng Date: Wed, 6 Mar 2019 10:26:11 +0800 Subject: [PATCH 2/2] feat(heap): Link heap to IRAM --- components/esp8266/ld/esp8266.common.ld | 2 ++ components/esp8266/source/esp_wifi_os_adapter.c | 10 +++++----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/components/esp8266/ld/esp8266.common.ld b/components/esp8266/ld/esp8266.common.ld index f35ca08a..2894f55e 100644 --- a/components/esp8266/ld/esp8266.common.ld +++ b/components/esp8266/ld/esp8266.common.ld @@ -133,6 +133,8 @@ SECTIONS *libesp8266.a:ets_printf.o(.literal .text .literal.* .text.* .rodata.* .rodata) #endif + *libheap.a:(.literal .text .literal.* .text.*) + _text_end = ABSOLUTE(.); _etext = .; } >iram1_0_seg :iram1_0_phdr diff --git a/components/esp8266/source/esp_wifi_os_adapter.c b/components/esp8266/source/esp_wifi_os_adapter.c index 25aecacd..001b0b32 100644 --- a/components/esp8266/source/esp_wifi_os_adapter.c +++ b/components/esp8266/source/esp_wifi_os_adapter.c @@ -272,7 +272,7 @@ static bool timer_delete_wrapper(void *timer, uint32_t ticks) return xTimerDelete(timer, ticks); } -static void *malloc_wrapper(uint32_t s, uint32_t cap, const char *file, size_t line) +static void IRAM_ATTR *malloc_wrapper(uint32_t s, uint32_t cap, const char *file, size_t line) { uint32_t os_caps; @@ -284,7 +284,7 @@ static void *malloc_wrapper(uint32_t s, uint32_t cap, const char *file, size_t l return _heap_caps_malloc(s, os_caps, file, line); } -static void *zalloc_wrapper(uint32_t s, uint32_t cap, const char *file, size_t line) +static void IRAM_ATTR *zalloc_wrapper(uint32_t s, uint32_t cap, const char *file, size_t line) { uint32_t os_caps; @@ -296,7 +296,7 @@ static void *zalloc_wrapper(uint32_t s, uint32_t cap, const char *file, size_t l return _heap_caps_zalloc(s, os_caps, file, line); } -static void *realloc_wrapper(void *ptr, uint32_t s, uint32_t cap, const char *file, size_t line) +static void IRAM_ATTR *realloc_wrapper(void *ptr, uint32_t s, uint32_t cap, const char *file, size_t line) { uint32_t os_caps; @@ -308,7 +308,7 @@ static void *realloc_wrapper(void *ptr, uint32_t s, uint32_t cap, const char *fi return _heap_caps_realloc(ptr, s, os_caps, file, line); } -static void *calloc_wrapper(uint32_t cnt, uint32_t s, uint32_t cap, const char *file, size_t line) +static void IRAM_ATTR *calloc_wrapper(uint32_t cnt, uint32_t s, uint32_t cap, const char *file, size_t line) { uint32_t os_caps; @@ -320,7 +320,7 @@ static void *calloc_wrapper(uint32_t cnt, uint32_t s, uint32_t cap, const char * return _heap_caps_calloc(cnt , s, os_caps, file, line); } -static void free_wrapper(void *ptr, const char *file, size_t line) +static void IRAM_ATTR free_wrapper(void *ptr, const char *file, size_t line) { _heap_caps_free(ptr, file, line); }