From 4388099c3a79c404c1d5afb66b758d916303cb88 Mon Sep 17 00:00:00 2001 From: Victor Sun Date: Mon, 13 Apr 2020 09:47:26 +0800 Subject: [PATCH] Kconfig: change scenario variable type to string Basicly ACRN scenario is a configuration name for specific usage. By giving scenario name ACRN will load corresponding VM configurations to build the hypervisor. But customer might have their own scenario name, change the scenario type from choice to string is friendly to them since Kconfig source file change will not be needed. With this change, CONFIG_$(SCENARIO) will not exist in kconfig file and will be instead of CONFIG_SCENARIO, so the Makefile need to be changed accordingly; Tracked-On: #4616 Signed-off-by: Victor Sun --- Makefile | 27 +++++--------- hypervisor/Makefile | 30 +++------------ hypervisor/arch/x86/Kconfig | 51 +++++++------------------- hypervisor/scripts/makefile/kconfig.mk | 14 ++----- 4 files changed, 34 insertions(+), 88 deletions(-) diff --git a/Makefile b/Makefile index bae8d3373..325d7854e 100644 --- a/Makefile +++ b/Makefile @@ -75,8 +75,7 @@ ifeq ($(KCONFIG_FILE), $(wildcard $(KCONFIG_FILE))) $(error no BOARD info in KCONFIG_FILE: $(KCONFIG_FILE)) endif - SCENARIO_IN_KCONFIG := $(shell grep -E "SDC=y|SDC2=y|INDUSTRY=y|LOGICAL_PARTITION=y|HYBRID=y" \ - $(KCONFIG_FILE) | grep -v '\#' | awk -F "=" '{print $$1}' | cut -d '_' -f 2- | tr A-Z a-z) + SCENARIO_IN_KCONFIG := $(shell grep CONFIG_SCENARIO= $(KCONFIG_FILE) | grep -v '\#' | awk -F '"' '{print $$2}') ifeq ($(SCENARIO_IN_KCONFIG),) $(error no SCENARIO info in KCONFIG_FILE: $(KCONFIG_FILE)) endif @@ -131,14 +130,13 @@ include $(T)/hypervisor/scripts/makefile/cfg_update.mk #help functions to build acrn and install acrn/acrn symbols define build_acrn - $(MAKE) -C $(T)/hypervisor HV_OBJDIR=$(HV_OUT)-$(1)/$(2) BOARD=$(2) FIRMWARE=$(1) SCENARIO=$(4) RELEASE=$(RELEASE) clean - $(MAKE) -C $(T)/hypervisor HV_OBJDIR=$(HV_OUT)-$(1)/$(2) BOARD=$(2) FIRMWARE=$(1) SCENARIO=$(4) RELEASE=$(RELEASE) defconfig - @echo "$(3)=y" >> $(HV_OUT)-$(1)/$(2)/.config - $(MAKE) -C $(T)/hypervisor HV_OBJDIR=$(HV_OUT)-$(1)/$(2) BOARD=$(2) FIRMWARE=$(1) SCENARIO=$(4) RELEASE=$(RELEASE) oldconfig - $(MAKE) -C $(T)/hypervisor HV_OBJDIR=$(HV_OUT)-$(1)/$(2) BOARD=$(2) FIRMWARE=$(1) SCENARIO=$(4) RELEASE=$(RELEASE) + $(MAKE) -C $(T)/hypervisor HV_OBJDIR=$(HV_OUT)-$(1)/$(2) BOARD=$(2) FIRMWARE=$(1) SCENARIO=$(3) RELEASE=$(RELEASE) clean + $(MAKE) -C $(T)/hypervisor HV_OBJDIR=$(HV_OUT)-$(1)/$(2) BOARD=$(2) FIRMWARE=$(1) SCENARIO=$(3) RELEASE=$(RELEASE) defconfig + $(MAKE) -C $(T)/hypervisor HV_OBJDIR=$(HV_OUT)-$(1)/$(2) BOARD=$(2) FIRMWARE=$(1) SCENARIO=$(3) RELEASE=$(RELEASE) oldconfig + $(MAKE) -C $(T)/hypervisor HV_OBJDIR=$(HV_OUT)-$(1)/$(2) BOARD=$(2) FIRMWARE=$(1) SCENARIO=$(3) RELEASE=$(RELEASE) echo "building hypervisor as EFI executable..." @if [ "$(1)" = "uefi" ]; then \ - $(MAKE) -C $(T)/misc/efi-stub HV_OBJDIR=$(HV_OUT)-$(1)/$(2) SCENARIO=$(4) EFI_OBJDIR=$(HV_OUT)-$(1)/$(2)/$(EFI_OUT); \ + $(MAKE) -C $(T)/misc/efi-stub HV_OBJDIR=$(HV_OUT)-$(1)/$(2) SCENARIO=$(3) EFI_OBJDIR=$(HV_OUT)-$(1)/$(2)/$(EFI_OUT); \ fi endef @@ -157,17 +155,12 @@ define install_acrn_debug endef hypervisor: - @if [ "$(SCENARIO)" != "sdc" ] && [ "$(SCENARIO)" != "sdc2" ] && [ "$(SCENARIO)" != "industry" ] \ - && [ "$(SCENARIO)" != "logical_partition" ] && [ "$(SCENARIO)" != "hybrid" ]; then \ - echo "SCENARIO <$(SCENARIO)> is not supported. "; exit 1; \ - fi @if [ "$(BOARD_FILE)" != "" ] && [ -f $(BOARD_FILE) ] && [ "$(SCENARIO_FILE)" != "" ] && [ -f $(SCENARIO_FILE) ] && [ "$(TARGET_DIR)" = "" ]; then \ echo "No TARGET_DIR parameter is specified, the original configuration source is overwritten!";\ fi $(MAKE) -C $(T)/hypervisor HV_OBJDIR=$(HV_OUT) BOARD_FILE=$(BOARD_FILE) SCENARIO_FILE=$(SCENARIO_FILE) clean; $(MAKE) -C $(T)/hypervisor HV_OBJDIR=$(HV_OUT) BOARD_FILE=$(BOARD_FILE) SCENARIO_FILE=$(SCENARIO_FILE) TARGET_DIR=$(abspath $(TARGET_DIR)) defconfig; @if [ "$(CONFIG_XML_ENABLED)" != "true" ] && [ ! -f $(KCONFIG_FILE) ]; then \ - echo "CONFIG_$(shell echo $(SCENARIO) | tr a-z A-Z)=y" >> $(HV_OUT)/.config; \ if [ "$(SCENARIO)" != "sdc" ]; then \ echo "CONFIG_MAX_KATA_VM_NUM=0" >> $(HV_OUT)/.config; \ fi; \ @@ -239,13 +232,13 @@ ifeq ($(FIRMWARE),uefi) endif apl-mrb-sbl-sdc: - $(call build_acrn,sbl,apl-mrb,CONFIG_SDC,sdc) + $(call build_acrn,sbl,apl-mrb,sdc) apl-up2-sbl-sdc: - $(call build_acrn,sbl,apl-up2,CONFIG_SDC,sdc) + $(call build_acrn,sbl,apl-up2,sdc) kbl-nuc-i7-uefi-industry: - $(call build_acrn,uefi,nuc7i7dnb,CONFIG_INDUSTRY,industry) + $(call build_acrn,uefi,nuc7i7dnb,industry) apl-up2-uefi-hybrid: - $(call build_acrn,uefi,apl-up2,CONFIG_HYBRID,hybrid) + $(call build_acrn,uefi,apl-up2,hybrid) sbl-hypervisor: apl-mrb-sbl-sdc \ apl-up2-sbl-sdc \ diff --git a/hypervisor/Makefile b/hypervisor/Makefile index 6330031d4..902f224ec 100644 --- a/hypervisor/Makefile +++ b/hypervisor/Makefile @@ -50,31 +50,11 @@ include scripts/makefile/deps.mk include scripts/makefile/kconfig.mk -#initialize BOARD if it is not specified -ifeq ($(BOARD),) - override BOARD := $(CONFIG_BOARD) -endif +#override BOARD from CONFIG_BOARD, which is specified in kconfig.mk +override BOARD := $(shell echo $(CONFIG_BOARD) |sed 's/"//g') -ifeq ($(CONFIG_SDC),y) - KCONFIG_SCENARIO := sdc -else ifeq ($(CONFIG_SDC2),y) - KCONFIG_SCENARIO := sdc2 -else ifeq ($(CONFIG_LOGICAL_PARTITION),y) - KCONFIG_SCENARIO := logical_partition -else ifeq ($(CONFIG_INDUSTRY),y) - KCONFIG_SCENARIO := industry -else ifeq ($(CONFIG_HYBRID),y) - KCONFIG_SCENARIO := hybrid -endif - -#initialize SCENARIO if it is not specified -ifeq ($(SCENARIO),) - ifeq ($(KCONFIG_SCENARIO),) - override SCENARIO := sdc - else - override SCENARIO := $(KCONFIG_SCENARIO) - endif -endif +#override SCENARIO from CONFIG_SCENARIO, which is specified in kconfig.mk +override SCENARIO := $(shell echo $(CONFIG_SCENARIO) |sed 's/"//g') ifeq ($(TARGET_DIR),) BOARD_CFG_DIR := arch/x86/configs/$(BOARD) @@ -510,6 +490,8 @@ distclean: PHONY: (VERSION) $(VERSION): + @if [ "$(SCENARIO)" = "" ]; then echo "Please specify SCENARIO for the build!"; exit 1; fi; + @if [ "$(BOARD)" = "" ]; then echo "Please specify BOARD for the build!"; exit 1; fi; @echo "SCENARIO <$(SCENARIO)> for BOARD <$(BOARD)> is specified." @if [ ! -d $(BOARD_CFG_DIR) ]; then \ echo "Configurations for BOARD $(BOARD) is not found."; exit 1; \ diff --git a/hypervisor/arch/x86/Kconfig b/hypervisor/arch/x86/Kconfig index 61e051099..5eed0b9c4 100644 --- a/hypervisor/arch/x86/Kconfig +++ b/hypervisor/arch/x86/Kconfig @@ -1,41 +1,18 @@ -choice - prompt "ACRN Scenario" - default SDC +config SCENARIO + string "ACRN scenario" + default "sdc" help - Select the scenario name to load corresponding VM configuration. - -config SDC - bool "Software Defined Cockpit" - help - SDC (Software Defined Cockpit) is a typical scenario that ACRN supported. - SDC will have one pre-launched SOS VM and one post-launched VM. - -config SDC2 - bool "Software Defined Cockpit 2" - help - SDC2 (Software Defined Cockpit 2) is an extended scenario for automotive SDC system. - SDC2 will have one pre-launched SOS VM and up to three post-launched VM. - -config LOGICAL_PARTITION - bool "Logical Partition VMs" - help - This scenario will run two pre-launched VMs. - -config INDUSTRY - bool "Industry VMs" - help - This scenario is a typical scenario for industry usage with 4 VMs: - one pre-launched SOS VM, one post-launched Standard VM for HMI, one or two - post-launched RT VM for real-time control. - -config HYBRID - bool "Hybrid VMs" - help - This scenario is a typical scenario for hybrid usage with 3 VMs: - one pre-launched VM, one pre-launched SOS VM and one post-launched Standard - VM. - -endchoice + By specifying SCENARIO name, ACRN will load corresponding VM configurations + to build the hypervisor. Currently ACRN provides below reference scenarios: + sdc: Typical scenario for automotive Software Defined Cockpit system. + sdc will have one pre-launched SOS VM and one post-launched VM; + sdc2: Extended scenario for automotive Software Defined Cockpit system. + sdc2 will have one pre-launched SOS VM and up to three post-launched VMs; + industry: Typical scenario for industry usage with 3 VMs: one pre-launched SOS VM, + one post-launched Standard VM for HMI, one post-launched RT VM for real-time control. + hybrid: Typical scenario for hybrid usage with 3 VMs: one pre-launched VM, + one pre-launched SOS VM and one post-launched Standard VM; + logical_partition: Typical scenario that run two isolated pre-launched VMs; config MULTIBOOT2 bool "Multiboot2 support" diff --git a/hypervisor/scripts/makefile/kconfig.mk b/hypervisor/scripts/makefile/kconfig.mk index b1047111a..350c25fd2 100644 --- a/hypervisor/scripts/makefile/kconfig.mk +++ b/hypervisor/scripts/makefile/kconfig.mk @@ -36,16 +36,10 @@ ifeq ($(shell [ $(HV_OBJDIR)/$(HV_CONFIG) -nt $(HV_OBJDIR)/$(HV_CONFIG_MK) ] && # only happens when GNU make checks the prerequisites. -include $(HV_OBJDIR)/$(HV_CONFIG) endif - $(eval $(call override_config,BOARD,apl-mrb)) +$(eval $(call override_config,SCENARIO,)) $(eval $(call override_config,RELEASE,n)) -ifdef BOARD -TARGET_BOARD=$(BOARD) -else -TARGET_BOARD=$(CONFIG_BOARD) -endif - $(eval $(call check_dep_exec,python3,KCONFIG_DEPS)) $(eval $(call check_dep_py3lib,kconfiglib,KCONFIG_DEPS)) @@ -73,7 +67,7 @@ $(HV_OBJDIR)/$(HV_CONFIG_H): $(HV_OBJDIR)/$(HV_CONFIG) defconfig: $(KCONFIG_DEPS) @mkdir -p $(HV_OBJDIR) @if [ ! -f $(KCONFIG_FILE) ] && [ "$(CONFIG_XML_ENABLED)" != "true" ]; then \ - BOARD=$(TARGET_BOARD) python3 $(KCONFIG_DIR)/defconfig.py Kconfig $(HV_OBJDIR)/$(HV_CONFIG); \ + BOARD=$(CONFIG_BOARD) python3 $(KCONFIG_DIR)/defconfig.py Kconfig $(HV_OBJDIR)/$(HV_CONFIG); \ else \ if [ "$(KCONFIG_FILE)" != "" ] && [ -f $(KCONFIG_FILE) ]; then \ echo "Writing $(HV_OBJDIR)/$(HV_CONFIG) with $(KCONFIG_FILE)"; \ @@ -92,10 +86,10 @@ defconfig: $(KCONFIG_DEPS) .PHONY: oldconfig oldconfig: $(KCONFIG_DEPS) @mkdir -p $(HV_OBJDIR) - @BOARD=$(TARGET_BOARD) \ + @BOARD=$(CONFIG_BOARD) \ python3 $(KCONFIG_DIR)/silentoldconfig.py Kconfig \ $(HV_OBJDIR)/$(HV_CONFIG) \ - RELEASE=$(RELEASE) + SCENARIO=$(CONFIG_SCENARIO) RELEASE=$(RELEASE) # Minimize the current .config. This target can be used to generate a defconfig # for future use.