Home | History | Annotate | Line # | Download | only in bfin
      1 //Original:/proj/frio/dv/testcases/seq/se_excpt_ifprotviol/se_excpt_ifprotviol.dsp
      2 // Description: EXCPT instruction and IF Prot Viol priority
      3 # mach: bfin
      4 # sim: --environment operating
      5 
      6 #include "test.h"
      7 .include "testutils.inc"
      8 start
      9 
     10 include(gen_int.inc)
     11 include(selfcheck.inc)
     12 include(std.inc)
     13 include(mmrs.inc)
     14 include(symtable.inc)
     15 
     16 #ifndef STACKSIZE
     17 #define STACKSIZE 0x100   // change for how much stack you need
     18 #endif
     19 #ifndef ITABLE
     20 #define ITABLE 0xF0000000
     21 #endif
     22 
     23 GEN_INT_INIT(ITABLE) // set location for interrupt table
     24 
     25 //
     26 // Reset/Bootstrap Code
     27 //   (Here we should set the processor operating modes, initialize registers,
     28 //    etc.)
     29 //
     30 
     31 BOOT:
     32 INIT_R_REGS(0);     // initialize general purpose regs
     33 
     34 INIT_P_REGS(0);     // initialize the pointers
     35 
     36 INIT_I_REGS(0);     // initialize the dsp address regs
     37 INIT_M_REGS(0);
     38 INIT_L_REGS(0);
     39 INIT_B_REGS(0);
     40 
     41 CLI R1;           // inhibit events during MMR writes
     42 
     43 LD32_LABEL(sp, USTACK);   // setup the user stack pointer
     44 USP = SP;
     45 
     46 LD32_LABEL(sp, KSTACK);   // setup the kernel stack pointer
     47 FP = SP;        // and frame pointer
     48 
     49 LD32(p0, EVT0);      // Setup Event Vectors and Handlers
     50 
     51     P0 += 4;            // EVT0 not used (Emulation)
     52 
     53     P0 += 4;            // EVT1 not used (Reset)
     54 
     55 LD32_LABEL(r0, NHANDLE);  // NMI Handler (Int2)
     56     [ P0 ++ ] = R0;
     57 
     58 LD32_LABEL(r0, XHANDLE);  // Exception Handler (Int3)
     59     [ P0 ++ ] = R0;
     60 
     61     P0 += 4;            // EVT4 not used (Global Interrupt Enable)
     62 
     63 LD32_LABEL(r0, HWHANDLE); // HW Error Handler (Int5)
     64     [ P0 ++ ] = R0;
     65 
     66 LD32_LABEL(r0, THANDLE);  // Timer Handler (Int6)
     67     [ P0 ++ ] = R0;
     68 
     69 LD32_LABEL(r0, I7HANDLE); // IVG7 Handler
     70     [ P0 ++ ] = R0;
     71 
     72 LD32_LABEL(r0, I8HANDLE); // IVG8 Handler
     73     [ P0 ++ ] = R0;
     74 
     75 LD32_LABEL(r0, I9HANDLE); // IVG9 Handler
     76     [ P0 ++ ] = R0;
     77 
     78 LD32_LABEL(r0, I10HANDLE);// IVG10 Handler
     79     [ P0 ++ ] = R0;
     80 
     81 LD32_LABEL(r0, I11HANDLE);// IVG11 Handler
     82     [ P0 ++ ] = R0;
     83 
     84 LD32_LABEL(r0, I12HANDLE);// IVG12 Handler
     85     [ P0 ++ ] = R0;
     86 
     87 LD32_LABEL(r0, I13HANDLE);// IVG13 Handler
     88     [ P0 ++ ] = R0;
     89 
     90 LD32_LABEL(r0, I14HANDLE);// IVG14 Handler
     91     [ P0 ++ ] = R0;
     92 
     93 LD32_LABEL(r0, I15HANDLE);// IVG15 Handler
     94     [ P0 ++ ] = R0;
     95 
     96 LD32(p0, EVT_OVERRIDE);
     97     R0 = 0;
     98     [ P0 ++ ] = R0;
     99 
    100     R1 = -1;     // Change this to mask interrupts (*)
    101 CSYNC;       // wait for MMR writes to finish
    102 STI R1;      // sync and reenable events (implicit write to IMASK)
    103 
    104 DUMMY:
    105 
    106     R0 = 0 (Z);
    107 
    108 LT0 = r0;       // set loop counters to something deterministic
    109 LB0 = r0;
    110 LC0 = r0;
    111 LT1 = r0;
    112 LB1 = r0;
    113 LC1 = r0;
    114 
    115 ASTAT = r0;     // reset other internal regs
    116 SYSCFG = r0;
    117 RETS = r0;      // prevent X's breaking LINK instruction
    118 
    119 RETI = r0;      // prevent Xs later on
    120 RETX = r0;
    121 RETN = r0;
    122 RETE = r0;
    123 
    124 
    125 // The following code sets up the test for running in USER mode
    126 
    127 LD32_LABEL(r0, STARTUSER);// One gets to user mode by doing a
    128                         // ReturnFromInterrupt (RTI)
    129 RETI = r0;      // We need to load the return address
    130 
    131 // Comment the following line for a USER Mode test
    132 
    133 //    JUMP    STARTSUP;   // jump to code start for SUPERVISOR mode
    134 
    135 RTI;
    136 
    137 STARTSUP:
    138 LD32_LABEL(p1, BEGIN);
    139 
    140 LD32(p0, EVT15);
    141 
    142 CLI R1;   // inhibit events during write to MMR
    143     [ P0 ] = P1;  // IVG15 (General) handler (Int 15) load with start
    144 CSYNC;      // wait for it
    145 STI R1;     // reenable events with proper imask
    146 
    147 RAISE 15;       // after we RTI, INT 15 should be taken
    148 
    149 RTI;
    150 
    151 //
    152 // The Main Program
    153 //
    154 
    155 STARTUSER:
    156 
    157 LD32_LABEL(sp, USTACK);   // setup the user stack pointer
    158 FP = SP;
    159 LINK 0;     // change for how much stack frame space you need.
    160 
    161 JUMP BEGIN;
    162 
    163 //*********************************************************************
    164 
    165 BEGIN:
    166 
    167                 // COMMENT the following line for USER MODE tests
    168 //    [--sp] = RETI;  // enable interrupts in supervisor mode
    169 
    170     R0 = 0;
    171     R1 = -1;
    172 
    173 
    174 EXCPT 2;    // the RAISE should not prevent the EXCPT from being taken
    175 RAISE 15;
    176 
    177 CHECK_INIT_DEF(p0); //CHECK_INIT(p0, 0xFF7FFFFC);
    178 
    179 CHECKREG(r5, 2); // check the flag
    180 
    181 END:
    182 dbg_pass;            // End the test
    183 
    184 //*********************************************************************
    185 
    186 //
    187 // Handlers for Events
    188 //
    189 
    190 NHANDLE:            // NMI Handler 2
    191 RTN;
    192 
    193 XHANDLE:            // Exception Handler 3
    194 
    195     [ -- SP ] = ASTAT; // save what we damage
    196     [ -- SP ] = ( R7:6 );
    197     R7 = SEQSTAT;
    198     R7 <<= 26;
    199     R7 >>= 26;      // only want EXCAUSE
    200     R6 = 0x02;      // EXCAUSE 0x02 means EXCPT 2 instruction
    201 CC = r7 == r6;
    202 IF CC JUMP EXCPT2;
    203 
    204     R6 = 0x2E;      // EXCAUSE 0x2E means Illegal Use Supervisor Resource
    205 CC = r7 == r6;
    206 IF CC JUMP IFPROTVIOL;
    207 
    208 JUMP.S OUT;       // if the EXCAUSE is wrong the test will infinite loop
    209 
    210 EXCPT2:
    211     R5 = 1;         // Set a Flag
    212 JUMP.S OUT;
    213 
    214 IFPROTVIOL:
    215     R7 = RETX;      // Fix up return address
    216 
    217     R7 += 2;        // skip offending 16 bit instruction
    218 
    219 RETX = r7;      // and put back in RETX
    220 
    221     R5 <<= 1;        // Alter Global Flag
    222 
    223 OUT:
    224     ( R7:6 ) = [ SP ++ ];
    225 ASTAT = [sp++];
    226 RTX;
    227 
    228 HWHANDLE:           // HW Error Handler 5
    229 RTI;
    230 
    231 THANDLE:            // Timer Handler 6
    232 RTI;
    233 
    234 I7HANDLE:           // IVG 7 Handler
    235 RTI;
    236 
    237 I8HANDLE:           // IVG 8 Handler
    238 RTI;
    239 
    240 I9HANDLE:           // IVG 9 Handler
    241 RTI;
    242 
    243 I10HANDLE:          // IVG 10 Handler
    244 RTI;
    245 
    246 I11HANDLE:          // IVG 11 Handler
    247 RTI;
    248 
    249 I12HANDLE:          // IVG 12 Handler
    250 RTI;
    251 
    252 I13HANDLE:          // IVG 13 Handler
    253 RTI;
    254 
    255 I14HANDLE:          // IVG 14 Handler
    256 RTI;
    257 
    258 I15HANDLE:          // IVG 15 Handler
    259 RTI;
    260 
    261 
    262     // padding for the icache
    263 
    264 EXCPT 0; EXCPT 0; EXCPT 0; EXCPT 0; EXCPT 0; EXCPT 0; EXCPT 0;
    265 
    266 //
    267 // Data Segment
    268 //
    269 
    270 .data
    271 DATA:
    272     .space (0x10);
    273 
    274 // Stack Segments (Both Kernel and User)
    275 
    276     .space (STACKSIZE);
    277 KSTACK:
    278 
    279     .space (STACKSIZE);
    280 USTACK:
    281