2 ; * FreeRTOS SMP Kernel V202110.00
3 ; * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
5 ; * Permission is hereby granted, free of charge, to any person obtaining a copy of
6 ; * this software and associated documentation files (the "Software"), to deal in
7 ; * the Software without restriction, including without limitation the rights to
8 ; * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9 ; * the Software, and to permit persons to whom the Software is furnished to do so,
10 ; * subject to the following conditions:
12 ; * The above copyright notice and this permission notice shall be included in all
13 ; * copies or substantial portions of the Software.
15 ; * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 ; * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17 ; * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18 ; * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19 ; * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20 ; * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 ; * https://www.FreeRTOS.org
23 ; * https://github.com/FreeRTOS
25 ; * 1 tab == 4 spaces!
30 IMPORT vTaskSwitchContext
31 IMPORT xTaskIncrementTick
33 EXPORT vPortYieldProcessor
34 EXPORT vPortStartFirstTask
35 EXPORT vPreemptiveTick
39 VICVECTADDR EQU 0xFFFFF030
41 T0MATCHBIT EQU 0x00000001
44 AREA PORT_ASM, CODE, READONLY
48 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
49 ; Starting the first task is done by just restoring the context
50 ; setup by pxPortInitialiseStack
51 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
65 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
66 ; Interrupt service routine for the SWI interrupt. The vector table is
67 ; configured in the startup.s file.
69 ; vPortYieldProcessor() is used to manually force a context switch. The
70 ; SWI interrupt is generated by a call to taskYIELD() or portYIELD().
71 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
77 ; Within an IRQ ISR the link register has an offset from the true return
78 ; address, but an SWI ISR does not. Add the offset manually so the same
79 ; ISR return code can be used in both cases.
82 ; Perform the context switch.
83 portSAVE_CONTEXT ; Save current task context
84 LDR R0, =vTaskSwitchContext ; Get the address of the context switch function
85 MOV LR, PC ; Store the return address
86 BX R0 ; Call the contedxt switch function
87 portRESTORE_CONTEXT ; restore the context of the selected task
91 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
92 ; Interrupt service routine for preemptive scheduler tick timer
93 ; Only used if portUSE_PREEMPTION is set to 1 in portmacro.h
95 ; Uses timer 0 of LPC21XX Family
96 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
102 portSAVE_CONTEXT ; Save the context of the current task.
104 LDR R0, =xTaskIncrementTick ; Increment the tick count.
105 MOV LR, PC ; This may make a delayed task ready
109 BEQ SkipContextSwitch
110 LDR R0, =vTaskSwitchContext ; Find the highest priority task that
111 MOV LR, PC ; is ready to run.
114 MOV R0, #T0MATCHBIT ; Clear the timer event
118 LDR R0, =VICVECTADDR ; Acknowledge the interrupt
121 portRESTORE_CONTEXT ; Restore the context of the highest
122 ; priority task that is ready to run.