Skip to content
Snippets Groups Projects
Commit dfd46a30 authored by Dor Laor's avatar Dor Laor
Browse files

Available idx should be a free running counter.

Only it's usage within the array should be within limits.

Add a function for available ring content
parent 19030e63
No related branches found
No related tags found
No related merge requests found
...@@ -114,8 +114,8 @@ namespace virtio { ...@@ -114,8 +114,8 @@ namespace virtio {
_avail_added_since_kick++; _avail_added_since_kick++;
_avail_count -= i; _avail_count -= i;
_avail->_ring[_avail->_idx] = _avail_head; _avail->_ring[(_avail->_idx) % _num] = _avail_head;
_avail->_idx = (_avail->_idx + 1) % _num; _avail->_idx++;
_avail_head = idx; _avail_head = idx;
...@@ -159,7 +159,12 @@ namespace virtio { ...@@ -159,7 +159,12 @@ namespace virtio {
return cookie; return cookie;
} }
bool vring::used_ring_not_empy() bool vring::avail_ring_not_empty()
{
return (_avail_count > 0);
}
bool vring::used_ring_not_empty()
{ {
return (_used_guest_head != _used->_idx); return (_used_guest_head != _used->_idx);
} }
......
...@@ -112,7 +112,8 @@ class virtio_device; ...@@ -112,7 +112,8 @@ class virtio_device;
// Ring operations // Ring operations
bool add_buf(sglist* sg, u16 out, u16 in, void* cookie); bool add_buf(sglist* sg, u16 out, u16 in, void* cookie);
void* get_buf(); void* get_buf();
bool used_ring_not_empy(); bool used_ring_not_empty();
bool avail_ring_not_empty();
bool kick(); bool kick();
void register_callback(std::function<void ()> func) {_callback = func;}; void register_callback(std::function<void ()> func) {_callback = func;};
......
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