]> rtime.felk.cvut.cz Git - jailhouse.git/blobdiff - tools/root-cell-config.c.tmpl
jailhouse: inmates: bench: Add -R option -- repeats count.
[jailhouse.git] / tools / root-cell-config.c.tmpl
index 7aaa76341571a74c9e3c9832d3e6a10f6468c2c2..a864fb6fb681ec749583edd7afb95ac98ccbdd44 100644 (file)
@@ -1,11 +1,37 @@
 /*
  * Jailhouse, a Linux-based partitioning hypervisor
  *
- * Copyright (c) Siemens AG, 2014
+ * Copyright (c) Siemens AG, 2014-2016
  *
  * This work is licensed under the terms of the GNU GPL, version 2.  See
  * the COPYING file in the top-level directory.
  *
+ * Alternatively, you can use or redistribute this file under the following
+ * BSD license:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ *
  * Configuration for ${product[0]} ${product[1]}
  * created with '${argstr}'
  *
 #include <linux/types.h>
 #include <jailhouse/cell-config.h>
 
-#define ARRAY_SIZE(a) sizeof(a) / sizeof(a[0])
+#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
 
 struct {
        struct jailhouse_system header;
-       __u64 cpus[1];
+       __u64 cpus[${int((cpucount + 63) / 64)}];
        struct jailhouse_memory mem_regions[${len(regions)}];
-       struct jailhouse_irqchip irqchips[1];
+       struct jailhouse_irqchip irqchips[${len(irqchips)}];
        __u8 pio_bitmap[0x2000];
        struct jailhouse_pci_device pci_devices[${len(pcidevices)}];
+       struct jailhouse_pci_capability pci_caps[${len(pcicaps)}];
 } __attribute__((packed)) config = {
        .header = {
+               .signature = JAILHOUSE_SYSTEM_SIGNATURE,
                .hypervisor_memory = {
                        .phys_start = ${hex(hvmem[0])},
                        .size = ${hex(hvmem[1])},
                },
-               .config_memory = {
-                       .phys_start = ${hex(confmem[0])},
-                       .size = ${hex(confmem[1])},
+               .debug_console = {
+                       .phys_start = 0x3f8,
                },
                .platform_info.x86 = {
+                       .mmconfig_base = ${hex(mmconfig.base)},
+                       .mmconfig_end_bus = ${hex(mmconfig.end_bus)},
                        .pm_timer_address = ${hex(pm_timer_base)},
+                       % if iommu_units:
+                       .iommu_units = {
+                               % for unit in iommu_units:
+                               {
+                                       .base = ${hex(unit.base_addr)},
+                                       .size = ${hex(unit.mmio_size)},
+                                       % if unit.is_amd_iommu:
+                                       .amd_bdf = ${hex(unit.amd_bdf)},
+                                       .amd_base_cap = ${hex(unit.amd_base_cap)},
+                                       .amd_msi_cap = ${hex(unit.amd_msi_cap)},
+                                       .amd_features = ${hex(unit.amd_features)},
+                                       % endif
+                               },
+                               % endfor
+                       },
+                       % endif
                },
+               .interrupt_limit = 256,
                .root_cell = {
                        .name = "RootCell",
                        .cpu_set_size = sizeof(config.cpus),
@@ -45,11 +91,17 @@ struct {
                        .num_irqchips = ARRAY_SIZE(config.irqchips),
                        .pio_bitmap_size = ARRAY_SIZE(config.pio_bitmap),
                        .num_pci_devices = ARRAY_SIZE(config.pci_devices),
+                       .num_pci_caps = ARRAY_SIZE(config.pci_caps),
                },
        },
 
        .cpus = {
-               0b${'1'*cpucount},
+               % for n in range(int(cpucount / 64)):
+               0xffffffffffffffff,
+               % endfor
+               % if (cpucount % 64):
+               ${'0x%016x,' % ((1 << (cpucount % 64)) - 1)}
+               % endif
        },
 
        .mem_regions = {
@@ -59,36 +111,39 @@ struct {
                /* ${c} */
                % endfor
                {
-                       .phys_start = ${hex(r.start)},
-                       .virt_start = ${hex(r.start)},
-                       .size = ${hex(r.size())},
+                       .phys_start = ${hex(r.start).strip('L')},
+                       .virt_start = ${hex(r.start).strip('L')},
+                       .size = ${hex(r.size()).strip('L')},
                        .flags = ${r.flagstr('\t\t')},
                },
                % endfor
        },
 
        .irqchips = {
-               /* IOAPIC */ {
-                       .address = 0xfec00000,
-                       .id = ${hex(ioapic_id)},
-                       .pin_bitmap = 0xffffff,
+               % for i in irqchips:
+               /* ${str(i)} */
+               {
+                       .address = ${hex(i.address)},
+                       .id = ${hex(i.irqchip_id())},
+                       .pin_bitmap = {
+                               0xffffff
+                       },
                },
+               % endfor
        },
 
        .pio_bitmap = {
-               [     0/8 ...   0x1f/8] = -1,
-               [  0x20/8 ...   0x27/8] = 0xfc, /* HACK: PIC */
-               [  0x28/8 ...   0x3f/8] = -1,
+               [     0/8 ...   0x3f/8] = -1,
                [  0x40/8 ...   0x47/8] = 0xf0, /* PIT */
                [  0x48/8 ...   0x5f/8] = -1,
-               [  0x60/8 ...   0x67/8] = 0, /* HACK: 8042, NMI status/control */
+               [  0x60/8 ...   0x67/8] = 0xec, /* HACK: NMI status/control */
                [  0x68/8 ...   0x6f/8] = -1,
                [  0x70/8 ...   0x77/8] = 0xfc, /* RTC */
-               [  0x78/8 ...  0x3af/8] = -1,
+               [  0x78/8 ...   0x7f/8] = -1,
+               [  0x80/8 ...   0x87/8] = 0xfe, /* Linux: native_io_delay() */
+               [  0x88/8 ...  0x3af/8] = -1,
                [ 0x3b0/8 ...  0x3df/8] = 0x00, /* VGA */
-               [ 0x3e0/8 ...  0x3ff/8] = -1,
-               [ 0x400/8 ...  0x47f/8] = 0, /* HACK: ACPI */
-               [ 0x480/8 ...  0xcff/8] = -1,
+               [ 0x3e0/8 ...  0xcff/8] = -1,
                [ 0xd00/8 ... 0xffff/8] = 0, /* HACK: PCI bus */
        },
 
@@ -97,9 +152,40 @@ struct {
                /* ${str(d)} */
                {
                        .type = ${d.type},
+                       % if d.iommu is not None:
+                       .iommu = ${d.iommu},
+                       % endif
                        .domain = ${hex(d.domain)},
-                       .bus = ${hex(d.bus)},
-                       .devfn = ${hex(d.devfn())},
+                       .bdf = ${hex(d.bdf())},
+                       .bar_mask = {
+                               ${'0x%08x' % d.bars.mask[0]}, ${'0x%08x' % d.bars.mask[1]}, ${'0x%08x' % d.bars.mask[2]},
+                               ${'0x%08x' % d.bars.mask[3]}, ${'0x%08x' % d.bars.mask[4]}, ${'0x%08x' % d.bars.mask[5]},
+                       },
+                       .caps_start = ${d.caps_start},
+                       .num_caps = ${d.num_caps},
+                       .num_msi_vectors = ${d.num_msi_vectors},
+                       .msi_64bits = ${d.msi_64bits},
+                       .num_msix_vectors = ${d.num_msix_vectors},
+                       .msix_region_size = ${hex(d.msix_region_size)},
+                       .msix_address = ${hex(d.msix_address).strip('L')},
+               },
+               % endfor
+       },
+
+       .pci_caps = {
+               % for c in pcicaps:
+               % for comment in c.comments:
+               /* ${comment} */
+               % endfor
+               {
+                       % if (c.id & 0x8000) != 0:
+                       .id = ${hex(c.id & 0x7fff)} | JAILHOUSE_PCI_EXT_CAP,
+                       % else:
+                       .id = ${hex(c.id)},
+                       % endif
+                       .start = ${hex(c.start)},
+                       .len = ${c.len},
+                       .flags = ${c.flags},
                },
                % endfor
        },