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