-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbsp-csb336-Use-IRQ-extensions-API.patch
371 lines (340 loc) · 11.6 KB
/
bsp-csb336-Use-IRQ-extensions-API.patch
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
From 52e44630e57b030d22dc6866425929efb1abac0f Mon Sep 17 00:00:00 2001
From: Vipul Nayyar <[email protected]>
Date: Wed, 10 Jul 2013 09:54:01 +0200
Subject: [PATCH] bsp/csb336: Use IRQ extensions API
Fix warnings.
---
c/src/lib/libbsp/arm/csb336/console/uart.c | 142 +++++++++++++++-----------
c/src/lib/libbsp/arm/csb336/network/network.c | 46 +++------
2 files changed, 96 insertions(+), 92 deletions(-)
diff --git a/c/src/lib/libbsp/arm/csb336/console/uart.c b/c/src/lib/libbsp/arm/csb336/console/uart.c
index 4c64832..0f6388b 100644
--- a/c/src/lib/libbsp/arm/csb336/console/uart.c
+++ b/c/src/lib/libbsp/arm/csb336/console/uart.c
@@ -13,12 +13,12 @@
#include <libchip/sersupp.h>
#include <rtems/error.h>
#include <rtems/bspIo.h>
+#include <assert.h>
#include <termios.h>
#include <rtems/irq.h>
#include <bsp/irq.h>
#include <mc9328mxl.h>
-
/* Define this to use interrupt driver UART driver */
#define USE_INTERRUPTS 1
@@ -34,20 +34,23 @@ static int imx_uart_set_attrs(int, const struct termios *);
static void imx_uart_init(int minor);
static void imx_uart_set_baud(int, int);
static ssize_t imx_uart_poll_write(int, const char *, size_t);
+static int imx_uart_poll_read_char(int minor);
+static void imx_uart_poll_write_char(int minor, char c);
+static void _BSP_output_char(char c);
+static int _BSP_poll_char(void);
-#if defined(USE_INTERRUPTS)
+#if USE_INTERRUPTS
static void imx_uart_tx_isr(rtems_irq_hdl_param);
static void imx_uart_rx_isr(rtems_irq_hdl_param);
-static void imx_uart_isr_on(const rtems_irq_connect_data *irq);
-static void imx_uart_isr_off(const rtems_irq_connect_data *irq);
-static int imx_uart_isr_is_on(const rtems_irq_connect_data *irq);
+static void imx_uart_isr_on(const rtems_irq_number);
+static void imx_uart_isr_off(const rtems_irq_number);
static ssize_t imx_uart_intr_write(int, const char *, size_t);
+static rtems_vector_number imx_uart_name_transmit(int minor);
+static rtems_vector_number imx_uart_name_receive(int minor);
#endif
-
-
/* TERMIOS callbacks */
-#if defined(USE_INTERRUPTS)
+#if USE_INTERRUPTS
rtems_termios_callbacks imx_uart_cbacks = {
.firstOpen = imx_uart_first_open,
.lastClose = imx_uart_last_close,
@@ -71,11 +74,6 @@ rtems_termios_callbacks imx_uart_cbacks = {
};
#endif
-#if defined(USE_INTERRUPTS)
-static rtems_irq_connect_data imx_uart_tx_isr_data[NUM_DEVS];
-static rtems_irq_connect_data imx_uart_rx_isr_data[NUM_DEVS];
-#endif
-
typedef struct {
int minor;
mc9328mxl_uart_regs_t * regs;
@@ -184,17 +182,9 @@ static void imx_uart_init(int minor)
imx_uart_data[minor].idx = 0;
if (minor == 0) {
-#if defined(USE_INTERRUPTS)
- imx_uart_tx_isr_data[minor].name = BSP_INT_UART1_TX;
- imx_uart_rx_isr_data[minor].name = BSP_INT_UART1_RX;
-#endif
imx_uart_data[minor].regs =
(mc9328mxl_uart_regs_t *) MC9328MXL_UART1_BASE;
} else if (minor == 1) {
-#if defined(USE_INTERRUPTS)
- imx_uart_tx_isr_data[minor].name = BSP_INT_UART2_TX;
- imx_uart_rx_isr_data[minor].name = BSP_INT_UART2_RX;
-#endif
imx_uart_data[minor].regs =
(mc9328mxl_uart_regs_t *) MC9328MXL_UART2_BASE;
} else {
@@ -202,20 +192,6 @@ static void imx_uart_init(int minor)
__FUNCTION__, __LINE__, minor);
}
-#if defined(USE_INTERRUPTS)
- imx_uart_tx_isr_data[minor].hdl = imx_uart_tx_isr;
- imx_uart_tx_isr_data[minor].handle = &imx_uart_data[minor];
- imx_uart_tx_isr_data[minor].on = imx_uart_isr_on;
- imx_uart_tx_isr_data[minor].off = imx_uart_isr_off;
- imx_uart_tx_isr_data[minor].isOn = imx_uart_isr_is_on;
-
- imx_uart_rx_isr_data[minor].hdl = imx_uart_rx_isr;
- imx_uart_rx_isr_data[minor].handle = &imx_uart_data[minor];
- imx_uart_rx_isr_data[minor].on = imx_uart_isr_on;
- imx_uart_rx_isr_data[minor].off = imx_uart_isr_off;
- imx_uart_rx_isr_data[minor].isOn = imx_uart_isr_is_on;
-#endif
-
imx_uart_data[minor].regs->cr1 = (
MC9328MXL_UART_CR1_UARTCLKEN |
MC9328MXL_UART_CR1_UARTEN);
@@ -243,12 +219,30 @@ static void imx_uart_init(int minor)
static int imx_uart_first_open(int major, int minor, void *arg)
{
rtems_libio_open_close_args_t *args = arg;
+ rtems_status_code status = RTEMS_SUCCESSFUL;
imx_uart_data[minor].tty = args->iop->data1;
-#if defined(USE_INTERRUPTS)
- BSP_install_rtems_irq_handler(&imx_uart_tx_isr_data[minor]);
- BSP_install_rtems_irq_handler(&imx_uart_rx_isr_data[minor]);
+#if USE_INTERRUPTS
+ status = rtems_interrupt_handler_install(
+ imx_uart_name_transmit(minor),
+ "UART",
+ RTEMS_INTERRUPT_UNIQUE,
+ imx_uart_tx_isr,
+ &imx_uart_data[minor]
+ );
+ assert(status == RTEMS_SUCCESSFUL);
+ imx_uart_isr_on(imx_uart_name_transmit(minor));
+
+ status = rtems_interrupt_handler_install(
+ imx_uart_name_receive(minor),
+ "UART",
+ RTEMS_INTERRUPT_UNIQUE,
+ imx_uart_rx_isr,
+ &imx_uart_data[minor]
+ );
+ assert(status == RTEMS_SUCCESSFUL);
+ imx_uart_isr_on(imx_uart_name_receive(minor));
imx_uart_data[minor].regs->cr1 |= MC9328MXL_UART_CR1_RRDYEN;
#endif
@@ -258,9 +252,24 @@ static int imx_uart_first_open(int major, int minor, void *arg)
static int imx_uart_last_close(int major, int minor, void *arg)
{
-#if defined(USE_INTERRUPTS)
- BSP_remove_rtems_irq_handler(&imx_uart_tx_isr_data[minor]);
- BSP_remove_rtems_irq_handler(&imx_uart_rx_isr_data[minor]);
+#if USE_INTERRUPTS
+ rtems_status_code status = RTEMS_SUCCESSFUL;
+
+ imx_uart_isr_off(imx_uart_name_transmit(minor));
+ status = rtems_interrupt_handler_remove(
+ imx_uart_name_transmit(minor),
+ imx_uart_tx_isr,
+ &imx_uart_data[minor]
+ );
+ assert(status == RTEMS_SUCCESSFUL);
+
+ imx_uart_isr_off(imx_uart_name_receive(minor));
+ status = rtems_interrupt_handler_remove(
+ imx_uart_name_receive(minor),
+ imx_uart_rx_isr,
+ &imx_uart_data[minor]
+ );
+ assert(status == RTEMS_SUCCESSFUL);
#endif
return 0;
@@ -291,7 +300,7 @@ static ssize_t imx_uart_poll_write(int minor, const char *buf, size_t len)
}
-#if defined(USE_INTERRUPTS)
+#if USE_INTERRUPTS
static ssize_t imx_uart_intr_write(int minor, const char *buf, size_t len)
{
if (len > 0) {
@@ -318,23 +327,14 @@ static int imx_uart_set_attrs(int minor, const struct termios *t)
return 0;
}
-#if defined(USE_INTERRUPTS)
-static void imx_uart_isr_on(const rtems_irq_connect_data *irq)
+#if USE_INTERRUPTS
+static void imx_uart_isr_on(const rtems_irq_number name)
{
- MC9328MXL_AITC_INTENNUM = irq->name;
+ MC9328MXL_AITC_INTENNUM = name;
}
-static void imx_uart_isr_off(const rtems_irq_connect_data *irq)
+static void imx_uart_isr_off(const rtems_irq_number name)
{
- MC9328MXL_AITC_INTDISNUM = irq->name;
-}
-static int imx_uart_isr_is_on(const rtems_irq_connect_data *irq)
-{
- int irq_num = (int)irq->name;
- if (irq_num < 32) {
- return MC9328MXL_AITC_INTENABLEL & (1 << irq_num);
- } else {
- return MC9328MXL_AITC_INTENABLEH & (1 << (irq_num - 32));
- }
+ MC9328MXL_AITC_INTDISNUM = name;
}
static void imx_uart_rx_isr(rtems_irq_hdl_param param)
@@ -371,6 +371,28 @@ static void imx_uart_tx_isr(rtems_irq_hdl_param param)
rtems_termios_dequeue_characters(uart_data->tty, len);
}
}
+
+static rtems_vector_number imx_uart_name_transmit(int minor)
+{
+ if (minor == 0) {
+ return BSP_INT_UART1_TX;
+ } else if (minor == 1) {
+ return BSP_INT_UART2_TX;
+ }
+
+ assert(0);
+}
+
+static rtems_vector_number imx_uart_name_receive(int minor)
+{
+ if (minor == 0) {
+ return BSP_INT_UART1_RX;
+ } else if (minor == 1) {
+ return BSP_INT_UART2_RX;
+ }
+
+ assert(0);
+}
#endif
/*
@@ -419,7 +441,7 @@ static void imx_uart_set_baud(int minor, int baud)
/*
* Polled, non-blocking read from UART
*/
-int imx_uart_poll_read_char(int minor)
+static int imx_uart_poll_read_char(int minor)
{
return imx_uart_poll_read(minor);
}
@@ -427,7 +449,7 @@ int imx_uart_poll_read_char(int minor)
/*
* Polled, blocking write from UART
*/
-void imx_uart_poll_write_char(int minor, char c)
+static void imx_uart_poll_write_char(int minor, char c)
{
imx_uart_poll_write(minor, &c, 1);
}
@@ -435,7 +457,7 @@ void imx_uart_poll_write_char(int minor, char c)
/*
* Functions for printk() and friends.
*/
-void _BSP_output_char(char c)
+static void _BSP_output_char(char c)
{
poll_write(c);
if (c == '\n') {
@@ -445,7 +467,7 @@ void _BSP_output_char(char c)
BSP_output_char_function_type BSP_output_char = _BSP_output_char;
-int _BSP_poll_char(void)
+static int _BSP_poll_char(void)
{
return poll_read();
}
diff --git a/c/src/lib/libbsp/arm/csb336/network/network.c b/c/src/lib/libbsp/arm/csb336/network/network.c
index e513595..f93fcc8 100644
--- a/c/src/lib/libbsp/arm/csb336/network/network.c
+++ b/c/src/lib/libbsp/arm/csb336/network/network.c
@@ -19,6 +19,7 @@
#include <errno.h>
#include <rtems/error.h>
#include <rtems/bspIo.h>
+#include <assert.h>
#include <sys/param.h>
#include <sys/mbuf.h>
@@ -39,19 +40,8 @@
#define START_TRANSMIT_EVENT RTEMS_EVENT_2
static void enet_isr(rtems_irq_hdl_param);
-static void enet_isr_on(const rtems_irq_connect_data *unused);
-static void enet_isr_off(const rtems_irq_connect_data *unused);
-static int enet_isr_is_on(const rtems_irq_connect_data *irq);
-
-/* Replace the first value with the clock's interrupt name. */
-rtems_irq_connect_data mc9328mxl_enet_isr_data = {
- .name = BSP_INT_GPIO_PORTA,
- .hdl = enet_isr,
- .handle = (void *)BSP_INT_GPIO_PORTA,
- .on = enet_isr_on,
- .off = enet_isr_off,
- .isOn = enet_isr_is_on,
-};
+static void enet_isr_on(void);
+
typedef struct {
unsigned long rx_packets; /* total packets received */
unsigned long tx_packets; /* total packets transmitted */
@@ -238,6 +228,7 @@ void mc9328mxl_enet_init_hw(mc9328mxl_enet_softc_t *sc)
{
uint16_t stat;
uint16_t my = 0;
+ rtems_status_code status = RTEMS_SUCCESSFUL;
lan91c11x_write_reg(LAN91C11X_RCR, LAN91C11X_RCR_RST);
lan91c11x_write_reg(LAN91C11X_RCR, 0);
@@ -334,7 +325,15 @@ void mc9328mxl_enet_init_hw(mc9328mxl_enet_softc_t *sc)
MC9328MXL_GPIOA_IMR |= bit(3);
/* Install the interrupt handler */
- BSP_install_rtems_irq_handler(&mc9328mxl_enet_isr_data);
+ status = rtems_interrupt_handler_install(
+ BSP_INT_GPIO_PORTA,
+ "Network",
+ RTEMS_INTERRUPT_UNIQUE,
+ enet_isr,
+ (void *)BSP_INT_GPIO_PORTA
+ );
+ assert(status == RTEMS_SUCCESSFUL);
+ enet_isr_on();
} /* mc9328mxl_enet_init_hw() */
@@ -602,7 +601,7 @@ void mc9328mxl_enet_stats (mc9328mxl_enet_softc_t *sc)
/* Enables mc9328mxl_enet interrupts. */
-static void enet_isr_on(const rtems_irq_connect_data *unused)
+static void enet_isr_on(void)
{
/* Enable interrupts */
MC9328MXL_AITC_INTENNUM = MC9328MXL_INT_GPIO_PORTA;
@@ -610,23 +609,6 @@ static void enet_isr_on(const rtems_irq_connect_data *unused)
return;
}
-/* Disables enet interrupts */
-static void enet_isr_off(const rtems_irq_connect_data *unused)
-{
- /* disable all various TX/RX interrupts */
- MC9328MXL_AITC_INTDISNUM = MC9328MXL_INT_GPIO_PORTA;
-
- return;
-}
-
-/* Tests to see if mc9328mxl_enet interrupts are enabled, and returns non-0 if so.
- * If interrupt is not enabled, returns 0.
- */
-static int enet_isr_is_on(const rtems_irq_connect_data *irq)
-{
- return MC9328MXL_AITC_INTENABLEL & (1 << MC9328MXL_INT_GPIO_PORTA);
-}
-
/* Driver ioctl handler */
static int
mc9328mxl_enet_ioctl (struct ifnet *ifp, ioctl_command_t command, caddr_t data)
--
1.7.11.7