L4Re Operating System Framework – Interface and Usage Documentation
Loading...
Searching...
No Matches
L4virtio::Svr::Dev_config Class Reference

Abstraction for L4-Virtio device config memory. More...

#include <l4virtio>

Inherited by L4virtio::Svr::Dev_config_t< l4virtio_block_config_t >, and L4virtio::Svr::Dev_config_t< PRIV_CONFIG >.

+ Collaboration diagram for L4virtio::Svr::Dev_config:

Public Member Functions

 Dev_config (l4_uint32_t vendor, l4_uint32_t device, unsigned cfg_size, l4_uint32_t num_queues=0)
 Create a L4-Virtio config data space.
 
 Dev_config (Cfg_cap const &cfg, l4_addr_t cfg_offset, l4_uint32_t vendor, l4_uint32_t device, unsigned cfg_size, l4_uint32_t num_queues=0)
 Setup an L4-Virtio config space in an existing data space.
 
l4_uint32_t guest_features (unsigned idx) const
 Return a specific set of guest features.
 
l4_uint32_t negotiated_features (unsigned idx) const
 Compute a specific set of negotiated features.
 
Status status () const
 Get current device status (trusted).
 
l4_uint32_t get_cmd () const
 Get the value from the cmd register.
 
void reset_cmd ()
 Reset the cmd register after execution of a command.
 
void set_status (Status status)
 Set device status register.
 
void set_device_needs_reset ()
 Set DEVICE_NEEDS_RESET bit in device status register.
 
bool change_queue_config (l4_uint32_t num_queues)
 Setup new queue configuration.
 
l4virtio_config_queue_t volatile const * qconfig (unsigned index) const
 Get queue read-only config data for queue with the given index.
 
void reset_hdr (bool inc_generation=false) const
 Reset the config header to the initial contents.
 
bool reset_queue (unsigned index, unsigned num_max, bool inc_generation=false) const
 Reset queue config for the given queue.
 
l4virtio_config_hdr_t const volatile * hdr () const
 Get a read-only pointer to the config header.
 
L4::Cap< L4Re::Dataspaceds () const
 Get data-space capability for the shared config data space.
 
l4_addr_t ds_offset () const
 Return the offset into the config dataspace where the device configuration starts.
 

Detailed Description

Abstraction for L4-Virtio device config memory.

Virtio defines a device configuration mechanism, L4-Virtio implements this mechanism based on shared memory a set_status() and a config_queue() call. This class provides an abstraction for L4-Virtio host implementations to establish such a shared memory data space and providing the necessary contents and access functions.

Definition at line 52 of file l4virtio.

Constructor & Destructor Documentation

◆ Dev_config() [1/2]

L4virtio::Svr::Dev_config::Dev_config ( l4_uint32_t  vendor,
l4_uint32_t  device,
unsigned  cfg_size,
l4_uint32_t  num_queues = 0 
)
inline

Create a L4-Virtio config data space.

Parameters
vendorThe vendor ID to store in config header.
deviceThe device ID to store in config header.
cfg_sizeThe size of the device-specific config data in bytes.
num_queuesThe number of queues provided by the device.

This constructor allocates a data space used for L4-virtio config attaches the data space to the local address space and writes the initial contents to the config header.

Definition at line 112 of file l4virtio.

References L4Re::chkcap(), L4Re::chksys(), L4Re::Env::env(), and L4_PAGESIZE.

+ Here is the call graph for this function:

◆ Dev_config() [2/2]

L4virtio::Svr::Dev_config::Dev_config ( Cfg_cap const &  cfg,
l4_addr_t  cfg_offset,
l4_uint32_t  vendor,
l4_uint32_t  device,
unsigned  cfg_size,
l4_uint32_t  num_queues = 0 
)
inline

Setup an L4-Virtio config space in an existing data space.

Parameters
cfgDataspace that should hold the L4-Virtio configuration.
cfg_offsetOffset into the dataspace where the configuration starts.
vendorThe vendor ID to store in config header.
deviceThe device ID to store in config header.
cfg_sizeThe size of the device-specific config data in bytes.
num_queuesThe number of queues provided by the device.

Definition at line 146 of file l4virtio.

References L4_PAGESIZE.

Member Function Documentation

◆ change_queue_config()

bool L4virtio::Svr::Dev_config::change_queue_config ( l4_uint32_t  num_queues)
inline

Setup new queue configuration.

Parameters
num_queuesThe number of queues provided by the device.

Definition at line 269 of file l4virtio.

References L4_PAGESIZE, and reset_hdr().

+ Here is the call graph for this function:

◆ ds()

L4::Cap< L4Re::Dataspace > L4virtio::Svr::Dev_config::ds ( ) const
inline

Get data-space capability for the shared config data space.

Returns
Capability for the shared config data space.

Definition at line 358 of file l4virtio.

