1
0
Fork 0
forked from nuttx/nuttx-update

First clean C5471 Ethernet compile

git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@424 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
patacongo 2007-12-04 20:23:43 +00:00
parent 5efd8589a7
commit c3b6c26c1b
11 changed files with 605 additions and 147 deletions

View file

@ -61,6 +61,7 @@
#include <net/uip/uip-arch.h>
#include "chip.h"
#include "up_arch.h"
#include "up_internal.h"
/****************************************************************************
@ -76,6 +77,38 @@
# define CONFIG_C5471_NET_NINTERFACES 1
#endif
/* CONFIG_C5471_NET_STATS will enabled collection of driver statistics.
* Default is disabled.
*/
/* CONFIG_C5471_ETHERNET_PHY may be set to one of the following values to
* select the PHY (or left undefined if there is no PHY)
*/
#ifndef ETHERNET_PHY_LU3X31T_T64
# define ETHERNET_PHY_LU3X31T_T64 1
#endif
#ifndef ETHERNET_PHY_AC101L
# define ETHERNET_PHY_AC101L 2
#endif
/* Mode of operation defaults to AUTONEGOTIATION */
#if defined(CONFIG_NET_C5471_AUTONEGOTIATION)
# undef CONFIG_NET_C5471_BASET100
# undef CONFIG_NET_C5471_BASET10
#elif defined(CONFIG_NET_C5471_BASET100)
# undef CONFIG_NET_C5471_AUTONEGOTIATION
# undef CONFIG_NET_C5471_BASET10
#elif defined(CONFIG_NET_C5471_BASET10)
# undef CONFIG_NET_C5471_AUTONEGOTIATION
# undef CONFIG_NET_C5471_BASET100
#else
# define CONFIG_NET_C5471_AUTONEGOTIATION 1
# undef CONFIG_NET_C5471_BASET100
# undef CONFIG_NET_C5471_BASET10
#endif
/* Timing values ************************************************************/
/* TX poll deley = 1 seconds. CLK_TCK=number of clock ticks per second */
@ -323,8 +356,8 @@ static int c5471_phyinit (void);
/* Support logic */
static void c5471_inctxcpu(void);
static void c5471_incrxcpu(void);
static inline void c5471_inctxcpu(struct c5471_driver_s *c5471);
static inline void c5471_incrxcpu(struct c5471_driver_s *c5471);
/* Common TX logic */
@ -351,7 +384,7 @@ static int c5471_txavail(struct uip_driver_s *dev);
/* Initialization functions */
static void c5471_eimreset (struct c5471_driver_s *c5471);
static void c5471_eimconfig(void);
static void c5471_eimconfig(struct c5471_driver_s *c5471);
static void c5471_reset(struct c5471_driver_s *c5471);
static void c5471_macassign(struct c5471_driver_s *c5471);
@ -392,7 +425,7 @@ static void c5471_mdtxbit (int bit_state)
{
/* set MDIO state high. */
putreg32(getreg32(GPIO_IO) | GPIO_CIO_MDIO), GPIO_IO);
putreg32((getreg32(GPIO_IO) | GPIO_CIO_MDIO), GPIO_IO);
}
else
{
@ -706,10 +739,12 @@ static int c5471_phyinit (void)
}
#else
# define c5471_phyinit()
# if !defined(CONFIG_C5471_ETHERNET_PHY)
# warning "CONFIG_C5471_ETHERNET_PHY not defined -- assumed NONE"
# endif
# define c5471_phyinit()
# if defined(CONFIG_C5471_ETHERNET_PHY)
# error "CONFIG_C5471_ETHERNET_PHY value not recognized"
# else
# warning "CONFIG_C5471_ETHERNET_PHY not defined -- assumed NO PHY"
# endif
#endif
/****************************************************************************
@ -719,13 +754,13 @@ static int c5471_phyinit (void)
*
****************************************************************************/
static void c5471_inctxcpu(void)
static inline void c5471_inctxcpu(struct c5471_driver_s *c5471)
{
if (EIM_TXDESC_WRAP_NEXT & getreg32(c5471->c_txcpudesc))
{
/* Loop back around to base of descriptor queue */
c5471->c_txcpudesc = (volatile uint32 *)(getreg32(EIM_CPU_TXBA) + EIM_RAM_START);
c5471->c_txcpudesc = getreg32(EIM_CPU_TXBA) + EIM_RAM_START;
}
else
{
@ -740,13 +775,13 @@ static void c5471_inctxcpu(void)
*
****************************************************************************/
static void c5471_incrxcpu(void)
static inline void c5471_incrxcpu(struct c5471_driver_s *c5471)
{
if (EIM_RXDESC_WRAP_NEXT & getreg32(c5471->c_rxcpudesc))
{
/* Loop back around to base of descriptor queue */
c5471->c_rxcpudesc = (volatile uint32 *)(getreg32(EIM_CPU_RXBA) + EIM_RAM_START);
c5471->c_rxcpudesc = getreg32(EIM_CPU_RXBA) + EIM_RAM_START;
}
else
{
@ -773,21 +808,23 @@ static void c5471_incrxcpu(void)
static int c5471_transmit(struct c5471_driver_s *c5471)
{
volatile uint32 *packetmem;
volatile uint32 *ptr;
uint16 bytelen;
uint16 longlen;
struct uip_driver_s *dev = &c5471->c_dev;
volatile uint16 *packetmem;
uint16 framelen;
boolean bfirstframe;
int nbytes;
int nshorts;
unsigned int i;
unsigned int j;
nbytes = (dev->d_len + 1) & ~1;
j = 0;
bfirstframe = TRUE;
c5471->c_lastdescstart = c5471->c_rxcpudesc;
while (nbytes)
{
/* Verify that the hardware is ready to send another packet */
/* Words #0 and #1 of descriptor */
while (EIM_TXDESC_OWN_HOST & getreg32(c5471->c_rxcpudesc))
@ -815,39 +852,31 @@ static int c5471_transmit(struct c5471_driver_s *c5471)
if (nbytes >= EIM_PACKET_BYTES)
{
bytelen = EIM_PACKET_BYTES;
framelen = EIM_PACKET_BYTES;
}
else
{
bytelen = nbytes;
framelen = nbytes;
}
/* Next, submit ether frame bytes to the C547x Ether Module packet memory space */
/* Submit ether frame bytes to the C5472 Ether Module packet memory space. */
for (i = 0; i < longlen; i++, j++)
{
}
/* Get the number of 16-bit values to transfer by dividing by 2 with round up. */
/* Next, submit ether frame bytes to the C5472 Ether Module packet
* memory space.
*/
/* divide by 2 with round up. */
nshorts = (bytelen+1)>>1;
nshorts = (framelen + 1) >> 1;
/* Words #2 and #3 of descriptor */
packetmem = (uint32 *)getreg32(c5471->c_rxcpudesc + sizeof(uint32));
packetmem = (uint16*)getreg32(c5471->c_rxcpudesc + sizeof(uint32));
for (i = 0; i < nshorts; i++, j++)
{
/* 16-bits at a time. */
packetmem[i] = __swap_16(((uint16*)buf)[j]);
packetmem[i] = htons(((uint16*)dev->d_buf)[j]);
}
putreg32(((getreg32(c5471->c_rxcpudesc) & ~EIM_RXDESC_BYTEMASK) | bytelen), c5471->c_rxcpudesc);
nbytes -= bytelen;
putreg32(((getreg32(c5471->c_rxcpudesc) & ~EIM_RXDESC_BYTEMASK) | framelen), c5471->c_rxcpudesc);
nbytes -= framelen;
if (0 == nbytes)
{
putreg32((getreg32(c5471->c_rxcpudesc) | EIM_RXDESC_LIF), c5471->c_rxcpudesc);
@ -868,20 +897,15 @@ static int c5471_transmit(struct c5471_driver_s *c5471)
/* Advance to the next free descriptor */
c5471_incrxcpu();
c5471_incrxcpu(c5471);
bfirstframe = FALSE;
}
return;
/* Verify that the hardware is ready to send another packet */
/* Packet transferred .. Update statistics */
/* Increment statistics */
/* Disable Ethernet interrupts */
/* Send the packet: address=c5471->c_dev.d_buf, length=c5471->c_dev.d_len */
/* Restore Ethernet interrupts */
#ifdef CONFIG_C5471_NET_STATS
c5471->c_txpackets++;
#endif
/* Setup the TX timeout watchdog (perhaps restarting the timer) */
@ -927,7 +951,7 @@ static int c5471_uiptxpoll(struct uip_driver_s *dev)
* rights to submit another Ethernet frame.
*/
if (EIM_TXDESC_OWN_HOST & getreg32(c5471->c_rxcpudesc) != 0)
if ((EIM_TXDESC_OWN_HOST & getreg32(c5471->c_rxcpudesc)) != 0)
{
/* No, then return non-zero to terminate the poll */
@ -961,7 +985,7 @@ static int c5471_uiptxpoll(struct uip_driver_s *dev)
#ifdef CONFIG_C5471_NET_STATS
void c5471_rxstatus(int *numbytes)
{
uint32 *pdesc = c5471->c_txcpudesc;
uint32 desc = c5471->c_txcpudesc;
uint32 rxstatus;
/* Walk that last packet we just received to collect xmit status bits. */
@ -969,31 +993,31 @@ void c5471_rxstatus(int *numbytes)
rxstatus = 0;
for (;;)
{
if (EIM_TXDESC_OWN_HOST & getreg32(pdesc))
if (EIM_TXDESC_OWN_HOST & getreg32(desc))
{
/* The incoming packe queue is empty. */
break;
}
rxstatus |= (getreg32(pdesc) & EIM_TXDESC_STATUSMASK);
rxstatus |= (getreg32(desc) & EIM_TXDESC_STATUSMASK);
if ((getreg32(pdesc) & EIM_TXDESC_LIF) != 0)
if ((getreg32(desc) & EIM_TXDESC_LIF) != 0)
{
break;
}
/* This packet is made up of several descriptors, find next one in chain. */
if (EIM_TXDESC_WRAP_NEXT & getreg32(pdesc))
if (EIM_TXDESC_WRAP_NEXT & getreg32(desc))
{
/* Loop back around to base of descriptor queue. */
pdesc = (uint32*)(getreg32(EIM_CPU_RXBA) + EIM_RAM_START);
desc = getreg32(EIM_CPU_RXBA) + EIM_RAM_START;
}
else
{
pdesc += 2;
desc += 2 * sizeof(uint32);
}
}
@ -1055,11 +1079,11 @@ void c5471_rxstatus(int *numbytes)
static void c5471_receive(struct c5471_driver_s *c5471)
{
struct uip_driver_s *dev = c5471->c_dev;
uint16 *packetmem = NULL;
struct uip_driver_s *dev = &c5471->c_dev;
uint16 *packetmem;
boolean bmore = TRUE;
int packetlen;
int bytelen = 0;
int packetlen = 0;
int framelen;
int nshorts;
int i;
int j = 0;
@ -1080,8 +1104,8 @@ static void c5471_receive(struct c5471_driver_s *c5471)
break;
}
bytelen = (getreg32(c5471->c_txcpudesc) & EIM_TXDESC_BYTEMASK);
packetlen += bytelen;
framelen = (getreg32(c5471->c_txcpudesc) & EIM_TXDESC_BYTEMASK);
packetlen += framelen;
/* Words #2 and #3 of descriptor */
@ -1089,18 +1113,18 @@ static void c5471_receive(struct c5471_driver_s *c5471)
/* Divide by 2 with round up to get the number of 16-bit words. */
nshorts = (bytelen + 1) >> 1;
nshorts = (framelen + 1) >> 1;
for (i = 0 ; i < nshorts; i++, j++)
{
/* Check if the received packet will fit without the uIP packet buffer */
if (packelen < (CONFIG_NET_BUFSIZE - 4))
if (packetlen < (CONFIG_NET_BUFSIZE - 4))
{
/* Copy the data data from the hardware to c5471->c_dev.d_buf 16-bits at
* a time.
*/
((uint16*)dev->d_buf)[j] = __swap_16(packetmem[i]);
((uint16*)dev->d_buf)[j] = htons(packetmem[i]);
}
}
@ -1122,7 +1146,7 @@ static void c5471_receive(struct c5471_driver_s *c5471)
/* Advance to the next data buffer */
c5471_inctxcpu();
c5471_inctxcpu(c5471);
}
/* Adjust the packet length to remove the CRC bytes that uIP doesn't care about. */
@ -1202,7 +1226,7 @@ static void c5471_receive(struct c5471_driver_s *c5471)
#ifdef CONFIG_C5471_NET_STATS
static inline void c5471_txstatus(void)
{
uint32 *pdesc = c5471->c_lastdescstart;
uint32 desc = c5471->c_lastdescstart;
uint32 txstatus;
/* Walk that last packet we just sent to collect xmit status bits. */
@ -1212,8 +1236,8 @@ static inline void c5471_txstatus(void)
{
for (;;)
{
txstatus |= (getreg32(pdesc) & EIM_TXDESC_STATUSMASK);
if (pdesc == c5471->c_lastdescend)
txstatus |= (getreg32(desc) & EIM_TXDESC_STATUSMASK);
if (desc == c5471->c_lastdescend)
{
break;
}
@ -1224,11 +1248,11 @@ static inline void c5471_txstatus(void)
{
/* Loop back around to base of descriptor queue. */
pdesc = (uint32*)(getreg32(EIM_CPU_RXBA) + EIM_RAM_START);
desc = getreg32(EIM_CPU_RXBA) + EIM_RAM_START;
}
else
{
pdesc += 2;
desc += 2 * sizeof(uint32);
}
}
}
@ -1290,11 +1314,7 @@ static inline void c5471_txstatus(void)
static void c5471_txdone(struct c5471_driver_s *c5471)
{
/* Update statistics */
#ifdef CONFIG_C5471_NET_STATS
c5471->c_txpackets++;
/* Check for TX errors */
c5471_txstatus(c5471);
@ -1328,13 +1348,19 @@ static void c5471_txdone(struct c5471_driver_s *c5471)
static int c5471_interrupt(int irq, FAR void *context)
{
#if CONFIG_C5471_NET_NINTERFACES == 1
register struct c5471_driver_s *c5471 = &g_c5471[0];
#else
# error "Additional logic needed to support multiple interfaces"
#endif
/* Get and clear interrupt status bits */
/* Handle interrupts according to status bit settings */
c5471->c_eimstatus = getreg32(EIM_STATUS);
/* Handle interrupts according to status bit settings */
/* Check if we received an incoming packet, if so, call c5471_receive() */
c5471->c_eimstatus = getreg32(EIM_STATUS);
if (EIM_STATUS_CPU_TX & c5471->c_eimstatus)
{
/* An incoming packet has been received by the EIM from the network and
@ -1442,7 +1468,7 @@ static void c5471_polltimer(int argc, uint32 arg, ...)
* to submit another Ethernet frame.
*/
if (EIM_TXDESC_OWN_HOST & getreg32(c5471->c_rxcpudesc) == 0)
if ((EIM_TXDESC_OWN_HOST & getreg32(c5471->c_rxcpudesc)) == 0)
{
/* If so, update TCP timing states and poll uIP for new XMIT data */
@ -1483,16 +1509,19 @@ static int c5471_ifup(struct uip_driver_s *dev)
/* Initilize Ethernet interface */
c5471_reset();
c5471_reset(c5471);
/* Assign the MAC to the device */
c5471_macassign(c5471);
/* Clear pending interrupts by reading the EIM status register */
clearbits = getreg32(EIM_STATUS);
/* Enable interrupts going from EIM Module to Interrupt Module. */
clearbits = eth_in32(EIM_STATUS);
putreg32((getreg32(EIM_INTEN) | EIM_INTEN_CPU_TX|EIM_INTEN_CPU_RX)), EIM_INTEN);
putreg32(((getreg32(EIM_INTEN) | EIM_INTEN_CPU_TX|EIM_INTEN_CPU_RX)), EIM_INTEN);
/* Next, go on-line. According to the C547X documentation the enables have to
* occur in this order to insure proper operation; ESM first then the ENET.
@ -1597,7 +1626,7 @@ static int c5471_txavail(struct uip_driver_s *dev)
* rights to submit another Ethernet frame.
*/
if (EIM_TXDESC_OWN_HOST & getreg32(c5471->c_rxcpudesc) == 0)
if ((EIM_TXDESC_OWN_HOST & getreg32(c5471->c_rxcpudesc)) == 0)
{
/* If so, then poll uIP for new XMIT data */
@ -1652,8 +1681,8 @@ static void c5471_eimreset (struct c5471_driver_s *c5471)
/* All EIM register should now be in there power-up default states */
c5471->c_lastdescstart = NULL;
c5471->c_lastdescend = NULL;
c5471->c_lastdescstart = 0;
c5471->c_lastdescend = 0;
}
/****************************************************************************
@ -1666,19 +1695,19 @@ static void c5471_eimreset (struct c5471_driver_s *c5471)
*
****************************************************************************/
static void c5471_eimconfig(void)
static void c5471_eimconfig(struct c5471_driver_s *c5471)
{
volatile uint8 *pbuf;
volatile uint32 *pdesc;
volatile uint32 *val;
volatile uint32 pbuf;
volatile uint32 desc;
volatile uint32 val;
int i;
pdesc = EIM_RAM_START;
pbuf = (uint8*)EIM_RAM_START + 0x6C0;
desc = EIM_RAM_START;
pbuf = EIM_RAM_START + 0x6C0;
/* TX ENET 0 */
putreg32((((uint32)pdesc) & 0x0000ffff), ENET0_TDBA); /* 16bit offset address */
putreg32((desc & 0x0000ffff), ENET0_TDBA); /* 16bit offset address */
for (i = NUM_DESC_TX-1; i >= 0; i--)
{
if (i == 0)
@ -1686,25 +1715,23 @@ static void c5471_eimconfig(void)
else
val = EIM_TXDESC_WRAP_FIRST;
val |= EIM_TXDESC_OWN_HOST|EIM_TXDESC_INTRE|EIM_TXDESC_PADCRC|EIM_PACKET_BYTES;
putreg32(val, pdesc);
pdesc++;
putreg32((uint32)pbuf, pdesc);
putreg32(val, desc);
desc += sizeof(uint32);
pdesc++;
*((volatile uint32 *)pbuf) = 0x00000000;
putreg32(pbuf, desc);
desc += sizeof(uint32);
putreg32(0, pbuf);;
pbuf += EIM_PACKET_BYTES;
*((volatile uint32 *)pbuf) = 0x00000000;
/* As per c547X doc; this space for Ether Module's "Buffer Usage Word" */
pbuf += 4;
putreg32(0, pbuf);;
pbuf += sizeof(uint32); /* Ether Module's "Buffer Usage Word" */
}
/* RX ENET 0 */
putreg32((((uint32)pdesc) & 0x0000ffff), ENET0_RDBA); /* 16bit offset address */
putreg32((desc & 0x0000ffff), ENET0_RDBA); /* 16bit offset address */
for (i = NUM_DESC_RX-1; i >= 0; i--)
{
if (i == 0)
@ -1712,26 +1739,24 @@ static void c5471_eimconfig(void)
else
val = EIM_RXDESC_WRAP_FIRST;
val |= EIM_RXDESC_OWN_ENET|EIM_RXDESC_INTRE|EIM_RXDESC_PADCRC|EIM_PACKET_BYTES;
putreg32(val, pdesc);
pdesc++;
putreg32((uint32)pbuf, pdesc);
putreg32(val, desc);
desc += sizeof(uint32);
pdesc++;
*((uint32 *)pbuf) = 0x00000000;
putreg32(pbuf, desc);
desc += sizeof(uint32);
putreg32(0, pbuf);;
pbuf += EIM_PACKET_BYTES;
*((uint32 *)pbuf) = 0x00000000;
/* As per c547X doc; this space for Ether Module's "Buffer Usage Word" */
pbuf += 4;
putreg32(0, pbuf);;
pbuf += sizeof(uint32); /* Ether Module's "Buffer Usage Word" */
}
/* TX CPU */
c5471->c_txcpudesc = pdesc;
putreg32((((uint32)pdesc) & 0x0000ffff), EIM_CPU_TXBA); /* 16bit offset address */
c5471->c_txcpudesc = desc;
putreg32((desc & 0x0000ffff), EIM_CPU_TXBA); /* 16bit offset address */
for (i = NUM_DESC_TX-1; i >= 0; i--)
{
/* Set words 1+2 of the TXDESC */
@ -1741,26 +1766,23 @@ static void c5471_eimconfig(void)
else
val = EIM_TXDESC_WRAP_FIRST;
val |= EIM_TXDESC_OWN_HOST|EIM_TXDESC_INTRE|EIM_TXDESC_PADCRC|EIM_PACKET_BYTES;
putreg32(val, pdesc);
putreg32(val, desc);
desc += sizeof(uint32);
pdesc++;
putreg32((uint32)pbuf, pdesc);
pdesc++;
*((uint32 *)pbuf) = 0x00000000;
putreg32(pbuf, desc);
desc += sizeof(uint32);
putreg(pbuf, 0);
pbuf += EIM_PACKET_BYTES;
*((uint32 *)pbuf) = 0x00000000;
/* As per C547X doc; this space for Ether Module's "Buffer Usage Word" */
pbuf += 4;
putreg(pbuf, 0);
pbuf += sizeof(uint32); /* Ether Module's "Buffer Usage Word" */
}
/* RX CPU */
c5471->c_rxcpudesc = pdesc;
putreg32((uint32)((uint32)(pdesc)&0x0000ffff), EIM_CPU_RXBA); /* 16bit offset address */
c5471->c_rxcpudesc = desc;
putreg32((desc & 0x0000ffff), EIM_CPU_RXBA); /* 16bit offset address */
for (i = NUM_DESC_RX-1; i >= 0; i--)
{
/* Set words 1+2 of the RXDESC */
@ -1770,20 +1792,18 @@ static void c5471_eimconfig(void)
else
val = EIM_RXDESC_WRAP_FIRST;
val |= EIM_RXDESC_OWN_ENET|EIM_RXDESC_INTRE|EIM_RXDESC_PADCRC|EIM_PACKET_BYTES;
putreg32(val, pdesc);
pdesc++;
putreg32((uint32)pbuf, pdesc);
putreg32(val, desc);
desc += sizeof(uint32);
pdesc++;
*((uint32 *)pbuf) = 0x0000;
putreg32(pbuf, desc);
desc += sizeof(uint32);
putreg32(0, pbuf);;
pbuf += EIM_PACKET_BYTES;
*((uint32 *)pbuf) = 0x0000;
/* As per c547X doc; this space for Ether Module's "Buffer Usage Word" */
pbuf += 4;
putreg32(0, pbuf);;
pbuf += sizeof(uint32); /* Ether Module's "Buffer Usage Word" */
}
/* Save the descriptor packet size */
@ -1870,7 +1890,7 @@ static void c5471_reset(struct c5471_driver_s *c5471)
c5471_eimreset(c5471);
#endif
c5471_phyinit();
c5471_eimconfig();
c5471_eimconfig(c5471);
}
/****************************************************************************
@ -1887,18 +1907,18 @@ static void c5471_reset(struct c5471_driver_s *c5471)
static void c5471_macassign(struct c5471_driver_s *c5471)
{
struct uip_driver_s *dev = &c5471->s_dev;
struct uip_driver_s *dev = &c5471->c_dev;
register uint32 tmp;
/* Set CPU port MAC address. S/W will only see incoming packets that match
* this destination address.
*/
tmp = (((uint32)dev->d_mac[0]) << 8) | ((uint32)dev->d_mac[1]);
tmp = (((uint32)dev->d_mac.addr[0]) << 8) | ((uint32)dev->d_mac.addr[1]);
putreg32(tmp, EIM_CPU_DAHI);
tmp = (((uint32)dev->d_mac[2]) << 24) | (((uint32)dev->d_mac[3]) << 16) |
(((uint32)dev->d_mac[4]) << 8) | ((uint32)dev->d_mac[5])
tmp = (((uint32)dev->d_mac.addr[2]) << 24) | (((uint32)dev->d_mac.addr[3]) << 16) |
(((uint32)dev->d_mac.addr[4]) << 8) | ((uint32)dev->d_mac.addr[5]);
putreg32(tmp, EIM_CPU_DALO);
#if 0
@ -1942,7 +1962,7 @@ static void c5471_macassign(struct c5471_driver_s *c5471)
/* Initialize the DM90x0 chip and driver */
int up_netinitialize(void)
void up_netinitialize(void)
{
/* Attach the IRQ to the driver */
@ -1950,7 +1970,8 @@ int up_netinitialize(void)
{
/* We could not attach the ISR to the ISR */
return -EAGAIN;
nlldbg("irq_attach() failed\n");
return;
}
/* Initialize the driver structure */
@ -1969,7 +1990,6 @@ int up_netinitialize(void)
/* Register the device with the OS so that socket IOCTLs can be performed */
(void)netdev_register(&g_c5471[0].c_dev);
return OK;
}
#endif /* CONFIG_NET */

View file

@ -0,0 +1,38 @@
README
^^^^^^
defconfig
^^^^^^^^^
The default configuration file, defconfig, performs a
simple OS test using examples/ostest. This can be
configuration as follows:
cd tools
./configure.sh c5471evm
cd -
. ./setenv.sh
netconfig
^^^^^^^^^
This alternative configuration file, netconfig, may be used
instead of the default configuration (defconfig). This
configuration enables networking using the c5471's built-in
Ethernet interface. It uses examples/nettest to excercise
the TCP/IP network.
uipconfig
^^^^^^^^^
This configuration file demonstrates the tiny webserver
at examples/uip.
udpconfig
^^^^^^^^^
This alternative configuration file, is similar to netconfig
except that is use examples/upd to exercise UDP.
TThese alternative configurations can be selected by (using
uipconfig as example):
(Seleted the default configuration as show above)
cp config/c5471evm/uiponfig .config

View file

@ -1,5 +1,5 @@
############################################################
# defconfig
# configs/c5471evm/defconfig
#
# Copyright (C) 2007 Gregory Nutt. All rights reserved.
# Author: Gregory Nutt <spudmonkey@racsa.co.cr>
@ -299,6 +299,26 @@ CONFIG_NET_BROADCAST=n
CONFIG_NET_DHCP_LIGHT=n
CONFIG_NET_RESOLV_ENTRIES=4
#
# Settings for examples/uip
CONFIG_EXAMPLE_UIP_IPADDR=(10<<24|0<<16|0<<8|2)
CONFIG_EXAMPLE_UIP_DRIPADDR=(10<<24|0<<16|0<<8|1)
CONFIG_EXAMPLE_UIP_NETMASK=(255<<24|255<<16|255<<8|0)
CONFIG_EXAMPLE_UIP_SMTP=n
CONFIG_EXAMPLE_UIP_TELNETD=n
CONFIG_EXAMPLE_UIP_WEBSERVER=y
CONFIG_EXAMPLE_UIP_DHCPC=n
CONFIG_EXAMPLE_UIP_WEBCLIENT=n
#
# Settings for examples/nettest
CONFIG_EXAMPLE_NETTEST_SERVER=n
CONFIG_EXAMPLE_NETTEST_PERFORMANCE=n
CONFIG_EXAMPLE_NETTEST_IPADDR=(10<<24|0<<16|0<<8|2)
CONFIG_EXAMPLE_NETTEST_DRIPADDR=(10<<24|0<<16|0<<8|1)
CONFIG_EXAMPLE_NETTEST_NETMASK=(255<<24|255<<16|255<<8|0)
CONFIG_EXAMPLE_NETTEST_CLIENTIP=(10<<24|0<<16|0<<8|1)
#
# Settings for examples/nsh
CONFIG_EXAMPLES_NSH_TELNET=n
@ -311,6 +331,16 @@ CONFIG_EXAMPLES_NSH_IPADDR=(10<<24|0<<16|0<<8|2)
CONFIG_EXAMPLES_NSH_DRIPADDR=(10<<24|0<<16|0<<8|1)
CONFIG_EXAMPLES_NSH_NETMASK=(255<<24|255<<16|255<<8|0)
#
# C5471 Ethernet Driver settings
CONFIG_C5471_NET_STATS=n
ETHERNET_PHY_LU3X31T_T64=1
ETHERNET_PHY_AC101L=2
CONFIG_C5471_ETHERNET_PHY=ETHERNET_PHY_LU3X31T_T64
CONFIG_NET_C5471_AUTONEGOTIATION=y
CONFIG_NET_C5471_BASET100=n
CONFIG_NET_C5471_BASET10=n
#
# Stack and heap information
#

365
configs/c5471evm/netconfig Normal file
View file

@ -0,0 +1,365 @@
############################################################
# configs/c5471evm/netconfig
#
# Copyright (C) 2007 Gregory Nutt. All rights reserved.
# Author: Gregory Nutt <spudmonkey@racsa.co.cr>
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in
# the documentation and/or other materials provided with the
# distribution.
# 3. Neither the name Gregory Nutt nor the names of its contributors may be
# used to endorse or promote products derived from this software
# without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
############################################################
#
# architecture selection
#
# CONFIG_ARCH - identifies the arch subdirectory and, hence, the
# processor architecture.
# CONFIG_ARCH_name - for use in C code. This identifies the
# particular chip or SoC that the architecture is implemented
# in.
# CONFIG_ARCH_CHIP - Identifies the arch/*/chip subdirectory
# CONFIG_ARCH_CHIP_name - For use in C code
# CONFIG_ARCH_BOARD - identifies the configs subdirectory and, hence,
# the board that supports the particular chip or SoC.
# CONFIG_ARCH_BOARD_name - for use in C code
# CONFIG_BOARD_LOOPSPERMSEC - for delay loops
# CONFIG_ENDIAN_BIG - define if big endian (default is little endian)
# CONFIG_ROM_VECTORS - unique to c5471
# CONFIG_DRAM_END - the size of installed DRAM.
# Unique to c5471
# CONFIG_ARCH_LEDS - Use LEDs to show state. Unique to c5471.
# CONFIG_ARCH_STACKDUMP - Do stack dumps after assertions
#
CONFIG_ARCH=arm
CONFIG_ARCH_ARM=y
CONFIG_ARCH_CHIP=c5471
CONFIG_ARCH_CHIP_C5471=y
CONFIG_ARCH_BOARD=c5471evm
CONFIG_ARCH_BOARD_C5471EVM=y
CONFIG_BOARD_LOOPSPERMSEC=1250
CONFIG_ROM_VECTORS=n
CONFIG_DRAM_END=0x11000000
CONFIG_ARCH_LEDS=y
CONFIG_ARCH_STACKDUMP=y
#
# C5471 specific device driver settings
#
# CONFIG_SERIAL_IRDA_CONSOLE - selects the IRDA UART for the
# console ant ttys0 (default is the modem UART).
# CONFIG_UART_*_HWFLOWCONTROL - enables hardware flow control
# CONFIG_UART_*_RXBUFSIZE - Characters are buffered as received.
# This specific the size of the receive buffer
# CONFIG_UART_*_TXBUFSIZE - Characters are buffered before
# being sent. This specific the size of the transmit buffer
# CONFIG_UART_*_BAUD - The configure BAUD of the UART. Must be
# CONFIG_UART_*_BITS - The number of bits. Must be either 7 or 8.
# CONFIG_UART_*_PARTIY - 0=no parity, 1=odd parity, 2=even parity
# CONFIG_UART_*_2STOP - Two stop bits
#
CONFIG_SERIAL_IRDA_CONSOLE=n
CONFIG_UART_IRDA_HWFLOWCONTROL=n
CONFIG_UART_MODEM_HWFLOWCONTROL=n
CONFIG_UART_IRDA_RXBUFSIZE=256
CONFIG_UART_MODEM_RXBUFSIZE=256
CONFIG_UART_IRDA_TXBUFSIZE=256
CONFIG_UART_MODEM_TXBUFSIZE=256
CONFIG_UART_IRDA_BAUD=115200
CONFIG_UART_MODEM_BAUD=115200
CONFIG_UART_IRDA_BITS=8
CONFIG_UART_MODEM_BITS=8
CONFIG_UART_IRDA_PARITY=0
CONFIG_UART_MODEM_PARITY=0
CONFIG_UART_IRDA_2STOP=0
CONFIG_UART_MODEM_2STOP=0
#
# General OS setup
#
# CONFIG_EXAMPLE - identifies the subdirectory in examples
# that will be used in the build
# CONFIG_DEBUG - enables built-in debug options
# CONFIG_DEBUG_VERBOSE - enables verbose debug output
# CONFIG_MM_REGIONS - If the architecture includes multiple
# regions of memory to allocate from, this specifies the
# number of memory regions that the memory manager must
# handle and enables the API mm_addregion(start, end);
# CONFIG_HAVE_LOWPUTC - architecture supports low-level, boot
# time console output
# CONFIG_TICKS_PER_MSEC - The default system timer is 100Hz
# or TICKS_PER_MSEC=10. This setting may be defined to
# inform NuttX that the processor hardware is providing
# system timer interrupts at some interrupt interval other
# than 10 msec.
# CONFIG_RR_INTERVAL - The round robin timeslice will be set
# this number of milliseconds; Round robin scheduling can
# be disabled by setting this value to zero.
# CONFIG_SCHED_INSTRUMENTATION - enables instrumentation in
# scheduler to monitor system performance
# CONFIG_TASK_NAME_SIZE - Spcifies that maximum size of a
# task name to save in the TCB. Useful if scheduler
# instrumentation is selected. Set to zero to disable.
# CONFIG_START_YEAR, CONFIG_START_MONTH, CONFIG_START_DAY -
# Used to initialize the internal time logic.
# CONFIG_JULIAN_TIME - Enables Julian time conversions
# CONFIG_DEV_CONSOLE - Set if architecture-specific logic
# provides /dev/console. Enables stdout, stderr, stdin.
#
CONFIG_EXAMPLE=nettest
CONFIG_DEBUG=n
CONFIG_DEBUG_VERBOSE=n
CONFIG_MM_REGIONS=1
CONFIG_ARCH_LOWPUTC=y
CONFIG_RR_INTERVAL=200
CONFIG_SCHED_INSTRUMENTATION=n
CONFIG_TASK_NAME_SIZE=0
CONFIG_START_YEAR=2007
CONFIG_START_MONTH=2
CONFIG_START_DAY=13
CONFIG_JULIAN_TIME=n
CONFIG_DEV_CONSOLE=y
#
# The following can be used to disable categories of
# APIs supported by the OS. If the compiler supports
# weak functions, then it should not be necessary to
# disable functions unless you want to restrict usage
# of those APIs.
#
# There are certain dependency relationships in these
# features.
#
# o mq_notify logic depends on signals to awaken tasks
# waiting for queues to become full or empty.
# o pthread_condtimedwait() depends on signals to wake
# up waiting tasks.
#
CONFIG_DISABLE_CLOCK=n
CONFIG_DISABLE_POSIX_TIMERS=n
CONFIG_DISABLE_PTHREAD=y
CONFIG_DISABLE_SIGNALS=n
CONFIG_DISABLE_MQUEUE=y
CONFIG_DISABLE_MOUNTPOINT=y
CONFIG_DISABLE_ENVIRON=y
#
# Misc libc settings
#
# CONFIG_NOPRINTF_FIELDWIDTH - sprintf-related logic is a
# little smaller if we do not support fieldwidthes
#
CONFIG_NOPRINTF_FIELDWIDTH=n
#
# Allow for architecture optimized implementations
#
# The architecture can provide optimized versions of the
# following to improve sysem performance
#
CONFIG_ARCH_MEMCPY=n
CONFIG_ARCH_MEMCMP=n
CONFIG_ARCH_MEMMOVE=n
CONFIG_ARCH_MEMSET=n
CONFIG_ARCH_STRCMP=n
CONFIG_ARCH_STRCPY=n
CONFIG_ARCH_STRNCPY=n
CONFIG_ARCH_STRLEN=n
CONFIG_ARCH_BZERO=n
CONFIG_ARCH_KMALLOC=n
CONFIG_ARCH_KZMALLOC=n
CONFIG_ARCH_KFREE=n
#
# General build options
#
# CONFIG_RRLOAD_BINARY - make the rrload binary format used with
# BSPs from www.ridgerun.com
#
CONFIG_RRLOAD_BINARY=y
#
# Sizes of configurable things (0 disables)
#
# CONFIG_MAX_TASKS - The maximum number of simultaneously
# active tasks. This value must be a power of two.
# CONFIG_MAX_TASK_ARGS - This controls the maximum number of
# of parameters that a task may receive (i.e., maxmum value
# of 'argc')
# CONFIG_NPTHREAD_KEYS - The number of items of thread-
# specific data that can be retained
# CONFIG_NFILE_DESCRIPTORS - The maximum number of file
# descriptors (one for each open)
# CONFIG_NFILE_STREAMS - The maximum number of streams that
# can be fopen'ed
# CONFIG_NAME_MAX - The maximum size of a file name.
# CONFIG_STDIO_BUFFER_SIZE - Size of the buffer to allocate
# on fopen. (Only if CONFIG_NFILE_STREAMS > 0)
# CONFIG_NUNGET_CHARS - Number of characters that can be
# buffered by ungetc() (Only if CONFIG_NFILE_STREAMS > 0)
# CONFIG_PREALLOC_MQ_MSGS - The number of pre-allocated message
# structures. The system manages a pool of preallocated
# message structures to minimize dynamic allocations
# CONFIG_MQ_MAXMSGSIZE - Message structures are allocated with
# a fixed payload size given by this settin (does not include
# other message structure overhead.
# CONFIG_MAX_WDOGPARMS - Maximum number of parameters that
# can be passed to a watchdog handler
# CONFIG_PREALLOC_WDOGS - The number of pre-allocated watchdog
# structures. The system manages a pool of preallocated
# watchdog structures to minimize dynamic allocations
# CONFIG_PREALLOC_TIMERS - The number of pre-allocated POSIX
# timer structures. The system manages a pool of preallocated
# timer structures to minimize dynamic allocations. Set to
# zero for all dynamic allocations.
#
CONFIG_MAX_TASKS=64
CONFIG_MAX_TASK_ARGS=4
CONFIG_NPTHREAD_KEYS=4
CONFIG_NFILE_DESCRIPTORS=8
CONFIG_NFILE_STREAMS=8
CONFIG_NAME_MAX=32
CONFIG_STDIO_BUFFER_SIZE=1024
CONFIG_NUNGET_CHARS=2
CONFIG_PREALLOC_MQ_MSGS=32
CONFIG_MQ_MAXMSGSIZE=32
CONFIG_MAX_WDOGPARMS=4
CONFIG_PREALLOC_WDOGS=8
CONFIG_PREALLOC_TIMERS=8
#
# TCP/IP and UDP support via uIP
# CONFIG_NET - Enable or disable all network features
# CONFIG_NET_IPv6 - Build in support for IPv6
# CONFIG_NSOCKET_DESCRIPTORS - Maximum number of socket descriptors per task/thread.
# CONFIG_NET_SOCKOPTS - Enable or disable support for socket options
# CONFIG_NET_BUFSIZE - uIP buffer size
# CONFIG_NET_TCP - TCP support on or off
# CONFIG_NET_TCP_CONNS - Maximum number of TCP connections (all tasks)
# CONFIG_NET_TCP_READAHEAD_BUFSIZE - Size of TCP read-ahead buffers
# CONFIG_NET_NTCP_READAHEAD_BUFFERS - Number of TCP read-ahead buffers (may be zero)
# CONFIG_NET_MAX_LISTENPORTS - Maximum number of listening TCP ports (all tasks)
# CONFIG_NET_UDP - UDP support on or off
# CONFIG_NET_UDP_CHECKSUMS - UDP checksums on or off
# CONFIG_NET_UDP_CONNS - The maximum amount of concurrent UDP connections
# CONFIG_NET_ICMP - ICMP ping support on or off
# CONFIG_NET_PINGADDRCONF - Use "ping" packet for setting IP address
# CONFIG_NET_STATISTICS - uIP statistics on or off
# CONFIG_NET_RECEIVE_WINDOW - The size of the advertised receiver's window
# CONFIG_NET_ARPTAB_SIZE - The size of the ARP table
# CONFIG_NET_BROADCAST - Broadcast support
# CONFIG_NET_LLH_LEN - The link level header length
# CONFIG_NET_FWCACHE_SIZE - number of packets to remember when looking for duplicates
CONFIG_NET=y
CONFIG_NET_IPv6=n
CONFIG_NSOCKET_DESCRIPTORS=8
CONFIG_NET_SOCKOPTS=y
CONFIG_NET_BUFSIZE=420
CONFIG_NET_TCP=y
CONFIG_NET_TCP_CONNS=8
CONFIG_NET_MAX_LISTENPORTS=8
CONFIG_NET_UDP=n
CONFIG_NET_UDP_CHECKSUMS=y
#CONFIG_NET_UDP_CONNS=10
CONFIG_NET_ICMP=y
#CONFIG_NET_PINGADDRCONF=0
CONFIG_NET_STATISTICS=n
#CONFIG_NET_RECEIVE_WINDOW=
#CONFIG_NET_ARPTAB_SIZE=8
CONFIG_NET_BROADCAST=n
#CONFIG_NET_LLH_LEN=14
#CONFIG_NET_FWCACHE_SIZE=2
#
# UIP Network Utilities
# CONFIG_NET_DHCP_LIGHT - Reduces size of DHCP
# CONFIG_NET_RESOLV_ENTRIES - Number of resolver entries
CONFIG_NET_DHCP_LIGHT=n
CONFIG_NET_RESOLV_ENTRIES=4
#
# Settings for examples/uip
CONFIG_EXAMPLE_UIP_IPADDR=(10<<24|0<<16|0<<8|2)
CONFIG_EXAMPLE_UIP_DRIPADDR=(10<<24|0<<16|0<<8|1)
CONFIG_EXAMPLE_UIP_NETMASK=(255<<24|255<<16|255<<8|0)
CONFIG_EXAMPLE_UIP_SMTP=n
CONFIG_EXAMPLE_UIP_TELNETD=n
CONFIG_EXAMPLE_UIP_WEBSERVER=y
CONFIG_EXAMPLE_UIP_DHCPC=n
CONFIG_EXAMPLE_UIP_WEBCLIENT=n
#
# Settings for examples/nettest
CONFIG_EXAMPLE_NETTEST_SERVER=n
CONFIG_EXAMPLE_NETTEST_PERFORMANCE=n
CONFIG_EXAMPLE_NETTEST_IPADDR=(10<<24|0<<16|0<<8|2)
CONFIG_EXAMPLE_NETTEST_DRIPADDR=(10<<24|0<<16|0<<8|1)
CONFIG_EXAMPLE_NETTEST_NETMASK=(255<<24|255<<16|255<<8|0)
CONFIG_EXAMPLE_NETTEST_CLIENTIP=(10<<24|0<<16|0<<8|1)
#
# Settings for examples/nsh
CONFIG_EXAMPLES_NSH_TELNET=n
CONFIG_EXAMPLES_NSH_IOBUFFER_SIZE=512
CONFIG_EXAMPLES_NSH_CMD_SIZE=40
CONFIG_EXAMPLES_NSH_STACKSIZE=4096
CONFIG_EXAMPLES_NSH_DHCPC=n
CONFIG_EXAMPLES_NSH_NOMAC=n
CONFIG_EXAMPLES_NSH_IPADDR=(10<<24|0<<16|0<<8|2)
CONFIG_EXAMPLES_NSH_DRIPADDR=(10<<24|0<<16|0<<8|1)
CONFIG_EXAMPLES_NSH_NETMASK=(255<<24|255<<16|255<<8|0)
#
# C5471 Ethernet Driver settings
CONFIG_C5471_NET_STATS=n
ETHERNET_PHY_LU3X31T_T64=1
ETHERNET_PHY_AC101L=2
CONFIG_C5471_ETHERNET_PHY=ETHERNET_PHY_LU3X31T_T64
CONFIG_NET_C5471_AUTONEGOTIATION=y
CONFIG_NET_C5471_BASET100=n
CONFIG_NET_C5471_BASET10=n
#
# Stack and heap information
#
# CONFIG_BOOT_FROM_FLASH - Some configurations support XIP
# operation from FLASH.
# CONFIG_CUSTOM_STACK - The up_ implementation will handle
# all stack operations outside of the nuttx model.
# CONFIG_STACK_POINTER - The initial stack pointer (arm7tdmi only)
# CONFIG_PROC_STACK_SIZE - The size of the initial stack
# CONFIG_PTHREAD_STACK_MIN - Minimum pthread stack size
# CONFIG_PTHREAD_STACK_DEFAULT - Default pthread stack size
# CONFIG_HEAP_BASE - The beginning of the heap
# CONFIG_HEAP_SIZE - The size of the heap
#
CONFIG_BOOT_FROM_FLASH=n
CONFIG_CUSTOM_STACK=n
CONFIG_STACK_POINTER=
CONFIG_PROC_STACK_SIZE=4096
CONFIG_PTHREAD_STACK_MIN=256
CONFIG_PTHREAD_STACK_DEFAULT=4096
CONFIG_HEAP_BASE=
CONFIG_HEAP_SIZE=

View file

@ -25,13 +25,14 @@ uipconfig
This configuration file demonstrates the tiny webserver
at examples/uip.
These alternative configurations can be selected by
(Seleted the default configuration as show above)
cp config/ntosd-dm320/uiponfig .config
udpconfig
^^^^^^^^^
This alternative configuration file, is similar to netconfig
except that is use examples/upd to exercise UDP.
These alternative configurations can be selected by (using
uipconfig as example):
(Seleted the default configuration as show above)
cp config/ntosd-dm320/uipconfig .config

View file

@ -1,5 +1,5 @@
############################################################
# defconfig
# configs/ntosd-dm320/defconfig
#
# Copyright (C) 2007 Gregory Nutt. All rights reserved.
# Author: Gregory Nutt <spudmonkey@racsa.co.cr>

View file

@ -1,5 +1,5 @@
############################################################
# arch/ntosd-dm320/netconfig
# configs/ntosd-dm320/netconfig
#
# Copyright (C) 2007 Gregory Nutt. All rights reserved.
# Author: Gregory Nutt <spudmonkey@racsa.co.cr>

View file

@ -1,5 +1,5 @@
############################################################
# arch/ntosd-dm320/udpconfig
# configs/ntosd-dm320/udpconfig
#
# Copyright (C) 2007 Gregory Nutt. All rights reserved.
# Author: Gregory Nutt <spudmonkey@racsa.co.cr>

View file

@ -1,5 +1,5 @@
############################################################
# arch/ntosd-dm320/uipconfig
# configs/ntosd-dm320/uipconfig
#
# Copyright (C) 2007 Gregory Nutt. All rights reserved.
# Author: Gregory Nutt <spudmonkey@racsa.co.cr>

View file

@ -1105,7 +1105,11 @@ static void dm9x_txdone(struct dm9x_driver_s *dm9x)
static int dm9x_interrupt(int irq, FAR void *context)
{
#if CONFIG_C5471_NET_NINTERFACES == 1
register struct dm9x_driver_s *dm9x = &g_dm9x[0];
#else
# error "Additional logic needed to support multiple interfaces"
#endif
uint8 isr;
uint8 save;
int i;

View file

@ -197,7 +197,7 @@ static uint8 send_interrupt(struct uip_driver_s *dev, struct uip_conn *conn,
{
struct send_s *pstate = (struct send_s *)conn->data_private;
nvdbg("flags: %02x state: %d\n", flags, pstate->snd_state);
nvdbg("flags: %02x acked: %d sent: %d\n", flags, pstate->snd_acked, pstate->snd_sent);
/* If this packet contains an acknowledgement, then update the count of
* acknowldged bytes.