comparison packages/io/eth/current/src/lwip/lw.diff @ 208:e0c0827131d1 ecos

Merge from eCos master repository on 2002-05-20-20:11:54-BST
author jlarmour
date Mon, 20 May 2002 22:19:26 +0000
parents
children d2c90368aeef
comparison
equal deleted inserted replaced
207:74c807ddde34 208:e0c0827131d1
1 diff -Nur lwip-0.5.3/proj/ecos/Makefile lwip.ecos/proj/ecos/Makefile
2 --- lwip-0.5.3/proj/ecos/Makefile Thu Jan 1 02:00:00 1970
3 +++ lwip.ecos/proj/ecos/Makefile Tue Apr 2 18:17:49 2002
4 @@ -0,0 +1,76 @@
5 +CCDEP=arm-elf-gcc
6 +CC=arm-elf-gcc
7 +AR=arm-elf-ar
8 +#CFLAGS=-g -Wall -DIPv4 -DLWIP_DEBUG
9 +#CFLAGS=-Wall -DIPv4
10 +CFLAGS=-g -Wall -DIPv4
11 +LDFLAGS=-nostdlib -L$(ECOSLIB) -Ttarget.ld -Wl,-static -Wl,--gc-sections -finit-priority
12 +LWIPARCH=ecos
13 +ARFLAGS=rs
14 +LWIPDIR=../../src
15 +
16 +ECOSDIR=/home/jani/ecos/build/lwip/edb/install
17 +ECOSINC=$(ECOSDIR)/include
18 +ECOSLIB=$(ECOSDIR)/lib
19 +
20 +CFLAGS:=$(CFLAGS) \
21 + -I$(LWIPDIR)/include -I$(LWIPDIR)/arch/$(LWIPARCH)/include -I$(LWIPDIR)/include/ipv4 \
22 + -Iapps -I$(ECOSINC) -I.
23 +
24 +# COREFILES, CORE4FILES: The minimum set of files needed for lwIP.
25 +COREFILES=$(LWIPDIR)/core/mem.c $(LWIPDIR)/core/memp.c $(LWIPDIR)/core/netif.c \
26 + $(LWIPDIR)/core/pbuf.c $(LWIPDIR)/core/stats.c $(LWIPDIR)/core/sys.c \
27 + $(LWIPDIR)/core/tcp.c $(LWIPDIR)/core/tcp_input.c \
28 + $(LWIPDIR)/core/tcp_output.c $(LWIPDIR)/core/udp.c
29 +CORE4FILES=$(LWIPDIR)/core/ipv4/icmp.c $(LWIPDIR)/core/ipv4/ip.c \
30 + $(LWIPDIR)/core/inet.c $(LWIPDIR)/core/ipv4/ip_addr.c
31 +
32 +
33 +# APIFILES: The files which implement the sequential and socket APIs.
34 +APIFILES=$(LWIPDIR)/api/api_lib.c $(LWIPDIR)/api/api_msg.c $(LWIPDIR)/api/tcpip.c \
35 + $(LWIPDIR)/api/err.c $(LWIPDIR)/api/sockets.c
36 +
37 +# NETIFFILES: Files implementing various generic network interface functions.'
38 +NETIFFILES= $(LWIPDIR)/netif/arp.c
39 +
40 +# ARCHFILES: Architecture specific files.
41 +ARCHFILES=$(wildcard $(LWIPDIR)/arch/$(LWIPARCH)/*.c $(LWIPDIR)/arch/$(LWIPARCH)/netif/*.c)
42 +
43 +
44 +# APPFILES: Applications.
45 +APPFILES=apps/tcpecho.c apps/httpd.c apps/fs.c apps/udpecho.c apps/shell.c
46 +
47 +# LWIPFILES: All the above.
48 +LWIPFILES=$(COREFILES) $(CORE4FILES) $(APIFILES) $(NETIFFILES) $(ARCHFILES)
49 +#LWIPFILESW=$(wildcard $(LWIPFILES))
50 +#LWIPOBJS=$(notdir $(LWIPFILESW:.c=.o))
51 +LWIPOBJS=$(notdir $(LWIPFILES:.c=.o))
52 +
53 +LWIPLIB=liblwip4.a
54 +APPLIB=liblwipapps.a
55 +APPOBJS=$(notdir $(APPFILES:.c=.o))
56 +
57 +%.o:
58 + $(CC) $(CFLAGS) -c $(<:.o=.c)
59 +
60 +all ipv4 compile: simhost
61 +.PHONY: all
62 +
63 +clean:
64 + rm -f *.o $(LWIPLIB) $(APPLIB) simhost *.s .depend* *.core core
65 +
66 +depend dep: .depend
67 +
68 +include .depend
69 +
70 +$(APPLIB): $(APPOBJS)
71 + $(AR) $(ARFLAGS) $(APPLIB) $?
72 +
73 +$(LWIPLIB): $(LWIPOBJS)
74 + $(AR) $(ARFLAGS) $(LWIPLIB) $?
75 +
76 +.depend: simhost.c $(LWIPFILES) $(APPFILES)
77 + $(CCDEP) $(CFLAGS) -MM $^ > .depend || rm -f .depend
78 +
79 +simhost: .depend $(LWIPLIB) $(APPLIB) simhost.o $(APPFILES) $(ECOSLIB)/libtarget.a
80 + $(CC) $(CFLAGS) $(LDFLAGS) -o simhost simhost.o $(APPLIB) $(LWIPLIB)
81 diff -Nur lwip-0.5.3/proj/ecos/README lwip.ecos/proj/ecos/README
82 --- lwip-0.5.3/proj/ecos/README Thu Jan 1 02:00:00 1970
83 +++ lwip.ecos/proj/ecos/README Tue Apr 2 19:12:52 2002
84 @@ -0,0 +1,21 @@
85 +Building the test prog with ecos+lwip
86 +
87 +I suppose you have a working ecos build with your target....
88 +
89 +There:
90 +
91 +#ecosconfig add net_drivers
92 +and select lwip and unselect standalone driver and debugging
93 +(after patching io/eth's cdl script with ioeth.diff first to see lwIP as an option)
94 +and build the ecos libs as usual
95 +
96 +
97 +Here:
98 +
99 +copy the files in unixsim/apps over here.Don't overwrite makefsdata or else the
100 +httpd data won't be aligned and won't work on platforms which require >1 alignment (ARM)
101 +
102 +modify ECOSDIR in the Makefile to point to your ecos project dir
103 +#make
104 +and you should have an ecos exec with lwIP linked to it.
105 +
106 diff -Nur lwip-0.5.3/proj/ecos/apps/makefsdata lwip.ecos/proj/ecos/apps/makefsdata
107 --- lwip-0.5.3/proj/ecos/apps/makefsdata Thu Jan 1 02:00:00 1970
108 +++ lwip.ecos/proj/ecos/apps/makefsdata Tue Apr 2 16:05:10 2002
109 @@ -0,0 +1,70 @@
110 +#!/usr/bin/perl
111 +
112 +open(OUTPUT, "> fsdata.c");
113 +
114 +chdir("fs");
115 +open(FILES, "find . -type f -o -name CVS -a -prune -type f |");
116 +
117 +while($file = <FILES>) {
118 +
119 + chop($file);
120 +
121 + open(HEADER, "> /tmp/header") || die $!;
122 + print(HEADER "HTTP/1.0 200 OK\r\n");
123 + if($file =~ /\.html$/) {
124 + print(HEADER "Content-Type: text/html\r\n");
125 + } elsif($file =~ /\.gif$/) {
126 + print(HEADER "Content-Type: image/gif\r\n");
127 + } elsif($file =~ /\.png$/) {
128 + print(HEADER "Content-Type: image/png\r\n");
129 + } elsif($file =~ /\.jpg$/) {
130 + print(HEADER "Content-Type: image/jpeg\r\n");
131 + } else {
132 + print(HEADER "Content-Type: text/plain\r\n");
133 + }
134 + print(HEADER "\r\n");
135 + close(HEADER);
136 +
137 + system("cat /tmp/header $file > /tmp/file");
138 +
139 + open(FILE, "/tmp/file");
140 + unlink("/tmp/file");
141 + unlink("/tmp/header");
142 +
143 + $file =~ s/\.//;
144 + $fvar = $file;
145 + $fvar =~ s-/-_-g;
146 + $fvar =~ s-\.-_-g;
147 + print(OUTPUT "static const char data".$fvar."[] __attribute__ ((aligned)) = {\n");
148 + $i = 0;
149 + while(read(FILE, $data, 1)) {
150 + if($i == 0) {
151 + print(OUTPUT "\t");
152 + }
153 + printf(OUTPUT "%#02x, ", unpack("C", $data));
154 + $i++;
155 + if($i == 10) {
156 + print(OUTPUT "\n");
157 + $i = 0;
158 + }
159 + }
160 + print(OUTPUT "};\n\n");
161 + close(FILE);
162 + push(@fvars, $fvar);
163 + push(@files, $file);
164 +}
165 +
166 +for($i = 0; $i < @fvars; $i++) {
167 + $file = $files[$i];
168 + $fvar = $fvars[$i];
169 +
170 + if($i == 0) {
171 + $prevfile = "NULL";
172 + } else {
173 + $prevfile = "file" . $fvars[$i - 1];
174 + }
175 + print(OUTPUT "static const struct fsdata_file file".$fvar."[] = {{$prevfile, \"$file\", ");
176 + print(OUTPUT "data$fvar, sizeof(data$fvar)}};\n\n");
177 +}
178 +
179 +print(OUTPUT "#define FS_ROOT file$fvars[$i - 1]\n\n");
180 diff -Nur lwip-0.5.3/proj/ecos/lwipopts.h lwip.ecos/proj/ecos/lwipopts.h
181 --- lwip-0.5.3/proj/ecos/lwipopts.h Thu Jan 1 02:00:00 1970
182 +++ lwip.ecos/proj/ecos/lwipopts.h Fri Mar 29 15:05:06 2002
183 @@ -0,0 +1,174 @@
184 +/*
185 + * Copyright (c) 2001, Swedish Institute of Computer Science.
186 + * All rights reserved.
187 + *
188 + * Redistribution and use in source and binary forms, with or without
189 + * modification, are permitted provided that the following conditions
190 + * are met:
191 + * 1. Redistributions of source code must retain the above copyright
192 + * notice, this list of conditions and the following disclaimer.
193 + * 2. Redistributions in binary form must reproduce the above copyright
194 + * notice, this list of conditions and the following disclaimer in the
195 + * documentation and/or other materials provided with the distribution.
196 + * 3. Neither the name of the Institute nor the names of its contributors
197 + * may be used to endorse or promote products derived from this software
198 + * without specific prior written permission.
199 + *
200 + * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
201 + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
202 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
203 + * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
204 + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
205 + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
206 + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
207 + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
208 + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
209 + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
210 + * SUCH DAMAGE.
211 + *
212 + * This file is part of the lwIP TCP/IP stack.
213 + *
214 + * Author: Adam Dunkels <adam@sics.se>
215 + *
216 + * $Id: lw.diff,v 1.1 2002/05/20 22:24:22 jlarmour Exp $
217 + */
218 +#ifndef __LWIPOPTS_H__
219 +#define __LWIPOPTS_H__
220 +
221 +/* ---------- Memory options ---------- */
222 +/* MEM_ALIGNMENT: should be set to the alignment of the CPU for which
223 + lwIP is compiled. 4 byte alignment -> define MEM_ALIGNMENT to 4, 2
224 + byte alignment -> define MEM_ALIGNMENT to 2. */
225 +#define MEM_ALIGNMENT 4
226 +
227 +/* MEM_SIZE: the size of the heap memory. If the application will send
228 +a lot of data that needs to be copied, this should be set high. */
229 +#define MEM_SIZE 1000
230 +
231 +/* MEMP_NUM_PBUF: the number of memp struct pbufs. If the application
232 + sends a lot of data out of ROM (or other static memory), this
233 + should be set high. */
234 +#define MEMP_NUM_PBUF 8
235 +/* MEMP_NUM_UDP_PCB: the number of UDP protocol control blocks. One
236 + per active UDP "connection". */
237 +#define MEMP_NUM_UDP_PCB 4
238 +/* MEMP_NUM_TCP_PCB: the number of simulatenously active TCP
239 + connections. */
240 +#define MEMP_NUM_TCP_PCB 5
241 +/* MEMP_NUM_TCP_PCB_LISTEN: the number of listening TCP
242 + connections. */
243 +#define MEMP_NUM_TCP_PCB_LISTEN 8
244 +/* MEMP_NUM_TCP_SEG: the number of simultaneously queued TCP
245 + segments. */
246 +#define MEMP_NUM_TCP_SEG 8
247 +/* MEMP_NUM_SYS_TIMEOUT: the number of simulateously active
248 + timeouts. */
249 +#define MEMP_NUM_SYS_TIMEOUT 3
250 +
251 +
252 +/* The following four are used only with the sequential API and can be
253 + set to 0 if the application only will use the raw API. */
254 +/* MEMP_NUM_NETBUF: the number of struct netbufs. */
255 +#define MEMP_NUM_NETBUF 2
256 +/* MEMP_NUM_NETCONN: the number of struct netconns. */
257 +#define MEMP_NUM_NETCONN 4
258 +/* MEMP_NUM_APIMSG: the number of struct api_msg, used for
259 + communication between the TCP/IP stack and the sequential
260 + programs. */
261 +#define MEMP_NUM_API_MSG 8
262 +/* MEMP_NUM_TCPIPMSG: the number of struct tcpip_msg, which is used
263 + for sequential API communication and incoming packets. Used in
264 + src/api/tcpip.c. */
265 +#define MEMP_NUM_TCPIP_MSG 8
266 +
267 +/* These two control is reclaimer functions should be compiled
268 + in. Should always be turned on (1). */
269 +#define MEM_RECLAIM 1
270 +#define MEMP_RECLAIM 1
271 +
272 +/* ---------- Pbuf options ---------- */
273 +/* PBUF_POOL_SIZE: the number of buffers in the pbuf pool. */
274 +#define PBUF_POOL_SIZE 6
275 +
276 +/* PBUF_POOL_BUFSIZE: the size of each pbuf in the pbuf pool. */
277 +#define PBUF_POOL_BUFSIZE 128
278 +
279 +/* PBUF_LINK_HLEN: the number of bytes that should be allocated for a
280 + link level header. */
281 +#define PBUF_LINK_HLEN 16
282 +
283 +/* ---------- TCP options ---------- */
284 +#define LWIP_TCP 1
285 +#define TCP_TTL 255
286 +
287 +/* Controls if TCP should queue segments that arrive out of
288 + order. Define to 0 if your device is low on memory. */
289 +#define TCP_QUEUE_OOSEQ 1
290 +
291 +/* TCP Maximum segment size. */
292 +#define TCP_MSS 128
293 +
294 +/* TCP sender buffer space (bytes). */
295 +#define TCP_SND_BUF 256
296 +
297 +/* TCP sender buffer space (pbufs). This must be at least = 2 *
298 + TCP_SND_BUF/TCP_MSS for things to work. */
299 +#define TCP_SND_QUEUELEN 4 * TCP_SND_BUF/TCP_MSS
300 +
301 +/* TCP receive window. */
302 +#define TCP_WND 1024
303 +
304 +/* Maximum number of retransmissions of data segments. */
305 +#define TCP_MAXRTX 12
306 +
307 +/* Maximum number of retransmissions of SYN segments. */
308 +#define TCP_SYNMAXRTX 4
309 +
310 +/* ---------- ARP options ---------- */
311 +#define ARP_TABLE_SIZE 10
312 +
313 +/* ---------- IP options ---------- */
314 +/* Define IP_FORWARD to 1 if you wish to have the ability to forward
315 + IP packets across network interfaces. If you are going to run lwIP
316 + on a device with only one network interface, define this to 0. */
317 +#define IP_FORWARD 1
318 +
319 +/* If defined to 1, IP options are allowed (but not parsed). If
320 + defined to 0, all packets with IP options are dropped. */
321 +#define IP_OPTIONS 1
322 +
323 +/* ---------- ICMP options ---------- */
324 +#define ICMP_TTL 255
325 +
326 +
327 +/* ---------- DHCP options ---------- */
328 +/* Define LWIP_DHCP to 1 if you want DHCP configuration of
329 + interfaces. DHCP is not implemented in lwIP 0.5.1, however, so
330 + turning this on does currently not work. */
331 +#define LWIP_DHCP 0
332 +
333 +/* 1 if you want to do an ARP check on the offered address
334 + (recommended). */
335 +#define DHCP_DOES_ARP_CHECK 1
336 +
337 +/* ---------- UDP options ---------- */
338 +#define LWIP_UDP 1
339 +#define UDP_TTL 255
340 +
341 +
342 +/* ---------- Statistics options ---------- */
343 +#define STATS
344 +
345 +#ifdef STATS
346 +#define LINK_STATS
347 +#define IP_STATS
348 +#define ICMP_STATS
349 +#define UDP_STATS
350 +#define TCP_STATS
351 +#define MEM_STATS
352 +#define MEMP_STATS
353 +#define PBUF_STATS
354 +#define SYS_STATS
355 +#endif /* STATS */
356 +
357 +#endif /* __LWIPOPTS_H__ */
358 diff -Nur lwip-0.5.3/proj/ecos/simhost.c lwip.ecos/proj/ecos/simhost.c
359 --- lwip-0.5.3/proj/ecos/simhost.c Thu Jan 1 02:00:00 1970
360 +++ lwip.ecos/proj/ecos/simhost.c Fri Mar 29 14:45:33 2002
361 @@ -0,0 +1,141 @@
362 +/*
363 + * Copyright (c) 2001, Swedish Institute of Computer Science.
364 + * All rights reserved.
365 + *
366 + * Redistribution and use in source and binary forms, with or without
367 + * modification, are permitted provided that the following conditions
368 + * are met:
369 + * 1. Redistributions of source code must retain the above copyright
370 + * notice, this list of conditions and the following disclaimer.
371 + * 2. Redistributions in binary form must reproduce the above copyright
372 + * notice, this list of conditions and the following disclaimer in the
373 + * documentation and/or other materials provided with the distribution.
374 + * 3. Neither the name of the Institute nor the names of its contributors
375 + * may be used to endorse or promote products derived from this software
376 + * without specific prior written permission.
377 + *
378 + * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
379 + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
380 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
381 + * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
382 + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
383 + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
384 + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
385 + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
386 + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
387 + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
388 + * SUCH DAMAGE.
389 + *
390 + * This file is part of the lwIP TCP/IP stack.
391 + *
392 + * Author: Adam Dunkels <adam@sics.se>
393 + *
394 + * $Id: lw.diff,v 1.1 2002/05/20 22:24:22 jlarmour Exp $
395 + */
396 +
397 +#include "lwip/debug.h"
398 +
399 +#include <unistd.h>
400 +
401 +#include "lwip/opt.h"
402 +
403 +#include "lwip/mem.h"
404 +#include "lwip/memp.h"
405 +#include "lwip/sys.h"
406 +
407 +#include "lwip/stats.h"
408 +
409 +#include "netif/ecosif.h"
410 +//#include "netif/loopif.h"
411 +
412 +#include "lwip/tcpip.h"
413 +
414 +#include "lwip/ip_addr.h"
415 +
416 +#include "arch/perf.h"
417 +
418 +#include "httpd.h"
419 +#include "tcpecho.h"
420 +#include "udpecho.h"
421 +#include "shell.h"
422 +
423 +/*-----------------------------------------------------------------------------------*/
424 +static void
425 +tcp_timeout(void *data)
426 +{
427 +#if TCP_DEBUG
428 + tcp_debug_print_pcbs();
429 +#endif /* TCP_DEBUG */
430 + sys_timeout(5000, tcp_timeout, NULL);
431 +}
432 +/*-----------------------------------------------------------------------------------*/
433 +static void
434 +tcpip_init_done(void *arg)
435 +{
436 + sys_sem_t *sem;
437 + sem = arg;
438 + sys_sem_signal(*sem);
439 +}
440 +/*-----------------------------------------------------------------------------------*/
441 +static void
442 +main_thread(void *arg)
443 +{
444 + struct ip_addr ipaddr, netmask, gw;
445 + sys_sem_t sem;
446 + netif_init();
447 +
448 + sem = sys_sem_new(0);
449 + tcpip_init(tcpip_init_done, &sem);
450 + sys_sem_wait(sem);
451 + sys_sem_free(sem);
452 + printf("TCP/IP initialized.\n");
453 +
454 + IP4_ADDR(&gw, 192,168,1,1);
455 + IP4_ADDR(&ipaddr, 192,168,1,99);
456 + IP4_ADDR(&netmask, 255,255,255,0);
457 +
458 + netif_set_default(netif_add(&ipaddr, &netmask, &gw, ecosif_init, tcpip_input));
459 + IP4_ADDR(&gw, 127,0,0,1);
460 + IP4_ADDR(&ipaddr, 127,0,0,1);
461 + IP4_ADDR(&netmask, 255,0,0,0);
462 +
463 +// netif_add(&ipaddr, &netmask, &gw, loopif_init, tcpip_input);
464 +// udpecho_init();
465 +// shell_init();
466 +// tcpecho_init();
467 + httpd_init();
468 + printf("Applications started.\n");
469 + /* Block for ever. */
470 + sem = sys_sem_new(0);
471 + sys_sem_wait(sem);
472 +}
473 +/*-----------------------------------------------------------------------------------*/
474 +int
475 +main(int argc, char **argv)
476 +{
477 +#ifdef STATS
478 + stats_init();
479 +#endif /* STATS */
480 + sys_init();
481 + mem_init();
482 + memp_init();
483 + pbuf_init();
484 +
485 +
486 +
487 + printf("System initialized.\n");
488 +
489 + sys_thread_new((void *)(main_thread), (void*)"simhost");
490 + while(1)
491 + {cyg_thread_delay(1000);}
492 + return 0;
493 +}
494 +/*-----------------------------------------------------------------------------------*/
495 +
496 +
497 +
498 +
499 +
500 +
501 +
502 +
503 diff -Nur lwip-0.5.3/src/arch/ecos/README lwip.ecos/src/arch/ecos/README
504 --- lwip-0.5.3/src/arch/ecos/README Thu Jan 1 02:00:00 1970
505 +++ lwip.ecos/src/arch/ecos/README Tue Apr 2 19:17:23 2002
506 @@ -0,0 +1,47 @@
507 +eCos port of lwIP
508 +======================
509 +
510 +Introduction
511 +-------------
512 +This is a beta version of the lwIP port to eCos.It was tested on a Cirrus Logic
513 +EDB72111 board with ARM and it responds to ping and runs the unixsim apps(http,tcpecho,shell,etc)
514 +The motivation behind it is that the current TCP stack in eCos is too large both
515 +as code size and as memory footprint for a board with 128K FLASH + 128K RAM.
516 +BTW this port is just working it still need optimization.
517 +
518 +Description
519 +------------
520 +
521 +The port consists of 3 main parts
522 +
523 +I) the eCos specific sys_arch implemetation
524 +- src/arch/ecos/sys_arch.c
525 +- sys/arch/ecos/include/....
526 +This maps lwIP semaphores, mailboxes and threads to their eCos counterparts
527 +along with the required header files defining endianness and primitive data types
528 +
529 +II) the interface to the hw network drivers
530 +- io/eth/lwip/eth_drv.c in the eCos repository
531 +This part consists of a hardware independent net driver which glues eCos
532 +low-level ethernet drivers to the lwIP stack (modeled after the two such drivers
533 +existing in eCos : the standalone for RedBoot and the other one for the BSD stack)
534 +This driver implements the 3 callbacks needed by hw specific drivers.
535 +It currently uses the polling model like the standalone driver and not interrupts.
536 +This makes the whole thing less intrusive
537 +
538 +III) the eCos specific lwIP netif
539 +- src/arch/ecos/netif/ecosif.c
540 +This file implements the lwIP netif model with init/input/output functions.This
541 +calls into and is called from eth_drv.c described above
542 +
543 +Usage
544 +-------
545 +
546 +The way to build an eCos app with lwIP is to just link the lwIP libs to your app and then
547 +the whole thing to libtarget.a from eCos as usual.So this way lwIP is more like part of you app
548 +than part of eCos.For an example of Makefile see the one in proj/ecos heavily based on
549 +unixim/ecos from the lwip distribution.
550 +
551 +The organisation should change.Ideally there would be an eCos package
552 +to simply add to your project and configure just like any other package.
553 +
554 diff -Nur lwip-0.5.3/src/arch/ecos/include/arch/cc.h lwip.ecos/src/arch/ecos/include/arch/cc.h
555 --- lwip-0.5.3/src/arch/ecos/include/arch/cc.h Thu Jan 1 02:00:00 1970
556 +++ lwip.ecos/src/arch/ecos/include/arch/cc.h Thu Mar 14 23:23:00 2002
557 @@ -0,0 +1,51 @@
558 +/*
559 + * Copyright (c) 2001, Swedish Institute of Computer Science.
560 + * All rights reserved.
561 + *
562 + * Redistribution and use in source and binary forms, with or without
563 + * modification, are permitted provided that the following conditions
564 + * are met:
565 + * 1. Redistributions of source code must retain the above copyright
566 + * notice, this list of conditions and the following disclaimer.
567 + * 2. Redistributions in binary form must reproduce the above copyright
568 + * notice, this list of conditions and the following disclaimer in the
569 + * documentation and/or other materials provided with the distribution.
570 + * 3. Neither the name of the Institute nor the names of its contributors
571 + * may be used to endorse or promote products derived from this software
572 + * without specific prior written permission.
573 + *
574 + * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
575 + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
576 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
577 + * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
578 + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
579 + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
580 + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
581 + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
582 + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
583 + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
584 + * SUCH DAMAGE.
585 + *
586 + * This file is part of the lwIP TCP/IP stack.
587 + *
588 + * Author: Adam Dunkels <adam@sics.se>
589 + *
590 + * $Id: lw.diff,v 1.1 2002/05/20 22:24:22 jlarmour Exp $
591 + */
592 +#ifndef __ARCH_CC_H__
593 +#define __ARCH_CC_H__
594 +
595 +typedef unsigned char u8_t;
596 +typedef signed char s8_t;
597 +typedef unsigned short u16_t;
598 +typedef signed short s16_t;
599 +typedef unsigned long u32_t;
600 +typedef signed long s32_t;
601 +
602 +
603 +#define PACK_STRUCT_FIELD(x) x __attribute__((packed))
604 +#define PACK_STRUCT_STRUCT __attribute__((packed))
605 +#define PACK_STRUCT_BEGIN
606 +#define PACK_STRUCT_END
607 +
608 +#endif /* __ARCH_CC_H__ */
609 diff -Nur lwip-0.5.3/src/arch/ecos/include/arch/cpu.h lwip.ecos/src/arch/ecos/include/arch/cpu.h
610 --- lwip-0.5.3/src/arch/ecos/include/arch/cpu.h Thu Jan 1 02:00:00 1970
611 +++ lwip.ecos/src/arch/ecos/include/arch/cpu.h Fri Mar 15 22:08:00 2002
612 @@ -0,0 +1,44 @@
613 +/*
614 + * Copyright (c) 2001, Swedish Institute of Computer Science.
615 + * All rights reserved.
616 + *
617 + * Redistribution and use in source and binary forms, with or without
618 + * modification, are permitted provided that the following conditions
619 + * are met:
620 + * 1. Redistributions of source code must retain the above copyright
621 + * notice, this list of conditions and the following disclaimer.
622 + * 2. Redistributions in binary form must reproduce the above copyright
623 + * notice, this list of conditions and the following disclaimer in the
624 + * documentation and/or other materials provided with the distribution.
625 + * 3. Neither the name of the Institute nor the names of its contributors
626 + * may be used to endorse or promote products derived from this software
627 + * without specific prior written permission.
628 + *
629 + * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
630 + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
631 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
632 + * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
633 + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
634 + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
635 + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
636 + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
637 + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
638 + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
639 + * SUCH DAMAGE.
640 + *
641 + * This file is part of the lwIP TCP/IP stack.
642 + *
643 + * Author: Adam Dunkels <adam@sics.se>
644 + *
645 + * $Id: lw.diff,v 1.1 2002/05/20 22:24:22 jlarmour Exp $
646 + */
647 +#ifndef __ARCH_CPU_H__
648 +#define __ARCH_CPU_H__
649 +
650 +#if (CYG_BYTEORDER == CYG_LSBFIRST)
651 +#define BYTE_ORDER LITTLE_ENDIAN
652 +#else
653 +#define BYTE_ORDER BIG_ENDIAN
654 +#endif
655 +
656 +#endif /* __ARCH_CPU_H__ */
657 diff -Nur lwip-0.5.3/src/arch/ecos/include/arch/init.h lwip.ecos/src/arch/ecos/include/arch/init.h
658 --- lwip-0.5.3/src/arch/ecos/include/arch/init.h Thu Jan 1 02:00:00 1970
659 +++ lwip.ecos/src/arch/ecos/include/arch/init.h Wed Dec 12 00:00:00 2001
660 @@ -0,0 +1,44 @@
661 +/*
662 + * Copyright (c) 2001, Swedish Institute of Computer Science.
663 + * All rights reserved.
664 + *
665 + * Redistribution and use in source and binary forms, with or without
666 + * modification, are permitted provided that the following conditions
667 + * are met:
668 + * 1. Redistributions of source code must retain the above copyright
669 + * notice, this list of conditions and the following disclaimer.
670 + * 2. Redistributions in binary form must reproduce the above copyright
671 + * notice, this list of conditions and the following disclaimer in the
672 + * documentation and/or other materials provided with the distribution.
673 + * 3. Neither the name of the Institute nor the names of its contributors
674 + * may be used to endorse or promote products derived from this software
675 + * without specific prior written permission.
676 + *
677 + * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
678 + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
679 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
680 + * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
681 + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
682 + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
683 + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
684 + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
685 + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
686 + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
687 + * SUCH DAMAGE.
688 + *
689 + * This file is part of the lwIP TCP/IP stack.
690 + *
691 + * Author: Adam Dunkels <adam@sics.se>
692 + *
693 + * $Id: lw.diff,v 1.1 2002/05/20 22:24:22 jlarmour Exp $
694 + */
695 +#ifndef __ARCH_INIT_H__
696 +#define __ARCH_INIT_H__
697 +
698 +#define TCPIP_INIT_DONE(arg) sys_sem_signal(*(sys_sem_t *)arg)
699 +
700 +#endif /* __ARCH_INIT_H__ */
701 +
702 +
703 +
704 +
705 diff -Nur lwip-0.5.3/src/arch/ecos/include/arch/lib.h lwip.ecos/src/arch/ecos/include/arch/lib.h
706 --- lwip-0.5.3/src/arch/ecos/include/arch/lib.h Thu Jan 1 02:00:00 1970
707 +++ lwip.ecos/src/arch/ecos/include/arch/lib.h Thu Mar 14 23:27:00 2002
708 @@ -0,0 +1,38 @@
709 +/*
710 + * Copyright (c) 2001, Swedish Institute of Computer Science.
711 + * All rights reserved.
712 + *
713 + * Redistribution and use in source and binary forms, with or without
714 + * modification, are permitted provided that the following conditions
715 + * are met:
716 + * 1. Redistributions of source code must retain the above copyright
717 + * notice, this list of conditions and the following disclaimer.
718 + * 2. Redistributions in binary form must reproduce the above copyright
719 + * notice, this list of conditions and the following disclaimer in the
720 + * documentation and/or other materials provided with the distribution.
721 + * 3. Neither the name of the Institute nor the names of its contributors
722 + * may be used to endorse or promote products derived from this software
723 + * without specific prior written permission.
724 + *
725 + * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
726 + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
727 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
728 + * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
729 + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
730 + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
731 + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
732 + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
733 + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
734 + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
735 + * SUCH DAMAGE.
736 + *
737 + * This file is part of the lwIP TCP/IP stack.
738 + *
739 + * Author: Adam Dunkels <adam@sics.se>
740 + *
741 + * $Id: lw.diff,v 1.1 2002/05/20 22:24:22 jlarmour Exp $
742 + */
743 +#ifndef __ARCH_LIB_H__
744 +#define __ARCH_LIB_H__
745 +
746 +#endif /* __ARCH_LIB_H__ */
747 diff -Nur lwip-0.5.3/src/arch/ecos/include/arch/perf.h lwip.ecos/src/arch/ecos/include/arch/perf.h
748 --- lwip-0.5.3/src/arch/ecos/include/arch/perf.h Thu Jan 1 02:00:00 1970
749 +++ lwip.ecos/src/arch/ecos/include/arch/perf.h Wed Dec 12 00:00:00 2001
750 @@ -0,0 +1,41 @@
751 +/*
752 + * Copyright (c) 2001, Swedish Institute of Computer Science.
753 + * All rights reserved.
754 + *
755 + * Redistribution and use in source and binary forms, with or without
756 + * modification, are permitted provided that the following conditions
757 + * are met:
758 + * 1. Redistributions of source code must retain the above copyright
759 + * notice, this list of conditions and the following disclaimer.
760 + * 2. Redistributions in binary form must reproduce the above copyright
761 + * notice, this list of conditions and the following disclaimer in the
762 + * documentation and/or other materials provided with the distribution.
763 + * 3. Neither the name of the Institute nor the names of its contributors
764 + * may be used to endorse or promote products derived from this software
765 + * without specific prior written permission.
766 + *
767 + * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
768 + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
769 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
770 + * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
771 + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
772 + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
773 + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
774 + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
775 + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
776 + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
777 + * SUCH DAMAGE.
778 + *
779 + * This file is part of the lwIP TCP/IP stack.
780 + *
781 + * Author: Adam Dunkels <adam@sics.se>
782 + *
783 + * $Id: lw.diff,v 1.1 2002/05/20 22:24:22 jlarmour Exp $
784 + */
785 +#ifndef __PERF_H__
786 +#define __PERF_H__
787 +
788 +#define PERF_START /* null definition */
789 +#define PERF_STOP(x) /* null definition */
790 +
791 +#endif /* __PERF_H__ */
792 diff -Nur lwip-0.5.3/src/arch/ecos/include/arch/sys_arch.h lwip.ecos/src/arch/ecos/include/arch/sys_arch.h
793 --- lwip-0.5.3/src/arch/ecos/include/arch/sys_arch.h Thu Jan 1 02:00:00 1970
794 +++ lwip.ecos/src/arch/ecos/include/arch/sys_arch.h Thu Mar 14 23:53:00 2002
795 @@ -0,0 +1,13 @@
796 +#ifndef __SYS_ECOS_H__
797 +#define __SYS_ECOS_H__
798 +
799 +#include <cyg/kernel/kapi.h>
800 +
801 +#define SYS_MBOX_NULL (sys_mbox_t)NULL
802 +#define SYS_SEM_NULL (sys_sem_t)NULL
803 +
804 +typedef cyg_sem_t * sys_sem_t;
805 +typedef cyg_handle_t sys_mbox_t;
806 +typedef cyg_thread * sys_thread_t;
807 +#endif /* __SYS_ECOS_H__ */
808 +
809 diff -Nur lwip-0.5.3/src/arch/ecos/include/netif/ecosif.h lwip.ecos/src/arch/ecos/include/netif/ecosif.h
810 --- lwip-0.5.3/src/arch/ecos/include/netif/ecosif.h Thu Jan 1 02:00:00 1970
811 +++ lwip.ecos/src/arch/ecos/include/netif/ecosif.h Tue Mar 19 23:38:00 2002
812 @@ -0,0 +1,42 @@
813 +/*
814 + * Copyright (c) 2001, Swedish Institute of Computer Science.
815 + * All rights reserved.
816 + *
817 + * Redistribution and use in source and binary forms, with or without
818 + * modification, are permitted provided that the following conditions
819 + * are met:
820 + * 1. Redistributions of source code must retain the above copyright
821 + * notice, this list of conditions and the following disclaimer.
822 + * 2. Redistributions in binary form must reproduce the above copyright
823 + * notice, this list of conditions and the following disclaimer in the
824 + * documentation and/or other materials provided with the distribution.
825 + * 3. Neither the name of the Institute nor the names of its contributors
826 + * may be used to endorse or promote products derived from this software
827 + * without specific prior written permission.
828 + *
829 + * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
830 + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
831 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
832 + * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
833 + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
834 + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
835 + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
836 + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
837 + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
838 + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
839 + * SUCH DAMAGE.
840 + *
841 + * This file is part of the lwIP TCP/IP stack.
842 + *
843 + * Author: Adam Dunkels <adam@sics.se>
844 + *
845 + * $Id: lw.diff,v 1.1 2002/05/20 22:24:22 jlarmour Exp $
846 + */
847 +#ifndef __ECOSIF_H__
848 +#define __ECOSIF_H__
849 +
850 +#include "lwip/netif.h"
851 +
852 +void ecosif_init(struct netif *netif);
853 +
854 +#endif /* __ECOSIF_H__ */
855 diff -Nur lwip-0.5.3/src/arch/ecos/lib_arch.c lwip.ecos/src/arch/ecos/lib_arch.c
856 --- lwip-0.5.3/src/arch/ecos/lib_arch.c Thu Jan 1 02:00:00 1970
857 +++ lwip.ecos/src/arch/ecos/lib_arch.c Wed Dec 12 00:00:00 2001
858 @@ -0,0 +1,92 @@
859 +/*
860 + * Copyright (c) 2001, Swedish Institute of Computer Science.
861 + * All rights reserved.
862 + *
863 + * Redistribution and use in source and binary forms, with or without
864 + * modification, are permitted provided that the following conditions
865 + * are met:
866 + * 1. Redistributions of source code must retain the above copyright
867 + * notice, this list of conditions and the following disclaimer.
868 + * 2. Redistributions in binary form must reproduce the above copyright
869 + * notice, this list of conditions and the following disclaimer in the
870 + * documentation and/or other materials provided with the distribution.
871 + * 3. Neither the name of the Institute nor the names of its contributors
872 + * may be used to endorse or promote products derived from this software
873 + * without specific prior written permission.
874 + *
875 + * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
876 + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
877 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
878 + * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
879 + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
880 + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
881 + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
882 + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
883 + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
884 + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
885 + * SUCH DAMAGE.
886 + *
887 + * This file is part of the lwIP TCP/IP stack.
888 + *
889 + * Author: Adam Dunkels <adam@sics.se>
890 + *
891 + * $Id: lw.diff,v 1.1 2002/05/20 22:24:22 jlarmour Exp $
892 + */
893 +
894 +/* These are generic implementations of various library functions used
895 + * throughout the lwIP code. When porting, those should be optimized
896 + * for the particular processor architecture, preferably coded in
897 + * assembler.
898 + */
899 +
900 +#include "lwip/arch.h"
901 +
902 +u16_t
903 +htons(u16_t n)
904 +{
905 + return ((n & 0xff) << 8) | ((n & 0xff00) >> 8);
906 +}
907 +/*-----------------------------------------------------------------------------------*/
908 +u16_t
909 +ntohs(u16_t n)
910 +{
911 + return htons(n);
912 +}
913 +/*-----------------------------------------------------------------------------------*/
914 +u32_t
915 +htonl(u32_t n)
916 +{
917 + return ((n & 0xff) << 24) |
918 + ((n & 0xff00) << 8) |
919 + ((n & 0xff0000) >> 8) |
920 + ((n & 0xff000000) >> 24);
921 +}
922 +/*-----------------------------------------------------------------------------------*/
923 +u32_t
924 +ntohl(u32_t n)
925 +{
926 + return htonl(n);
927 +}
928 +/*-----------------------------------------------------------------------------------*/
929 +void
930 +bcopy(const void *src, void *dst, unsigned int size)
931 +{
932 + char *csrc, *cdst;
933 + unsigned int i;
934 +
935 + csrc = (char *)src;
936 + cdst = dst;
937 +
938 + for(i = 0; i < size; ++i) {
939 + cdst[i] = csrc[i];
940 + }
941 +}
942 +/*-----------------------------------------------------------------------------------*/
943 +void
944 +bzero(void *s, int n)
945 +{
946 + for(--n ;n >= 0; --n) {
947 + ((char *)s)[n] = 0;
948 + }
949 +}
950 +/*-----------------------------------------------------------------------------------*/
951 diff -Nur lwip-0.5.3/src/arch/ecos/netif/ecosif.c lwip.ecos/src/arch/ecos/netif/ecosif.c
952 --- lwip-0.5.3/src/arch/ecos/netif/ecosif.c Thu Jan 1 02:00:00 1970
953 +++ lwip.ecos/src/arch/ecos/netif/ecosif.c Tue Apr 2 16:13:46 2002
954 @@ -0,0 +1,327 @@
955 +/*
956 + * Copyright (c) 2001, Swedish Institute of Computer Science.
957 + * All rights reserved.
958 + *
959 + * Redistribution and use in source and binary forms, with or without
960 + * modification, are permitted provided that the following conditions
961 + * are met:
962 + * 1. Redistributions of source code must retain the above copyright
963 + * notice, this list of conditions and the following disclaimer.
964 + * 2. Redistributions in binary form must reproduce the above copyright
965 + * notice, this list of conditions and the following disclaimer in the
966 + * documentation and/or other materials provided with the distribution.
967 + * 3. Neither the name of the Institute nor the names of its contributors
968 + * may be used to endorse or promote products derived from this software
969 + * without specific prior written permission.
970 + *
971 + * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
972 + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
973 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
974 + * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
975 + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
976 + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
977 + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
978 + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
979 + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
980 + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
981 + * SUCH DAMAGE.
982 + *
983 + * This file is part of the lwIP TCP/IP stack.
984 + *
985 + * Author: Adam Dunkels <adam@sics.se>
986 + *
987 + * $Id: lw.diff,v 1.1 2002/05/20 22:24:22 jlarmour Exp $
988 + */
989 +
990 +#include "lwip/debug.h"
991 +
992 +#include "lwip/opt.h"
993 +#include "lwip/def.h"
994 +#include "lwip/ip.h"
995 +#include "lwip/mem.h"
996 +#include "lwip/pbuf.h"
997 +#include "lwip/sys.h"
998 +
999 +#include "netif/arp.h"
1000 +
1001 +
1002 +#define IFNAME0 'c'
1003 +#define IFNAME1 'y'
1004 +
1005 +static const struct eth_addr ethbroadcast = {{0xff,0xff,0xff,0xff,0xff,0xff}};
1006 +
1007 +struct ecosif {
1008 + struct eth_addr *ethaddr;
1009 + /* Add whatever per-interface state that is needed here. */
1010 +};
1011 +
1012 +static struct netif *this_netif;
1013 +
1014 +/* Forward declarations. */
1015 +static void ecosif_input(struct netif *netif, char*buf, int len);
1016 +static err_t ecosif_output(struct netif *netif, struct pbuf *p,
1017 + struct ip_addr *ipaddr);
1018 +
1019 +/* Entry points in the eCos hw independent driver */
1020 +extern void eth_drv_write(char *, char *, int);
1021 +extern void init_hw_drivers(unsigned char *hw_addr,void (*pig)(char *,int));
1022 +
1023 +/*
1024 + * This is called from eCos when data is read from the driver
1025 + */
1026 +void lwip_input(char *buf, int len)
1027 +{
1028 + ecosif_input((struct netif*)this_netif,buf,len);
1029 +}
1030 +
1031 +
1032 +extern void input_thread(void *arg);
1033 +
1034 +static void
1035 +low_level_init(struct netif *netif)
1036 +{
1037 + struct ecosif *ecosif;
1038 +
1039 + ecosif = netif->state;
1040 +
1041 + /* Init eCos low level driver which sets MAC address */
1042 + init_hw_drivers((unsigned char *)ecosif->ethaddr->addr,lwip_input);
1043 + printf("MAC address : %X:%X:%X:%X:%X:%X\n",
1044 + (unsigned char)(ecosif->ethaddr->addr[0]),
1045 + (unsigned char)(ecosif->ethaddr->addr[1]),
1046 + (unsigned char)(ecosif->ethaddr->addr[2]),
1047 + (unsigned char)(ecosif->ethaddr->addr[3]),
1048 + (unsigned char)(ecosif->ethaddr->addr[4]),
1049 + (unsigned char)(ecosif->ethaddr->addr[5]));
1050 + sys_thread_new(input_thread,(void*)"poll_thread");
1051 +}
1052 +/*
1053 + * low_level_output():
1054 + *
1055 + * Should do the actual transmission of the packet. The packet is
1056 + * contained in the pbuf that is passed to the function. This pbuf
1057 + * might be chained.We pass the data down to the eCos hw independent
1058 + * ethernet driver
1059 + */
1060 +
1061 +static err_t
1062 +low_level_output(struct ecosif *ecosif, struct pbuf *p)
1063 +{
1064 + struct pbuf *q;
1065 + char buf[1500];
1066 + char *bufptr;
1067 +
1068 + /* initiate transfer(); */
1069 + bufptr = &buf[0];
1070 +
1071 + for(q = p; q != NULL; q = q->next) {
1072 + /* Send the data from the pbuf to the interface, one pbuf at a
1073 + time. The size of the data in each pbuf is kept in the ->len
1074 + variable. */
1075 + /* send data from(q->payload, q->len); */
1076 + bcopy(q->payload, bufptr, q->len);
1077 + bufptr += q->len;
1078 + }
1079 +
1080 + /* signal that packet should be sent(); */
1081 + eth_drv_write(NULL, buf, p->tot_len);
1082 + return ERR_OK;
1083 +}
1084 +/*-----------------------------------------------------------------------------------*/
1085 +/*
1086 + * ecosif_output():
1087 + *
1088 + * This function is called by the TCP/IP stack when an IP packet
1089 + * should be sent. It calls the function called low_level_output() to
1090 + * do the actuall transmission of the packet.
1091 + *
1092 + */
1093 +/*-----------------------------------------------------------------------------------*/
1094 +static err_t
1095 +ecosif_output(struct netif *netif, struct pbuf *p,
1096 + struct ip_addr *ipaddr)
1097 +{
1098 + struct ecosif *ecosif;
1099 + struct pbuf *q;
1100 + struct eth_hdr *ethhdr;
1101 + struct eth_addr *dest, mcastaddr;
1102 + struct ip_addr *queryaddr;
1103 + err_t err;
1104 + u8_t i;
1105 +
1106 + ecosif = netif->state;
1107 +
1108 + /* Make room for Ethernet header. */
1109 + if(pbuf_header(p, sizeof(struct eth_hdr)) != 0) {
1110 + /* The pbuf_header() call shouldn't fail, but we allocate an extra
1111 + pbuf just in case. */
1112 + q = pbuf_alloc(PBUF_LINK, sizeof(struct eth_hdr), PBUF_RAM);
1113 + if(q == NULL) {
1114 + return ERR_MEM;
1115 + }
1116 + pbuf_chain(q, p);
1117 + p = q;
1118 + }
1119 +
1120 + /* Construct Ethernet header. Start with looking up deciding which
1121 + MAC address to use as a destination address. Broadcasts and
1122 + multicasts are special, all other addresses are looked up in the
1123 + ARP table. */
1124 + queryaddr = ipaddr;
1125 + if(ip_addr_isany(ipaddr) ||
1126 + ip_addr_isbroadcast(ipaddr, &(netif->netmask))) {
1127 + dest = (struct eth_addr *)&ethbroadcast;
1128 + } else if(ip_addr_ismulticast(ipaddr)) {
1129 + /* Hash IP multicast address to MAC address. */
1130 + mcastaddr.addr[0] = 0x01;
1131 + mcastaddr.addr[1] = 0x0;
1132 + mcastaddr.addr[2] = 0x5e;
1133 + mcastaddr.addr[3] = ip4_addr2(ipaddr) & 0x7f;
1134 + mcastaddr.addr[4] = ip4_addr3(ipaddr);
1135 + mcastaddr.addr[5] = ip4_addr4(ipaddr);
1136 + dest = &mcastaddr;
1137 + } else {
1138 + if(ip_addr_maskcmp(ipaddr, &(netif->ip_addr), &(netif->netmask))) {
1139 + /* Use destination IP address if the destination is on the same
1140 + subnet as we are. */
1141 + queryaddr = ipaddr;
1142 + } else {
1143 + /* Otherwise we use the default router as the address to send
1144 + the Ethernet frame to. */
1145 + queryaddr = &(netif->gw);
1146 + }
1147 + dest = arp_lookup(queryaddr);
1148 + }
1149 +
1150 +
1151 + /* If the arp_lookup() didn't find an address, we send out an ARP
1152 + query for the IP address. */
1153 + if(dest == NULL) {
1154 + q = arp_query(netif, ecosif->ethaddr, queryaddr);
1155 + if(q != NULL) {
1156 + printf("Sending ARP after query\n");
1157 + err = low_level_output(ecosif, q);
1158 + pbuf_free(q);
1159 + return err;
1160 + }
1161 + return ERR_MEM;
1162 + }
1163 + ethhdr = p->payload;
1164 +
1165 + for(i = 0; i < 6; i++) {
1166 + ethhdr->dest.addr[i] = dest->addr[i];
1167 + ethhdr->src.addr[i] = ecosif->ethaddr->addr[i];
1168 + }
1169 +
1170 + ethhdr->type = htons(ETHTYPE_IP);
1171 +
1172 + return low_level_output(ecosif, p);
1173 +
1174 +}
1175 +
1176 +
1177 +
1178 +/*
1179 + * ecosif_input():
1180 + * This function is called when the eCos hw independent driver
1181 + * has some data to pass up to lwIP.It does it through lwip_input.
1182 + */
1183 +
1184 +static void
1185 +ecosif_input(struct netif *netif, char * bufptr, int len)
1186 +{
1187 + struct ecosif *ecosif;
1188 + struct eth_hdr *ethhdr;
1189 + struct pbuf *p, *q;
1190 +
1191 + ecosif = netif->state;
1192 + /* We allocate a pbuf chain of pbufs from the pool. */
1193 + p = pbuf_alloc(PBUF_LINK, len, PBUF_POOL);
1194 +
1195 + if(p != NULL) {
1196 + /* We iterate over the pbuf chain until we have read the entire
1197 + packet into the pbuf. */
1198 + for(q = p; q != NULL; q = q->next) {
1199 + /* Read enough bytes to fill this pbuf in the chain. The
1200 + avaliable data in the pbuf is given by the q->len
1201 + variable. */
1202 + /* read data into(q->payload, q->len); */
1203 + bcopy(bufptr, q->payload, q->len);
1204 + bufptr += q->len;
1205 + }
1206 + /* acknowledge that packet has been read(); */
1207 + } else {
1208 + /* drop packet(); */
1209 + }
1210 +
1211 + if(p == NULL) {
1212 + DEBUGF(ECOSIF_DEBUG, ("ecosif_input: low_level_input returned NULL\n"));
1213 + return;
1214 + }
1215 + ethhdr = p->payload;
1216 +
1217 + switch(htons(ethhdr->type)) {
1218 + case ETHTYPE_IP:
1219 + DEBUGF(ECOSIF_DEBUG, ("ecosif_input: IP packet\n"));
1220 + arp_ip_input(netif, p);
1221 + pbuf_header(p, -14);
1222 +#if LWIP_DEBUG
1223 + if(ip_lookup(p->payload, netif)) {
1224 +#endif
1225 + netif->input(p, netif);
1226 +#if LWIP_DEBUG
1227 + } else {
1228 + printf("ecosif_input: lookup failed!\n");
1229 + }
1230 +#endif
1231 + break;
1232 + case ETHTYPE_ARP:
1233 + DEBUGF(ECOSIF_DEBUG, ("ecosif_input: ARP packet\n"));
1234 + p = arp_arp_input(netif, ecosif->ethaddr, p);
1235 + if(p != NULL) {
1236 + DEBUGF(ECOSIF_DEBUG, ("ecosif_input: Sending ARP reply\n"));
1237 + low_level_output(ecosif, p);
1238 + pbuf_free(p);
1239 + }
1240 + break;
1241 + default:
1242 + pbuf_free(p);
1243 + break;
1244 + }
1245 +}
1246 +/*-----------------------------------------------------------------------------------*/
1247 +static void
1248 +arp_timer(void *arg)
1249 +{
1250 + arp_tmr();
1251 + sys_timeout(ARP_TMR_INTERVAL, (sys_timeout_handler)arp_timer, NULL);
1252 +}
1253 +/*-----------------------------------------------------------------------------------*/
1254 +/*
1255 + * ecosif_init():
1256 + *
1257 + * Should be called at the beginning of the program to set up the
1258 + * network interface. It calls the function low_level_init() to do the
1259 + * actual setup of the hardware.
1260 + *
1261 + */
1262 +/*-----------------------------------------------------------------------------------*/
1263 +void
1264 +ecosif_init(struct netif *netif)
1265 +{
1266 + struct ecosif *ecosif;
1267 +
1268 + this_netif = netif;
1269 + ecosif = mem_malloc(sizeof(struct ecosif));
1270 + netif->state = ecosif;
1271 + netif->name[0] = IFNAME0;
1272 + netif->name[1] = IFNAME1;
1273 + netif->output = ecosif_output;
1274 +
1275 + ecosif->ethaddr = (struct eth_addr *)&(netif->hwaddr[0]);
1276 + low_level_init(netif);
1277 + arp_init();
1278 +
1279 + sys_timeout(ARP_TMR_INTERVAL, (sys_timeout_handler)arp_timer, NULL);
1280 +}
1281 +/*-----------------------------------------------------------------------------------*/
1282 diff -Nur lwip-0.5.3/src/arch/ecos/sys_arch.c lwip.ecos/src/arch/ecos/sys_arch.c
1283 --- lwip-0.5.3/src/arch/ecos/sys_arch.c Thu Jan 1 02:00:00 1970
1284 +++ lwip.ecos/src/arch/ecos/sys_arch.c Tue Apr 2 19:05:58 2002
1285 @@ -0,0 +1,181 @@
1286 +/*
1287 + * This file implements the eCos specific sys_arch functions used by lwIP
1288 + */
1289 +
1290 +#include <cyg/kernel/kapi.h>
1291 +
1292 +#include "lwip/sys.h"
1293 +#include "lwip/def.h"
1294 +#include "lwip/debug.h"
1295 +
1296 +//FIXME use CYG_HWR_whatever for RTC
1297 +
1298 +/* lwIp timeouts are milliseconds, eCos time unit is clock tick */
1299 +//1s = 1000ms = 100ticks (eCos default is 100 tick per second for most(all?) platforms)
1300 +#define tick_to_msec(tick) ((u16_t)(tick*10+1))
1301 +#define msec_to_tick(msec) ((cyg_tick_count_t)(msec+9)/10)
1302 +
1303 +/* We use a common var mempool for allocating semaphores, mboxes and threads... */
1304 +#define VARMEMPOOLSIZE 0x4000 /* tunable */
1305 +static char memvar[VARMEMPOOLSIZE];
1306 +static cyg_mempool_var var_mempool;
1307 +static cyg_handle_t var_mempool_h;
1308 +
1309 +/* ...and a fix mempool for allocating thread stacks */
1310 +
1311 +#define LWIP_THREAD_STACK_SIZE 0x2000 /* tunable */
1312 +#define MAX_THREADS 4 /* tunable */
1313 +
1314 +static char memfix[LWIP_THREAD_STACK_SIZE * MAX_THREADS];
1315 +static cyg_mempool_fix fix_mempool;
1316 +static cyg_handle_t fix_mempool_h;
1317 +
1318 +/* List of threads: associate eCos thread info with lwIP timeout info */
1319 +struct lwip_thread {
1320 + struct lwip_thread * next;
1321 + struct sys_timeouts to;
1322 + cyg_handle_t th;
1323 + cyg_thread t;
1324 +} *threads;
1325 +
1326 +/*FIXME: the timeout struct used for non-lwIP threads -eCos
1327 + * there might be threads which are not created through
1328 + * sys_thread_new but access lwIP stuff (i.e. net interrupt)
1329 + * This must go away.
1330 + * */
1331 +struct sys_timeouts global_timeout;
1332 +
1333 +/* Set up memory pools and threads*/
1334 +void sys_init(void)
1335 +{
1336 + cyg_mempool_var_create(memvar, sizeof(memvar), &var_mempool_h, &var_mempool);
1337 +
1338 + cyg_mempool_fix_create(memfix, sizeof(memfix),
1339 + LWIP_THREAD_STACK_SIZE, &fix_mempool_h, &fix_mempool);
1340 + threads = NULL;
1341 + global_timeout.next = NULL;
1342 +}
1343 +
1344 +/* Message boxes */
1345 +
1346 +sys_mbox_t sys_mbox_new(void)
1347 +{
1348 + cyg_mbox * mbox;
1349 + cyg_handle_t m;
1350 + mbox = (cyg_mbox *)cyg_mempool_var_alloc(var_mempool_h, sizeof(cyg_mbox));
1351 + cyg_mbox_create(&m, mbox);
1352 + return m;
1353 +}
1354 +
1355 +void sys_mbox_free(sys_mbox_t mbox)
1356 +{
1357 + cyg_mbox_delete(mbox);
1358 +}
1359 +
1360 +//FIXME returns false maybe retry?
1361 +void sys_mbox_post(sys_mbox_t mbox, void *data)
1362 +{
1363 +#if 0
1364 + if (cyg_mbox_put(mbox, data)==false)
1365 + printf("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAaaa\n");
1366 +#endif
1367 + cyg_mbox_put(mbox,data);
1368 +}
1369 +
1370 +u16_t sys_arch_mbox_fetch(sys_mbox_t mbox, void **data, u16_t timeout)
1371 +{
1372 + void *d;
1373 + cyg_tick_count_t end_time, start_time,lool;
1374 + static int pig = 0;
1375 + if (timeout) {
1376 + start_time = cyg_current_time();
1377 + lool = start_time + msec_to_tick(timeout);
1378 + d = cyg_mbox_timed_get(mbox, lool);
1379 + end_time = cyg_current_time();
1380 +
1381 + if (d == NULL)
1382 + return 0;
1383 + } else {
1384 + d = cyg_mbox_get(mbox);
1385 + }
1386 + *data = d;
1387 + return tick_to_msec(end_time - start_time);
1388 +}
1389 +
1390 +/* Semaphores */
1391 +
1392 +sys_sem_t sys_sem_new(u8_t count)
1393 +{
1394 + sys_sem_t sem;
1395 +
1396 + sem = (cyg_sem_t *)cyg_mempool_var_alloc(var_mempool_h, sizeof(cyg_sem_t));
1397 + cyg_semaphore_init(sem, count);
1398 + return sem;
1399 +}
1400 +
1401 +u16_t sys_arch_sem_wait(sys_sem_t sem, u16_t timeout)
1402 +{
1403 + cyg_bool_t r;
1404 + cyg_tick_count_t end_time, start_time;
1405 +
1406 + if (timeout) {
1407 + start_time = cyg_current_time();
1408 + r = cyg_semaphore_timed_wait(sem, start_time + msec_to_tick(timeout));
1409 + end_time = cyg_current_time();
1410 +
1411 + if (r == false)
1412 + return 0;
1413 + } else {
1414 + cyg_semaphore_wait(sem);
1415 + }
1416 +
1417 + return tick_to_msec(end_time - start_time);
1418 +}
1419 +
1420 +void sys_sem_signal(sys_sem_t sem)
1421 +{
1422 + cyg_semaphore_post(sem);
1423 +}
1424 +
1425 +void sys_sem_free(sys_sem_t sem)
1426 +{
1427 + cyg_semaphore_destroy(sem);
1428 +}
1429 +
1430 +/* Thread creation */
1431 +
1432 +void sys_thread_new(void (*function) (void *arg), void *arg)
1433 +{
1434 + struct lwip_thread * nt;
1435 + void * stack;
1436 +
1437 + nt = (struct lwip_thread *)cyg_mempool_var_alloc(var_mempool_h, sizeof(struct lwip_thread));
1438 +
1439 + nt->next = threads;
1440 + nt->to.next = NULL;
1441 +
1442 + threads = nt;
1443 +
1444 + stack = cyg_mempool_fix_alloc(fix_mempool_h);
1445 +
1446 + cyg_thread_create(12, (cyg_thread_entry_t *)function, (cyg_addrword_t)arg,
1447 + (char *)arg , stack, LWIP_THREAD_STACK_SIZE, &(nt->th), &(nt->t) );
1448 +
1449 + cyg_thread_resume(nt->th);
1450 +}
1451 +
1452 +/* Find current thread's timeout info */
1453 +
1454 +struct sys_timeouts *sys_arch_timeouts(void)
1455 +{
1456 + cyg_handle_t ct;
1457 + struct lwip_thread *t;
1458 +
1459 + ct = cyg_thread_self();
1460 + for(t = threads; t; t = t->next)
1461 + if (t->th == ct)
1462 + return &(t->to);
1463 +
1464 + printf("tmobad@@@@@\n");
1465 + return &global_timeout;
1466 +}