Update to the latest atomic.h.
Improve commenting in RISC-V GCC port. Fix IAR RISC-V port so the first task starts with interrupts enabled. Add references to third party page ref using newlib with FreeRTOS into the tasks.c file in each place newlib is referenced. Move the position of the traceTASK_DELETE() trace macro in case of use with a memory allocator that writes over freed memory even when inside a critical section. Efficiency improvement: Make sure xTaskIncrementTick() does not return pdTRUE when the scheduler is locked. This just prevents an unnecessary yield interrupt (unnecessary as it is ignored) when xYieldPending happens to be pdTRUE.
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@ -172,7 +172,7 @@ handle_asynchronous:
|
||||
li t4, -1
|
||||
lw t2, 0(t1) /* Load the low word of ullNextTime into t2. */
|
||||
lw t3, 4(t1) /* Load the high word of ullNextTime into t3. */
|
||||
sw t4, 0(t0) /* Low word no smaller than old value to start with - will be overwritten below. */
|
||||
sw t4, 0(t0) /* Low word no smaller than old value. */
|
||||
sw t3, 4(t0) /* Store high word of ullNextTime into compare register. No smaller than new value. */
|
||||
sw t2, 0(t0) /* Store low word of ullNextTime into compare register. */
|
||||
lw t0, uxTimerIncrementsForOneTick /* Load the value of ullTimerIncrementForOneTick into t0 (could this be optimized by storing in an array next to pullNextTime?). */
|
||||
@ -402,7 +402,7 @@ xPortStartFirstTask:
|
||||
pxPortInitialiseStack:
|
||||
|
||||
csrr t0, mstatus /* Obtain current mstatus value. */
|
||||
addi t1, x0, 0x188 /* Generate the value 0x1888, which are the MIE, MPIE and privilege bits to set in mstatus. */
|
||||
addi t1, x0, 0x188 /* Generate the value 0x1880, which are the MPIE and MPP bits to set in mstatus. */
|
||||
slli t1, t1, 4
|
||||
or t0, t0, t1 /* Set MPIE and MPP bits in mstatus value. */
|
||||
|
||||
|
@ -65,6 +65,13 @@ typedef portBASE_TYPE BaseType_t;
|
||||
typedef portUBASE_TYPE UBaseType_t;
|
||||
typedef portUBASE_TYPE TickType_t;
|
||||
|
||||
/* Legacy type definitions. */
|
||||
#define portCHAR char
|
||||
#define portFLOAT float
|
||||
#define portDOUBLE double
|
||||
#define portLONG long
|
||||
#define portSHORT short
|
||||
|
||||
/* 32-bit tick type on a 32-bit architecture, so reads of the tick count do
|
||||
not need to be guarded with a critical section. */
|
||||
#define portTICK_TYPE_IS_ATOMIC 1
|
||||
|
@ -152,6 +152,12 @@ extern void xPortStartFirstTask( void );
|
||||
stack that was being used by main() prior to the scheduler being
|
||||
started. */
|
||||
configASSERT( ( xISRStackTop & portBYTE_ALIGNMENT_MASK ) == 0 );
|
||||
|
||||
#ifdef configISR_STACK_SIZE_WORDS
|
||||
{
|
||||
memset( ( void * ) xISRStack, portISR_STACK_FILL_BYTE, sizeof( xISRStack ) );
|
||||
}
|
||||
#endif /* configISR_STACK_SIZE_WORDS */
|
||||
}
|
||||
#endif /* configASSERT_DEFINED */
|
||||
|
||||
|
@ -180,7 +180,7 @@ handle_asynchronous:
|
||||
li t4, -1
|
||||
lw t2, 0(t1) /* Load the low word of ullNextTime into t2. */
|
||||
lw t3, 4(t1) /* Load the high word of ullNextTime into t3. */
|
||||
sw t4, 0(t0) /* Low word no smaller than old value. */
|
||||
sw t4, 0(t0) /* Low word no smaller than old value to start with - will be overwritten below. */
|
||||
sw t3, 4(t0) /* Store high word of ullNextTime into compare register. No smaller than new value. */
|
||||
sw t2, 0(t0) /* Store low word of ullNextTime into compare register. */
|
||||
lw t0, uxTimerIncrementsForOneTick /* Load the value of ullTimerIncrementForOneTick into t0 (could this be optimized by storing in an array next to pullNextTime?). */
|
||||
@ -304,6 +304,7 @@ xPortStartFirstTask:
|
||||
portasmRESTORE_ADDITIONAL_REGISTERS /* Defined in freertos_risc_v_chip_specific_extensions.h to restore any registers unique to the RISC-V implementation. */
|
||||
|
||||
load_x t0, 29 * portWORD_SIZE( sp ) /* mstatus */
|
||||
addi t0, t0, 0x08 /* Set MIE bit so the first task starts with interrupts enabled - required as returns with ret not eret. */
|
||||
csrrw x0, CSR_MSTATUS, t0 /* Interrupts enabled from here! */
|
||||
|
||||
load_x x5, 2 * portWORD_SIZE( sp ) /* t0 */
|
||||
|
@ -67,6 +67,13 @@ typedef portBASE_TYPE BaseType_t;
|
||||
typedef portUBASE_TYPE UBaseType_t;
|
||||
typedef portUBASE_TYPE TickType_t;
|
||||
|
||||
/* Legacy type definitions. */
|
||||
#define portCHAR char
|
||||
#define portFLOAT float
|
||||
#define portDOUBLE double
|
||||
#define portLONG long
|
||||
#define portSHORT short
|
||||
|
||||
/* 32-bit tick type on a 32-bit architecture, so reads of the tick count do
|
||||
not need to be guarded with a critical section. */
|
||||
#define portTICK_TYPE_IS_ATOMIC 1
|
||||
|
@ -300,7 +300,10 @@ typedef struct tskTaskControlBlock /* The old naming convention is used to pr
|
||||
responsible for resulting newlib operation. User must be familiar with
|
||||
newlib and must provide system-wide implementations of the necessary
|
||||
stubs. Be warned that (at the time of writing) the current newlib design
|
||||
implements a system-wide malloc() that must be provided with locks. */
|
||||
implements a system-wide malloc() that must be provided with locks.
|
||||
|
||||
See the third party link http://www.nadler.com/embedded/newlibAndFreeRTOS.html
|
||||
for additional information. */
|
||||
struct _reent xNewLib_reent;
|
||||
#endif
|
||||
|
||||
@ -993,7 +996,9 @@ UBaseType_t x;
|
||||
|
||||
#if ( configUSE_NEWLIB_REENTRANT == 1 )
|
||||
{
|
||||
/* Initialise this task's Newlib reent structure. */
|
||||
/* Initialise this task's Newlib reent structure.
|
||||
See the third party link http://www.nadler.com/embedded/newlibAndFreeRTOS.html
|
||||
for additional information. */
|
||||
_REENT_INIT_PTR( ( &( pxNewTCB->xNewLib_reent ) ) );
|
||||
}
|
||||
#endif
|
||||
@ -1218,12 +1223,12 @@ static void prvAddNewTaskToReadyList( TCB_t *pxNewTCB )
|
||||
else
|
||||
{
|
||||
--uxCurrentNumberOfTasks;
|
||||
traceTASK_DELETE( pxTCB );
|
||||
prvDeleteTCB( pxTCB );
|
||||
|
||||
/* Reset the next expected unblock time in case it referred to
|
||||
the task that has just been deleted. */
|
||||
prvResetNextTaskUnblockTime();
|
||||
traceTASK_DELETE( pxTCB );
|
||||
}
|
||||
}
|
||||
taskEXIT_CRITICAL();
|
||||
@ -2044,7 +2049,9 @@ BaseType_t xReturn;
|
||||
#if ( configUSE_NEWLIB_REENTRANT == 1 )
|
||||
{
|
||||
/* Switch Newlib's _impure_ptr variable to point to the _reent
|
||||
structure specific to the task that will run first. */
|
||||
structure specific to the task that will run first.
|
||||
See the third party link http://www.nadler.com/embedded/newlibAndFreeRTOS.html
|
||||
for additional information. */
|
||||
_impure_ptr = &( pxCurrentTCB->xNewLib_reent );
|
||||
}
|
||||
#endif /* configUSE_NEWLIB_REENTRANT */
|
||||
@ -2846,6 +2853,19 @@ BaseType_t xSwitchRequired = pdFALSE;
|
||||
}
|
||||
}
|
||||
#endif /* configUSE_TICK_HOOK */
|
||||
|
||||
#if ( configUSE_PREEMPTION == 1 )
|
||||
{
|
||||
if( xYieldPending != pdFALSE )
|
||||
{
|
||||
xSwitchRequired = pdTRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
mtCOVERAGE_TEST_MARKER();
|
||||
}
|
||||
}
|
||||
#endif /* configUSE_PREEMPTION */
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -2860,19 +2880,6 @@ BaseType_t xSwitchRequired = pdFALSE;
|
||||
#endif
|
||||
}
|
||||
|
||||
#if ( configUSE_PREEMPTION == 1 )
|
||||
{
|
||||
if( xYieldPending != pdFALSE )
|
||||
{
|
||||
xSwitchRequired = pdTRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
mtCOVERAGE_TEST_MARKER();
|
||||
}
|
||||
}
|
||||
#endif /* configUSE_PREEMPTION */
|
||||
|
||||
return xSwitchRequired;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
@ -3052,7 +3059,9 @@ void vTaskSwitchContext( void )
|
||||
#if ( configUSE_NEWLIB_REENTRANT == 1 )
|
||||
{
|
||||
/* Switch Newlib's _impure_ptr variable to point to the _reent
|
||||
structure specific to this task. */
|
||||
structure specific to this task.
|
||||
See the third party link http://www.nadler.com/embedded/newlibAndFreeRTOS.html
|
||||
for additional information. */
|
||||
_impure_ptr = &( pxCurrentTCB->xNewLib_reent );
|
||||
}
|
||||
#endif /* configUSE_NEWLIB_REENTRANT */
|
||||
@ -3874,7 +3883,9 @@ static void prvCheckTasksWaitingTermination( void )
|
||||
portCLEAN_UP_TCB( pxTCB );
|
||||
|
||||
/* Free up the memory allocated by the scheduler for the task. It is up
|
||||
to the task to free any memory allocated at the application level. */
|
||||
to the task to free any memory allocated at the application level.
|
||||
See the third party link http://www.nadler.com/embedded/newlibAndFreeRTOS.html
|
||||
for additional information. */
|
||||
#if ( configUSE_NEWLIB_REENTRANT == 1 )
|
||||
{
|
||||
_reclaim_reent( &( pxTCB->xNewLib_reent ) );
|
||||
|
Reference in New Issue
Block a user