]> rtime.felk.cvut.cz Git - jailhouse.git/blob - tools/root-cell-config.c.tmpl
x86/tools/inmates: Account for 32-bit PM timers
[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                 .platform_info.x86 = {
36                         .mmconfig_base = ${hex(mmconfig.base)},
37                         .mmconfig_end_bus = ${hex(mmconfig.end_bus)},
38                         .pm_timer_address = ${hex(pm_timer_base)},
39                         .pm_timer_val_ext = ${pm_timer_val_ext},
40                         % if dmar_units:
41                         .dmar_unit_base = {
42                                 % for d in dmar_units:
43                                 ${hex(d)},
44                                 % endfor
45                         },
46                         % endif
47                 },
48                 .device_limit = 128,
49                 .interrupt_limit = 256,
50                 .root_cell = {
51                         .name = "RootCell",
52                         .cpu_set_size = sizeof(config.cpus),
53                         .num_memory_regions = ARRAY_SIZE(config.mem_regions),
54                         .num_irqchips = ARRAY_SIZE(config.irqchips),
55                         .pio_bitmap_size = ARRAY_SIZE(config.pio_bitmap),
56                         .num_pci_devices = ARRAY_SIZE(config.pci_devices),
57                         .num_pci_caps = ARRAY_SIZE(config.pci_caps),
58                 },
59         },
60
61         .cpus = {
62                 % for n in range(int(cpucount / 64)):
63                 0xffffffffffffffff,
64                 % endfor
65                 % if (cpucount % 64):
66                 ${'0x%016x,' % ((1 << (cpucount % 64)) - 1)}
67                 % endif
68         },
69
70         .mem_regions = {
71                 % for r in regions:
72                 /* ${str(r)} */
73                 % for c in r.comments:
74                 /* ${c} */
75                 % endfor
76                 {
77                         .phys_start = ${hex(r.start).strip('L')},
78                         .virt_start = ${hex(r.start).strip('L')},
79                         .size = ${hex(r.size()).strip('L')},
80                         .flags = ${r.flagstr('\t\t')},
81                 },
82                 % endfor
83         },
84
85         .irqchips = {
86                 /* IOAPIC */ {
87                         .address = 0xfec00000,
88                         .id = ${hex(ioapic_id)},
89                         .pin_bitmap = 0xffffff,
90                 },
91         },
92
93         .pio_bitmap = {
94                 [     0/8 ...   0x3f/8] = -1,
95                 [  0x40/8 ...   0x47/8] = 0xf0, /* PIT */
96                 [  0x48/8 ...   0x5f/8] = -1,
97                 [  0x60/8 ...   0x67/8] = 0xec, /* HACK: NMI status/control */
98                 [  0x68/8 ...   0x6f/8] = -1,
99                 [  0x70/8 ...   0x77/8] = 0xfc, /* RTC */
100                 [  0x78/8 ...  0x3af/8] = -1,
101                 [ 0x3b0/8 ...  0x3df/8] = 0x00, /* VGA */
102                 [ 0x3e0/8 ...  0xcff/8] = -1,
103                 [ 0xd00/8 ... 0xffff/8] = 0, /* HACK: PCI bus */
104         },
105
106         .pci_devices = {
107                 % for d in pcidevices:
108                 /* ${str(d)} */
109                 {
110                         .type = ${d.type},
111                         .iommu = ${d.iommu},
112                         .domain = ${hex(d.domain)},
113                         .bdf = ${hex(d.bdf())},
114                         .caps_start = ${d.caps_start},
115                         .num_caps = ${d.num_caps},
116                         .num_msi_vectors = ${d.num_msi_vectors},
117                         .msi_64bits = ${d.msi_64bits},
118                         .num_msix_vectors = ${d.num_msix_vectors},
119                         .msix_region_size = ${hex(d.msix_region_size)},
120                         .msix_address = ${hex(d.msix_address).strip('L')},
121                 },
122                 % endfor
123         },
124
125         .pci_caps = {
126                 % for c in pcicaps:
127                 % for comment in c.comments:
128                 /* ${comment} */
129                 % endfor
130                 {
131                         .id = ${hex(c.id)},
132                         .start = ${hex(c.start)},
133                         .len = ${c.len},
134                         .flags = ${c.flags},
135                 },
136                 % endfor
137         },
138 };