]> git.sur5r.net Git - freertos/blobdiff - FreeRTOS/Source/portable/GCC/ARM_CA9/portASM.S
Demo application related:
[freertos] / FreeRTOS / Source / portable / GCC / ARM_CA9 / portASM.S
index eb8320a81ad6e6aafb887082d1f8f5de4fe48f74..1d9368eabd26c791520fbd97c5db734162984666 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
-    FreeRTOS V8.0.0:rc1 - Copyright (C) 2014 Real Time Engineers Ltd.\r
+    FreeRTOS V8.0.1 - Copyright (C) 2014 Real Time Engineers Ltd.\r
     All rights reserved\r
 \r
 \r
 */\r
 \r
        .text\r
+       .arm\r
 \r
        .set SYS_MODE,  0x1f\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
+       .extern ulPortTaskHasFPUContext\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
 \r
 .macro portRESTORE_CONTEXT\r
 \r
-       /* Switch to system mode. */\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
 \r
 \r
 /******************************************************************************\r
- * SVC handler is used to start the scheduler and yield a task.\r
+ * SVC handler is used to start the scheduler.\r
  *****************************************************************************/\r
+.align 4\r
+.type FreeRTOS_SWI_Handler, %function\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
+       portRESTORE_CONTEXT\r
+\r
 \r
+/******************************************************************************\r
+ * vPortRestoreTaskContext is used to start the scheduler.\r
+ *****************************************************************************/\r
+.type vPortRestoreTaskContext, %function\r
 vPortRestoreTaskContext:\r
+       /* Switch to system mode. */\r
+       CPS             #SYS_MODE\r
        portRESTORE_CONTEXT\r
 \r
+.align 4\r
+.type FreeRTOS_IRQ_Handler, %function\r
 FreeRTOS_IRQ_Handler:\r
        /* Return to the interrupted instruction. */\r
        SUB             lr, lr, #4\r
@@ -232,7 +206,7 @@ FreeRTOS_IRQ_Handler:
        /* 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
@@ -251,11 +225,14 @@ FreeRTOS_IRQ_Handler:
 \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
        CPSID   i\r
+       DSB\r
+       ISB\r
 \r
        /* Write the value read from ICCIAR to ICCEOIR. */\r
        LDR     r4, ulICCEOIRConst\r
@@ -306,7 +283,8 @@ switch_before_exit:
        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
@@ -314,15 +292,14 @@ switch_before_exit:
 \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
-       mcr     p15, 0, r0, c12, c0, 0\r
-       dsb\r
-       isb\r
-       bx lr\r
-\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