]> rtime.felk.cvut.cz Git - jailhouse.git/blob - tools/root-cell-config.c.tmpl
configs/tools: Describe MMCONFIG region in config files
[jailhouse.git] / tools / root-cell-config.c.tmpl
1 /*
2  * Jailhouse, a Linux-based partitioning hypervisor
3  *
4  * Copyright (c) Siemens AG, 2014
5  *
6  * This work is licensed under the terms of the GNU GPL, version 2.  See
7  * the COPYING file in the top-level directory.
8  *
9  * Configuration for ${product[0]} ${product[1]}
10  * created with '${argstr}'
11  *
12  * NOTE: This config expects the following to be appended to your kernel cmdline
13  *       "memmap=${hex(ourmem[1])}$${hex(ourmem[0])}"
14  */
15
16 #include <linux/types.h>
17 #include <jailhouse/cell-config.h>
18
19 #define ARRAY_SIZE(a) sizeof(a) / sizeof(a[0])
20
21 struct {
22         struct jailhouse_system header;
23         __u64 cpus[${int((cpucount + 63) / 64)}];
24         struct jailhouse_memory mem_regions[${len(regions)}];
25         struct jailhouse_irqchip irqchips[1];
26         __u8 pio_bitmap[0x2000];
27         struct jailhouse_pci_device pci_devices[${len(pcidevices)}];
28         struct jailhouse_pci_capability pci_caps[${len(pcicaps)}];
29 } __attribute__((packed)) config = {
30         .header = {
31                 .hypervisor_memory = {
32                         .phys_start = ${hex(hvmem[0])},
33                         .size = ${hex(hvmem[1])},
34                 },
35                 .config_memory = {
36                         .phys_start = ${hex(confmem[0])},
37                         .size = ${hex(confmem[1])},
38                 },
39                 .platform_info.x86 = {
40                         .mmconfig_base = ${hex(mmconfig.base)},
41                         .mmconfig_end_bus = ${hex(mmconfig.end_bus)},
42                         .pm_timer_address = ${hex(pm_timer_base)},
43                 },
44                 .root_cell = {
45                         .name = "RootCell",
46                         .cpu_set_size = sizeof(config.cpus),
47                         .num_memory_regions = ARRAY_SIZE(config.mem_regions),
48                         .num_irqchips = ARRAY_SIZE(config.irqchips),
49                         .pio_bitmap_size = ARRAY_SIZE(config.pio_bitmap),
50                         .num_pci_devices = ARRAY_SIZE(config.pci_devices),
51                         .num_pci_caps = ARRAY_SIZE(config.pci_caps),
52                 },
53         },
54
55         .cpus = {
56                 % for n in range(int(cpucount / 64)):
57                 0xffffffffffffffff,
58                 % endfor
59                 % if (cpucount % 64):
60                 ${'0x%016x,' % ((1 << (cpucount % 64)) - 1)}
61                 % endif
62         },
63
64         .mem_regions = {
65                 % for r in regions:
66                 /* ${str(r)} */
67                 % for c in r.comments:
68                 /* ${c} */
69                 % endfor
70                 {
71                         .phys_start = ${hex(r.start)},
72                         .virt_start = ${hex(r.start)},
73                         .size = ${hex(r.size())},
74                         .flags = ${r.flagstr('\t\t')},
75                 },
76                 % endfor
77         },
78
79         .irqchips = {
80                 /* IOAPIC */ {
81                         .address = 0xfec00000,
82                         .id = ${hex(ioapic_id)},
83                         .pin_bitmap = 0xffffff,
84                 },
85         },
86
87         .pio_bitmap = {
88                 [     0/8 ...   0x3f/8] = -1,
89                 [  0x40/8 ...   0x47/8] = 0xf0, /* PIT */
90                 [  0x48/8 ...   0x5f/8] = -1,
91                 [  0x60/8 ...   0x67/8] = 0, /* HACK: 8042, NMI status/control */
92                 [  0x68/8 ...   0x6f/8] = -1,
93                 [  0x70/8 ...   0x77/8] = 0xfc, /* RTC */
94                 [  0x78/8 ...  0x3af/8] = -1,
95                 [ 0x3b0/8 ...  0x3df/8] = 0x00, /* VGA */
96                 [ 0x3e0/8 ...  0xcff/8] = -1,
97                 [ 0xd00/8 ... 0xffff/8] = 0, /* HACK: PCI bus */
98         },
99
100         .pci_devices = {
101                 % for d in pcidevices:
102                 /* ${str(d)} */
103                 {
104                         .type = ${d.type},
105                         .domain = ${hex(d.domain)},
106                         .bdf = ${hex(d.bdf())},
107                         .caps_start = ${d.caps_start},
108                         .num_caps = ${d.num_caps},
109                 },
110                 % endfor
111         },
112
113         .pci_caps = {
114                 % for c in pcicaps:
115                 % for comment in c.comments:
116                 /* ${comment} */
117                 % endfor
118                 {
119                         .id = ${hex(c.id)},
120                         .start = ${hex(c.start)},
121                         .len = ${c.len},
122                         .flags = ${c.flags},
123                 },
124                 % endfor
125         },
126 };