[PATCH] Updated legacy code in i386 pc386

Vipul Nayyar nayyar_vipul at yahoo.com
Fri Jul 26 14:53:39 UTC 2013


---
 c/src/lib/libbsp/i386/pc386/3c509/3c509.c       | 113 +++++-------------------
 c/src/lib/libbsp/i386/pc386/clock/ckinit.c      |  71 +++++++--------
 c/src/lib/libbsp/i386/pc386/console/ps2_mouse.c |  58 +++++-------
 c/src/lib/libbsp/i386/pc386/console/vgacons.c   |  35 +++-----
 c/src/lib/libbsp/i386/pc386/include/bsp.h       |  10 ++-
 c/src/lib/libbsp/i386/pc386/wd8003/wd8003.c     |  44 ++++-----
 c/src/lib/libbsp/i386/shared/comm/tty_drv.c     |  93 +++++++------------
 c/src/lib/libbsp/i386/shared/smp/smp-imps.c     |  30 +++----
 8 files changed, 166 insertions(+), 288 deletions(-)

diff --git a/c/src/lib/libbsp/i386/pc386/3c509/3c509.c b/c/src/lib/libbsp/i386/pc386/3c509/3c509.c
index ec309ba..41c1de1 100644
--- a/c/src/lib/libbsp/i386/pc386/3c509/3c509.c
+++ b/c/src/lib/libbsp/i386/pc386/3c509/3c509.c
@@ -60,6 +60,7 @@
 #include <errno.h>
 #include <rtems/error.h>
 #include <rtems/rtems_bsdnet.h>
+#include <assert.h>
 
 #include <sys/param.h>
 #include <sys/mbuf.h>
@@ -163,11 +164,11 @@ struct ep_softc
     struct ep_board *epb;
     int unit;
 
-    rtems_irq_connect_data   irqInfo;
-    rtems_id		     	 rxDaemonTid;
-    rtems_id		     	 txDaemonTid;
+    rtems_id rxDaemonTid;
+    rtems_id txDaemonTid;
+    rtems_vector_number name;
 
-    int              	 acceptBroadcast;
+    int acceptBroadcast;
 
     short tx_underrun;
     short rx_no_first;
@@ -355,7 +356,7 @@ static __inline unsigned short inw( unsigned short io_addr )
  * RETURNS: nothing.
  *
  **********************************************************************************/
-void __inline outb( unsigned short io_addr, uint8_t out_data )
+static __inline void outb( unsigned short io_addr, uint8_t out_data )
 {
   outport_byte( io_addr, out_data );
 }
@@ -403,46 +404,6 @@ static int get_eeprom_data( int id_port, int offset )
 
 /**********************************************************************************
  *
- * DESCRIPTION: Waits until the EEPROM of the card is ready to be accessed.
- *
- * RETURNS: 0 - not ready; 1 - ok
- *
- **********************************************************************************/
-static int eeprom_rdy( struct ep_softc *sc )
-{
-    int i;
-
-    for (i = 0; is_eeprom_busy(BASE) && i < MAX_EEPROMBUSY; i++)
-	    continue;
-    if (i >= MAX_EEPROMBUSY)
-    {
-	   printf("ep%d: eeprom failed to come ready.\n", sc->unit);
-	   return (0);
-    }
-    return (1);
-}
-
-/**********************************************************************************
- *
- * DESCRIPTION:
- * get_e: gets a 16 bits word from the EEPROM.
- * We must have set the window before call this routine.
- *
- * RETURNS: data from EEPROM
- *
- **********************************************************************************/
-u_short get_e(  struct ep_softc *sc, int offset )
-{
-    if( !eeprom_rdy(sc) )
-	   return (0xffff);
-    outw(BASE + EP_W0_EEPROM_COMMAND, EEPROM_CMD_RD | offset );
-    if( !eeprom_rdy(sc) )
-	   return( 0xffff );
-    return( inw( BASE + EP_W0_EEPROM_DATA ) );
-}
-
-/**********************************************************************************
- *
  * DESCRIPTION:
  * Driver interrupt handler. This routine is called by the RTEMS kernel when this
  * interrupt is raised.
@@ -450,9 +411,9 @@ u_short get_e(  struct ep_softc *sc, int offset )
  * RETURNS: nothing.
  *
  **********************************************************************************/
