? cvs.log
? eposTCP.config
? eposTCP.creator
? eposTCP.files
? eposTCP.includes
? epos_uIP.patch
? run.sh
? app/ip_test.cc
? app/static_bug.cc
? app/uip.txt
? app/uip_test
? app/uip_test.cc
? bin/eposcc
? bin/eposldr
? bin/eposmkbi
? etc/eposcc.conf
? etc/eposmkbi.conf
? img/pc_boot
? img/pc_setup
? img/qemu-vlan0.pcap
? img/static_bug
? img/uip_test
? img/uip_test.img
? img/uip_test.out
? include/ip
? include/uip
? include/utility/buffer.h
? src/uip-1.0
? src/uip-1.0.tar.gz
? src/abstraction/icmp.cc
? src/abstraction/tcp.cc
? src/abstraction/tcp.cc_old
? src/arch/avr8/avr8_crt1.s
? src/arch/avr8/avr8_crtbegin.s
? src/arch/avr8/avr8_crtend.s
? src/arch/avr8/avr8_crti.s
? src/arch/avr8/avr8_crtn.s
? src/arch/ia32/ia32_crt1.s
? src/arch/ia32/ia32_crtbegin.s
? src/arch/ia32/ia32_crtend.s
? src/arch/ia32/ia32_crti.s
? src/arch/ia32/ia32_crtn.s
? src/boot/pc_boot
? src/boot/pc_boot.s
? src/setup/pc_setup
? tools/eposcc/eposcc.conf
? tools/eposldr/eposldr
? tools/eposmkbi/eposmkbi
? tools/eposmkbi/eposmkbi.conf
Index: makedefs
===================================================================
RCS file: /usr/local/cvs/epos--/makedefs,v
retrieving revision 1.44
diff -u -8 -p -r1.44 makedefs
--- makedefs	15 Sep 2010 01:10:37 -0000	1.44
+++ makedefs	3 Nov 2010 19:55:32 -0000
@@ -207,17 +207,17 @@ LIBSYS		= $(LIB)/lib$(LSYSNAME)_$(ARCH).
 LIBINIT		= $(LIB)/lib$(LINITNAME)_$(ARCH).a
 LIBUTIL		= $(LIB)/lib$(LUTILNAME)_$(ARCH).a
 LARCH		= $(LARCHNAME)_$(ARCH)
 LMACH		= $(LMACHNAME)_$(ARCH)
 LSYS		= $(LSYSNAME)_$(ARCH)
 LINIT		= $(LINITNAME)_$(ARCH)
 LUTIL		= $(LUTILNAME)_$(ARCH)
 ifndef APPLICATION
-APPLICATION 	= $(MACH)_app
+APPLICATION 	= uip_test
 endif
 
 # Tools to adapt linux files
 SED 		= sed
 
 # Tools and flags to compile system tools
 TCC		= gcc -ansi -c
 TCCFLAGS	= -m32 -Wall -O2 -I$(INCLUDE)
@@ -283,18 +283,17 @@ SHELL		= bash
 
 CLEAN		= rm -f
 CLEANDIR	= rm -rf
 
 TOUCH		= touch
 
 TEE		= tee
 
-#QEMU		= qemu -nographic -smp 8 -no-reboot -net none -fda
-QEMU		= qemu -no-reboot -serial stdio -net nic,model=pcnet -fda
+QEMU		= qemu -nographic -no-reboot -net user,hostfwd=tcp:0.0.0.0:8080-:80 -net nic,model=pcnet -net dump -fda
 
 # Rules
 lib%.o:		lib%.cc
 		$(CXX) $(CXXFLAGS) $<
 
 %_test.o:	%_test.cc
 		$(ACXX) $(ACXXFLAGS) $<
 
