Compare commits
27 Commits
weekly_202
...
OpenHarmon
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
275357fc54 | ||
|
|
76ee5b5afe | ||
|
|
3fa1ff8431 | ||
|
|
7d414613b0 | ||
|
|
512f08fac6 | ||
|
|
4e1dd7d7b4 | ||
|
|
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;
|
*stackEnd = (UINTPTR)taskCB->topOfStack + taskCB->stackSize;
|
||||||
if ((SP < (UINTPTR)taskCB->topOfStack) || (SP >= *stackEnd)) {
|
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",
|
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;
|
return LOS_NOK;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -135,7 +135,7 @@ STATIC INLINE UINT32 OsStackAddrGet(UINTPTR *stackStart, UINTPTR *stackEnd, UINT
|
|||||||
*stackEnd = CSTACK_END_ADDR;
|
*stackEnd = CSTACK_END_ADDR;
|
||||||
if ((*stackStart < CODE_START_ADDR) || (*stackStart >= 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",
|
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;
|
return LOS_NOK;
|
||||||
}
|
}
|
||||||
PRINTK("msp, start = %x, end = %x\n", *stackStart, *stackEnd);
|
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;
|
*stackEnd = (UINTPTR)taskCB->topOfStack + taskCB->stackSize;
|
||||||
if ((*stackStart < (UINTPTR)taskCB->topOfStack) || (*stackStart >= *stackEnd)) {
|
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",
|
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;
|
return LOS_NOK;
|
||||||
}
|
}
|
||||||
PRINTK("psp, start = %x, end = %x\n", *stackStart, *stackEnd);
|
PRINTK("psp, start = %x, end = %x\n", *stackStart, *stackEnd);
|
||||||
|
|||||||
@@ -44,6 +44,7 @@
|
|||||||
|
|
||||||
#ifdef LOSCFG_NET_LWIP_SACK
|
#ifdef LOSCFG_NET_LWIP_SACK
|
||||||
#include "lwip/lwipopts.h"
|
#include "lwip/lwipopts.h"
|
||||||
|
#include "lwip/sockets.h"
|
||||||
#define CONFIG_NSOCKET_DESCRIPTORS LWIP_CONFIG_NUM_SOCKETS
|
#define CONFIG_NSOCKET_DESCRIPTORS LWIP_CONFIG_NUM_SOCKETS
|
||||||
#else
|
#else
|
||||||
#define CONFIG_NSOCKET_DESCRIPTORS 0
|
#define CONFIG_NSOCKET_DESCRIPTORS 0
|
||||||
|
|||||||
@@ -32,19 +32,42 @@
|
|||||||
#ifndef _LWIP_PORTING_CC_H_
|
#ifndef _LWIP_PORTING_CC_H_
|
||||||
#define _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 <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include "securec.h"
|
#include "securec.h"
|
||||||
#include "log.h"
|
#include "memory_pool.h"
|
||||||
|
|
||||||
#ifdef htons
|
#ifdef htons
|
||||||
#define LWIP_DONT_PROVIDE_BYTEORDER_FUNCTIONS
|
#define LWIP_DONT_PROVIDE_BYTEORDER_FUNCTIONS
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define LWIP_PROVIDE_ERRNO 1
|
#define SOCKLEN_T_DEFINED
|
||||||
#define __SIZEOF_POINTER__ 4 // 32位系统
|
#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)
|
#if defined(__arm__) && defined(__ARMCC_VERSION)
|
||||||
/* Keil uVision4 tools */
|
/* Keil uVision4 tools */
|
||||||
@@ -96,7 +119,6 @@ extern void HilogPrintf(const char *fmt, ...);
|
|||||||
#define init_waitqueue_head(...)
|
#define init_waitqueue_head(...)
|
||||||
#define poll_check_waiters(...)
|
#define poll_check_waiters(...)
|
||||||
#define IOCTL_CMD_CASE_HANDLER()
|
#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(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")))
|
#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_
|
#define _LWIP_PORTING_SYS_ARCH_H_
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include "memory_pool.h"
|
|
||||||
#include "los_mux.h"
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
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_NETIF_LOOPBACK 1
|
||||||
#define LWIP_POSIX_SOCKETS_IO_NAMES 0
|
#define LWIP_POSIX_SOCKETS_IO_NAMES 0
|
||||||
#define LWIP_RAW 1
|
#define LWIP_RAW 1
|
||||||
#define CONFIG_NFILE_DESCRIPTORS 1
|
#define LWIP_SOCKET_OFFSET FAT_MAX_OPEN_FILES
|
||||||
#define LWIP_SOCKET_OFFSET CONFIG_NFILE_DESCRIPTORS
|
|
||||||
#define LWIP_SO_RCVBUF 1
|
#define LWIP_SO_RCVBUF 1
|
||||||
#define LWIP_SO_RCVTIMEO 1
|
#define LWIP_SO_RCVTIMEO 1
|
||||||
#define LWIP_SO_SNDTIMEO 1
|
#define LWIP_SO_SNDTIMEO 1
|
||||||
|
|||||||
@@ -29,11 +29,10 @@
|
|||||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __LITEOS_NETDB_PORTING_H__
|
#ifndef _LWIP_PORTING_NETDB_H_
|
||||||
#define __LITEOS_NETDB_PORTING_H__
|
#define _LWIP_PORTING_NETDB_H_
|
||||||
|
|
||||||
#include "lwip/netdb.h"
|
#include <netdb.h>
|
||||||
|
#include_next <lwip/netdb.h>
|
||||||
|
|
||||||
struct hostent *gethostbyname(const char *name);
|
#endif /* _LWIP_PORTING_NETDB_H_ */
|
||||||
|
|
||||||
#endif // __LITEOS_NETDB_PORTING_H__
|
|
||||||
@@ -32,6 +32,9 @@
|
|||||||
#ifndef _LWIP_PORTING_NETIF_H_
|
#ifndef _LWIP_PORTING_NETIF_H_
|
||||||
#define _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
|
#define netif_find netifapi_netif_find_by_name
|
||||||
|
|
||||||
#if LWIP_DHCPS
|
#if LWIP_DHCPS
|
||||||
@@ -39,12 +42,11 @@
|
|||||||
LWIP_NETIF_CLIENT_DATA_INDEX_DHCPS
|
LWIP_NETIF_CLIENT_DATA_INDEX_DHCPS
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define LWIP_NETIF_FULLNAME 16
|
|
||||||
#define linkoutput linkoutput; \
|
#define linkoutput linkoutput; \
|
||||||
void (*drv_send)(struct netif *netif, struct pbuf *p); \
|
void (*drv_send)(struct netif *netif, struct pbuf *p); \
|
||||||
u8_t (*drv_set_hwaddr)(struct netif *netif, u8_t *addr, u8_t len); \
|
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); \
|
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
|
u16_t link_layer_type
|
||||||
#include_next <lwip/netif.h>
|
#include_next <lwip/netif.h>
|
||||||
#undef linkoutput
|
#undef linkoutput
|
||||||
@@ -52,7 +54,7 @@
|
|||||||
#undef LWIP_NETIF_CLIENT_DATA_INDEX_DHCP
|
#undef LWIP_NETIF_CLIENT_DATA_INDEX_DHCP
|
||||||
#endif
|
#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
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
@@ -60,9 +62,9 @@ extern "C" {
|
|||||||
|
|
||||||
// redefine NETIF_NAMESIZE which was defined in netif.h
|
// redefine NETIF_NAMESIZE which was defined in netif.h
|
||||||
#undef NETIF_NAMESIZE
|
#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 ETHERNET_DRIVER_IF 1
|
||||||
#define WIFI_DRIVER_IF 801
|
#define WIFI_DRIVER_IF 801
|
||||||
#define BT_PROXY_IF 802
|
#define BT_PROXY_IF 802
|
||||||
|
|||||||
@@ -29,51 +29,55 @@
|
|||||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _SYS_SOCKET_PORTING_H
|
#ifndef _LWIP_PORTING_SOCKETS_H_
|
||||||
#define _SYS_SOCKET_PORTING_H
|
#define _LWIP_PORTING_SOCKETS_H_
|
||||||
|
|
||||||
#include "lwip/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
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int socket (int, int, int);
|
#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
|
||||||
|
|
||||||
int bind (int, const struct sockaddr *, socklen_t);
|
#if IOV_MAX > 0xFFFF
|
||||||
int connect (int, const struct sockaddr *, socklen_t);
|
#error "IOV_MAX larger than supported by LwIP"
|
||||||
int listen (int, int);
|
#endif
|
||||||
int accept (int, struct sockaddr *__restrict, socklen_t *__restrict);
|
|
||||||
|
|
||||||
int getsockname (int, struct sockaddr *__restrict, socklen_t *__restrict);
|
#if LWIP_UDP && LWIP_UDPLITE
|
||||||
int getpeername (int, struct sockaddr *__restrict, socklen_t *__restrict);
|
#define UDPLITE_SEND_CSCOV 0x01 /* sender checksum coverage */
|
||||||
|
#define UDPLITE_RECV_CSCOV 0x02 /* minimal receiver checksum coverage */
|
||||||
|
#endif
|
||||||
|
|
||||||
ssize_t send (int, const void *, size_t, int);
|
// For BSD 4.4 socket sa_len compatibility
|
||||||
ssize_t recv (int, void *, size_t, int);
|
#define DF_NADDR(addr)
|
||||||
ssize_t sendto (int, const void *, size_t, int, const struct sockaddr *, socklen_t);
|
#define SA_LEN(addr, _) (IP_IS_V4_VAL(addr) ? sizeof(struct sockaddr_in) : sizeof(struct sockaddr_in6))
|
||||||
ssize_t recvfrom (int, void *__restrict, size_t, int, struct sockaddr *__restrict, socklen_t *__restrict);
|
#define sa_len sa_data[0] * 0 + SA_LEN(naddr, _)
|
||||||
ssize_t sendmsg (int, const struct msghdr *, int);
|
#define sin_len sin_zero[0]
|
||||||
ssize_t recvmsg (int, struct msghdr *, int);
|
#define sin6_len sin6_addr.s6_addr[0]
|
||||||
|
|
||||||
int getsockopt (int, int, int, void *__restrict, socklen_t *__restrict);
|
// for sockets.c, TCP_KEEPALIVE is not supported currently
|
||||||
int setsockopt (int, int, int, const void *, socklen_t);
|
#define TCP_KEEPALIVE 0xFF
|
||||||
|
#define SIN_ZERO_LEN 8
|
||||||
|
|
||||||
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 closesocket(int sockfd);
|
||||||
|
|
||||||
int ioctlsocket(int s, long cmd, void *argp);
|
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
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#endif
|
|
||||||
|
#endif /* _LWIP_PORTING_SOCKETS_H_ */
|
||||||
@@ -29,7 +29,7 @@
|
|||||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "netdb.h"
|
#include "lwip/netdb.h"
|
||||||
|
|
||||||
struct hostent *gethostbyname(const char *name)
|
struct hostent *gethostbyname(const char *name)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -41,15 +41,15 @@
|
|||||||
#include <los_timer.h>
|
#include <los_timer.h>
|
||||||
#include <los_config.h>
|
#include <los_config.h>
|
||||||
|
|
||||||
#define YES 1
|
#ifndef LOSCFG_KERNEL_SMP
|
||||||
#define NO 0
|
#define LOSCFG_KERNEL_SMP 0
|
||||||
#define LOSCFG_KERNEL_SMP NO
|
#endif
|
||||||
|
|
||||||
#if (LOSCFG_KERNEL_SMP == YES)
|
#if (LOSCFG_KERNEL_SMP)
|
||||||
SPIN_LOCK_INIT(arch_protect_spin);
|
SPIN_LOCK_INIT(arch_protect_spin);
|
||||||
static u32_t lwprot_thread = LOS_ERRNO_TSK_ID_INVALID;
|
static u32_t lwprot_thread = LOS_ERRNO_TSK_ID_INVALID;
|
||||||
static int lwprot_count = 0;
|
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 ROUND_UP_DIV(val, div) (((val) + (div) - 1) / (div))
|
||||||
#define LWIP_LOG_BUF_SIZE 64
|
#define LWIP_LOG_BUF_SIZE 64
|
||||||
@@ -98,7 +98,7 @@ u32_t sys_now(void)
|
|||||||
*/
|
*/
|
||||||
sys_prot_t sys_arch_protect(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:
|
/* Note that we are using spinlock instead of mutex for LiteOS-SMP here:
|
||||||
* 1. spinlock is more effective for short critical region protection.
|
* 1. spinlock is more effective for short critical region protection.
|
||||||
* 2. this function is called only in task context, not in interrupt handler.
|
* 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
|
#else
|
||||||
LOS_TaskLock();
|
LOS_TaskLock();
|
||||||
#endif /* LOSCFG_KERNEL_SMP == YES */
|
#endif /* LOSCFG_KERNEL_SMP */
|
||||||
return 0; /* return value is unused */
|
return 0; /* return value is unused */
|
||||||
}
|
}
|
||||||
|
|
||||||
void sys_arch_unprotect(sys_prot_t pval)
|
void sys_arch_unprotect(sys_prot_t pval)
|
||||||
{
|
{
|
||||||
LWIP_UNUSED_ARG(pval);
|
LWIP_UNUSED_ARG(pval);
|
||||||
#if (LOSCFG_KERNEL_SMP == YES)
|
#if (LOSCFG_KERNEL_SMP)
|
||||||
if (lwprot_thread == LOS_CurTaskIDGet()) {
|
if (lwprot_thread == LOS_CurTaskIDGet()) {
|
||||||
lwprot_count--;
|
lwprot_count--;
|
||||||
if (lwprot_count == 0) {
|
if (lwprot_count == 0) {
|
||||||
@@ -133,7 +133,7 @@ void sys_arch_unprotect(sys_prot_t pval)
|
|||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
LOS_TaskUnlock();
|
LOS_TaskUnlock();
|
||||||
#endif /* LOSCFG_KERNEL_SMP == YES */
|
#endif /* LOSCFG_KERNEL_SMP */
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -32,8 +32,10 @@
|
|||||||
#ifndef LWIP_TEST_H
|
#ifndef LWIP_TEST_H
|
||||||
#define LWIP_TEST_H
|
#define LWIP_TEST_H
|
||||||
|
|
||||||
|
#include "lwip/arch.h"
|
||||||
|
#include "lwip/sockets.h"
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include "log.h"
|
#include <arpa/inet.h>
|
||||||
#include "securec.h"
|
#include "securec.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|||||||
@@ -30,14 +30,18 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "lwip_test.h"
|
#include "lwip_test.h"
|
||||||
|
#include "lwipopts.h"
|
||||||
|
#include <arch/sys_arch.h>
|
||||||
|
#include <lwip/sys.h>
|
||||||
|
|
||||||
#define MSG "Hi, I am UDP"
|
#define MSG "Hi, I am UDP"
|
||||||
#define TEST_CASE 120
|
#define TEST_CASE 120
|
||||||
|
|
||||||
static char g_buf[BUF_SIZE + 1] = { 0 };
|
static char g_buf[BUF_SIZE + 1] = { 0 };
|
||||||
|
|
||||||
int UdpTest(void)
|
void UdpTestTask(void *p)
|
||||||
{
|
{
|
||||||
|
(void)p;
|
||||||
LogPrintln("net_socket_test_002.c enter");
|
LogPrintln("net_socket_test_002.c enter");
|
||||||
g_testCase = TEST_CASE;
|
g_testCase = TEST_CASE;
|
||||||
int sfd;
|
int sfd;
|
||||||
@@ -111,6 +115,13 @@ int UdpTest(void)
|
|||||||
/* close socket */
|
/* close socket */
|
||||||
ret = closesocket(sfd);
|
ret = closesocket(sfd);
|
||||||
LWIP_ASSERT("socket invalid param.", ret != -1);
|
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
|
#define TEST_CASE 130
|
||||||
|
|
||||||
static char g_buf[BUF_SIZE + 1] = { 0 };
|
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()
|
static int SampleTcpServer()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -40,7 +40,6 @@ static char g_buf_temp[BUF_SIZE + 1] = { 0 };
|
|||||||
#define SEND_UDP_COUNT 10000 // send count
|
#define SEND_UDP_COUNT 10000 // send count
|
||||||
#define TEST_CASE 170
|
#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)
|
static void UdpTestMoreTask(void *p)
|
||||||
{
|
{
|
||||||
(void)p;
|
(void)p;
|
||||||
|
|||||||
@@ -41,8 +41,6 @@
|
|||||||
static char g_serverSendBuf[BUF_SIZE + 1] = { 0 };
|
static char g_serverSendBuf[BUF_SIZE + 1] = { 0 };
|
||||||
static char g_clientRecvBuf[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()
|
static void InitMsgBuf()
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|||||||
@@ -43,8 +43,6 @@
|
|||||||
|
|
||||||
static char g_buf[BUF_SIZE + 1] = { 0 };
|
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()
|
static int SampleTcpServer()
|
||||||
{
|
{
|
||||||
#if LWIP_SOCKET_SELECT
|
#if LWIP_SOCKET_SELECT
|
||||||
|
|||||||
@@ -43,8 +43,6 @@
|
|||||||
#define TIME_OUT (1000 * 10) // timeout 10s
|
#define TIME_OUT (1000 * 10) // timeout 10s
|
||||||
static char g_buf[BUF_SIZE + 1] = { 0 };
|
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()
|
static int SampleTcpServer()
|
||||||
{
|
{
|
||||||
#if LWIP_SOCKET_POLL
|
#if LWIP_SOCKET_POLL
|
||||||
|
|||||||
@@ -310,8 +310,9 @@ static struct netif *CreateBtNetIf()
|
|||||||
return btNetif;
|
return btNetif;
|
||||||
}
|
}
|
||||||
|
|
||||||
int UdpTestNetif(void)
|
static void UdpTestNetifTask(void *p)
|
||||||
{
|
{
|
||||||
|
(void)p;
|
||||||
LogPrintln("net_socket_test_011.c enter");
|
LogPrintln("net_socket_test_011.c enter");
|
||||||
g_testCase = TEST_CASE;
|
g_testCase = TEST_CASE;
|
||||||
int sfd;
|
int sfd;
|
||||||
@@ -363,7 +364,15 @@ int UdpTestNetif(void)
|
|||||||
/* close socket */
|
/* close socket */
|
||||||
ret = closesocket(sfd);
|
ret = closesocket(sfd);
|
||||||
LWIP_ASSERT("socket invalid param.", ret != -1);
|
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)
|
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_bufServer[BUF_SIZE + 1] = { 0 };
|
||||||
static char g_bufClient[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()
|
static int SampleTcpServer()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -38,8 +38,6 @@
|
|||||||
#define STACK_PORT_TCP_LONG 2231
|
#define STACK_PORT_TCP_LONG 2231
|
||||||
#define TCP_LONG_BUF_SIZE (2 * 1024)
|
#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()
|
static int SampleTcpServer()
|
||||||
{
|
{
|
||||||
int sfd, lsfd;
|
int sfd, lsfd;
|
||||||
|
|||||||
@@ -119,7 +119,7 @@ static void LwipTestTimeoutCallback(void const *argument)
|
|||||||
|
|
||||||
osTimerId_t g_lwipTestTimerId = NULL;
|
osTimerId_t g_lwipTestTimerId = NULL;
|
||||||
|
|
||||||
void LwipTestStartTimer(uint32 timeout)
|
void LwipTestStartTimer(uint32_t timeout)
|
||||||
{
|
{
|
||||||
osStatus_t status;
|
osStatus_t status;
|
||||||
if (g_lwipTestTimerId != NULL) {
|
if (g_lwipTestTimerId != NULL) {
|
||||||
|
|||||||
@@ -58,7 +58,12 @@ static osKernelState_t g_kernelState;
|
|||||||
|
|
||||||
extern BOOL g_taskScheduled;
|
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 };
|
const osVersion_t g_stLosVersion = { 001, 001 };
|
||||||
|
|
||||||
@@ -74,8 +79,6 @@ const osVersion_t g_stLosVersion = { 001, 001 };
|
|||||||
#define KERNEL_ID "HUAWEI-LiteOS"
|
#define KERNEL_ID "HUAWEI-LiteOS"
|
||||||
|
|
||||||
// ==== Kernel Management Functions ====
|
// ==== Kernel Management Functions ====
|
||||||
uint32_t osTaskStackWaterMarkGet(UINT32 taskID);
|
|
||||||
|
|
||||||
|
|
||||||
osStatus_t osKernelInitialize(void)
|
osStatus_t osKernelInitialize(void)
|
||||||
{
|
{
|
||||||
@@ -303,27 +306,28 @@ osThreadId_t osThreadNew(osThreadFunc_t func, void *argument, const osThreadAttr
|
|||||||
UINT32 uwTid;
|
UINT32 uwTid;
|
||||||
UINT32 uwRet;
|
UINT32 uwRet;
|
||||||
LosTaskCB *pstTaskCB = NULL;
|
LosTaskCB *pstTaskCB = NULL;
|
||||||
TSK_INIT_PARAM_S stTskInitParam;
|
TSK_INIT_PARAM_S stTskInitParam = {NULL};
|
||||||
|
UINT16 usPriority;
|
||||||
|
|
||||||
if (OS_INT_ACTIVE) {
|
if (OS_INT_ACTIVE || (func == NULL)) {
|
||||||
return NULL;
|
return (osThreadId_t)NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((attr == NULL) || (func == NULL) || (attr->priority < osPriorityLow1) ||
|
usPriority = attr ? LOS_PRIORITY(attr->priority) : LOSCFG_BASE_CORE_TSK_DEFAULT_PRIO;
|
||||||
(attr->priority > osPriorityAboveNormal6)) {
|
if (!ISVALID_LOS_PRIORITY(usPriority)) {
|
||||||
|
/* unsupported priority */
|
||||||
return (osThreadId_t)NULL;
|
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;
|
stTskInitParam.pfnTaskEntry = (TSK_ENTRY_FUNC)func;
|
||||||
#ifndef LITEOS_WIFI_IOT_VERSION
|
#ifndef LITEOS_WIFI_IOT_VERSION
|
||||||
stTskInitParam.uwArg = (UINT32)argument;
|
stTskInitParam.uwArg = (UINT32)argument;
|
||||||
#else
|
#else
|
||||||
stTskInitParam.auwArgs[0] = (UINT32)argument;
|
stTskInitParam.auwArgs[0] = (UINT32)argument;
|
||||||
#endif
|
#endif
|
||||||
stTskInitParam.uwStackSize = attr->stack_size;
|
stTskInitParam.uwStackSize = attr ? attr->stack_size : LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE;
|
||||||
stTskInitParam.pcName = (CHAR *)attr->name;
|
stTskInitParam.pcName = (CHAR *)(attr ? attr->name : "[NULL]");
|
||||||
stTskInitParam.usTaskPrio = OS_TASK_PRIORITY_LOWEST - ((UINT16)(attr->priority) - LOS_PRIORITY_WIN); /* 0~31 */
|
stTskInitParam.usTaskPrio = usPriority;
|
||||||
|
|
||||||
uwRet = LOS_TaskCreate(&uwTid, &stTskInitParam);
|
uwRet = LOS_TaskCreate(&uwTid, &stTskInitParam);
|
||||||
|
|
||||||
@@ -483,12 +487,12 @@ osStatus_t osThreadSetPriority(osThreadId_t thread_id, osPriority_t priority)
|
|||||||
return osErrorParameter;
|
return osErrorParameter;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (priority < osPriorityLow1 || priority > osPriorityAboveNormal6) {
|
usPriority = LOS_PRIORITY(priority);
|
||||||
|
if (!ISVALID_LOS_PRIORITY(usPriority)) {
|
||||||
return osErrorParameter;
|
return osErrorParameter;
|
||||||
}
|
}
|
||||||
|
|
||||||
pstTaskCB = (LosTaskCB *)thread_id;
|
pstTaskCB = (LosTaskCB *)thread_id;
|
||||||
usPriority = OS_TASK_PRIORITY_LOWEST - ((UINT16)priority - LOS_PRIORITY_WIN);
|
|
||||||
uwRet = LOS_TaskPriSet(pstTaskCB->taskID, usPriority);
|
uwRet = LOS_TaskPriSet(pstTaskCB->taskID, usPriority);
|
||||||
switch (uwRet) {
|
switch (uwRet) {
|
||||||
case LOS_ERRNO_TSK_PRIOR_ERROR:
|
case LOS_ERRNO_TSK_PRIOR_ERROR:
|
||||||
@@ -521,7 +525,7 @@ osPriority_t osThreadGetPriority(osThreadId_t thread_id)
|
|||||||
return osPriorityError;
|
return osPriorityError;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (osPriority_t)(OS_TASK_PRIORITY_LOWEST - (usRet - LOS_PRIORITY_WIN));
|
return (osPriority_t)CMSIS_PRIORITY(usRet);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -891,7 +895,7 @@ uint32_t osEventFlagsGet(osEventFlagsId_t ef_id)
|
|||||||
uint32_t rflags;
|
uint32_t rflags;
|
||||||
|
|
||||||
if (pstEventCB == NULL) {
|
if (pstEventCB == NULL) {
|
||||||
return (uint32_t)osFlagsErrorParameter;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
uwIntSave = LOS_IntLock();
|
uwIntSave = LOS_IntLock();
|
||||||
|
|||||||
@@ -5,6 +5,8 @@
|
|||||||
#define PATH_MAX 256
|
#define PATH_MAX 256
|
||||||
#define MQ_PRIO_MAX 1
|
#define MQ_PRIO_MAX 1
|
||||||
#define PTHREAD_STACK_MIN LOSCFG_BASE_CORE_TSK_MIN_STACK_SIZE
|
#define PTHREAD_STACK_MIN LOSCFG_BASE_CORE_TSK_MIN_STACK_SIZE
|
||||||
|
#define IOV_MAX 1024
|
||||||
|
#define SSIZE_MAX LONG_MAX
|
||||||
#include_next <limits.h>
|
#include_next <limits.h>
|
||||||
#else
|
#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.pfnTaskEntry = PthreadEntry;
|
||||||
taskInitParam.uwArg = (UINT32)(UINTPTR)pthreadData;
|
taskInitParam.uwArg = (UINT32)(UINTPTR)pthreadData;
|
||||||
|
|
||||||
if (LOS_TaskCreate(&taskID, &taskInitParam) != LOS_OK) {
|
if (LOS_TaskCreateOnly(&taskID, &taskInitParam) != LOS_OK) {
|
||||||
free(pthreadData);
|
free(pthreadData);
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
}
|
}
|
||||||
@@ -105,6 +105,8 @@ int pthread_create(pthread_t *thread, const pthread_attr_t *attr,
|
|||||||
/* set pthread default name */
|
/* set pthread default name */
|
||||||
(void)sprintf_s(taskInitParam.pcName, PTHREAD_NAMELEN, "pthread%u", taskID);
|
(void)sprintf_s(taskInitParam.pcName, PTHREAD_NAMELEN, "pthread%u", taskID);
|
||||||
|
|
||||||
|
(void)LOS_TaskResume(taskID);
|
||||||
|
|
||||||
*thread = (pthread_t)taskID;
|
*thread = (pthread_t)taskID;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
177
kal/posix/src/time.c
Executable file → Normal file
177
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 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,
|
* negative values indicate the east of UTC,
|
||||||
* positive values indicate the west of UTC.
|
* positive values indicate the west of UTC.
|
||||||
*/
|
*/
|
||||||
static INT32 g_rtcTimeZone = -480;
|
long timezone = -8 * 60 * 60; // defaults to CST: 8 hours east of the Prime Meridian
|
||||||
static struct tm g_tm = {0};
|
|
||||||
|
/* internal shared struct tm object for localtime and gmtime */
|
||||||
|
static struct tm g_tm;
|
||||||
|
|
||||||
int nanosleep(const struct timespec *rqtp, struct timespec *rmtp)
|
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)
|
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)
|
time_t time(time_t *timer)
|
||||||
{
|
{
|
||||||
UINT64 usec = 0;
|
struct timespec ts;
|
||||||
time_t sec;
|
|
||||||
INT32 rtcRet;
|
|
||||||
|
|
||||||
rtcRet = HalGetRtcTime(&usec);
|
if (-1 == clock_gettime(CLOCK_REALTIME, &ts)) {
|
||||||
if (rtcRet != 0) {
|
return (time_t)-1;
|
||||||
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 (timer != NULL) {
|
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];
|
days -= daysInMonth[month];
|
||||||
tp->tm_mon = month;
|
tp->tm_mon = month;
|
||||||
tp->tm_mday = days + 1;
|
tp->tm_mday = days + 1;
|
||||||
|
tp->__tm_gmtoff = offset;
|
||||||
|
tp->__tm_zone = NULL;
|
||||||
|
tp->tm_isdst = 0;
|
||||||
return 1;
|
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;
|
if ((timep == NULL) || (result == NULL)) {
|
||||||
UINT32 intSave;
|
errno = EFAULT;
|
||||||
if ((timer == NULL) || (tp == NULL)) {
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
intSave = LOS_IntLock();
|
if (!ConvertSecs2Utc(*timep, 0, result)) {
|
||||||
t64 = *timer;
|
errno = EINVAL;
|
||||||
if (!ConvertSecs2Utc(t64, 0, tp)) {
|
return NULL;
|
||||||
tp = NULL;
|
|
||||||
}
|
}
|
||||||
(void)LOS_IntRestore(intSave);
|
return result;
|
||||||
return tp;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct tm *gmtime(const time_t *timer)
|
struct tm *gmtime(const time_t *timer)
|
||||||
@@ -518,22 +512,17 @@ struct tm *gmtime(const time_t *timer)
|
|||||||
return gmtime_r(timer, &g_tm);
|
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;
|
if ((timep == NULL) || (result == NULL)) {
|
||||||
time_t t64;
|
errno = EFAULT;
|
||||||
INT32 offset;
|
|
||||||
if ((timer == NULL) || (tp == NULL)) {
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
intSave = LOS_IntLock();
|
if (!ConvertSecs2Utc(*timep, -timezone, result)) {
|
||||||
t64 = *timer;
|
errno = EINVAL;
|
||||||
offset = -(g_rtcTimeZone * SECS_PER_MIN);
|
return NULL;
|
||||||
if (!ConvertSecs2Utc(t64, offset, tp)) {
|
|
||||||
tp = NULL;
|
|
||||||
}
|
}
|
||||||
(void)LOS_IntRestore(intSave);
|
return result;
|
||||||
return tp;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct tm *localtime(const time_t *timer)
|
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_mday - 1) * SECS_PER_DAY;
|
||||||
|
|
||||||
seconds += tm->tm_hour * SECS_PER_HOUR + tm->tm_min * SECS_PER_MIN + tm->tm_sec;
|
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;
|
return seconds;
|
||||||
}
|
}
|
||||||
|
|
||||||
time_t mktime(struct tm *tmptr)
|
time_t mktime(struct tm *tmptr)
|
||||||
{
|
{
|
||||||
struct tm tempTime;
|
|
||||||
time_t timeInSeconds;
|
time_t timeInSeconds;
|
||||||
if (tmptr == NULL) {
|
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(tmptr);
|
||||||
timeInSeconds = ConvertUtc2Secs(&tempTime);
|
/* normalize tm_wday and tm_yday */
|
||||||
timeInSeconds += g_rtcTimeZone * SECS_PER_MIN;
|
ConvertSecs2Utc(timeInSeconds, tmptr->__tm_gmtoff, tmptr);
|
||||||
return timeInSeconds;
|
return timeInSeconds;
|
||||||
}
|
}
|
||||||
|
|
||||||
int gettimeofday(struct timeval *tv, void *ptz)
|
int gettimeofday(struct timeval *tv, void *ptz)
|
||||||
{
|
{
|
||||||
INT32 rtcRet;
|
struct timespec ts;
|
||||||
INT32 timeZone = 0;
|
|
||||||
UINT64 usec = 0;
|
|
||||||
UINT64 currentTime;
|
|
||||||
UINT64 tickDelta = 0;
|
|
||||||
UINT64 currentTick;
|
|
||||||
|
|
||||||
struct timezone *tz = (struct timezone *)ptz;
|
struct timezone *tz = (struct timezone *)ptz;
|
||||||
if ((tv == NULL) && (tz == NULL)) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
if (tv != NULL) {
|
if (tv != NULL) {
|
||||||
rtcRet = HalGetRtcTime(&usec);
|
if (-1 == clock_gettime(CLOCK_REALTIME, &ts)) {
|
||||||
if (rtcRet != 0) {
|
return -1;
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
tv->tv_sec = ts.tv_sec;
|
||||||
|
tv->tv_usec = ts.tv_nsec / OS_SYS_NS_PER_US;
|
||||||
}
|
}
|
||||||
HalGetRtcTimeZone(&timeZone);
|
|
||||||
if (tz != NULL) {
|
if (tz != NULL) {
|
||||||
tz->tz_minuteswest = timeZone;
|
tz->tz_minuteswest = timezone / SECS_PER_MIN;
|
||||||
|
tz->tz_dsttime = 0;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int settimeofday(const struct timeval *tv, const struct timezone *tz)
|
int settimeofday(const struct timeval *tv, const struct timezone *tz)
|
||||||
{
|
{
|
||||||
UINT64 usec;
|
struct timespec ts;
|
||||||
if ((tv == NULL) || (tz == NULL)) {
|
INT32 rtcTimeZone = timezone;
|
||||||
|
|
||||||
|
if (tv == NULL) {
|
||||||
|
errno = EFAULT;
|
||||||
return -1;
|
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 != NULL) {
|
||||||
if ((tz->tz_minuteswest > TIME_ZONE_MIN) &&
|
if ((tz->tz_minuteswest >= TIME_ZONE_MIN) &&
|
||||||
(tz->tz_minuteswest < TIME_ZONE_MAX)) {
|
(tz->tz_minuteswest <= TIME_ZONE_MAX)) {
|
||||||
g_rtcTimeZone = tz->tz_minuteswest;
|
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);
|
if (tv->tv_usec >= OS_SYS_US_PER_SECOND) {
|
||||||
HalSetRtcTimeZone(g_rtcTimeZone);
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -61,8 +61,8 @@
|
|||||||
#define DAYS_PER_NORMAL_YEAR 365
|
#define DAYS_PER_NORMAL_YEAR 365
|
||||||
#define DAYS_PER_LEAP_YEAR 366
|
#define DAYS_PER_LEAP_YEAR 366
|
||||||
#define BEGIN_WEEKDAY 4
|
#define BEGIN_WEEKDAY 4
|
||||||
#define TIME_ZONE_MAX 720 /* 12 * 60 */
|
#define TIME_ZONE_MAX 720 /* UTC-12:00 , the last time zone */
|
||||||
#define TIME_ZONE_MIN (-840) /* -14 * 60 */
|
#define TIME_ZONE_MIN (-840) /* UTC+14:00 , the first time zone */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Nonzero if YEAR is a leap year (every 4 years,
|
* Nonzero if YEAR is a leap year (every 4 years,
|
||||||
@@ -72,14 +72,6 @@
|
|||||||
#define IS_LEAP_YEAR(year) \
|
#define IS_LEAP_YEAR(year) \
|
||||||
(((year) % 4 == 0) && (((year) % 100 != 0) || ((year) % 400 == 0)))
|
(((year) % 4 == 0) && (((year) % 100 != 0) || ((year) % 400 == 0)))
|
||||||
#endif
|
#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 DIV(a, b) (((a) / (b)) - ((a) % (b) < 0))
|
||||||
#define LEAPS_THRU_END_OF(y) (DIV (y, 4) - DIV (y, 100) + DIV (y, 400))
|
#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!"
|
#error "Please use ARM Compiler Toolchain V4.0.677 or later!"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* intrinsic void __enable_irq(); */
|
|
||||||
/* intrinsic void __disable_irq(); */
|
|
||||||
|
|
||||||
/** \brief Get Control Register
|
/** \brief Get Control Register
|
||||||
|
|
||||||
This function returns the content of the 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();
|
__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
|
#ifdef __cplusplus
|
||||||
#if __cplusplus
|
#if __cplusplus
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -213,11 +213,6 @@ VOID HalEnterSleep(LOS_SysSleepEnum sleep)
|
|||||||
__ISB();
|
__ISB();
|
||||||
}
|
}
|
||||||
|
|
||||||
WEAK VOID HalDelay(UINT32 ticks)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
#if __cplusplus
|
#if __cplusplus
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -222,36 +222,6 @@ VOID HalEnterSleep(LOS_SysSleepEnum sleep)
|
|||||||
__ISB();
|
__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
|
#ifdef __cplusplus
|
||||||
#if __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();
|
__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
|
#ifdef __cplusplus
|
||||||
#if __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();
|
__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
|
#ifdef __cplusplus
|
||||||
#if __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();
|
__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
|
#ifdef __cplusplus
|
||||||
#if __cplusplus
|
#if __cplusplus
|
||||||
}
|
}
|
||||||
|
|||||||
32
kernel/arch/include/los_timer.h
Executable file → Normal file
32
kernel/arch/include/los_timer.h
Executable file → Normal file
@@ -69,38 +69,6 @@ VOID HalEnterSleep(LOS_SysSleepEnum sleep);
|
|||||||
|
|
||||||
VOID HalDelay(UINT32 ticks);
|
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
|
* @ingroup los_hwi
|
||||||
* @brief reconfig systick, and clear SysTick_IRQn.
|
* @brief reconfig systick, and clear SysTick_IRQn.
|
||||||
|
|||||||
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 */
|
||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
#define NS_PER_SECOND 1000000000.0
|
|
||||||
|
|
||||||
WEAK UINT32 HalTickStart(OS_TICK_HANDLER handler)
|
WEAK UINT32 HalTickStart(OS_TICK_HANDLER handler)
|
||||||
{
|
{
|
||||||
@@ -67,36 +66,6 @@ LITE_OS_SEC_TEXT_MINOR VOID HalGetCpuCycle(UINT32 *cntHi, UINT32 *cntLo)
|
|||||||
return;
|
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
|
#ifdef __cplusplus
|
||||||
#if __cplusplus
|
#if __cplusplus
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -502,6 +502,14 @@ extern UINT8 *m_aucSysMem0;
|
|||||||
#define OS_SYS_NOCACHEMEM_ADDR (&g_sysNoCacheMem0[0])
|
#define OS_SYS_NOCACHEMEM_ADDR (&g_sysNoCacheMem0[0])
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup los_config
|
||||||
|
* Configuration of multiple non-continuous memory regions as one memory pool
|
||||||
|
*/
|
||||||
|
#ifndef LOSCFG_MEM_MUL_REGIONS
|
||||||
|
#define LOSCFG_MEM_MUL_REGIONS 0
|
||||||
|
#endif
|
||||||
|
|
||||||
/* =============================================================================
|
/* =============================================================================
|
||||||
Exception module configuration
|
Exception module configuration
|
||||||
============================================================================= */
|
============================================================================= */
|
||||||
|
|||||||
@@ -120,6 +120,47 @@ extern UINT32 LOS_MemDeInit(VOID *pool);
|
|||||||
extern UINT32 LOS_MemPoolList(VOID);
|
extern UINT32 LOS_MemPoolList(VOID);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if (LOSCFG_MEM_MUL_REGIONS == 1)
|
||||||
|
typedef struct {
|
||||||
|
VOID *startAddress;
|
||||||
|
UINT32 length;
|
||||||
|
} LosMemRegion;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup los_memory
|
||||||
|
* @brief Initialize multiple non-continuous memory regions.
|
||||||
|
*
|
||||||
|
* @par Description:
|
||||||
|
* <ul>
|
||||||
|
* <li>This API is used to initialize multiple non-continuous memory regions. If the starting address of a pool is specified,
|
||||||
|
* the memory regions will be linked to the pool as free nodes. Otherwise, the first memory region will be initialized as a
|
||||||
|
* new pool, and the rest regions will be linked as free nodes to the new pool.</li>
|
||||||
|
* </ul>
|
||||||
|
*
|
||||||
|
* @attention
|
||||||
|
* <ul>
|
||||||
|
* <li>If the starting address of a memory pool is specified, the start address of the non-continuous memory regions should be
|
||||||
|
* greater than the end address of the memory pool.</li>
|
||||||
|
* <li>The multiple non-continuous memory regions shouldn't conflict with each other.</li>
|
||||||
|
* </ul>
|
||||||
|
*
|
||||||
|
* @param pool [IN] The memory pool address. If NULL is specified, the start address of first memory region will be
|
||||||
|
* initialized as the memory pool address. If not NULL, it should be a valid address of a memory pool.
|
||||||
|
* @param memRegions [IN] The LosMemRegion array that contains multiple non-continuous memory regions. The start address
|
||||||
|
* of the memory regions are placed in ascending order.
|
||||||
|
* @param memRegionCount [IN] The count of non-continuous memory regions, and it should be the length of the LosMemRegion array.
|
||||||
|
*
|
||||||
|
* @retval #LOS_NOK The multiple non-continuous memory regions fails to be initialized.
|
||||||
|
* @retval #LOS_OK The multiple non-continuous memory regions is initialized successfully.
|
||||||
|
* @par Dependency:
|
||||||
|
* <ul>
|
||||||
|
* <li>los_memory.h: the header file that contains the API declaration.</li>
|
||||||
|
* </ul>
|
||||||
|
* @see None.
|
||||||
|
*/
|
||||||
|
extern UINT32 LOS_MemRegionsAdd(VOID *pool, const LosMemRegion * const memRegions, UINT32 memRegionCount);
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ingroup los_memory
|
* @ingroup los_memory
|
||||||
* Memory pool extern information structure
|
* Memory pool extern information structure
|
||||||
|
|||||||
@@ -192,14 +192,6 @@ LITE_OS_SEC_TEXT_INIT UINT32 LOS_KernelInit(VOID)
|
|||||||
}
|
}
|
||||||
#endif
|
#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)
|
#if (LOSCFG_PLATFORM_EXC == 1)
|
||||||
OsExcMsgDumpInit();
|
OsExcMsgDumpInit();
|
||||||
#endif
|
#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 ",
|
PRINTK("%d %d %s 0x%x 0x%x 0x%x 0x%x 0x%x ",
|
||||||
taskCB->taskID, taskCB->priority, OsConvertTskStatus(taskCB->taskStatus),
|
taskCB->taskID, taskCB->priority, OsConvertTskStatus(taskCB->taskStatus),
|
||||||
taskCB->stackSize, OsGetTaskWaterLine(taskCB->taskID),
|
taskCB->stackSize, OsGetTaskWaterLine(taskCB->taskID),
|
||||||
(UINT32)(UINTPTR)taskCB->stackPointer, taskCB->topOfStack, taskCB->eventMask);
|
(UINT32)(UINTPTR)taskCB->stackPointer, taskCB->topOfStack, taskCB->eventMask);
|
||||||
|
|
||||||
semID = (taskCB->taskSem == NULL) ? OS_NULL_SHORT : (((LosSemCB *)taskCB->taskSem)->semID);
|
semID = (taskCB->taskSem == NULL) ? OS_NULL_SHORT : (((LosSemCB *)taskCB->taskSem)->semID);
|
||||||
PRINTK("0x%x ", semID);
|
PRINTK("0x%x ", semID);
|
||||||
|
|||||||
@@ -156,6 +156,9 @@ struct OsMemPoolInfo {
|
|||||||
UINT32 waterLine; /* Maximum usage size in a memory pool */
|
UINT32 waterLine; /* Maximum usage size in a memory pool */
|
||||||
UINT32 curUsedSize; /* Current usage size in a memory pool */
|
UINT32 curUsedSize; /* Current usage size in a memory pool */
|
||||||
#endif
|
#endif
|
||||||
|
#if (LOSCFG_MEM_MUL_REGIONS == 1)
|
||||||
|
UINT32 totalGapSize;
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
struct OsMemPoolHead {
|
struct OsMemPoolHead {
|
||||||
@@ -276,6 +279,20 @@ STATIC INLINE UINT32 OsMemAllocCheck(struct OsMemPoolHead *pool, UINT32 intSave)
|
|||||||
#define OS_MEM_MAGIC_VALID(node) TRUE
|
#define OS_MEM_MAGIC_VALID(node) TRUE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if (LOSCFG_MEM_MUL_REGIONS == 1)
|
||||||
|
/**
|
||||||
|
* When LOSCFG_MEM_MUL_REGIONS is enabled to support multiple non-continuous memory regions, the gap between two memory regions
|
||||||
|
* is marked as a used OsMemNodeHead node. The gap node couldn't be freed, and would also be skipped in some DFX functions. The
|
||||||
|
* 'ptr.prev' pointer of this node is set to OS_MEM_GAP_NODE_MAGIC to identify that this is a gap node.
|
||||||
|
*/
|
||||||
|
#define OS_MEM_GAP_NODE_MAGIC 0xDCBAABCD
|
||||||
|
#define OS_MEM_MARK_GAP_NODE(node) (((struct OsMemNodeHead *)(node))->ptr.prev = (struct OsMemNodeHead *)OS_MEM_GAP_NODE_MAGIC)
|
||||||
|
#define OS_MEM_IS_GAP_NODE(node) (((struct OsMemNodeHead *)(node))->ptr.prev == (struct OsMemNodeHead *)OS_MEM_GAP_NODE_MAGIC)
|
||||||
|
#else
|
||||||
|
#define OS_MEM_MARK_GAP_NODE(node)
|
||||||
|
#define OS_MEM_IS_GAP_NODE(node) FALSE
|
||||||
|
#endif
|
||||||
|
|
||||||
STATIC INLINE VOID OsMemFreeNodeAdd(VOID *pool, struct OsMemFreeNodeHead *node);
|
STATIC INLINE VOID OsMemFreeNodeAdd(VOID *pool, struct OsMemFreeNodeHead *node);
|
||||||
STATIC INLINE UINT32 OsMemFree(struct OsMemPoolHead *pool, struct OsMemNodeHead *node);
|
STATIC INLINE UINT32 OsMemFree(struct OsMemPoolHead *pool, struct OsMemNodeHead *node);
|
||||||
STATIC VOID OsMemInfoPrint(VOID *pool);
|
STATIC VOID OsMemInfoPrint(VOID *pool);
|
||||||
@@ -514,8 +531,8 @@ STATIC INLINE VOID OsMemUsedNodePrint(struct OsMemNodeHead *node)
|
|||||||
{
|
{
|
||||||
UINT32 count;
|
UINT32 count;
|
||||||
|
|
||||||
if (OS_MEM_NODE_GET_USED_FLAG(node->sizeAndFlag)) {
|
if (OS_MEM_NODE_GET_USED_FLAG(node->sizeAndFlag) && !OS_MEM_IS_GAP_NODE(node)) {
|
||||||
PRINTK("0x%x: 0x%x ", node, OS_MEM_NODE_GET_SIZE(node->sizeAndFlag));
|
PRINTK("0x%x: 0x%x ", (UINTPTR)node, OS_MEM_NODE_GET_SIZE(node->sizeAndFlag));
|
||||||
for (count = 0; count < LOSCFG_MEM_RECORD_LR_CNT; count++) {
|
for (count = 0; count < LOSCFG_MEM_RECORD_LR_CNT; count++) {
|
||||||
PRINTK(" 0x%x ", node->linkReg[count]);
|
PRINTK(" 0x%x ", node->linkReg[count]);
|
||||||
}
|
}
|
||||||
@@ -751,7 +768,7 @@ STATIC INLINE VOID OsMemMergeNode(struct OsMemNodeHead *node)
|
|||||||
|
|
||||||
node->ptr.prev->sizeAndFlag += node->sizeAndFlag;
|
node->ptr.prev->sizeAndFlag += node->sizeAndFlag;
|
||||||
nextNode = (struct OsMemNodeHead *)((UINTPTR)node + node->sizeAndFlag);
|
nextNode = (struct OsMemNodeHead *)((UINTPTR)node + node->sizeAndFlag);
|
||||||
if (!OS_MEM_NODE_GET_LAST_FLAG(nextNode->sizeAndFlag)) {
|
if (!OS_MEM_NODE_GET_LAST_FLAG(nextNode->sizeAndFlag) && !OS_MEM_IS_GAP_NODE(nextNode)) {
|
||||||
nextNode->ptr.prev = node->ptr.prev;
|
nextNode->ptr.prev = node->ptr.prev;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -766,7 +783,7 @@ STATIC INLINE VOID OsMemSplitNode(VOID *pool, struct OsMemNodeHead *allocNode, U
|
|||||||
newFreeNode->header.sizeAndFlag = allocNode->sizeAndFlag - allocSize;
|
newFreeNode->header.sizeAndFlag = allocNode->sizeAndFlag - allocSize;
|
||||||
allocNode->sizeAndFlag = allocSize;
|
allocNode->sizeAndFlag = allocSize;
|
||||||
nextNode = OS_MEM_NEXT_NODE(&newFreeNode->header);
|
nextNode = OS_MEM_NEXT_NODE(&newFreeNode->header);
|
||||||
if (!OS_MEM_NODE_GET_LAST_FLAG(nextNode->sizeAndFlag)) {
|
if (!OS_MEM_NODE_GET_LAST_FLAG(nextNode->sizeAndFlag) && !OS_MEM_IS_GAP_NODE(nextNode)) {
|
||||||
nextNode->ptr.prev = &newFreeNode->header;
|
nextNode->ptr.prev = &newFreeNode->header;
|
||||||
if (!OS_MEM_NODE_GET_USED_FLAG(nextNode->sizeAndFlag)) {
|
if (!OS_MEM_NODE_GET_USED_FLAG(nextNode->sizeAndFlag)) {
|
||||||
OsMemFreeNodeDelete(pool, (struct OsMemFreeNodeHead *)nextNode);
|
OsMemFreeNodeDelete(pool, (struct OsMemFreeNodeHead *)nextNode);
|
||||||
@@ -1161,6 +1178,10 @@ STATIC UINT32 OsMemCheckUsedNode(const struct OsMemPoolHead *pool, const struct
|
|||||||
|
|
||||||
do {
|
do {
|
||||||
do {
|
do {
|
||||||
|
if (OS_MEM_IS_GAP_NODE(node)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (!OsMemIsNodeValid(node, startNode, endNode, pool)) {
|
if (!OsMemIsNodeValid(node, startNode, endNode, pool)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -1174,7 +1195,7 @@ STATIC UINT32 OsMemCheckUsedNode(const struct OsMemPoolHead *pool, const struct
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!OS_MEM_NODE_GET_LAST_FLAG(nextNode->sizeAndFlag)) {
|
if (!OS_MEM_NODE_GET_LAST_FLAG(nextNode->sizeAndFlag) && !OS_MEM_IS_GAP_NODE(nextNode)) {
|
||||||
if (nextNode->ptr.prev != node) {
|
if (nextNode->ptr.prev != node) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -1472,6 +1493,9 @@ UINT32 LOS_MemPoolSizeGet(const VOID *pool)
|
|||||||
}
|
}
|
||||||
|
|
||||||
count += ((struct OsMemPoolHead *)pool)->info.totalSize;
|
count += ((struct OsMemPoolHead *)pool)->info.totalSize;
|
||||||
|
#if (LOSCFG_MEM_MUL_REGIONS == 1)
|
||||||
|
count -= ((struct OsMemPoolHead *)pool)->info.totalGapSize;
|
||||||
|
#endif
|
||||||
|
|
||||||
#if OS_MEM_EXPAND_ENABLE
|
#if OS_MEM_EXPAND_ENABLE
|
||||||
UINT32 size;
|
UINT32 size;
|
||||||
@@ -1524,7 +1548,9 @@ UINT32 LOS_MemTotalUsedGet(VOID *pool)
|
|||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
for (tmpNode = OS_MEM_FIRST_NODE(pool); tmpNode < endNode;) {
|
for (tmpNode = OS_MEM_FIRST_NODE(pool); tmpNode < endNode;) {
|
||||||
if (OS_MEM_NODE_GET_USED_FLAG(tmpNode->sizeAndFlag)) {
|
if (OS_MEM_IS_GAP_NODE(tmpNode)) {
|
||||||
|
memUsed += OS_MEM_NODE_HEAD_SIZE;
|
||||||
|
} else if (OS_MEM_NODE_GET_USED_FLAG(tmpNode->sizeAndFlag)) {
|
||||||
memUsed += OS_MEM_NODE_GET_SIZE(tmpNode->sizeAndFlag);
|
memUsed += OS_MEM_NODE_GET_SIZE(tmpNode->sizeAndFlag);
|
||||||
}
|
}
|
||||||
tmpNode = OS_MEM_NEXT_NODE(tmpNode);
|
tmpNode = OS_MEM_NEXT_NODE(tmpNode);
|
||||||
@@ -1656,6 +1682,9 @@ STATIC UINT32 OsMemIntegrityCheck(const struct OsMemPoolHead *pool, struct OsMem
|
|||||||
*preNode = OS_MEM_FIRST_NODE(pool);
|
*preNode = OS_MEM_FIRST_NODE(pool);
|
||||||
do {
|
do {
|
||||||
for (*tmpNode = *preNode; *tmpNode < endNode; *tmpNode = OS_MEM_NEXT_NODE(*tmpNode)) {
|
for (*tmpNode = *preNode; *tmpNode < endNode; *tmpNode = OS_MEM_NEXT_NODE(*tmpNode)) {
|
||||||
|
if (OS_MEM_IS_GAP_NODE(*tmpNode)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (OsMemIntegrityCheckSub(tmpNode, pool, endNode) == LOS_NOK) {
|
if (OsMemIntegrityCheckSub(tmpNode, pool, endNode) == LOS_NOK) {
|
||||||
return LOS_NOK;
|
return LOS_NOK;
|
||||||
}
|
}
|
||||||
@@ -1853,7 +1882,11 @@ STATIC INLINE VOID OsMemInfoGet(struct OsMemPoolHead *poolInfo, struct OsMemNode
|
|||||||
maxFreeSize = size;
|
maxFreeSize = size;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
size = OS_MEM_NODE_GET_SIZE(node->sizeAndFlag);
|
if (OS_MEM_IS_GAP_NODE(node)) {
|
||||||
|
size = OS_MEM_NODE_HEAD_SIZE;
|
||||||
|
} else {
|
||||||
|
size = OS_MEM_NODE_GET_SIZE(node->sizeAndFlag);
|
||||||
|
}
|
||||||
++usedNodeNum;
|
++usedNodeNum;
|
||||||
totalUsedSize += size;
|
totalUsedSize += size;
|
||||||
}
|
}
|
||||||
@@ -1942,7 +1975,7 @@ STATIC VOID OsMemInfoPrint(VOID *pool)
|
|||||||
PRINTK("--------------- -------- ------- -------- "
|
PRINTK("--------------- -------- ------- -------- "
|
||||||
"-------------- ------------- ------------\n");
|
"-------------- ------------- ------------\n");
|
||||||
PRINTK("0x%-16x 0x%-8x 0x%-8x 0x%-8x 0x%-16x 0x%-13x 0x%-13x\n",
|
PRINTK("0x%-16x 0x%-8x 0x%-8x 0x%-8x 0x%-16x 0x%-13x 0x%-13x\n",
|
||||||
(UINTPTR)poolInfo->info.pool, LOS_MemPoolSizeGet(pool), status.totalUsedSize,
|
poolInfo->info.pool, LOS_MemPoolSizeGet(pool), status.totalUsedSize,
|
||||||
status.totalFreeSize, status.maxFreeNodeSize, status.usedNodeNum,
|
status.totalFreeSize, status.maxFreeNodeSize, status.usedNodeNum,
|
||||||
status.freeNodeNum);
|
status.freeNodeNum);
|
||||||
#endif
|
#endif
|
||||||
@@ -2004,6 +2037,149 @@ VOID LOS_MemUnlockEnable(VOID *pool)
|
|||||||
((struct OsMemPoolHead *)pool)->info.attr |= OS_MEM_POOL_UNLOCK_ENABLE;
|
((struct OsMemPoolHead *)pool)->info.attr |= OS_MEM_POOL_UNLOCK_ENABLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if (LOSCFG_MEM_MUL_REGIONS == 1)
|
||||||
|
STATIC INLINE UINT32 OsMemMulRegionsParamCheck(VOID *pool, const LosMemRegion * const memRegions, UINT32 memRegionCount)
|
||||||
|
{
|
||||||
|
const LosMemRegion *memRegion = NULL;
|
||||||
|
VOID *lastStartAddress = NULL;
|
||||||
|
VOID *curStartAddress = NULL;
|
||||||
|
UINT32 lastLength;
|
||||||
|
UINT32 curLength;
|
||||||
|
UINT32 regionCount;
|
||||||
|
|
||||||
|
if ((pool != NULL) && (((struct OsMemPoolHead *)pool)->info.pool != pool)) {
|
||||||
|
PRINT_ERR("wrong mem pool addr: %p, func: %s, line: %d\n", pool, __FUNCTION__, __LINE__);
|
||||||
|
return LOS_NOK;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pool != NULL) {
|
||||||
|
lastStartAddress = pool;
|
||||||
|
lastLength = ((struct OsMemPoolHead *)pool)->info.totalSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
memRegion = memRegions;
|
||||||
|
regionCount = 0;
|
||||||
|
while (regionCount < memRegionCount) {
|
||||||
|
curStartAddress = memRegion->startAddress;
|
||||||
|
curLength = memRegion->length;
|
||||||
|
if ((curStartAddress == NULL) || (curLength == 0)) {
|
||||||
|
PRINT_ERR("Memory address or length configured wrongly:address:0x%x, the length:0x%x\n", (UINTPTR)curStartAddress, curLength);
|
||||||
|
return LOS_NOK;
|
||||||
|
}
|
||||||
|
if (((UINTPTR)curStartAddress & (OS_MEM_ALIGN_SIZE - 1)) || (curLength & (OS_MEM_ALIGN_SIZE - 1))) {
|
||||||
|
PRINT_ERR("Memory address or length configured not aligned:address:0x%x, the length:0x%x, alignsize:%d\n", \
|
||||||
|
(UINTPTR)curStartAddress, curLength, OS_MEM_ALIGN_SIZE);
|
||||||
|
return LOS_NOK;
|
||||||
|
}
|
||||||
|
if ((lastStartAddress != NULL) && (((UINT8 *)lastStartAddress + lastLength) >= (UINT8 *)curStartAddress)) {
|
||||||
|
PRINT_ERR("Memory regions overlapped, the last start address:0x%x, the length:0x%x, the current start address:0x%x\n", \
|
||||||
|
(UINTPTR)lastStartAddress, lastLength, (UINTPTR)curStartAddress);
|
||||||
|
return LOS_NOK;
|
||||||
|
}
|
||||||
|
memRegion++;
|
||||||
|
regionCount++;
|
||||||
|
lastStartAddress = curStartAddress;
|
||||||
|
lastLength = curLength;
|
||||||
|
}
|
||||||
|
return LOS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
STATIC INLINE VOID OsMemMulRegionsLink(struct OsMemPoolHead *poolHead, VOID *lastStartAddress, UINT32 lastLength, struct OsMemNodeHead *lastEndNode, const LosMemRegion *memRegion)
|
||||||
|
{
|
||||||
|
UINT32 curLength;
|
||||||
|
UINT32 gapSize;
|
||||||
|
struct OsMemNodeHead *curEndNode = NULL;
|
||||||
|
struct OsMemNodeHead *curFreeNode = NULL;
|
||||||
|
VOID *curStartAddress = NULL;
|
||||||
|
|
||||||
|
curStartAddress = memRegion->startAddress;
|
||||||
|
curLength = memRegion->length;
|
||||||
|
|
||||||
|
// mark the gap between two regions as one used node
|
||||||
|
gapSize = (UINT8 *)(curStartAddress) - ((UINT8 *)(lastStartAddress) + lastLength);
|
||||||
|
lastEndNode->sizeAndFlag = gapSize + OS_MEM_NODE_HEAD_SIZE;
|
||||||
|
OS_MEM_SET_MAGIC(lastEndNode);
|
||||||
|
OS_MEM_NODE_SET_USED_FLAG(lastEndNode->sizeAndFlag);
|
||||||
|
|
||||||
|
// mark the gap node with magic number
|
||||||
|
OS_MEM_MARK_GAP_NODE(lastEndNode);
|
||||||
|
|
||||||
|
poolHead->info.totalSize += (curLength + gapSize);
|
||||||
|
poolHead->info.totalGapSize += gapSize;
|
||||||
|
|
||||||
|
curFreeNode = (struct OsMemNodeHead *)curStartAddress;
|
||||||
|
curFreeNode->sizeAndFlag = curLength - OS_MEM_NODE_HEAD_SIZE;
|
||||||
|
curFreeNode->ptr.prev = lastEndNode;
|
||||||
|
OS_MEM_SET_MAGIC(curFreeNode);
|
||||||
|
OsMemFreeNodeAdd(poolHead, (struct OsMemFreeNodeHead *)curFreeNode);
|
||||||
|
|
||||||
|
curEndNode = OS_MEM_END_NODE(curStartAddress, curLength);
|
||||||
|
curEndNode->sizeAndFlag = 0;
|
||||||
|
curEndNode->ptr.prev = curFreeNode;
|
||||||
|
OS_MEM_SET_MAGIC(curEndNode);
|
||||||
|
OS_MEM_NODE_SET_USED_FLAG(curEndNode->sizeAndFlag);
|
||||||
|
|
||||||
|
#if (LOSCFG_MEM_WATERLINE == 1)
|
||||||
|
poolHead->info.curUsedSize += OS_MEM_NODE_HEAD_SIZE;
|
||||||
|
poolHead->info.waterLine = poolHead->info.curUsedSize;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
UINT32 LOS_MemRegionsAdd(VOID *pool, const LosMemRegion *const memRegions, UINT32 memRegionCount)
|
||||||
|
{
|
||||||
|
UINT32 ret;
|
||||||
|
UINT32 lastLength;
|
||||||
|
UINT32 curLength;
|
||||||
|
UINT32 regionCount;
|
||||||
|
struct OsMemPoolHead *poolHead = NULL;
|
||||||
|
struct OsMemNodeHead *lastEndNode = NULL;
|
||||||
|
struct OsMemNodeHead *firstFreeNode = NULL;
|
||||||
|
const LosMemRegion *memRegion = NULL;
|
||||||
|
VOID *lastStartAddress = NULL;
|
||||||
|
VOID *curStartAddress = NULL;
|
||||||
|
|
||||||
|
ret = OsMemMulRegionsParamCheck(pool, memRegions, memRegionCount);
|
||||||
|
if (ret != LOS_OK) {
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
memRegion = memRegions;
|
||||||
|
regionCount = 0;
|
||||||
|
if (pool != NULL) { // add the memory regions to the specified memory pool
|
||||||
|
poolHead = (struct OsMemPoolHead *)pool;
|
||||||
|
lastStartAddress = pool;
|
||||||
|
lastLength = poolHead->info.totalSize;
|
||||||
|
} else { // initialize the memory pool with the first memory region
|
||||||
|
lastStartAddress = memRegion->startAddress;
|
||||||
|
lastLength = memRegion->length;
|
||||||
|
poolHead = (struct OsMemPoolHead *)lastStartAddress;
|
||||||
|
ret = LOS_MemInit(lastStartAddress, lastLength);
|
||||||
|
if (ret != LOS_OK) {
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
memRegion++;
|
||||||
|
regionCount++;
|
||||||
|
}
|
||||||
|
|
||||||
|
firstFreeNode = OS_MEM_FIRST_NODE(lastStartAddress);
|
||||||
|
lastEndNode = OS_MEM_END_NODE(lastStartAddress, lastLength);
|
||||||
|
while (regionCount < memRegionCount) { // traverse the rest memory regions, and initialize them as free nodes and link together
|
||||||
|
curStartAddress = memRegion->startAddress;
|
||||||
|
curLength = memRegion->length;
|
||||||
|
|
||||||
|
OsMemMulRegionsLink(poolHead, lastStartAddress, lastLength, lastEndNode, memRegion);
|
||||||
|
lastStartAddress = curStartAddress;
|
||||||
|
lastLength = curLength;
|
||||||
|
lastEndNode = OS_MEM_END_NODE(curStartAddress, curLength);
|
||||||
|
memRegion++;
|
||||||
|
regionCount++;
|
||||||
|
}
|
||||||
|
|
||||||
|
firstFreeNode->ptr.prev = lastEndNode;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
UINT32 OsMemSystemInit(VOID)
|
UINT32 OsMemSystemInit(VOID)
|
||||||
{
|
{
|
||||||
UINT32 ret;
|
UINT32 ret;
|
||||||
|
|||||||
Reference in New Issue
Block a user