OpenCores
URL https://opencores.org/ocsvn/an-fpga-implementation-of-low-latency-noc-based-mpsoc/an-fpga-implementation-of-low-latency-noc-based-mpsoc/trunk

Subversion Repositories an-fpga-implementation-of-low-latency-noc-based-mpsoc

[/] [an-fpga-implementation-of-low-latency-noc-based-mpsoc/] [trunk/] [mpsoc/] [src_processor/] [or1200/] [sw/] [or1200/] [int.c] - Blame information for rev 38

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 38 alirezamon
/*
2
 *
3
 * User interrupt handler software for OR1200
4
 *
5
 */
6
 
7
#include "or1200-utils.h"
8
#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 irq, void (* handler)(void *), void *arg)
29
{
30
  if(irq >= MAX_INT_HANDLERS)
31
    return -1;
32
 
33
  int_handlers[irq].handler = handler;
34
  int_handlers[irq].arg = arg;
35
 
36
  mtspr(SPR_PICMR, mfspr(SPR_PICMR) | (0x00000001L << irq));
37
 
38
  return 0;
39
}
40
 
41
/* Disable interrupt */
42
int int_disable(unsigned long irq)
43
{
44
  if(irq >= MAX_INT_HANDLERS)
45
    return -1;
46
 
47
  mtspr(SPR_PICMR, mfspr(SPR_PICMR) & ~(0x00000001L << irq));
48
 
49
  return 0;
50
}
51
 
52
/* Enable interrupt */
53
int int_enable(unsigned long irq)
54
{
55
  if(irq >= MAX_INT_HANDLERS)
56
    return -1;
57
 
58
  mtspr(SPR_PICMR, mfspr(SPR_PICMR) | (0x00000001L << irq));
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
#ifdef OR1200_INT_CHECK_BIT_CLEARED
75
      // Ensure PICSR bit is cleared, incase it takes some time for the
76
      // IRQ line going low to propagate back to PIC
77
      while (mfspr(SPR_PICSR) & (0x00000001L << i))
78
#endif
79
              mtspr(SPR_PICSR, mfspr(SPR_PICSR) & ~(0x00000001L << i));
80
    }
81
    i++;
82
  }
83
}
84
 
85
 

powered by: WebSVN 2.1.0

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