summaryrefslogtreecommitdiff
path: root/nuttx/drivers/net/cs89x0.c
diff options
context:
space:
mode:
Diffstat (limited to 'nuttx/drivers/net/cs89x0.c')
-rw-r--r--nuttx/drivers/net/cs89x0.c450
1 files changed, 350 insertions, 100 deletions
diff --git a/nuttx/drivers/net/cs89x0.c b/nuttx/drivers/net/cs89x0.c
index f8d5ba58a..5fe8c8702 100644
--- a/nuttx/drivers/net/cs89x0.c
+++ b/nuttx/drivers/net/cs89x0.c
@@ -65,7 +65,7 @@
# define CONFIG_CS89x0_NINTERFACES 1
#endif
-/* TX poll deley = 1 seconds. CLK_TCK is the number of clock ticks per second */
+/* TX poll delay = 1 seconds. CLK_TCK is the number of clock ticks per second */
#define CS89x0_WDDELAY (1*CLK_TCK)
#define CS89x0_POLLHSEC (1*2)
@@ -76,37 +76,39 @@
/* This is a helper pointer for accessing the contents of the Ethernet header */
-#define BUF ((struct uip_eth_hdr *)cs89x0->sk_dev.d_buf)
+#define BUF ((struct uip_eth_hdr *)cs89x0->cs_dev.d_buf)
-/****************************************************************************
- * Private Types
- ****************************************************************************/
-
-/* The cs89x0_driver_s encapsulates all state information for a single hardware
- * interface
+/* If there is only one CS89x0 instance, then mapping the CS89x0 IRQ to
+ * a driver state instance is trivial.
*/
-struct cs89x0_driver_s
-{
- boolean sk_bifup; /* TRUE:ifup FALSE:ifdown */
- WDOG_ID sk_txpoll; /* TX poll timer */
- WDOG_ID sk_txtimeout; /* TX timeout timer */
-
- /* This holds the information visible to uIP/NuttX */
+#if CONFIG_CS89x0_NINTERFACES == 1
+# define cs89x0_mapirq(irq) g_cs89x0[0]
+#endif
- struct uip_driver_s sk_dev; /* Interface understood by uIP */
-};
+/****************************************************************************
+ * Private Types
+ ****************************************************************************/
/****************************************************************************
* Private Data
****************************************************************************/
-static struct cs89x0_driver_s g_cs89x0[CONFIG_CS89x0_NINTERFACES];
+static FAR struct cs89x0_driver_s *g_cs89x0[CONFIG_CS89x0_NINTERFACES];
/****************************************************************************
* Private Function Prototypes
****************************************************************************/
+/* CS89x0 register access */
+
+static uint16 cs89x0_getreg(struct cs89x0_driver_s *cs89x0, int offset);
+static void cs89x0_putreg(struct cs89x0_driver_s *cs89x0, int offset,
+ uint16 value);
+static uint16 cs89x0_getppreg(struct cs89x0_driver_s *cs89x0, int addr);
+static void cs89x0_putppreg(struct cs89x0_driver_s *cs89x0, int addr,
+ uint16 value);
+
/* Common TX logic */
static int cs89x0_transmit(struct cs89x0_driver_s *cs89x0);
@@ -115,7 +117,10 @@ static int cs89x0_uiptxpoll(struct uip_driver_s *dev);
/* Interrupt handling */
static void cs89x0_receive(struct cs89x0_driver_s *cs89x0);
-static void cs89x0_txdone(struct cs89x0_driver_s *cs89x0);
+static void cs89x0_txdone(struct cs89x0_driver_s *cs89x0, uint16 isq);
+#if CONFIG_CS89x0_NINTERFACES > 1
+static inline FAR struct cs89x0_driver_s *cs89x0_mapirq(int irq);
+#endif
static int cs89x0_interrupt(int irq, FAR void *context);
/* Watchdog timer expirations */
@@ -134,6 +139,80 @@ static int cs89x0_txavail(struct uip_driver_s *dev);
****************************************************************************/
/****************************************************************************
+ * Function: cs89x0_getreg and cs89x0_putreg
+ *
+ * Description:
+ * Read from and write to a CS89x0 register
+ *
+ * Parameters:
+ * cs89x0 - Reference to the driver state structure
+ * offset - Offset to the CS89x0 register
+ * value - Value to be written (cs89x0_putreg only)
+ *
+ * Returned Value:
+ * cs89x0_getreg: The 16-bit value of the register
+ * cs89x0_putreg: None
+ *
+ ****************************************************************************/
+
+static uint16 cs89x0_getreg(struct cs89x0_driver_s *cs89x0, int offset)
+{
+#ifdef CONFIG_CS89x0_ALIGN16
+ return getreg16(s89x0->cs_base + offset);
+#else
+ return (uint16)getreg32(s89x0->cs_base + offset);
+#endif
+}
+
+static void cs89x0_putreg(struct cs89x0_driver_s *cs89x0, int offset, uint16 value)
+{
+#ifdef CONFIG_CS89x0_ALIGN16
+ return putreg16(value, s89x0->cs_base + offset);
+#else
+ return (uint16)putreg32((uint32)value, s89x0->cs_base + offset);
+#endif
+}
+
+/****************************************************************************
+ * Function: cs89x0_getppreg and cs89x0_putppreg
+ *
+ * Description:
+ * Read from and write to a CS89x0 page packet register
+ *
+ * Parameters:
+ * cs89x0 - Reference to the driver state structure
+ * addr - Address of the CS89x0 page packet register
+ * value - Value to be written (cs89x0_putppreg only)
+ *
+ * Returned Value:
+ * cs89x0_getppreg: The 16-bit value of the page packet register
+ * cs89x0_putppreg: None
+ *
+ ****************************************************************************/
+
+static uint16 cs89x0_getppreg(struct cs89x0_driver_s *cs89x0, int addr)
+{
+#ifdef CONFIG_CS89x0_ALIGN16
+ putreg16((uint16)addr, cs89x0->cs_base + CS89x0_PPTR_OFFSET);
+ return getreg16(s89x0->cs_base + CS89x0_PDATA_OFFSET);
+#else
+ putreg32((uint32)addr, cs89x0->cs_base + CS89x0_PPTR_OFFSET);
+ return (uint16)getreg32(s89x0->cs_base + CS89x0_PDATA_OFFSET);
+#endif
+}
+
+static void cs89x0_putppreg(struct cs89x0_driver_s *cs89x0, int addr, uint16 value)
+{
+#ifdef CONFIG_CS89x0_ALIGN16
+ putreg16((uint16)addr, cs89x0->cs_base + CS89x0_PPTR_OFFSET);
+ putreg16(value), cs89x0->cs_base + CS89x0_PDATA_OFFSET);
+#else
+ putreg32((uint32)addr, cs89x0->cs_base + CS89x0_PPTR_OFFSET);
+ putreg32((uint32)value, cs89x0->cs_base + CS89x0_PDATA_OFFSET);
+#endif
+}
+
+/****************************************************************************
* Function: cs89x0_transmit
*
* Description:
@@ -153,18 +232,23 @@ static int cs89x0_txavail(struct uip_driver_s *dev);
static int cs89x0_transmit(struct cs89x0_driver_s *cs89x0)
{
/* Verify that the hardware is ready to send another packet */
+#warning "Missing logic"
/* Increment statistics */
+#warning "Missing logic"
/* Disable Ethernet interrupts */
+#warning "Missing logic"
- /* Send the packet: address=cs89x0->sk_dev.d_buf, length=cs89x0->sk_dev.d_len */
+ /* Send the packet: address=cs89x0->cs_dev.d_buf, length=cs89x0->cs_dev.d_len */
+#warning "Missing logic"
/* Restore Ethernet interrupts */
+#warning "Missing logic"
/* Setup the TX timeout watchdog (perhaps restarting the timer) */
- (void)wd_start(cs89x0->sk_txtimeout, CS89x0_TXTIMEOUT, cs89x0_txtimeout, 1, (uint32)cs89x0);
+ (void)wd_start(cs89x0->cs_txtimeout, CS89x0_TXTIMEOUT, cs89x0_txtimeout, 1, (uint32)cs89x0);
return OK;
}
@@ -197,14 +281,15 @@ static int cs89x0_uiptxpoll(struct uip_driver_s *dev)
* the field d_len is set to a value > 0.
*/
- if (cs89x0->sk_dev.d_len > 0)
+ if (cs89x0->cs_dev.d_len > 0)
{
- uip_arp_out(&cs89x0->sk_dev);
+ uip_arp_out(&cs89x0->cs_dev);
cs89x0_transmit(cs89x0);
/* Check if there is room in the CS89x0 to hold another packet. If not,
* return a non-zero value to terminate the poll.
*/
+#warning "Missing logic"
}
/* If zero is returned, the polling will continue until all connections have
@@ -222,6 +307,7 @@ static int cs89x0_uiptxpoll(struct uip_driver_s *dev)
*
* Parameters:
* cs89x0 - Reference to the driver state structure
+ * isq - Interrupt status queue value read by interrupt handler
*
* Returned Value:
* None
@@ -230,55 +316,100 @@ static int cs89x0_uiptxpoll(struct uip_driver_s *dev)
*
****************************************************************************/
-static void cs89x0_receive(struct cs89x0_driver_s *cs89x0)
+static void cs89x0_receive(struct cs89x0_driver_s *cs89x0, uint16 isq)
{
- do
+ uint16 *dest;
+ uint16 rxlength;
+ int nbytes;
+
+ /* Check for errors and update statistics */
+
+ rxlength = cs89x0_getreg(PPR_RXLENGTH);
+ if ((isq & RX_OK) == 0)
{
- /* Check for errors and update statistics */
+#ifdef CONFIG_C89x0_STATISTICS
+ cd89x0->cs_stats.rx_errors++;
+ if ((isq & RX_RUNT) != 0)
+ {
+ cd89x0->cs_stats.rx_lengtherrors++;
+ }
+ if ((isq & RX_EXTRA_DATA) != 0)
+ {
+ cd89x0->cs_stats.rx_lengtherrors++;
+ }
+ if (isq & RX_CRC_ERROR) != 0)
+ {
+ if (!(isq & (RX_EXTRA_DATA|RX_RUNT)))
+ {
+ cd89x0->cs_stats.rx_crcerrors++;
+ }
+ }
+ if ((isq & RX_DRIBBLE) != 0)
+ {
+ cd89x0->cs_stats.rx_frameerrors++;
+ }
+#endif
+ return;
+ }
- /* Check if the packet is a valid size for the uIP buffer configuration */
+ /* Check if the packet is a valid size for the uIP buffer configuration */
- /* Copy the data data from the hardware to cs89x0->sk_dev.d_buf. Set
- * amount of data in cs89x0->sk_dev.d_len
- */
+ if (rxlength > ???)
+ {
+#ifdef CONFIG_C89x0_STATISTICS
+ cd89x0->cs_stats.rx_errors++;
+ cd89x0->cs_stats.rx_lengtherrors++;
+#endif
+ return;
+ }
+
+ /* Copy the data data from the hardware to cs89x0->cs_dev.d_buf. Set
+ * amount of data in cs89x0->cs_dev.d_len
+ */
+
+ dest = (uint16*)cs89x0->cs_dev.d_buf;
+ for (nbytes = 0; nbytes < rxlength; nbytes += sizeof(uint16))
+ {
+ *dest++ = cs89x0_getreg(PPR_RXFRAMELOCATION);
+ }
- /* We only accept IP packets of the configured type and ARP packets */
+#ifdef CONFIG_C89x0_STATISTICS
+ cd89x0->cs_stats.rx_packets++;
+#endif
+ /* We only accept IP packets of the configured type and ARP packets */
#ifdef CONFIG_NET_IPv6
- if (BUF->type == HTONS(UIP_ETHTYPE_IP6))
+ if (BUF->type == HTONS(UIP_ETHTYPE_IP6))
#else
- if (BUF->type == HTONS(UIP_ETHTYPE_IP))
+ if (BUF->type == HTONS(UIP_ETHTYPE_IP))
#endif
+ {
+ uip_arp_ipin();
+ uip_input(&cs89x0->cs_dev);
+
+ /* If the above function invocation resulted in data that should be
+ * sent out on the network, the field d_len will set to a value > 0.
+ */
+
+ if (cs89x0->cs_dev.d_len > 0)
{
- uip_arp_ipin();
- uip_input(&cs89x0->sk_dev);
-
- /* If the above function invocation resulted in data that should be
- * sent out on the network, the field d_len will set to a value > 0.
- */
-
- if (cs89x0->sk_dev.d_len > 0)
- {
- uip_arp_out(&cs89x0->sk_dev);
- cs89x0_transmit(cs89x0);
- }
- }
- else if (BUF->type == htons(UIP_ETHTYPE_ARP))
- {
- uip_arp_arpin(&cs89x0->sk_dev);
+ uip_arp_out(&cs89x0->cs_dev);
+ cs89x0_transmit(cs89x0);
+ }
+ }
+ else if (BUF->type == htons(UIP_ETHTYPE_ARP))
+ {
+ uip_arp_arpin(&cs89x0->cs_dev);
- /* If the above function invocation resulted in data that should be
- * sent out on the network, the field d_len will set to a value > 0.
- */
+ /* If the above function invocation resulted in data that should be
+ * sent out on the network, the field d_len will set to a value > 0.
+ */
- if (cs89x0->sk_dev.d_len > 0)
- {
- cs89x0_transmit(cs89x0);
- }
- }
- }
+ if (cs89x0->cs_dev.d_len > 0)
+ {
+ cs89x0_transmit(cs89x0);
+ }
}
- while (); /* While there are more packets to be processed */
}
/****************************************************************************
@@ -297,20 +428,80 @@ static void cs89x0_receive(struct cs89x0_driver_s *cs89x0)
*
****************************************************************************/
-static void cs89x0_txdone(struct cs89x0_driver_s *cs89x0)
+static void cs89x0_txdone(struct cs89x0_driver_s *cs89x0, uint16 isq)
{
- /* Check for errors and update statistics */
+ /* Check for errors and update statistics. The lower 6-bits of the ISQ
+ * hold the register address causing the interrupt. We got here because
+ * those bits indicated */
+
+#ifdef CONFIG_C89x0_STATISTICS
+ cd89x0->cs_stats.tx_packets++;
+ if ((isq & ISQ_TXEVENT_TXOK) == 0)
+ {
+ cd89x0->cs_stats.tx_errors++;
+ }
+ if ((isq & ISQ_TXEVENT_LOSSOFCRS) != 0)
+ {
+ cd89x0->cs_stats.tx_carriererrors++;
+ }
+ if ((isq & ISQ_TXEVENT_SQEERROR) != 0)
+ {
+ cd89x0->cs_stats.tx_heartbeaterrors++;
+ }
+ if (i(sq & ISQ_TXEVENT_OUTWINDOW) != 0)
+ {
+ cd89x0->cs_stats.tx_windowerrors++;
+ }
+ if (isq & TX_16_COL)
+ {
+ cd89x0->cs_stats.tx_abortederrors++;
+ }
+#endif
/* If no further xmits are pending, then cancel the TX timeout */
- wd_cancel(cs89x0->sk_txtimeout);
+ wd_cancel(cs89x0->cs_txtimeout);
/* Then poll uIP for new XMIT data */
- (void)uip_poll(&cs89x0->sk_dev, cs89x0_uiptxpoll);
+ (void)uip_poll(&cs89x0->cs_dev, cs89x0_uiptxpoll);
}
/****************************************************************************
+ * Function: cs89x0_mapirq
+ *
+ * Description:
+ * Map an IRQ number to a CS89x0 device state instance. This is only
+ * necessary to handler the case where the architecture includes more than
+ * on CS89x0 chip.
+ *
+ * Parameters:
+ * irq - Number of the IRQ that generated the interrupt
+ *
+ * Returned Value:
+ * A reference to device state structure (NULL if irq does not correspond
+ * to any CS89x0 device).
+ *
+ * Assumptions:
+ *
+ ****************************************************************************/
+
+#if CONFIG_CS89x0_NINTERFACES > 1
+static inline FAR struct cs89x0_driver_s *cs89x0_mapirq(int irq)
+{
+ int i;
+ for (i = 0; i < CONFIG_CS89x0_NINTERFACES; i++)
+ {
+ if (g_cs89x0[i] && g_cs89x0[i].irq == irq)
+ {
+ return g_cs89x0[i];
+ }
+ }
+ return NULL'
+}
+#endif
+
+/****************************************************************************
* Function: cs89x0_interrupt
*
* Description:
@@ -329,26 +520,63 @@ static void cs89x0_txdone(struct cs89x0_driver_s *cs89x0)
static int cs89x0_interrupt(int irq, FAR void *context)
{
- register struct cs89x0_driver_s *cs89x0 = &g_cs89x0[0];
-
- /* Disable Ethernet interrupts */
-
- /* Get and clear interrupt status bits */
-
- /* Handle interrupts according to status bit settings */
+ register struct cs89x0_driver_s *cs89x0 = s89x0_mapirq(irq);
+ uint16 isq;
+
+#ifdef CONFIG_DEBUG
+ if (!cs89x0)
+ {
+ return -ENODEV;
+ }
+#endif
- /* Check if we received an incoming packet, if so, call cs89x0_receive() */
+ /* Read and process all of the events from the ISQ */
- cs89x0_receive(cs89x0);
+ while ((isq = cs89x0_getreg(dev, CS89x0_ISQ_OFFSET)) != 0)
+ {
+ nvdbg("ISQ: %04x\n", isq);
+ switch (isq & ISQ_EVENTMASK)
+ {
+ case ISQ_RXEVENT:
+ cs89x0_receive(cs89x0);
+ break;
- /* Check is a packet transmission just completed. If so, call cs89x0_txdone */
+ case ISQ_TXEVENT:
+ cs89x0_txdone(cs89x0, isq);
+ break;
- cs89x0_txdone(cs89x0);
+ case ISQ_BUFEVENT:
+ if ((isq & ISQ_BUFEVENT_TXUNDERRUN) != 0)
+ {
+ ndbg("Transmit underrun\n");
+#ifdef CONFIG_CS89x0_XMITEARLY
+
+ cd89x0->cs_txunderrun++;
+ if (cd89x0->cs_txunderrun == 3)
+ {
+ cd89x0->send_cmd = TX_AFTER_381;
+ }
+ else if (cd89x0->cs_txunderrun == 6)
+ {
+ cd89x0->send_cmd = TX_AFTER_ALL;
+ }
+#endif
+ }
+ break;
- /* Enable Ethernet interrupts (perhaps excluding the TX done interrupt if
- * there are no pending transmissions.
- */
+ case ISQ_RXMISSEVENT:
+#ifdef CONFIG_C89x0_STATISTICS
+ cd89x0->cs_stats.rx_missederrors += (isq >>6);
+#endif
+ break;
+ case ISQ_TXCOLEVENT:
+#ifdef CONFIG_C89x0_STATISTICS
+ cd89x0->cs_stats.collisions += (isq >>6);
+#endif
+ break;
+ }
+ }
return OK;
}
@@ -375,12 +603,14 @@ static void cs89x0_txtimeout(int argc, uint32 arg, ...)
struct cs89x0_driver_s *cs89x0 = (struct cs89x0_driver_s *)arg;
/* Increment statistics and dump debug info */
+#warning "Missing logic"
/* Then reset the hardware */
+#warning "Missing logic"
/* Then poll uIP for new XMIT data */
- (void)uip_poll(&cs89x0->sk_dev, cs89x0_uiptxpoll);
+ (void)uip_poll(&cs89x0->cs_dev, cs89x0_uiptxpoll);
}
/****************************************************************************
@@ -405,14 +635,15 @@ static void cs89x0_polltimer(int argc, uint32 arg, ...)
struct cs89x0_driver_s *cs89x0 = (struct cs89x0_driver_s *)arg;
/* Check if there is room in the send another TXr packet. */
+#warning "Missing logic"
/* If so, update TCP timing states and poll uIP for new XMIT data */
- (void)uip_timer(&cs89x0->sk_dev, cs89x0_uiptxpoll, CS89x0_POLLHSEC);
+ (void)uip_timer(&cs89x0->cs_dev, cs89x0_uiptxpoll, CS89x0_POLLHSEC);
/* Setup the watchdog poll timer again */
- (void)wd_start(cs89x0->sk_txpoll, CS89x0_WDDELAY, cs89x0_polltimer, 1, arg);
+ (void)wd_start(cs89x0->cs_txpoll, CS89x0_WDDELAY, cs89x0_polltimer, 1, arg);
}
/****************************************************************************
@@ -440,15 +671,16 @@ static int cs89x0_ifup(struct uip_driver_s *dev)
dev->d_ipaddr & 0xff, (dev->d_ipaddr >> 8) & 0xff,
(dev->d_ipaddr >> 16) & 0xff, dev->d_ipaddr >> 24 );
- /* Initilize Ethernet interface */
+ /* Initialize the Ethernet interface */
+#warning "Missing logic"
/* Set and activate a timer process */
- (void)wd_start(cs89x0->sk_txpoll, CS89x0_WDDELAY, cs89x0_polltimer, 1, (uint32)cs89x0);
+ (void)wd_start(cs89x0->cs_txpoll, CS89x0_WDDELAY, cs89x0_polltimer, 1, (uint32)cs89x0);
/* Enable the Ethernet interrupt */
- cs89x0->sk_bifup = TRUE;
+ cs89x0->cs_bifup = TRUE;
up_enable_irq(CONFIG_CS89x0_IRQ);
return OK;
}
@@ -481,12 +713,12 @@ static int cs89x0_ifdown(struct uip_driver_s *dev)
/* Cancel the TX poll timer and TX timeout timers */
- wd_cancel(cs89x0->sk_txpoll);
- wd_cancel(cs89x0->sk_txtimeout);
+ wd_cancel(cs89x0->cs_txpoll);
+ wd_cancel(cs89x0->cs_txtimeout);
/* Reset the device */
- cs89x0->sk_bifup = FALSE;
+ cs89x0->cs_bifup = FALSE;
irqrestore(flags);
return OK;
}
@@ -519,13 +751,14 @@ static int cs89x0_txavail(struct uip_driver_s *dev)
/* Ignore the notification if the interface is not yet up */
- if (cs89x0->sk_bifup)
+ if (cs89x0->cs_bifup)
{
/* Check if there is room in the hardware to hold another outgoing packet. */
+#warning "Missing logic"
/* If so, then poll uIP for new XMIT data */
- (void)uip_poll(&cs89x0->sk_dev, cs89x0_uiptxpoll);
+ (void)uip_poll(&cs89x0->cs_dev, cs89x0_uiptxpoll);
}
irqrestore(flags);
@@ -543,7 +776,13 @@ static int cs89x0_txavail(struct uip_driver_s *dev)
* Initialize the Ethernet driver
*
* Parameters:
- * None
+ * impl - decribes the the implementation of the cs89x00 implementation.
+ * This reference is retained so so must remain stable throughout the
+ * life of the driver instance.
+ * devno - Identifies the device number. This must be a number between
+ * zero CONFIG_CS89x0_NINTERFACES and the same devno must not be
+ * initialized twice. The associated network device will be referred
+ * to with the name "eth" followed by this number (eth0, eth1, etc).
*
* Returned Value:
* OK on success; Negated errno on failure.
@@ -554,13 +793,24 @@ static int cs89x0_txavail(struct uip_driver_s *dev)
/* Initialize the CS89x0 chip and driver */
-int cs89x0_initialize(void)
+int cs89x0_initialize(FAR const cs89x0_driver_s *cs89x0, int devno)
{
+ /* Sanity checks -- only performed with debug enabled */
+
+#ifdef CONFIG_DEBUG
+ if (!cs89x0 || (unsigned)devno > CONFIG_CS89x0_NINTERFACES || g_cs89x00[devno])
+ {
+ return -EINVAL;
+ }
+#endif
+
/* Check if a Ethernet chip is recognized at its I/O base */
+#warning "Missing logic"
+
/* Attach the IRQ to the driver */
- if (irq_attach(CONFIG_CS89x0_IRQ, cs89x0_interrupt))
+ if (irq_attach(cs89x0->irq, cs89x0_interrupt))
{
/* We could not attach the ISR to the ISR */
@@ -569,22 +819,22 @@ int cs89x0_initialize(void)
/* Initialize the driver structure */
- memset(g_cs89x0, 0, CONFIG_CS89x0_NINTERFACES*sizeof(struct cs89x0_driver_s));
- g_cs89x0[0].sk_dev.d_ifup = cs89x0_ifup; /* I/F down callback */
- g_cs89x0[0].sk_dev.d_ifdown = cs89x0_ifdown; /* I/F up (new IP address) callback */
- g_cs89x0[0].sk_dev.d_txavail = cs89x0_txavail; /* New TX data callback */
- g_cs89x0[0].sk_dev.d_private = (void*)g_cs89x0; /* Used to recover private state from dev */
+ g_cs89x[devno] = cs89x0; /* Used to map IRQ back to instance */
+ cs89x0->cs_dev.d_ifup = cs89x0_ifup; /* I/F down callback */
+ cs89x0->cs_dev.d_ifdown = cs89x0_ifdown; /* I/F up (new IP address) callback */
+ cs89x0->cs_dev.d_txavail = cs89x0_txavail; /* New TX data callback */
+ cs89x0->cs_dev.d_private = (void*)cs89x0; /* Used to recover private state from dev */
/* Create a watchdog for timing polling for and timing of transmisstions */
- g_cs89x0[0].sk_txpoll = wd_create(); /* Create periodic poll timer */
- g_cs89x0[0].sk_txtimeout = wd_create(); /* Create TX timeout timer */
+ cs89x0->cs_txpoll = wd_create(); /* Create periodic poll timer */
+ cs89x0->cs_txtimeout = wd_create(); /* Create TX timeout timer */
- /* Read the MAC address from the hardware into g_cs89x0[0].sk_dev.d_mac.ether_addr_octet */
+ /* Read the MAC address from the hardware into cs89x0->cs_dev.d_mac.ether_addr_octet */
/* Register the device with the OS so that socket IOCTLs can be performed */
- (void)netdev_register(&g_cs89x0[0].sk_dev);
+ (void)netdev_register(&cs89x0->cs_dev);
return OK;
}