[PATCH 27.0 3/3] GRETH: use shared-irq service instead of BSP specific set_vec()

Daniel Hellstrom daniel at gaisler.com
Thu Apr 5 15:23:17 UTC 2012


The ISR code is updated to use argument instead of global greth
structure, now that the greth private is available in the ISR.

The shared-irq routines will unmask the IRQ, so the forced LEON3
BSP unmask/clear IRQ is removed.

Signed-off-by: Daniel Hellstrom <daniel at gaisler.com>
---
 .../lib/libbsp/sparc/leon3/leon_greth/leon_greth.c |    7 +---
 c/src/libchip/network/greth.c                      |   36 ++++++++------------
 c/src/libchip/network/greth.h                      |    2 +-
 3 files changed, 17 insertions(+), 28 deletions(-)

diff --git a/c/src/lib/libbsp/sparc/leon3/leon_greth/leon_greth.c b/c/src/lib/libbsp/sparc/leon3/leon_greth/leon_greth.c
index dd301d7..5641575 100644
--- a/c/src/lib/libbsp/sparc/leon3/leon_greth/leon_greth.c
+++ b/c/src/lib/libbsp/sparc/leon3/leon_greth/leon_greth.c
@@ -48,13 +48,10 @@ int rtems_leon_greth_driver_attach(
     *(volatile int *) base_addr = GRETH_CTRL_RST;
     *(volatile int *) base_addr = 0;
     leon_greth_configuration.base_address = base_addr;
-    leon_greth_configuration.vector = eth_irq + 0x10;
+    leon_greth_configuration.vector = eth_irq; /* on LEON vector is IRQ no. */
     leon_greth_configuration.txd_count = TDA_COUNT;
     leon_greth_configuration.rxd_count = RDA_COUNT;
-    if (rtems_greth_driver_attach( config, &leon_greth_configuration )) {
-      LEON_Clear_interrupt(eth_irq);
-      LEON_Unmask_interrupt(eth_irq);
-    }
+    rtems_greth_driver_attach(config, &leon_greth_configuration);
   }
   return 0;
 }
diff --git a/c/src/libchip/network/greth.c b/c/src/libchip/network/greth.c
index c8b87ea..9682fa3 100644
--- a/c/src/libchip/network/greth.c
+++ b/c/src/libchip/network/greth.c
@@ -42,15 +42,6 @@
 #undef free
 #endif
 
-#if defined(__m68k__)
-extern m68k_isr_entry set_vector( rtems_isr_entry, rtems_vector_number, int );
-#elif defined(__lm32__)
-extern lm32_isr_entry set_vector( rtems_isr_entry, rtems_vector_number, int );
-#else
-extern rtems_isr_entry set_vector( rtems_isr_entry, rtems_vector_number, int );
-#endif
-
-
 /* #define GRETH_DEBUG */
 
 #ifdef CPU_U32_FIX
@@ -189,22 +180,22 @@ static char *almalloc(int sz)
 
 /* GRETH interrupt handler */
 
-rtems_isr
-greth_interrupt_handler (rtems_vector_number v)
+void greth_interrupt_handler (void *arg)
 {
         uint32_t status;
         uint32_t ctrl;
         rtems_event_set events = 0;
+        struct greth_softc *greth = arg;
 
         /* read and clear interrupt cause */
-        status = greth.regs->status;
-        greth.regs->status = status;
-        ctrl = greth.regs->ctrl;
+        status = greth->regs->status;
+        greth->regs->status = status;
+        ctrl = greth->regs->ctrl;
 
         /* Frame received? */
         if ((ctrl & GRETH_CTRL_RXIRQ) && (status & (GRETH_STATUS_RXERR | GRETH_STATUS_RXIRQ)))
         {
-                greth.rxInterrupts++;
+                greth->rxInterrupts++;
                 /* Stop RX-Error and RX-Packet interrupts */
                 ctrl &= ~GRETH_CTRL_RXIRQ;
                 events |= INTERRUPT_EVENT;
@@ -212,17 +203,17 @@ greth_interrupt_handler (rtems_vector_number v)
         
         if ( (ctrl & GRETH_CTRL_TXIRQ) && (status & (GRETH_STATUS_TXERR | GRETH_STATUS_TXIRQ)) )
         {
-                greth.txInterrupts++;
+                greth->txInterrupts++;
                 ctrl &= ~GRETH_CTRL_TXIRQ;
                 events |= GRETH_TX_WAIT_EVENT;
         }
-        
+
         /* Clear interrupt sources */
-        greth.regs->ctrl = ctrl;
-        
+        greth->regs->ctrl = ctrl;
+
         /* Send the event(s) */
         if ( events )
-            rtems_event_send (greth.daemonTid, events);
+                rtems_event_send (greth->daemonTid, events);
 }
 
 static uint32_t read_mii(uint32_t phy_addr, uint32_t reg_addr)
@@ -485,8 +476,9 @@ auto_neg_done:
     /* clear all pending interrupts */
     regs->status = 0xffffffff;
     
-    /* install interrupt vector */
-    set_vector(greth_interrupt_handler, sc->vector, 1);
+    /* install interrupt handler */
+    rtems_interrupt_handler_install(sc->vector, "greth", RTEMS_INTERRUPT_SHARED,
+                                    greth_interrupt_handler, sc);
 
     regs->ctrl |= GRETH_CTRL_RXEN | (sc->fd << 4) | GRETH_CTRL_RXIRQ | (sc->sp << 7) | (sc->gb << 8);
 
diff --git a/c/src/libchip/network/greth.h b/c/src/libchip/network/greth.h
index 50ddd99..4a7447d 100644
--- a/c/src/libchip/network/greth.h
+++ b/c/src/libchip/network/greth.h
@@ -18,7 +18,7 @@
 
 typedef struct {
   void                 *base_address;
-  uint32_t              vector;
+  rtems_vector_number   vector;
   uint32_t              txd_count;
   uint32_t              rxd_count;
 } greth_configuration_t;
-- 
1.7.0.4




More information about the devel mailing list