summaryrefslogtreecommitdiffstats
path: root/bsps/powerpc/haleakala/irq/irq_init.c
blob: d48855a9795f6788ab5255f14fd35457b7bd516c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
/*===============================================================*\
| Project: RTEMS Haleakala BSP                                    |
|  *  by Michael Hamel ADInstruments Ltd 2008                     |
+-----------------------------------------------------------------+
| The license and distribution terms for this file may be         |
| found in the file LICENSE in this distribution or at            |
|                                                                 |
| http://www.rtems.org/license/LICENSE.                           |
|                                                                 |
+-----------------------------------------------------------------+
| this file contains the irq controller handler                   |
\*===============================================================*/
#include <libcpu/spr.h>
#include <bsp/irq.h>
#include <bsp.h>
#include <bsp/vectors.h>
#include <rtems/bspIo.h>
#include <rtems/powerpc/powerpc.h>


/*
 * default on/off function
 */
static void nop_func(void)
{
}

/*
 * default isOn function
 */
static int not_connected(void)
{
	return 0;
}

static rtems_irq_connect_data      rtemsIrq[BSP_IRQ_NUMBER];
static rtems_irq_global_settings   initial_config;
static rtems_irq_connect_data      defaultIrq = {
  .name   = 0,
  .hdl    = NULL,
  .handle = NULL,
  .on     = (rtems_irq_enable) nop_func,
  .off    = (rtems_irq_disable) nop_func,
  .isOn   = (rtems_irq_is_enabled) not_connected,
#ifdef BSP_SHARED_HANDLER_SUPPORT
  .next_handler = NULL
#endif
};

static rtems_irq_prio irqPrioTable[BSP_IRQ_NUMBER]={
  /*
   * Processor exceptions handled as interrupts
   */
  0
};

  /*
   * This code assumes the exceptions management setup has already
   * been done. We just need to replace the exceptions that will
   * be handled like interrupt. On mcp750/mpc750 and many PPC processors
   * this means the decrementer exception and the external exception.
   */

void BSP_rtems_irq_mng_init(unsigned cpuId)
{
  int i;

  /*
   * re-init the rtemsIrq table
   */
  for (i = 0; i < BSP_IRQ_NUMBER; i++) {
    rtemsIrq[i]      = defaultIrq;
    rtemsIrq[i].name = i;
  }
  /*
   * Init initial Interrupt management config
   */
  initial_config.irqNb        = BSP_IRQ_NUMBER;
  initial_config.defaultEntry = defaultIrq;
  initial_config.irqHdlTbl    = rtemsIrq;
  initial_config.irqBase      = BSP_LOWEST_OFFSET;
  initial_config.irqPrioTbl   = irqPrioTable;

  if (!BSP_rtems_irq_mngt_set(&initial_config)) {
    /*
     * put something here that will show the failure...
     */
    rtems_panic(
      "Unable to initialize RTEMS interrupt management!!! System locked\n"
    );
  }

  #ifdef TRACE_IRQ_INIT
    printk("RTEMS IRQ management is now operational\n");
  #endif
}