+ .global vPortRestoreTaskContext\r
+ .global vPortInstallFreeRTOSVectorTable\r
+\r
+\r
+\r
+\r
+.macro portSAVE_CONTEXT\r
+\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, 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, ulPortTaskHasFPUContextConst\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, pxCurrentTCBConst\r
+ LDR R1, [R0]\r
+ STR SP, [R1]\r
+\r
+ .endm\r
+\r
+; /**********************************************************************/\r
+\r
+.macro portRESTORE_CONTEXT\r
+\r
+ /* Set the SP to point to the stack of the task being restored. */\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, ulPortTaskHasFPUContextConst\r
+ POP {R1}\r
+ STR R1, [R0]\r
+ CMP R1, #0\r
+\r
+ /* Restore the floating point context, if any. */\r
+ POPNE {R0}\r
+ VPOPNE {D16-D31}\r
+ VPOPNE {D0-D15}\r
+ VMSRNE FPSCR, R0\r
+\r
+ /* Restore the critical section nesting depth. */\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, ulICCPMRConst\r
+ LDR R2, [R2]\r
+ CMP R1, #0\r
+ MOVEQ R4, #255\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
+ POP {R0-R12, R14}\r
+\r
+ /* Return to the task code, loading CPSR on the way. */\r
+ RFEIA sp!\r
+\r
+ .endm\r