From 80fe0c7d2a1dde7a499f5e60461de3b6c71fbf93 Mon Sep 17 00:00:00 2001 From: YOUR_NAME Date: Mon, 12 Apr 2021 10:26:02 +0800 Subject: [PATCH 1/8] IssueNo:#I3IBCL Description:use posix instead of lwip self Feature or Bugfix:Bugfix Binary Source:No --- components/fs/fatfs/fs.c | 1 + .../net/lwip-2.1/porting/include/arch/cc.h | 26 ++- .../lwip-2.1/porting/include/arch/sys_arch.h | 1 - .../net/lwip-2.1/porting/include/lwip/inet.h | 65 +++++++ .../lwip-2.1/porting/include/lwip/lwipopts.h | 3 +- .../porting/include/{ => lwip}/netdb.h | 81 ++++----- .../net/lwip-2.1/porting/include/lwip/netif.h | 8 +- .../include/{sys/socket.h => lwip/sockets.h} | 162 +++++++++--------- .../net/lwip-2.1/porting/src/netdb_porting.c | 1 + components/net/test/lwip_test.h | 3 + components/net/test/net_socket_test_002.c | 17 +- components/net/test/net_socket_test_011.c | 13 +- components/net/test/test_main.c | 2 +- kal/posix/include/limits.h | 2 + 14 files changed, 254 insertions(+), 131 deletions(-) create mode 100644 components/net/lwip-2.1/porting/include/lwip/inet.h rename components/net/lwip-2.1/porting/include/{ => lwip}/netdb.h (88%) rename components/net/lwip-2.1/porting/include/{sys/socket.h => lwip/sockets.h} (56%) diff --git a/components/fs/fatfs/fs.c b/components/fs/fatfs/fs.c index 7435e822..04fecb89 100755 --- a/components/fs/fatfs/fs.c +++ b/components/fs/fatfs/fs.c @@ -44,6 +44,7 @@ #ifdef LOSCFG_NET_LWIP_SACK #include "lwip/lwipopts.h" +#include "lwip/sockets.h" #define CONFIG_NSOCKET_DESCRIPTORS LWIP_CONFIG_NUM_SOCKETS #else #define CONFIG_NSOCKET_DESCRIPTORS 0 diff --git a/components/net/lwip-2.1/porting/include/arch/cc.h b/components/net/lwip-2.1/porting/include/arch/cc.h index 746bf9e9..f305d3c9 100644 --- a/components/net/lwip-2.1/porting/include/arch/cc.h +++ b/components/net/lwip-2.1/porting/include/arch/cc.h @@ -32,17 +32,40 @@ #ifndef _LWIP_PORTING_CC_H_ #define _LWIP_PORTING_CC_H_ +#ifdef LITTLE_ENDIAN +#undef LITTLE_ENDIAN +#endif + +#ifdef BIG_ENDIAN +#undef BIG_ENDIAN +#endif + +#include #include #include #include "securec.h" #include "log.h" +#include "memory_pool.h" #ifdef htons #define LWIP_DONT_PROVIDE_BYTEORDER_FUNCTIONS #endif -#define LWIP_PROVIDE_ERRNO 1 +#define SOCKLEN_T_DEFINED +#define SA_FAMILY_T_DEFINED +#define IN_PORT_T_DEFINED + +#define LWIP_TIMEVAL_PRIVATE 0 +#define LWIP_ERRNO_STDINCLUDE +#define LWIP_SOCKET_STDINCLUDE + +#define LWIP_DNS_API_DEFINE_ERRORS 0 +#define LWIP_DNS_API_DEFINE_FLAGS 0 +#define LWIP_DNS_API_DECLARE_STRUCTS 0 + +#ifndef __SIZEOF_POINTER__ 4 #define __SIZEOF_POINTER__ 4 // 32位系统 +#endif #define LOS_TASK_STATUS_DETACHED 0x0100 // 预留字段 @@ -96,7 +119,6 @@ extern void HilogPrintf(const char *fmt, ...); #define init_waitqueue_head(...) #define poll_check_waiters(...) #define IOCTL_CMD_CASE_HANDLER() -#define DF_NADDR(addr) #define DNS_SERVER_ADDRESS(ipaddr) (ip4_addr_set_u32(ipaddr, ipaddr_addr("114.114.114.114"))) #define DNS_SERVER_ADDRESS_SECONDARY(ipaddr) (ip4_addr_set_u32(ipaddr, ipaddr_addr("114.114.115.115"))) diff --git a/components/net/lwip-2.1/porting/include/arch/sys_arch.h b/components/net/lwip-2.1/porting/include/arch/sys_arch.h index 95f7f80a..d8c3513f 100644 --- a/components/net/lwip-2.1/porting/include/arch/sys_arch.h +++ b/components/net/lwip-2.1/porting/include/arch/sys_arch.h @@ -33,7 +33,6 @@ #define _LWIP_PORTING_SYS_ARCH_H_ #include -#include "memory_pool.h" #include "los_mux.h" #ifdef __cplusplus diff --git a/components/net/lwip-2.1/porting/include/lwip/inet.h b/components/net/lwip-2.1/porting/include/lwip/inet.h new file mode 100644 index 00000000..3a77c310 --- /dev/null +++ b/components/net/lwip-2.1/porting/include/lwip/inet.h @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved. + * Copyright (c) 2020-2021 Huawei Device Co., Ltd. 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 copyright holder 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 COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER 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. + */ + +#ifndef _LWIP_PORTING_INET_H_ +#define _LWIP_PORTING_INET_H_ + +#include +#include +#include_next + +#if LWIP_IPV4 +#define inet_addr_from_ip4addr(target_inaddr, source_ipaddr) \ + ((target_inaddr)->s_addr = ip4_addr_get_u32(source_ipaddr)) +#define inet_addr_to_ip4addr(target_ipaddr, source_inaddr) \ + (ip4_addr_set_u32(target_ipaddr, (source_inaddr)->s_addr)) + +/* directly map this to the lwip internal functions */ +#define inet_addr(cp) ipaddr_addr(cp) +#define inet_aton(cp, addr) ip4addr_aton(cp, (ip4_addr_t*)addr) +#define inet_ntoa(addr) ip4addr_ntoa((const ip4_addr_t*)&(addr)) +#define inet_ntoa_r(addr, buf, buflen) ip4addr_ntoa_r((const ip4_addr_t*)&(addr), buf, buflen) +#endif /* LWIP_IPV4 */ +#if LWIP_IPV6 +#define inet6_addr_from_ip6addr(target_in6addr, source_ip6addr) \ + {(target_in6addr)->s6_addr32[0] = (source_ip6addr)->addr[0]; \ + (target_in6addr)->s6_addr32[1] = (source_ip6addr)->addr[1]; \ + (target_in6addr)->s6_addr32[2] = (source_ip6addr)->addr[2]; \ + (target_in6addr)->s6_addr32[3] = (source_ip6addr)->addr[3];} +#define inet6_addr_to_ip6addr(target_ip6addr, source_in6addr) \ + {(target_ip6addr)->addr[0] = (source_in6addr)->s6_addr32[0]; \ + (target_ip6addr)->addr[1] = (source_in6addr)->s6_addr32[1]; \ + (target_ip6addr)->addr[2] = (source_in6addr)->s6_addr32[2]; \ + (target_ip6addr)->addr[3] = (source_in6addr)->s6_addr32[3]; \ + ip6_addr_clear_zone(target_ip6addr);} +#endif /* LWIP_IPV6 */ + +#endif /* _LWIP_PORTING_INET_H_ */ diff --git a/components/net/lwip-2.1/porting/include/lwip/lwipopts.h b/components/net/lwip-2.1/porting/include/lwip/lwipopts.h index 7d077758..ab54f69a 100644 --- a/components/net/lwip-2.1/porting/include/lwip/lwipopts.h +++ b/components/net/lwip-2.1/porting/include/lwip/lwipopts.h @@ -134,8 +134,7 @@ #define LWIP_NETIF_LOOPBACK 1 #define LWIP_POSIX_SOCKETS_IO_NAMES 0 #define LWIP_RAW 1 -#define CONFIG_NFILE_DESCRIPTORS 1 -#define LWIP_SOCKET_OFFSET CONFIG_NFILE_DESCRIPTORS +#define LWIP_SOCKET_OFFSET FAT_MAX_OPEN_FILES #define LWIP_SO_RCVBUF 1 #define LWIP_SO_RCVTIMEO 1 #define LWIP_SO_SNDTIMEO 1 diff --git a/components/net/lwip-2.1/porting/include/netdb.h b/components/net/lwip-2.1/porting/include/lwip/netdb.h similarity index 88% rename from components/net/lwip-2.1/porting/include/netdb.h rename to components/net/lwip-2.1/porting/include/lwip/netdb.h index 5043cf0a..7172ea84 100644 --- a/components/net/lwip-2.1/porting/include/netdb.h +++ b/components/net/lwip-2.1/porting/include/lwip/netdb.h @@ -1,39 +1,42 @@ -/* - * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved. - * Copyright (c) 2020-2021 Huawei Device Co., Ltd. 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 copyright holder 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 COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER 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. - */ - -#ifndef __LITEOS_NETDB_PORTING_H__ -#define __LITEOS_NETDB_PORTING_H__ - -#include "lwip/netdb.h" - -struct hostent *gethostbyname(const char *name); - -#endif // __LITEOS_NETDB_PORTING_H__ \ No newline at end of file +/* + * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved. + * Copyright (c) 2020-2021 Huawei Device Co., Ltd. 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 copyright holder 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 COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER 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. + */ + +#ifndef _LWIP_PORTING_NETDB_H_ +#define _LWIP_PORTING_NETDB_H_ + +#include +#include_next + +#ifdef h_errno +#undef h_errno +#endif + +#endif /* _LWIP_PORTING_NETDB_H_ */ diff --git a/components/net/lwip-2.1/porting/include/lwip/netif.h b/components/net/lwip-2.1/porting/include/lwip/netif.h index 421a5fb6..bba71682 100644 --- a/components/net/lwip-2.1/porting/include/lwip/netif.h +++ b/components/net/lwip-2.1/porting/include/lwip/netif.h @@ -32,6 +32,9 @@ #ifndef _LWIP_PORTING_NETIF_H_ #define _LWIP_PORTING_NETIF_H_ +#include // For IFNAMSIZ/IF_NAMESIZE and `struct ifreq', by `lwip/netif.h' and `api/sockets.c' +#include // For IP_OFFMASK, by `core/ipv4/ip4_frag.c' + #define netif_find netifapi_netif_find_by_name #if LWIP_DHCPS @@ -39,12 +42,11 @@ LWIP_NETIF_CLIENT_DATA_INDEX_DHCPS #endif -#define LWIP_NETIF_FULLNAME 16 #define linkoutput linkoutput; \ void (*drv_send)(struct netif *netif, struct pbuf *p); \ u8_t (*drv_set_hwaddr)(struct netif *netif, u8_t *addr, u8_t len); \ void (*drv_config)(struct netif *netif, u32_t config_flags, u8_t setBit); \ - char full_name[LWIP_NETIF_FULLNAME]; \ + char full_name[IFNAMSIZ]; \ u16_t link_layer_type #include_next #undef linkoutput @@ -60,7 +62,7 @@ extern "C" { // redefine NETIF_NAMESIZE which was defined in netif.h #undef NETIF_NAMESIZE -#define NETIF_NAMESIZE LWIP_NETIF_FULLNAME +#define NETIF_NAMESIZE IFNAMSIZ #define LOOPBACK_IF 0 // 772 #define ETHERNET_DRIVER_IF 1 diff --git a/components/net/lwip-2.1/porting/include/sys/socket.h b/components/net/lwip-2.1/porting/include/lwip/sockets.h similarity index 56% rename from components/net/lwip-2.1/porting/include/sys/socket.h rename to components/net/lwip-2.1/porting/include/lwip/sockets.h index c5f27a60..c149113f 100644 --- a/components/net/lwip-2.1/porting/include/sys/socket.h +++ b/components/net/lwip-2.1/porting/include/lwip/sockets.h @@ -1,79 +1,83 @@ -/* - * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved. - * Copyright (c) 2020-2021 Huawei Device Co., Ltd. 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 copyright holder 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 COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER 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. - */ - -#ifndef _SYS_SOCKET_PORTING_H -#define _SYS_SOCKET_PORTING_H - -#include "lwip/sockets.h" - -#ifdef __cplusplus -extern "C" { -#endif - -int socket (int, int, int); - -int bind (int, const struct sockaddr *, socklen_t); -int connect (int, const struct sockaddr *, socklen_t); -int listen (int, int); -int accept (int, struct sockaddr *__restrict, socklen_t *__restrict); - -int getsockname (int, struct sockaddr *__restrict, socklen_t *__restrict); -int getpeername (int, struct sockaddr *__restrict, socklen_t *__restrict); - -ssize_t send (int, const void *, size_t, int); -ssize_t recv (int, void *, size_t, int); -ssize_t sendto (int, const void *, size_t, int, const struct sockaddr *, socklen_t); -ssize_t recvfrom (int, void *__restrict, size_t, int, struct sockaddr *__restrict, socklen_t *__restrict); -ssize_t sendmsg (int, const struct msghdr *, int); -ssize_t recvmsg (int, struct msghdr *, int); - -int getsockopt (int, int, int, void *__restrict, socklen_t *__restrict); -int setsockopt (int, int, int, const void *, socklen_t); - -const char *inet_ntop(int af, const void *src, char *dst, socklen_t size); -int inet_pton(int af, const char *src, void *dst); - -int shutdown (int, int); -int closesocket(int sockfd); - -int ioctlsocket(int s, long cmd, void *argp); - -#if LWIP_SOCKET_SELECT -int select(int maxfdp1, fd_set *readset, fd_set *writeset, fd_set *exceptset, struct timeval *timeout); -#endif -#if LWIP_SOCKET_POLL -int poll(struct pollfd *fds, nfds_t nfds, int timeout); -#endif - -#ifdef __cplusplus -} -#endif -#endif +/* + * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved. + * Copyright (c) 2020-2021 Huawei Device Co., Ltd. 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 copyright holder 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 COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER 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. + */ + +#ifndef _LWIP_PORTING_SOCKETS_H_ +#define _LWIP_PORTING_SOCKETS_H_ + +#include +#include // For poll_table +#include // For TCP_NODELAY etc. +#include +#include // For FIONREAD etc. +#include // For FD_SET +#include // For IOV_MAX +#include // For F_SETFL +#include_next +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#if FD_SETSIZE < (LWIP_SOCKET_OFFSET + MEMP_NUM_NETCONN) +#error "external FD_SETSIZE too small for number of sockets" +#else +#define LWIP_SELECT_MAXNFDS FD_SETSIZE +#endif + +#if IOV_MAX > 0xFFFF +#error "IOV_MAX larger than supported by LwIP" +#endif + +#if LWIP_UDP && LWIP_UDPLITE +#define UDPLITE_SEND_CSCOV 0x01 /* sender checksum coverage */ +#define UDPLITE_RECV_CSCOV 0x02 /* minimal receiver checksum coverage */ +#endif + +// For BSD 4.4 socket sa_len compatibility +#define DF_NADDR(addr) ip_addr_t naddr = addr +#define SA_LEN(addr, _) (IP_IS_V4_VAL(addr) ? sizeof(struct sockaddr_in) : sizeof(struct sockaddr_in6)) +#define sa_len sa_data[0] * 0 + SA_LEN(naddr, _) +#define sin_len sin_zero[0] +#define sin6_len sin6_addr.s6_addr[0] + +// for sockets.c, TCP_KEEPALIVE is not supported currently +#define TCP_KEEPALIVE 0xFF +#define SIN_ZERO_LEN 8 + +int closesocket(int sockfd); +int ioctlsocket(int s, long cmd, void *argp); + +#ifdef __cplusplus +} +#endif + +#endif /* _LWIP_PORTING_SOCKETS_H_ */ diff --git a/components/net/lwip-2.1/porting/src/netdb_porting.c b/components/net/lwip-2.1/porting/src/netdb_porting.c index df905f71..30accb25 100644 --- a/components/net/lwip-2.1/porting/src/netdb_porting.c +++ b/components/net/lwip-2.1/porting/src/netdb_porting.c @@ -30,6 +30,7 @@ */ #include "netdb.h" +#include "lwip/netdb.h" struct hostent *gethostbyname(const char *name) { diff --git a/components/net/test/lwip_test.h b/components/net/test/lwip_test.h index a873a59d..9e190df9 100644 --- a/components/net/test/lwip_test.h +++ b/components/net/test/lwip_test.h @@ -32,7 +32,10 @@ #ifndef LWIP_TEST_H #define LWIP_TEST_H +#include "lwip/arch.h" +#include "lwip/sockets.h" #include +#include #include "log.h" #include "securec.h" diff --git a/components/net/test/net_socket_test_002.c b/components/net/test/net_socket_test_002.c index 7abdfb13..1f0fb1ff 100644 --- a/components/net/test/net_socket_test_002.c +++ b/components/net/test/net_socket_test_002.c @@ -30,14 +30,19 @@ */ #include "lwip_test.h" +#include "lwipopts.h" +#include +#include #define MSG "Hi, I am UDP" #define TEST_CASE 120 static char g_buf[BUF_SIZE + 1] = { 0 }; +extern sys_thread_t sys_thread_new(const char *name, lwip_thread_fn thread, void *arg, int stackSize, int prio); -int UdpTest(void) +void UdpTestTask(void *p) { + void(p); LogPrintln("net_socket_test_002.c enter"); g_testCase = TEST_CASE; int sfd; @@ -111,6 +116,14 @@ int UdpTest(void) /* close socket */ ret = closesocket(sfd); LWIP_ASSERT("socket invalid param.", ret != -1); - return LWIP_TEST_RET_OK; + return; +} + +int UdpTest(void) +{ + int ret = sys_thread_new("udp_test", UdpTestTask, NULL, + STACK_TEST_SIZE, TCPIP_THREAD_PRIO); + ICUNIT_ASSERT_NOT_EQUAL(ret, -1, 23); + return ret; } diff --git a/components/net/test/net_socket_test_011.c b/components/net/test/net_socket_test_011.c index e324143b..2e18b7a6 100644 --- a/components/net/test/net_socket_test_011.c +++ b/components/net/test/net_socket_test_011.c @@ -310,8 +310,9 @@ static struct netif *CreateBtNetIf() return btNetif; } -int UdpTestNetif(void) +static void UdpTestNetifTask(void *p) { + void(p); LogPrintln("net_socket_test_011.c enter"); g_testCase = TEST_CASE; int sfd; @@ -363,7 +364,15 @@ int UdpTestNetif(void) /* close socket */ ret = closesocket(sfd); LWIP_ASSERT("socket invalid param.", ret != -1); - return LWIP_TEST_RET_OK; + return; +} + +int UdpTestNetif(void) +{ + int ret = sys_thread_new("udp_test_netif", UdpTestNetifTask, NULL, + STACK_TEST_SIZE, TCPIP_THREAD_PRIO); + ICUNIT_ASSERT_NOT_EQUAL(ret, -1, 23); + return ret; } static void ArpPackageProc(struct netif *netif, struct pbuf *p) diff --git a/components/net/test/test_main.c b/components/net/test/test_main.c index 125b9dd0..2ea6b700 100644 --- a/components/net/test/test_main.c +++ b/components/net/test/test_main.c @@ -119,7 +119,7 @@ static void LwipTestTimeoutCallback(void const *argument) osTimerId_t g_lwipTestTimerId = NULL; -void LwipTestStartTimer(uint32 timeout) +void LwipTestStartTimer(uint32_t timeout) { osStatus_t status; if (g_lwipTestTimerId != NULL) { diff --git a/kal/posix/include/limits.h b/kal/posix/include/limits.h index f77e3ed0..eefb2472 100644 --- a/kal/posix/include/limits.h +++ b/kal/posix/include/limits.h @@ -7,6 +7,8 @@ #define PATH_MAX 256 #define MQ_PRIO_MAX 1 #define PTHREAD_STACK_MIN LOSCFG_BASE_CORE_TSK_MIN_STACK_SIZE +#define IOV_MAX 1024 +#define SSIZE_MAX LONG_MAX #include_next #else From 247959fcbc63364863eb9f532f3bd28c0a71df4d Mon Sep 17 00:00:00 2001 From: YOUR_NAME Date: Mon, 12 Apr 2021 10:57:50 +0800 Subject: [PATCH 2/8] IssueNo:#I3IBCL Description:use posix instead of lwip self Feature or Bugfix:Bugfix Binary Source:No --- components/net/lwip-2.1/porting/include/arch/cc.h | 2 +- components/net/lwip-2.1/porting/include/lwip/sockets.h | 2 +- components/net/test/net_socket_test_002.c | 5 ++--- components/net/test/net_socket_test_011.c | 4 ++-- 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/components/net/lwip-2.1/porting/include/arch/cc.h b/components/net/lwip-2.1/porting/include/arch/cc.h index f305d3c9..4a3e5903 100644 --- a/components/net/lwip-2.1/porting/include/arch/cc.h +++ b/components/net/lwip-2.1/porting/include/arch/cc.h @@ -63,7 +63,7 @@ #define LWIP_DNS_API_DEFINE_FLAGS 0 #define LWIP_DNS_API_DECLARE_STRUCTS 0 -#ifndef __SIZEOF_POINTER__ 4 +#ifndef __SIZEOF_POINTER__ #define __SIZEOF_POINTER__ 4 // 32位系统 #endif diff --git a/components/net/lwip-2.1/porting/include/lwip/sockets.h b/components/net/lwip-2.1/porting/include/lwip/sockets.h index c149113f..0aefba52 100644 --- a/components/net/lwip-2.1/porting/include/lwip/sockets.h +++ b/components/net/lwip-2.1/porting/include/lwip/sockets.h @@ -63,7 +63,7 @@ extern "C" { #endif // For BSD 4.4 socket sa_len compatibility -#define DF_NADDR(addr) ip_addr_t naddr = addr +#define DF_NADDR(addr) #define SA_LEN(addr, _) (IP_IS_V4_VAL(addr) ? sizeof(struct sockaddr_in) : sizeof(struct sockaddr_in6)) #define sa_len sa_data[0] * 0 + SA_LEN(naddr, _) #define sin_len sin_zero[0] diff --git a/components/net/test/net_socket_test_002.c b/components/net/test/net_socket_test_002.c index 1f0fb1ff..b08efb00 100644 --- a/components/net/test/net_socket_test_002.c +++ b/components/net/test/net_socket_test_002.c @@ -42,7 +42,7 @@ extern sys_thread_t sys_thread_new(const char *name, lwip_thread_fn thread, void void UdpTestTask(void *p) { - void(p); + (void)p; LogPrintln("net_socket_test_002.c enter"); g_testCase = TEST_CASE; int sfd; @@ -119,11 +119,10 @@ void UdpTestTask(void *p) return; } -int UdpTest(void) +int UdpTest() { int ret = sys_thread_new("udp_test", UdpTestTask, NULL, STACK_TEST_SIZE, TCPIP_THREAD_PRIO); ICUNIT_ASSERT_NOT_EQUAL(ret, -1, 23); return ret; } - diff --git a/components/net/test/net_socket_test_011.c b/components/net/test/net_socket_test_011.c index 2e18b7a6..32174654 100644 --- a/components/net/test/net_socket_test_011.c +++ b/components/net/test/net_socket_test_011.c @@ -312,7 +312,7 @@ static struct netif *CreateBtNetIf() static void UdpTestNetifTask(void *p) { - void(p); + (void)p; LogPrintln("net_socket_test_011.c enter"); g_testCase = TEST_CASE; int sfd; @@ -367,7 +367,7 @@ static void UdpTestNetifTask(void *p) return; } -int UdpTestNetif(void) +int UdpTestNetif() { int ret = sys_thread_new("udp_test_netif", UdpTestNetifTask, NULL, STACK_TEST_SIZE, TCPIP_THREAD_PRIO); From eca2fae28a1cd911c4387d35c8e50ce1138add10 Mon Sep 17 00:00:00 2001 From: YOUR_NAME Date: Mon, 12 Apr 2021 20:37:22 +0800 Subject: [PATCH 3/8] IssueNo:#I3IBCL Description:use posix instead of lwip self Feature or Bugfix:Bugfix Binary Source:No --- components/net/lwip-2.1/porting/include/arch/cc.h | 4 ++-- components/net/lwip-2.1/porting/include/lwip/netif.h | 8 ++++---- .../net/lwip-2.1/porting/include/lwip/sockets.h | 12 ++++++------ components/net/lwip-2.1/porting/src/netdb_porting.c | 1 - 4 files changed, 12 insertions(+), 13 deletions(-) diff --git a/components/net/lwip-2.1/porting/include/arch/cc.h b/components/net/lwip-2.1/porting/include/arch/cc.h index 4a3e5903..c2eebaf5 100644 --- a/components/net/lwip-2.1/porting/include/arch/cc.h +++ b/components/net/lwip-2.1/porting/include/arch/cc.h @@ -64,10 +64,10 @@ #define LWIP_DNS_API_DECLARE_STRUCTS 0 #ifndef __SIZEOF_POINTER__ -#define __SIZEOF_POINTER__ 4 // 32位系统 +#define __SIZEOF_POINTER__ 4 // 32 bit system #endif -#define LOS_TASK_STATUS_DETACHED 0x0100 // 预留字段 +#define LOS_TASK_STATUS_DETACHED 0x0100 // reserved #if defined(__arm__) && defined(__ARMCC_VERSION) /* Keil uVision4 tools */ diff --git a/components/net/lwip-2.1/porting/include/lwip/netif.h b/components/net/lwip-2.1/porting/include/lwip/netif.h index bba71682..1e57b768 100644 --- a/components/net/lwip-2.1/porting/include/lwip/netif.h +++ b/components/net/lwip-2.1/porting/include/lwip/netif.h @@ -32,8 +32,8 @@ #ifndef _LWIP_PORTING_NETIF_H_ #define _LWIP_PORTING_NETIF_H_ -#include // For IFNAMSIZ/IF_NAMESIZE and `struct ifreq', by `lwip/netif.h' and `api/sockets.c' -#include // For IP_OFFMASK, by `core/ipv4/ip4_frag.c' +#include +#include #define netif_find netifapi_netif_find_by_name @@ -54,7 +54,7 @@ #undef LWIP_NETIF_CLIENT_DATA_INDEX_DHCP #endif -#include // For ETHARP_HWADDR_LEN, by `hieth-sf src/interface.c' and `wal/wal_net.c' +#include #ifdef __cplusplus extern "C" { @@ -64,7 +64,7 @@ extern "C" { #undef NETIF_NAMESIZE #define NETIF_NAMESIZE IFNAMSIZ -#define LOOPBACK_IF 0 // 772 +#define LOOPBACK_IF 0 #define ETHERNET_DRIVER_IF 1 #define WIFI_DRIVER_IF 801 #define BT_PROXY_IF 802 diff --git a/components/net/lwip-2.1/porting/include/lwip/sockets.h b/components/net/lwip-2.1/porting/include/lwip/sockets.h index 0aefba52..3ff28693 100644 --- a/components/net/lwip-2.1/porting/include/lwip/sockets.h +++ b/components/net/lwip-2.1/porting/include/lwip/sockets.h @@ -33,13 +33,13 @@ #define _LWIP_PORTING_SOCKETS_H_ #include -#include // For poll_table -#include // For TCP_NODELAY etc. +#include +#include #include -#include // For FIONREAD etc. -#include // For FD_SET -#include // For IOV_MAX -#include // For F_SETFL +#include +#include +#include +#include #include_next #include diff --git a/components/net/lwip-2.1/porting/src/netdb_porting.c b/components/net/lwip-2.1/porting/src/netdb_porting.c index 30accb25..804d7e07 100644 --- a/components/net/lwip-2.1/porting/src/netdb_porting.c +++ b/components/net/lwip-2.1/porting/src/netdb_porting.c @@ -29,7 +29,6 @@ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include "netdb.h" #include "lwip/netdb.h" struct hostent *gethostbyname(const char *name) From 788f9d2b4ff179090d3f04e3489ec647c960a247 Mon Sep 17 00:00:00 2001 From: YOUR_NAME Date: Mon, 12 Apr 2021 21:34:37 +0800 Subject: [PATCH 4/8] IssueNo:#I3IBCL Description:use posix instead of lwip self Feature or Bugfix:Bugfix Binary Source:No --- components/net/lwip-2.1/porting/include/arch/sys_arch.h | 1 - 1 file changed, 1 deletion(-) diff --git a/components/net/lwip-2.1/porting/include/arch/sys_arch.h b/components/net/lwip-2.1/porting/include/arch/sys_arch.h index d8c3513f..16b89d75 100644 --- a/components/net/lwip-2.1/porting/include/arch/sys_arch.h +++ b/components/net/lwip-2.1/porting/include/arch/sys_arch.h @@ -33,7 +33,6 @@ #define _LWIP_PORTING_SYS_ARCH_H_ #include -#include "los_mux.h" #ifdef __cplusplus extern "C" { From 2b88a46965def43eda60fc072ca709e041e661c1 Mon Sep 17 00:00:00 2001 From: Caoruihong Date: Thu, 15 Apr 2021 00:12:37 +0800 Subject: [PATCH 5/8] support osThreadNew with NULL attr parameter and fix priority issues Change-Id: Ie26b6878f8742207545e55372f724872a932542a --- kal/cmsis/cmsis_liteos2.c | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/kal/cmsis/cmsis_liteos2.c b/kal/cmsis/cmsis_liteos2.c index c37552a8..24021f1f 100755 --- a/kal/cmsis/cmsis_liteos2.c +++ b/kal/cmsis/cmsis_liteos2.c @@ -58,7 +58,12 @@ static osKernelState_t g_kernelState; extern BOOL g_taskScheduled; -#define LOS_PRIORITY_WIN 8 +/* LOSCFG_BASE_CORE_TSK_DEFAULT_PRIO <---> osPriorityNormal */ +#define LOS_PRIORITY(cmsisPriority) (LOSCFG_BASE_CORE_TSK_DEFAULT_PRIO - ((cmsisPriority) - osPriorityNormal)) +#define CMSIS_PRIORITY(losPriority) (osPriorityNormal + (LOSCFG_BASE_CORE_TSK_DEFAULT_PRIO - (losPriority))) + +/* OS_TASK_PRIORITY_HIGHEST and OS_TASK_PRIORITY_LOWEST is reserved for internal TIMER and IDLE task use only. */ +#define ISVALID_LOS_PRIORITY(losPrio) ((losPrio) > OS_TASK_PRIORITY_HIGHEST && (losPrio) < OS_TASK_PRIORITY_LOWEST) const osVersion_t g_stLosVersion = { 001, 001 }; @@ -74,8 +79,6 @@ const osVersion_t g_stLosVersion = { 001, 001 }; #define KERNEL_ID "HUAWEI-LiteOS" // ==== Kernel Management Functions ==== -uint32_t osTaskStackWaterMarkGet(UINT32 taskID); - osStatus_t osKernelInitialize(void) { @@ -303,27 +306,28 @@ osThreadId_t osThreadNew(osThreadFunc_t func, void *argument, const osThreadAttr UINT32 uwTid; UINT32 uwRet; LosTaskCB *pstTaskCB = NULL; - TSK_INIT_PARAM_S stTskInitParam; + TSK_INIT_PARAM_S stTskInitParam = {NULL}; + UINT16 usPriority; - if (OS_INT_ACTIVE) { - return NULL; - } - - if ((attr == NULL) || (func == NULL) || (attr->priority < osPriorityLow1) || - (attr->priority > osPriorityAboveNormal6)) { + if (OS_INT_ACTIVE || (func == NULL)) { + return (osThreadId_t)NULL; + } + + usPriority = attr ? LOS_PRIORITY(attr->priority) : LOSCFG_BASE_CORE_TSK_DEFAULT_PRIO; + if (!ISVALID_LOS_PRIORITY(usPriority)) { + /* unsupported priority */ return (osThreadId_t)NULL; } - (void)memset_s(&stTskInitParam, sizeof(TSK_INIT_PARAM_S), 0, sizeof(TSK_INIT_PARAM_S)); stTskInitParam.pfnTaskEntry = (TSK_ENTRY_FUNC)func; #ifndef LITEOS_WIFI_IOT_VERSION stTskInitParam.uwArg = (UINT32)argument; #else stTskInitParam.auwArgs[0] = (UINT32)argument; #endif - stTskInitParam.uwStackSize = attr->stack_size; - stTskInitParam.pcName = (CHAR *)attr->name; - stTskInitParam.usTaskPrio = OS_TASK_PRIORITY_LOWEST - ((UINT16)(attr->priority) - LOS_PRIORITY_WIN); /* 0~31 */ + stTskInitParam.uwStackSize = attr ? attr->stack_size : LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE; + stTskInitParam.pcName = (CHAR *)(attr ? attr->name : "[NULL]"); + stTskInitParam.usTaskPrio = usPriority; uwRet = LOS_TaskCreate(&uwTid, &stTskInitParam); @@ -483,12 +487,12 @@ osStatus_t osThreadSetPriority(osThreadId_t thread_id, osPriority_t priority) return osErrorParameter; } - if (priority < osPriorityLow1 || priority > osPriorityAboveNormal6) { + usPriority = LOS_PRIORITY(priority); + if (!ISVALID_LOS_PRIORITY(usPriority)) { return osErrorParameter; } pstTaskCB = (LosTaskCB *)thread_id; - usPriority = OS_TASK_PRIORITY_LOWEST - ((UINT16)priority - LOS_PRIORITY_WIN); uwRet = LOS_TaskPriSet(pstTaskCB->taskID, usPriority); switch (uwRet) { case LOS_ERRNO_TSK_PRIOR_ERROR: @@ -521,7 +525,7 @@ osPriority_t osThreadGetPriority(osThreadId_t thread_id) return osPriorityError; } - return (osPriority_t)(OS_TASK_PRIORITY_LOWEST - (usRet - LOS_PRIORITY_WIN)); + return (osPriority_t)CMSIS_PRIORITY(usRet); } From 84a9f655979985b7980b5780a0aa66bcefa1abdc Mon Sep 17 00:00:00 2001 From: arvinzzz Date: Thu, 15 Apr 2021 15:37:43 +0800 Subject: [PATCH 6/8] Description: The hook adaptation layer adds support for interrupts on other platforms. Change-Id: I09636885b2edf893322ea5fb0eabef02266875a0 --- kernel/arch/arm/cortex-m3/keil/los_interrupt.c | 5 +++++ kernel/arch/arm/cortex-m33/gcc/los_interrupt.c | 5 +++++ kernel/arch/arm/cortex-m4/gcc/los_interrupt.c | 5 +++++ kernel/arch/arm/cortex-m4/iar/los_interrupt.c | 4 ++-- kernel/arch/arm/cortex-m7/gcc/los_interrupt.c | 5 +++++ kernel/arch/arm/cortex-m7/iar/los_interrupt.c | 4 ++-- kernel/arch/risc-v/riscv32/gcc/los_interrupt.c | 5 +++++ .../project/los_demo.uvproj | 5 +++++ 8 files changed, 34 insertions(+), 4 deletions(-) diff --git a/kernel/arch/arm/cortex-m3/keil/los_interrupt.c b/kernel/arch/arm/cortex-m3/keil/los_interrupt.c index 54756f26..79975442 100755 --- a/kernel/arch/arm/cortex-m3/keil/los_interrupt.c +++ b/kernel/arch/arm/cortex-m3/keil/los_interrupt.c @@ -35,6 +35,7 @@ #include "los_context.h" #include "los_arch_interrupt.h" #include "los_debug.h" +#include "los_hook.h" #include "los_task.h" #include "los_memory.h" #include "los_membox.h" @@ -177,6 +178,8 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID) hwiIndex = HalIntNumGet(); + OsHookCall(LOS_HOOK_TYPE_ISR_ENTER, hwiIndex); + HalPreInterruptHandler(hwiIndex); #if (OS_HWI_WITH_ARG == 1) @@ -191,6 +194,8 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID) HalAftInterruptHandler(hwiIndex); + OsHookCall(LOS_HOOK_TYPE_ISR_EXIT, hwiIndex); + intSave = LOS_IntLock(); g_intCount--; LOS_IntRestore(intSave); diff --git a/kernel/arch/arm/cortex-m33/gcc/los_interrupt.c b/kernel/arch/arm/cortex-m33/gcc/los_interrupt.c index 42d1d414..dcb5fa0d 100755 --- a/kernel/arch/arm/cortex-m33/gcc/los_interrupt.c +++ b/kernel/arch/arm/cortex-m33/gcc/los_interrupt.c @@ -34,6 +34,7 @@ #include "los_context.h" #include "los_arch_interrupt.h" #include "los_debug.h" +#include "los_hook.h" #include "los_task.h" #include "los_memory.h" #include "los_membox.h" @@ -166,6 +167,8 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID) hwiIndex = HalIntNumGet(); + OsHookCall(LOS_HOOK_TYPE_ISR_ENTER, hwiIndex); + HalPreInterruptHandler(hwiIndex); #if (OS_HWI_WITH_ARG == 1) @@ -180,6 +183,8 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID) HalAftInterruptHandler(hwiIndex); + OsHookCall(LOS_HOOK_TYPE_ISR_EXIT, hwiIndex); + intSave = LOS_IntLock(); g_intCount--; LOS_IntRestore(intSave); diff --git a/kernel/arch/arm/cortex-m4/gcc/los_interrupt.c b/kernel/arch/arm/cortex-m4/gcc/los_interrupt.c index d4d48132..797da7ea 100644 --- a/kernel/arch/arm/cortex-m4/gcc/los_interrupt.c +++ b/kernel/arch/arm/cortex-m4/gcc/los_interrupt.c @@ -34,6 +34,7 @@ #include "los_context.h" #include "los_arch_interrupt.h" #include "los_debug.h" +#include "los_hook.h" #include "los_task.h" #include "los_memory.h" #include "los_membox.h" @@ -176,6 +177,8 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID) hwiIndex = HalIntNumGet(); + OsHookCall(LOS_HOOK_TYPE_ISR_ENTER, hwiIndex); + HalPreInterruptHandler(hwiIndex); #if (OS_HWI_WITH_ARG == 1) @@ -190,6 +193,8 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID) HalAftInterruptHandler(hwiIndex); + OsHookCall(LOS_HOOK_TYPE_ISR_EXIT, hwiIndex); + intSave = LOS_IntLock(); g_intCount--; LOS_IntRestore(intSave); diff --git a/kernel/arch/arm/cortex-m4/iar/los_interrupt.c b/kernel/arch/arm/cortex-m4/iar/los_interrupt.c index 35b41b71..96d491b8 100755 --- a/kernel/arch/arm/cortex-m4/iar/los_interrupt.c +++ b/kernel/arch/arm/cortex-m4/iar/los_interrupt.c @@ -194,11 +194,11 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID) HalAftInterruptHandler(hwiIndex); + OsHookCall(LOS_HOOK_TYPE_ISR_EXIT, hwiIndex); + intSave = LOS_IntLock(); g_intCount--; LOS_IntRestore(intSave); - - OsHookCall(LOS_HOOK_TYPE_ISR_EXIT, hwiIndex); } /* **************************************************************************** diff --git a/kernel/arch/arm/cortex-m7/gcc/los_interrupt.c b/kernel/arch/arm/cortex-m7/gcc/los_interrupt.c index 582e7eec..03900d83 100755 --- a/kernel/arch/arm/cortex-m7/gcc/los_interrupt.c +++ b/kernel/arch/arm/cortex-m7/gcc/los_interrupt.c @@ -34,6 +34,7 @@ #include "los_context.h" #include "los_arch_interrupt.h" #include "los_debug.h" +#include "los_hook.h" #include "los_task.h" #include "los_memory.h" #include "los_membox.h" @@ -166,6 +167,8 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID) hwiIndex = HalIntNumGet(); + OsHookCall(LOS_HOOK_TYPE_ISR_ENTER, hwiIndex); + HalPreInterruptHandler(hwiIndex); #if (OS_HWI_WITH_ARG == 1) @@ -180,6 +183,8 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID) HalAftInterruptHandler(hwiIndex); + OsHookCall(LOS_HOOK_TYPE_ISR_EXIT, hwiIndex); + intSave = LOS_IntLock(); g_intCount--; LOS_IntRestore(intSave); diff --git a/kernel/arch/arm/cortex-m7/iar/los_interrupt.c b/kernel/arch/arm/cortex-m7/iar/los_interrupt.c index 2a40bea1..b5212801 100755 --- a/kernel/arch/arm/cortex-m7/iar/los_interrupt.c +++ b/kernel/arch/arm/cortex-m7/iar/los_interrupt.c @@ -190,11 +190,11 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID) HalAftInterruptHandler(hwiIndex); + OsHookCall(LOS_HOOK_TYPE_ISR_EXIT, hwiIndex); + intSave = LOS_IntLock(); g_intCount--; LOS_IntRestore(intSave); - - OsHookCall(LOS_HOOK_TYPE_ISR_EXIT, hwiIndex); } /* **************************************************************************** diff --git a/kernel/arch/risc-v/riscv32/gcc/los_interrupt.c b/kernel/arch/risc-v/riscv32/gcc/los_interrupt.c index 8ad07867..2b6f5762 100755 --- a/kernel/arch/risc-v/riscv32/gcc/los_interrupt.c +++ b/kernel/arch/risc-v/riscv32/gcc/los_interrupt.c @@ -36,6 +36,7 @@ #include "los_arch_context.h" #include "los_task.h" #include "los_debug.h" +#include "los_hook.h" #include "riscv_hal.h" #ifdef __cplusplus @@ -120,12 +121,16 @@ __attribute__((section(".interrupt.text"))) VOID HalHwiInterruptDone(HWI_HANDLE_ { g_intCount++; + OsHookCall(LOS_HOOK_TYPE_ISR_ENTER, hwiNum); + HWI_HANDLE_FORM_S *hwiForm = &g_hwiForm[hwiNum]; HwiProcFunc func = (HwiProcFunc)(hwiForm->pfnHook); func(hwiForm->uwParam); ++g_hwiFormCnt[hwiNum]; + OsHookCall(LOS_HOOK_TYPE_ISR_EXIT, hwiNum); + g_intCount--; } diff --git a/targets/cortex-m3_stm32f103_simulator_keil/project/los_demo.uvproj b/targets/cortex-m3_stm32f103_simulator_keil/project/los_demo.uvproj index f8129709..beee6ef9 100644 --- a/targets/cortex-m3_stm32f103_simulator_keil/project/los_demo.uvproj +++ b/targets/cortex-m3_stm32f103_simulator_keil/project/los_demo.uvproj @@ -512,6 +512,11 @@ 1 ..\..\..\utils\los_error.c + + los_hook.c + 1 + ..\..\..\utils\los_hook.c + los_context.c 1 From 92c4e63ae77ecd76367ecfcecac3295936660634 Mon Sep 17 00:00:00 2001 From: YOUR_NAME Date: Thu, 15 Apr 2021 20:00:41 +0800 Subject: [PATCH 7/8] IssueNo:#I3IMWT Description:use posix instead of lwip self Feature or Bugfix:Bugfix Binary Source:No --- components/net/lwip-2.1/porting/include/arch/cc.h | 2 +- components/net/lwip-2.1/porting/include/lwip/netdb.h | 4 ---- components/net/test/lwip_test.h | 1 - components/net/test/net_socket_test_002.c | 1 - components/net/test/net_socket_test_003.c | 1 - components/net/test/net_socket_test_007.c | 1 - components/net/test/net_socket_test_008.c | 2 -- components/net/test/net_socket_test_009.c | 2 -- components/net/test/net_socket_test_010.c | 2 -- components/net/test/net_socket_test_012.c | 1 - components/net/test/net_socket_test_013.c | 2 -- kal/posix/musl_src/network/h_errno.c | 9 +++++++++ 12 files changed, 10 insertions(+), 18 deletions(-) create mode 100644 kal/posix/musl_src/network/h_errno.c diff --git a/components/net/lwip-2.1/porting/include/arch/cc.h b/components/net/lwip-2.1/porting/include/arch/cc.h index c2eebaf5..64e364fa 100644 --- a/components/net/lwip-2.1/porting/include/arch/cc.h +++ b/components/net/lwip-2.1/porting/include/arch/cc.h @@ -44,7 +44,6 @@ #include #include #include "securec.h" -#include "log.h" #include "memory_pool.h" #ifdef htons @@ -62,6 +61,7 @@ #define LWIP_DNS_API_DEFINE_ERRORS 0 #define LWIP_DNS_API_DEFINE_FLAGS 0 #define LWIP_DNS_API_DECLARE_STRUCTS 0 +#define LWIP_DNS_API_DECLARE_H_ERRNO 0 #ifndef __SIZEOF_POINTER__ #define __SIZEOF_POINTER__ 4 // 32 bit system diff --git a/components/net/lwip-2.1/porting/include/lwip/netdb.h b/components/net/lwip-2.1/porting/include/lwip/netdb.h index 7172ea84..aea2dbc9 100644 --- a/components/net/lwip-2.1/porting/include/lwip/netdb.h +++ b/components/net/lwip-2.1/porting/include/lwip/netdb.h @@ -35,8 +35,4 @@ #include #include_next -#ifdef h_errno -#undef h_errno -#endif - #endif /* _LWIP_PORTING_NETDB_H_ */ diff --git a/components/net/test/lwip_test.h b/components/net/test/lwip_test.h index 9e190df9..9b0894aa 100644 --- a/components/net/test/lwip_test.h +++ b/components/net/test/lwip_test.h @@ -36,7 +36,6 @@ #include "lwip/sockets.h" #include #include -#include "log.h" #include "securec.h" #ifdef __cplusplus diff --git a/components/net/test/net_socket_test_002.c b/components/net/test/net_socket_test_002.c index b08efb00..2a225872 100644 --- a/components/net/test/net_socket_test_002.c +++ b/components/net/test/net_socket_test_002.c @@ -38,7 +38,6 @@ #define TEST_CASE 120 static char g_buf[BUF_SIZE + 1] = { 0 }; -extern sys_thread_t sys_thread_new(const char *name, lwip_thread_fn thread, void *arg, int stackSize, int prio); void UdpTestTask(void *p) { diff --git a/components/net/test/net_socket_test_003.c b/components/net/test/net_socket_test_003.c index 120d5822..86854d2e 100644 --- a/components/net/test/net_socket_test_003.c +++ b/components/net/test/net_socket_test_003.c @@ -39,7 +39,6 @@ #define TEST_CASE 130 static char g_buf[BUF_SIZE + 1] = { 0 }; -extern sys_thread_t sys_thread_new(const char *name, lwip_thread_fn thread, void *arg, int stackSize, int prio); static int SampleTcpServer() { diff --git a/components/net/test/net_socket_test_007.c b/components/net/test/net_socket_test_007.c index 70845d1f..bb4d6c9d 100644 --- a/components/net/test/net_socket_test_007.c +++ b/components/net/test/net_socket_test_007.c @@ -40,7 +40,6 @@ static char g_buf_temp[BUF_SIZE + 1] = { 0 }; #define SEND_UDP_COUNT 10000 // send count #define TEST_CASE 170 -extern sys_thread_t sys_thread_new(const char *name, lwip_thread_fn thread, void *arg, int stackSize, int prio); static void UdpTestMoreTask(void *p) { (void)p; diff --git a/components/net/test/net_socket_test_008.c b/components/net/test/net_socket_test_008.c index 6248d53d..f46106a8 100644 --- a/components/net/test/net_socket_test_008.c +++ b/components/net/test/net_socket_test_008.c @@ -41,8 +41,6 @@ static char g_serverSendBuf[BUF_SIZE + 1] = { 0 }; static char g_clientRecvBuf[BUF_SIZE + 1] = { 0 }; -extern sys_thread_t sys_thread_new(const char *name, lwip_thread_fn thread, void *arg, int stackSize, int prio); - static void InitMsgBuf() { int i; diff --git a/components/net/test/net_socket_test_009.c b/components/net/test/net_socket_test_009.c index 282d1a10..95b678f4 100644 --- a/components/net/test/net_socket_test_009.c +++ b/components/net/test/net_socket_test_009.c @@ -43,8 +43,6 @@ static char g_buf[BUF_SIZE + 1] = { 0 }; -extern sys_thread_t sys_thread_new(const char *name, lwip_thread_fn thread, void *arg, int stackSize, int prio); - static int SampleTcpServer() { #if LWIP_SOCKET_SELECT diff --git a/components/net/test/net_socket_test_010.c b/components/net/test/net_socket_test_010.c index 9b5d8434..354cbbd8 100644 --- a/components/net/test/net_socket_test_010.c +++ b/components/net/test/net_socket_test_010.c @@ -43,8 +43,6 @@ #define TIME_OUT (1000 * 10) // timeout 10s static char g_buf[BUF_SIZE + 1] = { 0 }; -extern sys_thread_t sys_thread_new(const char *name, lwip_thread_fn thread, void *arg, int stackSize, int prio); - static int SampleTcpServer() { #if LWIP_SOCKET_POLL diff --git a/components/net/test/net_socket_test_012.c b/components/net/test/net_socket_test_012.c index 63073535..3385f337 100755 --- a/components/net/test/net_socket_test_012.c +++ b/components/net/test/net_socket_test_012.c @@ -45,7 +45,6 @@ static int g_portClient = STACK_PORT_TCP_DUP_START; static char g_bufServer[BUF_SIZE + 1] = { 0 }; static char g_bufClient[BUF_SIZE + 1] = { 0 }; -extern sys_thread_t sys_thread_new(const char *name, lwip_thread_fn thread, void *arg, int stackSize, int prio); static int SampleTcpServer() { diff --git a/components/net/test/net_socket_test_013.c b/components/net/test/net_socket_test_013.c index 325393ac..ccf7ba3b 100755 --- a/components/net/test/net_socket_test_013.c +++ b/components/net/test/net_socket_test_013.c @@ -38,8 +38,6 @@ #define STACK_PORT_TCP_LONG 2231 #define TCP_LONG_BUF_SIZE (2 * 1024) -extern sys_thread_t sys_thread_new(const char *name, lwip_thread_fn thread, void *arg, int stackSize, int prio); - static int SampleTcpServer() { int sfd, lsfd; diff --git a/kal/posix/musl_src/network/h_errno.c b/kal/posix/musl_src/network/h_errno.c new file mode 100644 index 00000000..8c7082c2 --- /dev/null +++ b/kal/posix/musl_src/network/h_errno.c @@ -0,0 +1,9 @@ +#include + +#undef h_errno +int h_errno; + +int *__h_errno_location(void) +{ + return &h_errno; +} From a5338840c08c8842d3a7efa4782b13a77e2ed7b9 Mon Sep 17 00:00:00 2001 From: Caoruihong Date: Fri, 16 Apr 2021 14:48:32 +0800 Subject: [PATCH 8/8] fix osEventFlagsGet for #I3IP98 --- kal/cmsis/cmsis_liteos2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kal/cmsis/cmsis_liteos2.c b/kal/cmsis/cmsis_liteos2.c index 24021f1f..a8acb51f 100755 --- a/kal/cmsis/cmsis_liteos2.c +++ b/kal/cmsis/cmsis_liteos2.c @@ -895,7 +895,7 @@ uint32_t osEventFlagsGet(osEventFlagsId_t ef_id) uint32_t rflags; if (pstEventCB == NULL) { - return (uint32_t)osFlagsErrorParameter; + return 0; } uwIntSave = LOS_IntLock();