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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [orpsocv2/] [sw/] [drivers/] [or1200/] [int.c] - Blame information for rev 505

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

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

powered by: WebSVN 2.1.0

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