-static rtems_isr ap_interrupt_handler( rtems_vector_number v )
+static rtems_isr ap_interrupt_handler(void *arg)
 {
-  struct ep_softc *sc = (struct ep_softc *)&ep_softc[ 0 ];
+  struct ep_softc *sc = (struct ep_softc *)arg;
 
   /* de-activate any pending interrrupt, and sent and event to interrupt task
    * to process all events required by this interrupt.
@@ -464,30 +425,6 @@ static rtems_isr ap_interrupt_handler( rtems_vector_number v )
 /**********************************************************************************
  *
  * DESCRIPTION:
- *
- * RETURNS:
- *
- **********************************************************************************/
-static void nopOn(const rtems_irq_connect_data* notUsed)
-{
-  /* does nothing */
-}
-
-/**********************************************************************************
- *
- * DESCRIPTION:
- *
- * RETURNS:
- *
- **********************************************************************************/
-static int _3c509_IsOn(const rtems_irq_connect_data* irq)
-{
-  return BSP_irq_enabled_at_i8259s (irq->name);
-}
-
-/**********************************************************************************
- *
- * DESCRIPTION:
  * Initializes the ethernet hardware.
  *
  * RETURNS: nothing.
@@ -495,24 +432,22 @@ static int _3c509_IsOn(const rtems_irq_connect_data* irq)
  **********************************************************************************/
 static void _3c509_initialize_hardware (struct ep_softc *sc)
 {
-  rtems_status_code st;
+  rtems_status_code status;
 
   epinit( sc );
 
   /*
    * Set up interrupts
    */
-  sc->irqInfo.hdl = ( rtems_irq_hdl )ap_interrupt_handler;
-  sc->irqInfo.on  = nopOn;
-  sc->irqInfo.off = nopOn;
-  sc->irqInfo.isOn = _3c509_IsOn;
-
-  printf ("3c509: IRQ with Kernel: %d\n", sc->irqInfo.name );
-  st = BSP_install_rtems_irq_handler( &sc->irqInfo );
-  if( !st )
-  {
-    rtems_panic ("Can't attach WD interrupt handler for irq %d\n", sc->irqInfo.name );
-  }
+  printf ("3c509: IRQ with Kernel: %d\n", (int)sc->name );
+  status = rtems_interrupt_handler_install(
+    sc->name,
+    "3c509",
+    RTEMS_INTERRUPT_UNIQUE,
+    ap_interrupt_handler,
+    sc
+  );
+  assert(status == RTEMS_SUCCESSFUL);
 }
 
 /**********************************************************************************
@@ -746,8 +681,8 @@ int rtems_3c509_driver_attach (struct rtems_bsdnet_ifconfig *config )
 	 */
 	overrun = 0;
 	resend = 0;
-    ep_unit = 0;
-    ep_boards = 0;
+  ep_unit = 0;
+  ep_boards = 0;
 
 	/*
 	 * Find a free driver
@@ -782,9 +717,9 @@ int rtems_3c509_driver_attach (struct rtems_bsdnet_ifconfig *config )
 		mtu = ETHERMTU;
 
 	if (config->irno)
-		sc->irqInfo.name = config->irno;
+		sc->name = config->irno;
 	else
-		sc->irqInfo.name = 10;
+		sc->name = 10;
 
 	if (config->port)
 		sc->ep_io_addr = config->port;
@@ -1046,13 +981,13 @@ static int ep_isa_attach( struct isa_device *is )
 
     irq = is->id_irq;
 	/* update the interrupt line number to registered with kernel */
-	sc->irqInfo.name = irq;
+	  sc->name = irq;
 
     GO_WINDOW( 0 );
     SET_IRQ( BASE, irq );
 
     printf( "3C509: I/O=0x%x, IRQ=%d, CONNECTOR=%s, ",
-	    sc->ep_io_addr, sc->irqInfo.name,ep_conn_type[ sc->ep_connector ] );
+	    sc->ep_io_addr, (int)sc->name,ep_conn_type[ sc->ep_connector ] );
 
     ep_attach( sc );
     return 1;
diff --git a/c/src/lib/libbsp/i386/pc386/clock/ckinit.c b/c/src/lib/libbsp/i386/pc386/clock/ckinit.c
index 37b0408..76024e8 100644
--- a/c/src/lib/libbsp/i386/pc386/clock/ckinit.c
+++ b/c/src/lib/libbsp/i386/pc386/clock/ckinit.c
@@ -27,6 +27,7 @@
 #include <bsp/irq.h>
 #include <bspopts.h>
 #include <libcpu/cpuModel.h>
+#include <assert.h>
 
 #define CLOCK_VECTOR 0
 
