Palacios Public Git Repository

To checkout Palacios execute

  git clone http://v3vee.org/palacios/palacios.web/palacios.git
This will give you the master branch. You probably want the devel branch or one of the release branches. To switch to the devel branch, simply execute
  cd palacios
  git checkout --track -b devel origin/devel
The other branches are similar.


updated host pci interface to support non-contiguous memory regions
[palacios.git] / palacios / include / interfaces / host_pci.h
1 /* 
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.  
5  *
6  * The V3VEE Project is a joint project between Northwestern University
7  * and the University of New Mexico.  You can find out more at 
8  * http://www.v3vee.org
9  *
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.
13  *
14  * Author: Jack Lange <jacklange@cs.pitt.edu>
15  *
16  * This is free software.  You are permitted to use,
17  * redistribute, and modify it as specified in the file "V3VEE_LICENSE".
18  */
19
20
21 #include <palacios/vmm.h>
22 #include <palacios/vmm_types.h>
23
24
25 struct v3_vm_info;
26
27 typedef enum { PT_BAR_NONE,
28                PT_BAR_IO, 
29                PT_BAR_MEM32, 
30                PT_BAR_MEM24, 
31                PT_BAR_MEM64_LO, 
32                PT_BAR_MEM64_HI,
33                PT_EXP_ROM } pt_bar_type_t;
34
35
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;
44
45 struct v3_host_pci_bar {
46     uint32_t size;
47     pt_bar_type_t type;
48
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
52      */
53     uint64_t addr; 
54
55     union {
56         uint32_t flags;
57         struct {
58             uint32_t prefetchable    : 1;
59             uint32_t cacheable       : 1;
60             uint32_t exp_rom_enabled : 1;
61             uint32_t rsvd            : 29;
62         } __attribute__((packed));
63     } __attribute__((packed));
64
65
66 };
67
68
69
70 struct v3_host_pci_dev {
71     struct v3_host_pci_bar bars[6];
72     struct v3_host_pci_bar exp_rom;
73
74     uint8_t cfg_space[256];
75
76     enum {IOMMU, SYMBIOTIC, EMULATED} iface;
77
78     int (*irq_handler)(void * guest_data, uint32_t vec_index);
79
80     void * host_data;
81     void * guest_data;
82 };
83
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 {
87     uint64_t start;
88     uint64_t end;
89 };
90
91
92 #ifdef __V3VEE__
93
94 #include <devices/pci.h>
95
96
97 struct v3_host_pci_dev * v3_host_pci_get_dev(struct v3_vm_info * vm, char * url, void * priv_data);
98
99
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);
102
103 int v3_host_pci_cmd_update(struct v3_host_pci_dev * v3_dev, pci_cmd_t cmd, uint64_t arg);
104
105 int v3_host_pci_ack_irq(struct v3_host_pci_dev * v3_dev, uint32_t vector);
106
107
108 #endif
109
110
111 struct v3_host_pci_hooks {
112     struct v3_host_pci_dev * (*request_device)(char * url, void * v3_ctx);
113
114     // emulated interface
115
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);
118
119     int (*pci_cmd)(struct v3_host_pci_dev * v3_dev, host_pci_cmd_t cmd, uint64_t arg);
120     
121     int (*ack_irq)(struct v3_host_pci_dev * v3_dev, uint32_t vector);
122
123
124 };
125
126
127
128 void V3_Init_Host_PCI(struct v3_host_pci_hooks * hooks);
129
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);
132