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

Subversion Repositories or1k

[/] [or1k/] [branches/] [oc/] [orpmon/] [common/] [int.c] - Blame information for rev 1771

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

Line No. Rev Author Line
1 809 simons
/* 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
#ifdef OR1K
9
 
10
/* Interrupt handlers table */
11
struct ihnd int_handlers[MAX_INT_HANDLERS];
12
 
13
/* Initialize routine */
14
int int_init()
15
{
16
  int i;
17
 
18
  for(i = 0; i < MAX_INT_HANDLERS; i++) {
19
    int_handlers[i].handler = 0;
20
    int_handlers[i].arg = 0;
21
  }
22
 
23
  return 0;
24
}
25
 
26
/* Add interrupt handler */
27
int int_add(unsigned long vect, void (* handler)(void *), void *arg)
28
{
29
  if(vect >= MAX_INT_HANDLERS)
30
    return -1;
31
 
32
  int_handlers[vect].handler = handler;
33
  int_handlers[vect].arg = arg;
34
 
35
  mtspr(SPR_PICMR, mfspr(SPR_PICMR) | (0x00000001L << vect));
36
 
37
  return 0;
38
}
39
 
40
/* Disable interrupt */
41
int int_disable(unsigned long vect)
42
{
43
  if(vect >= MAX_INT_HANDLERS)
44
    return -1;
45
 
46
  mtspr(SPR_PICMR, mfspr(SPR_PICMR) & ~(0x00000001L << vect));
47
 
48
  return 0;
49
}
50
 
51
/* Enable interrupt */
52
int int_enable(unsigned long vect)
53
{
54
  if(vect >= MAX_INT_HANDLERS)
55
    return -1;
56
 
57
  mtspr(SPR_PICMR, mfspr(SPR_PICMR) | (0x00000001L << vect));
58
 
59
  return 0;
60
}
61
 
62
/* Main interrupt handler */
63
void int_main()
64
{
65
  unsigned long picsr = mfspr(SPR_PICSR);
66
  unsigned long i = 0;
67
 
68
  mtspr(SPR_PICSR, 0);
69
 
70
  while(i < 32) {
71
    if((picsr & (0x01L << i)) && (int_handlers[i].handler != 0)) {
72
      (*int_handlers[i].handler)(int_handlers[i].arg);
73
      mtspr(SPR_PICSR, mfspr(SPR_PICSR) & ~(0x00000001L << i));
74
    }
75
    i++;
76
  }
77
}
78
 
79
#endif

powered by: WebSVN 2.1.0

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