Index: include/nic.h
===================================================================
RCS file: /usr/local/cvs/epos--/include/nic.h,v
retrieving revision 1.12
diff -u -8 -p -r1.12 nic.h
--- include/nic.h	13 Sep 2010 00:04:50 -0000	1.12
+++ include/nic.h	3 Nov 2010 19:55:32 -0000
@@ -100,17 +100,21 @@ public:
 
 	virtual ~NIC_Base() {}
     
 	virtual int send(const Address & dst, const Protocol & prot, 
 			 const void * data, unsigned int size) = 0; 
 
 	virtual int receive(Address * src, Protocol * prot,
 			    void * data, unsigned int size) = 0;
-    
+			    
+    	virtual int raw_send(const void * data, unsigned int size) = 0; 
+
+	virtual int raw_receive(void * data, unsigned int size) = 0;
+			    
 	virtual void reset() = 0;
     
 	virtual unsigned int mtu() = 0;
 
 	virtual const Address & address() = 0;
 
 	virtual const Statistics & statistics() = 0;
     };
@@ -131,16 +135,19 @@ public:
 			 const void * data, unsigned int size) {
 	    return NIC::send(dst, prot, data, size); 
 	}
 
 	virtual int receive(Address * src, Protocol * prot,
 			    void * data, unsigned int size) {
 	    return NIC::receive(src, prot, data, size); 
 	}
+	virtual int raw_send(const void * data, unsigned int size) = 0; 
+
+	virtual int raw_receive(void * data, unsigned int size) = 0;
     
 	virtual void reset() { NIC::reset(); }
     
 	virtual unsigned int mtu() { return NIC::mtu(); }
 
 	virtual const Address & address() { return NIC::address(); }
 
 	virtual const Statistics & statistics() { return NIC::statistics(); }
Index: include/traits.h
===================================================================
RCS file: /usr/local/cvs/epos--/include/traits.h,v
retrieving revision 1.45
diff -u -8 -p -r1.45 traits.h
--- include/traits.h	6 Oct 2010 08:08:39 -0000	1.45
+++ include/traits.h	3 Nov 2010 19:55:32 -0000
@@ -16,18 +16,18 @@ struct Traits
 };
 
 
 // Utilities
 template <> struct Traits<Debug>
 {
     static const bool error   = true;
     static const bool warning = true;
-    static const bool info    = false;
-    static const bool trace   = false;
+    static const bool info    = true;
+    static const bool trace   = true;
 };
 
 template <> struct Traits<Lists>: public Traits<void>
 {
     static const bool debugged = false;
 };
 
 template <> struct Traits<Spin>: public Traits<void>
@@ -92,16 +92,24 @@ template <> struct Traits<Network>: publ
     static const unsigned int   ARP_TRIES = 3;
     static const unsigned long  ARP_TIMEOUT = 1000000; // 1s
 };
 
 template <> struct Traits<IP>: public Traits<void>{
     static const unsigned long ADDRESS = 0xc0a80a01;   // 192.168.10.1
     static const unsigned long NETMASK = 0xffffff00;   // 255.255.255.0
     static const unsigned long BROADCAST = 0; // 0= Default Broadcast Address
+
+    static const bool spawn_thread = true;  // automatic creation of IP's worker thread
+    static const bool debugged = true;
+
+    // uIP Configuration
+    static const unsigned int MAX_CONNECTIONS = 50;
+    static const unsigned int MAX_LISTENPORTS = 50;
+    static const unsigned int BUFFER_SIZE = 1500; // <= NIC::mtu
 };
 
 __END_SYS
 
 #ifdef __ARCH_TRAITS_H
 #include __ARCH_TRAITS_H
 #endif
 
Index: include/mach/pc/ethernet.h
===================================================================
RCS file: /usr/local/cvs/epos--/include/mach/pc/ethernet.h,v
retrieving revision 1.2
diff -u -8 -p -r1.2 ethernet.h
--- include/mach/pc/ethernet.h	13 Sep 2010 00:04:49 -0000	1.2
+++ include/mach/pc/ethernet.h	3 Nov 2010 19:55:32 -0000
@@ -31,16 +31,24 @@ public:
 	     const void * data, unsigned int size) {
 	return _dev->send(dst, prot, data, size); 
     }
 
     int receive(Address * src, Protocol * prot,
 		void * data, unsigned int size) {
 	return _dev->receive(src, prot, data, size); 
     }
