]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/CORTEX_M0_Infineon_XMC1000_IAR_Keil_GCC/Keil_Specific/RegTest_Keil.s
0374936bb3c69674073d33511c85ea345a1de8f9
[freertos] / FreeRTOS / Demo / CORTEX_M0_Infineon_XMC1000_IAR_Keil_GCC / Keil_Specific / RegTest_Keil.s
1 ;/*\r
2 ; * FreeRTOS Kernel V10.2.1\r
3 ; * Copyright (C) 2019 Amazon.com, Inc. or its affiliates.  All Rights Reserved.\r
4 ; *\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
11 ; *\r
12 ; * The above copyright notice and this permission notice shall be included in all\r
13 ; * copies or substantial portions of the Software.\r
14 ; *\r
15 ; * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
16 ; * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS\r
17 ; * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR\r
18 ; * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER\r
19 ; * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
20 ; * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
21 ; *\r
22 ; * http://www.FreeRTOS.org\r
23 ; * http://aws.amazon.com/freertos\r
24 ; *\r
25 ; * 1 tab == 4 spaces!\r
26 ; */\r
27 \r
28 ;/*\r
29 ; * "Reg test" tasks - These fill the registers with known values, then check\r
30 ; * that each register maintains its expected value for the lifetime of the\r
31 ; * task.  Each task uses a different set of values.  The reg test tasks execute\r
32 ; * with a very low priority, so get preempted very frequently.  A register\r
33 ; * containing an unexpected value is indicative of an error in the context\r
34 ; * switching mechanism.\r
35 ; */\r
36 \r
37         PRESERVE8\r
38         THUMB\r
39 \r
40 \r
41         IMPORT ulRegTest1LoopCounter\r
42         IMPORT ulRegTest2LoopCounter\r
43 \r
44         EXPORT vRegTest1Task\r
45         EXPORT vRegTest2Task\r
46 \r
47         AREA    |.text|, CODE, READONLY\r
48 \r
49 ;/*-----------------------------------------------------------*/\r
50 vRegTest1Task PROC\r
51 \r
52         ;/* Fill the core registers with known values.  This is only done once. */\r
53         movs r1, #101\r
54         movs r2, #102\r
55         movs r3, #103\r
56         movs r4, #104\r
57         movs r5, #105\r
58         movs r6, #106\r
59         movs r7, #107\r
60         movs r0, #108\r
61         mov      r8, r0\r
62         movs r0, #109\r
63         mov  r9, r0\r
64         movs r0, #110\r
65         mov      r10, r0\r
66         movs r0, #111\r
67         mov      r11, r0\r
68         movs r0, #112\r
69         mov  r12, r0\r
70         movs r0, #100\r
71 \r
72 reg1_loop\r
73         ;/* Repeatedly check that each register still contains the value written to\r
74         ;it when the task started. */\r
75         cmp     r0, #100\r
76         bne     reg1_error_loop\r
77         cmp     r1, #101\r
78         bne     reg1_error_loop\r
79         cmp     r2, #102\r
80         bne     reg1_error_loop\r
81         cmp r3, #103\r
82         bne     reg1_error_loop\r
83         cmp     r4, #104\r
84         bne     reg1_error_loop\r
85         cmp     r5, #105\r
86         bne     reg1_error_loop\r
87         cmp     r6, #106\r
88         bne     reg1_error_loop\r
89         cmp     r7, #107\r
90         bne     reg1_error_loop\r
91         movs r0, #108\r
92         cmp     r8, r0\r
93         bne     reg1_error_loop\r
94         movs r0, #109\r
95         cmp     r9, r0\r
96         bne     reg1_error_loop\r
97         movs r0, #110\r
98         cmp     r10, r0\r
99         bne     reg1_error_loop\r
100         movs r0, #111\r
101         cmp     r11, r0\r
102         bne     reg1_error_loop\r
103         movs r0, #112\r
104         cmp     r12, r0\r
105         bne     reg1_error_loop\r
106 \r
107         ;/* Everything passed, increment the loop counter. */\r
108         push { r1 }\r
109         ldr     r0, =ulRegTest1LoopCounter\r
110         ldr r1, [r0]\r
111         adds r1, r1, #1\r
112         str r1, [r0]\r
113 \r
114         ;/* Yield to increase test coverage. */\r
115         movs r0, #0x01\r
116         ldr r1, =0xe000ed04 ; NVIC_INT_CTRL\r
117         lsls r0 ,r0, #28 ; Shift to PendSV bit\r
118         str r0, [r1]\r
119         dsb\r
120         pop { r1 }\r
121 \r
122         ;/* Start again. */\r
123         movs r0, #100\r
124 \r
125         b reg1_loop\r
126 \r
127 reg1_error_loop\r
128         ;/* If this line is hit then there was an error in a core register value.\r
129         ;The loop ensures the loop counter stops incrementing. */\r
130         b reg1_error_loop\r
131         nop\r
132         ENDP\r
133 \r
134 \r
135 \r
136 vRegTest2Task PROC\r
137 \r
138         ;/* Fill the core registers with known values.  This is only done once. */\r
139         movs r1, #1\r
140         movs r2, #2\r
141         movs r3, #3\r
142         movs r4, #4\r
143         movs r5, #5\r
144         movs r6, #6\r
145         movs r7, #7\r
146         movs r0, #8\r
147         mov     r8, r0\r
148         movs r0, #9\r
149         mov r9, r0\r
150         movs r0, #10\r
151         mov     r10, r0\r
152         movs r0, #11\r
153         mov     r11, r0\r
154         movs r0, #12\r
155         mov r12, r0\r
156         movs r0, #10\r
157 \r
158 reg2_loop\r
159         ;/* Repeatedly check that each register still contains the value written to\r
160         ;it when the task started. */\r
161         cmp     r0, #10\r
162         bne     reg2_error_loop\r
163         cmp     r1, #1\r
164         bne     reg2_error_loop\r
165         cmp     r2, #2\r
166         bne     reg2_error_loop\r
167         cmp r3, #3\r
168         bne     reg2_error_loop\r
169         cmp     r4, #4\r
170         bne     reg2_error_loop\r
171         cmp     r5, #5\r
172         bne     reg2_error_loop\r
173         cmp     r6, #6\r
174         bne     reg2_error_loop\r
175         cmp     r7, #7\r
176         bne     reg2_error_loop\r
177         movs r0, #8\r
178         cmp     r8, r0\r
179         bne     reg2_error_loop\r
180         movs r0, #9\r
181         cmp     r9, r0\r
182         bne     reg2_error_loop\r
183         movs r0, #10\r
184         cmp     r10, r0\r
185         bne     reg2_error_loop\r
186         movs r0, #11\r
187         cmp     r11, r0\r
188         bne     reg2_error_loop\r
189         movs r0, #12\r
190         cmp     r12, r0\r
191         bne     reg2_error_loop\r
192 \r
193         ;/* Everything passed, increment the loop counter. */\r
194         push { r1 }\r
195         ldr     r0, =ulRegTest2LoopCounter\r
196         ldr r1, [r0]\r
197         adds r1, r1, #1\r
198         str r1, [r0]\r
199         pop { r1 }\r
200 \r
201         ;/* Start again. */\r
202         movs r0, #10\r
203         b reg2_loop\r
204 \r
205 reg2_error_loop\r
206         ;/* If this line is hit then there was an error in a core register value.\r
207         ;The loop ensures the loop counter stops incrementing. */\r
208         b reg2_error_loop\r
209         nop\r
210         ENDP\r
211 \r
212         END\r