1 | /* |
---|
2 | * This file contains the implementation of rtems initialization |
---|
3 | * related to interrupt handling |
---|
4 | */ |
---|
5 | |
---|
6 | /* |
---|
7 | * Copyright (C) 1999 valette@crf.canon.fr |
---|
8 | * |
---|
9 | * Enhanced by Jay Kulpinski <jskulpin@eng01.gdds.com> |
---|
10 | * to make it valid for MVME2300 Motorola boards. |
---|
11 | * |
---|
12 | * The license and distribution terms for this file may be |
---|
13 | * found in the file LICENSE in this distribution or at |
---|
14 | * http://www.rtems.org/license/LICENSE. |
---|
15 | */ |
---|
16 | |
---|
17 | #include <libcpu/io.h> |
---|
18 | #include <libcpu/spr.h> |
---|
19 | #include <bsp/irq.h> |
---|
20 | #include <bsp.h> |
---|
21 | #include <psim.h> |
---|
22 | #include <bsp/vectors.h> |
---|
23 | #include <rtems/bspIo.h> |
---|
24 | #include <bsp/openpic.h> |
---|
25 | #include <bsp/irq-generic.h> |
---|
26 | |
---|
27 | static rtems_irq_connect_data rtemsIrq[BSP_IRQ_NUMBER]; |
---|
28 | static rtems_irq_global_settings initial_config; |
---|
29 | static rtems_irq_connect_data defaultIrq = { |
---|
30 | /* vectorIdex, hdl , handle , on , off , isOn */ |
---|
31 | 0, NULL, NULL , NULL, NULL, NULL |
---|
32 | }; |
---|
33 | static rtems_irq_prio irqPrioTable[BSP_IRQ_NUMBER]={ |
---|
34 | /* |
---|
35 | * Processor exceptions handled as interrupts |
---|
36 | */ |
---|
37 | 0 |
---|
38 | }; |
---|
39 | |
---|
40 | /* |
---|
41 | * This code assumes the exceptions management setup has already |
---|
42 | * been done. We just need to replace the exceptions that will |
---|
43 | * be handled like interrupt. On mcp750/mpc750 and many PPC processors |
---|
44 | * this means the decrementer exception and the external exception. |
---|
45 | */ |
---|
46 | void BSP_rtems_irq_mng_init(unsigned cpuId) |
---|
47 | { |
---|
48 | int i; |
---|
49 | |
---|
50 | /* |
---|
51 | * First initialize the Interrupt management hardware |
---|
52 | */ |
---|
53 | OpenPIC = (void*)PSIM.OpenPIC; |
---|
54 | openpic_init(1,0,0,16,0,0); |
---|
55 | |
---|
56 | /* |
---|
57 | * Initialize Rtems management interrupt table |
---|
58 | */ |
---|
59 | /* |
---|
60 | * re-init the rtemsIrq table |
---|
61 | */ |
---|
62 | for (i = 0; i < BSP_IRQ_NUMBER; i++) { |
---|
63 | rtemsIrq[i] = defaultIrq; |
---|
64 | rtemsIrq[i].name = i; |
---|
65 | } |
---|
66 | /* |
---|
67 | * Init initial Interrupt management config |
---|
68 | */ |
---|
69 | initial_config.irqNb = BSP_IRQ_NUMBER; |
---|
70 | initial_config.defaultEntry = defaultIrq; |
---|
71 | initial_config.irqHdlTbl = rtemsIrq; |
---|
72 | initial_config.irqBase = BSP_LOWEST_OFFSET; |
---|
73 | initial_config.irqPrioTbl = irqPrioTable; |
---|
74 | |
---|
75 | for (i = BSP_PCI_IRQ_LOWEST_OFFSET; i< BSP_PCI_IRQ_NUMBER; i++ ) { |
---|
76 | irqPrioTable[i] = 8; |
---|
77 | } |
---|
78 | |
---|
79 | if (!BSP_rtems_irq_mngt_set(&initial_config)) { |
---|
80 | /* |
---|
81 | * put something here that will show the failure... |
---|
82 | */ |
---|
83 | rtems_panic( |
---|
84 | "Unable to initialize RTEMS interrupt Management!!! System locked\n" |
---|
85 | ); |
---|
86 | } |
---|
87 | |
---|
88 | #ifdef TRACE_IRQ_INIT |
---|
89 | printk("RTEMS IRQ management is now operationnal\n"); |
---|
90 | #endif |
---|
91 | } |
---|
92 | |
---|
93 | static int psim_exception_handler( |
---|
94 | BSP_Exception_frame *frame, |
---|
95 | unsigned exception_number |
---|
96 | ) |
---|
97 | { |
---|
98 | rtems_panic("Unexpected interrupt occured"); |
---|
99 | return 0; |
---|
100 | } |
---|
101 | |
---|
102 | /* |
---|
103 | * functions to enable/disable a source at the ipic |
---|
104 | */ |
---|
105 | void bsp_interrupt_vector_enable( rtems_vector_number irqnum) |
---|
106 | { |
---|
107 | /* FIXME: do something */ |
---|
108 | bsp_interrupt_assert(bsp_interrupt_is_valid_vector(irqnum)); |
---|
109 | } |
---|
110 | |
---|
111 | void bsp_interrupt_vector_disable( rtems_vector_number irqnum) |
---|
112 | { |
---|
113 | /* FIXME: do something */ |
---|
114 | bsp_interrupt_assert(bsp_interrupt_is_valid_vector(irqnum)); |
---|
115 | } |
---|
116 | |
---|
117 | rtems_status_code bsp_interrupt_facility_initialize(void) |
---|
118 | { |
---|
119 | /* Install exception handler */ |
---|
120 | if (ppc_exc_set_handler( ASM_EXT_VECTOR, psim_exception_handler)) { |
---|
121 | return RTEMS_IO_ERROR; |
---|
122 | } |
---|
123 | |
---|
124 | return RTEMS_SUCCESSFUL; |
---|
125 | } |
---|