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 "FreeRTOS.h"
\r
33 * Two test tasks that fill the CPU registers with known values before
\r
34 * continuously looping round checking that each register still contains its
\r
35 * expected value. Both tasks use a separate set of values, with an incorrect
\r
36 * value being found at any time being indicative of an error in the context
\r
37 * switch mechanism. One of the tasks uses a yield instruction to increase the
\r
38 * test coverage. The nature of these tasks necessitates that they are written
\r
41 static void vRegTest1( void *pvParameters );
\r
42 static void vRegTest2( void *pvParameters );
\r
44 /* Counters used to ensure the tasks are still running. */
\r
45 static volatile unsigned long ulRegTest1Counter = 0UL, ulRegTest2Counter = 0UL;
\r
47 /*-----------------------------------------------------------*/
\r
49 void vStartRegTestTasks( void )
\r
51 xTaskCreate( vRegTest1, "RTest1", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL );
\r
52 xTaskCreate( vRegTest2, "RTest1", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL );
\r
54 /*-----------------------------------------------------------*/
\r
56 static void vRegTest1( void *pvParameters )
\r
60 " mov r2, #0x02 \n" /* Fill the registers with known values, r0 is always 0 and r1 is the stack pointer. */
\r
68 " mov r10, #0x0a \n"
\r
69 " mov r11, #0x0b \n"
\r
70 " mov r12, #0x0c \n"
\r
71 " mov r13, #0x0d \n"
\r
72 " mov r14, #0x0e \n"
\r
73 " mov r15, #0x0f \n"
\r
75 "reg_check_loop_1: \n"
\r
77 " cmp r2, #0x02 \n" /* Check that each register still contains the expected value, jump to an infinite loop if an error is found. */
\r
78 " bne.s reg_check_error_1 \n"
\r
80 " bne.s reg_check_error_1 \n"
\r
82 " bne.s reg_check_error_1 \n"
\r
84 " bne.s reg_check_error_1 \n"
\r
86 " bne.s reg_check_error_1 \n"
\r
88 " bne.s reg_check_error_1 \n"
\r
90 " bne.s reg_check_error_1 \n"
\r
92 " bne.s reg_check_error_1 \n"
\r
93 " cmp r10, #0x0a \n"
\r
94 " bne.s reg_check_error_1 \n"
\r
95 " cmp r11, #0x0b \n"
\r
96 " bne.s reg_check_error_1 \n"
\r
97 " cmp r12, #0x0c \n"
\r
98 " bne.s reg_check_error_1 \n"
\r
99 " cmp r13, #0x0d \n"
\r
100 " bne.s reg_check_error_1 \n"
\r
101 " cmp r14, #0x0e \n"
\r
102 " bne.s reg_check_error_1 \n"
\r
103 " cmp r15, #0x0f \n"
\r
104 " bne.s reg_check_error_1 \n"
\r
106 " ld r2, [r0]+short(ulRegTest1Counter) \n" /* Increment the loop counter to show that this task is still running error free. */
\r
108 " st r2, [r0]+short(ulRegTest1Counter) \n"
\r
109 " mov r2, #0x02 \n"
\r
111 " bra.s reg_check_loop_1 \n" /* Do it all again. */
\r
113 "reg_check_error_1: \n"
\r
117 /*-----------------------------------------------------------*/
\r
119 static void vRegTest2( void *pvParameters )
\r
123 " mov r2, #0x12 \n" /* Fill the registers with known values, r0 is always 0 and r1 is the stack pointer. */
\r
124 " mov r3, #0x13 \n"
\r
125 " mov r4, #0x14 \n"
\r
126 " mov r5, #0x15 \n"
\r
127 " mov r6, #0x16 \n"
\r
128 " mov r7, #0x17 \n"
\r
129 " mov r8, #0x18 \n"
\r
130 " mov r9, #0x19 \n"
\r
131 " mov r10, #0x1a \n"
\r
132 " mov r11, #0x1b \n"
\r
133 " mov r12, #0x1c \n"
\r
134 " mov r13, #0x1d \n"
\r
135 " mov r14, #0x1e \n"
\r
136 " mov r15, #0x1f \n"
\r
138 "reg_check_loop_2: \n"
\r
139 " cmp r2, #0x12 \n" /* Check that each register still contains the expected value, jump to an infinite loop if an error is found. */
\r
140 " bne.s reg_check_error_2 \n"
\r
141 " cmp r3, #0x13 \n"
\r
142 " bne.s reg_check_error_2 \n"
\r
143 " cmp r4, #0x14 \n"
\r
144 " bne.s reg_check_error_2 \n"
\r
145 " cmp r5, #0x15 \n"
\r
146 " bne.s reg_check_error_2 \n"
\r
147 " cmp r6, #0x16 \n"
\r
148 " bne.s reg_check_error_2 \n"
\r
149 " cmp r7, #0x17 \n"
\r
150 " bne.s reg_check_error_2 \n"
\r
151 " cmp r8, #0x18 \n"
\r
152 " bne.s reg_check_error_2 \n"
\r
153 " cmp r9, #0x19 \n"
\r
154 " bne.s reg_check_error_2 \n"
\r
155 " cmp r10, #0x1a \n"
\r
156 " bne.s reg_check_error_2 \n"
\r
157 " cmp r11, #0x1b \n"
\r
158 " bne.s reg_check_error_2 \n"
\r
159 " cmp r12, #0x1c \n"
\r
160 " bne.s reg_check_error_2 \n"
\r
161 " cmp r13, #0x1d \n"
\r
162 " bne.s reg_check_error_2 \n"
\r
163 " cmp r14, #0x1e \n"
\r
164 " bne.s reg_check_error_2 \n"
\r
165 " cmp r15, #0x1f \n"
\r
166 " bne.s reg_check_error_2 \n"
\r
168 " ld r2, [r0]+short(ulRegTest2Counter) \n" /* Increment the loop counter to show that this task is still running error free. */
\r
170 " st r2, [r0]+short(ulRegTest2Counter) \n"
\r
171 " mov r2, #0x12 \n"
\r
173 " bra.s reg_check_loop_2 \n" /* Do it all again. */
\r
175 "reg_check_error_2: \n"
\r
179 /*-----------------------------------------------------------*/
\r
181 portBASE_TYPE xAreRegTestTasksStillRunning( void )
\r
183 static unsigned long ulLastCounter1 = 0UL, ulLastCounter2 = 0UL;
\r
186 /* Check that both loop counters are still incrementing, indicating that
\r
187 both reg test tasks are still running error free. */
\r
188 if( ulLastCounter1 == ulRegTest1Counter )
\r
192 else if( ulLastCounter2 == ulRegTest2Counter )
\r
201 ulLastCounter1 = ulRegTest1Counter;
\r
202 ulLastCounter2 = ulRegTest2Counter;
\r