virtio: add queue_is_full(), queue_is_empty(), queue_size() hooks.

This commit is contained in:
Jerome Duval 2013-09-16 17:09:00 +02:00
parent 7416b5878f
commit 33f263cb01
3 changed files with 36 additions and 1 deletions

View File

@ -117,6 +117,12 @@ typedef struct {
size_t readVectorCount, size_t writtenVectorCount,
virtio_callback_func callback, void *callbackCookie);
bool (*queue_is_full)(virtio_queue queue);
bool (*queue_is_empty)(virtio_queue queue);
uint16 (*queue_size)(virtio_queue queue);
} virtio_device_interface;

View File

@ -134,6 +134,31 @@ virtio_queue_request(virtio_queue cookie, const physical_entry *readEntry,
}
bool
virtio_queue_is_full(virtio_queue cookie)
{
VirtioQueue *queue = (VirtioQueue *)cookie;
return queue->IsFull();
}
bool
virtio_queue_is_empty(virtio_queue cookie)
{
VirtioQueue *queue = (VirtioQueue *)cookie;
return queue->IsEmpty();
}
uint16
virtio_queue_size(virtio_queue cookie)
{
VirtioQueue *queue = (VirtioQueue *)cookie;
return queue->Size();
}
// #pragma mark -
@ -222,7 +247,10 @@ virtio_device_interface virtio_device_module = {
virtio_alloc_queues,
virtio_setup_interrupt,
virtio_queue_request,
virtio_queue_request_v
virtio_queue_request_v,
virtio_queue_is_full,
virtio_queue_is_empty,
virtio_queue_size
};
virtio_for_controller_interface virtio_for_controller_module = {

View File

@ -107,6 +107,7 @@ public:
bool IsFull() const { return fRingFree == 0; }
bool IsEmpty() const { return fRingFree == fRingSize; }
uint16 Size() const { return fRingSize; }
VirtioDevice* Device() { return fDevice; }