X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=FreeRTOS%2FSource%2Fportable%2FGCC%2FARM_CA9%2FportASM.S;h=1d9368eabd26c791520fbd97c5db734162984666;hb=857280ed8fe6610361bd144a505da7194591f2b1;hp=eb8320a81ad6e6aafb887082d1f8f5de4fe48f74;hpb=ebed79bb48a50e7491321595c45064f48c7971d3;p=freertos diff --git a/FreeRTOS/Source/portable/GCC/ARM_CA9/portASM.S b/FreeRTOS/Source/portable/GCC/ARM_CA9/portASM.S index eb8320a81..1d9368eab 100644 --- a/FreeRTOS/Source/portable/GCC/ARM_CA9/portASM.S +++ b/FreeRTOS/Source/portable/GCC/ARM_CA9/portASM.S @@ -1,5 +1,5 @@ /* - FreeRTOS V8.0.0:rc1 - Copyright (C) 2014 Real Time Engineers Ltd. + FreeRTOS V8.0.1 - Copyright (C) 2014 Real Time Engineers Ltd. All rights reserved @@ -53,31 +53,25 @@ */ .text + .arm .set SYS_MODE, 0x1f .set SVC_MODE, 0x13 .set IRQ_MODE, 0x12 + /* Hardware registers. */ .extern ulICCIAR .extern ulICCEOIR - .extern ulMaxAPIPriorityMask .extern ulICCPMR - .extern _freertos_vector_table - - .global FreeRTOS_vector_table - .global FIQInterrupt - .global Undefined - .global PrefetchAbortHandler - .global DataAbortInterrupt + /* Variables and functions. */ + .extern ulMaxAPIPriorityMask + .extern _freertos_vector_table .extern pxCurrentTCB - .extern XIntc_DeviceInterruptHandler .extern vTaskSwitchContext - .extern uxCriticalNesting - .extern pulISRStack - .extern ulTaskSwitchRequested - .extern vPortExceptionHandler - .extern pulStackPointerOnFunctionEntry + .extern vApplicationIRQHandler + .extern ulPortInterruptNesting + .extern ulPortTaskHasFPUContext .global FreeRTOS_IRQ_Handler .global FreeRTOS_SWI_Handler @@ -96,13 +90,13 @@ PUSH {R0-R12, R14} /* Push the critical nesting count. */ - LDR R2, =ulCriticalNesting + LDR R2, ulCriticalNestingConst LDR R1, [R2] PUSH {R1} /* Does the task have a floating point context that needs saving? If ulPortTaskHasFPUContext is 0 then no. */ - LDR R2, =ulPortTaskHasFPUContext + LDR R2, ulPortTaskHasFPUContextConst LDR R3, [R2] CMP R3, #0 @@ -116,7 +110,7 @@ PUSH {R3} /* Save the stack pointer in the TCB. */ - LDR R0, =pxCurrentTCB + LDR R0, pxCurrentTCBConst LDR R1, [R0] STR SP, [R1] @@ -126,17 +120,14 @@ .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 R0, pxCurrentTCBConst LDR R1, [R0] LDR SP, [R1] /* Is there a floating point context to restore? If the restored ulPortTaskHasFPUContext is zero then no. */ - LDR R0, =ulPortTaskHasFPUContext + LDR R0, ulPortTaskHasFPUContextConst POP {R1} STR R1, [R0] CMP R1, #0 @@ -148,16 +139,18 @@ VMSRNE FPSCR, R0 /* Restore the critical section nesting depth. */ - LDR R0, =ulCriticalNesting + LDR R0, ulCriticalNestingConst POP {R1} STR R1, [R0] /* Ensure the priority mask is correct for the critical nesting depth. */ - LDR R2, =ulICCPMR + LDR R2, ulICCPMRConst + LDR R2, [R2] CMP R1, #0 MOVEQ R4, #255 - LDRNE R4, =ulMaxAPIPriorityMask - STR R4, [r2] + LDRNE R4, ulMaxAPIPriorityMaskConst + LDRNE R4, [R4] + STR R4, [R2] /* Restore all system mode registers other than the SP (which is already being used). */ @@ -172,48 +165,29 @@ /****************************************************************************** - * 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 FreeRTOS_SWI_Handler: - /* Save the context of the current task and select a new task to run. */ - /* Save the LR and SPSR onto the system mode stack before switching to - system mode to save the remaining system mode registers. */ - SRSDB sp!, #SYS_MODE - CPS #SYS_MODE - PUSH {R0-R12, R14} - - /* Push the critical nesting count. */ - LDR R2, =ulCriticalNesting - LDR R1, [R2] - PUSH {R1} - - /* Does the task have a floating point context that needs saving? If - ulPortTaskHasFPUContext is 0 then no. */ - LDR R2, =ulPortTaskHasFPUContext - LDR R3, [R2] - CMP R3, #0 - - /* Save the floating point context, if any. */ - FMRXNE R1, FPSCR - VPUSHNE {D0-D15} - VPUSHNE {D16-D31} - PUSHNE {R1} - - /* Save ulPortTaskHasFPUContext itself. */ - PUSH {R3} - - /* Save the stack pointer in the TCB. */ - LDR R0, =pxCurrentTCB - LDR R1, [R0] - STR SP, [R1] - - LDR R0, =vTaskSwitchContext + 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 +.type FreeRTOS_IRQ_Handler, %function FreeRTOS_IRQ_Handler: /* Return to the interrupted instruction. */ SUB lr, lr, #4 @@ -232,7 +206,7 @@ FreeRTOS_IRQ_Handler: /* Increment nesting count. r3 holds the address of ulPortInterruptNesting for future use. r1 holds the original ulPortInterruptNesting value for future use. */ - LDR r3, =ulPortInterruptNesting + LDR r3, ulPortInterruptNestingConst LDR r1, [r3] ADD r4, r1, #1 STR r4, [r3] @@ -251,11 +225,14 @@ FreeRTOS_IRQ_Handler: /* Call the interrupt handler. */ PUSH {r0-r3, lr} - BL vApplicationIRQHandler + LDR r1, vApplicationIRQHandlerConst + BLX r1 POP {r0-r3, lr} ADD sp, sp, r2 CPSID i + DSB + ISB /* Write the value read from ICCIAR to ICCEOIR. */ LDR r4, ulICCEOIRConst @@ -306,7 +283,8 @@ switch_before_exit: vTaskSwitchContext() if vTaskSwitchContext() uses LDRD or STRD instructions, or 8 byte aligned stack allocated data. LR does not need saving as a new LR will be loaded by portRESTORE_CONTEXT anyway. */ - BL vTaskSwitchContext + LDR R0, vTaskSwitchContextConst + BLX R0 /* Restore the context of, and branch to, the task selected to execute next. */ @@ -314,15 +292,14 @@ switch_before_exit: ulICCIARConst: .word ulICCIAR ulICCEOIRConst: .word ulICCEOIR - -vPortInstallFreeRTOSVectorTable: - /* Set VBAR to the vector table that contains the FreeRTOS handlers. */ - ldr r0, =_freertos_vector_table - mcr p15, 0, r0, c12, c0, 0 - dsb - isb - bx lr - +ulICCPMRConst: .word ulICCPMR +pxCurrentTCBConst: .word pxCurrentTCB +ulCriticalNestingConst: .word ulCriticalNesting +ulPortTaskHasFPUContextConst: .word ulPortTaskHasFPUContext +ulMaxAPIPriorityMaskConst: .word ulMaxAPIPriorityMask +vTaskSwitchContextConst: .word vTaskSwitchContext +vApplicationIRQHandlerConst: .word vApplicationIRQHandler +ulPortInterruptNestingConst: .word ulPortInterruptNesting .end