+    
+    int raw_send(const void * data, unsigned int size) {
+	return _dev->raw_send(data, size); 
+    }
+
+    int raw_receive(void * data, unsigned int size) {
+	return _dev->raw_receive(data, size); 
+    }
 
     void reset() { _dev->reset(); }
 
     unsigned int mtu() const { return _dev->mtu(); }
     
     const Address & address() { return _dev->address(); }
 
     const Statistics & statistics() { return _dev->statistics(); }
Index: include/mach/pc/nic.h
===================================================================
RCS file: /usr/local/cvs/epos--/include/mach/pc/nic.h,v
retrieving revision 1.7
diff -u -8 -p -r1.7 nic.h
--- include/mach/pc/nic.h	13 Sep 2010 00:04:49 -0000	1.7
+++ include/mach/pc/nic.h	3 Nov 2010 19:55:32 -0000
@@ -31,16 +31,24 @@ public:
 	     const void * data, unsigned int size) {
 	return _dev->send(dst, prot, data, size); 
     }
 
     int receive(Address * src, Protocol * prot,
 		void * data, unsigned int size) {
 	return _dev->receive(src, prot, data, size); 
     }
+   
+    int raw_send(const void * data, unsigned int size) {
+    	return _dev->raw_send(data, size); 
+    }
+
+    int raw_receive(void * data, unsigned int size) {
+        return _dev->raw_receive(data, size); 
+    }
 
     void reset() { _dev->reset(); }
 
     unsigned int mtu() const { return _dev->mtu(); }
     
     const Address & address() { return _dev->address(); }
 
     const Statistics & statistics() { return _dev->statistics(); }
Index: include/mach/pc/pcnet32.h
===================================================================
RCS file: /usr/local/cvs/epos--/include/mach/pc/pcnet32.h,v
retrieving revision 1.6
diff -u -8 -p -r1.6 pcnet32.h
--- include/mach/pc/pcnet32.h	13 Sep 2010 00:04:49 -0000	1.6
+++ include/mach/pc/pcnet32.h	3 Nov 2010 19:55:32 -0000
@@ -409,16 +409,20 @@ public:
 
     ~PCNet32();
 
     int send(const Address & dst, const Protocol & prot,
  	     const void * data, unsigned int size);
 
     int receive(Address * src, Protocol * prot,
 		void * data, unsigned int size);
+		
+    int raw_send(const void * data, unsigned int size); 
+
+    int raw_receive(void * data, unsigned int size);
 
     void reset();
 
     unsigned int mtu() { return MTU; }
 
     const Address & address() { return _address; }
 
     const Statistics & statistics() { return _statistics; }
Index: include/system/types.h
===================================================================
RCS file: /usr/local/cvs/epos--/include/system/types.h,v
retrieving revision 1.40
diff -u -8 -p -r1.40 types.h
--- include/system/types.h	15 Sep 2010 00:52:58 -0000	1.40
+++ include/system/types.h	3 Nov 2010 19:55:32 -0000
@@ -1,15 +1,11 @@
 // EPOS Internal Type Management System
 
-#if defined(__newlib)
-typedef unsigned long size_t;
-#else
-typedef unsigned int size_t;
-#endif
+typedef __SIZE_TYPE__ size_t;
 
 #ifndef __types_h
 #define __types_h
 
 inline void * operator new(size_t s, void * a) { return a; }
 inline void * operator new[](size_t s, void * a) { return a; }
 
 __BEGIN_SYS
