1*48596154Schristos//Original:/proj/frio/dv/testcases/core/c_mode_user/c_mode_user.dsp
2*48596154Schristos// Spec Reference: mode_user
3*48596154Schristos# mach: bfin
4*48596154Schristos# sim: --environment operating
5*48596154Schristos
6*48596154Schristos#include "test.h"
7*48596154Schristos.include "testutils.inc"
8*48596154Schristosstart
9*48596154Schristos
10*48596154Schristosinclude(std.inc)
11*48596154Schristosinclude(selfcheck.inc)
12*48596154Schristosinclude(gen_int.inc)
13*48596154SchristosINIT_R_REGS(0);
14*48596154SchristosINIT_P_REGS(0);
15*48596154SchristosINIT_I_REGS(0);     // initialize the dsp address regs
16*48596154SchristosINIT_M_REGS(0);
17*48596154SchristosINIT_L_REGS(0);
18*48596154SchristosINIT_B_REGS(0);
19*48596154Schristos//CHECK_INIT(p5, 0xe0000000);
20*48596154Schristosinclude(symtable.inc)
21*48596154SchristosCHECK_INIT_DEF(p5);
22*48596154Schristos
23*48596154Schristos#ifndef STACKSIZE
24*48596154Schristos#define STACKSIZE 0x10
25*48596154Schristos#endif
26*48596154Schristos#ifndef EVT
27*48596154Schristos#define EVT  0xFFE02000
28*48596154Schristos#endif
29*48596154Schristos#ifndef EVT15
30*48596154Schristos#define EVT15  0xFFE0203C
31*48596154Schristos#endif
32*48596154Schristos#ifndef EVT_OVERRIDE
33*48596154Schristos#define EVT_OVERRIDE 0xFFE02100
34*48596154Schristos#endif
35*48596154Schristos//
36*48596154Schristos
37*48596154Schristos////MY_GEN_INT_INIT(0xF0000000) // set location for interrupt table
38*48596154Schristos
39*48596154Schristos//
40*48596154Schristos// Reset/Bootstrap Code
41*48596154Schristos//   (Here we should set the processor operating modes, initialize registers,
42*48596154Schristos//    etc.)
43*48596154Schristos//
44*48596154Schristos
45*48596154SchristosBOOT:
46*48596154Schristos
47*48596154Schristos                              // in reset mode now
48*48596154SchristosLD32_LABEL(sp, KSTACK);   // setup the stack pointer
49*48596154SchristosFP = SP;        // and frame pointer
50*48596154Schristos
51*48596154SchristosLD32(p0, EVT);      // Setup Event Vectors and Handlers
52*48596154SchristosLD32_LABEL(r0, EHANDLE);  // Emulation Handler (Int0)
53*48596154Schristos    [ P0 ++ ] = R0;
54*48596154Schristos
55*48596154SchristosLD32_LABEL(r0, RHANDLE);  // Reset Handler (Int1)
56*48596154Schristos    [ P0 ++ ] = R0;
57*48596154Schristos
58*48596154SchristosLD32_LABEL(r0, NHANDLE);  // NMI Handler (Int2)
59*48596154Schristos    [ P0 ++ ] = R0;
60*48596154Schristos
61*48596154SchristosLD32_LABEL(r0, XHANDLE);  // Exception Handler (Int3)
62*48596154Schristos    [ P0 ++ ] = R0;
63*48596154Schristos
64*48596154Schristos    [ P0 ++ ] = R0;        // IVT4 not used
65*48596154Schristos
66*48596154SchristosLD32_LABEL(r0, HWHANDLE); // HW Error Handler (Int5)
67*48596154Schristos    [ P0 ++ ] = R0;
68*48596154Schristos
69*48596154SchristosLD32_LABEL(r0, THANDLE);  // Timer Handler (Int6)
70*48596154Schristos    [ P0 ++ ] = R0;
71*48596154Schristos
72*48596154SchristosLD32_LABEL(r0, I7HANDLE); // IVG7 Handler
73*48596154Schristos    [ P0 ++ ] = R0;
74*48596154Schristos
75*48596154SchristosLD32_LABEL(r0, I8HANDLE); // IVG8 Handler
76*48596154Schristos    [ P0 ++ ] = R0;
77*48596154Schristos
78*48596154SchristosLD32_LABEL(r0, I9HANDLE); // IVG9 Handler
79*48596154Schristos    [ P0 ++ ] = R0;
80*48596154Schristos
81*48596154SchristosLD32_LABEL(r0, I10HANDLE);// IVG10 Handler
82*48596154Schristos    [ P0 ++ ] = R0;
83*48596154Schristos
84*48596154SchristosLD32_LABEL(r0, I11HANDLE);// IVG11 Handler
85*48596154Schristos    [ P0 ++ ] = R0;
86*48596154Schristos
87*48596154SchristosLD32_LABEL(r0, I12HANDLE);// IVG12 Handler
88*48596154Schristos    [ P0 ++ ] = R0;
89*48596154Schristos
90*48596154SchristosLD32_LABEL(r0, I13HANDLE);// IVG13 Handler
91*48596154Schristos    [ P0 ++ ] = R0;
92*48596154Schristos
93*48596154SchristosLD32_LABEL(r0, I14HANDLE);// IVG14 Handler
94*48596154Schristos    [ P0 ++ ] = R0;
95*48596154Schristos
96*48596154SchristosLD32_LABEL(r0, I15HANDLE);// IVG15 Handler
97*48596154Schristos    [ P0 ++ ] = R0;
98*48596154Schristos
99*48596154SchristosLD32(p0, EVT_OVERRIDE);
100*48596154Schristos    R0 = 0;
101*48596154Schristos    [ P0 ++ ] = R0;
102*48596154Schristos    R0 = -1;     // Change this to mask interrupts (*)
103*48596154Schristos    [ P0 ] = R0;   // IMASK
104*48596154Schristos
105*48596154SchristosDUMMY:
106*48596154Schristos
107*48596154Schristos    A0 = 0;         // reset accumulators
108*48596154Schristos    A1 = 0;
109*48596154Schristos
110*48596154Schristos    R0 = 0 (Z);
111*48596154Schristos
112*48596154SchristosLT0 = r0;       // set loop counters to something deterministic
113*48596154SchristosLB0 = r0;
114*48596154SchristosLC0 = r0;
115*48596154SchristosLT1 = r0;
116*48596154SchristosLB1 = r0;
117*48596154SchristosLC1 = r0;
118*48596154Schristos
119*48596154SchristosASTAT = r0;     // reset other internal regs
120*48596154Schristos
121*48596154Schristos// The following code sets up the test for running in USER mode
122*48596154Schristos
123*48596154SchristosLD32_LABEL(r0, STARTUSER);// One gets to user mode by doing a
124*48596154Schristos                        // ReturnFromInterrupt (RTI)
125*48596154SchristosRETI = r0;      // We need to load the return address
126*48596154Schristos
127*48596154Schristos// Comment the following line for a USER Mode test
128*48596154Schristos
129*48596154Schristos//  JUMP    STARTSUP;   // jump to code start for SUPERVISOR mode
130*48596154Schristos
131*48596154SchristosRTI;            // execute this instr put us in USER mode
132*48596154Schristos
133*48596154SchristosSTARTSUP:
134*48596154SchristosLD32_LABEL(p1, BEGIN);
135*48596154Schristos
136*48596154SchristosLD32(p0, EVT15);
137*48596154Schristos    [ P0 ] = P1;   // IVG15 (General) handler (Int 15) load with start
138*48596154Schristos
139*48596154SchristosRAISE 15;   // after we RTI, INT 15 should be taken,& return to BEGIN in
140*48596154Schristos                // USER MODE & go to different RAISE in USER mode
141*48596154Schristos                // until the end of the test.
142*48596154Schristos
143*48596154SchristosNOP;    // Workaround for Bug 217
144*48596154SchristosRTI;
145*48596154Schristos
146*48596154Schristos//
147*48596154Schristos// The Main Program
148*48596154Schristos//
149*48596154SchristosSTARTUSER:
150*48596154SchristosLD32_LABEL(sp, USTACK);   // setup the stack pointer
151*48596154SchristosFP = SP;            // set frame pointer
152*48596154SchristosJUMP BEGIN;
153*48596154Schristos
154*48596154Schristos//*********************************************************************
155*48596154Schristos
156*48596154SchristosBEGIN:
157*48596154Schristos
158*48596154Schristos                // COMMENT the following line for USER MODE tests
159*48596154Schristos    [ -- SP ] = RETI;  // enable interrupts in supervisor mode
160*48596154Schristos
161*48596154Schristos                // **** YOUR CODE GOES HERE ****
162*48596154Schristos
163*48596154Schristos
164*48596154Schristos
165*48596154Schristos    // PUT YOUR TEST HERE!
166*48596154SchristosA1 = A0 = 0;
167*48596154SchristosASTAT = R0;
168*48596154Schristos
169*48596154Schristos
170*48596154Schristos// R-reg to P-reg to R reg: stall
171*48596154SchristosLD32(r0, 0x1357bdad);
172*48596154SchristosLD32(r1, 0x02dfe804);
173*48596154SchristosLD32(r2, 0x12345679);
174*48596154SchristosLD32(r3, 0x34751975);
175*48596154SchristosLD32(r4, 0x08810990);
176*48596154SchristosLD32(r5, 0x01a1b0b0);
177*48596154SchristosLD32(r6, 0x01c1dd00);
178*48596154SchristosLD32(r7, 0x01e1fff0);
179*48596154SchristosR5 = R3.L * R1.L, R4 = R3.L * R1.L;            // dsp32mult_pair
180*48596154SchristosP4 = R5;
181*48596154SchristosR6 = P4;
182*48596154SchristosR1 = ( A1 += R5.L * R6.H ), A0 = R5.H * R6.L;   // dsp32mac_pair
183*48596154SchristosP3 = A0.w;
184*48596154SchristosP4 = A1.w;
185*48596154SchristosA1 = A1 (S), A0 = A0 (S);                               // dsp32alu_sat_aa
186*48596154SchristosR6 = A0.w;
187*48596154SchristosR7 = A1.w;
188*48596154SchristosR0 = R7;
189*48596154SchristosR2 = R0;                          // regmv
190*48596154SchristosR2 >>>= R3;                         // c_alu2op_arith_r_sft.dsp
191*48596154SchristosR4 = R2 - R1;
192*48596154SchristosR5.L = ASHIFT R4.L BY R3.L;
193*48596154SchristosR6 += -3;                                  //c_compi2opd_dr_add_i7_n.dsp
194*48596154SchristosI2 = R6;
195*48596154SchristosI2 += 2;
196*48596154SchristosI2 += M1;
197*48596154SchristosR7 = I2;
198*48596154Schristos
199*48596154Schristos
200*48596154SchristosCHECKREG(r0, 0x015AF820);
201*48596154SchristosCHECKREG(r2, 0x00000000);
202*48596154SchristosCHECKREG(r3, 0x34751975);
203*48596154SchristosCHECKREG(r4, 0xFEA507E0);
204*48596154SchristosCHECKREG(r5, 0xFB3A0000);
205*48596154SchristosCHECKREG(r6, 0x015AF81D);
206*48596154SchristosCHECKREG(r7, 0x015AF81F);
207*48596154SchristosR0 = I0;
208*48596154SchristosR1 = I1;
209*48596154SchristosR2 = I2;
210*48596154SchristosR3 = I3;
211*48596154SchristosCHECKREG(r0, 0x00000000);
212*48596154SchristosCHECKREG(r1, 0x00000000);
213*48596154SchristosCHECKREG(r2, 0x015AF81F);
214*48596154SchristosCHECKREG(r3, 0x00000000);
215*48596154SchristosCHECKREG(r4, 0xFEA507E0);
216*48596154Schristos
217*48596154Schristos
218*48596154SchristosEND:
219*48596154Schristosdbg_pass;            // End the test
220*48596154Schristos
221*48596154Schristos//*********************************************************************
222*48596154Schristos
223*48596154Schristos//
224*48596154Schristos// Handlers for Events
225*48596154Schristos//
226*48596154Schristos
227*48596154SchristosEHANDLE:            // Emulation Handler 0
228*48596154SchristosRTE;
229*48596154Schristos
230*48596154SchristosRHANDLE:            // Reset Handler 1
231*48596154SchristosRTI;
232*48596154Schristos
233*48596154SchristosNHANDLE:            // NMI Handler 2
234*48596154Schristos    R0 = RETN;
235*48596154Schristos    R0 += 2;
236*48596154SchristosRETN = r0;
237*48596154SchristosRTN;
238*48596154Schristos
239*48596154SchristosXHANDLE:            // Exception Handler 3
240*48596154Schristos    R1 = RETX;
241*48596154Schristos    R0 += 1;
242*48596154Schristos    R1 += 2;
243*48596154Schristos    R2 += 1;
244*48596154Schristos    R3 += 1;
245*48596154Schristos    R4 += 1;
246*48596154Schristos    R5 += 1;
247*48596154Schristos    R6 += 1;
248*48596154Schristos    R7 += 1;
249*48596154SchristosRETX = r1;
250*48596154SchristosRTX;
251*48596154Schristos
252*48596154SchristosHWHANDLE:           // HW Error Handler 5
253*48596154Schristos    R2 = RETI;
254*48596154Schristos    R2 += 2;
255*48596154SchristosRETI = r2;
256*48596154SchristosRTI;
257*48596154Schristos
258*48596154SchristosTHANDLE:            // Timer Handler 6
259*48596154Schristos    R3 = RETI;
260*48596154Schristos    R3 += 2;
261*48596154SchristosRETI = r3;
262*48596154SchristosRTI;
263*48596154Schristos
264*48596154SchristosI7HANDLE:           // IVG 7 Handler
265*48596154Schristos    R4 = RETI;
266*48596154Schristos    R4 += 2;
267*48596154SchristosRETI = r4;
268*48596154SchristosRTI;
269*48596154Schristos
270*48596154SchristosI8HANDLE:           // IVG 8 Handler
271*48596154Schristos    R5 = RETI;
272*48596154Schristos    R5 += 2;
273*48596154SchristosRETI = r5;
274*48596154SchristosRTI;
275*48596154Schristos
276*48596154SchristosI9HANDLE:           // IVG 9 Handler
277*48596154Schristos    R6 = RETI;
278*48596154Schristos    R6 += 2;
279*48596154SchristosRETI = r6;
280*48596154SchristosRTI;
281*48596154Schristos
282*48596154SchristosI10HANDLE:          // IVG 10 Handler
283*48596154Schristos    R7 = RETI;
284*48596154Schristos    R7 += 2;
285*48596154SchristosRETI = r7;
286*48596154SchristosRTI;
287*48596154Schristos
288*48596154SchristosI11HANDLE:          // IVG 11 Handler
289*48596154Schristos    I0 = R0;
290*48596154Schristos    I1 = R1;
291*48596154Schristos    I2 = R2;
292*48596154Schristos    I3 = R3;
293*48596154Schristos    M0 = R4;
294*48596154Schristos    R0 = RETI;
295*48596154Schristos    R0 += 2;
296*48596154SchristosRETI = r0;
297*48596154SchristosRTI;
298*48596154Schristos
299*48596154SchristosI12HANDLE:          // IVG 12 Handler
300*48596154Schristos    R1 = RETI;
301*48596154Schristos    R1 += 2;
302*48596154SchristosRETI = r1;
303*48596154SchristosRTI;
304*48596154Schristos
305*48596154SchristosI13HANDLE:          // IVG 13 Handler
306*48596154Schristos    R2 = RETI;
307*48596154Schristos    R2 += 2;
308*48596154SchristosRETI = r2;
309*48596154SchristosRTI;
310*48596154Schristos
311*48596154SchristosI14HANDLE:          // IVG 14 Handler
312*48596154Schristos    R3 = RETI;
313*48596154Schristos    R3 += 2;
314*48596154SchristosRETI = r3;
315*48596154SchristosRTI;
316*48596154Schristos
317*48596154SchristosI15HANDLE:          // IVG 15 Handler
318*48596154Schristos    R4 = 15;
319*48596154SchristosRTI;
320*48596154Schristos
321*48596154SchristosNOP;NOP;NOP;NOP;NOP;NOP;NOP; // needed for icache bug
322*48596154Schristos
323*48596154Schristos//
324*48596154Schristos// Data Segment
325*48596154Schristos//
326*48596154Schristos
327*48596154Schristos.data
328*48596154SchristosDATA:
329*48596154Schristos    .space (0x10);
330*48596154Schristos
331*48596154Schristos// Stack Segments (Both Kernel and User)
332*48596154Schristos
333*48596154Schristos    .space (STACKSIZE);
334*48596154SchristosKSTACK:
335*48596154Schristos
336*48596154Schristos    .space (STACKSIZE);
337*48596154SchristosUSTACK:
338*48596154Schristos//  .space (STACKSIZE);  // adding this may solve the problem
339