]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/IA32_flat_GCC_Galileo_Gen_2/Full_Demo/RegTest.S
Update to MIT licensed FreeRTOS V10.0.0 - see https://www.freertos.org/History.txt
[freertos] / FreeRTOS / Demo / IA32_flat_GCC_Galileo_Gen_2 / Full_Demo / RegTest.S
1 /*\r
2  * FreeRTOS Kernel V10.0.0\r
3  * Copyright (C) 2017 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. 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
15  *\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
22  *\r
23  * http://www.FreeRTOS.org\r
24  * http://aws.amazon.com/freertos\r
25  *\r
26  * 1 tab == 4 spaces!\r
27  */\r
28 \r
29 .file "RegTest.S"\r
30 #include "FreeRTOSConfig.h"\r
31 #include "ISR_Support.h"\r
32 \r
33         .extern ulRegTest1Counter\r
34         .extern ulRegTest2Counter\r
35         .extern dRegTest1_st7\r
36         .extern dRegTest1_st6\r
37         .extern dRegTest1_st5\r
38         .extern dRegTest1_st4\r
39         .extern dRegTest1_st3\r
40         .extern dRegTest1_st2\r
41         .extern dRegTest1_st1\r
42         .extern dRegTest2_st7\r
43         .extern dRegTest2_st6\r
44         .extern dRegTest2_st5\r
45         .extern dRegTest2_st4\r
46         .extern dRegTest2_st3\r
47         .extern dRegTest2_st2\r
48         .extern dRegTest2_st1\r
49         .extern vGenerateYieldInterrupt\r
50         .extern vHPETIRQHandler1\r
51         \r
52         .global vRegTest1\r
53         .global vRegTest2\r
54         .global vApplicationHPETTimer1Wrapper\r
55 \r
56         .section .text.last /* Push up the memory to check executing from higher memory addresses. */\r
57         .align 4\r
58 \r
59 .func vRegTest1\r
60 vRegTest1:\r
61 \r
62         /* Set initial values into the general purpose registers. */\r
63         movl    $0x11111111, %eax\r
64         movl    $0x22222222, %ebx\r
65         movl    $0x33333333, %ecx\r
66         movl    $0x44444444, %edx\r
67         movl    $0x55555555, %esi\r
68         movl    $0x66666666, %edi\r
69 \r
70         /* Set initial values into the floating point registers. */\r
71         .if configSUPPORT_FPU == 1\r
72                 fldl    dRegTest1_st7\r
73                 fldl    dRegTest1_st6\r
74                 fldl    dRegTest1_st5\r
75                 fldl    dRegTest1_st4\r
76                 fldl    dRegTest1_st3\r
77                 fldl    dRegTest1_st2\r
78                 fldl    dRegTest1_st1\r
79         .endif /* configSUPPORT_FPU */\r
80 \r
81 _RegTest1Loop:\r
82 \r
83         /* Loop checking the values originally loaded into the general purpose\r
84         registers remain through the life of the task. */\r
85         cmp     $0x11111111, %eax\r
86         jne     _RegTest1Error\r
87         cmp     $0x22222222, %ebx\r
88         jne     _RegTest1Error\r
89         cmp     $0x33333333, %ecx\r
90         jne     _RegTest1Error\r
91         cmp     $0x44444444, %edx\r
92         jne     _RegTest1Error\r
93         cmp     $0x55555555, %esi\r
94         jne     _RegTest1Error\r
95         cmp     $0x66666666, %edi\r
96         jne     _RegTest1Error\r
97 \r
98 \r
99         .if configSUPPORT_FPU == 1\r
100                 /* Loop checking the values originally loaded into the floating point\r
101                 registers remain through the life of the task. */\r
102                 push    %eax                    /* push clobbered register. */\r
103                 fldl    dRegTest1_st7   /* st( 0 ) set to st( 7 ) value. */\r
104                 fucomp  %st( 7 )                /* Compare st( 0 ) with st( 7 ) and pop. */\r
105                 fnstsw  %ax                             /* Copy status word to ax. */\r
106                 and     $0x45, %ah              /* Mask bits. */\r
107                 xor     $0x40, %ah              /* test bits. */\r
108                 jne     _RegTest1Error\r
109                 fldl    dRegTest1_st6\r
110                 fucomp  %st( 6 )\r
111                 fnstsw  %ax\r
112                 and     $0x45, %ah\r
113                 xor     $0x40, %ah\r
114                 jne     _RegTest1Error\r
115                 fldl    dRegTest1_st5\r
116                 fucomp  %st( 5 )\r
117                 fnstsw  %ax\r
118                 and     $0x45, %ah\r
119                 xor     $0x40, %ah\r
120                 jne     _RegTest1Error\r
121                 fldl    dRegTest1_st4\r
122                 fucomp  %st( 4 )\r
123                 fnstsw  %ax\r
124                 and     $0x45, %ah\r
125                 xor     $0x40, %ah\r
126                 jne     _RegTest1Error\r
127                 fldl    dRegTest1_st3\r
128                 fucomp  %st( 3 )\r
129                 fnstsw  %ax\r
130                 and     $0x45, %ah\r
131                 xor     $0x40, %ah\r
132                 jne     _RegTest1Error\r
133                 fldl    dRegTest1_st2\r
134                 fucomp  %st( 2 )\r
135                 fnstsw  %ax\r
136                 and     $0x45, %ah\r
137                 xor     $0x40, %ah\r
138                 jne     _RegTest1Error\r
139                 fldl    dRegTest1_st1\r
140                 fucomp  %st( 1 )\r
141                 fnstsw  %ax\r
142                 and     $0x45, %ah\r
143                 xor     $0x40, %ah\r
144                 jne     _RegTest1Error\r
145 \r
146                 /* Restore clobbered register. */\r
147                 pop     %eax\r
148         .endif /* configSUPPORT_FPU */\r
149 \r
150         /* Incrememnt the loop counter to prove this task has not gone into the\r
151         error null loop. */\r
152         add     $1, ulRegTest1Counter\r
153 \r
154         /* Loop again. */\r
155         jmp     _RegTest1Loop\r
156 \r
157 _RegTest1Error:\r
158         jmp             .\r
159 .endfunc\r
160 /*-----------------------------------------------------------*/\r
161 \r
162 .func vRegTest2\r
163 vRegTest2:\r
164 \r
165         /* Set initial values into the general purpose registers. */\r
166         movl    $0x10101010, %eax\r
167         movl    $0x20202020, %ebx\r
168         movl    $0x30303030, %ecx\r
169         movl    $0x40404040, %edx\r
170         movl    $0x50505050, %esi\r
171         movl    $0x60606060, %edi\r
172 \r
173         /* Set initial values into the floating point registers. */\r
174         .if configSUPPORT_FPU == 1\r
175                 fldl    dRegTest2_st7\r
176                 fldl    dRegTest2_st6\r
177                 fldl    dRegTest2_st5\r
178                 fldl    dRegTest2_st4\r
179                 fldl    dRegTest2_st3\r
180                 fldl    dRegTest2_st2\r
181                 fldl    dRegTest2_st1\r
182         .endif\r
183 \r
184 _RegTest2Loop:\r
185 \r
186         /* Loop checking the values originally loaded into the general purpose\r
187         registers remain through the life of the task. */\r
188         cmp     $0x10101010, %eax\r
189         jne     _RegTest2Error\r
190         cmp     $0x20202020, %ebx\r
191         jne     _RegTest2Error\r
192         cmp     $0x30303030, %ecx\r
193         jne     _RegTest2Error\r
194         cmp     $0x40404040, %edx\r
195         jne     _RegTest2Error\r
196         cmp     $0x50505050, %esi\r
197         jne     _RegTest2Error\r
198         cmp     $0x60606060, %edi\r
199         jne     _RegTest1Error\r
200 \r
201         .if configSUPPORT_FPU == 1\r
202                 /* Loop checking the values originally loaded into the floating point\r
203                 registers remain through the life of the task. */\r
204                 /* Loop checking the values originally loaded into the floating point\r
205                 registers remain through the life of the task. */\r
206                 push    %eax                    /* push clobbered register. */\r
207                 fldl    dRegTest2_st7                   /* st( 0 ) set to st( 7 ) value. */\r
208                 fucomp  %st( 7 )                /* Compare st( 0 ) with st( 7 ) and pop. */\r
209                 fnstsw  %ax                             /* Copy status word to ax. */\r
210                 and     $0x45, %ah              /* Mask bits. */\r
211                 xor     $0x40, %ah              /* test bits. */\r
212                 jne     _RegTest1Error\r
213                 fldl    dRegTest2_st6\r
214                 fucomp  %st( 6 )\r
215                 fnstsw  %ax\r
216                 and     $0x45, %ah\r
217                 xor     $0x40, %ah\r
218                 jne     _RegTest1Error\r
219                 fldl    dRegTest2_st5\r
220                 fucomp  %st( 5 )\r
221                 fnstsw  %ax\r
222                 and     $0x45, %ah\r
223                 xor     $0x40, %ah\r
224                 jne     _RegTest1Error\r
225                 fldl    dRegTest2_st4\r
226                 fucomp  %st( 4 )\r
227                 fnstsw  %ax\r
228                 and     $0x45, %ah\r
229                 xor     $0x40, %ah\r
230                 jne     _RegTest1Error\r
231                 fldl    dRegTest2_st3\r
232                 fucomp  %st( 3 )\r
233                 fnstsw  %ax\r
234                 and     $0x45, %ah\r
235                 xor     $0x40, %ah\r
236                 jne     _RegTest1Error\r
237                 fldl    dRegTest2_st2\r
238                 fucomp  %st( 2 )\r
239                 fnstsw  %ax\r
240                 and     $0x45, %ah\r
241                 xor     $0x40, %ah\r
242                 jne     _RegTest1Error\r
243                 fldl    dRegTest2_st1\r
244                 fucomp  %st( 1 )\r
245                 fnstsw  %ax\r
246                 and     $0x45, %ah\r
247                 xor     $0x40, %ah\r
248                 jne     _RegTest1Error\r
249 \r
250                 /* Restore clobbered register. */\r
251                 pop     %eax\r
252 \r
253         .endif /* configSUPPORT_FPU */\r
254 \r
255         /* Force a yield from one of the reg test tasks to increase coverage. */\r
256         call vGenerateYieldInterrupt\r
257 \r
258         /* Increment the loop counter to prove this task has not entered the error\r
259         null loop. */\r
260         add     $1, ulRegTest2Counter\r
261         jmp     _RegTest2Loop\r
262 \r
263 _RegTest2Error:\r
264         jmp     .\r
265 \r
266 .endfunc\r
267 \r
268 /*-----------------------------------------------------------*/\r
269 \r
270 /* Purely for demonstration purposes, two of the HPET timers used by the\r
271 IntQueue test use the central interrupt handler, and timer 1 uses its own\r
272 assembly wrapper - which is defined below.  See\r
273 http://www.freertos.org/RTOS_Intel_Quark_Galileo_GCC.html#interrupts for more\r
274 information. */\r
275 .func vApplicationHPETTimer1Wrapper\r
276 vApplicationHPETTimer1Wrapper:\r
277 \r
278         portFREERTOS_INTERRUPT_ENTRY\r
279         call vHPETIRQHandler1\r
280         portFREERTOS_INTERRUPT_EXIT\r
281 \r
282 .endfunc\r
283 \r
284 .end\r