◆ get_cmd()

l4_uint32_t L4virtio::Svr::Dev_config::get_cmd ( ) const
inline

Get the value from the cmd register.

Note, the most significant eight bits are the command (0 is nothing to do). The upper eight bit are reset to zero after the command was handled.

Definition at line 224 of file l4virtio.

References l4virtio_config_hdr_t::cmd, and hdr().

Referenced by L4virtio::Svr::Device_t< DATA >::handle_mem_cmd_write().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ guest_features()

l4_uint32_t L4virtio::Svr::Dev_config::guest_features ( unsigned  idx) const
inline

Return a specific set of guest features.

Parameters
idxIndex into the guest features array.
Return values
Theselected set of guest features.

This function returns a specific 32bit set of features enabled by the guest/driver. idx is the index in the guest features array, resp. the 32 bit set to return.

Definition at line 192 of file l4virtio.

◆ hdr()

l4virtio_config_hdr_t const volatile * L4virtio::Svr::Dev_config::hdr ( ) const
inline

Get a read-only pointer to the config header.

Returns
Read-only pointer to the shared config header.

Definition at line 351 of file l4virtio.

References L4Re::Rm::Unique_region< T >::get().

Referenced by get_cmd(), reset_cmd(), set_device_needs_reset(), and set_status().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ negotiated_features()

l4_uint32_t L4virtio::Svr::Dev_config::negotiated_features ( unsigned  idx) const
inline

Compute a specific set of negotiated features.

Parameters
idxIndex into the guest/host features array.
Return values
Theselected set of negotiated features.

This function returns a specific 32-bit set of features negotiated by the guest/driver and host/device. idx is the index in the guest/host features array, resp. the 32-bit set to return.

Definition at line 206 of file l4virtio.

◆ qconfig()

l4virtio_config_queue_t volatile const * L4virtio::Svr::Dev_config::qconfig ( unsigned  index) const
inline

Get queue read-only config data for queue with the given index.

Parameters
indexThe index of the queue.
Returns
Read-only pointer to the config of the queue with the given index, or NULL if index is out of range.

Definition at line 286 of file l4virtio.

References L4Re::Rm::Unique_region< T >::get(), and L4_UNLIKELY.

Referenced by reset_queue(), and L4virtio::Svr::Device_t< DATA >::setup_queue().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ reset_cmd()

void L4virtio::Svr::Dev_config::reset_cmd ( )
inline

Reset the cmd register after execution of a command.

This function resets the cmd register in order for the client to detect that the command was executed by the device.

Definition at line 235 of file l4virtio.

References l4virtio_config_hdr_t::cmd, and hdr().

Referenced by L4virtio::Svr::Device_t< DATA >::handle_mem_cmd_write().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ reset_queue()

bool L4virtio::Svr::Dev_config::reset_queue ( unsigned  index,
unsigned  num_max,
bool  inc_generation = false 
) const
inline

Reset queue config for the given queue.

Parameters
indexThe index of the queue to reset.
num_maxThe maximum number of descriptors supported by this queue.
inc_generationThe config generation will be incremented when this is true.
Returns
true on success, or false when index is out of range.

Definition at line 328 of file l4virtio.

References L4_UNLIKELY, l4virtio_config_queue_t::num, l4virtio_config_queue_t::num_max, qconfig(), and l4virtio_config_queue_t::ready.

Referenced by L4virtio::Svr::Device_t< DATA >::reset_queue_config().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ set_device_needs_reset()

void L4virtio::Svr::Dev_config::set_device_needs_reset ( )
inline

Set DEVICE_NEEDS_RESET bit in device status register.

This function sets the internal status register and also the status register in the shared memory to DEVICE_NEEDS_RESET.

Definition at line 259 of file l4virtio.

References L4virtio::Svr::Dev_status::device_needs_reset(), hdr(), L4virtio::Svr::Dev_status::raw, and l4virtio_config_hdr_t::status.

Referenced by L4virtio::Svr::Device_t< DATA >::device_error().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ set_status()

void L4virtio::Svr::Dev_config::set_status ( Status  status)
inline

Set device status register.

Parameters
statusThe new value for the device status register.

This function sets the internal status register and also the status register in the shared memory to status.

Definition at line 247 of file l4virtio.

References hdr(), L4virtio::Svr::Dev_status::raw, status(), and l4virtio_config_hdr_t::status.

+ Here is the call graph for this function:

◆ status()

Status L4virtio::Svr::Dev_config::status ( ) const
inline

Get current device status (trusted).

Returns
Current device status register (trusted).

The status returned by this function is value stored internally and cannot be written by the guest (i.e., the value can be taken as trusted.)

Definition at line 216 of file l4virtio.

Referenced by L4virtio::Svr::Device_t< DATA >::device_error(), and set_status().

+ Here is the caller graph for this function:

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