diff --git a/drivers/virtio.cc b/drivers/virtio.cc index 38e4ab660e83af240542327429fe7ed8264325a5..28289bd6febe8b91a5ff1d93b135badbf57e0b49 100644 --- a/drivers/virtio.cc +++ b/drivers/virtio.cc @@ -21,6 +21,8 @@ namespace virtio { virtio_driver::~virtio_driver() { + reset_host_side(); + for (int i=0; i < max_virtqueues_nr; i++) { if (NULL != _queues[i]) { delete (_queues[i]); @@ -28,6 +30,11 @@ namespace virtio { } } + void virtio_driver::reset_host_side() { + set_dev_status(0); + pci_conf_write(VIRTIO_PCI_QUEUE_PFN,(u32)0); + } + bool virtio_driver::earlyInitChecks() { if (!Driver::earlyInitChecks()) { @@ -58,6 +65,9 @@ namespace virtio { debug(fmt("Virtio:Init %x:%x") % _vid % _id); + //make sure the queue is reset + reset_host_side(); + // Acknowledge device add_dev_status(VIRTIO_CONFIG_S_ACKNOWLEDGE | VIRTIO_CONFIG_S_DRIVER); @@ -74,6 +84,12 @@ namespace virtio { return true; } + bool virtio_driver::kick(int queue) + { + set_virtio_config(VIRTIO_PCI_QUEUE_NOTIFY, queue); + return true; + } + bool virtio_driver::probe_virt_queues(void) { u16 queuesel = 0; @@ -93,7 +109,7 @@ namespace virtio { } // Init a new queue - vring * queue = new vring(qsize); + vring * queue = new vring(this, qsize, queuesel); _queues[queuesel++] = queue; // Tell host about pfn diff --git a/drivers/virtio.hh b/drivers/virtio.hh index 9ffbeeb1c6c302e0808c2026f36c52fe92a9212b..608244f804f768eb1788f572f023b8572fe56463 100644 --- a/drivers/virtio.hh +++ b/drivers/virtio.hh @@ -102,6 +102,8 @@ namespace virtio { virtual bool Init(Device *d); virtual void dumpConfig() const; + bool kick(int queue); + void reset_host_side(); protected: