Add ivshmem devices to root cell and linux-demo for networking purposes.
A virtual PCI host is introduced and INTx SPIs are carefully selected
for both sides so that they fall into the supported set of the GICD and
do not overlap with actually used interrupts.

Signed-off-by: Jan Kiszka <[email protected]>
---
 configs/dts/inmate-hikey.dts | 17 +++++++++++++++++
 configs/hikey-linux-demo.c   | 28 ++++++++++++++++++++++++++--
 configs/hikey.c              | 42 +++++++++++++++++++++++++++++++++++-------
 3 files changed, 78 insertions(+), 9 deletions(-)

diff --git a/configs/dts/inmate-hikey.dts b/configs/dts/inmate-hikey.dts
index d4ac79f..bcd82f3 100644
--- a/configs/dts/inmate-hikey.dts
+++ b/configs/dts/inmate-hikey.dts
@@ -88,4 +88,21 @@
                clocks = <&uartclk>, <&uartclk>;
                clock-names = "uartclk", "apb_pclk";
        };
+
+       vpci@f6000000 {
+               compatible = "pci-host-ecam-generic";
+               device_type = "pci";
+               bus-range = <0 0>;
+               #address-cells = <3>;
+               #size-cells = <2>;
+               #interrupt-cells = <1>;
+               interrupt-map-mask = <0 0 0 7>;
+               interrupt-map = <0 0 0 1 &gic GIC_SPI 111 0>,
+                               <0 0 0 2 &gic GIC_SPI 112 0>,
+                               <0 0 0 3 &gic GIC_SPI 113 0>,
+                               <0 0 0 4 &gic GIC_SPI 114 0>;
+               reg = <0x0 0xf6000000 0x0 0x100000>;
+               ranges =
+                       <0x02000000 0x00 0x10000000 0x0 0x10000000 0x00 
0x10000>;
+       };
 };
diff --git a/configs/hikey-linux-demo.c b/configs/hikey-linux-demo.c
index c96c724..f78190d 100644
--- a/configs/hikey-linux-demo.c
+++ b/configs/hikey-linux-demo.c
@@ -21,8 +21,9 @@
 struct {
        struct jailhouse_cell_desc cell;
        __u64 cpus[1];
-       struct jailhouse_memory mem_regions[3];
+       struct jailhouse_memory mem_regions[4];
        struct jailhouse_irqchip irqchips[1];
+       struct jailhouse_pci_device pci_devices[1];
 } __attribute__((packed)) config = {
        .cell = {
                .signature = JAILHOUSE_CELL_DESC_SIGNATURE,
@@ -32,6 +33,9 @@ struct {
                .cpu_set_size = sizeof(config.cpus),
                .num_memory_regions = ARRAY_SIZE(config.mem_regions),
                .num_irqchips = ARRAY_SIZE(config.irqchips),
+               .num_pci_devices = ARRAY_SIZE(config.pci_devices),
+
+               .vpci_irq_base = 143-32,
        },
 
        .cpus = {
@@ -61,6 +65,13 @@ struct {
                                JAILHOUSE_MEM_EXECUTE | JAILHOUSE_MEM_DMA |
                                JAILHOUSE_MEM_LOADABLE,
                },
+               /* IVSHMEM shared memory region */ {
+                       .phys_start = 0x7f000000,
+                       .virt_start = 0x7f000000,
+                       .size = 0x100000,
+                       .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
+                               JAILHOUSE_MEM_ROOTSHARED,
+               },
        },
 
        .irqchips = {
@@ -68,8 +79,21 @@ struct {
                        .address = 0xf6801000,
                        .pin_base = 32,
                        .pin_bitmap = {
-                               0, 1 << (71 - 64)
+                               0, 1 << (71 - 64), 0, 1 << (143 - 128)
+                       },
+               },
+       },
+
+       .pci_devices = {
+               /* 00:00.0 */ {
+                       .type = JAILHOUSE_PCI_TYPE_IVSHMEM,
+                       .bdf = 0x00,
+                       .bar_mask = {
+                               0xffffff00, 0xffffffff, 0x00000000,
+                               0x00000000, 0xffffffe0, 0xffffffff,
                        },
+                       .shmem_region = 3,
+                       .shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
                },
        },
 };
diff --git a/configs/hikey.c b/configs/hikey.c
index 3c16c25..2295251 100644
--- a/configs/hikey.c
+++ b/configs/hikey.c
@@ -18,8 +18,9 @@
 struct {
        struct jailhouse_system header;
        __u64 cpus[1];
-       struct jailhouse_memory mem_regions[2];
+       struct jailhouse_memory mem_regions[3];
        struct jailhouse_irqchip irqchips[1];
+       struct jailhouse_pci_device pci_devices[1];
 } __attribute__((packed)) config = {
        .header = {
                .signature = JAILHOUSE_SYSTEM_SIGNATURE,
@@ -32,12 +33,17 @@ struct {
                        .size = 0x1000,
                        .flags = JAILHOUSE_MEM_IO,
                },
-               .platform_info.arm = {
-                       .gicd_base = 0xf6801000,
-                       .gicc_base = 0xf6802000,
-                       .gich_base = 0xf6804000,
-                       .gicv_base = 0xf6806000,
-                       .maintenance_irq = 25,
+               .platform_info = {
+                       .pci_mmconfig_base = 0xf6000000,
+                       .pci_mmconfig_end_bus = 1,
+                       .pci_is_virtual = 1,
+                       .arm = {
+                               .gicd_base = 0xf6801000,
+                               .gicc_base = 0xf6802000,
+                               .gich_base = 0xf6804000,
+                               .gicv_base = 0xf6806000,
+                               .maintenance_irq = 25,
+                       },
                },
                .root_cell = {
                        .name = "HiKey",
@@ -45,6 +51,9 @@ struct {
                        .cpu_set_size = sizeof(config.cpus),
                        .num_memory_regions = ARRAY_SIZE(config.mem_regions),
                        .num_irqchips = ARRAY_SIZE(config.irqchips),
+                       .num_pci_devices = ARRAY_SIZE(config.pci_devices),
+
+                       .vpci_irq_base = 136-32,
                },
        },
 
@@ -67,7 +76,14 @@ struct {
                        .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
                                JAILHOUSE_MEM_EXECUTE,
                },
+               /* IVSHMEM shared memory region */ {
+                       .phys_start = 0x7f000000,
+                       .virt_start = 0x7f000000,
+                       .size = 0x100000,
+                       .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE,
+               },
        },
+
        .irqchips = {
                /* GIC */ {
                        .address = 0xf6801000,
@@ -78,4 +94,16 @@ struct {
                },
        },
 
+       .pci_devices = {
+               /* 00:00.0 */ {
+                       .type = JAILHOUSE_PCI_TYPE_IVSHMEM,
+                       .bdf = 0x00,
+                       .bar_mask = {
+                               0xffffff00, 0xffffffff, 0x00000000,
+                               0x00000000, 0xffffffe0, 0xffffffff,
+                       },
+                       .shmem_region = 2,
+                       .shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
+               },
+       },
 };
-- 
2.1.4

-- 
You received this message because you are subscribed to the Google Groups 
"Jailhouse" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to