Skip to content
Snippets Groups Projects
Commit ae5470f8 authored by Avi Kivity's avatar Avi Kivity
Browse files

virtio-driver: unindent

parent b4f9d646
No related branches found
No related tags found
No related merge requests found
......@@ -9,67 +9,65 @@ using namespace pci;
namespace virtio {
virtio_driver::virtio_driver(virtio_device* vdev)
: hw_driver()
, _dev(vdev)
, _msi(&vdev->pci_device())
{
_dev->pci_device().set_bus_master(true);
virtio_driver::virtio_driver(virtio_device* vdev)
: hw_driver()
, _dev(vdev)
, _msi(&vdev->pci_device())
{
_dev->pci_device().set_bus_master(true);
_dev->pci_device().msix_enable();
_dev->pci_device().msix_enable();
//make sure the queue is reset
_dev->reset_host_side();
//make sure the queue is reset
_dev->reset_host_side();
// Acknowledge device
_dev->add_dev_status(VIRTIO_CONFIG_S_ACKNOWLEDGE | VIRTIO_CONFIG_S_DRIVER);
// Acknowledge device
_dev->add_dev_status(VIRTIO_CONFIG_S_ACKNOWLEDGE | VIRTIO_CONFIG_S_DRIVER);
// Generic init of virtqueues
_dev->probe_virt_queues();
// Generic init of virtqueues
_dev->probe_virt_queues();
setup_features();
}
virtio_driver::~virtio_driver()
{
_dev->reset_host_side();
_dev->free_queues();
}
bool virtio_driver::setup_features(void)
{
u32 dev_features = _dev->get_device_features();
u32 drv_features = this->get_driver_features();
setup_features();
}
u32 subset = dev_features & drv_features;
virtio_driver::~virtio_driver()
{
_dev->reset_host_side();
_dev->free_queues();
}
//notify the host about the features in used according
//to the virtio spec
for (int i=0;i<32;i++)
if (subset & (1 << i))
virtio_d(fmt("%s: found feature intersec of bit %d") % __FUNCTION__ % i);
bool virtio_driver::setup_features(void)
{
u32 dev_features = _dev->get_device_features();
u32 drv_features = this->get_driver_features();
if (subset & (1 << VIRTIO_RING_F_INDIRECT_DESC))
_dev->set_indirect_buf_cap(true);
u32 subset = dev_features & drv_features;
_dev->set_guest_features(subset);
//notify the host about the features in used according
//to the virtio spec
for (int i=0;i<32;i++)
if (subset & (1 << i))
virtio_d(fmt("%s: found feature intersec of bit %d") % __FUNCTION__ % i);
return (subset != 0);
if (subset & (1 << VIRTIO_RING_F_INDIRECT_DESC))
_dev->set_indirect_buf_cap(true);
}
_dev->set_guest_features(subset);
void virtio_driver::dump_config()
{
u8 B, D, F;
_dev->pci_device().get_bdf(B, D, F);
return (subset != 0);
virtio_d(fmt("%s [%x:%x.%x] vid:id= %x:%x") % get_name() %
(u16)B % (u16)D % (u16)F %
_dev->pci_device().get_vendor_id() %
_dev->pci_device().get_device_id());
}
}
void virtio_driver::dump_config()
{
u8 B, D, F;
_dev->pci_device().get_bdf(B, D, F);
virtio_d(fmt("%s [%x:%x.%x] vid:id= %x:%x") % get_name() %
(u16)B % (u16)D % (u16)F %
_dev->pci_device().get_vendor_id() %
_dev->pci_device().get_device_id());
}
}
......@@ -7,28 +7,28 @@
namespace virtio {
class virtio_driver : public hw_driver {
public:
explicit virtio_driver(virtio_device* vdev);
virtual ~virtio_driver();
class virtio_driver : public hw_driver {
public:
explicit virtio_driver(virtio_device* vdev);
virtual ~virtio_driver();
virtual const std::string get_name(void) = 0;
virtual const std::string get_name(void) = 0;
virtual void dump_config(void);
virtual void dump_config(void);
protected:
// Actual drivers should implement this on top of the basic ring features
virtual u32 get_driver_features(void) { return (1 << VIRTIO_RING_F_INDIRECT_DESC); }
bool setup_features(void);
protected:
// Actual drivers should implement this on top of the basic ring features
virtual u32 get_driver_features(void) { return (1 << VIRTIO_RING_F_INDIRECT_DESC); }
bool setup_features(void);
///////////////////
// Device access //
///////////////////
///////////////////
// Device access //
///////////////////
// Virtio device
virtio_device *_dev;
interrupt_manager _msi;
};
// Virtio device
virtio_device *_dev;
interrupt_manager _msi;
};
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment