#warning configINSTALL_FREERTOS_VECTOR_TABLE was undefined. Defaulting configINSTALL_FREERTOS_VECTOR_TABLE to 0.\r
#endif\r
\r
+#ifndef configCLEAR_TICK_INTERRUPT\r
+ #define configCLEAR_TICK_INTERRUPT()\r
+#endif\r
+\r
/* A critical section is exited when the critical section nesting count reaches\r
this value. */\r
#define portNO_CRITICAL_NESTING ( ( uint32_t ) 0 )\r
determined priority level. Sometimes it is necessary to turn interrupt off in\r
the CPU itself before modifying certain hardware registers. */\r
#define portCPU_IRQ_DISABLE() \\r
- __asm volatile ( "CPSID i" ); \\r
- __asm volatile ( "DSB" ); \\r
+ __asm volatile ( "CPSID i" ); \\r
+ __asm volatile ( "DSB" ); \\r
__asm volatile ( "ISB" );\r
\r
#define portCPU_IRQ_ENABLE() \\r
- __asm volatile ( "CPSIE i" ); \\r
- __asm volatile ( "DSB" ); \\r
+ __asm volatile ( "CPSIE i" ); \\r
+ __asm volatile ( "DSB" ); \\r
__asm volatile ( "ISB" );\r
\r
\r
/* Macro to unmask all interrupt priorities. */\r
-#define portCLEAR_INTERRUPT_MASK() \\r
-{ \\r
+#define portCLEAR_INTERRUPT_MASK() \\r
+{ \\r
portCPU_IRQ_DISABLE(); \\r
- portICCPMR_PRIORITY_MASK_REGISTER = portUNMASK_VALUE; \\r
- __asm( "DSB \n" \\r
- "ISB \n" ); \\r
+ portICCPMR_PRIORITY_MASK_REGISTER = portUNMASK_VALUE; \\r
+ __asm( "DSB \n" \\r
+ "ISB \n" ); \\r
portCPU_IRQ_ENABLE(); \\r
}\r
\r
\r
/* Ensure all interrupt priorities are active again. */\r
portCLEAR_INTERRUPT_MASK();\r
+ configCLEAR_TICK_INTERRUPT();\r
}\r
/*-----------------------------------------------------------*/\r
\r
.set SVC_MODE, 0x13\r
.set IRQ_MODE, 0x12\r
\r
+ /* Hardware registers. */\r
.extern ulICCIAR\r
.extern ulICCEOIR\r
- .extern ulMaxAPIPriorityMask\r
.extern ulICCPMR\r
- .extern _freertos_vector_table\r
-\r
- .global FreeRTOS_vector_table\r
- .global FIQInterrupt\r
- .global Undefined\r
- .global PrefetchAbortHandler\r
- .global DataAbortInterrupt\r
\r
+ /* Variables and functions. */\r
+ .extern ulMaxAPIPriorityMask\r
+ .extern _freertos_vector_table\r
.extern pxCurrentTCB\r
- .extern XIntc_DeviceInterruptHandler\r
.extern vTaskSwitchContext\r
- .extern uxCriticalNesting\r
- .extern pulISRStack\r
- .extern ulTaskSwitchRequested\r
- .extern vPortExceptionHandler\r
- .extern pulStackPointerOnFunctionEntry\r
+ .extern vApplicationIRQHandler\r
+ .extern ulPortInterruptNesting\r
\r
.global FreeRTOS_IRQ_Handler\r
.global FreeRTOS_SWI_Handler\r
PUSH {R0-R12, R14}\r
\r
/* Push the critical nesting count. */\r
- LDR R2, =ulCriticalNesting\r
+ LDR R2, ulCriticalNestingConst\r
LDR R1, [R2]\r
PUSH {R1}\r
\r
/* Does the task have a floating point context that needs saving? If\r
ulPortTaskHasFPUContext is 0 then no. */\r
- LDR R2, =ulPortTaskHasFPUContext\r
+ LDR R2, ulPortTaskHasFPUContextConst\r
LDR R3, [R2]\r
CMP R3, #0\r
\r
PUSH {R3}\r
\r
/* Save the stack pointer in the TCB. */\r
- LDR R0, =pxCurrentTCB\r
+ LDR R0, pxCurrentTCBConst\r
LDR R1, [R0]\r
STR SP, [R1]\r
\r
CPS #SYS_MODE\r
\r
/* Set the SP to point to the stack of the task being restored. */\r
- LDR R0, =pxCurrentTCB\r
+ LDR R0, pxCurrentTCBConst\r
LDR R1, [R0]\r
LDR SP, [R1]\r
\r
/* Is there a floating point context to restore? If the restored\r
ulPortTaskHasFPUContext is zero then no. */\r
- LDR R0, =ulPortTaskHasFPUContext\r
+ LDR R0, ulPortTaskHasFPUContextConst\r
POP {R1}\r
STR R1, [R0]\r
CMP R1, #0\r
VMSRNE FPSCR, R0\r
\r
/* Restore the critical section nesting depth. */\r
- LDR R0, =ulCriticalNesting\r
+ LDR R0, ulCriticalNestingConst\r
POP {R1}\r
STR R1, [R0]\r
\r
/* Ensure the priority mask is correct for the critical nesting depth. */\r
- LDR R2, =ulICCPMR\r
+ LDR R2, ulICCPMRConst\r
+ LDR R2, [R2]\r
CMP R1, #0\r
MOVEQ R4, #255\r
- LDRNE R4, =ulMaxAPIPriorityMask\r
- STR R4, [r2]\r
+ LDRNE R4, ulMaxAPIPriorityMaskConst\r
+ LDRNE R4, [R4]\r
+ STR R4, [R2]\r
\r
/* Restore all system mode registers other than the SP (which is already\r
being used). */\r
* SVC handler is used to start the scheduler and yield a task.\r
*****************************************************************************/\r
FreeRTOS_SWI_Handler:\r
-\r
/* Save the context of the current task and select a new task to run. */\r
- /* Save the LR and SPSR onto the system mode stack before switching to\r
- system mode to save the remaining system mode registers. */\r
- SRSDB sp!, #SYS_MODE\r
- CPS #SYS_MODE\r
- PUSH {R0-R12, R14}\r
-\r
- /* Push the critical nesting count. */\r
- LDR R2, =ulCriticalNesting\r
- LDR R1, [R2]\r
- PUSH {R1}\r
-\r
- /* Does the task have a floating point context that needs saving? If\r
- ulPortTaskHasFPUContext is 0 then no. */\r
- LDR R2, =ulPortTaskHasFPUContext\r
- LDR R3, [R2]\r
- CMP R3, #0\r
-\r
- /* Save the floating point context, if any. */\r
- FMRXNE R1, FPSCR\r
- VPUSHNE {D0-D15}\r
- VPUSHNE {D16-D31}\r
- PUSHNE {R1}\r
-\r
- /* Save ulPortTaskHasFPUContext itself. */\r
- PUSH {R3}\r
-\r
- /* Save the stack pointer in the TCB. */\r
- LDR R0, =pxCurrentTCB\r
- LDR R1, [R0]\r
- STR SP, [R1]\r
-\r
- LDR R0, =vTaskSwitchContext\r
+ portSAVE_CONTEXT\r
+ LDR R0, vTaskSwitchContextConst\r
BLX R0\r
\r
vPortRestoreTaskContext:\r
/* Increment nesting count. r3 holds the address of ulPortInterruptNesting\r
for future use. r1 holds the original ulPortInterruptNesting value for\r
future use. */\r
- LDR r3, =ulPortInterruptNesting\r
+ LDR r3, ulPortInterruptNestingConst\r
LDR r1, [r3]\r
ADD r4, r1, #1\r
STR r4, [r3]\r
\r
/* Call the interrupt handler. */\r
PUSH {r0-r3, lr}\r
- BL vApplicationIRQHandler\r
+ LDR r1, vApplicationIRQHandlerConst\r
+ BLX r1\r
POP {r0-r3, lr}\r
ADD sp, sp, r2\r
\r
vTaskSwitchContext() if vTaskSwitchContext() uses LDRD or STRD\r
instructions, or 8 byte aligned stack allocated data. LR does not need\r
saving as a new LR will be loaded by portRESTORE_CONTEXT anyway. */\r
- BL vTaskSwitchContext\r
+ LDR R0, vTaskSwitchContextConst\r
+ BLX R0\r
\r
/* Restore the context of, and branch to, the task selected to execute\r
next. */\r
portRESTORE_CONTEXT\r
\r
-ulICCIARConst: .word ulICCIAR\r
-ulICCEOIRConst: .word ulICCEOIR\r
-\r
vPortInstallFreeRTOSVectorTable:\r
/* Set VBAR to the vector table that contains the FreeRTOS handlers. */\r
ldr r0, =_freertos_vector_table\r
isb\r
bx lr\r
\r
+ulICCIARConst: .word ulICCIAR\r
+ulICCEOIRConst: .word ulICCEOIR\r
+ulICCPMRConst: .word ulICCPMR\r
+pxCurrentTCBConst: .word pxCurrentTCB\r
+ulCriticalNestingConst: .word ulCriticalNesting\r
+ulPortTaskHasFPUContextConst: .word ulPortTaskHasFPUContext\r
+ulMaxAPIPriorityMaskConst: .word ulMaxAPIPriorityMask\r
+vTaskSwitchContextConst: .word vTaskSwitchContext\r
+vApplicationIRQHandlerConst: .word vApplicationIRQHandler\r
+ulPortInterruptNestingConst: .word ulPortInterruptNesting\r
\r
.end\r
\r