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

Subversion Repositories minsoc

[/] [minsoc/] [trunk/] [sw/] [support/] [int.c] - Blame information for rev 9

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

Line No. Rev Author Line
1 2 rfajardo
/* 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
  mtspr(SPR_PICMR, 0x00000000);
23
 
24
  //set OR1200 to accept exceptions
25
  mtspr(SPR_SR, mfspr(SPR_SR) | SPR_SR_IEE);
26
 
27
  return 0;
28
}
29
 
30
/* Add interrupt handler */
31
int int_add(unsigned long vect, void (* handler)(void *), void *arg)
32
{
33
  if(vect >= MAX_INT_HANDLERS)
34
    return -1;
35
 
36
  int_handlers[vect].handler = handler;
37
  int_handlers[vect].arg = arg;
38
 
39
  mtspr(SPR_PICMR, mfspr(SPR_PICMR) | (0x00000001L << vect));
40
 
41
  return 0;
42
}
43
 
44
/* Disable interrupt */
45
int int_disable(unsigned long vect)
46
{
47
  if(vect >= MAX_INT_HANDLERS)
48
    return -1;
49
 
50
  mtspr(SPR_PICMR, mfspr(SPR_PICMR) & ~(0x00000001L << vect));
51
 
52
  return 0;
53
}
54
 
55
/* Enable interrupt */
56
int int_enable(unsigned long vect)
57
{
58
  if(vect >= MAX_INT_HANDLERS)
59
    return -1;
60
 
61
  mtspr(SPR_PICMR, mfspr(SPR_PICMR) | (0x00000001L << vect));
62
 
63
  return 0;
64
}
65
 
66
/* Main interrupt handler */
67
void int_main()
68
{
69
  unsigned long picsr = mfspr(SPR_PICSR);
70
  unsigned long i = 0;
71
 
72
  mtspr(SPR_PICSR, 0);
73
 
74
  while(i < 32) {
75
    if((picsr & (0x01L << i)) && (int_handlers[i].handler != 0)) {
76
      (*int_handlers[i].handler)(int_handlers[i].arg);
77
    }
78
    i++;
79
  }
80
}
81
 
82
#endif

powered by: WebSVN 2.1.0

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