]> begriffs open source - freertos/blob - portable/RVDS/ARM7_LPC21xx/portASM.s
RP2040: Fix compiler warning and comment (#509)
[freertos] / portable / RVDS / ARM7_LPC21xx / portASM.s
1 ;/*
2 ; * FreeRTOS SMP Kernel V202110.00
3 ; * Copyright (C) 2020 Amazon.com, Inc. or its affiliates.  All Rights Reserved.
4 ; *
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:
11 ; *
12 ; * The above copyright notice and this permission notice shall be included in all
13 ; * copies or substantial portions of the Software.
14 ; *
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.
21 ; *
22 ; * https://www.FreeRTOS.org
23 ; * https://github.com/FreeRTOS
24 ; *
25 ; * 1 tab == 4 spaces!
26 ; */
27
28         INCLUDE portmacro.inc
29
30         IMPORT  vTaskSwitchContext
31         IMPORT  xTaskIncrementTick
32
33         EXPORT  vPortYieldProcessor
34         EXPORT  vPortStartFirstTask
35         EXPORT  vPreemptiveTick
36         EXPORT  vPortYield
37
38
39 VICVECTADDR     EQU     0xFFFFF030
40 T0IR            EQU     0xE0004000
41 T0MATCHBIT      EQU     0x00000001
42
43         ARM
44         AREA    PORT_ASM, CODE, READONLY
45
46
47
48 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
49 ; Starting the first task is done by just restoring the context
50 ; setup by pxPortInitialiseStack
51 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
52 vPortStartFirstTask
53
54         PRESERVE8
55
56         portRESTORE_CONTEXT
57
58 vPortYield
59
60         PRESERVE8
61
62         SVC 0
63         bx lr
64
65 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
66 ; Interrupt service routine for the SWI interrupt.  The vector table is
67 ; configured in the startup.s file.
68 ;
69 ; vPortYieldProcessor() is used to manually force a context switch.  The
70 ; SWI interrupt is generated by a call to taskYIELD() or portYIELD().
71 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
72
73 vPortYieldProcessor
74
75         PRESERVE8
76
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.
80         ADD     LR, LR, #4
81
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
88
89
90
91 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
92 ; Interrupt service routine for preemptive scheduler tick timer
93 ; Only used if portUSE_PREEMPTION is set to 1 in portmacro.h
94 ;
95 ; Uses timer 0 of LPC21XX Family
96 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
97
98 vPreemptiveTick
99
100         PRESERVE8
101
102         portSAVE_CONTEXT                                        ; Save the context of the current task.
103
104         LDR R0, =xTaskIncrementTick                     ; Increment the tick count.
105         MOV LR, PC                                                      ; This may make a delayed task ready
106         BX R0                                                           ; to run.
107
108         CMP R0, #0
109         BEQ SkipContextSwitch
110         LDR R0, =vTaskSwitchContext                     ; Find the highest priority task that
111         MOV LR, PC                                                      ; is ready to run.
112         BX R0
113 SkipContextSwitch
114         MOV R0, #T0MATCHBIT                                     ; Clear the timer event
115         LDR R1, =T0IR
116         STR R0, [R1]
117
118         LDR     R0, =VICVECTADDR                                ; Acknowledge the interrupt
119         STR     R0,[R0]
120
121         portRESTORE_CONTEXT                                     ; Restore the context of the highest
122                                                                                 ; priority task that is ready to run.
123         END
124