diff --git a/src/sys/i386/sched.c b/src/sys/i386/sched.c index ee51b81..e808666 100644 --- a/src/sys/i386/sched.c +++ b/src/sys/i386/sched.c @@ -48,7 +48,7 @@ static kTask_t *taskList = 0x0; static kTask_t *delList = 0x0; -static uint32_t nextID = -1; +static uint32_t nextID = 1; kTask_t *_current = 0x0; kTask_t *_usedMath = 0x0; diff --git a/src/sys/include/net/lwipopts.h b/src/sys/include/net/lwipopts.h index 8074033..e9eb0b7 100644 --- a/src/sys/include/net/lwipopts.h +++ b/src/sys/include/net/lwipopts.h @@ -46,7 +46,7 @@ /* Core locking and MPU */ #define LWIP_MPU_COMPATIBLE 0 #define LWIP_TCPIP_CORE_LOCKING 1 -#define LWIP_TCPIP_CORE_LOCKING_INPUT 0 +#define LWIP_TCPIP_CORE_LOCKING_INPUT 1 #define SYS_LIGHTWEIGHT_PROT 0 @@ -134,7 +134,7 @@ #define ICMP_TTL (IP_DEFAULT_TTL) -#define LWIP_BROADCAST_PING 0 +#define LWIP_BROADCAST_PING 1 #define LWIP_MULTICAST_PING 0 @@ -232,7 +232,7 @@ #define LWIP_LOOPIF_MULTICAST 0 -#define LWIP_NETIF_LOOPBACK 0 +#define LWIP_NETIF_LOOPBACK 1 #define LWIP_LOOPBACK_MAX_PBUFS 0 @@ -446,7 +446,7 @@ #define INET_DEBUG LWIP_DBG_OFF -#define IP_DEBUG LWIP_DBG_OFF +#define IP_DEBUG LWIP_DBG_ON #define IP_REASS_DEBUG LWIP_DBG_OFF diff --git a/src/sys/include/net/net.h b/src/sys/include/net/net.h index ab7541b..d18fc60 100644 --- a/src/sys/include/net/net.h +++ b/src/sys/include/net/net.h @@ -25,6 +25,7 @@ #define _NET_H #include +#include struct netif lnc_netif; diff --git a/src/sys/include/net/sys.h b/src/sys/include/net/sys.h index 8143ba1..c7e73fa 100644 --- a/src/sys/include/net/sys.h +++ b/src/sys/include/net/sys.h @@ -161,14 +161,14 @@ * @ingroup sys_sem * Check if a semaphore is valid/allocated: return 1 for valid, 0 for invalid */ -int sys_sem_valid(sys_sem_t *sem); +int sys_sem_valid(struct sys_sem **s); #endif #ifndef sys_sem_set_invalid /** * @ingroup sys_sem * Set a semaphore invalid so that sys_sem_valid returns 0 */ -void sys_sem_set_invalid(sys_sem_t *sem); +void sys_sem_set_invalid(struct sys_sem **s); #endif #ifndef sys_sem_valid_val /** @@ -255,14 +255,14 @@ * @ingroup sys_mbox * Check if an mbox is valid/allocated: return 1 for valid, 0 for invalid */ -int sys_mbox_valid(sys_mbox_t *mbox); +int sys_mbox_valid(struct sys_mbox **mb); #endif #ifndef sys_mbox_set_invalid /** * @ingroup sys_mbox * Set an mbox invalid so that sys_mbox_valid returns 0 */ -void sys_mbox_set_invalid(sys_mbox_t *mbox); +void sys_mbox_set_invalid(struct sys_mbox **mb); #endif #ifndef sys_mbox_valid_val /** diff --git a/src/sys/kernel/ubthread.c b/src/sys/kernel/ubthread.c index 7972281..ef179cc 100644 --- a/src/sys/kernel/ubthread.c +++ b/src/sys/kernel/ubthread.c @@ -94,7 +94,7 @@ } while (1) { - if (!xchg_32(&ubmutex->lock, TRUE)) + if (xchg_32(&ubmutex->lock, TRUE) == FALSE) break; while (ubmutex->lock == TRUE) @@ -108,21 +108,21 @@ int ubthread_mutex_unlock(ubthread_mutex_t *mutex) { ubthread_mutex_t ubmutex = *mutex; - if (ubmutex->pid == _current->id) { - while (xchg_32(&ubmutex->lock, FALSE)) - sched_yield(); - return (0x0); - } - else { + if (ubmutex->lock != TRUE) + kpanic("NOT LOCKED?"); + + if (ubmutex->pid != _current->id) kprintf("Trying To Unlock Mutex From No Locking Thread[%i - %i:0x%X]\n", ubmutex->pid, _current->id, *ubmutex); - kpanic("WTF2"); - while (ubmutex->pid != _current->id) + + while (1) { + if (xchg_32(&ubmutex->lock, FALSE) == TRUE) + break; + while (ubmutex->lock == FALSE) sched_yield(); - kprintf("GOT IT UNLOCKING"); - while (!xchg_32(&ubmutex->lock, FALSE)) - sched_yield(); - return (0x0); } + + ubmutex->pid = 0x0; + return (0x0); } int ubthread_cond_timedwait(ubthread_cond_t *cond, ubthread_mutex_t *mutex, const struct timespec *abstime) { diff --git a/src/sys/net/api/api_lib.c b/src/sys/net/api/api_lib.c index a50b00b..c68c7c1 100644 --- a/src/sys/net/api/api_lib.c +++ b/src/sys/net/api/api_lib.c @@ -149,6 +149,7 @@ return NULL; } } + kprintf("netconn_new"); API_MSG_VAR_FREE(msg); return conn; } @@ -421,19 +422,23 @@ #else sys_arch_mbox_fetch(&conn->acceptmbox, &accept_ptr, 0); #endif /* LWIP_SO_RCVTIMEO*/ +kprintf("%s:%i", __FILE__, __LINE__); newconn = (struct netconn *)accept_ptr; /* Register event with callback */ API_EVENT(conn, NETCONN_EVT_RCVMINUS, 0); +kprintf("%s:%i", __FILE__, __LINE__); if (accept_ptr == &netconn_aborted) { /* a connection has been aborted: out of pcbs or out of netconns during accept */ /* @todo: set netconn error, but this would be fatal and thus block further accepts */ #if TCP_LISTEN_BACKLOG +kprintf("[%s:%i]", __FILE__, __LINE__); API_MSG_VAR_FREE(msg); #endif /* TCP_LISTEN_BACKLOG */ return ERR_ABRT; } if (newconn == NULL) { +kprintf("[%s:%i]", __FILE__, __LINE__); /* connection has been aborted */ /* in this special case, we set the netconn error from application thread, as on a ready-to-accept listening netconn, there should not be anything running @@ -444,6 +449,7 @@ #endif /* TCP_LISTEN_BACKLOG */ return ERR_CLSD; } +kprintf("[%s:%i]", __FILE__, __LINE__); #if TCP_LISTEN_BACKLOG /* Let the stack know that we have accepted the connection. */ API_MSG_VAR_REF(msg).conn = newconn; @@ -452,8 +458,10 @@ API_MSG_VAR_FREE(msg); #endif /* TCP_LISTEN_BACKLOG */ +kprintf("[%s:%i]", __FILE__, __LINE__); *new_conn = newconn; /* don't set conn->last_err: it's only ERR_OK, anyway */ +kprintf("[%s:%i]", __FILE__, __LINE__); return ERR_OK; #else /* LWIP_TCP */ LWIP_UNUSED_ARG(conn); diff --git a/src/sys/net/api/tcpip.c b/src/sys/net/api/tcpip.c index 28a2d02..ae5708b 100644 --- a/src/sys/net/api/tcpip.c +++ b/src/sys/net/api/tcpip.c @@ -97,6 +97,7 @@ LWIP_ASSERT("tcpip_thread: invalid message", 0); continue; } +//kprintf("MSG->TYPE: 0x%X]", msg->type); switch (msg->type) { #if !LWIP_TCPIP_CORE_LOCKING case TCPIP_MSG_API: @@ -168,30 +169,23 @@ #else /* LWIP_TCPIP_CORE_LOCKING_INPUT */ struct tcpip_msg *msg; -//kprintf("INPKT?\n"); - LWIP_ASSERT("Invalid mbox", sys_mbox_valid_val(mbox)); msg = (struct tcpip_msg *) memp_malloc(MEMP_TCPIP_MSG_INPKT); -//kprintf("INPKT %i\n", __LINE__); if (msg == NULL) { return ERR_MEM; } - kprintf("INPKT %i\n", __LINE__); msg->type = TCPIP_MSG_INPKT; msg->msg.inp.p = p; msg->msg.inp.netif = inp; msg->msg.inp.input_fn = input_fn; - kprintf("%s:%i\n", __FILE__, __LINE__); if (sys_mbox_trypost(&mbox, msg) != ERR_OK) { kprintf("INPKT %i\n", __LINE__); memp_free(MEMP_TCPIP_MSG_INPKT, msg); kprintf("INPKT %i\n", __LINE__); return ERR_MEM; } - kprintf("INPKT %i\n", __LINE__); - return ERR_OK; #endif /* LWIP_TCPIP_CORE_LOCKING_INPUT */ } diff --git a/src/sys/net/core/ipv4/ip4.c b/src/sys/net/core/ipv4/ip4.c index 5ac95a8..870b8ae 100644 --- a/src/sys/net/core/ipv4/ip4.c +++ b/src/sys/net/core/ipv4/ip4.c @@ -387,6 +387,7 @@ /* identify the IP header */ iphdr = (struct ip_hdr *)p->payload; if (IPH_V(iphdr) != 4) { +//kprintf("%s:%i", __FILE__, __LINE__); LWIP_DEBUGF(IP_DEBUG | LWIP_DBG_LEVEL_WARNING, ("IP packet dropped due to bad version number %"U16_F"\n", (u16_t)IPH_V(iphdr))); ip4_debug_print(p); pbuf_free(p); @@ -463,6 +464,7 @@ /* match packet against an interface, i.e. is this packet for us? */ if (ip4_addr_ismulticast(ip4_current_dest_addr())) { #if LWIP_IGMP +kpanic("A"); if ((inp->flags & NETIF_FLAG_IGMP) && (igmp_lookfor_group(inp, ip4_current_dest_addr()))) { /* IGMP snooping switches need 0.0.0.0 to be allowed as source address (RFC 4541) */ ip4_addr_t allsystems; @@ -476,6 +478,7 @@ netif = NULL; } #else /* LWIP_IGMP */ +kpanic("B"); if ((netif_is_up(inp)) && (!ip4_addr_isany_val(*netif_ip4_addr(inp)))) { netif = inp; } else { @@ -489,6 +492,8 @@ int first = 1; netif = inp; do { +if (ip4_addr_get_u32(&iphdr->dest) == ip4_addr_get_u32(netif_ip4_addr(netif))) +//kprintf("netif: 0x%X-0x%X-0x%X", netif, ip4_addr_get_u32(&iphdr->dest), ip4_addr_get_u32(netif_ip4_addr(netif))); LWIP_DEBUGF(IP_DEBUG, ("ip_input: iphdr->dest 0x%"X32_F" netif->ip_addr 0x%"X32_F" (0x%"X32_F", 0x%"X32_F", 0x%"X32_F")\n", ip4_addr_get_u32(&iphdr->dest), ip4_addr_get_u32(netif_ip4_addr(netif)), ip4_addr_get_u32(&iphdr->dest) & ip4_addr_get_u32(netif_ip4_netmask(netif)), @@ -527,6 +532,7 @@ * interface that does not have the loopback address assigned to it, * unless a non-loopback interface is used for loopback traffic. */ if (ip4_addr_isloopback(ip4_current_dest_addr())) { +kpanic("D"); netif = NULL; break; } @@ -553,6 +559,7 @@ * #define LWIP_IP_ACCEPT_UDP_PORT(dst_port) ((dst_port) == PP_NTOHS(12345)) */ if (netif == NULL) { +//kprintf("%s:%i", __FILE__, __LINE__); /* remote port is DHCP server? */ if (IPH_PROTO(iphdr) == IP_PROTO_UDP) { struct udp_hdr *udphdr = (struct udp_hdr *)((u8_t *)iphdr + iphdr_hlen); @@ -577,6 +584,7 @@ ) #endif /* LWIP_IGMP || IP_ACCEPT_LINK_LAYER_ADDRESSING */ { +//kprintf("%s:%i", __FILE__, __LINE__); if ((ip4_addr_isbroadcast(ip4_current_src_addr(), inp)) || (ip4_addr_ismulticast(ip4_current_src_addr()))) { /* packet source is not valid */ @@ -586,12 +594,15 @@ IP_STATS_INC(ip.drop); MIB2_STATS_INC(mib2.ipinaddrerrors); MIB2_STATS_INC(mib2.ipindiscards); +//kprintf("%s:%i", __FILE__, __LINE__); return ERR_OK; } } +//kprintf("%s:%i", __FILE__, __LINE__); /* packet not for us? */ if (netif == NULL) { +//kprintf("%s:%i", __FILE__, __LINE__); /* packet not for us, route or discard */ LWIP_DEBUGF(IP_DEBUG | LWIP_DBG_TRACE, ("ip4_input: packet not for us.\n")); #if IP_FORWARD @@ -609,8 +620,10 @@ pbuf_free(p); return ERR_OK; } +//kprintf("%s:%i", __FILE__, __LINE__); /* packet consists of multiple fragments? */ if ((IPH_OFFSET(iphdr) & PP_HTONS(IP_OFFMASK | IP_MF)) != 0) { +//kprintf("%s:%i", __FILE__, __LINE__); #if IP_REASSEMBLY /* packet fragment reassembly code present? */ LWIP_DEBUGF(IP_DEBUG, ("IP packet is a fragment (id=0x%04"X16_F" tot_len=%"U16_F" len=%"U16_F" MF=%"U16_F" offset=%"U16_F"), calling ip4_reass()\n", lwip_ntohs(IPH_ID(iphdr)), p->tot_len, lwip_ntohs(IPH_LEN(iphdr)), (u16_t)!!(IPH_OFFSET(iphdr) & PP_HTONS(IP_MF)), (u16_t)((lwip_ntohs(IPH_OFFSET(iphdr)) & IP_OFFMASK)*8))); @@ -618,9 +631,11 @@ p = ip4_reass(p); /* packet not fully reassembled yet? */ if (p == NULL) { +//kprintf("%s:%i", __FILE__, __LINE__); return ERR_OK; } iphdr = (struct ip_hdr *)p->payload; +//kprintf("%s:%i", __FILE__, __LINE__); #else /* IP_REASSEMBLY == 0, no packet fragment reassembly code present */ pbuf_free(p); LWIP_DEBUGF(IP_DEBUG | LWIP_DBG_LEVEL_SERIOUS, ("IP packet dropped since it was fragmented (0x%"X16_F") (while IP_REASSEMBLY == 0).\n", @@ -647,6 +662,7 @@ IP_STATS_INC(ip.drop); /* unsupported protocol feature */ MIB2_STATS_INC(mib2.ipinunknownprotos); +//kprintf("%s:%i", __FILE__, __LINE__); return ERR_OK; } #endif /* IP_OPTIONS_ALLOWED == 0 */ @@ -660,6 +676,7 @@ ip_data.current_input_netif = inp; ip_data.current_ip4_header = iphdr; ip_data.current_ip_header_tot_len = IPH_HL(iphdr) * 4; +//kprintf("%s:%i", __FILE__, __LINE__); #if LWIP_RAW /* raw input did not eat the packet? */ @@ -668,6 +685,8 @@ { pbuf_header(p, -(s16_t)iphdr_hlen); /* Move to payload, no check necessary. */ +//kprintf("IPH_PROTO(%i))", IPH_PROTO(iphdr)); + switch (IPH_PROTO(iphdr)) { #if LWIP_UDP case IP_PROTO_UDP: @@ -675,6 +694,7 @@ case IP_PROTO_UDPLITE: #endif /* LWIP_UDPLITE */ MIB2_STATS_INC(mib2.ipindelivers); +//kprintf("UDP"); udp_input(p, inp); break; #endif /* LWIP_UDP */ diff --git a/src/sys/net/core/mem.c b/src/sys/net/core/mem.c index 1736ecf..21c75df 100644 --- a/src/sys/net/core/mem.c +++ b/src/sys/net/core/mem.c @@ -627,17 +627,17 @@ } /* protect the heap from concurrent access */ -kprintf("SML: [0x%i]", __LINE__); +//kprintf("SML: [0x%i][0x%X][0x%X]", __LINE__, mem_mutex, &mem_mutex); sys_mutex_lock(&mem_mutex); -kprintf("SML: [0x%i]", __LINE__); +//kprintf("SML: [0x%i]", __LINE__); LWIP_MEM_ALLOC_PROTECT(); -kprintf("SML: [0x%i]", __LINE__); +//kprintf("SML: [0x%i]", __LINE__); #if LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT /* run as long as a mem_free disturbed mem_malloc or mem_trim */ do { local_mem_free_count = 0; #endif /* LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT */ -kprintf("SML: [0x%i]", __LINE__); +//kprintf("SML: [0x%i]", __LINE__); /* Scan through the heap searching for a free block that is big enough, * beginning with the lowest free block. @@ -656,15 +656,15 @@ local_mem_free_count = 1; break; } -kprintf("SML: [0x%i]", __LINE__); +//kprintf("SML: [0x%i]", __LINE__); #endif /* LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT */ -kprintf("SML: [0x%i]", __LINE__); +//kprintf("SML: [0x%i]", __LINE__); if ((!mem->used) && (mem->next - (ptr + SIZEOF_STRUCT_MEM)) >= size) { /* mem is not used and at least perfect fit is possible: * mem->next - (ptr + SIZEOF_STRUCT_MEM) gives us the 'user data size' of mem */ -kprintf("SML: [0x%i]", __LINE__); +//kprintf("SML: [0x%i]", __LINE__); if (mem->next - (ptr + SIZEOF_STRUCT_MEM) >= (size + SIZEOF_STRUCT_MEM + MIN_SIZE_ALIGNED)) { /* (in addition to the above, we test if another struct mem (SIZEOF_STRUCT_MEM) containing @@ -686,7 +686,7 @@ /* and insert it between mem and mem->next */ mem->next = ptr2; mem->used = 1; -kprintf("SML: [0x%i]", __LINE__); +//kprintf("SML: [0x%i]", __LINE__); if (mem2->next != MEM_SIZE_ALIGNED) { ((struct mem *)(void *)&ram[mem2->next])->prev = ptr2; @@ -700,7 +700,7 @@ * also can't move mem->next directly behind mem, since mem->next * will always be used at this point! */ -kprintf("SML: [0x%i]", __LINE__); +//kprintf("SML: [0x%i]", __LINE__); mem->used = 1; MEM_STATS_INC_USED(used, mem->next - (mem_size_t)((u8_t *)mem - ram)); } @@ -709,7 +709,7 @@ #endif /* LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT */ if (mem == lfree) { struct mem *cur = lfree; -kprintf("SML: [0x%i]", __LINE__); +//kprintf("SML: [0x%i]", __LINE__); /* Find next free block after mem and update lowest free pointer */ while (cur->used && cur != ram_end) { #if LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT @@ -725,14 +725,16 @@ #endif /* LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT */ cur = (struct mem *)(void *)&ram[cur->next]; } -kprintf("SML: [0x%i]", __LINE__); +//kprintf("SML: [0x%i]", __LINE__); lfree = cur; LWIP_ASSERT("mem_malloc: !lfree->used", ((lfree == ram_end) || (!lfree->used))); -kprintf("SML: [0x%i]", __LINE__); +//kprintf("SML: [0x%i]", __LINE__); } +//kprintf("SML: [0x%i]", __LINE__); LWIP_MEM_ALLOC_UNPROTECT(); +//kprintf("SML: [0x%i][0x%X][0x%X]", __LINE__, mem_mutex, &mem_mutex); sys_mutex_unlock(&mem_mutex); -kprintf("SML: [0x%i]", __LINE__); +//kprintf("SML: [0x%i]", __LINE__); LWIP_ASSERT("mem_malloc: allocated memory not above ram_end.", (mem_ptr_t)mem + SIZEOF_STRUCT_MEM + size <= (mem_ptr_t)ram_end); LWIP_ASSERT("mem_malloc: allocated memory properly aligned.", @@ -740,11 +742,11 @@ LWIP_ASSERT("mem_malloc: sanity check alignment", (((mem_ptr_t)mem) & (MEM_ALIGNMENT-1)) == 0); -kprintf("SML: [0x%i]", __LINE__); +//kprintf("SML: [0x%i]", __LINE__); return (u8_t *)mem + SIZEOF_STRUCT_MEM; } } -kprintf("SML: [0x%i]", __LINE__); +//kprintf("SML: [0x%i]", __LINE__); #if LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT /* if we got interrupted by a mem_free, try again */ } while (local_mem_free_count != 0); @@ -752,9 +754,9 @@ LWIP_DEBUGF(MEM_DEBUG | LWIP_DBG_LEVEL_SERIOUS, ("mem_malloc: could not allocate %"S16_F" bytes\n", (s16_t)size)); MEM_STATS_INC(err); LWIP_MEM_ALLOC_UNPROTECT(); -kprintf("SML: [0x%i]]\n", __LINE__); +//kprintf("SML: [0x%i]]\n", __LINE__); sys_mutex_unlock(&mem_mutex); -kprintf("SML: [0x%i]]\n", __LINE__); +//kprintf("SML: [0x%i]]\n", __LINE__); return NULL; } diff --git a/src/sys/net/core/pbuf.c b/src/sys/net/core/pbuf.c index 2d0e449..ea2a6a2 100644 --- a/src/sys/net/core/pbuf.c +++ b/src/sys/net/core/pbuf.c @@ -725,17 +725,17 @@ ("pbuf_free(p == NULL) was called.\n")); return 0; } + LWIP_DEBUGF(PBUF_DEBUG | LWIP_DBG_TRACE, ("pbuf_free(%p)\n", (void *)p)); PERF_START; - LWIP_ASSERT("pbuf_free: sane type", - p->type == PBUF_RAM || p->type == PBUF_ROM || - p->type == PBUF_REF || p->type == PBUF_POOL); + LWIP_ASSERT("pbuf_free: sane type", p->type == PBUF_RAM || p->type == PBUF_ROM || p->type == PBUF_REF || p->type == PBUF_POOL); count = 0; /* de-allocate all consecutive pbufs from the head of the chain that * obtain a zero reference count after decrementing*/ + while (p != NULL) { u16_t ref; SYS_ARCH_DECL_PROTECT(old_level); @@ -744,6 +744,8 @@ * further protection. */ SYS_ARCH_PROTECT(old_level); /* all pbufs in a chain are referenced at least once */ + if (_current->id == 4) + kprintf("p->ref %i", p->ref); LWIP_ASSERT("pbuf_free: p->ref > 0", p->ref > 0); /* decrease reference count (number of pointers to pbuf) */ ref = --(p->ref); diff --git a/src/sys/net/net/Makefile b/src/sys/net/net/Makefile index e4965eb..a3489aa 100644 --- a/src/sys/net/net/Makefile +++ b/src/sys/net/net/Makefile @@ -6,7 +6,7 @@ include ../../Makefile.incl # Objects -OBJS = sys_arch.o init.o +OBJS = sys_arch.o init.o shell.o #shell.o udpecho.o init.o sys_arch.o bot.o all: $(OBJS) diff --git a/src/sys/net/net/init.c b/src/sys/net/net/init.c index 631586b..56139b5 100644 --- a/src/sys/net/net/init.c +++ b/src/sys/net/net/init.c @@ -45,6 +45,7 @@ #include void lnc_thread(); +void shell_thread(void *); struct netif lnc_netif; @@ -58,8 +59,12 @@ IP4_ADDR(&netmask, 255, 255, 0, 0); netif_add(&lnc_netif, &ipaddr, &netmask, &gw, NULL, ethernetif_init, tcpip_input); + netif_set_link_up(&lnc_netif); + netif_set_up(&lnc_netif); + netif_set_default(&lnc_netif); sys_thread_new("lncThread", (void *) lnc_thread, 0x0, 0x1000, 0x0); + sys_thread_new("shellThread", (void *) shell_thread, 0x0, 0x1000, 0x0); return(0x0); } diff --git a/src/sys/net/net/shell.c b/src/sys/net/net/shell.c index f987e47..c48ca16 100644 --- a/src/sys/net/net/shell.c +++ b/src/sys/net/net/shell.c @@ -56,7 +56,9 @@ // UBU static struct netconn *conns[NCONNS]; static void sendstr(const char *str, struct netconn *conn) { - netconn_write(conn, (void *) str, strlen(str), NETCONN_NOCOPY); +kprintf("[%s:%i](%s){%i}", __FILE__,__LINE__, str, strlen(str)); + netconn_write(conn, (void *) str, strlen(str), NETCONN_COPY); +kprintf("[%s:%i]", __FILE__,__LINE__); } static void prompt(struct netconn *conn) { @@ -66,11 +68,15 @@ static void shell_main(struct netconn *conn) { struct netbuf *buf = 0x0; uInt32 len; + uInt32 err = 0; // UBU int i; // UBU char bufr[1500]; + buf = kmalloc(1500); +kprintf("[%s:%i]", __FILE__,__LINE__); prompt(conn); +kprintf("[%s:%i]", __FILE__,__LINE__); while (1) { - buf = netconn_recv(conn); + err = netconn_recv(conn, &buf); if (buf != 0x0) netbuf_copy(buf, buffer, 1024); len = netbuf_len(buf); @@ -91,18 +97,21 @@ } } -static void shell_thread(void *arg) { +void shell_thread(void *arg) { struct netconn *conn = 0x0, *newconn = 0x0; buffer = (char *) kmalloc(1024); + kprintf("shell_thread: %i", _current->id); + conn = netconn_new(NETCONN_TCP); - netconn_bind(conn, NULL, 23); + + netconn_bind(conn, IP4_ADDR_ANY, 23); netconn_listen(conn); while (1) { - kprintf("shell1"); - newconn = netconn_accept(conn); + kprintf("shell1: 0x%X:0x%X", conn->recvmbox, conn->acceptmbox); + netconn_accept(conn,&newconn); kprintf("2"); shell_main(newconn); kprintf("3"); @@ -110,12 +119,3 @@ kprintf("4"); } } - -void shell_init(void) { - sys_thread_new(shell_thread, NULL); -} - -/*** - END - ***/ - diff --git a/src/sys/net/net/sys_arch.c b/src/sys/net/net/sys_arch.c index e1b2a31..7b5b3bf 100644 --- a/src/sys/net/net/sys_arch.c +++ b/src/sys/net/net/sys_arch.c @@ -118,14 +118,16 @@ return time_needed; } -int sys_sem_valid(sys_sem_t *sem) { +int sys_sem_valid(struct sys_sem **s) { + struct sys_sem *sem = *s; if (sem == 0) - return 1; - else return 0; + else + return 1; } -void sys_sem_set_invalid(sys_sem_t *sem) { +void sys_sem_set_invalid(struct sys_sem **s) { + *s = 0x0; kprintf("NEED TO DO THIS"); } @@ -139,9 +141,7 @@ } void sys_mutex_lock(sys_mutex_t *mutex) { - kprintf("L4.0"); ubthread_mutex_lock(&(mutex->mutex)); - kprintf("L4.1"); } void sys_mutex_unlock(sys_mutex_t *mutex) { @@ -269,11 +269,15 @@ } uint32_t sys_arch_mbox_fetch(struct sys_mbox **mb, void **msg, uint32_t timeout) { - uint32_t time_needed = 0; - struct sys_mbox *mbox; + uint32_t time_needed = 0x0; + struct sys_mbox *mbox = 0x0; + LWIP_ASSERT("invalid mbox", (mb != NULL) && (*mb != NULL)); mbox = *mb; + if (_current->id == 4) + kprintf("MBOX: 0x%X]", mbox); + /* The mutex lock is quick so we don't bother with the timeout stuff here. */ sys_arch_sem_wait(&mbox->lock, 0); @@ -347,11 +351,16 @@ return 0; } -int sys_mbox_valid(sys_mbox_t *mbox) { - return mbox != NULL; +int sys_mbox_valid(struct sys_mbox **mb) { + struct sys_mbox *mbox = *mb; + if (mbox == NULL) + return(0); + else + return(1); } -void sys_mbox_set_invalid(sys_mbox_t *mbox) { +void sys_mbox_set_invalid(struct sys_mbox **mb) { + *mb = 0x0; } sys_thread_t sys_thread_new(const char *name, void (*thread)(void *arg), void *arg, int stacksize, int prio) { diff --git a/src/sys/net/netif/ethernet.c b/src/sys/net/netif/ethernet.c index 9aa9f1e..4290609 100644 --- a/src/sys/net/netif/ethernet.c +++ b/src/sys/net/netif/ethernet.c @@ -87,6 +87,7 @@ #endif /* LWIP_ARP || ETHARP_SUPPORT_VLAN */ if (p->len <= SIZEOF_ETH_HDR) { + kprintf("BAD HEADER"); /* a packet with only an ethernet header (or less) is not valid for us */ ETHARP_STATS_INC(etharp.proterr); ETHARP_STATS_INC(etharp.drop); @@ -165,6 +166,7 @@ #if LWIP_IPV4 && LWIP_ARP /* IP packet? */ case PP_HTONS(ETHTYPE_IP): +//kprintf("%s:%i - Type: %i", __FILE__, __LINE__, type); if (!(netif->flags & NETIF_FLAG_ETHARP)) { goto free_and_return; } @@ -177,12 +179,15 @@ goto free_and_return; } else { /* pass to IP layer */ +//kprintf("%s:%i - Type: %i", __FILE__, __LINE__, type); ip4_input(p, netif); } break; case PP_HTONS(ETHTYPE_ARP): +//kprintf("%s:%i - Type: %i", __FILE__, __LINE__, type); if (!(netif->flags & NETIF_FLAG_ETHARP)) { +//kprintf("%s:%i - Type: %i", __FILE__, __LINE__, type); goto free_and_return; } /* skip Ethernet header */ @@ -193,25 +198,30 @@ LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("Can't move over header in packet")); ETHARP_STATS_INC(etharp.lenerr); ETHARP_STATS_INC(etharp.drop); +//kprintf("%s:%i - Type: %i", __FILE__, __LINE__, type); goto free_and_return; } else { /* pass p to ARP module */ +//kprintf("%s:%i - Type: %i", __FILE__, __LINE__, type); etharp_input(p, netif); } break; #endif /* LWIP_IPV4 && LWIP_ARP */ #if PPPOE_SUPPORT case PP_HTONS(ETHTYPE_PPPOEDISC): /* PPP Over Ethernet Discovery Stage */ +//kprintf("%s:%i - Type: %i", __FILE__, __LINE__, type); pppoe_disc_input(netif, p); break; case PP_HTONS(ETHTYPE_PPPOE): /* PPP Over Ethernet Session Stage */ +//kprintf("%s:%i - Type: %i", __FILE__, __LINE__, type); pppoe_data_input(netif, p); break; #endif /* PPPOE_SUPPORT */ #if LWIP_IPV6 case PP_HTONS(ETHTYPE_IPV6): /* IPv6 */ +//kprintf("%s:%i - Type: %i", __FILE__, __LINE__, type); /* skip Ethernet header */ if ((p->len < ip_hdr_offset) || pbuf_header(p, (s16_t)-ip_hdr_offset)) { LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_LEVEL_WARNING, @@ -226,6 +236,7 @@ #endif /* LWIP_IPV6 */ default: +//kprintf("%s:%i - Type: %i", __FILE__, __LINE__, type); #ifdef LWIP_HOOK_UNKNOWN_ETH_PROTOCOL if(LWIP_HOOK_UNKNOWN_ETH_PROTOCOL(p, netif) == ERR_OK) { break; diff --git a/src/sys/net/netif/ethernetif.c b/src/sys/net/netif/ethernetif.c index dde9c87..8237635 100644 --- a/src/sys/net/netif/ethernetif.c +++ b/src/sys/net/netif/ethernetif.c @@ -155,6 +155,7 @@ time. The size of the data in each pbuf is kept in the ->len variable. */ //send data from(q->payload, q->len); + //kprintf("SENDING DATA!!!!!"); lnc_sendPacket(lnc, q->payload, q->len,0x0); } diff --git a/src/sys/pci/lnc.c b/src/sys/pci/lnc.c index eafeb3a..97b8ce1 100644 --- a/src/sys/pci/lnc.c +++ b/src/sys/pci/lnc.c @@ -542,13 +542,13 @@ int lnc_sendPacket(struct lncInfo *lnc, void *packet, size_t len, uint8_t *dest) { - //kprintf("SEND PACKET1!\n"); + //kprintf("SEND PACKET1![%i]\n", lnc->txPtr); if (!lnc_driverOwnsTX(lnc)) { kpanic("NO TX BUFFERS"); return (0); } - //kprintf("SEND PACKET2!\n"); + //kprintf("SEND PACKET2![%i]\n", lnc->txPtr); memcpy((void *) (lnc->txBuffer + (lnc->txPtr * lnc->bufferSize)), packet, len); @@ -563,6 +563,8 @@ lnc->txRing[lnc->txPtr].md[1] |= 0x80; lnc_nextTxPtr(lnc); + + //kprintf("SEND PACKET3![%i]\n", lnc->txPtr); return (len); }