diff --git a/components/fs/fs.c b/components/fs/fs.c index 1bb0cbca..bb08d3eb 100644 --- a/components/fs/fs.c +++ b/components/fs/fs.c @@ -331,7 +331,7 @@ ssize_t read(int fd, void *buf, size_t nbyte) errno = EINVAL; return FS_FAILURE; } - if (nbyte > 1024) { + if (nbyte > 1024) { /* 1024, max random_size */ nbyte = 1024; /* hks_generate_random: random_size must <= 1024 */ } struct hks_blob key = {HKS_BLOB_TYPE_RAW, (uint8_t *)buf, nbyte}; diff --git a/components/fs/littlefs/lfs_api.c b/components/fs/littlefs/lfs_api.c index 9250adeb..67a2db90 100644 --- a/components/fs/littlefs/lfs_api.c +++ b/components/fs/littlefs/lfs_api.c @@ -41,7 +41,7 @@ struct FileOpInfo g_fsOp[LOSCFG_LFS_MAX_MOUNT_SIZE] = {0}; static LittleFsHandleStruct g_handle[LITTLE_FS_MAX_OPEN_FILES] = {0}; struct dirent g_nameValue; static pthread_mutex_t g_FslocalMutex = PTHREAD_MUTEX_INITIALIZER; -static const char *g_littlefsMntName[LOSCFG_LFS_MAX_MOUNT_SIZE] = {"/a","/b","/c"}; +static const char *g_littlefsMntName[LOSCFG_LFS_MAX_MOUNT_SIZE] = {"/a", "/b", "/c"}; LittleFsHandleStruct *LfsAllocFd(const char *fileName, int *fd) { diff --git a/components/net/lwip-2.1/enhancement/src/lwip_ifaddrs.c b/components/net/lwip-2.1/enhancement/src/lwip_ifaddrs.c index 83c408d9..049fdd97 100644 --- a/components/net/lwip-2.1/enhancement/src/lwip_ifaddrs.c +++ b/components/net/lwip-2.1/enhancement/src/lwip_ifaddrs.c @@ -242,7 +242,7 @@ static void getifaddrs_internal(struct getifaddrs_arg *arg) if_storage = new_ifaddrs_storage(); if (if_storage == NULL) { lwip_freeifaddrs( - *(arg->ifap)); /* ifap is assigned to NULL in getifaddrs, so garbage value will not be there */ + *(arg->ifap)); /* ifap is assigned to NULL in getifaddrs, so garbage value will not be there */ arg->ret = ENOMEM; goto RETURN; } diff --git a/components/net/lwip-2.1/porting/src/api_shell.c b/components/net/lwip-2.1/porting/src/api_shell.c index 1e4b968b..d82beb49 100644 --- a/components/net/lwip-2.1/porting/src/api_shell.c +++ b/components/net/lwip-2.1/porting/src/api_shell.c @@ -47,11 +47,9 @@ #include "lwip/icmp.h" #include "los_config.h" #include -#include "lwip/api_shell.h" #include "shcmd.h" #include "shell.h" -#include "los_timer_pri.h" #include "los_debug.h" #include "los_task.h" @@ -104,10 +102,10 @@ int print_netif(struct netif *netif, char *print_buf, unsigned int buf_len) if (buf_len < 1) { goto out; } - if(netif->link_layer_type == LOOPBACK_IF){ - ret = snprintf_s(tmp, buf_len, (buf_len-1), "%s\t", netif->name); + if (netif->link_layer_type == LOOPBACK_IF) { + ret = snprintf_s(tmp, buf_len, (buf_len - 1), "%s\t", netif->name); } else { - ret = snprintf_s(tmp, buf_len, (buf_len-1), "%s%u\t", netif->name, netif->num); + ret = snprintf_s(tmp, buf_len, (buf_len - 1), "%s%u\t", netif->name, netif->num); } if ((ret <= 0) || ((unsigned int)ret >= buf_len)) @@ -317,8 +315,7 @@ static int ping_kill = 0; static void lwip_ping_usage(void) { - PRINTK("Usage:"\ - "\n ping [ip]\n" + PRINTK("Usage:\n ping [ip]\n"); } LWIP_STATIC int OsPingFunc(u32_t *parg) @@ -332,11 +329,11 @@ LWIP_STATIC int OsPingFunc(u32_t *parg) u32_t iecho_len; s16_t ip_hlen; u32_t forever; - u32_t i = 0; + u32_t i; u32_t succ_cnt = 0; u32_t failed_cnt = 0; struct timespec start, end; - long timout_ms = 0; + long timout_ms; struct pollfd pfd; long rtt; int ret = 0; diff --git a/components/shell/src/base/shcmd.c b/components/shell/src/base/shcmd.c index 6c5c2116..312d8222 100755 --- a/components/shell/src/base/shcmd.c +++ b/components/shell/src/base/shcmd.c @@ -190,7 +190,7 @@ LITE_OS_SEC_TEXT_MINOR VOID OsCmdAscendingInsert(CmdItemNode *cmd) } for (cmdItem = LOS_DL_LIST_ENTRY((&cmdInfo.cmdList.list)->pstPrev, CmdItemNode, list); - &cmdItem->list != &(cmdInfo.cmdList.list);) { + &cmdItem->list != &(cmdInfo.cmdList.list); ) { cmdNext = LOS_DL_LIST_ENTRY(cmdItem->list.pstPrev, CmdItemNode, list); if (&cmdNext->list != &(cmdInfo.cmdList.list)) { if ((strncmp(cmdItem->cmd->cmdKey, cmd->cmd->cmdKey, strlen(cmd->cmd->cmdKey)) >= 0) && diff --git a/components/shell/src/base/shmsg.c b/components/shell/src/base/shmsg.c index 9ae03dfc..eb1c15c5 100755 --- a/components/shell/src/base/shmsg.c +++ b/components/shell/src/base/shmsg.c @@ -64,7 +64,7 @@ char *GetCmdName(const char *cmdline, unsigned int len) { unsigned int loop; const char *tmpStr = NULL; - bool quotes = FALSE; + BOOL quotes = FALSE; char *cmdName = NULL; if (cmdline == NULL) { return NULL; @@ -78,7 +78,7 @@ char *GetCmdName(const char *cmdline, unsigned int len) /* Scan the 'cmdline' string for command */ /* Notice: Command string must not have any special name */ - for (tmpStr = cmdline, loop = 0; (*tmpStr != '\0') && (loop < len);) { + for (tmpStr = cmdline, loop = 0; (*tmpStr != '\0') && (loop < len); ) { /* If reach a double quotes, switch the quotes matching status */ if (*tmpStr == '\"') { SWITCH_QUOTES_STATUS(quotes); @@ -114,12 +114,10 @@ int ShellCmdExec(const char *msgName, const char *cmdString) } uintRet = ShellMsgTypeGet(&cmdParsed, msgName); - if (uintRet != LOS_OK) { PRINTK("%s:command not found\n", msgName); return -EFAULT; } else { - (void)OsCmdExec(&cmdParsed, (char *)cmdString); } return 0; diff --git a/components/shell/src/cmds/fullpath.c b/components/shell/src/cmds/fullpath.c index 875217b1..1110db93 100755 --- a/components/shell/src/cmds/fullpath.c +++ b/components/shell/src/cmds/fullpath.c @@ -88,11 +88,11 @@ static char *StrNormalizePath(char *fullpath) while (*src != '\0') { if (*src == '.') { if (*(src + 1) == '/') { - src += 2; + src += 2; /* 2, sizeof "./" */ continue; } else if (*(src + 1) == '.') { - if ((*(src + 2) == '/') || (*(src + 2) == '\0')) { - src += 2; + if ((*(src + 2) == '/') || (*(src + 2) == '\0')) { /* 2, 2, offset to check */ + src += 2; /* 2, sizeof offset */ } else { while ((*src != '\0') && (*src != '/')) { *dest++ = *src++; @@ -174,7 +174,7 @@ static char *VfsNotAbsolutePath(const char *directory, const char *filename, cha /* 2: The position of the path character: / and the end character /0 */ if ((namelen > 1) && (filename[0] == '.') && (filename[1] == '/')) { - filename += 2; + filename += 2; /* 2, sizeof "./" */ } fullpath = (char *)malloc(strlen(directory) + namelen + 2); @@ -184,8 +184,7 @@ static char *VfsNotAbsolutePath(const char *directory, const char *filename, cha return (char *)NULL; } - /* join path and file name */ - + /* 2, sizeof "./", join path and file name */ ret = snprintf_s(fullpath, strlen(directory) + namelen + 2, strlen(directory) + namelen + 1, "%s/%s", directory, filename); if (ret < 0) { @@ -213,7 +212,6 @@ static char *VfsNormalizeFullpath(const char *directory, const char *filename, c /* it's a absolute path, use it directly */ fullpath = strdup(filename); /* copy string */ - if (fullpath == NULL) { *pathname = NULL; SetErrno(ENOMEM); @@ -246,8 +244,7 @@ int VfsNormalizePath(const char *directory, const char *filename, char **pathnam return -EINVAL; } - /* 2: The position of the path character: / and the end character /0 */ - + /* 2, The position of the path character: / and the end character /0 */ if ((filename[0] != '/') && (strlen(directory) + namelen + 2 > TEMP_PATH_MAX)) { return -ENAMETOOLONG; } diff --git a/config.gni b/config.gni old mode 100644 new mode 100755 index d9c0f837..45e83360 --- a/config.gni +++ b/config.gni @@ -33,7 +33,7 @@ declare_args() { enable_ohos_kernel_liteos_m_exchook = true enable_ohos_kernel_liteos_m_kal = true enable_ohos_kernel_liteos_m_fs = true - enable_ohos_kernel_liteos_m_shell = false + enable_ohos_kernel_liteos_m_shell = true enable_ohos_kernel_liteos_m_backtrace = true enable_ohos_kernel_liteos_m_test = false enable_ohos_kernel_liteos_m_pm = true diff --git a/kal/cmsis/kal.h b/kal/cmsis/kal.h index 2dbcd1eb..b1ad1904 100644 --- a/kal/cmsis/kal.h +++ b/kal/cmsis/kal.h @@ -50,10 +50,10 @@ extern "C" { * @version 1.0 */ typedef enum { - /** The timer is not allowed to wake up the RTOS. */ - osTimerRousesIgnore = 0, - /** The timer is allowed to wake up the RTOS. */ - osTimerRousesAllow = 1 + /** The timer is not allowed to wake up the RTOS. */ + osTimerRousesIgnore = 0, + /** The timer is allowed to wake up the RTOS. */ + osTimerRousesAllow = 1 } osTimerRouses_t; /** @@ -61,10 +61,10 @@ typedef enum { * */ typedef enum { - /** The timer ignores alignment. */ - osTimerAlignIgnore = 0, - /** The timer allows alignment. */ - osTimerAlignAllow = 1 + /** The timer ignores alignment. */ + osTimerAlignIgnore = 0, + /** The timer allows alignment. */ + osTimerAlignAllow = 1 } osTimerAlign_t; osTimerId_t osTimerExtNew (osTimerFunc_t func, osTimerType_t type, void *argument, const osTimerAttr_t *attr, diff --git a/kal/posix/src/pthread_attr.c b/kal/posix/src/pthread_attr.c index d5e6d7b4..3caf5ea8 100644 --- a/kal/posix/src/pthread_attr.c +++ b/kal/posix/src/pthread_attr.c @@ -231,3 +231,23 @@ int pthread_attr_getstacksize(const pthread_attr_t *attr, size_t *stackSize) return 0; } + +int sched_get_priority_min(int policy) +{ + if (policy != SCHED_RR) { + errno = EINVAL; + return -1; + } + + return LOS_TASK_PRIORITY_LOWEST; +} + +int sched_get_priority_max(int policy) +{ + if (policy != SCHED_RR) { + errno = EINVAL; + return -1; + } + + return LOS_TASK_PRIORITY_HIGHEST; +} diff --git a/kal/posix/src/time.c b/kal/posix/src/time.c index adf3ca76..0f54fca3 100644 --- a/kal/posix/src/time.c +++ b/kal/posix/src/time.c @@ -42,6 +42,7 @@ #include "los_swtmr.h" #include "los_tick.h" #include "los_context.h" +#include "los_interrupt.h" /* accumulative time delta from discontinuous modify */ STATIC struct timespec g_accDeltaFromSet; diff --git a/kernel/BUILD.gn b/kernel/BUILD.gn index ae9c3420..65f03b25 100644 --- a/kernel/BUILD.gn +++ b/kernel/BUILD.gn @@ -61,7 +61,7 @@ static_library("kernel") { } else if ("$board_cpu" == "cortex-m7") { deps = [ "arch/arm/cortex-m7/gcc/:arch" ] } else if ("$board_cpu" == "cortex-m33") { - deps = [ "arch/arm/cortex-m33/gcc/:arch" ] + deps = [ "arch/arm/cortex-m33/gcc/TZ:arch" ] } else if ("$board_cpu" == "") { if ("$board_arch" == "rv32imac" || "$board_arch" == "rv32imafdc") { deps = [ "arch/risc-v/riscv32/gcc:arch" ] diff --git a/kernel/arch/arm/cortex-m33/gcc/NTZ/los_arch_interrupt.h b/kernel/arch/arm/cortex-m33/gcc/NTZ/los_arch_interrupt.h index 3c98b745..dd1b3ed5 100755 --- a/kernel/arch/arm/cortex-m33/gcc/NTZ/los_arch_interrupt.h +++ b/kernel/arch/arm/cortex-m33/gcc/NTZ/los_arch_interrupt.h @@ -545,7 +545,7 @@ VOID HalExcHardFault(VOID); VOID HalExcMemFault(VOID); VOID HalExcBusFault(VOID); VOID HalExcUsageFault(VOID); -VOID HalExcSvcCall(VOID); +VOID HalSVCHandler(VOID); VOID HalHwiInit(); diff --git a/kernel/arch/arm/cortex-m33/gcc/NTZ/los_exc.S b/kernel/arch/arm/cortex-m33/gcc/NTZ/los_exc.S index af0753ab..5660c577 100755 --- a/kernel/arch/arm/cortex-m33/gcc/NTZ/los_exc.S +++ b/kernel/arch/arm/cortex-m33/gcc/NTZ/los_exc.S @@ -41,7 +41,7 @@ .global HalExcMemFault .global HalExcBusFault .global HalExcUsageFault - .global HalExcSvcCall + .global HalSVCHandler .extern HalExcHandleEntry .extern g_uwExcTbl @@ -148,9 +148,9 @@ osHFExcCommonBMU: B osExcDispatch .fnend - .type HalExcSvcCall, %function - .global HalExcSvcCall -HalExcSvcCall: + .type HalSVCHandler, %function + .global HalSVCHandler +HalSVCHandler: .fnstart .cantunwind TST LR, #0x4 diff --git a/kernel/arch/arm/cortex-m33/gcc/NTZ/los_interrupt.c b/kernel/arch/arm/cortex-m33/gcc/NTZ/los_interrupt.c index c5952da6..d1f55b80 100755 --- a/kernel/arch/arm/cortex-m33/gcc/NTZ/los_interrupt.c +++ b/kernel/arch/arm/cortex-m33/gcc/NTZ/los_interrupt.c @@ -497,7 +497,7 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit() g_hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = HalExcMemFault; g_hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = HalExcBusFault; g_hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = HalExcUsageFault; - g_hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = HalExcSvcCall; + g_hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = HalSVCHandler; g_hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = HalPendSV; g_hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = OsTickHandler; diff --git a/kernel/arch/arm/cortex-m33/gcc/TZ/BUILD.gn b/kernel/arch/arm/cortex-m33/gcc/TZ/BUILD.gn index 3c92fa3c..49389c88 100644 --- a/kernel/arch/arm/cortex-m33/gcc/TZ/BUILD.gn +++ b/kernel/arch/arm/cortex-m33/gcc/TZ/BUILD.gn @@ -41,6 +41,8 @@ static_library("arch") { ] include_dirs = [ + "./non_secure", + "./secure", "../../../../../../kernel/arch/include", "../../../../../../kernel/arch/include", "../../../../../../kernel/include", diff --git a/kernel/arch/arm/cortex-m33/gcc/TZ/non_secure/los_arch_interrupt.h b/kernel/arch/arm/cortex-m33/gcc/TZ/non_secure/los_arch_interrupt.h index 3c98b745..dd1b3ed5 100755 --- a/kernel/arch/arm/cortex-m33/gcc/TZ/non_secure/los_arch_interrupt.h +++ b/kernel/arch/arm/cortex-m33/gcc/TZ/non_secure/los_arch_interrupt.h @@ -545,7 +545,7 @@ VOID HalExcHardFault(VOID); VOID HalExcMemFault(VOID); VOID HalExcBusFault(VOID); VOID HalExcUsageFault(VOID); -VOID HalExcSvcCall(VOID); +VOID HalSVCHandler(VOID); VOID HalHwiInit(); diff --git a/kernel/arch/arm/cortex-m33/gcc/TZ/non_secure/los_dispatch.S b/kernel/arch/arm/cortex-m33/gcc/TZ/non_secure/los_dispatch.S index 756b4f83..08ac871e 100644 --- a/kernel/arch/arm/cortex-m33/gcc/TZ/non_secure/los_dispatch.S +++ b/kernel/arch/arm/cortex-m33/gcc/TZ/non_secure/los_dispatch.S @@ -48,8 +48,6 @@ .type HalStartFirstTask, %function .global HalStartFirstTask HalStartFirstTask: - .fnstart - .cantunwind MOV R0, #2 MSR CONTROL, R0 @@ -77,7 +75,6 @@ __DisabledFPU1: MSR PSP, R12 CPSIE I BX R3 - .fnend .type HalIntLock, %function .global HalIntLock diff --git a/kernel/arch/arm/cortex-m33/gcc/TZ/non_secure/los_exc.S b/kernel/arch/arm/cortex-m33/gcc/TZ/non_secure/los_exc.S index af0753ab..e95b12c5 100755 --- a/kernel/arch/arm/cortex-m33/gcc/TZ/non_secure/los_exc.S +++ b/kernel/arch/arm/cortex-m33/gcc/TZ/non_secure/los_exc.S @@ -41,7 +41,6 @@ .global HalExcMemFault .global HalExcBusFault .global HalExcUsageFault - .global HalExcSvcCall .extern HalExcHandleEntry .extern g_uwExcTbl @@ -148,21 +147,6 @@ osHFExcCommonBMU: B osExcDispatch .fnend - .type HalExcSvcCall, %function - .global HalExcSvcCall -HalExcSvcCall: - .fnstart - .cantunwind - TST LR, #0x4 - ITE EQ - MRSEQ R0, MSP - MRSNE R0, PSP - LDR R1, [R0,#24] - LDRB R0, [R1,#-2] - MOV R1, #0 - B osExcDispatch - .fnend - .type HalExcBusFault, %function .global HalExcBusFault HalExcBusFault: diff --git a/kernel/arch/arm/cortex-m33/gcc/TZ/non_secure/los_interrupt.c b/kernel/arch/arm/cortex-m33/gcc/TZ/non_secure/los_interrupt.c index c5952da6..d1f55b80 100755 --- a/kernel/arch/arm/cortex-m33/gcc/TZ/non_secure/los_interrupt.c +++ b/kernel/arch/arm/cortex-m33/gcc/TZ/non_secure/los_interrupt.c @@ -497,7 +497,7 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit() g_hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = HalExcMemFault; g_hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = HalExcBusFault; g_hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = HalExcUsageFault; - g_hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = HalExcSvcCall; + g_hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = HalSVCHandler; g_hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = HalPendSV; g_hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = OsTickHandler; diff --git a/kernel/arch/arm/cortex-m33/gcc/TZ/secure/los_secure_context.h b/kernel/arch/arm/cortex-m33/gcc/TZ/secure/los_secure_context.h index c988598e..ff3dfaad 100755 --- a/kernel/arch/arm/cortex-m33/gcc/TZ/secure/los_secure_context.h +++ b/kernel/arch/arm/cortex-m33/gcc/TZ/secure/los_secure_context.h @@ -63,5 +63,3 @@ extern VOID HalSecureContextSaveAsm(OsSecureContext *secureContext); #endif /* __cplusplus */ #endif - - diff --git a/kernel/arch/arm/cortex-m33/gcc/TZ/secure/los_secure_context_asm.S b/kernel/arch/arm/cortex-m33/gcc/TZ/secure/los_secure_context_asm.S index 8743d046..f5f0e8ac 100755 --- a/kernel/arch/arm/cortex-m33/gcc/TZ/secure/los_secure_context_asm.S +++ b/kernel/arch/arm/cortex-m33/gcc/TZ/secure/los_secure_context_asm.S @@ -94,7 +94,7 @@ HalSecureContextSaveAsm: MOV R0, #0 MSR PSPLIM, R0 /* No PSPLIM for the current task. */ MSR PSP, R0 /* No secure stack for the current task. */ + .fnend __ThreadMode: BX LR - .fnend \ No newline at end of file diff --git a/kernel/arch/risc-v/nuclei/gcc/los_context.c b/kernel/arch/risc-v/nuclei/gcc/los_context.c index 0e1fcb0e..9f3156d0 100644 --- a/kernel/arch/risc-v/nuclei/gcc/los_context.c +++ b/kernel/arch/risc-v/nuclei/gcc/los_context.c @@ -29,7 +29,6 @@ extern VOID HalHwiInit(VOID); #define INITIAL_MSTATUS ( MSTATUS_MPP | MSTATUS_MPIE | MSTATUS_FS_INITIAL) - #define ALIGN_DOWN(size, align) ((size) & ~((align) - 1)) #ifdef __cplusplus diff --git a/kernel/arch/risc-v/nuclei/gcc/los_interrupt.c b/kernel/arch/risc-v/nuclei/gcc/los_interrupt.c index cb1b0b48..f096ae78 100644 --- a/kernel/arch/risc-v/nuclei/gcc/los_interrupt.c +++ b/kernel/arch/risc-v/nuclei/gcc/los_interrupt.c @@ -71,13 +71,13 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID) HWI_PROC_FUNC handler, HWI_ARG_T arg) { - if (hwiNum > SOC_INT_MAX){ + if (hwiNum > SOC_INT_MAX) { return OS_ERRNO_HWI_NUM_INVALID; } - if (mode > ECLIC_VECTOR_INTERRUPT){ + if (mode > ECLIC_VECTOR_INTERRUPT) { return OS_ERRNO_HWI_MODE_INVALID; } - if (arg > ECLIC_NEGTIVE_EDGE_TRIGGER){ + if (arg > ECLIC_NEGTIVE_EDGE_TRIGGER) { return OS_ERRNO_HWI_ARG_INVALID; }