2 * FreeRTOS Kernel V10.3.0
\r
3 * Copyright (C) 2020 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.
\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
22 * http://www.FreeRTOS.org
\r
23 * http://aws.amazon.com/freertos
\r
25 * 1 tab == 4 spaces!
\r
28 #include "FreeRTOS.h"
\r
32 * Two test tasks that fill the CPU registers with known values before
\r
33 * continuously looping round checking that each register still contains its
\r
34 * expected value. Both tasks use a separate set of values, with an incorrect
\r
35 * value being found at any time being indicative of an error in the context
\r
36 * switch mechanism. One of the tasks uses a yield instruction to increase the
\r
37 * test coverage. The nature of these tasks necessitates that they are written
\r
40 static void vRegTest1( void *pvParameters );
\r
41 static void vRegTest2( void *pvParameters );
\r
43 /* Counters used to ensure the tasks are still running. */
\r
44 static volatile unsigned long ulRegTest1Counter = 0UL, ulRegTest2Counter = 0UL;
\r
46 /*-----------------------------------------------------------*/
\r
48 void vStartRegTestTasks( void )
\r
50 xTaskCreate( vRegTest1, "RTest1", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL );
\r
51 xTaskCreate( vRegTest2, "RTest1", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL );
\r
53 /*-----------------------------------------------------------*/
\r
55 static void vRegTest1( void *pvParameters )
\r
59 " mov r2, #0x02 \n" /* Fill the registers with known values, r0 is always 0 and r1 is the stack pointer. */
\r
67 " mov r10, #0x0a \n"
\r
68 " mov r11, #0x0b \n"
\r
69 " mov r12, #0x0c \n"
\r
70 " mov r13, #0x0d \n"
\r
71 " mov r14, #0x0e \n"
\r
72 " mov r15, #0x0f \n"
\r
74 "reg_check_loop_1: \n"
\r
76 " cmp r2, #0x02 \n" /* Check that each register still contains the expected value, jump to an infinite loop if an error is found. */
\r
77 " bne.s reg_check_error_1 \n"
\r
79 " bne.s reg_check_error_1 \n"
\r
81 " bne.s reg_check_error_1 \n"
\r
83 " bne.s reg_check_error_1 \n"
\r
85 " bne.s reg_check_error_1 \n"
\r
87 " bne.s reg_check_error_1 \n"
\r
89 " bne.s reg_check_error_1 \n"
\r
91 " bne.s reg_check_error_1 \n"
\r
92 " cmp r10, #0x0a \n"
\r
93 " bne.s reg_check_error_1 \n"
\r
94 " cmp r11, #0x0b \n"
\r
95 " bne.s reg_check_error_1 \n"
\r
96 " cmp r12, #0x0c \n"
\r
97 " bne.s reg_check_error_1 \n"
\r
98 " cmp r13, #0x0d \n"
\r
99 " bne.s reg_check_error_1 \n"
\r
100 " cmp r14, #0x0e \n"
\r
101 " bne.s reg_check_error_1 \n"
\r
102 " cmp r15, #0x0f \n"
\r
103 " bne.s reg_check_error_1 \n"
\r
105 " ld r2, [r0]+short(ulRegTest1Counter) \n" /* Increment the loop counter to show that this task is still running error free. */
\r
107 " st r2, [r0]+short(ulRegTest1Counter) \n"
\r
108 " mov r2, #0x02 \n"
\r
110 " bra.s reg_check_loop_1 \n" /* Do it all again. */
\r
112 "reg_check_error_1: \n"
\r
116 /*-----------------------------------------------------------*/
\r
118 static void vRegTest2( void *pvParameters )
\r
122 " mov r2, #0x12 \n" /* Fill the registers with known values, r0 is always 0 and r1 is the stack pointer. */
\r
123 " mov r3, #0x13 \n"
\r
124 " mov r4, #0x14 \n"
\r
125 " mov r5, #0x15 \n"
\r
126 " mov r6, #0x16 \n"
\r
127 " mov r7, #0x17 \n"
\r
128 " mov r8, #0x18 \n"
\r
129 " mov r9, #0x19 \n"
\r
130 " mov r10, #0x1a \n"
\r
131 " mov r11, #0x1b \n"
\r
132 " mov r12, #0x1c \n"
\r
133 " mov r13, #0x1d \n"
\r
134 " mov r14, #0x1e \n"
\r
135 " mov r15, #0x1f \n"
\r
137 "reg_check_loop_2: \n"
\r
138 " cmp r2, #0x12 \n" /* Check that each register still contains the expected value, jump to an infinite loop if an error is found. */
\r
139 " bne.s reg_check_error_2 \n"
\r
140 " cmp r3, #0x13 \n"
\r
141 " bne.s reg_check_error_2 \n"
\r
142 " cmp r4, #0x14 \n"
\r
143 " bne.s reg_check_error_2 \n"
\r
144 " cmp r5, #0x15 \n"
\r
145 " bne.s reg_check_error_2 \n"
\r
146 " cmp r6, #0x16 \n"
\r
147 " bne.s reg_check_error_2 \n"
\r
148 " cmp r7, #0x17 \n"
\r
149 " bne.s reg_check_error_2 \n"
\r
150 " cmp r8, #0x18 \n"
\r
151 " bne.s reg_check_error_2 \n"
\r
152 " cmp r9, #0x19 \n"
\r
153 " bne.s reg_check_error_2 \n"
\r
154 " cmp r10, #0x1a \n"
\r
155 " bne.s reg_check_error_2 \n"
\r
156 " cmp r11, #0x1b \n"
\r
157 " bne.s reg_check_error_2 \n"
\r
158 " cmp r12, #0x1c \n"
\r
159 " bne.s reg_check_error_2 \n"
\r
160 " cmp r13, #0x1d \n"
\r
161 " bne.s reg_check_error_2 \n"
\r
162 " cmp r14, #0x1e \n"
\r
163 " bne.s reg_check_error_2 \n"
\r
164 " cmp r15, #0x1f \n"
\r
165 " bne.s reg_check_error_2 \n"
\r
167 " ld r2, [r0]+short(ulRegTest2Counter) \n" /* Increment the loop counter to show that this task is still running error free. */
\r
169 " st r2, [r0]+short(ulRegTest2Counter) \n"
\r
170 " mov r2, #0x12 \n"
\r
172 " bra.s reg_check_loop_2 \n" /* Do it all again. */
\r
174 "reg_check_error_2: \n"
\r
178 /*-----------------------------------------------------------*/
\r
180 portBASE_TYPE xAreRegTestTasksStillRunning( void )
\r
182 static unsigned long ulLastCounter1 = 0UL, ulLastCounter2 = 0UL;
\r
185 /* Check that both loop counters are still incrementing, indicating that
\r
186 both reg test tasks are still running error free. */
\r
187 if( ulLastCounter1 == ulRegTest1Counter )
\r
191 else if( ulLastCounter2 == ulRegTest2Counter )
\r
200 ulLastCounter1 = ulRegTest1Counter;
\r
201 ulLastCounter2 = ulRegTest2Counter;
\r