Skip to content

Commit

Permalink
spider: add lwip support of Trampoline OS, without the needs to defin…
Browse files Browse the repository at this point in the history
…e NO_SYS=1
  • Loading branch information
fsylvestre committed Nov 15, 2023
1 parent 0cfa5d5 commit 570ea98
Show file tree
Hide file tree
Showing 4 changed files with 682 additions and 17 deletions.
10 changes: 9 additions & 1 deletion libraries/drivers/lwip_port/renesas/arch/cc.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@

#include "utils.h"

// Hack to use our own 'atoi' function in order to prevent usage of libc one, because libc 'atoi' has many dependencies
#undef atoi
//unsigned int atoi(const unsigned char* s);
int atoi(const char *num);

#define LWIP_ERR_T int

#define LWIP_PROVIDE_ERRNO
Expand All @@ -15,6 +20,8 @@
#define S32_F "d"
#define X32_F "x"

#define BYTE_ORDER LITTLE_ENDIAN

/* Compiler hints for packing structures */
#define PACK_STRUCT_FIELD(x) x
#define PACK_STRUCT_STRUCT __attribute__((packed))
Expand All @@ -23,10 +30,11 @@

/* Plaform specific diagnostic output */
#define LWIP_PLATFORM_DIAG(x) do { \
debug_msg x; \
debug_msg x; \
} while (0)

#define LWIP_PLATFORM_ASSERT(x) do { \
while(1); \
} while (0)

#endif /* __ARCH_CC_H__ */
42 changes: 42 additions & 0 deletions libraries/drivers/lwip_port/renesas/arch/sys_arch.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#ifndef LWIP_ARCH_SYS_ARCH_H
#define LWIP_ARCH_SYS_ARCH_H

#include "lwip/arch.h"

#if !NO_SYS

#define SYS_MBOX_NULL NULL
#define SYS_SEM_NULL NULL

#define MAX_NB_MUTEX 100
#define MAX_NB_SEM 40
#define MAX_NB_MBOX 10

typedef u32_t sys_prot_t;

struct sys_sem;
typedef struct sys_sem * sys_sem_t;
#define sys_sem_valid(sem) (((sem) != NULL) && (*(sem) != NULL))
#define sys_sem_valid_val(sem) ((sem) != NULL)
#define sys_sem_set_invalid(sem) do { if((sem) != NULL) { *(sem) = NULL; }}while(0)
#define sys_sem_set_invalid_val(sem) do { (sem) = NULL; }while(0)

struct sys_mutex;
typedef struct sys_mutex * sys_mutex_t;
#define sys_mutex_valid(mutex) sys_sem_valid(mutex)
#define sys_mutex_set_invalid(mutex) sys_sem_set_invalid(mutex)

struct sys_mbox;
typedef struct sys_mbox * sys_mbox_t;
#define sys_mbox_valid(mbox) sys_sem_valid(mbox)
#define sys_mbox_valid_val(mbox) sys_sem_valid_val(mbox)
#define sys_mbox_set_invalid(mbox) sys_sem_set_invalid(mbox)
#define sys_mbox_set_invalid_val(mbox) sys_sem_set_invalid_val(mbox)

struct sys_thread;
typedef struct sys_thread * sys_thread_t;

#endif /* !NO_SYS */

#endif /* LWIP_ARCH_SYS_ARCH_H */

27 changes: 19 additions & 8 deletions libraries/drivers/lwip_port/renesas/lwipopts.h
Original file line number Diff line number Diff line change
@@ -1,13 +1,28 @@
#define LWIP_DEBUG 1
#if NO_SYS
#define SYS_LIGHTWEIGHT_PROT 0
#define LWIP_SOCKET 0
#else
#define SYS_LIGHTWEIGHT_PROT 1
#define LWIP_SOCKET 1
#endif

#define LWIP_TCP 1
#define LWIP_TCPIP_CORE_LOCKING 0
#define LWIP_RAW 1
#define SO_REUSE 1

#define TCPIP_MBOX_SIZE 5
#define PBUF_POOL_SIZE 16
#define MEMP_NUM_PBUF 30

//#define LWIP_DEBUG 1

/* test an lwipopts.h file with default contents */
#define NO_SYS 1
#define NO_SYS_NO_TIMERS 1
#define LWIP_TIMERS 1
#define LWIP_TIMERS_CUSTOM 0
#define LWIP_MPU_COMPATIBLE 0
#define LWIP_TCPIP_CORE_LOCKING 1
#define LWIP_TCPIP_CORE_LOCKING_INPUT 0
#define SYS_LIGHTWEIGHT_PROT 0
#define MEM_LIBC_MALLOC 0
#define MEMP_MEM_MALLOC 0
#define MEMP_MEM_INIT 0
Expand Down Expand Up @@ -70,7 +85,6 @@
#define ICMP_TTL (IP_DEFAULT_TTL)
#define LWIP_BROADCAST_PING 0
#define LWIP_MULTICAST_PING 0
#define LWIP_RAW 0
#define RAW_TTL (IP_DEFAULT_TTL)
#define LWIP_DHCP 1
#define LWIP_DHCP_CHECK_LINK_UP 0
Expand Down Expand Up @@ -98,7 +112,6 @@
#define LWIP_UDPLITE 0
#define UDP_TTL (IP_DEFAULT_TTL)
#define LWIP_NETBUF_RECVINFO 0
#define LWIP_TCP 0
#define TCP_TTL (IP_DEFAULT_TTL)
#define TCP_WND (4 * TCP_MSS)
#define TCP_MAXRTX 12
Expand Down Expand Up @@ -166,7 +179,6 @@
#define LWIP_TCPIP_TIMEOUT 0
#define LWIP_NETCONN_SEM_PER_THREAD 0
#define LWIP_NETCONN_FULLDUPLEX 0
#define LWIP_SOCKET 0
#define LWIP_COMPAT_SOCKETS 1 /* 0..2 */
#define LWIP_POSIX_SOCKETS_IO_NAMES 1
#define LWIP_SOCKET_OFFSET 0
Expand All @@ -178,7 +190,6 @@
#define LWIP_SO_LINGER 0
#define RECV_BUFSIZE_DEFAULT INT_MAX
#define LWIP_TCP_CLOSE_TIMEOUT_MS_DEFAULT 20000
#define SO_REUSE 0
#define SO_REUSE_RXTOALL 0
#define LWIP_FIONREAD_LINUXMODE 0
#define LWIP_SOCKET_SELECT 1
Expand Down
Loading

0 comments on commit 570ea98

Please sign in to comment.