Index: include/utility/ostream.h
===================================================================
RCS file: /usr/local/cvs/epos--/include/utility/ostream.h,v
retrieving revision 1.4
diff -u -8 -p -r1.4 ostream.h
--- include/utility/ostream.h	13 Sep 2010 00:04:53 -0000	1.4
+++ include/utility/ostream.h	3 Nov 2010 19:55:32 -0000
@@ -102,28 +102,42 @@ public:
     }
 
     OStream & operator<<(const char * s) { 
 	print(s);
 	return *this; 
     }
 
 private:
-    void print(const char * s);
+    virtual void print(const char * s);
     void flush() {}
     int itoa(int v, char * s);
     int utoa(unsigned int v, char * s, unsigned int i = 0);
     int llitoa(long long int v, char * s);
     int llutoa(unsigned long long int v, char * s, unsigned int i = 0);
     int ptoa(const void * p, char * s);
 
 private:
     int _base;
 
     static const char _digits[];
+};
+
+class StringStream : public OStream {
+private:
+    char * _str;
+    int _size;
+    int _written;
+    
+    virtual void print(const char * s);
+    
+public:
+    StringStream(char * s,int l) : _str(s), _size(l), _written(0) {}
+    int written() { return _written; }
+    void end() { if (_size) *_str = '\0'; }
 }; 
 
 extern OStream::Endl endl;
 extern OStream::Hex hex;
 extern OStream::Dec dec;
 extern OStream::Oct oct;
 extern OStream::Bin bin;
 extern OStream kout, kerr;
Index: include/utility/string.h
===================================================================
RCS file: /usr/local/cvs/epos--/include/utility/string.h,v
retrieving revision 1.5
diff -u -8 -p -r1.5 string.h
--- include/utility/string.h	15 Sep 2010 00:55:44 -0000	1.5
+++ include/utility/string.h	3 Nov 2010 19:55:32 -0000
@@ -9,11 +9,13 @@ extern "C" {
     void * memset(void * m, int c, size_t n);
     void * memchr(const void * m, int c, size_t n);
     int strcmp(const char * s1, const char * s2);
     int strncmp(const char * s1, const char * s2, size_t n);
     char * strcpy(char * d, const char * s);
     char * strncpy(char * d, const char * s, size_t n);
     char *strchr(const char * s, int c);
     size_t strlen(const char * s);
+    
+    char * strrchr (const char *s, int c);
 }
 
 #endif
Index: src/mach/pc/pcnet32.cc
===================================================================
RCS file: /usr/local/cvs/epos--/src/mach/pc/pcnet32.cc,v
retrieving revision 1.9
diff -u -8 -p -r1.9 pcnet32.cc
--- src/mach/pc/pcnet32.cc	13 Sep 2010 00:04:50 -0000	1.9
+++ src/mach/pc/pcnet32.cc	3 Nov 2010 19:55:32 -0000
@@ -243,16 +243,65 @@ int PCNet32::receive(Address * src, Prot
 		     << ",p=" << hex << *prot << dec
 		     << ",dt=" << data
 		     << ",sz=" << s
 		     << ")\n";
 
     return s;
 }
 
