Browse Source
they are unmaintained since about 10 years now. If someone needs them, download the old archivesmaster
92 changed files with 0 additions and 13817 deletions
@ -1,54 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001-2003 Swedish Institute of Computer Science. |
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met: |
||||
* |
||||
* 1. Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, |
||||
* this list of conditions and the following disclaimer in the documentation |
||||
* and/or other materials provided with the distribution. |
||||
* 3. The name of the author may not be used to endorse or promote products |
||||
* derived from this software without specific prior written permission.
|
||||
* |
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE. |
||||
* |
||||
* This file is part of the lwIP TCP/IP stack. |
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se> |
||||
* |
||||
*/ |
||||
#ifndef __CC_H__ |
||||
#define __CC_H__ |
||||
|
||||
typedef unsigned char u8_t; |
||||
typedef signed char s8_t; |
||||
typedef unsigned short u16_t; |
||||
typedef signed short s16_t; |
||||
typedef unsigned long u32_t; |
||||
typedef signed long s32_t; |
||||
|
||||
#define U16_F "hu" |
||||
#define S16_F "hd" |
||||
#define X16_F "hx" |
||||
#define U32_F "lu" |
||||
#define S32_F "ld" |
||||
#define X32_F "lx" |
||||
|
||||
#define PACK_STRUCT_BEGIN |
||||
#define PACK_STRUCT_STRUCT |
||||
#define PACK_STRUCT_END |
||||
#define PACK_STRUCT_FIELD(x) x |
||||
|
||||
#endif /* __CC_H__ */ |
||||
@ -1,37 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001-2003 Swedish Institute of Computer Science. |
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met: |
||||
* |
||||
* 1. Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, |
||||
* this list of conditions and the following disclaimer in the documentation |
||||
* and/or other materials provided with the distribution. |
||||
* 3. The name of the author may not be used to endorse or promote products |
||||
* derived from this software without specific prior written permission.
|
||||
* |
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE. |
||||
* |
||||
* This file is part of the lwIP TCP/IP stack. |
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se> |
||||
* |
||||
*/ |
||||
#ifndef __CPU_H__ |
||||
#define __CPU_H__ |
||||
|
||||
#define BYTE_ORDER LITTLE_ENDIAN |
||||
|
||||
#endif /* __CPU_H__ */ |
||||
@ -1,38 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001-2003 Swedish Institute of Computer Science. |
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met: |
||||
* |
||||
* 1. Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, |
||||
* this list of conditions and the following disclaimer in the documentation |
||||
* and/or other materials provided with the distribution. |
||||
* 3. The name of the author may not be used to endorse or promote products |
||||
* derived from this software without specific prior written permission.
|
||||
* |
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE. |
||||
* |
||||
* This file is part of the lwIP TCP/IP stack. |
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se> |
||||
* |
||||
*/ |
||||
#ifndef __LIB_H__ |
||||
#define __LIB_H__ |
||||
|
||||
int strlen(const char *str); |
||||
int strncmp(const char *str1, const char *str2, int len); |
||||
|
||||
#endif /* __LIB_H__ */ |
||||
@ -1,38 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001-2003 Swedish Institute of Computer Science. |
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met: |
||||
* |
||||
* 1. Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, |
||||
* this list of conditions and the following disclaimer in the documentation |
||||
* and/or other materials provided with the distribution. |
||||
* 3. The name of the author may not be used to endorse or promote products |
||||
* derived from this software without specific prior written permission.
|
||||
* |
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE. |
||||
* |
||||
* This file is part of the lwIP TCP/IP stack. |
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se> |
||||
* |
||||
*/ |
||||
#ifndef __PERF_H__ |
||||
#define __PERF_H__ |
||||
|
||||
#define PERF_START /* null definition */ |
||||
#define PERF_STOP(x) /* null definition */ |
||||
|
||||
#endif /* __PERF_H__ */ |
||||
@ -1,41 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001-2003 Swedish Institute of Computer Science. |
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met: |
||||
* |
||||
* 1. Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, |
||||
* this list of conditions and the following disclaimer in the documentation |
||||
* and/or other materials provided with the distribution. |
||||
* 3. The name of the author may not be used to endorse or promote products |
||||
* derived from this software without specific prior written permission.
|
||||
* |
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE. |
||||
* |
||||
* This file is part of the lwIP TCP/IP stack. |
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se> |
||||
* |
||||
*/ |
||||
#ifndef __SYS_C64_H__ |
||||
#define __SYS_C64_H__ |
||||
|
||||
#define SYS_MBOX_NULL 0 |
||||
|
||||
typedef int sys_sem_t; |
||||
typedef int sys_mbox_t; |
||||
typedef int sys_thread_t; |
||||
|
||||
#endif /* __SYS_C64_H__ */ |
||||
@ -1,39 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001-2003 Swedish Institute of Computer Science. |
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met: |
||||
* |
||||
* 1. Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, |
||||
* this list of conditions and the following disclaimer in the documentation |
||||
* and/or other materials provided with the distribution. |
||||
* 3. The name of the author may not be used to endorse or promote products |
||||
* derived from this software without specific prior written permission.
|
||||
* |
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE. |
||||
* |
||||
* This file is part of the lwIP TCP/IP stack. |
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se> |
||||
* |
||||
*/ |
||||
|
||||
/* These are generic implementations of various library functions used
|
||||
* throughout the lwIP code. When porting, those should be optimized |
||||
* for the particular processor architecture, preferably coded in |
||||
* assembler. |
||||
*/ |
||||
|
||||
|
||||
@ -1,121 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001-2003 Swedish Institute of Computer Science. |
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met: |
||||
* |
||||
* 1. Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, |
||||
* this list of conditions and the following disclaimer in the documentation |
||||
* and/or other materials provided with the distribution. |
||||
* 3. The name of the author may not be used to endorse or promote products |
||||
* derived from this software without specific prior written permission.
|
||||
* |
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE. |
||||
* |
||||
* This file is part of the lwIP TCP/IP stack. |
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se> |
||||
* |
||||
*/ |
||||
|
||||
#include <c64.h> |
||||
#include <time.h> |
||||
|
||||
#include "lwip/sys.h" |
||||
#include "lwip/def.h" |
||||
|
||||
struct sys_timeouts timeouts; |
||||
|
||||
/*-----------------------------------------------------------------------------------*/ |
||||
void |
||||
sys_arch_block(u16_t time) |
||||
{ |
||||
u16_t ticks; |
||||
|
||||
ticks = time * (CLK_TCK / 1000) + clock(); |
||||
printf("ticks %d\n", ticks); |
||||
|
||||
while (clock() != ticks);
|
||||
} |
||||
/*-----------------------------------------------------------------------------------*/ |
||||
sys_mbox_t |
||||
sys_mbox_new(void) |
||||
{ |
||||
return SYS_MBOX_NULL; |
||||
} |
||||
/*-----------------------------------------------------------------------------------*/ |
||||
void |
||||
sys_mbox_free(sys_mbox_t mbox) |
||||
{ |
||||
return; |
||||
} |
||||
/*-----------------------------------------------------------------------------------*/ |
||||
void |
||||
sys_mbox_post(sys_mbox_t mbox, void *data) |
||||
{ |
||||
return; |
||||
} |
||||
/*-----------------------------------------------------------------------------------*/ |
||||
u16_t
|
||||
sys_arch_mbox_fetch(sys_mbox_t mbox, void **data, u16_t timeout) |
||||
{ |
||||
sys_arch_block(timeout); |
||||
return 0; |
||||
} |
||||
/*-----------------------------------------------------------------------------------*/ |
||||
sys_sem_t |
||||
sys_sem_new(u8_t count) |
||||
{ |
||||
return 0; |
||||
} |
||||
/*-----------------------------------------------------------------------------------*/ |
||||
u16_t |
||||
sys_arch_sem_wait(sys_sem_t sem, u16_t timeout) |
||||
{ |
||||
sys_arch_block(timeout); |
||||
return 0; |
||||
} |
||||
/*-----------------------------------------------------------------------------------*/ |
||||
void |
||||
sys_sem_signal(sys_sem_t sem) |
||||
{ |
||||
return; |
||||
} |
||||
/*-----------------------------------------------------------------------------------*/ |
||||
void |
||||
sys_sem_free(sys_sem_t sem) |
||||
{ |
||||
return; |
||||
} |
||||
/*-----------------------------------------------------------------------------------*/ |
||||
void |
||||
sys_init(void) |
||||
{ |
||||
timeouts.next = NULL; |
||||
return; |
||||
} |
||||
/*-----------------------------------------------------------------------------------*/ |
||||
struct sys_timeouts * |
||||
sys_arch_timeouts(void) |
||||
{ |
||||
return &timeouts; |
||||
} |
||||
/*-----------------------------------------------------------------------------------*/ |
||||
sys_thread_t |
||||
sys_thread_new(char *name, void (* function)(void *arg), void *arg, int stacksize, int prio) |
||||
{ |
||||
return 0; |
||||
} |
||||
/*-----------------------------------------------------------------------------------*/ |
||||
@ -1,34 +0,0 @@
|
||||
This directory contains ports that are no longer actively maintained. |
||||
|
||||
6502/ - Architectural files for the 6502 CPU. |
||||
|
||||
c16x/ - Architectural files for the C16x/ST10 uC. |
||||
Supports lwIP Raw API only. |
||||
CS8900a Ethernet driver for 16-bit mode. |
||||
|
||||
rtxc/ - Architectural files for the RTXC operating system. |
||||
|
||||
v2pro/ - Architectural files for the Xilinx Virtex-II PRO device with |
||||
embedded PowerPC 405 Processor. Supports lwIP Raw API only. |
||||
(requires EDK - http://www.xilinx.com/ise/embedded/edk.htm) |
||||
|
||||
coldfire/ - Architectural files for Motorola Coldfire 5272 CPU running |
||||
under Nucleus OS. Supports DMA and ISRs in ethernet driver. |
||||
|
||||
ti_c6711/ - Architectural files for TI TMS320C6000 DSP running under uC/OS-II. |
||||
Supports lwIP Raw API only. |
||||
It's done with an 10/100M ethernet daughtercard. |
||||
[more info at https://sourceforge.net/projects/ucos-lwip-c6x/] |
||||
|
||||
|
||||
Each subdirectory (may) also include: |
||||
|
||||
perf.c - Optional file that should be implemented when running |
||||
performance tests of lwIP. |
||||
|
||||
sys.c - Implementation of the operating system emulation layer. |
||||
|
||||
include/ - Architectural specific header files. |
||||
|
||||
netif/ - Architectural specific network interfaces. |
||||
|
||||
@ -1,13 +0,0 @@
|
||||
This directory contains architecture and compiler specific stuff for porting lwIP |
||||
to the C16x and ST10 microcontrollers. The compiler specifics are for Tasking EDE |
||||
v7.5r2. |
||||
|
||||
The sequential API has not been ported; its functions are empties. If someone is |
||||
interested in adding a sequential API, please contact the author (see below). |
||||
|
||||
Besides this, a Cirrus (formerly Crystal Semiconductors) CS8900a Ethernet driver |
||||
is included, which assumes a 16-bit data bus configuration. When porting this |
||||
driver, note that the CS8900a does not support interrupts in 8-bit mode. |
||||
|
||||
Leon Woestenberg |
||||
<leon.woestenberg@axon.tv> |
||||
@ -1,65 +0,0 @@
|
||||
#ifndef __CC_H__ |
||||
#define __CC_H__ |
||||
|
||||
/* memset(), memcpy() */ |
||||
#include <string.h> |
||||
/* printf() and abort() */ |
||||
#include <stdio.h> |
||||
#include <stdlib.h> |
||||
/* isdigit() */ |
||||
#include <ctype.h> |
||||
|
||||
#include "arch/cpu.h" |
||||
|
||||
typedef unsigned char u8_t; |
||||
typedef signed char s8_t; |
||||
typedef unsigned short u16_t; |
||||
typedef signed short s16_t; |
||||
typedef unsigned long u32_t; |
||||
typedef signed long s32_t; |
||||
|
||||
typedef u32_t mem_ptr_t; |
||||
|
||||
/* Define (sn)printf formatters for these lwIP types */ |
||||
#define U16_F "hu" |
||||
#define S16_F "hd" |
||||
#define X16_F "hx" |
||||
#define U32_F "lu" |
||||
#define S32_F "ld" |
||||
#define X32_F "lx" |
||||
|
||||
/* LW: Supported in at least >=v7.5 r2, but lwIP worked without the "_packed" attribute already */ |
||||
#define PACK_STRUCT_BEGIN _packed |
||||
#define PACK_STRUCT_STRUCT |
||||
#define PACK_STRUCT_END |
||||
#define PACK_STRUCT_FIELD(x) x |
||||
|
||||
#define LWIP_PLATFORM_BYTESWAP 1 |
||||
#define LWIP_PLATFORM_HTONS(x) _ror(x,8) |
||||
#define LWIP_PLATFORM_HTONL(x) c16x_htonl(x) |
||||
|
||||
_inline u32_t c16x_htonl(u32_t n) |
||||
{ |
||||
u16_t msw, lsw; |
||||
|
||||
msw = n >> 16; |
||||
msw = _ror(msw,8); |
||||
lsw = n; |
||||
lsw = _ror(lsw,8); |
||||
n = ((u32_t)lsw << 16) | (u32_t)msw; |
||||
return n; |
||||
} |
||||
|
||||
#ifdef LWIP_DEBUG |
||||
|
||||
/* LW: forward declaration */ |
||||
void debug_printf(char *format, ...); |
||||
void page_printf(char *format, ...); |
||||
|
||||
/* Plaform specific diagnostic output */ |
||||
#define LWIP_PLATFORM_DIAG(x) { debug_printf x; } |
||||
#define LWIP_PLATFORM_ASSERT(x) { debug_printf("\fline %d in %s\n", __LINE__, __FILE__); while(1); } |
||||
|
||||
#endif/* LWIP_DEBUG */ |
||||
|
||||
#endif /* __CC_H__ */ |
||||
@ -1,6 +0,0 @@
|
||||
#ifndef __CPU_H__ |
||||
#define __CPU_H__ |
||||
|
||||
#define BYTE_ORDER LITTLE_ENDIAN |
||||
|
||||
#endif /* __CPU_H__ */ |
||||
@ -1,39 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001, Swedish Institute of Computer Science. |
||||
* All rights reserved.
|
||||
* |
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the Institute nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
* |
||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
* |
||||
* This file is part of the lwIP TCP/IP stack. |
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se> |
||||
* |
||||
* $Id: lib.h,v 1.1 2007/06/14 12:33:57 kieranm Exp $ |
||||
*/ |
||||
#ifndef __LIB_H__ |
||||
#define __LIB_H__ |
||||
|
||||
|
||||
#endif /* __LIB_H__ */ |
||||
@ -1,41 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001, Swedish Institute of Computer Science. |
||||
* All rights reserved.
|
||||
* |
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the Institute nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
* |
||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
* |
||||
* This file is part of the lwIP TCP/IP stack. |
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se> |
||||
* |
||||
* $Id: perf.h,v 1.1 2007/06/14 12:33:57 kieranm Exp $ |
||||
*/ |
||||
#ifndef __PERF_H__ |
||||
#define __PERF_H__ |
||||
|
||||
#define PERF_START /* null definition */ |
||||
#define PERF_STOP(x) /* null definition */ |
||||
|
||||
#endif /* __PERF_H__ */ |
||||
@ -1,82 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001-2003 Leon Woestenberg <leon.woestenberg@axon.tv> |
||||
* Copyright (c) 2001-2003 Axon Digital Design B.V., The Netherlands. |
||||
* All rights reserved. |
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met: |
||||
* |
||||
* 1. Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, |
||||
* this list of conditions and the following disclaimer in the documentation |
||||
* and/or other materials provided with the distribution. |
||||
* 3. The name of the author may not be used to endorse or promote products |
||||
* derived from this software without specific prior written permission.
|
||||
* |
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE. |
||||
* |
||||
* This file is part of the lwIP TCP/IP stack. |
||||
*
|
||||
* Author: Leon Woestenberg <leon.woestenberg@axon.tv> |
||||
* |
||||
* This is a device driver for the Crystal Semiconductor CS8900 |
||||
* chip in combination with the lwIP stack. |
||||
* |
||||
* This is work under development. Please coordinate changes |
||||
* and requests with Leon Woestenberg <leon.woestenberg@axon.tv> |
||||
* |
||||
* The Swedish Institute of Computer Science and Adam Dunkels |
||||
* are specifically granted permission to redistribute this |
||||
* source code under any conditions they seem fit. |
||||
* |
||||
*/ |
||||
#ifndef __NETIF_CS8900IF_H__ |
||||
#define __NETIF_CS8900IF_H__ |
||||
|
||||
#include "lwip/netif.h" |
||||
|
||||
/* interface statistics gathering
|
||||
* such as collisions, dropped packets, missed packets |
||||
* 0 = no statistics, minimal memory requirements, no overhead
|
||||
* 1 = statistics on, but some have large granularity (0x200), very low overhead |
||||
* 2 = statistics on, updated on every call to cs8900_service(), low overhead |
||||
*/ |
||||
#define CS8900_STATS 2 |
||||
|
||||
/* Number of ISQ events that may be serviced by cs8900_service() (at least 1) */ |
||||
#define CS8900_EVTS2SRV 10 |
||||
|
||||
struct cs8900if |
||||
{ |
||||
//struct eth_addr *ethaddr;
|
||||
volatile u8_t needs_service; |
||||
u8_t use_polling; |
||||
#if (CS8900_STATS > 0) |
||||
u32_t interrupts; // #interrupt requests of cs8900
|
||||
u32_t missed; // #packets on medium that could not enter cs8900a chip due to buffer shortage
|
||||
u32_t dropped; // #packets dropped after they have been received in chip buffer
|
||||
u32_t collisions; // #collisions on medium when transmitting packets
|
||||
u32_t sentpackets; // #number of sent packets
|
||||
u32_t sentbytes; // #number of sent bytes
|
||||
#endif |
||||
/* Add whatever per-interface state that is needed here. */ |
||||
}; |
||||
|
||||
void cs8900if_reset(struct netif *netif); |
||||
err_t cs8900if_init(struct netif *); |
||||
void cs8900if_service(struct netif *); |
||||
void cs8900if_input(struct netif *netif); |
||||
|
||||
void cs8900_send_debug(u8_t *p, u16_t len); |
||||
|
||||
#endif /* __NETIF_CS8900IF_H__ */ |
||||
@ -1,73 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001, Swedish Institute of Computer Science. |
||||
* All rights reserved.
|
||||
* |
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the Institute nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
* |
||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
* |
||||
* This file is part of the lwIP TCP/IP stack. |
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se> |
||||
* |
||||
* $Id: lib.c,v 1.1 2007/06/14 12:33:57 kieranm Exp $ |
||||
*/ |
||||
|
||||
/* These are generic implementations of various library functions used
|
||||
* throughout the lwIP code. When porting, those should be optimized |
||||
* for the particular processor architecture, preferably coded in |
||||
* assembler. |
||||
*/ |
||||
|
||||
#include "lwip/arch.h" |
||||
|
||||
#if BYTE_ORDER == LITTLE_ENDIAN |
||||
/*-----------------------------------------------------------------------------------*/ |
||||
u16_t |
||||
htons(u16_t n) |
||||
{ |
||||
return ((n & 0xff) << 8) | ((n & 0xff00) >> 8); |
||||
} |
||||
/*-----------------------------------------------------------------------------------*/ |
||||
u16_t |
||||
ntohs(u16_t n) |
||||
{ |
||||
return htons(n); |
||||
} |
||||
/*-----------------------------------------------------------------------------------*/ |
||||
u32_t |
||||
htonl(u32_t n) |
||||
{ |
||||
return ((n & 0xff) << 24) | |
||||
((n & 0xff00) << 8) | |
||||
((n & 0xff0000) >> 8) | |
||||
((n & 0xff000000) >> 24); |
||||
} |
||||
/*-----------------------------------------------------------------------------------*/ |
||||
u32_t |
||||
ntohl(u32_t n) |
||||
{ |
||||
return htonl(n); |
||||
} |
||||
/*-----------------------------------------------------------------------------------*/ |
||||
#endif /* BYTE_ORDER == LITTLE_ENDIAN */ |
||||
@ -1,939 +0,0 @@
|
||||
/** @file
|
||||
* |
||||
* Ethernet network driver for IP |
||||
*/ |
||||
/*
|
||||
* Copyright (c) 2001-2003 Leon Woestenberg <leon.woestenberg@axon.tv> |
||||
* Copyright (c) 2001-2003 Axon Digital Design B.V., The Netherlands. |
||||
* All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without modification, |
||||
* are permitted provided that the following conditions are met: |
||||
* |
||||
* 1. Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, |
||||
* this list of conditions and the following disclaimer in the documentation |
||||
* and/or other materials provided with the distribution. |
||||
* 3. The name of the author may not be used to endorse or promote products |
||||
* derived from this software without specific prior written permission. |
||||
* |
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED |
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT |
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT |
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING |
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY |
||||
* OF SUCH DAMAGE. |
||||
* |
||||
* This file is part of the lwIP TCP/IP stack. |
||||
* |
||||
* Author: Leon Woestenberg <leon.woestenberg@axon.tv> |
||||
* |
||||
* This is a device driver for the Crystal Semiconductor CS8900 |
||||
* chip in combination with the lwIP stack. |
||||
* |
||||
* This is work under development. Please coordinate changes |
||||
* and requests with Leon Woestenberg <leon.woestenberg@axon.tv> |
||||
* |
||||
* The Swedish Institute of Computer Science and Adam Dunkels |
||||
* are specifically granted permission to redistribute this |
||||
* source code under any conditions they seem fit. |
||||
* |
||||
* A quick function roadmap: |
||||
* |
||||
* cs8900_*() are low level, cs8900 hardware specific functions. |
||||
* These are declared static in the device driver source and |
||||
* SHOULD NOT need to be called from outside this source. |
||||
* |
||||
* cs8900if_*() are the lwIP network interface functions. |
||||
* |
||||
* cs8900_interrupt() is an early interrupt service routine (ISR). |
||||
* It merely sets a flag to indicate the cs8900 needs servicing. |
||||
* (This function MAY be tied to an interrupt vector, IF present). |
||||
* |
||||
* cs8900_service() is the actual interrupt event service routine. |
||||
* It must be called whenever the cs8900 needs servicing. It MAY |
||||
* be polled safely (so, you do NOT NEED interrupt support.) |
||||
* |
||||
* cs8900_init() sets up the cs8900, using its register set. When |
||||
* using the driver on your particular hardware platform, make sure |
||||
* the register setups match. |
||||
* Function is called from cs8900if_init(). |
||||
* |
||||
* cs8900_input() transfers a received packet from the chip. |
||||
* Function is called from cs8900if_input(). |
||||
* |
||||
* cs8900_output() transfers a packet to the chip for transmission. |
||||
* Function is called as netif->linkoutput from etharp_output(). |
||||
* |
||||
* cs8900if_init() initializes the lwIP network interface, and |
||||
* calls cs8900_init() to initialize the hardware. |
||||
* Function is called from lwIP. |
||||
* |
||||
* cs8900if_service() is the service routine, which must be called |
||||
* upon the need for service, or on a regular basis, in order to |
||||
* service the Ethernet chip. |
||||
* |
||||
* cs8900if_input() calls cs8900_input() to get a received packet |
||||
* and then forwards the packet to protocol(s) handler(s). |
||||
* Function is called from cs8900_service(). |
||||
* |
||||
* netif->output() resolves the hardware address, then |
||||
* calls cs8900_output() (as netif->linkoutput()) to transfer the packet. |
||||
* Function is called from lwIP. |
||||
* |
||||
* Future development: |
||||
* |
||||
* Split the generic Ethernet functionality (a lot of the |
||||
* cs8900if_*() functions) and the actual cs8900a dependencies. |
||||
* |
||||
* Enhance the interrupt handler to service the Ethernet |
||||
* chip (to decrease latency); support early packet |
||||
* inspection (during reception) to early drop unwanted |
||||
* packets, minimize chip buffer use and maximize throughput. |
||||
* |
||||
* Statistics gathering, currently under development. |
||||
* SNMP support, currently under development. |
||||
* |
||||
*/ |
||||
|
||||
#include "lwip/opt.h" |
||||
#include "lwip/def.h" |
||||
#include "lwip/err.h" |
||||
#include "lwip/mem.h" |
||||
#include "lwip/pbuf.h" |
||||
#include "lwip/stats.h" |
||||
#include "lwip/sys.h" |
||||
#include "netif/etharp.h" |
||||
|
||||
#if 0 |
||||
// include some debugging help
|
||||
# define LWIP_DBG_LEVEL 1 |
||||
# include "leds.h" |
||||
# include "display.h" |
||||
//# include "page.h"
|
||||
# define LED_NEED_SERVICE LED_FP1 |
||||
#else |
||||
// no debugging
|
||||
# define leds_on() |
||||
# define leds_off() |
||||
#endif |
||||
|
||||
/**
|
||||
* Dependend on physical layer. This is a safe minimum for 802.3 10base5/T. |
||||
* @sa RFC1042 |
||||
*/ |
||||
#define ETH_MIN_FRAME_LEN 60 |
||||
|
||||
#include "cs8900if.h" |
||||
#include "lwip/snmp.h" |
||||
|
||||
// Define those to better describe your network interface
|
||||
#define IFNAME0 'e' |
||||
#define IFNAME1 'n' |
||||
|
||||
// Forward declarations
|
||||
static err_t cs8900_output(struct netif *netif, struct pbuf *p); |
||||
static struct pbuf *cs8900_input(struct netif *netif); |
||||
static void cs8900_service(struct netif *netif); |
||||
static u32_t cs8900_chksum(void *dataptr, s16_t len); |
||||
static void cs8900_reset(struct netif *netif); |
||||
|
||||
// Define these to match your hardware setup
|
||||
#define MEM_BASE 0x00E000 |
||||
#define IO_BASE 0x800 |
||||
#define INT_NR 0x00 |
||||
|
||||
#define RXTXREG *((volatile u16_t *)(MEM_BASE + IO_BASE)) |
||||
#define TXCMD *((volatile u16_t *)(MEM_BASE + IO_BASE + 0x04)) |
||||
#define TXLENGTH *((volatile u16_t *)(MEM_BASE + IO_BASE + 0x06)) |
||||
#define ISQ *((volatile u16_t *)(MEM_BASE + IO_BASE + 0x08)) |
||||
#define PACKETPP *((volatile u16_t *)(MEM_BASE + IO_BASE + 0x0A)) |
||||
#define PPDATA *((volatile u16_t *)(MEM_BASE + IO_BASE + 0x0C)) |
||||
|
||||
// CS8900 PacketPage register offsets
|
||||
#define CS_PP_EISA 0x0000 // EISA Registration number of CS8900
|
||||
#define CS_PP_PRODID 0x0002 // Product ID Number
|
||||
#define CS_PP_IOBASE 0x0020 // I/O Base Address
|
||||
#define CS_PP_INTNUM 0x0022 // Interrupt number (0,1,2, or 3)
|
||||
#define CS_PP_RXCFG 0x0102 // Receiver Configuration
|
||||
#define CS_PP_RXCTL 0x0104 // Receiver Control
|
||||
#define CS_PP_TXCFG 0x0106 // Transmit Configuration
|
||||
#define CS_PP_BUFCFG 0x010A // Buffer Configuration
|
||||
#define CS_PP_LINECTL 0x0112 // Line Control Register offset
|
||||
#define CS_PP_SELFCTL 0x0114 // Self Control
|
||||
#define CS_PP_BUSCTL 0x0116 // Bus Control
|
||||
#define CS_PP_TESTCTL 0x0118 // Test Control
|
||||
#define CS_PP_ISQ 0x0120 // Interrupt status queue
|
||||
#define CS_PP_RXEVENT 0x0124 // Receiver Event
|
||||
#define CS_PP_TX_EVENT 0x0128 // Transmitter Event
|
||||
#define CS_PP_BUF_EVENT 0x012C // Buffer Event
|
||||
#define CS_PP_RXMISS 0x0130 // Receiver Miss Counter
|
||||
#define CS_PP_TXCOL 0x0132 // Transmit Collision Counter
|
||||
#define CS_PP_LINESTATUS 0x0134 // Line Status
|
||||
#define CS_PP_SELFTEST 0x0136 // Self Status
|
||||
#define CS_PP_BUSSTATUS 0x0138 // Bus Status
|
||||
#define CS_PP_TXCMD 0x0144 // Transmit Command Request
|
||||
#define CS_PP_TXLEN 0x0146 // Transmit Length
|
||||
#define CS_PP_IA1 0x0158 // Individual Address (IA)
|
||||
#define CS_PP_IA2 0x015A // Individual Address (IA)
|
||||
#define CS_PP_IA3 0x015C // Individual Address (IA)
|
||||
|
||||
#define CS_PP_RXSTATUS 0x0400 // Receive Status
|
||||
#define CS_PP_RXLEN 0x0402 // Receive Length
|
||||
#define CS_PP_RXFRAME 0x0404 // Receive Frame Location
|
||||
#define CS_PP_TXFRAME 0x0A00 // Transmit Frame Location
|
||||
|
||||
|
||||
// removed interrupt from library
|
||||
#if 0 |
||||
// hardware interrupt vector handler
|
||||
_interrupt(0x18) void cs8900_interrupt(void) |
||||
{ |
||||
struct cs8900if *cs8900if = cs8900if_netif->state; |
||||
// network interface is configured?
|
||||
if (cs8900if != NULL) |
||||
{ |
||||
// chip needs service
|
||||
cs8900if->needs_service = 1; |
||||
#if (CS8900_STATS > 0) |
||||
cs8900if->interrupts++; |
||||
#endif |
||||
} |
||||
} |
||||
#endif |
||||
|
||||
/**
|
||||
* Reset the CS8900A chip-wide using a soft reset |
||||
* |
||||
* @note You MUST wait 30 ms before accessing the CS8900 |
||||
* after calling this function. |
||||
*/ |
||||
static void cs8900_reset(struct netif *netif) |
||||
{ |
||||
(void)netif; |
||||
/* set RESET bit */ |
||||
PACKETPP = CS_PP_SELFCTL; |
||||
PPDATA = 0x0055U; |
||||
} |
||||
|
||||
// cs8900_init()
|
||||
//
|
||||
// initializes the CS8900A chip
|
||||
//
|
||||
static err_t cs8900_init(struct netif *netif) |
||||
{ |
||||
#ifdef LED_NEED_SERVICE |
||||
leds_off(LED_NEED_SERVICE); |
||||
#endif |
||||
|
||||
// { the RESET bit will be cleared by the cs8900a
|
||||
// as a result of a hardware reset - wait for it}
|
||||
// RESET bit cleared?
|
||||
while ((PPDATA & 0x0040U) != 0); // TODO: add timeout
|
||||
|
||||
// { after full initialization of the cs8900a
|
||||
// the INITD bit will be set }
|
||||
|
||||
PACKETPP = CS_PP_SELFTEST; |
||||
// INITD bit still clear?
|
||||
while ((PPDATA & 0x0080U) == 0); // TODO: add timeout
|
||||
// { INITD bit is set }
|
||||
|
||||
// SIBUSY bit still set?
|
||||
while ((PPDATA & 0x0100U) == 0x0100); // TODO: add timeout
|
||||
// { SIBUSY bit clear }
|
||||
|
||||
#if 1 |
||||
{ |
||||
u16_t dummy; |
||||
// datasheet section 3.3.3
|
||||
dummy = *(u16_t *)(MEM_BASE + IO_BASE + 0x0D); |
||||
// Dummy read, put chip in 16-bit mode
|
||||
dummy = *(u16_t *)(MEM_BASE + IO_BASE + 0x0D); |
||||
} |
||||
#endif |
||||
|
||||
// Set MAC address
|
||||
PACKETPP = CS_PP_IA1; |
||||
PPDATA = (u16_t)(netif->hwaddr[0]) | (u16_t)(netif->hwaddr[1] << 8U); |
||||
PACKETPP = CS_PP_IA2; |
||||
PPDATA = (u16_t)(netif->hwaddr[2]) | (u16_t)(netif->hwaddr[3] << 8U); |
||||
PACKETPP = CS_PP_IA3; |
||||
PPDATA = (u16_t)(netif->hwaddr[4]) | (u16_t)(netif->hwaddr[5] << 8U); |
||||
|
||||
// accept valid unicast or broadcast frames
|
||||
PACKETPP = CS_PP_RXCTL; |
||||
PPDATA = (0x0005U | 0x0800U/*broadcast*/ | 0x0400U/*individual*/ | 0x0100U/*RxOK*/); |
||||
|
||||
// enable receive interrupt
|
||||
PACKETPP = CS_PP_RXCFG; |
||||
PPDATA = (0x0003U | 0x0100U/*RXIRQ*/); |
||||
|
||||
// disable transmit interrupt (is default)
|
||||
PACKETPP = CS_PP_TXCFG; |
||||
PPDATA = (0x0007U | 0); |
||||
|
||||
// use interrupt number 0
|
||||
PACKETPP = CS_PP_INTNUM; |
||||
PPDATA = (0x0000U); |
||||
|
||||
// generate interrupt event on:
|
||||
// - the RxMISS counter reaches 0x200, or
|
||||
// - a received frame is lost
|
||||
PACKETPP = CS_PP_BUFCFG; |
||||
PPDATA = (0x000bU | |
||||
#if (CS8900_STATS > 0) // interrupt before counter overflow
|
||||
(0x2000U/*MissOvfloiE*/ | 0x1000U/*TxColOvfloiE*/) | |
||||
#endif |
||||
#if (CS8900_STATS > 1) // interrupt on counter increment
|
||||
(0x0400U/*RxMissiE*/) | |
||||
#endif |
||||
0x0000); |
||||
|
||||
// enable interrupt generation
|
||||
PACKETPP = CS_PP_BUSCTL; |
||||
PPDATA = (0x0017U | 0x8000U/*EnableIRQ*/); |
||||
|
||||
// enable:
|
||||
// - receiver
|
||||
// - transmitter
|
||||
PACKETPP = CS_PP_LINECTL; |
||||
PPDATA = (0x0013U | 0x0080U/*SerTxOn*/ | 0x0040U/*SerRxOn*/); |
||||
|
||||
return ERR_OK; |
||||
} |
||||
|
||||
/**
|
||||
* |
||||
* |
||||
* @return error code |
||||
* - ERR_OK: packet transferred to hardware |
||||
* - ERR_CONN: no link or link failure |
||||
* - ERR_IF: could not transfer to link (hardware buffer full?) |
||||
*/ |
||||
static err_t cs8900_output(struct netif *netif, struct pbuf *p) |
||||
{ |
||||
s16_t tries = 0; |
||||
err_t result; |
||||
|
||||
// exit if link has failed
|
||||
PACKETPP = CS_PP_LINESTATUS; |
||||
if ((PPDATA & 0x0080U/*LinkOK*/) == 0) return ERR_CONN; // no Ethernet link
|
||||
|
||||
result = ERR_OK; |
||||
/* TODO: should this occur AFTER setting TXLENGTH??? */ |
||||
/* drop the padding word */ |
||||
#if ETH_PAD_SIZE |
||||
pbuf_header(p, -ETH_PAD_SIZE); |
||||
#endif |
||||
|
||||
/* issue 'transmit' command to CS8900 */ |
||||
TXCMD = 0x00C9U; |
||||
/* send length (in bytes) of packet to send, but at least minimum frame length */ |
||||
TXLENGTH = (p->tot_len < ETH_MIN_FRAME_LEN? ETH_MIN_FRAME_LEN: p->tot_len); |
||||
|
||||
PACKETPP = CS_PP_BUSSTATUS; |
||||
// not ready for transmission and still within 100 retries?
|
||||
while (((PPDATA & 0x0100U/*Rdy4TxNOW*/) == 0) && (tries++ < 100)) |
||||
{ |
||||
// throw away the last committed received frame
|
||||
PACKETPP = CS_PP_RXCFG; |
||||
PPDATA = (0x0003U | 0x0040U/*Skip_1*/ | 0x0100U/*RxOKiE*/); |
||||
PACKETPP = CS_PP_BUSSTATUS; |
||||
/* cs8900if->dropped++; // CHECK: we do not know if we actually will drop a frame here */ |
||||
} |
||||
// ready to transmit?
|
||||
if ((PPDATA & 0x0100U/*Rdy4TxNOW*/) != 0) |
||||
{ |
||||
u16_t sent_bytes = 0; |
||||
/* q traverses through linked list of pbuf's
|
||||
* This list MUST consist of a single packet ONLY */ |
||||
struct pbuf *q; |
||||
u16_t pbuf_index = 0; |
||||
u8_t word_index = 0; |
||||
u8_t word[2]; |
||||
q = p; |
||||
/* Write data into CS8900, two bytes at a time
|
||||
* Handling pbuf's with odd number of bytes correctly
|
||||
* No attempt to optimize for speed has been made */ |
||||
while (q) |
||||
{ |
||||
if (pbuf_index < q->len) |
||||
{ |
||||
word[word_index++] = ((u8_t*)q->payload)[pbuf_index++]; |
||||
if (word_index == 2) |
||||
{ |
||||
RXTXREG = (word[1] << 8) | word[0]; |
||||
word_index = 0; |
||||
sent_bytes += 2; |
||||
} |
||||
} |
||||
else |
||||
{ |
||||
q = q->next; |
||||
pbuf_index = 0; |
||||
} |
||||
} |
||||
/* One byte could still be unsent */ |
||||
if (word_index == 1) |
||||
{ |
||||
RXTXREG = word[0]; |
||||
sent_bytes += 2; |
||||
} |
||||
/* provide any additional padding to comply with minimum Ethernet
|
||||
* frame length (RFC10242) */ |
||||
while (sent_bytes < ETH_MIN_FRAME_LEN) |
||||
{ |
||||
RXTXREG = 0x0000; |
||||
sent_bytes += 2; |
||||
} |
||||
/* { the packet has been sent } */ |
||||
#if (CS8900_STATS > 0) |
||||
((struct cs8900if *)netif->state)->sentpackets++; |
||||
((struct cs8900if *)netif->state)->sentbytes += sent_bytes; |
||||
#endif |
||||
snmp_add_ifoutoctets(netif,sent_bytes); |
||||
} |
||||
else |
||||
{ |
||||
// { not ready to transmit!? }
|
||||
snmp_inc_ifoutdiscards(netif); |
||||
/* return not connected */ |
||||
result = ERR_IF; |
||||
} |
||||
#if ETH_PAD_SIZE |
||||
/* reclaim the padding word */ |
||||
pbuf_header(p, ETH_PAD_SIZE); |
||||
#endif |
||||
return result; |
||||
} |
||||
|
||||
/**
|
||||
* Move a received packet from the cs8900 into a new pbuf. |
||||
* |
||||
* Must be called after reading an ISQ event containing the |
||||
* "Receiver Event" register, before reading new ISQ events. |
||||
* |
||||
* This function copies a frame from the CS8900A. |
||||
* It is designed failsafe: |
||||
* - It does not assume a frame is actually present. |
||||
* - It checks for non-zero length |
||||
* - It does not overflow the frame buffer |
||||
*/ |
||||
static struct pbuf *cs8900_input(struct netif *netif) |
||||
{ |
||||
volatile u16_t* rxtx_reg; |
||||
volatile u32_t rxtx_num = (MEM_BASE + IO_BASE); |
||||
u16_t* ptr = NULL; |
||||
struct pbuf *p = NULL, *q = NULL; |
||||
u16_t len = 0; |
||||
u16_t event_type; |
||||
u16_t i; |
||||
|
||||
/* optimized register mapping for Tasking c166 7.5 (default optimalisation setting)
|
||||
Using RXTXREG directly produces inefficient code with many const address loads. */ |
||||
rxtx_reg = ((volatile u16_t *)(rxtx_num)); |
||||
// read RxStatus
|
||||
event_type = *rxtx_reg; |
||||
|
||||
// correctly received frame, either broadcast or individual address?
|
||||
// TODO: maybe defer these conditions to cs8900_input()
|
||||
if ((event_type & 0x0100U/*RxOK*/) && (event_type & 0x0c00U/*Broadcast | Individual*/)) |
||||
{ |
||||
#if LWIP_SNMP > 0 |
||||
// update number of received MAC-unicast and non-MAC-unicast packets
|
||||
if (event_type & 0x0400U/*Individual*/) |
||||
{ |
||||
snmp_inc_ifinucastpkts(netif); |
||||
} |
||||
else |
||||
{ |
||||
snmp_inc_ifinnucastpkts(netif); |
||||
} |
||||
#endif |
||||
event_type = 0; |
||||
// read RxLength
|
||||
len = *rxtx_reg; |
||||
LWIP_DEBUGF(NETIF_DEBUG, ("cs8900_input: packet len %"U16_F"\n", len)); |
||||
snmp_add_ifinoctets(netif,len); |
||||
// positive length?
|
||||
if (len > 0) |
||||
{ |
||||
// allocate a pbuf chain with total length 'len + ETH_PAD_SIZE'
|
||||
p = pbuf_alloc(PBUF_RAW, len + ETH_PAD_SIZE, PBUF_POOL); |
||||
if (p != NULL) |
||||
{ |
||||
#if ETH_PAD_SIZE |
||||
/* drop the padding word */ |
||||
pbuf_header(p, -ETH_PAD_SIZE); /* drop the padding word */ |
||||
#endif |
||||
for (q = p; q != 0; q = q->next) |
||||
{ |
||||
LWIP_DEBUGF(NETIF_DEBUG, ("cs8900_input: pbuf @%p tot_len %"U16_F" len %"U16_F"\n", q, q->tot_len, q->len)); |
||||
|
||||
/* read 8 bytes per iteration */ |
||||
ptr = q->payload; |
||||
i = q->len / 8; |
||||
while(i > 0) |
||||
{ |
||||
*ptr = *rxtx_reg; |
||||
ptr++; |
||||
*ptr = *rxtx_reg; |
||||
ptr++; |
||||
*ptr = *rxtx_reg; |
||||
ptr++; |
||||
*ptr = *rxtx_reg; |
||||
ptr++; |
||||
i--; |
||||
} |
||||
/* read remainder */ |
||||
i = ((q->len % 8) + 1) / 2; |
||||
while(i > 0) |
||||
{ |
||||
*ptr = *rxtx_reg; |
||||
ptr++; |
||||
i--; |
||||
} |
||||
} |
||||
#if ETH_PAD_SIZE |
||||
/* reclaim the padding word */ |
||||
pbuf_header(p, ETH_PAD_SIZE); /* reclaim the padding word */ |
||||
#endif |
||||
} |
||||
// could not allocate a pbuf
|
||||
else |
||||
{ |
||||
// skip received frame
|
||||
// TODO: maybe do not skip the frame at this point in time?
|
||||
PACKETPP = CS_PP_RXCFG; |
||||
PPDATA = (0x0003U | 0x0100U/*RxOKiE*/ | 0x0040U/*Skip_1*/); |
||||
#if (CS8900_STATS > 0) |
||||
((struct cs8900if *)netif->state)->dropped++; |
||||
#endif |
||||
snmp_inc_ifindiscards(netif); |
||||
len = 0; |
||||
} |
||||
} |
||||
// length was zero
|
||||
else |
||||
{ |
||||
} |
||||
} |
||||
return p; |
||||
} |
||||
|
||||
|
||||
/**
|
||||
* To be called when the cs8900a needs service. Does |
||||
* not assume the cs8900a needs service. Does test the |
||||
* cs8900a whether it needs service. |
||||
* |
||||
* As such, may be used robustly called as a deferred |
||||
* (or "late") interrupt handler, or may be called in |
||||
* a loop to implement polling, or both. |
||||
* |
||||
* Use cs8900if_service() from your application instead |
||||
* of this function. |
||||
*/ |
||||
|
||||
static void cs8900_service(struct netif *netif) |
||||
{ |
||||
u8_t events2service = CS8900_EVTS2SRV; |
||||
#if (CS8900_STATS > 0) |
||||
u16_t miss_count = 0, coll_count = 0; |
||||
#endif |
||||
// NOTES:
|
||||
// static, so only initialized to zero at program start.
|
||||
// irq_status will always hold the last ISQ event register that
|
||||
// still needs service. As such, we may leave this function if
|
||||
// we encounter an event we cannot service yet, and return later
|
||||
// to try to service it.
|
||||
static u16_t irq_status = 0x0000U; |
||||
|
||||
// The "cs8900_needs_service" flag indicates whether any events
|
||||
// still need to be serviced.
|
||||
// clear flag here.
|
||||
// a receive interrupt can, *concurrently with this function*,
|
||||
// set this flag on new ISQ event occurences.
|
||||
// we will re-evaluate the correct setting of this flag at
|
||||
// function exit (below).
|
||||
((struct cs8900if *)netif->state)->needs_service = 0; |
||||
#ifdef LED_NEED_SERVICE |
||||
leds_off(LED_NEED_SERVICE); |
||||
#endif |
||||
/* no unhandled irq_status left? */ |
||||
if (irq_status == 0x0000U) |
||||
{ |
||||
/* read ISQ register */ |
||||
irq_status = ISQ; |
||||
} |
||||
/* ISQ interrupt event, and allowed to service in this loop? */ |
||||
while ((irq_status != 0x0000U) && (events2service-- > 0)) |
||||
{ |
||||
/* investigate event */ |
||||
if ((irq_status & 0x003fU) == 0x0004U/*Receiver Event*/) |
||||
{ |
||||
/* correctly received frame, either broadcast or individual address */ |
||||
/* TODO: think where these checks should appear: here or in cs8900_input() */ |
||||
if ((irq_status & 0x0100U/*RxOK*/) && (irq_status & 0x0c00U/*Broadcast | Individual*/)) |
||||
{ |
||||
/* read the frame from the cs8900a */ |
||||
cs8900if_input(netif); |
||||
} |
||||
else |
||||
{ |
||||
/* skip this frame */ |
||||
PACKETPP = CS_PP_RXCFG; |
||||
PPDATA |= 0x0040U/*Skip_1*/; |
||||
#if (CS8900_STATS > 0) |
||||
((struct cs8900if *)netif->state)->dropped++; |
||||
#endif |
||||
} |
||||
} |
||||
#if (CS8900_STATS > 0) |
||||
else if ((irq_status & 0x003fU) == 0x0010U/*RxMISS Event*/) |
||||
{ |
||||
miss_count += (irq_status >> 6); |
||||
} |
||||
else if ((irq_status & 0x003fU) == 0x0012U/*TxCOL Event*/) |
||||
{ |
||||
coll_count += (irq_status >> 6); |
||||
} |
||||
#endif |
||||
/* read ISQ register */ |
||||
irq_status = ISQ; |
||||
} |
||||
|
||||
/* we did not deplete the ISQ? */ |
||||
if (irq_status != 0x0000U) |
||||
{ |
||||
/* the cs8900a still needs service */ |
||||
((struct cs8900if *)netif->state)->needs_service = 1; |
||||
#ifdef LED_NEED_SERVICE |
||||
leds_on(LED_NEED_SERVICE); |
||||
#endif |
||||
} |
||||
#if (CS8900_STATS > 1) /* follow misses and collisions on a per-packet basis? */ |
||||
/* read RxMiss Counter (zeroes itself upon read) */ |
||||
PACKETPP = CS_PP_RXMISS; |
||||
miss_count += (PPDATA >> 6); |
||||
/* read RxCol Counter (zeroes itself upon read) */ |
||||
PACKETPP = CS_PP_TXCOL; |
||||
coll_count += (PPDATA >> 6); |
||||
#endif |
||||
#if (CS8900_STATS > 0) |
||||
/* copy statistics counters into netif state fields */ |
||||
((struct cs8900if *)netif->state)->missed += miss_count; |
||||
if (miss_count > 0) LWIP_DEBUGF(NETIF_DEBUG | 1, ("cs8900_input: %"U16_F" missed packets due to rx buffer overrun\n", miss_count)); |
||||
|
||||
((struct cs8900if *)netif->state)->collisions += coll_count; |
||||
if (coll_count > 0) LWIP_DEBUGF(NETIF_DEBUG | 1, ("cs8900_input: %"U16_F" packet collisions\n", coll_count));
|
||||
#endif |
||||
} |
||||
|
||||
/**
|
||||
* Service the CS8900. |
||||
* |
||||
* Can be called in a polling manner, or only after the CS8900 has raised |
||||
* an interrupt request. |
||||
* |
||||
* @param netif The lwIP network interface data structure belonging to this device. |
||||
* |
||||
*/ |
||||
void cs8900if_service(struct netif *netif) |
||||
{ |
||||
// is there a reason to call the service routine?
|
||||
if ((((struct cs8900if *)netif->state)->needs_service) || |
||||
(((struct cs8900if *)netif->state)->use_polling)) |
||||
{ |
||||
cs8900_service(netif); |
||||
} |
||||
} |
||||
|
||||
/**
|
||||
* Read a received packet from the CS8900. |
||||
* |
||||
* This function should be called when a packet is received by the CS8900 |
||||
* and is fully available to read. It moves the received packet to a pbuf |
||||
* which is forwarded to the IP network layer or ARP module. It transmits |
||||
* a resulting ARP reply or queued packet. |
||||
* |
||||
* @param netif The lwIP network interface to read from. |
||||
* |
||||
* @internal Uses cs8900_input() to move the packet from the CS8900 to a |
||||
* newly allocated pbuf. |
||||
* |
||||
*/ |
||||
void cs8900if_input(struct netif *netif) |
||||
{ |
||||
struct eth_hdr *ethhdr = NULL; |
||||
struct pbuf *p = NULL; |
||||
|
||||
/* move received packet into a new pbuf */ |
||||
p = cs8900_input(netif); |
||||
/* no packet could be read */ |
||||
if (p == NULL) { |
||||
/* silently ignore this */ |
||||
return; |
||||
} |
||||
/* points to packet payload, which starts with an Ethernet header */ |
||||
ethhdr = p->payload; |
||||
|
||||
switch (htons(ethhdr->type)) { |
||||
/* IP packet? */ |
||||
case ETHTYPE_IP: |
||||
#if 0 |
||||
/* CSi disabled ARP table update on ingress IP packets.
|
||||
This seems to work but needs thorough testing. */ |
||||
/* update ARP table */ |
||||
etharp_ip_input(netif, p); |
||||
#endif |
||||
/* skip Ethernet header */ |
||||
pbuf_header(p, -(s16_t)sizeof(struct eth_hdr)); |
||||
LWIP_DEBUGF(NETIF_DEBUG, ("cs8900_input: passing packet up to IP\n")); |
||||
/* pass to network layer */ |
||||
netif->input(p, netif); |
||||
break; |
||||
/* ARP packet? */ |
||||
case ETHTYPE_ARP: |
||||
/* pass p to ARP module */ |
||||
etharp_arp_input(netif, (struct eth_addr *)&netif->hwaddr, p); |
||||
break; |
||||
/* unsupported Ethernet packet type */ |
||||
default: |
||||
/* free pbuf */ |
||||
pbuf_free(p); |
||||
p = NULL; |
||||
break; |
||||
} |
||||
} |
||||
|
||||
/**
|
||||
* Reset the CS8900 Ethernet MAC/PHY chip. |
||||
* |
||||
* @param netif The lwIP network interface data structure belonging to this device. |
||||
* MAY be NULL as we do not support multiple devices yet. |
||||
* @note You SHOULD call cs8900if_init() afterwards to |
||||
* initialize and configure the chip. |
||||
*/ |
||||
void cs8900if_reset(struct netif *netif) |
||||
{ |
||||
/* reset the cs8900a chip */ |
||||
cs8900_reset(netif); |
||||
} |
||||
|
||||
/**
|
||||
* Initialize the CS8900 Ethernet MAC/PHY and its device driver. |
||||
* |
||||
* @param netif The lwIP network interface data structure belonging to this device. |
||||
* MAY be NULL as we do not support multiple devices yet. |
||||
* |
||||
*/ |
||||
err_t cs8900if_init(struct netif *netif) |
||||
{ |
||||
struct cs8900if *cs8900if; |
||||
|
||||
cs8900if = mem_malloc(sizeof(struct cs8900if)); |
||||
if (cs8900if == NULL) |
||||
{ |
||||
LWIP_DEBUGF(NETIF_DEBUG, ("cs8900_input: out of memory for cs8900if\n")); |
||||
return ERR_MEM; |
||||
} |
||||
/* initialize lwip network interface ... */ |
||||
#if LWIP_SNMP |
||||
/* ifType ethernetCsmacd(6) */ |
||||
netif->link_type = 6; |
||||
netif->link_speed = 10000000; |
||||
netif->ts = 0; |
||||
netif->ifinoctets = 0; |
||||
netif->ifinucastpkts = 0; |
||||
netif->ifinnucastpkts = 0; |
||||
netif->ifindiscards = 0; |
||||
netif->ifoutoctets = 0; |
||||
netif->ifoutucastpkts = 0; |
||||
netif->ifoutnucastpkts = 0; |
||||
netif->ifoutdiscards = 0; |
||||
#endif |
||||
|
||||
/* administrative details */ |
||||
netif->name[0] = IFNAME0; |
||||
netif->name[1] = IFNAME1; |
||||
|
||||
/* downward functions */ |
||||
netif->output = etharp_output; |
||||
netif->linkoutput = cs8900_output; |
||||
|
||||
/* initialize cs8900 specific interface state data pointer */ |
||||
netif->state = cs8900if; |
||||
|
||||
/* maximum transfer unit */ |
||||
netif->mtu = 1500; |
||||
|
||||
/* broadcast capability */ |
||||
netif->flags = NETIF_FLAG_BROADCAST; |
||||
|
||||
/* hardware address length */ |
||||
netif->hwaddr_len = 6; |
||||
|
||||
/* initially assume no ISQ event */ |
||||
cs8900if->needs_service = 0; |
||||
/* set to 1 if polling method is used */ |
||||
cs8900if->use_polling = 0; |
||||
|
||||
#if (CS8900_STATS > 0) |
||||
/* number of interrupt service routine calls */ |
||||
cs8900if->interrupts = 0; |
||||
cs8900if->missed = 0; |
||||
cs8900if->dropped = 0; |
||||
cs8900if->collisions = 0; |
||||
cs8900if->sentpackets = 0; |
||||
cs8900if->sentbytes = 0; |
||||
#endif |
||||
|
||||
/* intialize the cs8900a chip */ |
||||
return cs8900_init(netif); |
||||
} |
||||
|
||||
#if 1 |
||||
/**
|
||||
* Dump an array of bytes inside a UDP message's data field. |
||||
* |
||||
* It is a self-contained function, independent of higher protocol layers or other |
||||
* functions, so it allows you to debug these higher layers, such as lwIP. |
||||
* |
||||
* @param p pointer to an array of bytes, at least with length 'len' |
||||
* @param len number of bytes available at the address pointed to by 'p' |
||||
*/ |
||||
void cs8900_send_debug(u8_t *p, u16_t len) |
||||
{ |
||||
s16_t tries = 0, i; |
||||
|
||||
// network interface state
|
||||
extern struct netif *ethif; |
||||
|
||||
// exit if link has failed
|
||||
PACKETPP = CS_PP_LINESTATUS; |
||||
if ((PPDATA & 0x0080U/*LinkOK*/) == 0) return; // TODO: find a correct error code
|
||||
|
||||
// transmit command
|
||||
TXCMD = 0x00C9U; |
||||
// send at least 60 bytes
|
||||
TXLENGTH = (14 + 20 + 8 + len < 60) ? 60 : (14 + 20 + 8 + len); |
||||
|
||||
PACKETPP = CS_PP_BUSSTATUS; |
||||
// not ready for transmission and still within 100 retries?
|
||||
while (((PPDATA & 0x0100U/*Rdy4TxNOW*/) == 0) && (tries++ < 100)) |
||||
{ |
||||
// throw away the last committed received frame
|
||||
PACKETPP = CS_PP_RXCFG; |
||||
PPDATA = (0x0003U | 0x0040U/*Skip_1*/ | 0x0100U/*RxOKiE*/); |
||||
PACKETPP = CS_PP_BUSSTATUS; |
||||
/* cs8900if->dropped++; CHECK: we do not know if we actually will drop a frame here, do we? */ |
||||
} |
||||
// ready to transmit?
|
||||
if ((PPDATA & 0x0100U/*Rdy4TxNOW*/) != 0) |
||||
{ |
||||
u16_t data, checksum = 0; |
||||
u32_t udp_checksum = 0; |
||||
|
||||
// destination Ethernet address
|
||||
RXTXREG = 0xa000U; |
||||
RXTXREG = 0xc524U; |
||||
RXTXREG = 0x6d72U; |
||||
// source Ethernet address
|
||||
RXTXREG = htons(((u16_t)ethif->hwaddr[0] << 8U) | (u16_t)ethif->hwaddr[1]); |
||||
RXTXREG = htons(((u16_t)ethif->hwaddr[2] << 8U) | (u16_t)ethif->hwaddr[3]); |
||||
RXTXREG = htons(((u16_t)ethif->hwaddr[4] << 8U) | (u16_t)ethif->hwaddr[5]); |
||||
// frame type
|
||||
RXTXREG = htons(0x0800); |
||||
// TOS, version
|
||||
RXTXREG = htons(data = ((0x40 | 0x05) << 8) | 0x00); |
||||
checksum += data; |
||||
// length
|
||||
RXTXREG = htons(data = 20 + 8 + len); |
||||
checksum += data; |
||||
// identifier
|
||||
RXTXREG = htons(data = 0); |
||||
checksum += data; |
||||
// fragment offset
|
||||
RXTXREG = htons(data = 0); |
||||
checksum += data; |
||||
// TTL, UDP protocol
|
||||
RXTXREG = htons(data = (255U << 8) | 17U); |
||||
checksum += data; |
||||
|
||||
checksum += (htonl(ethif->ip_addr.addr) & 0xffff0000U) >> 16; |
||||
checksum += (htonl(ethif->ip_addr.addr) & 0x0000ffffU); |
||||
checksum += 0xc0a8U; |
||||
checksum += 0x0001U; |
||||
checksum += 6; // LW: kludge/hack: checksum calculation seems to be wrong somehow
|
||||
// LW: this seems (?) to fix it
|
||||
// checksum
|
||||
RXTXREG = htons(~checksum); |
||||
|
||||
// source IP
|
||||
RXTXREG = htons((htonl(ethif->ip_addr.addr) & 0xffff0000U) >> 16); |
||||
// source IP
|
||||
RXTXREG = htons( htonl(ethif->ip_addr.addr) & 0x0000ffffU); |
||||
// destination IP
|
||||
RXTXREG = htons(0xc0a8U); |
||||
// destination IP
|
||||
RXTXREG = htons(0x0001U); |
||||
// source port 3000
|
||||
RXTXREG = htons(3000U); |
||||
// destination port 3000
|
||||
RXTXREG = htons(3000U); |
||||
// UDP length
|
||||
RXTXREG = htons(len); |
||||
// UDP checksum (not present)
|
||||
|
||||
udp_checksum = (htonl(ethif->ip_addr.addr) & 0xffff0000U) >> 16; |
||||
udp_checksum += (htonl(ethif->ip_addr.addr) & 0x0000ffffU); |
||||
udp_checksum += 0xc0a8U; |
||||
udp_checksum += 0x0001U; |
||||
udp_checksum += 0x0011U; |
||||
udp_checksum += (8 + len); |
||||
udp_checksum += 3000; |
||||
udp_checksum += 3000; |
||||
udp_checksum += (8 + len); |
||||
udp_checksum += cs8900_chksum(p, len); |
||||
while (udp_checksum >> 16) { |
||||
udp_checksum = (udp_checksum & 0xffffUL) + (udp_checksum >> 16); |
||||
} |
||||
|
||||
RXTXREG = htons(~(udp_checksum & 0xffff)); |
||||
for (i = 0; i < len; i += 2) |
||||
{ |
||||
RXTXREG = htons((p[i] << 8) | p[i + 1]); |
||||
} |
||||
// pad to 60 bytes
|
||||
while (i < 60) |
||||
{ |
||||
RXTXREG = 0; |
||||
i += 2; |
||||
} |
||||
} |
||||
} |
||||
|
||||
static u32_t cs8900_chksum(void *dataptr, s16_t len) |
||||
{ |
||||
u32_t acc = 0; |
||||
u16_t *ptr = (u16_t *)dataptr; |
||||
|
||||
for(acc = 0; len > 1; len -= 2) { |
||||
acc += *ptr; |
||||
ptr++; |
||||
} |
||||
/* add up any odd byte */ |
||||
if (len == 1) { |
||||
acc += htons((u16_t)((*(u8_t *)ptr) & 0xffU) << 8); |
||||
} |
||||
return acc; |
||||
} |
||||
|
||||
#endif |
||||
@ -1,42 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001, Swedish Institute of Computer Science. |
||||
* All rights reserved.
|
||||
* |
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the Institute nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
* |
||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
* |
||||
* This file is part of the lwIP TCP/IP stack. |
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se> |
||||
* |
||||
* $Id: perf.c,v 1.1 2007/06/14 12:33:57 kieranm Exp $ |
||||
*/ |
||||
|
||||
#include "arch/perf.h" |
||||
|
||||
void |
||||
perf_init(char *fname) |
||||
{ |
||||
if (fname); // LEON: prevent warning
|
||||
} |
||||
@ -1,20 +0,0 @@
|
||||
### README --- c:/cygwin/home/dhaas/work/cfimage/lwip/arch/coldfire/ |
||||
|
||||
## |
||||
## Author: dhaas@alum.rpi.edu |
||||
|
||||
These files are a port of lwip to coldfire (specifically the MCF5272 with |
||||
on-board FEC) under the Nucleus OS. Nucleus is pretty generic so it should be |
||||
fairly easy to port this to any other embedded OS. Nucleus memory managment |
||||
is not used. It is assumed you have a working malloc (which at least |
||||
long-word aligns memory). |
||||
|
||||
The compiler used was Diab 4.3b. You will almost certainly need to change |
||||
cc.h for your compiler. |
||||
|
||||
IMPORTANT NOTE: If you use the fec driver for a different processor which has |
||||
a data cache you will need to make sure the buffer descriptors and memory |
||||
used for pbufs are not in a cachable area. Otherwise the fec driver is |
||||
guarrenteed to malfunction. The 5272 which this was written for does not |
||||
support data cache so it did not matter and malloc was used. |
||||
|
||||
@ -1,117 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001-2003, Swedish Institute of Computer Science. |
||||
* All rights reserved.
|
||||
* |
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the Institute nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
* |
||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
* |
||||
* This file is part of the lwIP TCP/IP stack. |
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se> |
||||
* |
||||
* $Id: cc.h,v 1.1 2007/06/14 12:34:00 kieranm Exp $ |
||||
*/ |
||||
#ifndef __CC_H__ |
||||
#define __CC_H__ |
||||
|
||||
#include <types.h> |
||||
#include <string.h> |
||||
|
||||
/* Specific code for NBS Card Technology */ |
||||
#ifdef CARDTECH |
||||
#include <errorlog.h> |
||||
#endif |
||||
|
||||
#define BYTE_ORDER BIG_ENDIAN |
||||
#define IMM_ADDRESS (0x10000000) |
||||
#define FEC_LEVEL 4 |
||||
|
||||
// typedef unsigned char u8_t;
|
||||
// typedef signed char s8_t;
|
||||
// typedef unsigned short u16_t;
|
||||
// typedef signed short s16_t;
|
||||
// typedef unsigned long u32_t;
|
||||
// typedef signed long s32_t;
|
||||
|
||||
typedef u32_t mem_ptr_t; |
||||
|
||||
/* Compiler hints for packing structures */ |
||||
#define PACK_STRUCT_BEGIN #pragma pack(1,1,0) |
||||
#define PACK_STRUCT_STRUCT |
||||
#define ALIGN_STRUCT_8_BEGIN #pragma pack(1,8,0) |
||||
#define ALIGN_STRUCT_END #pragma pack() |
||||
#define PACK_STRUCT_END #pragma pack() |
||||
#define PACK_STRUCT_FIELD(x) x |
||||
|
||||
|
||||
#define _SYS_TYPES_FD_SET |
||||
#define NBBY 8 /* number of bits in a byte */ |
||||
|
||||
#ifndef FD_SETSIZE |
||||
#define FD_SETSIZE 64 |
||||
#endif /* FD_SETSIZE */ |
||||
|
||||
typedef long fd_mask; |
||||
#define NFDBITS (sizeof (fd_mask) * NBBY) /* bits per mask */ |
||||
#ifndef howmany |
||||
#define howmany(x,y) (((x)+((y)-1))/(y)) |
||||
#endif /* howmany */ |
||||
|
||||
typedef struct _types_fd_set { |
||||
fd_mask fds_bits[howmany(FD_SETSIZE, NFDBITS)]; |
||||
} _types_fd_set; |
||||
|
||||
#define fd_set _types_fd_set |
||||
|
||||
#define FD_SET(n, p) ((p)->fds_bits[(n)/NFDBITS] |= (1L << ((n) % NFDBITS))) |
||||
#define FD_CLR(n, p) ((p)->fds_bits[(n)/NFDBITS] &= ~(1L << ((n) % NFDBITS))) |
||||
#define FD_ISSET(n, p) ((p)->fds_bits[(n)/NFDBITS] & (1L << ((n) % NFDBITS))) |
||||
#define FD_ZERO(p) do { \ |
||||
size_t __i; \
|
||||
char *__tmp = (char *)p; \
|
||||
for (__i = 0; __i < sizeof (*(p)); ++__i) \
|
||||
*__tmp++ = 0; \
|
||||
} while (0) |
||||
|
||||
/* prototypes for printf() and abort() */ |
||||
#include <stdio.h> |
||||
#include <stdlib.h> |
||||
/* Plaform specific diagnostic output */ |
||||
#ifndef LWIP_PLATFORM_DIAG |
||||
#define LWIP_PLATFORM_DIAG(x) do {printf x;} while(0) |
||||
#endif |
||||
|
||||
#ifndef LWIP_PLATFORM_ASSERT |
||||
#define LWIP_PLATFORM_ASSERT(x) do {printf("Assertion \"%s\" failed at line %d in %s\n", \ |
||||
x, __LINE__, __FILE__); fflush(NULL); abort();} while(0) |
||||
#endif |
||||
|
||||
asm u32_t GET_CALLER_PC (void) |
||||
{ |
||||
! "d0" |
||||
move.l 4(a6),d0 |
||||
} |
||||
|
||||
|
||||
#endif /* __CC_H__ */ |
||||
@ -1,44 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001, Swedish Institute of Computer Science. |
||||
* All rights reserved.
|
||||
* |
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the Institute nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
* |
||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
* |
||||
* This file is part of the lwIP TCP/IP stack. |
||||
*
|
||||
* Author: David Haas <dhaas@alum.rpi.edu> |
||||
* |
||||
* $Id:
|
||||
*/ |
||||
#ifndef __ERRNO_H__ |
||||
#define __ERRNO_H__ |
||||
|
||||
/* This can be used to test whether errno is implemented */ |
||||
#define ERRNO |
||||
|
||||
#define errno (*sys_arch_errno()) |
||||
|
||||
|
||||
#endif |
||||
File diff suppressed because it is too large
Load Diff
@ -1,38 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001-2003 Swedish Institute of Computer Science. |
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met: |
||||
* |
||||
* 1. Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, |
||||
* this list of conditions and the following disclaimer in the documentation |
||||
* and/or other materials provided with the distribution. |
||||
* 3. The name of the author may not be used to endorse or promote products |
||||
* derived from this software without specific prior written permission.
|
||||
* |
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE. |
||||
* |
||||
* This file is part of the lwIP TCP/IP stack. |
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se> |
||||
* |
||||
*/ |
||||
#ifndef __PERF_H__ |
||||
#define __PERF_H__ |
||||
|
||||
#define PERF_START /* null definition */ |
||||
#define PERF_STOP(x) /* null definition */ |
||||
|
||||
#endif /* __PERF_H__ */ |
||||
@ -1,66 +0,0 @@
|
||||
/* @(#)sys_arch.h
|
||||
* Copyright (c) 2001-2003 Swedish Institute of Computer Science. |
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met: |
||||
* |
||||
* 1. Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, |
||||
* this list of conditions and the following disclaimer in the documentation |
||||
* and/or other materials provided with the distribution. |
||||
* 3. The name of the author may not be used to endorse or promote products |
||||
* derived from this software without specific prior written permission.
|
||||
* |
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE. |
||||
* |
||||
* This file is part of the lwIP TCP/IP stack. |
||||
*
|
||||
* Author: David Haas |
||||
* |
||||
*/ |
||||
|
||||
#ifndef _SYS_ARCH_H |
||||
#define _SYS_ARCH_H 1 |
||||
|
||||
#include <nucleus.h> |
||||
#include <stdlib.h> |
||||
#include "netif/etharp.h" |
||||
|
||||
#define SYS_MBOX_NULL NULL |
||||
#define SYS_SEM_NULL NULL |
||||
|
||||
/* sockets needs this definition. include time.h if this is a unix system */ |
||||
struct timeval { |
||||
long tv_sec; |
||||
long tv_usec; |
||||
}; |
||||
|
||||
typedef NU_SEMAPHORE * sys_sem_t; |
||||
typedef NU_QUEUE * sys_mbox_t; |
||||
typedef NU_TASK * sys_thread_t; |
||||
typedef u32_t sys_prot_t; |
||||
|
||||
/* Functions specific to Coldfire/Nucleus */ |
||||
void |
||||
sys_setvect(u32_t vector, void (*isr_function)(void), void (*dis_funct)(void)); |
||||
void |
||||
sys_get_eth_addr(struct eth_addr *eth_addr); |
||||
int * |
||||
sys_arch_errno(void); |
||||
|
||||
|
||||
#include "arch/errno.h" |
||||
|
||||
#endif /* _SYS_ARCH_H */ |
||||
|
||||
@ -1,44 +0,0 @@
|
||||
/* @(#)5272fec.h
|
||||
* Copyright (c) 2001-2003 Swedish Institute of Computer Science. |
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met: |
||||
* |
||||
* 1. Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, |
||||
* this list of conditions and the following disclaimer in the documentation |
||||
* and/or other materials provided with the distribution. |
||||
* 3. The name of the author may not be used to endorse or promote products |
||||
* derived from this software without specific prior written permission.
|
||||
* |
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE. |
||||
* |
||||
* This file is part of the lwIP TCP/IP stack. |
||||
*
|
||||
* Purpose: MCF5272 fec ethernet driver |
||||
* |
||||
* Author: David Haas |
||||
* |
||||
*/ |
||||
|
||||
#ifndef _5272FEC_H |
||||
#define _5272FEC_H 1 |
||||
|
||||
|
||||
err_t |
||||
mcf5272fecif_init(struct netif *netif); |
||||
|
||||
|
||||
#endif /* _5272FEC_H */ |
||||
|
||||
@ -1,39 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001-2003 Swedish Institute of Computer Science. |
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met: |
||||
* |
||||
* 1. Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, |
||||
* this list of conditions and the following disclaimer in the documentation |
||||
* and/or other materials provided with the distribution. |
||||
* 3. The name of the author may not be used to endorse or promote products |
||||
* derived from this software without specific prior written permission.
|
||||
* |
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE. |
||||
* |
||||
* This file is part of the lwIP TCP/IP stack. |
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se> |
||||
* |
||||
*/ |
||||
#ifndef __NETIF_TCPDUMP_H__ |
||||
#define __NETIF_TCPDUMP_H__ |
||||
|
||||
#include "lwip/pbuf.h" |
||||
|
||||
void tcpdump(struct pbuf *p); |
||||
|
||||
#endif /* __NETIF_TCPDUMP_H__ */ |
||||
@ -1,778 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001-2003, Swedish Institute of Computer Science. |
||||
* All rights reserved.
|
||||
* |
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the Institute nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
* |
||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
* |
||||
* This file is part of the lwIP TCP/IP stack. |
||||
*
|
||||
* Author: David Haas dhaas@alum.rpi.edu |
||||
* |
||||
*/ |
||||
|
||||
/* This is an ethernet driver for the internal fec in the Coldfire MCF5272.
|
||||
The driver has been written to use ISRs for Receive Frame and Transmit Frame |
||||
Complete. |
||||
*/ |
||||
|
||||
#include "lwip/debug.h" |
||||
|
||||
#include "lwip/opt.h" |
||||
#include "lwip/def.h" |
||||
#include "lwip/mem.h" |
||||
#include "lwip/pbuf.h" |
||||
#include "lwip/stats.h" |
||||
#include "lwip/sys.h" |
||||
|
||||
#include "netif/etharp.h" |
||||
|
||||
#include "arch/mcf5272.h" |
||||
|
||||
/* Sizing the descriptor rings will depend upon how many pbufs you have available
|
||||
* and how big they are. Also on how many frames you might want to input before dropping |
||||
* frames. Generally it is a good idea to buffer one tcp window. This means that |
||||
* you won't get a tcp retransmit and your tcp transmissions will be reasonably fast. |
||||
*/ |
||||
#define NUM_RXBDS 64 // Number of receive descriptor rings
|
||||
#define NUM_TXBDS 32 // Number of transmit descriptor rings
|
||||
|
||||
/* Define those to better describe your network interface. */ |
||||
#define IFNAME0 'e' |
||||
#define IFNAME1 't' |
||||
|
||||
/* Define interface MTU size. We set this to 1518, since this is the max
|
||||
Size of an ethernet frame without VLAN support. */ |
||||
#define MTU_FEC 1518 |
||||
|
||||
PACK_STRUCT_BEGIN |
||||
struct rxbd
|
||||
{ |
||||
u16_t flags; |
||||
u16_t data_len; |
||||
u8_t *p_buf; |
||||
}; |
||||
PACK_STRUCT_END |
||||
typedef struct rxbd rxbd_t; |
||||
|
||||
PACK_STRUCT_BEGIN |
||||
struct txbd
|
||||
{ |
||||
u16_t flags; |
||||
u16_t data_len; |
||||
u8_t *p_buf; |
||||
}; |
||||
PACK_STRUCT_END |
||||
typedef struct txbd txbd_t; |
||||
|
||||
ALIGN_STRUCT_8_BEGIN |
||||
struct mcf5272if
|
||||
{ |
||||
rxbd_t rxbd_a[NUM_RXBDS]; // Rx descriptor ring. Must be aligned to double-word
|
||||
txbd_t txbd_a[NUM_TXBDS]; // Tx descriptor ring. Must be aligned to double-word
|
||||
struct pbuf *rx_pbuf_a[NUM_RXBDS]; // Array of pbufs corresponding to payloads in rx desc ring.
|
||||
struct pbuf *tx_pbuf_a[NUM_TXBDS]; // Array of pbufs corresponding to payloads in tx desc ring.
|
||||
unsigned int rx_remove; // Index that driver will remove next rx frame from.
|
||||
unsigned int rx_insert; // Index that driver will insert next empty rx buffer.
|
||||
unsigned int tx_insert; // Index that driver will insert next tx frame to.
|
||||
unsigned int tx_remove; // Index that driver will clean up next tx buffer.
|
||||
unsigned int tx_free; // Number of free transmit descriptors.
|
||||
unsigned int rx_buf_len; // number of bytes in a rx buffer (that we can use).
|
||||
MCF5272_IMM *imm; // imm address. All register accesses use this as base.
|
||||
struct eth_addr *ethaddr; |
||||
struct netif *netif; |
||||
}; |
||||
ALIGN_STRUCT_END |
||||
|
||||
typedef struct mcf5272if mcf5272if_t; |
||||
|
||||
#define INC_RX_BD_INDEX(idx) do { if (++idx >= NUM_RXBDS) idx = 0; } while (0) |
||||
#define INC_TX_BD_INDEX(idx) do { if (++idx >= NUM_TXBDS) idx = 0; } while (0) |
||||
#define DEC_TX_BD_INDEX(idx) do { if (idx-- == 0) idx = NUM_TXBDS-1; } while (0) |
||||
|
||||
static mcf5272if_t *mcf5272if; |
||||
static sys_sem_t tx_sem; |
||||
|
||||
u32_t phy; |
||||
|
||||
typedef struct mcf5272if mcf5272if_t; |
||||
|
||||
/*-----------------------------------------------------------------------------------*/ |
||||
static void |
||||
fill_rx_ring(mcf5272if_t *mcf5272) |
||||
{ |
||||
struct pbuf *p; |
||||
struct rxbd *p_rxbd; |
||||
int i = mcf5272->rx_insert; |
||||
void *new_payload; |
||||
u32_t u_p_pay; |
||||
|
||||
/* Try and fill as many receive buffers as we can */ |
||||
while (mcf5272->rx_pbuf_a[i] == 0) |
||||
{ |
||||
p = pbuf_alloc(PBUF_RAW, (u16_t) mcf5272->rx_buf_len, PBUF_POOL); |
||||
if (p == 0) |
||||
/* No pbufs, so can't refill ring */ |
||||
return; |
||||
/* Align payload start to be divisible by 16 as required by HW */ |
||||
u_p_pay = (u32_t) p->payload; |
||||
new_payload = p->payload = (void *) (((u_p_pay + 15) / 16) * 16); |
||||
|
||||
mcf5272->rx_pbuf_a[i] = p; |
||||
p_rxbd = &mcf5272->rxbd_a[i]; |
||||
p_rxbd->p_buf = (u8_t *) new_payload; |
||||
p_rxbd->flags = (p_rxbd->flags & MCF5272_FEC_RX_BD_W) | MCF5272_FEC_RX_BD_E; |
||||
INC_RX_BD_INDEX(mcf5272->rx_insert); |
||||
i = mcf5272->rx_insert; |
||||
} |
||||
} |
||||
|
||||
/*-----------------------------------------------------------------------------------*/ |
||||
static void |
||||
enable_fec(mcf5272if_t *mcf5272) |
||||
{ |
||||
MCF5272_IMM *imm = mcf5272->imm; |
||||
int i; |
||||
|
||||
/* Initialize empty tx descriptor ring */ |
||||
for(i = 0; i < NUM_TXBDS-1; i++) |
||||
mcf5272->txbd_a[i].flags = 0; |
||||
/* Set wrap bit for last descriptor */ |
||||
mcf5272->txbd_a[i].flags = MCF5272_FEC_TX_BD_W; |
||||
/* initialize tx indexes */ |
||||
mcf5272->tx_remove = mcf5272->tx_insert = 0; |
||||
mcf5272->tx_free = NUM_TXBDS; |
||||
|
||||
/* Initialize empty rx descriptor ring */ |
||||
for (i = 0; i < NUM_RXBDS-1; i++) |
||||
mcf5272->rxbd_a[i].flags = 0; |
||||
/* Set wrap bit for last descriptor */ |
||||
mcf5272->rxbd_a[i].flags = MCF5272_FEC_RX_BD_W; |
||||
/* Initialize rx indexes */ |
||||
mcf5272->rx_remove = mcf5272->rx_insert = 0; |
||||
|
||||
/* Fill receive descriptor ring */ |
||||
fill_rx_ring(mcf5272); |
||||
|
||||
/* Enable FEC */ |
||||
MCF5272_WR_FEC_ECR(imm, (MCF5272_FEC_ECR_ETHER_EN));// | 0x2000000));
|
||||
|
||||
/* Indicate that there have been empty receive buffers produced */ |
||||
MCF5272_WR_FEC_RDAR(imm,1); |
||||
} |
||||
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/ |
||||
static void |
||||
disable_fec(mcf5272if_t *mcf5272) |
||||
{ |
||||
MCF5272_IMM *imm = mcf5272->imm; |
||||
int i; |
||||
u32_t value; |
||||
u32_t old_level; |
||||
|
||||
/* We need to disable interrupts here, It is important when dealing with shared
|
||||
registers. */ |
||||
old_level = sys_arch_protect(); |
||||
|
||||
/* First disable the FEC interrupts. Do it in the appropriate ICR register. */ |
||||
value = MCF5272_RD_SIM_ICR3(imm); |
||||
MCF5272_WR_SIM_ICR3(imm, (value & ~(MCF5272_SIM_ICR_ERX_IL(7) | |
||||
MCF5272_SIM_ICR_ETX_IL(7) | |
||||
MCF5272_SIM_ICR_ENTC_IL(7)))); |
||||
|
||||
/* Now we can restore interrupts. This is because we can assume that
|
||||
* we are single threaded here (only 1 thread will be calling disable_fec |
||||
* for THIS interface). */ |
||||
sys_arch_unprotect(old_level); |
||||
|
||||
/* Release all buffers attached to the descriptors. Since the driver
|
||||
* ALWAYS zeros the pbuf array locations and descriptors when buffers are |
||||
* removed, we know we just have to free any non-zero descriptors */ |
||||
for (i = 0; i < NUM_RXBDS; i++) |
||||
if (mcf5272->rx_pbuf_a[i]) |
||||
{ |
||||
pbuf_free(mcf5272->rx_pbuf_a[i]); |
||||
mcf5272->rx_pbuf_a[i] = 0; |
||||
mcf5272->rxbd_a->p_buf = 0; |
||||
} |
||||
for (i = 0; i < NUM_TXBDS; i++) |
||||
if (mcf5272->tx_pbuf_a[i]) |
||||
{ |
||||
pbuf_free(mcf5272->tx_pbuf_a[i]); |
||||
mcf5272->tx_pbuf_a[i] = 0; |
||||
mcf5272->txbd_a->p_buf = 0; |
||||
} |
||||
|
||||
/* Reset the FEC - equivalent to a hard reset */ |
||||
MCF5272_WR_FEC_ECR(imm,MCF5272_FEC_ECR_RESET); |
||||
/* Wait for the reset sequence to complete, it should take about 16 clock cycles */ |
||||
i = 0; |
||||
while (MCF5272_RD_FEC_ECR(imm) & MCF5272_FEC_ECR_RESET)
|
||||
{ |
||||
if (++i > 100) |
||||
abort(); |
||||
} |
||||
|
||||
/* Disable all FEC interrupts by clearing the IMR register */ |
||||
MCF5272_WR_FEC_IMR(imm,0); |
||||
/* Clear any interrupts by setting all bits in the EIR register */ |
||||
MCF5272_WR_FEC_EIR(imm,0xFFFFFFFF); |
||||
} |
||||
|
||||
/*-----------------------------------------------------------------------------------*
|
||||
* Function called by receive LISR to disable fec tx interrupt |
||||
*-----------------------------------------------------------------------------------*/ |
||||
static void |
||||
mcf5272_dis_tx_int(void) |
||||
{ |
||||
mcf5272if_t *mcf5272 = mcf5272if; |
||||
MCF5272_IMM *imm = mcf5272->imm; |
||||
u32_t value; |
||||
|
||||
value = MCF5272_RD_FEC_IMR(imm); |
||||
/* Clear rx interrupt bit */ |
||||
MCF5272_WR_FEC_IMR(imm, (value & ~MCF5272_FEC_IMR_TXFEN)); |
||||
return; |
||||
} |
||||
|
||||
/*-----------------------------------------------------------------------------------*
|
||||
*-----------------------------------------------------------------------------------*/ |
||||
static void mcf5272fec_tx_hisr(void) |
||||
{ |
||||
/* Just signal task that it can run and cleanup */ |
||||
sys_sem_signal(tx_sem); |
||||
} |
||||
|
||||
/*-----------------------------------------------------------------------------------*
|
||||
This function must be run as a task, since it ends up calling free() through pbuf_free() |
||||
*-----------------------------------------------------------------------------------*/ |
||||
static void |
||||
mcf5272fec_tx_cleanup(void) |
||||
{ |
||||
struct pbuf *p; |
||||
mcf5272if_t *mcf5272 = mcf5272if; |
||||
MCF5272_IMM *imm = mcf5272->imm; |
||||
u32_t value; |
||||
u32_t old_level; |
||||
unsigned int tx_remove_sof; |
||||
unsigned int tx_remove_eof; |
||||
unsigned int i; |
||||
u16_t flags; |
||||
|
||||
|
||||
tx_remove_sof = tx_remove_eof = mcf5272->tx_remove; |
||||
/* We must protect reading the flags and then reading the buffer pointer. They must
|
||||
both be read together. */ |
||||
old_level = sys_arch_protect(); |
||||
/* Loop, looking for completed buffers at eof */ |
||||
while ((((flags = mcf5272->txbd_a[tx_remove_eof].flags) & MCF5272_FEC_TX_BD_R) == 0) && |
||||
(mcf5272->tx_pbuf_a[tx_remove_eof] != 0)) |
||||
{ |
||||
/* See if this is last buffer in frame */ |
||||
if ((flags & MCF5272_FEC_TX_BD_L) != 0) |
||||
{ |
||||
i = tx_remove_eof; |
||||
/* This frame is complete. Take the frame off backwards */ |
||||
do |
||||
{ |
||||
p = mcf5272->tx_pbuf_a[i]; |
||||
mcf5272->tx_pbuf_a[i] = 0; |
||||
mcf5272->txbd_a[i].p_buf = 0; |
||||
mcf5272->tx_free++; |
||||
if (i != tx_remove_sof) |
||||
DEC_TX_BD_INDEX(i); |
||||
else |
||||
break; |
||||
} while (1); |
||||
|
||||
sys_arch_unprotect(old_level); |
||||
pbuf_free(p); // Will be head of chain
|
||||
old_level = sys_arch_protect(); |
||||
/* Look at next descriptor */ |
||||
INC_TX_BD_INDEX(tx_remove_eof); |
||||
tx_remove_sof = tx_remove_eof; |
||||
} |
||||
else |
||||
INC_TX_BD_INDEX(tx_remove_eof); |
||||
} |
||||
mcf5272->tx_remove = tx_remove_sof; |
||||
|
||||
/* clear interrupt status for tx interrupt */ |
||||
MCF5272_WR_FEC_EIR(imm, MCF5272_FEC_EIR_TXF); |
||||
value = MCF5272_RD_FEC_IMR(imm); |
||||
/* Set tx interrupt bit again */ |
||||
MCF5272_WR_FEC_IMR(imm, (value | MCF5272_FEC_IMR_TXFEN)); |
||||
/* Now we can re-enable higher priority interrupts again */ |
||||
sys_arch_unprotect(old_level); |
||||
} |
||||
|
||||
|
||||
/*-----------------------------------------------------------------------------------*
|
||||
void low_level_output(mcf5272if_t *mcf5272, struct pbuf *p) |
||||
|
||||
Output pbuf chain to hardware. It is assumed that there is a complete and correct |
||||
ethernet frame in p. The only buffering we have in this system is in the |
||||
hardware descriptor ring. If there is no room on the ring, then drop the frame. |
||||
*-----------------------------------------------------------------------------------*/ |
||||
static err_t |
||||
low_level_output(struct netif *netif, struct pbuf *p) |
||||
{ |
||||
struct pbuf *q; |
||||
mcf5272if_t *mcf5272 = netif->state; |
||||
MCF5272_IMM *imm = mcf5272->imm; |
||||
int num_desc; |
||||
int num_free; |
||||
unsigned int tx_insert_sof, tx_insert_eof; |
||||
unsigned int i; |
||||
u32_t old_level; |
||||
|
||||
/* Make sure that there are no PBUF_REF buffers in the chain. These buffers
|
||||
have to be freed immediately and this ethernet driver puts the buffers on |
||||
the dma chain, so they get freed later */ |
||||
p = pbuf_take(p); |
||||
/* Interrupts are disabled through this whole thing to support multi-threading
|
||||
* transmit calls. Also this function might be called from an ISR. */ |
||||
old_level = sys_arch_protect(); |
||||
|
||||
/* Determine number of descriptors needed */ |
||||
num_desc = pbuf_clen(p); |
||||
if (num_desc > mcf5272->tx_free) |
||||
{ |
||||
/* Drop the frame, we have no place to put it */ |
||||
#ifdef LINK_STATS |
||||
lwip_stats.link.memerr++; |
||||
#endif |
||||
sys_arch_unprotect(old_level); |
||||
return ERR_MEM; |
||||
|
||||
} else { |
||||
/* Increment use count on pbuf */ |
||||
pbuf_ref(p); |
||||
|
||||
/* Put buffers on descriptor ring, but don't mark them as ready yet */ |
||||
tx_insert_eof = tx_insert_sof = mcf5272->tx_insert; |
||||
q = p; |
||||
do |
||||
{ |
||||
mcf5272->tx_free--; |
||||
mcf5272->tx_pbuf_a[tx_insert_eof] = q; |
||||
mcf5272->txbd_a[tx_insert_eof].p_buf = q->payload; |
||||
mcf5272->txbd_a[tx_insert_eof].data_len = q->len; |
||||
q = q->next; |
||||
if (q) |
||||
INC_TX_BD_INDEX(tx_insert_eof); |
||||
} while (q); |
||||
|
||||
/* Go backwards through descriptor ring setting flags */ |
||||
i = tx_insert_eof; |
||||
do |
||||
{ |
||||
mcf5272->txbd_a[i].flags = (u16_t) (MCF5272_FEC_TX_BD_R | |
||||
(mcf5272->txbd_a[i].flags & MCF5272_FEC_TX_BD_W) | |
||||
((i == tx_insert_eof) ? (MCF5272_FEC_TX_BD_L | MCF5272_FEC_TX_BD_TC) : 0)); |
||||
if (i != tx_insert_sof) |
||||
DEC_TX_BD_INDEX(i); |
||||
else |
||||
break; |
||||
} while (1); |
||||
INC_TX_BD_INDEX(tx_insert_eof); |
||||
mcf5272->tx_insert = tx_insert_eof; |
||||
#ifdef LINK_STATS |
||||
lwip_stats.link.xmit++; |
||||
#endif |
||||
/* Indicate that there has been a transmit buffer produced */ |
||||
MCF5272_WR_FEC_TDAR(imm,1); |
||||
sys_arch_unprotect(old_level); |
||||
} |
||||
return ERR_OK; |
||||
} |
||||
|
||||
/*-----------------------------------------------------------------------------------*/ |
||||
static void |
||||
eth_input(struct pbuf *p, struct netif *netif) |
||||
{ |
||||
/* Ethernet protocol layer */ |
||||
struct eth_hdr *ethhdr; |
||||
mcf5272if_t *mcf5272 = netif->state; |
||||
|
||||
ethhdr = p->payload; |
||||
|
||||
switch (htons(ethhdr->type)) { |
||||
case ETHTYPE_IP: |
||||
etharp_ip_input(netif, p); |
||||
pbuf_header(p, -14); |
||||
netif->input(p, netif); |
||||
break; |
||||
case ETHTYPE_ARP: |
||||
etharp_arp_input(netif, mcf5272->ethaddr, p); |
||||
break; |
||||
default: |
||||
pbuf_free(p); |
||||
break; |
||||
} |
||||
} |
||||
|
||||
/*-----------------------------------------------------------------------------------*/ |
||||
static void |
||||
arp_timer(void *arg) |
||||
{ |
||||
etharp_tmr(); |
||||
sys_timeout(ARP_TMR_INTERVAL, (sys_timeout_handler)arp_timer, NULL); |
||||
} |
||||
|
||||
/*-----------------------------------------------------------------------------------*
|
||||
* Function called by receive LISR to disable fec rx interrupt |
||||
*-----------------------------------------------------------------------------------*/ |
||||
static void |
||||
mcf5272_dis_rx_int(void) |
||||
{ |
||||
mcf5272if_t *mcf5272 = mcf5272if; |
||||
MCF5272_IMM *imm = mcf5272->imm; |
||||
u32_t value; |
||||
|
||||
value = MCF5272_RD_FEC_IMR(imm); |
||||
/* Clear rx interrupt bit */ |
||||
MCF5272_WR_FEC_IMR(imm, (value & ~MCF5272_FEC_IMR_RXFEN)); |
||||
return; |
||||
} |
||||
|
||||
/*-----------------------------------------------------------------------------------*/ |
||||
static void |
||||
mcf5272fec_rx(void) |
||||
{ |
||||
/* This is the receive ISR. It is written to be a high-level ISR. */ |
||||
u32_t old_level; |
||||
mcf5272if_t *mcf5272 = mcf5272if; |
||||
MCF5272_IMM *imm = mcf5272->imm; |
||||
u32_t value; |
||||
u16_t flags; |
||||
unsigned int rx_remove_sof; |
||||
unsigned int rx_remove_eof; |
||||
struct pbuf *p; |
||||
|
||||
|
||||
rx_remove_sof = rx_remove_eof = mcf5272->rx_remove; |
||||
|
||||
/* Loop, looking for filled buffers at eof */ |
||||
while ((((flags = mcf5272->rxbd_a[rx_remove_eof].flags) & MCF5272_FEC_RX_BD_E) == 0) && |
||||
(mcf5272->rx_pbuf_a[rx_remove_eof] != 0)) |
||||
{ |
||||
/* See if this is last buffer in frame */ |
||||
if ((flags & MCF5272_FEC_RX_BD_L) != 0) |
||||
{ |
||||
/* This frame is ready to go. Start at first descriptor in frame. */ |
||||
p = 0; |
||||
do |
||||
{ |
||||
/* Adjust pbuf length if this is last buffer in frame */ |
||||
if (rx_remove_sof == rx_remove_eof) |
||||
{ |
||||
mcf5272->rx_pbuf_a[rx_remove_sof]->tot_len = |
||||
mcf5272->rx_pbuf_a[rx_remove_sof]->len = (u16_t) |
||||
(mcf5272->rxbd_a[rx_remove_sof].data_len - (p ? p->tot_len : 0)); |
||||
} |
||||
else |
||||
mcf5272->rx_pbuf_a[rx_remove_sof]->len = |
||||
mcf5272->rx_pbuf_a[rx_remove_sof]->tot_len = mcf5272->rxbd_a[rx_remove_sof].data_len; |
||||
|
||||
/* Chain pbuf */ |
||||
if (p == 0) |
||||
{ |
||||
p = mcf5272->rx_pbuf_a[rx_remove_sof]; // First in chain
|
||||
p->tot_len = p->len; // Important since len might have changed
|
||||
} else { |
||||
pbuf_chain(p, mcf5272->rx_pbuf_a[rx_remove_sof]); |
||||
pbuf_free(mcf5272->rx_pbuf_a[rx_remove_sof]); |
||||
} |
||||
|
||||
/* Clear pointer to mark descriptor as free */ |
||||
mcf5272->rx_pbuf_a[rx_remove_sof] = 0; |
||||
mcf5272->rxbd_a[rx_remove_sof].p_buf = 0; |
||||
|
||||
if (rx_remove_sof != rx_remove_eof) |
||||
INC_RX_BD_INDEX(rx_remove_sof); |
||||
else |
||||
break; |
||||
|
||||
} while (1); |
||||
INC_RX_BD_INDEX(rx_remove_sof); |
||||
|
||||
/* Check error status of frame */ |
||||
if (flags & (MCF5272_FEC_RX_BD_LG | |
||||
MCF5272_FEC_RX_BD_NO | |
||||
MCF5272_FEC_RX_BD_CR | |
||||
MCF5272_FEC_RX_BD_OV)) |
||||
{ |
||||
#ifdef LINK_STATS |
||||
lwip_stats.link.drop++; |
||||
if (flags & MCF5272_FEC_RX_BD_LG) |
||||
lwip_stats.link.lenerr++; //Jumbo gram
|
||||
else |
||||
if (flags & (MCF5272_FEC_RX_BD_NO | MCF5272_FEC_RX_BD_OV)) |
||||
lwip_stats.link.err++; |
||||
else |
||||
if (flags & MCF5272_FEC_RX_BD_CR) |
||||
lwip_stats.link.chkerr++; // CRC errors
|
||||
#endif |
||||
/* Drop errored frame */ |
||||
pbuf_free(p); |
||||
} else { |
||||
/* Good frame. increment stat */ |
||||
#ifdef LINK_STATS |
||||
lwip_stats.link.recv++; |
||||
#endif |
||||
eth_input(p, mcf5272->netif); |
||||
} |
||||
} |
||||
INC_RX_BD_INDEX(rx_remove_eof); |
||||
} |
||||
mcf5272->rx_remove = rx_remove_sof; |
||||
|
||||
/* clear interrupt status for rx interrupt */ |
||||
old_level = sys_arch_protect(); |
||||
MCF5272_WR_FEC_EIR(imm, MCF5272_FEC_EIR_RXF); |
||||
value = MCF5272_RD_FEC_IMR(imm); |
||||
/* Set rx interrupt bit again */ |
||||
MCF5272_WR_FEC_IMR(imm, (value | MCF5272_FEC_IMR_RXFEN)); |
||||
/* Now we can re-enable higher priority interrupts again */ |
||||
sys_arch_unprotect(old_level); |
||||
|
||||
/* Fill up empty descriptor rings */ |
||||
fill_rx_ring(mcf5272); |
||||
/* Tell fec that we have filled up her ring */ |
||||
MCF5272_WR_FEC_RDAR(imm, 1); |
||||
|
||||
return; |
||||
} |
||||
|
||||
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/ |
||||
static void |
||||
low_level_init(struct netif *netif) |
||||
{ |
||||
mcf5272if_t *mcf5272; |
||||
MCF5272_IMM *imm; |
||||
VOID (*old_lisr)(INT); /* old LISR */ |
||||
u32_t value; |
||||
u32_t old_level; |
||||
struct pbuf *p; |
||||
int i; |
||||
|
||||
mcf5272 = netif->state; |
||||
imm = mcf5272->imm; |
||||
|
||||
/* Initialize our ethernet address */ |
||||
sys_get_eth_addr(mcf5272->ethaddr); |
||||
|
||||
/* First disable fec */ |
||||
disable_fec(mcf5272); |
||||
|
||||
/* Plug appropriate low level interrupt vectors */ |
||||
sys_setvect(MCF5272_VECTOR_ERx, mcf5272fec_rx, mcf5272_dis_rx_int); |
||||
sys_setvect(MCF5272_VECTOR_ETx, mcf5272fec_tx_hisr, mcf5272_dis_tx_int); |
||||
//sys_setvect(MCF5272_VECTOR_ENTC, mcf5272fec_ntc);
|
||||
|
||||
/* Set the I_MASK register to enable only rx & tx frame interrupts */ |
||||
MCF5272_WR_FEC_IMR(imm, MCF5272_FEC_IMR_TXFEN | MCF5272_FEC_IMR_RXFEN); |
||||
|
||||
/* Clear I_EVENT register */ |
||||
MCF5272_WR_FEC_EIR(imm,0xFFFFFFFF); |
||||
|
||||
/* Set up the appropriate interrupt levels */ |
||||
/* Disable interrupts, since this is a read/modify/write operation */ |
||||
old_level = sys_arch_protect(); |
||||
value = MCF5272_RD_SIM_ICR3(imm); |
||||
MCF5272_WR_SIM_ICR3(imm, value | MCF5272_SIM_ICR_ERX_IL(FEC_LEVEL) | |
||||
MCF5272_SIM_ICR_ETX_IL(FEC_LEVEL)); |
||||
sys_arch_unprotect(old_level); |
||||
|
||||
/* Set the source address for the controller */ |
||||
MCF5272_WR_FEC_MALR(imm,0
|
||||
| (mcf5272->ethaddr->addr[0] <<24)
|
||||
| (mcf5272->ethaddr->addr[1] <<16)
|
||||
| (mcf5272->ethaddr->addr[2] <<8)
|
||||
| (mcf5272->ethaddr->addr[3] <<0));
|
||||
MCF5272_WR_FEC_MAUR(imm,0 |
||||
| (mcf5272->ethaddr->addr[4] <<24) |
||||
| (mcf5272->ethaddr->addr[5] <<16)); |
||||
|
||||
/* Initialize the hash table registers */ |
||||
/* We are not supporting multicast addresses */ |
||||
MCF5272_WR_FEC_HTUR(imm,0); |
||||
MCF5272_WR_FEC_HTLR(imm,0); |
||||
|
||||
/* Set Receive Buffer Size. We subtract 16 because the start of the receive
|
||||
* buffer MUST be divisible by 16, so depending on where the payload really |
||||
* starts in the pbuf, we might be increasing the start point by up to 15 bytes. |
||||
* See the alignment code in fill_rx_ring() */ |
||||
/* There might be an offset to the payload address and we should subtract
|
||||
* that offset */ |
||||
p = pbuf_alloc(PBUF_RAW, PBUF_POOL_BUFSIZE, PBUF_POOL); |
||||
i = 0; |
||||
if (p) |
||||
{ |
||||
struct pbuf *q = p; |
||||
|
||||
while ((q = q->next) != 0) |
||||
i += q->len; |
||||
mcf5272->rx_buf_len = PBUF_POOL_BUFSIZE-16-i; |
||||
pbuf_free(p); |
||||
} |
||||
|
||||
|
||||
MCF5272_WR_FEC_EMRBR(imm, (u16_t) mcf5272->rx_buf_len); |
||||
|
||||
/* Point to the start of the circular Rx buffer descriptor queue */ |
||||
MCF5272_WR_FEC_ERDSR(imm, ((u32_t) &mcf5272->rxbd_a[0])); |
||||
|
||||
/* Point to the start of the circular Tx buffer descriptor queue */ |
||||
MCF5272_WR_FEC_ETDSR(imm, ((u32_t) &mcf5272->txbd_a[0])); |
||||
|
||||
/* Set the tranceiver interface to MII mode */ |
||||
MCF5272_WR_FEC_RCR(imm, 0 |
||||
| MCF5272_FEC_RCR_MII_MODE |
||||
| MCF5272_FEC_RCR_DRT); /* half duplex */ |
||||
|
||||
/* Only operate in half-duplex, no heart beat control */ |
||||
MCF5272_WR_FEC_TCR(imm, 0); |
||||
|
||||
/* Set the maximum frame length (MTU) */ |
||||
MCF5272_WR_FEC_MFLR(imm, MTU_FEC); |
||||
|
||||
/* Set MII bus speed */ |
||||
MCF5272_WR_FEC_MSCR(imm, 0x0a); |
||||
|
||||
/* Enable fec i/o pins */ |
||||
value = MCF5272_RD_GPIO_PBCNT(imm); |
||||
MCF5272_WR_GPIO_PBCNT(imm, ((value & 0x0000ffff) | 0x55550000)); |
||||
|
||||
/* Clear MII interrupt status */ |
||||
MCF5272_WR_FEC_EIR(imm, MCF5272_FEC_IMR_MIIEN); |
||||
|
||||
/* /\* Read phy ID *\/ */ |
||||
/* MCF5272_WR_FEC_MMFR(imm, 0x600a0000); */ |
||||
/* while (1) */ |
||||
/* { */ |
||||
/* value = MCF5272_RD_FEC_EIR(imm); */ |
||||
/* if ((value & MCF5272_FEC_IMR_MIIEN) != 0) */ |
||||
/* { */ |
||||
/* MCF5272_WR_FEC_EIR(imm, MCF5272_FEC_IMR_MIIEN); */ |
||||
/* break; */ |
||||
/* } */ |
||||
/* } */ |
||||
/* phy = MCF5272_RD_FEC_MMFR(imm); */ |
||||
|
||||
/* Enable FEC */ |
||||
enable_fec(mcf5272); |
||||
|
||||
/* THIS IS FOR LEVEL ONE/INTEL PHY ONLY!!! */ |
||||
/* Program Phy LED 3 to tell us transmit status */ |
||||
MCF5272_WR_FEC_MMFR(imm, 0x50520412); |
||||
|
||||
} |
||||
|
||||
/*-----------------------------------------------------------------------------------*
|
||||
* etharp timer thread |
||||
* It's only job is to initialize the timer, create a semaphore and wait on it |
||||
* forever. We need a special task to handle the arp timer. |
||||
*-----------------------------------------------------------------------------------*/ |
||||
static void |
||||
etharp_timer_thread(void *arg) |
||||
{ |
||||
sys_sem_t *psem = (sys_sem_t *) arg; |
||||
|
||||
/* Create timeout timer */ |
||||
sys_timeout(ARP_TMR_INTERVAL, (sys_timeout_handler)arp_timer, NULL); |
||||
/* Signal previous task that it can go */ |
||||
sys_sem_signal(*psem); |
||||
|
||||
tx_sem = sys_sem_new(0); |
||||
|
||||
while (1) |
||||
{ |
||||
sys_sem_wait(tx_sem); |
||||
mcf5272fec_tx_cleanup(); |
||||
} |
||||
} |
||||
|
||||
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/ |
||||
static void |
||||
etharp_timer_init(void *arg) |
||||
{ |
||||
sys_thread_new(DEFAULT_THREAD_NAME, (void *)etharp_timer_thread, arg, DEFAULT_THREAD_STACKSIZE, DEFAULT_THREAD_PRIO); |
||||
} |
||||
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/ |
||||
/*
|
||||
* mcf5272fecif_init(struct netif *netif): |
||||
* |
||||
* Should be called at the beginning of the program to set up the |
||||
* network interface. It calls the function low_level_init() to do the |
||||
* actual setup of the hardware. |
||||
* |
||||
* Note that there is only one fec in a 5272! |
||||
* |
||||
*/ |
||||
err_t |
||||
mcf5272fecif_init(struct netif *netif) |
||||
{ |
||||
sys_sem_t sem; |
||||
|
||||
/* Allocate our interface control block */ |
||||
/* IMPORTANT NOTE: This works for 5272, but if you are using a cpu with data cache
|
||||
* then you need to make sure you get this memory from non-cachable memory. */ |
||||
mcf5272if = (mcf5272if_t *) calloc(1, sizeof(mcf5272if_t)); |
||||
if (mcf5272if) |
||||
{ |
||||
netif->state = mcf5272if; |
||||
mcf5272if->netif = netif; |
||||
netif->name[0] = IFNAME0; |
||||
netif->name[1] = IFNAME1; |
||||
netif->output = etharp_output; |
||||
netif->linkoutput = low_level_output; |
||||
netif->mtu = MTU_FEC - 18; // mtu without ethernet header and crc
|
||||
mcf5272if->ethaddr = (struct eth_addr *)&(netif->hwaddr[0]); |
||||
netif->hwaddr_len = 6; /* Ethernet interface */ |
||||
mcf5272if->imm = mcf5272_get_immp(); |
||||
|
||||
low_level_init(netif); |
||||
|
||||
etharp_init(); |
||||
sem = sys_sem_new(0); |
||||
etharp_timer_init(&sem); |
||||
sys_sem_wait(sem); |
||||
sys_sem_free(sem); |
||||
|
||||
return ERR_OK; |
||||
} |
||||
else |
||||
return ERR_MEM; |
||||
} |
||||
|
||||
/*-----------------------------------------------------------------------------------*/ |
||||
@ -1,50 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001-2003 Swedish Institute of Computer Science. |
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met: |
||||
* |
||||
* 1. Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, |
||||
* this list of conditions and the following disclaimer in the documentation |
||||
* and/or other materials provided with the distribution. |
||||
* 3. The name of the author may not be used to endorse or promote products |
||||
* derived from this software without specific prior written permission.
|
||||
* |
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE. |
||||
* |
||||
* This file is part of the lwIP TCP/IP stack. |
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se> |
||||
* |
||||
*/ |
||||
|
||||
#include <stdio.h> |
||||
|
||||
#include "netif/tcpdump.h" |
||||
#include "lwip/ip.h" |
||||
#include "lwip/tcp.h" |
||||
#include "lwip/udp.h" |
||||
#include "lwip/inet.h" |
||||
|
||||
/*-----------------------------------------------------------------------------------*/ |
||||
void |
||||
tcpdump(struct pbuf *p) |
||||
{ |
||||
} |
||||
/*-----------------------------------------------------------------------------------*/ |
||||
|
||||
|
||||
|
||||
|
||||
@ -1,38 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001-2003 Swedish Institute of Computer Science. |
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met: |
||||
* |
||||
* 1. Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, |
||||
* this list of conditions and the following disclaimer in the documentation |
||||
* and/or other materials provided with the distribution. |
||||
* 3. The name of the author may not be used to endorse or promote products |
||||
* derived from this software without specific prior written permission.
|
||||
* |
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE. |
||||
* |
||||
* This file is part of the lwIP TCP/IP stack. |
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se> |
||||
* |
||||
*/ |
||||
|
||||
#include "arch/perf.h" |
||||
|
||||
void |
||||
perf_init(char *fname) |
||||
{ |
||||
} |
||||
@ -1,204 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001-2003 Swedish Institute of Computer Science. |
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met: |
||||
* |
||||
* 1. Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, |
||||
* this list of conditions and the following disclaimer in the documentation |
||||
* and/or other materials provided with the distribution. |
||||
* 3. The name of the author may not be used to endorse or promote products |
||||
* derived from this software without specific prior written permission.
|
||||
* |
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE. |
||||
* |
||||
* This file is part of the lwIP TCP/IP stack. |
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se> |
||||
* |
||||
*/ |
||||
#ifndef __LWIPOPTS_H__ |
||||
#define __LWIPOPTS_H__ |
||||
|
||||
#define NO_SYS 0 |
||||
/*#define LWIP_EVENT_API 0*/ |
||||
|
||||
/* ---------- Memory options ---------- */ |
||||
/* MEM_ALIGNMENT: should be set to the alignment of the CPU for which
|
||||
lwIP is compiled. 4 byte alignment -> define MEM_ALIGNMENT to 4, 2 |
||||
byte alignment -> define MEM_ALIGNMENT to 2. */ |
||||
#define MEM_ALIGNMENT 4 |
||||
|
||||
/* MEM_SIZE: the size of the heap memory. If the application will send
|
||||
a lot of data that needs to be copied, this should be set high. */ |
||||
#define MEM_SIZE 65000 |
||||
|
||||
/* MEMP_NUM_PBUF: the number of memp struct pbufs. If the application
|
||||
sends a lot of data out of ROM (or other static memory), this |
||||
should be set high. */ |
||||
#define MEMP_NUM_PBUF 16 |
||||
/* MEMP_NUM_UDP_PCB: the number of UDP protocol control blocks. One
|
||||
per active UDP "connection". */ |
||||
#define MEMP_NUM_UDP_PCB 4 |
||||
/* MEMP_NUM_TCP_PCB: the number of simulatenously active TCP
|
||||
connections. */ |
||||
#define MEMP_NUM_TCP_PCB 5 |
||||
/* MEMP_NUM_TCP_PCB_LISTEN: the number of listening TCP
|
||||
connections. */ |
||||
#define MEMP_NUM_TCP_PCB_LISTEN 8 |
||||
/* MEMP_NUM_TCP_SEG: the number of simultaneously queued TCP
|
||||
segments. */ |
||||
#define MEMP_NUM_TCP_SEG 16 |
||||
|
||||
/* The following four are used only with the sequential API and can be
|
||||
set to 0 if the application only will use the raw API. */ |
||||
/* MEMP_NUM_NETBUF: the number of struct netbufs. */ |
||||
#define MEMP_NUM_NETBUF 6 |
||||
/* MEMP_NUM_NETCONN: the number of struct netconns. */ |
||||
#define MEMP_NUM_NETCONN 10 |
||||
/* MEMP_NUM_TCPIP_MSG: the number of struct tcpip_msg, which is used
|
||||
for sequential API communication and incoming packets. Used in |
||||
src/api/tcpip.c. */ |
||||
#define MEMP_NUM_TCPIP_MSG_API 16 |
||||
#define MEMP_NUM_TCPIP_MSG_INPKT 16 |
||||
/* MEMP_NUM_SYS_TIMEOUT: the number of simulateously active
|
||||
timeouts. */ |
||||
#define MEMP_NUM_SYS_TIMEOUT 3 |
||||
|
||||
/* These two control is reclaimer functions should be compiled
|
||||
in. Should always be turned on (1). */ |
||||
#define MEM_RECLAIM 1 |
||||
#define MEMP_RECLAIM 1 |
||||
|
||||
/* ---------- Pbuf options ---------- */ |
||||
/* PBUF_POOL_SIZE: the number of buffers in the pbuf pool. */ |
||||
#define PBUF_POOL_SIZE 128 |
||||
|
||||
/* PBUF_POOL_BUFSIZE: the size of each pbuf in the pbuf pool. */ |
||||
#define PBUF_POOL_BUFSIZE 1024 |
||||
|
||||
/* PBUF_LINK_HLEN: the number of bytes that should be allocated for a
|
||||
link level header. */ |
||||
#define PBUF_LINK_HLEN 16 |
||||
|
||||
/** SYS_LIGHTWEIGHT_PROT
|
||||
* define SYS_LIGHTWEIGHT_PROT in lwipopts.h if you want inter-task protection |
||||
* for certain critical regions during buffer allocation, deallocation and memory |
||||
* allocation and deallocation. |
||||
*/ |
||||
#define SYS_LIGHTWEIGHT_PROT 1 |
||||
|
||||
/* ---------- TCP options ---------- */ |
||||
#define LWIP_TCP 1 |
||||
#define TCP_TTL 255 |
||||
|
||||
/* Controls if TCP should queue segments that arrive out of
|
||||
order. Define to 0 if your device is low on memory. */ |
||||
#define TCP_QUEUE_OOSEQ 1 |
||||
|
||||
/* TCP Maximum segment size. */ |
||||
#define TCP_MSS 128 |
||||
|
||||
/* TCP sender buffer space (bytes). */ |
||||
#define TCP_SND_BUF 256 |
||||
|
||||
/* TCP sender buffer space (pbufs). This must be at least = 2 *
|
||||
TCP_SND_BUF/TCP_MSS for things to work. */ |
||||
#define TCP_SND_QUEUELEN 4 * TCP_SND_BUF/TCP_MSS |
||||
|
||||
/* TCP receive window. */ |
||||
#define TCP_WND 1024 |
||||
|
||||
/* Maximum number of retransmissions of data segments. */ |
||||
#define TCP_MAXRTX 12 |
||||
|
||||
/* Maximum number of retransmissions of SYN segments. */ |
||||
#define TCP_SYNMAXRTX 4 |
||||
|
||||
/* TCP writable space (bytes). This must be less than or equal
|
||||
to TCP_SND_BUF. It is the amount of space which must be |
||||
available in the tcp snd_buf for select to return writable */ |
||||
#define TCP_SNDLOWAT TCP_SND_BUF/2 |
||||
|
||||
/* ---------- ARP options ---------- */ |
||||
#define ARP_TABLE_SIZE 10 |
||||
#define ARP_QUEUEING 1 |
||||
|
||||
/* ---------- IP options ---------- */ |
||||
/* Define IP_FORWARD to 1 if you wish to have the ability to forward
|
||||
IP packets across network interfaces. If you are going to run lwIP |
||||
on a device with only one network interface, define this to 0. */ |
||||
#define IP_FORWARD 0 |
||||
|
||||
/* If defined to 1, IP options are allowed (but not parsed). If
|
||||
defined to 0, all packets with IP options are dropped. */ |
||||
#define IP_OPTIONS 1 |
||||
|
||||
/* IP reassembly and segmentation.These are orthogonal even
|
||||
* if they both deal with IP fragments */ |
||||
#define IP_REASSEMBLY 1 |
||||
#define IP_FRAG 1 |
||||
|
||||
/* ---------- ICMP options ---------- */ |
||||
#define ICMP_TTL 255 |
||||
|
||||
|
||||
/* ---------- DHCP options ---------- */ |
||||
/* Define LWIP_DHCP to 1 if you want DHCP configuration of
|
||||
interfaces. DHCP is not implemented in lwIP 0.5.1, however, so |
||||
turning this on does currently not work. */ |
||||
#define LWIP_DHCP 0 |
||||
|
||||
/* 1 if you want to do an ARP check on the offered address
|
||||
(recommended). */ |
||||
#define DHCP_DOES_ARP_CHECK 1 |
||||
|
||||
/* ---------- UDP options ---------- */ |
||||
#define LWIP_UDP 1 |
||||
#define UDP_TTL 255 |
||||
|
||||
|
||||
/* ---------- Statistics options ---------- */ |
||||
#define LWIP_STATS 1 |
||||
|
||||
#ifdef LWIP_STATS |
||||
#define LINK_STATS |
||||
#define IP_STATS |
||||
#define ICMP_STATS |
||||
#define UDP_STATS |
||||
#define TCP_STATS |
||||
#define MEM_STATS |
||||
#define MEMP_STATS |
||||
#define PBUF_STATS |
||||
#define SYS_STATS |
||||
#endif /* STATS */ |
||||
|
||||
|
||||
#define LWIP_COMPAT_SOCKETS 1 |
||||
#define LWIP_PROVIDE_ERRNO 1 |
||||
|
||||
/* People often make a mistake on the priority of their communications task.
|
||||
The TCP/IP stack should be at a relatively low priority if it is an endpoint |
||||
(not a router) on a somewhat underpowered CPU. You are'nt going to keep up |
||||
with network traffic during a denial of service attack or misconfigured network |
||||
and you don't want an overburdened network task to cause other important tasks |
||||
(including your UI) to stop working. Drop packets! It forces flow control and |
||||
lets the rest of your system run. |
||||
*/ |
||||
#define TCPIP_THREAD_PRIO 220 // Relatively low priority
|
||||
|
||||
#define DEFAULT_THREAD_PRIO 240 |
||||
|
||||
#endif /* __LWIPOPTS_H__ */ |
||||
@ -1,597 +0,0 @@
|
||||
/* @(#)sys_arch.c
|
||||
* Copyright (c) 2001-2003 Swedish Institute of Computer Science. |
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met: |
||||
* |
||||
* 1. Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, |
||||
* this list of conditions and the following disclaimer in the documentation |
||||
* and/or other materials provided with the distribution. |
||||
* 3. The name of the author may not be used to endorse or promote products |
||||
* derived from this software without specific prior written permission.
|
||||
* |
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE. |
||||
* |
||||
* This file is part of the lwIP TCP/IP stack. |
||||
*
|
||||
* Author: David Haas <dhaas@alum.rpi.edu> |
||||
* |
||||
*/ |
||||
|
||||
#include "lwip/debug.h" |
||||
|
||||
#include "lwip/sys.h" |
||||
#include "lwip/opt.h" |
||||
#include "lwip/stats.h" |
||||
|
||||
#include "nucleus.h" |
||||
#include "config.h" |
||||
#include <stdlib.h> |
||||
#include <string.h> |
||||
|
||||
struct sys_thread { |
||||
struct sys_thread *next; |
||||
struct sys_timeouts timeouts; |
||||
int errno_i; |
||||
NU_TASK *pthread; |
||||
void (*function)(void *arg); |
||||
void *arg; |
||||
}; |
||||
|
||||
struct sys_hisr
|
||||
{ |
||||
struct sys_hisr *next; |
||||
NU_HISR *hisr; |
||||
void (*disablefun) (void); |
||||
u32_t vector; |
||||
}; |
||||
|
||||
static int num_sem = 0; // Number of semaphores created
|
||||
static int num_mbox = 0; // Number of mailboxes created
|
||||
static int num_thread = 0; // Number of threads created
|
||||
static int num_hisr = 0; // Number of hisrs created
|
||||
static struct sys_thread *threads = NULL; |
||||
static struct sys_hisr *hisrs = NULL; |
||||
|
||||
#define TICKS_PER_SECOND 10000 |
||||
#define MS_TO_TICKS(MS) (MS * (TICKS_PER_SECOND / 1000)) |
||||
#define TICKS_TO_MS(TICKS) ((unsigned long)((1000ULL * TICKS) / TICKS_PER_SECOND)) |
||||
#define TICKS_TO_HUNDMICROSEC(TICKS) TICKS |
||||
|
||||
#define SYS_MBOX_SIZE 128 // Number of elements in mbox queue
|
||||
#define SYS_STACK_SIZE 2048 // A minimum Nucleus stack for coldfire
|
||||
#define SYS_HISR_STACK_SIZE 2048 // A minimum Nucleus stack for coldfire
|
||||
|
||||
/*---------------------------------------------------------------------------------*/ |
||||
void |
||||
sys_init(void) |
||||
{ |
||||
return; |
||||
} |
||||
|
||||
/*---------------------------------------------------------------------------------*/ |
||||
static void |
||||
sys_thread_entry(UNSIGNED argc, VOID *argv) |
||||
{ |
||||
/* argv is passed as a pointer to our thread structure */ |
||||
struct sys_thread *p_thread = (struct sys_thread *)argv; |
||||
|
||||
p_thread->function(p_thread->arg); |
||||
} |
||||
|
||||
/*---------------------------------------------------------------------------------*/ |
||||
static struct sys_thread *
|
||||
introduce_thread(NU_TASK *id, void (*function)(void *arg), void *arg) |
||||
{ |
||||
struct sys_thread *thread; |
||||
sys_prot_t old_level; |
||||
|
||||
thread = (struct sys_thread *) calloc(1,sizeof(struct sys_thread)); |
||||
|
||||
if (thread) { |
||||
old_level = sys_arch_protect(); |
||||
thread->next = threads; |
||||
thread->timeouts.next = NULL; |
||||
thread->pthread = id; |
||||
thread->function = function; |
||||
thread->arg = arg; |
||||
threads = thread; |
||||
sys_arch_unprotect(old_level); |
||||
} |
||||
|
||||
return thread; |
||||
} |
||||
|
||||
/*---------------------------------------------------------------------------------*/ |
||||
/* We use Nucleus task as thread. Create one with a standard size stack at a standard
|
||||
* priority. */ |
||||
sys_thread_t |
||||
sys_thread_new(char *name, void (* function)(void *arg), void *arg, int stacksize, int prio) |
||||
{ |
||||
NU_TASK *p_thread; |
||||
u8_t *p_stack; |
||||
STATUS status; |
||||
char thread_name[8] = " "; |
||||
struct sys_thread *st; |
||||
|
||||
/** @todo Replace SYS_STACK_SIZE by "stacksize" parameter, perhaps use "name" if it is prefered */ |
||||
|
||||
p_stack = (u8_t *) malloc(SYS_STACK_SIZE); |
||||
if (p_stack) |
||||
{ |
||||
p_thread = (NU_TASK *) calloc(1,sizeof(NU_TASK)); |
||||
if (p_thread) |
||||
{ |
||||
/* get a new thread structure */ |
||||
st = introduce_thread(p_thread, function, arg); |
||||
if (st) |
||||
{ |
||||
num_thread = (num_thread +1) % 100; // Only count to 99
|
||||
sprintf(thread_name, "lwip%02d", num_thread); |
||||
thread_name[strlen(thread_name)] = ' '; |
||||
|
||||
status = NU_Create_Task(p_thread, |
||||
thread_name, |
||||
sys_thread_entry, |
||||
0, |
||||
st, |
||||
p_stack, |
||||
SYS_STACK_SIZE, |
||||
prio, |
||||
0, //Disable timeslicing
|
||||
NU_PREEMPT, |
||||
NU_START); |
||||
if (status == NU_SUCCESS) |
||||
return p_thread; |
||||
} |
||||
|
||||
} |
||||
} |
||||
abort(); |
||||
} |
||||
|
||||
/*-----------------------------------------------------------------------------------*/ |
||||
static struct sys_thread * |
||||
current_thread(void) |
||||
{ |
||||
struct sys_thread *st; |
||||
sys_prot_t old_level; |
||||
NU_TASK *pt; |
||||
|
||||
pt = NU_Current_Task_Pointer(); |
||||
old_level = sys_arch_protect(); |
||||
|
||||
for(st = threads; st != NULL; st = st->next) |
||||
{
|
||||
if (st->pthread == pt) |
||||
{ |
||||
sys_arch_unprotect(old_level); |
||||
return st; |
||||
} |
||||
} |
||||
|
||||
sys_arch_unprotect(old_level); |
||||
st = introduce_thread(pt, 0, 0); |
||||
|
||||
if (!st) { |
||||
abort(); |
||||
} |
||||
|
||||
return st; |
||||
} |
||||
|
||||
|
||||
/*---------------------------------------------------------------------------------*/ |
||||
struct sys_timeouts * |
||||
sys_arch_timeouts(void) |
||||
{ |
||||
struct sys_thread *thread; |
||||
|
||||
thread = current_thread(); |
||||
return &thread->timeouts; |
||||
} |
||||
/*---------------------------------------------------------------------------------*/ |
||||
int * |
||||
sys_arch_errno(void) |
||||
{ |
||||
struct sys_thread *thread; |
||||
|
||||
thread = current_thread(); |
||||
return &thread->errno_i; |
||||
} |
||||
|
||||
/*---------------------------------------------------------------------------------*/ |
||||
sys_sem_t |
||||
sys_sem_new(u8_t count) |
||||
{ |
||||
STATUS status; |
||||
NU_SEMAPHORE *sem; |
||||
char sem_name[8] = " "; |
||||
|
||||
#ifdef SYS_STATS |
||||
lwip_stats.sys.sem.used++; |
||||
if (lwip_stats.sys.sem.used > lwip_stats.sys.sem.max) |
||||
{ |
||||
lwip_stats.sys.sem.max = lwip_stats.sys.sem.used; |
||||
} |
||||
#endif /* SYS_STATS */ |
||||
|
||||
/* Get memory for new semaphore */ |
||||
sem = (NU_SEMAPHORE *) calloc(1,sizeof(NU_SEMAPHORE)); |
||||
|
||||
if (sem) |
||||
{ |
||||
/* Create a unique name for semaphore based on number created */ |
||||
num_sem = (num_sem + 1) % 100; // Only count to 99
|
||||
sprintf(sem_name, "lwip%02d", num_sem); |
||||
sem_name[strlen(sem_name)] = ' '; |
||||
|
||||
/* Ask nucleus to create semaphore */ |
||||
NU_Create_Semaphore(sem, |
||||
sem_name, |
||||
count, |
||||
NU_FIFO); |
||||
} |
||||
return sem; |
||||
} |
||||
|
||||
/*---------------------------------------------------------------------------------*/ |
||||
void |
||||
sys_sem_free(sys_sem_t sem) |
||||
{ |
||||
if (sem != SYS_SEM_NULL) |
||||
{ |
||||
#ifdef SYS_STATS |
||||
lwip_stats.sys.sem.used--; |
||||
#endif /* SYS_STATS */ |
||||
NU_Delete_Semaphore(sem); |
||||
free(sem); |
||||
} |
||||
} |
||||
|
||||
/*---------------------------------------------------------------------------------*/ |
||||
void |
||||
sys_sem_signal(sys_sem_t sem) |
||||
{ |
||||
NU_Release_Semaphore(sem); |
||||
} |
||||
|
||||
/*---------------------------------------------------------------------------------*/ |
||||
u32_t |
||||
sys_arch_sem_wait(sys_sem_t sem, u32_t timeout) |
||||
{ |
||||
UNSIGNED timestart, timespent; |
||||
STATUS status; |
||||
|
||||
/* Get the current time */ |
||||
timestart = NU_Retrieve_Clock(); |
||||
/* Wait for the semaphore */ |
||||
status = NU_Obtain_Semaphore(sem, |
||||
timeout ? MS_TO_TICKS(timeout) : NU_SUSPEND); |
||||
/* This next statement takes wraparound into account. It works. Really! */ |
||||
timespent = TICKS_TO_HUNDMICROSEC(((s32_t) ((s32_t) NU_Retrieve_Clock() - (s32_t) timestart))); |
||||
|
||||
if (status == NU_TIMEOUT) |
||||
return SYS_ARCH_TIMEOUT; |
||||
else |
||||
/* Round off to milliseconds */ |
||||
return (timespent+5)/10; |
||||
} |
||||
|
||||
/*---------------------------------------------------------------------------------*/ |
||||
sys_mbox_t |
||||
sys_mbox_new(void) |
||||
{ |
||||
u32_t *p_queue_mem; |
||||
NU_QUEUE *p_queue; |
||||
char queue_name[8] = " "; |
||||
|
||||
/* Allocate memory for queue */ |
||||
p_queue_mem = (u32_t *) calloc(1,(SYS_MBOX_SIZE * sizeof(u32_t))); |
||||
if (p_queue_mem) |
||||
{ |
||||
/* Allocate memory for queue control block */ |
||||
p_queue = (NU_QUEUE *) calloc(1,sizeof(NU_QUEUE)); |
||||
if (p_queue) |
||||
{ |
||||
/* Create a unique name for mbox based on number created */ |
||||
num_mbox = (num_mbox + 1) % 100; |
||||
sprintf(queue_name, "lwip%02d", num_mbox); |
||||
queue_name[strlen(queue_name)] = ' '; |
||||
|
||||
NU_Create_Queue(p_queue, |
||||
queue_name, |
||||
p_queue_mem, |
||||
SYS_MBOX_SIZE, |
||||
NU_FIXED_SIZE, |
||||
1, |
||||
NU_FIFO); |
||||
#ifdef SYS_STATS |
||||
lwip_stats.sys.mbox.used++; |
||||
if (lwip_stats.sys.mbox.used > lwip_stats.sys.mbox.max) { |
||||
lwip_stats.sys.mbox.max = lwip_stats.sys.mbox.used; |
||||
} |
||||
#endif /* SYS_STATS */ |
||||
return p_queue; |
||||
} |
||||
else |
||||
free(p_queue_mem); |
||||
} |
||||
return SYS_MBOX_NULL; |
||||
} |
||||
|
||||
/*---------------------------------------------------------------------------------*/ |
||||
void |
||||
sys_mbox_free(sys_mbox_t mbox) |
||||
{ |
||||
VOID *p_queue_mem; |
||||
CHAR name[8]; |
||||
UNSIGNED queue_size; |
||||
UNSIGNED available; |
||||
UNSIGNED messages; |
||||
OPTION message_type; |
||||
UNSIGNED message_size; |
||||
OPTION suspend_type; |
||||
UNSIGNED tasks_waiting; |
||||
NU_TASK *first_task; |
||||
STATUS status; |
||||
|
||||
if (mbox != SYS_MBOX_NULL) |
||||
{ |
||||
/* First we need to get address of queue memory. Ask Nucleus
|
||||
for information about the queue */ |
||||
status = NU_Queue_Information(mbox, |
||||
name, |
||||
&p_queue_mem, |
||||
&queue_size, |
||||
&available, |
||||
&messages, |
||||
&message_type, |
||||
&message_size, |
||||
&suspend_type, |
||||
&tasks_waiting, |
||||
&first_task); |
||||
if (status == NU_SUCCESS) |
||||
free(p_queue_mem); |
||||
NU_Delete_Queue(mbox); |
||||
free(mbox); |
||||
#ifdef SYS_STATS |
||||
lwip_stats.sys.mbox.used--; |
||||
#endif /* SYS_STATS */ |
||||
} |
||||
|
||||
} |
||||
|
||||
/*---------------------------------------------------------------------------------
|
||||
This function sends a message to a mailbox. It is unusual in that no error |
||||
return is made. This is because the caller is responsible for ensuring that |
||||
the mailbox queue will not fail. The caller does this by limiting the number |
||||
of msg structures which exist for a given mailbox. |
||||
---------------------------------------------------------------------------------*/ |
||||
void |
||||
sys_mbox_post(sys_mbox_t mbox, void *msg) |
||||
{ |
||||
UNSIGNED status; |
||||
|
||||
LWIP_DEBUGF(SYS_DEBUG, ("sys_mbox_post: mbox %p msg %p\n", mbox, msg)); |
||||
status = NU_Send_To_Queue(mbox, |
||||
&msg, |
||||
1, |
||||
NU_NO_SUSPEND); |
||||
LWIP_ASSERT("sys_mbox_post: mbx post failed", status == NU_SUCCESS); |
||||
} |
||||
/*---------------------------------------------------------------------------------*/ |
||||
u32_t |
||||
sys_arch_mbox_fetch(sys_mbox_t mbox, void **msg, u32_t timeout) |
||||
{ |
||||
UNSIGNED timestart, timespent; |
||||
STATUS status; |
||||
void *ret_msg; |
||||
UNSIGNED actual_size; |
||||
|
||||
/* Get the current time */ |
||||
timestart = NU_Retrieve_Clock(); |
||||
|
||||
/* Wait for message */ |
||||
status = NU_Receive_From_Queue(mbox, |
||||
&ret_msg, |
||||
1, |
||||
&actual_size, |
||||
timeout ? MS_TO_TICKS(timeout) : NU_SUSPEND); |
||||
|
||||
if (status == NU_SUCCESS) |
||||
{ |
||||
if (msg)
|
||||
*msg = ret_msg; |
||||
LWIP_DEBUGF(SYS_DEBUG, ("sys_mbox_fetch: mbox %p msg %p\n", mbox, ret_msg)); |
||||
} else { |
||||
if (msg) |
||||
*msg = 0; |
||||
if (status == NU_TIMEOUT) |
||||
LWIP_DEBUGF(SYS_DEBUG, ("sys_mbox_fetch: timeout on mbox %p\n", mbox)); |
||||
else |
||||
LWIP_DEBUGF(SYS_DEBUG, ("sys_mbox_fetch: Queue Error %i on mbox %p\n", status, mbox)); |
||||
} |
||||
|
||||
|
||||
/* This next statement takes wraparound into account. It works. Really! */ |
||||
timespent = TICKS_TO_HUNDMICROSEC(((s32_t) ((s32_t) NU_Retrieve_Clock() - (s32_t) timestart))); |
||||
|
||||
if (status == NU_TIMEOUT) |
||||
return SYS_ARCH_TIMEOUT; |
||||
else |
||||
/* Round off to milliseconds */ |
||||
return (timespent+5)/10; |
||||
} |
||||
|
||||
/*---------------------------------------------------------------------------------*/ |
||||
static void |
||||
sys_arch_lisr(INT vector_number) |
||||
{ |
||||
struct sys_hisr *p_hisr = hisrs; |
||||
|
||||
/* Determine which HISR to activate */ |
||||
while (p_hisr != NULL) |
||||
{ |
||||
if (vector_number == p_hisr->vector) |
||||
{ |
||||
if (p_hisr->disablefun) |
||||
(*p_hisr->disablefun)(); |
||||
NU_Activate_HISR(p_hisr->hisr); |
||||
break; |
||||
} |
||||
p_hisr = p_hisr->next; |
||||
} |
||||
return; |
||||
} |
||||
|
||||
|
||||
/*---------------------------------------------------------------------------------*/ |
||||
void |
||||
sys_setvect(u32_t vector, void (*isr_function)(void), void (*dis_funct)(void)) |
||||
{ |
||||
/* The passed function is called as a high level ISR on the selected vector.
|
||||
It is assumed that all the functions in this module can be called by the |
||||
isr_function. |
||||
*/ |
||||
struct sys_hisr *p_hisr = hisrs; |
||||
INT old_level; |
||||
NU_HISR *nucleus_hisr; |
||||
u8_t *p_stack; |
||||
STATUS status; |
||||
char hisr_name[8] = " "; |
||||
void (*old_lisr)(INT); |
||||
|
||||
/* In this case a Nucleus HISR is created for the isr_function. This
|
||||
* requires it's own stack. Also get memory for Nucleus HISR. */ |
||||
nucleus_hisr = (NU_HISR *) calloc(1,sizeof(NU_HISR)); |
||||
if (nucleus_hisr) |
||||
{ |
||||
p_stack = (u8_t *) malloc(SYS_HISR_STACK_SIZE); |
||||
if (p_stack) |
||||
{ |
||||
|
||||
/* It is most efficient to disable interrupts for Nucleus for a short
|
||||
time. Chances are we are doing this while interrupts are disabled |
||||
already during system initialization. |
||||
*/ |
||||
old_level = NU_Control_Interrupts(NU_DISABLE_INTERRUPTS); |
||||
|
||||
/* It is a simplification here that once an HISR is set up for a particular
|
||||
* vector it will never be set up again. This way if the init code is called |
||||
* more than once it is harmless (no memory leaks) |
||||
*/ |
||||
while (p_hisr != NULL) |
||||
{ |
||||
if (vector == p_hisr->vector) |
||||
{ |
||||
NU_Control_Interrupts(old_level); |
||||
free(p_stack); |
||||
free(nucleus_hisr); |
||||
return; |
||||
} |
||||
p_hisr = p_hisr->next; |
||||
} |
||||
|
||||
/* Get a sys_hisr structure */ |
||||
p_hisr = (struct sys_hisr *) calloc(1,sizeof(struct sys_hisr)); |
||||
if (p_hisr) |
||||
{ |
||||
p_hisr->next = hisrs; |
||||
p_hisr->vector = vector; |
||||
p_hisr->hisr = nucleus_hisr; |
||||
p_hisr->disablefun = dis_funct; |
||||
hisrs = p_hisr; |
||||
|
||||
NU_Control_Interrupts(old_level); |
||||
|
||||
num_hisr = (num_hisr + 1) % 100; |
||||
sprintf(hisr_name, "lwip%02d", num_hisr); |
||||
hisr_name[strlen(hisr_name)] = ' '; |
||||
|
||||
/* Ask Nucleus to create the HISR */ |
||||
status = NU_Create_HISR(p_hisr->hisr, |
||||
hisr_name, |
||||
isr_function, |
||||
1, //Priority 0-2
|
||||
p_stack, |
||||
SYS_HISR_STACK_SIZE); |
||||
if (status == NU_SUCCESS) |
||||
{ |
||||
/* Plug vector with system lisr now */ |
||||
NU_Register_LISR(vector, sys_arch_lisr, &old_lisr); |
||||
return; //Success
|
||||
} |
||||
} |
||||
NU_Control_Interrupts(old_level); |
||||
} |
||||
} |
||||
/* Errors should be logged here */ |
||||
abort(); |
||||
} |
||||
|
||||
/*---------------------------------------------------------------------------------*/ |
||||
/** sys_prot_t sys_arch_protect(void)
|
||||
|
||||
This optional function does a "fast" critical region protection and returns |
||||
the previous protection level. This function is only called during very short |
||||
critical regions. An embedded system which supports ISR-based drivers might |
||||
want to implement this function by disabling interrupts. Task-based systems |
||||
might want to implement this by using a mutex or disabling tasking. This |
||||
function should support recursive calls from the same task or interrupt. In |
||||
other words, sys_arch_protect() could be called while already protected. In |
||||
that case the return value indicates that it is already protected. |
||||
|
||||
sys_arch_protect() is only required if your port is supporting an operating |
||||
system. |
||||
*/ |
||||
sys_prot_t |
||||
sys_arch_protect(void) |
||||
{ |
||||
return NU_Control_Interrupts(NU_DISABLE_INTERRUPTS); |
||||
} |
||||
|
||||
/*---------------------------------------------------------------------------------*/ |
||||
/** void sys_arch_unprotect(sys_prot_t pval)
|
||||
|
||||
This optional function does a "fast" set of critical region protection to the |
||||
value specified by pval. See the documentation for sys_arch_protect() for |
||||
more information. This function is only required if your port is supporting |
||||
an operating system. |
||||
*/ |
||||
void |
||||
sys_arch_unprotect(sys_prot_t pval) |
||||
{ |
||||
NU_Control_Interrupts(pval); |
||||
} |
||||
|
||||
/*********************************************************************
|
||||
* void sys_get_eth_addr(struct eth_addr *eth_addr) |
||||
* |
||||
* Get configured ethernet address from nvram and return it |
||||
* in a eth_addr structure. |
||||
*********************************************************************/ |
||||
void |
||||
sys_get_eth_addr(struct eth_addr *eth_addr) |
||||
{ |
||||
Cfg_lan *p_lan = config_get_lan_setup(); |
||||
|
||||
eth_addr->addr[0] = (u8_t) ((p_lan->etheraddrhi >> 16) & 0xff); |
||||
eth_addr->addr[1] = (u8_t) ((p_lan->etheraddrhi >> 8) & 0xff); |
||||
eth_addr->addr[2] = (u8_t) ((p_lan->etheraddrhi) & 0xff); |
||||
eth_addr->addr[3] = (u8_t) ((p_lan->etheraddrlo >> 16) & 0xff); |
||||
eth_addr->addr[4] = (u8_t) ((p_lan->etheraddrlo >> 8) & 0xff); |
||||
eth_addr->addr[5] = (u8_t) ((p_lan->etheraddrlo) & 0xff); |
||||
} |
||||
@ -1,43 +0,0 @@
|
||||
This part of the lwip-contrib section is the ecos glue |
||||
|
||||
Check out latest ecos from CVS (>= 19 Jan 2004) so it has the latest io/eth glue for lwip. |
||||
|
||||
You must have the current lwip sources checked out and the scripts here will hopefully generate |
||||
a correct EPK suitable for use with ecos. |
||||
|
||||
|
||||
To make an ecos package: |
||||
|
||||
Run the mkepk script something like this |
||||
|
||||
# EPK=/dir/of/epk LWIP_CVS=/dir/of/checked/out/lwip ./mkepk |
||||
|
||||
This will put the generated EPK in the dir you specify |
||||
|
||||
|
||||
then add that EPK to your package repository and use it |
||||
|
||||
Build example: |
||||
#ecosconfig new edb7xxx kernel |
||||
#ecosconfig add lwip |
||||
this will default to SLIP connection.If you also |
||||
#ecosconfig add net_drivers |
||||
you'll be able to configure for ethernet |
||||
|
||||
In both cases set LWIP_MY_ADDR and LWIP_SERV_ADDR (means host/gateway for eth or host/peer for slip) |
||||
#ecosconfig tree |
||||
#make tests |
||||
and you can try any of the five tests included |
||||
|
||||
Tests: |
||||
udpecho - echo service port 7 on UDP |
||||
tcpecho - ditto on TCP |
||||
sockets - as tcpecho but written with the socket API not the lwip specific API |
||||
https - http server on port 80 written with the raw API |
||||
nc_test_slave - a port of the test with the same name in net/common to lwip. Used to compare |
||||
lwIP throughput to that of the FreeBSD stack.In this matchup lwIP gets a well deserved |
||||
silver medal.Not bad for a newcomer ;) |
||||
|
||||
|
||||
Bugreports (or even better patches) at jani@iv.ro not the lwip or ecos mailing lists!! |
||||
Only if you peek into the lwip sources and think you found a bug post to lwip-users. |
||||
@ -1,16 +0,0 @@
|
||||
#!/bin/sh |
||||
|
||||
#make an ecos epk from CVS lwIP |
||||
CURRENT=$EPK/net/lwip_tcpip/current |
||||
mkdir -p `dirname $CURRENT/$2` |
||||
|
||||
#prepend eCos license text to all files but the ones |
||||
#in the ppp directory: those have the advertising clause |
||||
#type of BSD license which is not compatible with GPL |
||||
#or that's what I'be been told and IANAL |
||||
if [ "`dirname $1`" != "src/netif/ppp" ]; then |
||||
#cat header $LWIP_CVS/$1 > $CURRENT/$2 |
||||
cp -f $LWIP_CVS/$1 $CURRENT/$2 |
||||
else |
||||
cp -f $LWIP_CVS/$1 $CURRENT/$2 |
||||
fi |
||||
@ -1,680 +0,0 @@
|
||||
#==================================================================== |
||||
# |
||||
# lwip_net.cdl |
||||
# |
||||
# lwIP network stack configuration data |
||||
# |
||||
# ==================================================================== |
||||
#####ECOSGPLCOPYRIGHTBEGIN#### |
||||
## ------------------------------------------- |
||||
## This file is part of eCos, the Embedded Configurable Operating System. |
||||
## Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc. |
||||
## Copyright (C) 2004 eCosCentric |
||||
## |
||||
## eCos is free software; you can redistribute it and/or modify it under |
||||
## the terms of the GNU General Public License as published by the Free |
||||
## Software Foundation; either version 2 or (at your option) any later version. |
||||
## |
||||
## eCos is distributed in the hope that it will be useful, but WITHOUT ANY |
||||
## WARRANTY; without even the implied warranty of MERCHANTABILITY or |
||||
## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
||||
## for more details. |
||||
## |
||||
## You should have received a copy of the GNU General Public License along |
||||
## with eCos; if not, write to the Free Software Foundation, Inc., |
||||
## 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. |
||||
## |
||||
## As a special exception, if other files instantiate templates or use macros |
||||
## or inline functions from this file, or you compile this file and link it |
||||
## with other works to produce a work based on this file, this file does not |
||||
## by itself cause the resulting work to be covered by the GNU General Public |
||||
## License. However the source code for this file must still be made available |
||||
## in accordance with section (3) of the GNU General Public License. |
||||
## |
||||
## This exception does not invalidate any other reasons why a work based on |
||||
## this file might be covered by the GNU General Public License. |
||||
## |
||||
## ------------------------------------------- |
||||
#####ECOSGPLCOPYRIGHTEND#### |
||||
# ==================================================================== |
||||
######DESCRIPTIONBEGIN#### |
||||
# |
||||
# Author(s): cris@iv.ro, jani@iv.ro |
||||
# Original data: jani@iv.ro |
||||
# Contributors: |
||||
# Date: 2002-06-21 |
||||
# |
||||
#####DESCRIPTIONEND#### |
||||
# |
||||
# ==================================================================== |
||||
|
||||
cdl_package CYGPKG_NET_LWIP { |
||||
display "lwIP" |
||||
description "Lightweight TCP/IP stack" |
||||
requires {(CYGPKG_LWIP_ETH == 1) || (CYGPKG_LWIP_SLIP == 1) || (CYGPKG_LWIP_PPP == 1)} |
||||
|
||||
compile core/mem.c \ |
||||
core/memp.c \ |
||||
core/netif.c \ |
||||
core/pbuf.c \ |
||||
core/stats.c \ |
||||
core/sys.c \ |
||||
core/tcp.c \ |
||||
core/tcp_in.c \ |
||||
core/tcp_out.c \ |
||||
core/inet.c \ |
||||
core/ipv4/icmp.c \ |
||||
core/ipv4/ip.c \ |
||||
core/ipv4/ip_addr.c \ |
||||
core/ipv4/ip_frag.c \ |
||||
api/api_lib.c \ |
||||
api/api_msg.c \ |
||||
api/tcpip.c \ |
||||
api/err.c \ |
||||
api/sockets.c \ |
||||
ecos/sys_arch.c \ |
||||
ecos/init.c |
||||
|
||||
|
||||
cdl_component CYGPKG_LWIP_STATS { |
||||
display "Turn ON/OFF statistics" |
||||
flavor bool |
||||
default_value 0 |
||||
description " |
||||
Check this box to turn ON statistics options for lwIP." |
||||
} |
||||
|
||||
cdl_component CYGPKG_LWIP_DEBUG { |
||||
display "Turn ON/OFF debug options" |
||||
flavor bool |
||||
default_value 0 |
||||
description " |
||||
Check this box to turn ON debug options for lwIP." |
||||
|
||||
cdl_option CYGPKG_LWIP_DEBUG_TCP { |
||||
display "Control TCP debug" |
||||
flavor bool |
||||
default_value 0 |
||||
description " |
||||
Generic TCP debug switch." |
||||
|
||||
} |
||||
|
||||
} |
||||
|
||||
cdl_component CYGPKG_LWIP_ASSERTS { |
||||
display "Turn ON/OFF assertions" |
||||
flavor bool |
||||
default_value 0 |
||||
description " |
||||
Check this box to turn ON assertions for lwIP." |
||||
} |
||||
|
||||
cdl_component CYGPKG_LWIP_IPV4_CONF { |
||||
display "IPV4 netconf" |
||||
flavor none |
||||
no_define |
||||
description " |
||||
See suboptions to define gateway IP, local IP and netmask." |
||||
|
||||
cdl_option CYGPKG_LWIP_SERV_ADDR { |
||||
display "Gateway IP" |
||||
flavor data |
||||
default_value {"192,168,1,1"} |
||||
description " |
||||
Gateway's IP address." |
||||
|
||||
} |
||||
cdl_option CYGPKG_LWIP_MY_ADDR { |
||||
display "My IP" |
||||
flavor data |
||||
default_value {"192,168,1,222"} |
||||
description " |
||||
The IP address for this device." |
||||
|
||||
} |
||||
cdl_option CYGPKG_LWIP_NETMASK { |
||||
display "Netmask" |
||||
flavor data |
||||
default_value {"255,255,255,0"} |
||||
description " |
||||
Netmask of the local network." |
||||
|
||||
} |
||||
} |
||||
|
||||
cdl_component CYGPKG_LWIP_MEM_OPTIONS { |
||||
display "Memory options" |
||||
flavor none |
||||
no_define |
||||
description " |
||||
Tunables for various aspects of memory usage throughout the stack." |
||||
|
||||
|
||||
|
||||
cdl_option CYGPKG_LWIP_MEM_ALIGNMENT { |
||||
display "Memory alignment" |
||||
flavor data |
||||
default_value 4 |
||||
description " |
||||
MEM_ALIGNMENT: should be set to the alignment of the CPU for which |
||||
lwIP is compiled. 4 byte alignment -> define MEM_ALIGNMENT to 4, |
||||
2 byte alignment -> define MEM_ALIGNMENT to 2." |
||||
} |
||||
cdl_option CYGPKG_LWIP_MEM_SIZE { |
||||
display "Memory size" |
||||
flavor data |
||||
default_value 4000 |
||||
description " |
||||
MEM_SIZE: the size of the heap memory. If the application will send |
||||
a lot of data that needs to be copied, this should be set high." |
||||
|
||||
} |
||||
cdl_option CYGPKG_LWIP_MEMP_NUM_PBUF { |
||||
display "Number of memp struct pbufs" |
||||
flavor data |
||||
default_value 8 |
||||
description " |
||||
MEMP_NUM_PBUF: the number of memp struct pbufs. If the application |
||||
sends a lot of data out of ROM (or other static memory), this |
||||
should be set high." |
||||
|
||||
} |
||||
cdl_option CYGPKG_LWIP_MEMP_NUM_UDP_PCB { |
||||
display "Simultaneous UDP control blocks " |
||||
flavor data |
||||
default_value 4 |
||||
description " |
||||
MEMP_NUM_UDP_PCB: the number of UDP protocol control blocks. One |
||||
per active UDP 'connection'." |
||||
|
||||
} |
||||
cdl_option CYGPKG_LWIP_MEMP_NUM_TCP_PCB { |
||||
display "Simultaneous active TCP connections " |
||||
flavor data |
||||
default_value 5 |
||||
description " |
||||
MEMP_NUM_TCP_PCB: the number of simulatenously active TCP |
||||
connections." |
||||
|
||||
} |
||||
cdl_option CYGPKG_LWIP_MEMP_NUM_TCP_PCB_LISTEN { |
||||
display "Listening TCP connections" |
||||
flavor data |
||||
default_value 8 |
||||
description " |
||||
MEMP_NUM_TCP_PCB_LISTEN: the number of listening TCP |
||||
connections." |
||||
|
||||
} |
||||
cdl_option CYGPKG_LWIP_MEMP_NUM_TCP_SEG { |
||||
display "Simultaneous TCP segments queued" |
||||
flavor data |
||||
default_value 8 |
||||
description " |
||||
MEMP_NUM_TCP_SEG: the number of simultaneously queued TCP |
||||
segments." |
||||
|
||||
} |
||||
cdl_option CYGPKG_LWIP_MEMP_NUM_SYS_TIMEOUT { |
||||
display "Simultaneous active timeouts" |
||||
flavor data |
||||
default_value 3 |
||||
description " |
||||
MEMP_NUM_SYS_TIMEOUT: the number of simulateously active |
||||
timeouts." |
||||
|
||||
} |
||||
cdl_component CYGPKG_LWIP_CYGPKG_LWIP_MEM_SEQ_API { |
||||
display "Sequential API settings" |
||||
flavor none |
||||
no_define |
||||
description " |
||||
The following four are used only with the sequential API and can be |
||||
set to 0 if the application only will use the raw API." |
||||
|
||||
|
||||
cdl_option CYGPKG_LWIP_MEMP_NUM_NETBUF { |
||||
display "Struct netbufs" |
||||
flavor data |
||||
default_value 2 |
||||
description " |
||||
MEMP_NUM_NETBUF: the number of struct netbufs." |
||||
|
||||
} |
||||
cdl_option CYGPKG_LWIP_MEMP_NUM_NETCONN { |
||||
display "Struct netconns" |
||||
flavor data |
||||
default_value 4 |
||||
description " |
||||
MEMP_NUM_NETCONN: the number of struct netconns." |
||||
|
||||
} |
||||
cdl_option CYGPKG_LWIP_MEMP_NUM_APIMSG { |
||||
display "Struct api_msgs" |
||||
flavor data |
||||
default_value 8 |
||||
description " |
||||
MEMP_NUM_APIMSG: the number of struct api_msg, used for |
||||
communication between the TCP/IP stack and the sequential |
||||
programs." |
||||
|
||||
} |
||||
cdl_option CYGPKG_LWIP_MEMP_NUM_TCPIP_MSG { |
||||
display "Struct tcpip_msgs" |
||||
flavor data |
||||
default_value 8 |
||||
description " |
||||
MEMP_NUM_TCPIPMSG: the number of struct tcpip_msg, which is used |
||||
for sequential API communication and incoming packets. Used in |
||||
src/api/tcpip.c." |
||||
|
||||
} |
||||
} |
||||
|
||||
} |
||||
|
||||
cdl_component CYGPKG_LWIP_PBUF_OPTIONS { |
||||
display "PBUF" |
||||
flavor none |
||||
no_define |
||||
description " |
||||
Packet buffer related tunings." |
||||
|
||||
|
||||
cdl_option CYGPKG_LWIP_PBUF_POOL_SIZE { |
||||
display "PBUF pool size" |
||||
flavor data |
||||
default_value 60 |
||||
description " |
||||
PBUF_POOL_SIZE: the number of buffers in the pbuf pool." |
||||
|
||||
} |
||||
|
||||
cdl_option CYGPKG_LWIP_PBUF_POOL_BUFSIZE { |
||||
display "PBUF buffer size" |
||||
flavor data |
||||
default_value 1024 |
||||
description " |
||||
PBUF_POOL_BUFSIZE: the size of each pbuf in the pbuf pool." |
||||
|
||||
} |
||||
cdl_option CYGPKG_LWIP_PBUF_LINK_HLEN { |
||||
display "Allocation for a link level header" |
||||
flavor data |
||||
calculated {CYGPKG_LWIP_SLIP || CYGPKG_LWIP_PPP ? 0 : 16} |
||||
description " |
||||
PBUF_LINK_HLEN: the number of bytes that should be allocated for a |
||||
link level header." |
||||
} |
||||
} |
||||
|
||||
cdl_component CYGPKG_LWIP_TCP_OPTIONS { |
||||
display "TCP" |
||||
flavor none |
||||
no_define |
||||
description " |
||||
Tune the TCP protocol details" |
||||
|
||||
cdl_option CYGPKG_LWIP_TCP { |
||||
display "Activate TCP" |
||||
flavor bool |
||||
default_value 1 |
||||
description "" |
||||
|
||||
} |
||||
|
||||
cdl_option CYGPKG_LWIP_TCPIP_THREAD_PRIORITY { |
||||
display "tcpip thread priority" |
||||
flavor data |
||||
default_value 7 |
||||
description "Pririty of the lwIP network thread.This thread handles all API messages and |
||||
network packets." |
||||
} |
||||
|
||||
cdl_option CYGPKG_LWIP_TCP_TTL { |
||||
display "Time To Live" |
||||
flavor data |
||||
default_value 255 |
||||
description "" |
||||
|
||||
} |
||||
cdl_option CYGPKG_LWIP_TCP_QUEUE_OOSEQ { |
||||
display "Queue segments" |
||||
flavor bool |
||||
default_value 1 |
||||
description " |
||||
Controls if TCP should queue segments that arrive out of |
||||
order. Define to 0 if your device is low on memory." |
||||
|
||||
} |
||||
cdl_option CYGPKG_LWIP_TCP_MSS { |
||||
display "Maximum segment size" |
||||
flavor data |
||||
default_value 2048 |
||||
description " |
||||
TCP Maximum segment size." |
||||
} |
||||
cdl_option CYGPKG_LWIP_TCP_SND_BUF { |
||||
display "Sender buffer space" |
||||
flavor data |
||||
default_value 2048 |
||||
description " |
||||
TCP sender buffer space (bytes)." |
||||
|
||||
} |
||||
cdl_option CYGPKG_LWIP_TCP_SND_QUEUELEN { |
||||
display "Sender pbufs" |
||||
flavor data |
||||
calculated "4 * CYGPKG_LWIP_TCP_SND_BUF/CYGPKG_LWIP_TCP_MSS" |
||||
description " |
||||
TCP sender buffer space (pbufs). This must be at least = 2 * |
||||
TCP_SND_BUF/TCP_MSS for things to work." |
||||
|
||||
} |
||||
cdl_option CYGPKG_LWIP_TCP_WND { |
||||
display "Receive window" |
||||
flavor data |
||||
default_value 4096 |
||||
description " |
||||
TCP receive window." |
||||
|
||||
} |
||||
cdl_option CYGPKG_LWIP_TCP_MAXRTX { |
||||
display "Segment retransmissions" |
||||
flavor data |
||||
default_value 12 |
||||
description " |
||||
Maximum number of retransmissions of data segments." |
||||
|
||||
} |
||||
cdl_option CYGPKG_LWIP_TCP_SYNMAXRTX { |
||||
display "Syn retransmissions" |
||||
flavor data |
||||
default_value 4 |
||||
description " |
||||
Maximum number of retransmissions of SYN segments." |
||||
} |
||||
} |
||||
|
||||
cdl_component CYGPKG_LWIP_ARP_OPTIONS { |
||||
display "ARP" |
||||
flavor none |
||||
no_define |
||||
|
||||
cdl_option CYGPKG_LWIP_ARP_TABLE_SIZE { |
||||
display "ARP table size" |
||||
flavor data |
||||
default_value 10 |
||||
description "" |
||||
|
||||
} |
||||
} |
||||
|
||||
cdl_component CYGPKG_LWIP_IP { |
||||
display "IP" |
||||
flavor none |
||||
no_define |
||||
|
||||
cdl_option CYGPKG_LWIP_IP_FORWARD { |
||||
display "IP forwarding" |
||||
flavor bool |
||||
default_value 1 |
||||
description " |
||||
Define IP_FORWARD to 1 if you wish to have the ability to forward |
||||
IP packets across network interfaces. If you are going to run lwIP |
||||
on a device with only one network interface, define this to 0." |
||||
|
||||
} |
||||
cdl_option CYGPKG_LWIP_IP_OPTIONS { |
||||
display "Allow IP options" |
||||
flavor bool |
||||
default_value 1 |
||||
description " |
||||
If defined to 1, IP options are allowed (but not parsed). If |
||||
defined to 0, all packets with IP options are dropped." |
||||
|
||||
} |
||||
|
||||
cdl_option CYGPKG_LWIP_IP_FRAG { |
||||
display "Support IP fragmentation" |
||||
flavor bool |
||||
default_value 1 |
||||
description " |
||||
" |
||||
} |
||||
|
||||
cdl_option CYGPKG_LWIP_IP_REASS { |
||||
display "Support IP reassembly" |
||||
flavor bool |
||||
default_value 1 |
||||
description " |
||||
" |
||||
} |
||||
|
||||
} |
||||
|
||||
cdl_component CYGPKG_LWIP_ICMP_OPTIONS { |
||||
display "ICMP" |
||||
flavor none |
||||
no_define |
||||
|
||||
cdl_option CYGPKG_LWIP_ICMP_TTL { |
||||
display "ICMP Time To Live" |
||||
flavor data |
||||
default_value 255 |
||||
description "" |
||||
} |
||||
} |
||||
|
||||
cdl_component CYGPKG_LWIP_DHCP_OPTIONS { |
||||
display "DHCP" |
||||
flavor none |
||||
no_define |
||||
|
||||
|
||||
cdl_option CYGPKG_LWIP_DHCP { |
||||
display "Activate DHCP" |
||||
flavor bool |
||||
default_value 0 |
||||
description " |
||||
Define LWIP_DHCP to 1 if you want DHCP configuration of |
||||
interfaces." |
||||
compile core/dhcp.c |
||||
} |
||||
|
||||
|
||||
cdl_option CYGPKG_LWIP_DHCP_DOES_ARP_CHECK { |
||||
display "Check offered address" |
||||
flavor bool |
||||
default_value 0 |
||||
description " |
||||
1 if you want to do an ARP check on the offered address |
||||
(recommended)." |
||||
} |
||||
} |
||||
|
||||
cdl_component CYGPKG_LWIP_LOOPIF { |
||||
display "Support loop interface (127.0.0.1)" |
||||
flavor bool |
||||
default_value 1 |
||||
compile netif/loopif.c |
||||
} |
||||
|
||||
cdl_component CYGPKG_LWIP_ETH { |
||||
display "Ethernet support" |
||||
flavor bool |
||||
requires CYGPKG_IO_ETH_DRIVERS |
||||
default_value 1 |
||||
description "Ethernet support" |
||||
compile netif/etharp.c |
||||
|
||||
cdl_option CYGPKG_LWIP_ETH_THREAD_PRIORITY { |
||||
display "ethernet input thread priority" |
||||
flavor data |
||||
default_value 6 |
||||
description "Priority of the ethernet input thread" |
||||
} |
||||
|
||||
} |
||||
|
||||
cdl_component CYGPKG_LWIP_SLIP { |
||||
display "SLIP" |
||||
flavor bool |
||||
requires CYGPKG_IO_SERIAL_DEVICES |
||||
default_value 0 |
||||
description "IP over Serial Line" |
||||
compile netif/slipif.c ecos/sio.c |
||||
|
||||
cdl_option CYGPKG_LWIP_SLIPIF_THREAD_PRIORITY { |
||||
display "SLIP thread priority" |
||||
flavor data |
||||
default_value 8 |
||||
description "Priority of the SLIP input thread" |
||||
} |
||||
|
||||
cdl_option CYGPKG_LWIP_SLIP_DEV { |
||||
display "Serial device" |
||||
flavor data |
||||
default_value {"\"/dev/ser0\""} |
||||
description " |
||||
Which serial port to use SLIP on." |
||||
} |
||||
} |
||||
|
||||
cdl_component CYGPKG_LWIP_PPP { |
||||
display "PPP" |
||||
flavor bool |
||||
requires CYGPKG_IO_SERIAL_DEVICES |
||||
default_value 0 |
||||
description "The Point-to-Point Protocol" |
||||
compile netif/ppp/ppp.c \ |
||||
netif/ppp/auth.c \ |
||||
netif/ppp/chpms.c \ |
||||
netif/ppp/fsm.c \ |
||||
netif/ppp/ipcp.c \ |
||||
netif/ppp/lcp.c \ |
||||
netif/ppp/magic.c \ |
||||
netif/ppp/md5.c \ |
||||
netif/ppp/randm.c \ |
||||
netif/ppp/vj.c \ |
||||
ecos/sio.c |
||||
|
||||
|
||||
cdl_option CYGPKG_LWIP_PPP_PAP_AUTH { |
||||
display "Support PAP authentication" |
||||
flavor bool |
||||
default_value 1 |
||||
compile netif/ppp/pap.c |
||||
} |
||||
|
||||
cdl_option CYGPKG_LWIP_PPP_CHAP_AUTH { |
||||
display "Support CHAP authentication" |
||||
flavor bool |
||||
default_value 1 |
||||
compile netif/ppp/chap.c |
||||
} |
||||
|
||||
cdl_option CYGPKG_LWIP_PPP_DEV { |
||||
display "Serial device for PPP" |
||||
flavor data |
||||
default_value {"\"/dev/ser0\""} |
||||
description " |
||||
Which serial port to use PPP on." |
||||
} |
||||
|
||||
cdl_option CYGPKG_LWIP_PPP_THREAD_PRIORITY { |
||||
display "PPP main thread priority" |
||||
flavor data |
||||
default_value 8 |
||||
description "Priority of the PPP input thread" |
||||
} |
||||
} |
||||
|
||||
cdl_component CYGPKG_LWIP_UDP_OPTIONS { |
||||
display "UDP" |
||||
flavor none |
||||
no_define |
||||
|
||||
cdl_option CYGPKG_LWIP_UDP { |
||||
display "Activate UDP" |
||||
flavor bool |
||||
default_value 1 |
||||
description "" |
||||
compile core/udp.c |
||||
} |
||||
|
||||
cdl_option CYGPKG_LWIP_UDP_TTL { |
||||
display "Time To Live" |
||||
flavor data |
||||
default_value 255 |
||||
description "" |
||||
} |
||||
} |
||||
|
||||
cdl_option CYGPKG_LWIP_RAW { |
||||
display "Enable RAW socket support" |
||||
flavor bool |
||||
default_value 1 |
||||
description "" |
||||
compile core/raw.c |
||||
} |
||||
|
||||
cdl_component CYGPKG_LWIP_APP_MEM_OPTIONS { |
||||
display "Memory options for apps" |
||||
flavor none |
||||
no_define |
||||
description "Memory options for applications." |
||||
|
||||
cdl_option CYGNUM_LWIP_VARMEMPOOL_SIZE { |
||||
display "Size of variable memory pool" |
||||
flavor data |
||||
default_value 2048 |
||||
description " |
||||
Memory required to hold semaphore, mbox and thread structures |
||||
are allocated from this memory pool. |
||||
" |
||||
} |
||||
|
||||
|
||||
|
||||
cdl_option CYGNUM_LWIP_APP_THREADS { |
||||
display "Number of network threads in application" |
||||
flavor data |
||||
default_value 1 |
||||
description " |
||||
At startup at least two lwIP threads are created:the polling(input) thread |
||||
and the TCP/IP (output) thread.Additionally your application creates one |
||||
or more threads. |
||||
Set this option to the maximum number of threads you will create through |
||||
sys_thread_new().Threads which you create through cyg_thread_create() |
||||
are not lwIP threads and don't count.This number is needed so that enough |
||||
static memory is reserved for stack space. |
||||
" |
||||
} |
||||
|
||||
cdl_option CYGNUM_LWIP_THREAD_STACK_SIZE { |
||||
display "Size of per thread stack in lwIP" |
||||
flavor data |
||||
default_value 4096 |
||||
description " |
||||
Since stack space for threads needs to be statically allocated you can |
||||
specify the amount of memory to use for each network thread. |
||||
" |
||||
} |
||||
} |
||||
|
||||
|
||||
cdl_option CYGPKG_NET_LWIP_TESTS { |
||||
display "Some lwIP tests" |
||||
flavor data |
||||
no_define |
||||
calculated { |
||||
"tests/tcpecho tests/udpecho tests/httpd tests/socket tests/nc_test_slave tests/sys_timeout" |
||||
} |
||||
description " |
||||
This option specifies the set of tests for lwIP.They show the usage of |
||||
the raw, the sequential and the BSD socket compatible APIs" |
||||
} |
||||
|
||||
} |
||||
@ -1,116 +0,0 @@
|
||||
//==========================================================================
|
||||
//####ECOSGPLCOPYRIGHTBEGIN####
|
||||
// -------------------------------------------
|
||||
// This file is part of eCos, the Embedded Configurable Operating System.
|
||||
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
|
||||
//
|
||||
// eCos is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU General Public License as published by the Free
|
||||
// Software Foundation; either version 2 or (at your option) any later version.
|
||||
//
|
||||
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
// for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License along
|
||||
// with eCos; if not, write to the Free Software Foundation, Inc.,
|
||||
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
||||
//
|
||||
// As a special exception, if other files instantiate templates or use macros
|
||||
// or inline functions from this file, or you compile this file and link it
|
||||
// with other works to produce a work based on this file, this file does not
|
||||
// by itself cause the resulting work to be covered by the GNU General Public
|
||||
// License. However the source code for this file must still be made available
|
||||
// in accordance with section (3) of the GNU General Public License.
|
||||
//
|
||||
// This exception does not invalidate any other reasons why a work based on
|
||||
// this file might be covered by the GNU General Public License.
|
||||
// -------------------------------------------
|
||||
//####ECOSGPLCOPYRIGHTEND####
|
||||
//==========================================================================
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001, Swedish Institute of Computer Science. |
||||
* All rights reserved.
|
||||
* |
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the Institute nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
* |
||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
* |
||||
* This file is part of the lwIP TCP/IP stack. |
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se> |
||||
* |
||||
*/ |
||||
#ifndef __ARCH_CC_H__ |
||||
#define __ARCH_CC_H__ |
||||
|
||||
#include <string.h> |
||||
#include <cyg/error/codes.h> |
||||
//while EFAULT should have no meaning in eCos since there are no address spaces
|
||||
//it is defined here because set/getsockopt in lwIP use it.
|
||||
#define EFAULT 14 |
||||
|
||||
//found no better place for this prototype
|
||||
int lwip_init(void); |
||||
|
||||
//#define LWIP_PROVIDE_ERRNO
|
||||
#include <cyg/infra/cyg_type.h> |
||||
#if (CYG_BYTEORDER == CYG_LSBFIRST) |
||||
#define BYTE_ORDER LITTLE_ENDIAN |
||||
#else |
||||
#define BYTE_ORDER BIG_ENDIAN |
||||
#endif |
||||
|
||||
|
||||
typedef unsigned char u8_t; |
||||
typedef signed char s8_t; |
||||
typedef unsigned short u16_t; |
||||
typedef signed short s16_t; |
||||
typedef unsigned long u32_t; |
||||
typedef signed long s32_t; |
||||
typedef unsigned long mem_ptr_t; |
||||
|
||||
#define U16_F "hu" |
||||
#define S16_F "hd" |
||||
#define X16_F "hx" |
||||
#define U32_F "lu" |
||||
#define S32_F "ld" |
||||
#define X32_F "lx" |
||||
|
||||
#define PACK_STRUCT_FIELD(x) x __attribute__((packed)) |
||||
#define PACK_STRUCT_STRUCT __attribute__((packed)) |
||||
#define PACK_STRUCT_BEGIN |
||||
#define PACK_STRUCT_END |
||||
|
||||
#include <cyg/infra/diag.h> |
||||
#include <cyg/infra/cyg_ass.h> |
||||
#define LWIP_PLATFORM_DIAG(x) {diag_printf x;} |
||||
#define LWIP_PLATFORM_ASSERT(x) {CYG_FAIL(x);} |
||||
|
||||
#define SYS_ARCH_DECL_PROTECT(x) |
||||
#define SYS_ARCH_PROTECT(x) |
||||
#define SYS_ARCH_UNPROTECT(x) |
||||
|
||||
#endif /* __ARCH_CC_H__ */ |
||||
@ -1,72 +0,0 @@
|
||||
//==========================================================================
|
||||
//####ECOSGPLCOPYRIGHTBEGIN####
|
||||
// -------------------------------------------
|
||||
// This file is part of eCos, the Embedded Configurable Operating System.
|
||||
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
|
||||
//
|
||||
// eCos is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU General Public License as published by the Free
|
||||
// Software Foundation; either version 2 or (at your option) any later version.
|
||||
//
|
||||
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
// for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License along
|
||||
// with eCos; if not, write to the Free Software Foundation, Inc.,
|
||||
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
||||
//
|
||||
// As a special exception, if other files instantiate templates or use macros
|
||||
// or inline functions from this file, or you compile this file and link it
|
||||
// with other works to produce a work based on this file, this file does not
|
||||
// by itself cause the resulting work to be covered by the GNU General Public
|
||||
// License. However the source code for this file must still be made available
|
||||
// in accordance with section (3) of the GNU General Public License.
|
||||
//
|
||||
// This exception does not invalidate any other reasons why a work based on
|
||||
// this file might be covered by the GNU General Public License.
|
||||
// -------------------------------------------
|
||||
//####ECOSGPLCOPYRIGHTEND####
|
||||
//==========================================================================
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001, Swedish Institute of Computer Science. |
||||
* All rights reserved.
|
||||
* |
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the Institute nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
* |
||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
* |
||||
* This file is part of the lwIP TCP/IP stack. |
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se> |
||||
* |
||||
*/ |
||||
#ifndef __PERF_H__ |
||||
#define __PERF_H__ |
||||
|
||||
#define PERF_START /* null definition */ |
||||
#define PERF_STOP(x) /* null definition */ |
||||
|
||||
#endif /* __PERF_H__ */ |
||||
@ -1,45 +0,0 @@
|
||||
//==========================================================================
|
||||
//####ECOSGPLCOPYRIGHTBEGIN####
|
||||
// -------------------------------------------
|
||||
// This file is part of eCos, the Embedded Configurable Operating System.
|
||||
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
|
||||
//
|
||||
// eCos is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU General Public License as published by the Free
|
||||
// Software Foundation; either version 2 or (at your option) any later version.
|
||||
//
|
||||
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
// for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License along
|
||||
// with eCos; if not, write to the Free Software Foundation, Inc.,
|
||||
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
||||
//
|
||||
// As a special exception, if other files instantiate templates or use macros
|
||||
// or inline functions from this file, or you compile this file and link it
|
||||
// with other works to produce a work based on this file, this file does not
|
||||
// by itself cause the resulting work to be covered by the GNU General Public
|
||||
// License. However the source code for this file must still be made available
|
||||
// in accordance with section (3) of the GNU General Public License.
|
||||
//
|
||||
// This exception does not invalidate any other reasons why a work based on
|
||||
// this file might be covered by the GNU General Public License.
|
||||
// -------------------------------------------
|
||||
//####ECOSGPLCOPYRIGHTEND####
|
||||
//==========================================================================
|
||||
|
||||
#ifndef __SYS_ECOS_H__ |
||||
#define __SYS_ECOS_H__ |
||||
|
||||
#include <cyg/kernel/kapi.h> |
||||
|
||||
#define SYS_MBOX_NULL (sys_mbox_t)NULL |
||||
#define SYS_SEM_NULL (sys_sem_t)NULL |
||||
|
||||
typedef cyg_sem_t * sys_sem_t; |
||||
typedef cyg_handle_t sys_mbox_t; |
||||
typedef cyg_thread * sys_thread_t; |
||||
#endif /* __SYS_ECOS_H__ */ |
||||
|
||||
@ -1,254 +0,0 @@
|
||||
//==========================================================================
|
||||
//####ECOSGPLCOPYRIGHTBEGIN####
|
||||
// -------------------------------------------
|
||||
// This file is part of eCos, the Embedded Configurable Operating System.
|
||||
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
|
||||
//
|
||||
// eCos is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU General Public License as published by the Free
|
||||
// Software Foundation; either version 2 or (at your option) any later version.
|
||||
//
|
||||
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
// for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License along
|
||||
// with eCos; if not, write to the Free Software Foundation, Inc.,
|
||||
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
||||
//
|
||||
// As a special exception, if other files instantiate templates or use macros
|
||||
// or inline functions from this file, or you compile this file and link it
|
||||
// with other works to produce a work based on this file, this file does not
|
||||
// by itself cause the resulting work to be covered by the GNU General Public
|
||||
// License. However the source code for this file must still be made available
|
||||
// in accordance with section (3) of the GNU General Public License.
|
||||
//
|
||||
// This exception does not invalidate any other reasons why a work based on
|
||||
// this file might be covered by the GNU General Public License.
|
||||
// -------------------------------------------
|
||||
//####ECOSGPLCOPYRIGHTEND####
|
||||
//==========================================================================
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001, Swedish Institute of Computer Science. |
||||
* All rights reserved.
|
||||
* |
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the Institute nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
* |
||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
* |
||||
* This file is part of the lwIP TCP/IP stack. |
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se> |
||||
* |
||||
*/ |
||||
#ifndef __LWIPOPTS_H__ |
||||
#define __LWIPOPTS_H__ |
||||
/*include the configuration made with configtool*/ |
||||
#include <pkgconf/net_lwip.h> |
||||
/* ---------- Memory options ---------- */ |
||||
/* MEM_ALIGNMENT: should be set to the alignment of the CPU for which
|
||||
lwIP is compiled. 4 byte alignment -> define MEM_ALIGNMENT to 4, 2 |
||||
byte alignment -> define MEM_ALIGNMENT to 2. */ |
||||
#define MEM_ALIGNMENT CYGPKG_LWIP_MEM_ALIGNMENT |
||||
|
||||
/* MEM_SIZE: the size of the heap memory. If the application will send
|
||||
a lot of data that needs to be copied, this should be set high. */ |
||||
#define MEM_SIZE CYGPKG_LWIP_MEM_SIZE |
||||
|
||||
/* MEMP_NUM_PBUF: the number of memp struct pbufs. If the application
|
||||
sends a lot of data out of ROM (or other static memory), this |
||||
should be set high. */ |
||||
#define MEMP_NUM_PBUF CYGPKG_LWIP_MEMP_NUM_PBUF |
||||
/* MEMP_NUM_UDP_PCB: the number of UDP protocol control blocks. One
|
||||
per active UDP "connection". */ |
||||
#define MEMP_NUM_UDP_PCB CYGPKG_LWIP_MEMP_NUM_UDP_PCB |
||||
/* MEMP_NUM_TCP_PCB: the number of simulatenously active TCP
|
||||
connections. */ |
||||
#define MEMP_NUM_TCP_PCB CYGPKG_LWIP_MEMP_NUM_TCP_PCB |
||||
/* MEMP_NUM_TCP_PCB_LISTEN: the number of listening TCP
|
||||
connections. */ |
||||
#define MEMP_NUM_TCP_PCB_LISTEN CYGPKG_LWIP_MEMP_NUM_TCP_PCB_LISTEN |
||||
/* MEMP_NUM_TCP_SEG: the number of simultaneously queued TCP
|
||||
segments. */ |
||||
#define MEMP_NUM_TCP_SEG CYGPKG_LWIP_MEMP_NUM_TCP_SEG |
||||
/* MEMP_NUM_SYS_TIMEOUT: the number of simulateously active
|
||||
timeouts. */ |
||||
#define MEMP_NUM_SYS_TIMEOUT CYGPKG_LWIP_MEMP_NUM_SYS_TIMEOUT |
||||
|
||||
|
||||
/* The following four are used only with the sequential API and can be
|
||||
set to 0 if the application only will use the raw API. */ |
||||
/* MEMP_NUM_NETBUF: the number of struct netbufs. */ |
||||
#define MEMP_NUM_NETBUF CYGPKG_LWIP_MEMP_NUM_NETBUF |
||||
/* MEMP_NUM_NETCONN: the number of struct netconns. */ |
||||
#define MEMP_NUM_NETCONN CYGPKG_LWIP_MEMP_NUM_NETCONN |
||||
/* MEMP_NUM_TCPIP_MSG: the number of struct tcpip_msg, which is used
|
||||
for sequential API communication and incoming packets. Used in |
||||
src/api/tcpip.c. */ |
||||
#define MEMP_NUM_TCPIP_MSG_API CYGPKG_LWIP_MEMP_NUM_TCPIP_MSG |
||||
#define MEMP_NUM_TCPIP_MSG_INPKT CYGPKG_LWIP_MEMP_NUM_TCPIP_MSG |
||||
|
||||
/* ---------- Pbuf options ---------- */ |
||||
/* PBUF_POOL_SIZE: the number of buffers in the pbuf pool. */ |
||||
#define PBUF_POOL_SIZE CYGPKG_LWIP_PBUF_POOL_SIZE |
||||
|
||||
/* PBUF_POOL_BUFSIZE: the size of each pbuf in the pbuf pool. */ |
||||
#define PBUF_POOL_BUFSIZE CYGPKG_LWIP_PBUF_POOL_BUFSIZE |
||||
|
||||
/* PBUF_LINK_HLEN: the number of bytes that should be allocated for a
|
||||
link level header. */ |
||||
#define PBUF_LINK_HLEN CYGPKG_LWIP_PBUF_LINK_HLEN |
||||
|
||||
/* ---------- TCP options ---------- */ |
||||
#define LWIP_TCP defined (CYGPKG_LWIP_TCP) |
||||
#define TCP_TTL CYGPKG_LWIP_TCP_TTL |
||||
|
||||
/* Controls if TCP should queue segments that arrive out of
|
||||
order. Define to 0 if your device is low on memory. */ |
||||
#define TCP_QUEUE_OOSEQ CYGPKG_LWIP_TCP_QUEUE_OOSEQ |
||||
|
||||
/* TCP Maximum segment size. */ |
||||
#define TCP_MSS CYGPKG_LWIP_TCP_MSS |
||||
|
||||
/* TCP sender buffer space (bytes). */ |
||||
#define TCP_SND_BUF CYGPKG_LWIP_TCP_SND_BUF |
||||
#define TCP_SNDLOWAT TCP_SND_BUF/2 |
||||
|
||||
/* TCP sender buffer space (pbufs). This must be at least = 2 *
|
||||
TCP_SND_BUF/TCP_MSS for things to work. */ |
||||
#define TCP_SND_QUEUELEN CYGPKG_LWIP_TCP_SND_QUEUELEN |
||||
|
||||
/* TCP receive window. */ |
||||
#define TCP_WND CYGPKG_LWIP_TCP_WND |
||||
|
||||
/* Maximum number of retransmissions of data segments. */ |
||||
#define TCP_MAXRTX CYGPKG_LWIP_TCP_MAXRTX |
||||
|
||||
/* Maximum number of retransmissions of SYN segments. */ |
||||
#define TCP_SYNMAXRTX CYGPKG_LWIP_TCP_SYNMAXRTX |
||||
|
||||
/* ---------- ARP options ---------- */ |
||||
#define ARP_TABLE_SIZE CYGPKG_LWIP_ARP_TABLE_SIZE |
||||
|
||||
/* ---------- IP options ---------- */ |
||||
/* Define IP_FORWARD to 1 if you wish to have the ability to forward
|
||||
IP packets across network interfaces. If you are going to run lwIP |
||||
on a device with only one network interface, define this to 0. */ |
||||
#define IP_FORWARD CYGPKG_LWIP_IP_FORWARD |
||||
|
||||
/* If defined to 1, IP options are allowed (but not parsed). If
|
||||
defined to 0, all packets with IP options are dropped. */ |
||||
#define IP_OPTIONS CYGPKG_LWIP_IP_OPTIONS |
||||
|
||||
/* ---------- ICMP options ---------- */ |
||||
#define ICMP_TTL CYGPKG_LWIP_ICMP_TTL |
||||
|
||||
|
||||
/* ---------- DHCP options ---------- */ |
||||
/* Define LWIP_DHCP to 1 if you want DHCP configuration of
|
||||
interfaces.*/ |
||||
|
||||
#ifdef CYGPKG_LWIP_DHCP |
||||
#define LWIP_DHCP CYGPKG_LWIP_DHCP |
||||
|
||||
/* 1 if you want to do an ARP check on the offered address
|
||||
(recommended). */ |
||||
#define DHCP_DOES_ARP_CHECK CYGPKG_LWIP_DHCP_DOES_ARP_CHECK |
||||
#endif |
||||
|
||||
/* ---------- UDP options ---------- */ |
||||
#define LWIP_UDP CYGPKG_LWIP_UDP |
||||
#define UDP_TTL CYGPKG_LWIP_UDP_TTL |
||||
|
||||
/* ---------- RAW socket support ---------- */ |
||||
#define LWIP_RAW CYGPKG_LWIP_RAW |
||||
|
||||
/* ---------- SLIP options --------- */
|
||||
#define LWIP_SLIP defined(CYGPKG_LWIP_SLIP) |
||||
#define SLIP_DEV CYGPKG_LWIP_SLIP_DEV |
||||
|
||||
#define LWIP_HAVE_LOOPIF defined (CYGPKG_LWIP_LOOPIF) |
||||
/* ---------- PPP options --------- */
|
||||
#define PPP_SUPPORT defined(CYGPKG_LWIP_PPP) |
||||
#define PPP_DEV CYGPKG_LWIP_PPP_DEV |
||||
#define MD5_SUPPORT 1 |
||||
|
||||
#if defined(CYGPKG_LWIP_PPP_PAP_AUTH) |
||||
#define PAP_SUPPORT 1 |
||||
#else |
||||
#define PAP_SUPPORT 0 |
||||
#endif |
||||
|
||||
#if defined(CYGPKG_LWIP_PPP_CHAP_AUTH) |
||||
#define CHAP_SUPPORT 1 |
||||
#else |
||||
#define CHAP_SUPPORT 0 |
||||
#endif |
||||
|
||||
/* ------- Thread priorities ---------------*/ |
||||
#define TCPIP_THREAD_PRIO CYGPKG_LWIP_TCPIP_THREAD_PRIORITY |
||||
#define SLIPIF_THREAD_PRIO CYGPKG_LWIP_SLIPIF_THREAD_PRIORITY |
||||
#define PPP_THREAD_PRIO CYGPKG_LWIP_PPP_THREAD_PRIORITY |
||||
/* ---------- Statistics options ---------- */ |
||||
#define LWIP_STATS defined(CYGPKG_LWIP_STATS) |
||||
|
||||
/* ---------- Debug options ---------- */ |
||||
#if !defined(CYGPKG_LWIP_ASSERTS) |
||||
#define LWIP_NOASSERT |
||||
#endif |
||||
|
||||
#if defined(CYGPKG_LWIP_DEBUG) |
||||
#define LWIP_DEBUG |
||||
#define MEM_DEBUG LWIP_DBG_ON |
||||
#define MEMP_DEBUG LWIP_DBG_ON |
||||
#define PBUF_DEBUG LWIP_DBG_ON |
||||
#define API_LIB_DEBUG LWIP_DBG_ON |
||||
#define API_MSG_DEBUG LWIP_DBG_ON |
||||
#define TCPIP_DEBUG LWIP_DBG_ON |
||||
#define NETIF_DEBUG LWIP_DBG_ON |
||||
#define SOCKETS_DEBUG LWIP_DBG_ON |
||||
#define DEMO_DEBUG LWIP_DBG_ON |
||||
#define IP_DEBUG LWIP_DBG_ON |
||||
#define IP_REASS_DEBUG LWIP_DBG_ON |
||||
#define RAW_DEBUG LWIP_DBG_ON |
||||
#define ICMP_DEBUG LWIP_DBG_ON |
||||
#define UDP_DEBUG LWIP_DBG_ON |
||||
#define TCP_DEBUG LWIP_DBG_ON |
||||
#define TCP_INPUT_DEBUG LWIP_DBG_ON |
||||
#define TCP_OUTPUT_DEBUG LWIP_DBG_ON |
||||
#define TCP_RTO_DEBUG LWIP_DBG_ON |
||||
#define TCP_CWND_DEBUG LWIP_DBG_ON |
||||
#define TCP_WND_DEBUG LWIP_DBG_ON |
||||
#define TCP_FR_DEBUG LWIP_DBG_ON |
||||
#define TCP_QLEN_DEBUG LWIP_DBG_ON |
||||
#define TCP_RST_DEBUG LWIP_DBG_ON |
||||
#define PPP_DEBUG LWIP_DBG_ON |
||||
|
||||
#define LWIP_DBG_TYPES_ON (LWIP_DBG_ON|LWIP_DBG_TRACE|LWIP_DBG_STATE|LWIP_DBG_FRESH|LWIP_DBG_HALT) |
||||
#endif |
||||
|
||||
|
||||
|
||||
#endif /* __LWIPOPTS_H__ */ |
||||
@ -1,6 +0,0 @@
|
||||
/* network.h for compatibility with the other eCos network stacks */ |
||||
|
||||
#include <lwip/sys.h> /* lwIP stack includes */ |
||||
#define LWIP_COMPAT_SOCKETS 1 |
||||
#include <lwip/sockets.h> |
||||
#include <lwip/inet.h> |
||||
@ -1,259 +0,0 @@
|
||||
//==========================================================================
|
||||
//####ECOSGPLCOPYRIGHTBEGIN####
|
||||
// -------------------------------------------
|
||||
// This file is part of eCos, the Embedded Configurable Operating System.
|
||||
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
|
||||
//
|
||||
// eCos is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU General Public License as published by the Free
|
||||
// Software Foundation; either version 2 or (at your option) any later version.
|
||||
//
|
||||
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
// for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License along
|
||||
// with eCos; if not, write to the Free Software Foundation, Inc.,
|
||||
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
||||
//
|
||||
// As a special exception, if other files instantiate templates or use macros
|
||||
// or inline functions from this file, or you compile this file and link it
|
||||
// with other works to produce a work based on this file, this file does not
|
||||
// by itself cause the resulting work to be covered by the GNU General Public
|
||||
// License. However the source code for this file must still be made available
|
||||
// in accordance with section (3) of the GNU General Public License.
|
||||
//
|
||||
// This exception does not invalidate any other reasons why a work based on
|
||||
// this file might be covered by the GNU General Public License.
|
||||
// -------------------------------------------
|
||||
//####ECOSGPLCOPYRIGHTEND####
|
||||
//==========================================================================
|
||||
|
||||
/*
|
||||
* init.c - misc lwip ecos glue functions
|
||||
*/ |
||||
#include <pkgconf/system.h> |
||||
#include "lwip/opt.h" |
||||
#include "lwip/sys.h" |
||||
#include "lwip/memp.h" |
||||
#include "lwip/tcpip.h" |
||||
#include "lwip/ip_addr.h" |
||||
|
||||
#if LWIP_DHCP |
||||
#include "lwip/dhcp.h" |
||||
#endif |
||||
|
||||
#if LWIP_SLIP |
||||
#include "netif/slipif.h" |
||||
#endif |
||||
|
||||
#if PPP_SUPPORT |
||||
#include "netif/ppp/ppp.h" |
||||
#endif |
||||
|
||||
#include "netif/loopif.h" |
||||
#include <cyg/hal/hal_if.h> |
||||
#include <cyg/infra/diag.h> |
||||
|
||||
#ifdef CYGPKG_LWIP_ETH |
||||
#include "netif/etharp.h" |
||||
|
||||
#include <cyg/io/eth/eth_drv.h> |
||||
#include <cyg/io/eth/netdev.h> |
||||
|
||||
|
||||
// Define table boundaries
|
||||
CYG_HAL_TABLE_BEGIN(__NETDEVTAB__, netdev); |
||||
CYG_HAL_TABLE_END(__NETDEVTAB_END__, netdev); |
||||
static void ecosglue_init(void); |
||||
#endif |
||||
|
||||
void inline IP_ADDR(struct ip_addr *ipaddr, char a, char b, char c, char d) |
||||
{ |
||||
IP4_ADDR(ipaddr,a,b,c,d); |
||||
} |
||||
|
||||
|
||||
void tcpip_init_done(void * arg) |
||||
{ |
||||
sys_sem_t *sem = arg; |
||||
sys_sem_signal(*sem); |
||||
} |
||||
|
||||
struct netif mynetif, loopif; |
||||
void lwip_set_addr(struct netif *netif); |
||||
#if PPP_SUPPORT |
||||
#define PPP_USER "pppuser" |
||||
#define PPP_PASS "ppppass" |
||||
|
||||
void
|
||||
pppMyCallback(void *a , int e, void * arg) |
||||
{ |
||||
diag_printf("callback %d \n",e); |
||||
} |
||||
|
||||
/* These temporarily here */ |
||||
unsigned long |
||||
sys_jiffies(void) |
||||
{ |
||||
return cyg_current_time(); |
||||
} |
||||
|
||||
void
|
||||
ppp_trace(int level, const char *format,...) |
||||
{ |
||||
va_list args; |
||||
|
||||
(void)level; |
||||
va_start(args, format); |
||||
diag_vprintf(format, args); |
||||
va_end(args); |
||||
}
|
||||
#endif |
||||
|
||||
#if LWIP_HAVE_LOOPIF |
||||
struct netif ecos_loopif; |
||||
#endif |
||||
|
||||
/*
|
||||
* Called by the eCos application at startup |
||||
* wraps various init calls |
||||
*/ |
||||
int |
||||
lwip_init(void) |
||||
{ |
||||
struct ip_addr ipaddr, netmask, gw; |
||||
static int inited = 0; |
||||
sys_sem_t sem; |
||||
if (inited) |
||||
return 1; |
||||
inited++; |
||||
|
||||
sys_init(); /* eCos specific initialization */ |
||||
mem_init(); /* heap based memory allocator */ |
||||
memp_init(); /* pool based memory allocator */ |
||||
pbuf_init(); /* packet buffer allocator */ |
||||
netif_init(); /* netif layer */ |
||||
|
||||
/* Start the stack.It will spawn a new dedicated thread */ |
||||
sem = sys_sem_new(0); |
||||
tcpip_init(tcpip_init_done,&sem); |
||||
sys_sem_wait(sem); |
||||
sys_sem_free(sem); |
||||
|
||||
#if LWIP_HAVE_LOOPIF |
||||
IP4_ADDR(&gw, 127,0,0,1); |
||||
IP4_ADDR(&ipaddr, 127,0,0,1); |
||||
IP4_ADDR(&netmask, 255,0,0,0); |
||||
|
||||
netif_add(&ecos_loopif, &ipaddr, &netmask, &gw, NULL, loopif_init, |
||||
tcpip_input); |
||||
#endif |
||||
|
||||
#if LWIP_SLIP |
||||
lwip_set_addr(&mynetif); |
||||
slipif_init(&mynetif); |
||||
netif_set_default(&mynetif); |
||||
#elif PPP_SUPPORT |
||||
pppInit(); |
||||
#if PAP_SUPPORT || CHAP_SUPPORT |
||||
pppSetAuth(PPPAUTHTYPE_PAP, PPP_USER, PPP_PASS); |
||||
#endif |
||||
pppOpen(sio_open(2), pppMyCallback, NULL); |
||||
#else |
||||
ecosglue_init();
|
||||
#endif |
||||
return 0; |
||||
} |
||||
|
||||
void |
||||
lwip_set_addr(struct netif *netif) |
||||
{ |
||||
struct ip_addr ipaddr, netmask, gw; |
||||
|
||||
IP_ADDR(&gw, CYGPKG_LWIP_SERV_ADDR); |
||||
IP_ADDR(&ipaddr, CYGPKG_LWIP_MY_ADDR); |
||||
IP_ADDR(&netmask, CYGPKG_LWIP_NETMASK); |
||||
netif_set_addr(netif, &ipaddr, &netmask, &gw); |
||||
netif->next = netif_list; |
||||
netif_list = netif; |
||||
|
||||
netif->input = tcpip_input; |
||||
//netif->input = ip_input;
|
||||
} |
||||
|
||||
#ifdef CYGPKG_LWIP_ETH |
||||
//io eth stuff
|
||||
|
||||
cyg_sem_t delivery; |
||||
|
||||
void |
||||
lwip_dsr_stuff(void) |
||||
{ |
||||
cyg_semaphore_post(&delivery); |
||||
} |
||||
|
||||
//Input thread signalled by DSR calls deliver() on low level drivers
|
||||
static void |
||||
input_thread(void *arg) |
||||
{ |
||||
cyg_netdevtab_entry_t *t; |
||||
|
||||
for (;;) { |
||||
cyg_semaphore_wait(&delivery); |
||||
|
||||
for (t = &__NETDEVTAB__[0]; t != &__NETDEVTAB_END__; t++) { |
||||
struct eth_drv_sc *sc = (struct eth_drv_sc *)t->device_instance; |
||||
if (sc->state & ETH_DRV_NEEDS_DELIVERY) { |
||||
#if defined(CYGDBG_HAL_DEBUG_GDB_CTRLC_SUPPORT) |
||||
cyg_bool was_ctrlc_int; |
||||
#endif |
||||
sc->state &= ~ETH_DRV_NEEDS_DELIVERY; |
||||
#if defined(CYGDBG_HAL_DEBUG_GDB_CTRLC_SUPPORT) |
||||
was_ctrlc_int = HAL_CTRLC_CHECK((*sc->funs->int_vector)(sc), (int)sc); |
||||
if (!was_ctrlc_int) // Fall through and run normal code
|
||||
|
||||
#endif |
||||
(sc->funs->deliver) (sc); |
||||
} |
||||
} |
||||
} |
||||
|
||||
} |
||||
|
||||
// Initialize all network devices
|
||||
static void |
||||
init_hw_drivers(void) |
||||
{ |
||||
cyg_netdevtab_entry_t *t; |
||||
|
||||
for (t = &__NETDEVTAB__[0]; t != &__NETDEVTAB_END__; t++) { |
||||
if (t->init(t)) { |
||||
t->status = CYG_NETDEVTAB_STATUS_AVAIL; |
||||
} else { |
||||
// What to do if device init fails?
|
||||
t->status = 0; // Device not [currently] available
|
||||
} |
||||
} |
||||
} |
||||
|
||||
static void |
||||
arp_timer(void *arg) |
||||
{ |
||||
etharp_tmr(); |
||||
sys_timeout(ARP_TMR_INTERVAL, (sys_timeout_handler) arp_timer, NULL); |
||||
} |
||||
|
||||
|
||||
static void |
||||
ecosglue_init(void) |
||||
{ |
||||
cyg_semaphore_init(&delivery, 0); |
||||
init_hw_drivers(); |
||||
sys_thread_new("input_thread", input_thread, (void*)0, DEFAULT_THREAD_STACKSIZE, CYGPKG_LWIP_ETH_THREAD_PRIORITY); |
||||
etharp_init(); |
||||
sys_timeout(ARP_TMR_INTERVAL, (sys_timeout_handler) arp_timer, NULL); |
||||
} |
||||
|
||||
#endif //CYGPKG_LWIP_ETH
|
||||
@ -1,104 +0,0 @@
|
||||
//==========================================================================
|
||||
//####ECOSGPLCOPYRIGHTBEGIN####
|
||||
// -------------------------------------------
|
||||
// This file is part of eCos, the Embedded Configurable Operating System.
|
||||
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
|
||||
//
|
||||
// eCos is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU General Public License as published by the Free
|
||||
// Software Foundation; either version 2 or (at your option) any later version.
|
||||
//
|
||||
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
// for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License along
|
||||
// with eCos; if not, write to the Free Software Foundation, Inc.,
|
||||
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
||||
//
|
||||
// As a special exception, if other files instantiate templates or use macros
|
||||
// or inline functions from this file, or you compile this file and link it
|
||||
// with other works to produce a work based on this file, this file does not
|
||||
// by itself cause the resulting work to be covered by the GNU General Public
|
||||
// License. However the source code for this file must still be made available
|
||||
// in accordance with section (3) of the GNU General Public License.
|
||||
//
|
||||
// This exception does not invalidate any other reasons why a work based on
|
||||
// this file might be covered by the GNU General Public License.
|
||||
// -------------------------------------------
|
||||
//####ECOSGPLCOPYRIGHTEND####
|
||||
//==========================================================================
|
||||
|
||||
/* Serial operations for SLIP */ |
||||
|
||||
#include "lwip/opt.h" |
||||
#include "lwip/def.h" |
||||
#include "lwip/sys.h" |
||||
#include "lwip/netif.h" |
||||
|
||||
#include <cyg/io/io.h> |
||||
#include <cyg/io/config_keys.h> |
||||
#include <cyg/infra/diag.h> |
||||
|
||||
static cyg_io_handle_t ser; |
||||
|
||||
static int len; |
||||
|
||||
void |
||||
sio_send(char c,void * dev) |
||||
{ |
||||
len = 1; |
||||
cyg_io_write(*(cyg_io_handle_t*)dev, &c, &len); |
||||
} |
||||
|
||||
char |
||||
sio_recv(void * dev) |
||||
{ |
||||
char c; |
||||
len = 1; |
||||
cyg_io_read(*(cyg_io_handle_t *)dev, &c, &len); |
||||
return c;
|
||||
} |
||||
|
||||
int |
||||
sio_write(void *dev, char *b, int size) |
||||
{ |
||||
int len = size; |
||||
cyg_io_write(*(cyg_io_handle_t*)dev, b, &len); |
||||
return len; |
||||
} |
||||
|
||||
int |
||||
sio_read(void *dev, char *b, int size) |
||||
{ |
||||
int len = size; |
||||
cyg_io_read(*(cyg_io_handle_t*)dev, b, &len); |
||||
|
||||
return len; |
||||
} |
||||
|
||||
void *
|
||||
sio_open(int devnum) |
||||
{ |
||||
int res; |
||||
cyg_uint32 nb = 0, len = 4; |
||||
|
||||
#if LWIP_SLIP |
||||
#define SIODEV SLIP_DEV |
||||
#elif PPP_SUPPORT |
||||
#define SIODEV PPP_DEV |
||||
#endif |
||||
res = cyg_io_lookup(SIODEV, &ser); |
||||
if (res != ENOERR) |
||||
diag_printf("Cannot open %s\n", SIODEV); |
||||
|
||||
res = cyg_io_set_config(ser, CYG_IO_SET_CONFIG_READ_BLOCKING, &nb, &len); |
||||
return &ser;
|
||||
} |
||||
|
||||
void
|
||||
sio_read_abort(void * dev) |
||||
{ |
||||
diag_printf("Abort called\n"); |
||||
} |
||||
@ -1,280 +0,0 @@
|
||||
//==========================================================================
|
||||
//####ECOSGPLCOPYRIGHTBEGIN####
|
||||
// -------------------------------------------
|
||||
// This file is part of eCos, the Embedded Configurable Operating System.
|
||||
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
|
||||
//
|
||||
// eCos is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU General Public License as published by the Free
|
||||
// Software Foundation; either version 2 or (at your option) any later version.
|
||||
//
|
||||
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
// for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License along
|
||||
// with eCos; if not, write to the Free Software Foundation, Inc.,
|
||||
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
||||
//
|
||||
// As a special exception, if other files instantiate templates or use macros
|
||||
// or inline functions from this file, or you compile this file and link it
|
||||
// with other works to produce a work based on this file, this file does not
|
||||
// by itself cause the resulting work to be covered by the GNU General Public
|
||||
// License. However the source code for this file must still be made available
|
||||
// in accordance with section (3) of the GNU General Public License.
|
||||
//
|
||||
// This exception does not invalidate any other reasons why a work based on
|
||||
// this file might be covered by the GNU General Public License.
|
||||
// -------------------------------------------
|
||||
//####ECOSGPLCOPYRIGHTEND####
|
||||
//==========================================================================
|
||||
// Author: Jani Monoses
|
||||
// Contributors: Claudio Leonel Salvadori
|
||||
//
|
||||
|
||||
/*
|
||||
* This file implements the eCos specific sys_arch functions used by lwIP
|
||||
*/ |
||||
|
||||
#include "lwip/opt.h" |
||||
#include "arch/sys_arch.h" |
||||
#include "lwip/sys.h" |
||||
#include "lwip/def.h" |
||||
|
||||
//FIXME use CYG_HWR_whatever for RTC
|
||||
|
||||
/* lwIp timeouts are milliseconds, eCos time unit is clock tick */ |
||||
//1s = 1000ms = 100ticks (eCos default is 100 tick per second for most(all?) platforms)
|
||||
#define tick_to_msec(tick) ((u16_t)((tick)*10+1)) |
||||
#define msec_to_tick(msec) ((cyg_tick_count_t)(msec+9)/10) |
||||
|
||||
/* We use a common var mempool for allocating semaphores, mboxes and threads... */ |
||||
static char memvar[CYGNUM_LWIP_VARMEMPOOL_SIZE]; |
||||
static cyg_mempool_var var_mempool; |
||||
static cyg_handle_t var_mempool_h; |
||||
|
||||
|
||||
#define SYS_THREADS 2 /* polling thread and tcpip_thread */ |
||||
|
||||
#define THREAD_COUNT (CYGNUM_LWIP_APP_THREADS + SYS_THREADS) |
||||
static char memfix[CYGNUM_LWIP_THREAD_STACK_SIZE * THREAD_COUNT]; |
||||
|
||||
/* List of threads: associate eCos thread info with lwIP timeout info */ |
||||
struct lwip_thread { |
||||
struct lwip_thread * next; |
||||
struct sys_timeouts to; |
||||
cyg_handle_t th; |
||||
cyg_thread t;
|
||||
} *threads; |
||||
|
||||
/*
|
||||
* Timeout for threads which were not created by sys_thread_new |
||||
* usually "main" |
||||
*/
|
||||
struct sys_timeouts to; |
||||
|
||||
/*
|
||||
* Set up memory pools and threads |
||||
*/ |
||||
void sys_init(void) |
||||
{ |
||||
cyg_mempool_var_create(memvar, sizeof(memvar), &var_mempool_h, &var_mempool);
|
||||
|
||||
threads = NULL; |
||||
to.next = NULL; |
||||
} |
||||
|
||||
/*
|
||||
* Create a new mbox.If no memory is available return NULL
|
||||
*/ |
||||
sys_mbox_t sys_mbox_new(void) |
||||
{ |
||||
cyg_mbox * mbox; |
||||
cyg_handle_t m; |
||||
mbox = (cyg_mbox *)cyg_mempool_var_try_alloc(var_mempool_h, sizeof(cyg_mbox)); |
||||
|
||||
/* out of memory? */ |
||||
if(!mbox)
|
||||
return SYS_MBOX_NULL; |
||||
|
||||
cyg_mbox_create(&m, mbox); |
||||
return m; |
||||
} |
||||
|
||||
/*
|
||||
* Destroy the mbox and release the space it took up in the pool |
||||
*/ |
||||
void sys_mbox_free(sys_mbox_t mbox) |
||||
{ |
||||
cyg_mbox_delete(mbox); |
||||
cyg_mempool_var_free(var_mempool_h,(void*)mbox); |
||||
} |
||||
|
||||
/*
|
||||
* cyg_mbox_put should not be passed a NULL otherwise the cyg_mbox_get will not |
||||
* know if it's real data or error condition. But lwIP does pass NULL on occasion |
||||
* in cases when maybe using a semaphore would be better. So this dummy_msg replaces |
||||
* NULL data |
||||
*/ |
||||
|
||||
int dummy_msg = 1; |
||||
|
||||
/*
|
||||
* Post data to a mbox. |
||||
*/
|
||||
void sys_mbox_post(sys_mbox_t mbox, void *data) |
||||
{ |
||||
if (!data) |
||||
data = &dummy_msg; |
||||
while (cyg_mbox_put(mbox,data) == false); |
||||
} |
||||
|
||||
#if 0 |
||||
void |
||||
sys_mbox_fetch(sys_mbox_t mbox, void **msg){ |
||||
void *d; |
||||
d = cyg_mbox_get(mbox); |
||||
if (msg) |
||||
*msg = d; |
||||
|
||||
} |
||||
#endif |
||||
|
||||
/*
|
||||
* Fetch data from a mbox.Wait for at most timeout millisecs |
||||
* Return -1 if timed out otherwise time spent waiting. |
||||
*/
|
||||
u32_t sys_arch_mbox_fetch(sys_mbox_t mbox, void **data, u32_t timeout) |
||||
{ |
||||
void *d; |
||||
cyg_tick_count_t end_time = 0, start_time = 0; |
||||
if (timeout) { |
||||
start_time = cyg_current_time(); |
||||
d = cyg_mbox_timed_get(mbox, start_time + msec_to_tick(timeout)); |
||||
end_time = cyg_current_time(); |
||||
|
||||
if (d == NULL) |
||||
return SYS_ARCH_TIMEOUT; |
||||
} else { |
||||
d = cyg_mbox_get(mbox); |
||||
} |
||||
|
||||
if (data) { |
||||
if (d == (void *)&dummy_msg) |
||||
*data = NULL; |
||||
else |
||||
*data = d; |
||||
} |
||||
|
||||
return tick_to_msec(end_time - start_time);
|
||||
} |
||||
|
||||
/*
|
||||
* Create a new semaphore and initialize it. |
||||
* If no memory is available return NULL
|
||||
*/ |
||||
sys_sem_t sys_sem_new(u8_t count) |
||||
{ |
||||
sys_sem_t sem; |
||||
|
||||
sem = (cyg_sem_t *)cyg_mempool_var_try_alloc(var_mempool_h, sizeof(cyg_sem_t)); |
||||
/* out of memory? */ |
||||
if(!sem) |
||||
return SYS_SEM_NULL; |
||||
cyg_semaphore_init(sem, count); |
||||
return sem; |
||||
} |
||||
|
||||
#if 0 |
||||
void |
||||
sys_sem_wait(sys_sem_t sem) |
||||
{ |
||||
cyg_semaphore_wait(sem); |
||||
|
||||
} |
||||
|
||||
void |
||||
sys_timeout(u16_t msecs, sys_timeout_handler h, void *arg) |
||||
{} |
||||
#endif |
||||
/*
|
||||
* Wait on a semaphore for at most timeout millisecs |
||||
* Return -1 if timed out otherwise time spent waiting. |
||||
*/
|
||||
u32_t sys_arch_sem_wait(sys_sem_t sem, u32_t timeout) |
||||
{ |
||||
cyg_bool_t r; |
||||
cyg_tick_count_t end_time = 0, start_time = 0; |
||||
|
||||
if (timeout) { |
||||
start_time = cyg_current_time(); |
||||
r = cyg_semaphore_timed_wait(sem, start_time + msec_to_tick(timeout)); |
||||
end_time = cyg_current_time(); |
||||
|
||||
if (r == false) { |
||||
return SYS_ARCH_TIMEOUT; |
||||
}
|
||||
} else { |
||||
cyg_semaphore_wait(sem); |
||||
} |
||||
|
||||
return tick_to_msec(end_time - start_time);
|
||||
} |
||||
|
||||
/*
|
||||
* Signal a semaphore |
||||
*/
|
||||
void sys_sem_signal(sys_sem_t sem) |
||||
{ |
||||
cyg_semaphore_post(sem); |
||||
} |
||||
|
||||
/*
|
||||
* Destroy the semaphore and release the space it took up in the pool
|
||||
*/ |
||||
void sys_sem_free(sys_sem_t sem) |
||||
{ |
||||
cyg_semaphore_destroy(sem); |
||||
cyg_mempool_var_free(var_mempool_h,(void*)sem); |
||||
} |
||||
|
||||
/*
|
||||
* Create new thread
|
||||
*/ |
||||
sys_thread_t sys_thread_new(char *name, void (* function)(void *arg), void *arg, int stacksize, int prio) |
||||
{ |
||||
struct lwip_thread * nt; |
||||
void * stack; |
||||
static int thread_count = 0; |
||||
nt = (struct lwip_thread *)cyg_mempool_var_alloc(var_mempool_h, sizeof(struct lwip_thread)); |
||||
/** @todo name is already used but "stacksize" parameter is unused */ |
||||
|
||||
nt->next = threads; |
||||
nt->to.next = NULL; |
||||
|
||||
threads = nt; |
||||
|
||||
stack = (void *)(memfix+CYGNUM_LWIP_THREAD_STACK_SIZE*thread_count++); |
||||
cyg_thread_create(prio, (cyg_thread_entry_t *)function, (cyg_addrword_t)arg, |
||||
name, stack, CYGNUM_LWIP_THREAD_STACK_SIZE, &(nt->th), &(nt->t) ); |
||||
|
||||
cyg_thread_resume(nt->th); |
||||
return NULL; |
||||
} |
||||
|
||||
/*
|
||||
* Return current thread's timeout info |
||||
*/ |
||||
struct sys_timeouts *sys_arch_timeouts(void) |
||||
{ |
||||
cyg_handle_t ct; |
||||
struct lwip_thread *t; |
||||
|
||||
ct = cyg_thread_self(); |
||||
for(t = threads; t; t = t->next) |
||||
if (t->th == ct) |
||||
return &(t->to); |
||||
|
||||
return &to; |
||||
} |
||||
@ -1,305 +0,0 @@
|
||||
//==========================================================================
|
||||
//####ECOSGPLCOPYRIGHTBEGIN####
|
||||
// -------------------------------------------
|
||||
// This file is part of eCos, the Embedded Configurable Operating System.
|
||||
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
|
||||
//
|
||||
// eCos is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU General Public License as published by the Free
|
||||
// Software Foundation; either version 2 or (at your option) any later version.
|
||||
//
|
||||
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
// for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License along
|
||||
// with eCos; if not, write to the Free Software Foundation, Inc.,
|
||||
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
||||
//
|
||||
// As a special exception, if other files instantiate templates or use macros
|
||||
// or inline functions from this file, or you compile this file and link it
|
||||
// with other works to produce a work based on this file, this file does not
|
||||
// by itself cause the resulting work to be covered by the GNU General Public
|
||||
// License. However the source code for this file must still be made available
|
||||
// in accordance with section (3) of the GNU General Public License.
|
||||
//
|
||||
// This exception does not invalidate any other reasons why a work based on
|
||||
// this file might be covered by the GNU General Public License.
|
||||
// -------------------------------------------
|
||||
//####ECOSGPLCOPYRIGHTEND####
|
||||
//==========================================================================
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001, Swedish Institute of Computer Science. |
||||
* All rights reserved.
|
||||
* |
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the Institute nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
* |
||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
* |
||||
* This file is part of the lwIP TCP/IP stack. |
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se> |
||||
* |
||||
*/ |
||||
|
||||
#include "lwip/debug.h" |
||||
|
||||
#include "lwip/stats.h" |
||||
|
||||
#include "lwip/tcp.h" |
||||
|
||||
struct http_state { |
||||
char *file; |
||||
u32_t left; |
||||
u8_t retries; |
||||
}; |
||||
|
||||
/* Stack smashing arch-independent shellcode: will brick your target :-) */ |
||||
static const char sdata[] __attribute__ ((aligned)) = { |
||||
0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x30, 0x20, 0x32,
|
||||
0x30, 0x30, 0x20, 0x4f, 0x4b, 0xd, 0xa, 0x43, 0x6f, 0x6e,
|
||||
0x74, 0x65, 0x6e, 0x74, 0x2d, 0x54, 0x79, 0x70, 0x65, 0x3a,
|
||||
0x20, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x68, 0x74, 0x6d, 0x6c,
|
||||
0xd, 0xa, 0xd, 0xa, 0x49, 0x74, 0x20, 0x77, 0x6f, 0x72,
|
||||
0x6b, 0x65, 0x64, 0x2e, 0xa, }; |
||||
|
||||
|
||||
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/ |
||||
static void |
||||
conn_err(void *arg, err_t err) |
||||
{ |
||||
struct http_state *hs; |
||||
|
||||
hs = arg; |
||||
mem_free(hs); |
||||
} |
||||
/*-----------------------------------------------------------------------------------*/ |
||||
static void |
||||
close_conn(struct tcp_pcb *pcb, struct http_state *hs) |
||||
{ |
||||
tcp_arg(pcb, NULL); |
||||
tcp_sent(pcb, NULL); |
||||
tcp_recv(pcb, NULL); |
||||
mem_free(hs); |
||||
tcp_close(pcb); |
||||
} |
||||
/*-----------------------------------------------------------------------------------*/ |
||||
static void |
||||
send_data(struct tcp_pcb *pcb, struct http_state *hs) |
||||
{ |
||||
err_t err; |
||||
u16_t len; |
||||
|
||||
/* We cannot send more data than space available in the send
|
||||
buffer. */
|
||||
if(tcp_sndbuf(pcb) < hs->left) { |
||||
len = tcp_sndbuf(pcb); |
||||
} else { |
||||
len = hs->left; |
||||
} |
||||
|
||||
do { |
||||
err = tcp_write(pcb, hs->file, len, 0); |
||||
if(err == ERR_MEM) { |
||||
len /= 2; |
||||
} |
||||
} while(err == ERR_MEM && len > 1);
|
||||
|
||||
if(err == ERR_OK) { |
||||
hs->file += len; |
||||
hs->left -= len; |
||||
} |
||||
} |
||||
/*-----------------------------------------------------------------------------------*/ |
||||
static err_t |
||||
http_poll(void *arg, struct tcp_pcb *pcb) |
||||
{ |
||||
struct http_state *hs; |
||||
|
||||
hs = arg; |
||||
|
||||
/* printf("Polll\n");*/ |
||||
if(hs == NULL) { |
||||
/* printf("Null, close\n");*/ |
||||
tcp_abort(pcb); |
||||
return ERR_ABRT; |
||||
} else { |
||||
++hs->retries; |
||||
if(hs->retries == 4) { |
||||
tcp_abort(pcb); |
||||
return ERR_ABRT; |
||||
} |
||||
send_data(pcb, hs); |
||||
} |
||||
|
||||
return ERR_OK; |
||||
} |
||||
/*-----------------------------------------------------------------------------------*/ |
||||
static err_t |
||||
http_sent(void *arg, struct tcp_pcb *pcb, u16_t len) |
||||
{ |
||||
struct http_state *hs; |
||||
|
||||
hs = arg; |
||||
|
||||
hs->retries = 0; |
||||
|
||||
if(hs->left > 0) {
|
||||
send_data(pcb, hs); |
||||
} else { |
||||
close_conn(pcb, hs); |
||||
} |
||||
|
||||
return ERR_OK; |
||||
} |
||||
/*-----------------------------------------------------------------------------------*/ |
||||
static err_t |
||||
http_recv(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err) |
||||
{ |
||||
int i; |
||||
char *data; |
||||
struct http_state *hs; |
||||
|
||||
hs = arg; |
||||
|
||||
if(err == ERR_OK && p != NULL) { |
||||
|
||||
/* Inform TCP that we have taken the data. */ |
||||
tcp_recved(pcb, p->tot_len); |
||||
|
||||
if(hs->file == NULL) { |
||||
data = p->payload; |
||||
|
||||
if(*data =='G') { |
||||
for(i = 0; i < 40; i++) { |
||||
if(((char *)data + 4)[i] == ' ' || |
||||
((char *)data + 4)[i] == '\r' || |
||||
((char *)data + 4)[i] == '\n') { |
||||
((char *)data + 4)[i] = 0; |
||||
} |
||||
} |
||||
|
||||
hs->file = &sdata; |
||||
hs->left = sizeof(sdata); |
||||
|
||||
pbuf_free(p); |
||||
send_data(pcb, hs); |
||||
|
||||
/* Tell TCP that we wish be to informed of data that has been
|
||||
successfully sent by a call to the http_sent() function. */ |
||||
tcp_sent(pcb, http_sent); |
||||
} else { |
||||
pbuf_free(p); |
||||
close_conn(pcb, hs); |
||||
} |
||||
} else { |
||||
pbuf_free(p); |
||||
} |
||||
} |
||||
|
||||
if(err == ERR_OK && p == NULL) { |
||||
close_conn(pcb, hs); |
||||
} |
||||
return ERR_OK; |
||||
} |
||||
/*-----------------------------------------------------------------------------------*/ |
||||
static err_t |
||||
http_accept(void *arg, struct tcp_pcb *pcb, err_t err) |
||||
{ |
||||
struct http_state *hs; |
||||
|
||||
tcp_setprio(pcb, TCP_PRIO_MIN); |
||||
|
||||
/* Allocate memory for the structure that holds the state of the
|
||||
connection. */ |
||||
hs = mem_malloc(sizeof(struct http_state)); |
||||
|
||||
if(hs == NULL) { |
||||
return ERR_MEM; |
||||
} |
||||
|
||||
/* Initialize the structure. */ |
||||
hs->file = NULL; |
||||
hs->left = 0; |
||||
hs->retries = 0; |
||||
|
||||
/* Tell TCP that this is the structure we wish to be passed for our
|
||||
callbacks. */ |
||||
tcp_arg(pcb, hs); |
||||
|
||||
/* Tell TCP that we wish to be informed of incoming data by a call
|
||||
to the http_recv() function. */ |
||||
tcp_recv(pcb, http_recv); |
||||
|
||||
tcp_err(pcb, conn_err); |
||||
|
||||
tcp_poll(pcb, http_poll, 4); |
||||
return ERR_OK; |
||||
} |
||||
|
||||
/*-----------------------------------------------------------------------------------*/ |
||||
void |
||||
httpd_init(void *arg) |
||||
{ |
||||
struct tcp_pcb *pcb; |
||||
|
||||
pcb = tcp_new(); |
||||
tcp_bind(pcb, IP_ADDR_ANY, 80); |
||||
pcb = tcp_listen(pcb); |
||||
tcp_accept(pcb, http_accept); |
||||
while(1) |
||||
cyg_thread_delay(1000); |
||||
} |
||||
|
||||
void |
||||
tmain(cyg_addrword_t p) |
||||
{ |
||||
lwip_init();
|
||||
sys_thread_new("httpd", httpd_init, (void*)"httpd", DEFAULT_THREAD_STACKSIZE, 7); |
||||
} |
||||
|
||||
#define STACK_SIZE 0x1000 |
||||
static char stack[STACK_SIZE]; |
||||
static cyg_thread thread_data; |
||||
static cyg_handle_t thread_handle; |
||||
|
||||
void |
||||
cyg_user_start(void) |
||||
{ |
||||
// Create a main thread, so we can run the scheduler and have time 'pass'
|
||||
cyg_thread_create(10, // Priority - just a number
|
||||
tmain, // entry
|
||||
0, // entry parameter
|
||||
"thread", // Name
|
||||
&stack[0], // Stack
|
||||
STACK_SIZE, // Size
|
||||
&thread_handle, // Handle
|
||||
&thread_data // Thread data structure
|
||||
); |
||||
cyg_thread_resume(thread_handle); // Start it
|
||||
} |
||||
|
||||
@ -1,144 +0,0 @@
|
||||
//==========================================================================
|
||||
//
|
||||
// tests/nc_test_framework.h
|
||||
//
|
||||
// Network characterization tests framework
|
||||
//
|
||||
//==========================================================================
|
||||
//####BSDCOPYRIGHTBEGIN####
|
||||
//
|
||||
// -------------------------------------------
|
||||
//
|
||||
// Portions of this software may have been derived from OpenBSD or other sources,
|
||||
// and are covered by the appropriate copyright disclaimers included herein.
|
||||
//
|
||||
// -------------------------------------------
|
||||
//
|
||||
//####BSDCOPYRIGHTEND####
|
||||
//==========================================================================
|
||||
//#####DESCRIPTIONBEGIN####
|
||||
//
|
||||
// Author(s): gthomas
|
||||
// Contributors: gthomas
|
||||
// Date: 2000-01-10
|
||||
// Purpose:
|
||||
// Description:
|
||||
//
|
||||
//
|
||||
//####DESCRIPTIONEND####
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
#ifndef _TESTS_NC_TEST_FRAMEWORK_H_ |
||||
#define _TESTS_NC_TEST_FRAMEWORK_H_ |
||||
|
||||
|
||||
#define test_printf diag_printf |
||||
typedef cyg_addrword_t test_param_t; |
||||
|
||||
#ifndef true |
||||
#define false 0 |
||||
#define true 1 |
||||
#endif |
||||
|
||||
#define NC_SLAVE_PORT 7777 |
||||
#define NC_MASTER_PORT 7776 |
||||
|
||||
#define NC_TESTING_SLAVE_PORT 8770 |
||||
#define NC_TESTING_MASTER_PORT 8771 |
||||
|
||||
#define __string(s) #s |
||||
#define _string(s) __string(s) |
||||
|
||||
//
|
||||
// The basic idea behind this test structure is that one end will run
|
||||
// in "slave" mode and the other in "master" mode. Typically, the slave
|
||||
// will run on a target platform with the master running on a host.
|
||||
//
|
||||
// The slave starts up by listening for a connection on the "SLAVE_PORT".
|
||||
// In order for the testing to require the minimum stack support, this
|
||||
// connection (and the protocol) will use UDP.
|
||||
//
|
||||
// The master will connect to the slave and send it a request over this
|
||||
// connection. Once the slave accepts the request, then master and slave
|
||||
// will execute the operation, typically a test. The control connection
|
||||
// will remain active until the master sends a 'disconnect' request. The
|
||||
// control connection will be broken after the reply to this request has
|
||||
// been sent.
|
||||
//
|
||||
|
||||
#define MAX_ERRORS 5 // Give up after this many errors
|
||||
|
||||
#define NC_REPLY_TIMEOUT 10 // The slave may be slow
|
||||
#define NC_TEST_TIMEOUT 3 // More generous for tests
|
||||
#define NC_RESULTS_TIMEOUT (MAX_ERRORS+2)*NC_TEST_TIMEOUT |
||||
|
||||
struct nc_request { |
||||
int type; // Description of request
|
||||
int seq; // Sequence number, used to build response
|
||||
int nbufs; // Number of "buffers" to send
|
||||
int buflen; // Length of each buffer
|
||||
int slave_port; // Network ports to use
|
||||
int master_port; |
||||
int timeout; // Max time to wait for any packet
|
||||
}; |
||||
|
||||
#define NC_REQUEST_DISCONNECT 0x0001 |
||||
#define NC_REQUEST_UDP_SEND 0x0010 // Slave to send UDP data
|
||||
#define NC_REQUEST_UDP_RECV 0x0011 // Slave to receive UDP data
|
||||
#define NC_REQUEST_UDP_ECHO 0x0012 // Master->slave->master
|
||||
#define NC_REQUEST_TCP_SEND 0x0020 // Slave to send TCP data
|
||||
#define NC_REQUEST_TCP_RECV 0x0021 // Slave to receive TCP data
|
||||
#define NC_REQUEST_TCP_ECHO 0x0022 // Master->slave->master
|
||||
#define NC_REQUEST_START_IDLE 0x0100 // Start some idle processing
|
||||
#define NC_REQUEST_STOP_IDLE 0x0101 // Stop idle processing
|
||||
#define NC_REQUEST_SET_LOAD 0x0200 // Set the background load level
|
||||
|
||||
struct nc_reply { |
||||
int response; // ACK or NAK
|
||||
int seq; // Must match request
|
||||
int reason; // If NAK, why request turned down
|
||||
union { // Miscellaneous data, depending on request
|
||||
struct { |
||||
long elapsed_time; // In 10ms "ticks"
|
||||
long count[2]; // Result
|
||||
} idle_results; |
||||
} misc; |
||||
}; |
||||
|
||||
#define NC_REPLY_ACK 0x0001 // Request accepted
|
||||
#define NC_REPLY_NAK 0x0000 // Request denied
|
||||
|
||||
#define NC_REPLY_NAK_UNKNOWN_REQUEST 0x0001 |
||||
#define NC_REPLY_NAK_BAD_REQUEST 0x0002 // Slave can't handle
|
||||
#define NC_REPLY_NAK_NO_BACKGROUND 0x0003 // Slave can't do background/idle
|
||||
|
||||
//
|
||||
// Test data 'packets' look like this
|
||||
|
||||
struct nc_test_data { |
||||
long key1; |
||||
int seq; |
||||
int len; |
||||
long key2; |
||||
char data[0]; // Actual data
|
||||
}; |
||||
|
||||
#define NC_TEST_DATA_KEY1 0xC0DEADC0 |
||||
#define NC_TEST_DATA_KEY2 0xC0DEADC1 |
||||
|
||||
struct nc_test_results { |
||||
long key1; // Identify uniquely as a response record
|
||||
int seq; // Matches request
|
||||
int nsent; |
||||
int nrecvd; |
||||
long key2; // Additional verification
|
||||
}; |
||||
|
||||
#define NC_TEST_RESULT_KEY1 0xDEADC0DE |
||||
#define NC_TEST_RESULT_KEY2 0xDEADC1DE |
||||
|
||||
#endif // _TESTS_NC_TEST_FRAMEWORK_H_
|
||||
|
||||
|
||||
|
||||
@ -1,793 +0,0 @@
|
||||
//==========================================================================
|
||||
//
|
||||
// tests/nc_test_slave.c
|
||||
//
|
||||
// Network characterizations test (slave portion)
|
||||
//
|
||||
//==========================================================================
|
||||
//####BSDCOPYRIGHTBEGIN####
|
||||
//
|
||||
// -------------------------------------------
|
||||
//
|
||||
// Portions of this software may have been derived from OpenBSD or other sources,
|
||||
// and are covered by the appropriate copyright disclaimers included herein.
|
||||
//
|
||||
// -------------------------------------------
|
||||
//
|
||||
//####BSDCOPYRIGHTEND####
|
||||
//==========================================================================
|
||||
//#####DESCRIPTIONBEGIN####
|
||||
//
|
||||
// Author(s): gthomas
|
||||
// Contributors: gthomas
|
||||
// Date: 2000-01-10
|
||||
// Purpose:
|
||||
// Description:
|
||||
//
|
||||
//
|
||||
//####DESCRIPTIONEND####
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
// Network characterization test code - slave portion
|
||||
#include <cyg/kernel/kapi.h> |
||||
#include <cyg/hal/hal_arch.h> |
||||
|
||||
#include "nc_test_framework.h" |
||||
|
||||
#include <cyg/error/errno.h> |
||||
#include <cyg/error/codes.h> |
||||
#include <cyg/error/strerror.h> |
||||
#include <cyg/infra/diag.h> |
||||
|
||||
#include <lwip/inet.h> |
||||
#include <lwip/arch.h> |
||||
#define LWIP_TIMEVAL_PRIVATE |
||||
#include <lwip/sockets.h> |
||||
|
||||
#ifndef CYGPKG_LIBC_STDIO |
||||
#define perror(s) diag_printf(#s ": %s\n", strerror(errno)) |
||||
#endif |
||||
#define STACK_SIZE (CYGNUM_HAL_STACK_SIZE_TYPICAL + 0x1000) |
||||
#define MAX_LOAD_THREAD_LEVEL 20 |
||||
#define MIN_LOAD_THREAD_LEVEL 0 |
||||
#define NUM_LOAD_THREADS 10 |
||||
#define CYGPKG_NET_THREAD_PRIORITY 7 |
||||
#define IDLE_THREAD_PRIORITY CYGPKG_NET_THREAD_PRIORITY+3 |
||||
#define LOAD_THREAD_PRIORITY CYGPKG_NET_THREAD_PRIORITY-1 |
||||
#define MAIN_THREAD_PRIORITY CYGPKG_NET_THREAD_PRIORITY-2 |
||||
#define DESIRED_BACKGROUND_LOAD 20 |
||||
#define CYGHWR_NET_DRIVERS 1 |
||||
static char main_thread_stack[CYGHWR_NET_DRIVERS][STACK_SIZE]; |
||||
static cyg_thread main_thread_data[CYGHWR_NET_DRIVERS]; |
||||
static cyg_handle_t main_thread_handle[CYGHWR_NET_DRIVERS]; |
||||
static char idle_thread_stack[STACK_SIZE]; |
||||
static cyg_thread idle_thread_data; |
||||
static cyg_handle_t idle_thread_handle; |
||||
static cyg_sem_t idle_thread_sem; |
||||
volatile static long long idle_thread_count; |
||||
static cyg_tick_count_t idle_thread_start_time; |
||||
static cyg_tick_count_t idle_thread_stop_time; |
||||
static char load_thread_stack[NUM_LOAD_THREADS][STACK_SIZE]; |
||||
static cyg_thread load_thread_data[NUM_LOAD_THREADS]; |
||||
static cyg_handle_t load_thread_handle[NUM_LOAD_THREADS]; |
||||
static cyg_sem_t load_thread_sem[NUM_LOAD_THREADS]; |
||||
static long load_thread_level; |
||||
static void calibrate_load(int load); |
||||
static void start_load(int load); |
||||
static void do_some_random_computation(int p); |
||||
#define abs(n) ((n) < 0 ? -(n) : (n)) |
||||
|
||||
#define test_param_t cyg_addrword_t |
||||
#ifdef CYGDBG_NET_TIMING_STATS |
||||
extern void show_net_times(void); |
||||
#endif |
||||
|
||||
#define MAX_BUF 8192 |
||||
static unsigned char in_buf[MAX_BUF], out_buf[MAX_BUF]; |
||||
|
||||
extern void |
||||
cyg_test_exit(void); |
||||
|
||||
static void |
||||
test_delay(int ticks) |
||||
{ |
||||
cyg_thread_delay(ticks); |
||||
} |
||||
|
||||
|
||||
void |
||||
pexit(char *s) |
||||
{ |
||||
perror(s); |
||||
#ifdef CYGDBG_NET_TIMING_STATS |
||||
show_net_times(); |
||||
#endif |
||||
cyg_test_exit(); |
||||
} |
||||
|
||||
//
|
||||
// Generic UDP test
|
||||
//
|
||||
|
||||
static void |
||||
do_udp_test(int s1, struct nc_request *req, struct sockaddr_in *master) |
||||
{ |
||||
int i, s, td_len, seq, seq_errors, lost; |
||||
struct sockaddr_in test_chan_slave, test_chan_master; |
||||
fd_set fds; |
||||
struct timeval timeout; |
||||
struct nc_test_results results; |
||||
struct nc_test_data *tdp; |
||||
int nsent, nrecvd; |
||||
int need_recv, need_send; |
||||
|
||||
need_recv = true; need_send = true; |
||||
switch (ntohl(req->type)) { |
||||
case NC_REQUEST_UDP_SEND: |
||||
need_recv = false; |
||||
need_send = true; |
||||
break; |
||||
case NC_REQUEST_UDP_RECV: |
||||
need_recv = true; |
||||
need_send = false; |
||||
break; |
||||
case NC_REQUEST_UDP_ECHO: |
||||
break; |
||||
} |
||||
|
||||
s = socket(AF_INET, SOCK_DGRAM, 0); |
||||
if (s < 0) { |
||||
pexit("datagram socket"); |
||||
} |
||||
|
||||
memset((char *) &test_chan_slave, 0, sizeof(test_chan_slave)); |
||||
test_chan_slave.sin_family = AF_INET; |
||||
test_chan_slave.sin_len = sizeof(test_chan_slave); |
||||
test_chan_slave.sin_addr.s_addr = htonl(INADDR_ANY); |
||||
test_chan_slave.sin_port = htons(ntohl(req->slave_port)); |
||||
|
||||
if (bind(s, (struct sockaddr *) &test_chan_slave, sizeof(test_chan_slave)) < 0) { |
||||
perror("bind"); |
||||
close(s); |
||||
} |
||||
|
||||
memcpy(&test_chan_master, master, sizeof(*master)); |
||||
test_chan_master.sin_port = htons(ntohl(req->master_port)); |
||||
nsent = 0; nrecvd = 0; seq = 0; seq_errors = 0; lost = 0; |
||||
for (i = 0; i < ntohl(req->nbufs); i++) { |
||||
if (need_recv) { |
||||
FD_ZERO(&fds); |
||||
FD_SET(s, &fds); |
||||
timeout.tv_sec = NC_TEST_TIMEOUT; |
||||
timeout.tv_usec = 0; |
||||
if (select(s+1, &fds, 0, 0, &timeout) <= 0) { |
||||
test_printf("recvfrom timeout, expecting seq #%d\n", seq);
|
||||
if (++lost > MAX_ERRORS) { |
||||
test_printf("... giving up\n"); |
||||
break; |
||||
} |
||||
} else { |
||||
nrecvd++; |
||||
tdp = (struct nc_test_data *)in_buf; |
||||
td_len = ntohl(req->buflen) + sizeof(struct nc_test_data); |
||||
if (recvfrom(s, tdp, td_len, 0, 0, 0) < 0) { |
||||
perror("recvfrom"); |
||||
close(s); |
||||
return; |
||||
} |
||||
if ((ntohl(tdp->key1) == NC_TEST_DATA_KEY1) && |
||||
(ntohl(tdp->key2) == NC_TEST_DATA_KEY2)) { |
||||
if (ntohl(tdp->seq) != seq) { |
||||
test_printf("Packets out of sequence - recvd: %d, expected: %d\n", |
||||
ntohl(tdp->seq), seq); |
||||
seq = ntohl(tdp->seq); |
||||
seq_errors++; |
||||
} |
||||
} else { |
||||
test_printf("Bad data packet - key: %x/%x, seq: %d\n", |
||||
ntohl(tdp->key1), ntohl(tdp->key2), |
||||
ntohl(tdp->seq)); |
||||
} |
||||
} |
||||
} |
||||
if (need_send) { |
||||
int retries = 10; |
||||
int sent = false; |
||||
int res; |
||||
|
||||
tdp = (struct nc_test_data *)out_buf; |
||||
tdp->key1 = htonl(NC_TEST_DATA_KEY1); |
||||
tdp->key2 = htonl(NC_TEST_DATA_KEY2); |
||||
tdp->seq = htonl(seq); |
||||
td_len = ntohl(req->buflen) + sizeof(struct nc_test_data); |
||||
tdp->len = htonl(td_len); |
||||
while (!sent && (--retries >= 0)) { |
||||
res = sendto(s, tdp, td_len, 0,
|
||||
(struct sockaddr *)&test_chan_master, sizeof(test_chan_master)); |
||||
if (res > 0) { |
||||
sent = true; |
||||
break; |
||||
} |
||||
if (errno == ENOBUFS) { |
||||
// Saturated the system
|
||||
test_delay(1); // Time for 200 500 byte 10-baseT packets
|
||||
} else { |
||||
// What else to do?
|
||||
close(s); |
||||
return; |
||||
} |
||||
} |
||||
if (sent) { |
||||
nsent++; |
||||
} else { |
||||
perror("sendto"); |
||||
} |
||||
} |
||||
seq++; |
||||
} |
||||
results.key1 = htonl(NC_TEST_RESULT_KEY1); |
||||
results.key2 = htonl(NC_TEST_RESULT_KEY2); |
||||
results.seq = req->seq; |
||||
results.nsent = htonl(nsent); |
||||
results.nrecvd = htonl(nrecvd); |
||||
if (sendto(s, &results, sizeof(results), 0,
|
||||
(struct sockaddr *)&test_chan_master, sizeof(test_chan_master)) < 0) { |
||||
perror("sendto results"); |
||||
} |
||||
close(s); |
||||
} |
||||
|
||||
//
|
||||
// Read data from a stream, accounting for the fact that packet 'boundaries'
|
||||
// are not preserved. This can also timeout (which would probably wreck the
|
||||
// data boundaries).
|
||||
//
|
||||
|
||||
int |
||||
do_read(int fd, void *buf, int buflen) |
||||
{ |
||||
char *p = (char *)buf; |
||||
int len = buflen; |
||||
int res; |
||||
while (len) { |
||||
res = read(fd, p, len); |
||||
if (res < 0) { |
||||
perror("read"); |
||||
} else { |
||||
len -= res; |
||||
p += res; |
||||
if (res == 0) { |
||||
break; |
||||
} |
||||
} |
||||
} |
||||
return (buflen - len); |
||||
} |
||||
|
||||
//
|
||||
// Generic TCP test
|
||||
//
|
||||
|
||||
static void |
||||
do_tcp_test(int s1, struct nc_request *req, struct sockaddr_in *master) |
||||
{ |
||||
int i, s, len, td_len, seq, seq_errors, lost, test_chan, res; |
||||
struct sockaddr_in test_chan_slave, test_chan_master; |
||||
struct nc_test_results results; |
||||
struct nc_test_data *tdp; |
||||
int nsent, nrecvd; |
||||
int need_recv, need_send; |
||||
int one = 1; |
||||
static int slave_tcp_port = -1; |
||||
|
||||
need_recv = true; need_send = true; |
||||
switch (ntohl(req->type)) { |
||||
case NC_REQUEST_TCP_SEND: |
||||
need_recv = false; |
||||
need_send = true; |
||||
break; |
||||
case NC_REQUEST_TCP_RECV: |
||||
need_recv = true; |
||||
need_send = false; |
||||
break; |
||||
case NC_REQUEST_TCP_ECHO: |
||||
break; |
||||
} |
||||
|
||||
if (slave_tcp_port < 0) { |
||||
s = socket(AF_INET, SOCK_STREAM, 0); |
||||
if (s < 0) { |
||||
pexit("datagram socket"); |
||||
} |
||||
|
||||
if (setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &one, sizeof(one))) { |
||||
perror("setsockopt SO_REUSEADDR"); |
||||
return; |
||||
} |
||||
#ifdef SO_REUSEPORT |
||||
if (setsockopt(s, SOL_SOCKET, SO_REUSEPORT, &one, sizeof(one))) { |
||||
perror("setsockopt SO_REUSEPORT"); |
||||
return; |
||||
} |
||||
#endif |
||||
memset((char *) &test_chan_slave, 0, sizeof(test_chan_slave)); |
||||
test_chan_slave.sin_family = AF_INET; |
||||
test_chan_slave.sin_len = sizeof(test_chan_slave); |
||||
test_chan_slave.sin_addr.s_addr = htonl(INADDR_ANY); |
||||
test_chan_slave.sin_port = htons(ntohl(req->slave_port)); |
||||
|
||||
if (bind(s, (struct sockaddr *) &test_chan_slave, sizeof(test_chan_slave)) < 0) { |
||||
perror("bind"); |
||||
close(s); |
||||
} |
||||
listen(s, 128); |
||||
slave_tcp_port = s; |
||||
} |
||||
|
||||
s = slave_tcp_port; |
||||
len = sizeof(test_chan_master); |
||||
if ((test_chan = accept(s, (struct sockaddr *)&test_chan_master, &len)) < 0) { |
||||
pexit("accept"); |
||||
} |
||||
len = sizeof(test_chan_master); |
||||
getpeername(test_chan, (struct sockaddr *)&test_chan_master, &len); |
||||
// test_printf("connection from %s.%d\n", inet_ntoa(test_chan_master.sin_addr),
|
||||
// ntohs(test_chan_master.sin_port));
|
||||
|
||||
nsent = 0; nrecvd = 0; seq = 0; seq_errors = 0; lost = 0; |
||||
for (i = 0; i < ntohl(req->nbufs); i++) { |
||||
if (need_recv) { |
||||
tdp = (struct nc_test_data *)in_buf; |
||||
td_len = ntohl(req->buflen) + sizeof(struct nc_test_data); |
||||
res = do_read(test_chan, tdp, td_len); |
||||
if (res != td_len) { |
||||
test_printf("recvfrom timeout, expecting seq #%d\n", seq);
|
||||
if (++lost > MAX_ERRORS) { |
||||
test_printf("... giving up\n"); |
||||
break; |
||||
} |
||||
} else { |
||||
nrecvd++; |
||||
if ((ntohl(tdp->key1) == NC_TEST_DATA_KEY1) && |
||||
(ntohl(tdp->key2) == NC_TEST_DATA_KEY2)) { |
||||
if (ntohl(tdp->seq) != seq) { |
||||
test_printf("Packets out of sequence - recvd: %d, expected: %d\n", |
||||
ntohl(tdp->seq), seq); |
||||
seq = ntohl(tdp->seq); |
||||
seq_errors++; |
||||
} |
||||
} else { |
||||
test_printf("Bad data packet - key: %x/%x, seq: %d\n", |
||||
ntohl(tdp->key1), ntohl(tdp->key2), |
||||
ntohl(tdp->seq)); |
||||
} |
||||
} |
||||
} |
||||
if (need_send) { |
||||
tdp = (struct nc_test_data *)out_buf; |
||||
tdp->key1 = htonl(NC_TEST_DATA_KEY1); |
||||
tdp->key2 = htonl(NC_TEST_DATA_KEY2); |
||||
tdp->seq = htonl(seq); |
||||
td_len = ntohl(req->buflen) + sizeof(struct nc_test_data); |
||||
tdp->len = htonl(td_len); |
||||
if (write(test_chan, tdp, td_len) != td_len) { |
||||
perror("write"); |
||||
if (errno == ENOBUFS) { |
||||
// Saturated the system
|
||||
test_delay(25); |
||||
} else { |
||||
// What else to do?
|
||||
close(test_chan); |
||||
return; |
||||
} |
||||
} else { |
||||
nsent++; |
||||
} |
||||
} |
||||
seq++; |
||||
} |
||||
results.key1 = htonl(NC_TEST_RESULT_KEY1); |
||||
results.key2 = htonl(NC_TEST_RESULT_KEY2); |
||||
results.seq = req->seq; |
||||
results.nsent = htonl(nsent); |
||||
results.nrecvd = htonl(nrecvd); |
||||
if (write(test_chan, &results, sizeof(results)) != sizeof(results)) { |
||||
perror("write"); |
||||
} |
||||
close(test_chan); |
||||
} |
||||
|
||||
//
|
||||
// Protocol driver for testing slave.
|
||||
//
|
||||
// This function is the main routine running here, handling requests sent from
|
||||
// the master and providing various responses.
|
||||
//
|
||||
static void |
||||
nc_slave(test_param_t param) |
||||
{ |
||||
int s, masterlen; |
||||
struct sockaddr_in my_addr, master; |
||||
struct nc_request req; |
||||
struct nc_reply reply; |
||||
int done = false; |
||||
|
||||
test_printf("Start test for eth%d\n", param); |
||||
|
||||
s = socket(AF_INET, SOCK_DGRAM, 0); |
||||
if (s < 0) { |
||||
pexit("datagram socket"); |
||||
} |
||||
|
||||
memset((char *) &my_addr, 0, sizeof(my_addr)); |
||||
my_addr.sin_family = AF_INET; |
||||
my_addr.sin_len = sizeof(my_addr); |
||||
my_addr.sin_addr.s_addr = htonl(INADDR_ANY); |
||||
my_addr.sin_port = htons(NC_SLAVE_PORT); |
||||
|
||||
if (bind(s, (struct sockaddr *) &my_addr, sizeof(my_addr)) < 0) { |
||||
pexit("bind"); |
||||
} |
||||
|
||||
while (!done) { |
||||
masterlen = sizeof(master); |
||||
if (recvfrom(s, &req, sizeof(req), 0, (struct sockaddr *)&master, &masterlen) < 0) { |
||||
pexit("recvfrom"); |
||||
} |
||||
#if 0 |
||||
test_printf("Request %d from %s:%d\n", ntohl(req.type),
|
||||
inet_ntoa(master.sin_addr), ntohs(master.sin_port)); |
||||
#endif |
||||
reply.response = htonl(NC_REPLY_ACK); |
||||
reply.seq = req.seq; |
||||
switch (ntohl(req.type)) { |
||||
case NC_REQUEST_DISCONNECT: |
||||
done = true; |
||||
break; |
||||
case NC_REQUEST_UDP_SEND: |
||||
test_printf("UDP send - %d buffers, %d bytes\n", ntohl(req.nbufs), ntohl(req.buflen)); |
||||
break; |
||||
case NC_REQUEST_UDP_RECV: |
||||
test_printf("UDP recv - %d buffers, %d bytes\n", ntohl(req.nbufs), ntohl(req.buflen)); |
||||
break; |
||||
case NC_REQUEST_UDP_ECHO: |
||||
test_printf("UDP echo - %d buffers, %d bytes\n", ntohl(req.nbufs), ntohl(req.buflen)); |
||||
break; |
||||
case NC_REQUEST_TCP_SEND: |
||||
test_printf("TCP send - %d buffers, %d bytes\n", ntohl(req.nbufs), ntohl(req.buflen)); |
||||
break; |
||||
case NC_REQUEST_TCP_RECV: |
||||
test_printf("TCP recv - %d buffers, %d bytes\n", ntohl(req.nbufs), ntohl(req.buflen)); |
||||
break; |
||||
case NC_REQUEST_TCP_ECHO: |
||||
test_printf("TCP echo - %d buffers, %d bytes\n", ntohl(req.nbufs), ntohl(req.buflen)); |
||||
break; |
||||
case NC_REQUEST_SET_LOAD: |
||||
start_load(ntohl(req.nbufs)); |
||||
break; |
||||
case NC_REQUEST_START_IDLE: |
||||
test_printf("Start IDLE thread\n"); |
||||
idle_thread_count = 0; |
||||
idle_thread_start_time = cyg_current_time(); |
||||
cyg_semaphore_post(&idle_thread_sem); |
||||
break; |
||||
case NC_REQUEST_STOP_IDLE: |
||||
cyg_semaphore_wait(&idle_thread_sem); |
||||
idle_thread_stop_time = cyg_current_time(); |
||||
test_printf("Stop IDLE thread\n"); |
||||
reply.misc.idle_results.elapsed_time = htonl(idle_thread_stop_time - idle_thread_start_time); |
||||
reply.misc.idle_results.count[0] = htonl(idle_thread_count >> 32); |
||||
reply.misc.idle_results.count[1] = htonl((long)idle_thread_count); |
||||
break; |
||||
default: |
||||
test_printf("Unrecognized request: %d\n", ntohl(req.type)); |
||||
reply.response = htonl(NC_REPLY_NAK); |
||||
reply.reason = htonl(NC_REPLY_NAK_UNKNOWN_REQUEST); |
||||
break; |
||||
} |
||||
if (sendto(s, &reply, sizeof(reply), 0, (struct sockaddr *)&master, masterlen) < 0) { |
||||
pexit("sendto"); |
||||
} |
||||
if (reply.response == ntohl(NC_REPLY_NAK)) { |
||||
continue; |
||||
} |
||||
switch (ntohl(req.type)) { |
||||
case NC_REQUEST_UDP_SEND: |
||||
case NC_REQUEST_UDP_RECV: |
||||
case NC_REQUEST_UDP_ECHO: |
||||
do_udp_test(s, &req, &master); |
||||
break; |
||||
case NC_REQUEST_TCP_SEND: |
||||
case NC_REQUEST_TCP_RECV: |
||||
case NC_REQUEST_TCP_ECHO: |
||||
do_tcp_test(s, &req, &master); |
||||
break; |
||||
case NC_REQUEST_START_IDLE: |
||||
case NC_REQUEST_STOP_IDLE: |
||||
case NC_REQUEST_SET_LOAD: |
||||
default: |
||||
break; |
||||
} |
||||
} |
||||
close(s); |
||||
} |
||||
|
||||
void |
||||
net_test(test_param_t param) |
||||
{ |
||||
// int i;
|
||||
if (param == 0) { |
||||
test_printf("Start Network Characterization - SLAVE\n"); |
||||
calibrate_load(DESIRED_BACKGROUND_LOAD); |
||||
} |
||||
nc_slave(param); |
||||
#ifdef CYGDBG_NET_TIMING_STATS |
||||
show_net_times(); |
||||
#endif |
||||
#if LWIP_STATS_DISPLAY |
||||
stats_display(); |
||||
#endif |
||||
cyg_test_exit(); |
||||
} |
||||
|
||||
|
||||
//
|
||||
// This function is called to calibrate the "background load" which can be
|
||||
// applied during testing. It will be called before any commands from the
|
||||
// host are managed.
|
||||
//
|
||||
static void |
||||
calibrate_load(int desired_load) |
||||
{ |
||||
long long no_load_idle, load_idle; |
||||
int percent_load; |
||||
int high, low; |
||||
|
||||
// Set limits
|
||||
high = MAX_LOAD_THREAD_LEVEL; |
||||
low = MIN_LOAD_THREAD_LEVEL; |
||||
test_printf("Start Network Characterization - SLAVE\n"); |
||||
|
||||
// Compute the "no load" idle value
|
||||
idle_thread_count = 0; |
||||
cyg_semaphore_post(&idle_thread_sem); // Start idle thread
|
||||
test_printf("Start Network Characterization - SLAVE\n"); |
||||
cyg_thread_delay(1*100); // Pause for one second
|
||||
test_printf("Start Network Characterization - SLAVE\n"); |
||||
cyg_semaphore_wait(&idle_thread_sem); // Stop idle thread
|
||||
test_printf("Start Network Characterization - SLAVE\n"); |
||||
no_load_idle = idle_thread_count; |
||||
diag_printf("No load = %d\n", (int)idle_thread_count); |
||||
|
||||
// First ensure that the HIGH level is indeed higher
|
||||
while (true) { |
||||
load_thread_level = high; |
||||
start_load(desired_load); // Start up a given load
|
||||
idle_thread_count = 0; |
||||
cyg_semaphore_post(&idle_thread_sem); // Start idle thread
|
||||
cyg_thread_delay(1*100); // Pause for one second
|
||||
cyg_semaphore_wait(&idle_thread_sem); // Stop idle thread
|
||||
load_idle = idle_thread_count; |
||||
start_load(0); // Shut down background load
|
||||
percent_load = 100 - ((load_idle * 100) / no_load_idle); |
||||
diag_printf("High Load[%d] = %d => %d%%\n", load_thread_level,
|
||||
(int)idle_thread_count, percent_load); |
||||
if ( percent_load > desired_load ) |
||||
break; // HIGH level is indeed higher
|
||||
low = load_thread_level; // known to be lower
|
||||
high *= 2; // else double it and try again
|
||||
} |
||||
|
||||
// Now chop down to the level required
|
||||
while (true) { |
||||
load_thread_level = (high + low) / 2; |
||||
start_load(desired_load); // Start up a given load
|
||||
idle_thread_count = 0; |
||||
cyg_semaphore_post(&idle_thread_sem); // Start idle thread
|
||||
cyg_thread_delay(1*100); // Pause for one second
|
||||
cyg_semaphore_wait(&idle_thread_sem); // Stop idle thread
|
||||
load_idle = idle_thread_count; |
||||
start_load(0); // Shut down background load
|
||||
percent_load = 100 - ((load_idle * 100) / no_load_idle); |
||||
diag_printf("Load[%d] = %d => %d%%\n", load_thread_level,
|
||||
(int)idle_thread_count, percent_load); |
||||
if (((high-low) <= 1) || (abs(desired_load-percent_load) <= 2)) break; |
||||
if (percent_load < desired_load) { |
||||
low = load_thread_level; |
||||
} else {
|
||||
high = load_thread_level; |
||||
} |
||||
} |
||||
|
||||
// Now we are within a few percent of the target; scale the load
|
||||
// factor to get a better fit, and test it, print the answer.
|
||||
load_thread_level *= desired_load; |
||||
load_thread_level /= percent_load; |
||||
start_load(desired_load); // Start up a given load
|
||||
idle_thread_count = 0; |
||||
cyg_semaphore_post(&idle_thread_sem); // Start idle thread
|
||||
cyg_thread_delay(1*100); // Pause for one second
|
||||
cyg_semaphore_wait(&idle_thread_sem); // Stop idle thread
|
||||
load_idle = idle_thread_count; |
||||
start_load(0); // Shut down background load
|
||||
percent_load = 100 - ((load_idle * 100) / no_load_idle); |
||||
diag_printf("Final load[%d] = %d => %d%%\n", load_thread_level,
|
||||
(int)idle_thread_count, percent_load); |
||||
// no_load_idle_count_1_second = no_load_idle;
|
||||
} |
||||
|
||||
//
|
||||
// This function is called to set up a load level of 'load' percent (given
|
||||
// as a whole number, e.g. start_load(20) would mean initiate a background
|
||||
// load of 20%, leaving the cpu 80% idle).
|
||||
//
|
||||
static void |
||||
start_load(int load) |
||||
{ |
||||
static int prev_load = 0; |
||||
int i; |
||||
test_printf("Set background load = %d%%\n", load); |
||||
if (load == 0) { |
||||
if (prev_load == 0) return; // Nothing out there to stop
|
||||
for (i = 0; i < prev_load/10; i++) { |
||||
cyg_semaphore_wait(&load_thread_sem[i]); |
||||
} |
||||
prev_load = 0; |
||||
} else { |
||||
for (i = 0; i < load/10; i++) { |
||||
cyg_semaphore_post(&load_thread_sem[i]); |
||||
} |
||||
prev_load = load; |
||||
} |
||||
} |
||||
|
||||
//
|
||||
// These thread(s) do some amount of "background" computing. This is used
|
||||
// to simulate a given load level. They need to be run at a higher priority
|
||||
// than the network code itself.
|
||||
//
|
||||
// Like the "idle" thread, they run as long as their "switch" (aka semaphore)
|
||||
// is enabled.
|
||||
//
|
||||
void |
||||
net_load(cyg_addrword_t who) |
||||
{ |
||||
int i; |
||||
while (true) { |
||||
cyg_semaphore_wait(&load_thread_sem[who]); |
||||
for (i = 0; i < load_thread_level; i++) { |
||||
do_some_random_computation(i); |
||||
} |
||||
cyg_thread_delay(1); // Wait until the next 'tick'
|
||||
cyg_semaphore_post(&load_thread_sem[who]); |
||||
} |
||||
} |
||||
|
||||
//
|
||||
// Some arbitrary computation, designed to use up the CPU and cause associated
|
||||
// cache "thrash" behaviour - part of background load modelling.
|
||||
//
|
||||
static void |
||||
do_some_random_computation(int p) |
||||
{ |
||||
// Just something that might be "hard"
|
||||
volatile double x; |
||||
x = ((p * 10) * 3.14159) / 180.0; // radians
|
||||
} |
||||
|
||||
//
|
||||
// This thread does nothing but count. It will be allowed to count
|
||||
// as long as the semaphore is "free".
|
||||
//
|
||||
void |
||||
net_idle(cyg_addrword_t param) |
||||
{ |
||||
while (true) { |
||||
cyg_semaphore_wait(&idle_thread_sem); |
||||
idle_thread_count++; |
||||
cyg_semaphore_post(&idle_thread_sem); |
||||
} |
||||
} |
||||
#if 0 |
||||
void |
||||
cyg_start(void *n) |
||||
{ |
||||
int i; |
||||
// Create processing threads
|
||||
for (i = 0; i < CYGHWR_NET_DRIVERS; i++) { |
||||
cyg_thread_create(MAIN_THREAD_PRIORITY, // Priority
|
||||
net_test, // entry
|
||||
i, // entry parameter
|
||||
"Network test", // Name
|
||||
&main_thread_stack[i][0], // Stack
|
||||
STACK_SIZE, // Size
|
||||
&main_thread_handle[i], // Handle
|
||||
&main_thread_data[i] // Thread data structure
|
||||
); |
||||
} |
||||
cyg_thread_resume(main_thread_handle[0]); // Start first one
|
||||
// Create the idle thread environment
|
||||
cyg_semaphore_init(&idle_thread_sem, 0); |
||||
cyg_thread_create(IDLE_THREAD_PRIORITY, // Priority
|
||||
net_idle, // entry
|
||||
0, // entry parameter
|
||||
"Network idle", // Name
|
||||
&idle_thread_stack[0], // Stack
|
||||
STACK_SIZE, // Size
|
||||
&idle_thread_handle, // Handle
|
||||
&idle_thread_data // Thread data structure
|
||||
); |
||||
cyg_thread_resume(idle_thread_handle); // Start it
|
||||
// Create the load threads and their environment(s)
|
||||
for (i = 0; i < NUM_LOAD_THREADS; i++) { |
||||
cyg_semaphore_init(&load_thread_sem[i], 0); |
||||
cyg_thread_create(LOAD_THREAD_PRIORITY, // Priority
|
||||
net_load, // entry
|
||||
i, // entry parameter
|
||||
"Background load", // Name
|
||||
&load_thread_stack[i][0], // Stack
|
||||
STACK_SIZE, // Size
|
||||
&load_thread_handle[i], // Handle
|
||||
&load_thread_data[i] // Thread data structure
|
||||
); |
||||
cyg_thread_resume(load_thread_handle[i]); // Start it
|
||||
} |
||||
cyg_scheduler_start(); |
||||
} |
||||
|
||||
#endif |
||||
|
||||
void |
||||
tmain(cyg_addrword_t p) |
||||
{ |
||||
lwip_init(); |
||||
sys_thread_new("net_test", net_test, 0, DEFAULT_THREAD_STACKSIZE, MAIN_THREAD_PRIORITY); |
||||
} |
||||
|
||||
static char stack[STACK_SIZE]; |
||||
static cyg_thread thread_data; |
||||
static cyg_handle_t thread_handle; |
||||
|
||||
void |
||||
cyg_user_start(void) |
||||
{ |
||||
int i;
|
||||
// Create the idle thread environment
|
||||
cyg_semaphore_init(&idle_thread_sem, 0); |
||||
cyg_thread_create(IDLE_THREAD_PRIORITY, // Priority
|
||||
net_idle, // entry
|
||||
0, // entry parameter
|
||||
"Network idle", // Name
|
||||
&idle_thread_stack[0], // Stack
|
||||
STACK_SIZE, // Size
|
||||
&idle_thread_handle, // Handle
|
||||
&idle_thread_data // Thread data structure
|
||||
); |
||||
cyg_thread_resume(idle_thread_handle); // Start it
|
||||
// Create the load threads and their environment(s)
|
||||
for (i = 0; i < NUM_LOAD_THREADS; i++) { |
||||
cyg_semaphore_init(&load_thread_sem[i], 0); |
||||
cyg_thread_create(LOAD_THREAD_PRIORITY, // Priority
|
||||
net_load, // entry
|
||||
i, // entry parameter
|
||||
"Background load", // Name
|
||||
&load_thread_stack[i][0], // Stack
|
||||
STACK_SIZE, // Size
|
||||
&load_thread_handle[i], // Handle
|
||||
&load_thread_data[i] // Thread data structure
|
||||
); |
||||
cyg_thread_resume(load_thread_handle[i]); // Start it
|
||||
} |
||||
// Create a main thread, so we can run the scheduler and have time 'pass'
|
||||
cyg_thread_create(10, // Priority - just a number
|
||||
tmain, // entry
|
||||
0, // entry parameter
|
||||
"socket echo test", // Name
|
||||
&stack[0], // Stack
|
||||
STACK_SIZE, // Size
|
||||
&thread_handle, // Handle
|
||||
&thread_data // Thread data structure
|
||||
); |
||||
cyg_thread_resume(thread_handle); // Start it
|
||||
} |
||||
@ -1,90 +0,0 @@
|
||||
//==========================================================================
|
||||
//####ECOSGPLCOPYRIGHTBEGIN####
|
||||
// -------------------------------------------
|
||||
// This file is part of eCos, the Embedded Configurable Operating System.
|
||||
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
|
||||
//
|
||||
// eCos is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU General Public License as published by the Free
|
||||
// Software Foundation; either version 2 or (at your option) any later version.
|
||||
//
|
||||
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
// for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License along
|
||||
// with eCos; if not, write to the Free Software Foundation, Inc.,
|
||||
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
||||
//
|
||||
// As a special exception, if other files instantiate templates or use macros
|
||||
// or inline functions from this file, or you compile this file and link it
|
||||
// with other works to produce a work based on this file, this file does not
|
||||
// by itself cause the resulting work to be covered by the GNU General Public
|
||||
// License. However the source code for this file must still be made available
|
||||
// in accordance with section (3) of the GNU General Public License.
|
||||
//
|
||||
// This exception does not invalidate any other reasons why a work based on
|
||||
// this file might be covered by the GNU General Public License.
|
||||
// -------------------------------------------
|
||||
//####ECOSGPLCOPYRIGHTEND####
|
||||
//==========================================================================
|
||||
|
||||
/* Simple test-case for the BSD socket API : echo on TCP port 7 */ |
||||
|
||||
#include "lwip/sys.h" |
||||
#define LWIP_COMPAT_SOCKETS 1 |
||||
#include "lwip/sockets.h" |
||||
|
||||
char buf[400]; |
||||
static void |
||||
socket_thread(void *arg) |
||||
{ |
||||
int sock,s; |
||||
int len; |
||||
struct sockaddr_in addr,rem; |
||||
sock = socket(AF_INET,SOCK_STREAM,0);
|
||||
addr.sin_family = AF_INET; |
||||
addr.sin_port = htons(7); |
||||
addr.sin_addr.s_addr = INADDR_ANY; |
||||
|
||||
bind(sock,(struct sockaddr *)&addr,sizeof(addr)); |
||||
|
||||
listen(sock,5); |
||||
while(1) {
|
||||
len = sizeof(rem); |
||||
s = accept(sock,(struct sockaddr*)&rem,&len); |
||||
while((len = read(s,buf,400)) > 0) |
||||
write(s,buf,len); |
||||
close(s); |
||||
}
|
||||
} |
||||
|
||||
void |
||||
tmain(cyg_addrword_t p) |
||||
{ |
||||
lwip_init();
|
||||
sys_thread_new("socket", socket_thread, (void*)"socket", DEFAULT_THREAD_STACKSIZE, 7); |
||||
} |
||||
|
||||
#define STACK_SIZE 0x1000 |
||||
static char stack[STACK_SIZE]; |
||||
static cyg_thread thread_data; |
||||
static cyg_handle_t thread_handle; |
||||
|
||||
void |
||||
cyg_user_start(void) |
||||
{ |
||||
// Create a main thread, so we can run the scheduler and have time 'pass'
|
||||
cyg_thread_create(10, // Priority - just a number
|
||||
tmain, // entry
|
||||
0, // entry parameter
|
||||
"socket echo test", // Name
|
||||
&stack[0], // Stack
|
||||
STACK_SIZE, // Size
|
||||
&thread_handle, // Handle
|
||||
&thread_data // Thread data structure
|
||||
); |
||||
cyg_thread_resume(thread_handle); // Start it
|
||||
} |
||||
|
||||
@ -1,95 +0,0 @@
|
||||
//==========================================================================
|
||||
//####ECOSGPLCOPYRIGHTBEGIN####
|
||||
// -------------------------------------------
|
||||
// This file is part of eCos, the Embedded Configurable Operating System.
|
||||
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
|
||||
//
|
||||
// eCos is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU General Public License as published by the Free
|
||||
// Software Foundation; either version 2 or (at your option) any later version.
|
||||
//
|
||||
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
// for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License along
|
||||
// with eCos; if not, write to the Free Software Foundation, Inc.,
|
||||
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
||||
//
|
||||
// As a special exception, if other files instantiate templates or use macros
|
||||
// or inline functions from this file, or you compile this file and link it
|
||||
// with other works to produce a work based on this file, this file does not
|
||||
// by itself cause the resulting work to be covered by the GNU General Public
|
||||
// License. However the source code for this file must still be made available
|
||||
// in accordance with section (3) of the GNU General Public License.
|
||||
//
|
||||
// This exception does not invalidate any other reasons why a work based on
|
||||
// this file might be covered by the GNU General Public License.
|
||||
// -------------------------------------------
|
||||
//####ECOSGPLCOPYRIGHTEND####
|
||||
//==========================================================================
|
||||
|
||||
/* Simple test-case for the lwip system timeout functionality */ |
||||
|
||||
#include "lwip/sys.h" |
||||
|
||||
#define TIMERS 100 |
||||
sys_timeout_handler timers[TIMERS]; |
||||
int intervals[TIMERS]; |
||||
|
||||
static void |
||||
timeout_fn ( void * arg) |
||||
{ |
||||
int i, j = (int)arg; |
||||
// diag_printf("Timeout #%d called\n", (int)arg);
|
||||
for (i = 0; i < j; i++) |
||||
diag_printf(" "); |
||||
diag_printf("%d\n", j); |
||||
// sys_timeout( intervals[j], timers[j], arg);
|
||||
sys_timeout( 1000, timers[j], arg);
|
||||
} |
||||
|
||||
static void |
||||
timeout_thread(void *arg) |
||||
{ |
||||
int i; |
||||
|
||||
for (i = 0; i < TIMERS; i++) { |
||||
diag_printf("Adding timer #%d\n", i); |
||||
timers[i] = timeout_fn; |
||||
intervals[i] = (i+1)*1000;
|
||||
sys_timeout(intervals[i], timers[i], (void *)i); |
||||
} |
||||
sys_msleep(0);
|
||||
diag_printf("Done\n"); |
||||
} |
||||
|
||||
void |
||||
tmain(cyg_addrword_t p) |
||||
{ |
||||
lwip_init();
|
||||
sys_thread_new("timeout", timeout_thread, (void*)"timeout", DEFAULT_THREAD_STACKSIZE, 7); |
||||
} |
||||
|
||||
#define STACK_SIZE 0x1000 |
||||
static char stack[STACK_SIZE]; |
||||
static cyg_thread thread_data; |
||||
static cyg_handle_t thread_handle; |
||||
|
||||
void |
||||
cyg_user_start(void) |
||||
{ |
||||
// Create a main thread, so we can run the scheduler and have time 'pass'
|
||||
cyg_thread_create(10, // Priority - just a number
|
||||
tmain, // entry
|
||||
0, // entry parameter
|
||||
"timeout test", // Name
|
||||
&stack[0], // Stack
|
||||
STACK_SIZE, // Size
|
||||
&thread_handle, // Handle
|
||||
&thread_data // Thread data structure
|
||||
); |
||||
cyg_thread_resume(thread_handle); // Start it
|
||||
} |
||||
|
||||
@ -1,137 +0,0 @@
|
||||
//==========================================================================
|
||||
//####ECOSGPLCOPYRIGHTBEGIN####
|
||||
// -------------------------------------------
|
||||
// This file is part of eCos, the Embedded Configurable Operating System.
|
||||
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
|
||||
//
|
||||
// eCos is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU General Public License as published by the Free
|
||||
// Software Foundation; either version 2 or (at your option) any later version.
|
||||
//
|
||||
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
// for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License along
|
||||
// with eCos; if not, write to the Free Software Foundation, Inc.,
|
||||
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
||||
//
|
||||
// As a special exception, if other files instantiate templates or use macros
|
||||
// or inline functions from this file, or you compile this file and link it
|
||||
// with other works to produce a work based on this file, this file does not
|
||||
// by itself cause the resulting work to be covered by the GNU General Public
|
||||
// License. However the source code for this file must still be made available
|
||||
// in accordance with section (3) of the GNU General Public License.
|
||||
//
|
||||
// This exception does not invalidate any other reasons why a work based on
|
||||
// this file might be covered by the GNU General Public License.
|
||||
// -------------------------------------------
|
||||
//####ECOSGPLCOPYRIGHTEND####
|
||||
//==========================================================================
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001, Swedish Institute of Computer Science. |
||||
* All rights reserved.
|
||||
* |
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the Institute nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
* |
||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
* |
||||
* This file is part of the lwIP TCP/IP stack. |
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se> |
||||
* |
||||
*/ |
||||
|
||||
#include "lwip/sys.h" |
||||
#include "lwip/api.h" |
||||
|
||||
static void
|
||||
tcpecho_thread(void *arg) |
||||
{ |
||||
struct netconn *conn, *newconn; |
||||
err_t err; |
||||
|
||||
/* Create a new connection identifier. */ |
||||
conn = netconn_new(NETCONN_TCP); |
||||
|
||||
/* Bind connection to well known port number 7. */ |
||||
netconn_bind(conn, NULL, 7); |
||||
|
||||
/* Tell connection to go into listening mode. */ |
||||
netconn_listen(conn); |
||||
|
||||
while(1) { |
||||
|
||||
/* Grab new connection. */ |
||||
newconn = netconn_accept(conn); |
||||
/* Process the new connection. */ |
||||
if(newconn != NULL) { |
||||
struct netbuf *buf; |
||||
void *data; |
||||
u16_t len; |
||||
|
||||
while((buf = netconn_recv(newconn)) != NULL) { |
||||
do { |
||||
netbuf_data(buf, &data, &len); |
||||
err = netconn_write(newconn, data, len, NETCONN_COPY); |
||||
if(err != ERR_OK) { |
||||
} |
||||
} while(netbuf_next(buf) >= 0); |
||||
netbuf_delete(buf);
|
||||
} |
||||
/* Close connection and discard connection identifier. */ |
||||
netconn_delete(newconn); |
||||
} |
||||
} |
||||
} |
||||
|
||||
void |
||||
tmain(cyg_addrword_t p) |
||||
{ |
||||
lwip_init();
|
||||
sys_thread_new("tcpecho", tcpecho_thread, (void*)"tcpecho", DEFAULT_THREAD_STACKSIZE, 7); |
||||
} |
||||
|
||||
#define STACK_SIZE 0x1000 |
||||
static char stack[STACK_SIZE]; |
||||
static cyg_thread thread_data; |
||||
static cyg_handle_t thread_handle; |
||||
|
||||
void |
||||
cyg_user_start(void) |
||||
{ |
||||
// Create a main thread, so we can run the scheduler and have time 'pass'
|
||||
cyg_thread_create(10, // Priority - just a number
|
||||
tmain, // entry
|
||||
0, // entry parameter
|
||||
"TCP echo test", // Name
|
||||
&stack[0], // Stack
|
||||
STACK_SIZE, // Size
|
||||
&thread_handle, // Handle
|
||||
&thread_data // Thread data structure
|
||||
); |
||||
cyg_thread_resume(thread_handle); // Start it
|
||||
} |
||||
|
||||
@ -1,120 +0,0 @@
|
||||
//==========================================================================
|
||||
//####ECOSGPLCOPYRIGHTBEGIN####
|
||||
// -------------------------------------------
|
||||
// This file is part of eCos, the Embedded Configurable Operating System.
|
||||
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
|
||||
//
|
||||
// eCos is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU General Public License as published by the Free
|
||||
// Software Foundation; either version 2 or (at your option) any later version.
|
||||
//
|
||||
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
// for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License along
|
||||
// with eCos; if not, write to the Free Software Foundation, Inc.,
|
||||
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
||||
//
|
||||
// As a special exception, if other files instantiate templates or use macros
|
||||
// or inline functions from this file, or you compile this file and link it
|
||||
// with other works to produce a work based on this file, this file does not
|
||||
// by itself cause the resulting work to be covered by the GNU General Public
|
||||
// License. However the source code for this file must still be made available
|
||||
// in accordance with section (3) of the GNU General Public License.
|
||||
//
|
||||
// This exception does not invalidate any other reasons why a work based on
|
||||
// this file might be covered by the GNU General Public License.
|
||||
// -------------------------------------------
|
||||
//####ECOSGPLCOPYRIGHTEND####
|
||||
//==========================================================================
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001, Swedish Institute of Computer Science. |
||||
* All rights reserved.
|
||||
* |
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the Institute nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
* |
||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
* |
||||
* This file is part of the lwIP TCP/IP stack. |
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se> |
||||
* |
||||
*/ |
||||
|
||||
#include "lwip/api.h" |
||||
#include "lwip/sys.h" |
||||
|
||||
/*-----------------------------------------------------------------------------------*/ |
||||
char buffer[100]; |
||||
void
|
||||
udpecho_thread(void *arg) |
||||
{ |
||||
struct netconn *conn; |
||||
struct netbuf *buf; |
||||
struct ip_addr *addr; |
||||
unsigned short port; |
||||
|
||||
conn = netconn_new(NETCONN_UDP); |
||||
netconn_bind(conn, NULL, 7); |
||||
|
||||
while(1) { |
||||
buf = netconn_recv(conn); |
||||
addr = netbuf_fromaddr(buf); |
||||
port = netbuf_fromport(buf); |
||||
netconn_connect(conn, addr, port); |
||||
netconn_send(conn, buf); |
||||
netbuf_copy(buf, buffer, sizeof(buffer)); |
||||
netbuf_delete(buf); |
||||
} |
||||
} |
||||
/*-----------------------------------------------------------------------------------*/ |
||||
void tmain(cyg_addrword_t p) |
||||
{ |
||||
lwip_init();
|
||||
sys_thread_new("udp_echo", udpecho_thread, (void*)"udpecho", DEFAULT_THREAD_STACKSIZE, 7); |
||||
} |
||||
|
||||
#define STACK_SIZE 0x1000 |
||||
static char stack[STACK_SIZE]; |
||||
static cyg_thread thread_data; |
||||
static cyg_handle_t thread_handle; |
||||
|
||||
void |
||||
cyg_user_start(void) |
||||
{ |
||||
// Create a main thread, so we can run the scheduler and have time 'pass'
|
||||
cyg_thread_create(10, // Priority - just a number
|
||||
tmain, // entry
|
||||
0, // entry parameter
|
||||
"UDP echo test", // Name
|
||||
&stack[0], // Stack
|
||||
STACK_SIZE, // Size
|
||||
&thread_handle, // Handle
|
||||
&thread_data // Thread data structure
|
||||
); |
||||
cyg_thread_resume(thread_handle); // Start it
|
||||
} |
||||
|
||||
@ -1,7 +0,0 @@
|
||||
package CYGPKG_NET_LWIP { |
||||
alias {"lwIP" lwip} |
||||
directory net/lwip_tcpip |
||||
script cdl/lwip_net.cdl |
||||
description "lightweight TCP/IP stack: lwIP" |
||||
} |
||||
|
||||
@ -1,80 +0,0 @@
|
||||
src/api/api_lib.c src/api/api_lib.c |
||||
src/api/api_msg.c src/api/api_msg.c |
||||
src/api/err.c src/api/err.c |
||||
src/api/sockets.c src/api/sockets.c |
||||
src/api/tcpip.c src/api/tcpip.c |
||||
src/core/tcp_out.c src/core/tcp_out.c |
||||
src/core/inet.c src/core/inet.c |
||||
src/core/mem.c src/core/mem.c |
||||
src/core/memp.c src/core/memp.c |
||||
src/core/netif.c src/core/netif.c |
||||
src/core/pbuf.c src/core/pbuf.c |
||||
src/core/stats.c src/core/stats.c |
||||
src/core/sys.c src/core/sys.c |
||||
src/core/tcp.c src/core/tcp.c |
||||
src/core/ipv4/ip_addr.c src/core/ipv4/ip_addr.c |
||||
src/core/ipv4/icmp.c src/core/ipv4/icmp.c |
||||
src/core/ipv4/ip.c src/core/ipv4/ip.c |
||||
src/core/ipv4/ip_frag.c src/core/ipv4/ip_frag.c |
||||
src/core/udp.c src/core/udp.c |
||||
src/core/dhcp.c src/core/dhcp.c |
||||
src/core/tcp_in.c src/core/tcp_in.c |
||||
src/core/raw.c src/core/raw.c |
||||
src/include/ipv4/lwip/ip_addr.h include/lwip/ip_addr.h |
||||
src/include/ipv4/lwip/icmp.h include/lwip/icmp.h |
||||
src/include/ipv4/lwip/inet.h include/lwip/inet.h |
||||
src/include/ipv4/lwip/ip.h include/lwip/ip.h |
||||
src/include/ipv4/lwip/ip_frag.h include/lwip/ip_frag.h |
||||
src/include/lwip/api_msg.h include/lwip/api_msg.h |
||||
src/include/lwip/api.h include/lwip/api.h |
||||
src/include/lwip/arch.h include/lwip/arch.h |
||||
src/include/lwip/sockets.h include/lwip/sockets.h |
||||
src/include/lwip/debug.h include/lwip/debug.h |
||||
src/include/lwip/def.h include/lwip/def.h |
||||
src/include/lwip/err.h include/lwip/err.h |
||||
src/include/lwip/snmp.h include/lwip/snmp.h |
||||
src/include/lwip/mem.h include/lwip/mem.h |
||||
src/include/lwip/memp.h include/lwip/memp.h |
||||
src/include/lwip/netif.h include/lwip/netif.h |
||||
src/include/lwip/opt.h include/lwip/opt.h |
||||
src/include/lwip/pbuf.h include/lwip/pbuf.h |
||||
src/include/lwip/stats.h include/lwip/stats.h |
||||
src/include/lwip/sys.h include/lwip/sys.h |
||||
src/include/lwip/tcp.h include/lwip/tcp.h |
||||
src/include/lwip/raw.h include/lwip/raw.h |
||||
src/include/lwip/tcpip.h include/lwip/tcpip.h |
||||
src/include/lwip/udp.h include/lwip/udp.h |
||||
src/include/lwip/sio.h include/lwip/sio.h |
||||
src/include/lwip/dhcp.h include/lwip/dhcp.h |
||||
src/include/netif/etharp.h include/netif/etharp.h |
||||
src/include/netif/slipif.h include/netif/slipif.h |
||||
src/include/netif/loopif.h include/netif/loopif.h |
||||
src/netif/etharp.c src/netif/etharp.c |
||||
src/netif/slipif.c src/netif/slipif.c |
||||
src/netif/loopif.c src/netif/loopif.c |
||||
src/netif/ppp/ppp.c src/netif/ppp/ppp.c |
||||
src/netif/ppp/auth.c src/netif/ppp/auth.c |
||||
src/netif/ppp/chap.c src/netif/ppp/chap.c |
||||
src/netif/ppp/chpms.c src/netif/ppp/chpms.c |
||||
src/netif/ppp/pap.c src/netif/ppp/pap.c |
||||
src/netif/ppp/magic.c src/netif/ppp/magic.c |
||||
src/netif/ppp/md5.c src/netif/ppp/md5.c |
||||
src/netif/ppp/fsm.c src/netif/ppp/fsm.c |
||||
src/netif/ppp/ipcp.c src/netif/ppp/ipcp.c |
||||
src/netif/ppp/lcp.c src/netif/ppp/lcp.c |
||||
src/netif/ppp/randm.c src/netif/ppp/randm.c |
||||
src/netif/ppp/vj.c src/netif/ppp/vj.c |
||||
src/netif/ppp/ppp.h src/netif/ppp/ppp.h |
||||
src/netif/ppp/pppdebug.h src/netif/ppp/pppdebug.h |
||||
src/netif/ppp/auth.h src/netif/ppp/auth.h |
||||
src/netif/ppp/chap.h src/netif/ppp/chap.h |
||||
src/netif/ppp/chpms.h src/netif/ppp/chpms.h |
||||
src/netif/ppp/pap.h src/netif/ppp/pap.h |
||||
src/netif/ppp/magic.h src/netif/ppp/magic.h |
||||
src/netif/ppp/md5.h src/netif/ppp/md5.h |
||||
src/netif/ppp/fsm.h src/netif/ppp/fsm.h |
||||
src/netif/ppp/ipcp.h src/netif/ppp/ipcp.h |
||||
src/netif/ppp/lcp.h src/netif/ppp/lcp.h |
||||
src/netif/ppp/randm.h src/netif/ppp/randm.h |
||||
src/netif/ppp/vj.h src/netif/ppp/vj.h |
||||
src/netif/ppp/vjbsdhdr.h src/netif/ppp/vjbsdhdr.h |
||||
@ -1,32 +0,0 @@
|
||||
//========================================================================== |
||||
//####ECOSGPLCOPYRIGHTBEGIN#### |
||||
// ------------------------------------------- |
||||
// This file is part of eCos, the Embedded Configurable Operating System. |
||||
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc. |
||||
// |
||||
// eCos is free software; you can redistribute it and/or modify it under |
||||
// the terms of the GNU General Public License as published by the Free |
||||
// Software Foundation; either version 2 or (at your option) any later version. |
||||
// |
||||
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY |
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or |
||||
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
||||
// for more details. |
||||
// |
||||
// You should have received a copy of the GNU General Public License along |
||||
// with eCos; if not, write to the Free Software Foundation, Inc., |
||||
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. |
||||
// |
||||
// As a special exception, if other files instantiate templates or use macros |
||||
// or inline functions from this file, or you compile this file and link it |
||||
// with other works to produce a work based on this file, this file does not |
||||
// by itself cause the resulting work to be covered by the GNU General Public |
||||
// License. However the source code for this file must still be made available |
||||
// in accordance with section (3) of the GNU General Public License. |
||||
// |
||||
// This exception does not invalidate any other reasons why a work based on |
||||
// this file might be covered by the GNU General Public License. |
||||
// ------------------------------------------- |
||||
//####ECOSGPLCOPYRIGHTEND#### |
||||
//========================================================================== |
||||
|
||||
@ -1,28 +0,0 @@
|
||||
#!/bin/sh |
||||
|
||||
#make an ecos epk from CVS lwIP |
||||
|
||||
if test $EPK"" == "" ; then |
||||
echo you must set the EPK environment var to the dir you want the EPK in |
||||
exit; |
||||
fi |
||||
|
||||
if test $LWIP_CVS"" == "" ; then |
||||
echo you must set the LWIP_CVS environment var to the dir you checked out the lwip module |
||||
LWIP_CVS=../../../lwip; |
||||
exit; |
||||
fi |
||||
EPK=$EPK/lwip_epk |
||||
|
||||
#cleanup |
||||
rm -Rf $EPK |
||||
|
||||
|
||||
#copy files from CVS |
||||
xargs -n 2 ./copy < files |
||||
|
||||
#copy ecos specific files |
||||
cd ecos && find . ! -path '*CVS*' -a -type f -exec cp --parents {} $EPK \; |
||||
#make epk |
||||
cd $EPK && tar czf lwip.epk * |
||||
|
||||
@ -1,54 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001-2003 Swedish Institute of Computer Science. |
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met: |
||||
* |
||||
* 1. Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, |
||||
* this list of conditions and the following disclaimer in the documentation |
||||
* and/or other materials provided with the distribution. |
||||
* 3. The name of the author may not be used to endorse or promote products |
||||
* derived from this software without specific prior written permission.
|
||||
* |
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE. |
||||
* |
||||
* This file is part of the lwIP TCP/IP stack. |
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se> |
||||
* |
||||
*/ |
||||
#ifndef __CC_H__ |
||||
#define __CC_H__ |
||||
|
||||
typedef unsigned char u8_t; |
||||
typedef signed char s8_t; |
||||
typedef unsigned short u16_t; |
||||
typedef signed short s16_t; |
||||
typedef unsigned long u32_t; |
||||
typedef signed long s32_t; |
||||
|
||||
#define U16_F "hu" |
||||
#define S16_F "hd" |
||||
#define X16_F "hx" |
||||
#define U32_F "lu" |
||||
#define S32_F "ld" |
||||
#define X32_F "lx" |
||||
|
||||
#define PACK_STRUCT_BEGIN |
||||
#define PACK_STRUCT_STRUCT |
||||
#define PACK_STRUCT_END |
||||
#define PACK_STRUCT_FIELD(x) x |
||||
|
||||
#endif /* __CC_H__ */ |
||||
@ -1,37 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001-2003 Swedish Institute of Computer Science. |
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met: |
||||
* |
||||
* 1. Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, |
||||
* this list of conditions and the following disclaimer in the documentation |
||||
* and/or other materials provided with the distribution. |
||||
* 3. The name of the author may not be used to endorse or promote products |
||||
* derived from this software without specific prior written permission.
|
||||
* |
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE. |
||||
* |
||||
* This file is part of the lwIP TCP/IP stack. |
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se> |
||||
* |
||||
*/ |
||||
#ifndef __CPU_H__ |
||||
#define __CPU_H__ |
||||
|
||||
#define BYTE_ORDER LITTLE_ENDIAN |
||||
|
||||
#endif /* __CPU_H__ */ |
||||
@ -1,44 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001-2003 Swedish Institute of Computer Science. |
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met: |
||||
* |
||||
* 1. Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, |
||||
* this list of conditions and the following disclaimer in the documentation |
||||
* and/or other materials provided with the distribution. |
||||
* 3. The name of the author may not be used to endorse or promote products |
||||
* derived from this software without specific prior written permission.
|
||||
* |
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE. |
||||
* |
||||
* This file is part of the lwIP TCP/IP stack. |
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se> |
||||
* |
||||
*/ |
||||
#ifndef __ARCH_INIT_H__ |
||||
#define __ARCH_INIT_H__ |
||||
|
||||
#define TCPIP_INIT_DONE(arg) tcpip_init_done(arg) |
||||
|
||||
void tcpip_init_done(void *); |
||||
int wait_for_tcpip_init(void); |
||||
|
||||
#endif /* __ARCH_INIT_H__ */ |
||||
|
||||
|
||||
|
||||
|
||||
@ -1,38 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001-2003 Swedish Institute of Computer Science. |
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met: |
||||
* |
||||
* 1. Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, |
||||
* this list of conditions and the following disclaimer in the documentation |
||||
* and/or other materials provided with the distribution. |
||||
* 3. The name of the author may not be used to endorse or promote products |
||||
* derived from this software without specific prior written permission.
|
||||
* |
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE. |
||||
* |
||||
* This file is part of the lwIP TCP/IP stack. |
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se> |
||||
* |
||||
*/ |
||||
#ifndef __LIB_H__ |
||||
#define __LIB_H__ |
||||
|
||||
#include <string.h> |
||||
|
||||
|
||||
#endif /* __LIB_H__ */ |
||||
@ -1,38 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001-2003 Swedish Institute of Computer Science. |
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met: |
||||
* |
||||
* 1. Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, |
||||
* this list of conditions and the following disclaimer in the documentation |
||||
* and/or other materials provided with the distribution. |
||||
* 3. The name of the author may not be used to endorse or promote products |
||||
* derived from this software without specific prior written permission.
|
||||
* |
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE. |
||||
* |
||||
* This file is part of the lwIP TCP/IP stack. |
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se> |
||||
* |
||||
*/ |
||||
#ifndef __PERF_H__ |
||||
#define __PERF_H__ |
||||
|
||||
#define PERF_START /* null definition */ |
||||
#define PERF_STOP(x) /* null definition */ |
||||
|
||||
#endif /* __PERF_H__ */ |
||||
@ -1,45 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001-2003 Swedish Institute of Computer Science. |
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met: |
||||
* |
||||
* 1. Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, |
||||
* this list of conditions and the following disclaimer in the documentation |
||||
* and/or other materials provided with the distribution. |
||||
* 3. The name of the author may not be used to endorse or promote products |
||||
* derived from this software without specific prior written permission.
|
||||
* |
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE. |
||||
* |
||||
* This file is part of the lwIP TCP/IP stack. |
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se> |
||||
* |
||||
*/ |
||||
#ifndef __SYS_RTXC_H__ |
||||
#define __SYS_RTXC_H__ |
||||
|
||||
#include "rtxcapi.h" |
||||
|
||||
#define SYS_MBOX_NULL (QUEUE)0 |
||||
#define SYS_SEM_NULL (SEMA)0 |
||||
|
||||
typedef SEMA sys_sem_t; |
||||
typedef QUEUE sys_mbox_t; |
||||
typedef TASK sys_thread_t; |
||||
|
||||
#endif /* __SYS_RTXC_H__ */ |
||||
|
||||
@ -1,41 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001-2003 Swedish Institute of Computer Science. |
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met: |
||||
* |
||||
* 1. Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, |
||||
* this list of conditions and the following disclaimer in the documentation |
||||
* and/or other materials provided with the distribution. |
||||
* 3. The name of the author may not be used to endorse or promote products |
||||
* derived from this software without specific prior written permission.
|
||||
* |
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE. |
||||
* |
||||
* This file is part of the lwIP TCP/IP stack. |
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se> |
||||
* |
||||
*/ |
||||
#ifndef __NETIF_CS8900IF_H__ |
||||
#define __NETIF_CS8900IF_H__ |
||||
|
||||
#include "lwip/netif.h" |
||||
|
||||
void cs8900if_init(struct netif *); |
||||
u8_t cs8900if_poll(struct netif *); |
||||
void cs8900if_input(struct netif *);
|
||||
|
||||
#endif /* __NETIF_CS8900IF_H__ */ |
||||
@ -1,39 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001-2003 Swedish Institute of Computer Science. |
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met: |
||||
* |
||||
* 1. Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, |
||||
* this list of conditions and the following disclaimer in the documentation |
||||
* and/or other materials provided with the distribution. |
||||
* 3. The name of the author may not be used to endorse or promote products |
||||
* derived from this software without specific prior written permission.
|
||||
* |
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE. |
||||
* |
||||
* This file is part of the lwIP TCP/IP stack. |
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se> |
||||
* |
||||
*/ |
||||
#ifndef __NETIF_SIOSLIPIF_H__ |
||||
#define __NETIF_SIOSLIPIF_H__ |
||||
|
||||
#include "lwip/netif.h" |
||||
|
||||
void sioslipif_init(struct netif *); |
||||
|
||||
#endif /* __NETIF_SIOSLIPIF_H__ */ |
||||
@ -1,38 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001-2003 Swedish Institute of Computer Science. |
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met: |
||||
* |
||||
* 1. Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, |
||||
* this list of conditions and the following disclaimer in the documentation |
||||
* and/or other materials provided with the distribution. |
||||
* 3. The name of the author may not be used to endorse or promote products |
||||
* derived from this software without specific prior written permission.
|
||||
* |
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE. |
||||
* |
||||
* This file is part of the lwIP TCP/IP stack. |
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se> |
||||
* |
||||
*/ |
||||
|
||||
/* These are generic implementations of various library functions used
|
||||
* throughout the lwIP code. When porting, those should be optimized |
||||
* for the particular processor architecture, preferably coded in |
||||
* assembler. |
||||
*/ |
||||
|
||||
@ -1 +0,0 @@
|
||||
sioslipif.c - Implementation of the SLIP protocol on top of a serial line. |
||||
@ -1,170 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001-2003 Swedish Institute of Computer Science. |
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met: |
||||
* |
||||
* 1. Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, |
||||
* this list of conditions and the following disclaimer in the documentation |
||||
* and/or other materials provided with the distribution. |
||||
* 3. The name of the author may not be used to endorse or promote products |
||||
* derived from this software without specific prior written permission.
|
||||
* |
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE. |
||||
* |
||||
* This file is part of the lwIP TCP/IP stack. |
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se> |
||||
* |
||||
*/ |
||||
|
||||
#include "lwip/debug.h" |
||||
#include "lwip/def.h" |
||||
#include "netif/sioslipif.h" |
||||
#include "lwip/pbuf.h" |
||||
#include "lwip/sys.h" |
||||
|
||||
#define SLIP_END 0300 |
||||
#define SLIP_ESC 0333 |
||||
#define SLIP_ESC_END 0334 |
||||
#define SLIP_ESC_ESC 0335 |
||||
|
||||
/* This variable is used for passing the netif pointer between the
|
||||
threads. */ |
||||
static struct netif *netif_pass; |
||||
|
||||
static int infd, outfd; |
||||
/*-----------------------------------------------------------------------------------*/ |
||||
static void |
||||
sio_send(u8_t c) |
||||
{ |
||||
write(outfd, &c, 1); |
||||
} |
||||
/*-----------------------------------------------------------------------------------*/ |
||||
static u8_t |
||||
sio_recv(void) |
||||
{ |
||||
u8_t c; |
||||
read(infd, &c, 1); |
||||
return c; |
||||
} |
||||
/*-----------------------------------------------------------------------------------*/ |
||||
static int |
||||
sioslipif_output(struct netif *netif, struct pbuf *p, struct ip_addr *ipaddr) |
||||
{ |
||||
struct pbuf *q; |
||||
int i; |
||||
u8_t c; |
||||
|
||||
/* Send pbuf out on the serial I/O device. */ |
||||
sio_send(SLIP_END); |
||||
|
||||
for(q = p; q != NULL; q = q->next) { |
||||
for(i = 0; i < q->len; i++) { |
||||
c = ((u8_t *)q->payload)[i]; |
||||
switch (c) { |
||||
case SLIP_END: |
||||
sio_send(SLIP_ESC); |
||||
sio_send(SLIP_ESC_END); |
||||
break; |
||||
case SLIP_ESC: |
||||
sio_send(SLIP_ESC); |
||||
sio_send(SLIP_ESC_ESC); |
||||
break; |
||||
default: |
||||
sio_send(c); |
||||
break; |
||||
} |
||||
} |
||||
} |
||||
sio_send(SLIP_END); |
||||
return 0; |
||||
} |
||||
/*-----------------------------------------------------------------------------------*/ |
||||
static struct pbuf * |
||||
sioslipif_input(void) |
||||
{ |
||||
u8_t c; |
||||
struct pbuf *p, *q; |
||||
int recved; |
||||
int i; |
||||
|
||||
p = pbuf_alloc(PBUF_LINK, PBUF_MAX_SIZE, PBUF_POOL); |
||||
q = p; |
||||
recved = i = 0; |
||||
|
||||
while (1) { |
||||
c = sio_recv(); |
||||
switch (c) { |
||||
case SLIP_END: |
||||
if (recved > 0) { |
||||
/* Received whole packet. */ |
||||
pbuf_realloc(p, recved); |
||||
return p; |
||||
} |
||||
break; |
||||
case SLIP_ESC: |
||||
c = sio_recv(); |
||||
switch (c) { |
||||
case SLIP_ESC_END: |
||||
c = SLIP_END; |
||||
break; |
||||
case SLIP_ESC_ESC: |
||||
c = SLIP_ESC; |
||||
break; |
||||
} |
||||
/* FALLTHROUGH */ |
||||
default: |
||||
if (recved < p->tot_len && q != NULL) { |
||||
((u8_t *)q->payload)[i] = c; |
||||
recved++; |
||||
i++; |
||||
if (i >= q->len) { |
||||
i = 0; |
||||
q = q->next; |
||||
} |
||||
} |
||||
break; |
||||
} |
||||
|
||||
} |
||||
} |
||||
/*-----------------------------------------------------------------------------------*/ |
||||
static void |
||||
sioslipif_loop(void) |
||||
{ |
||||
struct pbuf *p; |
||||
struct netif *netif; |
||||
|
||||
netif = netif_pass; |
||||
while (1) { |
||||
p = sioslipif_input();
|
||||
netif->input(p, netif); |
||||
} |
||||
} |
||||
/*-----------------------------------------------------------------------------------*/ |
||||
void |
||||
sioslipif_init(struct netif *netif) |
||||
{ |
||||
netif->state = NULL; |
||||
netif->name[0] = 's'; |
||||
netif->name[1] = 'l'; |
||||
netif->output = sioslipif_output; |
||||
|
||||
netif_pass = netif; |
||||
sys_thread_new("sioslipif_loop", (void *)sioslipif_loop, NULL, DEFAULT_THREAD_STACKSIZE, DEFAULT_THREAD_PRIO); |
||||
/* Do some magic to make it possible to receive data from the serial I/O device. */ |
||||
} |
||||
/*-----------------------------------------------------------------------------------*/ |
||||
@ -1,38 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001-2003 Swedish Institute of Computer Science. |
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met: |
||||
* |
||||
* 1. Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, |
||||
* this list of conditions and the following disclaimer in the documentation |
||||
* and/or other materials provided with the distribution. |
||||
* 3. The name of the author may not be used to endorse or promote products |
||||
* derived from this software without specific prior written permission.
|
||||
* |
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE. |
||||
* |
||||
* This file is part of the lwIP TCP/IP stack. |
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se> |
||||
* |
||||
*/ |
||||
|
||||
#include "arch/perf.h" |
||||
|
||||
void |
||||
perf_init(char *fname) |
||||
{ |
||||
} |
||||
@ -1,273 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001-2003 Swedish Institute of Computer Science. |
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met: |
||||
* |
||||
* 1. Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, |
||||
* this list of conditions and the following disclaimer in the documentation |
||||
* and/or other materials provided with the distribution. |
||||
* 3. The name of the author may not be used to endorse or promote products |
||||
* derived from this software without specific prior written permission.
|
||||
* |
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE. |
||||
* |
||||
* This file is part of the lwIP TCP/IP stack. |
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se> |
||||
* |
||||
*/ |
||||
|
||||
#include "lwip/debug.h" |
||||
|
||||
#include "lwip/def.h" |
||||
#include "lwip/sys.h" |
||||
#include "lwip/mem.h" |
||||
|
||||
#include "rtxcapi.h" |
||||
#include "csema.h" |
||||
#include "cclock.h" |
||||
#include "cqueue.h" |
||||
#include "cres.h" |
||||
#include "cpart.h" |
||||
#include "ctask.h" |
||||
|
||||
struct timeoutlist { |
||||
struct sys_timeouts timeouts; |
||||
TASK pid; |
||||
}; |
||||
|
||||
#define SYS_THREAD_MAX 2 |
||||
|
||||
static struct timeoutlist timeoutlist[SYS_THREAD_MAX]; |
||||
static u16_t nextthread = 0; |
||||
|
||||
/*-----------------------------------------------------------------------------------*/ |
||||
sys_mbox_t |
||||
sys_mbox_new(void) |
||||
{ |
||||
QUEUE mbox;
|
||||
KS_dequeuew(IP_MBOXQ, &mbox); |
||||
KS_purgequeue(mbox); |
||||
return mbox; |
||||
} |
||||
/*-----------------------------------------------------------------------------------*/ |
||||
void |
||||
sys_mbox_free(sys_mbox_t mbox) |
||||
{ |
||||
KS_enqueue(IP_MBOXQ, &mbox); |
||||
} |
||||
/*-----------------------------------------------------------------------------------*/ |
||||
void |
||||
sys_mbox_post(sys_mbox_t mbox, void *data) |
||||
{ |
||||
if (KS_enqueue(mbox, &data) != RC_GOOD) { |
||||
} |
||||
} |
||||
/*-----------------------------------------------------------------------------------*/ |
||||
u16_t |
||||
sys_arch_mbox_fetch(sys_mbox_t mbox, void **data, u16_t timeout) |
||||
{ |
||||
KSRC ret; |
||||
u16_t wtime = 1; |
||||
|
||||
if (timeout == 0) { |
||||
LWIP_DEBUGF(SYS_DEBUG, ("PID: %d sys_mbox_fetch: without timeouts\n",KS_inqtask())); |
||||
KS_dequeuew(mbox, data); |
||||
|
||||
} else {
|
||||
|
||||
ret = KS_dequeuet(mbox, data, (TICKS)timeout/CLKTICK); |
||||
if (ret == RC_TIMEOUT) { |
||||
/* The call timed out, so we return 0. */ |
||||
wtime = 0; |
||||
} else { |
||||
/* Calculate time we waited for the message to arrive. */ |
||||
|
||||
/* XXX: we cheat and just pretend that we waited for half the timeout value! */ |
||||
wtime = timeout / 2; |
||||
|
||||
/* Make sure we don't return 0 here. */ |
||||
if (wtime == 0) { |
||||
wtime = 1; |
||||
} |
||||
} |
||||
} |
||||
return wtime; |
||||
} |
||||
/*-----------------------------------------------------------------------------------*/ |
||||
sys_sem_t |
||||
sys_sem_new(u8_t count) |
||||
{ |
||||
SEMA sem; |
||||
KS_dequeuew(IP_SEMQ, &sem); |
||||
KS_pend(sem); |
||||
if (count > 0) { |
||||
KS_signal(sem); |
||||
} |
||||
return sem; |
||||
} |
||||
/*-----------------------------------------------------------------------------------*/ |
||||
u16_t |
||||
sys_arch_sem_wait(sys_sem_t sem, u16_t timeout) |
||||
{ |
||||
KSRC ret; |
||||
u16_t wtime = 1; |
||||
|
||||
if (timeout == 0) { |
||||
LWIP_DEBUGF(SYS_DEBUG, ("PID: %d sys_mbox_fetch: without timeouts\n",KS_inqtask())); |
||||
KS_wait(sem); |
||||
|
||||
} else {
|
||||
ret = KS_waitt(sem, (TICKS)timeout/CLKTICK);
|
||||
if (ret == RC_TIMEOUT) { |
||||
/* The call timed out, so we return 0. */ |
||||
wtime = 0; |
||||
} else { |
||||
/* Calculate time we waited for the message to arrive. */ |
||||
|
||||
/* XXX: we cheat and just pretend that we waited for half the timeout value! */ |
||||
wtime = timeout / 2; |
||||
|
||||
/* Make sure we don't return 0 here. */ |
||||
if (wtime == 0) { |
||||
wtime = 1; |
||||
} |
||||
} |
||||
} |
||||
return wtime; |
||||
|
||||
} |
||||
/*-----------------------------------------------------------------------------------*/ |
||||
void |
||||
sys_sem_signal(sys_sem_t sem) |
||||
{ |
||||
KS_signal(sem); |
||||
} |
||||
/*-----------------------------------------------------------------------------------*/ |
||||
void |
||||
sys_sem_free(sys_sem_t sem) |
||||
{ |
||||
KS_enqueue(IP_SEMQ, &sem); |
||||
} |
||||
/*-----------------------------------------------------------------------------------*/ |
||||
void |
||||
sys_init(void) |
||||
{ |
||||
/* posta in alla semaforer i IP_SEMQ, posta in alla mboxar i
|
||||
IP_MBOXQ */ |
||||
QUEUE mbox; |
||||
SEMA sem; |
||||
|
||||
mbox = IP_Q_01; KS_enqueue(IP_MBOXQ, &mbox); |
||||
mbox = IP_Q_02; KS_enqueue(IP_MBOXQ, &mbox); |
||||
mbox = IP_Q_03; KS_enqueue(IP_MBOXQ, &mbox); |
||||
mbox = IP_Q_04; KS_enqueue(IP_MBOXQ, &mbox); |
||||
mbox = IP_Q_05; KS_enqueue(IP_MBOXQ, &mbox); |
||||
mbox = IP_Q_06; KS_enqueue(IP_MBOXQ, &mbox); |
||||
mbox = IP_Q_07; KS_enqueue(IP_MBOXQ, &mbox); |
||||
mbox = IP_Q_08; KS_enqueue(IP_MBOXQ, &mbox); |
||||
mbox = IP_Q_09; KS_enqueue(IP_MBOXQ, &mbox); |
||||
mbox = IP_Q_10; KS_enqueue(IP_MBOXQ, &mbox); |
||||
mbox = IP_Q_11; KS_enqueue(IP_MBOXQ, &mbox); |
||||
mbox = IP_Q_12; KS_enqueue(IP_MBOXQ, &mbox); |
||||
mbox = IP_Q_13; KS_enqueue(IP_MBOXQ, &mbox); |
||||
mbox = IP_Q_14; KS_enqueue(IP_MBOXQ, &mbox); |
||||
mbox = IP_Q_15; KS_enqueue(IP_MBOXQ, &mbox); |
||||
sem = IP_S_01; KS_enqueue(IP_SEMQ, &sem); |
||||
sem = IP_S_02; KS_enqueue(IP_SEMQ, &sem); |
||||
sem = IP_S_03; KS_enqueue(IP_SEMQ, &sem); |
||||
} |
||||
/*-----------------------------------------------------------------------------------*/ |
||||
struct sys_timeouts * |
||||
sys_arch_timeouts(void) |
||||
{ |
||||
int i; |
||||
TASK pid; |
||||
struct timeoutlist *tl;
|
||||
|
||||
LWIP_DEBUGF(SYS_DEBUG, ("PID: %d sys_mbox_fetch: timeoutlist not empty\n",KS_inqtask())); |
||||
pid = KS_inqtask(); |
||||
for(i = 0; i < nextthread; i++) { |
||||
tl = &timeoutlist[i]; |
||||
if (tl->pid == pid) { |
||||
LWIP_DEBUGF(SYS_DEBUG, ("PID: %d sys_mbox_fetch: corresponding pid found!\n",KS_inqtask())); |
||||
return &(tl->timeouts); |
||||
} |
||||
} |
||||
|
||||
/* Error! */ |
||||
return NULL; |
||||
} |
||||
/*-----------------------------------------------------------------------------------*/ |
||||
struct sys_thread_arg { |
||||
void (* thread)(void *); |
||||
void *threadarg; |
||||
SEMA sem; |
||||
}; |
||||
/*-----------------------------------------------------------------------------------*/ |
||||
static void |
||||
sys_thread(void) |
||||
{ |
||||
struct sys_thread_arg *arg; |
||||
void (* thread)(void *); |
||||
void *threadarg; |
||||
|
||||
arg = KS_inqtask_arg(0); |
||||
if (arg != NULL) { |
||||
|
||||
timeoutlist[nextthread].timeouts.next = NULL; |
||||
timeoutlist[nextthread].pid = KS_inqtask(); |
||||
|
||||
++nextthread; |
||||
|
||||
thread = arg->thread; |
||||
threadarg = arg->threadarg; |
||||
KS_signal(arg->sem); |
||||
thread(threadarg); |
||||
} |
||||
KS_terminate(0); |
||||
} |
||||
/*-----------------------------------------------------------------------------------*/ |
||||
sys_thread_t |
||||
sys_thread_new(char *name, void (* function)(void *arg), void *arg, int istacksize, int prio) |
||||
{ |
||||
TASK newtask; |
||||
PRIORITY pri = prio; /* This may have to be changed. */ |
||||
char *stack; |
||||
/** @todo Replace this local constant by the "istacksize" parameter */ |
||||
int stacksize = 512; /* This may have to be changed. */ |
||||
struct sys_thread_arg threadarg; |
||||
|
||||
|
||||
newtask = KS_alloc_task(); |
||||
stack = KS_allocw(MAP512); |
||||
|
||||
KS_deftask(newtask, pri, (char ks_stk *)stack, (size_t)stacksize, (void (*)(void))sys_thread); |
||||
|
||||
threadarg.thread = function; |
||||
threadarg.threadarg = arg; |
||||
threadarg.sem = THRDSYNC; |
||||
KS_deftask_arg(newtask, &threadarg);
|
||||
KS_execute(newtask); |
||||
KS_wait(THRDSYNC); |
||||
return newtask; |
||||
} |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -1,13 +0,0 @@
|
||||
This directory contains architecture and compiler specific stuff for porting lwIP |
||||
to the TI TMS320C6711 DSP. It's done on the official C6711 DSK board, in CCS v2.10. |
||||
|
||||
The sequential API has not been ported; its functions are empties. If someone is |
||||
interested in adding a sequential API, please contact the author (see below). |
||||
|
||||
The ethernet connection was based on an daughtercard design by the author. |
||||
Schematic files can be found as part of project "ucos-lwip-c6x" on SourceForge.net |
||||
The daughtercard is NE2000 compliant. And the driver supports interrupts. |
||||
|
||||
|
||||
Zeng, Ming |
||||
<ming@zming.net> |
||||
@ -1,63 +0,0 @@
|
||||
[Note]: |
||||
|
||||
Special options setting of lwIP in this project (for using it with uC/OS-II on TI C6000 DSP) |
||||
|
||||
******************************************************************************************* |
||||
This port was for project ucos-lwip-c6x (http://gro.clinux.org/projects/ucos-lwip-c6x/). |
||||
|
||||
For the moment we were writing this note, lwIP v1.1.0 was used in this project. |
||||
|
||||
This note was written in Jan.22 2005 by zengming99@mails.tsinghua.edu.cn. |
||||
******************************************************************************************* |
||||
|
||||
Usually, options of lwIP can be set in file "lwipopts.h". |
||||
|
||||
It was included by "opt.h", amd all options would be set as default value in "opt.h" |
||||
if they were not defined in "lwipopts.h". |
||||
|
||||
Each project should have its own "lwiports.h", and keep "opt.h" as it was. |
||||
|
||||
In this project, for making lwIP work with uC/OS-II on a 32bits TI DSP, |
||||
following options should be set: |
||||
------------------------------------------------------------------------------------ |
||||
|
||||
1. Define symbol "LWIP_PROVIDE_ERRNO" in compiler of CodeComposerStudio |
||||
|
||||
|
||||
2. #define MEM_ALIGNMENT 4 (in "lwipopts.h" ) |
||||
#define ETH_PAD_SIZE 2 (in "lwipopts.h" ) |
||||
|
||||
For the struct align problem on 32bits DSP. |
||||
|
||||
|
||||
3. #define ARP_QUEUEING 0 (in "lwipopts.h") |
||||
|
||||
ARP_QUEUEING has a bug in lwIP v1.0.0 with TCP |
||||
|
||||
|
||||
4. #define LWIP_TASK_MAX 5 (in "sys_arch.h" ) |
||||
#define LWIP_START_PRIO 10 (in "sys_arch.h" ) |
||||
|
||||
#define TCPIP_THREAD_PRIO 5 (in "lwipopts.h" ) |
||||
|
||||
The default TCPIP_THREAD used priority 5. |
||||
|
||||
And, 5 lwIP threads were allowed, user defined lwIP thread should have its priority between 10 ~ 14. |
||||
|
||||
|
||||
5. #define SYS_LIGHTWEIGHT_PROT 1 (in "lwipopts.h" ) |
||||
|
||||
#define SYS_ARCH_DECL_PROTECT(lev) (in "sys_arch.h" ) |
||||
#define SYS_ARCH_PROTECT(lev) OS_ENTER_CRITICAL() (in "sys_arch.h" ) |
||||
#define SYS_ARCH_UNPROTECT(lev) OS_EXIT_CRITICAL() (in "sys_arch.h" ) |
||||
|
||||
These were very important when ethernet driver used intrrupt to check packet |
||||
and pBuf function was called in ISR. Or else, uC/OS-II would run away. |
||||
|
||||
A much better and clean method is to set up a thread for the driver, in ISR |
||||
just check packet and post MailBox to the thread. |
||||
|
||||
|
||||
Zeng, Ming |
||||
|
||||
2005-01-18 |
||||
@ -1,70 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001, Swedish Institute of Computer Science. |
||||
* All rights reserved.
|
||||
* |
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the Institute nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
* |
||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
* |
||||
* This file is part of the lwIP TCP/IP stack. |
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se> |
||||
* |
||||
* $Id: cc.h,v 1.1 2007/06/14 12:34:09 kieranm Exp $ |
||||
*/ |
||||
#ifndef __CC_H__ |
||||
#define __CC_H__ |
||||
|
||||
typedef unsigned char u8_t; |
||||
typedef signed char s8_t; |
||||
typedef unsigned short u16_t; |
||||
typedef signed short s16_t; |
||||
typedef unsigned int u32_t; |
||||
typedef signed int s32_t; |
||||
|
||||
typedef u32_t mem_ptr_t; |
||||
|
||||
#define U16_F "hu" |
||||
#define S16_F "hd" |
||||
#define X16_F "hx" |
||||
#define U32_F "u" |
||||
#define S32_F "d" |
||||
#define X32_F "x" |
||||
|
||||
#define BYTE_ORDER LITTLE_ENDIAN |
||||
|
||||
#define PACK_STRUCT_FIELD(x) x//; #pragma STRUCT_ALIGN(x,1)
|
||||
#define PACK_STRUCT_STRUCT |
||||
#define PACK_STRUCT_BEGIN |
||||
#define PACK_STRUCT_END |
||||
|
||||
#ifndef LWIP_PLATFORM_DIAG |
||||
#define LWIP_PLATFORM_DIAG(x) do {printf x;} while(0) |
||||
#endif |
||||
|
||||
#ifndef LWIP_PLATFORM_ASSERT |
||||
#define LWIP_PLATFORM_ASSERT(x) do {printf("Assertion \"%s\" failed at line %d in %s\n", x, __LINE__, __FILE__); fflush(NULL); abort();} while(0) |
||||
#endif |
||||
|
||||
#endif /* __CC_H__ */ |
||||
|
||||
@ -1,44 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001, Swedish Institute of Computer Science. |
||||
* All rights reserved.
|
||||
* |
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the Institute nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
* |
||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
* |
||||
* This file is part of the lwIP TCP/IP stack. |
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se> |
||||
* |
||||
* $Id: init.h,v 1.1 2007/06/14 12:34:09 kieranm Exp $ |
||||
*/ |
||||
#ifndef __ARCH_INIT_H__ |
||||
#define __ARCH_INIT_H__ |
||||
|
||||
#define TCPIP_INIT_DONE(arg) sys_sem_signal(*(sys_sem_t *)arg) |
||||
|
||||
#endif /* __ARCH_INIT_H__ */ |
||||
|
||||
|
||||
|
||||
|
||||
@ -1,45 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001, Swedish Institute of Computer Science. |
||||
* All rights reserved.
|
||||
* |
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the Institute nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
* |
||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
* |
||||
* This file is part of the lwIP TCP/IP stack. |
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se> |
||||
* |
||||
* $Id: lib.h,v 1.1 2007/06/14 12:34:09 kieranm Exp $ |
||||
*/ |
||||
#ifndef __LIB_H__ |
||||
#define __LIB_H__ |
||||
|
||||
#include "arch/cc.h" |
||||
|
||||
u16_t htons(u16_t n); |
||||
u16_t ntohs(u16_t n); |
||||
u32_t htonl(u32_t n); |
||||
u32_t ntohl(u32_t n); |
||||
|
||||
#endif /* __LIB_H__ */ |
||||
@ -1,41 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001, Swedish Institute of Computer Science. |
||||
* All rights reserved.
|
||||
* |
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the Institute nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
* |
||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
* |
||||
* This file is part of the lwIP TCP/IP stack. |
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se> |
||||
* |
||||
* $Id: perf.h,v 1.1 2007/06/14 12:34:09 kieranm Exp $ |
||||
*/ |
||||
#ifndef __PERF_H__ |
||||
#define __PERF_H__ |
||||
|
||||
#define PERF_START /* null definition */ |
||||
#define PERF_STOP(x) /* null definition */ |
||||
|
||||
#endif /* __PERF_H__ */ |
||||
@ -1,73 +0,0 @@
|
||||
/*
|
||||
********************************************************************************************************* |
||||
* lwIP TCP/IP Stack |
||||
* port for uC/OS-II RTOS on TIC6711 DSK |
||||
* |
||||
* File : sys_arch.h |
||||
* By : ZengMing @ DEP,Tsinghua University,Beijing,China |
||||
* Reference: YangYe's source code for SkyEye project |
||||
********************************************************************************************************* |
||||
*/ |
||||
#ifndef __SYS_ARCH_H__ |
||||
#define __SYS_ARCH_H__ |
||||
|
||||
#include "os_cpu.h" |
||||
#include "os_cfg.h" |
||||
#include "ucos_ii.h" |
||||
|
||||
#define LWIP_STK_SIZE 4096 |
||||
|
||||
#define LWIP_TASK_MAX 5 //max number of lwip tasks
|
||||
#define LWIP_START_PRIO 5 //first prio of lwip tasks
|
||||
//!!!! so priority of lwip tasks is from 5-9
|
||||
|
||||
#define SYS_MBOX_NULL (void*)0 |
||||
#define SYS_SEM_NULL (void*)0 |
||||
|
||||
#define MAX_QUEUES 20 |
||||
#define MAX_QUEUE_ENTRIES 20 |
||||
|
||||
typedef struct { |
||||
OS_EVENT* pQ; |
||||
void* pvQEntries[MAX_QUEUE_ENTRIES]; |
||||
} TQ_DESCR, *PQ_DESCR; |
||||
|
||||
typedef OS_EVENT* sys_sem_t; |
||||
typedef PQ_DESCR sys_mbox_t;//the structure defined above
|
||||
typedef INT8U sys_thread_t; |
||||
|
||||
|
||||
/* Critical Region Protection */ |
||||
/* These functions must be implemented in the sys_arch.c file.
|
||||
In some implementations they can provide a more light-weight protection |
||||
mechanism than using semaphores. Otherwise semaphores can be used for |
||||
implementation */ |
||||
/** SYS_ARCH_DECL_PROTECT
|
||||
* declare a protection variable. This macro will default to defining a variable of |
||||
* type sys_prot_t. If a particular port needs a different implementation, then |
||||
* this macro may be defined in sys_arch.h. |
||||
*/ |
||||
#define SYS_ARCH_DECL_PROTECT(lev) |
||||
/** SYS_ARCH_PROTECT
|
||||
* Perform a "fast" protect. This could be implemented by |
||||
* disabling interrupts for an embedded system or by using a semaphore or |
||||
* mutex. The implementation should allow calling SYS_ARCH_PROTECT when |
||||
* already protected. The old protection level is returned in the variable |
||||
* "lev". This macro will default to calling the sys_arch_protect() function |
||||
* which should be implemented in sys_arch.c. If a particular port needs a |
||||
* different implementation, then this macro may be defined in sys_arch.h |
||||
*/ |
||||
#define SYS_ARCH_PROTECT(lev) OS_ENTER_CRITICAL() |
||||
/** SYS_ARCH_UNPROTECT
|
||||
* Perform a "fast" set of the protection level to "lev". This could be |
||||
* implemented by setting the interrupt level to "lev" within the MACRO or by |
||||
* using a semaphore or mutex. This macro will default to calling the |
||||
* sys_arch_unprotect() function which should be implemented in |
||||
* sys_arch.c. If a particular port needs a different implementation, then |
||||
* this macro may be defined in sys_arch.h |
||||
*/ |
||||
#define SYS_ARCH_UNPROTECT(lev) OS_EXIT_CRITICAL() |
||||
|
||||
|
||||
|
||||
#endif |
||||
@ -1,187 +0,0 @@
|
||||
/*
|
||||
********************************************************************************************************* |
||||
* lwIP TCP/IP Stack |
||||
* port for uC/OS-II RTOS on TIC6711 DSK |
||||
* |
||||
* File : tcp_ip.c |
||||
* By : ZengMing @ DEP,Tsinghua University,Beijing,China |
||||
* Reference: YangYe's source code for SkyEye project |
||||
********************************************************************************************************* |
||||
*/ |
||||
|
||||
#ifndef _NE2K_H_ |
||||
#define _NE2K_H_ |
||||
|
||||
#include "lwip/netif.h" |
||||
|
||||
|
||||
#define MIN_PACKET_SIZE 60 /* smallest legal size packet, no fcs */ |
||||
#define MAX_PACKET_SIZE 1514 /* largest legal size packet, no fcs */ |
||||
|
||||
|
||||
#define DELAY 0x590b2 //0.5s test by ming
|
||||
#define DELAY_2S 0xbf000 //2s test
|
||||
#define DELAY_MS 0x38F4 //20ms test
|
||||
|
||||
|
||||
/**
|
||||
* Driver functions. |
||||
*/ |
||||
err_t ne2k_init(struct netif *netif); |
||||
static void low_level_init(struct netif * netif); |
||||
static void arp_timer(void *arg); |
||||
|
||||
static err_t low_level_output(struct netif * netif,struct pbuf *p); |
||||
u16_t write_AX88796(u8_t * buf, u16_t remote_Addr, u16_t Count); |
||||
|
||||
static void ne2k_input(struct netif *netif); |
||||
static struct pbuf * low_level_input(struct netif *netif); |
||||
u16_t read_AX88796(u8_t * buf, u16_t remote_Addr, u16_t Count); |
||||
|
||||
|
||||
|
||||
/*----------------------------------------
|
||||
* Register header of C6x DSP |
||||
*----------------------------------------*/ |
||||
#define EMIF_CE2 0x01800010 |
||||
|
||||
/* Define QDMA Memory Mapped Registers */ |
||||
#define QDMA_OPT 0x02000000 /* Address of QDMA options register */ |
||||
#define QDMA_SRC 0x02000004 /* Address of QDMA SRC address register */ |
||||
#define QDMA_CNT 0x02000008 /* Address of QDMA counts register */ |
||||
#define QDMA_DST 0x0200000C /* Address of QDMA DST address register */ |
||||
#define QDMA_IDX 0x02000010 /* Address of QDMA index register */ |
||||
|
||||
/* Define QDMA Pseudo Registers */ |
||||
#define QDMA_S_OPT 0x02000020 /* Address of QDMA options register */ |
||||
#define QDMA_S_SRC 0x02000024 /* Address of QDMA SRC address register */ |
||||
#define QDMA_S_CNT 0x02000028 /* Address of QDMA counts register */ |
||||
#define QDMA_S_DST 0x0200002C /* Address of QDMA DST address register */ |
||||
#define QDMA_S_IDX 0x02000030 /* Address of QDMA index register */ |
||||
|
||||
|
||||
|
||||
/*----------------------------------------
|
||||
* Register header of NE2000 chip |
||||
*----------------------------------------*/ |
||||
#define Base_ADDR 0xA0000200 ///CE2 space of DSK is 0xA0000000
|
||||
// and ethernet chip is at 0x200 by default
|
||||
|
||||
// actual address on DSK
|
||||
#define EN_CMD *(unsigned char *)(Base_ADDR+0x00) /* The command register (for all pages) */ |
||||
#define EN_DATA *(unsigned short *)(Base_ADDR+0x10) /*by ming (change to 16bit) Remote DMA Port10~17h (for all pages)*/ |
||||
#define EN_RESET *(unsigned char *)(Base_ADDR+0x1F) /* Reset Port 1fh(for all pages) */ |
||||
|
||||
/* Page 0 register offsets */ |
||||
#define EN0_STARTPG *(unsigned char *)(Base_ADDR+0x01) /* WR Starting page of ring buffer */ |
||||
#define EN0_STOPPG *(unsigned char *)(Base_ADDR+0x02) /* WR Ending page +1 of ring buffer */ |
||||
#define EN0_BOUNDARY *(unsigned char *)(Base_ADDR+0x03) /* RD/WR Boundary page of ring buffer */ |
||||
#define EN0_TSR *(unsigned char *)(Base_ADDR+0x04) /* RD Transmit status reg */ |
||||
#define EN0_TPSR *(unsigned char *)(Base_ADDR+0x04) /* WR Transmit starting page */ |
||||
#define EN0_NCR *(unsigned char *)(Base_ADDR+0x05) /* RD Number of collision reg */ |
||||
#define EN0_TCNTLO *(unsigned char *)(Base_ADDR+0x05) /* WR Low byte of tx byte count */ |
||||
#define EN0_CRP *(unsigned char *)(Base_ADDR+0x06) /* Current Page Register */ |
||||
#define EN0_TCNTHI *(unsigned char *)(Base_ADDR+0x06) /* WR High byte of tx byte count */ |
||||
#define EN0_ISR *(unsigned char *)(Base_ADDR+0x07) /* RD/WR Interrupt status reg */ |
||||
#define EN0_CRDALO *(unsigned char *)(Base_ADDR+0x08) /* RD low byte of current remote dma add*/ |
||||
#define EN0_RSARLO *(unsigned char *)(Base_ADDR+0x08) /* WR Remote start address reg 0 */ |
||||
#define EN0_CRDAHI *(unsigned char *)(Base_ADDR+0x09) /* RD high byte, current remote dma add.*/ |
||||
#define EN0_RSARHI *(unsigned char *)(Base_ADDR+0x09) /* WR Remote start address reg 1 */ |
||||
#define EN0_RCNTLO *(unsigned char *)(Base_ADDR+0x0A) /* WR Remote byte count reg 0 */ |
||||
#define EN0_RCNTHI *(unsigned char *)(Base_ADDR+0x0B) /* WR Remote byte count reg 1 */ |
||||
#define EN0_RSR *(unsigned char *)(Base_ADDR+0x0C) /* RD RX status reg */ |
||||
#define EN0_RXCR *(unsigned char *)(Base_ADDR+0x0C) /* WR RX configuration reg */ |
||||
#define EN0_TXCR *(unsigned char *)(Base_ADDR+0x0D) /* WR TX configuration reg */ |
||||
#define EN0_DCFG *(unsigned char *)(Base_ADDR+0x0E) /* WR Data configuration reg */ |
||||
#define EN0_IMR *(unsigned char *)(Base_ADDR+0x0F) /* WR Interrupt mask reg */ |
||||
|
||||
/* Page 1 register offsets */ |
||||
#define EN1_PAR0 *(unsigned char *)(Base_ADDR+0x01) /* RD/WR This board's physical ethernet addr */ |
||||
#define EN1_PAR1 *(unsigned char *)(Base_ADDR+0x02) |
||||
#define EN1_PAR2 *(unsigned char *)(Base_ADDR+0x03) |
||||
#define EN1_PAR3 *(unsigned char *)(Base_ADDR+0x04) |
||||
#define EN1_PAR4 *(unsigned char *)(Base_ADDR+0x05) |
||||
#define EN1_PAR5 *(unsigned char *)(Base_ADDR+0x06) |
||||
#define EN1_CURR *(unsigned char *)(Base_ADDR+0x07) /* RD/WR current page reg */ |
||||
#define EN1_CURPAG EN1_CURR |
||||
#define EN1_MAR0 *(unsigned char *)(Base_ADDR+0x08) /* RD/WR Multicast filter mask array (8 bytes) */ |
||||
#define EN1_MAR1 *(unsigned char *)(Base_ADDR+0x09) |
||||
#define EN1_MAR2 *(unsigned char *)(Base_ADDR+0x0A) |
||||
#define EN1_MAR3 *(unsigned char *)(Base_ADDR+0x0B) |
||||
#define EN1_MAR4 *(unsigned char *)(Base_ADDR+0x0C) |
||||
#define EN1_MAR5 *(unsigned char *)(Base_ADDR+0x0D) |
||||
#define EN1_MAR6 *(unsigned char *)(Base_ADDR+0x0E) |
||||
#define EN1_MAR7 *(unsigned char *)(Base_ADDR+0x0F) |
||||
|
||||
/* Command Values at EN_CMD */ |
||||
#define EN_STOP 0x01 /* Stop and reset the chip */ |
||||
#define EN_START 0x02 /* Start the chip, clear reset */ |
||||
#define EN_TRANS 0x04 /* Transmit a frame */ |
||||
#define EN_RREAD 0x08 /* Remote read */ |
||||
#define EN_RWRITE 0x10 /* Remote write */ |
||||
#define EN_NODMA 0x20 /* Remote DMA */ |
||||
#define EN_PAGE0 0x00 /* Select page chip registers */ |
||||
#define EN_PAGE1 0x40 /* using the two high-order bits */ |
||||
|
||||
|
||||
//---------------------------------
|
||||
// Values for Ring-Buffer setting
|
||||
//---------------------------------
|
||||
|
||||
#define NE_START_PG 0x40 /* First page of TX buffer */ |
||||
#define NE_STOP_PG 0x80 /* Last page + 1 of RX Ring */ |
||||
|
||||
#define TX_PAGES 6 |
||||
#define TX_START_PG NE_START_PG //0x40
|
||||
|
||||
#define RX_START_PG NE_START_PG + TX_PAGES //0x46
|
||||
#define RX_CURR_PG RX_START_PG + 1 //0x47
|
||||
#define RX_STOP_PG NE_STOP_PG //0x80
|
||||
|
||||
|
||||
|
||||
|
||||
/* Bits in EN0_ISR - Interrupt status register (RD WR) */ |
||||
#define ENISR_RX 0x01 /* Receiver, no error */ |
||||
#define ENISR_TX 0x02 /* Transceiver, no error */ |
||||
#define ENISR_RX_ERR 0x04 /* Receiver, with error */ |
||||
//接收数据包出错。做重新设置BNRY=CURR处理。
|
||||
#define ENISR_TX_ERR 0x08 /* Transmitter, with error */ |
||||
//由于冲突次数过多,发送出错。做重发处理
|
||||
#define ENISR_OVER 0x10 /* Receiver overwrote the ring */ |
||||
/* Gap area of receiver ring buffer was disappeared */
|
||||
//网卡内存溢出。做软件重启网卡处理。见手册。
|
||||
#define ENISR_COUNTERS 0x20 /* Counters need emptying */ |
||||
/* MSB of network tally counter became 1 */ |
||||
//出错计数器中断,屏蔽掉(屏蔽用IMR寄存器)。
|
||||
#define ENISR_RDC 0x40 /* remote dma complete */ |
||||
//屏蔽掉。轮询等待DMA结束。
|
||||
#define ENISR_RESET 0x80 /* Reset completed */ |
||||
//网卡Reset,屏蔽掉。
|
||||
#define ENISR_ALL 0x3f /* 3f Interrupts we will enable */ |
||||
/* RST RDC CNT OVW TXE RXE PTX PRX */ |
||||
|
||||
|
||||
/* Bits in EN0_RXCR - RX configuration reg */ |
||||
//#define ENRXCR_RXCONFIG 0x04 /* EN0_RXCR: broadcasts,no multicast,errors */
|
||||
#define ENRXCR_RXCONFIG 0x00 /* EN0_RXCR: only unicast */ |
||||
#define ENRXCR_CRC 0x01 /* Save error packets(admit) */ |
||||
#define ENRXCR_RUNT 0x02 /* Accept runt pckt(below 64bytes) */ |
||||
#define ENRXCR_BCST 0x04 /* Accept broadcasts when 1 */ |
||||
#define ENRXCR_MULTI 0x08 /* Multicast (if pass filter) when 0 */ |
||||
#define ENRXCR_PROMP 0x10 /* Promiscuous physical addresses when 1*/ |
||||
/* when 0,accept assigned PAR0~5 address */ |
||||
#define ENRXCR_MON 0x20 /* Monitor mode (no packets rcvd) */ |
||||
|
||||
|
||||
/* Bits in EN0_TXCR - TX configuration reg */ |
||||
#define ENTXCR_TXCONFIG 0x00 /* Normal transmit mode */ |
||||
#define ENTXCR_CRC 0x01 /* inhibit CRC,do not append crc when 1 */ |
||||
#define ENTXCR_LOOP 0x02 /* set internal loopback mode ? */ |
||||
#define ENTXCR_LB01 0x06 /* encoded loopback control ? */ |
||||
#define ENTXCR_ATD 0x08 /* auto tx disable */ |
||||
/* when 1, if specified multicast packet was received, disable transmit */
|
||||
#define ENTXCR_OFST 0x10 /* collision offset enable */ |
||||
/* selection of collision algorithm. When 0, gererally back-off algorithm select */ |
||||
|
||||
#endif /* _NE2K_H_ */ |
||||
@ -1,74 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001, Swedish Institute of Computer Science. |
||||
* All rights reserved.
|
||||
* |
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the Institute nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
* |
||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
* |
||||
* This file is part of the lwIP TCP/IP stack. |
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se> |
||||
* |
||||
* $Id: lib_arch.c,v 1.1 2007/06/14 12:34:09 kieranm Exp $ |
||||
*/ |
||||
|
||||
/* These are generic implementations of various library functions used
|
||||
* throughout the lwIP code. When porting, those should be optimized |
||||
* for the particular processor architecture, preferably coded in |
||||
* assembler. |
||||
*/ |
||||
|
||||
|
||||
//yangye 2003-1-22
|
||||
#include "lwip/arch.h" |
||||
|
||||
/*u16_t
|
||||
htons(u16_t n) |
||||
{ |
||||
return ((n & 0xff) << 8) | ((n & 0xff00) >> 8); |
||||
} |
||||
|
||||
u16_t |
||||
ntohs(u16_t n) |
||||
{ |
||||
return htons(n); |
||||
} |
||||
|
||||
|
||||
u32_t |
||||
htonl(u32_t n) |
||||
{ |
||||
return ((n & 0xff) << 24) | |
||||
((n & 0xff00) << 8) | |
||||
((n & 0xff0000) >> 8) | |
||||
((n & 0xff000000) >> 24); |
||||
} |
||||
|
||||
|
||||
u32_t |
||||
ntohl(u32_t n) |
||||
{ |
||||
return htonl(n); |
||||
}*/ |
||||
/*-----------------------------------------------------------------------------------*/ |
||||
@ -1,636 +0,0 @@
|
||||
/*
|
||||
********************************************************************************************************* |
||||
* lwIP TCP/IP Stack |
||||
* port for uC/OS-II RTOS on TIC6711 DSK |
||||
* |
||||
* File : tcp_ip.c |
||||
* By : ZengMing @ DEP,Tsinghua University,Beijing,China |
||||
* Reference: YangYe's source code for SkyEye project |
||||
********************************************************************************************************* |
||||
*/ |
||||
#include "lwip/opt.h" |
||||
#include "lwip/def.h" |
||||
#include "lwip/mem.h" |
||||
#include "lwip/pbuf.h" |
||||
#include "lwip/sys.h" |
||||
#include <lwip/stats.h> |
||||
|
||||
#include "netif/etharp.h" |
||||
|
||||
#include "netif/ne2kif.h" |
||||
|
||||
/* define this to use QDMA, which is much faster! */ |
||||
#define QDMA_Enabled |
||||
|
||||
/* Define those to better describe your network interface. */ |
||||
#define IFNAME0 'e' |
||||
#define IFNAME1 't' |
||||
|
||||
struct ne2k_if { |
||||
struct eth_addr *ethaddr; //MAC Address
|
||||
}; |
||||
|
||||
struct netif *ne2k_if_netif;
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------------------
|
||||
**************************************************************************************** |
||||
----------------------------------------------------------------------------------------*/ |
||||
|
||||
/*
|
||||
* ethernetif_init(): |
||||
* |
||||
* Should be called at the beginning of the program to set up the |
||||
* network interface. It calls the function low_level_init() to do the |
||||
* actual setup of the hardware. |
||||
* |
||||
*/ |
||||
err_t ne2k_init(struct netif *netif) |
||||
{ |
||||
struct ne2k_if *ne2k_if; |
||||
|
||||
ne2k_if = mem_malloc(sizeof(struct ne2k_if));//MAC Address
|
||||
|
||||
if (ne2k_if == NULL) |
||||
{ |
||||
LWIP_DEBUGF(NETIF_DEBUG,("ne2k_init: out of memory!\n")); |
||||
return ERR_MEM; |
||||
} |
||||
|
||||
netif->state = ne2k_if; |
||||
netif->name[0] = IFNAME0; |
||||
netif->name[1] = IFNAME1; |
||||
netif->output = etharp_output; |
||||
netif->linkoutput = low_level_output; |
||||
|
||||
ne2k_if->ethaddr = (struct eth_addr *)&(netif->hwaddr[0]); |
||||
|
||||
low_level_init(netif); |
||||
|
||||
etharp_init(); |
||||
|
||||
sys_timeout(ARP_TMR_INTERVAL, arp_timer, NULL); |
||||
|
||||
return ERR_OK; |
||||
} |
||||
|
||||
/**
|
||||
* arp_timer. |
||||
*/ |
||||
static void arp_timer(void *arg) |
||||
{ |
||||
etharp_tmr(); |
||||
sys_timeout(ARP_TMR_INTERVAL, (sys_timeout_handler)arp_timer, NULL); |
||||
} |
||||
|
||||
/**
|
||||
* Initialize the ne2k ethernet chip, resetting the interface and getting the ethernet |
||||
* address. |
||||
*/ |
||||
static void low_level_init(struct netif * netif) |
||||
{ |
||||
u16_t i; |
||||
struct ne2k_if *ne2k_if; |
||||
|
||||
ne2k_if = netif->state; |
||||
// the meaning of "netif->state" can be defined in drivers, here for MAC address!
|
||||
|
||||
netif->hwaddr_len=6; |
||||
netif->mtu = 1500;
|
||||
netif->flags = NETIF_FLAG_BROADCAST; |
||||
|
||||
// ---------- start -------------
|
||||
*(u32_t *)EMIF_CE2 = 0x11D4C714; // Set CE2 to 16bits mode,
|
||||
// AX88796 required no less than 160ns period
|
||||
|
||||
i = EN_RESET; //this instruction let NE2K chip soft reset
|
||||
|
||||
for (i=0;i<DELAY_MS;i++); //wait
|
||||
|
||||
EN_CMD = (u8_t) (EN_PAGE0 + EN_NODMA + EN_STOP);
|
||||
|
||||
EN0_DCFG = (u8_t) 0x01; |
||||
|
||||
/* Clear the remote byte count registers. */ |
||||
EN0_RCNTHI = (u8_t) 0x00; /* MSB remote byte count reg */ |
||||
EN0_RCNTLO = (u8_t) 0x00; /* LSB remote byte count reg */ |
||||
|
||||
/* RX configuration reg Monitor mode (no packet receive) */ |
||||
EN0_RXCR = (u8_t) ENRXCR_MON; |
||||
/* TX configuration reg set internal loopback mode */ |
||||
EN0_TXCR = (u8_t) ENTXCR_LOOP; |
||||
|
||||
EN0_TPSR = (u8_t) 0x40; //发送缓冲首地址 大小为6页,刚好是1个最大包
|
||||
//为0x40-0x46
|
||||
|
||||
EN0_STARTPG = (u8_t) 0x46 ; /* 接收缓冲 47。Starting page of ring buffer. First page of Rx ring buffer 46h*/ |
||||
EN0_BOUNDARY = (u8_t) 0x46 ; /* Boundary page of ring buffer 0x46*/ |
||||
EN0_STOPPG = (u8_t) 0x80 ; /* Ending page of ring buffer ,0x80*/ |
||||
|
||||
EN0_ISR = (u8_t) 0xff; /* clear the all flag bits in EN0_ISR */ |
||||
EN0_IMR = (u8_t) 0x00; /* Disable all Interrupt */ |
||||
|
||||
EN_CMD = (u8_t) (EN_PAGE1 + EN_NODMA + EN_STOP); |
||||
EN1_CURR = (u8_t) 0x47; /* keep curr=boundary+1 means no new packet */ |
||||
|
||||
EN1_PAR0 = (u8_t)0x12;// MAC_addr.addr[0]; //自定义的mac地址
|
||||
EN1_PAR1 = (u8_t)0x34;// MAC_addr.addr[1];
|
||||
EN1_PAR2 = (u8_t)0x56;// MAC_addr.addr[2];
|
||||
EN1_PAR3 = (u8_t)0x78;// MAC_addr.addr[3];
|
||||
EN1_PAR4 = (u8_t)0x9a;// MAC_addr.addr[4];
|
||||
EN1_PAR5 = (u8_t)0xe0;// MAC_addr.addr[5];
|
||||
|
||||
/* make up an address. */ |
||||
ne2k_if->ethaddr->addr[0] = (u8_t) 0x12;//MAC_addr.addr[0];
|
||||
ne2k_if->ethaddr->addr[1] = (u8_t) 0x34;//MAC_addr.addr[1];
|
||||
ne2k_if->ethaddr->addr[2] = (u8_t) 0x56;//MAC_addr.addr[2];
|
||||
ne2k_if->ethaddr->addr[3] = (u8_t) 0x78;//MAC_addr.addr[3];
|
||||
ne2k_if->ethaddr->addr[4] = (u8_t) 0x9a;//MAC_addr.addr[4];
|
||||
ne2k_if->ethaddr->addr[5] = (u8_t) 0xe0;//MAC_addr.addr[5];
|
||||
|
||||
/* Initialize the multicast list to reject-all.
|
||||
If we enable multicast the higher levels can do the filtering.
|
||||
<multicast filter mask array (8 bytes)> */ |
||||
EN1_MAR0 = (u8_t) 0x00;
|
||||
EN1_MAR1 = (u8_t) 0x00; |
||||
EN1_MAR2 = (u8_t) 0x00; |
||||
EN1_MAR3 = (u8_t) 0x00; |
||||
EN1_MAR4 = (u8_t) 0x00; |
||||
EN1_MAR5 = (u8_t) 0x00; |
||||
EN1_MAR6 = (u8_t) 0x00; |
||||
EN1_MAR7 = (u8_t) 0x00; |
||||
|
||||
EN_CMD = (u8_t) (EN_PAGE0 + EN_NODMA + EN_STOP); |
||||
|
||||
EN0_IMR = (u8_t) (ENISR_OVER + ENISR_RX + ENISR_RX_ERR); |
||||
|
||||
EN0_TXCR = (u8_t) 0x00; //E0 //TCR
|
||||
EN0_RXCR = (u8_t) 0x44; //CC //RCR
|
||||
|
||||
EN_CMD = (u8_t) (EN_PAGE0 + EN_NODMA + EN_START); |
||||
|
||||
EN0_ISR = (u8_t) 0xff; // clear the all flag bits in EN0_ISR
|
||||
|
||||
ne2k_if_netif = netif; |
||||
} |
||||
|
||||
|
||||
/*----------------------------------------------------------------------------------------
|
||||
**************************************************************************************** |
||||
----------------------------------------------------------------------------------------*/ |
||||
|
||||
/*
|
||||
* low_level_output(): |
||||
* |
||||
* Should do the actual transmission of the packet. The packet is |
||||
* contained in the pbuf that is passed to the function. This pbuf |
||||
* might be chained. |
||||
* |
||||
*/ |
||||
static err_t low_level_output(struct netif * netif, struct pbuf *p) |
||||
{ |
||||
struct pbuf *q; |
||||
u16_t packetLength,remote_Addr,Count; |
||||
u8_t *buf; |
||||
|
||||
packetLength = p->tot_len - ETH_PAD_SIZE; //05 01 millin
|
||||
|
||||
if ((packetLength) < 64) packetLength = 64; //add pad by the AX88796 automatically
|
||||
|
||||
// turn off RX int
|
||||
EN0_IMR = (u8_t) (ENISR_OVER); |
||||
|
||||
/* We should already be in page 0, but to be safe... */ |
||||
EN_CMD = (u8_t) (EN_PAGE0 + EN_START + EN_NODMA); |
||||
|
||||
// clear the RDC bit
|
||||
EN0_ISR = (u8_t) ENISR_RDC; |
||||
|
||||
remote_Addr = (u16_t)(TX_START_PG<<8);
|
||||
|
||||
/*
|
||||
* Write packet to ring buffers. |
||||
*/ |
||||
for(q = p; q != NULL; q = q->next) { |
||||
/* Send the data from the pbuf to the interface, one pbuf at a
|
||||
time. The size of the data in each pbuf is kept in the ->len |
||||
variable. */ |
||||
Count = q->len; |
||||
buf = q->payload; |
||||
|
||||
if (q == p){ |
||||
buf += ETH_PAD_SIZE; |
||||
Count -= ETH_PAD_SIZE;//Pad in Eth_hdr struct
|
||||
} |
||||
|
||||
// Write data to AX88796
|
||||
remote_Addr = write_AX88796(buf, remote_Addr, Count);
|
||||
} //for
|
||||
|
||||
/* Just send it, and does not check */ |
||||
while (EN_CMD & EN_TRANS); |
||||
|
||||
EN0_TPSR = (u8_t) TX_START_PG; |
||||
EN0_TCNTLO = (u8_t) (packetLength & 0xff); |
||||
EN0_TCNTHI = (u8_t) (packetLength >> 8); |
||||
EN_CMD = (u8_t) (EN_PAGE0 + EN_NODMA + EN_TRANS + EN_START); |
||||
|
||||
EN0_IMR = (u8_t) (ENISR_OVER + ENISR_RX + ENISR_RX_ERR); |
||||
|
||||
#if LINK_STATS |
||||
lwip_stats.link.xmit++; |
||||
#endif /* LINK_STATS */ |
||||
|
||||
return ERR_OK; |
||||
} |
||||
|
||||
/**
|
||||
* write_AX88796. |
||||
*/ |
||||
u16_t write_AX88796(u8_t * buf, u16_t remote_Addr, u16_t Count) |
||||
{ |
||||
#ifndef QDMA_Enabled |
||||
u16_t loop; |
||||
#endif |
||||
|
||||
/* AX88796. */ |
||||
EN0_RCNTLO = (u8_t) ( Count & 0xff); |
||||
EN0_RCNTHI = (u8_t) ( Count >> 8); |
||||
EN0_RSARLO = (u8_t) ( remote_Addr & 0xff); |
||||
EN0_RSARHI = (u8_t) ( remote_Addr >> 8); |
||||
EN_CMD = (u8_t) (EN_RWRITE + EN_START + EN_PAGE0); |
||||
|
||||
// Add for next loop...
|
||||
remote_Addr += Count; |
||||
|
||||
Count = (Count + 1) >> 1; // Turn to 16bits count. <Must add 1 first!>
|
||||
|
||||
#ifdef QDMA_Enabled |
||||
*(u32_t *)QDMA_SRC = (u32_t) buf; |
||||
*(u32_t *)QDMA_DST = (u32_t) &EN_DATA; |
||||
*(u32_t *)QDMA_CNT = (u32_t) Count; |
||||
*(u32_t *)QDMA_IDX = 0x00000000; |
||||
*(u32_t *)QDMA_S_OPT = 0x29000001; |
||||
#else |
||||
for (loop=0;loop < Count ;loop++){ |
||||
EN_DATA = *(u16_t *)buf; |
||||
buf += 2; |
||||
} |
||||
#endif //QDMA_Enabled
|
||||
|
||||
while ((EN0_ISR & ENISR_RDC) == 0); |
||||
|
||||
EN0_ISR = (u8_t) ENISR_RDC; |
||||
|
||||
return remote_Addr; |
||||
} |
||||
|
||||
|
||||
/*----------------------------------------------------------------------------------------
|
||||
**************************************************************************************** |
||||
----------------------------------------------------------------------------------------*/ |
||||
|
||||
/*
|
||||
* ethernetif_input(): |
||||
* |
||||
* This function should be called when a packet is ready to be read |
||||
* from the interface. It uses the function low_level_input() that |
||||
* should handle the actual reception of bytes from the network |
||||
* interface. |
||||
* |
||||
*/ |
||||
static void
|
||||
ne2k_input(struct netif *netif) |
||||
{ |
||||
struct ne2k_if *ne2k_if; |
||||
struct eth_hdr *ethhdr; |
||||
struct pbuf *p; |
||||
|
||||
ne2k_if = netif->state; |
||||
|
||||
/* move received packet into a new pbuf */ |
||||
p = low_level_input(netif); |
||||
/* no packet could be read, silently ignore this */ |
||||
if (p == NULL) return; |
||||
/* points to packet payload, which starts with an Ethernet header */ |
||||
ethhdr = p->payload; |
||||
|
||||
#if LINK_STATS |
||||
lwip_stats.link.recv++; |
||||
#endif /* LINK_STATS */ |
||||
|
||||
switch(htons(ethhdr->type)) { |
||||
/* IP packet? */ |
||||
case ETHTYPE_IP: |
||||
/* update ARP table */ |
||||
etharp_ip_input(netif, p); |
||||
/* skip Ethernet header */ |
||||
pbuf_header(p, -(14+ETH_PAD_SIZE)); |
||||
/* pass to network layer */ |
||||
netif->input(p, netif); |
||||
break; |
||||
case ETHTYPE_ARP: |
||||
/* pass p to ARP module */ |
||||
etharp_arp_input(netif, ne2k_if->ethaddr, p); |
||||
break; |
||||
default: |
||||
pbuf_free(p); |
||||
p = NULL; |
||||
break; |
||||
} |
||||
} |
||||
|
||||
/*
|
||||
* low_level_input(): |
||||
* |
||||
* Should allocate a pbuf and transfer the bytes of the incoming |
||||
* packet from the interface into the pbuf. |
||||
* |
||||
*/ |
||||
static struct pbuf *
|
||||
low_level_input(struct netif *netif) |
||||
{ |
||||
u16_t packetLength, Count, remote_Addr; |
||||
u8_t *buf, PDHeader[4]; |
||||
u8_t curr, this_frame, next_frame; |
||||
struct pbuf *p, *q, *r; |
||||
|
||||
EN_CMD = (u8_t) (EN_PAGE1 + EN_NODMA + EN_START); |
||||
curr = (u8_t) EN1_CURR; |
||||
EN_CMD = (u8_t) (EN_PAGE0 + EN_NODMA + EN_START); |
||||
this_frame = (u8_t) EN0_BOUNDARY + 1; |
||||
|
||||
if (this_frame >= RX_STOP_PG) |
||||
this_frame = RX_START_PG; |
||||
|
||||
//---------- get the first 4 bytes from AX88796 ---------
|
||||
(void) read_AX88796(PDHeader, (u16_t)(this_frame<<8), 4); |
||||
|
||||
|
||||
//----- Store real length, set len to packet length - header ---------
|
||||
packetLength = ((unsigned) PDHeader[2] | (PDHeader[3] << 8 )) - 4; // minus PDHeader[4]
|
||||
next_frame = (u8_t) (this_frame + 1 + ((packetLength + 4) >> 8)); |
||||
|
||||
// Bad frame!
|
||||
if ((PDHeader[1] != (u8_t)next_frame) && (PDHeader[1] != (u8_t)(next_frame + 1)) |
||||
&& (PDHeader[1] != (u8_t)(next_frame - RX_STOP_PG + RX_START_PG)) |
||||
&& (PDHeader[1] != (u8_t)(next_frame + 1 - RX_STOP_PG + RX_START_PG))) |
||||
{ |
||||
EN0_BOUNDARY = (u8_t) (curr - 1);
|
||||
return NULL; |
||||
} |
||||
|
||||
// Bogus Packet Size
|
||||
if (packetLength > MAX_PACKET_SIZE || packetLength < MIN_PACKET_SIZE)
|
||||
{ |
||||
next_frame = PDHeader[1]; |
||||
EN0_BOUNDARY = (u8_t) (next_frame-1); |
||||
return NULL; |
||||
} |
||||
|
||||
|
||||
EN_CMD = (u8_t) (EN_PAGE0 + EN_NODMA + EN_START); |
||||
|
||||
EN0_ISR = (u8_t) ENISR_RDC; // clear the RDC bit
|
||||
|
||||
|
||||
remote_Addr = (u16_t)((this_frame << 8) + 4); |
||||
|
||||
if ((remote_Addr + packetLength + ETH_PAD_SIZE) > (u16_t)(RX_STOP_PG<<8)) { |
||||
p = pbuf_alloc(PBUF_RAW, (u16_t)(RX_STOP_PG<<8) - remote_Addr, PBUF_POOL); /* length of buf */ |
||||
packetLength -= (u16_t)(RX_STOP_PG<<8) - remote_Addr - ETH_PAD_SIZE; |
||||
} else { |
||||
p = pbuf_alloc(PBUF_RAW, packetLength+ETH_PAD_SIZE, PBUF_POOL); /* length of buf */ |
||||
packetLength = 0; |
||||
} |
||||
|
||||
if(p != NULL) { /* We iterate over the pbuf chain until we have read the entire packet into the pbuf. */ |
||||
for(q = p; q != NULL; q= q->next){ /* Read enough bytes to fill this pbuf in the chain. The avaliable data in the pbuf is given by the q->len variable. */ |
||||
buf = q->payload;
|
||||
Count = q->len; |
||||
if (q == p){ // if it's the first pbuf in chain...
|
||||
buf += ETH_PAD_SIZE; |
||||
Count -= ETH_PAD_SIZE; // pad in Eth_hdr struct
|
||||
} |
||||
remote_Addr = read_AX88796(buf, remote_Addr, Count); |
||||
|
||||
#if LINK_STATS |
||||
lwip_stats.link.recv++; |
||||
#endif /* LINK_STATS */ |
||||
} //for(q = p; q != NULL; q= q->next)
|
||||
} //if(p != NULL)
|
||||
else
|
||||
{ // p == NULL
|
||||
#if LINK_STATS |
||||
lwip_stats.link.memerr++; |
||||
lwip_stats.link.drop++; |
||||
#endif /* LINK_STATS */ |
||||
} |
||||
|
||||
|
||||
if (packetLength) // ring buffer cycled
|
||||
{ |
||||
remote_Addr = (u16_t)(RX_START_PG << 8); |
||||
r = pbuf_alloc(PBUF_RAW, packetLength, PBUF_POOL); /* length of buf */ |
||||
|
||||
if(r != NULL) { /* We iterate over the pbuf chain until we have read the entire packet into the pbuf. */ |
||||
for(q = r; q != NULL; q= q->next){ /* Read enough bytes to fill this pbuf in the chain. The avaliable data in the pbuf is given by the q->len variable. */ |
||||
buf = q->payload;
|
||||
Count = q->len; |
||||
remote_Addr = read_AX88796(buf, remote_Addr, Count); |
||||
} //for
|
||||
// link pbuf p & r
|
||||
pbuf_cat(p, r);
|
||||
}
|
||||
else // r == NULL
|
||||
{
|
||||
#if LINK_STATS |
||||
lwip_stats.link.memerr++; |
||||
lwip_stats.link.drop++; |
||||
#endif |
||||
} |
||||
} // if (packetLength)
|
||||
|
||||
|
||||
next_frame = PDHeader[1]; |
||||
|
||||
EN0_BOUNDARY = (u8_t) (next_frame-1); |
||||
|
||||
return p; |
||||
} |
||||
|
||||
/**
|
||||
* read_AX88796. |
||||
*/ |
||||
u16_t read_AX88796(u8_t * buf, u16_t remote_Addr, u16_t Count) |
||||
{ |
||||
u8_t flagOdd=0; |
||||
#ifndef QDMA_Enabled |
||||
u16_t loop; |
||||
#endif |
||||
|
||||
flagOdd = (Count & 0x0001); // set Flag if Count is odd.
|
||||
|
||||
Count -= flagOdd; |
||||
|
||||
EN0_RCNTLO = (u8_t) (Count & 0xff); |
||||
EN0_RCNTHI = (u8_t) (Count >> 8); |
||||
EN0_RSARLO = (u8_t) (remote_Addr & 0xff); |
||||
EN0_RSARHI = (u8_t) (remote_Addr >> 8); |
||||
EN_CMD = (u8_t) (EN_PAGE0 + EN_RREAD + EN_START); |
||||
|
||||
remote_Addr += Count; |
||||
|
||||
Count = Count>>1; |
||||
|
||||
#ifdef QDMA_Enabled |
||||
*(u32_t *)QDMA_SRC = (u32_t) &EN_DATA; |
||||
*(u32_t *)QDMA_DST = (u32_t) buf; |
||||
*(u32_t *)QDMA_CNT = (u32_t) Count; |
||||
*(u32_t *)QDMA_IDX = 0x00000000; |
||||
*(u32_t *)QDMA_S_OPT = 0x28200001; |
||||
buf += Count*2; |
||||
#else |
||||
for (loop=0;loop < Count ;loop++){ |
||||
*(u16_t *)buf = EN_DATA ; |
||||
buf += 2; |
||||
} |
||||
#endif //QDMA_Enabled
|
||||
|
||||
while ((EN0_ISR & ENISR_RDC) == 0); |
||||
|
||||
EN0_ISR = (u8_t) ENISR_RDC; |
||||
|
||||
if (flagOdd) { |
||||
EN0_RCNTLO = 0x01; |
||||
EN0_RCNTHI = 0x00; |
||||
EN0_RSARLO = (u8_t) (remote_Addr & 0xff); |
||||
EN0_RSARHI = (u8_t) (remote_Addr >> 8); |
||||
EN_CMD = (u8_t) (EN_PAGE0 + EN_RREAD + EN_START); |
||||
|
||||
remote_Addr += 1; |
||||
|
||||
*(u8_t *)buf = *(u8_t *)(Base_ADDR+0x10) ; |
||||
|
||||
while ((EN0_ISR & ENISR_RDC) == 0); |
||||
|
||||
EN0_ISR = (u8_t) ENISR_RDC;
|
||||
} |
||||
|
||||
return remote_Addr; |
||||
} |
||||
|
||||
/*----------------------------------------------------------------------------------------
|
||||
**************************************************************************************** |
||||
----------------------------------------------------------------------------------------*/ |
||||
|
||||
/**
|
||||
* ne2k_rx_err. |
||||
*/ |
||||
void ne2k_rx_err(void) |
||||
{ |
||||
u8_t curr; |
||||
EN_CMD = (u8_t) (EN_PAGE1 + EN_NODMA + EN_STOP); |
||||
curr = (u8_t) EN1_CURR; |
||||
EN_CMD = (u8_t) (EN_PAGE0 + EN_NODMA + EN_STOP); |
||||
EN0_BOUNDARY = (u8_t) curr-1; |
||||
} |
||||
|
||||
/**
|
||||
* ne2k_rx. |
||||
*/ |
||||
void ne2k_rx(void) |
||||
{ |
||||
u8_t curr,bnry,loopCnt = 0; |
||||
|
||||
while(loopCnt < 10) { |
||||
|
||||
EN_CMD = (u8_t) (EN_PAGE1 + EN_NODMA + EN_STOP); |
||||
curr = (u8_t) EN1_CURR; |
||||
EN_CMD = (u8_t) (EN_PAGE0 + EN_NODMA + EN_STOP); |
||||
bnry = (u8_t) EN0_BOUNDARY + 1; |
||||
|
||||
if (bnry >= RX_STOP_PG) |
||||
bnry = RX_START_PG; |
||||
|
||||
if (curr == bnry) break; |
||||
|
||||
ne2k_input(ne2k_if_netif); |
||||
|
||||
loopCnt++; |
||||
} |
||||
} |
||||
|
||||
/*---*---*---*---*---*---*---*
|
||||
* void ne2k_isr(void) |
||||
* can be int 4 5 6 or 7
|
||||
*---*---*---*---*---*---*---*/ |
||||
void ne2k_isr(void) |
||||
{ |
||||
DSP_C6x_Save(); |
||||
|
||||
OSIntEnter(); |
||||
|
||||
if (OSIntNesting == 1) |
||||
{ |
||||
OSTCBCur->OSTCBStkPtr = (OS_STK *) DSP_C6x_GetCurrentSP(); |
||||
} |
||||
|
||||
/* You can enable Interrupt again here,
|
||||
if want to use nested interrupt..... */ |
||||
//------------------------------------------------------------
|
||||
|
||||
EN_CMD = (u8_t) (EN_PAGE0 + EN_NODMA + EN_STOP); |
||||
//outb(CMD_PAGE0 | CMD_NODMA | CMD_STOP,NE_CR);
|
||||
|
||||
EN0_IMR = (u8_t) 0x00;//close
|
||||
|
||||
// ram overflow interrupt
|
||||
if (EN0_ISR & ENISR_OVER) { |
||||
EN0_ISR = (u8_t) ENISR_OVER; // clear interrupt
|
||||
} |
||||
|
||||
// error transfer interrupt ,NIC abort tx due to excessive collisions
|
||||
if (EN0_ISR & ENISR_TX_ERR) { |
||||
EN0_ISR = (u8_t) ENISR_TX_ERR; // clear interrupt
|
||||
//temporarily do nothing
|
||||
} |
||||
|
||||
// Rx error , reset BNRY pointer to CURR (use SEND PACKET mode)
|
||||
if (EN0_ISR & ENISR_RX_ERR) { |
||||
EN0_ISR = (u8_t) ENISR_RX_ERR; // clear interrupt
|
||||
ne2k_rx_err(); |
||||
} |
||||
|
||||
//got packet with no errors
|
||||
if (EN0_ISR & ENISR_RX) { |
||||
EN0_ISR = (u8_t) ENISR_RX; |
||||
ne2k_rx();
|
||||
} |
||||
|
||||
//Transfer complelte, do nothing here
|
||||
if (EN0_ISR & ENISR_TX){ |
||||
EN0_ISR = (u8_t) ENISR_TX; // clear interrupt
|
||||
} |
||||
|
||||
EN_CMD = (u8_t) (EN_PAGE0 + EN_NODMA + EN_STOP); |
||||
|
||||
EN0_ISR = (u8_t) 0xff; // clear ISR
|
||||
|
||||
EN0_IMR = (u8_t) (ENISR_OVER + ENISR_RX + ENISR_RX_ERR); |
||||
|
||||
//open nic for next packet
|
||||
EN_CMD = (u8_t) (EN_PAGE0 + EN_NODMA + EN_START); |
||||
|
||||
if (led_stat & 0x04) {LED3_on;} |
||||
else {LED3_off;} |
||||
|
||||
//--------------------------------------------------------
|
||||
|
||||
OSIntExit(); |
||||
|
||||
DSP_C6x_Resume(); |
||||
|
||||
asm (" nop 5"); //important!
|
||||
// this can avoid a stack error when compile with the optimization!
|
||||
} |
||||
@ -1,152 +0,0 @@
|
||||
/*
|
||||
********************************************************************************************************* |
||||
* lwIP TCP/IP Stack |
||||
* port for uC/OS-II RTOS on TIC6711 DSK |
||||
* |
||||
* File : tcp_ip.c |
||||
* By : ZengMing @ DEP,Tsinghua University,Beijing,China |
||||
********************************************************************************************************* |
||||
*/ |
||||
#include <stdio.h> |
||||
#include <string.h> |
||||
#include <ctype.h> |
||||
#include <stdlib.h> |
||||
|
||||
#include "..\uCOS-II\TI_C6711\DSP_C6x_Vectors\DSP_C6x_Vectors.H" |
||||
|
||||
// -- Architecture Files --
|
||||
#include "..\lwIP\arch\TI_C6711\sys_arch.c" |
||||
#include "..\lwIP\arch\TI_C6711\netif\ne2kif.c" |
||||
// -- Generic network interface --
|
||||
#include "..\lwIP\src\netif\loopif.c" |
||||
#include "..\lwIP\src\netif\etharp.c" |
||||
|
||||
// -- common file
|
||||
#include "..\lwIP\src\core\mem.c" |
||||
#include "..\lwIP\src\core\memp.c" |
||||
#include "..\lwIP\src\core\netif.c" |
||||
#include "..\lwIP\src\core\pbuf.c" |
||||
#include "..\lwIP\src\core\stats.c" |
||||
#include "..\lwIP\src\core\sys.c" |
||||
#include "..\lwIP\src\core\tcp.c" |
||||
#include "..\lwIP\src\core\tcp_in.c" |
||||
#include "..\lwIP\src\core\tcp_out.c" |
||||
#include "..\lwIP\src\core\udp.c" |
||||
#include "..\lwIP\src\core\raw.c" |
||||
// -- target ipv4 --
|
||||
#include "..\lwIP\src\core\ipv4\icmp.c" |
||||
#include "..\lwIP\src\core\ipv4\ip.c" |
||||
#include "..\lwIP\src\core\inet.c" |
||||
#include "..\lwIP\src\core\ipv4\ip_addr.c" |
||||
#include "..\lwIP\src\core\ipv4\ip_frag.c" |
||||
// -- sequential and socket APIs --
|
||||
#include "..\lwIP\src\api\api_lib.c" |
||||
#include "..\lwIP\src\api\api_msg.c" |
||||
#include "..\lwIP\src\api\tcpip.c" |
||||
#include "..\lwIP\src\api\err.c" |
||||
#include "..\lwIP\src\api\sockets.c" |
||||
|
||||
// sample task code (http demo)
|
||||
#include "sample_http.c" |
||||
|
||||
struct netif ne2kif_if; |
||||
//struct netif loop_if;
|
||||
|
||||
void ethernet_hardreset(void); //These reset codes are built for C6711 DSP
|
||||
void tcpip_init_done_ok(void * arg); |
||||
|
||||
void Task_lwip_init(void * pParam) |
||||
{ |
||||
struct ip_addr ipaddr, netmask, gw; |
||||
sys_sem_t sem; |
||||
|
||||
ethernet_hardreset();//hard reset of EthernetDaughterCard
|
||||
|
||||
#if LWIP_STATS |
||||
stats_init(); |
||||
#endif |
||||
// initial lwIP stack
|
||||
sys_init(); |
||||
mem_init(); |
||||
memp_init(); |
||||
pbuf_init(); |
||||
netif_init();
|
||||
lwip_socket_init(); |
||||
|
||||
printf("TCP/IP initializing...\n");
|
||||
sem = sys_sem_new(0); |
||||
tcpip_init(tcpip_init_done_ok, &sem); |
||||
sys_sem_wait(sem); |
||||
sys_sem_free(sem); |
||||
printf("TCP/IP initialized.\n"); |
||||
|
||||
//add loop interface //set local loop-interface 127.0.0.1
|
||||
/*
|
||||
IP4_ADDR(&gw, 127,0,0,1); |
||||
IP4_ADDR(&ipaddr, 127,0,0,1); |
||||
IP4_ADDR(&netmask, 255,0,0,0); |
||||
netif_add(&loop_if, &ipaddr, &netmask, &gw, NULL, loopif_init, |
||||
tcpip_input);*/ |
||||
|
||||
//add ne2k interface
|
||||
IP4_ADDR(&gw, 166,111,32,1); |
||||
IP4_ADDR(&ipaddr, 166,111,33,120); |
||||
IP4_ADDR(&netmask, 255,255,254,0); |
||||
|
||||
netif_add(&ne2kif_if, &ipaddr, &netmask, &gw, NULL, ne2k_init, tcpip_input); |
||||
netif_set_default(&ne2kif_if); |
||||
netif_set_up(&ne2kif_if); // new step from lwip 1.0.0
|
||||
|
||||
printf("Applications started.\n"); |
||||
|
||||
//------------------------------------------------------------
|
||||
//All thread(task) of lwIP must have their PRI between 10 and 14.
|
||||
// sys_thread_new("httpd_init", httpd_init, (void*)"httpd", DEFAULT_THREAD_STACKSIZE, 10);
|
||||
//------------------------------------------------------------
|
||||
httpd_init();//sample_http
|
||||
|
||||
printf("lwIP threads created!\n"); |
||||
|
||||
DSP_C6x_TimerInit(); // Timer interrupt enabled
|
||||
DSP_C6x_Int4Init(); // Int4(Ethernet Chip int) enabled
|
||||
|
||||
/* Block for ever. */ |
||||
sem = sys_sem_new(0); |
||||
sys_sem_wait(sem); |
||||
printf(" never goes here, should not appear!\n"); |
||||
} |
||||
|
||||
//---------------------------------------------------------
|
||||
void tcpip_init_done_ok(void * arg) |
||||
{ |
||||
sys_sem_t *sem; |
||||
sem = arg; |
||||
sys_sem_signal(*sem); |
||||
} |
||||
|
||||
|
||||
/*-----------------------------------------------------------*/ |
||||
/* This function do the hard reset of EthernetDaughterCard *
|
||||
* through the DaughterBoardControl0 signal in DB-IF */
|
||||
/*-----------------------------------------------------------*/ |
||||
void ethernet_hardreset(void) //These reset codes are built for C6711 DSK
|
||||
{ |
||||
u32_t i; |
||||
|
||||
OS_ENTER_CRITICAL(); |
||||
|
||||
//SET LED1 ON AND /RST pin Low
|
||||
*(unsigned char *)0x90080003 = 0x06; |
||||
for (i=0;i<DELAY;i++); |
||||
//SET LED2 ON AND /RST pin High _|-|_
|
||||
*(unsigned char *)0x90080003 = 0xfd; |
||||
for (i=0;i<DELAY;i++);
|
||||
//SET LED3 ON AND /RST pin Low
|
||||
*(unsigned char *)0x90080003 = 0x03; |
||||
for (i=0;i<DELAY_2S;i++); |
||||
|
||||
OS_EXIT_CRITICAL(); |
||||
} |
||||
|
||||
|
||||
|
||||
@ -1,301 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001, Swedish Institute of Computer Science. |
||||
* All rights reserved.
|
||||
* |
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the Institute nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
* |
||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
* |
||||
* This file is part of the lwIP TCP/IP stack. |
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se> |
||||
* |
||||
* $Id: lwipopts.h,v 1.2 2007/09/07 23:28:54 fbernon Exp $ |
||||
*/ |
||||
#ifndef __LWIPOPTS_H__ |
||||
#define __LWIPOPTS_H__ |
||||
|
||||
// for TI C6000 DSP target, struct align....
|
||||
//------------------------------------------------
|
||||
#define ETH_PAD_SIZE 2 |
||||
//------------------------------------------------
|
||||
|
||||
//------------------------------------------------
|
||||
/* Critical Region Protection */ |
||||
//------------------------------------------------
|
||||
/** SYS_LIGHTWEIGHT_PROT
|
||||
* define SYS_LIGHTWEIGHT_PROT in lwipopts.h if you want inter-task protection |
||||
* for certain critical regions during buffer allocation, deallocation and memory |
||||
* allocation and deallocation. |
||||
*/ |
||||
#define SYS_LIGHTWEIGHT_PROT 1 //millin
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
/* ---------- Memory options ---------- */ |
||||
//----------------------------------------------------------------------
|
||||
|
||||
/* MEM_ALIGNMENT: should be set to the alignment of the CPU for which
|
||||
lwIP is compiled. 4 byte alignment -> define MEM_ALIGNMENT to 4, 2 |
||||
byte alignment -> define MEM_ALIGNMENT to 2. */ |
||||
#define MEM_ALIGNMENT 4 |
||||
|
||||
/* MEM_SIZE: the size of the heap memory. If the application will send
|
||||
a lot of data that needs to be copied, this should be set high. */ |
||||
#define MEM_SIZE 65536 |
||||
|
||||
/* MEMP_NUM_PBUF: the number of memp struct pbufs. If the application
|
||||
sends a lot of data out of ROM (or other static memory), this |
||||
should be set high. */ |
||||
#define MEMP_NUM_PBUF 32 |
||||
|
||||
/* Number of raw connection PCBs */ |
||||
#define MEMP_NUM_RAW_PCB 8 |
||||
|
||||
/* MEMP_NUM_UDP_PCB: the number of UDP protocol control blocks. One
|
||||
per active UDP "connection". */ |
||||
#define MEMP_NUM_UDP_PCB 8 |
||||
|
||||
/* MEMP_NUM_TCP_PCB: the number of simulatenously active TCP
|
||||
connections. */ |
||||
#define MEMP_NUM_TCP_PCB 8 |
||||
|
||||
/* MEMP_NUM_TCP_PCB_LISTEN: the number of listening TCP
|
||||
connections. */ |
||||
#define MEMP_NUM_TCP_PCB_LISTEN 2 |
||||
|
||||
/* MEMP_NUM_TCP_SEG: the number of simultaneously queued TCP
|
||||
segments. */ |
||||
#define MEMP_NUM_TCP_SEG 32 |
||||
|
||||
/* MEMP_NUM_SYS_TIMEOUT: the number of simulateously active
|
||||
timeouts. */ |
||||
#define MEMP_NUM_SYS_TIMEOUT 8 |
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
/* The following four are used only with the sequential API and can be
|
||||
set to 0 if the application only will use the raw API. */ |
||||
//----------------------------------------------------------------------
|
||||
/* MEMP_NUM_NETBUF: the number of struct netbufs. */ |
||||
#define MEMP_NUM_NETBUF 32 |
||||
|
||||
/* MEMP_NUM_NETCONN: the number of struct netconns. */ |
||||
#define MEMP_NUM_NETCONN 32 |
||||
|
||||
/* MEMP_NUM_TCPIP_MSG: the number of struct tcpip_msg, which is used
|
||||
for sequential API communication and incoming packets. Used in |
||||
src/api/tcpip.c. */ |
||||
#define MEMP_NUM_TCPIP_MSG_API 32 |
||||
#define MEMP_NUM_TCPIP_MSG_INPKT 32 |
||||
|
||||
//----------------------------------------------------------------------
|
||||
/* ---------- Pbuf options ---------- */ |
||||
//----------------------------------------------------------------------
|
||||
/* PBUF_POOL_SIZE: the number of buffers in the pbuf pool. */ |
||||
#define PBUF_POOL_SIZE 16 |
||||
|
||||
/* PBUF_POOL_BUFSIZE: the size of each pbuf in the pbuf pool. */ |
||||
#define PBUF_POOL_BUFSIZE 1536 |
||||
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
/* ---------- ARP options ---------- */ |
||||
//----------------------------------------------------------------------
|
||||
/** Number of active hardware address, IP address pairs cached */ |
||||
#define ARP_TABLE_SIZE 10//10
|
||||
/**
|
||||
* If enabled, outgoing packets are queued during hardware address |
||||
* resolution. |
||||
* |
||||
* This feature has not stabilized yet. Single-packet queueing is |
||||
* believed to be stable, multi-packet queueing is believed to |
||||
* clash with the TCP segment queueing. |
||||
*
|
||||
* As multi-packet-queueing is currently disabled, enabling this |
||||
* _should_ work, but we need your testing feedback on lwip-users. |
||||
* |
||||
*/ |
||||
#define ARP_QUEUEING 0 |
||||
// if TCP was used, must disable this in v1.1.0 //millin
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
/* ---------- IP options ---------- */ |
||||
//----------------------------------------------------------------------
|
||||
/* Define IP_FORWARD to 1 if you wish to have the ability to forward
|
||||
IP packets across network interfaces. If you are going to run lwIP |
||||
on a device with only one network interface, define this to 0. */ |
||||
#define IP_FORWARD 0 |
||||
|
||||
/* If defined to 1, IP options are allowed (but not parsed). If
|
||||
defined to 0, all packets with IP options are dropped. */ |
||||
#define IP_OPTIONS 0 |
||||
|
||||
/** IP reassembly and segmentation. Even if they both deal with IP
|
||||
* fragments, note that these are orthogonal, one dealing with incoming |
||||
* packets, the other with outgoing packets |
||||
*/ |
||||
|
||||
/** Reassemble incoming fragmented IP packets */ |
||||
#define IP_REASSEMBLY 0 |
||||
|
||||
/** Fragment outgoing IP packets if their size exceeds MTU */ |
||||
#define IP_FRAG 0 |
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
/* ---------- DHCP options ---------- */ |
||||
//----------------------------------------------------------------------
|
||||
|
||||
/* Define LWIP_DHCP to 1 if you want DHCP configuration of
|
||||
interfaces. DHCP is not implemented in lwIP 0.5.1, however, so |
||||
turning this on does currently not work. */ |
||||
#define LWIP_DHCP 0 |
||||
|
||||
/* 1 if you want to do an ARP check on the offered address
|
||||
(recommended). */ |
||||
#define DHCP_DOES_ARP_CHECK 1 |
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
/* ---------- UDP options ---------- */ |
||||
//----------------------------------------------------------------------
|
||||
#define LWIP_UDP 1 |
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
/* ---------- TCP options ---------- */ |
||||
//----------------------------------------------------------------------
|
||||
#define LWIP_TCP 1 |
||||
|
||||
/* TCP receive window. */ |
||||
#define TCP_WND 32768 |
||||
|
||||
/* Maximum number of retransmissions of data segments. */ |
||||
#define TCP_MAXRTX 4 |
||||
|
||||
/* Maximum number of retransmissions of SYN segments. */ |
||||
#define TCP_SYNMAXRTX 4 |
||||
|
||||
/* Controls if TCP should queue segments that arrive out of
|
||||
order. Define to 0 if your device is low on memory. */ |
||||
#define TCP_QUEUE_OOSEQ 1 |
||||
|
||||
/* TCP Maximum segment size. */ |
||||
#define TCP_MSS 1476 |
||||
|
||||
/* TCP sender buffer space (bytes). */ |
||||
#define TCP_SND_BUF 32768 |
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
/* ---------- Other options ---------- */ |
||||
//----------------------------------------------------------------------
|
||||
|
||||
/* Support loop interface (127.0.0.1) */ |
||||
#define LWIP_HAVE_LOOPIF 0 |
||||
|
||||
#define LWIP_COMPAT_SOCKETS 1 |
||||
|
||||
// for uC/OS-II port on TI DSP
|
||||
#define TCPIP_THREAD_PRIO 5 //millin
|
||||
//#define SLIPIF_THREAD_PRIO 1
|
||||
//#define PPP_THREAD_PRIO 1
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
/* ---------- Socket Options ---------- */ |
||||
//----------------------------------------------------------------------
|
||||
|
||||
/* Enable SO_REUSEADDR and SO_REUSEPORT options */
|
||||
#define SO_REUSE 0 |
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
/* ---------- Statistics options ---------- */ |
||||
//----------------------------------------------------------------------
|
||||
|
||||
#define STATS 0 |
||||
|
||||
#if LWIP_STATS |
||||
|
||||
#define LWIP_STATS_DISPLAY 1 |
||||
#define LINK_STATS 1 |
||||
#define IP_STATS 1 |
||||
#define IPFRAG_STATS 1 |
||||
#define ICMP_STATS 1 |
||||
#define UDP_STATS 1 |
||||
#define TCP_STATS 1 |
||||
#define MEM_STATS 1 |
||||
#define MEMP_STATS 1 |
||||
#define PBUF_STATS 1 |
||||
#define SYS_STATS 1 |
||||
#endif /* STATS */ |
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
/* ------------if you need to do debug-------------*/ |
||||
//----------------------------------------------------------------------
|
||||
/*
|
||||
define LWIP_DEBUG in compiler and following... |
||||
*/ |
||||
#define LWIP_DBG_MIN_LEVEL LWIP_DBG_LEVEL_SERIOUS |
||||
//LWIP_DBG_LEVEL_WARNING LWIP_DBG_LEVEL_SERIOUS LWIP_DBG_LEVEL_SEVERE
|
||||
|
||||
#define LWIP_DBG_TYPES_ON 0//LWIP_DBG_TRACE | LWIP_DBG_STATE |LWIP_DBG_FRESH | LWIP_DBG_HALT
|
||||
/*
|
||||
Then, define debug class in opt.h |
||||
* --------------------------------------------------*/ |
||||
|
||||
#define ETHARP_DEBUG LWIP_DBG_OFF |
||||
#define NETIF_DEBUG LWIP_DBG_OFF |
||||
#define PBUF_DEBUG LWIP_DBG_OFF |
||||
#define API_LIB_DEBUG LWIP_DBG_OFF |
||||
#define API_MSG_DEBUG LWIP_DBG_OFF |
||||
#define SOCKETS_DEBUG LWIP_DBG_OFF |
||||
#define ICMP_DEBUG LWIP_DBG_OFF |
||||
#define INET_DEBUG LWIP_DBG_OFF |
||||
#define IP_DEBUG LWIP_DBG_OFF |
||||
#define IP_REASS_DEBUG LWIP_DBG_OFF |
||||
#define RAW_DEBUG LWIP_DBG_OFF |
||||
#define MEM_DEBUG LWIP_DBG_OFF |
||||
#define MEMP_DEBUG LWIP_DBG_OFF |
||||
#define SYS_DEBUG LWIP_DBG_OFF |
||||
#define TCP_DEBUG LWIP_DBG_OFF |
||||
#define TCP_INPUT_DEBUG LWIP_DBG_OFF |
||||
#define TCP_FR_DEBUG LWIP_DBG_OFF |
||||
#define TCP_RTO_DEBUG LWIP_DBG_OFF |
||||
#define TCP_CWND_DEBUG LWIP_DBG_OFF |
||||
#define TCP_WND_DEBUG LWIP_DBG_OFF |
||||
#define TCP_OUTPUT_DEBUG LWIP_DBG_OFF |
||||
#define TCP_RST_DEBUG LWIP_DBG_OFF |
||||
#define TCP_QLEN_DEBUG LWIP_DBG_OFF |
||||
#define UDP_DEBUG LWIP_DBG_OFF |
||||
#define TCPIP_DEBUG LWIP_DBG_OFF |
||||
#define PPP_DEBUG LWIP_DBG_OFF |
||||
#define SLIP_DEBUG LWIP_DBG_OFF |
||||
#define DHCP_DEBUG LWIP_DBG_OFF |
||||
|
||||
|
||||
#endif /* __LWIPOPTS_H__ */ |
||||
@ -1,223 +0,0 @@
|
||||
/*
|
||||
********************************************************************************************************* |
||||
* lwIP TCP/IP Stack |
||||
* port for uC/OS-II RTOS on TIC6711 DSK |
||||
* |
||||
* File : sys_arch.c |
||||
* By : ZengMing @ DEP,Tsinghua University,Beijing,China |
||||
* Reference: YangYe's source code for SkyEye project |
||||
********************************************************************************************************* |
||||
*/ |
||||
|
||||
//#include "lwip/debug.h"
|
||||
|
||||
#include "lwip/def.h" |
||||
#include "lwip/sys.h" |
||||
#include "lwip/mem.h" |
||||
|
||||
#include "arch/sys_arch.h" |
||||
|
||||
static OS_MEM *pQueueMem; |
||||
|
||||
const void * const pvNullPointer; |
||||
|
||||
static char pcQueueMemoryPool[MAX_QUEUES * sizeof(TQ_DESCR) ]; |
||||
|
||||
struct sys_timeouts lwip_timeouts[LWIP_TASK_MAX+1]; |
||||
struct sys_timeouts null_timeouts; |
||||
|
||||
OS_STK LWIP_TASK_STK[LWIP_TASK_MAX+1][LWIP_STK_SIZE]; |
||||
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/ |
||||
/* This func should be called first in lwip task!
|
||||
* ------------------------------------------------- */ |
||||
void sys_init(void) |
||||
{ |
||||
u8_t i; |
||||
u8_t ucErr; |
||||
//init mem used by sys_mbox_t //use ucosII functions
|
||||
pQueueMem = OSMemCreate( (void*)pcQueueMemoryPool, MAX_QUEUES, sizeof(TQ_DESCR), &ucErr ); |
||||
//init lwip_timeouts for every lwip task
|
||||
for(i=0;i<LWIP_TASK_MAX+1;i++){ |
||||
lwip_timeouts[i].next = NULL; |
||||
} |
||||
} |
||||
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/ |
||||
|
||||
sys_sem_t sys_sem_new(u8_t count) |
||||
{ |
||||
sys_sem_t pSem; |
||||
pSem = OSSemCreate((u16_t)count ); |
||||
return pSem; |
||||
} |
||||
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/ |
||||
|
||||
void sys_sem_free(sys_sem_t sem) |
||||
{ |
||||
u8_t ucErr; |
||||
(void)OSSemDel((OS_EVENT *)sem, OS_DEL_NO_PEND, &ucErr ); |
||||
} |
||||
|
||||
/*-----------------------------------------------------------------------------------*/ |
||||
|
||||
void sys_sem_signal(sys_sem_t sem) |
||||
{ |
||||
OSSemPost((OS_EVENT *)sem ); |
||||
} |
||||
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/ |
||||
|
||||
u32_t sys_arch_sem_wait(sys_sem_t sem, u32_t timeout) |
||||
{ |
||||
u8_t err; |
||||
u32_t ucos_timeout; |
||||
|
||||
ucos_timeout = 0; |
||||
if(timeout != 0){ |
||||
ucos_timeout = (timeout * OS_TICKS_PER_SEC) / 1000; |
||||
if(ucos_timeout < 1) |
||||
ucos_timeout = 1; |
||||
else if(ucos_timeout > 65535) //ucOS only support u16_t pend
|
||||
ucos_timeout = 65535; |
||||
} |
||||
|
||||
OSSemPend ((OS_EVENT *)sem,(u16_t)ucos_timeout, (u8_t *)&err); |
||||
|
||||
if(err == OS_TIMEOUT) |
||||
return 0; // only when timeout!
|
||||
else |
||||
return 1; |
||||
} |
||||
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/ |
||||
sys_mbox_t sys_mbox_new(void) |
||||
{ |
||||
u8_t ucErr; |
||||
PQ_DESCR pQDesc; |
||||
|
||||
pQDesc = OSMemGet( pQueueMem, &ucErr ); |
||||
if( ucErr == OS_NO_ERR ) {
|
||||
pQDesc->pQ = OSQCreate( &(pQDesc->pvQEntries[0]), MAX_QUEUE_ENTRIES );
|
||||
if( pQDesc->pQ != NULL ) { |
||||
return pQDesc; |
||||
} |
||||
}
|
||||
return SYS_MBOX_NULL; |
||||
} |
||||
|
||||
/*-----------------------------------------------------------------------------------*/ |
||||
void |
||||
sys_mbox_free(sys_mbox_t mbox) |
||||
{ |
||||
u8_t ucErr; |
||||
|
||||
//clear OSQ EVENT
|
||||
OSQFlush( mbox->pQ ); |
||||
//del OSQ EVENT
|
||||
(void)OSQDel( mbox->pQ, OS_DEL_NO_PEND, &ucErr); |
||||
//put mem back to mem queue
|
||||
ucErr = OSMemPut( pQueueMem, mbox ); |
||||
} |
||||
|
||||
/*-----------------------------------------------------------------------------------*/ |
||||
void |
||||
sys_mbox_post(sys_mbox_t mbox, void *msg) |
||||
{ |
||||
if( !msg )
|
||||
msg = (void*)&pvNullPointer; |
||||
(void)OSQPost( mbox->pQ, msg); |
||||
} |
||||
|
||||
/*-----------------------------------------------------------------------------------*/ |
||||
u32_t
|
||||
sys_arch_mbox_fetch(sys_mbox_t mbox, void **msg, u32_t timeout) |
||||
{ |
||||
u8_t ucErr; |
||||
u32_t ucos_timeout; |
||||
|
||||
ucos_timeout = 0; |
||||
if(timeout != 0){ |
||||
ucos_timeout = (timeout * OS_TICKS_PER_SEC)/1000; |
||||
if(ucos_timeout < 1) |
||||
ucos_timeout = 1; |
||||
else if(ucos_timeout > 65535) //ucOS only support u16_t timeout
|
||||
ucos_timeout = 65535; |
||||
}
|
||||
|
||||
if(msg != NULL){ |
||||
*msg = OSQPend( mbox->pQ, (u16_t)ucos_timeout, &ucErr );
|
||||
}else{ |
||||
//just discard return value if msg==NULL
|
||||
OSQPend(mbox->pQ,(u16_t)ucos_timeout,&ucErr); |
||||
} |
||||
|
||||
if( ucErr == OS_TIMEOUT ) { |
||||
timeout = 0; |
||||
} else { |
||||
if(*msg == (void*)&pvNullPointer )
|
||||
*msg = NULL; |
||||
timeout = 1; |
||||
} |
||||
|
||||
return timeout; |
||||
} |
||||
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------*/ |
||||
struct
|
||||
sys_timeouts * sys_arch_timeouts(void) |
||||
{ |
||||
u8_t curr_prio; |
||||
s16_t offset; |
||||
|
||||
OS_TCB curr_task_pcb; |
||||
|
||||
null_timeouts.next = NULL; |
||||
|
||||
OSTaskQuery(OS_PRIO_SELF,&curr_task_pcb); |
||||
curr_prio = curr_task_pcb.OSTCBPrio; |
||||
|
||||
offset = curr_prio - LWIP_START_PRIO; |
||||
|
||||
if(curr_prio == TCPIP_THREAD_PRIO)
|
||||
return &lwip_timeouts[LWIP_TASK_MAX]; |
||||
else if(offset >= 0 && offset < LWIP_TASK_MAX) |
||||
return &lwip_timeouts[offset]; |
||||
else return &null_timeouts; |
||||
|
||||
//if not called by a lwip task ,return timeouts->NULL
|
||||
} |
||||
|
||||
|
||||
/*------------------------------------------------------------------------*/ |
||||
sys_thread_t sys_thread_new(char *name, void (* thread)(void *arg), void *arg, int stacksize, int prio) |
||||
{ |
||||
/** @todo Replace LWIP_TASK_STK by the use of "stacksize" parameter */ |
||||
if(prio == TCPIP_THREAD_PRIO){ |
||||
OSTaskCreate(thread, (void *)0x1111, &LWIP_TASK_STK[LWIP_TASK_MAX][LWIP_STK_SIZE-1], prio); |
||||
return prio; |
||||
}
|
||||
else if(prio - LWIP_START_PRIO < LWIP_TASK_MAX){
|
||||
OSTaskCreate(thread, (void *)0x1111, &LWIP_TASK_STK[prio - LWIP_START_PRIO][LWIP_STK_SIZE-1], prio); |
||||
return prio; |
||||
} |
||||
else { |
||||
printf(" lwip task prio out of range ! error! "); |
||||
return 0; |
||||
} |
||||
} |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -1,181 +0,0 @@
|
||||
###############################################################################
|
||||
# Copyright (c) 2001-2003 Swedish Institute of Computer Science.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Copyright (c) 2003 Xilinx, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright notice,
|
||||
# this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
# this list of conditions and the following disclaimer in the documentation
|
||||
# and/or other materials provided with the distribution.
|
||||
# 3. The name of the author may not be used to endorse or promote products
|
||||
# derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
||||
# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
# XILINX IS PROVIDING THIS DESIGN, CODE, OR INFORMATION "AS IS".
|
||||
# BY PROVIDING THIS DESIGN, CODE, OR INFORMATION AS ONE POSSIBLE
|
||||
# IMPLEMENTATION OF THIS FEATURE, APPLICATION OR STANDARD, XILINX
|
||||
# IS MAKING NO REPRESENTATION THAT THIS IMPLEMENTATION IS FREE FROM
|
||||
# ANY CLAIMS OF INFRINGEMENT, AND YOU ARE RESPONSIBLE FOR OBTAINING
|
||||
# ANY RIGHTS YOU MAY REQUIRE FOR YOUR IMPLEMENTATION. XILINX
|
||||
# EXPRESSLY DISCLAIMS ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
|
||||
# ADEQUACY OF THE IMPLEMENTATION, INCLUDING BUT NOT LIMITED TO ANY
|
||||
# WARRANTIES OR REPRESENTATIONS THAT THIS IMPLEMENTATION IS FREE
|
||||
# FROM CLAIMS OF INFRINGEMENT, IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
# AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
#
|
||||
# This file is part of the lwIP TCP/IP stack.
|
||||
#
|
||||
# Author: Chris Borrelli <Chris.Borrelli@xilinx.com>
|
||||
#
|
||||
###############################################################################
|
||||
|
||||
COMPILER=powerpc-eabi-gcc
|
||||
ARCHIVER=powerpc-eabi-ar
|
||||
ARFLAGS=rs
|
||||
CP=cp
|
||||
COMPILERFLAGS=-Wall -gdwarf
|
||||
#EXTRA_COMPILER_FLAGS = -DIPv4 -fpack-struct -msdata=eabi -mcpu=403
|
||||
EXTRA_COMPILER_FLAGS = -DIPv4 -msdata=eabi -mcpu=403
|
||||
LWIPDIR=../../../lwip/src
|
||||
LIB=liblwip4.a
|
||||
RELEASEDIR=../../../../../ppc405_i/lib
|
||||
INCLUDEDIR=../../../../../ppc405_i/include
|
||||
LEVEL=0
|
||||
|
||||
XLIBINCLUDEDIR=../../../../../ppc405_i/include
|
||||
|
||||
INCLUDES= \
|
||||
-I$(LWIPDIR)/include \
|
||||
-I$(LWIPDIR)/include/ipv4 \
|
||||
-I$(XLIBINCLUDEDIR) \
|
||||
-I./include \
|
||||
-I.
|
||||
|
||||
INCLUDEFILES=../../../lwip/src/include/ipv4/lwip \
|
||||
../../../lwip/src/include/lwip \
|
||||
../../../lwip/src/include/netif \
|
||||
./include/netif \
|
||||
./include/arch \
|
||||
./lwipopts.h
|
||||
|
||||
# COREFILES, CORE4FILES: The minimum set of files needed for lwIP.
|
||||
COREFILES=$(LWIPDIR)/core/mem.c \
|
||||
$(LWIPDIR)/core/memp.c \
|
||||
$(LWIPDIR)/core/netif.c \
|
||||
$(LWIPDIR)/core/pbuf.c \
|
||||
$(LWIPDIR)/core/stats.c \
|
||||
$(LWIPDIR)/core/sys.c \
|
||||
$(LWIPDIR)/core/tcp.c \
|
||||
$(LWIPDIR)/core/tcp_in.c \
|
||||
$(LWIPDIR)/core/tcp_out.c \
|
||||
$(LWIPDIR)/core/udp.c \
|
||||
|
||||
CORE4FILES=$(LWIPDIR)/core/ipv4/icmp.c \
|
||||
$(LWIPDIR)/core/ipv4/ip.c \
|
||||
$(LWIPDIR)/core/inet.c \
|
||||
$(LWIPDIR)/core/ipv4/ip_addr.c \
|
||||
$(LWIPDIR)/core/ipv4/ip_frag.c
|
||||
|
||||
# NETIFFILES: Files implementing various generic network interface functions.
|
||||
NETIFFILES=$(LWIPDIR)/netif/etharp.c
|
||||
|
||||
# ARCHFILES: Archiecture specific files.
|
||||
ARCHFILES=$(wildcard *.c \
|
||||
netif/*.c)
|
||||
|
||||
# LWIPFILES: All the above.
|
||||
LWIPFILES=$(COREFILES) $(CORE4FILES) $(NETIFFILES) $(ARCHFILES)
|
||||
LWIPFILESW=$(wildcard $(LWIPFILES))
|
||||
LWIPOBJS=$(notdir $(LWIPFILESW:.c=.o))
|
||||
|
||||
help: |
||||
@echo ""
|
||||
@echo "This Makefile generates a library for the v2pro port of lwIP."
|
||||
@echo ""
|
||||
@echo " Below are the targets:"
|
||||
@echo ""
|
||||
@echo " make libs"
|
||||
@echo " This is the target that will compile all lwIP files, and"
|
||||
@echo " build the library, $(LIB). The final library will be"
|
||||
@echo " copied to $(RELEASEDIR)."
|
||||
@echo ""
|
||||
@echo " make include"
|
||||
@echo " Copies the lwIP include files into the EDK directory,"
|
||||
@echo " $(INCLUDEDIR)"
|
||||
@echo ""
|
||||
@echo " make clean"
|
||||
@echo " Removes all object files and the $(LIB) library from"
|
||||
@echo " the local directory."
|
||||
@echo ""
|
||||
@echo " make depend"
|
||||
@echo " Generates the .depend file, which contains the"
|
||||
@echo " dependancies needed to compile each .c file. The"
|
||||
@echo " .depend file will be generated automatically for"
|
||||
@echo " other targets, so it is not nessessary to run"
|
||||
@echo " make depend."
|
||||
@echo ""
|
||||
|
||||
%.o: |
||||
@echo ""
|
||||
@echo "Building File: $@"
|
||||
@echo ""
|
||||
$(COMPILER) $(COMPILERFLAGS) $(EXTRA_COMPILER_FLAGS) $(INCLUDES) -c $(<:.o=.c)
|
||||
|
||||
all ipv4 libs: include $(LIB) |
||||
.PHONY: all ipv4 libs include help |
||||
|
||||
include: |
||||
@for i in $(INCLUDEFILES); do \
|
||||
echo ${CP} -r $$i ${INCLUDEDIR}; \
|
||||
${CP} -r $$i ${INCLUDEDIR}; \
|
||||
done
|
||||
|
||||
clean: |
||||
@echo ""
|
||||
@echo "Cleaning up..."
|
||||
@echo ""
|
||||
@rm -f *.o *.a .depend* core
|
||||
|
||||
depend dep: .depend |
||||
@exit
|
||||
|
||||
$(LIB): $(LWIPOBJS) |
||||
@echo ""
|
||||
@echo "Building lwIP Library, $@"
|
||||
$(ARCHIVER) $(ARFLAGS) $@ $?
|
||||
@cp $@ $(RELEASEDIR)/
|
||||
|
||||
.depend: $(LWIPFILES) $(APPFILES) |
||||
@echo ""
|
||||
@echo "Building dependancies..."
|
||||
$(COMPILER) $(COMPILERFLAGS) $(EXTRA_COMPILER_FLAGS) $(INCLUDES) \
|
||||
-MM $^ > .depend || rm -f .depend
|
||||
|
||||
ifneq ($(MAKECMDGOALS), clean) |
||||
ifneq ($(MAKECMDGOALS), depend) |
||||
ifneq ($(MAKECMDGOALS), dep) |
||||
ifneq ($(MAKECMDGOALS), ) |
||||
ifneq ($(MAKECMDGOALS), help) |
||||
-include .depend |
||||
endif |
||||
endif |
||||
endif |
||||
endif |
||||
endif |
||||
@ -1,60 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001-2003 Swedish Institute of Computer Science. |
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met: |
||||
* |
||||
* 1. Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, |
||||
* this list of conditions and the following disclaimer in the documentation |
||||
* and/or other materials provided with the distribution. |
||||
* 3. The name of the author may not be used to endorse or promote products |
||||
* derived from this software without specific prior written permission.
|
||||
* |
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
||||
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||
* |
||||
* This file is part of the lwIP TCP/IP stack. |
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se> |
||||
* |
||||
*/ |
||||
|
||||
#ifndef __ARCH_CC_H__ |
||||
#define __ARCH_CC_H__ |
||||
|
||||
#define BYTE_ORDER BIG_ENDIAN |
||||
|
||||
typedef unsigned char u8_t; |
||||
typedef signed char s8_t; |
||||
typedef unsigned short u16_t; |
||||
typedef signed short s16_t; |
||||
typedef unsigned long u32_t; |
||||
typedef signed long s32_t; |
||||
|
||||
typedef u32_t mem_ptr_t; |
||||
|
||||
#define U16_F "hu" |
||||
#define S16_F "hd" |
||||
#define X16_F "hx" |
||||
#define U32_F "lu" |
||||
#define S32_F "ld" |
||||
#define X32_F "lx" |
||||
|
||||
#define PACK_STRUCT_FIELD(x) x __attribute__((packed)) |
||||
#define PACK_STRUCT_STRUCT __attribute__((packed)) |
||||
#define PACK_STRUCT_BEGIN |
||||
#define PACK_STRUCT_END |
||||
|
||||
#endif /* __ARCH_CC_H__ */ |
||||
@ -1,39 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001-2003 Swedish Institute of Computer Science. |
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met: |
||||
* |
||||
* 1. Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, |
||||
* this list of conditions and the following disclaimer in the documentation |
||||
* and/or other materials provided with the distribution. |
||||
* 3. The name of the author may not be used to endorse or promote products |
||||
* derived from this software without specific prior written permission.
|
||||
* |
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
||||
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||
* |
||||
* This file is part of the lwIP TCP/IP stack. |
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se> |
||||
* |
||||
*/ |
||||
|
||||
#ifndef __ARCH_CPU_H__ |
||||
#define __ARCH_CPU_H__ |
||||
|
||||
#define BYTE_ORDER BIG_ENDIAN |
||||
|
||||
#endif /* __ARCH_CPU_H__ */ |
||||
@ -1,42 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001-2003 Swedish Institute of Computer Science. |
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met: |
||||
* |
||||
* 1. Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, |
||||
* this list of conditions and the following disclaimer in the documentation |
||||
* and/or other materials provided with the distribution. |
||||
* 3. The name of the author may not be used to endorse or promote products |
||||
* derived from this software without specific prior written permission.
|
||||
* |
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
||||
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||
* |
||||
* This file is part of the lwIP TCP/IP stack. |
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se> |
||||
* |
||||
*/ |
||||
|
||||
#ifndef __ARCH_PERF_H__ |
||||
#define __ARCH_PERF_H__ |
||||
|
||||
#define PERF_START /* null definition */ |
||||
#define PERF_STOP(x) /* null definition */ |
||||
|
||||
void perf_init(char *fname); |
||||
|
||||
#endif /* __ARCH_PERF_H__ */ |
||||
@ -1,39 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001-2003 Swedish Institute of Computer Science. |
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met: |
||||
* |
||||
* 1. Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, |
||||
* this list of conditions and the following disclaimer in the documentation |
||||
* and/or other materials provided with the distribution. |
||||
* 3. The name of the author may not be used to endorse or promote products |
||||
* derived from this software without specific prior written permission.
|
||||
* |
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
||||
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||
* |
||||
* This file is part of the lwIP TCP/IP stack. |
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se> |
||||
* |
||||
*/ |
||||
|
||||
#ifndef __SYS_XILINX_V2P_H__ |
||||
#define __SYS_XILINX_V2P_H__ |
||||
|
||||
#define SYS_MBOX_NULL 0 |
||||
|
||||
#endif /* __SYS_XILINX_V2P_H__ */ |
||||
@ -1,57 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2002, 2003 Xilinx, Inc. |
||||
* All rights reserved. |
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met: |
||||
* |
||||
* 1. Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, |
||||
* this list of conditions and the following disclaimer in the documentation |
||||
* and/or other materials provided with the distribution. |
||||
* 3. The name of the author may not be used to endorse or promote products |
||||
* derived from this software without specific prior written permission.
|
||||
* |
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
||||
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||
* |
||||
* This file is part of the lwIP TCP/IP stack. |
||||
*
|
||||
* Author: Chris Borrelli <chris.borrelli@xilinx.com> |
||||
* |
||||
*/ |
||||
|
||||
#ifndef __NETIF_XEMACIF_H__ |
||||
#define __NETIF_XEMACIF_H__ |
||||
|
||||
#include "lwip/netif.h" |
||||
#include "netif/etharp.h" |
||||
#include "xemac.h" |
||||
|
||||
void xemacif_setmac(u32_t index, u8_t *addr); |
||||
u8_t * xemacif_getmac(u32_t index); |
||||
err_t xemacif_init(struct netif *netif); |
||||
err_t xemacif_input(void *CallBackRef); |
||||
|
||||
/**
|
||||
* This typedef contains configuration information for an xemac instance. |
||||
*/ |
||||
typedef struct |
||||
{ |
||||
Xuint32 DevId; |
||||
Xuint32 IntrId; |
||||
struct eth_addr ethaddr; |
||||
XEmac* instance_ptr; |
||||
} XEmacIf_Config; |
||||
|
||||
#endif /* __NETIF_XEMACIF_H__ */ |
||||
@ -1,33 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001-2003 Swedish Institute of Computer Science. |
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met: |
||||
* |
||||
* 1. Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, |
||||
* this list of conditions and the following disclaimer in the documentation |
||||
* and/or other materials provided with the distribution. |
||||
* 3. The name of the author may not be used to endorse or promote products |
||||
* derived from this software without specific prior written permission.
|
||||
* |
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
||||
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||
* |
||||
* This file is part of the lwIP TCP/IP stack. |
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se> |
||||
* |
||||
*/ |
||||
|
||||
@ -1,177 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2002 Swedish Institute of Computer Science. |
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met: |
||||
* |
||||
* 1. Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, |
||||
* this list of conditions and the following disclaimer in the documentation |
||||
* and/or other materials provided with the distribution. |
||||
* 3. The name of the author may not be used to endorse or promote products |
||||
* derived from this software without specific prior written permission.
|
||||
* |
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE. |
||||
* |
||||
* This file is part of the lwIP TCP/IP stack. |
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se> |
||||
* |
||||
*/ |
||||
|
||||
#ifndef __LWIPOPTS_H__ |
||||
#define __LWIPOPTS_H__ |
||||
|
||||
#define NO_SYS 1 |
||||
#define LWIP_CALLBACK_API 1 |
||||
|
||||
/* -------- TCP Timer Intervals ------- */ |
||||
#define TCP_TMR_INTERVAL 1 /* The TCP timer interval in |
||||
milliseconds. */ |
||||
|
||||
#define TCP_FAST_INTERVAL 2 /* the fine grained timeout in |
||||
milliseconds */ |
||||
|
||||
#define TCP_SLOW_INTERVAL 5 /* the coarse grained timeout in |
||||
milliseconds */ |
||||
|
||||
/* ---------- Memory options ---------- */ |
||||
/* MEM_ALIGNMENT: should be set to the alignment of the CPU for which
|
||||
lwIP is compiled. 4 byte alignment -> define MEM_ALIGNMENT to 4, 2 |
||||
byte alignment -> define MEM_ALIGNMENT to 2. */ |
||||
#define MEM_ALIGNMENT 4 |
||||
|
||||
/* MEM_SIZE: the size of the heap memory. If the application will send
|
||||
a lot of data that needs to be copied, this should be set high. */ |
||||
#define MEM_SIZE 8 * 1024 * 1024 |
||||
|
||||
/* MEMP_NUM_PBUF: the number of memp struct pbufs. If the application
|
||||
sends a lot of data out of ROM (or other static memory), this |
||||
should be set high. */ |
||||
#define MEMP_NUM_PBUF 64 |
||||
/* MEMP_NUM_UDP_PCB: the number of UDP protocol control blocks. One
|
||||
per active UDP "connection". */ |
||||
#define MEMP_NUM_UDP_PCB 1 |
||||
/* MEMP_NUM_TCP_PCB: the number of simulatenously active TCP
|
||||
connections. */ |
||||
#define MEMP_NUM_TCP_PCB 8 |
||||
/* MEMP_NUM_TCP_PCB_LISTEN: the number of listening TCP
|
||||
connections. */ |
||||
#define MEMP_NUM_TCP_PCB_LISTEN 16 |
||||
/* MEMP_NUM_TCP_SEG: the number of simultaneously queued TCP
|
||||
segments. */ |
||||
#define MEMP_NUM_TCP_SEG 255 |
||||
|
||||
/* The following four are used only with the sequential API and can be
|
||||
set to 0 if the application only will use the raw API. */ |
||||
/* MEMP_NUM_NETBUF: the number of struct netbufs. */ |
||||
#define MEMP_NUM_NETBUF 0 |
||||
/* MEMP_NUM_NETCONN: the number of struct netconns. */ |
||||
#define MEMP_NUM_NETCONN 0 |
||||
/* MEMP_NUM_TCPIP_MSG: the number of struct tcpip_msg, which is used
|
||||
for sequential API communication and incoming packets. Used in |
||||
src/api/tcpip.c. */ |
||||
#define MEMP_NUM_TCPIP_MSG_API 0 |
||||
#define MEMP_NUM_TCPIP_MSG_INPKT 0 |
||||
/* MEMP_NUM_SYS_TIMEOUT: the number of simulateously active
|
||||
timeouts. */ |
||||
#define MEMP_NUM_SYS_TIMEOUT 0 |
||||
|
||||
/* ---------- Pbuf options ---------- */ |
||||
/* PBUF_POOL_SIZE: the number of buffers in the pbuf pool. */ |
||||
#define PBUF_POOL_SIZE 512 |
||||
|
||||
/* PBUF_POOL_BUFSIZE: the size of each pbuf in the pbuf pool. */ |
||||
#define PBUF_POOL_BUFSIZE 1536 |
||||
|
||||
/* PBUF_LINK_HLEN: the number of bytes that should be allocated for a
|
||||
link level header. */ |
||||
#define PBUF_LINK_HLEN 16 |
||||
|
||||
/* ---------- TCP options ---------- */ |
||||
#define LWIP_TCP 1 |
||||
#define TCP_TTL 255 |
||||
|
||||
/* Controls if TCP should queue segments that arrive out of
|
||||
order. Define to 0 if your device is low on memory. */ |
||||
#define TCP_QUEUE_OOSEQ 1 |
||||
|
||||
/* TCP Maximum segment size. */ |
||||
#define TCP_MSS 1476 |
||||
|
||||
/* TCP sender buffer space (bytes). */ |
||||
#define TCP_SND_BUF 32 * 1024 |
||||
|
||||
/* TCP sender buffer space (pbufs). This must be at least = 2 *
|
||||
TCP_SND_BUF/TCP_MSS for things to work. */ |
||||
#define TCP_SND_QUEUELEN 2 * TCP_SND_BUF/TCP_MSS |
||||
|
||||
/* TCP receive window. */ |
||||
#define TCP_WND 16 * 1024 |
||||
|
||||
/* Maximum number of retransmissions of data segments. */ |
||||
#define TCP_MAXRTX 12 |
||||
|
||||
/* Maximum number of retransmissions of SYN segments. */ |
||||
#define TCP_SYNMAXRTX 4 |
||||
|
||||
/* ---------- ARP options ---------- */ |
||||
#define ARP_TABLE_SIZE 10 |
||||
#define ARP_QUEUEING 1 |
||||
|
||||
/* ---------- IP options ---------- */ |
||||
/* Define IP_FORWARD to 1 if you wish to have the ability to forward
|
||||
IP packets across network interfaces. If you are going to run lwIP |
||||
on a device with only one network interface, define this to 0. */ |
||||
#define IP_FORWARD 0 |
||||
|
||||
/* If defined to 1, IP options are allowed (but not parsed). If
|
||||
defined to 0, all packets with IP options are dropped. */ |
||||
#define IP_OPTIONS 1 |
||||
|
||||
/* ---------- ICMP options ---------- */ |
||||
#define ICMP_TTL 255 |
||||
|
||||
|
||||
/* ---------- DHCP options ---------- */ |
||||
/* Define LWIP_DHCP to 1 if you want DHCP configuration of
|
||||
interfaces. DHCP is not implemented in lwIP 0.5.1, however, so |
||||
turning this on does currently not work. */ |
||||
#define LWIP_DHCP 0 |
||||
|
||||
/* 1 if you want to do an ARP check on the offered address
|
||||
(recommended). */ |
||||
#define DHCP_DOES_ARP_CHECK 1 |
||||
|
||||
/* ---------- UDP options ---------- */ |
||||
#define LWIP_UDP 0 |
||||
#define UDP_TTL 255 |
||||
|
||||
|
||||
/* ---------- Statistics options ---------- */ |
||||
/*#define STATS*/ |
||||
|
||||
#ifdef STATS |
||||
#define LINK_STATS |
||||
#define IP_STATS |
||||
#define ICMP_STATS |
||||
#define UDP_STATS |
||||
#define TCP_STATS |
||||
#define MEM_STATS |
||||
#define MEMP_STATS |
||||
#define PBUF_STATS |
||||
#define SYS_STATS |
||||
#endif /* STATS */ |
||||
|
||||
#endif /* __LWIPOPTS_H__ */ |
||||
@ -1,388 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001-2003 Swedish Institute of Computer Science. |
||||
* All rights reserved.
|
||||
* |
||||
* Copyright (c) 2001, 2002, 2003 Xilinx, Inc. |
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met: |
||||
* |
||||
* 1. Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, |
||||
* this list of conditions and the following disclaimer in the documentation |
||||
* and/or other materials provided with the distribution. |
||||
* 3. The name of the author may not be used to endorse or promote products |
||||
* derived from this software without specific prior written permission.
|
||||
* |
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
||||
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||
* |
||||
* XILINX IS PROVIDING THIS DESIGN, CODE, OR INFORMATION "AS IS". |
||||
* BY PROVIDING THIS DESIGN, CODE, OR INFORMATION AS ONE POSSIBLE
|
||||
* IMPLEMENTATION OF THIS FEATURE, APPLICATION OR STANDARD, XILINX
|
||||
* IS MAKING NO REPRESENTATION THAT THIS IMPLEMENTATION IS FREE FROM
|
||||
* ANY CLAIMS OF INFRINGEMENT, AND YOU ARE RESPONSIBLE FOR OBTAINING
|
||||
* ANY RIGHTS YOU MAY REQUIRE FOR YOUR IMPLEMENTATION. XILINX
|
||||
* EXPRESSLY DISCLAIMS ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
|
||||
* ADEQUACY OF THE IMPLEMENTATION, INCLUDING BUT NOT LIMITED TO ANY
|
||||
* WARRANTIES OR REPRESENTATIONS THAT THIS IMPLEMENTATION IS FREE
|
||||
* FROM CLAIMS OF INFRINGEMENT, IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS FOR A PARTICULAR PURPOSE. |
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack. |
||||
*
|
||||
* Author: Chris Borrelli <chris.borrelli@xilinx.com> |
||||
*
|
||||
* Based on example ethernetif.c, Adam Dunkels <adam@sics.se> |
||||
* |
||||
*/ |
||||
|
||||
/*---------------------------------------------------------------------------*/ |
||||
/* EDK Include Files */ |
||||
/*---------------------------------------------------------------------------*/ |
||||
#include "xemac.h" |
||||
#include "xparameters.h" |
||||
#include "xstatus.h" |
||||
#include "xexception_l.h" |
||||
|
||||
/*---------------------------------------------------------------------------*/ |
||||
/* LWIP Include Files */ |
||||
/*---------------------------------------------------------------------------*/ |
||||
#include "lwip/debug.h" |
||||
#include "lwip/opt.h" |
||||
#include "lwip/def.h" |
||||
#include "lwip/mem.h" |
||||
#include "lwip/pbuf.h" |
||||
#include "lwip/stats.h" |
||||
#include "lwip/sys.h" |
||||
#include "lwip/netif.h" |
||||
#include "netif/etharp.h" |
||||
#include "netif/xemacif.h" |
||||
|
||||
/*---------------------------------------------------------------------------*/ |
||||
/* Describe network interface */ |
||||
/*---------------------------------------------------------------------------*/ |
||||
#define IFNAME0 'e' |
||||
#define IFNAME1 '0' |
||||
|
||||
/*---------------------------------------------------------------------------*/ |
||||
/* Constant Definitions */ |
||||
/*---------------------------------------------------------------------------*/ |
||||
#define XEM_MAX_FRAME_SIZE_IN_WORDS ((XEM_MAX_FRAME_SIZE/sizeof(Xuint32))+1) |
||||
|
||||
extern XEmacIf_Config XEmacIf_ConfigTable[]; |
||||
|
||||
/*---------------------------------------------------------------------------*/ |
||||
/* low_level_init function */ |
||||
/* - hooks up the data structures and sets the mac options and mac */ |
||||
/*---------------------------------------------------------------------------*/ |
||||
static err_t
|
||||
low_level_init(struct netif *netif_ptr) |
||||
{ |
||||
XEmac *InstancePtr = mem_malloc(sizeof(XEmac)); |
||||
XEmacIf_Config *xemacif_ptr = (XEmacIf_Config *) netif_ptr->state; |
||||
Xuint16 DeviceId = xemacif_ptr->DevId; |
||||
XStatus Result; |
||||
Xuint32 Options; |
||||
|
||||
xemacif_ptr->instance_ptr = InstancePtr; |
||||
|
||||
/* Call Initialize Function of EMAC driver */ |
||||
Result = XEmac_Initialize(InstancePtr, DeviceId); |
||||
if (Result != XST_SUCCESS) return ERR_MEM; |
||||
|
||||
/* Stop the EMAC hardware */ |
||||
XEmac_Stop(InstancePtr); |
||||
|
||||
/* Set MAC Address of EMAC */ |
||||
Result = XEmac_SetMacAddress(InstancePtr, (Xuint8*) netif_ptr->hwaddr); |
||||
if (Result != XST_SUCCESS) return ERR_MEM; |
||||
|
||||
/* Set MAC Options */ |
||||
|
||||
Options = ( XEM_INSERT_FCS_OPTION |
|
||||
XEM_INSERT_PAD_OPTION |
|
||||
XEM_UNICAST_OPTION |
|
||||
XEM_BROADCAST_OPTION |
|
||||
XEM_POLLED_OPTION | |
||||
XEM_STRIP_PAD_FCS_OPTION); |
||||
|
||||
Result = XEmac_SetOptions(InstancePtr, Options); |
||||
if (Result != XST_SUCCESS) return ERR_MEM; |
||||
|
||||
/* Start the EMAC hardware */ |
||||
Result = XEmac_Start(InstancePtr); |
||||
if (Result != XST_SUCCESS) return ERR_MEM; |
||||
|
||||
/* Clear driver stats */ |
||||
XEmac_ClearStats(InstancePtr); |
||||
|
||||
return ERR_OK; |
||||
} |
||||
|
||||
/*---------------------------------------------------------------------------*/ |
||||
/* low_level_output() */ |
||||
/* */ |
||||
/* Should do the actual transmission of the packet. The packet is */ |
||||
/* contained in the pbuf that is passed to the function. This pbuf */ |
||||
/* might be chained. */ |
||||
/*---------------------------------------------------------------------------*/ |
||||
static err_t low_level_output(struct netif *netif, struct pbuf *p) |
||||
{ |
||||
struct pbuf *q; |
||||
u32_t frame_buffer[XEM_MAX_FRAME_SIZE_IN_WORDS]; /* word aligned */ |
||||
Xuint8 *frame_ptr; |
||||
int payload_size = 0, i; |
||||
XStatus Result; |
||||
Xuint32 Options; |
||||
XEmacIf_Config *xemacif_ptr = netif->state; |
||||
|
||||
frame_ptr = (Xuint8 *) frame_buffer; |
||||
|
||||
for(q = p; q != NULL; q = q->next) { |
||||
/*
|
||||
* Send the data from the pbuf to the interface, one pbuf at a |
||||
* time. The size of the data in each pbuf is kept in the ->len |
||||
* variable. |
||||
*/ |
||||
for(i = 0 ; i < q->len ; i++) { |
||||
*(frame_ptr++) = (Xuint8) *(((u8_t *) q->payload) + i); |
||||
payload_size++; |
||||
} |
||||
} |
||||
|
||||
Result = XEmac_PollSend(xemacif_ptr->instance_ptr, |
||||
(Xuint8 *) frame_buffer, |
||||
payload_size); |
||||
|
||||
if (Result != XST_SUCCESS) |
||||
{ |
||||
xil_printf("XEmac_PollSend: failed\r\n"); |
||||
if (Result == XST_FIFO_ERROR) |
||||
{ |
||||
XEmac_Reset(xemacif_ptr->instance_ptr); |
||||
XEmac_SetMacAddress(xemacif_ptr->instance_ptr,
|
||||
(Xuint8*) xemacif_ptr->ethaddr.addr); |
||||
Options = ( XEM_INSERT_FCS_OPTION |
|
||||
XEM_INSERT_PAD_OPTION |
|
||||
XEM_UNICAST_OPTION |
|
||||
XEM_BROADCAST_OPTION |
|
||||
XEM_POLLED_OPTION |
|
||||
XEM_STRIP_PAD_FCS_OPTION); |
||||
XEmac_SetOptions(xemacif_ptr->instance_ptr, Options); |
||||
XEmac_Start(xemacif_ptr->instance_ptr); |
||||
xil_printf("XEmac_PollSend: returned XST_FIFO_ERROR\r\n"); |
||||
} |
||||
return ERR_MEM; |
||||
} |
||||
|
||||
#if 0 |
||||
xil_printf("\r\n\r\n TXFRAME:\r\n"); |
||||
for (i=0 ; i < payload_size ; i++) { |
||||
xil_printf("%2X", ((Xuint8 *) frame_buffer)[i]); |
||||
if (! (i%20) && i) xil_printf("\r\n"); |
||||
else xil_printf(" "); |
||||
} |
||||
xil_printf ("\r\n\r\n"); |
||||
#endif |
||||
|
||||
#ifdef LINK_STATS |
||||
lwip_stats.link.xmit++; |
||||
#endif /* LINK_STATS */ |
||||
|
||||
return ERR_OK; |
||||
} |
||||
|
||||
/*---------------------------------------------------------------------------*/ |
||||
/* low_level_input() */ |
||||
/* */ |
||||
/* Allocates a pbuf pool and transfers bytes of */ |
||||
/* incoming packet from the interface into the pbuf. */ |
||||
/*---------------------------------------------------------------------------*/ |
||||
static struct pbuf * low_level_input(XEmacIf_Config *xemacif_ptr) |
||||
{ |
||||
struct pbuf *p = NULL, *q = NULL; |
||||
XEmac *EmacPtr = (XEmac *) xemacif_ptr->instance_ptr; |
||||
|
||||
Xuint32 RecvBuffer[XEM_MAX_FRAME_SIZE_IN_WORDS]; |
||||
Xuint32 FrameLen = XEM_MAX_FRAME_SIZE; |
||||
Xuint32 i, Options; |
||||
u8_t * frame_bytes = (u8_t *) RecvBuffer; |
||||
XStatus Result; |
||||
|
||||
Result = XEmac_PollRecv(EmacPtr, (Xuint8 *)RecvBuffer, &FrameLen); |
||||
|
||||
if (Result != XST_SUCCESS) |
||||
{ |
||||
if (!(Result == XST_NO_DATA || Result == XST_BUFFER_TOO_SMALL)) |
||||
{ |
||||
XEmac_Reset(xemacif_ptr->instance_ptr); |
||||
XEmac_SetMacAddress(xemacif_ptr->instance_ptr,
|
||||
(Xuint8*) xemacif_ptr->ethaddr.addr); |
||||
Options = ( XEM_INSERT_FCS_OPTION |
|
||||
XEM_INSERT_PAD_OPTION |
|
||||
XEM_UNICAST_OPTION |
|
||||
XEM_BROADCAST_OPTION |
|
||||
XEM_POLLED_OPTION |
|
||||
XEM_STRIP_PAD_FCS_OPTION); |
||||
XEmac_SetOptions(xemacif_ptr->instance_ptr, Options); |
||||
XEmac_Start(xemacif_ptr->instance_ptr); |
||||
} |
||||
return p; |
||||
} |
||||
|
||||
#if 0 |
||||
xil_printf("\r\n"); |
||||
for (i=0 ; i < FrameLen ; i++) { |
||||
xil_printf("%2X", frame_bytes[i]); |
||||
if (! (i%20) && i) xil_printf("\r\n"); |
||||
else xil_printf(" "); |
||||
} |
||||
xil_printf ("\r\n"); |
||||
#endif |
||||
|
||||
/* Allocate a pbuf chain of pbufs from the pool. */ |
||||
p = pbuf_alloc(PBUF_RAW, FrameLen, PBUF_POOL); |
||||
|
||||
if (p != NULL) { |
||||
/* Iterate over the pbuf chain until we have
|
||||
* read the entire packet into the pbuf. */ |
||||
for(q = p; q != NULL; q = q->next) { |
||||
/* Read enough bytes to fill this pbuf
|
||||
* in the chain. The available data in
|
||||
* the pbuf is given by the q->len variable. */ |
||||
for (i = 0 ; i < q->len ; i++) { |
||||
((u8_t *)q->payload)[i] = *(frame_bytes++); |
||||
} |
||||
} |
||||
|
||||
#ifdef LINK_STATS |
||||
lwip_stats.link.recv++; |
||||
#endif /* LINK_STATS */ |
||||
|
||||
} else { |
||||
|
||||
#ifdef LINK_STATS |
||||
lwip_stats.link.memerr++; |
||||
lwip_stats.link.drop++; |
||||
#endif /* LINK_STATS */ |
||||
; |
||||
} |
||||
return p;
|
||||
} |
||||
|
||||
/*---------------------------------------------------------------------------*/ |
||||
/* xemacif_input(): */ |
||||
/* */ |
||||
/* This function should be called when a packet is ready to be read */ |
||||
/* from the interface. It uses the function low_level_input() that */ |
||||
/* should handle the actual reception of bytes from the network */ |
||||
/* interface. */ |
||||
/*---------------------------------------------------------------------------*/ |
||||
err_t xemacif_input(void *CallBackRef) |
||||
{ |
||||
struct netif * netif_ptr = (struct netif *) CallBackRef; |
||||
XEmacIf_Config * xemacif_ptr; |
||||
struct eth_hdr * ethernet_header; |
||||
struct pbuf *p; |
||||
|
||||
xemacif_ptr = netif_ptr->state; |
||||
|
||||
p = low_level_input(xemacif_ptr); |
||||
|
||||
if (p != NULL) { |
||||
ethernet_header = p->payload; |
||||
|
||||
q = NULL; |
||||
switch (htons(ethernet_header->type)) { |
||||
case ETHTYPE_IP: |
||||
etharp_ip_input(netif_ptr, p); |
||||
pbuf_header(p, -14); |
||||
netif_ptr->input(p, netif_ptr); |
||||
break; |
||||
case ETHTYPE_ARP: |
||||
etharp_arp_input(netif_ptr, &(xemacif_ptr->ethaddr), p); |
||||
break; |
||||
default: |
||||
pbuf_free(p); |
||||
break; |
||||
} |
||||
} |
||||
|
||||
return ERR_OK; |
||||
} |
||||
|
||||
/*---------------------------------------------------------------------------*/ |
||||
/* xemacif_setmac(): */ |
||||
/* */ |
||||
/* Sets the MAC address of the system. */ |
||||
/* Note: Should only be called before xemacif_init is called. */ |
||||
/* - the stack calls xemacif_init after the user calls netif_add */ |
||||
/*---------------------------------------------------------------------------*/ |
||||
void xemacif_setmac(u32_t index, u8_t *addr) |
||||
{ |
||||
XEmacIf_ConfigTable[index].ethaddr.addr[0] = addr[0]; |
||||
XEmacIf_ConfigTable[index].ethaddr.addr[1] = addr[1]; |
||||
XEmacIf_ConfigTable[index].ethaddr.addr[2] = addr[2]; |
||||
XEmacIf_ConfigTable[index].ethaddr.addr[3] = addr[3]; |
||||
XEmacIf_ConfigTable[index].ethaddr.addr[4] = addr[4]; |
||||
XEmacIf_ConfigTable[index].ethaddr.addr[5] = addr[5]; |
||||
} |
||||
|
||||
/*---------------------------------------------------------------------------*/ |
||||
/* xemacif_getmac(): */ |
||||
/* */ |
||||
/* Returns a pointer to the ethaddr variable in the ConfigTable */ |
||||
/* (6 bytes in length) */ |
||||
/*---------------------------------------------------------------------------*/ |
||||
u8_t * xemacif_getmac(u32_t index) { |
||||
return &(XEmacIf_ConfigTable[index].ethaddr.addr[0]); |
||||
} |
||||
|
||||
/*---------------------------------------------------------------------------*/ |
||||
/* xemacif_init(): */ |
||||
/* */ |
||||
/* Should be called at the beginning of the program to set up the */ |
||||
/* network interface. It calls the function low_level_init() to do the */ |
||||
/* actual setup of the hardware. */ |
||||
/*---------------------------------------------------------------------------*/ |
||||
err_t xemacif_init(struct netif *netif_ptr) |
||||
{ |
||||
XEmacIf_Config *xemacif_ptr; |
||||
|
||||
xemacif_ptr = (XEmacIf_Config *) netif_ptr->state; |
||||
|
||||
netif_ptr->mtu = 1500; |
||||
netif_ptr->hwaddr_len = 6; |
||||
netif_ptr->hwaddr[0] = xemacif_ptr->ethaddr.addr[0]; |
||||
netif_ptr->hwaddr[1] = xemacif_ptr->ethaddr.addr[1]; |
||||
netif_ptr->hwaddr[2] = xemacif_ptr->ethaddr.addr[2]; |
||||
netif_ptr->hwaddr[3] = xemacif_ptr->ethaddr.addr[3]; |
||||
netif_ptr->hwaddr[4] = xemacif_ptr->ethaddr.addr[4]; |
||||
netif_ptr->hwaddr[5] = xemacif_ptr->ethaddr.addr[5]; |
||||
netif_ptr->name[0] = IFNAME0; |
||||
netif_ptr->name[1] = IFNAME1; |
||||
netif_ptr->output = etharp_output; |
||||
netif_ptr->linkoutput = low_level_output; |
||||
|
||||
/* removed this statement because the ethaddr in the XEmacIf_Config
|
||||
* structure is now a struct not a pointer to a struct |
||||
*/ |
||||
//xemacif_ptr->ethaddr = (struct eth_addr *)&(netif_ptr->hwaddr[0]);
|
||||
|
||||
low_level_init(netif_ptr); |
||||
etharp_init(); |
||||
|
||||
return ERR_OK; |
||||
} |
||||
@ -1,40 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001-2003 Swedish Institute of Computer Science. |
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met: |
||||
* |
||||
* 1. Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, |
||||
* this list of conditions and the following disclaimer in the documentation |
||||
* and/or other materials provided with the distribution. |
||||
* 3. The name of the author may not be used to endorse or promote products |
||||
* derived from this software without specific prior written permission.
|
||||
* |
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE. |
||||
* |
||||
* This file is part of the lwIP TCP/IP stack. |
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se> |
||||
* |
||||
*/ |
||||
|
||||
#include "arch/perf.h" |
||||
|
||||
void |
||||
perf_init(char *fname) |
||||
{ |
||||
return;
|
||||
} |
||||
|
||||
@ -1,76 +0,0 @@
|
||||
############################################################################### |
||||
# Copyright (c) 2001-2003 Swedish Institute of Computer Science. |
||||
# All rights reserved. |
||||
# |
||||
# Copyright (c) 2003 Xilinx, Inc. |
||||
# All rights reserved. |
||||
# |
||||
# Redistribution and use in source and binary forms, with or without |
||||
# modification, are permitted provided that the following conditions |
||||
# are met: |
||||
# |
||||
# 1. Redistributions of source code must retain the above copyright notice, |
||||
# this list of conditions and the following disclaimer. |
||||
# 2. Redistributions in binary form must reproduce the above copyright notice, |
||||
# this list of conditions and the following disclaimer in the documentation |
||||
# and/or other materials provided with the distribution. |
||||
# 3. The name of the author may not be used to endorse or promote products |
||||
# derived from this software without specific prior written permission. |
||||
# |
||||
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED |
||||
# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
||||
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO |
||||
# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
||||
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; |
||||
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
||||
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR |
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||
# |
||||
# XILINX IS PROVIDING THIS DESIGN, CODE, OR INFORMATION "AS IS". |
||||
# BY PROVIDING THIS DESIGN, CODE, OR INFORMATION AS ONE POSSIBLE |
||||
# IMPLEMENTATION OF THIS FEATURE, APPLICATION OR STANDARD, XILINX |
||||
# IS MAKING NO REPRESENTATION THAT THIS IMPLEMENTATION IS FREE FROM |
||||
# ANY CLAIMS OF INFRINGEMENT, AND YOU ARE RESPONSIBLE FOR OBTAINING |
||||
# ANY RIGHTS YOU MAY REQUIRE FOR YOUR IMPLEMENTATION. XILINX |
||||
# EXPRESSLY DISCLAIMS ANY WARRANTY WHATSOEVER WITH RESPECT TO THE |
||||
# ADEQUACY OF THE IMPLEMENTATION, INCLUDING BUT NOT LIMITED TO ANY |
||||
# WARRANTIES OR REPRESENTATIONS THAT THIS IMPLEMENTATION IS FREE |
||||
# FROM CLAIMS OF INFRINGEMENT, IMPLIED WARRANTIES OF MERCHANTABILITY |
||||
# AND FITNESS FOR A PARTICULAR PURPOSE. |
||||
# |
||||
# This file is part of the lwIP TCP/IP stack. |
||||
# |
||||
# Author: Sathya Thammanur <Sathyanarayanan.Thammanur@xilinx.com> |
||||
# |
||||
############################################################################### |
||||
|
||||
OPTION psf_version = 2.1; |
||||
|
||||
BEGIN LIBRARY lwip |
||||
|
||||
OPTION drc = lwip_drc; |
||||
OPTION copyfiles = (Makefile); |
||||
|
||||
BEGIN ARRAY emac_instances |
||||
PROPERTY desc = "List of Ethernet instances to be used with lwip"; |
||||
PROPERTY size = 0; |
||||
PARAM name = emac_instname, desc = "Name of Emac instance", type = peripheral_instance; |
||||
PARAM name = eth_addr1, desc = "First byte of MAC address", type = int; |
||||
PARAM name = eth_addr2, desc = "Second byte of MAC address", type = int; |
||||
PARAM name = eth_addr3, desc = "Third byte of MAC address", type = int; |
||||
PARAM name = eth_addr4, desc = "Fourth byte of MAC address", type = int; |
||||
PARAM name = eth_addr5, desc = "Fifth byte of MAC address", type = int; |
||||
PARAM name = eth_addr6, desc = "Sixth byte of MAC address", type = int; |
||||
END ARRAY |
||||
|
||||
BEGIN ARRAY gemac_instances |
||||
PROPERTY desc = "List of Gigabit Ethernet instances to be used with lwip"; |
||||
PROPERTY size = 0; |
||||
PARAM name = gemac_instname, desc = "Name of GEmac instance", type = peripheral_instance; |
||||
END ARRAY |
||||
|
||||
PARAM name = lwip_srcdir, desc = "Source directory of lwip", type = string; |
||||
|
||||
END LIBRARY |
||||
@ -1,265 +0,0 @@
|
||||
############################################################################### |
||||
# Copyright (c) 2001-2003 Swedish Institute of Computer Science. |
||||
# All rights reserved. |
||||
# |
||||
# Copyright (c) 2003 Xilinx, Inc. |
||||
# All rights reserved. |
||||
# |
||||
# Redistribution and use in source and binary forms, with or without |
||||
# modification, are permitted provided that the following conditions |
||||
# are met: |
||||
# |
||||
# 1. Redistributions of source code must retain the above copyright notice, |
||||
# this list of conditions and the following disclaimer. |
||||
# 2. Redistributions in binary form must reproduce the above copyright notice, |
||||
# this list of conditions and the following disclaimer in the documentation |
||||
# and/or other materials provided with the distribution. |
||||
# 3. The name of the author may not be used to endorse or promote products |
||||
# derived from this software without specific prior written permission. |
||||
# |
||||
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED |
||||
# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
||||
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO |
||||
# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
||||
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; |
||||
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
||||
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR |
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||
# |
||||
# XILINX IS PROVIDING THIS DESIGN, CODE, OR INFORMATION "AS IS". |
||||
# BY PROVIDING THIS DESIGN, CODE, OR INFORMATION AS ONE POSSIBLE |
||||
# IMPLEMENTATION OF THIS FEATURE, APPLICATION OR STANDARD, XILINX |
||||
# IS MAKING NO REPRESENTATION THAT THIS IMPLEMENTATION IS FREE FROM |
||||
# ANY CLAIMS OF INFRINGEMENT, AND YOU ARE RESPONSIBLE FOR OBTAINING |
||||
# ANY RIGHTS YOU MAY REQUIRE FOR YOUR IMPLEMENTATION. XILINX |
||||
# EXPRESSLY DISCLAIMS ANY WARRANTY WHATSOEVER WITH RESPECT TO THE |
||||
# ADEQUACY OF THE IMPLEMENTATION, INCLUDING BUT NOT LIMITED TO ANY |
||||
# WARRANTIES OR REPRESENTATIONS THAT THIS IMPLEMENTATION IS FREE |
||||
# FROM CLAIMS OF INFRINGEMENT, IMPLIED WARRANTIES OF MERCHANTABILITY |
||||
# AND FITNESS FOR A PARTICULAR PURPOSE. |
||||
# |
||||
# This file is part of the lwIP TCP/IP stack. |
||||
# |
||||
# Author: Sathya Thammanur <Sathyanarayanan.Thammanur@xilinx.com> |
||||
# Author: Chris Borrelli <Chris.Borrelli@xilinx.com> |
||||
# |
||||
############################################################################### |
||||
|
||||
# Globals |
||||
lappend emac_list |
||||
lappend gemac_list |
||||
|
||||
############################################################################### |
||||
# lwip_drc - run drc checking (future work) |
||||
############################################################################### |
||||
proc lwip_drc {lib_handle} { |
||||
puts "LWIP DRC..." |
||||
puts " ...not implemented yet." |
||||
} |
||||
|
||||
############################################################################### |
||||
# generate - generates the .c file |
||||
############################################################################### |
||||
proc generate {libname} { |
||||
global emac_list |
||||
global gemac_list |
||||
|
||||
# generate emac_list of instances to be used with lwip |
||||
set emac_inst_array [xget_handle $libname "ARRAY" "emac_instances"] |
||||
if {[string compare -nocase $emac_inst_array ""] != 0} { |
||||
set emac_inst_array_elems [xget_handle $emac_inst_array "ELEMENTS" "*"] |
||||
puts "XEmac Instances : [llength $emac_inst_array_elems]" |
||||
if {[string compare -nocase $emac_inst_array_elems ""] != 0} { |
||||
set emac_list $emac_inst_array_elems |
||||
} |
||||
} |
||||
|
||||
# generate gemac_list of instances to be used with lwip |
||||
set gemac_inst_array [xget_handle $libname "ARRAY" "gemac_instances"] |
||||
if {[string compare -nocase $gemac_inst_array ""] != 0} { |
||||
set gemac_inst_array_elems [xget_handle $gemac_inst_array "ELEMENTS" "*"] |
||||
puts "XGEmac Instances : [llength $gemac_inst_array_elems]" |
||||
if {[string compare -nocase $gemac_inst_array_elems ""] != 0} { |
||||
set gemac_list $gemac_inst_array_elems |
||||
} |
||||
} |
||||
|
||||
# Generate XEmacIf_Config Table in xemacif_g.c file |
||||
if {[string compare -nocase $emac_list ""] != 0} { |
||||
xgen_config_file "xemacif_g.c" "XEmacIf" |
||||
} |
||||
|
||||
# Generate XGEmacIf_Config Table in xgemacif_g.c file |
||||
if {[string compare -nocase $gemac_list ""] != 0} { |
||||
xgen_config_file "xgemacif_g.c" "XGEmacIf" |
||||
} |
||||
} |
||||
|
||||
############################################################################### |
||||
# xgen_config_file - does the real work of generating a C header file |
||||
############################################################################### |
||||
proc xgen_config_file {file_name if_type} { |
||||
global emac_list |
||||
global gemac_list |
||||
|
||||
lappend list |
||||
|
||||
puts "Generating $file_name ..." |
||||
|
||||
set config_file [open [file join "src" $file_name] w] |
||||
xprint_generated_header $config_file "$if_type Configuration" |
||||
|
||||
puts $config_file "#include \"xparameters.h\"" |
||||
set if_file [file join "netif" [format "%s.h" [string tolower $if_type]]] |
||||
puts $config_file "#include \"$if_file\"" |
||||
|
||||
if {[string compare -nocase $if_type "XEmacIf"] == 0} { |
||||
puts $config_file "#include \"xemac.h\"" |
||||
set list $emac_list |
||||
} elseif {[string compare -nocase $if_type "XGEmacIf"] == 0} { |
||||
puts $config_file "#include \"xgemac.h\"" |
||||
set list $gemac_list |
||||
} |
||||
|
||||
#set list_size [llength $list] |
||||
#puts $config_file "\n/*" |
||||
#puts $config_file " * Number of $if_type Instances" |
||||
#puts $config_file " */\n" |
||||
#puts $config_file [format "#define %s_ConfigTableSize %s" $if_type $list_size] |
||||
|
||||
puts $config_file "\n/*" |
||||
puts $config_file " * The configuration table for devices" |
||||
puts $config_file " */\n" |
||||
puts $config_file [format "%s_Config %s_ConfigTable\[\] =" $if_type $if_type] |
||||
puts $config_file "\{" |
||||
|
||||
set start_comma "" |
||||
|
||||
foreach elem $list { |
||||
puts $config_file [format "%s\t\{" $start_comma] |
||||
set comma "" |
||||
|
||||
if {[string compare -nocase $if_type "XEmacIf"] == 0} { |
||||
set inst [xget_value $elem "PARAMETER" "emac_instname"] |
||||
set ethaddr1 [xget_value $elem "PARAMETER" "eth_addr1"] |
||||
set ethaddr2 [xget_value $elem "PARAMETER" "eth_addr2"] |
||||
set ethaddr3 [xget_value $elem "PARAMETER" "eth_addr3"] |
||||
set ethaddr4 [xget_value $elem "PARAMETER" "eth_addr4"] |
||||
set ethaddr5 [xget_value $elem "PARAMETER" "eth_addr5"] |
||||
set ethaddr6 [xget_value $elem "PARAMETER" "eth_addr6"] |
||||
} elseif {[string compare -nocase $if_type "XGEmacIf"] == 0} { |
||||
set inst [xget_value $elem "PARAMETER" "emac_instname"] |
||||
set ethaddr1 "" |
||||
set ethaddr2 "" |
||||
set ethaddr3 "" |
||||
set ethaddr4 "" |
||||
set ethaddr5 "" |
||||
set ethaddr6 "" |
||||
} |
||||
|
||||
# Get the instance handle - |
||||
# for example, get pointer to an instance named my_opb_ethernet |
||||
# Get the handle to the interrupt port -ip2intc_irpt |
||||
# (same name in emac and gemac) |
||||
set inst_handle [xget_hwhandle $inst] |
||||
set intr_port_name "IP2INTC_Irpt" |
||||
|
||||
######################################################################## |
||||
# generate device id |
||||
######################################################################## |
||||
puts -nonewline $config_file [format "%s\t\t%s" $comma [xget_name $inst_handle "DEVICE_ID"]] |
||||
set comma ",\n" |
||||
|
||||
######################################################################## |
||||
# generate intr id - doesn't work in EDK 3.2.2 |
||||
######################################################################## |
||||
|
||||
# START : CHRISB COMMENTED THIS OUT |
||||
#set intr_id [xget_intr_name $inst_handle $intr_port_name] |
||||
#puts -nonewline $config_file [format "%s\t\t%s" $comma $intr_id] |
||||
# END : CHRISB COMMENTED THIS OUT |
||||
|
||||
# START : CHRISB ADDED THIS |
||||
puts -nonewline $config_file [format "%s\t\t%s" $comma "0"] |
||||
# END : CHRISB ADDED THIS |
||||
|
||||
######################################################################## |
||||
# generate ethaddr |
||||
######################################################################## |
||||
puts -nonewline $config_file [format "%s\t\t{{%s,%s,%s,%s,%s,%s}}" $comma $ethaddr1 $ethaddr2 $ethaddr3 $ethaddr4 $ethaddr5 $ethaddr6] |
||||
|
||||
######################################################################## |
||||
# generate instance ptr - always NULL because it is setup at runtime |
||||
######################################################################## |
||||
puts -nonewline $config_file [format "%s\t\tNULL" $comma ] |
||||
|
||||
puts -nonewline $config_file [format "\n\t\}" ] |
||||
set start_comma ",\n" |
||||
} |
||||
|
||||
puts $config_file "\n\};" |
||||
close $config_file |
||||
} |
||||
|
||||
############################################################################### |
||||
# This procedure does not work under EDK 3.2.2 |
||||
############################################################################### |
||||
#proc xget_intr_name {periph_handle port_name} { |
||||
# |
||||
# set intr_port [xget_handle $periph_handle "PORT" $port_name] |
||||
# set intr_signal [xget_value $intr_port "VALUE"] |
||||
# #puts "intr_signal : $intr_signal" |
||||
# |
||||
# set mhs_handle [xget_handle $periph_handle "parent"] |
||||
# set source_port [xget_connected_ports_handle $mhs_handle $intr_signal "sink"] |
||||
# #puts "sourceport : $source_port" |
||||
# |
||||
# set intc_handle [xget_handle $source_port "parent"] |
||||
# set intc_name [xget_value $intc_handle "NAME"] |
||||
# |
||||
# set periph_name [xget_value $periph_handle "NAME"] |
||||
# |
||||
# set intc_drvhandle [xget_swhandle $intc_name] |
||||
# #puts "intcdrvname: [xget_value $intc_drvhandle "NAME"]" |
||||
# |
||||
# set level [xget_value $intc_drvhandle "PARAMETER" "level"] |
||||
# set intr_string "" |
||||
# if {$level == 0} { |
||||
# set intr_string "MASK" |
||||
# set retval [format "XPAR_%s_%s_%s" [string toupper $periph_name] [string toupper $port_name] [string toupper $intr_string]] |
||||
# } elseif {$level == 1} { |
||||
# set intr_string "INTR" |
||||
# set retval [format "XPAR_%s_%s_%s_%s" [string toupper $intc_name] [string toupper $periph_name] [string toupper $port_name] [string toupper $intr_string]] |
||||
# } |
||||
# |
||||
# return $retval |
||||
#} |
||||
|
||||
############################################################################### |
||||
# post_generate - doesn't do anything at the moment |
||||
############################################################################### |
||||
proc post_generate {libname} { |
||||
|
||||
} |
||||
|
||||
############################################################################### |
||||
# execs_generate |
||||
# This procedure builds the liblwipv4.a |
||||
# library. |
||||
############################################################################### |
||||
proc execs_generate {libname} { |
||||
global errorCode |
||||
global errorInfo |
||||
|
||||
set topdir [xget_value $libname "PARAMETER" "lwip_srcdir"] |
||||
puts "\n********************************" |
||||
puts " Building lwIP library" |
||||
puts "********************************\n" |
||||
puts "Using LWIP sources from directory $topdir " |
||||
|
||||
if { [catch {exec bash -c "cd src;make all \"TOPDIR=$topdir\" >& logs"} errmsg] } { |
||||
error $errmsg $errorInfo |
||||
} |
||||
} |
||||
@ -1,193 +0,0 @@
|
||||
###############################################################################
|
||||
# Copyright (c) 2001-2003 Swedish Institute of Computer Science.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Copyright (c) 2003 Xilinx, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright notice,
|
||||
# this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
# this list of conditions and the following disclaimer in the documentation
|
||||
# and/or other materials provided with the distribution.
|
||||
# 3. The name of the author may not be used to endorse or promote products
|
||||
# derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
||||
# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
# XILINX IS PROVIDING THIS DESIGN, CODE, OR INFORMATION "AS IS".
|
||||
# BY PROVIDING THIS DESIGN, CODE, OR INFORMATION AS ONE POSSIBLE
|
||||
# IMPLEMENTATION OF THIS FEATURE, APPLICATION OR STANDARD, XILINX
|
||||
# IS MAKING NO REPRESENTATION THAT THIS IMPLEMENTATION IS FREE FROM
|
||||
# ANY CLAIMS OF INFRINGEMENT, AND YOU ARE RESPONSIBLE FOR OBTAINING
|
||||
# ANY RIGHTS YOU MAY REQUIRE FOR YOUR IMPLEMENTATION. XILINX
|
||||
# EXPRESSLY DISCLAIMS ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
|
||||
# ADEQUACY OF THE IMPLEMENTATION, INCLUDING BUT NOT LIMITED TO ANY
|
||||
# WARRANTIES OR REPRESENTATIONS THAT THIS IMPLEMENTATION IS FREE
|
||||
# FROM CLAIMS OF INFRINGEMENT, IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
# AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
#
|
||||
# This file is part of the lwIP TCP/IP stack.
|
||||
#
|
||||
# Author: Chris Borrelli <Chris.Borrelli@xilinx.com>
|
||||
#
|
||||
|
||||
#
|
||||
# This Makefile is meant to be run from EDK (libgen). Please do not try
|
||||
# try using this Makefile stand-alone on the command line; it will not work
|
||||
#
|
||||
|
||||
COMPILER=powerpc-eabi-gcc
|
||||
ARCHIVER=powerpc-eabi-ar
|
||||
ARFLAGS=rs
|
||||
CP=cp
|
||||
COMPILERFLAGS=-Wall -gdwarf
|
||||
#EXTRA_COMPILER_FLAGS = -DIPv4 -fpack-struct -msdata=eabi -mcpu=403
|
||||
EXTRA_COMPILER_FLAGS = -DIPv4 -msdata=eabi -mcpu=403
|
||||
LWIPDIR=$(TOPDIR)/lwip/src
|
||||
ARCHDIR=$(TOPDIR)/contrib/ports/v2pro
|
||||
LIB=liblwip4.a
|
||||
RELEASEDIR=../../../lib
|
||||
INCLUDEDIR=../../../include
|
||||
|
||||
INCLUDES= \
|
||||
-I$(LWIPDIR)/include \
|
||||
-I$(LWIPDIR)/include/ipv4 \
|
||||
-I$(ARCHDIR) \
|
||||
-I$(ARCHDIR)/include \
|
||||
-I$(INCLUDEDIR)
|
||||
|
||||
INCLUDEFILES=$(TOPDIR)/lwip/src/include/ipv4/lwip \
|
||||
$(TOPDIR)/lwip/src/include/lwip \
|
||||
$(TOPDIR)/lwip/src/include/netif \
|
||||
$(TOPDIR)/contrib/ports/v2pro/include/netif \
|
||||
$(TOPDIR)/contrib/ports/v2pro/include/arch \
|
||||
$(TOPDIR)/contrib/ports/v2pro/lwipopts.h
|
||||
|
||||
# COREFILES, CORE4FILES: The minimum set of files needed for lwIP.
|
||||
COREFILES=$(LWIPDIR)/core/mem.c \
|
||||
$(LWIPDIR)/core/memp.c \
|
||||
$(LWIPDIR)/core/netif.c \
|
||||
$(LWIPDIR)/core/pbuf.c \
|
||||
$(LWIPDIR)/core/stats.c \
|
||||
$(LWIPDIR)/core/sys.c \
|
||||
$(LWIPDIR)/core/tcp.c \
|
||||
$(LWIPDIR)/core/tcp_in.c \
|
||||
$(LWIPDIR)/core/tcp_out.c \
|
||||
$(LWIPDIR)/core/udp.c \
|
||||
|
||||
CORE4FILES=$(LWIPDIR)/core/ipv4/icmp.c \
|
||||
$(LWIPDIR)/core/ipv4/ip.c \
|
||||
$(LWIPDIR)/core/inet.c \
|
||||
$(LWIPDIR)/core/ipv4/ip_addr.c \
|
||||
$(LWIPDIR)/core/ipv4/ip_frag.c
|
||||
|
||||
# NETIFFILES: Files implementing various generic network interface functions.
|
||||
NETIFFILES=$(LWIPDIR)/netif/etharp.c
|
||||
|
||||
# ARCHFILES: Archiecture specific files.
|
||||
ARCHFILES=$(ARCHDIR)/lib_arch.c \
|
||||
$(ARCHDIR)/perf.c \
|
||||
$(ARCHDIR)/netif/xemacif.c \
|
||||
xemacif_g.c
|
||||
|
||||
# LWIPFILES: All the above.
|
||||
LWIPFILES=$(COREFILES) $(CORE4FILES) $(NETIFFILES) $(ARCHFILES)
|
||||
LWIPFILESW=$(wildcard $(LWIPFILES))
|
||||
LWIPOBJS=$(notdir $(LWIPFILESW:.c=.o))
|
||||
|
||||
help: |
||||
@echo ""
|
||||
@echo "This Makefile generates a library for the v2pro port of lwIP."
|
||||
@echo ""
|
||||
@echo " Below are the targets:"
|
||||
@echo ""
|
||||
@echo " make lwiplibs"
|
||||
@echo " This is the target that will compile all lwIP files, and"
|
||||
@echo " build the library, $(LIB). The final library will be"
|
||||
@echo " copied to $(RELEASEDIR)."
|
||||
@echo ""
|
||||
@echo " make lwipinclude"
|
||||
@echo " Copies the lwIP include files into the EDK directory,"
|
||||
@echo " $(INCLUDEDIR)"
|
||||
@echo ""
|
||||
@echo " make clean"
|
||||
@echo " Removes all object files and the $(LIB) library from"
|
||||
@echo " the local directory."
|
||||
@echo ""
|
||||
@echo " make depend"
|
||||
@echo " Generates the .depend file, which contains the"
|
||||
@echo " dependancies needed to compile each .c file. The"
|
||||
@echo " .depend file will be generated automatically for"
|
||||
@echo " other targets, so it is not nessessary to run"
|
||||
@echo " make depend."
|
||||
@echo ""
|
||||
|
||||
%.o: |
||||
@echo ""
|
||||
@echo "Building File: $@"
|
||||
@echo ""
|
||||
$(COMPILER) $(COMPILERFLAGS) $(EXTRA_COMPILER_FLAGS) $(INCLUDES) -c $(<:.o=.c)
|
||||
|
||||
all ipv4 lwiplibs: lwipinclude $(LIB) |
||||
.PHONY: all ipv4 lwiplibs lwip_include help |
||||
|
||||
lwipinclude: |
||||
@for i in $(INCLUDEFILES); do \
|
||||
echo ${CP} -r $$i ${INCLUDEDIR}; \
|
||||
${CP} -r $$i ${INCLUDEDIR}; \
|
||||
done
|
||||
|
||||
include: |
||||
@exit
|
||||
|
||||
libs: |
||||
@exit
|
||||
|
||||
clean: |
||||
@echo ""
|
||||
@echo "Cleaning up..."
|
||||
@echo ""
|
||||
@rm -f *.o *.a .depend* core
|
||||
|
||||
depend dep: .depend |
||||
@exit
|
||||
|
||||
$(LIB): $(LWIPOBJS) |
||||
@echo ""
|
||||
@echo "Building lwIP Library, $@"
|
||||
$(ARCHIVER) $(ARFLAGS) $@ $?
|
||||
@cp $@ $(RELEASEDIR)/
|
||||
|
||||
.depend: $(LWIPFILES) $(APPFILES) |
||||
@echo ""
|
||||
@echo "Building dependancies..."
|
||||
$(COMPILER) $(COMPILERFLAGS) $(EXTRA_COMPILER_FLAGS) $(INCLUDES) \
|
||||
-MM $^ > .depend || rm -f .depend
|
||||
|
||||
ifneq ($(MAKECMDGOALS), clean) |
||||
ifneq ($(MAKECMDGOALS), depend) |
||||
ifneq ($(MAKECMDGOALS), dep) |
||||
ifneq ($(MAKECMDGOALS), libs) |
||||
ifneq ($(MAKECMDGOALS), include) |
||||
ifneq ($(MAKECMDGOALS), help) |
||||
-include .depend |
||||
endif |
||||
endif |
||||
endif |
||||
endif |
||||
endif |
||||
endif |
||||
Loading…
Reference in new issue