2 ; FreeRTOS V8.1.2 - Copyright (C) 2014 Real Time Engineers Ltd.
\r
3 ; All rights reserved
\r
6 ; ***************************************************************************
\r
8 ; * FreeRTOS tutorial books are available in pdf and paperback. *
\r
9 ; * Complete, revised, and edited pdf reference manuals are also *
\r
12 ; * Purchasing FreeRTOS documentation will not only help you, by *
\r
13 ; * ensuring you get running as quickly as possible and with an *
\r
14 ; * in-depth knowledge of how to use FreeRTOS, it will also help *
\r
15 ; * the FreeRTOS project to continue with its mission of providing *
\r
16 ; * professional grade, cross platform, de facto standard solutions *
\r
17 ; * for microcontrollers - completely free of charge! *
\r
19 ; * >>> See http://www.FreeRTOS.org/Documentation for details. <<< *
\r
21 ; * Thank you for using FreeRTOS, and thank you for your support! *
\r
23 ; ***************************************************************************
\r
26 ; This file is part of the FreeRTOS distribution.
\r
28 ; FreeRTOS is free software; you can redistribute it and/or modify it under
\r
29 ; the terms of the GNU General Public License (version 2) as published by the
\r
30 ; Free Software Foundation AND MODIFIED BY the FreeRTOS exception.
\r
31 ; >>>NOTE<<< The modification to the GPL is included to allow you to
\r
32 ; distribute a combined work that includes FreeRTOS without being obliged to
\r
33 ; provide the source code for proprietary components outside of the FreeRTOS
\r
34 ; kernel. FreeRTOS is distributed in the hope that it will be useful, but
\r
35 ; WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
\r
36 ; or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
\r
37 ; more details. You should have received a copy of the GNU General Public
\r
38 ; License and the FreeRTOS license exception along with FreeRTOS; if not it
\r
39 ; can be viewed here: http://www.freertos.org/a00114.html and also obtained
\r
40 ; by writing to Richard Barry, contact details for whom are available on the
\r
41 ; FreeRTOS WEB site.
\r
43 ; 1 tab == 4 spaces!
\r
45 ; http://www.FreeRTOS.org - Documentation, latest information, license and
\r
48 ; http://www.SafeRTOS.com - A version that is certified for use in safety
\r
51 ; http://www.OpenRTOS.com - Commercial support, development, porting,
\r
52 ; licensing and training services.
\r
55 INCLUDE FreeRTOSConfig.h
\r
58 EXTERN vTaskSwitchContext
\r
59 EXTERN ulPortYieldRequired
\r
60 EXTERN ulPortInterruptNesting
\r
61 EXTERN vApplicationIRQHandler
\r
63 PUBLIC FreeRTOS_SWI_Handler
\r
64 PUBLIC FreeRTOS_IRQ_Handler
\r
65 PUBLIC vPortRestoreTaskContext
\r
71 SECTION .text:CODE:ROOT(2)
\r
76 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
\r
77 ; SVC handler is used to yield a task.
\r
78 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
\r
79 FreeRTOS_SWI_Handler
\r
83 ; Save the context of the current task and select a new task to run.
\r
85 LDR R0, =vTaskSwitchContext
\r
89 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
\r
90 ; vPortRestoreTaskContext is used to start the scheduler.
\r
91 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
\r
92 vPortRestoreTaskContext
\r
96 ; Switch to system mode
\r
100 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
\r
101 ; IRQ interrupt handler used when individual priorities cannot be masked
\r
102 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
\r
103 FreeRTOS_IRQ_Handler
\r
107 ; Return to the interrupted instruction.
\r
110 ; Push the return address and SPSR
\r
115 ; Change to supervisor mode to allow reentry.
\r
118 ; Push used registers.
\r
121 ; Increment nesting count. r3 holds the address of ulPortInterruptNesting
\r
122 ; for future use. r1 holds the original ulPortInterruptNesting value for
\r
124 LDR r3, =ulPortInterruptNesting
\r
129 ; Ensure bit 2 of the stack pointer is clear. r2 holds the bit 2 value for
\r
135 ; Obtain the address of the interrupt handler, then pass it into the ISR
\r
138 LDR r1, =configINTERRUPT_VECTOR_ADDRESS
\r
140 LDR r1, =vApplicationIRQHandler
\r
147 ; Write to the EOI register
\r
148 LDR r4, =configEOI_ADDRESS
\r
151 ; Restore the old nesting count
\r
154 ; A context switch is never performed if the nesting count is not 0
\r
156 BNE exit_without_switch
\r
158 ; Did the interrupt request a context switch? r1 holds the address of
\r
159 ; ulPortYieldRequired and r0 the value of ulPortYieldRequired for future
\r
161 LDR r1, =ulPortYieldRequired
\r
164 BNE switch_before_exit
\r
166 exit_without_switch
\r
167 ; No context switch. Restore used registers, LR_irq and SPSR before
\r
177 ; A context switch is to be performed. Clear the context switch pending
\r
182 ; Restore used registers, LR-irq and SPSR before saving the context
\r
183 ; to the task stack.
\r
191 ; Call the function that selects the new task to execute.
\r
192 ; vTaskSwitchContext() if vTaskSwitchContext() uses LDRD or STRD
\r
193 ; instructions, or 8 byte aligned stack allocated data. LR does not need
\r
194 ; saving as a new LR will be loaded by portRESTORE_CONTEXT anyway.
\r
195 LDR r0, =vTaskSwitchContext
\r
198 ; Restore the context of, and branch to, the task selected to execute next.
\r
199 portRESTORE_CONTEXT
\r