Move all code paths touched by NMI to IRAM

Prerequisite for calling Cache_Read_Disable() for OTA updates.

Massive thanks due to @foogod and their xtobjdis tool, creating the call
graph of where the wDev_ProcessFiq touched (including in newlib, etc.)
would have otherwise been very painful:
https://bitbucket.org/foogod/xtobjdis
This commit is contained in:
Angus Gratton 2015-07-29 10:34:09 +10:00
parent 28fdebee92
commit efc454035c
7 changed files with 44 additions and 24 deletions

View file

@ -98,7 +98,7 @@ void vListInitialiseItem( xListItem * const pxItem )
}
/*-----------------------------------------------------------*/
void vListInsertEnd( xList * const pxList, xListItem * const pxNewListItem )
void IRAM vListInsertEnd( xList * const pxList, xListItem * const pxNewListItem )
{
xListItem * pxIndex;
@ -119,7 +119,7 @@ xListItem * pxIndex;
}
/*-----------------------------------------------------------*/
void vListInsert( xList * const pxList, xListItem * const pxNewListItem )
void IRAM vListInsert( xList * const pxList, xListItem * const pxNewListItem )
{
xListItem *pxIterator;
portTickType xValueOfInsertion;
@ -177,7 +177,7 @@ portTickType xValueOfInsertion;
}
/*-----------------------------------------------------------*/
unsigned portBASE_TYPE uxListRemove( xListItem * const pxItemToRemove )
unsigned portBASE_TYPE IRAM uxListRemove( xListItem * const pxItemToRemove )
{
xList * pxList;

View file

@ -265,7 +265,7 @@ void IRAM vPortExitCritical( void )
_xt_isr isr[16];
void _xt_isr_attach(uint8_t i, _xt_isr func)
void IRAM _xt_isr_attach(uint8_t i, _xt_isr func)
{
isr[i] = func;
}

View file

@ -179,7 +179,7 @@ typedef struct QueueDefinition
* to indicate that a task may require unblocking. When the queue in unlocked
* these lock counts are inspected, and the appropriate action taken.
*/
static void prvUnlockQueue( xQUEUE *pxQueue ) PRIVILEGED_FUNCTION;
static void IRAM prvUnlockQueue( xQUEUE *pxQueue ) PRIVILEGED_FUNCTION;
/*
* Uses a critical section to determine if there is any data in a queue.
@ -543,7 +543,7 @@ xQueueHandle xReturn = NULL;
#endif /* configUSE_COUNTING_SEMAPHORES */
/*-----------------------------------------------------------*/
signed portBASE_TYPE xQueueGenericSend( xQueueHandle xQueue, const void * const pvItemToQueue, portTickType xTicksToWait, portBASE_TYPE xCopyPosition )
signed portBASE_TYPE IRAM xQueueGenericSend( xQueueHandle xQueue, const void * const pvItemToQueue, portTickType xTicksToWait, portBASE_TYPE xCopyPosition )
{
signed portBASE_TYPE xEntryTimeSet = pdFALSE;
xTimeOutType xTimeOut;
@ -1316,7 +1316,7 @@ unsigned portBASE_TYPE uxReturn;
} /*lint !e818 Pointer cannot be declared const as xQueue is a typedef not pointer. */
/*-----------------------------------------------------------*/
unsigned portBASE_TYPE uxQueueMessagesWaitingFromISR( const xQueueHandle xQueue )
unsigned portBASE_TYPE IRAM uxQueueMessagesWaitingFromISR( const xQueueHandle xQueue )
{
unsigned portBASE_TYPE uxReturn;
@ -1374,7 +1374,7 @@ xQUEUE * const pxQueue = ( xQUEUE * ) xQueue;
#endif /* configUSE_TRACE_FACILITY */
/*-----------------------------------------------------------*/
static void prvCopyDataToQueue( xQUEUE *pxQueue, const void *pvItemToQueue, portBASE_TYPE xPosition )
static void IRAM prvCopyDataToQueue( xQUEUE *pxQueue, const void *pvItemToQueue, portBASE_TYPE xPosition )
{
if( pxQueue->uxItemSize == ( unsigned portBASE_TYPE ) 0 )
{
@ -1436,7 +1436,7 @@ static void prvCopyDataFromQueue( xQUEUE * const pxQueue, const void * const pvB
}
}
/*-----------------------------------------------------------*/
static void prvUnlockQueue( xQUEUE *pxQueue )
static void IRAM prvUnlockQueue( xQUEUE *pxQueue )
{
/* THIS FUNCTION MUST BE CALLED WITH THE SCHEDULER SUSPENDED. */

View file

@ -427,7 +427,7 @@ static void prvCheckTasksWaitingTermination( void ) PRIVILEGED_FUNCTION;
* The currently executing task is entering the Blocked state. Add the task to
* either the current or the overflow delayed task list.
*/
static void prvAddCurrentTaskToDelayedList( portTickType xTimeToWake ) PRIVILEGED_FUNCTION;
static void IRAM prvAddCurrentTaskToDelayedList( portTickType xTimeToWake ) PRIVILEGED_FUNCTION;
/*
* Allocates memory from the heap for a TCB and associated stack. Checks the
@ -1297,7 +1297,7 @@ void vTaskEndScheduler( void )
}
/*----------------------------------------------------------*/
void vTaskSuspendAll( void )
void IRAM vTaskSuspendAll( void )
{
/* A critical section is not required as the variable is of type
portBASE_TYPE. */
@ -1333,7 +1333,7 @@ void vTaskSuspendAll( void )
#endif /* configUSE_TICKLESS_IDLE */
/*----------------------------------------------------------*/
signed portBASE_TYPE xTaskResumeAll( void )
signed portBASE_TYPE IRAM xTaskResumeAll( void )
{
tskTCB *pxTCB;
portBASE_TYPE xAlreadyYielded = pdFALSE;
@ -1568,7 +1568,7 @@ implementations require configUSE_TICKLESS_IDLE to be set to a value other than
#endif /* configUSE_TICKLESS_IDLE */
/*----------------------------------------------------------*/
portBASE_TYPE xTaskIncrementTick( void )
portBASE_TYPE IRAM xTaskIncrementTick( void )
{
tskTCB * pxTCB;
portTickType xItemValue;
@ -1843,7 +1843,7 @@ void vTaskSwitchContext( void )
}
/*-----------------------------------------------------------*/
void vTaskPlaceOnEventList( xList * const pxEventList, portTickType xTicksToWait )
void IRAM vTaskPlaceOnEventList( xList * const pxEventList, portTickType xTicksToWait )
{
portTickType xTimeToWake;
@ -1936,7 +1936,7 @@ portTickType xTimeToWake;
#endif /* configUSE_TIMERS */
/*-----------------------------------------------------------*/
signed portBASE_TYPE xTaskRemoveFromEventList( const xList * const pxEventList )
signed portBASE_TYPE IRAM xTaskRemoveFromEventList( const xList * const pxEventList )
{
tskTCB *pxUnblockedTCB;
portBASE_TYPE xReturn;
@ -1987,7 +1987,7 @@ portBASE_TYPE xReturn;
}
/*-----------------------------------------------------------*/
void vTaskSetTimeOutState( xTimeOutType * const pxTimeOut )
void IRAM vTaskSetTimeOutState( xTimeOutType * const pxTimeOut )
{
configASSERT( pxTimeOut );
pxTimeOut->xOverflowCount = xNumOfOverflows;
@ -1995,7 +1995,7 @@ void vTaskSetTimeOutState( xTimeOutType * const pxTimeOut )
}
/*-----------------------------------------------------------*/
portBASE_TYPE xTaskCheckForTimeOut( xTimeOutType * const pxTimeOut, portTickType * const pxTicksToWait )
portBASE_TYPE IRAM xTaskCheckForTimeOut( xTimeOutType * const pxTimeOut, portTickType * const pxTicksToWait )
{
portBASE_TYPE xReturn;
@ -2044,7 +2044,7 @@ portBASE_TYPE xReturn;
}
/*-----------------------------------------------------------*/
void vTaskMissedYield( void )
void IRAM vTaskMissedYield( void )
{
xYieldPending = pdTRUE;
}
@ -2397,7 +2397,7 @@ static void prvCheckTasksWaitingTermination( void )
}
/*-----------------------------------------------------------*/
static void prvAddCurrentTaskToDelayedList( portTickType xTimeToWake )
static void IRAM prvAddCurrentTaskToDelayedList( portTickType xTimeToWake )
{
/* The list item will be inserted in wake time order. */
listSET_LIST_ITEM_VALUE( &( pxCurrentTCB->xGenericListItem ), xTimeToWake );
@ -2676,7 +2676,7 @@ tskTCB *pxNewTCB;
#if ( configUSE_MUTEXES == 1 )
void vTaskPriorityDisinherit( xTaskHandle const pxMutexHolder )
void IRAM vTaskPriorityDisinherit( xTaskHandle const pxMutexHolder )
{
tskTCB * const pxTCB = ( tskTCB * ) pxMutexHolder;

View file

@ -7,9 +7,10 @@
#include <sys/reent.h>
#include <sys/types.h>
#include <espressif/sdk_private.h>
#include <common_macros.h>
#include <stdlib.h>
caddr_t _sbrk_r (struct _reent *r, int incr)
IRAM caddr_t _sbrk_r (struct _reent *r, int incr)
{
extern char _heap_start; /* linker script defined */
static char * heap_end;

View file

@ -8,8 +8,9 @@
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <common_macros.h>
void *zalloc(size_t nbytes)
void IRAM *zalloc(size_t nbytes)
{
return calloc(1, nbytes);
}

View file

@ -229,10 +229,28 @@ SECTIONS
*(.iram1.*)
/* SDK libraries expect their .text sections to link to iram, not irom */
*sdklib*:*(.literal .text .literal.* .text.*)
/* libgcc functions also need to be in .text, as some are called before
/* libgcc integer functions also need to be in .text, as some are called before
flash is mapped (also performance)
*/
*libgcc.a:*.o(.literal .text .literal.* .text.*)
*libgcc.a:*i3.o(.literal .text .literal.* .text.*)
/* libc also in IRAM */
*libc.a:*malloc.o(.literal .text .literal.* .text.*)
*libc.a:*mallocr.o(.literal .text .literal.* .text.*)
*libc.a:*freer.o(.literal .text .literal.* .text.*)
*libc.a:*memcpy.o(.literal .text .literal.* .text.*)
*libc.a:*memset.o(.literal .text .literal.* .text.*)
*libc.a:*memcmp.o(.literal .text .literal.* .text.*)
*libc.a:*rand.o(.literal .text .literal.* .text.*)
*libc.a:*bzero.o(.literal .text .literal.* .text.*)
*libc.a:*lock.o(.literal .text .literal.* .text.*)
*libc.a:*printf.o(.literal .text .literal.* .text.*)
*libc.a:*findfp.o(.literal .text .literal.* .text.*)
*libc.a:*fputwc.o(.literal .text .literal.* .text.*)
/* xthal_set_intset() called from PendSV in NMI context */
*libhal.a:*set_intset.o(.literal .text .literal.* .text.*)
*(.stub .gnu.warning .gnu.linkonce.literal.* .gnu.linkonce.t.*.literal .gnu.linkonce.t.*)
*(.fini.literal)