mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2025-08-01 08:54:14 -04:00
Demo application related:
+ Update the RZ IAR project so it targets the RZ RSK rather than custom hardware. + Update the RZ ARM/DS-5 project so it targets the RZ RSK rather than custom hardware. + Updated RX64M demos to use the new iodefine.h naming. Cortex-A9 port related: + Update IAR, ARM and GCC Cortex-A9 port layers to include a 'task exit error' function which is called if a task attempts to incorrectly exit its implementing function. + Moved the instruction which switches into system mode out of the restore context macro, as it is only needed when starting the first task. Core kernel files related: + Ensure there are no references to the mutexes held count when mutexes are excluded from the build.
This commit is contained in:
parent
162448f06b
commit
52e687086c
37 changed files with 264 additions and 125 deletions
|
@ -176,6 +176,15 @@ the CPU itself before modifying certain hardware registers. */
|
|||
#define portMAX_8_BIT_VALUE ( ( uint8_t ) 0xff )
|
||||
#define portBIT_0_SET ( ( uint8_t ) 0x01 )
|
||||
|
||||
/* Let the user override the pre-loading of the initial LR with the address of
|
||||
prvTaskExitError() in case is messes up unwinding of the stack in the
|
||||
debugger. */
|
||||
#ifdef configTASK_RETURN_ADDRESS
|
||||
#define portTASK_RETURN_ADDRESS configTASK_RETURN_ADDRESS
|
||||
#else
|
||||
#define portTASK_RETURN_ADDRESS prvTaskExitError
|
||||
#endif
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
|
@ -184,6 +193,11 @@ the CPU itself before modifying certain hardware registers. */
|
|||
*/
|
||||
extern void vPortRestoreTaskContext( void );
|
||||
|
||||
/*
|
||||
* Used to catch tasks that attempt to return from their implementing function.
|
||||
*/
|
||||
static void prvTaskExitError( void );
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/* A variable is used to keep track of the critical section nesting. This
|
||||
|
@ -243,7 +257,7 @@ StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, TaskFunction_t px
|
|||
pxTopOfStack--;
|
||||
|
||||
/* Next all the registers other than the stack pointer. */
|
||||
*pxTopOfStack = ( StackType_t ) 0x00000000; /* R14 */
|
||||
*pxTopOfStack = ( StackType_t ) portTASK_RETURN_ADDRESS; /* R14 */
|
||||
pxTopOfStack--;
|
||||
*pxTopOfStack = ( StackType_t ) 0x12121212; /* R12 */
|
||||
pxTopOfStack--;
|
||||
|
@ -286,6 +300,20 @@ StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, TaskFunction_t px
|
|||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static void prvTaskExitError( void )
|
||||
{
|
||||
/* A function that implements a task must not exit or attempt to return to
|
||||
its caller as there is nothing to return to. If a task wants to exit it
|
||||
should instead call vTaskDelete( NULL ).
|
||||
|
||||
Artificially force an assert() to be triggered if configASSERT() is
|
||||
defined, then stop here so application writers can catch the error. */
|
||||
configASSERT( ulPortInterruptNesting == ~0UL );
|
||||
portDISABLE_INTERRUPTS();
|
||||
for( ;; );
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
BaseType_t xPortStartScheduler( void )
|
||||
{
|
||||
uint32_t ulAPSR;
|
||||
|
@ -380,7 +408,7 @@ void vPortEnterCritical( void )
|
|||
ulCriticalNesting++;
|
||||
|
||||
/* This is not the interrupt safe version of the enter critical function so
|
||||
assert() if it is being called from an interrupt context. Only API
|
||||
assert() if it is being called from an interrupt context. Only API
|
||||
functions that end in "FromISR" can be used in an interrupt. Only assert if
|
||||
the critical nesting count is 1 to protect against recursive calls if the
|
||||
assert function also uses a critical section. */
|
||||
|
|
|
@ -120,9 +120,6 @@
|
|||
|
||||
.macro portRESTORE_CONTEXT
|
||||
|
||||
/* Switch to system mode. */
|
||||
CPS #SYS_MODE
|
||||
|
||||
/* Set the SP to point to the stack of the task being restored. */
|
||||
LDR R0, pxCurrentTCBConst
|
||||
LDR R1, [R0]
|
||||
|
@ -168,7 +165,7 @@
|
|||
|
||||
|
||||
/******************************************************************************
|
||||
* SVC handler is used to start the scheduler and yield a task.
|
||||
* SVC handler is used to start the scheduler.
|
||||
*****************************************************************************/
|
||||
.align 4
|
||||
.type FreeRTOS_SWI_Handler, %function
|
||||
|
@ -177,9 +174,16 @@ FreeRTOS_SWI_Handler:
|
|||
portSAVE_CONTEXT
|
||||
LDR R0, vTaskSwitchContextConst
|
||||
BLX R0
|
||||
portRESTORE_CONTEXT
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* vPortRestoreTaskContext is used to start the scheduler.
|
||||
*****************************************************************************/
|
||||
.type vPortRestoreTaskContext, %function
|
||||
vPortRestoreTaskContext:
|
||||
/* Switch to system mode. */
|
||||
CPS #SYS_MODE
|
||||
portRESTORE_CONTEXT
|
||||
|
||||
.align 4
|
||||
|
|
|
@ -74,6 +74,9 @@
|
|||
/* Library includes. */
|
||||
#include "string.h"
|
||||
|
||||
/* Hardware specifics. */
|
||||
#include "iodefine.h"
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/* Tasks should start with interrupts enabled and in Supervisor mode, therefore
|
||||
|
|
|
@ -166,6 +166,11 @@ mode. */
|
|||
*/
|
||||
extern void vPortRestoreTaskContext( void );
|
||||
|
||||
/*
|
||||
* Used to catch tasks that attempt to return from their implementing function.
|
||||
*/
|
||||
static void prvTaskExitError( void );
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/* A variable is used to keep track of the critical section nesting. This
|
||||
|
@ -175,8 +180,8 @@ the scheduler starts. As it is stored as part of the task context it will
|
|||
automatically be set to 0 when the first task is started. */
|
||||
volatile uint32_t ulCriticalNesting = 9999UL;
|
||||
|
||||
/* Saved as part of the task context. If ulPortTaskHasFPUContext is non-zero then
|
||||
a floating point context must be saved and restored for the task. */
|
||||
/* Saved as part of the task context. If ulPortTaskHasFPUContext is non-zero
|
||||
then a floating point context must be saved and restored for the task. */
|
||||
uint32_t ulPortTaskHasFPUContext = pdFALSE;
|
||||
|
||||
/* Set to 1 to pend a context switch from an ISR. */
|
||||
|
@ -221,7 +226,7 @@ StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, TaskFunction_t px
|
|||
pxTopOfStack--;
|
||||
|
||||
/* Next all the registers other than the stack pointer. */
|
||||
*pxTopOfStack = ( StackType_t ) 0x00000000; /* R14 */
|
||||
*pxTopOfStack = ( StackType_t ) prvTaskExitError; /* R14 */
|
||||
pxTopOfStack--;
|
||||
*pxTopOfStack = ( StackType_t ) 0x12121212; /* R12 */
|
||||
pxTopOfStack--;
|
||||
|
@ -264,6 +269,20 @@ StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, TaskFunction_t px
|
|||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static void prvTaskExitError( void )
|
||||
{
|
||||
/* A function that implements a task must not exit or attempt to return to
|
||||
its caller as there is nothing to return to. If a task wants to exit it
|
||||
should instead call vTaskDelete( NULL ).
|
||||
|
||||
Artificially force an assert() to be triggered if configASSERT() is
|
||||
defined, then stop here so application writers can catch the error. */
|
||||
configASSERT( ulPortInterruptNesting == ~0UL );
|
||||
portDISABLE_INTERRUPTS();
|
||||
for( ;; );
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
BaseType_t xPortStartScheduler( void )
|
||||
{
|
||||
uint32_t ulAPSR;
|
||||
|
|
|
@ -97,9 +97,6 @@ portSAVE_CONTEXT macro
|
|||
|
||||
portRESTORE_CONTEXT macro
|
||||
|
||||
; Switch to system mode
|
||||
CPS #SYS_MODE
|
||||
|
||||
; Set the SP to point to the stack of the task being restored.
|
||||
LDR R0, =pxCurrentTCB
|
||||
LDR R1, [R0]
|
||||
|
|
|
@ -75,7 +75,7 @@ IRQ_MODE EQU 0x12
|
|||
INCLUDE portASM.h
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
; SVC handler is used to start the scheduler and yield a task.
|
||||
; SVC handler is used to yield a task.
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
FreeRTOS_SWI_Handler
|
||||
|
||||
|
@ -85,10 +85,15 @@ FreeRTOS_SWI_Handler
|
|||
portSAVE_CONTEXT
|
||||
LDR R0, =vTaskSwitchContext
|
||||
BLX R0
|
||||
|
||||
vPortRestoreTaskContext
|
||||
portRESTORE_CONTEXT
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
; vPortRestoreTaskContext is used to start the scheduler.
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
vPortRestoreTaskContext
|
||||
; Switch to system mode
|
||||
CPS #SYS_MODE
|
||||
portRESTORE_CONTEXT
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
; PL390 GIC interrupt handler
|
||||
|
@ -167,7 +172,7 @@ exit_without_switch
|
|||
MOVS PC, LR
|
||||
|
||||
switch_before_exit
|
||||
; A context swtich is to be performed. Clear the context switch pending
|
||||
; A context switch is to be performed. Clear the context switch pending
|
||||
; flag.
|
||||
MOV r0, #0
|
||||
STR r0, [r1]
|
||||
|
|
|
@ -198,6 +198,11 @@ mode. */
|
|||
*/
|
||||
extern void vPortRestoreTaskContext( void );
|
||||
|
||||
/*
|
||||
* Used to catch tasks that attempt to return from their implementing function.
|
||||
*/
|
||||
static void prvTaskExitError( void );
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/* A variable is used to keep track of the critical section nesting. This
|
||||
|
@ -260,7 +265,7 @@ StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, TaskFunction_t px
|
|||
pxTopOfStack--;
|
||||
|
||||
/* Next all the registers other than the stack pointer. */
|
||||
*pxTopOfStack = ( StackType_t ) 0x00000000; /* R14 */
|
||||
*pxTopOfStack = ( StackType_t ) prvTaskExitError; /* R14 */
|
||||
pxTopOfStack--;
|
||||
*pxTopOfStack = ( StackType_t ) 0x12121212; /* R12 */
|
||||
pxTopOfStack--;
|
||||
|
@ -303,6 +308,20 @@ StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, TaskFunction_t px
|
|||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static void prvTaskExitError( void )
|
||||
{
|
||||
/* A function that implements a task must not exit or attempt to return to
|
||||
its caller as there is nothing to return to. If a task wants to exit it
|
||||
should instead call vTaskDelete( NULL ).
|
||||
|
||||
Artificially force an assert() to be triggered if configASSERT() is
|
||||
defined, then stop here so application writers can catch the error. */
|
||||
configASSERT( ulPortInterruptNesting == ~0UL );
|
||||
portDISABLE_INTERRUPTS();
|
||||
for( ;; );
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
BaseType_t xPortStartScheduler( void )
|
||||
{
|
||||
uint32_t ulAPSR;
|
||||
|
@ -354,6 +373,16 @@ void vPortEnterCritical( void )
|
|||
directly. Increment ulCriticalNesting to keep a count of how many times
|
||||
portENTER_CRITICAL() has been called. */
|
||||
ulCriticalNesting++;
|
||||
|
||||
/* This is not the interrupt safe version of the enter critical function so
|
||||
assert() if it is being called from an interrupt context. Only API
|
||||
functions that end in "FromISR" can be used in an interrupt. Only assert if
|
||||
the critical nesting count is 1 to protect against recursive calls if the
|
||||
assert function also uses a critical section. */
|
||||
if( ulCriticalNesting == 1 )
|
||||
{
|
||||
configASSERT( ulPortInterruptNesting == 0 );
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
|
|
|
@ -71,7 +71,7 @@
|
|||
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
; SVC handler is used to start the scheduler and yield a task.
|
||||
; SVC handler is used to yield a task.
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
FreeRTOS_SWI_Handler
|
||||
|
||||
|
@ -81,10 +81,15 @@ FreeRTOS_SWI_Handler
|
|||
portSAVE_CONTEXT
|
||||
LDR R0, =vTaskSwitchContext
|
||||
BLX R0
|
||||
|
||||
vPortRestoreTaskContext
|
||||
portRESTORE_CONTEXT
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
; vPortRestoreTaskContext is used to start the scheduler.
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
vPortRestoreTaskContext
|
||||
; Switch to system mode
|
||||
CPS #SYS_MODE
|
||||
portRESTORE_CONTEXT
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
; PL390 GIC interrupt handler
|
||||
|
@ -132,7 +137,7 @@ FreeRTOS_IRQ_Handler
|
|||
ADD sp, sp, r2
|
||||
|
||||
CPSID i
|
||||
|
||||
|
||||
; Write the value read from ICCIAR to ICCEOIR
|
||||
LDR r4, =ulICCEOIR
|
||||
STR r0, [r4]
|
||||
|
|
|
@ -104,9 +104,6 @@ IRQ_MODE EQU 0x12
|
|||
MACRO
|
||||
portRESTORE_CONTEXT
|
||||
|
||||
; Switch to system mode
|
||||
CPS #SYS_MODE
|
||||
|
||||
; Set the SP to point to the stack of the task being restored.
|
||||
LDR R0, =pxCurrentTCB
|
||||
LDR R1, [R0]
|
||||
|
|
|
@ -74,6 +74,9 @@
|
|||
/* Library includes. */
|
||||
#include "string.h"
|
||||
|
||||
/* Hardware specifics. */
|
||||
#include "iodefine.h"
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/* Tasks should start with interrupts enabled and in Supervisor mode, therefore
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue