Start to configure the uIP demo for the RX RDK hardware. ping is working, but thus far the web server is not.

This commit is contained in:
Richard Barry 2010-09-05 20:06:30 +00:00
parent 2e0af9b6e6
commit a4893aed60
8 changed files with 153 additions and 85 deletions

View file

@ -55,7 +55,6 @@
#include "iodefine.h"
#include "typedefine.h"
#include "r_ether.h"
#include "phy.h"
/* FreeRTOS includes. */
#include "FreeRTOS.h"
@ -95,28 +94,24 @@ become free. */
/*-----------------------------------------------------------*/
/* The buffers and descriptors themselves. */
static union x_RX_Desc
{
unsigned long long ullAlignmentVariable;
ethfifo xDescriptorArray[ emacNUM_RX_DESCRIPTORS ];
} xRxDescriptors;
/* The buffers and descriptors themselves. */
#pragma section _RX_DESC
volatile ethfifo xRxDescriptors[ emacNUM_RX_DESCRIPTORS ];
#pragma section _TX_DESC
volatile ethfifo xTxDescriptors[ emacNUM_TX_BUFFERS ];
#pragma section _ETHERNET_BUFFERS
struct
{
unsigned long ulAlignmentVariable;
char cBuffer[ emacNUM_BUFFERS ][ UIP_BUFSIZE ];
} xEthernetBuffers;
#pragma section
static union x_TX_Desc
{
unsigned long long ullAlignmentVariable;
ethfifo xDescriptorArray[ emacNUM_TX_BUFFERS ];
} xTxDescriptors;
static union x_ETH_Buffers
{
unsigned long long ullAlignmentVariable;
char xDataBuffers[ emacNUM_BUFFERS ][ UIP_BUFSIZE ];
} xEthernetBuffers;
/* Used to indicate which buffers are free and which are in use. If an index
contains 0 then the corresponding buffer in xEthernetBuffers.xDataBuffers is free, otherwise
contains 0 then the corresponding buffer in xEthernetBuffers is free, otherwise
the buffer is in use or about to be used. */
static unsigned char ucBufferInUse[ emacNUM_BUFFERS ];
@ -128,7 +123,7 @@ static unsigned char ucBufferInUse[ emacNUM_BUFFERS ];
static void prvInitialiseDescriptors( void );
/*
* Return a pointer to a free buffer within xEthernetBuffers.xDataBuffers.
* Return a pointer to a free buffer within xEthernetBuffers.
*/
static unsigned char *prvGetNextBuffer( void );
@ -204,7 +199,7 @@ long x;
/* Wait until the second transmission of the last packet has completed. */
for( x = 0; x < emacTX_WAIT_ATTEMPTS; x++ )
{
if( ( xTxDescriptors.xDescriptorArray[ 1 ].status & ACT ) != 0 )
if( ( xTxDescriptors[ 1 ].status & ACT ) != 0 )
{
/* Descriptor is still active. */
vTaskDelay( emacTX_WAIT_DELAY_ms );
@ -216,27 +211,27 @@ long x;
}
/* Is the descriptor free after waiting for it? */
if( ( xTxDescriptors.xDescriptorArray[ 1 ].status & ACT ) != 0 )
if( ( xTxDescriptors[ 1 ].status & ACT ) != 0 )
{
/* Something has gone wrong. */
prvResetEverything();
}
/* Setup both descriptors to transmit the frame. */
xTxDescriptors.xDescriptorArray[ 0 ].buf_p = ( char * ) uip_buf;
xTxDescriptors.xDescriptorArray[ 0 ].bufsize = uip_len;
xTxDescriptors.xDescriptorArray[ 1 ].buf_p = ( char * ) uip_buf;
xTxDescriptors.xDescriptorArray[ 1 ].bufsize = uip_len;
xTxDescriptors[ 0 ].buf_p = ( char * ) uip_buf;
xTxDescriptors[ 0 ].bufsize = uip_len;
xTxDescriptors[ 1 ].buf_p = ( char * ) uip_buf;
xTxDescriptors[ 1 ].bufsize = uip_len;
/* uip_buf is being sent by the Tx descriptor. Allocate a new buffer
for use by the stack. */
uip_buf = prvGetNextBuffer();
/* Clear previous settings and go. */
xTxDescriptors.xDescriptorArray[0].status &= ~( FP1 | FP0 );
xTxDescriptors.xDescriptorArray[0].status |= ( FP1 | FP0 | ACT );
xTxDescriptors.xDescriptorArray[1].status &= ~( FP1 | FP0 );
xTxDescriptors.xDescriptorArray[1].status |= ( FP1 | FP0 | ACT );
xTxDescriptors[0].status &= ~( FP1 | FP0 );
xTxDescriptors[0].status |= ( FP1 | FP0 | ACT );
xTxDescriptors[1].status &= ~( FP1 | FP0 );
xTxDescriptors[1].status |= ( FP1 | FP0 | ACT );
EDMAC.EDTRR.LONG = 0x00000001;
}
@ -282,15 +277,28 @@ long lReturn;
{
/* Half duplex link */
case PHY_LINK_100H:
case PHY_LINK_10H:
ETHERC.ECMR.BIT.DM = 0;
ETHERC.ECMR.BIT.RTM = 1;
lReturn = pdPASS;
break;
case PHY_LINK_10H:
ETHERC.ECMR.BIT.DM = 0;
ETHERC.ECMR.BIT.RTM = 0;
lReturn = pdPASS;
break;
/* Full duplex link */
case PHY_LINK_100F:
ETHERC.ECMR.BIT.DM = 1;
ETHERC.ECMR.BIT.RTM = 1;
lReturn = pdPASS;
break;
case PHY_LINK_10F:
ETHERC.ECMR.BIT.DM = 1;
ETHERC.ECMR.BIT.RTM = 0;
lReturn = pdPASS;
break;
@ -327,13 +335,13 @@ long x;
/* Initialise the Rx descriptors. */
for( x = 0; x < emacNUM_RX_DESCRIPTORS; x++ )
{
pxDescriptor = &( xRxDescriptors.xDescriptorArray[ x ] );
pxDescriptor->buf_p = &( xEthernetBuffers.xDataBuffers[ x ][ 0 ] );
pxDescriptor = &( xRxDescriptors[ x ] );
pxDescriptor->buf_p = &( xEthernetBuffers.cBuffer[ x ][ 0 ] );
pxDescriptor->bufsize = UIP_BUFSIZE;
pxDescriptor->size = 0;
pxDescriptor->status = ACT;
pxDescriptor->next = &xRxDescriptors.xDescriptorArray[ x + 1 ];
pxDescriptor->next = &xRxDescriptors[ x + 1 ];
/* Mark this buffer as in use. */
ucBufferInUse[ x ] = pdTRUE;
@ -341,12 +349,12 @@ long x;
/* The last descriptor points back to the start. */
pxDescriptor->status |= DL;
pxDescriptor->next = &xRxDescriptors.xDescriptorArray[ 0 ];
pxDescriptor->next = &xRxDescriptors[ 0 ];
/* Initialise the Tx descriptors. */
for( x = 0; x < emacNUM_TX_BUFFERS; x++ )
{
pxDescriptor = &( xTxDescriptors.xDescriptorArray[ x ] );
pxDescriptor = &( xTxDescriptors[ x ] );
/* A buffer is not allocated to the Tx descriptor until a send is
actually required. */
@ -355,15 +363,15 @@ long x;
pxDescriptor->bufsize = UIP_BUFSIZE;
pxDescriptor->size = 0;
pxDescriptor->status = 0;
pxDescriptor->next = &xTxDescriptors.xDescriptorArray[ x + 1 ];
pxDescriptor->next = &xTxDescriptors[ x + 1 ];
}
/* The last descriptor points back to the start. */
pxDescriptor->status |= DL;
pxDescriptor->next = &( xTxDescriptors.xDescriptorArray[ 0 ] );
pxDescriptor->next = &( xTxDescriptors[ 0 ] );
/* Use the first Rx descriptor to start with. */
xCurrentRxDesc = &( xRxDescriptors.xDescriptorArray[ 0 ] );
xCurrentRxDesc = &( xRxDescriptors[ 0 ] );
}
/*-----------------------------------------------------------*/
@ -382,7 +390,7 @@ unsigned long ulAttempts = 0;
if( ucBufferInUse[ x ] == pdFALSE )
{
ucBufferInUse[ x ] = pdTRUE;
pucReturn = ( unsigned char * ) &( xEthernetBuffers.xDataBuffers[ x ][ 0 ] );
pucReturn = ( unsigned char * ) &( xEthernetBuffers.cBuffer[ x ][ 0 ] );
break;
}
}
@ -413,7 +421,7 @@ unsigned long ul;
/* Return a buffer to the pool of free buffers. */
for( ul = 0; ul < emacNUM_BUFFERS; ul++ )
{
if( &( xEthernetBuffers.xDataBuffers[ ul ][ 0 ] ) == ( void * ) pucBuffer )
if( &( xEthernetBuffers.cBuffer[ ul ][ 0 ] ) == ( void * ) pucBuffer )
{
ucBufferInUse[ ul ] = pdFALSE;
break;
@ -503,12 +511,18 @@ static void prvConfigureEtherCAndEDMAC( void )
/* EDMAC */
EDMAC.EESR.LONG = 0x47FF0F9F; /* Clear all ETHERC and EDMAC status bits */
#ifdef __LIT
EDMAC.EDMR.BIT.DE = 1;
#endif
EDMAC.RDLAR = ( void * ) xCurrentRxDesc; /* Initialaize Rx Descriptor List Address */
EDMAC.TDLAR = &( xTxDescriptors.xDescriptorArray[ 0 ] ); /* Initialaize Tx Descriptor List Address */
EDMAC.TDLAR = &( xTxDescriptors[ 0 ] ); /* Initialaize Tx Descriptor List Address */
EDMAC.TRSCER.LONG = 0x00000000; /* Copy-back status is RFE & TFE only */
EDMAC.TFTR.LONG = 0x00000000; /* Threshold of Tx_FIFO */
EDMAC.FDR.LONG = 0x00000000; /* Transmit fifo & receive fifo is 256 bytes */
EDMAC.RMCR.LONG = 0x00000003; /* Receive function is normal mode(continued) */
/* Enable the interrupt... */
_IEN( _ETHER_EINT ) = 1;
}
/*-----------------------------------------------------------*/
@ -527,7 +541,7 @@ static long ulTxEndInts = 0;
if( ulTxEndInts >= 2 )
{
/* Only return the buffer to the pool once both Txes have completed. */
prvReturnBuffer( ( void * ) xTxDescriptors.xDescriptorArray[ 0 ].buf_p );
prvReturnBuffer( ( void * ) xTxDescriptors[ 0 ].buf_p );
ulTxEndInts = 0;
}
EDMAC.EESR.LONG = emacTX_END_INTERRUPT;
@ -542,3 +556,4 @@ static long ulTxEndInts = 0;
EDMAC.EESR.LONG = emacRX_END_INTERRUPT;
}
}

View file

@ -114,7 +114,7 @@ typedef unsigned short uip_stats_t;
*
* \hideinitializer
*/
#define UIP_CONF_BYTE_ORDER UIP_BIG_ENDIAN
#define UIP_CONF_BYTE_ORDER UIP_LITTLE_ENDIAN
/**
* Logging on or off