1 | /* |
---|
2 | * RTEMS for Nintendo DS interrupt manager. |
---|
3 | * |
---|
4 | * Copyright (c) 2008 by Matthieu Bucchianeri <mbucchia@gmail.com> |
---|
5 | * |
---|
6 | * The license and distribution terms for this file may be |
---|
7 | * found in the file LICENSE in this distribution or at |
---|
8 | * |
---|
9 | * http://www.rtems.com/license/LICENSE |
---|
10 | * |
---|
11 | * $Id$ |
---|
12 | */ |
---|
13 | |
---|
14 | #include <bsp.h> |
---|
15 | #include <rtems/irq.h> |
---|
16 | #include <nds.h> |
---|
17 | |
---|
18 | /* |
---|
19 | * this function check that the value given for the irq line is valid. |
---|
20 | */ |
---|
21 | |
---|
22 | static int |
---|
23 | isValidInterrupt (int irq) |
---|
24 | { |
---|
25 | if (irq < 0 || irq >= MAX_INTERRUPTS) |
---|
26 | return 0; |
---|
27 | return 1; |
---|
28 | } |
---|
29 | |
---|
30 | /* |
---|
31 | * initialize the irq management. |
---|
32 | */ |
---|
33 | |
---|
34 | void |
---|
35 | BSP_rtems_irq_mngt_init (void) |
---|
36 | { |
---|
37 | printk ("[+] irq manager started\n"); |
---|
38 | |
---|
39 | irqInit (); |
---|
40 | |
---|
41 | REG_IME = IME_ENABLE; |
---|
42 | } |
---|
43 | |
---|
44 | /* |
---|
45 | * install a irq handler. |
---|
46 | */ |
---|
47 | |
---|
48 | int |
---|
49 | BSP_install_rtems_irq_handler (const rtems_irq_connect_data * irq) |
---|
50 | { |
---|
51 | rtems_interrupt_level level; |
---|
52 | |
---|
53 | if (!isValidInterrupt (irq->name)) |
---|
54 | return 0; |
---|
55 | |
---|
56 | rtems_interrupt_disable (level); |
---|
57 | |
---|
58 | /* |
---|
59 | * FIXME: irq_hdl will probably not be called with its parameter |
---|
60 | */ |
---|
61 | irqSet (irq->name, (VoidFunctionPointer)irq->hdl); |
---|
62 | |
---|
63 | if (irq->on != NULL) |
---|
64 | irq->on (irq); |
---|
65 | |
---|
66 | rtems_interrupt_enable (level); |
---|
67 | |
---|
68 | return 1; |
---|
69 | } |
---|
70 | |
---|
71 | /* |
---|
72 | * return the handler hooked to the given irq. |
---|
73 | */ |
---|
74 | |
---|
75 | int |
---|
76 | BSP_get_current_rtems_irq_handler (rtems_irq_connect_data * irq) |
---|
77 | { |
---|
78 | return 0; /* FIXME */ |
---|
79 | } |
---|
80 | |
---|
81 | /* |
---|
82 | * remove & disable given irq. |
---|
83 | */ |
---|
84 | |
---|
85 | int |
---|
86 | BSP_remove_rtems_irq_handler (const rtems_irq_connect_data * irq) |
---|
87 | { |
---|
88 | rtems_interrupt_level level; |
---|
89 | |
---|
90 | if (!isValidInterrupt (irq->name)) |
---|
91 | return 0; |
---|
92 | |
---|
93 | rtems_interrupt_disable (level); |
---|
94 | |
---|
95 | if (irq->off != NULL) |
---|
96 | irq->off (irq); |
---|
97 | |
---|
98 | irqClear (irq->name); |
---|
99 | |
---|
100 | rtems_interrupt_enable (level); |
---|
101 | |
---|
102 | return 1; |
---|
103 | } |
---|