LwIP on 64 bit processor

This commit is contained in:
bigmagic 2020-09-04 10:23:31 +08:00
parent 88314868dd
commit e0aa079e52
6 changed files with 29 additions and 19 deletions

View File

@ -807,7 +807,7 @@ void eth_rx_irq(int irqno, void *param)
if (dma_status_reg & GmacLineIntfIntr) if (dma_status_reg & GmacLineIntfIntr)
{ {
rt_kprintf("%s:: Interrupt due to GMAC LINE module\n", __FUNCTION__); //rt_kprintf("%s:: Interrupt due to GMAC LINE module\n", __FUNCTION__);
} }
interrupt = synopGMAC_get_interrupt_type(gmacdev); interrupt = synopGMAC_get_interrupt_type(gmacdev);

View File

@ -118,7 +118,7 @@ config RT_USING_LWIP
config RT_USING_LWIP202 config RT_USING_LWIP202
bool "lwIP v2.0.2" bool "lwIP v2.0.2"
config RT_USING_LWIP212 config RT_USING_LWIP212
bool "lwIP v2.1.2" bool "lwIP v2.1.2"
endchoice endchoice
@ -131,6 +131,10 @@ config RT_USING_LWIP
select NETDEV_IPV6_SCOPES if RT_USING_LWIP212 select NETDEV_IPV6_SCOPES if RT_USING_LWIP212
endif endif
config RT_LWIP_MEM_ALIGNMENT
int "Memory alignment"
default 4
config RT_LWIP_IGMP config RT_LWIP_IGMP
bool "IGMP protocol" bool "IGMP protocol"
default y default y

View File

