2 ; * FreeRTOS Kernel V10.0.0
\r
3 ; * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
\r
5 ; * Permission is hereby granted, free of charge, to any person obtaining a copy of
\r
6 ; * this software and associated documentation files (the "Software"), to deal in
\r
7 ; * the Software without restriction, including without limitation the rights to
\r
8 ; * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
\r
9 ; * the Software, and to permit persons to whom the Software is furnished to do so,
\r
10 ; * subject to the following conditions:
\r
12 ; * The above copyright notice and this permission notice shall be included in all
\r
13 ; * copies or substantial portions of the Software. If you wish to use our Amazon
\r
14 ; * FreeRTOS name, please do so in a fair use way that does not cause confusion.
\r
16 ; * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
\r
17 ; * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
\r
18 ; * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
\r
19 ; * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
\r
20 ; * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
\r
21 ; * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
\r
23 ; * http://www.FreeRTOS.org
\r
24 ; * http://aws.amazon.com/freertos
\r
26 ; * 1 tab == 4 spaces!
\r
29 INCLUDE portmacro.inc
\r
31 IMPORT vApplicationIRQHandler
\r
32 IMPORT vTaskSwitchContext
\r
33 IMPORT ulPortYieldRequired
\r
34 IMPORT ulPortInterruptNesting
\r
35 IMPORT vTaskSwitchContext
\r
39 EXPORT FreeRTOS_SWI_Handler
\r
40 EXPORT FreeRTOS_IRQ_Handler
\r
41 EXPORT vPortRestoreTaskContext
\r
44 AREA PORT_ASM, CODE, READONLY
\r
47 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
\r
48 ; SVC handler is used to yield a task.
\r
49 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
\r
50 FreeRTOS_SWI_Handler
\r
54 ; Save the context of the current task and select a new task to run.
\r
56 LDR R0, =vTaskSwitchContext
\r
60 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
\r
61 ; vPortRestoreTaskContext is used to start the scheduler.
\r
62 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
\r
63 vPortRestoreTaskContext
\r
64 ; Switch to system mode
\r
68 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
\r
69 ; PL390 GIC interrupt handler
\r
70 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
\r
71 FreeRTOS_IRQ_Handler
\r
73 ; Return to the interrupted instruction.
\r
76 ; Push the return address and SPSR
\r
81 ; Change to supervisor mode to allow reentry.
\r
84 ; Push used registers.
\r
87 ; Increment nesting count. r3 holds the address of ulPortInterruptNesting
\r
88 ; for future use. r1 holds the original ulPortInterruptNesting value for
\r
90 LDR r3, =ulPortInterruptNesting
\r
95 ; Read value from the interrupt acknowledge register, which is stored in r0
\r
96 ; for future parameter and interrupt clearing use.
\r
100 ; Ensure bit 2 of the stack pointer is clear. r2 holds the bit 2 value for
\r
101 ; future use. _RB_ Does this ever actually need to be done provided the
\r
102 ; start of the stack is 8-byte aligned?
\r
107 ; Call the interrupt handler. r4 is pushed to maintain alignment.
\r
109 LDR r1, =vApplicationIRQHandler
\r
116 ; Write the value read from ICCIAR to ICCEOIR
\r
120 ; Restore the old nesting count
\r
123 ; A context switch is never performed if the nesting count is not 0
\r
125 BNE exit_without_switch
\r
127 ; Did the interrupt request a context switch? r1 holds the address of
\r
128 ; ulPortYieldRequired and r0 the value of ulPortYieldRequired for future
\r
130 LDR r1, =ulPortYieldRequired
\r
133 BNE switch_before_exit
\r
135 exit_without_switch
\r
136 ; No context switch. Restore used registers, LR_irq and SPSR before
\r
146 ; A context swtich is to be performed. Clear the context switch pending
\r
151 ; Restore used registers, LR-irq and SPSR before saving the context
\r
152 ; to the task stack.
\r
160 ; Call the function that selects the new task to execute.
\r
161 ; vTaskSwitchContext() if vTaskSwitchContext() uses LDRD or STRD
\r
162 ; instructions, or 8 byte aligned stack allocated data. LR does not need
\r
163 ; saving as a new LR will be loaded by portRESTORE_CONTEXT anyway.
\r
164 LDR r0, =vTaskSwitchContext
\r
167 ; Restore the context of, and branch to, the task selected to execute next.
\r
168 portRESTORE_CONTEXT
\r