mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-06-18 19:57:31 +00:00
hv: vpci: add emulated PCI device configure for SOS
Add emulated PCI device configure for SOS to prepare for add support for customizing special pci operations for each emulated PCI device. Tracked-On: #3475 Signed-off-by: Li, Fei1 <fei1.li@intel.com>
This commit is contained in:
parent
973ba5b63f
commit
ff54fa2325
@ -213,8 +213,8 @@ HW_C_SRCS += hw/pci.c
|
||||
HW_C_SRCS += arch/x86/configs/vm_config.c
|
||||
HW_C_SRCS += arch/x86/configs/$(CONFIG_BOARD)/board.c
|
||||
HW_C_SRCS += scenarios/$(SCENARIO_NAME)/vm_configurations.c
|
||||
ifneq (,$(wildcard scenarios/$(SCENARIO_NAME)/pt_dev.c))
|
||||
HW_C_SRCS += scenarios/$(SCENARIO_NAME)/pt_dev.c
|
||||
ifneq (,$(wildcard scenarios/$(SCENARIO_NAME)/pci_dev.c))
|
||||
HW_C_SRCS += scenarios/$(SCENARIO_NAME)/pci_dev.c
|
||||
endif
|
||||
HW_C_SRCS += boot/acpi_base.c
|
||||
HW_C_SRCS += boot/dmar_info.c
|
||||
|
@ -6,9 +6,21 @@
|
||||
|
||||
#include <vm_config.h>
|
||||
#include <pci.h>
|
||||
#include <pci_dev.h>
|
||||
|
||||
static uint16_t pcidev_config_num = 0U;
|
||||
static struct acrn_vm_pci_dev_config pcidev_config[CONFIG_MAX_PCI_DEV_NUM] = {};
|
||||
/*
|
||||
* In theory, emulated PCI device doesn't need to bind to physical PCI device.
|
||||
* However, now we need to search virtual PCI device by pBDF because we bind
|
||||
* post-launched VM PTDev with SOS's.
|
||||
* Remove the pBDF for emulated PCI device once we don't have this limit.
|
||||
*/
|
||||
struct acrn_vm_pci_dev_config sos_pci_devs[CONFIG_MAX_PCI_DEV_NUM] = {
|
||||
{
|
||||
.emu_type = PCI_DEV_TYPE_HVEMUL,
|
||||
.vbdf.bits = {.b = 0x00U, .d = 0x00U, .f = 0x00U},
|
||||
.pbdf.bits = {.b = 0x00U, .d = 0x00U, .f = 0x00U},
|
||||
},
|
||||
};
|
||||
|
||||
/*
|
||||
* @pre pdev != NULL;
|
||||
@ -51,23 +63,36 @@ static bool is_allocated_to_prelaunched_vm(struct pci_pdev *pdev)
|
||||
*/
|
||||
void fill_pci_dev_config(struct pci_pdev *pdev)
|
||||
{
|
||||
uint16_t vmid;
|
||||
uint32_t idx;
|
||||
struct acrn_vm_config *vm_config;
|
||||
struct acrn_vm_pci_dev_config *dev_config;
|
||||
|
||||
if (!is_allocated_to_prelaunched_vm(pdev)) {
|
||||
dev_config = &pcidev_config[pcidev_config_num];
|
||||
dev_config->emu_type = (pdev->bdf.value != HOST_BRIDGE_BDF) ? PCI_DEV_TYPE_PTDEV : PCI_DEV_TYPE_HVEMUL;
|
||||
for (vmid = 0U; vmid < CONFIG_MAX_VM_NUM; vmid++) {
|
||||
vm_config = get_vm_config(vmid);
|
||||
if (vm_config->load_order != SOS_VM) {
|
||||
continue;
|
||||
}
|
||||
|
||||
/* TODO: revert me if we could split post-launched VM's PTDev from SOS's */
|
||||
for (idx = 0U; idx < SOS_EMULATED_PCI_DEV_NUM; idx++) {
|
||||
dev_config = &vm_config->pci_devs[idx];
|
||||
if (bdf_is_equal(&dev_config->pbdf, &pdev->bdf)) {
|
||||
dev_config->pdev = pdev;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (idx == SOS_EMULATED_PCI_DEV_NUM) {
|
||||
dev_config = &vm_config->pci_devs[vm_config->pci_dev_num];
|
||||
dev_config->emu_type = PCI_DEV_TYPE_PTDEV;
|
||||
dev_config->vbdf.value = pdev->bdf.value;
|
||||
dev_config->pbdf.value = pdev->bdf.value;
|
||||
dev_config->pdev = pdev;
|
||||
pcidev_config_num++;
|
||||
vm_config->pci_dev_num++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* @pre vm_config != NULL
|
||||
*/
|
||||
void initialize_sos_pci_dev_config(struct acrn_vm_config *vm_config)
|
||||
{
|
||||
vm_config->pci_dev_num = pcidev_config_num;
|
||||
vm_config->pci_devs = pcidev_config;
|
||||
}
|
||||
|
@ -448,8 +448,6 @@ int32_t create_vm(uint16_t vm_id, struct acrn_vm_config *vm_config, struct acrn_
|
||||
status = init_vm_boot_info(vm);
|
||||
if (status != 0) {
|
||||
need_cleanup = true;
|
||||
} else {
|
||||
initialize_sos_pci_dev_config(vm_config);
|
||||
}
|
||||
} else {
|
||||
/* For PRE_LAUNCHED_VM and POST_LAUNCHED_VM */
|
||||
|
@ -7,11 +7,13 @@
|
||||
#ifndef PCI_DEV_H_
|
||||
#define PCI_DEV_H_
|
||||
|
||||
#include <vpci.h>
|
||||
#include <vm_config.h>
|
||||
|
||||
struct acrn_vm_config;
|
||||
#define SOS_EMULATED_PCI_DEV_NUM 1U
|
||||
|
||||
extern struct acrn_vm_pci_dev_config sos_pci_devs[CONFIG_MAX_PCI_DEV_NUM];
|
||||
|
||||
struct pci_pdev;
|
||||
void fill_pci_dev_config(struct pci_pdev *pdev);
|
||||
void initialize_sos_pci_dev_config(struct acrn_vm_config *vm_config);
|
||||
|
||||
#endif /* PCI_DEV_H_ */
|
||||
|
@ -6,6 +6,7 @@
|
||||
|
||||
#include <vm_config.h>
|
||||
#include <vuart.h>
|
||||
#include <pci_dev.h>
|
||||
|
||||
struct acrn_vm_config vm_configs[CONFIG_MAX_VM_NUM] = {
|
||||
{ /* VM0 */
|
||||
@ -41,6 +42,8 @@ struct acrn_vm_config vm_configs[CONFIG_MAX_VM_NUM] = {
|
||||
.t_vuart.vm_id = 1U,
|
||||
.t_vuart.vuart_id = 1U,
|
||||
},
|
||||
.pci_dev_num = SOS_EMULATED_PCI_DEV_NUM,
|
||||
.pci_devs = sos_pci_devs,
|
||||
},
|
||||
{ /* VM1 */
|
||||
.load_order = SOS_VM,
|
||||
|
@ -6,6 +6,7 @@
|
||||
|
||||
#include <vm_config.h>
|
||||
#include <vuart.h>
|
||||
#include <pci_dev.h>
|
||||
|
||||
struct acrn_vm_config vm_configs[CONFIG_MAX_VM_NUM] = {
|
||||
{
|
||||
@ -34,7 +35,9 @@ struct acrn_vm_config vm_configs[CONFIG_MAX_VM_NUM] = {
|
||||
.vuart[1] = {
|
||||
.type = VUART_LEGACY_PIO,
|
||||
.addr.port_base = INVALID_COM_BASE,
|
||||
}
|
||||
},
|
||||
.pci_dev_num = SOS_EMULATED_PCI_DEV_NUM,
|
||||
.pci_devs = sos_pci_devs,
|
||||
},
|
||||
{
|
||||
.load_order = POST_LAUNCHED_VM,
|
||||
|
@ -12,7 +12,7 @@
|
||||
* The memory range of vBAR should exactly match with the e820 layout of VM.
|
||||
*/
|
||||
|
||||
struct acrn_vm_pci_dev_config vm0_pci_devs[VM0_CONFIG_PCI_PTDEV_NUM] = {
|
||||
struct acrn_vm_pci_dev_config vm0_pci_devs[VM0_CONFIG_PCI_DEV_NUM] = {
|
||||
{
|
||||
.emu_type = PCI_DEV_TYPE_HVEMUL,
|
||||
.vbdf.bits = {.b = 0x00U, .d = 0x00U, .f = 0x00U},
|
||||
@ -29,7 +29,7 @@ struct acrn_vm_pci_dev_config vm0_pci_devs[VM0_CONFIG_PCI_PTDEV_NUM] = {
|
||||
},
|
||||
};
|
||||
|
||||
struct acrn_vm_pci_dev_config vm1_pci_devs[VM1_CONFIG_PCI_PTDEV_NUM] = {
|
||||
struct acrn_vm_pci_dev_config vm1_pci_devs[VM1_CONFIG_PCI_DEV_NUM] = {
|
||||
{
|
||||
.emu_type = PCI_DEV_TYPE_HVEMUL,
|
||||
.vbdf.bits = {.b = 0x00U, .d = 0x00U, .f = 0x00U},
|
@ -7,8 +7,8 @@
|
||||
#include <vm_config.h>
|
||||
#include <vuart.h>
|
||||
|
||||
extern struct acrn_vm_pci_dev_config vm0_pci_devs[VM0_CONFIG_PCI_PTDEV_NUM];
|
||||
extern struct acrn_vm_pci_dev_config vm1_pci_devs[VM1_CONFIG_PCI_PTDEV_NUM];
|
||||
extern struct acrn_vm_pci_dev_config vm0_pci_devs[VM0_CONFIG_PCI_DEV_NUM];
|
||||
extern struct acrn_vm_pci_dev_config vm1_pci_devs[VM1_CONFIG_PCI_DEV_NUM];
|
||||
|
||||
struct acrn_vm_config vm_configs[CONFIG_MAX_VM_NUM] = {
|
||||
{ /* VM0 */
|
||||
@ -46,7 +46,7 @@ struct acrn_vm_config vm_configs[CONFIG_MAX_VM_NUM] = {
|
||||
.t_vuart.vm_id = 1U,
|
||||
.t_vuart.vuart_id = 1U,
|
||||
},
|
||||
.pci_dev_num = VM0_CONFIG_PCI_PTDEV_NUM,
|
||||
.pci_dev_num = VM0_CONFIG_PCI_DEV_NUM,
|
||||
.pci_devs = vm0_pci_devs,
|
||||
},
|
||||
{ /* VM1 */
|
||||
@ -85,7 +85,7 @@ struct acrn_vm_config vm_configs[CONFIG_MAX_VM_NUM] = {
|
||||
.t_vuart.vm_id = 0U,
|
||||
.t_vuart.vuart_id = 1U,
|
||||
},
|
||||
.pci_dev_num = VM1_CONFIG_PCI_PTDEV_NUM,
|
||||
.pci_dev_num = VM1_CONFIG_PCI_DEV_NUM,
|
||||
.pci_devs = vm1_pci_devs,
|
||||
},
|
||||
};
|
||||
|
@ -45,7 +45,7 @@
|
||||
*/
|
||||
#define VM0_STORAGE_CONTROLLER SATA_CONTROLLER_0
|
||||
#define VM0_NETWORK_CONTROLLER ETHERNET_CONTROLLER_0
|
||||
#define VM0_CONFIG_PCI_PTDEV_NUM 3U
|
||||
#define VM0_CONFIG_PCI_DEV_NUM 3U
|
||||
|
||||
#define VM1_STORAGE_CONTROLLER USB_CONTROLLER_0
|
||||
#if defined(ETHERNET_CONTROLLER_1)
|
||||
@ -57,10 +57,10 @@
|
||||
#endif
|
||||
|
||||
#if defined(VM1_NETWORK_CONTROLLER)
|
||||
#define VM1_CONFIG_PCI_PTDEV_NUM 3U
|
||||
#define VM1_CONFIG_PCI_DEV_NUM 3U
|
||||
#else
|
||||
/* no network controller could be assigned to VM1 */
|
||||
#define VM1_CONFIG_PCI_PTDEV_NUM 2U
|
||||
#define VM1_CONFIG_PCI_DEV_NUM 2U
|
||||
#endif
|
||||
|
||||
#endif /* VM_CONFIGURATIONS_H */
|
||||
|
@ -6,6 +6,7 @@
|
||||
|
||||
#include <vm_config.h>
|
||||
#include <vuart.h>
|
||||
#include <pci_dev.h>
|
||||
|
||||
struct acrn_vm_config vm_configs[CONFIG_MAX_VM_NUM] = {
|
||||
{
|
||||
@ -36,7 +37,9 @@ struct acrn_vm_config vm_configs[CONFIG_MAX_VM_NUM] = {
|
||||
.vuart[1] = {
|
||||
.type = VUART_LEGACY_PIO,
|
||||
.addr.port_base = INVALID_COM_BASE,
|
||||
}
|
||||
},
|
||||
.pci_dev_num = SOS_EMULATED_PCI_DEV_NUM,
|
||||
.pci_devs = sos_pci_devs,
|
||||
},
|
||||
{
|
||||
.load_order = POST_LAUNCHED_VM,
|
||||
|
@ -6,6 +6,7 @@
|
||||
|
||||
#include <vm_config.h>
|
||||
#include <vuart.h>
|
||||
#include <pci_dev.h>
|
||||
|
||||
struct acrn_vm_config vm_configs[CONFIG_MAX_VM_NUM] = {
|
||||
{
|
||||
@ -36,7 +37,9 @@ struct acrn_vm_config vm_configs[CONFIG_MAX_VM_NUM] = {
|
||||
.vuart[1] = {
|
||||
.type = VUART_LEGACY_PIO,
|
||||
.addr.port_base = INVALID_COM_BASE,
|
||||
}
|
||||
},
|
||||
.pci_dev_num = SOS_EMULATED_PCI_DEV_NUM,
|
||||
.pci_devs = sos_pci_devs,
|
||||
},
|
||||
{
|
||||
.load_order = POST_LAUNCHED_VM,
|
||||
|
Loading…
Reference in New Issue
Block a user