@@ -36,15 +37,12 @@ uint32_t pc386_clock_click_count;
 
 /* forward declaration */
 void Clock_isr(void *param);
-void Clock_driver_support_at_tick_tsc(void);
-void Clock_driver_support_at_tick_empty(void);
-uint32_t bsp_clock_nanoseconds_since_last_tick_tsc(void);
-uint32_t bsp_clock_nanoseconds_since_last_tick_i8254(void);
-void Clock_isr_handler(rtems_irq_hdl_param param);
-int clockIsOn(const rtems_irq_connect_data* unused);
-void clockOff(const rtems_irq_connect_data* unused);
-void Clock_driver_install_handler(void);
-void Clock_driver_support_initialize_hardware(void);
+static void Clock_driver_support_at_tick_empty(void);
+static void clockOff(void);
+static void Clock_driver_support_at_tick_tsc(void);
+static uint32_t bsp_clock_nanoseconds_since_last_tick_tsc(void);
+static uint32_t bsp_clock_nanoseconds_since_last_tick_i8254(void);
+static void Clock_isr_handler(void *param);
 
 /*
  * Roughly the number of cycles per tick and per nanosecond. Note that these
@@ -83,7 +81,7 @@ uint32_t (*Clock_driver_nanoseconds_since_last_tick)(void) = NULL;
 /*
  *  What do we do at each clock tick?
  */
