mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2026-11-14 16:02:37 +08:00
[add] lwIP 2.1.2 transplantation on RT-Thread.
Signed-off-by: liuxianliang <liuxianliang@rt-thread.com>
This commit is contained in:
1 parent
a9796b90ad
commit
de1fd2bfc4
16 files changed
+3531
-2
No files matched your search
@@ -120,9 +120,13 @@ config RT_USING_LWIP
|
||||
|
||||
config RT_USING_LWIP210
|
||||
bool "lwIP v2.1.0"
|
||||
|
||||
config RT_USING_LWIP212
|
||||
bool "lwIP v2.1.2"
|
||||
|
||||
endchoice
|
||||
|
||||
if (RT_USING_LWIP210 || RT_USING_LWIP202)
|
||||
if (RT_USING_LWIP210 || RT_USING_LWIP202 || RT_USING_LWIP212)
|
||||
config RT_USING_LWIP_IPV6
|
||||
bool "IPV6 protocol"
|
||||
default n
|
||||
|
||||
@@ -8,7 +8,7 @@ cwd = GetCurrentDir()
|
||||
list = os.listdir(cwd)
|
||||
|
||||
# the default version of LWIP is 2.0.2
|
||||
if not GetDepend('RT_USING_LWIP141') and not GetDepend('RT_USING_LWIP202') and not GetDepend('RT_USING_LWIP210'):
|
||||
if not GetDepend('RT_USING_LWIP141') and not GetDepend('RT_USING_LWIP202') and not GetDepend('RT_USING_LWIP210') and not GetDepend('RT_USING_LWIP212'):
|
||||
AddDepend('RT_USING_LWIP202')
|
||||
|
||||
for d in list:
|
||||
|
||||
@@ -0,0 +1,89 @@
|
||||
# lwip 移植说明
|
||||
|
||||
为了适配 RT-Thread 网卡设备,RT-Thread 团队基于原 [lwip](http://savannah.nongnu.org/projects/lwip/) 进行了一些修改,本文档记录了相关修改内容。
|
||||
|
||||
> 本 lwip-2.1.2 版本基于 [lwip STABLE-2_1_2_RELEASE](https://git.savannah.gnu.org/git/lwip.git) 版本移植而来。
|
||||
|
||||
|
||||
| Date | Author | Notes |
|
||||
| :---- | :---- | :---- |
|
||||
| 2019-09-02 | MurphyZhao | 增加 lwip 2.1.2 移植说明 |
|
||||
| 2020-06-18 | xiangxistu | 增加部分 lwIP 2.1.2 移植说明 |
|
||||
|
||||
## 修改内容
|
||||
|
||||
### src/api
|
||||
|
||||
- `src/api/sockets.c` 增加 `lwip_tryget_socket` 函数,作为 `tryget_socket` 函数的全局实现
|
||||
- `src/api/sockets.c` 在 `alloc_socket` 函数中,增加 SAL 移植函数 `rt_wqueue_init`
|
||||
|
||||
```
|
||||
#ifdef SAL_USING_POSIX
|
||||
rt_wqueue_init(&sockets[i].wait_head);
|
||||
#endif
|
||||
```
|
||||
|
||||
### src/app
|
||||
|
||||
- 增加 `ping/ping.c`,便于在 finsh/msh 中使用 ping 功能
|
||||
- 增加 `tftp/tftp_port.c`,便于在 finsh/msh 中使用 tftp_server 功能
|
||||
|
||||
### src/arch
|
||||
|
||||
增加 `src/arch` 目录,存储对接 RT-Thread 设备框架的移植文件,从 lwip-2.0.2 版本中的移植文件修改而来。
|
||||
|
||||
|
||||
|
||||
以及相对于 lwIP2.0.2 的增加修改内容:
|
||||
|
||||
|
||||
* 在 `src/arch/sys_arch.c` 中增加 MTU 与 etharp_output 的初始化
|
||||
|
||||
* 在 `src/arch/sys_arch.c` 中增加新添加的邮箱函数
|
||||
|
||||
对邮箱机制的新增加的 sys_mbox_trypost_fromisr 函数予以实现
|
||||
|
||||
* 在 `src/arch/sys_arch.c` 中增加新添加的内存堆函数
|
||||
|
||||
对内存堆的新增加的 mem_overflow_check_raw 与 mem_overflow_init_raw 函数予以实现
|
||||
|
||||
* 在 `src/arch/cc.h` 中增加对 lwIP 使用的标准错误代码宏的处理,不再使用 lwIP 内置的错误宏
|
||||
|
||||
|
||||
### src/core
|
||||
|
||||
- 在 `src/core/dns.c` 的 `dns_setserver` 函数中增加 RT-Thread netdev 相关的移植
|
||||
- 在 `src/core/netif.c` 中增加 RT-Thread netdev 相关的移植
|
||||
|
||||
### src/include
|
||||
|
||||
- 在 `src/include/lwip/priv/sockets_priv.h` 中增加 SAL 相关的移植
|
||||
|
||||
在 `lwip_sock` 结构体中增加 ` rt_wqueue_t wait_head;` 成员
|
||||
|
||||
- 在 `src/include/lwip/prot/ieee.h` 中增加 EAPOL, EAP over LAN 标识
|
||||
|
||||
- 在 `src/include/lwip/init.h` 中的版本号后增加 `U` 标识
|
||||
|
||||
- 在 `src/include/lwip/sockets.h` 中增加 `LWIP_SOCKET_SELECT`,解决开启 RT_USING_POSIX 时的冲突
|
||||
|
||||
- 在 `src/include/lwip/arch.h` 中修改 `<unistd.h> `为 `"sys/types.h" `,解决编译冲突
|
||||
|
||||
并添加 typedef int ssize_t 定义,补足因 libc 与 dfs 未开启时 ssize_t 的定义不足问题
|
||||
|
||||
- 在 `src/include/netif/` 中增加 `ethernetif.h`,用于对接 RT-Thread 网卡设备
|
||||
|
||||
### src/netif
|
||||
|
||||
- 在 `src/netif/` 中增加 `ethernetif.c`,用于对接 RT-Thread 网卡设备
|
||||
- 在 `src/netif/lowpan6.c` 中增加 `LWIP_6LOWPAN` 宏定义,以防止编译错误
|
||||
|
||||
### src
|
||||
|
||||
- 在 src 目录下,增加 `src/lwipopts.h`,用于 lwip 功能裁剪以及配置设置
|
||||
- 在 src 目录下,增加 `src/lwippools.h`,用于定义 `LWIP_MALLOC_MEMPOOL`
|
||||
|
||||
### 其它
|
||||
|
||||
- 增加 SConscript 文件,用于 scons 构建
|
||||
- 增加 README_RT-THREAD.md 文件,用于记录相对原 lwip 源码的改动
|
||||
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
* File : tftp_port.c
|
||||
* This file is part of RT-Thread RTOS
|
||||
* COPYRIGHT (C) 2006 - 2017, RT-Thread Development Team
|
||||
*
|
||||
* This program 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 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program 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 this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2017-08-17 armink first version.
|
||||
*/
|
||||
|
||||
|
||||
#include <rtthread.h>
|
||||
#include <dfs_posix.h>
|
||||
#include <lwip/apps/tftp_server.h>
|
||||
|
||||
static struct tftp_context ctx;
|
||||
|
||||
static void* tftp_open(const char* fname, const char* mode, u8_t write)
|
||||
{
|
||||
int fd = -1;
|
||||
|
||||
if (!rt_strcmp(mode, "octet"))
|
||||
{
|
||||
if (write)
|
||||
{
|
||||
fd = open(fname, O_WRONLY | O_CREAT, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
fd = open(fname, O_RDONLY, 0);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
rt_kprintf("tftp: No support this mode(%s).", mode);
|
||||
}
|
||||
|
||||
return (void *) fd;
|
||||
}
|
||||
|
||||
static int tftp_write(void* handle, struct pbuf* p)
|
||||
{
|
||||
int fd = (int) handle;
|
||||
|
||||
return write(fd, p->payload, p->len);
|
||||
}
|
||||
|
||||
#if defined(RT_USING_FINSH)
|
||||
#include <finsh.h>
|
||||
|
||||
static void tftp_server(uint8_t argc, char **argv)
|
||||
{
|
||||
ctx.open = tftp_open;
|
||||
ctx.close = (void (*)(void *)) close;
|
||||
ctx.read = (int (*)(void *, void *, int)) read;
|
||||
ctx.write = tftp_write;
|
||||
|
||||
if (tftp_init(&ctx) == ERR_OK)
|
||||
{
|
||||
rt_kprintf("TFTP server start successfully.\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
rt_kprintf("TFTP server start failed.\n");
|
||||
}
|
||||
}
|
||||
FINSH_FUNCTION_EXPORT(tftp_server, start tftp server.);
|
||||
|
||||
#if defined(FINSH_USING_MSH)
|
||||
MSH_CMD_EXPORT(tftp_server, start tftp server.);
|
||||
#endif /* defined(FINSH_USING_MSH) */
|
||||
|
||||
#endif /* defined(RT_USING_FINSH) */
|
||||
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* 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>
|
||||
*
|
||||
*/
|
||||
|
||||
#if defined(__ICCARM__)
|
||||
#pragma pack(1)
|
||||
#endif
|
||||
@@ -0,0 +1,103 @@
|
||||
/*
|
||||
* 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.1.1 2004/12/16 14:17:13 bear Exp $
|
||||
*/
|
||||
#ifndef __ARCH_CC_H__
|
||||
#define __ARCH_CC_H__
|
||||
|
||||
#include <rthw.h>
|
||||
#include <rtthread.h>
|
||||
|
||||
#define U16_F "hu"
|
||||
#define S16_F "hd"
|
||||
#define X16_F "hx"
|
||||
#define U32_F "lu"
|
||||
#define S32_F "ld"
|
||||
#define X32_F "lx"
|
||||
|
||||
#ifdef RT_USING_LIBC
|
||||
#if defined(__CC_ARM) || defined(__CLANG_ARM) || defined(__IAR_SYSTEMS_ICC__)
|
||||
#include <sys/errno.h>
|
||||
#else
|
||||
#include <errno.h>
|
||||
/* some errno not defined in newlib */
|
||||
#define ENSRNOTFOUND 163 /* Domain name not found */
|
||||
/* WARNING: ESHUTDOWN also not defined in newlib. We chose
|
||||
180 here because the number "108" which is used
|
||||
in arch.h has been assigned to another error code. */
|
||||
#define ESHUTDOWN 180
|
||||
#endif /* __CC_ARM/__IAR_SYSTEMS_ICC__ */
|
||||
#endif /* RT_USING_LIBC */
|
||||
|
||||
#if defined(RT_USING_LIBC) || defined(RT_USING_MINILIBC) || defined(RT_LIBC_USING_TIME)
|
||||
#include <sys/time.h>
|
||||
#define LWIP_TIMEVAL_PRIVATE 0
|
||||
#else
|
||||
#define LWIP_TIMEVAL_PRIVATE 1
|
||||
#endif
|
||||
|
||||
#if defined(__CC_ARM) /* ARMCC compiler */
|
||||
#define PACK_STRUCT_FIELD(x) x
|
||||
#define PACK_STRUCT_STRUCT __attribute__ ((__packed__))
|
||||
#define PACK_STRUCT_BEGIN
|
||||
#define PACK_STRUCT_END
|
||||
#elif defined(__IAR_SYSTEMS_ICC__) /* IAR Compiler */
|
||||
#define PACK_STRUCT_BEGIN
|
||||
#define PACK_STRUCT_STRUCT
|
||||
#define PACK_STRUCT_END
|
||||
#define PACK_STRUCT_FIELD(x) x
|
||||
#define PACK_STRUCT_USE_INCLUDES
|
||||
#elif defined(__GNUC__) /* GNU GCC Compiler */
|
||||
#define PACK_STRUCT_FIELD(x) x
|
||||
#define PACK_STRUCT_STRUCT __attribute__((packed))
|
||||
#define PACK_STRUCT_BEGIN
|
||||
#define PACK_STRUCT_END
|
||||
#elif defined(_MSC_VER)
|
||||
#define PACK_STRUCT_FIELD(x) x
|
||||
#define PACK_STRUCT_STRUCT
|
||||
#define PACK_STRUCT_BEGIN
|
||||
#define PACK_STRUCT_END
|
||||
#endif
|
||||
|
||||
void sys_arch_assert(const char* file, int line);
|
||||
#define LWIP_PLATFORM_DIAG(x) do {rt_kprintf x;} while(0)
|
||||
#define LWIP_PLATFORM_ASSERT(x) do {rt_kprintf(x); sys_arch_assert(__FILE__, __LINE__);}while(0)
|
||||
|
||||
#include "string.h"
|
||||
|
||||
#define SYS_ARCH_DECL_PROTECT(level)
|
||||
#define SYS_ARCH_PROTECT(level) rt_enter_critical()
|
||||
#define SYS_ARCH_UNPROTECT(level) rt_exit_critical()
|
||||
|
||||
#endif /* __ARCH_CC_H__ */
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* 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>
|
||||
*
|
||||
*/
|
||||
|
||||
#if defined(__ICCARM__)
|
||||
#pragma pack()
|
||||
#endif
|
||||
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* 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.1.1 2004/12/16 14:17:13 bear Exp $
|
||||
*/
|
||||
#ifndef __ARCH_PERF_H__
|
||||
#define __ARCH_PERF_H__
|
||||
|
||||
//#include <sys/times.h>
|
||||
|
||||
#define PERF_START /* null definition */
|
||||
#define PERF_STOP(x) /* null definition */
|
||||
|
||||
/*
|
||||
void perf_print(unsigned long c1l, unsigned long c1h,
|
||||
unsigned long c2l, unsigned long c2h,
|
||||
char *key);
|
||||
|
||||
void perf_print_times(struct tms *start, struct tms *end, char *key);
|
||||
|
||||
void perf_init(char *fname);
|
||||
*/
|
||||
#endif /* __ARCH_PERF_H__ */
|
||||
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* 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: sys_arch.h,v 1.3 2005/03/13 16:03:23 bear Exp $
|
||||
*/
|
||||
#ifndef __ARCH_SYS_ARCH_H__
|
||||
#define __ARCH_SYS_ARCH_H__
|
||||
|
||||
#include "arch/cc.h"
|
||||
|
||||
#include <rtthread.h>
|
||||
|
||||
#ifndef BYTE_ORDER
|
||||
#define BYTE_ORDER LITTLE_ENDIAN
|
||||
#endif
|
||||
|
||||
#define SYS_MBOX_NULL RT_NULL
|
||||
#define SYS_SEM_NULL RT_NULL
|
||||
|
||||
typedef u32_t sys_prot_t;
|
||||
|
||||
#define SYS_MBOX_SIZE 10
|
||||
#define SYS_LWIP_TIMER_NAME "timer"
|
||||
#define SYS_LWIP_MBOX_NAME "mbox"
|
||||
#define SYS_LWIP_SEM_NAME "sem"
|
||||
#define SYS_LWIP_MUTEX_NAME "mu"
|
||||
|
||||
typedef rt_sem_t sys_sem_t;
|
||||
typedef rt_mutex_t sys_mutex_t;
|
||||
typedef rt_mailbox_t sys_mbox_t;
|
||||
typedef rt_thread_t sys_thread_t;
|
||||
|
||||
// err_t sys_mbox_trypost_fromisr(sys_mbox_t *q, void *msg);
|
||||
|
||||
#endif /* __ARCH_SYS_ARCH_H__ */
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,52 @@
|
||||
#ifndef __NETIF_ETHERNETIF_H__
|
||||
#define __NETIF_ETHERNETIF_H__
|
||||
|
||||
#include "lwip/netif.h"
|
||||
#include <rtthread.h>
|
||||
|
||||
#define NIOCTL_GADDR 0x01
|
||||
#ifndef RT_LWIP_ETH_MTU
|
||||
#define ETHERNET_MTU 1500
|
||||
#else
|
||||
#define ETHERNET_MTU RT_LWIP_ETH_MTU
|
||||
#endif
|
||||
|
||||
/* eth flag with auto_linkup or phy_linkup */
|
||||
#define ETHIF_LINK_AUTOUP 0x0000
|
||||
#define ETHIF_LINK_PHYUP 0x0100
|
||||
|
||||
struct eth_device
|
||||
{
|
||||
/* inherit from rt_device */
|
||||
struct rt_device parent;
|
||||
|
||||
/* network interface for lwip */
|
||||
struct netif *netif;
|
||||
struct rt_semaphore tx_ack;
|
||||
|
||||
rt_uint16_t flags;
|
||||
rt_uint8_t link_changed;
|
||||
rt_uint8_t link_status;
|
||||
|
||||
/* eth device interface */
|
||||
struct pbuf* (*eth_rx)(rt_device_t dev);
|
||||
rt_err_t (*eth_tx)(rt_device_t dev, struct pbuf* p);
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
rt_err_t eth_device_ready(struct eth_device* dev);
|
||||
rt_err_t eth_device_init(struct eth_device * dev, const char *name);
|
||||
rt_err_t eth_device_init_with_flag(struct eth_device *dev, const char *name, rt_uint16_t flag);
|
||||
rt_err_t eth_device_linkchange(struct eth_device* dev, rt_bool_t up);
|
||||
void eth_device_deinit(struct eth_device *dev);
|
||||
|
||||
int eth_system_device_init(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __NETIF_ETHERNETIF_H__ */
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,10 @@
|
||||
#if 1
|
||||
LWIP_MALLOC_MEMPOOL_START
|
||||
LWIP_MALLOC_MEMPOOL((unsigned char)128, 256)
|
||||
LWIP_MALLOC_MEMPOOL((unsigned char)128, 512)
|
||||
LWIP_MALLOC_MEMPOOL((unsigned char)128, 1024)
|
||||
LWIP_MALLOC_MEMPOOL((unsigned char)128, 1514)
|
||||
LWIP_MALLOC_MEMPOOL((unsigned char)128, 1536)
|
||||
LWIP_MALLOC_MEMPOOL((unsigned char)128, 4096)
|
||||
LWIP_MALLOC_MEMPOOL_END
|
||||
#endif
|
||||
File diff suppressed because it is too large.
Load diff
Reference in new issue
Block a user