From 647f91af7b6a37fb514c49794786446a42915676 Mon Sep 17 00:00:00 2001 From: Zbigniew Bodek Date: Mon, 14 Sep 2020 20:52:52 +0800 Subject: [PATCH 01/21] Fix build problem after Kconfig file change conf --silentoldconfig generates required autoconf.h file but when invoked on modified Kconfig it will ask for user input which breaks the build. To automatically regenerate config structure and then autogenerate headers run config --olddefconfig first. Signed-off-by: Zbigniew Bodek Change-Id: If7f7653c80cc0c5c0d84015b8e50fcb66568d00a --- Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile b/Makefile index 0a7cd5af..fa38052f 100644 --- a/Makefile +++ b/Makefile @@ -126,6 +126,7 @@ menuconfig:$(MENUCONFIG_PATH)/mconf genconfig:$(MENUCONFIG_PATH)/conf $(HIDE)mkdir -p include/config include/generated + $< --olddefconfig $(KCONFIG_FILE_PATH) $< --silentoldconfig $(KCONFIG_FILE_PATH) -mv -f $(LITEOS_MENUCONFIG_H) $(LITEOS_PLATFORM_MENUCONFIG_H) ##### menuconfig end ####### From 59db6662c2b002bce5a98e61ba708b83800cbfe3 Mon Sep 17 00:00:00 2001 From: Zbigniew Bodek Date: Thu, 8 Oct 2020 16:10:50 +0800 Subject: [PATCH 02/21] Add new Qemu ARM virtual platform to Kconfig Qemu ARM virtual platform emulates an ARM machine with configurable, ARM components. This commit adds configuration option for Cortex-A7 based virtual machine. qemu_arm_virt_ca7 name is derived from a command to invoke Qemu: qemu-system-arm -M virt -cpu cortex-a7 Signed-off-by: Zbigniew Bodek Change-Id: Ia267ee7c989b8c22e6c19d6f11ff3ee2eef8148b --- platform/Kconfig | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/platform/Kconfig b/platform/Kconfig index 2b34a8dc..088d3a9d 100644 --- a/platform/Kconfig +++ b/platform/Kconfig @@ -2,6 +2,7 @@ config PLATFORM string default "hi3516dv300" if PLATFORM_HI3516DV300 default "hi3518ev300" if PLATFORM_HI3518EV300 + default "virt" if PLATFORM_QEMU_ARM_VIRT_CA7 choice prompt "Board" @@ -10,6 +11,8 @@ choice IPC has several chips: hi3516dv300 hi3518ev300 + Qemu ARM Virt variants (based on different CPU types): + qemu_arm_virt_ca7 config PLATFORM_HI3516DV300 bool "hi3516dv300" @@ -19,6 +22,12 @@ config PLATFORM_HI3518EV300 bool "hi3518ev300" select ARCH_CORTEX_A7 +config PLATFORM_QEMU_ARM_VIRT_CA7 + bool "qemu_arm_virt_ca7" + select ARCH_CORTEX_A7 + help + QEMU ARM Virtual Platform using Cortex-A7 CPU. + endchoice config TEE_ENABLE From 450f63d7b0548f1152f16df34fc4fbff7ec4b337 Mon Sep 17 00:00:00 2001 From: Zbigniew Bodek Date: Thu, 8 Oct 2020 17:09:23 +0800 Subject: [PATCH 03/21] Add Qemu ARM virtual platform to build configuration files Remove some dependencies on HiSilicon and add new platform to build. Signed-off-by: Zbigniew Bodek Change-Id: I8504bcc9a1bf1756e1e20694986d7774156f8b8e --- Kconfig | 6 +++--- Makefile | 12 +++++++++++- platform/Makefile | 5 ++++- platform/bsp.mk | 26 ++++++++++++++++++-------- tools/build/mk/los_config.mk | 6 ++++++ 5 files changed, 42 insertions(+), 13 deletions(-) diff --git a/Kconfig b/Kconfig index 522800bd..a47e793f 100644 --- a/Kconfig +++ b/Kconfig @@ -42,11 +42,11 @@ choice config COMPILER_HIMIX_32 bool "arm-linux-ohoseabi" - depends on PLATFORM_HI3518EV300 || PLATFORM_HI3516DV300 + depends on PLATFORM_HI3518EV300 || PLATFORM_HI3516DV300 || PLATFORM_QEMU_ARM_VIRT_CA7 config COMPILER_CLANG_LLVM bool "clang-llvm" - depends on PLATFORM_HI3518EV300 || PLATFORM_HI3516DV300 + depends on PLATFORM_HI3518EV300 || PLATFORM_HI3516DV300 || PLATFORM_QEMU_ARM_VIRT_CA7 endchoice endmenu @@ -274,7 +274,7 @@ config VM_OVERLAP_CHECK config NULL_ADDRESS_PROTECT bool "Enable NULL Address protect" default n - depends on (PLATFORM_HI3518EV200 || PLATFORM_HI3516CV300 || PLATFORM_HI3518EV300 || PLATFORM_HI3516DV300) && DEBUG_VERSION + depends on (PLATFORM_HI3518EV200 || PLATFORM_HI3516CV300 || PLATFORM_HI3518EV300 || PLATFORM_HI3516DV300 || PLATFORM_QEMU_ARM_VIRT_CA7) && DEBUG_VERSION help Answer Y to set mem address 0~1M prohibit to access, read or write will trigger exception. diff --git a/Makefile b/Makefile index fa38052f..3e02ad56 100644 --- a/Makefile +++ b/Makefile @@ -59,6 +59,9 @@ endif ifeq ($(LOSCFG_PLATFORM_HI3516DV300), y) FSTYPE = vfat endif +ifeq ($(LOSCFG_PLATFORM_QEMU_ARM_VIRT_CA7), y) +FSTYPE = vfat +endif ROOTFS_DIR = $(OUT)/rootfs ROOTFS_ZIP = $(OUT)/rootfs.zip VERSION = @@ -97,13 +100,20 @@ endif ##### make dynload ##### -include $(LITEOS_MK_PATH)/dynload.mk +ifeq ($(findstring y, $(LOSCFG_PLATFORM_HI3518EV300)$(LOSCFG_PLATFORM_HI3516DV300)), y) +VENDOR_BOARD_INCLUDE := $(LITEOSTOPDIR)/../../vendor/hisi/hi35xx/$(LITEOS_PLATFORM)/config/board +else ifeq ($(LOSCFG_PLATFORM_QEMU_ARM_VIRT_CA7), y) +VENDOR_BOARD_INCLUDE := $(LITEOSTOPDIR)/../../vendor/qemu/arm/$(LITEOS_PLATFORM)/config/board +else +$(error "No VENDOR_BOARD_INCLUDE defined") +endif #-----need move when make version-----# ##### make lib ##### $(__LIBS): $(OUT) $(CXX_INCLUDE) $(OUT): $(LITEOS_MENUCONFIG_H) $(HIDE)mkdir -p $(OUT)/lib - $(HIDE)$(CC) -I$(LITEOS_PLATFORM_BASE)/include -I$(LITEOSTOPDIR)/../../vendor/hisi/hi35xx/$(LITEOS_PLATFORM)/config/board \ + $(HIDE)$(CC) -I$(LITEOS_PLATFORM_BASE)/include -I$(VENDOR_BOARD_INCLUDE) \ -E $(LITEOS_PLATFORM_BASE)/board.ld.S \ -o $(LITEOS_PLATFORM_BASE)/board.ld -P diff --git a/platform/Makefile b/platform/Makefile index e7ced6bb..40e4757e 100644 --- a/platform/Makefile +++ b/platform/Makefile @@ -40,7 +40,10 @@ LOCAL_SRCS = $(wildcard $(HWI_SRC)/*.c) \ LOCAL_INCLUDE += -I $(LITEOSTOPDIR)/compat/posix/src \ -I $(LITEOSTOPDIR)/bsd/dev/random -ifeq ($(findstring y, $(LOSCFG_PLATFORM_HI3518EV300)$(LOSCFG_PLATFORM_HI3516DV300)), y) +MAIN_PLATFORMS := $(LOSCFG_PLATFORM_HI3518EV300) \ + $(LOSCFG_PLATFORM_HI3516DV300) \ + $(LOSCFG_PLATFORM_QEMU_ARM_VIRT_CA7) +ifeq ($(findstring y, $(MAIN_PLATFORMS)), y) LOCAL_SRCS += $(wildcard ../kernel/common/*.c) LOCAL_SRCS := $(filter-out ../kernel/common/los_rootfs.c, $(LOCAL_SRCS)) ifneq ($(LOSCFG_FS_VFS), y) diff --git a/platform/bsp.mk b/platform/bsp.mk index 7714dbfa..0223f82d 100644 --- a/platform/bsp.mk +++ b/platform/bsp.mk @@ -56,6 +56,12 @@ else ifeq ($(LOSCFG_PLATFORM_HI3518EV300), y) USB_TYPE := usb3.0_hi3518ev300 LITEOS_CMACRO_TEST += -DTEST3518EV300 +########################## Qemu ARM Virt Options############################## +else ifeq ($(LOSCFG_PLATFORM_QEMU_ARM_VIRT_CA7), y) + HWI_TYPE := arm/interrupt/gic + TIMER_TYPE := arm/timer/arm_generic + UART_TYPE := amba_pl011 + endif HWI_SRC := hw/$(HWI_TYPE) @@ -69,22 +75,26 @@ LITEOS_BASELIB += -lbsp LITEOS_PLATFORM := $(subst $\",,$(LOSCFG_PLATFORM)) -PLATFORM_BSP_HISI_BASE := $(LITEOSTOPDIR)/platform +PLATFORM_BSP_BASE := $(LITEOSTOPDIR)/platform -PLATFORM_INCLUDE := -I $(LITEOSTOPDIR)/../../vendor/hisi/hi35xx/$(LITEOS_PLATFORM)/config/board/include \ - -I $(PLATFORM_BSP_HISI_BASE)/../kernel/common \ - -I $(PLATFORM_BSP_HISI_BASE)/../../../drivers/liteos/platform/pm \ - -I $(PLATFORM_BSP_HISI_BASE)/hw/include \ - -I $(PLATFORM_BSP_HISI_BASE)/include \ - -I $(PLATFORM_BSP_HISI_BASE)/$(UART_SRC) +PLATFORM_INCLUDE := -I $(PLATFORM_BSP_BASE)/../kernel/common \ + -I $(PLATFORM_BSP_BASE)/../../../drivers/liteos/platform/pm \ + -I $(PLATFORM_BSP_BASE)/hw/include \ + -I $(PLATFORM_BSP_BASE)/include \ + -I $(PLATFORM_BSP_BASE)/$(UART_SRC) ifeq ($(findstring y, $(LOSCFG_PLATFORM_HI3518EV300)$(LOSCFG_PLATFORM_HI3516DV300)), y) + PLATFORM_INCLUDE += -I $(LITEOSTOPDIR)/../../vendor/hisi/hi35xx/$(LITEOS_PLATFORM)/config/board/include PLATFORM_INCLUDE += -I $(LITEOSTOPDIR)/../../vendor/hisi/hi35xx/$(LITEOS_PLATFORM)/config/board/include/hisoc +else ifeq ($(LOSCFG_PLATFORM_QEMU_ARM_VIRT_CA7), y) + PLATFORM_INCLUDE += -I $(LITEOSTOPDIR)/../../vendor/qemu/arm/$(LITEOS_PLATFORM)/config/board/include + # TODO: remove hisoc dependency in the code to avoid using hisoc here + PLATFORM_INCLUDE += -I $(LITEOSTOPDIR)/../../vendor/qemu/arm/$(LITEOS_PLATFORM)/config/board/include/hisoc endif # #-include $(LITEOSTOPDIR)/platform/bsp/board/$(LITEOS_PLATFORM)/board.mk # -LIB_SUBDIRS += $(PLATFORM_BSP_HISI_BASE) +LIB_SUBDIRS += $(PLATFORM_BSP_BASE) LITEOS_PLATFORM_INCLUDE += $(PLATFORM_INCLUDE) LITEOS_CXXINCLUDE += $(PLATFORM_INCLUDE) diff --git a/tools/build/mk/los_config.mk b/tools/build/mk/los_config.mk index ff273f2c..3d132f8b 100644 --- a/tools/build/mk/los_config.mk +++ b/tools/build/mk/los_config.mk @@ -163,8 +163,10 @@ LITEOS_BASELIB += -lbase LIB_SUBDIRS += kernel/base LITEOS_KERNEL_INCLUDE := -I $(LITEOSTOPDIR)/kernel/include +ifeq ($(findstring y, $(LOSCFG_PLATFORM_HI3518EV300)$(LOSCFG_PLATFORM_HI3516DV300)), y) LITEOS_BASELIB += -lhi35xx_bsp LIB_SUBDIRS += $(LITEOSTOPDIR)/../../vendor/hisi/hi35xx/$(LITEOS_PLATFORM)/config/board/ +endif ifeq ($(LOSCFG_KERNEL_CPUP), y) LITEOS_BASELIB += -lcpup @@ -358,7 +360,11 @@ endif #################################### Net Option End#################################### LITEOS_DRIVERS_BASE_PATH := $(LITEOSTOPDIR)/../../drivers/liteos +ifeq ($(findstring y, $(LOSCFG_PLATFORM_HI3518EV300)$(LOSCFG_PLATFORM_HI3516DV300)), y) LITEOS_VENDOR_DRIVERS_BASE_PATH := $(LITEOSTOPDIR)/../../vendor/hisi/hi35xx/platform +else ifeq ($(LOSCFG_PLATFORM_QEMU_ARM_VIRT_CA7), y) +LITEOS_VENDOR_DRIVERS_BASE_PATH := $(LITEOSTOPDIR)/../../vendor/qemu/arm/platform +endif ################################## Driver Option Begin ################################# ifeq ($(LOSCFG_DRIVERS_HDF), y) include $(LITEOSTOPDIR)/../../drivers/hdf/lite/hdf_lite.mk From 4188734ee4bc9e1f2ef6acaff738cb6336247960 Mon Sep 17 00:00:00 2001 From: Zbigniew Bodek Date: Thu, 8 Oct 2020 18:02:36 +0800 Subject: [PATCH 04/21] Allow to disable stack protector feature Currently disabling stack protector will cause build to fail. This commit will fix that problem and allow to toggle feature when needed. Signed-off-by: Zbigniew Bodek Change-Id: Iee8ccfdb9fce4ba69aa557e2ac915ddc45b2f21e --- arch/arm/arm/src/los_hw_exc.S | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/arch/arm/arm/src/los_hw_exc.S b/arch/arm/arm/src/los_hw_exc.S index 25d8639c..9a51b2a5 100644 --- a/arch/arm/arm/src/los_hw_exc.S +++ b/arch/arm/arm/src/los_hw_exc.S @@ -57,7 +57,11 @@ .global _osExceptPrefetchAbortHdl .global _osExceptSwiHdl .global _osExceptUndefInstrHdl +#if defined(LOSCFG_CC_STACKPROTECTOR_ALL) || \ + defined(LOSCFG_CC_STACKPROTECTOR_STRONG) || \ + defined(LOSCFG_CC_STACKPROTECTOR) .global __stack_chk_guard_setup +#endif .fpu vfpv4 @@ -147,6 +151,9 @@ .endm #endif +#if defined(LOSCFG_CC_STACKPROTECTOR_ALL) || \ + defined(LOSCFG_CC_STACKPROTECTOR_STRONG) || \ + defined(LOSCFG_CC_STACKPROTECTOR) @ Description: Stack-Protector Init __stack_chk_guard_setup: PUSH {FP, LR} @@ -156,6 +163,7 @@ __stack_chk_guard_setup: ORR R2, R3, #0X80000000 STR R2, [R1] POP {FP, PC} +#endif @ Description: Undefined instruction exception handler _osExceptUndefInstrHdl: From 064427fcafe8e00607041c8797b415bc70ff9bb6 Mon Sep 17 00:00:00 2001 From: Zbigniew Bodek Date: Thu, 8 Oct 2020 18:31:01 +0800 Subject: [PATCH 05/21] Allow enabling SSP for platforms that don't randomize canary HiSilicon-specific randomization routine for the __stack_chk_guard should not be called for other platforms that don't implement this function. Fix build for targets that don't link with HiSi libraries when stack smashing protector is enabled. Signed-off-by: Zbigniew Bodek Change-Id: I1843c897b32991fddc3d0ba362d188c4a621d052 --- arch/arm/arm/src/los_hw_exc.S | 3 +++ 1 file changed, 3 insertions(+) diff --git a/arch/arm/arm/src/los_hw_exc.S b/arch/arm/arm/src/los_hw_exc.S index 9a51b2a5..1dc3cf52 100644 --- a/arch/arm/arm/src/los_hw_exc.S +++ b/arch/arm/arm/src/los_hw_exc.S @@ -157,11 +157,14 @@ @ Description: Stack-Protector Init __stack_chk_guard_setup: PUSH {FP, LR} +#if defined(LOSCFG_PLATFORM_HI3516DV300) || defined(LOSCFG_PLATFORM_HI3518EV300) + /* Randomize __stack_chk_quard using platform-specific function. */ BL OsRandomStackGuard LDR R1, =__stack_chk_guard MOV R3, R0 ORR R2, R3, #0X80000000 STR R2, [R1] +#endif POP {FP, PC} #endif From 22f0e9ac30e6584f1faf761809df49627d7ff8ad Mon Sep 17 00:00:00 2001 From: Zbigniew Bodek Date: Thu, 8 Oct 2020 18:48:41 +0800 Subject: [PATCH 06/21] Fix build when HILOG is disabled Fix build when BASE_CORE_HILOG option is disabled. Use similar printing function to output missing HILOG logs. Signed-off-by: Zbigniew Bodek Change-Id: Id5c63568ccb1ba90daadddf7e26d3e0f6c9f30ce --- kernel/base/misc/kill_shellcmd.c | 7 +++++++ platform/Makefile | 3 +++ 2 files changed, 10 insertions(+) diff --git a/kernel/base/misc/kill_shellcmd.c b/kernel/base/misc/kill_shellcmd.c index 96b3d7e0..c1a0231a 100644 --- a/kernel/base/misc/kill_shellcmd.c +++ b/kernel/base/misc/kill_shellcmd.c @@ -35,7 +35,14 @@ #include "los_printf.h" #include "los_task_pri.h" #include "los_process_pri.h" + +#ifdef LOSCFG_BASE_CORE_HILOG #include "log.h" +#else +#define HILOG_INFO(type, fmt, ...) PRINT_INFO(fmt, __VA_ARGS__) +#define HILOG_ERROR(type, fmt, ...) PRINT_ERR(fmt, __VA_ARGS__) +#endif + #ifdef LOSCFG_SHELL #include "shcmd.h" #include "shell.h" diff --git a/platform/Makefile b/platform/Makefile index 40e4757e..eee94a0a 100644 --- a/platform/Makefile +++ b/platform/Makefile @@ -49,6 +49,9 @@ LOCAL_SRCS := $(filter-out ../kernel/common/los_rootfs.c, $(LOCAL_SRCS)) ifneq ($(LOSCFG_FS_VFS), y) LOCAL_SRCS := $(filter-out ../kernel/common/console.c ../kernel/common/virtual_serial.c, $(LOCAL_SRCS)) endif +ifneq ($(LOSCFG_BASE_CORE_HILOG), y) +LOCAL_SRCS := $(filter-out ../kernel/common/los_hilog.c, $(LOCAL_SRCS)) +endif else LOCAL_SRCS += $(wildcard ../kernel/common/los_config.c) LOCAL_SRCS += $(wildcard ../kernel/common/los_printf.c) From aff8a3e3c10c29cba2245a05266dc776ae37972d Mon Sep 17 00:00:00 2001 From: Zbigniew Bodek Date: Thu, 8 Oct 2020 20:19:28 +0800 Subject: [PATCH 07/21] Fix build when KERNEL_DYNLOAD is disabled Fix unused function warning treated as error when KERNEL_DYNLOAD option is switched off. Signed-off-by: Zbigniew Bodek Change-Id: I21a01ff3d7ecb7b2e65bacbaa985c6390f5e4be7 --- arch/arm/arm/Makefile | 1 + kernel/user/src/los_user_init.c | 5 +++-- syscall/Makefile | 1 + 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/arch/arm/arm/Makefile b/arch/arm/arm/Makefile index 24d47056..648fe5c7 100644 --- a/arch/arm/arm/Makefile +++ b/arch/arm/arm/Makefile @@ -35,6 +35,7 @@ LOCAL_SRCS := $(wildcard src/*.c) $(wildcard src/*.S) LOCAL_INCLUDE := \ -I $(LITEOSTOPDIR)/kernel/base/include \ -I $(LITEOSTOPDIR)/kernel/extended/include \ + -I $(LITEOSTOPDIR)/kernel/extended/dynload/include \ -I $(LITEOSTOPDIR)/arch/arm/arm/include \ ifeq ($(LITEOS_ARM_ARCH), -march=armv7-a) diff --git a/kernel/user/src/los_user_init.c b/kernel/user/src/los_user_init.c index e1bb9cfd..d8434323 100644 --- a/kernel/user/src/los_user_init.c +++ b/kernel/user/src/los_user_init.c @@ -30,13 +30,13 @@ */ #include "los_user_init.h" + +#ifdef LOSCFG_KERNEL_DYNLOAD #include "los_syscall.h" #define SYS_CALL_VALUE 0x900001 -#ifdef LOSCFG_KERNEL_DYNLOAD LITE_USER_SEC_RODATA STATIC CHAR *g_initPath = "/bin/init"; -#endif LITE_USER_SEC_TEXT STATIC UINT32 sys_call3(UINT32 nbr, UINT32 parm1, UINT32 parm2, UINT32 parm3) { @@ -55,6 +55,7 @@ LITE_USER_SEC_TEXT STATIC UINT32 sys_call3(UINT32 nbr, UINT32 parm1, UINT32 parm return reg0; } +#endif LITE_USER_SEC_ENTRY VOID OsUserInit(VOID *args) { diff --git a/syscall/Makefile b/syscall/Makefile index ef0e26a7..622ccc28 100644 --- a/syscall/Makefile +++ b/syscall/Makefile @@ -34,6 +34,7 @@ MODULE_NAME := $(notdir $(shell pwd)) LOCAL_SRCS := $(wildcard *.c) LOCAL_INCLUDE := -I $(LITEOSTOPDIR)/kernel/base/include \ + -I $(LITEOSTOPDIR)/kernel/extended/dynload/include \ -I $(LITEOSTOPDIR)/fs/include \ -I $(LITEOSTOPDIR)/compat/posix/include \ -I $(LITEOSTOPDIR)/bsd/compat/linuxkpi/include \ From 669221b620c030b0add1ca8a5abe16c5cca3df8e Mon Sep 17 00:00:00 2001 From: Zbigniew Bodek Date: Thu, 8 Oct 2020 20:52:11 +0800 Subject: [PATCH 08/21] Workaround undefined __stack_chk_guard by disabling LTO Disable LTO to avoid undefined __stack_chk_guard symbol problem. "externally_visible" attribute could be a fix for that but it is not known to our LLVM. Signed-off-by: Zbigniew Bodek Change-Id: I39e0ccaee5897c696a7a9a235e433cf9113853ce --- tools/build/mk/los_config.mk | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tools/build/mk/los_config.mk b/tools/build/mk/los_config.mk index 3d132f8b..a735842b 100644 --- a/tools/build/mk/los_config.mk +++ b/tools/build/mk/los_config.mk @@ -463,7 +463,10 @@ ifeq ($(LOSCFG_COMPILE_DEBUG), y) LITEOS_COPTS_OPTION = -g -gdwarf-2 else ifeq ($(LOSCFG_COMPILER_CLANG_LLVM), y) - LITEOS_COPTS_OPTMIZE = -Oz -flto + # WORKAROUND: Disable LTO to avoid undefined __stack_chk_guard + # problem. "externally_visible" attribute could be + # a fix for that but it is not known to our LLVM. + LITEOS_COPTS_OPTMIZE = -Oz #-flto else LITEOS_COPTS_OPTMIZE = -O2 endif From 850a566916a8a7fe6c4a74f3f05692129f7c6d3a Mon Sep 17 00:00:00 2001 From: Zbigniew Bodek Date: Thu, 8 Oct 2020 23:03:58 +0800 Subject: [PATCH 09/21] Workaround linking problem caused by missing SystemInit during build During LiteOS consolidation, system_init.o object that contains SystemInit() doesn't exist yet as it is being built later and linked in ./vendor directory when OHOS_Image is created. This is not the case when building for HiSilicon platforms as SystemInit is provided for them in precompiled libraries. Workaround this issue by creating "weak" function in LiteOS that will be replaced by the "strong" symbol from ./vendor in linking phase of the OHOS_Image. Signed-off-by: Zbigniew Bodek Change-Id: I39f327a350722a3e41a370ee93ba3b734c5681b0 --- kernel/common/los_config.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/kernel/common/los_config.c b/kernel/common/los_config.c index 368dd631..2de7b995 100644 --- a/kernel/common/los_config.c +++ b/kernel/common/los_config.c @@ -132,6 +132,11 @@ extern "C" { extern UINT32 OsSystemInit(VOID); extern VOID SystemInit(VOID); +VOID __attribute__((weak)) SystemInit(VOID) +{ + PRINT_WARN("Function not implemented. Using weak reference stub\n"); +} + LITE_OS_SEC_TEXT_INIT VOID osRegister(VOID) { g_sysClock = OS_SYS_CLOCK; From e559c86d770f4ec1cf1ea23cdc856024f57288e5 Mon Sep 17 00:00:00 2001 From: Zbigniew Bodek Date: Fri, 9 Oct 2020 15:33:49 +0800 Subject: [PATCH 10/21] Workaround missing machine_resource_init in BSD initialization BSD compatibility is not optional for the kernel to build, however platform dependent portion of this configuration, machine_resource_init(), which is called by nexus_init() is implemented only in the platform specific library for HiSilicon chips (libhi35xx_bsp.a). Workaround lack of this library, so that the kernel can be built for other platforms as well, by excluding it from the compilation. This change should be removed as soon as the appropriate function is implemented for other platforms. Signed-off-by: Zbigniew Bodek Change-Id: I66f15b167b9769f17820f5f0edb7ae8b0ebc9246 --- kernel/common/los_config.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/kernel/common/los_config.c b/kernel/common/los_config.c index 2de7b995..a9b78390 100644 --- a/kernel/common/los_config.c +++ b/kernel/common/los_config.c @@ -210,7 +210,17 @@ LITE_OS_SEC_TEXT_INIT STATIC VOID OsDriverHiEventInit(VOID) extern void configure (void); LITE_OS_SEC_TEXT_INIT STATIC INT32 OsBsdInit(VOID) { + /* + * WORKAROUND: Inside configure(), nexus_init() function calls + * HiSi-specific, library procedure - machine_resource_init(). + * The latter one is defined in libhi35xx_bsp.a which is only + * available for Hi3516 and Hi3518. + * Temporarily ifdef configure until this routine is implemented + * by other platforms. + */ +#if defined(LOSCFG_PLATFORM_HI3516DV300) || defined(LOSCFG_PLATFORM_HI3518EV300) configure(); +#endif mi_startup(SI_SUB_ARCH_INIT); return LOS_OK; } From 89fb5eb32f9a62fb029b594ec4189563aa87aab7 Mon Sep 17 00:00:00 2001 From: Zbigniew Bodek Date: Fri, 9 Oct 2020 17:19:21 +0800 Subject: [PATCH 11/21] Fix build when NET_LWIP_SACK is disabled Allows to disable NET_LWIP_SACK in the kernel configuration. Signed-off-by: Zbigniew Bodek Change-Id: Ibcde4a811e67d61bc713d405414c4991cbc1bdd3 --- syscall/Makefile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/syscall/Makefile b/syscall/Makefile index 622ccc28..bb32fe6e 100644 --- a/syscall/Makefile +++ b/syscall/Makefile @@ -33,6 +33,10 @@ MODULE_NAME := $(notdir $(shell pwd)) LOCAL_SRCS := $(wildcard *.c) +ifneq ($(LOSCFG_NET_LWIP_SACK), y) +LOCAL_SRCS := $(filter-out net_syscall.c, $(LOCAL_SRCS)) +endif + LOCAL_INCLUDE := -I $(LITEOSTOPDIR)/kernel/base/include \ -I $(LITEOSTOPDIR)/kernel/extended/dynload/include \ -I $(LITEOSTOPDIR)/fs/include \ From cef02d9340561a46f641bec5e20ddb301a3c830d Mon Sep 17 00:00:00 2001 From: Zbigniew Bodek Date: Fri, 9 Oct 2020 17:33:46 +0800 Subject: [PATCH 12/21] Add stub for fetching bootargs for Qemu ARM virt Currently unused but when rootfs is enabled we should get this error and quickly narrow down where to add proper bootargs handling. Signed-off-by: Zbigniew Bodek Change-Id: Ie8d96fc3b6ad7cc33abe67530ca8ff9526b46855 --- kernel/common/los_rootfs.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/kernel/common/los_rootfs.c b/kernel/common/los_rootfs.c index 8add614e..8210ad64 100644 --- a/kernel/common/los_rootfs.c +++ b/kernel/common/los_rootfs.c @@ -232,6 +232,17 @@ STATIC INT32 GetArgs(CHAR **args) } #endif +#ifdef LOSCFG_PLATFORM_QEMU_ARM_VIRT_CA7 + /* + * TODO: Implement method of fetching bootargs for + * Qemu ARM virtual platform. If used without + * bootloader it will pass DTB by default. + */ + (void)ret; + PRINT_ERR("Fetching bootargs unimplemented.\n"); + goto ERROUT; +#endif + for (i = 0; i < COMMAND_LINE_SIZE; i += len + 1) { len = strlen(cmdLine + i); tmp = strstr(cmdLine + i, bootargName); From 01cd099ea98a051a9f12c38e116b13a8d31357e0 Mon Sep 17 00:00:00 2001 From: Zbigniew Bodek Date: Fri, 9 Oct 2020 18:22:12 +0800 Subject: [PATCH 13/21] Create Shell task in kernel when PLATFORM_ROOTFS is disabled If the platform doesn't support rootfs but shell and serial console are enabled, create Shell task in kernel. Note that normally, shell task is created by /bin/init. Signed-off-by: Zbigniew Bodek Change-Id: If3bf55313d897569b59902b07eaa042eee71a8df --- shell/full/src/base/show.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/shell/full/src/base/show.c b/shell/full/src/base/show.c index 4b9cce00..122c0480 100644 --- a/shell/full/src/base/show.c +++ b/shell/full/src/base/show.c @@ -100,7 +100,16 @@ STATIC UINT32 OsShellSourceInit(INT32 consoleId) ret = LOS_NOK; goto ERR_OUT4; } - if (consoleId == CONSOLE_TELNET) { + if ((consoleId == CONSOLE_TELNET) +#if !defined(LOSCFG_PLATFORM_ROOTFS) + /* + * In case of ROOTFS disabled but + * serial console enabled, it is required + * to create Shell task in kernel for it. + */ + || (consoleId == CONSOLE_SERIAL) +#endif + ) { ret = OsShellCreateTask(shellCB); if (ret != LOS_OK) { goto ERR_OUT4; From e0406e3df7164d5616a78b2a8d7a95b6fa77d8d5 Mon Sep 17 00:00:00 2001 From: Zbigniew Bodek Date: Fri, 9 Oct 2020 20:24:08 +0800 Subject: [PATCH 14/21] Fix various build problems when building for non-HiSi config Mainly adding missing headers, removing redundant headers that induce undefined symbols or rearranging existing headers according to dependencies betheen them. Also add missing include paths to makefiles and make configs. Note: direct inclusion of pthread.h in disk.h is caused by the latter being used almost everywhere, including third_party libraries. Putting pthread.h there releases us from affecting more code. Basically fixes build for anything that is not default HiSi configuration. Signed-off-by: Zbigniew Bodek Change-Id: Icdcb0874d9fed34d01fa282d33bd2e041c2ac436 --- fs/include/disk.h | 2 ++ fs/vfs/disk/disk.c | 1 - syscall/los_syscall.c | 10 ++++++---- syscall/net_syscall.c | 1 - syscall/time_syscall.c | 1 + tools/build/mk/module.mk | 2 +- 6 files changed, 10 insertions(+), 7 deletions(-) diff --git a/fs/include/disk.h b/fs/include/disk.h index 569c0e58..072cc432 100644 --- a/fs/include/disk.h +++ b/fs/include/disk.h @@ -47,6 +47,8 @@ #endif +#include "pthread.h" + #ifdef __cplusplus #if __cplusplus extern "C" { diff --git a/fs/vfs/disk/disk.c b/fs/vfs/disk/disk.c index 99bd612c..590e8327 100644 --- a/fs/vfs/disk/disk.c +++ b/fs/vfs/disk/disk.c @@ -34,7 +34,6 @@ #include "stdlib.h" #include "unistd.h" #include "sys/mount.h" -#include "pthread.h" #include "linux/spinlock.h" #include "inode/inode.h" diff --git a/syscall/los_syscall.c b/syscall/los_syscall.c index 136c2ef0..04bd3784 100644 --- a/syscall/los_syscall.c +++ b/syscall/los_syscall.c @@ -30,6 +30,12 @@ */ #define _GNU_SOURCE +#include "menuconfig.h" +#ifdef LOSCFG_FS_VFS +#include "fs/fs.h" +#include "fs/file.h" +#endif +#include "los_signal.h" #include "los_syscall.h" #include "los_task_pri.h" #include "los_process_pri.h" @@ -40,10 +46,6 @@ #include "mqueue.h" #include "los_futex_pri.h" #include "sys/times.h" -#ifdef LOSCFG_FS_VFS -#include "fs/fs.h" -#include "fs/file.h" -#endif #include "dirent.h" #include "fcntl.h" #include "unistd.h" diff --git a/syscall/net_syscall.c b/syscall/net_syscall.c index f1ac2489..da948df5 100644 --- a/syscall/net_syscall.c +++ b/syscall/net_syscall.c @@ -29,7 +29,6 @@ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include "los_syscall.h" #include "los_process_pri.h" #include "lwip/sockets.h" #include diff --git a/syscall/time_syscall.c b/syscall/time_syscall.c index af2188dc..23926157 100644 --- a/syscall/time_syscall.c +++ b/syscall/time_syscall.c @@ -36,6 +36,7 @@ #include "time.h" #include "user_copy.h" #include "sys/times.h" +#include "los_signal.h" #include "los_memory.h" #include "los_strncpy_from_user.h" diff --git a/tools/build/mk/module.mk b/tools/build/mk/module.mk index 7c9c0159..e8916568 100644 --- a/tools/build/mk/module.mk +++ b/tools/build/mk/module.mk @@ -81,7 +81,7 @@ all : $(LIB) $(LOCAL_COBJS): $(OBJOUT)/%.o: %.c $(HIDE)$(OBJ_MKDIR) - $(HIDE)$(CC) $(LITEOS_CFLAGS) $(LOCAL_FLAGS) $(LOCAL_CFLAGS) -c $< -o $@ + $(HIDE)$(CC) $(LITEOS_CFLAGS) $(LOCAL_INCLUDE) $(LOCAL_FLAGS) $(LOCAL_CFLAGS) -c $< -o $@ $(LOCAL_CPPOBJS): $(OBJOUT)/%.o: %.cpp $(HIDE)$(OBJ_MKDIR) From 5400ef180afa622248c397b54b165089a65f0099 Mon Sep 17 00:00:00 2001 From: Zbigniew Bodek Date: Fri, 9 Oct 2020 20:37:45 +0800 Subject: [PATCH 15/21] Introduce Qemu ARM Virt CA7 platform debug configuration file Minimal system configuration for Qemu ARM Virtual platform based on Cortex-A7, with GICv2. Some debugging options are enabled to allow for shell bring-up, hence debug configuration type. Signed-off-by: Zbigniew Bodek Change-Id: Ifa01cd44733fd0154044013f45772d178e19e78e --- .../debug/qemu_arm_virt_ca7_clang.config | 146 ++++++++++++++++++ 1 file changed, 146 insertions(+) create mode 100644 tools/build/config/debug/qemu_arm_virt_ca7_clang.config diff --git a/tools/build/config/debug/qemu_arm_virt_ca7_clang.config b/tools/build/config/debug/qemu_arm_virt_ca7_clang.config new file mode 100644 index 00000000..c41774bb --- /dev/null +++ b/tools/build/config/debug/qemu_arm_virt_ca7_clang.config @@ -0,0 +1,146 @@ +# +# Automatically generated file; DO NOT EDIT. +# Huawei LiteOS Configuration +# + +# +# Compiler +# +# LOSCFG_COMPILER_HIMIX_32 is not set +LOSCFG_COMPILER_CLANG_LLVM=y + +# +# Platform +# +LOSCFG_PLATFORM="virt" +# LOSCFG_PLATFORM_HI3516DV300 is not set +# LOSCFG_PLATFORM_HI3518EV300 is not set +LOSCFG_PLATFORM_QEMU_ARM_VIRT_CA7=y +LOSCFG_PLATFORM_BSP_GIC_V2=y +LOSCFG_ARCH_ARM=y +LOSCFG_ARCH_ARM_AARCH32=y +LOSCFG_ARCH_ARM_V7A=y +LOSCFG_ARCH_ARM_VER="armv7-a" +LOSCFG_ARCH_FPU_VFP_V4=y +LOSCFG_ARCH_FPU_VFP_D32=y +LOSCFG_ARCH_FPU_VFP_NEON=y +LOSCFG_ARCH_FPU="neon-vfpv4" +LOSCFG_ARCH_CORTEX_A7=y +LOSCFG_ARCH_CPU="cortex-a7" + +# +# Extra Configurations +# +# LOSCFG_ARCH_FPU_DISABLE is not set +LOSCFG_IRQ_USE_STANDALONE_STACK=y + +# +# Kernel +# +# LOSCFG_KERNEL_SMP is not set +LOSCFG_KERNEL_EXTKERNEL=y +# LOSCFG_KERNEL_CPPSUPPORT is not set +LOSCFG_KERNEL_CPUP=y +LOSCFG_CPUP_INCLUDE_IRQ=y +# LOSCFG_KERNEL_DYNLOAD is not set +# LOSCFG_KERNEL_VDSO is not set +# LOSCFG_KERNEL_TICKLESS is not set +# LOSCFG_KERNEL_TRACE is not set +LOSCFG_KERNEL_LITEIPC=y +LOSCFG_KERNEL_PIPE=y +# LOSCFG_BASE_CORE_HILOG is not set + +# +# Lib +# +LOSCFG_LIB_LIBC=y +LOSCFG_LIB_ZLIB=y + +# +# Compat +# +LOSCFG_COMPAT_POSIX=y +LOSCFG_COMPAT_BSD=y + +# +# FileSystem +# +LOSCFG_FS_VFS=y +# LOSCFG_FS_VFS_BLOCK_DEVICE is not set +LOSCFG_FILE_MODE=y +# LOSCFG_FS_FAT is not set +LOSCFG_FS_RAMFS=y +LOSCFG_FS_PROC=y +# LOSCFG_FS_JFFS is not set + +# +# Net +# +# LOSCFG_NET_LWIP_SACK is not set + +# +# Debug +# +# LOSCFG_COMPILE_DEBUG is not set +# LOSCFG_PLATFORM_ADAPT is not set +# LOSCFG_ENABLE_OOM_LOOP_TASK is not set +# LOSCFG_ENABLE_MAGICKEY is not set +# LOSCFG_THUMB is not set +LOSCFG_DEBUG_VERSION=y +# LOSCFG_DEBUG_KERNEL is not set +LOSCFG_SHELL=y + +# +# Functionality of Shell +# +# LOSCFG_SHELL_LK is not set +# LOSCFG_SHELL_EXCINFO is not set +# LOSCFG_EXC_INTERACTION is not set +# LOSCFG_USER_INIT_DEBUG is not set +# LOSCFG_SHELL_CMD_DEBUG is not set +# LOSCFG_MEM_DEBUG is not set +# LOSCFG_NULL_ADDRESS_PROTECT is not set +LOSCFG_DRIVERS_HDF_PLATFORM_UART=y +# LOSCFG_PLATFORM_UART_WITHOUT_VFS is not set +# LOSCFG_PLATFORM_NO_UART is not set + +# +# Driver +# +LOSCFG_DRIVERS=y +# LOSCFG_DRIVERS_USB is not set +LOSCFG_DRIVERS_HDF=y +LOSCFG_DRIVERS_HDF_PLATFORM=y +# LOSCFG_DRIVERS_HDF_PLATFORM_I2C is not set +# LOSCFG_DRIVERS_HDF_PLATFORM_SPI is not set +# LOSCFG_DRIVERS_HDF_PLATFORM_GPIO is not set +# LOSCFG_DRIVERS_HDF_PLATFORM_WATCHDOG is not set +# LOSCFG_DRIVERS_HDF_PLATFORM_SDIO is not set +# LOSCFG_DRIVERS_HDF_PLATFORM_RTC is not set +# LOSCFG_DRIVERS_HDF_PLATFORM_HISI_SDK is not set +# LOSCFG_DRIVERS_HDF_WIFI is not set +# LOSCFG_DRIVERS_HDF_INPUT is not set +# LOSCFG_DRIVERS_HDF_LCD is not set +# LOSCFG_DRIVERS_HDF_USB is not set +LOSCFG_DRIVERS_MEM=y +# LOSCFG_DRIVERS_MMC is not set +# LOSCFG_DRIVERS_MTD is not set +# LOSCFG_DRIVERS_RANDOM is not set +# LOSCFG_DRIVERS_VIDEO is not set +# LOSCFG_DRIVERS_HIEVENT is not set + +# +# Security +# +LOSCFG_SECURITY=y +LOSCFG_SECURITY_CAPABILITY=y +LOSCFG_SECURITY_VID=y +# LOSCFG_SECURITY_BOOT is not set + +# +# Stack Smashing Protector (SSP) Compiler Feature +# +# LOSCFG_CC_NO_STACKPROTECTOR is not set +# LOSCFG_CC_STACKPROTECTOR is not set +# LOSCFG_CC_STACKPROTECTOR_STRONG is not set +LOSCFG_CC_STACKPROTECTOR_ALL=y From 3247d4f6510155c1dd703d4f6d91c5640e97cef1 Mon Sep 17 00:00:00 2001 From: Zbigniew Bodek Date: Tue, 27 Oct 2020 00:22:40 +0800 Subject: [PATCH 16/21] Fix build error due to "unequal" brackets For some reason more brackets is worse than no brackets and warning is generated that is threated as error. Therefore remove brackets to fix the build when LOSCFG_PLATFORM_ROOTFS is defined Signed-off-by: Zbigniew Bodek Change-Id: I610a5893217039a36d894641c54a83ff4d4b7822 --- shell/full/src/base/show.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/shell/full/src/base/show.c b/shell/full/src/base/show.c index 122c0480..e7eeae7e 100644 --- a/shell/full/src/base/show.c +++ b/shell/full/src/base/show.c @@ -100,14 +100,14 @@ STATIC UINT32 OsShellSourceInit(INT32 consoleId) ret = LOS_NOK; goto ERR_OUT4; } - if ((consoleId == CONSOLE_TELNET) + if (consoleId == CONSOLE_TELNET #if !defined(LOSCFG_PLATFORM_ROOTFS) /* * In case of ROOTFS disabled but * serial console enabled, it is required * to create Shell task in kernel for it. */ - || (consoleId == CONSOLE_SERIAL) + || consoleId == CONSOLE_SERIAL #endif ) { ret = OsShellCreateTask(shellCB); From 994ad00de78eacdb4d978eb9f014528133be8416 Mon Sep 17 00:00:00 2001 From: Zbigniew Bodek Date: Tue, 27 Oct 2020 01:11:36 +0800 Subject: [PATCH 17/21] Change DEFINE macro to U32_C The macro to append "U" suffix should be named according to what it actually does which is defining U32 constant. Signed-off-by: Zbigniew Bodek Change-Id: I55701f0650c88bd083c062581af5c7a1b966bc0b --- kernel/base/include/los_vm_zone.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/kernel/base/include/los_vm_zone.h b/kernel/base/include/los_vm_zone.h index 0292effd..0baba0a2 100644 --- a/kernel/base/include/los_vm_zone.h +++ b/kernel/base/include/los_vm_zone.h @@ -40,11 +40,11 @@ extern "C" { #endif /* __cplusplus */ #endif /* __cplusplus */ -#define DEFINE_(X) X##U -#define DEFINE(X) DEFINE_(X) +#define _U32_C(X) X##U +#define U32_C(X) _U32_C(X) -#define KERNEL_VMM_BASE DEFINE(KERNEL_VADDR_BASE) -#define KERNEL_VMM_SIZE DEFINE(KERNEL_VADDR_SIZE) +#define KERNEL_VMM_BASE U32_C(KERNEL_VADDR_BASE) +#define KERNEL_VMM_SIZE U32_C(KERNEL_VADDR_SIZE) #define KERNEL_ASPACE_BASE KERNEL_VMM_BASE #define KERNEL_ASPACE_SIZE KERNEL_VMM_SIZE @@ -57,11 +57,11 @@ extern "C" { #define VMALLOC_SIZE 0x08000000 #define PERIPH_DEVICE_BASE (VMALLOC_START + VMALLOC_SIZE) -#define PERIPH_DEVICE_SIZE PERIPH_PMM_SIZE +#define PERIPH_DEVICE_SIZE U32_C(PERIPH_PMM_SIZE) #define PERIPH_CACHED_BASE (PERIPH_DEVICE_BASE + PERIPH_DEVICE_SIZE) -#define PERIPH_CACHED_SIZE PERIPH_PMM_SIZE +#define PERIPH_CACHED_SIZE U32_C(PERIPH_PMM_SIZE) #define PERIPH_UNCACHED_BASE (PERIPH_CACHED_BASE + PERIPH_CACHED_SIZE) -#define PERIPH_UNCACHED_SIZE PERIPH_PMM_SIZE +#define PERIPH_UNCACHED_SIZE U32_C(PERIPH_PMM_SIZE) #define IO_DEVICE_ADDR(paddr) (paddr - PERIPH_PMM_BASE + PERIPH_DEVICE_BASE) #define IO_CACHED_ADDR(paddr) (paddr - PERIPH_PMM_BASE + PERIPH_CACHED_BASE) From 07c89a8473efd4b1537ec0516430a9165a2801f6 Mon Sep 17 00:00:00 2001 From: Zbigniew Bodek Date: Tue, 27 Oct 2020 01:17:49 +0800 Subject: [PATCH 18/21] Fix IS_PERIPH_ADDR() and IS_MEMORY_ADDR() macros The macros assume that constants that are compared against "addr" are either unsigned or less than INT_MAX. In some cases it is not true so change costants to unsigned using U32_C macros. The correct solution would be to change teh MEM_ADDR, PMM_BASE, etc. to be unsigned long but currently "U" suffix is appended in various places so the assumption is that those macros use default definition (which is int). Put "addr" into brackets by the way since it could be an expression rather than one variable. Signed-off-by: Zbigniew Bodek Change-Id: Ife9bc5863b4934ecaab64b24faa084b87d7d7ea5 --- kernel/base/include/los_vm_iomap.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/base/include/los_vm_iomap.h b/kernel/base/include/los_vm_iomap.h index f73aa89a..1b492510 100644 --- a/kernel/base/include/los_vm_iomap.h +++ b/kernel/base/include/los_vm_iomap.h @@ -46,8 +46,8 @@ enum DmaMemType { DMA_NOCACHE }; -#define IS_PERIPH_ADDR(addr) ((addr >= PERIPH_PMM_BASE) && (addr <= PERIPH_PMM_BASE + PERIPH_PMM_SIZE)) -#define IS_MEMORY_ADDR(addr) ((addr >= DDR_MEM_ADDR) && (addr <= DDR_MEM_ADDR + DDR_MEM_SIZE)) +#define IS_PERIPH_ADDR(addr) (((addr) >= U32_C(PERIPH_PMM_BASE)) && ((addr) <= U32_C(PERIPH_PMM_BASE) + U32_C(PERIPH_PMM_SIZE))) +#define IS_MEMORY_ADDR(addr) (((addr) >= U32_C(DDR_MEM_ADDR)) && ((addr) <= U32_C(DDR_MEM_ADDR) + U32_C(DDR_MEM_SIZE))) /* thread safety */ VOID *LOS_DmaMemAlloc(DMA_ADDR_T *dmaAddr, size_t size, size_t align, enum DmaMemType type); From 51263d87969873692b475aa8c21bfadf82e4ee78 Mon Sep 17 00:00:00 2001 From: Zbigniew Bodek Date: Wed, 28 Oct 2020 23:41:30 +0800 Subject: [PATCH 19/21] Add kernel configuration option to enable/disable HR Timer High resolution timer can now be excluded from the build. There is currently no HR Timer implementation for other platform than HiSi. Note: HR Timer will be enabled by default Signed-off-by: Zbigniew Bodek Change-Id: I5daf8e0ceec2a17025b579513e3bd74db1040916 --- bsd/compat/linuxkpi/Makefile | 4 ++++ platform/Kconfig | 7 +++++++ platform/Makefile | 5 ++++- platform/bsp.mk | 4 +++- 4 files changed, 18 insertions(+), 2 deletions(-) diff --git a/bsd/compat/linuxkpi/Makefile b/bsd/compat/linuxkpi/Makefile index 5244c469..be7ffc70 100644 --- a/bsd/compat/linuxkpi/Makefile +++ b/bsd/compat/linuxkpi/Makefile @@ -33,6 +33,10 @@ MODULE_NAME := $(notdir $(shell pwd)) LOCAL_SRCS := $(wildcard src/*.c) +ifneq ($(LOSCFG_HRTIMER_ENABLE), y) +LOCAL_SRCS := $(filter-out src/linux_hrtimer.c, $(LOCAL_SRCS)) +endif + LOCAL_INCLUDE := \ -I $(LITEOSTOPDIR)/kernel/base/include \ -I $(LITEOSTOPDIR)/bsd/compat/linuxkpi/include diff --git a/platform/Kconfig b/platform/Kconfig index 088d3a9d..db1af3f9 100644 --- a/platform/Kconfig +++ b/platform/Kconfig @@ -56,3 +56,10 @@ config PLATFORM_BSP_GIC_V3 General Interrupt Controller version 3. endchoice + +config HRTIMER_ENABLE + bool "HR TIMER enable" + default y + help + Enable High-resolution timer support + diff --git a/platform/Makefile b/platform/Makefile index eee94a0a..34ab7750 100644 --- a/platform/Makefile +++ b/platform/Makefile @@ -33,10 +33,13 @@ MODULE_NAME := bsp LOCAL_SRCS = $(wildcard $(HWI_SRC)/*.c) \ $(wildcard $(TIMER_SRC)/*.c) \ - $(wildcard $(HRTIMER_SRC)/*.c) \ $(wildcard $(UART_SRC)/*.c) \ $(wildcard ./main.c) +ifeq ($(LOSCFG_HRTIMER_ENABLE), y) +LOCAL_SRCS += $(wildcard $(HRTIMER_SRC)/*.c) +endif + LOCAL_INCLUDE += -I $(LITEOSTOPDIR)/compat/posix/src \ -I $(LITEOSTOPDIR)/bsd/dev/random diff --git a/platform/bsp.mk b/platform/bsp.mk index 0223f82d..99889951 100644 --- a/platform/bsp.mk +++ b/platform/bsp.mk @@ -64,9 +64,11 @@ else ifeq ($(LOSCFG_PLATFORM_QEMU_ARM_VIRT_CA7), y) endif +ifeq ($(LOSCFG_HRTIMER_ENABLE), y) +HRTIMER_SRC := hw/$(HRTIMER_TYPE) +endif HWI_SRC := hw/$(HWI_TYPE) TIMER_SRC := hw/$(TIMER_TYPE) -HRTIMER_SRC := hw/$(HRTIMER_TYPE) NET_SRC := net/$(NET_TYPE) UART_SRC := uart/$(UART_TYPE) USB_SRC := usb/$(USB_TYPE) From f0990f3b9286998e2364ec5bdb2cc65a8672298c Mon Sep 17 00:00:00 2001 From: Zbigniew Bodek Date: Thu, 29 Oct 2020 00:01:15 +0800 Subject: [PATCH 20/21] Update configuration files after HRTIMER option Update only those configuration files that are used during build (clang and clang+debug). Signed-off-by: Zbigniew Bodek Change-Id: I5639b0074e8c4e0fef4e21d9f3b8c1582bb038d5 --- tools/build/config/debug/hi3516dv300_clang.config | 2 ++ tools/build/config/debug/hi3518ev300_clang.config | 2 ++ tools/build/config/debug/qemu_arm_virt_ca7_clang.config | 1 + tools/build/config/hi3516dv300_clang_release.config | 2 ++ tools/build/config/hi3518ev300_clang_release.config | 2 ++ 5 files changed, 9 insertions(+) diff --git a/tools/build/config/debug/hi3516dv300_clang.config b/tools/build/config/debug/hi3516dv300_clang.config index a34f516f..111ba398 100644 --- a/tools/build/config/debug/hi3516dv300_clang.config +++ b/tools/build/config/debug/hi3516dv300_clang.config @@ -15,8 +15,10 @@ LOSCFG_COMPILER_CLANG_LLVM=y LOSCFG_PLATFORM="hi3516dv300" LOSCFG_PLATFORM_HI3516DV300=y # LOSCFG_PLATFORM_HI3518EV300 is not set +# LOSCFG_PLATFORM_QEMU_ARM_VIRT_CA7 is not set # LOSCFG_TEE_ENABLE is not set LOSCFG_PLATFORM_BSP_GIC_V2=y +LOSCFG_HRTIMER_ENABLE=y LOSCFG_ARCH_ARM=y LOSCFG_ARCH_ARM_AARCH32=y LOSCFG_ARCH_ARM_V7A=y diff --git a/tools/build/config/debug/hi3518ev300_clang.config b/tools/build/config/debug/hi3518ev300_clang.config index 8a4d6ebe..339674a9 100644 --- a/tools/build/config/debug/hi3518ev300_clang.config +++ b/tools/build/config/debug/hi3518ev300_clang.config @@ -15,7 +15,9 @@ LOSCFG_COMPILER_CLANG_LLVM=y LOSCFG_PLATFORM="hi3518ev300" # LOSCFG_PLATFORM_HI3516DV300 is not set LOSCFG_PLATFORM_HI3518EV300=y +# LOSCFG_PLATFORM_QEMU_ARM_VIRT_CA7 is not set LOSCFG_PLATFORM_BSP_GIC_V2=y +LOSCFG_HRTIMER_ENABLE=y LOSCFG_ARCH_ARM=y LOSCFG_ARCH_ARM_AARCH32=y LOSCFG_ARCH_ARM_V7A=y diff --git a/tools/build/config/debug/qemu_arm_virt_ca7_clang.config b/tools/build/config/debug/qemu_arm_virt_ca7_clang.config index c41774bb..b56d817a 100644 --- a/tools/build/config/debug/qemu_arm_virt_ca7_clang.config +++ b/tools/build/config/debug/qemu_arm_virt_ca7_clang.config @@ -17,6 +17,7 @@ LOSCFG_PLATFORM="virt" # LOSCFG_PLATFORM_HI3518EV300 is not set LOSCFG_PLATFORM_QEMU_ARM_VIRT_CA7=y LOSCFG_PLATFORM_BSP_GIC_V2=y +# LOSCFG_HRTIMER_ENABLE is not set LOSCFG_ARCH_ARM=y LOSCFG_ARCH_ARM_AARCH32=y LOSCFG_ARCH_ARM_V7A=y diff --git a/tools/build/config/hi3516dv300_clang_release.config b/tools/build/config/hi3516dv300_clang_release.config index 5fb2798a..4476fd70 100644 --- a/tools/build/config/hi3516dv300_clang_release.config +++ b/tools/build/config/hi3516dv300_clang_release.config @@ -15,8 +15,10 @@ LOSCFG_COMPILER_CLANG_LLVM=y LOSCFG_PLATFORM="hi3516dv300" LOSCFG_PLATFORM_HI3516DV300=y # LOSCFG_PLATFORM_HI3518EV300 is not set +# LOSCFG_PLATFORM_QEMU_ARM_VIRT_CA7 is not set # LOSCFG_TEE_ENABLE is not set LOSCFG_PLATFORM_BSP_GIC_V2=y +LOSCFG_HRTIMER_ENABLE=y LOSCFG_ARCH_ARM=y LOSCFG_ARCH_ARM_AARCH32=y LOSCFG_ARCH_ARM_V7A=y diff --git a/tools/build/config/hi3518ev300_clang_release.config b/tools/build/config/hi3518ev300_clang_release.config index 982d0f53..0d2da7ee 100644 --- a/tools/build/config/hi3518ev300_clang_release.config +++ b/tools/build/config/hi3518ev300_clang_release.config @@ -15,7 +15,9 @@ LOSCFG_COMPILER_CLANG_LLVM=y LOSCFG_PLATFORM="hi3518ev300" # LOSCFG_PLATFORM_HI3516DV300 is not set LOSCFG_PLATFORM_HI3518EV300=y +# LOSCFG_PLATFORM_QEMU_ARM_VIRT_CA7 is not set LOSCFG_PLATFORM_BSP_GIC_V2=y +LOSCFG_HRTIMER_ENABLE=y LOSCFG_ARCH_ARM=y LOSCFG_ARCH_ARM_AARCH32=y LOSCFG_ARCH_ARM_V7A=y From 0403820b22aec103274717ca5a661308b7e379b5 Mon Sep 17 00:00:00 2001 From: Zbigniew Bodek Date: Wed, 23 Dec 2020 19:45:03 +0800 Subject: [PATCH 21/21] Change path to Qemu ARM platform's config and init Change "vendor" to "device" where the latest version of MR puts stuff related to Qemu ARM Virt. Signed-off-by: Zbigniew Bodek --- Makefile | 2 +- platform/bsp.mk | 4 ++-- tools/build/mk/los_config.mk | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 3e02ad56..b7f3d045 100644 --- a/Makefile +++ b/Makefile @@ -103,7 +103,7 @@ endif ifeq ($(findstring y, $(LOSCFG_PLATFORM_HI3518EV300)$(LOSCFG_PLATFORM_HI3516DV300)), y) VENDOR_BOARD_INCLUDE := $(LITEOSTOPDIR)/../../vendor/hisi/hi35xx/$(LITEOS_PLATFORM)/config/board else ifeq ($(LOSCFG_PLATFORM_QEMU_ARM_VIRT_CA7), y) -VENDOR_BOARD_INCLUDE := $(LITEOSTOPDIR)/../../vendor/qemu/arm/$(LITEOS_PLATFORM)/config/board +VENDOR_BOARD_INCLUDE := $(LITEOSTOPDIR)/../../device/qemu/arm/$(LITEOS_PLATFORM)/config/board else $(error "No VENDOR_BOARD_INCLUDE defined") endif diff --git a/platform/bsp.mk b/platform/bsp.mk index 99889951..9deee827 100644 --- a/platform/bsp.mk +++ b/platform/bsp.mk @@ -89,9 +89,9 @@ ifeq ($(findstring y, $(LOSCFG_PLATFORM_HI3518EV300)$(LOSCFG_PLATFORM_HI3516DV30 PLATFORM_INCLUDE += -I $(LITEOSTOPDIR)/../../vendor/hisi/hi35xx/$(LITEOS_PLATFORM)/config/board/include PLATFORM_INCLUDE += -I $(LITEOSTOPDIR)/../../vendor/hisi/hi35xx/$(LITEOS_PLATFORM)/config/board/include/hisoc else ifeq ($(LOSCFG_PLATFORM_QEMU_ARM_VIRT_CA7), y) - PLATFORM_INCLUDE += -I $(LITEOSTOPDIR)/../../vendor/qemu/arm/$(LITEOS_PLATFORM)/config/board/include + PLATFORM_INCLUDE += -I $(LITEOSTOPDIR)/../../device/qemu/arm/$(LITEOS_PLATFORM)/config/board/include # TODO: remove hisoc dependency in the code to avoid using hisoc here - PLATFORM_INCLUDE += -I $(LITEOSTOPDIR)/../../vendor/qemu/arm/$(LITEOS_PLATFORM)/config/board/include/hisoc + PLATFORM_INCLUDE += -I $(LITEOSTOPDIR)/../../device/qemu/arm/$(LITEOS_PLATFORM)/config/board/include/hisoc endif # #-include $(LITEOSTOPDIR)/platform/bsp/board/$(LITEOS_PLATFORM)/board.mk diff --git a/tools/build/mk/los_config.mk b/tools/build/mk/los_config.mk index a735842b..5839d3e5 100644 --- a/tools/build/mk/los_config.mk +++ b/tools/build/mk/los_config.mk @@ -363,7 +363,7 @@ LITEOS_DRIVERS_BASE_PATH := $(LITEOSTOPDIR)/../../drivers/liteos ifeq ($(findstring y, $(LOSCFG_PLATFORM_HI3518EV300)$(LOSCFG_PLATFORM_HI3516DV300)), y) LITEOS_VENDOR_DRIVERS_BASE_PATH := $(LITEOSTOPDIR)/../../vendor/hisi/hi35xx/platform else ifeq ($(LOSCFG_PLATFORM_QEMU_ARM_VIRT_CA7), y) -LITEOS_VENDOR_DRIVERS_BASE_PATH := $(LITEOSTOPDIR)/../../vendor/qemu/arm/platform +LITEOS_VENDOR_DRIVERS_BASE_PATH := $(LITEOSTOPDIR)/../../device/qemu/arm/platform endif ################################## Driver Option Begin ################################# ifeq ($(LOSCFG_DRIVERS_HDF), y)