Skip to content

Commit ff65a10

Browse files
jsun26intelwenlingz
authored andcommitted
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>
1 parent 0d90515 commit ff65a10

File tree

5 files changed

+68
-81
lines changed

5 files changed

+68
-81
lines changed

hypervisor/Makefile

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,10 +133,7 @@ C_SRCS += arch/x86/init.c
133133

134134
# configuration component
135135
C_SRCS += arch/x86/configs/vm_config.c
136-
ifeq ($(CONFIG_SHARING_MODE),y)
137-
C_SRCS += arch/x86/configs/sharing_config.c
138-
else ifeq ($(CONFIG_PARTITION_MODE),y)
139-
C_SRCS += arch/x86/configs/partition_config.c
136+
ifeq ($(CONFIG_PARTITION_MODE),y)
140137
C_SRCS += arch/x86/configs/$(CONFIG_BOARD)/ve820.c
141138
C_SRCS += arch/x86/configs/$(CONFIG_BOARD)/pt_dev.c
142139
endif

hypervisor/arch/x86/configs/partition_config.c

Lines changed: 0 additions & 45 deletions
This file was deleted.

hypervisor/arch/x86/configs/sharing_config.c

Lines changed: 0 additions & 22 deletions
This file was deleted.

hypervisor/arch/x86/configs/vm_config.c

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,72 @@
88
#include <cpu.h>
99
#include <errno.h>
1010
#include <acrn_common.h>
11+
#include <page.h>
12+
#ifndef CONFIG_PARTITION_MODE
13+
#include <sos_vm.h>
14+
15+
static struct acrn_vm_config vm_configs[CONFIG_MAX_VM_NUM] __aligned(PAGE_SIZE) = {
16+
{
17+
.type = SOS_VM,
18+
.name = SOS_VM_CONFIG_NAME,
19+
.guest_flags = SOS_VM_CONFIG_GUEST_FLAGS,
20+
.memory = {
21+
.start_hpa = 0x0UL,
22+
.size = CONFIG_SOS_RAM_SIZE,
23+
},
24+
.os_config = {
25+
.name = SOS_VM_CONFIG_OS_NAME,
26+
},
27+
},
28+
};
29+
#else
30+
#include <partition_config.h>
31+
32+
#define INIT_VM_CONFIG(idx) \
33+
{ \
34+
.type = VM##idx##_CONFIG_TYPE, \
35+
.name = VM##idx##_CONFIG_NAME, \
36+
.pcpu_bitmap = VM##idx##_CONFIG_PCPU_BITMAP, \
37+
.guest_flags = VM##idx##_CONFIG_FLAGS, \
38+
.memory = { \
39+
.start_hpa = VM##idx##_CONFIG_MEM_START_HPA, \
40+
.size = VM##idx##_CONFIG_MEM_SIZE, \
41+
}, \
42+
.os_config = { \
43+
.name = VM##idx##_CONFIG_OS_NAME, \
44+
.bootargs = VM##idx##_CONFIG_OS_BOOTARGS, \
45+
}, \
46+
.vm_vuart = true, \
47+
.pci_ptdev_num = VM##idx##_CONFIG_PCI_PTDEV_NUM, \
48+
.pci_ptdevs = vm##idx##_pci_ptdevs, \
49+
}
50+
51+
static struct acrn_vm_config vm_configs[CONFIG_MAX_VM_NUM] __aligned(PAGE_SIZE) = {
52+
#ifdef VM0_CONFIGURED
53+
INIT_VM_CONFIG(0),
54+
#endif
55+
56+
#ifdef VM1_CONFIGURED
57+
INIT_VM_CONFIG(1),
58+
#endif
59+
60+
#ifdef VM2_CONFIGURED
61+
INIT_VM_CONFIG(2),
62+
#endif
63+
64+
#ifdef VM3_CONFIGURED
65+
INIT_VM_CONFIG(3),
66+
#endif
67+
};
68+
#endif
69+
70+
/*
71+
* @pre vm_id < CONFIG_MAX_VM_NUM
72+
*/
73+
struct acrn_vm_config *get_vm_config(uint16_t vm_id)
74+
{
75+
return &vm_configs[vm_id];
76+
}
1177

1278
/**
1379
* @pre vm_config != NULL

hypervisor/include/arch/x86/vm_config.h

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -64,16 +64,7 @@ struct acrn_vm_config {
6464
#endif
6565
} __aligned(8);
6666

67-
extern struct acrn_vm_config vm_configs[CONFIG_MAX_VM_NUM];
68-
69-
/*
70-
* @pre vm_id < CONFIG_MAX_VM_NUM
71-
*/
72-
static inline struct acrn_vm_config *get_vm_config(uint16_t vm_id)
73-
{
74-
return &vm_configs[vm_id];
75-
}
76-
67+
struct acrn_vm_config *get_vm_config(uint16_t vm_id);
7768
int32_t sanitize_vm_config(void);
7869

7970
#endif /* VM_CONFIG_H_ */

0 commit comments

Comments
 (0)