L4Re Operating System Framework
Interface and Usage Documentation
|
Simple class for accessing a virtio block device synchronously. More...
#include <virtio-block>
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::Cap< L4Re::Dataspace > qds=L4::Cap< L4Re::Dataspace >(), l4_uint32_t fmask0=-1U, l4_uint32_t fmask1=-1U) |
Establish a connection to the device and set up shared memory. | |
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. | |
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. | |
int | send_request (Handle handle) |
Process request asynchronously. | |
int | process_request (Handle handle) |
Process request synchronously. | |
void | process_used_queue () |
Process and free all items in the used queue. | |
Public Member Functions inherited from L4virtio::Driver::Device | |
void | driver_connect (L4::Cap< L4virtio::Device > srvcap, bool manage_notify=true) |
Contacts the device and starts the initial handshake. | |
int | bind_notification_irq (unsigned index, L4::Cap< L4::Triggerable > irq) const |
Register a triggerable to receive notifications from the device. | |
bool | fail_state () const |
Return true if the device is in a fail state. | |
bool | feature_negotiated (unsigned int feat) const |
Check if a particular feature bit was negotiated with the device. | |
int | driver_acknowledge () |
Finalize handshake with the device. | |
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. | |
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. | |
int | max_queue_size (int num) const |
Maximum queue size allowed by the device. | |
int | send_and_wait (Virtqueue &queue, l4_uint16_t descno) |
Send a request to the device and wait for it to be processed. | |
int | wait (int index) const |
Wait for a notification from the device. | |
int | wait_for_next_used (Virtqueue &queue, l4_uint32_t *len=nullptr) const |
Wait for the next item to arrive in the used queue and return it. | |
void | send (Virtqueue &queue, l4_uint16_t descno) |
Send a request to the device. | |
Simple class for accessing a virtio block device synchronously.
Definition at line 36 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 successfully added. |
-L4_EAGAIN | No descriptors available. Try again later. |
Definition at line 229 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.
handle | Handle to request to process. |
L4_EOK | Request processed successfully. |
-L4_EAGAIN | No descriptors available. Try again later. |
-L4_EIO | IO error during request processing. |
-L4_ENOSYS | Unsupported request. |
<0 | Another unspecified error occurred. |
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 306 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_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 357 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 successfully 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 265 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 |
Establish a connection to the device and set up shared memory.
srvcap | IPC capability of the channel to the server. | |
usermem | Size of additional memory to share with device. | |
[out] | userdata | Pointer to the region of user-usable memory. |
[out] | user_devaddr | Address of user-usable memory in device address space. |
qds | External queue dataspace. If this capability is invalid, the function will attempt to allocate a dataspace on its own. Note that the external queue dataspace must be large enough. | |
fmask0 | Feature bits 0..31 that the driver supports. | |
fmask1 | Feature bits 32..63 that the driver supports. |
This function starts a handshake 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 function 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 92 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(), L4Re::Rm::Unique_region< T >::get(), L4virtio::Driver::Virtqueue::init_queue(), L4_EINVAL, L4_ENODEV, L4_PAGESHIFT, l4_round_page(), l4_round_size(), 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::RW, 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 191 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.