summaryrefslogtreecommitdiff
path: root/FreeRTOS/Demo/Tensilica_Simulator_Xplorer_XCC/regtest_xtensa.S
blob: 0256daf5b6e8a522bf76bd001682c4c5d50cfbf4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
/*
 * FreeRTOS Kernel V10.2.1
 * Copyright (C) 2019 Amazon.com, Inc. or its affiliates.  All Rights Reserved.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy of
 * this software and associated documentation files (the "Software"), to deal in
 * the Software without restriction, including without limitation the rights to
 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
 * the Software, and to permit persons to whom the Software is furnished to do so,
 * subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
 * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 *
 * http://www.FreeRTOS.org
 * http://aws.amazon.com/freertos
 *
 * 1 tab == 4 spaces!
 */

#include "FreeRTOSConfig.h"
//#include "ISR_Support.h"

	.extern ulRegTest1Counter
	.extern ulRegTest2Counter
	.extern vPortYield
	
	.global vRegTest1
	.global vRegTest2

	.text
	.align 4


/*-----------------------------------------------------------*/

vRegTest1:

	/* Set initial values into the general purpose registers.
	 * a0 = return address, a1 = stack pointer. */
#ifdef __XTENSA_WINDOWED_ABI__
	entry	a1, 64
	s32i	a0, a1, 0		/* Save return address. */
#else
	addi	a1, a1, -64
	s32i	a0, a1, 0		/* Save return address. */
	s32i	a12, a1, 4		/* Save callee-saved regs if call0 ABI. */
	s32i	a13, a1, 8
	s32i	a14, a1, 12
	s32i	a15, a1, 16
#endif
	movi	a2, 0x11111111
	movi	a3, 0x22222222
	movi	a4, 0x33333333
	movi	a5, 0x44444444
	movi	a6, 0x55555555
	movi	a7, 0x66666666
	movi	a8, 0x77777777
	movi	a9, 0x88888888
	movi	a10, 0x99999999
	movi	a11, 0xaaaaaaaa
	movi	a12, 0xbbbbbbbb
	movi	a13, 0xcccccccc
	movi	a14, 0xdddddddd
	movi	a15, 0xeeeeeeee

_RegTest1Loop:

	/* Loop checking the values originally loaded into the general purpose
	 * registers remain through the life of the task. */
	movi	a0, 0x11111111
	bne		a0, a2, _RegTest1Error
	movi	a0, 0x22222222
	bne		a0, a3, _RegTest1Error
	movi	a0, 0x33333333
	bne		a0, a4, _RegTest1Error
	movi	a0, 0x44444444
	bne		a0, a5, _RegTest1Error
	movi	a0, 0x55555555
	bne		a0, a6, _RegTest1Error
	movi	a0, 0x66666666
	bne		a0, a7, _RegTest1Error
	movi	a0, 0x77777777
	bne		a0, a8, _RegTest1Error
	movi	a0, 0x88888888
	bne		a0, a9, _RegTest1Error
	movi	a0, 0x99999999
	bne		a0, a10, _RegTest1Error
	movi	a0, 0xaaaaaaaa
	bne		a0, a11, _RegTest1Error
	movi	a0, 0xbbbbbbbb
	bne		a0, a12, _RegTest1Error
	movi	a0, 0xcccccccc
	bne		a0, a13, _RegTest1Error
	movi	a0, 0xdddddddd
	bne		a0, a14, _RegTest1Error
	movi	a0, 0xeeeeeeee
	bne		a0, a15, _RegTest1Error

	/* Incrememnt the loop counter to prove this task has not gone into the
	 * error null loop. */
	s32i	a2, a1, 20
	movi	a2, ulRegTest1Counter
	l32i	a0, a2, 0
	addi	a0, a0, 1
	s32i	a0, a2, 0
	l32i	a2, a1, 20

	/* Loop again. */
	j		_RegTest1Loop

_RegTest1Error:
.L1:
	j		.L1


	.align 4

/*-----------------------------------------------------------*/

vRegTest2:

	/* Set initial values into the general purpose registers.
	 * a0 = return address, a1 = stack pointer. */
#ifdef __XTENSA_WINDOWED_ABI__
	entry	a1, 64
	s32i	a0, a1, 0		/* Save return address. */
#else
	addi	a1, a1, -64
	s32i	a0, a1, 0		/* Save return address. */
	s32i	a12, a1, 4		/* Save callee-saved regs if call0 ABI. */
	s32i	a13, a1, 8
	s32i	a14, a1, 12
	s32i	a15, a1, 16
#endif

_ReInit:

	movi	a2, 0x01010101
	movi	a3, 0x02020202
	movi	a4, 0x03030303
	movi	a5, 0x04040404
	movi	a6, 0x05050505
	movi	a7, 0x06060606
	movi	a8, 0x07070707
	movi	a9, 0x08080808
	movi	a10, 0x09090909
	movi	a11, 0x0a0a0a0a
	movi	a12, 0x0b0b0b0b
	movi	a13, 0x0c0c0c0c
	movi	a14, 0x0d0d0d0d
	movi	a15, 0x0e0e0e0e

_RegTest2Loop:

	/* Loop checking the values originally loaded into the general purpose
	 * registers remain through the life of the task. */
	movi	a0, 0x01010101
	bne		a0, a2, _RegTest1Error
	movi	a0, 0x02020202
	bne		a0, a3, _RegTest1Error
	movi	a0, 0x03030303
	bne		a0, a4, _RegTest1Error
	movi	a0, 0x04040404
	bne		a0, a5, _RegTest1Error
	movi	a0, 0x05050505
	bne		a0, a6, _RegTest1Error
	movi	a0, 0x06060606
	bne		a0, a7, _RegTest1Error
	movi	a0, 0x07070707
	bne		a0, a8, _RegTest1Error
	movi	a0, 0x08080808
	bne		a0, a9, _RegTest1Error
	movi	a0, 0x09090909
	bne		a0, a10, _RegTest1Error
	movi	a0, 0x0a0a0a0a
	bne		a0, a11, _RegTest1Error
	movi	a0, 0x0b0b0b0b
	bne		a0, a12, _RegTest1Error
	movi	a0, 0x0c0c0c0c
	bne		a0, a13, _RegTest1Error
	movi	a0, 0x0d0d0d0d
	bne		a0, a14, _RegTest1Error
	movi	a0, 0x0e0e0e0e
	bne		a0, a15, _RegTest1Error

	/* Force a yield from one of the reg test tasks to increase coverage.
	 * IMPORTANT: this call will trash some number of registers. Branch
	 * to _ReInit to set things up again. */
#ifdef __XTENSA_WINDOWED_ABI__
	call8	vPortYield
#else
	call0	vPortYield
#endif

	/* Increment the loop counter to prove this task has not gone into the
	 * error null loop. */
	s32i	a2, a1, 20
	movi	a2, ulRegTest2Counter
	l32i	a0, a2, 0
	addi	a0, a0, 1
	s32i	a0, a2, 0
	l32i	a2, a1, 20

	/* Loop again. */
	j		_ReInit			/* See comments above about not using  j _RegTest2Loop.  */

_RegTest2Error:
.L2:
	j		.L2