Revert "add debug message"

This reverts commit 99967e9f9b.
This commit is contained in:
lr 2024-05-23 15:54:34 +08:00
parent 99967e9f9b
commit 8c0b51161e
2 changed files with 220 additions and 210 deletions

View File

@ -1,217 +1,222 @@
/* /*
* Copyright (c) 2001-2003 Swedish Institute of Computer Science. * Copyright (c) 2001-2003 Swedish Institute of Computer Science.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without modification, * Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met: * are permitted provided that the following conditions are met:
* *
* 1. Redistributions of source code must retain the above copyright notice, * 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer. * this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice, * 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation * this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution. * and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products * 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission. * derived from this software without specific prior written permission.
* *
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
* OF SUCH DAMAGE. * OF SUCH DAMAGE.
* *
* This file is part of the lwIP TCP/IP stack. * This file is part of the lwIP TCP/IP stack.
* *
* Author: Adam Dunkels <adam@sics.se> * Author: Adam Dunkels <adam@sics.se>
* *
*/ */
#ifndef LWIP_LWIPOPTS_H #ifndef LWIP_LWIPOPTS_H
#define LWIP_LWIPOPTS_H #define LWIP_LWIPOPTS_H
/** /**
* SYS_LIGHTWEIGHT_PROT==1: if you want inter-task protection for certain * SYS_LIGHTWEIGHT_PROT==1: if you want inter-task protection for certain
* critical regions during buffer allocation, deallocation and memory * critical regions during buffer allocation, deallocation and memory
* allocation and deallocation. * allocation and deallocation.
*/ */
#define SYS_LIGHTWEIGHT_PROT 1 #define SYS_LIGHTWEIGHT_PROT 1
/** /**
* NO_SYS==1: Provides VERY minimal functionality. Otherwise, * NO_SYS==1: Provides VERY minimal functionality. Otherwise,
* use lwIP facilities. * use lwIP facilities.
*/ */
#define NO_SYS 0 #define NO_SYS 0
/** /**
* NO_SYS_NO_TIMERS==1: Drop support for sys_timeout when NO_SYS==1 * NO_SYS_NO_TIMERS==1: Drop support for sys_timeout when NO_SYS==1
* Mainly for compatibility to old versions. * Mainly for compatibility to old versions.
*/ */
#define NO_SYS_NO_TIMERS 0 #define NO_SYS_NO_TIMERS 0
/* ---------- Memory options ---------- */ /* ---------- Memory options ---------- */
/* MEM_ALIGNMENT: should be set to the alignment of the CPU for which /* MEM_ALIGNMENT: should be set to the alignment of the CPU for which
lwIP is compiled. 4 byte alignment -> define MEM_ALIGNMENT to 4, 2 lwIP is compiled. 4 byte alignment -> define MEM_ALIGNMENT to 4, 2
byte alignment -> define MEM_ALIGNMENT to 2. */ byte alignment -> define MEM_ALIGNMENT to 2. */
#define MEM_ALIGNMENT 4 #define MEM_ALIGNMENT 4
/* MEM_SIZE: the size of the heap memory. If the application will send /* MEM_SIZE: the size of the heap memory. If the application will send
a lot of data that needs to be copied, this should be set high. */ a lot of data that needs to be copied, this should be set high. */
#define MEM_SIZE (15 * 1024) #define MEM_SIZE (15*1024)
/* MEMP_NUM_PBUF: the number of memp struct pbufs. If the application /* 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 sends a lot of data out of ROM (or other static memory), this
should be set high. */ should be set high. */
#define MEMP_NUM_PBUF 25 #define MEMP_NUM_PBUF 25
/* MEMP_NUM_UDP_PCB: the number of UDP protocol control blocks. One /* MEMP_NUM_UDP_PCB: the number of UDP protocol control blocks. One
per active UDP "connection". */ per active UDP "connection". */
#define MEMP_NUM_UDP_PCB 4 #define MEMP_NUM_UDP_PCB 4
/* MEMP_NUM_TCP_PCB: the number of simulatenously active TCP /* MEMP_NUM_TCP_PCB: the number of simulatenously active TCP
connections. */ connections. */
#define MEMP_NUM_TCP_PCB 6 #define MEMP_NUM_TCP_PCB 6
/* MEMP_NUM_TCP_PCB_LISTEN: the number of listening TCP /* MEMP_NUM_TCP_PCB_LISTEN: the number of listening TCP
connections. */ connections. */
#define MEMP_NUM_TCP_PCB_LISTEN 6 #define MEMP_NUM_TCP_PCB_LISTEN 6
/* MEMP_NUM_TCP_SEG: the number of simultaneously queued TCP /* MEMP_NUM_TCP_SEG: the number of simultaneously queued TCP
segments. */ segments. */
#define MEMP_NUM_TCP_SEG 150 #define MEMP_NUM_TCP_SEG 150
/* MEMP_NUM_SYS_TIMEOUT: the number of simulateously active /* MEMP_NUM_SYS_TIMEOUT: the number of simulateously active
timeouts. */ timeouts. */
#define MEMP_NUM_SYS_TIMEOUT 6 #define MEMP_NUM_SYS_TIMEOUT 6
/* ---------- Pbuf options ---------- */
/* PBUF_POOL_SIZE: the number of buffers in the pbuf pool. */
#define PBUF_POOL_SIZE 45
/* PBUF_POOL_BUFSIZE: the size of each pbuf in the pbuf pool. */
#define PBUF_POOL_BUFSIZE \
LWIP_MEM_ALIGN_SIZE(TCP_MSS + 40 + PBUF_LINK_ENCAPSULATION_HLEN + PBUF_LINK_HLEN)
/* ---------- TCP options ---------- */ /* ---------- Pbuf options ---------- */
#define LWIP_TCP 1 /* PBUF_POOL_SIZE: the number of buffers in the pbuf pool. */
#define TCP_TTL 255 #define PBUF_POOL_SIZE 45
/* PBUF_POOL_BUFSIZE: the size of each pbuf in the pbuf pool. */
#define PBUF_POOL_BUFSIZE \
LWIP_MEM_ALIGN_SIZE(TCP_MSS+40+PBUF_LINK_ENCAPSULATION_HLEN+PBUF_LINK_HLEN)
/* Controls if TCP should queue segments that arrive out of /* ---------- TCP options ---------- */
order. Define to 0 if your device is low on memory. */ #define LWIP_TCP 1
#define TCP_QUEUE_OOSEQ 0 #define TCP_TTL 255
/* TCP Maximum segment size. */ /* Controls if TCP should queue segments that arrive out of
#define TCP_MSS (1500 - 40) order. Define to 0 if your device is low on memory. */
#define TCP_QUEUE_OOSEQ 0
/* TCP sender buffer space (bytes). */ /* TCP Maximum segment size. */
#define TCP_SND_BUF (10 * TCP_MSS) #define TCP_MSS (1500 - 40)
/* TCP_SND_QUEUELEN: TCP sender buffer space (pbufs). This must be at least /* TCP sender buffer space (bytes). */
as much as (2 * TCP_SND_BUF/TCP_MSS) for things to work. */ #define TCP_SND_BUF (10*TCP_MSS)
#define TCP_SND_QUEUELEN (8 * TCP_SND_BUF / TCP_MSS) /* TCP_SND_QUEUELEN: TCP sender buffer space (pbufs). This must be at least
as much as (2 * TCP_SND_BUF/TCP_MSS) for things to work. */
/* TCP receive window. */ #define TCP_SND_QUEUELEN (8* TCP_SND_BUF/TCP_MSS)
#define TCP_WND (11 * TCP_MSS)
/* ---------- ICMP options ---------- */ /* TCP receive window. */
#define LWIP_ICMP 1 #define TCP_WND (11*TCP_MSS)
/* ---------- DHCP options ---------- */
/* Define LWIP_DHCP to 1 if you want DHCP configuration of
interfaces. DHCP is not implemented in lwIP 0.5.1, however, so
turning this on does currently not work. */
#define LWIP_DHCP 1
/* ---------- UDP options ---------- */ /* ---------- ICMP options ---------- */
#define LWIP_UDP 1 #define LWIP_ICMP 1
#define UDP_TTL 255
/* ---------- Statistics options ---------- */
#define LWIP_STATS 0
#define LWIP_PROVIDE_ERRNO 1
/* ---------- link callback options ---------- */ /* ---------- DHCP options ---------- */
/* LWIP_NETIF_LINK_CALLBACK==1: Support a callback function from an interface /* Define LWIP_DHCP to 1 if you want DHCP configuration of
interfaces. DHCP is not implemented in lwIP 0.5.1, however, so
turning this on does currently not work. */
#define LWIP_DHCP 1
/* ---------- UDP options ---------- */
#define LWIP_UDP 1
#define UDP_TTL 255
/* ---------- Statistics options ---------- */
#define LWIP_STATS 0
#define LWIP_PROVIDE_ERRNO 1
/* ---------- link callback options ---------- */
/* LWIP_NETIF_LINK_CALLBACK==1: Support a callback function from an interface
* whenever the link changes (i.e., link down) * whenever the link changes (i.e., link down)
*/ */
#define LWIP_NETIF_LINK_CALLBACK 0 #define LWIP_NETIF_LINK_CALLBACK 0
/* /*
-------------------------------------- --------------------------------------
---------- Checksum options ---------- ---------- Checksum options ----------
-------------------------------------- --------------------------------------
*/ */
/* The STM32F4x7 allows computing and verifying the IP, /* The STM32F4x7 allows computing and verifying the IP,
UDP, TCP and ICMP checksums by hardware: UDP, TCP and ICMP checksums by hardware:
- To use this feature let the following define uncommented. - To use this feature let the following define uncommented.
- To disable it and process by CPU comment the the checksum. - To disable it and process by CPU comment the the checksum.
*/ */
#define CHECKSUM_BY_HARDWARE #define CHECKSUM_BY_HARDWARE
#ifdef CHECKSUM_BY_HARDWARE #ifdef CHECKSUM_BY_HARDWARE
/* CHECKSUM_GEN_IP==0: Generate checksums by hardware for outgoing IP packets.*/ /* CHECKSUM_GEN_IP==0: Generate checksums by hardware for outgoing IP packets.*/
#define CHECKSUM_GEN_IP 0 #define CHECKSUM_GEN_IP 0
/* CHECKSUM_GEN_UDP==0: Generate checksums by hardware for outgoing UDP packets.*/ /* CHECKSUM_GEN_UDP==0: Generate checksums by hardware for outgoing UDP packets.*/
#define CHECKSUM_GEN_UDP 0 #define CHECKSUM_GEN_UDP 0
/* CHECKSUM_GEN_TCP==0: Generate checksums by hardware for outgoing TCP packets.*/ /* CHECKSUM_GEN_TCP==0: Generate checksums by hardware for outgoing TCP packets.*/
#define CHECKSUM_GEN_TCP 0 #define CHECKSUM_GEN_TCP 0
/* CHECKSUM_CHECK_IP==0: Check checksums by hardware for incoming IP packets.*/ /* CHECKSUM_CHECK_IP==0: Check checksums by hardware for incoming IP packets.*/
#define CHECKSUM_CHECK_IP 0 #define CHECKSUM_CHECK_IP 0
/* CHECKSUM_CHECK_UDP==0: Check checksums by hardware for incoming UDP packets.*/ /* CHECKSUM_CHECK_UDP==0: Check checksums by hardware for incoming UDP packets.*/
#define CHECKSUM_CHECK_UDP 0 #define CHECKSUM_CHECK_UDP 0
/* CHECKSUM_CHECK_TCP==0: Check checksums by hardware for incoming TCP packets.*/ /* CHECKSUM_CHECK_TCP==0: Check checksums by hardware for incoming TCP packets.*/
#define CHECKSUM_CHECK_TCP 0 #define CHECKSUM_CHECK_TCP 0
/*CHECKSUM_CHECK_ICMP==0: Check checksums by hardware for incoming ICMP packets.*/ /*CHECKSUM_CHECK_ICMP==0: Check checksums by hardware for incoming ICMP packets.*/
#define CHECKSUM_GEN_ICMP 0 #define CHECKSUM_GEN_ICMP 0
#else #else
/* CHECKSUM_GEN_IP==1: Generate checksums in software for outgoing IP packets.*/ /* CHECKSUM_GEN_IP==1: Generate checksums in software for outgoing IP packets.*/
#define CHECKSUM_GEN_IP 1 #define CHECKSUM_GEN_IP 1
/* CHECKSUM_GEN_UDP==1: Generate checksums in software for outgoing UDP packets.*/ /* CHECKSUM_GEN_UDP==1: Generate checksums in software for outgoing UDP packets.*/
#define CHECKSUM_GEN_UDP 1 #define CHECKSUM_GEN_UDP 1
/* CHECKSUM_GEN_TCP==1: Generate checksums in software for outgoing TCP packets.*/ /* CHECKSUM_GEN_TCP==1: Generate checksums in software for outgoing TCP packets.*/
#define CHECKSUM_GEN_TCP 1 #define CHECKSUM_GEN_TCP 1
/* CHECKSUM_CHECK_IP==1: Check checksums in software for incoming IP packets.*/ /* CHECKSUM_CHECK_IP==1: Check checksums in software for incoming IP packets.*/
#define CHECKSUM_CHECK_IP 1 #define CHECKSUM_CHECK_IP 1
/* CHECKSUM_CHECK_UDP==1: Check checksums in software for incoming UDP packets.*/ /* CHECKSUM_CHECK_UDP==1: Check checksums in software for incoming UDP packets.*/
#define CHECKSUM_CHECK_UDP 1 #define CHECKSUM_CHECK_UDP 1
/* CHECKSUM_CHECK_TCP==1: Check checksums in software for incoming TCP packets.*/ /* CHECKSUM_CHECK_TCP==1: Check checksums in software for incoming TCP packets.*/
#define CHECKSUM_CHECK_TCP 1 #define CHECKSUM_CHECK_TCP 1
/*CHECKSUM_CHECK_ICMP==1: Check checksums by hardware for incoming ICMP packets.*/ /*CHECKSUM_CHECK_ICMP==1: Check checksums by hardware for incoming ICMP packets.*/
#define CHECKSUM_GEN_ICMP 1 #define CHECKSUM_GEN_ICMP 1
#endif #endif
/* /*
---------------------------------------------- ----------------------------------------------
---------- Sequential layer options ---------- ---------- Sequential layer options ----------
---------------------------------------------- ----------------------------------------------
*/ */
/** /**
* LWIP_NETCONN==1: Enable Netconn API (require to use api_lib.c) * LWIP_NETCONN==1: Enable Netconn API (require to use api_lib.c)
*/ */
#define LWIP_NETCONN 1 #define LWIP_NETCONN 1
/* /*
------------------------------------ ------------------------------------
---------- Socket options ---------- ---------- Socket options ----------
------------------------------------ ------------------------------------
*/ */
/** /**
* LWIP_SOCKET==1: Enable Socket API (require to use sockets.c) * LWIP_SOCKET==1: Enable Socket API (require to use sockets.c)
*/ */
#define LWIP_SOCKET 1 #define LWIP_SOCKET 1
/* /*
--------------------------------- ---------------------------------
---------- OS options ---------- ---------- OS options ----------
--------------------------------- ---------------------------------
*/ */
#define DEFAULT_UDP_RECVMBOX_SIZE 10 #define DEFAULT_UDP_RECVMBOX_SIZE 10
#define DEFAULT_TCP_RECVMBOX_SIZE 10 #define DEFAULT_TCP_RECVMBOX_SIZE 10
#define DEFAULT_ACCEPTMBOX_SIZE 10 #define DEFAULT_ACCEPTMBOX_SIZE 10
#define DEFAULT_THREAD_STACKSIZE 1024 #define DEFAULT_THREAD_STACKSIZE 1024
#define TCPIP_THREAD_NAME "tcpip" #define TCPIP_THREAD_NAME "lwip"
#define TCPIP_THREAD_STACKSIZE 512 #define TCPIP_THREAD_STACKSIZE 512
#define TCPIP_MBOX_SIZE 8 #define TCPIP_MBOX_SIZE 8
#define TCPIP_THREAD_PRIO 3 #define TCPIP_THREAD_PRIO 3
/* /*
---------------------------------------- ----------------------------------------

View File

@ -25,8 +25,8 @@
#include <lwip/sys.h> #include <lwip/sys.h>
#if !NO_SYS #if !NO_SYS
#include "libserial.h"
#include "sys_arch.h" #include "sys_arch.h"
#include "libserial.h"
#include "usyscall.h" #include "usyscall.h"
#endif #endif
@ -47,10 +47,11 @@ u32_t sys_jiffies(void)
} }
u32_t sys_now(void) u32_t sys_now(void)
{ {
return 1; return 1;
} }
sys_prot_t sys_arch_protect(void) sys_prot_t sys_arch_protect(void)
{ {
return 1; return 1;
@ -64,11 +65,13 @@ void sys_arch_unprotect(sys_prot_t pval)
err_t sys_sem_new(sys_sem_t* sem, u8_t count) err_t sys_sem_new(sys_sem_t* sem, u8_t count)
{ {
struct Session sem_session;
sem_t semaphore; sem_t semaphore;
connect_session(&sem->sess, sem_server_name, 4096); connect_session(&sem_session, sem_server_name, 4096);
sem_create(&sem->sess, &semaphore, (int)count); sem_create(&sem_session, &semaphore, (int)count);
sem->sem = semaphore; sem->sem = semaphore;
#if SYS_STATS sem->sess = sem_session;
#if SYS_STATS
++lwip_stats.sys.sem.used; ++lwip_stats.sys.sem.used;
if (lwip_stats.sys.sem.max < lwip_stats.sys.sem.used) { if (lwip_stats.sys.sem.max < lwip_stats.sys.sem.used) {
lwip_stats.sys.sem.max = lwip_stats.sys.sem.used; lwip_stats.sys.sem.max = lwip_stats.sys.sem.used;
@ -91,7 +94,7 @@ void sys_sem_free(sys_sem_t* sem)
#if SYS_STATS #if SYS_STATS
--lwip_stats.sys.sem.used; --lwip_stats.sys.sem.used;
#endif /* SYS_STATS */ #endif /* SYS_STATS */
sem_delete(&sem->sess, &sem->sem); sem_delete(&sem->sess, &sem->sem);
free_session(&sem->sess); free_session(&sem->sess);
free(sem); free(sem);
sem = SYS_SEM_NULL; sem = SYS_SEM_NULL;
@ -113,9 +116,8 @@ u32_t sys_arch_sem_wait(sys_sem_t* sem, u32_t timeout)
if (sem->sem < 0) if (sem->sem < 0)
return SYS_ARCH_TIMEOUT; return SYS_ARCH_TIMEOUT;
printf("%s wait %d, %d\n", __func__, sem->sem, __LINE__);
sem_wait(&sem->sess, &sem->sem, 0); sem_wait(&sem->sess, &sem->sem, 0);
printf("%s, %d\n", __func__, __LINE__);
return 0; return 0;
} }
@ -138,19 +140,14 @@ void sys_mutex_set_invalid(sys_mutex_t* mutex)
{ {
sys_sem_set_invalid(mutex); sys_sem_set_invalid(mutex);
} }
void sys_mutex_lock(sys_mutex_t* mutex) void sys_mutex_lock(sys_mutex_t* mutex)
{ {
printf("%s(mtx: %d)\n", __func__, *mutex);
sys_arch_sem_wait(mutex, 0); sys_arch_sem_wait(mutex, 0);
printf("%s(mtx: %d), return\n", __func__, *mutex);
} }
void sys_mutex_unlock(sys_mutex_t* mutex) void sys_mutex_unlock(sys_mutex_t* mutex)
{ {
printf("%s(mtx: %d)\n", __func__, *mutex);
sys_sem_signal(mutex); sys_sem_signal(mutex);
printf("%s(mtx: %d), return\n", __func__, *mutex);
} }
sys_thread_t sys_thread_new(const char* name, lwip_thread_fn function, void* arg, int stacksize, int prio) sys_thread_t sys_thread_new(const char* name, lwip_thread_fn function, void* arg, int stacksize, int prio)
@ -163,7 +160,7 @@ sys_thread_t sys_thread_new(const char* name, lwip_thread_fn function, void* arg
err_t sys_mbox_new(sys_mbox_t* mbox, int size) err_t sys_mbox_new(sys_mbox_t* mbox, int size)
{ {
mbox->first = mbox->last = 0; mbox->first = mbox->last = 0;
sys_sem_t not_empty; sys_sem_t not_empty;
@ -177,7 +174,7 @@ err_t sys_mbox_new(sys_mbox_t* mbox, int size)
sys_sem_t mutex; sys_sem_t mutex;
sys_sem_new(&mutex, 1); sys_sem_new(&mutex, 1);
mbox->mutex = &mutex; mbox->mutex = &mutex;
mbox->wait_send = 0; mbox->wait_send = 0;
#if SYS_STATS #if SYS_STATS
@ -192,11 +189,11 @@ err_t sys_mbox_new(sys_mbox_t* mbox, int size)
} }
printf("lw: [%s] alloc %d mbox %p ok!\n", __func__, size, mbox); printf("lw: [%s] alloc %d mbox %p ok!\n", __func__, size, mbox);
return ERR_OK; return ERR_OK;
} }
void sys_mbox_free(sys_mbox_t* mbox) void sys_mbox_free(sys_mbox_t* mbox)
{ {
if (mbox != SYS_MBOX_NULL) { if (mbox != SYS_MBOX_NULL){
sys_arch_sem_wait(mbox->mutex, 0); sys_arch_sem_wait(mbox->mutex, 0);
sys_sem_free(mbox->not_empty); sys_sem_free(mbox->not_empty);
sys_sem_free(mbox->not_full); sys_sem_free(mbox->not_full);
@ -222,11 +219,11 @@ void sys_mbox_post(sys_mbox_t* q, void* msg)
u8_t first; u8_t first;
if (q == NULL) if (q == NULL)
printf("lw: [%s] alloc %d mbox %p failed\n", __func__, q); printf("lw: [%s] alloc %d mbox %p failed\n", __func__, q);
sys_arch_sem_wait(q->mutex, 0); sys_arch_sem_wait(q->mutex, 0);
printf("sys_mbox_post: mbox %p msg %p\n", (void*)q, (void*)msg); printf("sys_mbox_post: mbox %p msg %p\n", (void *)q, (void *)msg);
while ((q->last + 1) >= (q->first + SYS_MBOX_SIZE)) { while ((q->last + 1) >= (q->first + SYS_MBOX_SIZE)) {
q->wait_send++; q->wait_send++;
sys_sem_signal(q->mutex); sys_sem_signal(q->mutex);
@ -259,7 +256,7 @@ err_t sys_mbox_trypost(sys_mbox_t* q, void* msg)
sys_arch_sem_wait(q->mutex, 0); sys_arch_sem_wait(q->mutex, 0);
printf("sys_mbox_trypost: mbox %p msg %p\n", (void*)q, (void*)msg); printf("sys_mbox_trypost: mbox %p msg %p\n",(void *)q, (void *)msg);
if ((q->last + 1) >= (q->first + SYS_MBOX_SIZE)) { if ((q->last + 1) >= (q->first + SYS_MBOX_SIZE)) {
sys_sem_signal(q->mutex); sys_sem_signal(q->mutex);
@ -294,20 +291,21 @@ u32_t sys_arch_mbox_fetch(sys_mbox_t* q, void** msg, u32_t timeout)
{ {
if (q == NULL) if (q == NULL)
printf("lw: [%s] alloc %d mbox %p failed\n", __func__, q); printf("lw: [%s] alloc %d mbox %p failed\n", __func__, q);
sys_arch_sem_wait(q->mutex, 0); sys_arch_sem_wait(q->mutex, 0);
while (q->first == q->last) { while (q->first == q->last) {
sys_sem_signal(q->mutex); sys_sem_signal(q->mutex);
sys_arch_sem_wait(q->not_empty, 0); sys_arch_sem_wait(q->not_empty, 0);
sys_arch_sem_wait(q->mutex, 0); sys_arch_sem_wait(q->mutex, 0);
} }
if (msg != NULL) { if (msg != NULL) {
printf("sys_mbox_fetch: mbox %p msg %p\n", (void*)q, *msg); printf("sys_mbox_fetch: mbox %p msg %p\n", (void *)q, *msg);
*msg = q->msgs[q->first % SYS_MBOX_SIZE]; *msg = q->msgs[q->first % SYS_MBOX_SIZE];
} else { }
printf("sys_mbox_fetch: mbox %p, null msg\n", (void*)q); else{
printf("sys_mbox_fetch: mbox %p, null msg\n", (void *)q);
} }
q->first++; q->first++;
@ -324,7 +322,7 @@ u32_t sys_arch_mbox_tryfetch(sys_mbox_t* q, void** msg)
{ {
if (q == NULL) if (q == NULL)
printf("lw: [%s] alloc %d mbox %p failed\n", __func__, q); printf("lw: [%s] alloc %d mbox %p failed\n", __func__, q);
sys_arch_sem_wait(q->mutex, 0); sys_arch_sem_wait(q->mutex, 0);
if (q->first == q->last) { if (q->first == q->last) {
@ -333,10 +331,11 @@ u32_t sys_arch_mbox_tryfetch(sys_mbox_t* q, void** msg)
} }
if (msg != NULL) { if (msg != NULL) {
printf("sys_mbox_tryfetch: mbox %p msg %p\n", (void*)q, *msg); printf("sys_mbox_tryfetch: mbox %p msg %p\n", (void *)q, *msg);
*msg = q->msgs[q->first % SYS_MBOX_SIZE]; *msg = q->msgs[q->first % SYS_MBOX_SIZE];
} else { }
printf("sys_mbox_tryfetch: mbox %p, null msg\n", (void*)q); else{
printf("sys_mbox_tryfetch: mbox %p, null msg\n", (void *)q);
} }
q->first++; q->first++;
@ -372,21 +371,24 @@ int lwip_config_tcp(char* ip, char* mask, char* gw)
tcpip_init(NULL, NULL); tcpip_init(NULL, NULL);
#ifndef NETIF_ENET_INIT_FUNC #ifndef NETIF_ENET_INIT_FUNC
printf("Not Netif driver for Eport 0\n"); printf("Not Netif driver for Eport 0\n");
return 0; return 0;
#endif #endif
#ifdef NETIF_ENET_INIT_FUNC #ifdef NETIF_ENET_INIT_FUNC
netif_add(&gnetif, &net_ipaddr, &net_netmask, &net_gw, NULL, netif_add(&gnetif, &net_ipaddr, &net_netmask, &net_gw, NULL,
NETIF_ENET_INIT_FUNC, &tcpip_input); NETIF_ENET_INIT_FUNC, &tcpip_input);
/* Registers the default network interface */ /* Registers the default network interface */
netif_set_default(&gnetif); netif_set_default(&gnetif);
if (netif_is_link_up(&gnetif)) { if (netif_is_link_up(&gnetif))
/*When the netif is fully configured this function must be called */ {
/*When the netif is fully configured this function must be called */
netif_set_up(&gnetif); netif_set_up(&gnetif);
} else { }
else
{
/* When the netif link is down this function must be called */ /* When the netif link is down this function must be called */
netif_set_down(&gnetif); netif_set_down(&gnetif);
return -1; return -1;
@ -395,12 +397,15 @@ int lwip_config_tcp(char* ip, char* mask, char* gw)
printf(" Network Configuration\r\n"); printf(" Network Configuration\r\n");
printf("************************************************\r\n"); printf("************************************************\r\n");
printf(" IPv4 Address : %u.%u.%u.%u\r\n", ((u8_t*)&net_ipaddr)[0], ((u8_t*)&net_ipaddr)[1], printf(" IPv4 Address : %u.%u.%u.%u\r\n", ((u8_t*)&net_ipaddr)[0], ((u8_t*)&net_ipaddr)[1],
((u8_t*)&net_ipaddr)[2], ((u8_t*)&net_ipaddr)[3]); ((u8_t*)&net_ipaddr)[2], ((u8_t*)&net_ipaddr)[3]);
printf(" IPv4 Subnet mask : %u.%u.%u.%u\r\n", ((u8_t*)&net_netmask)[0], ((u8_t*)&net_netmask)[1], printf(" IPv4 Subnet mask : %u.%u.%u.%u\r\n", ((u8_t*)&net_netmask)[0], ((u8_t*)&net_netmask)[1],
((u8_t*)&net_netmask)[2], ((u8_t*)&net_netmask)[3]); ((u8_t*)&net_netmask)[2], ((u8_t*)&net_netmask)[3]);
printf(" IPv4 Gateway : %u.%u.%u.%u\r\n", ((u8_t*)&net_gw)[0], ((u8_t*)&net_gw)[1], printf(" IPv4 Gateway : %u.%u.%u.%u\r\n", ((u8_t*)&net_gw)[0], ((u8_t*)&net_gw)[1],
((u8_t*)&net_gw)[2], ((u8_t*)&net_gw)[3]); ((u8_t*)&net_gw)[2], ((u8_t*)&net_gw)[3]);
printf("************************************************\r\n"); printf("************************************************\r\n");
return 0; return 0;
#endif #endif
} }