]> rtime.felk.cvut.cz Git - jailhouse.git/blob - hypervisor/include/jailhouse/cell-config.h
core/configs/tools: Report IOMMU association of devices via config file
[jailhouse.git] / hypervisor / include / jailhouse / cell-config.h
1 /*
2  * Jailhouse, a Linux-based partitioning hypervisor
3  *
4  * Copyright (c) Siemens AG, 2013
5  *
6  * Authors:
7  *  Jan Kiszka <jan.kiszka@siemens.com>
8  *
9  * This work is licensed under the terms of the GNU GPL, version 2.  See
10  * the COPYING file in the top-level directory.
11  */
12
13 #ifndef _JAILHOUSE_CELL_CONFIG_H
14 #define _JAILHOUSE_CELL_CONFIG_H
15
16 #define JAILHOUSE_CELL_NAME_MAXLEN      31
17
18 #define JAILHOUSE_CELL_PASSIVE_COMMREG  0x00000001
19
20 struct jailhouse_cell_desc {
21         char name[JAILHOUSE_CELL_NAME_MAXLEN+1];
22         __u32 flags;
23
24         __u32 cpu_set_size;
25         __u32 num_memory_regions;
26         __u32 num_irqchips;
27         __u32 pio_bitmap_size;
28         __u32 num_pci_devices;
29         __u32 num_pci_caps;
30 } __attribute__((packed));
31
32 #define JAILHOUSE_MEM_READ              0x0001
33 #define JAILHOUSE_MEM_WRITE             0x0002
34 #define JAILHOUSE_MEM_EXECUTE           0x0004
35 #define JAILHOUSE_MEM_DMA               0x0008
36 #define JAILHOUSE_MEM_COMM_REGION       0x0010
37 #define JAILHOUSE_MEM_LOADABLE          0x0020
38
39 #define JAILHOUSE_MEM_VALID_FLAGS       (JAILHOUSE_MEM_READ | \
40                                          JAILHOUSE_MEM_WRITE | \
41                                          JAILHOUSE_MEM_EXECUTE | \
42                                          JAILHOUSE_MEM_DMA | \
43                                          JAILHOUSE_MEM_COMM_REGION | \
44                                          JAILHOUSE_MEM_LOADABLE)
45
46 struct jailhouse_memory {
47         __u64 phys_start;
48         __u64 virt_start;
49         __u64 size;
50         __u64 flags;
51 } __attribute__((packed));
52
53 struct jailhouse_irqchip {
54         __u64 address;
55         __u64 id;
56         __u64 pin_bitmap;
57 } __attribute__((packed));
58
59 #define JAILHOUSE_PCI_TYPE_DEVICE       0x01
60 #define JAILHOUSE_PCI_TYPE_BRIDGE       0x02
61
62 struct jailhouse_pci_device {
63         __u8 type;
64         __u8 iommu;
65         __u16 domain;
66         __u16 bdf;
67         __u16 caps_start;
68         __u16 num_caps;
69         __u8 num_msi_vectors;
70         __u8 msi_64bits;
71         __u16 num_msix_vectors;
72         __u16 msix_region_size;
73         __u64 msix_address;
74 } __attribute__((packed));
75
76 #define JAILHOUSE_PCICAPS_WRITE         0x0001
77
78 struct jailhouse_pci_capability {
79         __u16 id;
80         __u16 start;
81         __u16 len;
82         __u16 flags;
83 } __attribute__((packed));
84
85 #define JAILHOUSE_MAX_DMAR_UNITS        8
86
87 struct jailhouse_system {
88         struct jailhouse_memory hypervisor_memory;
89         union {
90                 struct {
91                         __u64 mmconfig_base;
92                         __u8 mmconfig_end_bus;
93                         __u8 padding[5];
94                         __u16 pm_timer_address;
95                         __u64 dmar_unit_base[JAILHOUSE_MAX_DMAR_UNITS];
96                 } __attribute__((packed)) x86;
97         } __attribute__((packed)) platform_info;
98         __u32 device_limit;
99         __u32 interrupt_limit;
100         struct jailhouse_cell_desc root_cell;
101 } __attribute__((packed));
102
103 static inline __u32
104 jailhouse_cell_config_size(struct jailhouse_cell_desc *cell)
105 {
106         return sizeof(struct jailhouse_cell_desc) +
107                 cell->cpu_set_size +
108                 cell->num_memory_regions * sizeof(struct jailhouse_memory) +
109                 cell->num_irqchips * sizeof(struct jailhouse_irqchip) +
110                 cell->pio_bitmap_size +
111                 cell->num_pci_devices * sizeof(struct jailhouse_pci_device) +
112                 cell->num_pci_caps * sizeof(struct jailhouse_pci_capability);
113 }
114
115 static inline __u32
116 jailhouse_system_config_size(struct jailhouse_system *system)
117 {
118         return sizeof(*system) - sizeof(system->root_cell) +
119                 jailhouse_cell_config_size(&system->root_cell);
120 }
121
122 static inline const unsigned long *
123 jailhouse_cell_cpu_set(const struct jailhouse_cell_desc *cell)
124 {
125         return (const unsigned long *)((const void *)cell +
126                 sizeof(struct jailhouse_cell_desc));
127 }
128
129 static inline const struct jailhouse_memory *
130 jailhouse_cell_mem_regions(const struct jailhouse_cell_desc *cell)
131 {
132         return (const struct jailhouse_memory *)
133                 ((void *)jailhouse_cell_cpu_set(cell) + cell->cpu_set_size);
134 }
135
136 static inline const struct jailhouse_irqchip *
137 jailhouse_cell_irqchips(const struct jailhouse_cell_desc *cell)
138 {
139         return (const struct jailhouse_irqchip *)
140                 ((void *)jailhouse_cell_mem_regions(cell) +
141                  cell->num_memory_regions * sizeof(struct jailhouse_memory));
142 }
143
144 static inline const __u8 *
145 jailhouse_cell_pio_bitmap(const struct jailhouse_cell_desc *cell)
146 {
147         return (const __u8 *)((void *)jailhouse_cell_irqchips(cell) +
148                 cell->num_irqchips * sizeof(struct jailhouse_irqchip));
149 }
150
151 static inline const struct jailhouse_pci_device *
152 jailhouse_cell_pci_devices(const struct jailhouse_cell_desc *cell)
153 {
154         return (const struct jailhouse_pci_device *)
155                 ((void *)jailhouse_cell_pio_bitmap(cell) +
156                  cell->pio_bitmap_size);
157 }
158
159 static inline const struct jailhouse_pci_capability *
160 jailhouse_cell_pci_caps(const struct jailhouse_cell_desc *cell)
161 {
162         return (const struct jailhouse_pci_capability *)
163                 ((void *)jailhouse_cell_pci_devices(cell) +
164                  cell->num_pci_devices * sizeof(struct jailhouse_pci_device));
165 }
166
167 #endif /* !_JAILHOUSE_CELL_CONFIG_H */