mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2025-04-19 21:11:57 -04:00
Zynq demo: Fix Xilinx network driver by deferring the function that allocated memory from the interrupt into a task. Add DHCP option.
This commit is contained in:
parent
f1a0534a56
commit
de7df3cfda
|
@ -117,7 +117,7 @@
|
|||
#define configUSE_TICK_HOOK 1
|
||||
#define configMAX_PRIORITIES ( 7 )
|
||||
#define configMINIMAL_STACK_SIZE ( ( unsigned short ) 200 )
|
||||
#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 80 * 1024 ) )
|
||||
#define configTOTAL_HEAP_SIZE ( 80 * 1024 )
|
||||
#define configMAX_TASK_NAME_LEN ( 10 )
|
||||
#define configUSE_TRACE_FACILITY 1
|
||||
#define configUSE_16_BIT_TICKS 0
|
||||
|
@ -165,7 +165,7 @@ extern XScuWdt xWatchDogInstance;
|
|||
extern void vInitialiseTimerForRunTimeStats( void );
|
||||
#define configGENERATE_RUN_TIME_STATS 1
|
||||
#define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() vInitialiseTimerForRunTimeStats()
|
||||
#define portGET_RUN_TIME_COUNTER_VALUE() ( 0xffffffffUL - XScuWdt_ReadReg( xWatchDogInstance.Config.BaseAddr, XSCUWDT_COUNTER_OFFSET ) )
|
||||
#define portGET_RUN_TIME_COUNTER_VALUE() ( ( 0xffffffffUL - XScuWdt_ReadReg( xWatchDogInstance.Config.BaseAddr, XSCUWDT_COUNTER_OFFSET ) ) >> 1 )
|
||||
|
||||
/* The size of the global output buffer that is available for use when there
|
||||
are multiple command interpreters running at once (for example, one on a UART
|
||||
|
|
|
@ -140,7 +140,7 @@ XUartPs_Config *pxConfig;
|
|||
the semaphore so it is in the correct state the first time
|
||||
xSerialSendString() is called. A block time of zero is used when taking
|
||||
the semaphore as it is guaranteed to be available (it was just created). */
|
||||
xTxCompleteSemaphore = xSemaphoreCreateMutex();
|
||||
xTxCompleteSemaphore = xSemaphoreCreateBinary();
|
||||
configASSERT( xTxCompleteSemaphore );
|
||||
xSemaphoreTake( xTxCompleteSemaphore, 0 );
|
||||
|
||||
|
@ -208,7 +208,7 @@ const TickType_t xMaxWait = 200UL / portTICK_PERIOD_MS;
|
|||
otherwise there is a risk the calling function will overwrite the string
|
||||
pointed to by the pcString parameter while it is still being transmitted.
|
||||
The calling task will wait in the Blocked state (so not consuming any
|
||||
processing time) until the mutex is available. */
|
||||
processing time) until the semaphore is available. */
|
||||
xSemaphoreTake( xTxCompleteSemaphore, xMaxWait );
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
@ -221,7 +221,7 @@ signed portBASE_TYPE xSerialPutChar( xComPortHandle pxPort, signed char cOutChar
|
|||
/* Send the character. */
|
||||
XUartPs_Send( &xUARTInstance, ( void * ) &cOutChar, sizeof( cOutChar ) );
|
||||
|
||||
/* Wait for the transmission to be complete so the mutex is left in the
|
||||
/* Wait for the transmission to be complete so the semaphore is left in the
|
||||
correct state for the next time vSerialPutString() is called. */
|
||||
xSemaphoreTake( xTxCompleteSemaphore, xBlockTime );
|
||||
|
||||
|
|
|
@ -67,7 +67,7 @@
|
|||
#include "FreeRTOS_CLI.h"
|
||||
|
||||
/* Dimensions the buffer into which input characters are placed. */
|
||||
#define cmdMAX_INPUT_SIZE 20
|
||||
#define cmdMAX_INPUT_SIZE 100
|
||||
|
||||
/* Dimensions the buffer into which string outputs can be placed. */
|
||||
#define cmdMAX_OUTPUT_SIZE 1024
|
||||
|
|
|
@ -62,6 +62,7 @@
|
|||
/* lwIP core includes */
|
||||
#include "lwip/opt.h"
|
||||
#include "lwip/tcpip.h"
|
||||
#include "lwip/inet.h"
|
||||
|
||||
/* applications includes */
|
||||
#include "apps/httpserver_raw_from_lwIP_download/httpd.h"
|
||||
|
@ -121,6 +122,21 @@ static signed char cTxBuffer[ lwipappsTX_BUFFER_SIZE ];
|
|||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void vStatusCallback( struct netif *pxNetIf )
|
||||
{
|
||||
char pcMessage[20];
|
||||
|
||||
if( netif_is_up( pxNetIf ) != 0 )
|
||||
{
|
||||
strcpy( pcMessage, "IP=" );
|
||||
strcat( pcMessage, inet_ntoa( *( struct in_addr* ) &( pxNetIf->ip_addr ) ) );
|
||||
xil_printf( pcMessage );
|
||||
}
|
||||
else
|
||||
{
|
||||
xil_printf( "Network is down" );
|
||||
}
|
||||
}
|
||||
|
||||
/* Called from the TCP/IP thread. */
|
||||
void lwIPAppsInit( void *pvArgument )
|
||||
|
@ -151,7 +167,16 @@ static struct netif xNetIf;
|
|||
xNetIf.hwaddr[ 5 ] = configMAC_ADDR5;
|
||||
|
||||
netif_set_default( netif_add( &xNetIf, &xIPAddr, &xNetMask, &xGateway, ( void * ) XPAR_XEMACPS_0_BASEADDR, xemacpsif_init, tcpip_input ) );
|
||||
netif_set_status_callback( &xNetIf, vStatusCallback );
|
||||
#if LWIP_DHCP
|
||||
{
|
||||
dhcp_start( &xNetIf );
|
||||
}
|
||||
#else
|
||||
{
|
||||
netif_set_up( &xNetIf );
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Install the server side include handler. */
|
||||
http_set_ssi_handler( uslwIPAppsSSIHandler, pccSSITags, sizeof( pccSSITags ) / sizeof( char * ) );
|
||||
|
|
|
@ -124,6 +124,12 @@ void process_sent_bds(XEmacPs_BdRing *txring)
|
|||
return;
|
||||
}
|
||||
|
||||
void vPendableSendCompleteFunction( void *pvParameter, uint32_t ulParameter )
|
||||
{
|
||||
( void ) ulParameter;
|
||||
process_sent_bds(pvParameter);
|
||||
}
|
||||
|
||||
void emacps_send_handler(void *arg)
|
||||
{
|
||||
struct xemac_s *xemac;
|
||||
|
@ -139,11 +145,19 @@ void emacps_send_handler(void *arg)
|
|||
regval = XEmacPs_ReadReg(xemacpsif->emacps.Config.BaseAddress, XEMACPS_TXSR_OFFSET);
|
||||
XEmacPs_WriteReg(xemacpsif->emacps.Config.BaseAddress,XEMACPS_TXSR_OFFSET, regval);
|
||||
|
||||
/* If Transmit done interrupt is asserted, process completed BD's */
|
||||
process_sent_bds(TxRingPtr);
|
||||
#ifdef OS_IS_FREERTOS
|
||||
xInsideISR--;
|
||||
#endif
|
||||
|
||||
/* If Transmit done interrupt is asserted, process completed BD's - Replaced
|
||||
a call to process_sent_bds(TxRingPtr); with a pendable function to prevent
|
||||
the memory allocation files being accessed from the ISR with not redress if
|
||||
obtaining the mutex fails. */
|
||||
{
|
||||
BaseType_t xHigherPriorityTaskWoken = pdFALSE;
|
||||
xTimerPendFunctionCallFromISR( vPendableSendCompleteFunction, TxRingPtr, 0, &xHigherPriorityTaskWoken );
|
||||
portYIELD_FROM_ISR( xHigherPriorityTaskWoken );
|
||||
}
|
||||
}
|
||||
|
||||
XStatus emacps_sgsend(xemacpsif_s *xemacpsif, struct pbuf *p)
|
||||
|
|
|
@ -69,35 +69,36 @@ void vLwipAppsReleaseTxBuffer( void );
|
|||
#define LWIP_SO_RCVTIMEO 1
|
||||
#define LWIP_SO_RCVBUF 1
|
||||
|
||||
//#define LWIP_DEBUG
|
||||
#ifdef LWIP_DEBUG
|
||||
|
||||
#define LWIP_DBG_MIN_LEVEL 0
|
||||
#define PPP_DEBUG LWIP_DBG_ON
|
||||
#define MEM_DEBUG LWIP_DBG_ON
|
||||
#define MEMP_DEBUG LWIP_DBG_ON
|
||||
#define PBUF_DEBUG LWIP_DBG_ON
|
||||
#define API_LIB_DEBUG LWIP_DBG_ON
|
||||
#define API_MSG_DEBUG LWIP_DBG_ON
|
||||
#define TCPIP_DEBUG LWIP_DBG_ON
|
||||
#define NETIF_DEBUG LWIP_DBG_ON
|
||||
#define SOCKETS_DEBUG LWIP_DBG_ON
|
||||
#define DNS_DEBUG LWIP_DBG_ON
|
||||
#define AUTOIP_DEBUG LWIP_DBG_ON
|
||||
#define LWIP_DBG_MIN_LEVEL LWIP_DBG_LEVEL_ALL // LWIP_DBG_LEVEL_SERIOUS
|
||||
#define PPP_DEBUG LWIP_DBG_OFF
|
||||
#define MEM_DEBUG LWIP_DBG_OFF
|
||||
#define MEMP_DEBUG LWIP_DBG_OFF
|
||||
#define PBUF_DEBUG LWIP_DBG_OFF
|
||||
#define API_LIB_DEBUG LWIP_DBG_OFF
|
||||
#define API_MSG_DEBUG LWIP_DBG_OFF
|
||||
#define TCPIP_DEBUG LWIP_DBG_OFF
|
||||
#define NETIF_DEBUG LWIP_DBG_OFF
|
||||
#define SOCKETS_DEBUG LWIP_DBG_OFF
|
||||
#define DNS_DEBUG LWIP_DBG_OFF
|
||||
#define AUTOIP_DEBUG LWIP_DBG_OFF
|
||||
#define DHCP_DEBUG LWIP_DBG_ON
|
||||
#define IP_DEBUG LWIP_DBG_ON
|
||||
#define IP_REASS_DEBUG LWIP_DBG_ON
|
||||
#define ICMP_DEBUG LWIP_DBG_ON
|
||||
#define IGMP_DEBUG LWIP_DBG_ON
|
||||
#define UDP_DEBUG LWIP_DBG_ON
|
||||
#define TCP_DEBUG LWIP_DBG_ON
|
||||
#define TCP_INPUT_DEBUG LWIP_DBG_ON
|
||||
#define TCP_OUTPUT_DEBUG LWIP_DBG_ON
|
||||
#define TCP_RTO_DEBUG LWIP_DBG_ON
|
||||
#define TCP_CWND_DEBUG LWIP_DBG_ON
|
||||
#define TCP_WND_DEBUG LWIP_DBG_ON
|
||||
#define TCP_FR_DEBUG LWIP_DBG_ON
|
||||
#define TCP_QLEN_DEBUG LWIP_DBG_ON
|
||||
#define TCP_RST_DEBUG LWIP_DBG_ON
|
||||
#define IP_DEBUG LWIP_DBG_OFF
|
||||
#define IP_REASS_DEBUG LWIP_DBG_OFF
|
||||
#define ICMP_DEBUG LWIP_DBG_OFF
|
||||
#define IGMP_DEBUG LWIP_DBG_OFF
|
||||
#define UDP_DEBUG LWIP_DBG_OFF
|
||||
#define TCP_DEBUG LWIP_DBG_OFF
|
||||
#define TCP_INPUT_DEBUG LWIP_DBG_OFF
|
||||
#define TCP_OUTPUT_DEBUG LWIP_DBG_OFF
|
||||
#define TCP_RTO_DEBUG LWIP_DBG_OFF
|
||||
#define TCP_CWND_DEBUG LWIP_DBG_OFF
|
||||
#define TCP_WND_DEBUG LWIP_DBG_OFF
|
||||
#define TCP_FR_DEBUG LWIP_DBG_OFF
|
||||
#define TCP_QLEN_DEBUG LWIP_DBG_OFF
|
||||
#define TCP_RST_DEBUG LWIP_DBG_OFF
|
||||
#endif
|
||||
|
||||
#define LWIP_DBG_TYPES_ON (LWIP_DBG_ON|LWIP_DBG_TRACE|LWIP_DBG_STATE|LWIP_DBG_FRESH|LWIP_DBG_HALT)
|
||||
|
@ -306,4 +307,6 @@ a lot of data that needs to be copied, this should be set high. */
|
|||
|
||||
#endif /* PPP_SUPPORT */
|
||||
|
||||
#define LWIP_NETIF_STATUS_CALLBACK 1
|
||||
|
||||
#endif /* __LWIPOPTS_H__ */
|
||||
|
|
|
@ -124,7 +124,7 @@
|
|||
*
|
||||
* When mainSELECTED_APPLICATION is set to 2 the lwIP example will be run.
|
||||
*/
|
||||
#define mainSELECTED_APPLICATION 2
|
||||
#define mainSELECTED_APPLICATION 1
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
|
|
Loading…
Reference in a new issue