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