L4Re – L4 Runtime Environment
|
Simple class for accessing a virtio block device synchronously. More...
Data Structures | |
class | Handle |
Handle to an ongoing request. More... | |
Public Member Functions | |
void | setup_device (L4::Cap< L4virtio::Device > srvcap, l4_size_t usermem, void **userdata, Ptr< void > &user_devaddr, l4_uint32_t fmask0=-1U, l4_uint32_t fmask1=-1U) |
Setup a connection to a device and set up shared memory. More... | |
l4virtio_block_config_t const & | device_config () const |
Return a reference to the device configuration. | |
Handle | start_request (l4_uint64_t sector, l4_uint32_t type, Callback callback) |
Start the setup of a new request. More... | |
int | add_block (Handle handle, Ptr< void > addr, l4_uint32_t size) |
Add a data block to a request that has already been set up. More... | |
int | send_request (Handle handle) |
Process request asynchronously. More... | |
int | process_request (Handle handle) |
Process request synchronously. More... | |
void | process_used_queue () |
Process and free all items in the used queue. More... | |
![]() | |
void | driver_connect (L4::Cap< L4virtio::Device > srvcap, bool manage_notify=true) |
Contacts the device and starts the initial handshake. More... | |
int | bind_notification_irq (unsigned index, L4::Cap< L4::Triggerable > irq) const |
Register a triggerable to receive notifications from the device. More... | |
bool | fail_state () const |
Return true if the device is in a fail state. | |
int | driver_acknowledge () |
Finalize handshake with the device. More... | |
int | register_ds (L4::Cap< L4Re::Dataspace > ds, l4_umword_t offset, l4_umword_t size, l4_uint64_t *devaddr) |
Share a dataspace with the device. More... | |
int | config_queue (int num, unsigned size, l4_uint64_t desc_addr, l4_uint64_t avail_addr, l4_uint64_t used_addr) |
Send the virtqueue configuration to the device. More... | |
int | max_queue_size (int num) const |
Maximum queue size allowed by the device. More... | |
int | send_and_wait (Virtqueue &queue, l4_uint16_t descno) |
Send a request to the device and wait for it to be processed. More... | |
int | wait (int index) const |
Wait for a notification from the device. More... | |
int | wait_for_next_used (Virtqueue &queue) const |
Wait for the next item to arrive in the used queue and return it. More... | |
void | send (Virtqueue &queue, l4_uint16_t descno) |
Send a request to the device. More... | |
Simple class for accessing a virtio block device synchronously.
Definition at line 346 of file virtio-block.
|
inline |
Add a data block to a request that has already been set up.
handle | Handle to request previously set up with start_request(). |
addr | Address of data block in device address space. |
size | Size of data block. |
L4_OK | Block was sucessfully added. |
-L4_EAGAIN | No descriptors available. Try again later. |
Definition at line 524 of file virtio-block.
References L4virtio::Virtqueue::Desc::addr, L4virtio::Driver::Virtqueue::alloc_descriptor(), L4virtio::Driver::Virtqueue::desc(), L4virtio::Virtqueue::Desc::flags, L4_EAGAIN, L4_EOK, L4virtio::Virtqueue::Desc::len, L4virtio::Virtqueue::Desc::Flags::next(), L4virtio::Virtqueue::Desc::next, L4virtio::Virtqueue::Desc::Flags::raw, l4virtio_block_header_t::type, and L4virtio::Virtqueue::Desc::Flags::write().
|
inline |
Process request synchronously.
req | Request to send to the device |
Sends a request to the driver that was previously set up with start_request() and add_block() and wait for it to be executed.
Definition at line 595 of file virtio-block.
References L4virtio::Virtqueue::Desc::addr, L4virtio::Driver::Virtqueue::alloc_descriptor(), L4virtio::Driver::Virtqueue::desc(), L4virtio::Virtqueue::Desc::flags, L4_EINVAL, L4_EIO, L4_ENOSYS, L4_EOK, L4VIRTIO_BLOCK_S_IOERR, L4VIRTIO_BLOCK_S_OK, L4VIRTIO_BLOCK_S_UNSUPP, L4virtio::Virtqueue::Desc::len, L4virtio::Virtqueue::Desc::Flags::next(), L4virtio::Virtqueue::Desc::next, L4virtio::Virtqueue::Desc::Flags::raw, L4virtio::Driver::Device::send_and_wait(), and L4virtio::Virtqueue::Desc::Flags::write().
|
inline |
Process and free all items in the used queue.
If the request has a callback registered it is called after the item has been removed from the queue.
Definition at line 646 of file virtio-block.
References L4Re::chksys(), L4virtio::Driver::Virtqueue::find_next_used(), L4_ENOSYS, and L4virtio::Virtqueue::num().
|
inline |
Process request asynchronously.
handle | Handle to request to send to the device |
L4_OK | Request was successfuly scheduled. |
-L4_EAGAIN | No descriptors available. Try again later. |
Sends a request to the driver that was previously set up with start_request() and add_block() and wait for it to be executed.
Definition at line 560 of file virtio-block.
References L4virtio::Virtqueue::Desc::addr, L4virtio::Driver::Virtqueue::alloc_descriptor(), L4virtio::Driver::Virtqueue::desc(), L4virtio::Virtqueue::Desc::flags, L4_EAGAIN, L4_EOK, L4virtio::Virtqueue::Desc::len, L4virtio::Virtqueue::Desc::Flags::next(), L4virtio::Virtqueue::Desc::next, L4virtio::Virtqueue::Desc::Flags::raw, L4virtio::Driver::Device::send(), and L4virtio::Virtqueue::Desc::Flags::write().
|
inline |
Setup a connection to a device and set up shared memory.
srvcap | IPC capability of the channel to the server. |
usermem | Size of additional memory to share with device. |
userdata | Pointer to the region of user-usable memory. |
user_devaddr | Adress of user-usable memory in device address space. |
fmask0 | Feature bits 0..31 that the driver supports. |
fmask1 | Feature bits 32..63 that the driver supports. |
This function starts a hand shake with the device and sets up the virtqueues for communication and the additional data structures for the block device. It will also allocate and share additional memory that the caller then can use freely, i.e. normally this memory would be used as a reception buffer. The caller may also decide to not make use of this convenience funcion and request 0 bytes in usermem. Then it has to allocate the block buffers for sending/receiving payload manually and share them using register_ds().
Definition at line 397 of file virtio-block.
References L4virtio::Virtqueue::avail_offset(), L4Re::chkcap(), L4Re::chksys(), L4virtio::Driver::Device::config_queue(), L4Re::Mem_alloc::Continuous, L4virtio::Driver::Device::driver_acknowledge(), L4virtio::Driver::Device::driver_connect(), L4Re::Env::env(), L4virtio::Driver::Virtqueue::init_queue(), L4_EINVAL, L4_ENODEV, L4_PAGESHIFT, l4_round_page(), l4_round_size(), l4util_bsr(), L4VIRTIO_ID_BLOCK, L4::Ipc::make_cap_rw(), L4virtio::Driver::Device::max_queue_size(), L4Re::Mem_alloc::Pinned, L4virtio::Driver::Device::register_ds(), L4Re::Rm::F::Search_addr, L4virtio::Virtqueue::total_size(), and L4virtio::Virtqueue::used_offset().
|
inline |
Start the setup of a new request.
sector | First sector to write to/read from. |
type | Request type. |
callback | Function to call, when the request is finished. May be 0 for synchronous requests. |
Definition at line 486 of file virtio-block.
References L4virtio::Virtqueue::Desc::addr, L4virtio::Driver::Virtqueue::alloc_descriptor(), L4virtio::Driver::Virtqueue::desc(), L4virtio::Virtqueue::Desc::flags, l4virtio_block_header_t::ioprio, L4virtio::Virtqueue::Desc::len, L4virtio::Virtqueue::Desc::Flags::raw, l4virtio_block_header_t::sector, and l4virtio_block_header_t::type.