L4Re - L4 Runtime Environment
|
Base class for virtio block devices. More...
Public Member Functions | |
Block_dev (l4_uint32_t vendor, unsigned queue_size, l4_uint64_t capacity, bool read_only) | |
Create a new virtio block device. More... | |
virtual bool | process_request (cxx::unique_ptr< Request > &&req)=0 |
Implements the actual processing of data in the device. More... | |
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. More... | |
int | reconfig_queue (unsigned idx) |
callback for client queue-config request | |
L4::Cap< void > | register_obj (L4::Registry_iface *registry, char const *service=0) |
Attach device to an object registry. More... | |
![]() | |
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. More... | |
void | init_mem_info (unsigned num) |
Initialize the memory region list to the given maximum. More... | |
void | device_error () |
Transition device into failed state. More... | |
bool | setup_queue (Virtqueue *q, unsigned qn, unsigned num_max) |
Enable/disable the specified queue. More... | |
bool | handle_mem_cmd_write () |
Check for a value in the cmd register and handle a write. More... | |
Protected Member Functions | |
void | set_size_max (l4_uint32_t sz) |
Sets the maximum size of any single segment reported to client. More... | |
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. More... | |
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. More... | |
Additional Inherited Members | |
![]() | |
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 22 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 377 of file virtio-block.
References L4Re::Util::cap_alloc, and L4Re::chkcap().
|
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 433 of file virtio-block.
|
pure virtual |
Implements the actual processing of data in the device.
req | The request to be processed. |
Synchronous and asynchronous processing of the data is supported. For asynchronous mode, the function should set up the worker and then return false. In synchronous mode, the function should return true, once processing is complete. If there is an error and processing is aborted, the status flag of needs to be set accordingly and the request immediately finished with finish_request() if the client is to be answered.
|
inline |
Attach device to an object registry.
registry | Object registry that will be responsible for dispatching requests. |
service | Name of an existing capability the device should use. |
This functions registers the general virtio interface as well as the interrupt handler which is used for receiving client notifications.
Definition at line 467 of file virtio-block.
References L4::cap_cast(), L4Re::chkcap(), L4Re::chksys(), L4virtio::Virtqueue::disable(), L4virtio::Svr::Virtqueue::next_avail(), L4virtio::Virtqueue::ready(), L4::Registry_iface::register_irq_obj(), and L4::Registry_iface::register_obj().
|
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 336 of file virtio-block.
|
inlineprotected |
Sets the maximum size of any single segment reported to client.
The limit is also applied to any incomming 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 294 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 352 of file virtio-block.