HV: vm_configs array refinement

- merge sharing_config.c and partition_config.c to vm_config.c;

- make vm_configs[] static;

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:
Victor Sun 2019-02-28 15:06:43 +08:00 committed by wenlingz
parent 0d90515bf6
commit ff65a10391
5 changed files with 68 additions and 81 deletions

View File

@ -133,10 +133,7 @@ C_SRCS += arch/x86/init.c
# configuration component
C_SRCS += arch/x86/configs/vm_config.c
ifeq ($(CONFIG_SHARING_MODE),y)
C_SRCS += arch/x86/configs/sharing_config.c
else ifeq ($(CONFIG_PARTITION_MODE),y)
C_SRCS += arch/x86/configs/partition_config.c
ifeq ($(CONFIG_PARTITION_MODE),y)
C_SRCS += arch/x86/configs/$(CONFIG_BOARD)/ve820.c
C_SRCS += arch/x86/configs/$(CONFIG_BOARD)/pt_dev.c
endif

View File

@ -1,45 +0,0 @@
/*
* Copyright (C) 2019 Intel Corporation. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#include <vm.h>
#include <partition_config.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, \
.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, \
},
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
};

View File

@ -1,22 +0,0 @@
/*
* Copyright (C) 2018 Intel Corporation. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#include <vm.h>
#include <sos_vm.h>
struct acrn_vm_config vm_configs[CONFIG_MAX_VM_NUM] __aligned(PAGE_SIZE) = {
{
.type = SOS_VM,
.name = SOS_VM_CONFIG_NAME,
.guest_flags = SOS_VM_CONFIG_GUEST_FLAGS,
.memory = {
.start_hpa = 0x0UL,
.size = CONFIG_SOS_RAM_SIZE,
},
.os_config = {
.name = SOS_VM_CONFIG_OS_NAME,
},
},
};

View File

@ -8,6 +8,72 @@
#include <cpu.h>
#include <errno.h>
#include <acrn_common.h>
#include <page.h>
#ifndef CONFIG_PARTITION_MODE
#include <sos_vm.h>
static struct acrn_vm_config vm_configs[CONFIG_MAX_VM_NUM] __aligned(PAGE_SIZE) = {
{
.type = SOS_VM,
.name = SOS_VM_CONFIG_NAME,
.guest_flags = SOS_VM_CONFIG_GUEST_FLAGS,
.memory = {
.start_hpa = 0x0UL,
.size = CONFIG_SOS_RAM_SIZE,
},
.os_config = {
.name = SOS_VM_CONFIG_OS_NAME,
},
},
};
#else
#include <partition_config.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, \
.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
};
#endif
/*
* @pre vm_id < CONFIG_MAX_VM_NUM
*/
struct acrn_vm_config *get_vm_config(uint16_t vm_id)
{
return &vm_configs[vm_id];
}
/**
* @pre vm_config != NULL

View File

@ -64,16 +64,7 @@ struct acrn_vm_config {
#endif
} __aligned(8);
extern struct acrn_vm_config vm_configs[CONFIG_MAX_VM_NUM];
/*
* @pre vm_id < CONFIG_MAX_VM_NUM
*/
static inline struct acrn_vm_config *get_vm_config(uint16_t vm_id)
{
return &vm_configs[vm_id];
}
struct acrn_vm_config *get_vm_config(uint16_t vm_id);
int32_t sanitize_vm_config(void);
#endif /* VM_CONFIG_H_ */