150476Speter//Original:/proj/frio/dv/testcases/core/c_interr_nested/c_interr_nested.dsp
223143Swosch// Spec Reference: interrupt nested using raises
323143Swosch# mach: bfin
423143Swosch# sim: --environment operating
523143Swosch
623143Swosch#include "test.h"
723143Swosch.include "testutils.inc"
823143Swoschstart
923143Swosch
1023143Swoschinclude(std.inc)
1123143Swoschinclude(selfcheck.inc)
1223143Swoschinclude(gen_int.inc)
1323143SwoschINIT_R_REGS(0);
1423143SwoschINIT_P_REGS(0);
1523143SwoschINIT_I_REGS(0);     // initialize the dsp address regs
1623143SwoschINIT_M_REGS(0);
1723143SwoschINIT_L_REGS(0);
1823143SwoschINIT_B_REGS(0);
1923143Swosch//CHECK_INIT(p5, 0xe0000000);
2023143Swoschinclude(symtable.inc)
2123143SwoschCHECK_INIT_DEF(p5);
2223143Swosch
2323143Swosch#ifndef STACKSIZE
2423143Swosch#define STACKSIZE 0x10
2523143Swosch#endif
2623143Swosch#ifndef EVT
2723143Swosch#define EVT  0xFFE02000
2823143Swosch#endif
2923143Swosch#ifndef EVT15
3023143Swosch#define EVT15  0xFFE0203C
3123143Swosch#endif
3223143Swosch#ifndef EVT_OVERRIDE
3323143Swosch#define EVT_OVERRIDE 0xFFE02100
3423143Swosch#endif
3523143Swosch#ifndef ITABLE
3623143Swosch#define ITABLE 0xF0000000
3723143Swosch#endif
3823143Swosch
3923143SwoschGEN_INT_INIT(ITABLE) // set location for interrupt table
4023143Swosch
4123143Swosch//
4223143Swosch// Reset/Bootstrap Code
4323143Swosch//   (Here we should set the processor operating modes, initialize registers,
4423143Swosch//    etc.)
4523143Swosch//
4623143Swosch
4723143SwoschBOOT:
4823143Swosch
4923143Swosch
5023143SwoschLD32_LABEL(sp, KSTACK);   // setup the stack pointer
5123143SwoschFP = SP;        // and frame pointer
5223143Swosch
5323143SwoschLD32(p0, EVT);      // Setup Event Vectors and Handlers
5423143SwoschLD32_LABEL(r0, EHANDLE);  // Emulation Handler (Int0)
5523143Swosch    [ P0 ++ ] = R0;
5623143Swosch
5723143SwoschLD32_LABEL(r0, RHANDLE);  // Reset Handler (Int1)
5823143Swosch    [ P0 ++ ] = R0;
5923143Swosch
6023143SwoschLD32_LABEL(r0, NHANDLE);  // NMI Handler (Int2)
6123143Swosch    [ P0 ++ ] = R0;
6223143Swosch
6323143SwoschLD32_LABEL(r0, XHANDLE);  // Exception Handler (Int3)
6423143Swosch    [ P0 ++ ] = R0;
6523143Swosch
6654090Sache    [ P0 ++ ] = R0;        // IVT4 not used
6723143Swosch
6823143SwoschLD32_LABEL(r0, HWHANDLE); // HW Error Handler (Int5)
6923143Swosch    [ P0 ++ ] = R0;
7023143Swosch
7123143SwoschLD32_LABEL(r0, THANDLE);  // Timer Handler (Int6)
7223143Swosch    [ P0 ++ ] = R0;
7323143Swosch
7423143SwoschLD32_LABEL(r0, I7HANDLE); // IVG7 Handler
7523143Swosch    [ P0 ++ ] = R0;
7623143Swosch
7723143SwoschLD32_LABEL(r0, I8HANDLE); // IVG8 Handler
7854090Sache    [ P0 ++ ] = R0;
7953943Sache
8053943SacheLD32_LABEL(r0, I9HANDLE); // IVG9 Handler
8153943Sache    [ P0 ++ ] = R0;
8253943Sache
8353943SacheLD32_LABEL(r0, I10HANDLE);// IVG10 Handler
8453943Sache    [ P0 ++ ] = R0;
8553943Sache
8653943SacheLD32_LABEL(r0, I11HANDLE);// IVG11 Handler
8753943Sache    [ P0 ++ ] = R0;
8853943Sache
8953943SacheLD32_LABEL(r0, I12HANDLE);// IVG12 Handler
9053943Sache    [ P0 ++ ] = R0;
9153943Sache
9253943SacheLD32_LABEL(r0, I13HANDLE);// IVG13 Handler
9353943Sache    [ P0 ++ ] = R0;
9453943Sache
9574413SacheLD32_LABEL(r0, I14HANDLE);// IVG14 Handler
9653943Sache    [ P0 ++ ] = R0;
9774413Sache
9853961SacheLD32_LABEL(r0, I15HANDLE);// IVG15 Handler
9974413Sache    [ P0 ++ ] = R0;
10053961Sache
10174413SacheLD32(p0, EVT_OVERRIDE);
10274413Sache    R0 = 0;
103    [ P0 ++ ] = R0;
104    R0 = -1;     // Change this to mask interrupts (*)
105    [ P0 ] = R0;   // IMASK
106
107DUMMY:
108
109    R0 = 0 (Z);
110
111LT0 = r0;       // set loop counters to something deterministic
112LB0 = r0;
113LC0 = r0;
114LT1 = r0;
115LB1 = r0;
116LC1 = r0;
117
118ASTAT = r0;     // reset other internal regs
119
120// The following code sets up the test for running in USER mode
121
122LD32_LABEL(r0, STARTUSER);// One gets to user mode by doing a
123                        // ReturnFromInterrupt (RTI)
124RETI = r0;      // We need to load the return address
125
126// Comment the following line for a USER Mode test
127
128JUMP    STARTSUP;   // jump to code start for SUPERVISOR mode
129
130RTI;
131
132STARTSUP:
133LD32_LABEL(p1, BEGIN);
134
135LD32(p0, EVT15);
136    [ P0 ] = P1;   // IVG15 (General) handler (Int 15) load with start
137CSYNC;
138RAISE 15;       // after we RTI, INT 15 should be taken
139
140RTI;
141
142//
143// The Main Program
144//
145STARTUSER:
146LD32_LABEL(sp, USTACK);   // setup the stack pointer
147FP = SP;            // set frame pointer
148JUMP BEGIN;
149
150//*********************************************************************
151
152BEGIN:
153
154                // COMMENT the following line for USER MODE tests
155    [ -- SP ] = RETI;  // enable interrupts in supervisor mode
156
157                // **** YOUR CODE GOES HERE ****
158
159
160
161    // PUT YOUR TEST HERE!
162                // Can't Raise 0, 3, or 4
163                // Raise 1 requires some intelligence so the test
164                //  doesn't loop forever - use SFTRESET bit in SEQSTAT (TBD)
165RAISE 2;    // RTN
166//  RAISE 5;    // RTI
167RAISE 6;    // RTI
168RAISE 7;    // RTI
169//  RAISE 8;    // RTI
170RAISE 9;    // RTI
171RAISE 10;   // RTI
172RAISE 11;   // RTI
173//  RAISE 12;   // RTI
174RAISE 13;   // RTI
175RAISE 14;   // RTI
176RAISE 15;   // RTI
177
178CHECKREG(r0, 0x0000000B);
179CHECKREG(r1, 0x0000000C);
180CHECKREG(r2, 0x0000000D);
181CHECKREG(r3, 0x0000000E);
182CHECKREG(r4, 0x00000007);
183CHECKREG(r5, 0x00000008);
184CHECKREG(r6, 0x00000009);
185CHECKREG(r7, 0x0000000A);
186R0 = I0;
187R1 = I1;
188R2 = I2;
189R3 = I3;
190R4 = M0;
191CHECKREG(r0, 0x00000002);
192CHECKREG(r1, 0x00000000);
193CHECKREG(r2, 0x00000005);
194CHECKREG(r3, 0x00000006);
195CHECKREG(r4, 0x00000007);
196
197
198END:
199dbg_pass;            // End the test
200
201//*********************************************************************
202
203//
204// Handlers for Events
205//
206
207EHANDLE:            // Emulation Handler 0
208RTE;
209
210RHANDLE:            // Reset Handler 1
211RTI;
212
213NHANDLE:            // NMI Handler 2
214    R0 = 2;
215RTN;
216
217XHANDLE:            // Exception Handler 3
218    R1 = 3;
219RTX;
220
221HWHANDLE:           // HW Error Handler 5
222    R2 = 5;
223RTI;
224
225THANDLE:            // Timer Handler 6
226    R3 = 6;
227RAISE 5;
228RTI;
229
230I7HANDLE:           // IVG 7 Handler
231    R4 = 7;
232RTI;
233
234I8HANDLE:           // IVG 8 Handler
235    R5 = 8;
236RTI;
237
238I9HANDLE:           // IVG 9 Handler
239    R6 = 9;
240RAISE 8;
241RTI;
242
243I10HANDLE:          // IVG 10 Handler
244    R7 = 10;
245RTI;
246
247I11HANDLE:          // IVG 11 Handler
248    I0 = R0;
249    I1 = R1;
250    I2 = R2;
251    I3 = R3;
252    M0 = R4;
253    R0 = 11;
254RTI;
255
256I12HANDLE:          // IVG 12 Handler
257    R1 = 12;
258RTI;
259
260I13HANDLE:          // IVG 13 Handler
261    R2 = 13;
262RTI;
263
264I14HANDLE:          // IVG 14 Handler
265    R3 = 14;
266RAISE 12;
267RTI;
268
269I15HANDLE:          // IVG 15 Handler
270    R4 = 15;
271RTI;
272
273NOP;NOP;NOP;NOP;NOP;NOP;NOP; // needed for icache bug
274
275//
276// Data Segment
277//
278
279.data
280DATA:
281    .space (0x10);
282
283// Stack Segments (Both Kernel and User)
284
285    .space (STACKSIZE);
286KSTACK:
287
288    .space (STACKSIZE);
289USTACK:
290