aboutsummaryrefslogtreecommitdiff
path: root/sim/testsuite/bfin/lmu_excpt_default.S
blob: 9b8a14f3a70300d086d902766f52f01fb1da0f64 (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
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
//Original:/proj/frio/dv/testcases/lmu/lmu_excpt_default/lmu_excpt_default.dsp
// Description: Default protection checks (CPLB disabled)
//		- MMR access in User mode
//		- DAG1 Access MMRs (supv/user mode, read/write)
//		- DAG1 Access Scratch SRAM (user or supervisor mode, read/write)
# mach: bfin
# sim: --environment operating

#include "test.h"
.include "testutils.inc"
start

include(selfcheck.inc)
include(std.inc)
include(mmrs.inc)

#define EXCPT_PROTVIOL 0x23
#define OMODE_SUPV 0 // not used in the hardware



	CHECK_INIT(p5, 0xE0000000);

	// setup interrupt controller with exception handler address
	WR_MMR_LABEL(EVT3, handler, p0, r1);
	WR_MMR_LABEL(EVT15, Supv, p0, r1);
	WR_MMR(EVT_IMASK, 0xFFFFFFFF, p0, r0);
	WR_MMR(EVT_OVERRIDE, 0x00000000, p0, r0);
	CSYNC;

	A0 = 0;

	// go to user mode. and enable exceptions
	LD32_LABEL(r0, User);
	RETI = R0;

	// But first raise interrupt 15 so we can run in supervisor mode.
	RAISE 15;

	RTI;

Supv:

	//-------------------------------------------------------
	// DAG1 MMR Write access



	LD32(i1, (DCPLB_ADDR0));
	LD32_LABEL(p2, Y01);			// Exception handler will return to this address
	LD32(r0, 0xdeadbeef);


	R4 = 0;R5 = 0;R6 = 0;R7 = 0;			// Exception handler will set these, reset them first
X01:	A0 = 0 || NOP || [ I1 ] = R1;			// Exception should occur here
Y01:

	// Now check that handler read correct values
	CHECKREG(r4, (OMODE_SUPV|EXCPT_PROTVIOL));		// SEQSTAT
	CHECKREG(r5, DCPLB_ADDR0);				// FAULT ADDRESS
	CHECKREG(r6, (FAULT_WRITE|FAULT_DAG1|FAULT_SUPV));	// DCPLB_STATUS
	CHECKREG_SYM(r7, X01, r0);					// RETX  X01:	(HARDCODED ADDR!!)

	//-------------------------------------------------------
	// DAG1 MMR Read access



	LD32(i1, (DCPLB_ADDR1));
	LD32_LABEL(p2, Y02);			// Exception handler will return to this address


	R4 = 0;R5 = 0;R6 = 0;R7 = 0;			// Exception handler will set these, reset them first
X02:	A0 = 0 || NOP || R1 = [ I1 ];			// Exception should occur here
Y02:

	// Now check that handler read correct values
	CHECKREG(r4, (OMODE_SUPV|EXCPT_PROTVIOL));		// SEQSTAT
	CHECKREG(r5, DCPLB_ADDR1);				// FAULT ADDRESS
	CHECKREG(r6, (FAULT_READ|FAULT_DAG1|FAULT_SUPV));	// DCPLB_STATUS
	CHECKREG_SYM(r7, X02, r0);					// RETX  X02:	(HARDCODED ADDR!!)

#if 0
	//-------------------------------------------------------
	// DAG1 Scratch SRAM Write access



	LD32(i1, (( 0xFF800000 + 0x300000)));
	LD32_LABEL(p2, Y03);			// Exception handler will return to this address
	LD32(r1, 0xdeadbeef);


	R4 = 0;R5 = 0;R6 = 0;R7 = 0;			// Exception handler will set these, reset them first
X03:	A0 = 0 || NOP || [ I1 ] = R1;			// Exception should occur here
Y03:

	// Now check that handler read correct values
	CHECKREG(r4, (OMODE_SUPV|EXCPT_PROTVIOL));		// SEQSTAT
	CHECKREG(r5, ( 0xFF800000 + 0x300000));				// FAULT ADDRESS
	CHECKREG(r6, (FAULT_WRITE|FAULT_DAG1|FAULT_SUPV));	// DCPLB_STATUS
	CHECKREG_SYM(r7, X03, r0);					// RETX  X03:	(HARDCODED ADDR!!)

	//-------------------------------------------------------
	// DAG1 Scratch SRAM Read access



	LD32(i1, ((( 0xFF800000 + 0x300000) + 4)));
	LD32_LABEL(p2, Y04);			// Exception handler will return to this address


	R4 = 0;R5 = 0;R6 = 0;R7 = 0;			// Exception handler will set these, reset them first
X04:	A0 = 0 || NOP || R1 = [ I1 ];			// Exception should occur here
Y04:

	// Now check that handler read correct values
	CHECKREG(r4, (OMODE_SUPV|EXCPT_PROTVIOL));		// SEQSTAT
	CHECKREG(r5, (( 0xFF800000 + 0x300000) + 4));				// FAULT ADDRESS
	CHECKREG(r6, (FAULT_READ|FAULT_DAG1|FAULT_SUPV));	// DCPLB_STATUS
	CHECKREG_SYM(r7, X04, r0);					// RETX  X04:	(HARDCODED ADDR!!)
#endif

	//-------------------------------------------------------

	// Now, go to User mode
	LD32_LABEL(r0, User);
	RETI = R0;
	RTI;


User:

	//-------------------------------------------------------
	// DAG0 MMR Write access (multi-issue)



	LD32(i1, (DCPLB_ADDR0));
	LD32_LABEL(p2, Y11);			// Exception handler will return to this address
	LD32(r0, 0xdeadbeef);


	R4 = 0;R5 = 0;R6 = 0;R7 = 0;			// Exception handler will set these, reset them first
X11:	A0 = 0 || [ I1 ] = R1 || NOP;			// Exception should occur here
Y11:

	// Now check that handler read correct values
	CHECKREG(r4, (OMODE_SUPV|EXCPT_PROTVIOL));		// SEQSTAT
	CHECKREG(r5, DCPLB_ADDR0);				// FAULT ADDRESS
	CHECKREG(r6, (FAULT_WRITE|FAULT_DAG0|FAULT_USER));	// DCPLB_STATUS
	CHECKREG_SYM(r7, X11, r0);					// RETX  X11:	(HARDCODED ADDR!!)

	//-------------------------------------------------------
	// DAG0 MMR Read access (multi-issue)



	LD32(i1, (DCPLB_ADDR1));
	LD32_LABEL(p2, Y12);			// Exception handler will return to this address


	R4 = 0;R5 = 0;R6 = 0;R7 = 0;			// Exception handler will set these, reset them first
X12:	A0 = 0 || R1 = [ I1 ] || NOP;			// Exception should occur here
Y12:

	// Now check that handler read correct values
	CHECKREG(r4, (OMODE_SUPV|EXCPT_PROTVIOL));		// SEQSTAT
	CHECKREG(r5, DCPLB_ADDR1);				// FAULT ADDRESS
	CHECKREG(r6, (FAULT_READ|FAULT_DAG0|FAULT_USER));	// DCPLB_STATUS
	CHECKREG_SYM(r7, X12, r0);					// RETX  X12:	(HARDCODED ADDR!!)

	//-------------------------------------------------------
	// DAG1 MMR Write access



	LD32(i1, (DCPLB_ADDR0));
	LD32_LABEL(p2, Y13);			// Exception handler will return to this address
	LD32(r0, 0xdeadbeef);


	R4 = 0;R5 = 0;R6 = 0;R7 = 0;			// Exception handler will set these, reset them first
X13:	A0 = 0 || NOP || [ I1 ] = R1;			// Exception should occur here
Y13:

	// Now check that handler read correct values
	CHECKREG(r4, (OMODE_SUPV|EXCPT_PROTVIOL));		// SEQSTAT
	CHECKREG(r5, DCPLB_ADDR0);				// FAULT ADDRESS
	CHECKREG(r6, (FAULT_WRITE|FAULT_DAG1|FAULT_USER));	// DCPLB_STATUS
	CHECKREG_SYM(r7, X13, r0);					// RETX  X13:	(HARDCODED ADDR!!)

	//-------------------------------------------------------
	// DAG1 MMR Read access



	LD32(i1, (DCPLB_ADDR1));
	LD32_LABEL(p2, Y14);			// Exception handler will return to this address


	R4 = 0;R5 = 0;R6 = 0;R7 = 0;			// Exception handler will set these, reset them first
X14:	A0 = 0 || NOP || R1 = [ I1 ];			// Exception should occur here
Y14:

	// Now check that handler read correct values
	CHECKREG(r4, (OMODE_SUPV|EXCPT_PROTVIOL));		// SEQSTAT
	CHECKREG(r5, DCPLB_ADDR1);				// FAULT ADDRESS
	CHECKREG(r6, (FAULT_READ|FAULT_DAG1|FAULT_USER));	// DCPLB_STATUS
	CHECKREG_SYM(r7, X14, r0);					// RETX  X14:	(HARDCODED ADDR!!)

#if 0
	//-------------------------------------------------------
	// DAG1 Scratch SRAM Write access



	LD32(i1, (( 0xFF800000 + 0x300000)));
	LD32_LABEL(p2, Y15);			// Exception handler will return to this address
	LD32(r1, 0xdeadbeef);


	R4 = 0;R5 = 0;R6 = 0;R7 = 0;			// Exception handler will set these, reset them first
X15:	A0 = 0 || NOP || [ I1 ] = R1;			// Exception should occur here
Y15:

	// Now check that handler read correct values
	CHECKREG(r4, (OMODE_SUPV|EXCPT_PROTVIOL));		// SEQSTAT
	CHECKREG(r5, ( 0xFF800000 + 0x300000));				// FAULT ADDRESS
	CHECKREG(r6, (FAULT_WRITE|FAULT_DAG1|FAULT_USER));	// DCPLB_STATUS
	CHECKREG_SYM(r7, X15, r0);					// RETX  X15:	(HARDCODED ADDR!!)

	//-------------------------------------------------------
	// DAG1 Scratch SRAM Read access



	LD32(i1, ((( 0xFF800000 + 0x300000) + 4)));
	LD32_LABEL(p2, Y16);			// Exception handler will return to this address


	R4 = 0;R5 = 0;R6 = 0;R7 = 0;			// Exception handler will set these, reset them first
X16:	A0 = 0 || NOP || R1 = [ I1 ];			// Exception should occur here
Y16:

	// Now check that handler read correct values
	CHECKREG(r4, (OMODE_SUPV|EXCPT_PROTVIOL));		// SEQSTAT
	CHECKREG(r5, (( 0xFF800000 + 0x300000) + 4));				// FAULT ADDRESS
	CHECKREG(r6, (FAULT_READ|FAULT_DAG1|FAULT_USER));	// DCPLB_STATUS
	CHECKREG_SYM(r7, X16, r0);					// RETX  X16:	(HARDCODED ADDR!!)
#endif

	//-------------------------------------------------------
	// DAG0 MMR Write access (single-issue)



	LD32(i1, (DCPLB_ADDR0));
	LD32_LABEL(p2, Y17);			// Exception handler will return to this address
	LD32(r0, 0xdeadbeef);


	R4 = 0;R5 = 0;R6 = 0;R7 = 0;			// Exception handler will set these, reset them first
X17:	[ I1 ] = R1;				// Exception should occur here
Y17:

	// Now check that handler read correct values
	CHECKREG(r4, (OMODE_SUPV|EXCPT_PROTVIOL));		// SEQSTAT
	CHECKREG(r5, DCPLB_ADDR0);				// FAULT ADDRESS
	CHECKREG(r6, (FAULT_WRITE|FAULT_DAG0|FAULT_USER));	// DCPLB_STATUS
	CHECKREG_SYM(r7, X17, r0);					// RETX  X17:	(HARDCODED ADDR!!)

	//-------------------------------------------------------
	// DAG0 MMR Read access (single-issue)



	LD32(i1, (DCPLB_ADDR1));
	LD32_LABEL(p2, Y18);			// Exception handler will return to this address


	R4 = 0;R5 = 0;R6 = 0;R7 = 0;			// Exception handler will set these, reset them first
X18:	R1 = [ I1 ];				// Exception should occur here
Y18:

	// Now check that handler read correct values
	CHECKREG(r4, (OMODE_SUPV|EXCPT_PROTVIOL));		// SEQSTAT
	CHECKREG(r5, DCPLB_ADDR1);				// FAULT ADDRESS
	CHECKREG(r6, (FAULT_READ|FAULT_DAG0|FAULT_USER));	// DCPLB_STATUS
	CHECKREG_SYM(r7, X18, r0);					// RETX  X18:	(HARDCODED ADDR!!)

	//-------------------------------------------------------
	dbg_pass;


handler:
	R4 = SEQSTAT;	// Get exception cause

	// read and check fail addr (addr_which_causes_exception)
	// should not be set for alignment exception
	RD_MMR(DCPLB_FAULT_ADDR, p0, r5);
	RD_MMR(DCPLB_STATUS, p0, r6);
	R7 = RETX;	// get address of excepting instruction

	RETX = P2;

	RTX;