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/bananapi-linux-demo.c   | 28 +++++++++++++++++++++++--
 configs/bananapi.c              | 46 +++++++++++++++++++++++++++++++++--------
 configs/dts/inmate-bananapi.dts | 17 +++++++++++++++
 3 files changed, 80 insertions(+), 11 deletions(-)

diff --git a/configs/bananapi-linux-demo.c b/configs/bananapi-linux-demo.c
index 51348f6..495d242 100644
--- a/configs/bananapi-linux-demo.c
+++ b/configs/bananapi-linux-demo.c
@@ -21,8 +21,9 @@
 struct {
        struct jailhouse_cell_desc cell;
        __u64 cpus[1];
-       struct jailhouse_memory mem_regions[4];
+       struct jailhouse_memory mem_regions[5];
        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 = 123,
        },
 
        .cpus = {
@@ -68,6 +72,13 @@ struct {
                                JAILHOUSE_MEM_EXECUTE | JAILHOUSE_MEM_DMA |
                                JAILHOUSE_MEM_LOADABLE,
                },
+               /* IVSHMEM shared memory region */ {
+                       .phys_start = 0x7bf00000,
+                       .virt_start = 0x7bf00000,
+                       .size = 0x100000,
+                       .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
+                               JAILHOUSE_MEM_ROOTSHARED,
+               },
        },
 
        .irqchips = {
@@ -75,8 +86,21 @@ struct {
                        .address = 0x01c81000,
                        .pin_base = 32,
                        .pin_bitmap = {
-                               1 << (52-32)
+                               1 << (52-32), 0, 0, 1 << (155-128),
+                       },
+               },
+       },
+
+       .pci_devices = {
+               {
+                       .type = JAILHOUSE_PCI_TYPE_IVSHMEM,
+                       .bdf = 0x00,
+                       .bar_mask = {
+                               0xffffff00, 0xffffffff, 0x00000000,
+                               0x00000000, 0xffffffe0, 0xffffffff,
                        },
+                       .shmem_region = 4,
+                       .shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
                },
        },
 };
diff --git a/configs/bananapi.c b/configs/bananapi.c
index 6f1103f..f3d095b 100644
--- a/configs/bananapi.c
+++ b/configs/bananapi.c
@@ -20,8 +20,9 @@
 struct {
        struct jailhouse_system header;
        __u64 cpus[1];
-       struct jailhouse_memory mem_regions[16];
+       struct jailhouse_memory mem_regions[17];
        struct jailhouse_irqchip irqchips[1];
+       struct jailhouse_pci_device pci_devices[1];
 } __attribute__((packed)) config = {
        .header = {
                .signature = JAILHOUSE_SYSTEM_SIGNATURE,
@@ -34,19 +35,27 @@ struct {
                        .size = 0x1000,
                        .flags = JAILHOUSE_MEM_IO,
                },
-               .platform_info.arm = {
-                       .gicd_base = 0x01c81000,
-                       .gicc_base = 0x01c82000,
-                       .gich_base = 0x01c84000,
-                       .gicv_base = 0x01c86000,
-                       .maintenance_irq = 25,
+               .platform_info = {
+                       .pci_mmconfig_base = 0x2000000,
+                       .pci_mmconfig_end_bus = 0,
+                       .pci_is_virtual = 1,
+                       .arm = {
+                               .gicd_base = 0x01c81000,
+                               .gicc_base = 0x01c82000,
+                               .gich_base = 0x01c84000,
+                               .gicv_base = 0x01c86000,
+                               .maintenance_irq = 25,
+                       },
                },
                .root_cell = {
                        .name = "Banana-Pi",
 
                        .cpu_set_size = sizeof(config.cpus),
                        .num_memory_regions = ARRAY_SIZE(config.mem_regions),
-                       .num_irqchips = 1,
+                       .num_irqchips = ARRAY_SIZE(config.irqchips),
+                       .num_pci_devices = ARRAY_SIZE(config.pci_devices),
+
+                       .vpci_irq_base = 108,
                },
        },
 
@@ -163,11 +172,18 @@ struct {
                /* RAM */ {
                        .phys_start = 0x40000000,
                        .virt_start = 0x40000000,
-                       .size = 0x3c000000,
+                       .size = 0x3bf00000,
                        .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
                                JAILHOUSE_MEM_EXECUTE,
                },
+               /* IVSHMEM shared memory region */ {
+                       .phys_start = 0x7bf00000,
+                       .virt_start = 0x7bf00000,
+                       .size = 0x100000,
+                       .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE,
+               },
        },
+
        .irqchips = {
                /* GIC */ {
                        .address = 0x01c81000,
@@ -178,4 +194,16 @@ struct {
                },
        },
 
+       .pci_devices = {
+               {
+                       .type = JAILHOUSE_PCI_TYPE_IVSHMEM,
+                       .bdf = 0x00,
+                       .bar_mask = {
+                               0xffffff00, 0xffffffff, 0x00000000,
+                               0x00000000, 0xffffffe0, 0xffffffff,
+                       },
+                       .shmem_region = 16,
+                       .shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
+               },
+       },
 };
diff --git a/configs/dts/inmate-bananapi.dts b/configs/dts/inmate-bananapi.dts
index bbe1876..036650f 100644
--- a/configs/dts/inmate-bananapi.dts
+++ b/configs/dts/inmate-bananapi.dts
@@ -92,4 +92,21 @@
                clock-frequency = <24000000>;
                clocks = <&apb1_gates 23>;
        };
+
+       vpci@2000000 {
+               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 123 0>,
+                               <0 0 0 2 &gic GIC_SPI 124 0>,
+                               <0 0 0 3 &gic GIC_SPI 125 0>,
+                               <0 0 0 4 &gic GIC_SPI 126 0>;
+               reg = <0x2000000 0x100000>;
+               ranges =
+                       <0x02000000 0x00 0x10000000 0x10000000 0x00 0x10000>;
+       };
 };
-- 
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