From 744b2021b2b49a95558ab7b40d6535d82dad4b5c Mon Sep 17 00:00:00 2001 From: Caoruihong Date: Sat, 5 Jun 2021 17:40:22 +0800 Subject: [PATCH] chore: add a mini config for qemu arm virt support turn off as many features as possible. current only libc and posix and bsd can not be turned off. Signed-off-by: Caoruihong Change-Id: I1e97570c67593207a56dc11f357eca4b4a018bfd --- Makefile | 5 +- arch/arm/arm/src/los_exc.c | 2 + compat/posix/src/mqueue.c | 2 + compat/posix/src/time.c | 87 ++++++++++---------- kernel/base/core/los_process.c | 4 + kernel/base/include/los_vm_filemap.h | 2 + kernel/base/misc/sysinfo_shellcmd.c | 1 + kernel/base/misc/vm_shellcmd.c | 3 +- kernel/base/vm/los_vm_dump.c | 2 + kernel/base/vm/los_vm_filemap.c | 3 + kernel/base/vm/los_vm_map.c | 2 + kernel/base/vm/los_vm_phys.c | 2 +- kernel/common/los_config.c | 7 ++ kernel/common/los_printf.c | 2 + syscall/los_syscall.h | 8 ++ tools/build/config/qemu_arm_virt_mini.config | 14 ++++ 16 files changed, 97 insertions(+), 49 deletions(-) create mode 100644 tools/build/config/qemu_arm_virt_mini.config diff --git a/Makefile b/Makefile index 6a36cc46..51868d66 100644 --- a/Makefile +++ b/Makefile @@ -145,10 +145,9 @@ genconfig:$(MENUCONFIG_CONF) $< --silentoldconfig $(KCONFIG_FILE_PATH) ##### menuconfig end ####### -$(LITEOS_MENUCONFIG_H): -ifneq ($(LITEOS_MENUCONFIG_H), $(wildcard $(LITEOS_MENUCONFIG_H))) +$(LITEOS_MENUCONFIG_H): .config $(HIDE)$(MAKE) genconfig -endif + $(LITEOS_TARGET): $(__LIBS) $(HIDE)touch $(LOSCFG_ENTRY_SRC) diff --git a/arch/arm/arm/src/los_exc.c b/arch/arm/arm/src/los_exc.c index 47430b82..0dcfe5f7 100644 --- a/arch/arm/arm/src/los_exc.c +++ b/arch/arm/arm/src/los_exc.c @@ -676,7 +676,9 @@ VOID BackTraceSub(UINTPTR regFP) UINTPTR backFP = regFP; UINT32 count = 0; VADDR_T kvaddr; +#ifdef LOSCFG_KERNEL_VM LosProcessCB *runProcess = OsCurrProcessGet(); +#endif if (FindSuitableStack(regFP, &stackStart, &stackEnd, &kvaddr) == FALSE) { PrintExcInfo("traceback error fp = 0x%x\n", regFP); diff --git a/compat/posix/src/mqueue.c b/compat/posix/src/mqueue.c index 9f1f0318..38adb40f 100644 --- a/compat/posix/src/mqueue.c +++ b/compat/posix/src/mqueue.c @@ -30,6 +30,7 @@ */ #include "mqueue.h" +#ifdef LOSCFG_FS_VFS #include "fcntl.h" #include "pthread.h" #include "map_error.h" @@ -831,3 +832,4 @@ ssize_t mq_receive(mqd_t personal, char *msg_ptr, size_t msg_len, unsigned int * return mq_timedreceive(personal, msg_ptr, msg_len, msg_prio, NULL); } +#endif diff --git a/compat/posix/src/time.c b/compat/posix/src/time.c index b94c6a2a..43a74fe2 100644 --- a/compat/posix/src/time.c +++ b/compat/posix/src/time.c @@ -451,6 +451,7 @@ int clock_settime(clockid_t clockID, const struct timespec *tp) return settimeofday(&tv, NULL); } +#ifdef LOSCFG_KERNEL_CPUP static int PthreadGetCputime(clockid_t clockID, struct timespec *ats) { uint64_t runtime; @@ -519,12 +520,47 @@ static int GetCputime(clockid_t clockID, struct timespec *tp) return ret; } +static int CheckClock(const clockid_t clockID) +{ + int error = 0; + const pid_t pid = ((pid_t) ~((clockID) >> CPUCLOCK_ID_OFFSET)); + + if (!((UINT32)clockID & CPUCLOCK_PERTHREAD_MASK)) { + LosProcessCB *spcb = NULL; + if (OsProcessIDUserCheckInvalid(pid) || pid < 0) { + return -EINVAL; + } + spcb = OS_PCB_FROM_PID(pid); + if (OsProcessIsUnused(spcb)) { + error = -EINVAL; + } + } else { + error = -EINVAL; + } + + return error; +} + +static int CpuClockGetres(const clockid_t clockID, struct timespec *tp) +{ + if (clockID > 0) { + return -EINVAL; + } + + int error = CheckClock(clockID); + if (!error) { + error = ProcessGetCputime(clockID, tp); + } + + return error; +} +#endif + int clock_gettime(clockid_t clockID, struct timespec *tp) { UINT32 intSave; struct timespec64 tmp = {0}; struct timespec64 hwTime = {0}; - int ret; if (clockID > MAX_CLOCKS) { goto ERROUT; @@ -566,61 +602,24 @@ int clock_gettime(clockid_t clockID, struct timespec *tp) case CLOCK_TAI: TIME_RETURN(ENOTSUP); default: - { + { #ifdef LOSCFG_KERNEL_CPUP - ret = GetCputime(clockID, tp); + int ret = GetCputime(clockID, tp); TIME_RETURN(-ret); #else - TIME_RETURN(EINVAL); + TIME_RETURN(EINVAL); #endif - } + } } return 0; -ERROUT: + ERROUT: TIME_RETURN(EINVAL); } -static int CheckClock(const clockid_t clockID) -{ - int error = 0; - const pid_t pid = ((pid_t) ~((clockID) >> CPUCLOCK_ID_OFFSET)); - - if (!((UINT32)clockID & CPUCLOCK_PERTHREAD_MASK)) { - LosProcessCB *spcb = NULL; - if (OsProcessIDUserCheckInvalid(pid) || pid < 0) { - return -EINVAL; - } - spcb = OS_PCB_FROM_PID(pid); - if (OsProcessIsUnused(spcb)) { - error = -EINVAL; - } - } else { - error = -EINVAL; - } - - return error; -} - -static int CpuClockGetres(const clockid_t clockID, struct timespec *tp) -{ - if (clockID > 0) { - return -EINVAL; - } - - int error = CheckClock(clockID); - if (!error) { - error = ProcessGetCputime(clockID, tp); - } - - return error; -} - int clock_getres(clockid_t clockID, struct timespec *tp) { - int ret; - if (tp == NULL) { TIME_RETURN(EINVAL); } @@ -650,7 +649,7 @@ int clock_getres(clockid_t clockID, struct timespec *tp) default: #ifdef LOSCFG_KERNEL_CPUP { - ret = CpuClockGetres(clockID, tp); + int ret = CpuClockGetres(clockID, tp); TIME_RETURN(-ret); } #else diff --git a/kernel/base/core/los_process.c b/kernel/base/core/los_process.c index 7d273d13..b1d7e46e 100644 --- a/kernel/base/core/los_process.c +++ b/kernel/base/core/los_process.c @@ -749,8 +749,12 @@ LITE_OS_SEC_TEXT_INIT UINT32 OsSystemProcessCreate(VOID) LOS_ListTailInsert(&kerInitProcess->childrenList, &idleProcess->siblingList); idleProcess->group = kerInitProcess->group; LOS_ListTailInsert(&kerInitProcess->group->processList, &idleProcess->subordinateGroupList); +#ifdef LOSCFG_SECURITY_CAPABILITY idleProcess->user = kerInitProcess->user; +#endif +#ifdef LOSCFG_FS_VFS idleProcess->files = kerInitProcess->files; +#endif ret = OsIdleTaskCreate(); if (ret != LOS_OK) { diff --git a/kernel/base/include/los_vm_filemap.h b/kernel/base/include/los_vm_filemap.h index e0d2d4ca..70047b20 100644 --- a/kernel/base/include/los_vm_filemap.h +++ b/kernel/base/include/los_vm_filemap.h @@ -37,7 +37,9 @@ #ifndef __LOS_VM_FILEMAP_H__ #define __LOS_VM_FILEMAP_H__ +#ifdef LOSCFG_FS_VFS #include "fs/file.h" +#endif #include "los_vm_map.h" #include "los_vm_page.h" #include "los_vm_common.h" diff --git a/kernel/base/misc/sysinfo_shellcmd.c b/kernel/base/misc/sysinfo_shellcmd.c index b1b38f00..31431743 100644 --- a/kernel/base/misc/sysinfo_shellcmd.c +++ b/kernel/base/misc/sysinfo_shellcmd.c @@ -34,6 +34,7 @@ #include "los_sem_pri.h" #include "los_queue_pri.h" #include "los_swtmr_pri.h" +#include "los_task_pri.h" #ifdef LOSCFG_SHELL #include "shcmd.h" diff --git a/kernel/base/misc/vm_shellcmd.c b/kernel/base/misc/vm_shellcmd.c index bb3edcaa..250c28c0 100644 --- a/kernel/base/misc/vm_shellcmd.c +++ b/kernel/base/misc/vm_shellcmd.c @@ -42,8 +42,9 @@ #include "los_oom.h" #include "los_vm_dump.h" #include "los_process_pri.h" +#ifdef LOSCFG_FS_VFS #include "fs/path_cache.h" - +#endif #ifdef LOSCFG_KERNEL_VM diff --git a/kernel/base/vm/los_vm_dump.c b/kernel/base/vm/los_vm_dump.c index c05cc97a..124ff65f 100644 --- a/kernel/base/vm/los_vm_dump.c +++ b/kernel/base/vm/los_vm_dump.c @@ -36,7 +36,9 @@ #include "los_vm_dump.h" #include "los_mmu_descriptor_v6.h" +#ifdef LOSCFG_FS_VFS #include "fs/fs.h" +#endif #include "los_printf.h" #include "los_vm_page.h" #include "los_vm_phys.h" diff --git a/kernel/base/vm/los_vm_filemap.c b/kernel/base/vm/los_vm_filemap.c index 9447b3da..fbdf836c 100644 --- a/kernel/base/vm/los_vm_filemap.c +++ b/kernel/base/vm/los_vm_filemap.c @@ -42,6 +42,9 @@ #include "los_process_pri.h" #include "los_vm_lock.h" +#ifndef UNUSED +#define UNUSED(x) (VOID)x +#endif #ifdef LOSCFG_KERNEL_VM diff --git a/kernel/base/vm/los_vm_map.c b/kernel/base/vm/los_vm_map.c index 95242796..566a7985 100644 --- a/kernel/base/vm/los_vm_map.c +++ b/kernel/base/vm/los_vm_map.c @@ -40,7 +40,9 @@ #include "los_vm_shm_pri.h" #include "los_arch_mmu.h" #include "los_process_pri.h" +#ifdef LOSCFG_FS_VFS #include "fs/fs.h" +#endif #include "los_task.h" #include "los_memory_pri.h" #include "los_vm_boot.h" diff --git a/kernel/base/vm/los_vm_phys.c b/kernel/base/vm/los_vm_phys.c index 59ab9e4e..d1e006d3 100644 --- a/kernel/base/vm/los_vm_phys.c +++ b/kernel/base/vm/los_vm_phys.c @@ -626,7 +626,7 @@ size_t LOS_PhysPagesFree(LOS_DL_LIST *list) #else VADDR_T *LOS_PaddrToKVaddr(PADDR_T paddr) { - if ((paddr < DDR_MEM_ADDR) || (paddr >= (DDR_MEM_ADDR + DDR_MEM_SIZE))) { + if ((paddr < DDR_MEM_ADDR) || (paddr >= ((PADDR_T)DDR_MEM_ADDR + DDR_MEM_SIZE))) { return NULL; } diff --git a/kernel/common/los_config.c b/kernel/common/los_config.c index c59fe917..afd45a78 100644 --- a/kernel/common/los_config.c +++ b/kernel/common/los_config.c @@ -280,6 +280,13 @@ LITE_OS_SEC_TEXT_INIT INT32 OsMain(VOID) return LOS_OK; } +#ifndef LOSCFG_PLATFORM_ADAPT +STATIC VOID SystemInit(VOID) +{ + PRINTK("dummy: *** %s ***\n", __FUNCTION__); +} +#endif + STATIC UINT32 OsSystemInitTaskCreate(VOID) { UINT32 taskID; diff --git a/kernel/common/los_printf.c b/kernel/common/los_printf.c index b5d2a002..98d0eb26 100644 --- a/kernel/common/los_printf.c +++ b/kernel/common/los_printf.c @@ -85,6 +85,7 @@ STATIC VOID UartOutput(const CHAR *str, UINT32 len, BOOL isLock) #endif } +#ifdef LOSCFG_PLATFORM_CONSOLE STATIC VOID ConsoleOutput(const CHAR *str, UINT32 len) { ssize_t writen = 0; @@ -100,6 +101,7 @@ STATIC VOID ConsoleOutput(const CHAR *str, UINT32 len) toWrite -= cnt; } } +#endif VOID OutputControl(const CHAR *str, UINT32 len, OutputType type) { diff --git a/syscall/los_syscall.h b/syscall/los_syscall.h index 786a1d18..726c9f8b 100644 --- a/syscall/los_syscall.h +++ b/syscall/los_syscall.h @@ -36,7 +36,9 @@ #include "los_task.h" #include "los_mux.h" #include "los_signal.h" +#ifdef LOSCFG_FS_VFS #include "fs/fs.h" +#endif #include "syscall.h" #include "sysinfo.h" #ifdef LOSCFG_KERNEL_DYNLOAD @@ -48,7 +50,9 @@ #include "sys/shm.h" #include "poll.h" #include "utime.h" +#ifdef LOSCFG_COMPAT_POSIX #include "mqueue.h" +#endif #include "time.h" #include "sys/time.h" #include "sys/stat.h" @@ -107,6 +111,8 @@ extern int SysFutex(const unsigned int *uAddr, unsigned int flags, int val, unsigned int absTime, const unsigned int *newUserAddr); extern int SysSchedGetAffinity(int id, unsigned int *cpuset, int flag); extern int SysSchedSetAffinity(int id, const unsigned short cpuset, int flag); + +#ifdef LOSCFG_COMPAT_POSIX extern mqd_t SysMqOpen(const char *mqName, int openFlag, mode_t mode, struct mq_attr *attr); extern int SysMqClose(mqd_t personal); extern int SysMqGetSetAttr(mqd_t mqd, const struct mq_attr *new, struct mq_attr *old); @@ -116,6 +122,8 @@ extern int SysMqTimedSend(mqd_t personal, const char *msg, size_t msgLen, unsign const struct timespec *absTimeout); extern ssize_t SysMqTimedReceive(mqd_t personal, char *msg, size_t msgLen, unsigned int *msgPrio, const struct timespec *absTimeout); +#endif + extern int SysSigAction(int sig, const sigaction_t *restrict sa, sigaction_t *restrict old, size_t sigsetsize); extern int SysSigprocMask(int how, const sigset_t_l *restrict set, sigset_t *restrict old, size_t sigsetsize); extern int SysKill(pid_t pid, int sig); diff --git a/tools/build/config/qemu_arm_virt_mini.config b/tools/build/config/qemu_arm_virt_mini.config new file mode 100644 index 00000000..1300f151 --- /dev/null +++ b/tools/build/config/qemu_arm_virt_mini.config @@ -0,0 +1,14 @@ +LOSCFG_PLATFORM_QEMU_ARM_VIRT_CA7=y +LOSCFG_BOARD_CONFIG_PATH="device/qemu/arm_virt/liteos_a/config/board" +# LOSCFG_HRTIMER_ENABLE is not set +# LOSCFG_IRQ_USE_STANDALONE_STACK is not set +# LOSCFG_KERNEL_MMU is not set +# LOSCFG_KERNEL_EXTKERNEL is not set +# LOSCFG_BASE_CORE_HILOG is not set +# LOSCFG_LIB_ZLIB is not set +# LOSCFG_FS_VFS is not set +# LOSCFG_NET_LWIP_SACK is not set +# LOSCFG_PLATFORM_ADAPT is not set +# LOSCFG_ENABLE_MAGICKEY is not set +# LOSCFG_DRIVERS is not set +# LOSCFG_SECURITY is not set