This is a pretty trivial patch that adds support of virtio net and block devices over mmio for aarch64 architecture. It accomplishes it by adding proper factory methods to register relevant interrupt handlers.
Signed-off-by: Waldemar Kozaczuk <[email protected]> --- Makefile | 1 + drivers/virtio-blk.cc | 10 +++++++++- drivers/virtio-device.hh | 4 +++- drivers/virtio-mmio.cc | 4 ++++ drivers/virtio-mmio.hh | 4 ++++ drivers/virtio-net.cc | 10 +++++++++- 6 files changed, 30 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 2896f725..3c609a1c 100644 --- a/Makefile +++ b/Makefile @@ -822,6 +822,7 @@ drivers += drivers/pl011.o drivers += drivers/xenconsole.o drivers += drivers/virtio.o drivers += drivers/virtio-pci-device.o +drivers += drivers/virtio-mmio.o drivers += drivers/virtio-vring.o drivers += drivers/virtio-rng.o drivers += drivers/virtio-blk.o diff --git a/drivers/virtio-blk.cc b/drivers/virtio-blk.cc index 87ef70f1..8845a093 100644 --- a/drivers/virtio-blk.cc +++ b/drivers/virtio-blk.cc @@ -144,7 +144,15 @@ blk::blk(virtio_device& virtio_dev) [=] { t->wake(); }); }; -#ifndef AARCH64_PORT_STUB +#ifdef AARCH64_PORT_STUB + int_factory.create_spi_edge_interrupt = [this,t]() { + return new spi_interrupt( + gic::irq_type::IRQ_TYPE_EDGE, + _dev.get_irq(), + [=] { return this->ack_irq(); }, + [=] { t->wake(); }); + }; +#else int_factory.create_gsi_edge_interrupt = [this,t]() { return new gsi_edge_interrupt( _dev.get_irq(), diff --git a/drivers/virtio-device.hh b/drivers/virtio-device.hh index 732f9b18..be6de395 100644 --- a/drivers/virtio-device.hh +++ b/drivers/virtio-device.hh @@ -28,7 +28,9 @@ namespace virtio { struct interrupt_factory { std::function<void(interrupt_manager &)> register_msi_bindings = nullptr; std::function<pci_interrupt *(pci::device &)> create_pci_interrupt = nullptr; -#ifndef AARCH64_PORT_STUB +#ifdef AARCH64_PORT_STUB + std::function<spi_interrupt *()> create_spi_edge_interrupt = nullptr; +#else std::function<gsi_edge_interrupt *()> create_gsi_edge_interrupt = nullptr; #endif /* !AARCH64_PORT_STUB */ }; diff --git a/drivers/virtio-mmio.cc b/drivers/virtio-mmio.cc index 36088ba1..b2f84d09 100644 --- a/drivers/virtio-mmio.cc +++ b/drivers/virtio-mmio.cc @@ -103,7 +103,11 @@ u8 mmio_device::read_config(u32 offset) void mmio_device::register_interrupt(interrupt_factory irq_factory) { +#ifdef AARCH64_PORT_STUB + _irq.reset(irq_factory.create_spi_edge_interrupt()); +#else _irq.reset(irq_factory.create_gsi_edge_interrupt()); +#endif } bool mmio_device::parse_config() diff --git a/drivers/virtio-mmio.hh b/drivers/virtio-mmio.hh index 0cbf7000..27632971 100644 --- a/drivers/virtio-mmio.hh +++ b/drivers/virtio-mmio.hh @@ -144,7 +144,11 @@ private: u16 _device_id; mmioaddr_t _addr_mmio; +#ifdef AARCH64_PORT_STUB + std::unique_ptr<spi_interrupt> _irq; +#else std::unique_ptr<gsi_edge_interrupt> _irq; +#endif }; void parse_mmio_device_configuration(char *cmdline); diff --git a/drivers/virtio-net.cc b/drivers/virtio-net.cc index 31a32684..65265ca7 100644 --- a/drivers/virtio-net.cc +++ b/drivers/virtio-net.cc @@ -317,7 +317,15 @@ net::net(virtio_device& dev) [=] { poll_task->wake(); }); }; -#ifndef AARCH64_PORT_STUB +#ifdef AARCH64_PORT_STUB + int_factory.create_spi_edge_interrupt = [this,poll_task]() { + return new spi_interrupt( + gic::irq_type::IRQ_TYPE_EDGE, + _dev.get_irq(), + [=] { return this->ack_irq(); }, + [=] { poll_task->wake(); }); + }; +#else int_factory.create_gsi_edge_interrupt = [this,poll_task]() { return new gsi_edge_interrupt( _dev.get_irq(), -- 2.26.2 -- You received this message because you are subscribed to the Google Groups "OSv Development" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/osv-dev/20200714045443.58517-1-jwkozaczuk%40gmail.com.
