2 * Jailhouse, a Linux-based partitioning hypervisor
4 * Copyright (c) Siemens AG, 2013
7 * Jan Kiszka <jan.kiszka@siemens.com>
9 * This work is licensed under the terms of the GNU GPL, version 2. See
10 * the COPYING file in the top-level directory.
13 #ifndef _JAILHOUSE_CELL_CONFIG_H
14 #define _JAILHOUSE_CELL_CONFIG_H
16 #define JAILHOUSE_CELL_NAME_MAXLEN 31
18 #define JAILHOUSE_CELL_PASSIVE_COMMREG 0x00000001
20 struct jailhouse_cell_desc {
21 char name[JAILHOUSE_CELL_NAME_MAXLEN+1];
25 __u32 num_memory_regions;
27 __u32 pio_bitmap_size;
28 __u32 num_pci_devices;
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
39 #define JAILHOUSE_MEM_VALID_FLAGS (JAILHOUSE_MEM_READ | \
40 JAILHOUSE_MEM_WRITE | \
41 JAILHOUSE_MEM_EXECUTE | \
43 JAILHOUSE_MEM_COMM_REGION)
45 struct jailhouse_memory {
52 struct jailhouse_irq_line {
57 #define JAILHOUSE_PCI_TYPE_DEVICE 0x01
58 #define JAILHOUSE_PCI_TYPE_BRIDGE 0x02
60 struct jailhouse_pci_device {
65 } __attribute__((packed));
67 struct jailhouse_system {
68 struct jailhouse_memory hypervisor_memory;
69 struct jailhouse_memory config_memory;
70 struct jailhouse_cell_desc system;
74 jailhouse_cell_config_size(struct jailhouse_cell_desc *cell)
76 return sizeof(struct jailhouse_cell_desc) +
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);
85 jailhouse_system_config_size(struct jailhouse_system *system)
87 return sizeof(system->hypervisor_memory) +
88 sizeof(system->config_memory) +
89 jailhouse_cell_config_size(&system->system);
92 static inline const unsigned long *
93 jailhouse_cell_cpu_set(const struct jailhouse_cell_desc *cell)
95 return (const unsigned long *)((const void *)cell +
96 sizeof(struct jailhouse_cell_desc));
99 static inline const struct jailhouse_memory *
100 jailhouse_cell_mem_regions(const struct jailhouse_cell_desc *cell)
102 return (const struct jailhouse_memory *)((void *)cell +
103 sizeof(struct jailhouse_cell_desc) + cell->cpu_set_size);
106 static inline const __u8 *
107 jailhouse_cell_pio_bitmap(const struct jailhouse_cell_desc *cell)
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));
115 static inline const struct jailhouse_pci_device *
116 jailhouse_cell_pci_devices(const struct jailhouse_cell_desc *cell)
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);
125 #endif /* !_JAILHOUSE_CELL_CONFIG_H */