-void Clock_driver_support_at_tick_tsc(void)
+static void Clock_driver_support_at_tick_tsc(void)
 {
 #ifdef CLOCK_DRIVER_ISRS_PER_TICK
   /*
@@ -99,7 +97,7 @@ void Clock_driver_support_at_tick_tsc(void)
 #endif
 }
 
-void Clock_driver_support_at_tick_empty(void)
+static void Clock_driver_support_at_tick_empty(void)
 {
 }
 
@@ -113,7 +111,7 @@ extern volatile uint32_t Clock_driver_isrs;
 /*
  * Get nanoseconds using Pentium-compatible TSC register
  */
-uint32_t bsp_clock_nanoseconds_since_last_tick_tsc(void)
+static uint32_t bsp_clock_nanoseconds_since_last_tick_tsc(void)
 {
   uint64_t                 diff_nsec;
 
@@ -140,7 +138,7 @@ uint32_t bsp_clock_nanoseconds_since_last_tick_tsc(void)
 /*
  * Get nanoseconds using 8254 timer chip
  */
-uint32_t bsp_clock_nanoseconds_since_last_tick_i8254(void)
+static uint32_t bsp_clock_nanoseconds_since_last_tick_i8254(void)
 {
   uint32_t                 usecs, clicks, isrs;
   uint32_t                 usecs1, usecs2;
@@ -232,9 +230,7 @@ static void calibrate_tsc(void)
   pc586_tsc_per_tick /= rtems_clock_get_ticks_per_second();
 }
 
-static void clockOn(
-  const rtems_irq_connect_data* unused
-)
+static void clockOn(void)
 {
   pc386_isrs_per_tick        = 1;
   pc386_microseconds_per_isr = rtems_configuration_get_microseconds_per_tick();
@@ -267,7 +263,7 @@ static void clockOn(
     calibrate_tsc();
 }
 
-void clockOff(const rtems_irq_connect_data* unused)
+static void clockOff(void)
 {
   /* reset timer mode to standard (BIOS) value */
   outport_byte(TIMER_MODE, TIMER_SEL0 | TIMER_16BIT | TIMER_RATEGEN);
@@ -275,35 +271,27 @@ void clockOff(const rtems_irq_connect_data* unused)
   outport_byte(TIMER_CNTR0, 0);
 } /* Clock_exit */
 
-int clockIsOn(const rtems_irq_connect_data* unused)
-{
-  return ((i8259s_cache & 0x1) == 0);
-}
 
 bool Clock_isr_enabled = false;
-void Clock_isr_handler(
-  rtems_irq_hdl_param param 
-)
+static void Clock_isr_handler(void *param)
 {
   if ( Clock_isr_enabled )
     Clock_isr( param );
 }
 
-static rtems_irq_connect_data clockIrqData = {
-  BSP_PERIODIC_TIMER,
-  Clock_isr_handler,
-  0,
-  clockOn,
-  clockOff,
-  clockIsOn
-};
-
 void Clock_driver_install_handler(void)
 {
-  if (!BSP_install_rtems_irq_handler (&clockIrqData)) {
-    printk("Unable to install system clock ISR handler\n");
-    rtems_fatal_error_occurred(1);
-  }
+  rtems_status_code status;
+
+  status = rtems_interrupt_handler_install(
+    BSP_PERIODIC_TIMER,
+    "ckinit",
+    RTEMS_INTERRUPT_UNIQUE,
+    Clock_isr_handler,
+    NULL
+  );
+  assert(status == RTEMS_SUCCESSFUL);
+  clockOn();
 }
 
 void Clock_driver_support_initialize_hardware(void)
@@ -349,7 +337,14 @@ void Clock_driver_support_initialize_hardware(void)
 
 #define Clock_driver_support_shutdown_hardware() \
   do { \
-    BSP_remove_rtems_irq_handler (&clockIrqData); \
+    rtems_status_code status; \
+    clockOff(); \
+    status = rtems_interrupt_handler_remove(  \
+      BSP_PERIODIC_TIMER, \
+      Clock_isr_handler,  \
+      NULL  \
+    );  \
+    assert(status == RTEMS_SUCCESSFUL); \
   } while (0)
 
 #include "../../../shared/clockdrv_shell.h"
diff --git a/c/src/lib/libbsp/i386/pc386/console/ps2_mouse.c b/c/src/lib/libbsp/i386/pc386/console/ps2_mouse.c
index d0af6b9..9112552 100644
--- a/c/src/lib/libbsp/i386/pc386/console/ps2_mouse.c
+++ b/c/src/lib/libbsp/i386/pc386/console/ps2_mouse.c
@@ -17,6 +17,7 @@
 #include <string.h>
 #include <errno.h>
 #include <sys/types.h>
+#include <assert.h>
 
 #include <bsp.h>
 #include <bsp/irq.h>
@@ -29,6 +30,7 @@
 #define  INITIALIZE_MOUSE
 /* Some configuration switches are present in the include file... */
 #include "ps2_mouse.h"
+#include "ps2_drv.h"
 
 static void kbd_write_command_w(int data);
 #if 0
@@ -36,6 +38,7 @@ static void kbd_write_output_w(int data);
 #endif
 
 static unsigned char handle_kbd_event(void);
+static void ps2_set_driver_handler(int port, mouse_parser_enqueue_handler handler);
 
 /* used only by send_data - set by keyboard_interrupt */
 static volatile unsigned char reply_expected = 0;
@@ -56,14 +59,14 @@ static unsigned char mouse_reply_expected = 0;
 #define AUX_INTS_ON  (KBD_MODE_KCC | KBD_MODE_SYS | KBD_MODE_MOUSE_INT | KBD_MODE_KBD_INT)
 #define MAX_RETRIES	60		/* some aux operations take long time*/
 
-static void ps2_mouse_interrupt(rtems_irq_hdl_param);
+static void ps2_mouse_interrupt(void *);
 static mouse_parser_enqueue_handler driver_input_handler_ps2 = NULL;
 
 /*
  * This routine sets the handler to handle the characters received
  * from the serial port.
  */
-void ps2_set_driver_handler(
+static void ps2_set_driver_handler(
   int                          port,
   mouse_parser_enqueue_handler handler
 )
@@ -78,30 +81,6 @@ static void mdelay( unsigned long t )
 
 static void*    termios_ttyp_paux = NULL;
 
-static void
-isr_on(const rtems_irq_connect_data *unused)
-{
-  return;
-}
-
-static void
-isr_off(const rtems_irq_connect_data *unused)
-{
-  return;
-}
-
-static int isr_is_on(const rtems_irq_connect_data *irq)
-{
-  return BSP_irq_enabled_at_i8259s( irq->name );
-}
-
-static rtems_irq_connect_data ps2_isr_data = { AUX_IRQ,
-                                               ps2_mouse_interrupt,
-                                               0,
-                                               isr_on,
-                                               isr_off,
-                                               isr_is_on };
-
 /*
  * Wait for keyboard controller input buffer to drain.
  *
@@ -223,7 +202,7 @@ static unsigned char handle_kbd_event(void)
   return status;
 }
 
-static void ps2_mouse_interrupt(rtems_irq_hdl_param ignored)
+static void ps2_mouse_interrupt(void * unused)
 {
   handle_kbd_event();
 }
@@ -323,11 +302,17 @@ static int queue_empty(void)
 
 static int release_aux(void)
 {
+  rtems_status_code status;
   if (--aux_count)
     return 0;
   kbd_write_cmd(AUX_INTS_OFF);			    /* Disable controller ints */
   kbd_write_command_w(KBD_CCMD_MOUSE_DISABLE);
-  BSP_remove_rtems_irq_handler( &ps2_isr_data );
+  status = rtems_interrupt_handler_remove(
+    AUX_IRQ,
+    ps2_mouse_interrupt,
+    NULL
+  );
+  assert(status == RTEMS_SUCCESSFUL);
   return 0;
 }
 
@@ -338,18 +323,21 @@ static int release_aux(void)
 
 static int open_aux(void)
 {
-  int status;
+  rtems_status_code status;
 
   if (aux_count++) {
     return 0;
   }
   queue->head = queue->tail = 0;		/* Flush input queue */
 
-  status = BSP_install_rtems_irq_handler( &ps2_isr_data );
-  if( !status ) {
-    printk("Error installing ps2-mouse interrupt handler!\n" );
-    rtems_fatal_error_occurred( status );
-  }
+  status = rtems_interrupt_handler_install(
+    AUX_IRQ,
+    "ps2_mouse",
+    RTEMS_INTERRUPT_UNIQUE,
+    ps2_mouse_interrupt,
+    NULL
+  );
+  assert(status == RTEMS_SUCCESSFUL);
 
   kbd_write_command_w(KBD_CCMD_MOUSE_ENABLE); /* Enable the auxiliary port on
                                                  controller. */
@@ -429,7 +417,7 @@ static int psaux_init( void )
 /*
  * paux device driver INITIALIZE entry point.
  */
-rtems_device_driver paux_initialize(  
+rtems_device_driver paux_initialize(
   rtems_device_major_number major,
   rtems_device_minor_number minor,
   void                      *arg)
diff --git a/c/src/lib/libbsp/i386/pc386/console/vgacons.c b/c/src/lib/libbsp/i386/pc386/console/vgacons.c
index d1143da..91d88ee 100644
--- a/c/src/lib/libbsp/i386/pc386/console/vgacons.c
+++ b/c/src/lib/libbsp/i386/pc386/console/vgacons.c
@@ -1,5 +1,5 @@
 /*
- *  This file contains the termios TTY driver for the i386 
+ *  This file contains the termios TTY driver for the i386
  *  vga.
  *
  *  COPYRIGHT (c) 1989-2011.
@@ -20,23 +20,11 @@
 #include <bsp/irq.h>
 #include <bsp.h>
 #include <crt.h>
+#include <assert.h>
+#include "keyboard.h"
 
 #define VGACONS_STATIC static
 
-static int isr_is_on(const rtems_irq_connect_data *irq)
-{
-  return BSP_irq_enabled_at_i8259s(irq->name);
-}
-
-static rtems_irq_connect_data keyboard_isr_data = {
-  BSP_KEYBOARD,
-  keyboard_interrupt,
-  0,
-  NULL,
-  NULL,
-  isr_is_on
-};
-
 /*
  *  vgacons_init
  *
@@ -44,7 +32,7 @@ static rtems_irq_connect_data keyboard_isr_data = {
  */
 VGACONS_STATIC void vgacons_init(int minor)
 {
-  /* 
+  /*
    * Note:  We do not initialize the KBD interface here since
    *        it was initialized regardless of whether the
    *        vga is available or not.  Therefore it is initialized
@@ -160,7 +148,7 @@ bool vgacons_probe(
   int minor
 )
 {
-  int         status;
+  rtems_status_code status;
   static bool firstTime = true;
 
   if ((*(unsigned char*) NB_MAX_ROW_ADDR == 0) &&
@@ -175,11 +163,14 @@ bool vgacons_probe(
    *  can be COM1 and you can still use the mouse/VGA for graphics.
    */
   if ( firstTime ) {
-    status = BSP_install_rtems_irq_handler(&keyboard_isr_data);
-    if (!status) {
-      printk("Error installing keyboard interrupt handler!\n");
-      rtems_fatal_error_occurred(status);
-    }
+    status = rtems_interrupt_handler_install(
+      BSP_KEYBOARD,
+      "vgacons",
+      RTEMS_INTERRUPT_UNIQUE,
+      keyboard_interrupt,
+      NULL
+    );
+    assert(status == RTEMS_SUCCESSFUL);
   }
   firstTime = false;
 
diff --git a/c/src/lib/libbsp/i386/pc386/include/bsp.h b/c/src/lib/libbsp/i386/pc386/include/bsp.h
index 5e6dcc6..625d4ce 100644
--- a/c/src/lib/libbsp/i386/pc386/include/bsp.h
+++ b/c/src/lib/libbsp/i386/pc386/include/bsp.h
@@ -80,6 +80,10 @@ extern int rtems_dec21140_driver_attach(struct rtems_bsdnet_ifconfig *, int);
 #define BSP_DEC21140_NETWORK_DRIVER_NAME    "dc1"
 #define BSP_DEC21140_NETWORK_DRIVER_ATTACH  rtems_dec21140_driver_attach
 
+extern int rtems_3c509_driver_attach(struct rtems_bsdnet_ifconfig *config);
+#define BSP_3C509_NETWORK_DRIVER_NAME    "3c1"
+#define BSP_3C509_NETWORK_DRIVER_ATTACH  rtems_3c509_driver_attach
+
 #ifndef RTEMS_BSP_NETWORK_DRIVER_NAME
 #define RTEMS_BSP_NETWORK_DRIVER_NAME   BSP_DEC21140_NETWORK_DRIVER_NAME
 #endif
@@ -134,7 +138,7 @@ extern int rtems_dec21140_driver_attach(struct rtems_bsdnet_ifconfig *, int);
 
 /*-------------------------------------------------------------------------+
 | Console Defines
-|      WARNING: These Values MUST match the order in 
+|      WARNING: These Values MUST match the order in
 |               Console_Configuration_Ports
 +--------------------------------------------------------------------------*/
 #define    BSP_CONSOLE_VGA            0
@@ -182,6 +186,10 @@ char          _IBMPC_inch_sleep (void);  /* from 'inch.c'   */
 
 void Wait_X_ms(unsigned int timeToWait); /* from 'timer.c'  */
 
+void Clock_driver_install_handler(void); /* from 'ckinit.c'  */
+void Clock_driver_support_initialize_hardware(void); /* from 'ckinit.c'  */
+size_t read_aux(char * buffer, size_t count); /* from 'ps2_mouse.c'  */
+
 /* Definitions for BSPConsolePort */
 #define BSP_CONSOLE_PORT_CONSOLE (-1)
 #define BSP_CONSOLE_PORT_COM1    (BSP_UART_COM1)
diff --git a/c/src/lib/libbsp/i386/pc386/wd8003/wd8003.c b/c/src/lib/libbsp/i386/pc386/wd8003/wd8003.c
index d26464c..64b7fda 100644
--- a/c/src/lib/libbsp/i386/pc386/wd8003/wd8003.c
+++ b/c/src/lib/libbsp/i386/pc386/wd8003/wd8003.c
@@ -18,6 +18,7 @@
 #include <errno.h>
 #include <rtems/error.h>
 #include <rtems/rtems_bsdnet.h>
+#include <assert.h>
 
 #include <sys/param.h>
 #include <sys/mbuf.h>
@@ -73,7 +74,6 @@
  */
 struct wd_softc {
   struct arpcom			arpcom;
-  rtems_irq_connect_data	irqInfo;
   struct mbuf			**rxMbuf;
   struct mbuf			**txMbuf;
   int				acceptBroadcast;
@@ -84,6 +84,7 @@ struct wd_softc {
   int				txBdActiveCount;
   rtems_id			rxDaemonTid;
   rtems_id			txDaemonTid;
+  rtems_vector_number name;
 
   unsigned int 			port;
   unsigned char			*base;
@@ -127,7 +128,7 @@ static struct wd_softc wd_softc[NWDDRIVER];
  * WD interrupt handler
  */
 static void
-wd8003Enet_interrupt_handler (void *unused)
+wd8003Enet_interrupt_handler (void * unused)
 {
   unsigned int tport;
   unsigned char status, status2;
@@ -169,19 +170,6 @@ wd8003Enet_interrupt_handler (void *unused)
 
 }
 
-static void nopOn(const rtems_irq_connect_data* notUsed)
-{
-  /*
-   * code should be moved from wd8003Enet_initialize_hardware
-   * to this location
-   */
-}
-
-static int wdIsOn(const rtems_irq_connect_data* irq)
-{
-  return BSP_irq_enabled_at_i8259s (irq->name);
-}
-
 /*
  * Initialize the ethernet hardware
  */
@@ -191,7 +179,7 @@ wd8003Enet_initialize_hardware (struct wd_softc *sc)
   int  i1, ultra;
   char cc1, cc2;
   unsigned char  temp;
-  rtems_status_code st;
+  rtems_status_code status;
   unsigned int tport;
   unsigned char *hwaddr;
 
@@ -257,15 +245,15 @@ wd8003Enet_initialize_hardware (struct wd_softc *sc)
   /*
    * Set up interrupts
    */
-  sc->irqInfo.hdl = wd8003Enet_interrupt_handler;
-  sc->irqInfo.on  = nopOn;
-  sc->irqInfo.off = nopOn;
-  sc->irqInfo.isOn = wdIsOn;
-
-  st = BSP_install_rtems_irq_handler (&sc->irqInfo);
-  if (!st)
-    rtems_panic ("Can't attach WD interrupt handler for irq %d\n",
-		  sc->irqInfo.name);
+
+  status = rtems_interrupt_handler_install(
+    sc->name,
+    "wd8003",
+    RTEMS_INTERRUPT_UNIQUE,
+    wd8003Enet_interrupt_handler,
+    NULL
+  );
+  assert(status == RTEMS_SUCCESSFUL);
 }
 
 static void
@@ -397,7 +385,7 @@ sendpacket (struct ifnet *ifp, struct mbuf *m)
 /*
  * Driver transmit daemon
  */
-void
+static void
 wd_txDaemon (void *arg)
 {
 	struct wd_softc *sc = (struct wd_softc *)arg;
@@ -607,9 +595,9 @@ rtems_wd_driver_attach (struct rtems_bsdnet_ifconfig *config, int attach)
 		mtu = ETHERMTU;
 
 	if (config->irno)
-		sc->irqInfo.name = config->irno;
+		sc->name = config->irno;
 	else
-		sc->irqInfo.name = 5;
+		sc->name = 5;
 
 	if (config->port)
 		sc->port = config->port;
diff --git a/c/src/lib/libbsp/i386/shared/comm/tty_drv.c b/c/src/lib/libbsp/i386/shared/comm/tty_drv.c
index aafb02a..16a40df 100644
--- a/c/src/lib/libbsp/i386/shared/comm/tty_drv.c
+++ b/c/src/lib/libbsp/i386/shared/comm/tty_drv.c
@@ -27,63 +27,19 @@
 #include <termios.h>
 #include <uart.h>
 #include <libcpu/cpuModel.h>
+#include "tty_drv.h"
 
 int BSP_poll_read(int);
 
 /* Internal routines */
 static int tty1_conSetAttr( int minor, const struct termios *t);
 static int tty2_conSetAttr( int minor, const struct termios *t);
-static void isr_on(const rtems_irq_connect_data *);
-static void isr_off(const rtems_irq_connect_data *);
-static int  isr_is_on(const rtems_irq_connect_data *);
 
 extern BSP_polling_getchar_function_type BSP_poll_char;
 extern int BSPConsolePort;
 extern void rtems_set_waiting_id_comx( int port,  rtems_id id, rtems_event_set event );
 
 /*
- * Interrupt structure for tty1
- */
-static rtems_irq_connect_data tty1_isr_data =
-{
-  BSP_UART_COM1_IRQ,
-  BSP_uart_termios_isr_com1,
-  0,
-  isr_on,
-  isr_off,
-  isr_is_on};
-
-/*
- * Interrupt structure for tty2
- */
-static rtems_irq_connect_data tty2_isr_data =
-{
-  BSP_UART_COM2_IRQ,
-  BSP_uart_termios_isr_com2,
-  0,
-  isr_on,
-  isr_off,
-  isr_is_on};
-
-static void
-isr_on(const rtems_irq_connect_data *unused)
-{
-  return;
-}
-
-static void
-isr_off(const rtems_irq_connect_data *unused)
-{
-  return;
-}
-
-static int
-isr_is_on(const rtems_irq_connect_data *irq)
-{
-  return BSP_irq_enabled_at_i8259s(irq->name);
-}
-
-/*
  *  TTYS1 - device driver INITIALIZE entry point.
  */
 rtems_device_driver
@@ -111,12 +67,14 @@ tty1_initialize(rtems_device_major_number major,
    */
   /* 9600-8-N-1, without hardware flow control */
   BSP_uart_init( BSP_UART_COM1, 9600, CHR_8_BITS, 0, 0, 0 );
-  status = BSP_install_rtems_irq_handler( &tty1_isr_data );
-  if( !status )
-  {
-    printk("Error installing ttyS1 interrupt handler!\n");
-    rtems_fatal_error_occurred(status);
-  }
+  status = rtems_interrupt_handler_install(
+    BSP_UART_COM1_IRQ,
+    "tty_drv",
+    RTEMS_INTERRUPT_UNIQUE,
+    BSP_uart_termios_isr_com1,
+    NULL
+  );
+  assert(status == RTEMS_SUCCESSFUL);
   /*
    * Register the device
    */
@@ -132,7 +90,14 @@ tty1_initialize(rtems_device_major_number major,
 
 static int tty1_last_close(int major, int minor, void *arg)
 {
-  BSP_remove_rtems_irq_handler( &tty1_isr_data );
+  rtems_status_code status;
+
+  status = rtems_interrupt_handler_remove(
+    BSP_UART_COM1_IRQ,
+    BSP_uart_termios_isr_com1,
+    NULL
+  );
+  assert(status == RTEMS_SUCCESSFUL);
   return 0;
 }
 
@@ -339,12 +304,15 @@ tty2_initialize(rtems_device_major_number major,
    */
   /* 9600-8-N-1, without hardware flow control */
   BSP_uart_init( BSP_UART_COM2, 9600, CHR_8_BITS, 0, 0, 0);
-  status = BSP_install_rtems_irq_handler( &tty2_isr_data );
-  if( !status )
-  {
-    printk("Error installing serial console interrupt handler!\n");
-    rtems_fatal_error_occurred(status);
-  }
+  status = rtems_interrupt_handler_install(
+    BSP_UART_COM2_IRQ,
+    "tty_drv",
+    RTEMS_INTERRUPT_UNIQUE,
+    BSP_uart_termios_isr_com2,
+    NULL
+  );
+  assert(status == RTEMS_SUCCESSFUL);
+
   /*
    * Register the device
    */
@@ -360,7 +328,14 @@ tty2_initialize(rtems_device_major_number major,
 
 static int tty2_last_close(int major, int minor, void *arg)
 {
-  BSP_remove_rtems_irq_handler( &tty2_isr_data );
+  rtems_status_code status;
+
+  status = rtems_interrupt_handler_remove(
+    BSP_UART_COM2_IRQ,
+    BSP_uart_termios_isr_com2,
+    NULL
+  );
+  assert(status == RTEMS_SUCCESSFUL);
   return 0;
 }
 
diff --git a/c/src/lib/libbsp/i386/shared/smp/smp-imps.c b/c/src/lib/libbsp/i386/shared/smp/smp-imps.c
index 916379e..3e51f02 100644
--- a/c/src/lib/libbsp/i386/shared/smp/smp-imps.c
+++ b/c/src/lib/libbsp/i386/shared/smp/smp-imps.c
@@ -79,6 +79,7 @@
 #include <rtems/bspsmp.h>
 #include <rtems/bspIo.h>
 #include <libcpu/cpu.h>
+#include <assert.h>
 
 extern void _pc386_delay(void);
 
@@ -120,14 +121,14 @@ static void UDELAY(int x)
   while ( _i-- )
     _pc386_delay();
 }
- 
+
 #define READ_MSR_LO(_x) \
   (unsigned int)(read_msr(_x) & 0xffffffff)
 
 static inline unsigned long long read_msr(unsigned int msr)
 {
   unsigned long long value;
- 
+
   asm volatile("rdmsr" : "=A" (value) : "c" (msr));
   return value;
 }
@@ -385,7 +386,7 @@ imps_read_config_table(unsigned start, int count)
     case IMPS_BCT_PROCESSOR:
       if ( imps_num_cpus < rtems_configuration_get_maximum_processors() ) {
 	add_processor((imps_processor *)start);
-      } else 
+      } else
         imps_num_cpus++;
       start += 12;  /* 20 total */
       break;
@@ -751,22 +752,19 @@ rtems_isr ap_ipi_isr(
 
 #include <rtems/irq.h>
 
-static rtems_irq_connect_data apIPIIrqData = {
-  16,
-  (void *)ap_ipi_isr,
-  0,
-  NULL,            /* On */
-  NULL,            /* Off */
-  NULL,            /* IsOn */
-};
-
 extern void bsp_reset(void);
 void ipi_install_irq(void)
 {
-  if (!BSP_install_rtems_irq_handler (&apIPIIrqData)) {
-    printk("Unable to initialize IPI\n");
-    bsp_reset();
-  }
+  rtems_status_code status;
+
+  status = rtems_interrupt_handler_install(
+    16,
+    "smp-imps",
+    RTEMS_INTERRUPT_UNIQUE,
+    ap_ipi_isr,
+    NULL
+  );
+  assert(status == RTEMS_SUCCESSFUL);
 }
 
 #ifdef __SSE__
-- 
1.7.11.7




More information about the devel mailing list