Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d2b40f293d | |||
| b95196e954 | |||
| 61191eb629 | |||
| d47ec89be7 | |||
| 96a8074bb1 | |||
| 91650c04a6 | |||
| dc4cc3fb26 | |||
| 64f43fabd3 |
@@ -31,11 +31,6 @@ import("//build/lite/config/component/lite_component.gni")
|
|||||||
|
|
||||||
LITEOS_MENUCONFIG_H = rebase_path("$root_out_dir/config.h")
|
LITEOS_MENUCONFIG_H = rebase_path("$root_out_dir/config.h")
|
||||||
|
|
||||||
declare_args() {
|
|
||||||
liteos_name = "OHOS_Image"
|
|
||||||
liteos_kernel_only = false
|
|
||||||
}
|
|
||||||
|
|
||||||
import("liteos.gni")
|
import("liteos.gni")
|
||||||
|
|
||||||
if (defined(LOSCFG_COMPILER_ICCARM)) {
|
if (defined(LOSCFG_COMPILER_ICCARM)) {
|
||||||
@@ -194,15 +189,7 @@ executable("liteos") {
|
|||||||
":los_config",
|
":los_config",
|
||||||
]
|
]
|
||||||
|
|
||||||
if (defined(LOSCFG_COMPILER_ICCARM)) {
|
ldflags = executable_config_ldflags
|
||||||
ldflags = [ "--map=$liteos_name.map" ]
|
|
||||||
} else {
|
|
||||||
ldflags = [
|
|
||||||
"-static",
|
|
||||||
"-Wl,--gc-sections",
|
|
||||||
"-Wl,-Map=$liteos_name.map",
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
output_dir = target_out_dir
|
output_dir = target_out_dir
|
||||||
|
|
||||||
@@ -223,20 +210,5 @@ build_ext_component("build_kernel_image") {
|
|||||||
deps = [ ":copy_liteos" ]
|
deps = [ ":copy_liteos" ]
|
||||||
exec_path = rebase_path(root_out_dir)
|
exec_path = rebase_path(root_out_dir)
|
||||||
|
|
||||||
if (defined(LOSCFG_COMPILER_ICCARM)) {
|
command = toochain_config_command
|
||||||
objcopy = "${compile_prefix}ielftool$toolchain_cmd_suffix"
|
|
||||||
objdump = "${compile_prefix}ielfdumparm$toolchain_cmd_suffix"
|
|
||||||
|
|
||||||
command = "$objcopy --bin --verbose $liteos_name $liteos_name.bin"
|
|
||||||
command +=
|
|
||||||
" && sh -c '$objdump --source --all $liteos_name -o $liteos_name.asm'"
|
|
||||||
} else {
|
|
||||||
objcopy = "${compile_prefix}objcopy$toolchain_cmd_suffix"
|
|
||||||
objdump = "${compile_prefix}objdump$toolchain_cmd_suffix"
|
|
||||||
|
|
||||||
command = "$objcopy -O binary $liteos_name $liteos_name.bin"
|
|
||||||
command +=
|
|
||||||
" && sh -c '$objdump -t $liteos_name | sort >$liteos_name.sym.sorted'"
|
|
||||||
command += " && sh -c '$objdump -d $liteos_name >$liteos_name.asm'"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -357,15 +357,10 @@ config KERNEL_PM_DEBUG
|
|||||||
help
|
help
|
||||||
Configuration item for low power frame debug tailoring.
|
Configuration item for low power frame debug tailoring.
|
||||||
|
|
||||||
config DEBUG_HOOK
|
|
||||||
bool
|
|
||||||
default n
|
|
||||||
|
|
||||||
config PLATFORM_EXC
|
config PLATFORM_EXC
|
||||||
bool "Enable Hook Feature"
|
bool "Enable Platform Exc Hook"
|
||||||
default n
|
default n
|
||||||
depends on KERNEL_EXTKERNEL
|
depends on KERNEL_EXTKERNEL
|
||||||
select DEBUG_HOOK
|
|
||||||
|
|
||||||
config KERNEL_LMK
|
config KERNEL_LMK
|
||||||
bool "Enable Low Memory Killer"
|
bool "Enable Low Memory Killer"
|
||||||
@@ -532,14 +527,20 @@ config DEBUG_SEMAPHORE
|
|||||||
help
|
help
|
||||||
Answer Y to enable debug semaphore.
|
Answer Y to enable debug semaphore.
|
||||||
|
|
||||||
source "components/shell/Kconfig"
|
|
||||||
config NET_LWIP_SACK_TFTP
|
config NET_LWIP_SACK_TFTP
|
||||||
bool "Enable Tftp"
|
bool "Enable Tftp"
|
||||||
default y
|
default y
|
||||||
depends on SHELL && NET_LWIP_SACK && DEBUG_VERSION
|
depends on SHELL && NET_LWIP_SACK && DEBUG_VERSION
|
||||||
help
|
help
|
||||||
Answer Y to enable LiteOS support tftp cmd and tftp tool.
|
Answer Y to enable LiteOS support tftp cmd and tftp tool.
|
||||||
osource "net/telnet/Kconfig"
|
|
||||||
|
config DEBUG_HOOK
|
||||||
|
bool "Enable Hook Framework"
|
||||||
|
default n
|
||||||
|
depends on DEBUG_VERSION
|
||||||
|
help
|
||||||
|
Enable the kernel hook framework to support customized trace information capture.
|
||||||
|
|
||||||
config SCHED_DEBUG
|
config SCHED_DEBUG
|
||||||
bool "Enable sched debug Feature"
|
bool "Enable sched debug Feature"
|
||||||
default n
|
default n
|
||||||
@@ -606,6 +607,8 @@ config TASK_MEM_USED
|
|||||||
default n
|
default n
|
||||||
depends on DEBUG_VERSION && MEM_DEBUG
|
depends on DEBUG_VERSION && MEM_DEBUG
|
||||||
|
|
||||||
|
source "components/shell/Kconfig"
|
||||||
|
|
||||||
endmenu
|
endmenu
|
||||||
|
|
||||||
######################## config options os drivers ########################
|
######################## config options os drivers ########################
|
||||||
|
|||||||
@@ -724,7 +724,7 @@ STATIC INT32 OsWildcardExtractDirectory(CHAR *fullpath, VOID *dst, wildcard_type
|
|||||||
|
|
||||||
if (d == NULL) {
|
if (d == NULL) {
|
||||||
perror("opendir error");
|
perror("opendir error");
|
||||||
return VFS_ERROR;
|
return (INT32)VFS_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
config KERNEL_TRACE
|
config KERNEL_TRACE
|
||||||
bool "Enable Trace Feature"
|
bool "Enable Trace Feature"
|
||||||
default n
|
default n
|
||||||
depends on DEBUG_HOOK
|
select DEBUG_HOOK
|
||||||
|
|
||||||
config TRACE_MSG_EXTEND
|
config TRACE_MSG_EXTEND
|
||||||
bool "Enable Record more extended content"
|
bool "Enable Record more extended content"
|
||||||
|
|||||||
+20
@@ -31,6 +31,9 @@ import("liteos.gni")
|
|||||||
|
|
||||||
LITEOS_MENUCONFIG_H = rebase_path("$root_out_dir/config.h")
|
LITEOS_MENUCONFIG_H = rebase_path("$root_out_dir/config.h")
|
||||||
|
|
||||||
|
liteos_name = "OHOS_Image"
|
||||||
|
liteos_kernel_only = false
|
||||||
|
|
||||||
#
|
#
|
||||||
# arch_config
|
# arch_config
|
||||||
#
|
#
|
||||||
@@ -188,3 +191,20 @@ if (!defined(LOSCFG_COMPILER_CLANG_LLVM)) {
|
|||||||
}
|
}
|
||||||
misc_config_asmflags += misc_config_cflags
|
misc_config_asmflags += misc_config_cflags
|
||||||
misc_config_asmflags += [ "-DCLZ=CLZ" ]
|
misc_config_asmflags += [ "-DCLZ=CLZ" ]
|
||||||
|
|
||||||
|
# ldflags for generating executable bin files
|
||||||
|
executable_config_ldflags = [
|
||||||
|
"-static",
|
||||||
|
"-Wl,--gc-sections",
|
||||||
|
"-Wl,-Map=$liteos_name.map",
|
||||||
|
]
|
||||||
|
|
||||||
|
# Commands to generate kernel_image
|
||||||
|
toochain_config_objcopy = "${compile_prefix}objcopy$toolchain_cmd_suffix"
|
||||||
|
toochain_config_objdump = "${compile_prefix}objdump$toolchain_cmd_suffix"
|
||||||
|
|
||||||
|
toochain_config_command =
|
||||||
|
"$toochain_config_objcopy -O binary $liteos_name $liteos_name.bin"
|
||||||
|
toochain_config_command += " && sh -c '$toochain_config_objdump -t $liteos_name | sort >$liteos_name.sym.sorted'"
|
||||||
|
toochain_config_command +=
|
||||||
|
" && sh -c '$toochain_config_objdump -d $liteos_name >$liteos_name.asm'"
|
||||||
|
|||||||
@@ -31,6 +31,9 @@ import("liteos.gni")
|
|||||||
|
|
||||||
LITEOS_MENUCONFIG_H = rebase_path("$root_out_dir/config.h")
|
LITEOS_MENUCONFIG_H = rebase_path("$root_out_dir/config.h")
|
||||||
|
|
||||||
|
liteos_name = "OHOS_Image"
|
||||||
|
liteos_kernel_only = false
|
||||||
|
|
||||||
#
|
#
|
||||||
# arch_config
|
# arch_config
|
||||||
#
|
#
|
||||||
@@ -138,3 +141,14 @@ misc_config_cflags = []
|
|||||||
misc_config_asmflags = []
|
misc_config_asmflags = []
|
||||||
|
|
||||||
misc_config_asmflags += [ "-DCLZ=CLZ" ]
|
misc_config_asmflags += [ "-DCLZ=CLZ" ]
|
||||||
|
|
||||||
|
# ldflags for generating executable bin files
|
||||||
|
executable_config_ldflags = [ "--map=$liteos_name.map" ]
|
||||||
|
|
||||||
|
# Commands to generate kernel_image
|
||||||
|
toochain_config_objcopy = "${compile_prefix}ielftool$toolchain_cmd_suffix"
|
||||||
|
toochain_config_objdump = "${compile_prefix}ielfdumparm$toolchain_cmd_suffix"
|
||||||
|
|
||||||
|
toochain_config_command =
|
||||||
|
"$toochain_config_objcopy --bin --verbose $liteos_name $liteos_name.bin"
|
||||||
|
toochain_config_command += " && sh -c '$toochain_config_objdump --source --all $liteos_name -o $liteos_name.asm'"
|
||||||
|
|||||||
@@ -631,6 +631,12 @@ void osThreadExit(void)
|
|||||||
UNREACHABLE;
|
UNREACHABLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* before kernel running osDelay is implemented by HalDelay interface */
|
||||||
|
WEAK VOID HalDelay(UINT32 ticks)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
osStatus_t osDelay(uint32_t ticks)
|
osStatus_t osDelay(uint32_t ticks)
|
||||||
{
|
{
|
||||||
UINT32 ret;
|
UINT32 ret;
|
||||||
@@ -640,6 +646,12 @@ osStatus_t osDelay(uint32_t ticks)
|
|||||||
if (ticks == 0) {
|
if (ticks == 0) {
|
||||||
return osErrorParameter;
|
return osErrorParameter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (osKernelGetState() != osKernelRunning) {
|
||||||
|
HalDelay(ticks);
|
||||||
|
return osOK;
|
||||||
|
}
|
||||||
|
|
||||||
ret = LOS_TaskDelay(ticks);
|
ret = LOS_TaskDelay(ticks);
|
||||||
if (ret == LOS_OK) {
|
if (ret == LOS_OK) {
|
||||||
return osOK;
|
return osOK;
|
||||||
@@ -788,7 +800,7 @@ osStatus_t osTimerStop(osTimerId_t timer_id)
|
|||||||
uint32_t osTimerIsRunning(osTimerId_t timer_id)
|
uint32_t osTimerIsRunning(osTimerId_t timer_id)
|
||||||
{
|
{
|
||||||
if (OS_INT_ACTIVE) {
|
if (OS_INT_ACTIVE) {
|
||||||
return osErrorISR;
|
return (uint32_t)osErrorISR;
|
||||||
}
|
}
|
||||||
if (timer_id == NULL) {
|
if (timer_id == NULL) {
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@@ -31,7 +31,6 @@
|
|||||||
#ifndef _ADAPT_TIME_H
|
#ifndef _ADAPT_TIME_H
|
||||||
#define _ADAPT_TIME_H
|
#define _ADAPT_TIME_H
|
||||||
|
|
||||||
#define _timezone timezone
|
|
||||||
#define __TM_GMTOFF __tm_gmtoff
|
#define __TM_GMTOFF __tm_gmtoff
|
||||||
#define __TM_ZONE __tm_zone
|
#define __TM_ZONE __tm_zone
|
||||||
|
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ int _gettimeofday(struct timeval *__tp, void *__tzp)
|
|||||||
__tp->tv_usec = ts.tv_nsec / OS_SYS_NS_PER_US;
|
__tp->tv_usec = ts.tv_nsec / OS_SYS_NS_PER_US;
|
||||||
}
|
}
|
||||||
if (tz != NULL) {
|
if (tz != NULL) {
|
||||||
tz->tz_minuteswest = timezone / SECS_PER_MIN;
|
tz->tz_minuteswest = _timezone / SECS_PER_MIN;
|
||||||
tz->tz_dsttime = 0;
|
tz->tz_dsttime = 0;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
Executable
+95
@@ -0,0 +1,95 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||||
|
* Copyright (c) 2022-2022 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 _RTC_TIME_HOOK_H
|
||||||
|
#define _RTC_TIME_HOOK_H
|
||||||
|
|
||||||
|
#include "los_config.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
#if __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif /* __cplusplus */
|
||||||
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* RTC interfaces for improving the accuracy of the time, need implement and
|
||||||
|
* register by user, implementation method is as follows:
|
||||||
|
*
|
||||||
|
* UINT64 RtcGetTickHook(VOID)
|
||||||
|
* brief: supplement expanded ticks
|
||||||
|
* input: VOID
|
||||||
|
* return: UINT64 ticks
|
||||||
|
*
|
||||||
|
* INT32 RtcGetTimeHook(UINT64 *usec)
|
||||||
|
* brief: get RTC time
|
||||||
|
* output: UINT64 *usec, pointer to get the time, value is counted in microsecond(us)
|
||||||
|
* return: non-0 if error, 0 if success.
|
||||||
|
*
|
||||||
|
* INT32 RtcSetTimeHook(UINT64 msec, UINT64 *usec)
|
||||||
|
* brief: set RTC time
|
||||||
|
* input: UINT64 msec, the time to be set counted in millisecond(ms).
|
||||||
|
* input: UINT64 *usec, the time to be set counted in microsecond(us)
|
||||||
|
* return: non-0 if error, 0 if success.
|
||||||
|
*
|
||||||
|
* INT32 RtcGetTimezoneHook(INT32 *tz)
|
||||||
|
* brief: get RTC timezone
|
||||||
|
* output: INT32 *tz, pointer to get the timezone, value is counted in second
|
||||||
|
* return: non-0 if error, 0 if success.
|
||||||
|
*
|
||||||
|
* INT32 RtcSetTimezoneHook(INT32 tz)
|
||||||
|
* brief: set RTC timezone
|
||||||
|
* input: INT32 tz, the timezone to be set, value is counted in second
|
||||||
|
* return: non-0 if error, 0 if success.
|
||||||
|
*/
|
||||||
|
struct RtcTimeHook {
|
||||||
|
UINT64 (*RtcGetTickHook)(VOID);
|
||||||
|
INT32 (*RtcGetTimeHook)(UINT64 *usec);
|
||||||
|
INT32 (*RtcSetTimeHook)(UINT64 msec, UINT64 *usec);
|
||||||
|
INT32 (*RtcGetTimezoneHook)(INT32 *tz);
|
||||||
|
INT32 (*RtcSetTimezoneHook)(INT32 tz);
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @brief let user register a RTC getter hook to improve time accuracy for time-related POSIX methods.
|
||||||
|
* @param cfg, a structure, member is pointer to function to be registered
|
||||||
|
* @return VOID.
|
||||||
|
*/
|
||||||
|
VOID LOS_RtcHookRegister(struct RtcTimeHook *cfg);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
#if __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif /* __cplusplus */
|
||||||
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -163,14 +163,14 @@ STATIC int SaveMqueueName(const CHAR *mqName, struct mqarray *mqueueCB)
|
|||||||
mqueueCB->mq_name = (char *)LOS_MemAlloc(OS_SYS_MEM_ADDR, nameLen + 1);
|
mqueueCB->mq_name = (char *)LOS_MemAlloc(OS_SYS_MEM_ADDR, nameLen + 1);
|
||||||
if (mqueueCB->mq_name == NULL) {
|
if (mqueueCB->mq_name == NULL) {
|
||||||
errno = ENOMEM;
|
errno = ENOMEM;
|
||||||
return LOS_NOK;
|
return (int)LOS_NOK;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strncpy_s(mqueueCB->mq_name, (nameLen + 1), mqName, nameLen) != EOK) {
|
if (strncpy_s(mqueueCB->mq_name, (nameLen + 1), mqName, nameLen) != EOK) {
|
||||||
LOS_MemFree(OS_SYS_MEM_ADDR, mqueueCB->mq_name);
|
LOS_MemFree(OS_SYS_MEM_ADDR, mqueueCB->mq_name);
|
||||||
mqueueCB->mq_name = NULL;
|
mqueueCB->mq_name = NULL;
|
||||||
errno = EINVAL;
|
errno = EINVAL;
|
||||||
return LOS_NOK;
|
return (int)LOS_NOK;
|
||||||
}
|
}
|
||||||
mqueueCB->mq_name[nameLen] = '\0';
|
mqueueCB->mq_name[nameLen] = '\0';
|
||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
|
|||||||
@@ -215,6 +215,7 @@ STATIC INT32 PipeDevRegister(CHAR *devName, UINT32 len)
|
|||||||
{
|
{
|
||||||
INT32 ret;
|
INT32 ret;
|
||||||
INT32 num = PipeDevNumAlloc();
|
INT32 num = PipeDevNumAlloc();
|
||||||
|
struct PipeDev *devTemp = NULL;
|
||||||
if (num < 0) {
|
if (num < 0) {
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
}
|
}
|
||||||
@@ -228,7 +229,7 @@ STATIC INT32 PipeDevRegister(CHAR *devName, UINT32 len)
|
|||||||
(VOID)snprintf_s(dev->devName, PIPE_DEV_NAME_MAX, PIPE_DEV_NAME_MAX - 1, "%s%d", PIPE_DEV_PATH, num);
|
(VOID)snprintf_s(dev->devName, PIPE_DEV_NAME_MAX, PIPE_DEV_NAME_MAX - 1, "%s%d", PIPE_DEV_PATH, num);
|
||||||
(VOID)memcpy_s(devName, len, dev->devName, strlen(dev->devName));
|
(VOID)memcpy_s(devName, len, dev->devName, strlen(dev->devName));
|
||||||
|
|
||||||
struct PipeDev *devTemp = PipeDevFind(dev->devName);
|
devTemp = PipeDevFind(dev->devName);
|
||||||
if (devTemp != NULL) {
|
if (devTemp != NULL) {
|
||||||
ret = -EEXIST;
|
ret = -EEXIST;
|
||||||
goto ERROR;
|
goto ERROR;
|
||||||
|
|||||||
@@ -504,6 +504,8 @@ int pthread_detach(pthread_t thread)
|
|||||||
void pthread_exit(void *retVal)
|
void pthread_exit(void *retVal)
|
||||||
{
|
{
|
||||||
UINT32 intSave;
|
UINT32 intSave;
|
||||||
|
LosTaskCB *tcb = NULL;
|
||||||
|
PthreadData *pthreadData = NULL;
|
||||||
|
|
||||||
pthread_t thread = pthread_self();
|
pthread_t thread = pthread_self();
|
||||||
if (!IsPthread(thread)) {
|
if (!IsPthread(thread)) {
|
||||||
@@ -511,9 +513,9 @@ void pthread_exit(void *retVal)
|
|||||||
goto EXIT;
|
goto EXIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
LosTaskCB *tcb = OS_TCB_FROM_TID((UINT32)thread);
|
tcb = OS_TCB_FROM_TID((UINT32)thread);
|
||||||
tcb->joinRetval = (UINTPTR)retVal;
|
tcb->joinRetval = (UINTPTR)retVal;
|
||||||
PthreadData *pthreadData = (PthreadData *)(UINTPTR)tcb->arg;
|
pthreadData = (PthreadData *)(UINTPTR)tcb->arg;
|
||||||
if (pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL) != 0) {
|
if (pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL) != 0) {
|
||||||
PRINT_ERR("%s: %d failed\n", __FUNCTION__, __LINE__);
|
PRINT_ERR("%s: %d failed\n", __FUNCTION__, __LINE__);
|
||||||
}
|
}
|
||||||
|
|||||||
+134
-33
@@ -1,6 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
* Copyright (c) 2022-2022 Huawei Device 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,
|
* Redistribution and use in source and binary forms, with or without modification,
|
||||||
* are permitted provided that the following conditions are met:
|
* are permitted provided that the following conditions are met:
|
||||||
@@ -44,6 +43,7 @@
|
|||||||
#include "los_context.h"
|
#include "los_context.h"
|
||||||
#include "los_interrupt.h"
|
#include "los_interrupt.h"
|
||||||
#include "sys/times.h"
|
#include "sys/times.h"
|
||||||
|
#include "rtc_time_hook.h"
|
||||||
|
|
||||||
#define DELAYTIMER_MAX 0x7FFFFFFFF
|
#define DELAYTIMER_MAX 0x7FFFFFFFF
|
||||||
|
|
||||||
@@ -61,12 +61,38 @@ 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 };
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef __USE_NEWLIB__
|
||||||
|
#define g_timezone timezone
|
||||||
|
#else
|
||||||
|
#define g_Timezone _timezone
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Time zone information, stored in seconds,
|
* 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.
|
||||||
*/
|
*/
|
||||||
long timezone = -8 * 60 * 60; // defaults to CST: 8 hours east of the Prime Meridian
|
long g_timezone = -8 * 60 * 60; // set default to CST(UTC+8)
|
||||||
|
|
||||||
|
/*
|
||||||
|
* store register rtc func
|
||||||
|
*/
|
||||||
|
STATIC struct RtcTimeHook g_rtcTimeFunc;
|
||||||
|
|
||||||
|
STATIC UINT64 g_rtcTimeBase = 0;
|
||||||
|
STATIC UINT64 g_systickBase = 0;
|
||||||
|
|
||||||
|
VOID LOS_RtcHookRegister(struct RtcTimeHook *cfg)
|
||||||
|
{
|
||||||
|
if (cfg == NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
g_rtcTimeFunc.RtcGetTickHook = cfg->RtcGetTickHook;
|
||||||
|
g_rtcTimeFunc.RtcGetTimeHook = cfg->RtcGetTimeHook;
|
||||||
|
g_rtcTimeFunc.RtcSetTimeHook = cfg->RtcSetTimeHook;
|
||||||
|
g_rtcTimeFunc.RtcGetTimezoneHook = cfg->RtcGetTimezoneHook;
|
||||||
|
g_rtcTimeFunc.RtcSetTimezoneHook = cfg->RtcSetTimezoneHook;
|
||||||
|
}
|
||||||
|
|
||||||
int nanosleep(const struct timespec *rqtp, struct timespec *rmtp)
|
int nanosleep(const struct timespec *rqtp, struct timespec *rmtp)
|
||||||
{
|
{
|
||||||
@@ -443,6 +469,10 @@ int clock_nanosleep(clockid_t clk, int flags, const struct timespec *req, struct
|
|||||||
|
|
||||||
clock_t clock(void)
|
clock_t clock(void)
|
||||||
{
|
{
|
||||||
|
if (g_rtcTimeFunc.RtcGetTickHook != NULL) {
|
||||||
|
return g_rtcTimeFunc.RtcGetTickHook();
|
||||||
|
}
|
||||||
|
|
||||||
clock_t clk;
|
clock_t clk;
|
||||||
struct timespec hwTime;
|
struct timespec hwTime;
|
||||||
OsGetHwTime(&hwTime);
|
OsGetHwTime(&hwTime);
|
||||||
@@ -453,19 +483,52 @@ clock_t clock(void)
|
|||||||
return clk;
|
return clk;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
STATIC UINT64 GetCurrentTime(VOID)
|
||||||
|
{
|
||||||
|
UINT64 tickDelta = 0;
|
||||||
|
UINT64 currentTick;
|
||||||
|
|
||||||
|
if (g_rtcTimeFunc.RtcGetTickHook != NULL) {
|
||||||
|
currentTick = g_rtcTimeFunc.RtcGetTickHook();
|
||||||
|
if ((g_systickBase != 0) && (currentTick > g_systickBase)) {
|
||||||
|
tickDelta = currentTick - g_systickBase;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return g_rtcTimeBase + LOS_Tick2MS((UINT32)tickDelta);
|
||||||
|
}
|
||||||
|
|
||||||
time_t time(time_t *timer)
|
time_t time(time_t *timer)
|
||||||
{
|
{
|
||||||
struct timespec ts;
|
UINT64 usec = 0;
|
||||||
|
time_t sec;
|
||||||
|
INT32 rtcRet = 0;
|
||||||
|
|
||||||
if (-1 == clock_gettime(CLOCK_REALTIME, &ts)) {
|
if (g_rtcTimeFunc.RtcGetTimeHook != NULL) {
|
||||||
return (time_t)-1;
|
rtcRet = g_rtcTimeFunc.RtcGetTimeHook(&usec);
|
||||||
}
|
if (rtcRet != 0) {
|
||||||
|
UINT64 currentTime;
|
||||||
|
currentTime = GetCurrentTime();
|
||||||
|
sec = currentTime / OS_SYS_MS_PER_SECOND;
|
||||||
|
} else {
|
||||||
|
sec = usec / OS_SYS_US_PER_SECOND;
|
||||||
|
}
|
||||||
|
if (timer != NULL) {
|
||||||
|
*timer = sec;
|
||||||
|
}
|
||||||
|
return sec;
|
||||||
|
} else {
|
||||||
|
struct timespec ts;
|
||||||
|
if (-1 == clock_gettime(CLOCK_REALTIME, &ts)) {
|
||||||
|
return (time_t)-1;
|
||||||
|
}
|
||||||
|
|
||||||
if (timer != NULL) {
|
if (timer != NULL) {
|
||||||
*timer = ts.tv_sec;
|
*timer = ts.tv_sec;
|
||||||
|
}
|
||||||
|
return ts.tv_sec;
|
||||||
}
|
}
|
||||||
return ts.tv_sec;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef __USE_NEWLIB__
|
#ifndef __USE_NEWLIB__
|
||||||
/*
|
/*
|
||||||
* Compute the `struct tm' representation of T,
|
* Compute the `struct tm' representation of T,
|
||||||
@@ -558,7 +621,7 @@ struct tm *localtime_r(const time_t *timep, struct tm *result)
|
|||||||
errno = EFAULT;
|
errno = EFAULT;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (!ConvertSecs2Utc(*timep, -timezone, result)) {
|
if (!ConvertSecs2Utc(*timep, -g_timezone, result)) {
|
||||||
errno = EINVAL;
|
errno = EINVAL;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@@ -633,18 +696,42 @@ time_t mktime(struct tm *tmptr)
|
|||||||
|
|
||||||
int gettimeofday(struct timeval *tv, void *ptz)
|
int gettimeofday(struct timeval *tv, void *ptz)
|
||||||
{
|
{
|
||||||
struct timespec ts;
|
|
||||||
struct timezone *tz = (struct timezone *)ptz;
|
struct timezone *tz = (struct timezone *)ptz;
|
||||||
|
|
||||||
if (tv != NULL) {
|
if (tv != NULL) {
|
||||||
if (-1 == clock_gettime(CLOCK_REALTIME, &ts)) {
|
INT32 rtcRet;
|
||||||
return -1;
|
UINT64 usec = 0;
|
||||||
|
UINT64 currentTime;
|
||||||
|
|
||||||
|
if (g_rtcTimeFunc.RtcGetTimeHook != NULL) {
|
||||||
|
rtcRet = g_rtcTimeFunc.RtcGetTimeHook(&usec);
|
||||||
|
if (rtcRet != 0) {
|
||||||
|
currentTime = GetCurrentTime();
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
struct timespec ts;
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
tv->tv_sec = ts.tv_sec;
|
|
||||||
tv->tv_usec = ts.tv_nsec / OS_SYS_NS_PER_US;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tz != NULL) {
|
if (tz != NULL) {
|
||||||
tz->tz_minuteswest = timezone / SECS_PER_MIN;
|
INT32 timeZone = 0;
|
||||||
|
if (g_rtcTimeFunc.RtcGetTimezoneHook != NULL) {
|
||||||
|
g_rtcTimeFunc.RtcGetTimezoneHook(&timeZone);
|
||||||
|
tz->tz_minuteswest = timezone / SECS_PER_MIN;
|
||||||
|
} else {
|
||||||
|
tz->tz_minuteswest = g_timezone / SECS_PER_MIN;
|
||||||
|
}
|
||||||
|
|
||||||
tz->tz_dsttime = 0;
|
tz->tz_dsttime = 0;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
@@ -654,34 +741,49 @@ int gettimeofday(struct timeval *tv, void *ptz)
|
|||||||
int settimeofday(const struct timeval *tv, const struct timezone *tz)
|
int settimeofday(const struct timeval *tv, const struct timezone *tz)
|
||||||
{
|
{
|
||||||
struct timespec ts;
|
struct timespec ts;
|
||||||
INT32 rtcTimeZone = timezone;
|
|
||||||
|
|
||||||
if (tv == NULL) {
|
if (tv == NULL) {
|
||||||
errno = EFAULT;
|
errno = EFAULT;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tv->tv_usec >= OS_SYS_US_PER_SECOND) {
|
if (tv->tv_usec >= OS_SYS_US_PER_SECOND) {
|
||||||
errno = EINVAL;
|
errno = EINVAL;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ts.tv_sec = tv->tv_sec;
|
if (tz != NULL) {
|
||||||
ts.tv_nsec = tv->tv_usec * OS_SYS_NS_PER_US;
|
if ((tz->tz_minuteswest >= TIME_ZONE_MIN) &&
|
||||||
if (-1 == clock_settime(CLOCK_REALTIME, &ts)) {
|
(tz->tz_minuteswest <= TIME_ZONE_MAX)) {
|
||||||
return -1;
|
g_timezone = tz->tz_minuteswest * SECS_PER_MIN;
|
||||||
|
} else {
|
||||||
|
errno = EINVAL;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (g_rtcTimeFunc.RtcSetTimezoneHook != NULL) {
|
||||||
|
g_rtcTimeFunc.RtcSetTimezoneHook(g_timezone);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
timezone = rtcTimeZone;
|
if (g_rtcTimeFunc.RtcSetTimeHook != NULL) {
|
||||||
|
UINT64 usec;
|
||||||
|
g_rtcTimeBase = tv->tv_sec * OS_SYS_MS_PER_SECOND + tv->tv_usec / OS_SYS_MS_PER_SECOND;
|
||||||
|
usec = tv->tv_sec * OS_SYS_US_PER_SECOND + tv->tv_usec;
|
||||||
|
if (-1 == g_rtcTimeFunc.RtcSetTimeHook(g_rtcTimeBase, &usec)) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (g_rtcTimeFunc.RtcGetTickHook != NULL) {
|
||||||
|
g_systickBase = g_rtcTimeFunc.RtcGetTickHook();
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -718,4 +820,3 @@ clock_t times(struct tms *tms)
|
|||||||
}
|
}
|
||||||
return clockTick;
|
return clockTick;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1901,14 +1901,12 @@ STATIC VOID OsMemIntegrityCheckError(struct OsMemPoolHead *pool,
|
|||||||
if (taskID >= LOSCFG_BASE_CORE_TSK_LIMIT) {
|
if (taskID >= LOSCFG_BASE_CORE_TSK_LIMIT) {
|
||||||
MEM_UNLOCK(pool, intSave);
|
MEM_UNLOCK(pool, intSave);
|
||||||
LOS_Panic("Task ID %u in pre node is invalid!\n", taskID);
|
LOS_Panic("Task ID %u in pre node is invalid!\n", taskID);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
taskCB = OS_TCB_FROM_TID(taskID);
|
taskCB = OS_TCB_FROM_TID(taskID);
|
||||||
if ((taskCB->taskStatus & OS_TASK_STATUS_UNUSED) || (taskCB->taskEntry == NULL)) {
|
if ((taskCB->taskStatus & OS_TASK_STATUS_UNUSED) || (taskCB->taskEntry == NULL)) {
|
||||||
MEM_UNLOCK(pool, intSave);
|
MEM_UNLOCK(pool, intSave);
|
||||||
LOS_Panic("\r\nTask ID %u in pre node is not created!\n", taskID);
|
LOS_Panic("\r\nTask ID %u in pre node is not created!\n", taskID);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
PRINTK("The prev node is free\n");
|
PRINTK("The prev node is free\n");
|
||||||
|
|||||||
@@ -34,7 +34,7 @@
|
|||||||
|
|
||||||
/* for IAR Compiler */
|
/* for IAR Compiler */
|
||||||
#ifdef __ICCARM__
|
#ifdef __ICCARM__
|
||||||
#include"iccarm_builtin.h"
|
#include "iccarm_builtin.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|||||||
+1
-1
@@ -87,7 +87,7 @@ VOID OsDoExcHook(EXC_TYPE excType)
|
|||||||
INT32 OsLogLevelCheck(INT32 level)
|
INT32 OsLogLevelCheck(INT32 level)
|
||||||
{
|
{
|
||||||
if (level > PRINT_LEVEL) {
|
if (level > PRINT_LEVEL) {
|
||||||
return LOS_NOK;
|
return (INT32)LOS_NOK;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((level != LOG_COMMON_LEVEL) && ((level > LOG_EMG_LEVEL) && (level <= LOG_DEBUG_LEVEL))) {
|
if ((level != LOG_COMMON_LEVEL) && ((level > LOG_EMG_LEVEL) && (level <= LOG_DEBUG_LEVEL))) {
|
||||||
|
|||||||
Reference in New Issue
Block a user