+int PCNet32::raw_send(const void * data, unsigned int size)
+{
+    db<PCNet32>(TRC) << "PCNet32::send(dt="<< data << ",sz=" << size << ")\n";
+
+    // Wait for a free buffer
+    while(_tx_ring[_tx_cur].status & Rx_Desc::OWN);
+
+    if (size > mtu()) size = mtu();
+    memcpy(_tx_buffer[_tx_cur], data, size);
+
+    _tx_ring[_tx_cur].size = -size; // 2's comp.
+
+    // Status must be set last, since it can trigger a send
+    _tx_ring[_tx_cur].status = Tx_Desc::OWN | Tx_Desc::STP | Tx_Desc::ENP;
+
+    // Trigger an immediate send poll
+    csr(0, csr(0) | CSR0_TDMD);
+
+    _statistics.tx_packets++;
+    _statistics.tx_bytes += size;
+
+    ++_tx_cur %= TX_BUFS;
+
+    return size;
+}
+
+int PCNet32::raw_receive(void * data, unsigned int size)
+{
+    // Wait for a frame in the ring buffer
+    while(_rx_ring[_rx_cur].status & Rx_Desc::OWN);
+
+    unsigned int s = (_rx_ring[_rx_cur].misc & 0x00000fff);
+
+    // Copy data
+    memcpy(data, _rx_buffer[_rx_cur], (s > size) ? size : s);
+ 
+    // Release the buffer to the NIC
+    _rx_ring[_rx_cur].status = Rx_Desc::OWN;
+
+    _statistics.rx_packets++;
+    _statistics.rx_bytes += s;
+
+    ++_rx_cur %= RX_BUFS;
+
+    db<PCNet32>(TRC) << "PCNet32::raw_receive(dt="<< data <<",sz="<< s << ")\n";
+
+    return s;
+}
+
 void PCNet32::handle_int()
 {
     CPU::int_disable();
 
     while(csr(0) & CSR0_INTR) {
 	int csr0 = csr(0);
 	int csr4 = csr(4);
 	int csr5 = csr(5);
Index: src/utility/ostream.cc
===================================================================
RCS file: /usr/local/cvs/epos--/src/utility/ostream.cc,v
retrieving revision 1.9
diff -u -8 -p -r1.9 ostream.cc
--- src/utility/ostream.cc	13 Sep 2010 00:04:50 -0000	1.9
+++ src/utility/ostream.cc	3 Nov 2010 19:55:32 -0000
@@ -95,10 +95,16 @@ int OStream::ptoa(const void * p, char *
 
     for(j = 0; j < sizeof(void *) * 2; j++, v >>= 4)
 	s[2 + sizeof(void *) * 2 - 1 - j]
 	    = _digits[v & 0xf];
 
     return j + 2;
 }    
 
+void StringStream::print(const char * s) {
+    while (*s && _size) { 
+        *_str++ = *s++;
+        _written++; _size--;
+    }
+}
 
 __END_SYS
Index: src/utility/string.cc
===================================================================
RCS file: /usr/local/cvs/epos--/src/utility/string.cc,v
retrieving revision 1.1
diff -u -8 -p -r1.1 string.cc
--- src/utility/string.cc	15 Sep 2010 01:04:51 -0000	1.1
+++ src/utility/string.cc	3 Nov 2010 19:55:32 -0000
@@ -10,16 +10,17 @@ extern "C"
     void * memcpy(void * d, const void * s, size_t n) __attribute__ ((weak));
     void * memset(void * m, int c, size_t n) __attribute__ ((weak));
     void * memchr(const void * m, int c, size_t n) __attribute__ ((weak));
     int strcmp(const char * s1, const char * s2) __attribute__ ((weak));
     int strncmp(const char * s1, const char * s2, size_t n) __attribute__ ((weak));
     char * strcpy(char *d, const char *s) __attribute__ ((weak));
     char * strncpy(char *d, const char *s, size_t n) __attribute__ ((weak));
     char *strchr(const char * s, int c) __attribute__ ((weak));
+    char * strrchr (const char *s, int c) __attribute__ ((weak));
     size_t strlen(const char * s) __attribute__ ((weak));
 
     int memcmp(const void * m1, const void * m2, size_t n)
     {
 	unsigned char *s1 = (unsigned char *) m1;
 	unsigned char *s2 = (unsigned char *) m2;
 	unsigned long *a1;
 	unsigned long *a2;
@@ -374,9 +375,20 @@ extern "C"
 	    aligned_addr++;
 
 	str = (char *) aligned_addr;
 
 	while(*str)
 	    str++;
 	return str - start;
     }
+    
+    char * strrchr (const char *s, int c)
+    {
+        char *rtnval = 0;
+
+        do {
+           if (*s == c)
+               rtnval = (char*) s;
+        } while (*s++);
+        return (rtnval);
+    }
 }
