licensing and training services.\r
*/\r
\r
-#if 0\r
-\r
-//_RB_\r
-\r
/* FreeRTOS includes. */\r
#include "FreeRTOS.h"\r
#include "task.h"\r
#include "queue.h"\r
\r
+/* BSP includes. */\r
+#include "xemaclite.h"\r
+\r
/* lwIP includes. */\r
#include "lwip/opt.h"\r
#include "lwip/def.h"\r
#include <lwip/stats.h>\r
#include <lwip/snmp.h>\r
#include "netif/etharp.h"\r
-#include "netif/ppp_oe.h"\r
\r
/* Define those to better describe your network interface. */\r
-#define IFNAME0 'w'\r
-#define IFNAME1 'p'\r
+#define IFNAME0 'e'\r
+#define IFNAME1 'l'\r
\r
#define netifMAX_MTU 1500\r
\r
-struct ethernetif \r
+struct xEthernetIf\r
{\r
struct eth_addr *ethaddr;\r
/* Add whatever per-interface state that is needed here. */\r
};\r
\r
-/* Forward declarations. */\r
-static void ethernetif_input( const unsigned char * const pucInputData, long lLength );\r
-static struct pbuf *low_level_input( const unsigned char * const pucInputData, long lDataLength );\r
-\r
/*\r
- * Query the computer the simulation is being executed on to find the network\r
- * interfaces it has installed.\r
+ * Place received packet in a pbuf and send a message to the tcpip task to let\r
+ * it know new data has arrived.\r
*/\r
-static pcap_if_t * prvPrintAvailableNetworkInterfaces( void );\r
+static void prvEthernetInput( struct netif *pxNetIf, const unsigned char * const pucInputData, long lInputLength );\r
\r
/*\r
- * Open the network interface. The number of the interface to be opened is set\r
- * by the configNETWORK_INTERFACE_TO_USE constant in FreeRTOSConfig.h.\r
+ * Copy the received data into a pbuf.\r
*/\r
-static void prvOpenSelectedNetworkInterface( pcap_if_t *pxAllNetworkInterfaces );\r
+static struct pbuf *prvLowLevelInput( const unsigned char * const pucInputData, long lDataLength );\r
\r
/*\r
- * Interrupts cannot truely be simulated using WinPCap. In reality this task\r
- * just polls the interface. \r
+ * Send data from a pbuf to the hardware.\r
*/\r
-static void prvInterruptSimulator( void *pvParameters );\r
+static err_t prvLowLevelOutput( struct netif *pxNetIf, struct pbuf *p );\r
+\r
/*\r
- * Configure the capture filter to allow blocking reads, and to filter out\r
- * packets that are not of interest to this demo.\r
+ * Perform any hardware and/or driver initialisation necessary.\r
*/\r
-static void prvConfigureCaptureBehaviour( void );\r
-\r
-/* The WinPCap interface being used. */\r
-static pcap_t *pxOpenedInterfaceHandle = NULL;\r
+static void prvLowLevelInit( struct netif *pxNetIf );\r
\r
-/* Parameter required for WinPCap API functions. */\r
-static char cErrorBuffer[ PCAP_ERRBUF_SIZE ];\r
-\r
-/* The network interface that was opened. */\r
-static struct netif *xlwIPNetif = NULL;\r
+/*-----------------------------------------------------------*/\r
\r
/**\r
* In this function, the hardware should be initialized.\r
* Called from ethernetif_init().\r
*\r
- * @param netif the already initialized lwip network interface structure\r
- * for this ethernetif\r
+ * @param pxNetIf the already initialized lwip network interface structure\r
+ * for this etherpxNetIf\r
*/\r
-static void low_level_init(struct netif *netif)\r
+static void prvLowLevelInit( struct netif *pxNetIf )\r
{\r
-pcap_if_t *pxAllNetworkInterfaces;\r
- \r
/* set MAC hardware address length */\r
- netif->hwaddr_len = ETHARP_HWADDR_LEN;\r
+ pxNetIf->hwaddr_len = ETHARP_HWADDR_LEN;\r
\r
/* set MAC hardware address */\r
- netif->hwaddr[ 0 ] = configMAC_ADDR0;\r
- netif->hwaddr[ 1 ] = configMAC_ADDR1;\r
- netif->hwaddr[ 2 ] = configMAC_ADDR2;\r
- netif->hwaddr[ 3 ] = configMAC_ADDR3;\r
- netif->hwaddr[ 4 ] = configMAC_ADDR4;\r
- netif->hwaddr[ 5 ] = configMAC_ADDR5;\r
+ pxNetIf->hwaddr[ 0 ] = configMAC_ADDR0;\r
+ pxNetIf->hwaddr[ 1 ] = configMAC_ADDR1;\r
+ pxNetIf->hwaddr[ 2 ] = configMAC_ADDR2;\r
+ pxNetIf->hwaddr[ 3 ] = configMAC_ADDR3;\r
+ pxNetIf->hwaddr[ 4 ] = configMAC_ADDR4;\r
+ pxNetIf->hwaddr[ 5 ] = configMAC_ADDR5;\r
\r
/* device capabilities */\r
- /* don't set NETIF_FLAG_ETHARP if this device is not an ethernet one */\r
- netif->flags = NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP | NETIF_FLAG_LINK_UP;\r
- \r
- /* Query the computer the simulation is being executed on to find the \r
+ /* don't set pxNetIf_FLAG_ETHARP if this device is not an ethernet one */\r
+ pxNetIf->flags = NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP | NETIF_FLAG_LINK_UP;\r
+\r
+#if 0\r
+_RB_\r
+\r
+ /* Query the computer the simulation is being executed on to find the\r
network interfaces it has installed. */\r
pxAllNetworkInterfaces = prvPrintAvailableNetworkInterfaces();\r
- \r
- /* Open the network interface. The number of the interface to be opened is \r
+\r
+ /* Open the network interface. The number of the interface to be opened is\r
set by the configNETWORK_INTERFACE_TO_USE constant in FreeRTOSConfig.h.\r
Calling this function will set the pxOpenedInterfaceHandle variable. If,\r
after calling this function, pxOpenedInterfaceHandle is equal to NULL, then\r
prvOpenSelectedNetworkInterface( pxAllNetworkInterfaces );\r
}\r
\r
- /* Remember which interface was opened as it is used in the interrupt \r
+ /* Remember which interface was opened as it is used in the interrupt\r
simulator task. */\r
- xlwIPNetif = netif;\r
+ pxlwIPNetIf = pxNetIf;\r
+#endif\r
}\r
\r
/**\r
* contained in the pbuf that is passed to the function. This pbuf\r
* might be chained.\r
*\r
- * @param netif the lwip network interface structure for this ethernetif\r
+ * @param pxNetIf the lwip network interface structure for this etherpxNetIf\r
* @param p the MAC packet to send (e.g. IP packet including MAC addresses and type)\r
* @return ERR_OK if the packet could be sent\r
- * an err_t value if the packet couldn't be sent\r
+ * an err_t value if the packet couldn't be sent\r
*\r
* @note Returning ERR_MEM here if a DMA queue of your MAC is full can lead to\r
- * strange results. You might consider waiting for space in the DMA queue\r
- * to become availale since the stack doesn't retry to send a packet\r
- * dropped because of memory failure (except for the TCP timers).\r
+ * strange results. You might consider waiting for space in the DMA queue\r
+ * to become availale since the stack doesn't retry to send a packet\r
+ * dropped because of memory failure (except for the TCP timers).\r
*/\r
\r
-static err_t low_level_output(struct netif *netif, struct pbuf *p)\r
+static err_t prvLowLevelOutput( struct netif *pxNetIf, struct pbuf *p )\r
{\r
\r
/* This is taken from lwIP example code and therefore does not conform\r
to the FreeRTOS coding standard. */\r
\r
struct pbuf *q;\r
-static unsigned char buffer[ 1520 ];\r
-unsigned char *buf = buffer;\r
-unsigned char *ptr;\r
-struct eth_hdr *ethhdr;\r
-u16_t tot_len = p->tot_len - ETH_PAD_SIZE;\r
+static unsigned char ucBuffer[ 1520 ];\r
+unsigned char *pucBuffer = ucBuffer;\r
+unsigned char *pucChar;\r
+struct eth_hdr *pxHeader;\r
+u16_t usTotalLength = p->tot_len - ETH_PAD_SIZE;\r
+err_t xReturn = ERR_OK;\r
\r
#if defined(LWIP_DEBUG) && LWIP_NETIF_TX_SINGLE_PBUF\r
- LWIP_ASSERT("p->next == NULL && p->len == p->tot_len", p->next == NULL && p->len == p->tot_len);\r
+ LWIP_ASSERT("p->next == NULL && p->len == p->tot_len", p->next == NULL && p->len == p->tot_len);\r
#endif\r
\r
- /* initiate transfer */\r
- if (p->len == p->tot_len) \r
+ /* Initiate transfer. */\r
+ if( p->len == p->tot_len ) \r
{\r
- /* no pbuf chain, don't have to copy -> faster */\r
- buf = &((unsigned char*)p->payload)[ETH_PAD_SIZE];\r
+ /* No pbuf chain, don't have to copy -> faster. */\r
+ pucBuffer = &( ( unsigned char * ) p->payload )[ ETH_PAD_SIZE ];\r
} \r
else \r
{\r
- /* pbuf chain, copy into contiguous buffer */\r
- if (p->tot_len >= sizeof(buffer)) \r
+ /* pbuf chain, copy into contiguous ucBuffer. */\r
+ if( p->tot_len >= sizeof( ucBuffer ) )\r
{\r
- LINK_STATS_INC(link.lenerr);\r
- LINK_STATS_INC(link.drop);\r
- snmp_inc_ifoutdiscards(netif);\r
- return ERR_BUF;\r
+ LINK_STATS_INC( link.lenerr );\r
+ LINK_STATS_INC( link.drop );\r
+ snmp_inc_ifoutdiscards( pxNetIf );\r
+ xReturn = ERR_BUF;\r
}\r
+ else\r
+ {\r
+ pucChar = ucBuffer;\r
\r
- ptr = buffer;\r
+ for( q = p; q != NULL; q = q->next )\r
+ {\r
+ /* Send the data from the pbuf to the interface, one pbuf at a\r
+ time. The size of the data in each pbuf is kept in the ->len\r
+ variable. */\r
+ /* send data from(q->payload, q->len); */\r
+ LWIP_DEBUGF( NETIF_DEBUG, ("NETIF: send pucChar %p q->payload %p q->len %i q->next %p\n", pucChar, q->payload, ( int ) q->len, ( void* ) q->next ) );\r
+ if( q == p )\r
+ {\r
+ memcpy( pucChar, &( ( char * ) q->payload )[ ETH_PAD_SIZE ], q->len - ETH_PAD_SIZE );\r
+ pucChar += q->len - ETH_PAD_SIZE;\r
+ }\r
+ else\r
+ {\r
+ memcpy( pucChar, q->payload, q->len );\r
+ pucChar += q->len;\r
+ }\r
+ }\r
+ }\r
+ }\r
\r
- for( q = p; q != NULL; q = q->next ) \r
+ if( xReturn == ERR_OK )\r
+ {\r
+#if 0\r
+_RB_\r
+ /* signal that packet should be sent */\r
+ if( pcap_sendpacket( pxOpenedInterfaceHandle, pucBuffer, usTotalLength ) < 0 ) \r
+ {\r
+ LINK_STATS_INC( link.memerr );\r
+ LINK_STATS_INC( link.drop );\r
+ snmp_inc_ifoutdiscards( pxNetIf );\r
+ xReturn = ERR_BUF;\r
+ }\r
+ else\r
{\r
- /* Send the data from the pbuf to the interface, one pbuf at a\r
- time. The size of the data in each pbuf is kept in the ->len\r
- variable. */\r
- /* send data from(q->payload, q->len); */\r
- LWIP_DEBUGF(NETIF_DEBUG, ("netif: send ptr %p q->payload %p q->len %i q->next %p\n", ptr, q->payload, (int)q->len, (void*)q->next));\r
- if (q == p) \r
+ LINK_STATS_INC( link.xmit );\r
+ snmp_add_ifoutoctets( pxNetIf, usTotalLength );\r
+ pxHeader = ( struct eth_hdr * )p->payload;\r
+\r
+ if( ( pxHeader->dest.addr[ 0 ] & 1 ) != 0 ) \r
{\r
- memcpy(ptr, &((char*)q->payload)[ETH_PAD_SIZE], q->len - ETH_PAD_SIZE);\r
- ptr += q->len - ETH_PAD_SIZE;\r
+ /* broadcast or multicast packet*/\r
+ snmp_inc_ifoutnucastpkts( pxNetIf );\r
} \r
else \r
{\r
- memcpy(ptr, q->payload, q->len);\r
- ptr += q->len;\r
+ /* unicast packet */\r
+ snmp_inc_ifoutucastpkts( pxNetIf );\r
}\r
}\r
+#endif\r
}\r
\r
- /* signal that packet should be sent */\r
- if( pcap_sendpacket( pxOpenedInterfaceHandle, buf, tot_len ) < 0 ) \r
- {\r
- LINK_STATS_INC(link.memerr);\r
- LINK_STATS_INC(link.drop);\r
- snmp_inc_ifoutdiscards(netif);\r
- return ERR_BUF;\r
- }\r
-\r
- LINK_STATS_INC(link.xmit);\r
- snmp_add_ifoutoctets(netif, tot_len);\r
- ethhdr = (struct eth_hdr *)p->payload;\r
-\r
- if( ( ethhdr->dest.addr[ 0 ] & 1 ) != 0 ) \r
- {\r
- /* broadcast or multicast packet*/\r
- snmp_inc_ifoutnucastpkts(netif);\r
- } \r
- else \r
- {\r
- /* unicast packet */\r
- snmp_inc_ifoutucastpkts( netif );\r
- }\r
-\r
- return ERR_OK;\r
+ return xReturn;\r
}\r
\r
/**\r
* Should allocate a pbuf and transfer the bytes of the incoming\r
* packet from the interface into the pbuf.\r
*\r
- * @param netif the lwip network interface structure for this ethernetif\r
+ * @param pxNetIf the lwip network interface structure for this etherpxNetIf\r
* @return a pbuf filled with the received packet (including MAC header)\r
- * NULL on memory error\r
+ * NULL on memory error\r
*/\r
-static struct pbuf *low_level_input( const unsigned char * const pucInputData, long lDataLength )\r
+static struct pbuf *prvLowLevelInput( const unsigned char * const pucInputData, long lDataLength )\r
{\r
struct pbuf *p = NULL, *q;\r
\r
if( p != NULL ) \r
{\r
#if ETH_PAD_SIZE\r
- pbuf_header(p, -ETH_PAD_SIZE); /* drop the padding word */\r
+ pbuf_header( p, -ETH_PAD_SIZE ); /* drop the padding word */\r
#endif\r
\r
/* We iterate over the pbuf chain until we have read the entire\r
* variable.\r
* This does not necessarily have to be a memcpy, you can also preallocate\r
* pbufs for a DMA-enabled MAC and after receiving truncate it to the\r
- * actually received size. In this case, ensure the tot_len member of the\r
+ * actually received size. In this case, ensure the usTotalLength member of the\r
* pbuf is the sum of the chained pbuf len members.\r
*/\r
memcpy( q->payload, &( pucInputData[ lDataLength ] ), q->len );\r
\r
/**\r
* This function should be called when a packet is ready to be read\r
- * from the interface. It uses the function low_level_input() that\r
+ * from the interface. It uses the function prvLowLevelInput() that\r
* should handle the actual reception of bytes from the network\r
* interface. Then the type of the received packet is determined and\r
* the appropriate input function is called.\r
*\r
- * @param netif the lwip network interface structure for this ethernetif\r
+ * @param pxNetIf the lwip network interface structure for this etherpxNetIf\r
*/\r
-static void ethernetif_input( const unsigned char * const pucInputData, long lInputLength )\r
+static void prvEthernetInput( struct netif *pxNetIf, const unsigned char * const pucInputData, long lInputLength )\r
{\r
/* This is taken from lwIP example code and therefore does not conform\r
to the FreeRTOS coding standard. */\r
\r
-struct eth_hdr *ethhdr;\r
+struct eth_hdr *pxHeader;\r
struct pbuf *p;\r
\r
/* move received packet into a new pbuf */\r
- p = low_level_input( pucInputData, lInputLength );\r
+ p = prvLowLevelInput( pucInputData, lInputLength );\r
+\r
/* no packet could be read, silently ignore this */\r
- if( p == NULL ) \r
+ if( p != NULL )\r
{\r
- return;\r
- }\r
+ /* points to packet payload, which starts with an Ethernet header */\r
+ pxHeader = p->payload;\r
\r
- /* points to packet payload, which starts with an Ethernet header */\r
- ethhdr = p->payload;\r
-\r
- switch( htons( ethhdr->type ) ) \r
- {\r
- /* IP or ARP packet? */\r
- case ETHTYPE_IP:\r
- case ETHTYPE_ARP:\r
- /* full packet send to tcpip_thread to process */\r
- if(xlwIPNetif->input( p, xlwIPNetif )!=ERR_OK )\r
- { \r
- LWIP_DEBUGF(NETIF_DEBUG, ("ethernetif_input: IP input error\n"));\r
- pbuf_free(p);\r
+ switch( htons( pxHeader->type ) )\r
+ {\r
+ /* IP or ARP packet? */\r
+ case ETHTYPE_IP:\r
+ case ETHTYPE_ARP:\r
+ /* full packet send to tcpip_thread to process */\r
+ if( pxNetIf->input( p, pxNetIf ) != ERR_OK )\r
+ {\r
+ LWIP_DEBUGF(NETIF_DEBUG, ( "ethernetif_input: IP input error\n" ) );\r
+ pbuf_free(p);\r
+ p = NULL;\r
+ }\r
+ break;\r
+\r
+ default:\r
+ pbuf_free( p );\r
p = NULL;\r
- }\r
- break;\r
-\r
- default:\r
- pbuf_free( p );\r
- p = NULL;\r
- break;\r
+ break;\r
+ }\r
}\r
}\r
\r
/**\r
* Should be called at the beginning of the program to set up the\r
- * network interface. It calls the function low_level_init() to do the\r
+ * network interface. It calls the function prvLowLevelInit() to do the\r
* actual setup of the hardware.\r
*\r
- * This function should be passed as a parameter to netif_add().\r
+ * This function should be passed as a parameter to pxNetIf_add().\r
*\r
- * @param netif the lwip network interface structure for this ethernetif\r
+ * @param pxNetIf the lwip network interface structure for this etherpxNetIf\r
* @return ERR_OK if the loopif is initialized\r
- * ERR_MEM if private data couldn't be allocated\r
- * any other err_t on error\r
+ * ERR_MEM if private data couldn't be allocated\r
+ * any other err_t on error\r
*/\r
-err_t ethernetif_init( struct netif *netif )\r
+err_t ethernetif_init( struct netif *pxNetIf )\r
{\r
+err_t xReturn = ERR_OK;\r
+\r
/* This is taken from lwIP example code and therefore does not conform\r
to the FreeRTOS coding standard. */\r
\r
- struct ethernetif *ethernetif;\r
-\r
- LWIP_ASSERT( "netif != NULL", ( netif != NULL ) );\r
- \r
- ethernetif = mem_malloc( sizeof( struct ethernetif ) );\r
- if (ethernetif == NULL) \r
- {\r
- LWIP_DEBUGF(NETIF_DEBUG, ("ethernetif_init: out of memory\n"));\r
- return ERR_MEM;\r
- }\r
-\r
- #if LWIP_NETIF_HOSTNAME\r
- /* Initialize interface hostname */\r
- netif->hostname = "lwip";\r
- #endif /* LWIP_NETIF_HOSTNAME */\r
-\r
- netif->state = ethernetif;\r
- netif->name[0] = IFNAME0;\r
- netif->name[1] = IFNAME1;\r
-\r
- /* We directly use etharp_output() here to save a function call.\r
- * You can instead declare your own function an call etharp_output()\r
- * from it if you have to do some checks before sending (e.g. if link\r
- * is available...) */\r
- netif->output = etharp_output;\r
- netif->flags = NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP | NETIF_FLAG_IGMP;\r
- netif->hwaddr_len = ETHARP_HWADDR_LEN;\r
- netif->mtu = netifMAX_MTU;\r
- netif->linkoutput = low_level_output;\r
-\r
- ethernetif->ethaddr = ( struct eth_addr * ) &( netif->hwaddr[ 0 ] );\r
- \r
- /* initialize the hardware */\r
- low_level_init( netif );\r
-\r
- return ERR_OK;\r
-}\r
-/*-----------------------------------------------------------*/\r
-\r
-static pcap_if_t * prvPrintAvailableNetworkInterfaces( void )\r
-{ \r
-pcap_if_t * pxAllNetworkInterfaces = NULL, *xInterface;\r
-long lInterfaceNumber = 1;\r
-\r
- if( pcap_findalldevs_ex( PCAP_SRC_IF_STRING, NULL, &pxAllNetworkInterfaces, cErrorBuffer ) == -1 )\r
- {\r
- printf( "\r\nCould not obtain a list of network interfaces\r\n%s\r\n", cErrorBuffer );\r
- pxAllNetworkInterfaces = NULL;\r
- }\r
-\r
- if( pxAllNetworkInterfaces != NULL )\r
- {\r
- /* Print out the list of network interfaces. The first in the list\r
- is interface '1', not interface '0'. */\r
- for( xInterface = pxAllNetworkInterfaces; xInterface != NULL; xInterface = xInterface->next )\r
- {\r
- printf( "%d. %s", lInterfaceNumber, xInterface->name );\r
- \r
- if( xInterface->description != NULL )\r
- {\r
- printf( " (%s)\r\n", xInterface->description );\r
- }\r
- else\r
- {\r
- printf( " (No description available)\r\n") ;\r
- }\r
- \r
- lInterfaceNumber++;\r
- }\r
- }\r
-\r
- if( lInterfaceNumber == 1 )\r
- {\r
- /* The interface number was never incremented, so the above for() loop\r
- did not execute meaning no interfaces were found. */\r
- printf( " \r\nNo network interfaces were found.\r\n" );\r
- pxAllNetworkInterfaces = NULL;\r
- }\r
+struct xEthernetIf *pxEthernetIf;\r
\r
- printf( "\r\nThe interface that will be opened is set by configNETWORK_INTERFACE_TO_USE which should be defined in FreeRTOSConfig.h\r\n" );\r
- printf( "Attempting to open interface number %d.\r\n", configNETWORK_INTERFACE_TO_USE );\r
+ LWIP_ASSERT( "pxNetIf != NULL", ( pxNetIf != NULL ) );\r
\r
- if( ( configNETWORK_INTERFACE_TO_USE < 1L ) || ( configNETWORK_INTERFACE_TO_USE > lInterfaceNumber ) )\r
- {\r
- printf("\r\nconfigNETWORK_INTERFACE_TO_USE is not in the valid range.\r\n" );\r
- \r
- if( pxAllNetworkInterfaces != NULL )\r
- {\r
- /* Free the device list, as no devices are going to be opened. */\r
- pcap_freealldevs( pxAllNetworkInterfaces );\r
- pxAllNetworkInterfaces = NULL;\r
- }\r
- }\r
-\r
- return pxAllNetworkInterfaces;\r
-}\r
-/*-----------------------------------------------------------*/\r
-\r
-static void prvOpenSelectedNetworkInterface( pcap_if_t *pxAllNetworkInterfaces )\r
-{\r
-pcap_if_t *xInterface;\r
-long x;\r
-\r
- /* Walk the list of devices until the selected device is located. */\r
- xInterface = pxAllNetworkInterfaces;\r
- for( x = 0L; x < ( configNETWORK_INTERFACE_TO_USE - 1L ); x++ )\r
+ pxEthernetIf = mem_malloc( sizeof( struct xEthernetIf ) );\r
+ if( pxEthernetIf == NULL ) \r
{\r
- xInterface = xInterface->next;\r
+ LWIP_DEBUGF(NETIF_DEBUG, ( "ethernetif_init: out of memory\n" ) );\r
+ xReturn = ERR_MEM;\r
}\r
-\r
- /* Open the selected interface. */\r
- pxOpenedInterfaceHandle = pcap_open( xInterface->name, /* The name of the selected interface. */\r
- netifMAX_MTU, /* The size of the packet to capture. */\r
- PCAP_OPENFLAG_PROMISCUOUS, /* Open in promiscious mode as the MAC and \r
- IP address is going to be "simulated", and \r
- not be the real MAC and IP address. This allows\r
- trafic to the simulated IP address to be routed\r
- to uIP, and trafic to the real IP address to be\r
- routed to the Windows TCP/IP stack. */\r
- 0L, /* The read time out. This is going to block\r
- until data is available. */\r
- NULL, /* No authentication is required as this is\r
- not a remote capture session. */\r
- cErrorBuffer \r
- );\r
- \r
- if ( pxOpenedInterfaceHandle == NULL )\r
- {\r
- printf( "\r\n%s is not supported by WinPcap and cannot be opened\r\n", xInterface->name );\r
- }\r
else\r
{\r
- /* Configure the capture filter to allow blocking reads, and to filter \r
- out packets that are not of interest to this demo. */\r
- prvConfigureCaptureBehaviour();\r
- }\r
-\r
- /* The device list is no longer required. */\r
- pcap_freealldevs( pxAllNetworkInterfaces );\r
-}\r
-/*-----------------------------------------------------------*/\r
-\r
-static void prvInterruptSimulator( void *pvParameters )\r
-{\r
-static struct pcap_pkthdr *pxHeader;\r
-const unsigned char *pucPacketData;\r
-extern xQueueHandle xEMACEventQueue;\r
-long lResult;\r
-\r
- /* Just to kill the compiler warning. */\r
- ( void ) pvParameters;\r
-\r
- for( ;; )\r
- {\r
- /* Get the next packet. */\r
- lResult = pcap_next_ex( pxOpenedInterfaceHandle, &pxHeader, &pucPacketData );\r
- if( lResult == 1 )\r
- {\r
- if( xlwIPNetif != NULL )\r
- {\r
- ethernetif_input( pucPacketData, pxHeader->len );\r
- }\r
- }\r
- else\r
+ #if LWIP_NETIF_HOSTNAME\r
{\r
- /* There is no real way of simulating an interrupt. \r
- Make sure other tasks can run. */\r
- vTaskDelay( 5 );\r
+ /* Initialize interface hostname */\r
+ pxNetIf->hostname = "lwip";\r
}\r
+ #endif /* LWIP_NETIF_HOSTNAME */\r
+\r
+ pxNetIf->state = pxEthernetIf;\r
+ pxNetIf->name[ 0 ] = IFNAME0;\r
+ pxNetIf->name[ 1 ] = IFNAME1;\r
+\r
+ /* We directly use etharp_output() here to save a function call.\r
+ * You can instead declare your own function an call etharp_output()\r
+ * from it if you have to do some checks before sending (e.g. if link\r
+ * is available...) */\r
+ pxNetIf->output = etharp_output;\r
+ pxNetIf->flags = NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP | NETIF_FLAG_IGMP;\r
+ pxNetIf->hwaddr_len = ETHARP_HWADDR_LEN;\r
+ pxNetIf->mtu = netifMAX_MTU;\r
+ pxNetIf->linkoutput = prvLowLevelOutput;\r
+\r
+ pxEthernetIf->ethaddr = ( struct eth_addr * ) &( pxNetIf->hwaddr[ 0 ] );\r
+\r
+ /* initialize the hardware */\r
+ prvLowLevelInit( pxNetIf );\r
}\r
-}\r
-/*-----------------------------------------------------------*/\r
-\r
-static void prvConfigureCaptureBehaviour( void )\r
-{\r
-struct bpf_program xFilterCode;\r
-const long lMinBytesToCopy = 10L, lBlocking = 1L;\r
-unsigned long ulNetMask;\r
\r
- /* Unblock a read as soon as anything is received. */\r
- pcap_setmintocopy( pxOpenedInterfaceHandle, lMinBytesToCopy );\r
-\r
- /* Allow blocking. */\r
- pcap_setnonblock( pxOpenedInterfaceHandle, lBlocking, cErrorBuffer );\r
-\r
- /* Set up a filter so only the packets of interest are passed to the lwIP\r
- stack. cErrorBuffer is used for convenience to create the string. Don't\r
- confuse this with an error message. */\r
- sprintf( cErrorBuffer, "broadcast or multicast or host %d.%d.%d.%d", configIP_ADDR0, configIP_ADDR1, configIP_ADDR2, configIP_ADDR3 );\r
-\r
- ulNetMask = ( configNET_MASK3 << 24UL ) | ( configNET_MASK2 << 16UL ) | ( configNET_MASK1 << 8L ) | configNET_MASK0;\r
-\r
- if( pcap_compile(pxOpenedInterfaceHandle, &xFilterCode, cErrorBuffer, 1, ulNetMask ) < 0 )\r
- {\r
- printf("\r\nThe packet filter string is invalid\r\n" );\r
- }\r
- else\r
- { \r
- if( pcap_setfilter( pxOpenedInterfaceHandle, &xFilterCode ) < 0 )\r
- {\r
- printf( "\r\nAn error occurred setting the packet filter.\r\n" );\r
- }\r
- }\r
-\r
- /* Create a task that simulates an interrupt in a real system. This will\r
- block waiting for packets, then send a message to the uIP task when data\r
- is available. */\r
- xTaskCreate( prvInterruptSimulator, ( signed char * ) "MAC_ISR", configMINIMAL_STACK_SIZE, NULL, configMAC_ISR_SIMULATOR_PRIORITY, NULL );\r
+ return xReturn;\r
}\r
-\r
-#endif\r
-\r
+/*-----------------------------------------------------------*/\r
#include "lwip/mem.h"\r
#include "lwip/stats.h"\r
\r
-/*---------------------------------------------------------------------------*\r
- * Globals:\r
- *---------------------------------------------------------------------------*/\r
-\r
-#if 0\r
-_RB_\r
-struct timeoutlist\r
-{\r
- struct sys_timeouts timeouts;\r
- xTaskHandle pid;\r
-};\r
-\r
-/* This is the number of threads that can be started with sys_thread_new() */\r
-#define SYS_THREAD_MAX 4\r
-\r
-static u16_t s_nextthread = 0;\r
-\r
-static struct timeoutlist s_timeoutlist[SYS_THREAD_MAX];\r
-#endif\r
-\r
-/*-----------------------------------------------------------------------------------*/\r
-\r
/*---------------------------------------------------------------------------*\r
* Routine: sys_mbox_new\r
*---------------------------------------------------------------------------*\r
* Outputs:\r
* sys_mbox_t -- Handle to new mailbox\r
*---------------------------------------------------------------------------*/\r
-err_t sys_mbox_new(sys_mbox_t *mbox, int size)\r
+err_t sys_mbox_new( sys_mbox_t *pxMailBox, int iSize )\r
{\r
-err_t lwip_err= ERR_MEM;\r
+err_t xReturn = ERR_MEM;\r
\r
- *mbox = xQueueCreate( size, sizeof( void * ) );\r
+ *pxMailBox = xQueueCreate( iSize, sizeof( void * ) );\r
\r
- // Created succesfully?\r
- if(*mbox != NULL)\r
+ if( *pxMailBox != NULL )\r
{\r
- lwip_err = ERR_OK;\r
-#if SYS_STATS\r
- SYS_STATS_INC(mbox.used);\r
-#endif /* SYS_STATS */\r
+ xReturn = ERR_OK;\r
+ #if SYS_STATS\r
+ {\r
+ SYS_STATS_INC( mbox.used );\r
+ }\r
+ #endif /* SYS_STATS */\r
}\r
\r
- return lwip_err;\r
+ return xReturn;\r
}\r
\r
\r
* Outputs:\r
* sys_mbox_t -- Handle to new mailbox\r
*---------------------------------------------------------------------------*/\r
-void sys_mbox_free(sys_mbox_t *mbox)\r
+void sys_mbox_free( sys_mbox_t *pxMailBox )\r
{\r
-unsigned portBASE_TYPE uxMessagesWaiting;\r
+unsigned long ulMessagesWaiting;\r
\r
- uxMessagesWaiting = uxQueueMessagesWaiting( *mbox );\r
- configASSERT( ( uxMessagesWaiting == 0 ) );\r
+ ulMessagesWaiting = uxQueueMessagesWaiting( *pxMailBox );\r
+ configASSERT( ( ulMessagesWaiting == 0 ) );\r
\r
-#if SYS_STATS\r
- if (uxMessagesWaiting != 0U)\r
+ #if SYS_STATS\r
{\r
- SYS_STATS_INC(mbox.err);\r
- }\r
+ if( ulMessagesWaiting != 0UL )\r
+ {\r
+ SYS_STATS_INC( mbox.err );\r
+ }\r
\r
- SYS_STATS_DEC(mbox.used);\r
-#endif /* SYS_STATS */\r
+ SYS_STATS_DEC( mbox.used );\r
+ }\r
+ #endif /* SYS_STATS */\r
\r
- vQueueDelete( *mbox );\r
+ vQueueDelete( *pxMailBox );\r
}\r
\r
/*---------------------------------------------------------------------------*\r
* sys_mbox_t mbox -- Handle of mailbox\r
* void *data -- Pointer to data to post\r
*---------------------------------------------------------------------------*/\r
-void sys_mbox_post(sys_mbox_t *mbox, void *msg)\r
+void sys_mbox_post( sys_mbox_t *pxMailBox, void *pxMessageToPost )\r
{\r
- while( xQueueSendToBack( *mbox, &msg, portMAX_DELAY ) != pdTRUE );\r
+ while( xQueueSendToBack( *pxMailBox, &pxMessageToPost, portMAX_DELAY ) != pdTRUE );\r
}\r
\r
/*---------------------------------------------------------------------------*\r
* err_t -- ERR_OK if message posted, else ERR_MEM\r
* if not.\r
*---------------------------------------------------------------------------*/\r
-err_t sys_mbox_trypost(sys_mbox_t *mbox, void *msg)\r
+err_t sys_mbox_trypost( sys_mbox_t *pxMailBox, void *pxMessageToPost )\r
{\r
-err_t result;\r
+err_t xReturn;\r
\r
- if ( xQueueSend( *mbox, &msg, 0 ) == pdPASS )\r
+ if( xQueueSend( *pxMailBox, &pxMessageToPost, 0UL ) == pdPASS )\r
{\r
- result = ERR_OK;\r
+ xReturn = ERR_OK;\r
}\r
else\r
{\r
- // could not post, queue must be full\r
- result = ERR_MEM;\r
-#if SYS_STATS\r
- SYS_STATS_INC(mbox.err);\r
-#endif /* SYS_STATS */\r
+ /* The queue was already full. */\r
+ xReturn = ERR_MEM;\r
+ #if SYS_STATS\r
+ {\r
+ SYS_STATS_INC( mbox.err );\r
+ }\r
+ #endif /* SYS_STATS */\r
}\r
- return result;\r
+\r
+ return xReturn;\r
}\r
\r
/*---------------------------------------------------------------------------*\r
* u32_t -- SYS_ARCH_TIMEOUT if timeout, else number\r
* of milliseconds until received.\r
*---------------------------------------------------------------------------*/\r
-u32_t sys_arch_mbox_fetch(sys_mbox_t *mbox, void **msg, u32_t timeout)\r
+u32_t sys_arch_mbox_fetch( sys_mbox_t *pxMailBox, void **ppvBuffer, u32_t ulTimeOut )\r
{\r
-void *dummyptr;\r
-portTickType StartTime, EndTime, Elapsed;\r
+void *pvDummy;\r
+portTickType xStartTime, xEndTime, xElapsed;\r
+unsigned long ulReturn;\r
\r
- StartTime = xTaskGetTickCount();\r
+ xStartTime = xTaskGetTickCount();\r
\r
- if (NULL == msg)\r
+ if( NULL == ppvBuffer )\r
{\r
- msg = &dummyptr;\r
+ ppvBuffer = &pvDummy;\r
}\r
\r
- if (timeout != 0)\r
+ if( ulTimeOut != 0UL )\r
{\r
- if ( pdTRUE == xQueueReceive( *mbox, &(*msg), timeout / portTICK_RATE_MS ) )\r
+ if( pdTRUE == xQueueReceive( *pxMailBox, &( *ppvBuffer ), ulTimeOut/ portTICK_RATE_MS ) )\r
{\r
- EndTime = xTaskGetTickCount();\r
- Elapsed = (EndTime - StartTime) * portTICK_RATE_MS;\r
+ xEndTime = xTaskGetTickCount();\r
+ xElapsed = ( xEndTime - xStartTime ) * portTICK_RATE_MS;\r
\r
- return ( Elapsed );\r
+ ulReturn = xElapsed;\r
}\r
- else // timed out blocking for message\r
+ else\r
{\r
- *msg = NULL;\r
-\r
- return SYS_ARCH_TIMEOUT;\r
+ /* Timed out. */\r
+ *ppvBuffer = NULL;\r
+ ulReturn = SYS_ARCH_TIMEOUT;\r
}\r
}\r
else\r
{\r
- while( pdTRUE != xQueueReceive( mbox, &(*msg), portMAX_DELAY ) ); // time is arbitrary\r
- EndTime = xTaskGetTickCount();\r
- Elapsed = (EndTime - StartTime) * portTICK_RATE_MS;\r
+ while( pdTRUE != xQueueReceive( pxMailBox, &( *ppvBuffer ), portMAX_DELAY ) );\r
+ xEndTime = xTaskGetTickCount();\r
+ xElapsed = ( xEndTime - xStartTime ) * portTICK_RATE_MS;\r
\r
- if (Elapsed == 0)\r
+ if( xElapsed == 0UL )\r
{\r
- Elapsed = 1;\r
+ xElapsed = 1UL;\r
}\r
\r
- // return time blocked TBD test\r
- return (Elapsed);\r
+ ulReturn = xElapsed;\r
}\r
+\r
+ return ulReturn;\r
}\r
\r
/*---------------------------------------------------------------------------*\r
* u32_t -- SYS_MBOX_EMPTY if no messages. Otherwise,\r
* return ERR_OK.\r
*---------------------------------------------------------------------------*/\r
-u32_t sys_arch_mbox_tryfetch(sys_mbox_t *mbox, void **msg)\r
+u32_t sys_arch_mbox_tryfetch( sys_mbox_t *pxMailBox, void **ppvBuffer )\r
{\r
- void *dummyptr;\r
+void *pvDummy;\r
+unsigned long ulReturn;\r
\r
- if (msg == NULL)\r
+ if( ppvBuffer== NULL )\r
{\r
- msg = &dummyptr;\r
+ ppvBuffer = &pvDummy;\r
}\r
\r
- if ( pdTRUE == xQueueReceive( *mbox, &(*msg), 0 ) )\r
+ if( pdTRUE == xQueueReceive( *pxMailBox, &( *ppvBuffer ), 0UL ) )\r
{\r
- return ERR_OK;\r
+ ulReturn = ERR_OK;\r
}\r
else\r
{\r
- return SYS_MBOX_EMPTY;\r
+ ulReturn = SYS_MBOX_EMPTY;\r
}\r
+\r
+ return ulReturn;\r
}\r
\r
/*---------------------------------------------------------------------------*\r
* Routine: sys_sem_new\r
*---------------------------------------------------------------------------*\r
* Description:\r
- * Creates and returns a new semaphore. The "count" argument specifies\r
+ * Creates and returns a new semaphore. The "ucCount" argument specifies\r
* the initial state of the semaphore.\r
* NOTE: Currently this routine only creates counts of 1 or 0\r
* Inputs:\r
* sys_mbox_t mbox -- Handle of mailbox\r
- * u8_t count -- Initial count of semaphore (1 or 0)\r
+ * u8_t ucCount -- Initial ucCount of semaphore (1 or 0)\r
* Outputs:\r
* sys_sem_t -- Created semaphore or 0 if could not create.\r
*---------------------------------------------------------------------------*/\r
-err_t sys_sem_new(sys_sem_t *sem, u8_t count)\r
+err_t sys_sem_new( sys_sem_t *pxSemaphore, u8_t ucCount )\r
{\r
- err_t lwip_err = ERR_MEM;\r
+err_t xReturn = ERR_MEM;\r
\r
- vSemaphoreCreateBinary( (*sem) );\r
+ vSemaphoreCreateBinary( ( *pxSemaphore ) );\r
\r
- if( *sem != NULL )\r
+ if( *pxSemaphore != NULL )\r
{\r
- // Means it can't be taken\r
- if (count == 0)\r
+ if( ucCount == 0U )\r
{\r
- xSemaphoreTake(*sem, 1);\r
+ xSemaphoreTake( *pxSemaphore, 1UL );\r
}\r
\r
- lwip_err = ERR_OK;\r
+ xReturn = ERR_OK;\r
\r
-#if SYS_STATS\r
- SYS_STATS_INC(sem.used);\r
-#endif\r
+ #if SYS_STATS\r
+ {\r
+ SYS_STATS_INC( sem.used );\r
+ }\r
+ #endif\r
}\r
else\r
{\r
-#if SYS_STATS\r
- SYS_STATS_INC(sem.err);\r
-#endif\r
+ #if SYS_STATS\r
+ {\r
+ SYS_STATS_INC( sem.err );\r
+ }\r
+ #endif\r
}\r
\r
- return lwip_err;\r
+ return xReturn;\r
}\r
\r
/*---------------------------------------------------------------------------*\r
* Outputs:\r
* u32_t -- Time elapsed or SYS_ARCH_TIMEOUT.\r
*---------------------------------------------------------------------------*/\r
-u32_t sys_arch_sem_wait(sys_sem_t *sem, u32_t timeout)\r
+u32_t sys_arch_sem_wait( sys_sem_t *pxSemaphore, u32_t ulTimeout )\r
{\r
-portTickType StartTime, EndTime, Elapsed;\r
+portTickType xStartTime, xEndTime, xElapsed;\r
+unsigned long ulReturn;\r
\r
- StartTime = xTaskGetTickCount();\r
+ xStartTime = xTaskGetTickCount();\r
\r
- if (timeout != 0)\r
+ if( ulTimeout != 0UL )\r
{\r
- if( xSemaphoreTake( *sem, timeout / portTICK_RATE_MS ) == pdTRUE )\r
+ if( xSemaphoreTake( *pxSemaphore, ulTimeout / portTICK_RATE_MS ) == pdTRUE )\r
{\r
- EndTime = xTaskGetTickCount();\r
- Elapsed = (EndTime - StartTime) * portTICK_RATE_MS;\r
-\r
- return (Elapsed); // return time blocked TODO test\r
+ xEndTime = xTaskGetTickCount();\r
+ xElapsed = (xEndTime - xStartTime) * portTICK_RATE_MS;\r
+ ulReturn = xElapsed;\r
}\r
else\r
{\r
- return SYS_ARCH_TIMEOUT;\r
+ ulReturn = SYS_ARCH_TIMEOUT;\r
}\r
-\r
}\r
else\r
{\r
- while( xSemaphoreTake( sem, portMAX_DELAY ) != pdTRUE );\r
- EndTime = xTaskGetTickCount();\r
- Elapsed = (EndTime - StartTime) * portTICK_RATE_MS;\r
+ while( xSemaphoreTake( pxSemaphore, portMAX_DELAY ) != pdTRUE );\r
+ xEndTime = xTaskGetTickCount();\r
+ xElapsed = ( xEndTime - xStartTime ) * portTICK_RATE_MS;\r
\r
- if (Elapsed == 0)\r
+ if( xElapsed == 0UL )\r
{\r
- Elapsed = 1;\r
+ xElapsed = 1UL;\r
}\r
\r
- // return time blocked\r
- return (Elapsed);\r
+ ulReturn = xElapsed;\r
}\r
+\r
+ return ulReturn;\r
}\r
\r
/** Create a new mutex\r
* @param mutex pointer to the mutex to create\r
* @return a new mutex */\r
-err_t sys_mutex_new(sys_mutex_t *mutex) \r
+err_t sys_mutex_new( sys_mutex_t *pxMutex )\r
{\r
-err_t lwip_err = ERR_MEM;\r
+err_t xReturn = ERR_MEM;\r
\r
- *mutex = xQueueCreateMutex();\r
+ *pxMutex = xQueueCreateMutex();\r
\r
- if( *mutex != NULL ) \r
+ if( *pxMutex != NULL )\r
{\r
- lwip_err = ERR_OK;\r
-#if SYS_STATS\r
- SYS_STATS_INC(mutex.used);\r
-#endif\r
+ xReturn = ERR_OK;\r
+ #if SYS_STATS\r
+ {\r
+ SYS_STATS_INC( mutex.used );\r
+ }\r
+ #endif\r
} \r
else \r
{\r
-#if SYS_STATS\r
- SYS_STATS_INC(mutex.err);\r
-#endif\r
+ #if SYS_STATS\r
+ {\r
+ SYS_STATS_INC( mutex.err );\r
+ }\r
+ #endif\r
}\r
\r
- return lwip_err;\r
+ return xReturn;\r
}\r
\r
/** Lock a mutex\r
* @param mutex the mutex to lock */\r
-void sys_mutex_lock(sys_mutex_t *mutex)\r
+void sys_mutex_lock( sys_mutex_t *pxMutex )\r
{\r
- while( xSemaphoreTake( *mutex, portMAX_DELAY ) != pdPASS );\r
+ while( xSemaphoreTake( *pxMutex, portMAX_DELAY ) != pdPASS );\r
}\r
\r
/** Unlock a mutex\r
* @param mutex the mutex to unlock */\r
-void sys_mutex_unlock(sys_mutex_t *mutex)\r
+void sys_mutex_unlock(sys_mutex_t *pxMutex )\r
{\r
- xSemaphoreGive(*mutex);\r
+ xSemaphoreGive( *pxMutex );\r
}\r
\r
\r
/** Delete a semaphore\r
* @param mutex the mutex to delete */\r
-void sys_mutex_free(sys_mutex_t *mutex)\r
+void sys_mutex_free( sys_mutex_t *pxMutex )\r
{\r
-#if SYS_STATS\r
- SYS_STATS_DEC(mutex.used);\r
-#endif /* SYS_STATS */\r
- vQueueDelete(*mutex);\r
+ #if SYS_STATS\r
+ {\r
+ SYS_STATS_DEC( mutex.used );\r
+ }\r
+ #endif /* SYS_STATS */\r
+ vQueueDelete( *pxMutex );\r
}\r
\r
\r
* Inputs:\r
* sys_sem_t sem -- Semaphore to signal\r
*---------------------------------------------------------------------------*/\r
-void sys_sem_signal(sys_sem_t * sem)\r
+void sys_sem_signal( sys_sem_t *pxSemaphore )\r
{\r
- //LWIP_ASSERT( "sys_sem_signal: sem != SYS_SEM_NULL", sem != SYS_SEM_NULL );\r
- xSemaphoreGive(*sem);\r
+ xSemaphoreGive( *pxSemaphore );\r
}\r
\r
/*---------------------------------------------------------------------------*\r
* Inputs:\r
* sys_sem_t sem -- Semaphore to free\r
*---------------------------------------------------------------------------*/\r
-void sys_sem_free(sys_sem_t * sem)\r
+void sys_sem_free( sys_sem_t *pxSemaphore )\r
{\r
- //LWIP_ASSERT( "sys_sem_free: sem != SYS_SEM_NULL", sem != SYS_SEM_NULL );\r
-\r
-#if SYS_STATS\r
- SYS_STATS_DEC(sem.used);\r
-#endif /* SYS_STATS */\r
+ #if SYS_STATS\r
+ {\r
+ SYS_STATS_DEC(sem.used);\r
+ }\r
+ #endif\r
\r
- vQueueDelete(*sem);\r
+ vQueueDelete( *pxSemaphore );\r
}\r
\r
/*---------------------------------------------------------------------------*\r
*---------------------------------------------------------------------------*/\r
void sys_init(void)\r
{\r
-#if 0\r
- int i;\r
-\r
- // Initialize the the per-thread sys_timeouts structures\r
- // make sure there are no valid pids in the list\r
- for (i = 0; i < SYS_THREAD_MAX; i++)\r
- {\r
- s_timeoutlist[i].pid = SYS_THREAD_NULL;\r
- // s_timeoutlist[i].timeouts.next = NULL;\r
- }\r
-\r
- // keep track of how many threads have been created\r
- s_nextthread = 0;\r
-#endif\r
}\r
\r
u32_t sys_now(void)\r
return xTaskGetTickCount();\r
}\r
\r
-#if 0\r
-_RB_\r
-u32_t sys_jiffies(void)\r
-{\r
- return UEZTickCounterGet();\r
-}\r
-#endif\r
-\r
-/*---------------------------------------------------------------------------*\r
- * Routine: sys_arch_timeouts\r
- *---------------------------------------------------------------------------*\r
- * Description:\r
- * Returns a pointer to the per-thread sys_timeouts structure. In lwIP,\r
- * each thread has a list of timeouts which is represented as a linked\r
- * list of sys_timeout structures. The sys_timeouts structure holds a\r
- * pointer to a linked list of timeouts. This function is called by\r
- * the lwIP timeout scheduler and must not return a NULL value.\r
- *\r
- * In a single threaded sys_arch implementation, this function will\r
- * simply return a pointer to a global sys_timeouts variable stored in\r
- * the sys_arch module.\r
- * Outputs:\r
- * sys_timeouts * -- Pointer to per-thread timeouts.\r
- *---------------------------------------------------------------------------*/\r
-#if 0\r
-struct sys_timeouts *sys_arch_timeouts(void)\r
-{\r
- int i;\r
- T_uezTask pid;\r
- struct timeoutlist *tl;\r
-\r
- pid = UEZTaskGetCurrent();\r
-\r
- for (i = 0; i < s_nextthread; i++)\r
- {\r
- tl = &(s_timeoutlist[i]);\r
- if (tl->pid == pid)\r
- {\r
- // return &(tl->timeouts);\r
- }\r
- }\r
-\r
- // Error\r
- return NULL;\r
-}\r
-#endif\r
/*---------------------------------------------------------------------------*\r
* Routine: sys_thread_new\r
*---------------------------------------------------------------------------*\r
* Outputs:\r
* sys_thread_t -- Pointer to per-thread timeouts.\r
*---------------------------------------------------------------------------*/\r
-sys_thread_t sys_thread_new(const char *name, void(* thread)(void *arg), void *arg, int stacksize, int prio)\r
+sys_thread_t sys_thread_new( const char *pcName, void( *pxThread )( void *pvParameters ), void *pvArg, int iStackSize, int iPriority )\r
{\r
-xTaskHandle CreatedTask;\r
-int result;\r
+xTaskHandle xCreatedTask;\r
+portBASE_TYPE xResult;\r
+sys_thread_t xReturn;\r
\r
- result = xTaskCreate( thread, ( signed portCHAR * ) name, stacksize, arg, prio, &CreatedTask );\r
+ xResult = xTaskCreate( pxThread, ( signed char * ) pcName, iStackSize, pvArg, iPriority, &xCreatedTask );\r
\r
- if(result == pdPASS)\r
+ if( xResult == pdPASS )\r
{\r
- return CreatedTask;\r
+ xReturn = xCreatedTask;\r
}\r
else\r
{\r
- return NULL;\r
+ xReturn = NULL;\r
}\r
+\r
+ return xReturn;\r
}\r
\r
/*---------------------------------------------------------------------------*\r
* Outputs:\r
* sys_prot_t -- Previous protection level (not used here)\r
*---------------------------------------------------------------------------*/\r
-sys_prot_t sys_arch_protect(void)\r
+sys_prot_t sys_arch_protect( void )\r
{\r
taskENTER_CRITICAL();\r
- return 1;\r
+ return ( sys_prot_t ) 1;\r
}\r
\r
/*---------------------------------------------------------------------------*\r
* Inputs:\r
* sys_prot_t -- Previous protection level (not used here)\r
*---------------------------------------------------------------------------*/\r
-void sys_arch_unprotect(sys_prot_t pval)\r
+void sys_arch_unprotect( sys_prot_t xValue )\r
{\r
- (void) pval;\r
+ (void) xValue;\r
taskEXIT_CRITICAL();\r
}\r
\r
/*\r
* Prints an assertion messages and aborts execution.\r
*/\r
-void sys_assert(const char *msg)\r
+void sys_assert( const char *pcMessage )\r
{\r
- (void) msg;\r
+ (void) pcMessage;\r
\r
for (;;)\r
{\r