[virtio][v9p] Add the VirtIO 9p device driver
This commit adds the VirtIO 9p device driver based on the VirtIO driver stack in LK, `dev/virtio`. The driver supports a subset of 9P2000.L protocol (https://github.com/chaos/diod/blob/master/protocol.md), which is able to perform basic file operations (fread, fwrite, dirread, etc.). The primary interface for sending and receiving the 9p messages is `virtio_9p_rpc`, which is handy and scalable. The driver is limited to communicate to the host with only one outstanding 9p message per device due to the simplified driver design. Basically that is enough for embedded environments when there is no massive file IO. Signed-off-by: Cody Wong <codycswong@google.com>
This commit is contained in:
committed by
Travis Geiselbrecht
parent
3288b15a39
commit
2b02c8a046
@@ -35,6 +35,9 @@
|
||||
#if WITH_DEV_VIRTIO_GPU
|
||||
#include <dev/virtio/gpu.h>
|
||||
#endif
|
||||
#if WITH_DEV_VIRTIO_9P
|
||||
#include <dev/virtio/9p.h>
|
||||
#endif
|
||||
|
||||
#define LOCAL_TRACE 0
|
||||
|
||||
@@ -185,6 +188,25 @@ int virtio_mmio_detect(void *ptr, uint count, const uint irqs[], size_t stride)
|
||||
}
|
||||
}
|
||||
#endif // WITH_DEV_VIRTIO_NET
|
||||
#if WITH_DEV_VIRTIO_9P
|
||||
if (mmio->device_id == 9) { // 9p device
|
||||
LTRACEF("found 9p device\n");
|
||||
|
||||
dev->mmio_config = mmio;
|
||||
dev->config_ptr = (void *)mmio->config;
|
||||
|
||||
status_t err = virtio_9p_init(dev, mmio->host_features);
|
||||
if (err >= 0) {
|
||||
// good device
|
||||
dev->valid = true;
|
||||
|
||||
if (dev->irq_driver_callback)
|
||||
unmask_interrupt(dev->irq);
|
||||
|
||||
virtio_9p_start(dev);
|
||||
}
|
||||
}
|
||||
#endif // WITH_DEV_VIRTIO_9P
|
||||
#if WITH_DEV_VIRTIO_GPU
|
||||
if (mmio->device_id == 0x10) { // virtio-gpu
|
||||
LTRACEF("found gpu device\n");
|
||||
|
||||
Reference in New Issue
Block a user