From: Waldemar Kozaczuk <jwkozac...@gmail.com> Committer: Waldemar Kozaczuk <jwkozac...@gmail.com> Branch: master
aarch64: support virtio mmio devices 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 <jwkozac...@gmail.com> --- diff --git a/Makefile b/Makefile --- 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 --- 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 --- 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 --- 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 --- 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 --- 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(), -- 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 osv-dev+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/osv-dev/000000000000dbf40205aaa95b42%40google.com.