]> rtime.felk.cvut.cz Git - jailhouse.git/blob - hypervisor/include/jailhouse/cell-config.h
configs/tools: Provide MSI parameters via config
[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         __u32 type;
64         __u16 domain;
65         __u16 bdf;
66         __u16 caps_start;
67         __u16 num_caps;
68         __u8 num_msi_vectors;
69         __u8 msi_64bits;
70         __u16 padding;
71 } __attribute__((packed));
72
73 #define JAILHOUSE_PCICAPS_WRITE         0x0001
74
75 struct jailhouse_pci_capability {
76         __u16 id;
77         __u16 start;
78         __u16 len;
79         __u16 flags;
80 } __attribute__((packed));
81
82 #define JAILHOUSE_MAX_DMAR_UNITS        8
83
84 struct jailhouse_system {
85         struct jailhouse_memory hypervisor_memory;
86         union {
87                 struct {
88                         __u64 mmconfig_base;
89                         __u8 mmconfig_end_bus;
90                         __u8 padding[5];
91                         __u16 pm_timer_address;
92                         __u64 dmar_unit_base[JAILHOUSE_MAX_DMAR_UNITS];
93                 } x86;
94         } platform_info;
95         struct jailhouse_cell_desc root_cell;
96 } __attribute__((packed));
97
98 static inline __u32
99 jailhouse_cell_config_size(struct jailhouse_cell_desc *cell)
100 {
101         return sizeof(struct jailhouse_cell_desc) +
102                 cell->cpu_set_size +
103                 cell->num_memory_regions * sizeof(struct jailhouse_memory) +
104                 cell->num_irqchips * sizeof(struct jailhouse_irqchip) +
105                 cell->pio_bitmap_size +
106                 cell->num_pci_devices * sizeof(struct jailhouse_pci_device) +
107                 cell->num_pci_caps * sizeof(struct jailhouse_pci_capability);
108 }
109
110 static inline __u32
111 jailhouse_system_config_size(struct jailhouse_system *system)
112 {
113         return sizeof(*system) - sizeof(system->root_cell) +
114                 jailhouse_cell_config_size(&system->root_cell);
115 }
116
117 static inline const unsigned long *
118 jailhouse_cell_cpu_set(const struct jailhouse_cell_desc *cell)
119 {
120         return (const unsigned long *)((const void *)cell +
121                 sizeof(struct jailhouse_cell_desc));
122 }
123
124 static inline const struct jailhouse_memory *
125 jailhouse_cell_mem_regions(const struct jailhouse_cell_desc *cell)
126 {
127         return (const struct jailhouse_memory *)
128                 ((void *)jailhouse_cell_cpu_set(cell) + cell->cpu_set_size);
129 }
130
131 static inline const struct jailhouse_irqchip *
132 jailhouse_cell_irqchips(const struct jailhouse_cell_desc *cell)
133 {
134         return (const struct jailhouse_irqchip *)
135                 ((void *)jailhouse_cell_mem_regions(cell) +
136                  cell->num_memory_regions * sizeof(struct jailhouse_memory));
137 }
138
139 static inline const __u8 *
140 jailhouse_cell_pio_bitmap(const struct jailhouse_cell_desc *cell)
141 {
142         return (const __u8 *)((void *)jailhouse_cell_irqchips(cell) +
143                 cell->num_irqchips * sizeof(struct jailhouse_irqchip));
144 }
145
146 static inline const struct jailhouse_pci_device *
147 jailhouse_cell_pci_devices(const struct jailhouse_cell_desc *cell)
148 {
149         return (const struct jailhouse_pci_device *)
150                 ((void *)jailhouse_cell_pio_bitmap(cell) +
151                  cell->pio_bitmap_size);
152 }
153
154 static inline const struct jailhouse_pci_capability *
155 jailhouse_cell_pci_caps(const struct jailhouse_cell_desc *cell)
156 {
157         return (const struct jailhouse_pci_capability *)
158                 ((void *)jailhouse_cell_pci_devices(cell) +
159                  cell->num_pci_devices * sizeof(struct jailhouse_pci_device));
160 }
161
162 #endif /* !_JAILHOUSE_CELL_CONFIG_H */