]> rtime.felk.cvut.cz Git - jailhouse.git/blob - hypervisor/include/jailhouse/cell-config.h
core/configs: Rename cell flag "Unmanaged Exit" to "Passive Comm Region"
[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_irq_lines;
27         __u32 pio_bitmap_size;
28         __u32 num_pci_devices;
29
30         __u32 padding[2];
31 };
32
33 #define JAILHOUSE_MEM_READ              0x0001
34 #define JAILHOUSE_MEM_WRITE             0x0002
35 #define JAILHOUSE_MEM_EXECUTE           0x0004
36 #define JAILHOUSE_MEM_DMA               0x0008
37 #define JAILHOUSE_MEM_COMM_REGION       0x0010
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
45 struct jailhouse_memory {
46         __u64 phys_start;
47         __u64 virt_start;
48         __u64 size;
49         __u64 flags;
50 };
51
52 struct jailhouse_irq_line {
53         __u32 num;
54         __u32 irqchip;
55 };
56
57 #define JAILHOUSE_PCI_TYPE_DEVICE       0x01
58 #define JAILHOUSE_PCI_TYPE_BRIDGE       0x02
59
60 struct jailhouse_pci_device {
61         __u32 type;
62         __u16 domain;
63         __u8 bus;
64         __u8 devfn;
65 } __attribute__((packed));
66
67 struct jailhouse_system {
68         struct jailhouse_memory hypervisor_memory;
69         struct jailhouse_memory config_memory;
70         struct jailhouse_cell_desc system;
71 };
72
73 static inline __u32
74 jailhouse_cell_config_size(struct jailhouse_cell_desc *cell)
75 {
76         return sizeof(struct jailhouse_cell_desc) +
77                 cell->cpu_set_size +
78                 cell->num_memory_regions * sizeof(struct jailhouse_memory) +
79                 cell->num_irq_lines * sizeof(struct jailhouse_irq_line) +
80                 cell->pio_bitmap_size +
81                 cell->num_pci_devices * sizeof(struct jailhouse_pci_device);
82 }
83
84 static inline __u32
85 jailhouse_system_config_size(struct jailhouse_system *system)
86 {
87         return sizeof(system->hypervisor_memory) +
88                 sizeof(system->config_memory) +
89                 jailhouse_cell_config_size(&system->system);
90 }
91
92 static inline const unsigned long *
93 jailhouse_cell_cpu_set(const struct jailhouse_cell_desc *cell)
94 {
95         return (const unsigned long *)((const void *)cell +
96                 sizeof(struct jailhouse_cell_desc));
97 }
98
99 static inline const struct jailhouse_memory *
100 jailhouse_cell_mem_regions(const struct jailhouse_cell_desc *cell)
101 {
102         return (const struct jailhouse_memory *)((void *)cell +
103                 sizeof(struct jailhouse_cell_desc) + cell->cpu_set_size);
104 }
105
106 static inline const __u8 *
107 jailhouse_cell_pio_bitmap(const struct jailhouse_cell_desc *cell)
108 {
109         return (const __u8 *)((void *)cell +
110                 sizeof(struct jailhouse_cell_desc) + cell->cpu_set_size +
111                 cell->num_memory_regions * sizeof(struct jailhouse_memory) +
112                 cell->num_irq_lines * sizeof(struct jailhouse_irq_line));
113 }
114
115 static inline const struct jailhouse_pci_device *
116 jailhouse_cell_pci_devices(const struct jailhouse_cell_desc *cell)
117 {
118         return (const struct jailhouse_pci_device *)((void *)cell +
119                 sizeof(struct jailhouse_cell_desc) + cell->cpu_set_size +
120                 cell->num_memory_regions * sizeof(struct jailhouse_memory) +
121                 cell->num_irq_lines * sizeof(struct jailhouse_irq_line) +
122                 cell->pio_bitmap_size);
123 }
124
125 #endif /* !_JAILHOUSE_CELL_CONFIG_H */