summaryrefslogtreecommitdiff
path: root/sim/testsuite/bfin/lmu_excpt_prot0.S
blob: 279cc025223d26925569f0faef9f7244c24529cd (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
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
//Original:/proj/frio/dv/testcases/lmu/lmu_excpt_prot0/lmu_excpt_prot0.dsp
// Description: LMU protection exceptions
# mach: bfin
# sim: --environment operating

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

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

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

// Test LMU/CPLB exceptions

// Basic outline:
//   Set exception handler
//   program CPLB Entries
//   Enable CPLB in DMEM_CNTL
//   perform access
//   verify exception occurred

CHECK_INIT(p5, 0xEFFFFFFC);

//-------------------------
// Zero the CPLB Address and Data regs.

	LD32(p0, DCPLB_ADDR0);
	R0 = 0;
	[ P0 ++ ] = R0;	// 0
	[ P0 ++ ] = R0;	// 1
	[ P0 ++ ] = R0;	// 2
	[ P0 ++ ] = R0;	// 3
	[ P0 ++ ] = R0;	// 4
	[ P0 ++ ] = R0;	// 5
	[ P0 ++ ] = R0;	// 6
	[ P0 ++ ] = R0;	// 7
	[ P0 ++ ] = R0;	// 8
	[ P0 ++ ] = R0;	// 9
	[ P0 ++ ] = R0;	// 10
	[ P0 ++ ] = R0;	// 11
	[ P0 ++ ] = R0;	// 12
	[ P0 ++ ] = R0;	// 13
	[ P0 ++ ] = R0;	// 14
	[ P0 ++ ] = R0;	// 15

	LD32(p0, DCPLB_DATA0);
	[ P0 ++ ] = R0;	// 0
	[ P0 ++ ] = R0;	// 1
	[ P0 ++ ] = R0;	// 2
	[ P0 ++ ] = R0;	// 3
	[ P0 ++ ] = R0;	// 4
	[ P0 ++ ] = R0;	// 5
	[ P0 ++ ] = R0;	// 6
	[ P0 ++ ] = R0;	// 7
	[ P0 ++ ] = R0;	// 8
	[ P0 ++ ] = R0;	// 9
	[ P0 ++ ] = R0;	// 10
	[ P0 ++ ] = R0;	// 11
	[ P0 ++ ] = R0;	// 12
	[ P0 ++ ] = R0;	// 13
	[ P0 ++ ] = R0;	// 14
	[ P0 ++ ] = R0;	// 15

	// Now set the CPLB entries we will need

























	// Data area for the desired error
	WR_MMR(DCPLB_ADDR0, 0x800, p0, r0);
	WR_MMR(DCPLB_ADDR1, 0x1000, p0, r0);
	WR_MMR(DCPLB_DATA0, PAGE_SIZE_1K|CPLB_VALID|CPLB_DIRTY|CPLB_L1_CACHABLE|CPLB_USER_RW, p0, r0);
	WR_MMR(DCPLB_ADDR2, 0x2000, p0, r0);
	WR_MMR(DCPLB_ADDR3, 0x3000, p0, r0);
	WR_MMR(DCPLB_ADDR4, 0x4000, p0, r0);
	WR_MMR(DCPLB_ADDR5, 0x5000, p0, r0);
	WR_MMR(DCPLB_ADDR6, 0x6000, p0, r0);
	WR_MMR(DCPLB_ADDR7, 0x7000, p0, r0);

	// CHECKREG segment
	WR_MMR(DCPLB_ADDR14, 0xEFFFFC00, p0, r0);
	WR_MMR(DCPLB_DATA14, PAGE_SIZE_1K|CPLB_VALID|CPLB_DIRTY|CPLB_WT|CPLB_L1_CACHABLE|CPLB_SUPV_WR|CPLB_USER_RW, p0, r0);

	//  MMR space
	WR_MMR(DCPLB_ADDR15, 0xFFC00000, p0, r0);
	WR_MMR(DCPLB_DATA15, PAGE_SIZE_4M|CPLB_VALID|CPLB_DIRTY|CPLB_SUPV_WR, p0, r0);

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

	// enable CPLB
	WR_MMR(DMEM_CONTROL, ENDM | ENDCPLB | DMC_AB_CACHE, p0, r0);
	NOP;NOP;NOP;NOP;NOP;	// in lieu of CSYNC

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

	// But first raise interrupt 15 so we can do one test
	// in supervisor mode.
	RAISE 15;
	NOP;

	RTI;

	// Nops to work around ICache bug
	NOP;NOP;NOP;NOP;NOP;
	NOP;NOP;NOP;NOP;NOP;


int_15:
	// Interrupt 15 handler - needed to try supervisor access with exceptions enabled
	//-------------------------------------------------------
	// Protection violation - Illegal Supervisor Write Access
	R0 = 0;R1 = 0;R2 = 0;R3 = 0;R4 = 0;R5 = 0;R6 = 0;R7 = 0;

	LD32(p1, 0x800);
	LD32(r1, 0xDEADBEEF);

	LD32(p2, DCPLB_DATA0);
	LD32(r2, PAGE_SIZE_1K|CPLB_VALID|CPLB_DIRTY|CPLB_L1_CACHABLE|CPLB_SUPV_WR);

	LD32(p3, DCPLB_DATA1);
	LD32(r3, PAGE_SIZE_1K|CPLB_VALID|CPLB_DIRTY|CPLB_L1_CACHABLE|CPLB_SUPV_WR);


X0:	[ P1 ] = R1;		// Exception should occur here


	// Now check that handler read correct values
	CHECKREG(r4,0x23);			// supv and EXCPT_PROT
	CHECKREG(r5, 0x800);
	CHECKREG(r6, (FAULT_WRITE|FAULT_DAG0|FAULT_SUPV|FAULT_CPLB0));
	CHECKREG_SYM(r7, X0, r0);			// RETX should be value of X0	(HARDCODED ADDR!!)

	// go to user mode. and enable exceptions
	LD32_LABEL(r0, User);
	RTI;
	NOP;NOP;NOP;NOP;NOP;
	NOP;NOP;NOP;NOP;NOP;


User:
	NOP;NOP;NOP;NOP;NOP;

	//-------------------------------------------------------
	// Protection violation - Illegal User Write Access
	R0 = 0;R1 = 0;R2 = 0;R3 = 0;R4 = 0;R5 = 0;R6 = 0;R7 = 0;

	LD32(p1, 0x1000);
	LD32(r1, 0xDEADBEEF);


	// values to fix up current test
	LD32(p2, DCPLB_DATA1);
	LD32(r2, PAGE_SIZE_1K|CPLB_VALID|CPLB_DIRTY|CPLB_L1_CACHABLE|CPLB_USER_RW|CPLB_SUPV_WR);

	// values for next test
	LD32(p3, DCPLB_DATA2);
	LD32(r3, PAGE_SIZE_1K|CPLB_VALID|CPLB_DIRTY|CPLB_L1_CACHABLE);

X1:	[ P1 ] = R1;		// Exception should occur here

	// Now check that handler read correct values

	CHECKREG(r4,0x23);			// supv and EXCPT_PROT
	CHECKREG(r5, 0x1000);
	CHECKREG(r6, (FAULT_WRITE|FAULT_DAG0|FAULT_USER | FAULT_CPLB1));
	CHECKREG_SYM(r7, X1, r0);			// RETX should be value of X1	(HARDCODED ADDR!!)


	//-------------------------------------------------------
	// Protection violation - Illegal User Read Access
	R0 = 0;R1 = 0;R2 = 0;R3 = 0;R4 = 0;R5 = 0;R6 = 0;R7 = 0;

	LD32(p1, 0x2000);
	LD32(r1, 0xDEADBEEF);

	LD32(p2, DCPLB_DATA2);
	LD32(r2, PAGE_SIZE_1K|CPLB_VALID|CPLB_DIRTY|CPLB_L1_CACHABLE|CPLB_USER_RO|CPLB_SUPV_WR);

	LD32(p3, DCPLB_DATA3);
	LD32(r3, PAGE_SIZE_1K|CPLB_VALID|CPLB_L1_CACHABLE|CPLB_USER_RW|CPLB_SUPV_WR);

X2:	//[p1] = r1;		// Exception should occur here
	R0 = [ P1 ];


	// Now check that handler read correct values
	CHECKREG(r4,0x23);			// supv and EXCPT_PROT
	CHECKREG(r5, 0x2000);
	CHECKREG(r6, (FAULT_READ|FAULT_DAG0|FAULT_USER | FAULT_CPLB2));
	CHECKREG_SYM(r7, X2, r0);			// RETX should be value of X2	(HARDCODED ADDR!!)

	//-------------------------------------------------------
	// Protection violation - Illegal Dirty Page Access
	R0 = 0;R1 = 0;R2 = 0;R3 = 0;R4 = 0;R5 = 0;R6 = 0;R7 = 0;

	LD32(p1, 0x3000);
	LD32(r1, 0xDEADBEEF);

	LD32(p2, DCPLB_DATA3);
	LD32(r2, PAGE_SIZE_1K|CPLB_VALID|CPLB_DIRTY|CPLB_L1_CACHABLE|CPLB_USER_RW|CPLB_SUPV_WR);

	LD32(p3, DCPLB_DATA4);
	LD32(r3, PAGE_SIZE_1K|CPLB_VALID|CPLB_DA0ACC|CPLB_DIRTY|CPLB_L1_CACHABLE|CPLB_USER_RW|CPLB_SUPV_WR);


X3:	[ P1 ] = R1;		// Exception should occur here


	// Now check that handler read correct values
	CHECKREG(r4,0x23);			// supv and EXCPT_PROT
	CHECKREG(r5, 0x3000);
	CHECKREG(r6, (FAULT_WRITE|FAULT_DAG0|FAULT_USER | FAULT_CPLB3));
	CHECKREG_SYM(r7, X3, r0);			// RETX should be value of X3	(HARDCODED ADDR!!)

	//-------------------------------------------------------
	// Protection violation - Illegal DAG1 Access
	// Since this test uses DAG0, there shouldn't be any exception
	R0 = 0;R1 = 0;R2 = 0;R3 = 0;R4 = 0;R5 = 0;R6 = 0;R7 = 0;

	LD32(p1, 0x4000);
	LD32(r1, 0xDEADBEEF);

	LD32(p2, DCPLB_DATA4);
	LD32(r2, PAGE_SIZE_1K|CPLB_VALID|CPLB_DIRTY|CPLB_L1_CACHABLE|CPLB_USER_RW|CPLB_SUPV_WR);

	LD32(p3, DCPLB_DATA5);
	LD32(r3, PAGE_SIZE_1K|CPLB_VALID|CPLB_DIRTY|CPLB_L1_CACHABLE|CPLB_USER_RW|CPLB_SUPV_WR);


X4:	[ P1 ] = R1;		// Exception should NOT occur here


	// Now check that handler read correct values
	// Handler shouldn't have been invoked, so registers should
	// remain unchanged.
	CHECKREG(r4,0);			// supv and EXCPT_PROT
	CHECKREG(r5, 0);
	CHECKREG(r6, 0);
	CHECKREG(r7, 0);		// RETX should NOT be value of X4	(HARDCODED ADDR!!)

	//-------------------------------------------------------
	// L1Miss not implemented yet - skip for now....

//	//-------------------------------------------------------
//	// Protection violation - L1 Miss
//	r0=0;r1=0;r2=0;r3=0;r4=0;r5=0;r6=0;r7=0;
//
//	LD32(p1, 0x5000);
//	LD32(r1, 0xDEADBEEF);
//
//	LD32(p2, DCPLB_DATA5);
//	LD32(r2, PAGE_SIZE_1K|CPLB_VALID|CPLB_DIRTY|CPLB_L1_CACHABLE|CPLB_USER_RW|CPLB_SUPV_WR);
//
//	LD32(p3, DCPLB_DATA6);
//	LD32(r3, PAGE_SIZE_1K|CPLB_VALID|CPLB_DIRTY|CPLB_USER_RW|CPLB_SUPV_WR);
//
//
//X5:	//[p1] = r1;		// Exception should occur here
//	r0 = [p1];
//
//
//	// Now check that handler read correct values
//	CHECKREG(r4,0x23);			// supv and EXCPT_PROT
//	CHECKREG(r5, 0x5000);
//	// CHECKREG(r6, FAULT_DATA | FAULT_CPLB5);
//	CHECKREG_SYM(r7, X5, r0);			// RETX should be value of X5	(HARDCODED ADDR!!)


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


handler:
	// generic protection exception handler
	// Inputs:
	//	p2:	addr of CPLB entry to be modified	( current test)
	//	r2:	new data for CPLB entry
	//
	//	p3:	addr of CPLB entry to be modified	( next test)
	//	r3:	new data for CPLB entry
	//
	// Outputs:
	//	r4:	SEQSTAT
	//	r5:	DCPLB_FAULT_ADDR
	//	r6:	DCPLB_STATUS
	//	r7:	RETX	(instruction addr where exception occurred)


	R4 = SEQSTAT;	// Get exception cause

	// read data addr which caused exception
	RD_MMR(DCPLB_FAULT_ADDR, p0, r5);

	RD_MMR(DCPLB_STATUS, p0, r6);

	R7 = RETX;	// get address of excepting instruction


	// modify CPLB to allow access.  Main pgm passes in addr and data
	[ P2 ] = R2;

	// Set up for next test
	[ P3 ] = R3;

	NOP;NOP;NOP;NOP;NOP;NOP;NOP;	// in lieu of CSYNC;

	// return from exception and re-execute offending instruction
	RTX;

	// Nops to work around ICache bug
	NOP;NOP;NOP;NOP;NOP;
	NOP;NOP;NOP;NOP;NOP;


.section MEM_0x800,"aw"
	.dd 0x00000000
	.dd 0x00000000
	.dd 0x00000000
	.dd 0x00000000

.section MEM_0x1000,"aw"
	.dd 0x00000000
	.dd 0x00000000
	.dd 0x00000000
	.dd 0x00000000

.section MEM_0x2000,"aw"
	.dd 0x00000000
	.dd 0x00000000
	.dd 0x00000000
	.dd 0x00000000

.section MEM_0x3000,"aw"
	.dd 0x00000000
	.dd 0x00000000
	.dd 0x00000000
	.dd 0x00000000

.section MEM_0x4000,"aw"
	.dd 0x00000000
	.dd 0x00000000
	.dd 0x00000000
	.dd 0x00000000

.section MEM_0x5000,"aw"
	.dd 0x00000000
	.dd 0x00000000
	.dd 0x00000000
	.dd 0x00000000

// Need illegal SRAM addr to test CPLB_L1SRAM
//.data 0x6000
//	.dd 0x00000000
//	.dd 0x00000000
//	.dd 0x00000000
//	.dd 0x00000000

.section MEM_0x7000,"aw"
	.dd 0x00000000
	.dd 0x00000000
	.dd 0x00000000
	.dd 0x00000000