@ -460,7 +460,7 @@ void sys_mbox_post(sys_mbox_t *mbox, void *msg)
{ {
RT_DEBUG_NOT_IN_INTERRUPT; RT_DEBUG_NOT_IN_INTERRUPT;
rt_mb_send_wait(*mbox, (rt_uint32_t)msg, RT_WAITING_FOREVER); rt_mb_send_wait(*mbox, (rt_ubase_t)msg, RT_WAITING_FOREVER);
return; return;
} }
@ -472,7 +472,7 @@ void sys_mbox_post(sys_mbox_t *mbox, void *msg)
*/ */
err_t sys_mbox_trypost(sys_mbox_t *mbox, void *msg) err_t sys_mbox_trypost(sys_mbox_t *mbox, void *msg)
{ {
if (rt_mb_send(*mbox, (rt_uint32_t)msg) == RT_EOK) if (rt_mb_send(*mbox, (rt_ubase_t)msg) == RT_EOK)
return ERR_OK; return ERR_OK;
return ERR_MEM; return ERR_MEM;

View File

@ -230,7 +230,12 @@
#define LWIP_DBG_TYPES_ON (LWIP_DBG_ON|LWIP_DBG_TRACE|LWIP_DBG_STATE|LWIP_DBG_FRESH|LWIP_DBG_HALT) #define LWIP_DBG_TYPES_ON (LWIP_DBG_ON|LWIP_DBG_TRACE|LWIP_DBG_STATE|LWIP_DBG_FRESH|LWIP_DBG_HALT)
/* ---------- Memory options ---------- */ /* ---------- Memory options ---------- */
#ifdef RT_LWIP_MEM_ALIGNMENT
#define MEM_ALIGNMENT RT_LWIP_MEM_ALIGNMENT
#else
#define MEM_ALIGNMENT 4 #define MEM_ALIGNMENT 4
#endif
#define MEMP_OVERFLOW_CHECK 1 //// #define MEMP_OVERFLOW_CHECK 1 ////
#define LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT 1 //// #define LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT 1 ////
//#define MEM_LIBC_MALLOC 1 //#define MEM_LIBC_MALLOC 1

View File

@ -38,6 +38,7 @@
* after lwIP initialization. * after lwIP initialization.
* 2013-02-28 aozima fixed list_tcps bug: ipaddr_ntoa isn't reentrant. * 2013-02-28 aozima fixed list_tcps bug: ipaddr_ntoa isn't reentrant.
* 2016-08-18 Bernard port to lwIP 2.0.0 * 2016-08-18 Bernard port to lwIP 2.0.0
* 2020-08-10 lizhirui fixed some problems when this is running on 64-bit cpu
*/ */
#include "lwip/opt.h" #include "lwip/opt.h"
@ -85,10 +86,10 @@ struct eth_tx_msg
static struct rt_mailbox eth_tx_thread_mb; static struct rt_mailbox eth_tx_thread_mb;
static struct rt_thread eth_tx_thread; static struct rt_thread eth_tx_thread;
#ifndef RT_LWIP_ETHTHREAD_MBOX_SIZE #ifndef RT_LWIP_ETHTHREAD_MBOX_SIZE
static char eth_tx_thread_mb_pool[32 * 4]; static char eth_tx_thread_mb_pool[32 * sizeof(rt_ubase_t)];
static char eth_tx_thread_stack[512]; static char eth_tx_thread_stack[512];
#else #else
static char eth_tx_thread_mb_pool[RT_LWIP_ETHTHREAD_MBOX_SIZE * 4]; static char eth_tx_thread_mb_pool[RT_LWIP_ETHTHREAD_MBOX_SIZE * sizeof(rt_ubase_t)];
static char eth_tx_thread_stack[RT_LWIP_ETHTHREAD_STACKSIZE]; static char eth_tx_thread_stack[RT_LWIP_ETHTHREAD_STACKSIZE];
#endif #endif
#endif #endif
@ -97,10 +98,10 @@ static char eth_tx_thread_stack[RT_LWIP_ETHTHREAD_STACKSIZE];
static struct rt_mailbox eth_rx_thread_mb; static struct rt_mailbox eth_rx_thread_mb;
static struct rt_thread eth_rx_thread; static struct rt_thread eth_rx_thread;
#ifndef RT_LWIP_ETHTHREAD_MBOX_SIZE #ifndef RT_LWIP_ETHTHREAD_MBOX_SIZE
static char eth_rx_thread_mb_pool[48 * 4]; static char eth_rx_thread_mb_pool[48 * sizeof(rt_ubase_t)];
static char eth_rx_thread_stack[1024]; static char eth_rx_thread_stack[1024];
#else #else
static char eth_rx_thread_mb_pool[RT_LWIP_ETHTHREAD_MBOX_SIZE * 4]; static char eth_rx_thread_mb_pool[RT_LWIP_ETHTHREAD_MBOX_SIZE * sizeof(rt_ubase_t)];
static char eth_rx_thread_stack[RT_LWIP_ETHTHREAD_STACKSIZE]; static char eth_rx_thread_stack[RT_LWIP_ETHTHREAD_STACKSIZE];
#endif #endif
#endif #endif
@ -395,7 +396,7 @@ static err_t ethernetif_linkoutput(struct netif *netif, struct pbuf *p)
/* send a message to eth tx thread */ /* send a message to eth tx thread */
msg.netif = netif; msg.netif = netif;
msg.buf = p; msg.buf = p;
if (rt_mb_send(&eth_tx_thread_mb, (rt_uint32_t) &msg) == RT_EOK) if (rt_mb_send(&eth_tx_thread_mb, (rt_ubase_t) &msg) == RT_EOK)
{ {
/* waiting for ack */ /* waiting for ack */
rt_sem_take(&(enetif->tx_ack), RT_WAITING_FOREVER); rt_sem_take(&(enetif->tx_ack), RT_WAITING_FOREVER);
@ -599,7 +600,7 @@ rt_err_t eth_device_ready(struct eth_device* dev)
{ {
if (dev->netif) if (dev->netif)
/* post message to Ethernet thread */ /* post message to Ethernet thread */
return rt_mb_send(&eth_rx_thread_mb, (rt_uint32_t)dev); return rt_mb_send(&eth_rx_thread_mb, (rt_ubase_t)dev);
else else
return ERR_OK; /* netif is not initialized yet, just return. */ return ERR_OK; /* netif is not initialized yet, just return. */
} }
@ -619,7 +620,7 @@ rt_err_t eth_device_linkchange(struct eth_device* dev, rt_bool_t up)
rt_hw_interrupt_enable(level); rt_hw_interrupt_enable(level);
/* post message to ethernet thread */ /* post message to ethernet thread */
return rt_mb_send(&eth_rx_thread_mb, (rt_uint32_t)dev); return rt_mb_send(&eth_rx_thread_mb, (rt_ubase_t)dev);
} }
#else #else
/* NOTE: please not use it in interrupt when no RxThread exist */ /* NOTE: please not use it in interrupt when no RxThread exist */
@ -739,7 +740,7 @@ int eth_system_device_init_private(void)
#ifndef LWIP_NO_RX_THREAD #ifndef LWIP_NO_RX_THREAD
/* initialize mailbox and create Ethernet Rx thread */ /* initialize mailbox and create Ethernet Rx thread */
result = rt_mb_init(&eth_rx_thread_mb, "erxmb", result = rt_mb_init(&eth_rx_thread_mb, "erxmb",
&eth_rx_thread_mb_pool[0], sizeof(eth_rx_thread_mb_pool)/4, &eth_rx_thread_mb_pool[0], sizeof(eth_rx_thread_mb_pool)/sizeof(rt_ubase_t),
RT_IPC_FLAG_FIFO); RT_IPC_FLAG_FIFO);
RT_ASSERT(result == RT_EOK); RT_ASSERT(result == RT_EOK);
@ -755,7 +756,7 @@ int eth_system_device_init_private(void)
#ifndef LWIP_NO_TX_THREAD #ifndef LWIP_NO_TX_THREAD
/* initialize mailbox and create Ethernet Tx thread */ /* initialize mailbox and create Ethernet Tx thread */
result = rt_mb_init(&eth_tx_thread_mb, "etxmb", result = rt_mb_init(&eth_tx_thread_mb, "etxmb",
&eth_tx_thread_mb_pool[0], sizeof(eth_tx_thread_mb_pool)/4, &eth_tx_thread_mb_pool[0], sizeof(eth_tx_thread_mb_pool)/sizeof(rt_ubase_t),
RT_IPC_FLAG_FIFO); RT_IPC_FLAG_FIFO);
RT_ASSERT(result == RT_EOK); RT_ASSERT(result == RT_EOK);

View File

@ -63,11 +63,11 @@ static struct rt_mailbox eth_rx_thread_mb;
static struct rt_thread eth_rx_thread; static struct rt_thread eth_rx_thread;
#ifndef RT_LWIP_ETHTHREAD_PRIORITY #ifndef RT_LWIP_ETHTHREAD_PRIORITY
#define RT_ETHERNETIF_THREAD_PREORITY 0x90 #define RT_ETHERNETIF_THREAD_PREORITY 0x90
static char eth_rx_thread_mb_pool[48 * 4]; static char eth_rx_thread_mb_pool[48 * sizeof(rt_ubase_t)];
static char eth_rx_thread_stack[1024]; static char eth_rx_thread_stack[1024];
#else #else
#define RT_ETHERNETIF_THREAD_PREORITY RT_LWIP_ETHTHREAD_PRIORITY #define RT_ETHERNETIF_THREAD_PREORITY RT_LWIP_ETHTHREAD_PRIORITY
static char eth_rx_thread_mb_pool[RT_LWIP_ETHTHREAD_MBOX_SIZE * 4]; static char eth_rx_thread_mb_pool[RT_LWIP_ETHTHREAD_MBOX_SIZE * sizeof(rt_ubase_t)];
static char eth_rx_thread_stack[RT_LWIP_ETHTHREAD_STACKSIZE]; static char eth_rx_thread_stack[RT_LWIP_ETHTHREAD_STACKSIZE];
#endif #endif
@ -79,10 +79,10 @@ struct eth_tx_msg
static struct rt_mailbox eth_tx_thread_mb; static struct rt_mailbox eth_tx_thread_mb;
static struct rt_thread eth_tx_thread; static struct rt_thread eth_tx_thread;
#ifndef RT_LWIP_ETHTHREAD_PRIORITY #ifndef RT_LWIP_ETHTHREAD_PRIORITY
static char eth_tx_thread_mb_pool[32 * 4]; static char eth_tx_thread_mb_pool[32 * sizeof(rt_ubase_t)];
static char eth_tx_thread_stack[512]; static char eth_tx_thread_stack[512];
#else #else
static char eth_tx_thread_mb_pool[RT_LWIP_ETHTHREAD_MBOX_SIZE * 4]; static char eth_tx_thread_mb_pool[RT_LWIP_ETHTHREAD_MBOX_SIZE * sizeof(rt_ubase_t)];
static char eth_tx_thread_stack[RT_LWIP_ETHTHREAD_STACKSIZE]; static char eth_tx_thread_stack[RT_LWIP_ETHTHREAD_STACKSIZE];
#endif #endif
@ -281,7 +281,7 @@ rt_err_t eth_system_device_init()
/* init rx thread */ /* init rx thread */
/* init mailbox and create ethernet thread */ /* init mailbox and create ethernet thread */
result = rt_mb_init(&eth_rx_thread_mb, "erxmb", result = rt_mb_init(&eth_rx_thread_mb, "erxmb",
&eth_rx_thread_mb_pool[0], sizeof(eth_rx_thread_mb_pool)/4, &eth_rx_thread_mb_pool[0], sizeof(eth_rx_thread_mb_pool)/sizeof(rt_ubase_t),
RT_IPC_FLAG_FIFO); RT_IPC_FLAG_FIFO);
RT_ASSERT(result == RT_EOK); RT_ASSERT(result == RT_EOK);
@ -297,7 +297,7 @@ rt_err_t eth_system_device_init()
/* init mailbox and create ethernet thread */ /* init mailbox and create ethernet thread */
result = rt_mb_init(&eth_tx_thread_mb, "etxmb", result = rt_mb_init(&eth_tx_thread_mb, "etxmb",
&eth_tx_thread_mb_pool[0], sizeof(eth_tx_thread_mb_pool)/4, &eth_tx_thread_mb_pool[0], sizeof(eth_tx_thread_mb_pool)/sizeof(rt_ubase_t),
RT_IPC_FLAG_FIFO); RT_IPC_FLAG_FIFO);
RT_ASSERT(result == RT_EOK); RT_ASSERT(result == RT_EOK);