[PATCH] Updated legacy code in ata & dec21140

Vipul Nayyar nayyar_vipul at yahoo.com
Wed Jul 31 15:53:46 UTC 2013


---
 c/src/libchip/ide/ata.c          | 77 ++++++++++++----------------------------
 c/src/libchip/network/dec21140.c | 52 ++++++++++-----------------
 2 files changed, 40 insertions(+), 89 deletions(-)

diff --git a/c/src/libchip/ide/ata.c b/c/src/libchip/ide/ata.c
index 8229714..f48205d 100644
--- a/c/src/libchip/ide/ata.c
+++ b/c/src/libchip/ide/ata.c
@@ -35,6 +35,7 @@ bool ata_trace;
 
 #if CPU_SIMPLE_VECTORED_INTERRUPTS != TRUE
 #include <rtems/irq.h>
+#include <rtems/irq-extension.h>
 #define ATA_IRQ_CHAIN_MAX_CNT 4 /* support up to 4 ATA devices */
 typedef struct {
   rtems_irq_number name;
@@ -610,7 +611,7 @@ static rtems_isr ata_interrupt_handler(rtems_vector_number vec)
     }
 }
 #else
-static void ata_interrupt_handler(rtems_irq_hdl_param handle)
+static void ata_interrupt_handler(void * handle)
 {
   int ata_irq_chain_index = (int) handle;
     rtems_chain_node *the_node =
@@ -637,7 +638,7 @@ static void ata_interrupt_handler(rtems_irq_hdl_param handle)
     }
 }
 
-static void ata_interrupt_on(const rtems_irq_connect_data *ptr)
+static void ata_interrupt_on(void)
   {
 
     /* enable ATA device interrupt */
@@ -647,42 +648,6 @@ static void ata_interrupt_on(const rtems_irq_connect_data *ptr)
                                  );
   }
 
-
-static void ata_interrupt_off(const rtems_irq_connect_data *ptr)
-  {
-
-    /* disable ATA device interrupt */
-    ide_controller_write_register(0,
-                                  IDE_REGISTER_DEVICE_CONTROL_OFFSET,
-                                  IDE_REGISTER_DEVICE_CONTROL_nIEN
-                                 );
-  }
-
-
-static int ata_interrupt_isOn(const rtems_irq_connect_data *ptr)
-  {
-  uint16_t byte; /* emphasize that only 8 low bits is meaningful */
-
-    /* return int. status od ATA device */
-    ide_controller_read_register(0,
-                                IDE_REGISTER_DEVICE_CONTROL_OFFSET,
-                                &byte
-                                );
-
-    return !(byte & IDE_REGISTER_DEVICE_CONTROL_nIEN);
-  }
-
-
-static rtems_irq_connect_data ata_irq_data =
-  {
-
-    0, /* filled out before use... */
-    ata_interrupt_handler,/* filled out before use... */
-    NULL,
-    ata_interrupt_on,
-    ata_interrupt_off,
-    ata_interrupt_isOn
-  };
 #endif
 
 /* ata_pio_in_protocol --
@@ -1250,23 +1215,25 @@ rtems_ata_initialize(rtems_device_major_number major,
 	      /*
 	       * no match found, try to use new channel entry
 	       */
-	      if (ata_irq_chain_cnt < ATA_IRQ_CHAIN_MAX_CNT) {
-		ata_irq_chain_use = ata_irq_chain_cnt++;
-
-		ata_irq_chain[ata_irq_chain_use].name =
-		  IDE_Controller_Table[ctrl_minor].int_vec;
-		ata_irq_data.name   =
-		  IDE_Controller_Table[ctrl_minor].int_vec;
-		ata_irq_data.hdl    = ata_interrupt_handler;
-		ata_irq_data.handle = (rtems_irq_hdl_param) ctrl_minor;
-
-		status = ((0 == BSP_install_rtems_irq_handler(&ata_irq_data))
-			  ? RTEMS_INVALID_NUMBER
-			  : RTEMS_SUCCESSFUL);
-	      }
-	      else {
-		status = RTEMS_TOO_MANY;
-	      }
+	        if (ata_irq_chain_cnt < ATA_IRQ_CHAIN_MAX_CNT) {
+		        ata_irq_chain_use = ata_irq_chain_cnt++;
+
+		        ata_irq_chain[ata_irq_chain_use].name =
+		          IDE_Controller_Table[ctrl_minor].int_vec;
+
+                status = rtems_interrupt_handler_install(
+                    IDE_Controller_Table[ctrl_minor].int_vec,
+                    "ATA",
+                    RTEMS_INTERRUPT_UNIQUE,
+                    ata_interrupt_handler,
+                    (void *)ctrl_minor
+                );
+                assert(status == RTEMS_SUCCESSFUL);
+                ata_interrupt_on();
+            }
+	        else {
+		      status = RTEMS_TOO_MANY;
+	        }
 	    }
 #endif
             if (status != RTEMS_SUCCESSFUL)
