diff --git a/src/sys/Makefile b/src/sys/Makefile index 90a5eb4..3a69599 100644 --- a/src/sys/Makefile +++ b/src/sys/Makefile @@ -119,6 +119,7 @@ (cd lib;make clean) (cd isa;make clean) (cd pci;make clean) + (cd net;make clean) (cd compile;make clean) #(cd vfs;make clean) #(cd sde;make clean) diff --git a/src/sys/include/net/arch.h b/src/sys/include/net/arch.h index 73771b5..da0a1d8 100644 --- a/src/sys/include/net/arch.h +++ b/src/sys/include/net/arch.h @@ -48,6 +48,7 @@ #include #include #include +#include /** * @defgroup compiler_abstraction Compiler/platform abstraction @@ -87,8 +88,7 @@ * systems, this should be defined to something less resource-consuming. */ #ifndef LWIP_PLATFORM_ASSERT -#define LWIP_PLATFORM_ASSERT(x) do {kprintf("Assertion \"%s\" failed at line %d in %s\n", \ - x, __LINE__, __FILE__); kpanic("asserted");} while(0) +#define LWIP_PLATFORM_ASSERT(x) do {kprintf("Assertion \"%s\" failed at line %d in %s\n", x, __LINE__, __FILE__); kpanic("asserted");} while(0) #endif /** Define this to 1 in arch/cc.h of your port if you do not want to diff --git a/src/sys/include/net/arch/cc.h b/src/sys/include/net/arch/cc.h index 22907f8..bb4d2ce 100644 --- a/src/sys/include/net/arch/cc.h +++ b/src/sys/include/net/arch/cc.h @@ -1,6 +1,8 @@ #ifndef __ARCH_CC_H__ #define __ARCH_CC_H__ +#include + #define PACK_STRUCT_FIELD(x) x __attribute__((packed)) #define PACK_STRUCT_STRUCT __attribute__((packed)) #define PACK_STRUCT_BEGIN diff --git a/src/sys/include/net/arch/sys_arch.h b/src/sys/include/net/arch/sys_arch.h index 80128da..cc85f57 100644 --- a/src/sys/include/net/arch/sys_arch.h +++ b/src/sys/include/net/arch/sys_arch.h @@ -1,24 +1,42 @@ #ifndef __ARCH_SYS_ARCH_H__ #define __ARCH_SYS_ARCH_H__ +#include + #define SYS_MBOX_NULL NULL #define SYS_SEM_NULL NULL - -/* -struct sys_sem; -typedef struct sys_sem * sys_sem_t; - -struct sys_mbox; -typedef struct sys_mbox *sys_mbox_t; - -struct sys_thread; -typedef struct sys_thread * sys_thread_t; -*/ +#define SYS_MBOX_SIZE 100 struct sys_timeouts { struct sys_timeout *next; }; -void sys_thread_new(void (*)(void), void *); +struct sys_sem { + unsigned int c; + ubthread_cond_t cond; + ubthread_mutex_t mutex; +}; + +typedef struct sys_sem * sys_sem_t; + +struct sys_mbox { + uInt16 first, last; + void *msgs[SYS_MBOX_SIZE]; + struct sys_sem *mail; + struct sys_sem *mutex; +}; +typedef struct sys_mbox *sys_mbox_t; + +struct sys_thread { + struct sys_thread *next; + struct sys_timeouts timeouts; + kTask_t *ubthread; + char name[128]; +}; + +typedef struct sys_thread * sys_thread_t; + + +//void sys_thread_new(void (*)(void), void *); #endif diff --git a/src/sys/include/net/lwipopts.h b/src/sys/include/net/lwipopts.h index c24cfb6..6ecebb7 100644 --- a/src/sys/include/net/lwipopts.h +++ b/src/sys/include/net/lwipopts.h @@ -29,6 +29,7 @@ * Author: Simon Goldschmidt * */ + #ifndef LWIP_HDR_LWIPOPTS_H #define LWIP_HDR_LWIPOPTS_H @@ -41,8 +42,7 @@ #define LWIP_TCPIP_CORE_LOCKING 1 #define LWIP_TCPIP_CORE_LOCKING_INPUT 0 -#define SYS_LIGHTWEIGHT_PROT 1 - +#define SYS_LIGHTWEIGHT_PROT 0 #define MEM_LIBC_MALLOC 0 #define MEMP_MEM_MALLOC 0 @@ -225,7 +225,6 @@ #define TCP_WND_UPDATE_THRESHOLD LWIP_MIN((TCP_WND / 4), (TCP_MSS * 4)) #define LWIP_EVENT_API 0 - #define LWIP_WND_SCALE 0 #define PBUF_LINK_HLEN (14 + ETH_PAD_SIZE) @@ -421,31 +420,31 @@ #define LWIP_IPV6_DHCP6 0 -#define LWIP_HOOK_FILENAME "path/to/my/lwip_hooks.h" +//#define LWIP_HOOK_FILENAME "path/to/my/lwip_hooks.h" -#define LWIP_HOOK_TCP_ISN(local_ip, local_port, remote_ip, remote_port) +//#define LWIP_HOOK_TCP_ISN(local_ip, local_port, remote_ip, remote_port) -#define LWIP_HOOK_IP4_INPUT(pbuf, input_netif) +//#define LWIP_HOOK_IP4_INPUT(pbuf, input_netif) -#define LWIP_HOOK_IP4_ROUTE() +//#define LWIP_HOOK_IP4_ROUTE() -#define LWIP_HOOK_IP4_ROUTE_SRC(dest, src) +//#define LWIP_HOOK_IP4_ROUTE_SRC(dest, src) -#define LWIP_HOOK_ETHARP_GET_GW(netif, dest) +//#define LWIP_HOOK_ETHARP_GET_GW(netif, dest) -#define LWIP_HOOK_IP6_INPUT(pbuf, input_netif) +//#define LWIP_HOOK_IP6_INPUT(pbuf, input_netif) -#define LWIP_HOOK_IP6_ROUTE(src, dest) +//#define LWIP_HOOK_IP6_ROUTE(src, dest) -#define LWIP_HOOK_ND6_GET_GW(netif, dest) +///#define LWIP_HOOK_ND6_GET_GW(netif, dest) -#define LWIP_HOOK_VLAN_CHECK(netif, eth_hdr, vlan_hdr) +//#define LWIP_HOOK_VLAN_CHECK(netif, eth_hdr, vlan_hdr) -#define LWIP_HOOK_VLAN_SET(netif, p, src, dst, eth_type) +//#define LWIP_HOOK_VLAN_SET(netif, p, src, dst, eth_type) -#define LWIP_HOOK_MEMP_AVAILABLE(memp_t_type) +//#define LWIP_HOOK_MEMP_AVAILABLE(memp_t_type) -#define LWIP_HOOK_UNKNOWN_ETH_PROTOCOL(pbuf, netif) +//#define LWIP_HOOK_UNKNOWN_ETH_PROTOCOL(pbuf, netif) #define LWIP_DBG_MIN_LEVEL LWIP_DBG_LEVEL_ALL #define LWIP_DBG_TYPES_ON LWIP_DBG_ON @@ -509,6 +508,11 @@ #define IP6_DEBUG LWIP_DBG_OFF #define LWIP_PERF 0 -//#define LWIP_SOCKET 1 //#define TCP_RCV_SCALE 0 //#define PBUF_POOL_SIZE 400 /* pbuf tests need ~200KByte */ +#define LWIP_COMPAT_MUTEX 1 +#define LWIP_COMPAT_MUTEX_ALLOWED 1 +#define LWIP_TIMEVAL_PRIVATE 0 +#define LWIP_CALLBACK_API 1 +#define LWIP_PROVIDE_ERRNO 1 +#endif diff --git a/src/sys/include/net/sockets.h b/src/sys/include/net/sockets.h index d546f23..a094de2 100644 --- a/src/sys/include/net/sockets.h +++ b/src/sys/include/net/sockets.h @@ -501,8 +501,7 @@ int lwip_socket(int domain, int type, int protocol); int lwip_write(int s, const void *dataptr, size_t size); int lwip_writev(int s, const struct iovec *iov, int iovcnt); -int lwip_select(int maxfdp1, fd_set *readset, fd_set *writeset, fd_set *exceptset, - struct timeval *timeout); +int lwip_select(int maxfdp1, fd_set *readset, fd_set *writeset, fd_set *exceptset, struct timeval *timeout); int lwip_ioctl(int s, long cmd, void *argp); int lwip_fcntl(int s, int cmd, int val); diff --git a/src/sys/include/net/sys.h b/src/sys/include/net/sys.h index ca026b0..1339f27 100644 --- a/src/sys/include/net/sys.h +++ b/src/sys/include/net/sys.h @@ -38,6 +38,7 @@ #define LWIP_HDR_SYS_H #include +#include #ifdef __cplusplus extern "C" { diff --git a/src/sys/include/ubixos/ubthread.h b/src/sys/include/ubixos/ubthread.h index 0f01cfc..297db85 100644 --- a/src/sys/include/ubixos/ubthread.h +++ b/src/sys/include/ubixos/ubthread.h @@ -34,7 +34,9 @@ #include #include +#ifndef ETIMEDOUT #define ETIMEDOUT -1 +#endif #define LOCKED 1 #define UNLOCKED 0 diff --git a/src/sys/net/api/sockets.c b/src/sys/net/api/sockets.c index 9971bdf..884922b 100644 --- a/src/sys/net/api/sockets.c +++ b/src/sys/net/api/sockets.c @@ -1367,10 +1367,7 @@ return nready; } -int -lwip_select(int maxfdp1, fd_set *readset, fd_set *writeset, fd_set *exceptset, - struct timeval *timeout) -{ +int lwip_select(int maxfdp1, fd_set *readset, fd_set *writeset, fd_set *exceptset, struct timeval *timeout) { u32_t waitres = 0; int nready; fd_set lreadset, lwriteset, lexceptset; diff --git a/src/sys/net/core/init.c b/src/sys/net/core/init.c index e07a515..09ef246 100644 --- a/src/sys/net/core/init.c +++ b/src/sys/net/core/init.c @@ -328,7 +328,7 @@ * Use this in NO_SYS mode. Use tcpip_init() otherwise. */ void -net_init(void) +lwip_init(void) { #ifndef LWIP_SKIP_CONST_CHECK int a = 0; diff --git a/src/sys/net/net/init.c b/src/sys/net/net/init.c index 4208b30..19588ea 100644 --- a/src/sys/net/net/init.c +++ b/src/sys/net/net/init.c @@ -44,11 +44,8 @@ #include #include -void netMainThread(); - -static void tcpip_init_done(void *arg); - - +//void netMainThread(); +//static void tcpip_init_done(void *arg); int net_init() { ip_addr_t ipaddr, netmask, gw; @@ -60,20 +57,21 @@ IP4_ADDR(&ipaddr, 10, 50, 0, 7); IP4_ADDR(&netmask, 255, 255, 0, 0); - netif_add(&netif, &ipaddr, &netmask, &gw, ethernetif_init, tcpip_input); + netif_add(&netif, &ipaddr, &netmask, &gw, NULL, ethernetif_init, tcpip_input); //netif_set_default(netif_add(&ipaddr, &netmask, &gw, ethernetif_init, tcpip_input)); return(0x0); } +#ifdef _BALLS int net_init_dead() { sys_init(); mem_init(); memp_init(); pbuf_init(); - sys_thread_new((void *) (netMainThread), 0x0); + sys_thread_new("mainThread", (void *) (netMainThread), 0x0, 0x1000, 0x0); return (0x0); } @@ -116,6 +114,7 @@ sem = arg; sys_sem_signal(*sem); } +#endif /*** END diff --git a/src/sys/net/net/sys_arch.c b/src/sys/net/net/sys_arch.c index f99c436..e13fd9b 100644 --- a/src/sys/net/net/sys_arch.c +++ b/src/sys/net/net/sys_arch.c @@ -98,27 +98,26 @@ static spinLock_t netThreadSpinlock = SPIN_LOCK_INITIALIZER; static struct sys_thread *threads = 0x0; -struct sys_thread { - struct sys_thread *next; - struct sys_timeouts timeouts; - kTask_t *ubthread; -}; - -void sys_thread_new(void (*function)(void), void *arg) { - struct sys_thread *thread = 0x0; +sys_thread_t sys_thread_new(const char *name, void (*thread)(void *arg), void *arg, int stacksize, int prio) { + //void sys_thread_new(void (*function)(void), void *arg) { + struct sys_thread *new_thread = 0x0; //struct thread_start_param *thread_param; + + LWIP_ASSERT("Non-positive prio", prio > 0); + LWIP_ASSERT("Prio is too big", prio < 20); + kprintf("sys_thread: [0x%X]\n", sizeof(struct sys_thread)); - thread = kmalloc(sizeof(struct sys_thread)); - memset(thread, 0x0, sizeof(struct sys_thread)); - kprintf("THREAD: [0x%X]\n", thread); + new_thread = kmalloc(sizeof(struct sys_thread)); + memset(new_thread, 0x0, sizeof(struct sys_thread)); + kprintf("THREAD: [0x%X]\n", new_thread); spinLock(&netThreadSpinlock); - thread->next = threads; - thread->timeouts.next = NULL; - thread->ubthread = 0x0; - threads = thread; + new_thread->next = threads; + new_thread->timeouts.next = NULL; + new_thread->ubthread = 0x0; + threads = new_thread; spinUnlock(&netThreadSpinlock); /* @@ -129,11 +128,11 @@ thread_param->thread = thread; */ //execThread((void *)function,0x0,0x0); - kprintf("thread->ubthread: [0x%X]\n", thread->ubthread); - if (ubthread_create(&thread->ubthread, 0x0, (void *) (function), arg) != 0x0) { + kprintf("thread->ubthread: [0x%X]\n", new_thread->ubthread); + if (ubthread_create(&new_thread->ubthread, 0x0, (void *) (thread), arg) != 0x0) { kpanic("sys_thread_new: ubthread_create"); } - kprintf("thread->ubthread: [0x%X]\n", thread->ubthread); + kprintf("thread->ubthread: [0x%X]\n", new_thread->ubthread); }