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
|
//Original:/proj/frio/dv/testcases/lmu/lmu_excpt_illaddr/lmu_excpt_illaddr.dsp
// Description: LMU illegal address exceptions
// Illegal core MMR: addr[19:16] != 0
// Illegal core MMR: Illegal peripheral
// Illegal core MMR: Illegal addr in peripheral
# mach: bfin
# sim: --environment operating
#include "test.h"
.include "testutils.inc"
start
include(selfcheck.inc)
include(std.inc)
include(mmrs.inc)
#ifndef SR_BASE
#define SR_BASE 0xFF800000 // must match value used for sram_baddr inputs
#endif
#ifndef A_SRAM_BASE
#define A_SRAM_BASE SR_BASE
#endif
#ifndef B_SRAM_BASE
#define B_SRAM_BASE SR_BASE + 0x100000
#endif
#ifndef I_SRAM_BASE
#define I_SRAM_BASE SR_BASE + 0x200000
#endif
#ifndef SCRATCH_SRAM_BASE
#define SCRATCH_SRAM_BASE SR_BASE + 0x300000
#endif
#ifndef A_SRAM_SIZE
#define A_SRAM_SIZE 0x4000
#endif
#ifndef B_SRAM_SIZE
#define B_SRAM_SIZE 0x4000
#endif
#ifndef I_SRAM_SIZE
#define I_SRAM_SIZE 0x4000
#endif
#ifndef SCRATCH_SRAM_SIZE
#define SCRATCH_SRAM_SIZE 0x1000
#endif
CHECK_INIT(p5, 0xE0000000);
// setup interrupt controller with exception handler address
WR_MMR_LABEL(EVT3, handler, p0, r1);
WR_MMR_LABEL(EVT15, int15, p0, r1);
WR_MMR(EVT_IMASK, 0xFFFFFFFF, p0, r0);
WR_MMR(EVT_OVERRIDE, 0x00000000, p0, r0);
// Set up CPLB
WR_MMR(DCPLB_ADDR1, SR_BASE, p0, r0); // SRAM segment: Non-cacheable
WR_MMR(DCPLB_DATA1, ( CPLB_VALID | CPLB_L1SRAM | CPLB_DIRTY | CPLB_SUPV_WR | PAGE_SIZE_4M), p0, r0);
WR_MMR(DCPLB_ADDR2, 0xE0000000, p0, r0); // CHECKREG segment: Non-cacheable
WR_MMR(DCPLB_DATA2, ( CPLB_VALID | CPLB_DIRTY | CPLB_SUPV_WR | PAGE_SIZE_4M), p0, r0);
WR_MMR(DCPLB_ADDR15, 0xFFC00000, p0, r0); // MMRs: Non-cacheable
WR_MMR(DCPLB_DATA15, ( CPLB_VALID | CPLB_DIRTY | CPLB_SUPV_WR | PAGE_SIZE_4M), p0, r0);
WR_MMR(DMEM_CONTROL, (DMC_AB_SRAM | ENDCPLB | ENDM), p0, r0);
CSYNC;
// Write fault addr MMR to known state
WR_MMR(DCPLB_FAULT_ADDR, 0, p0, r6);
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 will run in supervisor mode.
RAISE 15;
NOP;
RTI;
// Nops to work around ICache bug
NOP;NOP;NOP;NOP;NOP;
NOP;NOP;NOP;NOP;NOP;
int15:
NOP;NOP;NOP;NOP;NOP;
//-------------------------------------------------------
// First do stores
//-------------------------------------------------------
//
// illegal core MMR: addr[19] !=0
LD32(p1, 0xFFE80000);
LD32(p2, SRAM_BASE_ADDRESS); // Valid addr (handler will use move this to p1)
LD32(r1, 0xDEADBEEF);
R5 = 0;R6 = 0;R7 = 0; // Exception handler will set these, reset them first
X01: [ P1 ] = R1; // Exception should occur here
CHECKREG(r5,0x2e); // supv and EXCPT_PROT
CHECKREG(r6, 0xFFE80000); // FAULT_ADDR should contain test address
CHECKREG_SYM(r7, X01, r0); // RETX should be value of X01 (HARDCODED ADDR!!)
//-------------------------------------------------------
// illegal core MMR: addr[18] !=0
LD32(p1, 0xFFE40000);
LD32(p2, SRAM_BASE_ADDRESS); // Valid addr (handler will use move this to p1)
LD32(r1, 0xDEADBEEF);
R5 = 0;R6 = 0;R7 = 0; // Exception handler will set these, reset them first
X02: [ P1 ] = R1; // Exception should occur here
CHECKREG(r5,0x2e); // supv and EXCPT_PROT
CHECKREG(r6, 0xFFE40000); // FAULT_ADDR should contain test address
CHECKREG_SYM(r7, X02, r0); // RETX should be value of X02 (HARDCODED ADDR!!)
//-------------------------------------------------------
// illegal core MMR: addr[17] !=0
LD32(p1, 0xFFE20000);
LD32(p2, SRAM_BASE_ADDRESS); // Valid addr (handler will use move this to p1)
LD32(r1, 0xDEADBEEF);
R5 = 0;R6 = 0;R7 = 0; // Exception handler will set these, reset them first
X03: [ P1 ] = R1; // Exception should occur here
CHECKREG(r5,0x2e); // supv and EXCPT_PROT
CHECKREG(r6, 0xFFE20000); // FAULT_ADDR should contain test address
CHECKREG_SYM(r7, X03, r0); // RETX should be value of X03 (HARDCODED ADDR!!)
//-------------------------------------------------------
// illegal core MMR: addr[16] !=0
LD32(p1, 0xFFE10000);
LD32(p2, SRAM_BASE_ADDRESS); // Valid addr (handler will use move this to p1)
LD32(r1, 0xDEADBEEF);
R5 = 0;R6 = 0;R7 = 0; // Exception handler will set these, reset them first
X04: [ P1 ] = R1; // Exception should occur here
CHECKREG(r5,0x2e); // supv and EXCPT_PROT
CHECKREG(r6, 0xFFE10000); // FAULT_ADDR should contain test address
CHECKREG_SYM(r7, X04, r0); // RETX should be value of X04 (HARDCODED ADDR!!)
//-------------------------------------------------------
// illegal core MMR: illegal periperal (addr[15:12] > 8)
LD32(p1, 0xFFE09000);
LD32(p2, SRAM_BASE_ADDRESS); // Valid addr (handler will use move this to p1)
LD32(r1, 0xDEADBEEF);
R5 = 0;R6 = 0;R7 = 0; // Exception handler will set these, reset them first
X10: [ P1 ] = R1; // Exception should occur here
CHECKREG(r5,0x2e); // supv and EXCPT_PROT
CHECKREG(r6, 0xFFE09000); // FAULT_ADDR should contain test address
CHECKREG_SYM(r7, X10, r0); // RETX should be value of X10 (HARDCODED ADDR!!)
//-------------------------------------------------------
// illegal core MMR: illegal addr in peripheral 00
LD32(p1, 0xFFE00408);
LD32(p2, SRAM_BASE_ADDRESS); // Valid addr (handler will use move this to p1)
LD32(r1, 0xDEADBEEF);
R5 = 0;R6 = 0;R7 = 0; // Exception handler will set these, reset them first
X20: [ P1 ] = R1; // Exception should occur here
CHECKREG(r5,0x2e); // supv and EXCPT_PROT
CHECKREG(r6, 0xFFE00408); // FAULT_ADDR should contain test address
CHECKREG_SYM(r7, X20, r0); // RETX should be value of X20 (HARDCODED ADDR!!)
//-------------------------------------------------------
// illegal core MMR: illegal addr in peripheral 01
LD32(p1, 0xFFE01408);
LD32(p2, SRAM_BASE_ADDRESS); // Valid addr (handler will use move this to p1)
LD32(r1, 0xDEADBEEF);
R5 = 0;R6 = 0;R7 = 0; // Exception handler will set these, reset them first
X21: [ P1 ] = R1; // Exception should occur here
CHECKREG(r5,0x2e); // supv and EXCPT_PROT
CHECKREG(r6, 0xFFE01408); // FAULT_ADDR should contain test address
CHECKREG_SYM(r7, X21, r0); // RETX should be value of X21 (HARDCODED ADDR!!)
//-------------------------------------------------------
// illegal core MMR: illegal addr in peripheral 02
LD32(p1, 0xFFE02114);
LD32(p2, SRAM_BASE_ADDRESS); // Valid addr (handler will use move this to p1)
LD32(r1, 0xDEADBEEF);
R5 = 0;R6 = 0;R7 = 0; // Exception handler will set these, reset them first
X22: [ P1 ] = R1; // Exception should occur here
CHECKREG(r5,0x2e); // supv and EXCPT_PROT
CHECKREG(r6, 0xFFE02114); // FAULT_ADDR should contain test address
CHECKREG_SYM(r7, X22, r0); // RETX should be value of X22 (HARDCODED ADDR!!)
//-------------------------------------------------------
// illegal core MMR: illegal addr in peripheral 03
LD32(p1, 0xFFE03010);
LD32(p2, SRAM_BASE_ADDRESS); // Valid addr (handler will use move this to p1)
LD32(r1, 0xDEADBEEF);
R5 = 0;R6 = 0;R7 = 0; // Exception handler will set these, reset them first
X23: [ P1 ] = R1; // Exception should occur here
CHECKREG(r5,0x2e); // supv and EXCPT_PROT
CHECKREG(r6, 0xFFE03010); // FAULT_ADDR should contain test address
CHECKREG_SYM(r7, X23, r0); // RETX should be value of X23 (HARDCODED ADDR!!)
//-------------------------------------------------------
// illegal core MMR: illegal addr in peripheral 04
LD32(p1, 0xFFE04008);
LD32(p2, SRAM_BASE_ADDRESS); // Valid addr (handler will use move this to p1)
LD32(r1, 0xDEADBEEF);
R5 = 0;R6 = 0;R7 = 0; // Exception handler will set these, reset them first
X24: [ P1 ] = R1; // Exception should occur here
CHECKREG(r5,0x2e); // supv and EXCPT_PROT
CHECKREG(r6, 0xFFE04008); // FAULT_ADDR should contain test address
CHECKREG_SYM(r7, X24, r0); // RETX should be value of X24 (HARDCODED ADDR!!)
//-------------------------------------------------------
// illegal core MMR: illegal addr in peripheral 05
LD32(p1, 0xFFE05010);
LD32(p2, SRAM_BASE_ADDRESS); // Valid addr (handler will use move this to p1)
LD32(r1, 0xDEADBEEF);
R5 = 0;R6 = 0;R7 = 0; // Exception handler will set these, reset them first
X25: [ P1 ] = R1; // Exception should occur here
CHECKREG(r5,0x2e); // supv and EXCPT_PROT
CHECKREG(r6, 0xFFE05010); // FAULT_ADDR should contain test address
CHECKREG_SYM(r7, X25, r0); // RETX should be value of X25 (HARDCODED ADDR!!)
//-------------------------------------------------------
// illegal core MMR: illegal addr in peripheral 06
LD32(p1, 0xFFE06104);
LD32(p2, SRAM_BASE_ADDRESS); // Valid addr (handler will use move this to p1)
LD32(r1, 0xDEADBEEF);
R5 = 0;R6 = 0;R7 = 0; // Exception handler will set these, reset them first
X26: [ P1 ] = R1; // Exception should occur here
CHECKREG(r5,0x2e); // supv and EXCPT_PROT
CHECKREG(r6, 0xFFE06104); // FAULT_ADDR should contain test address
CHECKREG_SYM(r7, X26, r0); // RETX should be value of X26 (HARDCODED ADDR!!)
//-------------------------------------------------------
// illegal core MMR: illegal addr in peripheral 07
LD32(p1, 0xFFE07204);
LD32(p2, SRAM_BASE_ADDRESS); // Valid addr (handler will use move this to p1)
LD32(r1, 0xDEADBEEF);
R5 = 0;R6 = 0;R7 = 0; // Exception handler will set these, reset them first
X27: [ P1 ] = R1; // Exception should occur here
CHECKREG(r5,0x2e); // supv and EXCPT_PROT
CHECKREG(r6, 0xFFE07204); // FAULT_ADDR should contain test address
CHECKREG_SYM(r7, X27, r0); // RETX should be value of X27 (HARDCODED ADDR!!)
//-------------------------------------------------------
// illegal core MMR: illegal addr in peripheral 08
LD32(p1, 0xFFE08108);
LD32(p2, SRAM_BASE_ADDRESS); // Valid addr (handler will use move this to p1)
LD32(r1, 0xDEADBEEF);
R5 = 0;R6 = 0;R7 = 0; // Exception handler will set these, reset them first
X28: [ P1 ] = R1; // Exception should occur here
CHECKREG(r5,0x2e); // supv and EXCPT_PROT
CHECKREG(r6, 0xFFE08108); // FAULT_ADDR should contain test address
CHECKREG_SYM(r7, X28, r0); // RETX should be value of X28 (HARDCODED ADDR!!)
//-------------------------------------------------------
User:
dbg_pass;
//-------------------------------------------------------
handler:
R5 = 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, r6);
R7 = RETX; // get address of excepting instruction
// align the offending address
P1 = P2;
RTX;
// Nops to work around ICache bug
NOP;NOP;NOP;NOP;NOP;
NOP;NOP;NOP;NOP;NOP;
|