1 /*
2  * Copyright (C) 2022 Intel Corporation.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  */
6 
7 #include <asm/vm_config.h>
8 #include <vuart.h>
9 #include <asm/pci_dev.h>
10 #include <asm/pgtable.h>
11 #include <schedule.h>
12 
13 extern struct acrn_vm_pci_dev_config sos_pci_devs[CONFIG_MAX_PCI_DEV_NUM];
14 struct acrn_vm_config vm_configs[CONFIG_MAX_VM_NUM] = {
15 	{
16 		/* Static configured VM0 */
17 		CONFIG_SERVICE_VM,
18 		.name = "ACRN_Service_VM",
19 		/* Allow Service VM to reboot the system since it is the highest priority VM. */
20 		.sched_params =
21 			{
22 				.prio = PRIO_LOW,
23 			},
24 		.companion_vm_id = 65535U,
25 		.guest_flags = (GUEST_FLAG_STATIC_VM),
26 		.cpu_affinity = SERVICE_VM_CONFIG_CPU_AFFINITY,
27 		.os_config =
28 			{
29 				.name = "",
30 				.kernel_type = KERNEL_BZIMAGE,
31 				.kernel_mod_tag = "Linux_bzImage",
32 				.ramdisk_mod_tag = "",
33 				.bootargs = SERVICE_VM_OS_BOOTARGS,
34 			},
35 		.vuart[0] =
36 			{
37 				.type = VUART_LEGACY_PIO,
38 				.addr.port_base = 0x3F8U,
39 				.irq = 4U,
40 			},
41 		.vuart[1] =
42 			{
43 				.irq = 3U,
44 				.type = VUART_LEGACY_PIO,
45 				.addr.port_base = 0x2F8U,
46 				.t_vuart.vm_id = 1U,
47 				.t_vuart.vuart_id = 1U,
48 			},
49 		.vuart[2] =
50 			{
51 				.irq = 4U,
52 				.type = VUART_LEGACY_PIO,
53 				.addr.port_base = 0x3E8U,
54 				.t_vuart.vm_id = 2U,
55 				.t_vuart.vuart_id = 1U,
56 			},
57 		.vuart[3] =
58 			{
59 				.irq = 0U,
60 				.type = VUART_LEGACY_PIO,
61 				.addr.port_base = 0X9000U,
62 				.t_vuart.vm_id = 1U,
63 				.t_vuart.vuart_id = 2U,
64 			},
65 		.vuart[4] =
66 			{
67 				.irq = 0U,
68 				.type = VUART_LEGACY_PIO,
69 				.addr.port_base = 0X9008U,
70 				.t_vuart.vm_id = 2U,
71 				.t_vuart.vuart_id = 2U,
72 			},
73 		.pci_dev_num = 0U,
74 		.pci_devs = sos_pci_devs,
75 	},
76 	{
77 		/* Static configured VM1 */
78 		CONFIG_POST_STD_VM,
79 		.name = "POST_STD_VM1",
80 		.sched_params =
81 			{
82 				.prio = PRIO_LOW,
83 			},
84 		.companion_vm_id = 65535U,
85 		.guest_flags = (GUEST_FLAG_STATIC_VM),
86 		.cpu_affinity = VM1_CONFIG_CPU_AFFINITY,
87 		.vuart[0] =
88 			{
89 				.type = VUART_LEGACY_PIO,
90 				.addr.port_base = 0x3F8U,
91 				.irq = 4U,
92 			},
93 		.vuart[1] =
94 			{
95 				.irq = 3U,
96 				.type = VUART_LEGACY_PIO,
97 				.t_vuart.vm_id = 0U,
98 				.t_vuart.vuart_id = 1U,
99 				.addr.port_base = 0x2F8U,
100 			},
101 		.vuart[2] =
102 			{
103 				.irq = 3U,
104 				.type = VUART_LEGACY_PIO,
105 				.t_vuart.vm_id = 0U,
106 				.t_vuart.vuart_id = 3U,
107 				.addr.port_base = 0x2F8U,
108 			},
109 	},
110 	{
111 		/* Static configured VM2 */
112 		CONFIG_POST_RT_VM,
113 		.name = "POST_RT_VM1",
114 		.sched_params =
115 			{
116 				.prio = PRIO_LOW,
117 			},
118 		.companion_vm_id = 65535U,
119 		.guest_flags = (GUEST_FLAG_LAPIC_PASSTHROUGH | GUEST_FLAG_RT | GUEST_FLAG_STATIC_VM),
120 		.cpu_affinity = VM2_CONFIG_CPU_AFFINITY,
121 		.vuart[0] =
122 			{
123 				.type = VUART_LEGACY_PIO,
124 				.addr.port_base = 0x3F8U,
125 				.irq = 4U,
126 			},
127 		.vuart[1] =
128 			{
129 				.irq = 4U,
130 				.type = VUART_LEGACY_PIO,
131 				.t_vuart.vm_id = 0U,
132 				.t_vuart.vuart_id = 2U,
133 				.addr.port_base = 0x3E8U,
134 			},
135 		.vuart[2] =
136 			{
137 				.irq = 3U,
138 				.type = VUART_LEGACY_PIO,
139 				.t_vuart.vm_id = 0U,
140 				.t_vuart.vuart_id = 4U,
141 				.addr.port_base = 0x2F8U,
142 			},
143 	},
144 	{
145 		/* Dynamic configured  VM3 */
146 		CONFIG_POST_STD_VM,
147 	},
148 	{
149 		/* Dynamic configured  VM4 */
150 		CONFIG_POST_STD_VM,
151 	},
152 	{
153 		/* Dynamic configured  VM5 */
154 		CONFIG_POST_STD_VM,
155 	},
156 	{
157 		/* Dynamic configured  VM6 */
158 		CONFIG_POST_STD_VM,
159 	},
160 	{
161 		/* Dynamic configured  VM7 */
162 		CONFIG_POST_STD_VM,
163 	},
164 	{
165 		/* Dynamic configured  VM8 */
166 		CONFIG_POST_STD_VM,
167 	},
168 	{
169 		/* Dynamic configured  VM9 */
170 		CONFIG_POST_STD_VM,
171 	},
172 	{
173 		/* Dynamic configured  VM10 */
174 		CONFIG_POST_STD_VM,
175 	},
176 	{
177 		/* Dynamic configured  VM11 */
178 		CONFIG_POST_STD_VM,
179 	},
180 	{
181 		/* Dynamic configured  VM12 */
182 		CONFIG_POST_STD_VM,
183 	},
184 	{
185 		/* Dynamic configured  VM13 */
186 		CONFIG_POST_STD_VM,
187 	},
188 	{
189 		/* Dynamic configured  VM14 */
190 		CONFIG_POST_STD_VM,
191 	},
192 	{
193 		/* Dynamic configured  VM15 */
194 		CONFIG_POST_STD_VM,
195 	}
196 
197 };
198