Compare commits
21 Commits
OpenHarmon
...
OpenHarmon
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2a307e190c | ||
|
|
cbf094bc51 | ||
|
|
32b8750966 | ||
|
|
31efd1ec5d | ||
|
|
3caf86f6dc | ||
|
|
71bb445d77 | ||
|
|
94d906094c | ||
|
|
0d403fc524 | ||
|
|
b91d6a3704 | ||
|
|
bfb54af7bb | ||
|
|
a6bacba3f7 | ||
|
|
a33ee3a427 | ||
|
|
c40329e1ea | ||
|
|
0cfa7bfcc2 | ||
|
|
e4ce40d386 | ||
|
|
294680f77b | ||
|
|
af1d5bb94b | ||
|
|
d7789ce6a2 | ||
|
|
a2c7a5279e | ||
|
|
4084cd0dbe | ||
|
|
7db6a2b82a |
11
.gitee/ISSUE_TEMPLATE.zh-CN.md
Normal file
11
.gitee/ISSUE_TEMPLATE.zh-CN.md
Normal file
@@ -0,0 +1,11 @@
|
||||
### 该问题是怎么引起的?
|
||||
|
||||
|
||||
|
||||
### 重现步骤
|
||||
|
||||
|
||||
|
||||
### 报错信息
|
||||
|
||||
|
||||
12
.gitee/PULL_REQUEST_TEMPLATE.zh-CN.md
Normal file
12
.gitee/PULL_REQUEST_TEMPLATE.zh-CN.md
Normal file
@@ -0,0 +1,12 @@
|
||||
### 相关的Issue
|
||||
|
||||
|
||||
### 原因(目的、解决的问题等)
|
||||
|
||||
|
||||
### 描述(做了什么,变更了什么)
|
||||
|
||||
|
||||
### 测试用例(新增、改动、可能影响的功能)
|
||||
|
||||
|
||||
@@ -125,7 +125,7 @@ STATIC INLINE UINT32 OsStackAddrGet(UINTPTR *stackStart, UINTPTR *stackEnd, UINT
|
||||
*stackEnd = (UINTPTR)taskCB->topOfStack + taskCB->stackSize;
|
||||
if ((SP < (UINTPTR)taskCB->topOfStack) || (SP >= *stackEnd)) {
|
||||
PRINT_ERR("msp statck [0x%x, 0x%x], cur task stack [0x%x, 0x%x], cur sp(0x%x) is overflow!\n",
|
||||
CODE_START_ADDR, CSTACK_END_ADDR, (UINTPTR)taskCB->topOfStack, *stackEnd, SP);
|
||||
CODE_START_ADDR, CSTACK_END_ADDR, (UINTPTR)taskCB->topOfStack, *stackEnd, SP);
|
||||
return LOS_NOK;
|
||||
}
|
||||
}
|
||||
@@ -135,7 +135,7 @@ STATIC INLINE UINT32 OsStackAddrGet(UINTPTR *stackStart, UINTPTR *stackEnd, UINT
|
||||
*stackEnd = CSTACK_END_ADDR;
|
||||
if ((*stackStart < CODE_START_ADDR) || (*stackStart >= CSTACK_END_ADDR)) {
|
||||
PRINT_ERR("msp stack [0x%x, 0x%x], cur sp(0x%x) is overflow!\n",
|
||||
CODE_START_ADDR, CSTACK_END_ADDR, *stackStart);
|
||||
CODE_START_ADDR, CSTACK_END_ADDR, *stackStart);
|
||||
return LOS_NOK;
|
||||
}
|
||||
PRINTK("msp, start = %x, end = %x\n", *stackStart, *stackEnd);
|
||||
@@ -146,7 +146,7 @@ STATIC INLINE UINT32 OsStackAddrGet(UINTPTR *stackStart, UINTPTR *stackEnd, UINT
|
||||
*stackEnd = (UINTPTR)taskCB->topOfStack + taskCB->stackSize;
|
||||
if ((*stackStart < (UINTPTR)taskCB->topOfStack) || (*stackStart >= *stackEnd)) {
|
||||
PRINT_ERR("psp stack [0x%x, 0x%x], cur sp(0x%x) is overflow, cur task id is %d!\n",
|
||||
taskCB->topOfStack, *stackEnd, *stackStart, taskID);
|
||||
taskCB->topOfStack, *stackEnd, *stackStart, taskID);
|
||||
return LOS_NOK;
|
||||
}
|
||||
PRINTK("psp, start = %x, end = %x\n", *stackStart, *stackEnd);
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -32,19 +32,42 @@
|
||||
#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 <endian.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#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 __SIZEOF_POINTER__ 4 // 32位系统
|
||||
#define SOCKLEN_T_DEFINED
|
||||
#define SA_FAMILY_T_DEFINED
|
||||
#define IN_PORT_T_DEFINED
|
||||
|
||||
#define LOS_TASK_STATUS_DETACHED 0x0100 // 预留字段
|
||||
#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
|
||||
#define LWIP_DNS_API_DECLARE_H_ERRNO 0
|
||||
|
||||
#ifndef __SIZEOF_POINTER__
|
||||
#define __SIZEOF_POINTER__ 4 // 32 bit system
|
||||
#endif
|
||||
|
||||
#define LOS_TASK_STATUS_DETACHED 0x0100 // reserved
|
||||
|
||||
#if defined(__arm__) && defined(__ARMCC_VERSION)
|
||||
/* Keil uVision4 tools */
|
||||
@@ -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")))
|
||||
|
||||
@@ -33,8 +33,6 @@
|
||||
#define _LWIP_PORTING_SYS_ARCH_H_
|
||||
|
||||
#include <stdint.h>
|
||||
#include "memory_pool.h"
|
||||
#include "los_mux.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
||||
65
components/net/lwip-2.1/porting/include/lwip/inet.h
Normal file
65
components/net/lwip-2.1/porting/include/lwip/inet.h
Normal file
@@ -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 <arpa/inet.h>
|
||||
#include <netinet/in.h>
|
||||
#include_next <lwip/inet.h>
|
||||
|
||||
#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_ */
|
||||
@@ -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
|
||||
|
||||
@@ -1,39 +1,38 @@
|
||||
/*
|
||||
* 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__
|
||||
/*
|
||||
* 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 <netdb.h>
|
||||
#include_next <lwip/netdb.h>
|
||||
|
||||
#endif /* _LWIP_PORTING_NETDB_H_ */
|
||||
@@ -32,6 +32,9 @@
|
||||
#ifndef _LWIP_PORTING_NETIF_H_
|
||||
#define _LWIP_PORTING_NETIF_H_
|
||||
|
||||
#include <net/if.h>
|
||||
#include <netinet/ip.h>
|
||||
|
||||
#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 <lwip/netif.h>
|
||||
#undef linkoutput
|
||||
@@ -52,7 +54,7 @@
|
||||
#undef LWIP_NETIF_CLIENT_DATA_INDEX_DHCP
|
||||
#endif
|
||||
|
||||
#include <lwip/etharp.h> // For ETHARP_HWADDR_LEN, by `hieth-sf src/interface.c' and `wal/wal_net.c'
|
||||
#include <lwip/etharp.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -60,9 +62,9 @@ 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 LOOPBACK_IF 0
|
||||
#define ETHERNET_DRIVER_IF 1
|
||||
#define WIFI_DRIVER_IF 801
|
||||
#define BT_PROXY_IF 802
|
||||
|
||||
@@ -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 <sys/socket.h>
|
||||
#include <poll.h>
|
||||
#include <netinet/tcp.h>
|
||||
#include <netinet/in.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/select.h>
|
||||
#include <limits.h>
|
||||
#include <fcntl.h>
|
||||
#include_next <lwip/sockets.h>
|
||||
#include <fatfs.h>
|
||||
|
||||
#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)
|
||||
#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_ */
|
||||
@@ -29,7 +29,7 @@
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "netdb.h"
|
||||
#include "lwip/netdb.h"
|
||||
|
||||
struct hostent *gethostbyname(const char *name)
|
||||
{
|
||||
|
||||
@@ -41,15 +41,15 @@
|
||||
#include <los_timer.h>
|
||||
#include <los_config.h>
|
||||
|
||||
#define YES 1
|
||||
#define NO 0
|
||||
#define LOSCFG_KERNEL_SMP NO
|
||||
#ifndef LOSCFG_KERNEL_SMP
|
||||
#define LOSCFG_KERNEL_SMP 0
|
||||
#endif
|
||||
|
||||
#if (LOSCFG_KERNEL_SMP == YES)
|
||||
#if (LOSCFG_KERNEL_SMP)
|
||||
SPIN_LOCK_INIT(arch_protect_spin);
|
||||
static u32_t lwprot_thread = LOS_ERRNO_TSK_ID_INVALID;
|
||||
static int lwprot_count = 0;
|
||||
#endif /* LOSCFG_KERNEL_SMP == YES */
|
||||
#endif /* LOSCFG_KERNEL_SMP */
|
||||
|
||||
#define ROUND_UP_DIV(val, div) (((val) + (div) - 1) / (div))
|
||||
#define LWIP_LOG_BUF_SIZE 64
|
||||
@@ -98,7 +98,7 @@ u32_t sys_now(void)
|
||||
*/
|
||||
sys_prot_t sys_arch_protect(void)
|
||||
{
|
||||
#if (LOSCFG_KERNEL_SMP == YES)
|
||||
#if (LOSCFG_KERNEL_SMP)
|
||||
/* Note that we are using spinlock instead of mutex for LiteOS-SMP here:
|
||||
* 1. spinlock is more effective for short critical region protection.
|
||||
* 2. this function is called only in task context, not in interrupt handler.
|
||||
@@ -116,14 +116,14 @@ sys_prot_t sys_arch_protect(void)
|
||||
}
|
||||
#else
|
||||
LOS_TaskLock();
|
||||
#endif /* LOSCFG_KERNEL_SMP == YES */
|
||||
#endif /* LOSCFG_KERNEL_SMP */
|
||||
return 0; /* return value is unused */
|
||||
}
|
||||
|
||||
void sys_arch_unprotect(sys_prot_t pval)
|
||||
{
|
||||
LWIP_UNUSED_ARG(pval);
|
||||
#if (LOSCFG_KERNEL_SMP == YES)
|
||||
#if (LOSCFG_KERNEL_SMP)
|
||||
if (lwprot_thread == LOS_CurTaskIDGet()) {
|
||||
lwprot_count--;
|
||||
if (lwprot_count == 0) {
|
||||
@@ -133,7 +133,7 @@ void sys_arch_unprotect(sys_prot_t pval)
|
||||
}
|
||||
#else
|
||||
LOS_TaskUnlock();
|
||||
#endif /* LOSCFG_KERNEL_SMP == YES */
|
||||
#endif /* LOSCFG_KERNEL_SMP */
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -32,8 +32,10 @@
|
||||
#ifndef LWIP_TEST_H
|
||||
#define LWIP_TEST_H
|
||||
|
||||
#include "lwip/arch.h"
|
||||
#include "lwip/sockets.h"
|
||||
#include <sys/socket.h>
|
||||
#include "log.h"
|
||||
#include <arpa/inet.h>
|
||||
#include "securec.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -30,14 +30,18 @@
|
||||
*/
|
||||
|
||||
#include "lwip_test.h"
|
||||
#include "lwipopts.h"
|
||||
#include <arch/sys_arch.h>
|
||||
#include <lwip/sys.h>
|
||||
|
||||
#define MSG "Hi, I am UDP"
|
||||
#define TEST_CASE 120
|
||||
|
||||
static char g_buf[BUF_SIZE + 1] = { 0 };
|
||||
|
||||
int UdpTest(void)
|
||||
void UdpTestTask(void *p)
|
||||
{
|
||||
(void)p;
|
||||
LogPrintln("net_socket_test_002.c enter");
|
||||
g_testCase = TEST_CASE;
|
||||
int sfd;
|
||||
@@ -111,6 +115,13 @@ int UdpTest(void)
|
||||
/* close socket */
|
||||
ret = closesocket(sfd);
|
||||
LWIP_ASSERT("socket invalid param.", ret != -1);
|
||||
return LWIP_TEST_RET_OK;
|
||||
return;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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()
|
||||
{
|
||||
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)
|
||||
|
||||
@@ -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()
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -5,6 +5,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 <limits.h>
|
||||
#else
|
||||
|
||||
|
||||
9
kal/posix/musl_src/network/h_errno.c
Normal file
9
kal/posix/musl_src/network/h_errno.c
Normal file
@@ -0,0 +1,9 @@
|
||||
#include <netdb.h>
|
||||
|
||||
#undef h_errno
|
||||
int h_errno;
|
||||
|
||||
int *__h_errno_location(void)
|
||||
{
|
||||
return &h_errno;
|
||||
}
|
||||
@@ -97,7 +97,7 @@ int pthread_create(pthread_t *thread, const pthread_attr_t *attr,
|
||||
taskInitParam.pfnTaskEntry = PthreadEntry;
|
||||
taskInitParam.uwArg = (UINT32)(UINTPTR)pthreadData;
|
||||
|
||||
if (LOS_TaskCreate(&taskID, &taskInitParam) != LOS_OK) {
|
||||
if (LOS_TaskCreateOnly(&taskID, &taskInitParam) != LOS_OK) {
|
||||
free(pthreadData);
|
||||
return EINVAL;
|
||||
}
|
||||
@@ -105,6 +105,8 @@ int pthread_create(pthread_t *thread, const pthread_attr_t *attr,
|
||||
/* set pthread default name */
|
||||
(void)sprintf_s(taskInitParam.pcName, PTHREAD_NAMELEN, "pthread%u", taskID);
|
||||
|
||||
(void)LOS_TaskResume(taskID);
|
||||
|
||||
*thread = (pthread_t)taskID;
|
||||
return 0;
|
||||
}
|
||||
|
||||
179
kal/posix/src/time.c
Executable file → Normal file
179
kal/posix/src/time.c
Executable file → Normal file
@@ -55,16 +55,15 @@ STATIC const UINT16 g_daysInMonth[2][13] = {
|
||||
|
||||
STATIC const UINT8 g_montbl[12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
|
||||
|
||||
static UINT64 g_rtcTimeBase = 0;
|
||||
static UINT64 g_systickBase = 0;
|
||||
|
||||
/*
|
||||
* Time zone information, stored in minutes,
|
||||
* Time zone information, stored in seconds,
|
||||
* negative values indicate the east of UTC,
|
||||
* positive values indicate the west of UTC.
|
||||
*/
|
||||
static INT32 g_rtcTimeZone = -480;
|
||||
static struct tm g_tm = {0};
|
||||
long timezone = -8 * 60 * 60; // defaults to CST: 8 hours east of the Prime Meridian
|
||||
|
||||
/* internal shared struct tm object for localtime and gmtime */
|
||||
static struct tm g_tm;
|
||||
|
||||
int nanosleep(const struct timespec *rqtp, struct timespec *rmtp)
|
||||
{
|
||||
@@ -405,33 +404,28 @@ int clock_nanosleep(clockid_t clk, int flags, const struct timespec *req, struct
|
||||
|
||||
clock_t clock(void)
|
||||
{
|
||||
return HalGetExpandTick();
|
||||
clock_t clk;
|
||||
struct timespec hwTime;
|
||||
OsGetHwTime(&hwTime);
|
||||
|
||||
clk = hwTime.tv_sec * CLOCKS_PER_SEC;
|
||||
clk += hwTime.tv_nsec / (OS_SYS_NS_PER_SECOND / CLOCKS_PER_SEC);
|
||||
|
||||
return clk;
|
||||
}
|
||||
|
||||
time_t time(time_t *timer)
|
||||
{
|
||||
UINT64 usec = 0;
|
||||
time_t sec;
|
||||
INT32 rtcRet;
|
||||
struct timespec ts;
|
||||
|
||||
rtcRet = HalGetRtcTime(&usec);
|
||||
if (rtcRet != 0) {
|
||||
UINT64 currentTime;
|
||||
UINT64 tickDelta;
|
||||
UINT64 currentTick = HalGetExpandTick();
|
||||
if ((g_systickBase != 0) && (currentTick > g_systickBase)) {
|
||||
tickDelta = currentTick - g_systickBase;
|
||||
}
|
||||
currentTime = g_rtcTimeBase + tickDelta;
|
||||
sec = currentTime / OS_SYS_MS_PER_SECOND;
|
||||
} else {
|
||||
sec = usec / OS_SYS_US_PER_SECOND;
|
||||
if (-1 == clock_gettime(CLOCK_REALTIME, &ts)) {
|
||||
return (time_t)-1;
|
||||
}
|
||||
|
||||
if (timer != NULL) {
|
||||
*timer = sec;
|
||||
*timer = ts.tv_sec;
|
||||
}
|
||||
return sec;
|
||||
return ts.tv_sec;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -494,23 +488,23 @@ static INT32 ConvertSecs2Utc(time_t t, INT32 offset, struct tm *tp)
|
||||
days -= daysInMonth[month];
|
||||
tp->tm_mon = month;
|
||||
tp->tm_mday = days + 1;
|
||||
tp->__tm_gmtoff = offset;
|
||||
tp->__tm_zone = NULL;
|
||||
tp->tm_isdst = 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
struct tm *gmtime_r(const time_t *timer, struct tm *tp)
|
||||
struct tm *gmtime_r(const time_t *timep, struct tm *result)
|
||||
{
|
||||
time_t t64;
|
||||
UINT32 intSave;
|
||||
if ((timer == NULL) || (tp == NULL)) {
|
||||
if ((timep == NULL) || (result == NULL)) {
|
||||
errno = EFAULT;
|
||||
return NULL;
|
||||
}
|
||||
intSave = LOS_IntLock();
|
||||
t64 = *timer;
|
||||
if (!ConvertSecs2Utc(t64, 0, tp)) {
|
||||
tp = NULL;
|
||||
if (!ConvertSecs2Utc(*timep, 0, result)) {
|
||||
errno = EINVAL;
|
||||
return NULL;
|
||||
}
|
||||
(void)LOS_IntRestore(intSave);
|
||||
return tp;
|
||||
return result;
|
||||
}
|
||||
|
||||
struct tm *gmtime(const time_t *timer)
|
||||
@@ -518,22 +512,17 @@ struct tm *gmtime(const time_t *timer)
|
||||
return gmtime_r(timer, &g_tm);
|
||||
}
|
||||
|
||||
struct tm *localtime_r(const time_t *timer, struct tm *tp)
|
||||
struct tm *localtime_r(const time_t *timep, struct tm *result)
|
||||
{
|
||||
UINT32 intSave;
|
||||
time_t t64;
|
||||
INT32 offset;
|
||||
if ((timer == NULL) || (tp == NULL)) {
|
||||
if ((timep == NULL) || (result == NULL)) {
|
||||
errno = EFAULT;
|
||||
return NULL;
|
||||
}
|
||||
intSave = LOS_IntLock();
|
||||
t64 = *timer;
|
||||
offset = -(g_rtcTimeZone * SECS_PER_MIN);
|
||||
if (!ConvertSecs2Utc(t64, offset, tp)) {
|
||||
tp = NULL;
|
||||
if (!ConvertSecs2Utc(*timep, -timezone, result)) {
|
||||
errno = EINVAL;
|
||||
return NULL;
|
||||
}
|
||||
(void)LOS_IntRestore(intSave);
|
||||
return tp;
|
||||
return result;
|
||||
}
|
||||
|
||||
struct tm *localtime(const time_t *timer)
|
||||
@@ -569,78 +558,90 @@ static time_t ConvertUtc2Secs(struct tm *tm)
|
||||
}
|
||||
|
||||
seconds += (tm->tm_mday - 1) * SECS_PER_DAY;
|
||||
|
||||
seconds += tm->tm_hour * SECS_PER_HOUR + tm->tm_min * SECS_PER_MIN + tm->tm_sec;
|
||||
|
||||
seconds -= tm->__tm_gmtoff; // sub time zone to get UTC time
|
||||
return seconds;
|
||||
}
|
||||
|
||||
time_t mktime(struct tm *tmptr)
|
||||
{
|
||||
struct tm tempTime;
|
||||
time_t timeInSeconds;
|
||||
if (tmptr == NULL) {
|
||||
return 0;
|
||||
errno = EFAULT;
|
||||
return (time_t)-1;
|
||||
}
|
||||
if (tmptr->tm_year < (EPOCH_YEAR - TM_YEAR_BASE)) {
|
||||
return 0;
|
||||
|
||||
/* tm_isdst is not supported and is ignored */
|
||||
if (tmptr->tm_year < (EPOCH_YEAR - TM_YEAR_BASE) ||
|
||||
tmptr->__tm_gmtoff > (-TIME_ZONE_MIN * SECS_PER_MIN) ||
|
||||
tmptr->__tm_gmtoff < (-TIME_ZONE_MAX * SECS_PER_MIN) ||
|
||||
tmptr->tm_sec > 60 || tmptr->tm_sec < 0 || /* Seconds [0-60] */
|
||||
tmptr->tm_min > 59 || tmptr->tm_min < 0 || /* Minutes [0-59] */
|
||||
tmptr->tm_hour > 23 || tmptr->tm_hour < 0 || /* Hours [0-23] */
|
||||
tmptr->tm_mday > 31 || tmptr->tm_mday < 1 || /* Day of the month [1-31] */
|
||||
tmptr->tm_mon > 11 || tmptr->tm_mon < 0) { /* Month [0-11] */
|
||||
errno = EOVERFLOW;
|
||||
return (time_t)-1;
|
||||
}
|
||||
tempTime = *tmptr;
|
||||
timeInSeconds = ConvertUtc2Secs(&tempTime);
|
||||
timeInSeconds += g_rtcTimeZone * SECS_PER_MIN;
|
||||
timeInSeconds = ConvertUtc2Secs(tmptr);
|
||||
/* normalize tm_wday and tm_yday */
|
||||
ConvertSecs2Utc(timeInSeconds, tmptr->__tm_gmtoff, tmptr);
|
||||
return timeInSeconds;
|
||||
}
|
||||
|
||||
int gettimeofday(struct timeval *tv, void *ptz)
|
||||
{
|
||||
INT32 rtcRet;
|
||||
INT32 timeZone = 0;
|
||||
UINT64 usec = 0;
|
||||
UINT64 currentTime;
|
||||
UINT64 tickDelta = 0;
|
||||
UINT64 currentTick;
|
||||
|
||||
struct timespec ts;
|
||||
struct timezone *tz = (struct timezone *)ptz;
|
||||
if ((tv == NULL) && (tz == NULL)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (tv != NULL) {
|
||||
rtcRet = HalGetRtcTime(&usec);
|
||||
if (rtcRet != 0) {
|
||||
currentTick = HalGetExpandTick();
|
||||
if ((g_systickBase != 0) && (currentTick > g_systickBase)) {
|
||||
tickDelta = currentTick - g_systickBase;
|
||||
}
|
||||
currentTime = g_rtcTimeBase + tickDelta;
|
||||
tv->tv_sec = currentTime / OS_SYS_MS_PER_SECOND;
|
||||
tv->tv_usec = (currentTime % OS_SYS_MS_PER_SECOND) * OS_SYS_MS_PER_SECOND;
|
||||
} else {
|
||||
tv->tv_sec = usec / OS_SYS_US_PER_SECOND;
|
||||
tv->tv_usec = usec % OS_SYS_US_PER_SECOND;
|
||||
if (-1 == clock_gettime(CLOCK_REALTIME, &ts)) {
|
||||
return -1;
|
||||
}
|
||||
tv->tv_sec = ts.tv_sec;
|
||||
tv->tv_usec = ts.tv_nsec / OS_SYS_NS_PER_US;
|
||||
}
|
||||
HalGetRtcTimeZone(&timeZone);
|
||||
if (tz != NULL) {
|
||||
tz->tz_minuteswest = timeZone;
|
||||
tz->tz_minuteswest = timezone / SECS_PER_MIN;
|
||||
tz->tz_dsttime = 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int settimeofday(const struct timeval *tv, const struct timezone *tz)
|
||||
{
|
||||
UINT64 usec;
|
||||
if ((tv == NULL) || (tz == NULL)) {
|
||||
struct timespec ts;
|
||||
INT32 rtcTimeZone = timezone;
|
||||
|
||||
if (tv == NULL) {
|
||||
errno = EFAULT;
|
||||
return -1;
|
||||
}
|
||||
g_rtcTimeBase = tv->tv_sec * OS_SYS_MS_PER_SECOND + tv->tv_usec / OS_SYS_MS_PER_SECOND;
|
||||
g_systickBase = HalGetExpandTick();
|
||||
if ((tz->tz_minuteswest > TIME_ZONE_MIN) &&
|
||||
(tz->tz_minuteswest < TIME_ZONE_MAX)) {
|
||||
g_rtcTimeZone = tz->tz_minuteswest;
|
||||
|
||||
if (tz != NULL) {
|
||||
if ((tz->tz_minuteswest >= TIME_ZONE_MIN) &&
|
||||
(tz->tz_minuteswest <= TIME_ZONE_MAX)) {
|
||||
rtcTimeZone = tz->tz_minuteswest * SECS_PER_MIN;
|
||||
} else {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
usec = tv->tv_sec * OS_SYS_US_PER_SECOND + tv->tv_usec;
|
||||
HalSetRtcTime(g_rtcTimeBase, &usec);
|
||||
HalSetRtcTimeZone(g_rtcTimeZone);
|
||||
|
||||
if (tv->tv_usec >= OS_SYS_US_PER_SECOND) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
ts.tv_sec = tv->tv_sec;
|
||||
ts.tv_nsec = tv->tv_usec * OS_SYS_NS_PER_US;
|
||||
if (-1 == clock_settime(CLOCK_REALTIME, &ts)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
timezone = rtcTimeZone;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -652,4 +653,4 @@ int usleep(unsigned useconds)
|
||||
specTime.tv_sec = (time_t)(nanoseconds / OS_SYS_NS_PER_SECOND);
|
||||
specTime.tv_nsec = (long)(nanoseconds % OS_SYS_NS_PER_SECOND);
|
||||
return nanosleep(&specTime, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,8 +61,8 @@
|
||||
#define DAYS_PER_NORMAL_YEAR 365
|
||||
#define DAYS_PER_LEAP_YEAR 366
|
||||
#define BEGIN_WEEKDAY 4
|
||||
#define TIME_ZONE_MAX 720 /* 12 * 60 */
|
||||
#define TIME_ZONE_MIN (-840) /* -14 * 60 */
|
||||
#define TIME_ZONE_MAX 720 /* UTC-12:00 , the last time zone */
|
||||
#define TIME_ZONE_MIN (-840) /* UTC+14:00 , the first time zone */
|
||||
|
||||
/*
|
||||
* Nonzero if YEAR is a leap year (every 4 years,
|
||||
@@ -72,14 +72,6 @@
|
||||
#define IS_LEAP_YEAR(year) \
|
||||
(((year) % 4 == 0) && (((year) % 100 != 0) || ((year) % 400 == 0)))
|
||||
#endif
|
||||
/* The lowest two bytes indicate minutes of the time zone */
|
||||
#ifndef OFFSET_TO_MINUTE
|
||||
#define OFFSET_TO_MINUTE(time) (((time) < 0) ? (-(time)) : (time))
|
||||
#endif
|
||||
/* The highest 31 bytes, 1 indicates eastern time zone<6E><65>? indicates western time zone */
|
||||
#ifndef TIME_ZONE_SIGN
|
||||
#define TIME_ZONE_SIGN(time) ((time) >> 31)
|
||||
#endif
|
||||
|
||||
#define DIV(a, b) (((a) / (b)) - ((a) % (b) < 0))
|
||||
#define LEAPS_THRU_END_OF(y) (DIV (y, 4) - DIV (y, 100) + DIV (y, 400))
|
||||
|
||||
@@ -52,9 +52,6 @@
|
||||
#error "Please use ARM Compiler Toolchain V4.0.677 or later!"
|
||||
#endif
|
||||
|
||||
/* intrinsic void __enable_irq(); */
|
||||
/* intrinsic void __disable_irq(); */
|
||||
|
||||
/** \brief Get Control Register
|
||||
|
||||
This function returns the content of the Control Register.
|
||||
|
||||
30
kernel/arch/arm/cortex-m3/keil/los_timer.c
Executable file → Normal file
30
kernel/arch/arm/cortex-m3/keil/los_timer.c
Executable file → Normal file
@@ -223,36 +223,6 @@ VOID HalEnterSleep(LOS_SysSleepEnum sleep)
|
||||
__ISB();
|
||||
}
|
||||
|
||||
WEAK VOID HalDelay(UINT32 ticks)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
WEAK UINT64 HalGetExpandTick(VOID)
|
||||
{
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
WEAK INT32 HalGetRtcTime(UINT64 *usec)
|
||||
{
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
WEAK INT32 HalGetRtcTimeZone(INT32 *timeZone)
|
||||
{
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
WEAK INT32 HalSetRtcTime(UINT64 utcTime, UINT64 *usec)
|
||||
{
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
WEAK INT32 HalSetRtcTimeZone(INT32 timeZone)
|
||||
{
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
|
||||
@@ -213,11 +213,6 @@ VOID HalEnterSleep(LOS_SysSleepEnum sleep)
|
||||
__ISB();
|
||||
}
|
||||
|
||||
WEAK VOID HalDelay(UINT32 ticks)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
|
||||
@@ -222,36 +222,6 @@ VOID HalEnterSleep(LOS_SysSleepEnum sleep)
|
||||
__ISB();
|
||||
}
|
||||
|
||||
WEAK VOID HalDelay(UINT32 ticks)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
WEAK UINT64 HalGetExpandTick(VOID)
|
||||
{
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
WEAK INT32 HalGetRtcTime(UINT64 *usec)
|
||||
{
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
WEAK INT32 HalGetRtcTimeZone(INT32 *timeZone)
|
||||
{
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
WEAK INT32 HalSetRtcTime(UINT64 utcTime, UINT64 *usec)
|
||||
{
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
WEAK INT32 HalSetRtcTimeZone(INT32 timeZone)
|
||||
{
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
|
||||
30
kernel/arch/arm/cortex-m4/iar/los_timer.c
Executable file → Normal file
30
kernel/arch/arm/cortex-m4/iar/los_timer.c
Executable file → Normal file
@@ -222,36 +222,6 @@ VOID HalEnterSleep(LOS_SysSleepEnum sleep)
|
||||
__ISB();
|
||||
}
|
||||
|
||||
WEAK VOID HalDelay(UINT32 ticks)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
WEAK UINT64 HalGetExpandTick(VOID)
|
||||
{
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
WEAK INT32 HalGetRtcTime(UINT64 *usec)
|
||||
{
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
WEAK INT32 HalGetRtcTimeZone(INT32 *timeZone)
|
||||
{
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
WEAK INT32 HalSetRtcTime(UINT64 utcTime, UINT64 *usec)
|
||||
{
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
WEAK INT32 HalSetRtcTimeZone(INT32 timeZone)
|
||||
{
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
|
||||
30
kernel/arch/arm/cortex-m7/gcc/los_timer.c
Executable file → Normal file
30
kernel/arch/arm/cortex-m7/gcc/los_timer.c
Executable file → Normal file
@@ -222,36 +222,6 @@ VOID HalEnterSleep(LOS_SysSleepEnum sleep)
|
||||
__ISB();
|
||||
}
|
||||
|
||||
WEAK VOID HalDelay(UINT32 ticks)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
WEAK UINT64 HalGetExpandTick(VOID)
|
||||
{
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
WEAK INT32 HalGetRtcTime(UINT64 *usec)
|
||||
{
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
WEAK INT32 HalGetRtcTimeZone(INT32 *timeZone)
|
||||
{
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
WEAK INT32 HalSetRtcTime(UINT64 utcTime, UINT64 *usec)
|
||||
{
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
WEAK INT32 HalSetRtcTimeZone(INT32 timeZone)
|
||||
{
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
|
||||
30
kernel/arch/arm/cortex-m7/iar/los_timer.c
Executable file → Normal file
30
kernel/arch/arm/cortex-m7/iar/los_timer.c
Executable file → Normal file
@@ -222,36 +222,6 @@ VOID HalEnterSleep(LOS_SysSleepEnum sleep)
|
||||
__ISB();
|
||||
}
|
||||
|
||||
WEAK VOID HalDelay(UINT32 ticks)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
WEAK UINT64 HalGetExpandTick(VOID)
|
||||
{
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
WEAK INT32 HalGetRtcTime(UINT64 *usec)
|
||||
{
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
WEAK INT32 HalGetRtcTimeZone(INT32 *timeZone)
|
||||
{
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
WEAK INT32 HalSetRtcTime(UINT64 utcTime, UINT64 *usec)
|
||||
{
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
WEAK INT32 HalSetRtcTimeZone(INT32 timeZone)
|
||||
{
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
|
||||
34
kernel/arch/include/los_timer.h
Executable file → Normal file
34
kernel/arch/include/los_timer.h
Executable file → Normal file
@@ -69,38 +69,6 @@ VOID HalEnterSleep(LOS_SysSleepEnum sleep);
|
||||
|
||||
VOID HalDelay(UINT32 ticks);
|
||||
|
||||
UINT64 HalGetExpandTick(VOID);
|
||||
|
||||
INT32 HalGetRtcTime(UINT64 *usec);
|
||||
|
||||
INT32 HalGetRtcTimeZone(INT32 *timeZone);
|
||||
|
||||
INT32 HalSetRtcTime(UINT64 utcTime, UINT64 *usec);
|
||||
|
||||
INT32 HalSetRtcTimeZone(INT32 timeZone);
|
||||
|
||||
/**
|
||||
* @ingroup los_timer
|
||||
* @brief Configure Tick Interrupt Start.
|
||||
*
|
||||
* @par Description:
|
||||
* This API is used to configure Tick Interrupt Start while macro LOSCFG_BASE_CORE_TICK_HW_TIME is No.
|
||||
*
|
||||
* @attention
|
||||
* <ul>
|
||||
* <li>None.</li>
|
||||
* </ul>
|
||||
*
|
||||
* @param: None.
|
||||
*
|
||||
* @retval #LOS_OK 0:configure Tick Interrupt success.
|
||||
* @retval #LOS_ERRNO_TICK_CFG_INVALID 0x02000400:configure Tick Interrupt failed.
|
||||
*
|
||||
* @par Dependency:
|
||||
* <ul><li>los_config.h: the header file that contains the API declaration.</li></ul>
|
||||
* @see
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ingroup los_hwi
|
||||
* @brief reconfig systick, and clear SysTick_IRQn.
|
||||
@@ -218,4 +186,4 @@ extern VOID HalTicklessDisable(VOID);
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
31
kernel/arch/risc-v/riscv32/gcc/los_timer.c
Executable file → Normal file
31
kernel/arch/risc-v/riscv32/gcc/los_timer.c
Executable file → Normal file
@@ -41,7 +41,6 @@ extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#define NS_PER_SECOND 1000000000.0
|
||||
|
||||
WEAK UINT32 HalTickStart(OS_TICK_HANDLER handler)
|
||||
{
|
||||
@@ -67,36 +66,6 @@ LITE_OS_SEC_TEXT_MINOR VOID HalGetCpuCycle(UINT32 *cntHi, UINT32 *cntLo)
|
||||
return;
|
||||
}
|
||||
|
||||
WEAK VOID HalDelay(UINT32 ticks)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
WEAK UINT64 HalGetExpandTick(VOID)
|
||||
{
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
WEAK INT32 HalGetRtcTime(UINT64 *usec)
|
||||
{
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
WEAK INT32 HalGetRtcTimeZone(INT32 *timeZone)
|
||||
{
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
WEAK INT32 HalSetRtcTime(UINT64 utcTime, UINT64 *usec)
|
||||
{
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
WEAK INT32 HalSetRtcTimeZone(INT32 timeZone)
|
||||
{
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
|
||||
@@ -192,14 +192,6 @@ LITE_OS_SEC_TEXT_INIT UINT32 LOS_KernelInit(VOID)
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef LOSCFG_TEST
|
||||
//ret = los_TestInit();
|
||||
//if (ret != LOS_OK) {
|
||||
// PRINT_ERR("los_TestInit error\n");
|
||||
// return ret;
|
||||
//}
|
||||
#endif
|
||||
|
||||
#if (LOSCFG_PLATFORM_EXC == 1)
|
||||
OsExcMsgDumpInit();
|
||||
#endif
|
||||
|
||||
@@ -545,9 +545,9 @@ LITE_OS_SEC_TEXT_MINOR UINT32 OsGetAllTskInfo(VOID)
|
||||
}
|
||||
|
||||
PRINTK("%d %d %s 0x%x 0x%x 0x%x 0x%x 0x%x ",
|
||||
taskCB->taskID, taskCB->priority, OsConvertTskStatus(taskCB->taskStatus),
|
||||
taskCB->stackSize, OsGetTaskWaterLine(taskCB->taskID),
|
||||
(UINT32)(UINTPTR)taskCB->stackPointer, taskCB->topOfStack, taskCB->eventMask);
|
||||
taskCB->taskID, taskCB->priority, OsConvertTskStatus(taskCB->taskStatus),
|
||||
taskCB->stackSize, OsGetTaskWaterLine(taskCB->taskID),
|
||||
(UINT32)(UINTPTR)taskCB->stackPointer, taskCB->topOfStack, taskCB->eventMask);
|
||||
|
||||
semID = (taskCB->taskSem == NULL) ? OS_NULL_SHORT : (((LosSemCB *)taskCB->taskSem)->semID);
|
||||
PRINTK("0x%x ", semID);
|
||||
|
||||
Reference in New Issue
Block a user