Skip to content
Snippets Groups Projects
Commit d8ac7e49 authored by Pekka Enberg's avatar Pekka Enberg
Browse files

virtio: Add virtio::probe() helper


Add a new virtio::probe() helper function to simplify virtio driver
probing.

Signed-off-by: default avatarPekka Enberg <penberg@cloudius-systems.com>
parent 0f56c7d3
No related branches found
No related tags found
No related merge requests found
......@@ -176,6 +176,17 @@ protected:
bool _cap_event_idx = false;
};
template <typename T, u16 ID>
hw_driver* probe(hw_device* dev)
{
if (auto pci_dev = dynamic_cast<pci::device*>(dev)) {
if (pci_dev->get_id() == hw_device_id(VIRTIO_VENDOR_ID, ID)) {
return new T(*pci_dev);
}
}
return nullptr;
}
}
#endif
......
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