L4Re Operating System Framework
Interface and Usage Documentation
Loading...
Searching...
No Matches
L4virtio::Svr::Block_dev_base< Ds_data > Class Template Referenceabstract

Base class for virtio block devices. More...

#include <virtio-block>

+ Inheritance diagram for L4virtio::Svr::Block_dev_base< Ds_data >:
+ Collaboration diagram for L4virtio::Svr::Block_dev_base< Ds_data >:

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::Irqdevice_notify_irq () const
 callback to gather the device notification IRQ (old-style)
 
virtual L4::Cap< L4::Irqdevice_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.
 

Detailed Description

template<typename Ds_data>
class L4virtio::Svr::Block_dev_base< Ds_data >

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.

Constructor & Destructor Documentation

◆ Block_dev_base()

template<typename Ds_data >
L4virtio::Svr::Block_dev_base< Ds_data >::Block_dev_base ( l4_uint32_t  vendor,
unsigned  queue_size,
l4_uint64_t  capacity,
bool  read_only 
)
inline

Create a new virtio block device.

Parameters
vendorVendor ID
queue_sizeNumber of entries to provide in avail and used queue.
capacitySize of the device in 512-byte sectors.
read_onlyTrue, 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().

+ Here is the call graph for this function:

Member Function Documentation

◆ finalize_request()

template<typename Ds_data >
void L4virtio::Svr::Block_dev_base< Ds_data >::finalize_request ( cxx::unique_ptr< Request >  req,
unsigned  sz,
l4_uint8_t  status = L4VIRTIO_BLOCK_S_OK 
)
inline

Releases resources related to a request and notifies the client.

Parameters
reqPointer to request that has finished.
szNumber of bytes consumed.
statusStatus 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().

+ Here is the call graph for this function:

◆ get_writeback()

template<typename Ds_data >
l4_uint8_t L4virtio::Svr::Block_dev_base< Ds_data >::get_writeback ( )
inlineprotected

Get the writeback field from the configuration space.

Returns
Value of the writeback field.

Definition at line 386 of file virtio-block.

◆ set_blk_size()

template<typename Ds_data >
void L4virtio::Svr::Block_dev_base< Ds_data >::set_blk_size ( l4_uint32_t  sz)
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.

◆ set_config_wce()

template<typename Ds_data >
void L4virtio::Svr::Block_dev_base< Ds_data >::set_config_wce ( l4_uint8_t  writeback)
inlineprotected

Sets cache mode and enables the writeback toggle.

Parameters
writebackMode of the cache (0 for writethrough, 1 for writeback).

Definition at line 373 of file virtio-block.

◆ set_discard()

template<typename Ds_data >
void L4virtio::Svr::Block_dev_base< Ds_data >::set_discard ( l4_uint32_t  max_discard_sectors,
l4_uint32_t  max_discard_seg,
l4_uint32_t  discard_sector_alignment 
)
inlineprotected

Sets constraints for and enables the discard command.

Parameters
max_discard_sectorsMaximum discard sectors size.
max_discard_segMaximum discard segment number.
discard_sector_alignmentCan be used by the driver when splitting a request based on alignment.

Definition at line 400 of file virtio-block.

◆ set_size_max()

template<typename Ds_data >
void L4virtio::Svr::Block_dev_base< Ds_data >::set_size_max ( l4_uint32_t  sz)
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.

◆ set_topology()

template<typename Ds_data >
void L4virtio::Svr::Block_dev_base< Ds_data >::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 
)
inlineprotected

Sets the I/O alignment information reported back to the client.

Parameters
physical_block_expNumber of logical blocks per physical block(log2)
alignment_offsetOffset of the first aligned logical block
min_io_sizeSuggested minimum I/O size in blocks
opt_io_sizeOptimal I/O size in blocks

Definition at line 346 of file virtio-block.

◆ set_write_zeroes()

template<typename Ds_data >
void L4virtio::Svr::Block_dev_base< Ds_data >::set_write_zeroes ( l4_uint32_t  max_write_zeroes_sectors,
l4_uint32_t  max_write_zeroes_seg,
l4_uint8_t  write_zeroes_may_unmap 
)
inlineprotected

Sets constraints for and enables the write zeroes command.

Parameters
max_write_zeroes_sectorsMaximum write zeroes sectors size.
max_write_zeroes_segmaximum write zeroes segment number.
write_zeroes_may_unmapSet if a write zeroes request can result in deallocating one or more sectors.

Definition at line 420 of file virtio-block.


The documentation for this class was generated from the following file: