2 * This file is part of the Palacios Virtual Machine Monitor developed
3 * by the V3VEE Project with funding from the United States National
4 * Science Foundation and the Department of Energy.
6 * The V3VEE Project is a joint project between Northwestern University
7 * and the University of New Mexico. You can find out more at
10 * Copyright (c) 2012, Jack Lange <jacklange@cs.pitt.edu>
11 * Copyright (c) 2012, The V3VEE Project <http://www.v3vee.org>
12 * All rights reserved.
14 * Author: Jack Lange <jacklange@cs.pitt.edu>
16 * This is free software. You are permitted to use,
17 * redistribute, and modify it as specified in the file "V3VEE_LICENSE".
21 #include <palacios/vmm.h>
22 #include <palacios/vmm_types.h>
27 typedef enum { PT_BAR_NONE,
33 PT_EXP_ROM } pt_bar_type_t;
36 typedef enum { HOST_PCI_CMD_DMA_DISABLE = 1,
37 HOST_PCI_CMD_DMA_ENABLE = 2,
38 HOST_PCI_CMD_INTX_DISABLE = 3,
39 HOST_PCI_CMD_INTX_ENABLE = 4,
40 HOST_PCI_CMD_MSI_DISABLE = 5,
41 HOST_PCI_CMD_MSI_ENABLE = 6,
42 HOST_PCI_CMD_MSIX_DISABLE = 7,
43 HOST_PCI_CMD_MSIX_ENABLE = 8 } host_pci_cmd_t;
45 struct v3_host_pci_bar {
49 /* We store 64 bit memory bar addresses in the high BAR
50 * because they are the last to be updated
51 * This means that the addr field must be 64 bits
58 uint32_t prefetchable : 1;
59 uint32_t cacheable : 1;
60 uint32_t exp_rom_enabled : 1;
62 } __attribute__((packed));
63 } __attribute__((packed));
70 struct v3_host_pci_dev {
71 struct v3_host_pci_bar bars[6];
72 struct v3_host_pci_bar exp_rom;
74 uint8_t cfg_space[256];
76 enum {IOMMU, SYMBIOTIC, EMULATED} iface;
78 int (*irq_handler)(void * guest_data, uint32_t vec_index);
84 // For now we just support the single contiguous region
85 // This can be updated in the future to support non-contiguous guests
86 struct v3_guest_mem_region {
94 #include <devices/pci.h>
97 struct v3_host_pci_dev * v3_host_pci_get_dev(struct v3_vm_info * vm, char * url, void * priv_data);
100 int v3_host_pci_config_write(struct v3_host_pci_dev * v3_dev, uint32_t reg_num, void * src, uint32_t length);
101 int v3_host_pci_config_read(struct v3_host_pci_dev * v3_dev, uint32_t reg_num, void * dst, uint32_t length);
103 int v3_host_pci_cmd_update(struct v3_host_pci_dev * v3_dev, pci_cmd_t cmd, uint64_t arg);
105 int v3_host_pci_ack_irq(struct v3_host_pci_dev * v3_dev, uint32_t vector);
111 struct v3_host_pci_hooks {
112 struct v3_host_pci_dev * (*request_device)(char * url, void * v3_ctx);
114 // emulated interface
116 int (*config_write)(struct v3_host_pci_dev * v3_dev, uint32_t reg_num, void * src, uint32_t length);
117 int (*config_read)(struct v3_host_pci_dev * v3_dev, uint32_t reg_num, void * dst, uint32_t length);
119 int (*pci_cmd)(struct v3_host_pci_dev * v3_dev, host_pci_cmd_t cmd, uint64_t arg);
121 int (*ack_irq)(struct v3_host_pci_dev * v3_dev, uint32_t vector);
128 void V3_Init_Host_PCI(struct v3_host_pci_hooks * hooks);
130 int V3_get_guest_mem_region(struct v3_vm_info * vm, struct v3_guest_mem_region * region, uint64_t gpa);
131 int V3_host_pci_raise_irq(struct v3_host_pci_dev * v3_dev, uint32_t vec_index);