diff --git a/net/lwip/src/arch/sys_arch.c b/net/lwip/src/arch/sys_arch.c index 267d6ddaf2e24b43107e705325ccea0464c6cb24..caecd51cec458f95e2ebff944cb7eb1ed16d28f3 100644 --- a/net/lwip/src/arch/sys_arch.c +++ b/net/lwip/src/arch/sys_arch.c @@ -31,12 +31,12 @@ sys_sem_t sys_sem_new(u8_t count) rt_snprintf(tname, RT_NAME_MAX, "%s%d", SYS_LWIP_SEM_NAME, counter); -#ifdef LWIP_DEBUG +#if SYS_DEBUG { struct rt_thread *thread; thread = rt_thread_self(); - LWIP_DEBUGF(TCPIP_DEBUG, ("%s, Create sem: %s \n",thread->name, tname)); + LWIP_DEBUGF(SYS_DEBUG, ("%s, Create sem: %s \n",thread->name, tname)); } #endif @@ -47,12 +47,12 @@ sys_sem_t sys_sem_new(u8_t count) void sys_sem_free(sys_sem_t sem) { -#ifdef LWIP_DEBUG +#if SYS_DEBUG { struct rt_thread *thread; thread = rt_thread_self(); - LWIP_DEBUGF(TCPIP_DEBUG, ("%s, Delete sem: %s \n",thread->name, + LWIP_DEBUGF(SYS_DEBUG, ("%s, Delete sem: %s \n",thread->name, sem->parent.parent.name)); } #endif @@ -64,12 +64,12 @@ void sys_sem_free(sys_sem_t sem) void sys_sem_signal(sys_sem_t sem) { -#ifdef LWIP_DEBUG +#if SYS_DEBUG { struct rt_thread *thread; thread = rt_thread_self(); - LWIP_DEBUGF(TCPIP_DEBUG, ("%s, Release signal: %s , %d\n",thread->name, + LWIP_DEBUGF(SYS_DEBUG, ("%s, Release signal: %s , %d\n",thread->name, sem->parent.parent.name, sem->value)); } #endif @@ -87,12 +87,12 @@ u32_t sys_arch_sem_wait(sys_sem_t sem, u32_t timeout) /* get the begin tick */ tick = rt_tick_get(); -#ifdef LWIP_DEBUG +#if SYS_DEBUG { struct rt_thread *thread; thread = rt_thread_self(); - LWIP_DEBUGF(TCPIP_DEBUG, ("%s, Wait sem: %s , %d\n",thread->name, + LWIP_DEBUGF(SYS_DEBUG, ("%s, Wait sem: %s , %d\n",thread->name, sem->parent.parent.name, sem->value)); } #endif @@ -128,12 +128,12 @@ sys_mbox_t sys_mbox_new(int size) rt_snprintf(tname, RT_NAME_MAX, "%s%d", SYS_LWIP_MBOX_NAME, counter); -#ifdef LWIP_DEBUG +#if SYS_DEBUG { struct rt_thread *thread; thread = rt_thread_self(); - LWIP_DEBUGF(TCPIP_DEBUG, ("%s, Create mbox: %s \n",thread->name, tname)); + LWIP_DEBUGF(SYS_DEBUG, ("%s, Create mbox: %s \n",thread->name, tname)); } #endif @@ -144,12 +144,12 @@ sys_mbox_t sys_mbox_new(int size) void sys_mbox_free(sys_mbox_t mbox) { -#ifdef LWIP_DEBUG +#if SYS_DEBUG { struct rt_thread *thread; thread = rt_thread_self(); - LWIP_DEBUGF(TCPIP_DEBUG, ("%s, Delete mbox: %s\n",thread->name, + LWIP_DEBUGF(SYS_DEBUG, ("%s, Delete mbox: %s\n",thread->name, mbox->parent.parent.name)); } #endif @@ -161,12 +161,12 @@ void sys_mbox_free(sys_mbox_t mbox) void sys_mbox_post(sys_mbox_t mbox, void *msg) { -#ifdef LWIP_DEBUG +#if SYS_DEBUG { struct rt_thread *thread; thread = rt_thread_self(); - LWIP_DEBUGF(TCPIP_DEBUG, ("%s, Post mail: %s ,0x%x\n",thread->name, + LWIP_DEBUGF(SYS_DEBUG, ("%s, Post mail: %s ,0x%x\n",thread->name, mbox->parent.parent.name, (rt_uint32_t)msg)); } #endif @@ -178,12 +178,12 @@ void sys_mbox_post(sys_mbox_t mbox, void *msg) err_t sys_mbox_trypost(sys_mbox_t mbox, void *msg) { -#ifdef LWIP_DEBUG +#if SYS_DEBUG { struct rt_thread *thread; thread = rt_thread_self(); - LWIP_DEBUGF(TCPIP_DEBUG, ("%s, Post mail: %s ,0x%x\n",thread->name, + LWIP_DEBUGF(SYS_DEBUG, ("%s, Post mail: %s ,0x%x\n",thread->name, mbox->parent.parent.name, (rt_uint32_t)msg)); } #endif @@ -216,12 +216,12 @@ u32_t sys_arch_mbox_fetch(sys_mbox_t mbox, void **msg, u32_t timeout) if(ret == -RT_ETIMEOUT) return SYS_ARCH_TIMEOUT; else if (ret == RT_EOK) ret = 1; -#ifdef LWIP_DEBUG +#if SYS_DEBUG { struct rt_thread *thread; thread = rt_thread_self(); - LWIP_DEBUGF(TCPIP_DEBUG, ("%s, Fetch mail: %s , 0x%x\n",thread->name, + LWIP_DEBUGF(SYS_DEBUG, ("%s, Fetch mail: %s , 0x%x\n",thread->name, mbox->parent.parent.name, *(rt_uint32_t **)msg)); } #endif @@ -245,12 +245,12 @@ u32_t sys_arch_mbox_tryfetch(sys_mbox_t mbox, void **msg) if(ret == -RT_ETIMEOUT) return SYS_ARCH_TIMEOUT; else if (ret == RT_EOK) ret = 1; -#ifdef LWIP_DEBUG +#if SYS_DEBUG { struct rt_thread *thread; thread = rt_thread_self(); - LWIP_DEBUGF(TCPIP_DEBUG, ("%s, Fetch mail: %s , 0x%x\n",thread->name, + LWIP_DEBUGF(SYS_DEBUG, ("%s, Fetch mail: %s , 0x%x\n",thread->name, mbox->parent.parent.name, *(rt_uint32_t **)msg)); } #endif diff --git a/net/lwip/src/arch/sys_arch_init.c b/net/lwip/src/arch/sys_arch_init.c index 7a782cd7c2fcd22c9ad7aa3cd42b6a173fc7783d..febab3c3f30ac29fb06e10a3ba6e37d6d79eb469 100644 --- a/net/lwip/src/arch/sys_arch_init.c +++ b/net/lwip/src/arch/sys_arch_init.c @@ -1,62 +1,61 @@ -#include -#ifdef RT_USING_FINSH -#include -#endif - -#include "lwip/debug.h" -#include "lwip/mem.h" -#include "lwip/memp.h" -#include "lwip/sys.h" -#include "lwip/stats.h" -#include "lwip/tcpip.h" -#include "lwip/ip_addr.h" -#include "lwip/dhcp.h" - -#include "netif/ethernetif.h" -#include "netif/etharp.h" - -/* - * lwip system initial entry - */ -void lwip_sys_init() -{ - struct ip_addr ipaddr, netmask, gw; - -#if LWIP_DHCP - rt_uint32_t mscnt = 0; - - IP4_ADDR(&gw, 0,0,0,0); - IP4_ADDR(&ipaddr, 0,0,0,0); - IP4_ADDR(&netmask, 0,0,0,0); -#else - IP4_ADDR(&ipaddr, RT_LWIP_IPADDR0, RT_LWIP_IPADDR1, RT_LWIP_IPADDR2, RT_LWIP_IPADDR3); - IP4_ADDR(&gw, RT_LWIP_GWADDR0, RT_LWIP_GWADDR1, RT_LWIP_GWADDR2, RT_LWIP_GWADDR3); - IP4_ADDR(&netmask, RT_LWIP_MSKADDR0, RT_LWIP_MSKADDR1, RT_LWIP_MSKADDR2, RT_LWIP_MSKADDR3); -#endif - - tcpip_init(RT_NULL, RT_NULL); - - netif_set_addr(netif_default, &ipaddr, &netmask, &gw); - netif_set_up(netif_default); - -#if LWIP_DHCP - /* use DHCP client */ - dhcp_start(netif_default); - - while (1) { - rt_thread_delay(DHCP_FINE_TIMER_MSECS); - - dhcp_fine_tmr(); - mscnt += DHCP_FINE_TIMER_MSECS; - if (mscnt >= DHCP_COARSE_TIMER_SECS*1000) - { - dhcp_coarse_tmr(); - mscnt = 0; - } - } -#endif - -#if defined(RT_USING_FINSH) && (LWIP_STATS_DISPLAY) - finsh_syscall_append("lwip_info", (syscall_func)stats_display); -#endif -} +#include +#ifdef RT_USING_FINSH +#include +#endif + +#include "lwip/debug.h" +#include "lwip/mem.h" +#include "lwip/sys.h" +#include "lwip/stats.h" +#include "lwip/tcpip.h" +#include "lwip/ip_addr.h" +#include "lwip/dhcp.h" + +#include "netif/ethernetif.h" +#include "netif/etharp.h" + +/* + * lwip system initial entry + */ +void lwip_sys_init() +{ + struct ip_addr ipaddr, netmask, gw; + +#if LWIP_DHCP + rt_uint32_t mscnt = 0; + + IP4_ADDR(&gw, 0,0,0,0); + IP4_ADDR(&ipaddr, 0,0,0,0); + IP4_ADDR(&netmask, 0,0,0,0); +#else + IP4_ADDR(&ipaddr, RT_LWIP_IPADDR0, RT_LWIP_IPADDR1, RT_LWIP_IPADDR2, RT_LWIP_IPADDR3); + IP4_ADDR(&gw, RT_LWIP_GWADDR0, RT_LWIP_GWADDR1, RT_LWIP_GWADDR2, RT_LWIP_GWADDR3); + IP4_ADDR(&netmask, RT_LWIP_MSKADDR0, RT_LWIP_MSKADDR1, RT_LWIP_MSKADDR2, RT_LWIP_MSKADDR3); +#endif + + tcpip_init(RT_NULL, RT_NULL); + + netif_set_addr(netif_default, &ipaddr, &netmask, &gw); + netif_set_up(netif_default); + +#if LWIP_DHCP + /* use DHCP client */ + dhcp_start(netif_default); + + while (1) { + rt_thread_delay(DHCP_FINE_TIMER_MSECS); + + dhcp_fine_tmr(); + mscnt += DHCP_FINE_TIMER_MSECS; + if (mscnt >= DHCP_COARSE_TIMER_SECS*1000) + { + dhcp_coarse_tmr(); + mscnt = 0; + } + } +#endif + +#if defined(RT_USING_FINSH) && (LWIP_STATS_DISPLAY) + finsh_syscall_append("lwip_info", (syscall_func)stats_display); +#endif +} diff --git a/net/lwip/src/lwipopts.h b/net/lwip/src/lwipopts.h index caffaa93a40eb251e7880a5136ff6e28e0867215..08727d167dd5747a76e4cecf5c79c1835fb7b643 100644 --- a/net/lwip/src/lwipopts.h +++ b/net/lwip/src/lwipopts.h @@ -40,7 +40,7 @@ #define LWIP_PLATFORM_BYTESWAP 0 #define BYTE_ORDER LITTLE_ENDIAN -// #define RT_LWIP_DEBUG +/* #define RT_LWIP_DEBUG */ #ifdef RT_LWIP_DEBUG #define LWIP_DEBUG @@ -52,7 +52,7 @@ #define ETHARP_DEBUG LWIP_DBG_OFF #define PPP_DEBUG LWIP_DBG_OFF #define MEM_DEBUG LWIP_DBG_OFF -#define MEMP_DEBUG LWIP_DBG_ON +#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 @@ -63,8 +63,8 @@ #define AUTOIP_DEBUG LWIP_DBG_OFF #define DHCP_DEBUG LWIP_DBG_OFF #define IP_DEBUG LWIP_DBG_OFF -#define IP_REASS_DEBUG LWIP_DBG_OFF -#define ICMP_DEBUG LWIP_DBG_OFF +#define IP_REASS_DEBUG LWIP_DBG_ON +#define ICMP_DEBUG LWIP_DBG_ON #define IGMP_DEBUG LWIP_DBG_OFF #define UDP_DEBUG LWIP_DBG_OFF #define TCP_DEBUG LWIP_DBG_OFF @@ -84,9 +84,9 @@ #define MEM_ALIGNMENT RT_ALIGN_SIZE #define MEM_LIBC_MALLOC 1 -#define malloc rt_malloc -#define free rt_free -#define calloc rt_calloc +#define mem_malloc rt_malloc +#define mem_free rt_free +#define mem_calloc rt_calloc /* MEMP_NUM_PBUF: the number of memp struct pbufs. If the application sends a lot of data out of ROM (or other static memory), this