1//Original:/proj/frio/dv/testcases/core/c_progctrl_excpt/c_progctrl_excpt.dsp 2// Spec Reference: progctrl excpt uimm4 3# mach: bfin 4# sim: --environment operating 5 6#include "test.h" 7.include "testutils.inc" 8start 9 10include(std.inc) 11include(selfcheck.inc) 12include(gen_int.inc) 13INIT_R_REGS(0); 14INIT_P_REGS(0); 15INIT_I_REGS(0); // initialize the dsp address regs 16INIT_M_REGS(0); 17INIT_L_REGS(0); 18INIT_B_REGS(0); 19//CHECK_INIT(p5, 0xe0000000); 20include(symtable.inc) 21CHECK_INIT_DEF(p5); 22 23#ifndef STACKSIZE 24#define STACKSIZE 0x10 25#endif 26#ifndef EVT 27#define EVT 0xFFE02000 28#endif 29#ifndef EVT15 30#define EVT15 0xFFE0203C 31#endif 32#ifndef EVT_OVERRIDE 33#define EVT_OVERRIDE 0xFFE02100 34#endif 35#ifndef ITABLE 36#define ITABLE 0xF0000000 37#endif 38 39GEN_INT_INIT(ITABLE) // set location for interrupt table 40 41// 42// Reset/Bootstrap Code 43// (Here we should set the processor operating modes, initialize registers, 44// etc.) 45// 46 47BOOT: 48 49 50LD32_LABEL(sp, KSTACK); // setup the stack pointer 51FP = SP; // and frame pointer 52 53LD32(p0, EVT); // Setup Event Vectors and Handlers 54LD32_LABEL(r0, EHANDLE); // Emulation Handler (Int0) 55 [ P0 ++ ] = R0; 56 57LD32_LABEL(r0, RHANDLE); // Reset Handler (Int1) 58 [ P0 ++ ] = R0; 59 60LD32_LABEL(r0, NHANDLE); // NMI Handler (Int2) 61 [ P0 ++ ] = R0; 62 63LD32_LABEL(r0, XHANDLE); // Exception Handler (Int3) 64 [ P0 ++ ] = R0; 65 66 [ P0 ++ ] = R0; // IVT4 not used 67 68LD32_LABEL(r0, HWHANDLE); // HW Error Handler (Int5) 69 [ P0 ++ ] = R0; 70 71LD32_LABEL(r0, THANDLE); // Timer Handler (Int6) 72 [ P0 ++ ] = R0; 73 74LD32_LABEL(r0, I7HANDLE); // IVG7 Handler 75 [ P0 ++ ] = R0; 76 77LD32_LABEL(r0, I8HANDLE); // IVG8 Handler 78 [ P0 ++ ] = R0; 79 80LD32_LABEL(r0, I9HANDLE); // IVG9 Handler 81 [ P0 ++ ] = R0; 82 83LD32_LABEL(r0, I10HANDLE);// IVG10 Handler 84 [ P0 ++ ] = R0; 85 86LD32_LABEL(r0, I11HANDLE);// IVG11 Handler 87 [ P0 ++ ] = R0; 88 89LD32_LABEL(r0, I12HANDLE);// IVG12 Handler 90 [ P0 ++ ] = R0; 91 92LD32_LABEL(r0, I13HANDLE);// IVG13 Handler 93 [ P0 ++ ] = R0; 94 95LD32_LABEL(r0, I14HANDLE);// IVG14 Handler 96 [ P0 ++ ] = R0; 97 98LD32_LABEL(r0, I15HANDLE);// IVG15 Handler 99 [ P0 ++ ] = R0; 100 101LD32(p0, EVT_OVERRIDE); 102 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 137 138RAISE 15; // after we RTI, INT 15 should be taken 139 140NOP; // Workaround for Bug 217 141RTI; 142 143// 144// The Main Program 145// 146STARTUSER: 147LD32_LABEL(sp, USTACK); // setup the stack pointer 148FP = SP; // set frame pointer 149JUMP BEGIN; 150 151//********************************************************************* 152 153BEGIN: 154 155 // COMMENT the following line for USER MODE tests 156 [ -- SP ] = RETI; // enable interrupts in supervisor mode 157 158 // **** YOUR CODE GOES HERE **** 159 160 161 162 // PUT YOUR TEST HERE! 163EXCPT 2; // RETX RTX 164 165CHECKREG(r0, 0x0000000A); 166CHECKREG(r1, 0x0000000B); 167CHECKREG(r2, 0x0000000C); 168CHECKREG(r3, 0x0000000D); 169CHECKREG(r4, 0x00000000); 170CHECKREG(r5, 0x00000000); 171CHECKREG(r6, 0x00000000); 172CHECKREG(r7, 0x00000000); 173 174 175END: 176dbg_pass; // End the test 177 178//********************************************************************* 179 180// 181// Handlers for Events 182// 183 184EHANDLE: // Emulation Handler 0 185RTE; 186 187RHANDLE: // Reset Handler 1 188RTI; 189 190NHANDLE: // NMI Handler 2 191 R0 = 2; 192RTN; 193 194XHANDLE: // Exception Handler 3 195 R0 = 10; 196 R1 = 11; 197 R2 = 12; 198 R3 = 13; 199RTX; 200 201HWHANDLE: // HW Error Handler 5 202 R2 = 5; 203RTI; 204 205THANDLE: // Timer Handler 6 206 R3 = 6; 207RTI; 208 209I7HANDLE: // IVG 7 Handler 210 R4 = 7; 211RTI; 212 213I8HANDLE: // IVG 8 Handler 214 R5 = 8; 215RTI; 216 217I9HANDLE: // IVG 9 Handler 218 R6 = 9; 219RTI; 220 221I10HANDLE: // IVG 10 Handler 222 R7 = 10; 223RTI; 224 225I11HANDLE: // IVG 11 Handler 226 R0 = 11; 227RTI; 228 229I12HANDLE: // IVG 12 Handler 230 R1 = 12; 231RTI; 232 233I13HANDLE: // IVG 13 Handler 234 R2 = 13; 235RTI; 236 237I14HANDLE: // IVG 14 Handler 238 R3 = 14; 239RTI; 240 241I15HANDLE: // IVG 15 Handler 242 R4 = 15; 243RTI; 244 245NOP;NOP;NOP;NOP;NOP;NOP;NOP; // needed for icache bug 246 247// 248// Data Segment 249// 250 251.data 252DATA: 253 .space (0x10); 254 255// Stack Segments (Both Kernel and User) 256 257 .space (STACKSIZE); 258KSTACK: 259 260 .space (STACKSIZE); 261USTACK: 262