[PATCH] Removing legacy method from arm csb336
Vipul Nayyar
nayyar_vipul at yahoo.com
Sun Jul 7 16:56:06 UTC 2013
---
c/src/lib/libbsp/arm/csb336/console/uart.c | 134 +++++++++++++++-----------
c/src/lib/libbsp/arm/csb336/network/network.c | 46 +++------
2 files changed, 92 insertions(+), 88 deletions(-)
diff --git a/c/src/lib/libbsp/arm/csb336/console/uart.c b/c/src/lib/libbsp/arm/csb336/console/uart.c
index 4dc409b..9876f43 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,18 +34,19 @@ 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)
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);
#endif
-
-
/* TERMIOS callbacks */
#if defined(USE_INTERRUPTS)
rtems_termios_callbacks imx_uart_cbacks = {
@@ -71,11 +72,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 +180,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 +190,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,13 +217,43 @@ 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;
-
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 defined(USE_INTERRUPTS)
+ rtems_status_code status = RTEMS_SUCCESSFUL;
+ rtems_irq_number name_uart_tx, name_uart_rx;
+
+ if (minor == 0) {
+ name_uart_tx = BSP_INT_UART1_TX;
+ name_uart_rx = BSP_INT_UART1_RX;
+ } else if (minor == 1) {
+ name_uart_tx = BSP_INT_UART2_TX;
+ name_uart_rx = BSP_INT_UART2_RX;
+ } else {
+ rtems_panic("%s:%d Unknown UART minor number %d\n",
+ __FUNCTION__, __LINE__, minor);
+ }
+ status = rtems_interrupt_handler_install(
+ name_uart_tx,
+ "Network",
+ RTEMS_INTERRUPT_UNIQUE,
+ imx_uart_tx_isr,
+ &imx_uart_data[minor]
+ );
+ assert(status == RTEMS_SUCCESSFUL);
+ imx_uart_isr_on(name_uart_tx);
+
+ status = rtems_interrupt_handler_install(
+ name_uart_rx,
+ "Network",
+ RTEMS_INTERRUPT_UNIQUE,
+ imx_uart_rx_isr,
+ &imx_uart_data[minor]
+ );
+ assert(status == RTEMS_SUCCESSFUL);
+ imx_uart_isr_on(name_uart_rx);
+
imx_uart_data[minor].regs->cr1 |= MC9328MXL_UART_CR1_RRDYEN;
#endif
@@ -259,8 +263,35 @@ 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]);
+ rtems_status_code status = RTEMS_SUCCESSFUL;
+ rtems_irq_number name_uart_tx, name_uart_rx;
+
+ if (minor == 0) {
+ name_uart_tx = BSP_INT_UART1_TX;
+ name_uart_rx = BSP_INT_UART1_RX;
+ } else if (minor == 1) {
+ name_uart_tx = BSP_INT_UART2_TX;
+ name_uart_rx = BSP_INT_UART2_RX;
+ } else {
+ rtems_panic("%s:%d Unknown UART minor number %d\n",
+ __FUNCTION__, __LINE__, minor);
+ }
+
+ imx_uart_isr_off(name_uart_tx);
+ status = rtems_interrupt_handler_remove(
+ name_uart_tx,
+ imx_uart_tx_isr,
+ &imx_uart_data[minor]
+ );
+ assert(status == RTEMS_SUCCESSFUL);
+
+ imx_uart_isr_off(name_uart_rx);
+ status = rtems_interrupt_handler_remove(
+ name_uart_rx,
+ imx_uart_rx_isr,
+ &imx_uart_data[minor]
+ );
+ assert(status == RTEMS_SUCCESSFUL);
#endif
return 0;
@@ -317,22 +348,13 @@ static int imx_uart_set_attrs(int minor, const struct termios *t)
}
#if defined(USE_INTERRUPTS)
-static void imx_uart_isr_on(const rtems_irq_connect_data *irq)
+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)
@@ -417,7 +439,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);
}
@@ -425,7 +447,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);
}
@@ -433,7 +455,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') {
@@ -443,7 +465,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..1367a8f 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()
{
/* 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
More information about the devel
mailing list