OpenCores
URL https://opencores.org/ocsvn/mips_enhanced/mips_enhanced/trunk

Subversion Repositories mips_enhanced

[/] [mips_enhanced/] [trunk/] [grlib-gpl-1.0.19-b3188/] [software/] [leon3/] [irqmp.c] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 dimamali
#include "testmod.h"
2
#include "irqmp.h"
3
 
4
struct irqmp *irqmp_base;
5
static volatile int irqtbl[18];
6
 
7
irqhandler(int irq)
8
{
9
        irqtbl[irqtbl[0]] = irq + 0x10;
10
        irqtbl[0]++;
11
}
12
 
13
init_irqmp(struct irqmp *lr)
14
{
15
        lr->irqlevel = 0;        /* clear level reg */
16
        lr->irqmask = 0x0;      /* mask all interrupts */
17
        lr->irqclear = -1;      /* clear all pending interrupts */
18
        irqtbl[0] = 1;           /* init irqtable */
19
}
20
 
21
irqtest(int addr)
22
{
23
        int i, a, psr;
24
        volatile int marr[4];
25
        volatile int larr[4];
26
        struct irqmp *lr = (struct irqmp *) addr;
27
        irqmp_base = lr;
28
 
29
        report_device(0x0100d000);
30
        init_irqmp(lr);
31
 
32
        for (i=1; i<16; i++) catch_interrupt(irqhandler, i);
33
 
34
/* test that interrupts are properly prioritised */
35
 
36
        lr->irqforce = 0x0fffe; /* force all interrupts */
37
        if (lr->irqforce != 0x0fffe) fail(1); /* check force reg */
38
 
39
        lr->irqmask = 0x0fffe;    /* unmask all interrupts */
40
        if (lr->irqmask != 0x0fffe) fail(2); /* check mask reg */
41
        while (lr->irqforce) {};  /* wait until all iterrupts are taken */
42
 
43
        /* check that all interrupts were take in right order */
44
        if (irqtbl[0] != 16) fail(3);
45
        for (i=1;i<16;i++) { if (irqtbl[i] != (0x20 - i))  fail(4);}
46
 
47
/* test priority of the two interrupt levels */
48
 
49
        irqtbl[0] = 1;                   /* init irqtable */
50
        lr->irqlevel = 0xaaaa;  /* set level reg to  odd irq -> level 1 */
51
        lr->irqmask = 0xfffe;
52
        if (lr->irqlevel != 0xaaaa) fail(5); /* check level reg */
53
        if (lr->irqmask != 0xfffe) fail(5); /* check mask reg */
54
        lr->irqforce = 0x0fffe; /* force all interrupts */
55
        while (lr->irqforce) {};  /* wait until all iterrupts are taken */
56
 
57
        /* check that all interrupts were take in right order */
58
        if (irqtbl[0] != 16) fail(6);
59
        for (i=1;i<8;i++) { if (irqtbl[i] != (0x20 - (i*2-1)))
60
                fail(7);}
61
        for (i=2;i<8;i++) { if (irqtbl[i+8] != (0x20 - (i*2)))
62
                fail(8);}
63
 
64
/* check interrupts of multi-cycle instructions */
65
 
66
        marr[0] = 1; marr[1] = marr[0]+1; marr[2] = marr[1]+1;
67
        a = marr[2]+1; marr[3] = a; larr[0] = 6;
68
 
69
        lr->irqlevel = 0;        /* clear level reg */
70
        lr->irqmask = 0x0;      /* mask all interrupts */
71
        irqtbl[0] = 1;           /* init irqtable */
72
        lr->irqmask = 0x00002;    /* unmask interrupt */
73
        lr->irqforce = 0x00002; /* force interrupt */
74
 
75
        asm(
76
        "       mov  %asr17, %g1\n\t"
77
        "       andcc %g1, 0x100, %g0\n\t"
78
        "       be 1f\n\t"
79
        "       nop \n\t"
80
        "       umul %g0, %g1, %g0\n\t"
81
        "       umul %g0, %g1, %g0\n\t"
82
        "       umul %g0, %g1, %g0\n\t"
83
        "       1:\n\t"
84
        "       ");
85
 
86
        lr->irqforce = 0x00002; /* force interrupt */
87
        asm("nop;");
88
        larr[1] = larr[0];
89
        if (larr[0] != 6) fail(10);
90
        lr->irqforce = 0x00002; /* force interrupt */
91
        asm("nop;");
92
        larr[1] = 0;
93
        if (larr[1] != 0) fail(11);
94
 
95
        while (lr->irqforce) {};  /* wait until all iterrupts are taken */
96
 
97
        /* check number of interrupts */
98
        if (irqtbl[0] != 4) fail(13);
99
 
100
        lr->irqmask = 0x0;      /* mask all interrupts */
101
 
102
/* check that PSR.PIL work properly */
103
 
104
        lr->irqforce = 0x0fffe; /* force all interrupts */
105
        irqtbl[0] = 1;           /* init irqtable */
106
        psr = xgetpsr() | (15 << 8);
107
        setpsr(psr); /* PIL = 15 */
108
        lr->irqmask = -1;       /* enable all interrupts */
109
        while (!lr->irqmask);   /* avoid compiler optimisation */
110
        if (irqtbl[0] != 2) fail(14);
111
        if (irqtbl[1] != 0x1f) fail(15);
112
        setpsr(xgetpsr() - (1 << 8));
113
        for (i=2;i<16;i++) {
114
                setpsr(xgetpsr() - (1 << 8));
115
                if (irqtbl[0] != i+1) fail(16);
116
                if (irqtbl[i] != (0x20 - i))  fail(17);
117
        }
118
 
119
/* test optional secondary interrupt controller */
120
/*
121
        lr->irqmask = 0x0;
122
        lr->imask2 = 0x0;
123
        lr->ipend2 = 0x0;
124
        lr->ipend2 = 0x1;
125
        if (!lr->ipend2) return(0);
126
        lr->ipend2 = -1;
127
        lr->imask2 = -1;
128
        for (i=lr->istat2 & 0x1f; i >=0; i--) {
129
                if ((lr->istat2 & 0x1f) != i) fail (17+i);
130
                lr->istat2 = (1 << i);
131
                lr->irqclear = -1;
132
        }
133
        if (lr->istat2 & 0x20) fail (33);
134
        if (lr->irqpend) fail (34);
135
*/
136
        lr->irqmask = 0x0;      /* mask all interrupts */
137
        lr->irqclear = -1;      /* clear all pending interrupts */
138
        return(0);
139
 
140
}
141
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.