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

Subversion Repositories or1k

[/] [or1k/] [tags/] [nog_patch_42/] [or1ksim/] [testbench/] [support/] [int.c] - Blame information for rev 376

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 376 markom
/* This file is part of test microkernel for OpenRISC 1000. */
2
/* (C) 2001 Simon Srot, srot@opencores.org */
3
 
4
#include "support.h"
5
#include "spr_defs.h"
6
#include "int.h"
7
 
8
/* Interrupt handlers table */
9
struct ihnd int_handlers[MAX_INT_HANDLERS];
10
 
11
/* Initialize routine */
12
int int_init(void)
13
{
14
        int     i;
15
 
16
        for(i = 0; i < MAX_INT_HANDLERS; i++) {
17
                int_handlers[i].handler = 0;
18
                int_handlers[i].arg = 0;
19
        }
20
 
21
        return 0;
22
}
23
 
24
/* Add interrupt handler */
25
int int_add(unsigned long vect, void (* handler)(), void *arg/*, int hilo*/)
26
{
27
        if(vect >= MAX_INT_HANDLERS)
28
                return -1;
29
 
30
        int_handlers[vect].handler = handler;
31
        int_handlers[vect].arg = arg;
32
 
33
        mtspr(SPR_PICMR, mfspr(SPR_PICMR) | (0x00000001L << vect));
34
        /*if(hilo == INT_HIGH_PRI)*/
35
        if(1)
36
                mtspr(SPR_PICPR, mfspr(SPR_PICPR) | (0x00000001L << vect));
37
        else
38
                mtspr(SPR_PICPR, mfspr(SPR_PICPR) & ~(0x00000001L << vect));
39
 
40
        return 0;
41
}
42
 
43
/* Disable interrupt */
44
int int_disable(unsigned long vect)
45
{
46
        if(vect >= MAX_INT_HANDLERS)
47
                return -1;
48
 
49
        mtspr(SPR_PICMR, mfspr(SPR_PICMR) & ~(0x00000001L << vect));
50
 
51
        return 0;
52
}
53
 
54
/* Enable interrupt */
55
int int_enable(unsigned long vect)
56
{
57
        if(vect >= MAX_INT_HANDLERS)
58
                return -1;
59
 
60
        mtspr(SPR_PICMR, mfspr(SPR_PICMR) | (0x00000001L << vect));
61
 
62
        return 0;
63
}
64
 
65
/* Main interrupt handler */
66
void int_main(void)
67
{
68
        unsigned long   picsr = mfspr(SPR_PICSR);
69
        unsigned long   i = 0;
70
 
71
        mtspr(SPR_PICSR, 0);
72
 
73
        while(i < 32) {
74
                if((picsr & (0x01L << i)) && (int_handlers[i].handler != 0)) {
75
                        (*int_handlers[i].handler)(int_handlers[i].arg);
76
                        mtspr(SPR_PICSR, mfspr(SPR_PICSR) & ~(0x00000001L << i));
77
                }
78
                i++;
79
        }
80
}
81
 

powered by: WebSVN 2.1.0

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