L4Re Operating System Framework
Interface and Usage Documentation
|
Base class for virtio block devices. More...
#include <virtio-block>
Public Member Functions | |
Block_dev_base (l4_uint32_t vendor, unsigned queue_size, l4_uint64_t capacity, bool read_only) | |
Create a new virtio block device. | |
virtual void | reset_device ()=0 |
Reset the actual hardware device. | |
virtual bool | queue_stopped ()=0 |
Return true, if the queues should not be processed further. | |
void | finalize_request (cxx::unique_ptr< Request > req, unsigned sz, l4_uint8_t status=L4VIRTIO_BLOCK_S_OK) |
Releases resources related to a request and notifies the client. | |
int | reconfig_queue (unsigned idx) override |
callback for client queue-config request | |
void | reset () override |
reset callback, called for doing a device reset | |
Public Member Functions inherited from L4virtio::Svr::Device_t< Ds_data > | |
virtual bool | check_features () |
callback for checking the subset of accepted features | |
virtual void | cfg_changed (unsigned) |
callback for client device configuration changes | |
virtual L4::Cap< L4::Irq > | device_notify_irq () const |
callback to gather the device notification IRQ (old-style) | |
virtual L4::Cap< L4::Irq > | device_notify_irq (unsigned idx) |
Callback to gather the device notification IRQ (multi IRQ). | |
virtual void | register_driver_irq (unsigned idx) |
Callback for registering an notification IRQ (multi IRQ). | |
virtual unsigned | num_events_supported () const |
Return the highest notification index supported. | |
Device_t (Dev_config *dev_config) | |
Make a device for the given config. | |
Mem_list const * | mem_info () const |
Get the memory region list used for this device. | |
void | reset_queue_config (unsigned idx, unsigned num_max, bool inc_generation=false) |
Trigger reset for the configuration space for queue idx. | |
void | init_mem_info (unsigned num) |
Initialize the memory region list to the given maximum. | |
void | device_error () |
Transition device into DEVICE_NEEDS_RESET state. | |
bool | setup_queue (Virtqueue *q, unsigned qn, unsigned num_max) |
Enable/disable the specified queue. | |
bool | handle_mem_cmd_write () |
Check for a value in the cmd register and handle a write. | |
void | enable_trusted_ds_validation () |
Enable trusted dataspace validation. | |
void | add_trusted_dataspaces (std::shared_ptr< Ds_vector const > ds) |
Provide a list of trusted dataspaces that can be used for validation. | |
Protected Member Functions | |
void | set_size_max (l4_uint32_t sz) |
Sets the maximum size of any single segment reported to client. | |
void | set_seg_max (l4_uint32_t sz) |
Sets the maximum number of segments in a request that is reported to client. | |
void | set_geometry (l4_uint16_t cylinders, l4_uint8_t heads, l4_uint8_t sectors) |
Set disk geometry that is reported to the client. | |
void | set_blk_size (l4_uint32_t sz) |
Sets block disk size to be reported to the client. | |
void | set_topology (l4_uint8_t physical_block_exp, l4_uint8_t alignment_offset, l4_uint32_t min_io_size, l4_uint32_t opt_io_size) |
Sets the I/O alignment information reported back to the client. | |
void | set_flush () |
Enables the flush command. | |
void | set_config_wce (l4_uint8_t writeback) |
Sets cache mode and enables the writeback toggle. | |
l4_uint8_t | get_writeback () |
Get the writeback field from the configuration space. | |
void | set_discard (l4_uint32_t max_discard_sectors, l4_uint32_t max_discard_seg, l4_uint32_t discard_sector_alignment) |
Sets constraints for and enables the discard command. | |
void | set_write_zeroes (l4_uint32_t max_write_zeroes_sectors, l4_uint32_t max_write_zeroes_seg, l4_uint8_t write_zeroes_may_unmap) |
Sets constraints for and enables the write zeroes command. | |
cxx::unique_ptr< Request > | get_request () |
Return one request if available. | |
Additional Inherited Members | |
Protected Attributes inherited from L4virtio::Svr::Device_t< Ds_data > | |
Mem_list | _mem_info |
Memory region list. | |
Base class for virtio block devices.
Use this class as a base to implement your own specific block device.
Definition at line 257 of file virtio-block.
|
inline |
Create a new virtio block device.
vendor | Vendor ID |
queue_size | Number of entries to provide in avail and used queue. |
capacity | Size of the device in 512-byte sectors. |
read_only | True, if the device should not be writable. |
Definition at line 442 of file virtio-block.
References L4VIRTIO_FEATURE_VERSION_1, and L4virtio::Svr::Device_t< Ds_data >::reset_queue_config().
|
inline |
Releases resources related to a request and notifies the client.
req | Pointer to request that has finished. |
sz | Number of bytes consumed. |
status | Status of request (see L4virtio_block_status). |
This function must be called when an asynchronous request finishes, either successfully or with an error. The status byte in the request must have been set prior to calling it.
Definition at line 481 of file virtio-block.
References L4virtio::Svr::Device_t< Ds_data >::device_error(), L4VIRTIO_IRQ_STATUS_VRING, L4virtio::Virtqueue::no_notify_guest(), and L4virtio::Virtqueue::ready().
|
inlineprotected |
Get the writeback field from the configuration space.
Definition at line 386 of file virtio-block.
|
inlineprotected |
Sets block disk size to be reported to the client.
Setting this does not change the logical sector size used for addressing the device.
Definition at line 330 of file virtio-block.
|
inlineprotected |
Sets cache mode and enables the writeback toggle.
writeback | Mode of the cache (0 for writethrough, 1 for writeback). |
Definition at line 373 of file virtio-block.
|
inlineprotected |
Sets constraints for and enables the discard command.
max_discard_sectors | Maximum discard sectors size. |
max_discard_seg | Maximum discard segment number. |
discard_sector_alignment | Can be used by the driver when splitting a request based on alignment. |
Definition at line 400 of file virtio-block.
|
inlineprotected |
Sets the maximum size of any single segment reported to client.
The limit is also applied to any incoming requests. Requests with larger segments result in an IO error being reported to the client. That means that process_request() can safely make the assumption that all segments in the received request are smaller.
Definition at line 288 of file virtio-block.
|
inlineprotected |
Sets the I/O alignment information reported back to the client.
physical_block_exp | Number of logical blocks per physical block(log2) |
alignment_offset | Offset of the first aligned logical block |
min_io_size | Suggested minimum I/O size in blocks |
opt_io_size | Optimal I/O size in blocks |
Definition at line 346 of file virtio-block.
|
inlineprotected |
Sets constraints for and enables the write zeroes command.
max_write_zeroes_sectors | Maximum write zeroes sectors size. |
max_write_zeroes_seg | maximum write zeroes segment number. |
write_zeroes_may_unmap | Set if a write zeroes request can result in deallocating one or more sectors. |
Definition at line 420 of file virtio-block.