mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-06-20 04:33:55 +00:00
HV: use separated vm_config.c for each scenario
Previously we use unified vm_config.c for all scenarios and use MACROs for each configuration items, then the initialization of vm_configs[] becomes more complicated when definition of MACROs increase, so change the coding style that all configurable items could be explicitly shown in vm_configuration.c to make code more readable. Tracked-On: #2291 Signed-off-by: Victor Sun <victor.sun@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
parent
d8cec9f9c4
commit
d3e4f69595
@ -147,7 +147,11 @@ C_SRCS += arch/x86/seed/seed_sbl.c
|
|||||||
C_SRCS += arch/x86/configs/vm_config.c
|
C_SRCS += arch/x86/configs/vm_config.c
|
||||||
C_SRCS += arch/x86/configs/$(CONFIG_BOARD)/ve820.c
|
C_SRCS += arch/x86/configs/$(CONFIG_BOARD)/ve820.c
|
||||||
C_SRCS += arch/x86/configs/$(CONFIG_BOARD)/board.c
|
C_SRCS += arch/x86/configs/$(CONFIG_BOARD)/board.c
|
||||||
|
C_SRCS += scenarios/$(SCENARIO_NAME)/vm_configurations.c
|
||||||
|
ifneq (,$(wildcard scenarios/$(SCENARIO_NAME)/pt_dev.c))
|
||||||
C_SRCS += scenarios/$(SCENARIO_NAME)/pt_dev.c
|
C_SRCS += scenarios/$(SCENARIO_NAME)/pt_dev.c
|
||||||
|
endif
|
||||||
|
|
||||||
|
|
||||||
C_SRCS += boot/acpi.c
|
C_SRCS += boot/acpi.c
|
||||||
C_SRCS += boot/dmar_parse.c
|
C_SRCS += boot/dmar_parse.c
|
||||||
|
@ -5,51 +5,11 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <vm_config.h>
|
#include <vm_config.h>
|
||||||
#include <cpu.h>
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <acrn_common.h>
|
#include <acrn_common.h>
|
||||||
#include <page.h>
|
#include <page.h>
|
||||||
#include <logmsg.h>
|
#include <logmsg.h>
|
||||||
#include <cat.h>
|
#include <cat.h>
|
||||||
#include <vm_configurations.h>
|
|
||||||
|
|
||||||
#define INIT_VM_CONFIG(idx) \
|
|
||||||
{ \
|
|
||||||
.type = VM##idx##_CONFIG_TYPE, \
|
|
||||||
.name = VM##idx##_CONFIG_NAME, \
|
|
||||||
.pcpu_bitmap = VM##idx##_CONFIG_PCPU_BITMAP, \
|
|
||||||
.guest_flags = VM##idx##_CONFIG_FLAGS, \
|
|
||||||
.clos = VM##idx##_CONFIG_CLOS, \
|
|
||||||
.memory = { \
|
|
||||||
.start_hpa = VM##idx##_CONFIG_MEM_START_HPA, \
|
|
||||||
.size = VM##idx##_CONFIG_MEM_SIZE, \
|
|
||||||
}, \
|
|
||||||
.os_config = { \
|
|
||||||
.name = VM##idx##_CONFIG_OS_NAME, \
|
|
||||||
.bootargs = VM##idx##_CONFIG_OS_BOOTARGS, \
|
|
||||||
}, \
|
|
||||||
.vm_vuart = true, \
|
|
||||||
.pci_ptdev_num = VM##idx##_CONFIG_PCI_PTDEV_NUM, \
|
|
||||||
.pci_ptdevs = vm##idx##_pci_ptdevs, \
|
|
||||||
}
|
|
||||||
|
|
||||||
static struct acrn_vm_config vm_configs[CONFIG_MAX_VM_NUM] __aligned(PAGE_SIZE) = {
|
|
||||||
#ifdef VM0_CONFIGURED
|
|
||||||
INIT_VM_CONFIG(0),
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef VM1_CONFIGURED
|
|
||||||
INIT_VM_CONFIG(1),
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef VM2_CONFIGURED
|
|
||||||
INIT_VM_CONFIG(2),
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef VM3_CONFIGURED
|
|
||||||
INIT_VM_CONFIG(3),
|
|
||||||
#endif
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @pre vm_id < CONFIG_MAX_VM_NUM
|
* @pre vm_id < CONFIG_MAX_VM_NUM
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
#include <pci.h>
|
#include <pci.h>
|
||||||
#include <multiboot.h>
|
#include <multiboot.h>
|
||||||
#include <acrn_common.h>
|
#include <acrn_common.h>
|
||||||
|
#include <vm_configurations.h>
|
||||||
|
|
||||||
#define PLUG_CPU(n) (1U << (n))
|
#define PLUG_CPU(n) (1U << (n))
|
||||||
|
|
||||||
@ -64,4 +65,6 @@ struct acrn_vm_config {
|
|||||||
struct acrn_vm_config *get_vm_config(uint16_t vm_id);
|
struct acrn_vm_config *get_vm_config(uint16_t vm_id);
|
||||||
int32_t sanitize_vm_config(void);
|
int32_t sanitize_vm_config(void);
|
||||||
|
|
||||||
|
extern struct acrn_vm_config vm_configs[CONFIG_MAX_VM_NUM];
|
||||||
|
|
||||||
#endif /* VM_CONFIG_H_ */
|
#endif /* VM_CONFIG_H_ */
|
||||||
|
61
hypervisor/scenarios/logical_partition/vm_configurations.c
Normal file
61
hypervisor/scenarios/logical_partition/vm_configurations.c
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2018 Intel Corporation. All rights reserved.
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: BSD-3-Clause
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <vm_config.h>
|
||||||
|
#include <vm_configurations.h>
|
||||||
|
#include <acrn_common.h>
|
||||||
|
|
||||||
|
extern struct acrn_vm_pci_ptdev_config vm0_pci_ptdevs[VM0_CONFIG_PCI_PTDEV_NUM];
|
||||||
|
extern struct acrn_vm_pci_ptdev_config vm1_pci_ptdevs[VM1_CONFIG_PCI_PTDEV_NUM];
|
||||||
|
|
||||||
|
struct acrn_vm_config vm_configs[CONFIG_MAX_VM_NUM] = {
|
||||||
|
{ /* VM0 */
|
||||||
|
.type = PRE_LAUNCHED_VM,
|
||||||
|
.name = "ACRN PRE-LAUNCHED VM0",
|
||||||
|
.pcpu_bitmap = VM0_CONFIG_PCPU_BITMAP,
|
||||||
|
.guest_flags = GUEST_FLAG_IO_COMPLETION_POLLING,
|
||||||
|
.clos = 0U,
|
||||||
|
.memory = {
|
||||||
|
.start_hpa = VM0_CONFIG_MEM_START_HPA,
|
||||||
|
.size = VM0_CONFIG_MEM_SIZE,
|
||||||
|
},
|
||||||
|
.os_config = {
|
||||||
|
.name = "ClearLinux",
|
||||||
|
.bootargs = VM0_CONFIG_OS_BOOTARG_CONSOLE \
|
||||||
|
VM0_CONFIG_OS_BOOTARG_MAXCPUS \
|
||||||
|
VM0_CONFIG_OS_BOOTARG_ROOT \
|
||||||
|
"rw rootwait noxsave nohpet console=hvc0 \
|
||||||
|
no_timer_check ignore_loglevel log_buf_len=16M \
|
||||||
|
consoleblank=0 tsc=reliable xapic_phys"
|
||||||
|
},
|
||||||
|
.vm_vuart = true,
|
||||||
|
.pci_ptdev_num = VM0_CONFIG_PCI_PTDEV_NUM,
|
||||||
|
.pci_ptdevs = vm0_pci_ptdevs,
|
||||||
|
},
|
||||||
|
{ /* VM1 */
|
||||||
|
.type = PRE_LAUNCHED_VM,
|
||||||
|
.name = "ACRN PRE-LAUNCHED VM1",
|
||||||
|
.pcpu_bitmap = VM1_CONFIG_PCPU_BITMAP,
|
||||||
|
.guest_flags = GUEST_FLAG_IO_COMPLETION_POLLING,
|
||||||
|
.clos = 0U,
|
||||||
|
.memory = {
|
||||||
|
.start_hpa = VM1_CONFIG_MEM_START_HPA,
|
||||||
|
.size = VM1_CONFIG_MEM_SIZE,
|
||||||
|
},
|
||||||
|
.os_config = {
|
||||||
|
.name = "ClearLinux",
|
||||||
|
.bootargs = VM1_CONFIG_OS_BOOTARG_CONSOLE \
|
||||||
|
VM1_CONFIG_OS_BOOTARG_MAXCPUS \
|
||||||
|
VM1_CONFIG_OS_BOOTARG_ROOT \
|
||||||
|
"rw rootwait noxsave nohpet console=hvc0 \
|
||||||
|
no_timer_check ignore_loglevel log_buf_len=16M \
|
||||||
|
consoleblank=0 tsc=reliable xapic_phys"
|
||||||
|
},
|
||||||
|
.vm_vuart = true,
|
||||||
|
.pci_ptdev_num = VM1_CONFIG_PCI_PTDEV_NUM,
|
||||||
|
.pci_ptdevs = vm1_pci_ptdevs,
|
||||||
|
},
|
||||||
|
};
|
@ -7,8 +7,6 @@
|
|||||||
#ifndef VM_CONFIGURATIONS_H
|
#ifndef VM_CONFIGURATIONS_H
|
||||||
#define VM_CONFIGURATIONS_H
|
#define VM_CONFIGURATIONS_H
|
||||||
|
|
||||||
#include <pci_devices.h>
|
|
||||||
|
|
||||||
/* The VM CONFIGs like:
|
/* The VM CONFIGs like:
|
||||||
* VMX_CONFIG_PCPU_BITMAP
|
* VMX_CONFIG_PCPU_BITMAP
|
||||||
* VMX_CONFIG_MEM_START_HPA
|
* VMX_CONFIG_MEM_START_HPA
|
||||||
@ -19,53 +17,20 @@
|
|||||||
* might be different on your board, please modify them per your needs.
|
* might be different on your board, please modify them per your needs.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define VM0_CONFIGURED
|
|
||||||
|
|
||||||
#define VM0_CONFIG_NAME "ACRN PRE-LAUNCHED VM0"
|
|
||||||
#define VM0_CONFIG_TYPE PRE_LAUNCHED_VM
|
|
||||||
#define VM0_CONFIG_PCPU_BITMAP (PLUG_CPU(0) | PLUG_CPU(2))
|
#define VM0_CONFIG_PCPU_BITMAP (PLUG_CPU(0) | PLUG_CPU(2))
|
||||||
#define VM0_CONFIG_FLAGS GUEST_FLAG_IO_COMPLETION_POLLING
|
|
||||||
#define VM0_CONFIG_CLOS 0U
|
|
||||||
#define VM0_CONFIG_MEM_START_HPA 0x100000000UL
|
#define VM0_CONFIG_MEM_START_HPA 0x100000000UL
|
||||||
#define VM0_CONFIG_MEM_SIZE 0x20000000UL
|
#define VM0_CONFIG_MEM_SIZE 0x20000000UL
|
||||||
|
|
||||||
#define VM0_CONFIG_OS_NAME "ClearLinux"
|
|
||||||
#define VM0_CONFIG_OS_BOOTARG_ROOT "root=/dev/sda3 "
|
#define VM0_CONFIG_OS_BOOTARG_ROOT "root=/dev/sda3 "
|
||||||
#define VM0_CONFIG_OS_BOOTARG_MAX_CPUS "max_cpus=2 "
|
#define VM0_CONFIG_OS_BOOTARG_MAXCPUS "maxcpus=2 "
|
||||||
#define VM0_CONFIG_OS_BOOTARG_CONSOLE "console=ttyS2 "
|
#define VM0_CONFIG_OS_BOOTARG_CONSOLE "console=ttyS2 "
|
||||||
#define VM0_CONFIG_OS_BOOTARGS VM0_CONFIG_OS_BOOTARG_CONSOLE \
|
#define VM0_CONFIG_PCI_PTDEV_NUM 3U
|
||||||
VM0_CONFIG_OS_BOOTARG_ROOT \
|
|
||||||
VM0_CONFIG_OS_BOOTARG_MAX_CPUS \
|
|
||||||
"rw rootwait noxsave nohpet console=hvc0 \
|
|
||||||
no_timer_check ignore_loglevel log_buf_len=16M \
|
|
||||||
consoleblank=0 tsc=reliable xapic_phys"
|
|
||||||
|
|
||||||
#define VM1_CONFIGURED
|
|
||||||
|
|
||||||
#define VM1_CONFIG_NAME "ACRN PRE-LAUNCHED VM1"
|
|
||||||
#define VM1_CONFIG_TYPE PRE_LAUNCHED_VM
|
|
||||||
#define VM1_CONFIG_PCPU_BITMAP (PLUG_CPU(1) | PLUG_CPU(3))
|
#define VM1_CONFIG_PCPU_BITMAP (PLUG_CPU(1) | PLUG_CPU(3))
|
||||||
#define VM1_CONFIG_FLAGS GUEST_FLAG_IO_COMPLETION_POLLING
|
|
||||||
#define VM1_CONFIG_CLOS 0U
|
|
||||||
#define VM1_CONFIG_MEM_START_HPA 0x120000000UL
|
#define VM1_CONFIG_MEM_START_HPA 0x120000000UL
|
||||||
#define VM1_CONFIG_MEM_SIZE 0x20000000UL
|
#define VM1_CONFIG_MEM_SIZE 0x20000000UL
|
||||||
|
|
||||||
#define VM1_CONFIG_OS_NAME "ClearLinux"
|
|
||||||
#define VM1_CONFIG_OS_BOOTARG_ROOT "root=/dev/sda3 "
|
#define VM1_CONFIG_OS_BOOTARG_ROOT "root=/dev/sda3 "
|
||||||
#define VM1_CONFIG_OS_BOOTARG_MAX_CPUS "max_cpus=2 "
|
#define VM1_CONFIG_OS_BOOTARG_MAXCPUS "maxcpus=2 "
|
||||||
#define VM1_CONFIG_OS_BOOTARG_CONSOLE "console=ttyS2 "
|
#define VM1_CONFIG_OS_BOOTARG_CONSOLE "console=ttyS2 "
|
||||||
#define VM1_CONFIG_OS_BOOTARGS VM1_CONFIG_OS_BOOTARG_CONSOLE \
|
|
||||||
VM1_CONFIG_OS_BOOTARG_ROOT \
|
|
||||||
VM1_CONFIG_OS_BOOTARG_MAX_CPUS \
|
|
||||||
"rw rootwait noxsave nohpet console=hvc0 \
|
|
||||||
no_timer_check ignore_loglevel log_buf_len=16M \
|
|
||||||
consoleblank=0 tsc=reliable xapic_phys"
|
|
||||||
|
|
||||||
|
|
||||||
#define VM0_CONFIG_PCI_PTDEV_NUM 3U
|
|
||||||
extern struct acrn_vm_pci_ptdev_config vm0_pci_ptdevs[VM0_CONFIG_PCI_PTDEV_NUM];
|
|
||||||
|
|
||||||
#define VM1_CONFIG_PCI_PTDEV_NUM 3U
|
#define VM1_CONFIG_PCI_PTDEV_NUM 3U
|
||||||
extern struct acrn_vm_pci_ptdev_config vm1_pci_ptdevs[VM0_CONFIG_PCI_PTDEV_NUM];
|
|
||||||
|
|
||||||
#endif /* VM_CONFIGURATIONS_H */
|
#endif /* VM_CONFIGURATIONS_H */
|
||||||
|
@ -1,10 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2019 Intel Corporation. All rights reserved.
|
|
||||||
*
|
|
||||||
* SPDX-License-Identifier: BSD-3-Clause
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <vm_config.h>
|
|
||||||
#include <vm_configurations.h>
|
|
||||||
|
|
||||||
__unused struct acrn_vm_pci_ptdev_config vm0_pci_ptdevs[VM0_CONFIG_PCI_PTDEV_NUM];
|
|
25
hypervisor/scenarios/sdc/vm_configurations.c
Normal file
25
hypervisor/scenarios/sdc/vm_configurations.c
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2018 Intel Corporation. All rights reserved.
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: BSD-3-Clause
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <vm_config.h>
|
||||||
|
#include <vm_configurations.h>
|
||||||
|
#include <acrn_common.h>
|
||||||
|
|
||||||
|
struct acrn_vm_config vm_configs[CONFIG_MAX_VM_NUM] = {
|
||||||
|
{
|
||||||
|
.type = SOS_VM,
|
||||||
|
.name = "ACRN SOS VM",
|
||||||
|
.guest_flags = GUEST_FLAG_IO_COMPLETION_POLLING,
|
||||||
|
.clos = 0U,
|
||||||
|
.memory = {
|
||||||
|
.start_hpa = 0UL,
|
||||||
|
.size = CONFIG_SOS_RAM_SIZE,
|
||||||
|
},
|
||||||
|
.os_config = {
|
||||||
|
.name = "ACRN Service OS",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
@ -4,26 +4,7 @@
|
|||||||
* SPDX-License-Identifier: BSD-3-Clause
|
* SPDX-License-Identifier: BSD-3-Clause
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
|
||||||
* This is a template of vm_configurations.h for sharing mode;
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef VM_CONFIGURATIONS_H
|
#ifndef VM_CONFIGURATIONS_H
|
||||||
#define VM_CONFIGURATIONS_H
|
#define VM_CONFIGURATIONS_H
|
||||||
|
|
||||||
#define VM0_CONFIGURED
|
|
||||||
|
|
||||||
#define VM0_CONFIG_NAME "ACRN SOS VM"
|
|
||||||
#define VM0_CONFIG_TYPE SOS_VM
|
|
||||||
#define VM0_CONFIG_PCPU_BITMAP 0UL /* PCPU Bitmap is reserved in SOS_VM */
|
|
||||||
#define VM0_CONFIG_FLAGS GUEST_FLAG_IO_COMPLETION_POLLING
|
|
||||||
#define VM0_CONFIG_CLOS 0U
|
|
||||||
#define VM0_CONFIG_MEM_START_HPA 0UL
|
|
||||||
#define VM0_CONFIG_MEM_SIZE CONFIG_SOS_RAM_SIZE
|
|
||||||
#define VM0_CONFIG_OS_NAME "ACRN Service OS"
|
|
||||||
#define VM0_CONFIG_OS_BOOTARGS "configured in devicemodel/samples/apl-mrb/sos_bootargs_xxxx.txt"
|
|
||||||
|
|
||||||
#define VM0_CONFIG_PCI_PTDEV_NUM 0U /* PTDEV is reserved in SOS_VM */
|
|
||||||
extern struct acrn_vm_pci_ptdev_config vm0_pci_ptdevs[VM0_CONFIG_PCI_PTDEV_NUM];
|
|
||||||
|
|
||||||
#endif /* VM_CONFIGURATIONS_H */
|
#endif /* VM_CONFIGURATIONS_H */
|
||||||
|
Loading…
Reference in New Issue
Block a user