diff --git a/c/src/libchip/network/dec21140.c b/c/src/libchip/network/dec21140.c
index 997b34c..bcf7180 100644
--- a/c/src/libchip/network/dec21140.c
+++ b/c/src/libchip/network/dec21140.c
@@ -74,6 +74,7 @@
 #include <stdarg.h>
 #include <string.h>
 #include <errno.h>
+#include <assert.h>
 #include <rtems/error.h>
 #include <rtems/bspIo.h>
 #include <rtems/rtems_bsdnet.h>
@@ -244,7 +245,7 @@ struct dec21140_softc {
 
       struct arpcom             arpcom;
 
-      rtems_irq_connect_data    irqInfo;
+      rtems_vector_number       name;
       rtems_event_set           ioevent;
 
       int                       numRxbuffers, numTxbuffers;
@@ -340,16 +341,6 @@ static int eeget16(volatile uint32_t *ioaddr, int location)
    return ( ((retval<<8)&0xff00) | ((retval>>8)&0xff) );
 }
 
-static void no_op(const rtems_irq_connect_data* irq)
-{
-   return;
-}
-
-static int dec21140IsOn(const rtems_irq_connect_data* irq)
-{
-  return BSP_irq_enabled_at_i8259s (irq->name);
-}
-
 /*
  * DEC21140 interrupt handler
  */
@@ -378,7 +369,7 @@ dec21140Enet_interrupt_handler ( struct dec21140_softc *sc )
 }
 
 static rtems_isr
-dec21140Enet_interrupt_handler_entry(void)
+dec21140Enet_interrupt_handler_entry(void * arg)
 {
    int i;
 
@@ -399,7 +390,8 @@ dec21140Enet_interrupt_handler_entry(void)
 static void
 dec21140Enet_initialize_hardware (struct dec21140_softc *sc)
 {
-   int i,st;
+   int i;
+   rtems_status_code status;
    volatile uint32_t      *tbase;
    volatile unsigned char *cp, *setup_frm, *eaddrs;
    volatile unsigned char *buffer;
@@ -412,7 +404,7 @@ dec21140Enet_initialize_hardware (struct dec21140_softc *sc)
           sc->arpcom.ac_enaddr[2], sc->arpcom.ac_enaddr[3],
           sc->arpcom.ac_enaddr[4], sc->arpcom.ac_enaddr[5],
           sc->arpcom.ac_if.if_name, sc->arpcom.ac_if.if_unit,
-          sc->port, (unsigned) sc->base, sc->irqInfo.name );
+          sc->port, (unsigned) sc->base, sc->name );
 #endif
 
    tbase = sc->base;
@@ -536,22 +528,18 @@ dec21140Enet_initialize_hardware (struct dec21140_softc *sc)
 
    sc->TxMD = rmd+1;
 
-   sc->irqInfo.hdl  = (rtems_irq_hdl)dec21140Enet_interrupt_handler_entry;
-   sc->irqInfo.on   = no_op;
-   sc->irqInfo.off  = no_op;
-   sc->irqInfo.isOn = dec21140IsOn;
-
 #ifdef DEC_DEBUG
-   printk( "dec2114x: Installing IRQ %d\n", sc->irqInfo.name );
-#endif
-#ifdef BSP_SHARED_HANDLER_SUPPORT
-   st = BSP_install_rtems_shared_irq_handler( &sc->irqInfo );
-#else
-   st = BSP_install_rtems_irq_handler( &sc->irqInfo );
+   printk( "dec2114x: Installing IRQ %d\n", sc->name );
 #endif
 
-   if (!st)
-      rtems_panic ("dec2114x : Interrupt name %d already in use\n", sc->irqInfo.name );
+   status = rtems_interrupt_handler_install(
+    sc->name,
+    "DEC21140",
+    RTEMS_INTERRUPT_UNIQUE,
+    dec21140Enet_interrupt_handler_entry,
+    NULL
+   );
+   assert(status == RTEMS_SUCCESSFUL);
 }
 
 static void
@@ -668,7 +656,7 @@ sendpacket (struct ifnet *ifp, struct mbuf *m)
 /*
  * Driver transmit daemon
  */
-void
+static void
 dec21140_txDaemon (void *arg)
 {
    struct dec21140_softc *sc;
@@ -735,10 +723,7 @@ dec21140_init (void *arg)
    /*
     * Set up DEC21140 hardware if its not already been done
     */
-   if( !sc->irqInfo.hdl )
-   {
-      dec21140Enet_initialize_hardware (sc);
-   }
+   dec21140Enet_initialize_hardware (sc);
 
    /*
     * Enable RX and TX
@@ -1020,8 +1005,7 @@ rtems_dec21140_driver_attach (struct rtems_bsdnet_ifconfig *config, int attach)
    ** Store the interrupt name, we'll use it later when we initialize
    ** the board.
    */
-   memset(&sc->irqInfo,0,sizeof(rtems_irq_connect_data));
-   sc->irqInfo.name = cvalue;
+   sc->name = cvalue;
 
 
 #ifdef DEC_DEBUG
-- 
1.7.11.7




More information about the devel mailing list